Prev: 48505 Up: Map Next: 48594
48507: Play Audio: Process Music Data
Used by the routines at PlayAudio_WaitKey and PlayAudio.
Input
A Music data byte
DE Music data terminated by 255
PlayAudio_Process 48507 AND %00111111 Keep only bits 0-5.
48509 JR Z,PlayAudio_Process_5 If we're left with zero, jump to PlayAudio_Process_5.
48511 LD L,A Creates an offset using H=0 and L=A.
48512 LD H,0
48514 ADD HL,HL HL=MusicData + (offset * 4).
48515 ADD HL,HL
48516 LD BC,48594
48519 ADD HL,BC
48520 LD B,(HL) BC=the address held at HL.
48521 INC HL
48522 LD C,(HL)
48523 INC HL
48524 LD A,(HL) A=.
48525 INC HL
48526 LD H,(HL)
48527 LD L,A
48528 LD A,(DE) A=.
48529 RLCA
48530 RLCA
48531 AND %00000011 Keep only bits 0-1.
48533 INC A
48534 PUSH DE Stash DE on the stack.
48535 LD E,L
48536 LD D,H
PlayAudio_Process_0 48537 DEC A
48538 JR Z,PlayAudio_Process_1
48540 ADD HL,DE
48541 JR PlayAudio_Process_0
PlayAudio_Process_1 48543 POP DE
PlayAudio_Process_2 48544 PUSH BC
48545 XOR A Set the border to black.
48546 OUT (254),A
PlayAudio_Process_3 48548 DJNZ PlayAudio_Process_3
48550 DEC C
48551 JR NZ,PlayAudio_Process_3
48553 POP BC
48554 PUSH BC
48555 LD A,%00010000 Flip speaker on (set bit 4).
48557 OUT (254),A
PlayAudio_Process_4 48559 DJNZ PlayAudio_Process_4 Decrease counter by one and loop back to PlayAudio_Process_4 until counter is zero.
48561 DEC C
48562 JR NZ,PlayAudio_Process_4
48564 POP BC
48565 DEC HL
48566 LD A,H
48567 OR L
48568 JR NZ,PlayAudio_Process_2
48570 INC DE
48571 RET Return.
PlayAudio_Process_5 48572 LD A,(DE)
48573 INC DE
48574 RLCA
48575 RLCA
48576 AND %00000011 Keep only bits 0-1.
48578 INC A
48579 LD L,A
48580 LD BC,17163 BC=17163.
PlayAudio_Process_6 48583 PUSH BC
PlayAudio_Process_7 48584 DEC BC
48585 LD A,B
48586 OR C
48587 JR NZ,PlayAudio_Process_7
48589 POP BC
48590 DEC L
48591 JR NZ,PlayAudio_Process_6
48593 RET Return.
Prev: 48505 Up: Map Next: 48594