For those interested in how to use the MIDI-PAC as a midi out device, below I've got some sources wich makes it possible to detect the MIDI-PAC, switch it's mode and how to send MIDI data to it's internal buffer.
I always wanted to make some nice manual about it but i just can;t find the time doing this. Probably the most can figuring out on how to do this just fine with the info below. The example is including a wait on MIDI-PAC, but you can skip this if you want, the MIDI-PAC can handle multiple transactions at once.
Have fun.
(Data send has to comply to the MIDI protocol, the midi-pac won't intervene with what you are transmitting)
Tjeerd.
#define DIRECT_MIDI 1
#define NORMAL_MODE 0
void SelectMode(Mode)
char Mode;
{
MP_AddressOut(0xED); /*Select required mode*/
MP_DataOutWait(Mode);
}
void SendMidi()
{
#asm
SM_01:
IN A,(07Ch) ;Get new handshake
AND 1
JR NZ,SM_01 ;Wait for midi to transmit if buffer is full
LD E,0EEH ;Write MIDI-PAC address
PUSH DE
CALL .MP_AddressOut
POP DE
LD A,(.Data) ;Write Data
LD E,A
PUSH DE
call .MP_DataOutWait
POP DE
#endasm
}
void MP_AddressOut(Address)
char Address;
{
#asm
LD HL,2 ;Get stack pointer into HL and skip ret address
ADD HL,SP
LD A,(HL) ;Get Address
OUT (07Ch),A
PUSH BC ;4 Wait minimum 24 clock cycles to overcome turbo-r speed
LD B,8 ;2
ATOADRWAIT:
DJNZ ATOADRWAIT ;2
POP BC ;3 9+(8(loops)*2)=25 cycles
#endasm
}
/*Write data to special MIDI-PAC register and wait until action has finished*/
void MP_DataOutWait(Data)
char Data;
{
#asm
LD HL,2 ;Get stack pointer into HL and skip ret address
ADD HL,SP
LD C,(HL) ;Get data
IN A,(07Ch) ;Store current handshake
AND 2
LD B,A
LD A,C ;Write new data to MIDI-PAC
OUT (07Dh),A
MP_006:
IN A,(07Ch) ;Get new handshake
AND 2
CP B ;Compare new handshake with old one
JR Z,MP_006 ;Still the same so continue waiting for MDI-PAC
#endasm
}
char MP_Present()
{
#asm
LD HL,0 ;Default return 0
IN A,(07Ch) ;Store last value of INT0 bit
AND 004h
XOR 004h
LD C,A
LD A,0F5h ;Write to WORP3 address 0xF5, which won't repply with handshake
OUT (07Ch),A
IN A,(07Ch)
AND 004h
CP C
RET NZ
IN A,(07Ch) ;Store last value of INT1 bit
AND 008h
XOR 008h
LD C,A
LD A,0FFh ;Write to WORP3 data register 0xFF
OUT (07Dh),A
IN A,(07Ch)
AND 008h
CP C
RET NZ
LD L,1 ;Return 1 (successful)
#endasm
}
Aangemeld of registreer om reacties te plaatsen
