Prev: 40338 Up: Map Next: 40406
40357: Check whether an egg has been dropped down the wishing well and set wish-pending flag if so
Used by the routine at 40338.
40357 LD A,36 Load A with 36 (object index of Golden Egg)
40359 LD B,6 Load B with 6 (as there are six eggs)
40361 PUSH BC Store BC (B = remaining number of eggs to process)
40362 PUSH AF Store AF (A = object index of current egg)
40363 LD C,A Load BC with three times object index of current egg...
40364 ADD A,A ...
40365 ADD A,C ...
40366 LD C,A ...
40367 LD B,0 ...
40369 LD HL,24922 Point HL at start of objects' current positions table...
40372 ADD HL,BC ...and add BC as offset
40373 LD A,(HL) Load A with room of current egg...
40374 CP 14 ...and if this is not 14 (Outdoors, 13, Wishing Well)...
40376 JR NZ,40395 ...then skip ahead to 40395
40378 INC HL Advance HL to y-coordinate of object...
40379 INC HL ...
40380 LD A,(HL) ...and load into A
40381 CP 19 If this is not 19...
40383 JR NZ,40395 ...then skip ahead to 40395
The instructions between 40385 and 40392 are only executed when the current egg is both in room 14 (Outdoors, 13, Wishing Well) and has a y-coordinate of 19, i.e. the egg has been dropped on top of (down) the well. The index of the dropped object (egg) is stored at 23365.
40385 POP AF Restore AF (A = object index of current egg)
40386 LD (23365),A Store object index of current egg at 23365, i.e. set wish-pending flag
40389 PUSH AF Store AF (A = object index of current egg)
40390 DEC HL Move HL back to room of object...
40391 DEC HL ...
40392 LD (40401),HL ...and store address in operand of instruction at 40400
40395 POP AF Restore AF (A = object index of current egg)
40396 POP BC Restore BC (B = remaining number of eggs to process)
40397 INC A Advance A to next egg
40398 DJNZ 40361 Decrease remaining number of eggs to process and loop back to 40361 if not zero
The operand of the instruction at 40400 represents the start address of the current position data for the object of interest. This is modified by the instruction at 40392.
40400 LD HL,0 Load HL with address of current position data for dropped egg...
40403 LD (HL),99 ...and set its current room to 99
40405 RET Return
Prev: 40338 Up: Map Next: 40406