| Alien (BUGFIX 1.7) | Routines |
| Prev: 44815 | Up: Map | Next: 44924 |
|
Plays a background music phrase through the ZX Spectrum beeper. Reads the music-active flag at 33737. If zero, falls through to the fixed ~36 ms delay at BusyWait and returns — the idle main loop therefore pays this wait TWICE per iteration (here and in FrameTiming). Otherwise plays a descending sequence of tones: reads 32 consecutive ROM bytes from $0200 and for each byte toggles bit 4 of port $FE (beeper output), with a delay of C counts between toggles. After each 32-byte block, decrements C by 8 to raise the pitch, producing a descending arpeggio effect. Runs until C underflows (B=255 exhausted), then returns.
|
||||
| 44880 | LD A,(33705) | A = sound-pending flag (queued by e.g. | ||
| 44883 | AND A | CrewAction3_RemoveGrille); anything queued? | ||
| 44884 | JP Z,36448 | no: fixed ~36ms busy-wait and return | ||
| 44887 | LD HL,512 | HL = $0200 (ROM data used as tone source) | ||
| 44890 | LD BC,2176 | B=8 (8 pitch steps), C=$88 (initial delay = 136) | ||
| 44893 | PUSH BC | save pitch counter | ||
| 44894 | LD B,32 | 32 bytes (ROM data) per pitch step | ||
| 44896 | LD A,(HL) | read ROM byte | ||
| 44897 | AND 16 | isolate bit 4 (beeper toggle bit) | ||
| 44899 | OUT (254),A | output to port $FE (beeper + border) | ||
| 44901 | INC HL | advance ROM pointer | ||
| 44902 | LD A,C | A = current delay count | ||
| 44903 | DEC A | count down delay | ||
| 44904 | JR NZ,44903 | busy-wait | ||
| 44906 | DJNZ 44896 | next ROM byte in this pitch step | ||
| 44908 | LD B,255 | inter-note gap: 255 NOP-equivalent iterations | ||
| 44910 | DJNZ 44910 | wait | ||
| 44912 | POP BC | restore pitch counter | ||
| 44913 | LD A,C | A = current delay value | ||
| 44914 | SUB 8 | reduce delay → raise pitch | ||
| 44916 | LD C,A | store updated delay | ||
| 44917 | DJNZ 44893 | |||
| 44919 | XOR A | |||
| 44920 | LD (33705),A | |||
| 44923 | RET | |||
| Prev: 44815 | Up: Map | Next: 44924 |