Prev: 41545 Up: Map Next: 41748
41578: Process command to pick up an object
Used by the routine at 64623.
41578 CALL 63399 Print or update command summary window at top of screen
41581 LD DE,51811 Point DE at "PICK UP THE" text...
41584 CALL 63349 ...and print in command summary window at top of screen
41587 LD HL,24922 Point HL at start of objects' current positions table
41590 LD BC,10752 Load B with 42 (as there are 42 objects) and C with 0
41593 LD A,(23702) Load A with Magic Knight's current room
41596 CP (HL) If current object's room is not the same as Magic Knight's then...
41597 JR NZ,41600 ...skip ahead to 41600
41599 INC C Increase C (count of objects in Magic Knight's current room)
41600 INC HL Advance HL to next object's position...
41601 INC HL ...
41602 INC HL ...
41603 DJNZ 41593 Decrease B and loop back for next object
41605 LD A,C Copy total number of objects into A...
41606 OR A ...and if this value is zero then set zero flag
41607 LD HL,51822 Load HL with address of "THERE IS NOTHING IN THIS ROOM" text
41610 JP Z,64261 Display "THERE IS NOTHING IN THIS ROOM" window (13) and return to game
41613 LD HL,24922 Point HL at start of objects' current positions table
41616 LD A,(23702) Load A with Magic Knight's current room
41619 LD C,A ...and copy into C
41620 CALL 45584 Load Magic Knight's coordinates (in characters) into DE
41623 XOR A Set A to zero
41624 EX AF,AF' Switch A register
41625 LD B,42 Load B with 42 (as there are 42 objects)
41627 LD A,C Load Magic Knight's current room into A
41628 CP (HL) If room of current object is not the same as Magic Knight's current room...
41629 JR NZ,41652 ...then skip ahead to 41652 [advance to next object]
41631 LD A,D Copy Magic Knight's y-coordinate into A
41632 INC HL Advance HL to current object's y-coordinate...
41633 INC HL ...
41634 CP (HL) ...and if this is not the same as Magic Knight's y-coordinate...
41635 JR NZ,41654 ...then skip ahead to 41654 [advance to next object]
41637 DEC HL Move HL back to object's x-coordinate
41638 LD A,E Load Magic Knight's x-coordinate into A
41639 DEC A Decrease x-coordinate by two...
41640 DEC A ...
41641 PUSH BC Store BC
41642 LD B,5 Load B with 5 (as we are going to test 5 different x-coordinates)
41644 CP (HL) If x-coordinate of object is the same as current x-coordinate value...
41645 JR Z,41666 ...then skip ahead to 41666
41647 INC A Increase value of current x-coordinate (to test next x-coordinate in range -2 to +2)
41648 DJNZ 41644 Decrease B (remaining number of x-coordinates to test) and loop back to 41644
41650 POP BC Restore BC
41651 DEC HL Move HL back one byte to start of position data for current object
41652 INC HL Advance HL by three bytes to move to next object...
41653 INC HL ...
41654 INC HL ...
41655 EX AF,AF' Switch A register back (so now contains the index of the object to test next)
41656 INC A Increase A [index of current object to test]
41657 EX AF,AF' Switch A register
41658 DJNZ 41627 Loop back to 41627 for next object
41660 LD HL,51833 Display "THERE IS NOTHING NEAR ENOUGH" window (13) and return to game...
41663 JP 64261 ...
An object has been found within Magic Knight's reach so make this the current object
41666 POP BC Restore BC
41667 EX AF,AF' Switch A register (so now contains index of first object that is within Magic Knight's reach)
41668 LD (41779),A Load index of this object into instruction at 41778 (i.e. set as Current Object)
41671 LD DE,45779 Point DE at character code to print name of Current Object
41674 CALL 63349 ...and print in command summary window at top of screen
41677 CALL 64207 Display execute / reject command window and return here if execute chosen, else exit to main game loop
41680 LD A,(41779) Load A with index of Current Object...
41683 CALL 45685 ...and if this is 4 (Teddy Bear) then display "THE BEAR SAYS..." message and wait for fire to be pressed
41686 LD HL,24852 Load A with index of object in Magic Knight's fifth inventory slot (carrying)...
41689 LD A,(HL) ...
41690 OR A If this is not zero (i.e. Magic Knight's hands are full)...
41691 JP NZ,64258 ...then display "YOUR HANDS ARE FULL" window and return to game
41694 CALL 45466 Check whether object has a weight greater than Magic Knight's surplus strength...
41697 JP P,64265 ...and if it does then display "THE [name of Current Object] IS TOO HEAVY FOR YOU" window and return to game
41700 LD A,(41779) Load A with index of Current Object...
41703 LD C,A ...and copy into C
41704 LD B,5 Load B with 5 (five inventory slots)
41706 LD HL,24848 Wait for interrupt then load object in C into Magic Knight's first empty inventory (carrying) slot...
41709 CALL 45380 ...
41712 LD A,(41779) Load A with index of Current Object...
41715 LD C,A ...and copy into C
41716 ADD A,A Multiply index by three in A...
41717 ADD A,C ...
41718 LD B,0 Load three times object index into BC...
41720 LD C,A ...
41721 LD HL,24922 Point HL at start of objects' current positions table
41724 ADD HL,BC Add BC as offset to point HL at position data for current object
41725 LD (HL),99 Set object's room to 99
This entry point is used by the routines at 41748, 42036, 42395 and 44635.
41727 LD IX,24848 Point IX at Magic Knight's current inventory (carrying)
41731 LD B,5 Load B with 5 (five inventory slots)
41733 LD HL,51794 Point HL at "YOU ARE NOW CARRYING" text
41736 CALL 45802 Display "Magic Knight's current inventory" window as an information window
This entry point is used by the routines at 42638 and 45552.
41739 CALL 64230 Wait for interrupt then display "PRESS FIRE TO CONTINUE" window and wait for fire to be pressed
This entry point is used by the routines at 41748, 41924, 42257, 42638, 43043, 43494, 43636, 44635, 44861, 44933, 64207, 64317 and 64623.
41742 CALL 46183 Set Magic Knight's available action flags
41745 JP 38205 Jump to start of main game loop
Prev: 41545 Up: Map Next: 41748