![]() |
Routines |
| Prev: 25180 | Up: Map | Next: 25368 |
|
Used by the routine at UpdateRadar.
Finds a cup to show on the radar. Each of the 8 cups in CupTable is checked in turn: if the map entry still has the cup sprite ID (32) and the cup is less than 12 cells (of 32 map units) from the player horizontally, then it is placed on the radar by LocateRadarBlip. Only the first such cup is used. If there is no cup then the blip is hidden.
|
||||||||
|
Find the player's horizontal position in cells.
|
||||||||
| CollisionCup | 25306 | LD HL,(24069) | Fetch the player's X position on the map from PlayerMapPosition. | |||||
| 25309 | SLA L | Double the value so it matches the scale used by the radar. | ||||||
| 25311 | RL H | |||||||
| 25313 | CALL MultiplyHLByFour | Call MultiplyHLByFour to multiply the position by 4 which leaves the position in cells in H. | ||||||
| 25316 | LD C,H | Keep the player's X position in cells in C. | ||||||
| 25317 | LD HL,29215 | Point HL at the table of cup map addresses (CupTable). | ||||||
| 25320 | LD B,8 | Set the cup counter to 8 one for each cup. | ||||||
|
Fetch the address of the cup from CupTable.
|
||||||||
| CollisionCup_Loop | 25322 | LD E,(HL) | Fetch the low byte of the map address of this cup. | |||||
| 25323 | INC HL | Move on to the high byte. | ||||||
| 25324 | LD D,(HL) | Fetch the high byte of the map address of this cup. | ||||||
| 25325 | INC HL | Move on to the next cup in the table. | ||||||
|
Check this is still a valid cup (that it hasn't been collected already).
|
||||||||
| 25326 | INC DE | Point DE at the sprite ID of the map entry. | ||||||
| 25327 | INC DE | |||||||
| 25328 | LD A,(DE) | If this is not a cup (the sprite ID is not 32) then jump to CollisionCup_Next. | ||||||
| 25329 | CP 32 | |||||||
| 25331 | JR NZ,CollisionCup_Next | |||||||
|
This is still a valid cup, so process it.
|
||||||||
| 25333 | DEC DE | Point DE back at the start of the map entry. | ||||||
| 25334 | DEC DE | |||||||
| 25335 | LD A,(DE) | Fetch the X position of the cup. | ||||||
| 25336 | SUB C | Subtract the player's X position to give the horizontal distance. | ||||||
| 25337 | JR NC,CollisionCup_Test_X | Make the distance positive. | ||||||
| 25339 | NEG | |||||||
| CollisionCup_Test_X | 25341 | CP 12 | If the cup is less than 12 cells away then jump to CollisionCup_Test_Y. | |||||
| 25343 | JR C,CollisionCup_Test_Y | |||||||
| CollisionCup_Next | 25345 | DJNZ CollisionCup_Loop | Decrease the cup counter by one and loop back to CollisionCup_Loop until all of the cups have been checked. | |||||
| 25347 | JP HideRadarBlip | There is no cup in range so jump to HideRadarBlip to hide the blip. | ||||||
|
Convert the position of the cup to the same scale used by LocateRadarBlip.
|
||||||||
| CollisionCup_Test_Y | 25350 | LD A,(DE) | Fetch the X position of the cup. | |||||
| 25351 | INC DE | Point DE at the Y position of the cup. | ||||||
| 25352 | LD H,A | Keep the X position of the cup in H. | ||||||
| 25353 | LD A,(DE) | Fetch the Y position of the cup. | ||||||
| 25354 | LD D,A | Keep the Y position of the cup in D. | ||||||
| 25355 | CALL ScaleValue_DivideByEight | Call ScaleValue_DivideByEight to set DE to the cup Y position multiplied by 32. | ||||||
| 25358 | EX DE,HL | Swap the DE and HL registers. | ||||||
| 25359 | CALL ScaleValue | Call ScaleValue to set DE to the cup X position multiplied by 64. | ||||||
| 25362 | EX DE,HL | Swap the DE and HL registers. | ||||||
| 25363 | LD B,H | Move the high byte of the doubled X position into B. | ||||||
| 25364 | LD C,L | Move the low byte of the doubled X position into C. | ||||||
| 25365 | JP LocateRadarBlip | Jump to LocateRadarBlip to place the blip (BC is the cup X position and DE is the cup Y position, both doubled). | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: 25180 | Up: Map | Next: 25368 |