Routines
 Prev: 37125 Up: Map Next: 37403
37173: Move and draw the Kong Beast in the current cavern
Used by the routine at 34574.
Input
Output
37173 LD HL,23558 Flip the left-hand switch at (0,6) if Willy is touching it
37176 CALL 37403
37179 LD A,(32987) Pick up the Kong Beast's status from 32987
37184 RET Z Return if so
37185 LD A,(29958) Pick up the sixth pixel row of the left-hand switch from the screen buffer at 28672
37188 CP 16 Has the switch been flipped?
37190 JP Z,37369 Jump if not
The left-hand switch has been flipped. Deal with opening up the wall if that is still in progress.
37193 LD A,(24433) Pick up the attribute byte of the tile at (11,17) in the buffer at 24064
37196 OR A Has the wall there been removed yet?
37197 JR Z,37238 Jump if so
37199 LD HL,32625 Point HL at the bottom row of pixels of the wall tile at (11,17) in the screen buffer at 28672
37202 LD A,(HL) Pick up a pixel row
37203 OR A Is it blank yet?
37204 JR NZ,37228 Jump if not
37206 DEC H Point HL at the next pixel row up
37207 LD A,H Have we checked all 8 pixel rows yet?
37208 CP 119
37210 JR NZ,37202 If not, jump back to check the next one
37212 LD A,(32800) Pick up the attribute byte of the background tile for the current cavern from 32800
37215 LD (24433),A Change the attributes at (11,17) and (12,17) in the buffer at 24064 to match the background tile (the wall there is now gone)
37218 LD (24465),A
37221 LD A,114 Update the seventh byte of the guardian definition at 32965 so that the guardian moves through the opening in the wall
37223 LD (32971),A
37226 JR 37238
37228 LD (HL),0 Clear a pixel row of the wall tile at (11,17) in the screen buffer at 28672
37230 LD L,145 Point HL at the opposite pixel row of the wall tile one cell down at (12,17)
37232 LD A,H
37233 XOR 7
37235 LD H,A
37236 LD (HL),0 Clear that pixel row as well
Now check the right-hand switch.
37238 LD HL,23570 Flip the right-hand switch at (0,18) if Willy is touching it (and it hasn't already been flipped)
37241 CALL 37403
37244 JR NZ,37277 Jump if the switch was not flipped
37246 XOR A Initialise the Kong Beast's pixel y-coordinate at 32988 to 0
37247 LD (32988),A
37250 INC A Update the Kong Beast's status at 32987 to 1: he is falling
37251 LD (32987),A
37254 LD A,(32800) Pick up the attribute byte of the background tile for the current cavern from 32800
37257 LD (24143),A Change the attributes of the floor beneath the Kong Beast in the buffer at 24064 to match that of the background tile
37260 LD (24144),A
37263 LD HL,28751 Point HL at (2,15) in the screen buffer at 28672
37266 LD B,8 Clear the cells at (2,15) and (2,16), removing the floor beneath the Kong Beast
37268 LD (HL),0
37270 INC L
37271 LD (HL),0
37273 DEC L
37274 INC H
37275 DJNZ 37268
37277 LD A,(32987) Pick up the Kong Beast's status from 32987
37280 OR A Is the Kong Beast still on the ledge?
37281 JR Z,37369 Jump if so
The Kong Beast is falling.
37283 LD A,(32988) Pick up the Kong Beast's pixel y-coordinate from 32988
37286 CP 100 Has he fallen into the portal yet?
37288 JR Z,37363 Jump if so
37290 ADD A,4 Add 4 to the Kong Beast's pixel y-coordinate at 32988 (moving him downwards)
37292 LD (32988),A
37295 LD C,A Copy the pixel y-coordinate to C; this value determines the pitch of the sound effect
37296 LD D,16 This value determines the duration of the sound effect
37298 LD A,(32883) Pick up the border colour for the current cavern from 32883
37301 OUT (254),A Make a falling sound effect
37303 XOR 24
37305 LD B,C
37306 DJNZ 37306
37308 DEC D
37309 JR NZ,37301
37311 LD A,C Copy the Kong Beast's pixel y-coordinate back into A
37312 RLCA Point DE at the entry in the screen buffer address lookup table at 33536 that corresponds to the Kong Beast's pixel y-coordinate
37313 LD E,A
37314 LD D,131
37316 LD A,(DE) Point HL at the address of the Kong Beast's location in the screen buffer at 24576
37317 OR 15
37319 LD L,A
37320 INC DE
37321 LD A,(DE)
37322 LD H,A
37323 LD D,129 Use bit 5 of the value of the game clock at 32957 (which is toggled once every eight passes through the main loop) to point DE at the graphic data for the appropriate Kong Beast sprite
37325 LD A,(32957)
37328 AND 32
37330 OR 64
37332 LD E,A
37333 LD C,0 Draw the Kong Beast to the screen buffer at 24576
37335 CALL 36852
37338 LD HL,33836 Add 100 to the score
37341 CALL 37118
37344 LD A,(32988) Pick up the Kong Beast's pixel y-coordinate from 32988
37347 AND 120 Point HL at the address of the Kong Beast's location in the attribute buffer at 23552
37349 LD L,A
37350 LD H,23
37354 LD A,L
37355 OR 15
37357 LD L,A
37358 LD A,6 The Kong Beast is drawn with yellow INK
37360 JP 36447 Set the attribute bytes for the Kong Beast
The Kong Beast has fallen into the portal.
37363 LD A,2 Set the Kong Beast's status at 32987 to 2: he is dead
37365 LD (32987),A
37368 RET
The Kong Beast is still on the ledge.
37369 LD A,(32957) Pick up the value of the game clock at 32957
37372 AND 32 Use bit 5 of this value (which is toggled once every eight passes through the main loop) to point DE at the graphic data for the appropriate Kong Beast sprite
37374 LD E,A
37375 LD D,129
37377 LD HL,24591 Draw the Kong Beast at (0,15) in the screen buffer at 24576
37380 LD C,1
37382 CALL 36852
37385 JP NZ,36102 Kill Willy if he collided with the Kong Beast
37388 LD A,68 A=68 (INK 4: PAPER 0: BRIGHT 1)
37390 LD (23599),A Set the attribute bytes for the Kong Beast in the buffer at 23552
37393 LD (23600),A
37396 LD (23567),A
37399 LD (23568),A
37402 RET
 Prev: 37125 Up: Map Next: 37403