I added a X68000 port to the MT32-Pi command line tool MT32-Pi-Control.
The port relies on MCDRV. You can find it here https://github.com/hkr/mt32-pi-control.
I haven't touched this in _ages_ but it probably works and doesn't require any drivers. I have some code for rs-midi but it is much less likely to work and I can't test it right now.
midi.c
// MIDI I/O slot card stuff
#define MIDI_A_BASE_ADDR 0xEAFA00
#define MIDI_B_BASE_ADDR 0xEAFA10
volatile char* MIDI_R00= 0;
volatile char* MIDI_R01= 0;
volatile char* MIDI_R02= 0;
volatile char* MIDI_R03= 0;
volatile char* MIDI_R04= 0;
volatile char* MIDI_R05= 0;
volatile char* MIDI_R06= 0;
volatile char* MIDI_R07= 0;
// 'which' picks which IO address to use
void midi_init(int which)
{
if(which == 0)
{
MIDI_R00 = (char*)(MIDI_A_BASE_ADDR+0x1);
MIDI_R01 = (char*)(MIDI_A_BASE_ADDR+0x3);
MIDI_R02 = (char*)(MIDI_A_BASE_ADDR+0x5);
MIDI_R03 = (char*)(MIDI_A_BASE_ADDR+0x7);
MIDI_R04 = (char*)(MIDI_A_BASE_ADDR+0x9);
MIDI_R05 = (char*)(MIDI_A_BASE_ADDR+0xB);
MIDI_R06 = (char*)(MIDI_A_BASE_ADDR+0xD);
MIDI_R07 = (char*)(MIDI_A_BASE_ADDR+0xF);
}
else
{
MIDI_R00 = (char*)(MIDI_B_BASE_ADDR+0x1);
MIDI_R01 = (char*)(MIDI_B_BASE_ADDR+0x3);
MIDI_R02 = (char*)(MIDI_B_BASE_ADDR+0x5);
MIDI_R03 = (char*)(MIDI_B_BASE_ADDR+0x7);
MIDI_R04 = (char*)(MIDI_B_BASE_ADDR+0x9);
MIDI_R05 = (char*)(MIDI_B_BASE_ADDR+0xB);
MIDI_R06 = (char*)(MIDI_B_BASE_ADDR+0xD);
MIDI_R07 = (char*)(MIDI_B_BASE_ADDR+0xF);
}
// initial reset
*MIDI_R01 = 0x80;
// group 5 (R5n)
*MIDI_R01 = 5;
// Tx reset
*MIDI_R05 = 0x81;
// set Tx clock (group 4)
*MIDI_R01 = 4;
*MIDI_R04 = 8;
// finally, set group 5
*MIDI_R01 = 5;
}
void midi_quit()
{
// hw reset
//*MIDI_R01 = 0x80;
}
void midi_write(char c)
{
int wait = 0;
// wait for Tx FIFO ready
while(!(*MIDI_R04 & 0x40))
wait++;
*MIDI_R06 = c;
}
midi.h
#ifndef __MIDI_H__
#define __MIDI_H__
void midi_init(int which);
void midi_quit();
void midi_write(char c);
#endif
There's an ASM version also if you prefer.
.include doscall.mac
.xdef midi_install
.xdef midi_write
.xdef midi_remove
MIDI_A_BASE_ADDR .equ 0xEAFA00
MIDI_B_BASE_ADDR .equ 0xEAFA10
MIDI_R00 .equ 0x01
MIDI_R01 .equ 0x03
MIDI_R02 .equ 0x05
MIDI_R03 .equ 0x06
MIDI_R04 .equ 0x09
MIDI_R05 .equ 0x0B
MIDI_R06 .equ 0x0D
MIDI_R07 .equ 0x0F
midi_install:
pea (string)
DOS _PRINT
addq.l #4, sp
ori.w #0x0700, sr
; TODO: check the base i/o flag and set either A or B addr
move.l #MIDI_A_BASE_ADDR, midi_addr
move.l midi_addr, a0
; hw reset
move.b #0x80, MIDI_R00(a0)
; group 5
move.b #0x05, MIDI_R01(a0)
; Tx reset
move.b #0x81, MIDI_R05(a0)
; set Tx clock
; clkm/32
; clkm = 1000000hz
; 1000000/32 = 31250 baud
move.b #0x04, MIDI_R01(a0)
move.b #0x08, MIDI_R04(a0)
; back to group 5 since thats where we want to be
move.b #0x05, MIDI_R01(a0)
andi.w #0xf8ff, sr
rts
; input: d0 = MIDI byte to send
midi_write:
move.l midi_addr, a3
; wait for Tx FIFO ready
; ...
@@:
btst.b #6, MIDI_R04(a3)
beq @B
; write
move.b d0, MIDI_R06(a3)
; move.b #0, MIDI_R04(a3)
rts
midi_remove:
ori.w #0x0700, sr
move.l midi_addr, a0
; hw reset
move.b #0x80, MIDI_R00(a0)
andi.w #0xf8ff, sr
rts
.bss
.even
midi_addr:
ds.l 1
.data
string:
dc.b "MIDI installing...",0
.even
Thanks, I'll try it!
Works fine, thanks again.
I was looking at your changes and wonder if this should be 'i' not 'len'? Just some friendly code review :)
midi_write(buf[i]);
for (i = 0; i < len; ++i)
midi_write(buf[len]);
Ha, thanks. Now I'm wondering what I even tested there.