Close

#RetroChallenge @RetroChallenge Update 1

A project log for A Retro-Authentic Microtronic Emulator

Compute like its 1981 - hex on a 6digit 7segment LED bubble display! (One of the) RetroChallenge 2021/10 "Winners"

michael-wesselMichael Wessel 10/07/2021 at 15:080 Comments

The Retro-Authentic Microtronic participates in the 2021/10 RetroChallenge!

https://www.retrochallenge.org/p/entrants-list-202110.html

#RetroChallenge @RetroChallenge

My first task is to update the firmware to make it play MIDI. Why? Why not! I recently got into using the S2 / X2 MIDI modules from @serdef. The Microtronic has just enough resources (memory) to make that work.

So, the first challenge was - I didn't anticipate this when I designed the board. I hence needed to find an (existing) pin on the headers that could be used for Serial Output. Unfortunately, the hardware UART TX (Pin 1) was already wired up as an input and over the CD4050 for input protection, so Serial Data didn't get through. I could have soldered a wire to the chip pin directly, but that seemed kind of ugly. So I decided to use Arduino's  SoftwareSerial library instead, which just uses standard digital output GPIO on any pin: 

#include <SoftwareSerial.h>

The only output pin that is not going through the TC4467 driver on my PCB is Arduino's A5, which outputs the 1 Hz Clock signal by default, so I used that, and it worked fine. SoftwareSerial doesn't have the greatest reputation for MIDI, but for MIDI OUT it is sufficient (MIDI IN would be problematic). 

Now, as soon as I included that library and instantiated the software serial object, I ran out of SRAM! The bubble LED display is also used to display a number of message strings, and I hadn't used the "F macro" around the strings yet. By putting my strings in PGMSPACE via the  "F  macro" I regained 300 bytes of SRAM (!), and everything was good again. Phew!

So, with the X2 MIDI Module hooked up to the VCC / GND power pins, and its TTL MIDI input to the 1 HZ CLOCK Pin (A5), I know had to update the firmware. I needed

  1. an Opcode to change the function of the A5 1 HZ Clock pin
  2. a way of sending MIDI Data from the program. 

The Microtronic has a few "vacuous" op-codes which I had previously equipped with "extra side effects" for extensions (i.e., sound, speech). No program is using them, because they don't do anything semantically reasonable. There is no way of adding "new" op-codes, as all op-codes are taken! Specifically, I have changed the firmware so that the following op-codes now have extra side-effects: 

  1. MOV 0,0 (op-code 000) to enable A5 as CLOCK 1 HZ digital output  (the default function of this pin on the board)
  2. MOV 1,1 (op-code 011) to change A5 to analog input for CPU Speed Throttle Control - I had previously hooked up a potentiometer  to the analog input to "dial in" the CPU emulation speed
  3. and then, finally MOV 2,2 (op-code 022) to enable MIDI output on A5.

So, a Microtronic program can change the A5 pin function to MIDI output simply via 022.

Now, to actually send MIDI data, we need more op-codes. For now, I am only supporting the GM drum channel 10. My first mile stone is hence to turn it into a MIDI drum computer.

MIDI NOTE ON messages sent to channel 10 will hence play drum sounds. The different drum note numbers go from 27 to 87 on the X2. I hence opted to use Microtronic registers 0 and 1 to to contain the BCD-encoded pitch of the drum (not that registers are 4 bit!), and then use MOV 3,3 (op-code 0,33) to send a MIDI NOTE ON message, consisting of three bytes: MIDI NOTE ON for channel 10 = 0x99, then the <drum number> = reg[0]+10*reg[1] pitch byte, and 127 as the third byte for volume. Hence,

  1. MOV 3,3 (op-code 033) plays the drum with pitch reg[0]+10*reg[1] on the X2 by sending the above assembled MIDI NOTE ONE message over A5 (provided A5 function is set to MIDI).

The drums start to play here:

Discussions