As I mentioned elsewhere, I'm working on a "common" low level MIDI handler, that could be used with any program to interface with MIDI without having to consider different interfaces (except maybe selecting one at the beginning), manually checking status registers etc. but just concentrate on the obvious: Different midi commands & their arguments.
Here's a simple "silent" test program (using Sequential Circuits) that basically just prints received arguments for specific midi commands (NoteOn, NoteOff, TimeCode, SongSelect, Start, Stop) and SHOULD handle running state properly (something I was mistakenly completely ignoring before)
http://jupp3.binaryriot.org/miditest1.zipSo, as for the API itself...
Currently I basically have 3 arrays for different types of messages:
; NoteOff NoteOn AfterTouch ContolChange ProgramChange ChannelPressure PitchBend
.define CommandHandler HandleNoteOff, HandleNoteOn, $0000, $0000, $0000, $0000, $0000
; SysEx MidiTimeCodeQF SongPosPtr SongSel Und Und TuneReq EndOfSysEx
.define SystemCommonHandler $0000, HandleMidiTimeCode, $0000, HandleSongSelect, $0000, $0000, $0000, $0000
; TimingClock Und Start Cont Stop Und ActiveSens Reset
.define RealTimeHandler $0000, $0000, HandleStart, $0000, HandleStop, $0000, $0000, $0000
Then, you can replace any array element with your own function, and then that function will be called, when there's a message of that type with all the args read (which will be always stored in same zero page array). If you're not interested in some message type, just add $0000 instead, and it will just be ignored (internally args will still be read etc. but no callback will be called)
In addition, program can have raster interrupt that will be called, whenever there's an interrupt that wasn't caused by the MIDI cart instead.
So what's currently missing?
Support for anything else than Sequential Circuits midi. Not an issue for Kerberos users, of course (should be relatively easy to add, just been busy with other things)
Midi channel handling: Should that be handled globally within API itself, or should the channel information be passed to callbacks to let them decide, whether to handle / ignore the command?
SysEx: This would definitely need some special handling, but there's currently none. Sure, there are callbacks in the list, simply because I just can't "leave out one midi command type" (as that would change the index of all commands that come after). I don't think this is too high priority though, but could be used as workaround for saving, as long as the cartridge floppy write support isn't implemented.
Midi out: Again, not that important in my opinion. Perhaps I could just have simple low level "send single byte" API for this...
Currently the whole thing is 368 bytes with all debug disabled.
Comments? Ideas?