Close
0%
0%

Monotron

VGA from a Cortex-M4, written in pure Rust

Similar projects worth following
I wanted to make a 1980s style home computer using an inexpensive Cortex-M4 devkit. Can you generate VGA from this board? In colour? How about handle a PS/2 keyboard? Load applications? Let the user write BASIC programs? Generate audio?

More importantly, can you do all this in pure Embedded Rust, with no C or C++ in sight?

Can you display VGA and play audio on a Cortex-M4 in pure Rust? The short answer is yes, yes you can! Minus the hand-unrolled assembler loop for fixing the phase error in the RGB output. But we don't talk about that in polite company.

The rev 0.7 Monotron PCB is now here! I got five from JLCPCB.com to test out the idea. So far, I've shown that:

  • The Atari Joystick interface works, but two Joysticks would be more fun
  • The PS/2 Keyboard via the Atmega works, but the pinout was mirrored so you have to put the connector under the PCB :/
  • The RTC works
  • VGA Output works
  • The MIDI Out seems to work when looped to MIDI In, as does the MIDI Though.
  • The MIDI In seems to receive data when connected to my electronic drum kit
  • The Audio output seems to work quite nicely
  • The SD card works, but the power supply can't handle hot-insertion of the SD card and it makes the TM4C reboot. More capacitors / some current limiting probably required.

I can load games and programs from the SD card into the 24 KiB of free Application RAM. You can interact with these games via the PS/2 Keyboard and Joystick. I can play simple games (like Snake) and play three channels of 8-bit wavetable audio simultaneously. I've even got a 6502 Emulator running a copy of 6502 Enhanced BASIC, if you want to go old school!

The TODO list includes:

  • Revising the PCB layout
    • Lose the 5V barrel jack - there's potential for problems if the USB is connected at the same time
    • Get the parallel port working
    • Add some mounting holes!
    • Add a second Joystick port
    • Add support for Sega Megadrive pads (which multiplex more than 8 signals on the 9 pin connector)
    • Find a way of leaving the Atmega reset as a reset pin, while still driving all 18 pins on the parallel port
    • Add an ICSP header for the Atmega
  • Write a programming language!
    • It's call Monotronian (for now)
    • It allows line editing like BASIC
    • It parses / tokenises each line as entered and only stores tokens to save RAM
    • It can render tokens back to text when you LIST
    • It has fewer magic keywords (like BASIC's INPUT) and instead has more functions (like C or Python)
    • It has IF / ENDIF, WHILE / ENDWHILE, FN / ENDFN
    • Functions take named parameters
    • Scalar values are Integer, Float, String, and Char
    • Collections include Array and HashMap
    • APIs for Sound, Joystick, I/O, Text and Graphics
    • Can LOAD and SAVE like BASIC, but to SD card
    • PC version for testing / debugging
    • All written in pure Rust
  • More games and demos!
    • Can we squeeze a MOD tracker into 24 KiB?
    • Use custom font as background tiles
    • Can we do a sprite as well as the text?
    • Write a MIDI synthesiser and/or sequencer you can plug a MIDI keyboard into
    • Write a MIDI player so you can play tunes on a Roland MT32 or similar
    • Write a text editor that can edit files much larger than RAM, using a swap-file on the SD card

pcb.pdf

Rev 0.7 CC-BY-SA 4.0

Adobe Portable Document Format - 1.12 MB - 04/08/2019 at 19:32

Preview
Download

schematic.pdf

Rev 0.7 CC-BY-SA 4.0

Adobe Portable Document Format - 217.71 kB - 04/08/2019 at 19:32

Preview
Download

  • 1 × Tiva-C EK-TM4C123GXL Launchpad
  • 1 × AtMega 328
  • 2 × 33n Capacitor
  • 7 × 100n Capacitor
  • 3 × 5-pin 180 degree DIN

View all 31 components

  • RustConf talk videos are out

    Jonathan 'theJPster' Pallant09/24/2019 at 15:02 0 comments

    So, I took the Monotron over to Portland in the USA for RustConf 2019. I'd added a couple of extra features since the ACCU talk, but I only had 30 minutes this time (instead of the 90 minutes i had before), so I had to cut a few things out. The main addition was that I brought my MIDI Keyboard and played a little tune with the Sawtooth wave in 3-note polyphony. I'd also added a roller-buffer to the video system, which allows me to map any visible scan-line to any scan line from any row in the text buffer. This lets you do neat tricks like flip the screen top to bottom, without using much CPU at all (the renderer just gets one extra array look-up per line).

    Here's the video: 

  • Lots of Talks in April!

    Jonathan 'theJPster' Pallant04/08/2019 at 19:36 0 comments

    I'll be at ACCU 2019 on Friday 12 April. If you see me, stop me an say hi! I'll also be at the Centre for Computing History in Cambridge, UK on 18 April. Tickets are available at http://www.computinghistory.org.uk/det/51020/Rust-Tutorial-with-Jonathan-Pallant-Thursday-18th-April-2019/. Finally, I'm hosting Oxidize - the Embedded Rust Conference in Berlin on 27 April.

View all 2 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates