Prev: 29272 Up: Map Next: 29488
29330: Process command to pick up an object
Used by the routine at 55726.
29330 CALL 54333 Print or update command summary window at top of screen
29333 LD DE,38824 Point DE at "PICK UP THE" text...
29336 CALL 54283 ...and print in command summary window at top of screen
29339 LD HL,25286 Point HL at start of objects' current positions table
29342 LD BC,3200 Load B with 12 and C with 128 (bug)
29345 LD A,(23701) Load A with Magic Knight's current room
29348 CP (HL) If current object's room is not the same as Magic Knight's then...
29349 JR NZ,29352 ...skip ahead to 29352
29351 INC C Increase C (count of objects in Magic Knight's current room)
29352 INC HL Advance HL to next object's position...
29353 INC HL ...
29354 INC HL ...
29355 DJNZ 29345 Decrease B and loop back for next object
29357 LD A,C Copy total number of objects into A...
29358 OR A ...and if this value is zero... [can't actually happen because of bug at 29342]
29359 JP Z,55192 ...then display "THERE IS NOTHING IN THIS ROOM" window (13) and return to game
29362 LD HL,25286 Point HL at start of objects' current positions table
29365 LD A,(23701) Load A with Magic Knight's current room
29368 LD C,A ...and copy into C
29369 CALL 33757 Load Magic Knight's coordinates (in characters) into DE
29372 XOR A Set A to zero
29373 EX AF,AF' Switch A register
29374 LD B,50 Load B with 50 (bug - should be 37 as there are only 37 objects)
29376 LD A,C Load Magic Knight's current room into A
29377 CP (HL) If room of current object is not the same as Magic Knight's current room...
29378 JR NZ,29401 ...then skip ahead to 29401 [advance to next object]
29380 LD A,D Copy Magic Knight's y-coordinate into A
29381 INC HL Advance HL to current object's y-coordinate...
29382 INC HL ...
29383 CP (HL) ...and if this is not the same as Magic Knight's y-coordinate...
29384 JR NZ,29403 ...then skip ahead to 29403 [advance to next object]
29386 DEC HL Move HL back to object's x-coordinate
29387 LD A,E Load Magic Knight's x-coordinate into A
29388 DEC A Decrease x-coordinate by two...
29389 DEC A ...
29390 PUSH BC Store BC
29391 LD B,5 Load B with 5 (as we are going to test 5 different x-coordinates)
29393 CP (HL) If x-coordinate of object is the same as current x-coordinate value...
29394 JR Z,29412 ...then skip ahead to 29412
29396 INC A Increase value of current x-coordinate (to test next x-coordinate in range -2 to +2)
29397 DJNZ 29393 Decrease B (remaining number of x-coordinates to test) and loop back to 29393
29399 POP BC Restore BC
29400 DEC HL Move HL back one byte to start of position data for current object
29401 INC HL Advance HL by three bytes to move to next object...
29402 INC HL ...
29403 INC HL ...
29404 EX AF,AF' Switch A register back (so now contains the index of the object to test next)
29405 INC A Increase A [index of current object to test]
29406 EX AF,AF' Switch A register
29407 DJNZ 29376 Loop back to 29376 for next object
29409 JP 55187 Display "THERE IS NOTHING NEAR ENOUGH" window (13) and return to game
An object has been found within Magic Knight's reach so make this the current object
29412 POP BC Restore BC
29413 EX AF,AF' Switch A register (so now contains index of first object that is within Magic Knight's reach)
29414 LD (29526),A Load index of this object into instruction at 29525 (i.e. set as Current Object)
29417 LD DE,33924 Point DE at character code to print name of Current Object
29420 CALL 54283 ...and print in command summary window at top of screen
29423 CALL 55115 Display execute / reject command window and return here if execute chosen, else exit to main game loop
29426 LD HL,25168 Load A with index of object in Magic Knight's fifth inventory slot (carrying)...
29429 LD A,(HL) ...
29430 OR A If this is not zero (i.e. Magic Knight's hands are full)...
29431 JP NZ,55165 ...then display "YOUR HANDS ARE FULL" window and return to game
29434 CALL 33601 Check whether object has a weight greater than Magic Knight's surplus strength...
29437 JP P,55177 ...and if it does then display "THE [name of Current Object] IS TOO HEAVY FOR YOU" window and return to game
29440 LD A,(29526) Load A with index of Current Object...
29443 LD C,A ...and copy into C
29444 LD B,5 Load B with 5 (five inventory slots)
29446 LD HL,25164 Load object in C into Magic Knight's first empty inventory (carrying) slot...
29449 CALL 33516 ...
29452 LD A,(29526) Load A with index of Current Object...
29455 LD C,A ...and copy into C
29456 ADD A,A Multiply index by three in A...
29457 ADD A,C ...
29458 LD B,0 Load three times object index into BC...
29460 LD C,A ...
29461 LD HL,25286 Point HL at start of objects' current positions table
29464 ADD HL,BC Add BC as offset to point HL at position data for current object
29465 LD (HL),99 Set object's room to 99
This entry point is used by the routines at 29488, 29619, 29756 and 31537.
29467 LD IX,25164 Point IX at Magic Knight's current inventory (carrying)
29471 LD B,5 Load B with 5 (five inventory slots)
29473 LD HL,38809 Point HL at "YOU ARE NOW CARRYING" text
29476 CALL 33945 Display "Magic Knight's current inventory" window as an information window
This entry point is used by the routines at 29756, 30145, 31188, 31280, 31312, 32895, 33338 and 33725.
29479 CALL 55138 Display "PRESS FIRE TO CONTINUE" window and wait for fire to be pressed
This entry point is used by the routines at 29488, 29619, 29756, 30145, 30686, 30968, 31257, 31537, 55115, 55364 and 55726.
29482 CALL 34265 Set Magic Knight's available action flags and validate I.D. Card if appropriate
29485 JP 27136 Jump to start of main game loop
Prev: 29272 Up: Map Next: 29488