Prev: 40149 Up: Map Next: 40362
40319: FrameTiming
Controls frame timing and plays a queued sound effect. Reads the sound- request flag at 33731. If zero, calls the standard one-frame wait at 36448 (approx 1/50s on a 48K Spectrum) 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.
Input
Used by the routines at 36457, 38379 and 42821.
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: standard one-frame timing wait (~1/50s)
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: 40149 Up: Map Next: 40362