![]() |
Routines |
| Prev: 34848 | Up: Map | Next: 35085 |
|
Used by the routine at FireRandomShot.
Starts a shot (type 28) from an object, in one of the three shot slots. The kind of shot is chosen by the caller using the value in ScratchValue.
|
||||||||||||
| FireShot | 34859 | PUSH IX | Save the address of the object. | |||||||||
| 34861 | LD A,3 | Look for a free slot among three slots... | ||||||||||
| 34863 | LD IX,39380 | ...starting at the first shot slot. | ||||||||||
| 34867 | CALL FindFreeSlot | Search for a free slot. | ||||||||||
| 34870 | PUSH IX | Copy the address of the slot into IY... | ||||||||||
| 34872 | POP IY | |||||||||||
| 34874 | POP IX | ...and restore the address of the object. | ||||||||||
| 34876 | RET NZ | Return if there are no free slots. | ||||||||||
| 34877 | LD A,(IX+17) | Fetch the horizontal screen position of the object. | ||||||||||
| 34880 | CP 192 | Return if it is off the right-hand side of the screen... | ||||||||||
| 34882 | RET NC | |||||||||||
| 34883 | CP 24 | ...or off the left-hand side. | ||||||||||
| 34885 | RET C | |||||||||||
| 34886 | LD A,(23580) | Fetch the kind of shot from ScratchValue. | ||||||||||
| 34889 | LD HL,35238 | Use the table of shot flags at ShotTables, less one. | ||||||||||
| 34892 | CALL AddAToHL | Add the kind of shot to the address. | ||||||||||
| 34895 | LD A,(HL) | Fetch the flags for this kind of shot. | ||||||||||
| 34896 | LD (23581),A | Store them in TileNumber. | ||||||||||
| 34899 | LD A,(IX+18) | Fetch the vertical screen position of the object. | ||||||||||
| 34902 | BIT 7,(HL) | Jump to FireShot_CheckHigh if bit 7 of the flags is clear. | ||||||||||
| 34904 | JR Z,FireShot_CheckHigh | |||||||||||
| 34906 | CP 88 | Return if the object is too low down the screen for this shot. | ||||||||||
| 34908 | RET NC | |||||||||||
| FireShot_CheckHigh | 34909 | BIT 6,(HL) | Jump to FireShot_Start if bit 6 of the flags is clear. | |||||||||
| 34911 | JR Z,FireShot_Start | |||||||||||
| 34913 | CP 80 | Return if the object is too high up the screen for this shot. | ||||||||||
| 34915 | RET C | |||||||||||
| FireShot_Start | 34916 | CALL SwapObjects | Swap IX and IY, then copy the position of the object. | |||||||||
| 34919 | CALL FreeObjectSlot | Clear the slot of the shot. | ||||||||||
| 34922 | LD (IX+0),28 | Make the object a shot. | ||||||||||
| 34926 | LD (IX+16),32 | Set the flags of the shot. | ||||||||||
| 34930 | LD HL,35243 | Use the table of shot speeds at ShotTables_Speeds. | ||||||||||
| 34933 | LD A,(23580) | Fetch the kind of shot. | ||||||||||
| 34936 | ADD A,A | Multiply it by four. | ||||||||||
| 34937 | ADD A,A | |||||||||||
| 34938 | CALL AddAToHL | Add it to the address. | ||||||||||
| 34941 | LD A,(HL) | Set the horizontal speed of the shot from the table. | ||||||||||
| 34942 | LD (IX+7),A | |||||||||||
| 34945 | INC HL | |||||||||||
| 34946 | LD A,(HL) | |||||||||||
| 34947 | LD (IX+9),A | Set the vertical speed of the shot from the table. | ||||||||||
| 34950 | INC HL | |||||||||||
| 34951 | LD A,(HL) | |||||||||||
| 34952 | LD (IX+19),A | Set the first state byte of the shot from the table. | ||||||||||
| 34955 | INC HL | |||||||||||
| 34956 | LD A,(HL) | |||||||||||
| 34957 | LD (IX+20),A | Set the second state byte of the shot from the table. | ||||||||||
| 34960 | LD A,(23581) | Fetch the flags for this kind of shot. | ||||||||||
| 34963 | AND %00001111 | Keep the colour in the bottom four bits. | ||||||||||
| 34965 | LD B,A | Copy it into the top four bits... | ||||||||||
| 34966 | ADD A,A | |||||||||||
| 34967 | ADD A,A | |||||||||||
| 34968 | ADD A,A | |||||||||||
| 34969 | ADD A,A | |||||||||||
| 34970 | OR B | ...and set the attribute of the shot. | ||||||||||
| 34971 | LD (IX+13),A | |||||||||||
| 34974 | LD (IX+21),56 | Set the lifetime of the shot to 56. | ||||||||||
| 34978 | CALL MoveObject | Draw the shot. | ||||||||||
| 34981 | PUSH IY | Swap IX and IY back again. | ||||||||||
| 34983 | PUSH IX | |||||||||||
| 34985 | POP IY | |||||||||||
| 34987 | POP IX | |||||||||||
| 34989 | LD A,(IY+19) | Fetch the state of the object that fired the shot. | ||||||||||
| 34992 | AND %00001111 | Keep the bottom four bits. | ||||||||||
| 34994 | JP Z,SetFallingSpeed | Jump to SetFallingSpeed if it is zero. | ||||||||||
| 34997 | CP 5 | Jump to SetRandomSpeed if it is 5. | ||||||||||
| 34999 | JP Z,SetRandomSpeed | |||||||||||
| 35002 | CP 6 | Jump to SetRandomSpeed if it is 6. | ||||||||||
| 35004 | JP Z,SetRandomSpeed | |||||||||||
| 35007 | CP 7 | Jump to ReverseVerticalSpeed if it is 7. | ||||||||||
| 35009 | JP Z,ReverseVerticalSpeed | |||||||||||
| 35012 | CP 10 | Jump to FireShot_State0A if it is 10. | ||||||||||
| 35014 | JP Z,FireShot_State0A | |||||||||||
| 35017 | LD H,(IX+7) | Fetch the horizontal speed of the shot... | ||||||||||
| 35020 | LD L,(IX+8) | |||||||||||
| 35023 | SRA H | ...halve it... | ||||||||||
| 35025 | RR L | |||||||||||
| 35027 | LD (IY+7),H | ...and give it to the object that fired. | ||||||||||
| 35030 | LD (IY+8),L | |||||||||||
| 35033 | LD A,(23581) | Fetch the flags for this kind of shot. | ||||||||||
| 35036 | LD (IY+9),5 | Set the vertical speed of the object to push it up. | ||||||||||
| 35040 | BIT 7,A | Jump to FireShot_Sound if bit 7 of the flags is set. | ||||||||||
| 35042 | JR NZ,FireShot_Sound | |||||||||||
| 35044 | LD (IY+9),251 | Otherwise set the vertical speed to push it down instead. | ||||||||||
|
This entry point is used by the routines at SetRandomSpeed, SetFallingSpeed and ReverseVerticalSpeed.
|
||||||||||||
| FireShot_Sound | 35048 | LD A,(IY+0) | Fetch the type of the object. | |||||||||
| 35051 | INC A | Increment it. | ||||||||||
| 35052 | CALL NZ,PlayNoiseBurst | Play a sound if the object is active. | ||||||||||
| 35055 | RET | Return. | ||||||||||
| FireShot_State0A | 35056 | LD (IY+7),6 | Set the horizontal speed of the object to six... | |||||||||
| 35060 | LD (IY+8),0 | ...and clear its other speeds. | ||||||||||
| 35064 | LD (IY+9),0 | |||||||||||
| 35068 | LD (IY+10),0 | |||||||||||
| 35072 | LD A,(23580) | Fetch the kind of shot. | ||||||||||
| 35075 | CP 7 | Jump to FireShot_Sound if it is 7. | ||||||||||
| 35077 | JR Z,FireShot_Sound | |||||||||||
| 35079 | LD (IY+7),250 | Otherwise reverse the horizontal speed. | ||||||||||
| 35083 | JR FireShot_Sound | Jump to FireShot_Sound. | ||||||||||
| Prev: 34848 | Up: Map | Next: 35085 |