Prev: 26887 Up: Map Next: 26988
26914: Make a guard drop his lunch if necessary
Used by the routine at 26887.
26914 LD A,(28094) Pick up the guard's return delay counter.
26917 AND A Has this guard been thrown out of the park?
26918 RET NZ Return if so.
26919 LD E,4 There are four maze background tiles to consider.
26921 LD HL,28095 Point HL at the first maze background tile in the temporary guard buffer.
26924 LD A,(HL) Pick up the attribute byte of this maze background tile.
26925 CP 58 Is there already a cherry or strawberry here?
26927 RET Z Return if so.
26928 LD BC,9 Point HL at the next maze background tile.
26931 ADD HL,BC
26932 DEC E Have we checked all four tiles yet?
26933 JR NZ,26924 Jump back if not.
26935 LD HL,(31845) Decrement the lunch-drop countdown timer.
26938 DEC HL
26939 LD (31845),HL
26942 LD A,H Is it zero now?
26943 OR L
26944 RET NZ Return if not.
26945 CALL 27410 Generate a pseudo-random number in A.
26948 LD L,A Copy it to L.
26949 PUSH HL Save L briefly.
26950 CALL 27410 Generate another pseudo-random number in A.
26953 POP HL Restore L.
26954 AND 3 Reduce A to 0, 1, 2 or 3 and copy it to H.
26956 LD H,A
26957 LD BC,800 Add 800 and reset the lunch-drop countdown timer to this value.
26960 ADD HL,BC
26961 LD (31845),HL
26964 CALL 27410 Generate yet another pseudo-random number in A.
26967 AND 1 Is bit 0 set?
26969 JR NZ,26976 Jump if so.
26971 LD HL,31868 Point HL at the sprite data for the cherry.
26974 JR 26979
26976 LD HL,31904 Point HL at the sprite data for the strawberry.
26979 LD DE,28095 Copy the cherry/strawberry sprite into the maze background tiles in the temporary guard buffer.
26982 LD BC,36
26985 LDIR
26987 RET
Prev: 26887 Up: Map Next: 26988