Prev: 44815 Up: Map Next: 45290
44880: PlayMusic
Plays a background music phrase through the ZX Spectrum beeper. Reads the music-active flag at 33737. If zero, falls through to the standard frame- timing wait at 36448 and returns. 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.
Input
Used by the routines at 36457 and 42821.
44880 LD A,(33705) A = sound-pending flag (queued by e.g.
44883 AND A CrewAction3_RemoveGrille); anything queued?
44884 JP Z,36448 no: standard frame-timing 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
This entry point is used by the routine at 37490.
44924 LD (IX+3),0
44928 LD HL,65535
44931 LD (31248),HL
44934 CALL 31820
44937 RET
This entry point is used by the routine at 37490.
44938 LD A,255
44940 LD (HL),A
44941 LD A,(31252)
44944 CP 1
44946 JR NZ,44964
44948 PUSH HL
44949 LD A,(33700)
44952 LD HL,31241
44955 CP (HL)
44956 POP HL
44957 JR NZ,44964
44959 LD A,255
44961 JP 37944
44964 LD A,255
44966 CP B
44967 LD A,(31249)
44970 JP NZ,37980
44973 RET
This entry point is used by the routine at 37490.
44974 CALL 31634
44977 LD A,255
44979 LD (29641),A
44982 CALL 32816
44985 RET
This entry point is used by the routine at 37490.
44986 LD HL,65535
44989 LD (31248),HL
44992 LD A,(33700)
44995 RET
This entry point is used by the routine at 31634.
44996 LD A,(IX+3)
44999 CP 4
45001 JR NZ,45010
45003 LD A,(IX+0)
45006 OR A
45007 JP NZ,32132
45010 CALL 45278
45013 LD DE,29643
45016 JP 32125
This entry point is used by the routine at 36457.
45019 PUSH IX
45021 PUSH DE
45022 LD A,(31241)
45025 ADD A,A
45026 ADD A,A
45027 ADD A,A
45028 LD E,A
45029 LD D,0
45031 LD IX,29566
45035 ADD IX,DE
45037 LD A,(IX+3)
45040 CP 4
45042 JR NZ,45050
45044 LD A,(IX+0)
45047 OR A
45048 JR NZ,45062
45050 POP DE
45051 POP IX
45053 CALL 45278
45056 CALL 39687
45059 JP 36833
45062 POP DE
45063 POP IX
45065 CALL 39687
45068 LD HL,32896
45071 LD (31263),HL
45074 LD A,4
45076 LD (31243),A
45079 RET
This entry point is used by the routine at 36457.
45080 RET NZ
45081 PUSH IX
45083 PUSH DE
45084 LD A,(31241)
45087 ADD A,A
45088 ADD A,A
45089 ADD A,A
45090 LD E,A
45091 LD D,0
45093 LD IX,29566
45097 ADD IX,DE
45099 LD A,(IX+3)
45102 CP 4
45104 JR Z,45111
45106 POP DE
45107 POP IX
45109 JR 45119
45111 LD A,(IX+0)
45114 OR A
45115 POP DE
45116 POP IX
45118 RET NZ
45119 CALL 45278
45122 JP 36844
This entry point is used by the routine at 31634.
45125 LD A,(IX+3)
45128 CP 4
45130 JR NZ,45139
45132 LD A,(IX+0)
45135 OR A
45136 JP NZ,32141
45139 CALL 45278
45142 LD DE,29643
45145 JP 32138
This entry point is used by the routine at 40826.
45148 LD A,(31252)
45151 CP 1
45153 JR NZ,45203
45155 LD HL,(33701)
45158 INC HL
45159 LD A,(31242)
45162 CP (HL)
45163 JR NZ,45203
45165 LD HL,29567
45168 CP (HL)
45169 JR Z,45203
45171 AND 63 refresh the menu's Special slot from
45173 LD E,A RoomGrilleState[viewed room]:
45174 LD HL,30076
45177 LD D,0
45179 ADD HL,DE
45180 LD A,(HL)
45181 CP 255
45183 JR Z,45195
45185 LD A,255 grille removed: clear the Special slot
45187 LD (29643),A
45190 CALL 32816
45193 JR 45203
45195 LD A,49 grille in place: offer "RmveGrille"
45197 LD (29643),A
45200 CALL 32816
45203 LD HL,33704
45206 RET
This entry point is used by the routine at 44313.
45207 LD HL,12320
45210 LD (42064),HL
45213 LD L,48
45215 RET
This entry point is used by the routine at 44313.
45216 LD (HL),48
45218 DEC HL
45219 LD (HL),49
45221 RET
This entry point is used by the routine at 41264.
45222 LD HL,65535
45225 LD (33743),HL
45228 CALL 33600
45231 RET
This entry point is used by the routine at 35973.
45232 PUSH IX
45234 CALL Z,36014
45237 POP IX
45239 RET
This entry point is used by the routine at 37490.
45240 LD A,(31242) refresh the menu's Special slot from
45243 AND 63 RoomGrilleState[viewed room]:
45245 LD E,A
45246 LD HL,30076
45249 LD D,0
45251 ADD HL,DE
45252 LD A,(HL)
45253 CP 255
45255 JR Z,45263
45257 LD A,255 grille removed: clear the Special slot
45259 LD (29643),A
45262 RET
45263 LD A,49 grille in place: offer "RmveGrille"
45265 LD (29643),A
45268 RET
This entry point is used by the routines at 37490 and 40826.
45269 CALL 45278 alien in the room: the Special slot
45272 LD A,52 becomes " ATTACK " (52)
45274 LD (29643),A
45277 RET
45278 LD A,(33685) if the live selection was "RmveGrille"
45281 CP 49 (49), swap it for " ATTACK " too
45283 RET NZ
45284 LD A,52
45286 LD (33685),A
45289 RET
Prev: 44815 Up: Map Next: 45290