![]() |
Routines |
| Prev: 6BC8 | Up: Map | Next: 6C39 |
|
Used by the routines at Handler_RedBird, UpdateRedBirdMovement, Direction_Jump_Table, Randomise_Butterfly_Position and Randomise_Position_Loop.
Validates a proposed position (B=Y, C=X) against the boundary table pointed to by *Pointer_RedBirdFlightpathData. Used by the red bird (UpdateRedBirdMovement), helicopter (Handler_Helicopter) and UFO (Handler_UFO); each caller ensures Pointer_RedBirdFlightpathData points to the appropriate boundary data. Scans through the table for a region containing the position.
Each entry is 04 bytes: Y-min, Y-max, X-min, X-max. If a valid region is found, the position is stored to *IX and carry is clear. If no valid region is found (entry is 00), carry is set.
|
||||||||||||||||
| Validate_Position | 6C0C | LD HL,($6CBB) | HL=*Pointer_RedBirdFlightpathData (boundary table pointer). | |||||||||||||
| Validate_Position_Loop | 6C0F | PUSH HL | Stash the boundary pointer on the stack. | |||||||||||||
| 6C10 | LD A,(HL) | A=*HL (Y-min for this region). | ||||||||||||||
| 6C11 | OR A | Jump to Validate_Position_OutOfBounds if A is 00 (end of boundary data). | ||||||||||||||
| 6C12 | JR Z,Validate_Position_OutOfBounds | |||||||||||||||
|
Check Y-min <= B.
|
||||||||||||||||
| 6C14 | CP B | Jump to Validate_Position_Next if B is less than Y-min. | ||||||||||||||
| 6C15 | JR NC,Validate_Position_Next | |||||||||||||||
|
Check B <= Y-max.
|
||||||||||||||||
| 6C17 | INC HL | Advance to Y-max. | ||||||||||||||
| 6C18 | LD A,(HL) | A=*HL. | ||||||||||||||
| 6C19 | CP B | Jump to Validate_Position_Next if B is greater than Y-max. | ||||||||||||||
| 6C1A | JR C,Validate_Position_Next | |||||||||||||||
|
Check X-min <= C.
|
||||||||||||||||
| 6C1C | INC HL | Advance to X-min. | ||||||||||||||
| 6C1D | LD A,(HL) | A=*HL. | ||||||||||||||
| 6C1E | CP C | Jump to Validate_Position_Next if C is less than X-min. | ||||||||||||||
| 6C1F | JR NC,Validate_Position_Next | |||||||||||||||
|
Check C <= X-max.
|
||||||||||||||||
| 6C21 | INC HL | Advance to X-max. | ||||||||||||||
| 6C22 | LD A,(HL) | A=*HL. | ||||||||||||||
| 6C23 | CP C | Jump to Validate_Position_Next if C is greater than X-max. | ||||||||||||||
| 6C24 | JR C,Validate_Position_Next | |||||||||||||||
|
Position is within this region so store it and return success.
|
||||||||||||||||
| 6C26 | LD (IX+$00),C | Write C to *IX+00 (X position). | ||||||||||||||
| 6C29 | LD (IX+$01),B | Write B to *IX+01 (Y position). | ||||||||||||||
| 6C2C | POP HL | Restore the boundary pointer from the stack. | ||||||||||||||
| 6C2D | AND A | Clear carry (valid position). | ||||||||||||||
| 6C2E | RET | Return. | ||||||||||||||
|
Position is outside this region so try the next one.
|
||||||||||||||||
| Validate_Position_Next | 6C2F | POP HL | Restore the boundary pointer from the stack. | |||||||||||||
| 6C30 | INC HL | Advance HL by 04 (next boundary entry). | ||||||||||||||
| 6C31 | INC HL | |||||||||||||||
| 6C32 | INC HL | |||||||||||||||
| 6C33 | INC HL | |||||||||||||||
| 6C34 | JR Validate_Position_Loop | Jump to Validate_Position_Loop. | ||||||||||||||
|
End of boundary data. No valid region found.
|
||||||||||||||||
| Validate_Position_OutOfBounds | 6C36 | POP HL | Restore the boundary pointer from the stack. | |||||||||||||
| 6C37 | SCF | Set carry (out of bounds). | ||||||||||||||
| 6C38 | RET | Return. | ||||||||||||||
| Prev: 6BC8 | Up: Map | Next: 6C39 |