| Alien (BUGFIX 1.7) | Routines |
| Prev: 40281 | Up: Map | Next: 40362 |
|
Controls frame timing and plays a queued sound effect. Reads the sound- request flag at 33731. If zero, calls the fixed ~36 ms delay at BusyWait — nearly two 50 Hz frames, so the main loop is not interrupt-synced (see the GameEntry header) — and returns. If non-zero, plays a beeper tone by reading 1-KB ROM bytes starting at $0200 and toggling bit 4 of port $FE for each byte; the outer loop runs 255 × 4 iterations with a short delay (D=64 counts) between each toggle. After playback, clears the sound-request flag.
|
||||
| 40319 | LD A,(33699) | A = sound-request flag (33731) | ||
| 40322 | AND A | any sound queued? | ||
| 40323 | JR NZ,40329 | yes: play beeper effect | ||
| 40325 | CALL 36448 | no: fixed ~36ms busy-wait | ||
| 40328 | RET | |||
| 40329 | LD HL,512 | HL = $0200 (ROM tone data source) | ||
| 40332 | LD D,64 | D = inter-toggle delay count | ||
| 40334 | LD B,255 | outer loop: 255 iterations | ||
| 40336 | PUSH BC | |||
| 40337 | LD B,4 | 4 sub-iterations per outer step | ||
| 40339 | PUSH BC | |||
| 40340 | PUSH DE | |||
| 40341 | LD A,(HL) | read ROM byte | ||
| 40342 | INC HL | advance data pointer | ||
| 40343 | AND 16 | isolate bit 4 (EAR/MIC output) | ||
| 40345 | OUT (254),A | toggle beeper | ||
| 40347 | DEC D | delay loop | ||
| 40348 | JR NZ,40347 | |||
| 40350 | POP DE | |||
| 40351 | POP BC | |||
| 40352 | DJNZ 40339 | repeat 4 sub-iterations | ||
| 40354 | POP BC | |||
| 40355 | DJNZ 40336 | repeat 255 outer iterations | ||
| 40357 | XOR A | |||
| 40358 | LD (33699),A | clear sound-request flag | ||
| 40361 | RET | |||
| Prev: 40281 | Up: Map | Next: 40362 |