Prev: 30198 Up: Map Next: 30396
30211: Check whether Sam has found something and update the icon panel
Used by the routines at 31204 and 61568. Scans the object location table at 32028 to check whether Sam has found the hook, the budgie, a key, some money, or a location that requires a message to be displayed, and then updates the icon panel appropriately.
30211 LD HL,58881 Point HL at byte 1 of Sam's buffer
30214 LD C,(HL) C=Sam's x-coordinate
30215 INC L L=2
30216 LD B,(HL) B=Sam's y-coordinate
30217 LD HL,32028 Point HL at the object location table at 32028
30220 LD A,(HL) Collect the first byte of an entry
30221 INC A Have we reached the end of the table?
30222 JR Z,30268 Jump if so
30224 INC HL Move HL to the second byte of the entry
30225 AND 2 Is this entry active?
30227 JR NZ,30239 Proceed to the next entry if not
30229 LD A,(HL) A=x-coordinate of the object
30230 CP C Is Sam's x-coordinate the same?
30231 JR NZ,30239 Jump if not
30233 INC HL Move HL to the third byte of the entry
30234 LD A,(HL) A=y-coordinate of the object
30235 CP B Set the zero flag if Sam's y-coordinate is the same
30236 DEC HL Move HL back to the second byte of the entry
30237 JR Z,30244 Jump if Sam's coordinates match the object's
30239 INC HL Point HL at the first byte of the next entry
30240 INC HL
30241 INC HL
30242 JR 30220 Jump back to check the next entry
Sam's coordinates match those of the object. Is it the hook or the budgie?
30244 DEC HL Move HL back to the first byte of the entry
30245 BIT 6,(HL) Is this entry for an object that can be picked up (i.e. the hook or the budgie)?
30247 JR Z,30271 Jump if not
30249 LD A,(58880) A=Sam's animatory state
30252 AND 127 Discard bit 7 (the direction bit)
30254 CP 6 6: Is Sam bending his knees?
30256 JR NZ,30270 Jump if not
30258 INC (HL) Increment the first byte of the entry (thus deactivating it)
30259 INC HL Point HL at the fourth byte of the entry
30260 INC HL
30261 INC HL
30262 LD A,(HL) Pick up the fourth byte of the entry
30263 LD HL,32745 Set the appropriate bit at 32745 to give Sam the object
30266 OR (HL)
30267 LD (HL),A
30268 JR 30339 Jump forward to update the icon panel
30270 DEC (HL) Decrement the first byte of the entry
30271 INC (HL) Increment the first byte of the entry (thus deactivating it if it's not the hook or the budgie)
30272 LD A,(HL) A=first byte of the entry
30273 INC HL Point HL at the fourth byte of the entry
30274 INC HL
30275 INC HL
30276 PUSH HL Save the object table entry pointer
30277 PUSH BC Save Sam's coordinates
30278 BIT 6,A Is this entry for an object that can be picked up (i.e. the hook or the budgie)?
30280 JR Z,30292 Jump if not
30282 LD A,(HL) A=fourth byte of the entry
30283 LD HL,32680 Store the object ID at 32680 for now
30286 LD (HL),A
30287 POP BC Restore Sam's coordinates to BC
30288 POP HL Restore the object table entry pointer to HL
30289 INC HL Point HL at the first byte of the next entry
30290 JR 30220 Jump back to check the next entry
It's not the hook or the budgie. Does a message need to be displayed?
30292 BIT 5,A Is this entry for a message that needs to be displayed?
30294 JR Z,30302 Jump if not
30296 LD A,(HL) A=message number
30297 CALL 28357 Queue the message
30300 JR 30287 Jump back to check the next entry
It's not the hook, the budgie or a message. Is it a key?
30302 BIT 4,A Is this entry for a key?
30304 JR Z,30321 Jump if not
30306 LD A,(HL) A=key identifier (8, 16, 32 or 64)
30307 LD HL,32746 Set the appropriate bit at 32746, thus giving Sam the key
30310 OR (HL)
30311 LD (HL),A
30312 LD A,100 $100 to add to Sam's cash supply
30314 JR 30322
30316 INC D This block of code is never executed
30317 LD D,2
30319 JR 30332
If it's not the hook, the budgie, a message or a key, it must be cash.
30321 LD A,(HL) A=number of bucks
30322 CALL 28306 Add this to Sam's total
30325 LD HL,5126 Prepare the cash bonus sound effect parameters
30328 LD C,144
30330 LD D,1
30332 LD A,2
30334 CALL 30053 Make a sound effect
30337 JR 30287 Jump back to check the next entry
Now we set the attribute bytes for the budgie and hook in the icon panel.
30339 LD HL,32680 32680 holds the ID of the object Sam is standing next to (if any)
30342 LD A,(HL) A=object ID
30343 LD (HL),0 Reset 32680 to 0
30345 LD L,233 HL=32745 (object inventory)
30347 LD H,(HL) H=object inventory flags
30348 LD L,A L=ID of the object Sam is standing next to (if any)
30349 LD E,176 176 is the LSB of 23216 (the attribute file address for the top-left tile of the budgie icon)
30351 LD BC,1538 B=6, C=2 (2 objects: budgie and hook)
30354 RL L Move an object ID bit (if any) into bit 0 of H, and an object inventory flag into the carry flag
30356 RL H
30358 LD A,48 48=PAPER 6: INK 0
30360 JR C,30368 Jump if Sam already has this object
30362 ADD A,B A=56 (INK 6: PAPER 6)
30363 BIT 0,H Is Sam standing next to this object?
30365 JR Z,30368 Jump if not
30367 LD A,B A=6 (INK 6: PAPER 0)
30368 CALL 28709 Set the attribute bytes for the object in the icon panel
30371 LD E,178 178 is the LSB of 23218 (the attribute file address for the top-left tile of the hook icon)
30373 DEC C Have we dealt with both objects yet?
30374 JR NZ,30354 Jump back to deal with the second object if not
Now we display the keys Sam has found.
30376 LD A,(32746) Pick up the key inventory flags from 32746
30379 ADD A,A Move bits 3-6 into bits 4-7 (thus discarding bit 7, which corresponds to the key to no. 19)
30380 LD BC,1072 B=4 (there are 4 keys), C=48 (INK 6: PAPER 0)
30383 LD HL,23280 Point HL at the attribute byte for the leftmost key in the icon panel
This entry point is used by the routine at 29716 with HL=23272 (attribute byte for the leftmost first aid kit in the icon panel) and C=50 (INK 2: PAPER 6).
30386 LD (HL),54 Set the attribute byte to 54 (INK 6: PAPER 6) by default
30388 ADD A,A Should there be a first aid kit or key displayed here?
30389 JR NC,30392 Jump if not
30391 LD (HL),C Otherwise reveal the first aid kit or key by setting the attribute byte to 50 (INK 2: PAPER 6) or 48 (INK 6: PAPER 0)
30392 INC L Move HL to the attribute byte for the next first aid kit or key
30393 DJNZ 30386 Jump back until all the first aid kits or keys have been done
30395 RET
Prev: 30198 Up: Map Next: 30396