Prev: BD79 Up: Map Next: BDD2
BD7B: Play Audio: Process Music Data
Used by the routines at PlayAudio_WaitKey and PlayAudio.
Input
A Music data byte
DE Music data terminated by FF
PlayAudio_Process BD7B AND %00111111 Keep only bits 0-5.
BD7D JR Z,PlayAudio_Process_5 If we're left with zero, jump to PlayAudio_Process_5.
BD7F LD L,A Creates an offset using H=00 and L=A.
BD80 LD H,$00
BD82 ADD HL,HL HL=MusicData + (offset * 04).
BD83 ADD HL,HL
BD84 LD BC,$BDD2
BD87 ADD HL,BC
BD88 LD B,(HL) BC=the address held at HL.
BD89 INC HL
BD8A LD C,(HL)
BD8B INC HL
BD8C LD A,(HL) A=.
BD8D INC HL
BD8E LD H,(HL)
BD8F LD L,A
BD90 LD A,(DE) A=.
BD91 RLCA
BD92 RLCA
BD93 AND %00000011 Keep only bits 0-1.
BD95 INC A
BD96 PUSH DE Stash DE on the stack.
BD97 LD E,L
BD98 LD D,H
PlayAudio_Process_0 BD99 DEC A
BD9A JR Z,PlayAudio_Process_1
BD9C ADD HL,DE
BD9D JR PlayAudio_Process_0
PlayAudio_Process_1 BD9F POP DE
PlayAudio_Process_2 BDA0 PUSH BC
BDA1 XOR A Set the border to black.
BDA2 OUT ($FE),A
PlayAudio_Process_3 BDA4 DJNZ PlayAudio_Process_3
BDA6 DEC C
BDA7 JR NZ,PlayAudio_Process_3
BDA9 POP BC
BDAA PUSH BC
BDAB LD A,%00010000 Flip speaker on (set bit 4).
BDAD OUT ($FE),A
PlayAudio_Process_4 BDAF DJNZ PlayAudio_Process_4 Decrease counter by one and loop back to PlayAudio_Process_4 until counter is zero.
BDB1 DEC C
BDB2 JR NZ,PlayAudio_Process_4
BDB4 POP BC
BDB5 DEC HL
BDB6 LD A,H
BDB7 OR L
BDB8 JR NZ,PlayAudio_Process_2
BDBA INC DE
BDBB RET Return.
PlayAudio_Process_5 BDBC LD A,(DE)
BDBD INC DE
BDBE RLCA
BDBF RLCA
BDC0 AND %00000011 Keep only bits 0-1.
BDC2 INC A
BDC3 LD L,A
BDC4 LD BC,$430B BC=430B.
PlayAudio_Process_6 BDC7 PUSH BC
PlayAudio_Process_7 BDC8 DEC BC
BDC9 LD A,B
BDCA OR C
BDCB JR NZ,PlayAudio_Process_7
BDCD POP BC
BDCE DEC L
BDCF JR NZ,PlayAudio_Process_6
BDD1 RET Return.
Prev: BD79 Up: Map Next: BDD2