![]() |
Routines |
| Prev: 55930 | Up: Map | Next: 56168 |
|
Used by the routine at UpdatePlayerLegs.
Throws the last item that was picked up, if the fire button has been pressed and the previous throw has finished. An item that belongs to a monster (items 1 to 4) is dropped into the object for the monster. Any other item becomes a shot, in one of the two objects from ObjectTable_Shots; if both are busy, the one that was not used last is turned into a burst.
|
||||||||
|
See No Throw Delay.
|
||||||||
| ThrowItem | 55991 | LD HL,48072 | Fetch the time left before another item can be thrown. | |||||
| 55994 | LD A,(HL) | |||||||
| 55995 | AND A | |||||||
| 55996 | JR Z,ThrowItem_Ready | |||||||
| 55998 | DEC (HL) | Count down the time and return if it has not run out. | ||||||
| 55999 | RET | |||||||
| ThrowItem_Ready | 56000 | BIT 3,E | Return if the fire button has not been pressed. | |||||
| 56002 | RET Z | |||||||
| 56003 | LD HL,48141 | Point HL at the last place in the inventory, and set a counter of eleven places. | ||||||
| 56006 | LD B,11 | |||||||
| ThrowItem_Find | 56008 | LD A,(HL) | Jump to ThrowItem_Found if there is an item in this place. | |||||
| 56009 | AND A | |||||||
| 56010 | JR NZ,ThrowItem_Found | |||||||
| 56012 | DEC HL | Move to the place before it and loop back until all of the places have been checked. | ||||||
| 56013 | DJNZ ThrowItem_Find | |||||||
| 56015 | RET | Return. | ||||||
|
An item has been found. Monster items are dropped; any other item becomes a shot.
|
||||||||
| ThrowItem_Found | 56016 | CP 5 | Jump to ThrowItem_Drop if the item is one of the monster items (1 to 4). | |||||
| 56018 | JR C,ThrowItem_Drop | |||||||
| 56020 | LD IY,48302 | Point IY at the first shot, and set the size of an object to 16 bytes. | ||||||
| 56024 | LD DE,16 | |||||||
| 56027 | LD C,2 | Set a counter of two shots. | ||||||
| ThrowItem_Shot | 56029 | LD A,(IY+0) | Jump to ThrowItem_Free if this shot is free. | |||||
| 56032 | AND A | |||||||
| 56033 | JR Z,ThrowItem_Free | |||||||
| 56035 | ADD IY,DE | Move on to the next shot and loop back until both have been checked. | ||||||
| 56037 | DEC C | |||||||
| 56038 | JR NZ,ThrowItem_Shot | |||||||
| 56040 | LD HL,48302 | Choose the shot that was not used last. | ||||||
| 56043 | LD A,(48116) | Fetch which shot was used last (0 or 16). | ||||||
| 56046 | AND 16 | |||||||
| 56048 | LD C,A | |||||||
| 56049 | LD B,0 | Set the offset of the shot. | ||||||
| 56051 | ADD HL,BC | Point at the shot. | ||||||
| 56052 | LD A,(HL) | Fetch the type of the shot, and subtract 80. | ||||||
| 56053 | SUB 80 | |||||||
| 56055 | CP 16 | |||||||
| 56057 | RET NC | Return if the shot has not got a type of 80 to 95. | ||||||
| 56058 | LD (HL),12 | Turn the shot into a burst. | ||||||
| 56060 | RET | Return. | ||||||
|
This shot is free, so the item is copied from the player into it.
|
||||||||
| ThrowItem_Free | 56061 | LD A,(48116) | Change the shot that was used last. | |||||
| 56064 | XOR 16 | |||||||
| 56066 | LD (48116),A | |||||||
| 56069 | PUSH BC | Keep the counter and the place in the inventory. | ||||||
| 56070 | PUSH HL | |||||||
| 56071 | LD A,(HL) | Fetch the item and remove it from the inventory. | ||||||
| 56072 | LD (HL),0 | |||||||
| 56074 | LD HL,48270 | Use the player as the source of the copy. | ||||||
| 56077 | PUSH IY | Use the shot as the destination of the copy (using the stack). | ||||||
| 56079 | POP DE | |||||||
| 56080 | LD BC,16 | Copy the player into the shot. | ||||||
| 56083 | LDIR | |||||||
| 56085 | ADD A,A | Make the type of the shot from the item. | ||||||
| 56086 | ADD A,A | |||||||
| 56087 | ADD A,60 | |||||||
| ThrowItem_Set | 56089 | LD (IY+0),A | Set the type of the object. | |||||
| 56092 | LD (IY+5),12 | Set the speed of the object to 12. | ||||||
| 56096 | LD A,16 | Set the width and the depth of the object to 16. | ||||||
| 56098 | LD (IY+8),A | |||||||
| 56101 | LD (IY+9),A | |||||||
| 56104 | LD (IY+12),248 | Set the X offset of the sprite. | ||||||
| 56108 | LD (IY+13),4 | Set the Y offset of the sprite. | ||||||
| 56112 | LD A,2 | Set the time before the next throw to two frames. | ||||||
| 56114 | LD (48072),A | |||||||
| 56117 | POP HL | Restore the inventory place and the counter from the stack. | ||||||
| 56118 | POP BC | |||||||
| 56119 | LD A,B | Work out the number of the place counted from the start of the inventory. | ||||||
| 56120 | NEG | |||||||
| 56122 | ADD A,12 | |||||||
| 56124 | LD B,A | |||||||
| 56125 | CALL DrawInventoryItem | Redraw the item in the inventory tube. | ||||||
| 56128 | JP PlaySweepSound | Jump to PlaySweepSound. | ||||||
|
The item is one of the monster items, which is dropped into the object for the monster.
|
||||||||
| ThrowItem_Drop | 56131 | PUSH BC | Keep the counter, the place in the inventory and the item. | |||||
| 56132 | PUSH HL | |||||||
| 56133 | PUSH AF | |||||||
| 56134 | LD (HL),0 | Remove the item from the inventory. | ||||||
| 56136 | NEG | Work out the offset of the object from the number of the item. | ||||||
| 56138 | ADD A,4 | |||||||
| 56140 | ADD A,A | |||||||
| 56141 | ADD A,A | |||||||
| 56142 | ADD A,A | |||||||
| 56143 | ADD A,A | |||||||
| 56144 | LD HL,48414 | Find the object for the monster. | ||||||
| 56147 | CALL AddAToHL | |||||||
| 56150 | PUSH HL | Point IY at the object, and keep the address of the object. | ||||||
| 56151 | PUSH HL | |||||||
| 56152 | POP IY | |||||||
| 56154 | POP DE | |||||||
| 56155 | LD HL,48270 | Copy the player into the object. | ||||||
| 56158 | LD BC,16 | |||||||
| 56161 | LDIR | |||||||
| 56163 | POP AF | Make the type of the object from the item, and jump to ThrowItem_Set. | ||||||
| 56164 | ADD A,7 | |||||||
| 56166 | JR ThrowItem_Set | |||||||
| Prev: 55930 | Up: Map | Next: 56168 |