Routines |
Prev: B471 | Up: Map | Next: B4E7 |
Used by the routine at 80E5.
|
||||
B482 | LD HL,($B4E7) | Point HL towards the next note in the tune. | ||
B485 | LD A,(HL) | Is the next byte zero? | ||
B486 | OR A | |||
B487 | JR NZ,$B494 | Jump forward if it isn't. | ||
B489 | LD A,$01 | Set tune back to index 1. | ||
B48B | LD ($B55F),A | |||
B48E | LD A,$FF | Set no keys pressed and return. | ||
B490 | LD ($B4E9),A | |||
B493 | RET | |||
There is more of the tune to play, so do it. First, work out if the type of sound wave needs changing.
|
||||
B494 | INC HL | Point HL at the next note. | ||
B495 | CP $FE | Is it a control character FE? | ||
B497 | JR NZ,$B4A2 | Jump forward if it isn't. | ||
B499 | XOR A | Switch to sawtooth wave. | ||
B49A | LD ($B4EA),A | |||
B49D | LD ($B4E7),HL | Set the next address of the tune to play. (B4E7) | ||
B4A0 | JR $B482 | Jump forward to play the note. | ||
B4A2 | CP $FF | Is it a control character FF? | ||
B4A4 | JR NZ,$B4AA | Jump forward if not. | ||
B4A6 | LD A,$01 | Switch to square wave and jump back to set this. | ||
B4A8 | JR $B49A | |||
Now play the note.
|
||||
B4AA | PUSH AF | Store AF. | ||
B4AB | LD A,(HL) | Get the current note. | ||
B4AC | INC HL | Point HL at the next note to play. | ||
B4AD | LD ($B4E7),HL | |||
B4B0 | OR A | Is it zero? | ||
B4B1 | JR Z,$B4DB | If so, jump forward. | ||
B4B3 | LD L,A | Put the note in HL. | ||
B4B4 | LD H,$00 | |||
B4B6 | ADD HL,HL | Double it to get a word offset. | ||
B4B7 | LD DE,$B537 | Add the base address for the note frequencies. (B537) | ||
B4BA | ADD HL,DE | |||
B4BB | LD C,(HL) | Get the frequency and put it in BC. | ||
B4BC | LD B,$00 | |||
B4BE | INC HL | Get the length and put it in DE. | ||
B4BF | LD E,(HL) | |||
B4C0 | LD D,B | |||
B4C1 | POP AF | Restore AF. | ||
B4C2 | LD HL,$0000 | Multiply DE with the note value to get the length. | ||
B4C5 | ADD HL,DE | |||
B4C6 | DEC A | |||
B4C7 | JR NZ,$B4C5 | |||
B4C9 | EX DE,HL | Swap DE and HL. | ||
B4CA | CALL $B505 | Play the note. | ||
B4CD | LD A,($B4E9) | Was a key pressed? | ||
B4D0 | CP $FF | |||
B4D2 | RET NZ | Return if it was. | ||
B4D3 | LD BC,$0320 | Pause and get a keypress. | ||
B4D6 | CALL $B4EB | |||
B4D9 | JR $B482 | Jump back and play more of the tune. | ||
B4DB | LD BC,$19C8 | |||
B4DE | POP AF | Restore AF. | ||
B4DF | CALL $B4EB | Pause and get a keypress. | ||
B4E2 | DEC A | Was a key pressed? Loop while there was. | ||
B4E3 | JR NZ,$B4DF | |||
B4E5 | JR $B4D3 | Otherwise jump back to play more of the tune. |
Prev: B471 | Up: Map | Next: B4E7 |