![]() |
Routines |
| Prev: 40810 | Up: Map | Next: 40962 |
|
Keep the collectible objects in the world. When the pickup slots are empty, refill them, choose a world X away from Jetman and the rover, place the pickups from it and then advance the level.
|
|||||||||||||||||||||||||||||||||||||||
|
Refill Object_Slot_1 from Pickup_Defaults when those slots are empty.
|
|||||||||||||||||||||||||||||||||||||||
| Handler_Pickups | 40816 | CALL ScanObjectSlots_Test | Call ScanObjectSlots_Test. | ||||||||||||||||||||||||||||||||||||
| 40819 | RET NZ | Return if any pickup slot is still in use. | |||||||||||||||||||||||||||||||||||||
| 40820 | LD HL,41064 | Copy the 144 bytes of pickup templates from Pickup_Defaults into the pickup slots at Object_Slot_1. | |||||||||||||||||||||||||||||||||||||
| 40823 | LD DE,24840 | ||||||||||||||||||||||||||||||||||||||
| 40826 | LD BC,144 | ||||||||||||||||||||||||||||||||||||||
| 40829 | LDIR | ||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||
| 40831 | LD A,(24130) | Fetch GameTimer. | |||||||||||||||||||||||||||||||||||||
| 40834 | LD H,A | Stash it in H. | |||||||||||||||||||||||||||||||||||||
| 40835 | LD A,(24128) | Fetch RandomNumber. | |||||||||||||||||||||||||||||||||||||
| 40838 | LD L,A | Stash it in L. | |||||||||||||||||||||||||||||||||||||
|
Keep the new world X at least 16 away from Jetman_Position and Rover_Position.
|
|||||||||||||||||||||||||||||||||||||||
| Handler_Pickups_AwayFromJetman | 40839 | LD A,(24699) | Fetch the high byte of Jetman_Position. | ||||||||||||||||||||||||||||||||||||
| 40842 | ADD A,A | Multiply it by 8. | |||||||||||||||||||||||||||||||||||||
| 40843 | ADD A,A | ||||||||||||||||||||||||||||||||||||||
| 40844 | ADD A,A | ||||||||||||||||||||||||||||||||||||||
| 40845 | SUB H | Subtract the candidate high byte. | |||||||||||||||||||||||||||||||||||||
| 40846 | JP P,Handler_Pickups_TestJetmanX | Jump to Handler_Pickups_TestJetmanX if the result is positive. | |||||||||||||||||||||||||||||||||||||
| 40849 | NEG | Negate the difference. | |||||||||||||||||||||||||||||||||||||
| Handler_Pickups_TestJetmanX | 40851 | CP 16 | Compare it against 16. | ||||||||||||||||||||||||||||||||||||
| 40853 | JR C,StepPickupCandidate | Jump to StepPickupCandidate if it is closer than that. | |||||||||||||||||||||||||||||||||||||
|
Retry unless the candidate is also at least 16 from Rover_Position.
|
|||||||||||||||||||||||||||||||||||||||
| 40855 | LD A,(24723) | Fetch the high byte of Rover_Position. | |||||||||||||||||||||||||||||||||||||
| 40858 | ADD A,A | Multiply it by 8. | |||||||||||||||||||||||||||||||||||||
| 40859 | ADD A,A | ||||||||||||||||||||||||||||||||||||||
| 40860 | ADD A,A | ||||||||||||||||||||||||||||||||||||||
| 40861 | SUB H | Subtract the candidate high byte. | |||||||||||||||||||||||||||||||||||||
| 40862 | JP P,Handler_Pickups_TestRoverX | Jump to Handler_Pickups_TestRoverX if the result is positive. | |||||||||||||||||||||||||||||||||||||
| 40865 | NEG | Negate the difference. | |||||||||||||||||||||||||||||||||||||
| Handler_Pickups_TestRoverX | 40867 | CP 16 | Compare it against 16. | ||||||||||||||||||||||||||||||||||||
| 40869 | JR C,StepPickupCandidate | Jump to StepPickupCandidate if it is closer than that. | |||||||||||||||||||||||||||||||||||||
|
Write the new pickup positions into the pickup slots.
|
|||||||||||||||||||||||||||||||||||||||
| 40871 | SRL H | Divide the candidate high byte by 8. | |||||||||||||||||||||||||||||||||||||
| 40873 | SRL H | ||||||||||||||||||||||||||||||||||||||
| 40875 | SRL H | ||||||||||||||||||||||||||||||||||||||
| 40877 | LD (24842),HL | Write it to 24842. | |||||||||||||||||||||||||||||||||||||
|
Derive the other pickup world X values by adding offsets and wrapping. MaskWorldX hands the wrapped result back in HL, so each offset is added to the world X written just before it.
|
|||||||||||||||||||||||||||||||||||||||
| 40880 | LD BC,64 | Set the offset in BC to 0064 to place the next pickup that far on from the first. | |||||||||||||||||||||||||||||||||||||
| 40883 | CALL MaskWorldX | Call MaskWorldX to add the offset and wrap the world X. | |||||||||||||||||||||||||||||||||||||
| 40886 | LD (24938),HL | Write it to 24938. | |||||||||||||||||||||||||||||||||||||
|
Place the next pickup a smaller step further on.
|
|||||||||||||||||||||||||||||||||||||||
| 40889 | LD BC,8 | Set the offset in BC to 0008. | |||||||||||||||||||||||||||||||||||||
| 40892 | CALL MaskWorldX | Call MaskWorldX to add the offset and wrap the world X. | |||||||||||||||||||||||||||||||||||||
| 40895 | LD (24962),HL | Write it to AlienBase_WorldX. | |||||||||||||||||||||||||||||||||||||
|
Finally step on by 64 again for the last pickup.
|
|||||||||||||||||||||||||||||||||||||||
| 40898 | LD BC,64 | Set the offset in BC to 0064. | |||||||||||||||||||||||||||||||||||||
| 40901 | CALL MaskWorldX | Call MaskWorldX to add the offset and wrap the world X. | |||||||||||||||||||||||||||||||||||||
| 40904 | LD (24890),HL | Write it to Object_Slot_3_Position. | |||||||||||||||||||||||||||||||||||||
|
Advance the level, and award an extra life every fourth level.
|
|||||||||||||||||||||||||||||||||||||||
| 40907 | LD A,(24224) | Fetch ActivePlayer_Level. | |||||||||||||||||||||||||||||||||||||
| 40910 | CP 99 | Jump to Handler_Pickups_WriteLevel if it is already 99. | |||||||||||||||||||||||||||||||||||||
| 40912 | JR Z,Handler_Pickups_WriteLevel | ||||||||||||||||||||||||||||||||||||||
| 40914 | INC A | Increase the level by one. | |||||||||||||||||||||||||||||||||||||
| Handler_Pickups_WriteLevel | 40915 | LD (24224),A | Write it back to ActivePlayer_Level. | ||||||||||||||||||||||||||||||||||||
| 40918 | AND A | Jump to Handler_Pickups_TestLevel10 if the new level is zero. | |||||||||||||||||||||||||||||||||||||
| 40919 | JR Z,Handler_Pickups_TestLevel10 | ||||||||||||||||||||||||||||||||||||||
| 40921 | AND %00000011 | Keep only bits 0-1. | |||||||||||||||||||||||||||||||||||||
| 40923 | JR NZ,Handler_Pickups_TestLevel10 | Jump to Handler_Pickups_TestLevel10 if this is not a fourth level. | |||||||||||||||||||||||||||||||||||||
|
Award an extra life and queue a jingle, then redraw the lives.
|
|||||||||||||||||||||||||||||||||||||||
| 40925 | LD HL,24225 | HL=ActivePlayer_Lives. | |||||||||||||||||||||||||||||||||||||
| 40928 | INC (HL) | Increase ActivePlayer_Lives by one. | |||||||||||||||||||||||||||||||||||||
| 40929 | LD DE,47796 | Point DE at the tune at Tune_Extra_2. | |||||||||||||||||||||||||||||||||||||
| 40932 | CALL QueueTune | Call QueueTune. | |||||||||||||||||||||||||||||||||||||
| 40935 | CALL DisplayPlayerLives | Call DisplayPlayerLives. | |||||||||||||||||||||||||||||||||||||
|
Turn the level into the missile launcher countdown at Missile_Launcher_Countdown (the higher the level, the shorter it is), then jump to PrintPlayerLevels. Rotating left twice multiplies the level by 4. Inverting and masking that to bits 2-5 gives 60 minus 4 for each level, so adding 81 leaves a countdown that falls by 4 per level, from 141 to 81.
|
|||||||||||||||||||||||||||||||||||||||
| Handler_Pickups_TestLevel10 | 40938 | LD A,(24224) | Fetch ActivePlayer_Level. | ||||||||||||||||||||||||||||||||||||
| 40941 | CP 16 | Compare it against 16. | |||||||||||||||||||||||||||||||||||||
| 40943 | CALL NC,Handler_Pickups_ForceMaximumLevel | Call Handler_Pickups_ForceMaximumLevel if the level is at least 16. | |||||||||||||||||||||||||||||||||||||
| 40946 | RLCA | Rotate the level left twice. | |||||||||||||||||||||||||||||||||||||
| 40947 | RLCA | ||||||||||||||||||||||||||||||||||||||
| 40948 | CPL | Invert the bits. | |||||||||||||||||||||||||||||||||||||
| 40949 | AND %00111100 | Keep only bits 2-5. | |||||||||||||||||||||||||||||||||||||
| 40951 | ADD A,81 | Add 81. | |||||||||||||||||||||||||||||||||||||
| 40953 | LD (24959),A | Write it to Missile_Launcher_Countdown. | |||||||||||||||||||||||||||||||||||||
| 40956 | JP PrintPlayerLevels | Jump to PrintPlayerLevels. | |||||||||||||||||||||||||||||||||||||
|
Levels of 16 and above use 255 in place of the level, so they all get the shortest countdown (81). The rotate would otherwise wrap the high bits of the level round into the result.
|
|||||||||||||||||||||||||||||||||||||||
| Handler_Pickups_ForceMaximumLevel | 40959 | LD A,255 | A=255. | ||||||||||||||||||||||||||||||||||||
| 40961 | RET | Return. | |||||||||||||||||||||||||||||||||||||
| Prev: 40810 | Up: Map | Next: 40962 |