![]() |
Routines |
| Prev: 59582 | Up: Map | Next: 59871 |
|
Handler for the object types 104 to 107 the four weapons that Sabreman can pick up (see Sprite_Weapon_1). The weapons are the small object records at Small_Object_Records. Byte 7 of a record holds the flags: bit 0 is set if there is no old image to erase, bit 1 is set while Sabreman carries the weapon and bit 2 is set while the weapon falls.
A weapon that lies on the floor is drawn again and again. When an action key has just been pressed (the flag at New_Action_Key_Press_Flag is 255) and Sabreman is touching it (see Check_Sabreman_Contact), he picks it up: the weapon moves to the x position 136 and the y position 15 which is its place in the panel at the top of the screen, bit 1 of the flags is set, the flag at New_Action_Key_Press_Flag is set to 254 to show that the key press has been used, and the type of the weapon is stored in the first of the weapon slots at Weapon_Slots.
Each later key press moves a carried weapon 24 pixels to the right in the panel and stores its type in the weapon slot that goes with the new x position (the x positions 160 and 184 both give the third slot, and none gives the second). A key press when the weapon has reached 184 makes Sabreman drop it. It is put at his position, with bit 1 of the flags reset, bit 2 set and the counter in byte 6 set to 16 and it falls (see Handle_Weapon_Pickup_Fall).
A weapon that is in a different room is dealt with by Handle_Distant_Weapon.
|
||||||||
| Handle_Weapon_Pickup | 59607 | CALL StoreEntity | Save the state of the weapon. | |||||
| 59610 | BIT 1,(IX+7) | Jump to Handle_Weapon_Pickup_Carried if Sabreman is carrying the weapon. | ||||||
| 59614 | JR NZ,Handle_Weapon_Pickup_Carried | |||||||
| 59616 | LD A,(36636) | Fetch the room x of Sabreman. | ||||||
| 59619 | CP (IX+2) | Jump to Handle_Distant_Weapon if the weapon is in a different room x. | ||||||
| 59622 | JP NZ,Handle_Distant_Weapon | |||||||
| 59625 | LD A,(36638) | Fetch the room y of Sabreman. | ||||||
| 59628 | CP (IX+4) | Jump to Handle_Distant_Weapon if the weapon is in a different room y. | ||||||
| 59631 | JP NZ,Handle_Distant_Weapon | |||||||
| 59634 | BIT 0,(IX+7) | Jump to Update_Object_Sprite_Using_Flags if it has no old image to erase. | ||||||
| 59638 | JP NZ,Update_Object_Sprite_Using_Flags | |||||||
| 59641 | BIT 2,(IX+7) | Jump to Handle_Weapon_Pickup_Fall if the weapon is falling. | ||||||
| 59645 | JP NZ,Handle_Weapon_Pickup_Fall | |||||||
| 59648 | LD A,(36586) | Fetch the flag for a new action key press. | ||||||
| 59651 | AND A | Jump to Handle_Weapon_Pickup_Draw if no action key has been pressed. | ||||||
| 59652 | JR Z,Handle_Weapon_Pickup_Draw | |||||||
| 59654 | INC A | Jump to Handle_Weapon_Pickup_Draw if the key press has been used already (the flag is not 255). | ||||||
| 59655 | JR NZ,Handle_Weapon_Pickup_Draw | |||||||
| 59657 | CALL Check_Sabreman_Contact | Check for contact with Sabreman. | ||||||
| 59660 | BIT 2,C | Jump to Handle_Weapon_Pickup_Draw if Sabreman is not touching the weapon. | ||||||
| 59662 | JR Z,Handle_Weapon_Pickup_Draw | |||||||
| 59664 | LD (IX+1),136 | Set the x position of the weapon to 136. | ||||||
| 59668 | LD (IX+3),15 | Set the y position of the weapon to 15. | ||||||
| 59672 | SET 1,(IX+7) | Set bit 1 of the flags, as Sabreman carries the weapon. | ||||||
| 59676 | LD A,254 | Mark the key press as used by writing 254 to New_Action_Key_Press_Flag. | ||||||
| 59678 | LD (36586),A | |||||||
| 59681 | LD A,(IX+0) | Fetch the type of the weapon. | ||||||
| 59684 | LD (36587),A | Store it in the first weapon slot. | ||||||
| 59687 | JP Update_Object_Sprite_Using_Flags | Jump to Update_Object_Sprite_Using_Flags. | ||||||
| Handle_Weapon_Pickup_Carried | 59690 | RES 0,(IX+7) | Reset bit 0 of the flags. | |||||
| 59694 | LD A,(36586) | Fetch the flag for a new action key press. | ||||||
| 59697 | AND A | Jump to Handle_Weapon_Pickup_Draw if no action key has been pressed. | ||||||
| 59698 | JR Z,Handle_Weapon_Pickup_Draw | |||||||
| 59700 | LD A,(IX+1) | Fetch the x position of the weapon. | ||||||
| 59703 | ADD A,24 | Add 24 to move it to the next place in the panel. | ||||||
| 59705 | CP 200 | Jump to Handle_Weapon_Pickup_Next_Slot if the result is less than 200. | ||||||
| 59707 | JR C,Handle_Weapon_Pickup_Next_Slot | |||||||
| 59709 | LD HL,(36635) | Fetch the x position and the room x of Sabreman. | ||||||
| 59712 | LD (IX+1),L | Set the x position of the weapon. | ||||||
| 59715 | LD (IX+2),H | Set the room x of the weapon. | ||||||
| 59718 | LD HL,(36637) | Fetch the y position and the room y of Sabreman. | ||||||
| 59721 | LD (IX+3),L | Set the y position of the weapon. | ||||||
| 59724 | LD (IX+4),H | Set the room y of the weapon. | ||||||
| 59727 | RES 1,(IX+7) | Reset bit 1 of the flags, as the weapon is dropped. | ||||||
| 59731 | SET 2,(IX+7) | Set bit 2 of the flags, as the weapon falls. | ||||||
| 59735 | LD (IX+6),16 | Set the counter in byte 6 to 16. | ||||||
| 59739 | JP Update_Object_Sprite_Using_Flags | Jump to Update_Object_Sprite_Using_Flags. | ||||||
| Handle_Weapon_Pickup_Next_Slot | 59742 | LD (IX+1),A | Set the x position of the weapon. | |||||
| 59745 | RRA | Shift the x position right four times. | ||||||
| 59746 | RRA | |||||||
| 59747 | RRA | |||||||
| 59748 | RRA | |||||||
| 59749 | AND %00000011 | Keep only the two low bits. | ||||||
| 59751 | CP 3 | Jump to Handle_Weapon_Pickup_Store_Slot unless the result is 3. | ||||||
| 59753 | JR NZ,Handle_Weapon_Pickup_Store_Slot | |||||||
| 59755 | DEC A | Change 3 to 2. | ||||||
| Handle_Weapon_Pickup_Store_Slot | 59756 | LD E,A | Store the weapon slot number in E. | |||||
| 59757 | LD D,0 | Clear the high byte of the slot number. | ||||||
| 59759 | LD HL,36587 | Point HL at Weapon_Slots. | ||||||
| 59762 | ADD HL,DE | Add the slot number to point at the weapon slot. | ||||||
| 59763 | LD A,(IX+0) | Fetch the type of the weapon. | ||||||
| 59766 | LD (HL),A | Store it in the weapon slot. | ||||||
| 59767 | JP Update_Object_Sprite_Using_Flags | Jump to Update_Object_Sprite_Using_Flags. | ||||||
| Handle_Weapon_Pickup_Draw | 59770 | CALL PrepDraw2 | Prepare the sprite of the weapon. | |||||
| 59773 | JP ColourEntity | Jump to ColourEntity. | ||||||
|
The weapon falls. The counter in byte 6 goes up on every call and one sixteenth of it is added to the y position.
|
||||||||
| Handle_Weapon_Pickup_Fall | 59776 | LD A,(IX+6) | Fetch the counter. | |||||
| 59779 | INC (IX+6) | Add one to the counter. | ||||||
| 59782 | RRA | Divide the old value by sixteen. | ||||||
| 59783 | RRA | |||||||
| 59784 | RRA | |||||||
| 59785 | RRA | |||||||
| 59786 | AND %00001111 | Keep only the low four bits. | ||||||
| 59788 | ADD A,(IX+3) | Add the y position of the weapon. | ||||||
| 59791 | LD (IX+3),A | Set the y position of the weapon. | ||||||
| 59794 | CALL Check_Decoration_Contact | Check for contact with the decorations. | ||||||
| 59797 | BIT 2,C | Jump to Handle_Weapon_Pickup_Check_Floor if the weapon is not touching a decoration. | ||||||
| 59799 | JR Z,Handle_Weapon_Pickup_Check_Floor | |||||||
| 59801 | LD A,B | Copy 160 less the y position of the top of the decoration to A. | ||||||
| 59802 | NEG | Negate it. | ||||||
| 59804 | ADD A,161 | Add 161 to get the y position just below the top of the decoration. | ||||||
| 59806 | LD (IX+3),A | Set the y position of the weapon. | ||||||
| 59809 | RES 2,(IX+7) | Reset bit 2 of the flags, as the weapon has stopped falling. | ||||||
| 59813 | JP Update_Object_Sprite_Using_Flags | Jump to Update_Object_Sprite_Using_Flags. | ||||||
| Handle_Weapon_Pickup_Check_Floor | 59816 | LD A,(IX+3) | Fetch the y position of the weapon. | |||||
| 59819 | CP 159 | Jump to Update_Object_Sprite_Using_Flags if it is less than 159. | ||||||
| 59821 | JP C,Update_Object_Sprite_Using_Flags | |||||||
| 59824 | CALL Read_World_Map | Read the world map entry of the room that the weapon is in. The flags of the room are returned in E. | ||||||
| 59827 | BIT 4,E | Jump to Handle_Weapon_Pickup_Check_Bottom if the room has no floor. | ||||||
| 59829 | JR Z,Handle_Weapon_Pickup_Check_Bottom | |||||||
| 59831 | LD (IX+3),159 | Set the y position of the weapon to 159 which is the floor. | ||||||
| 59835 | RES 2,(IX+7) | Reset bit 2 of the flags, as the weapon has stopped falling. | ||||||
| 59839 | JP Update_Object_Sprite_Using_Flags | Jump to Update_Object_Sprite_Using_Flags. | ||||||
| Handle_Weapon_Pickup_Check_Bottom | 59842 | LD A,(IX+3) | Fetch the y position of the weapon. | |||||
| 59845 | CP 191 | Jump to Update_Object_Sprite_Using_Flags if it is less than 191. | ||||||
| 59847 | JP C,Update_Object_Sprite_Using_Flags | |||||||
| Handle_Weapon_Pickup_Next_Room | 59850 | INC (IX+4) | Move the weapon to the room below. | |||||
| 59853 | CALL Read_World_Map | Read the world map entry of the room that the weapon is in. | ||||||
| 59856 | BIT 4,E | Jump back to Handle_Weapon_Pickup_Next_Room if the room has no floor. | ||||||
| 59858 | JR Z,Handle_Weapon_Pickup_Next_Room | |||||||
| 59860 | LD (IX+3),158 | Set the y position of the weapon to 158. | ||||||
| 59864 | LD (IX+6),0 | Clear the counter in byte 6. | ||||||
| 59868 | JP RemoveEntity | Erase the sprite of the weapon. | ||||||
| Prev: 59582 | Up: Map | Next: 59871 |