![]() |
Routines |
| Prev: A43B | Up: Map | Next: A493 |
|
Works out where an actor will be after it has moved by its velocities (see IX+06 and IX+07), keeping it on the screen. The velocities are in sixteenths of a pixel.
The X position is kept between 00 and 0100 minus the width (held in Actor_Width) and the Y position between 27 and BF.
|
||||||||||||||||
| CalculateNewPosition | A44B | LD B,$00 | Clear the edge flags in B. | |||||||||||||
| A44D | LD A,($96AD) | Fetch the width of the actor from Actor_Width. | ||||||||||||||
| A450 | LD C,A | Stash the width in C. | ||||||||||||||
|
Work out the new X position.
|
||||||||||||||||
| A451 | LD A,(IX+$06) | Fetch the X velocity of the actor. | ||||||||||||||
| A454 | CALL GetWholePixels | Convert the X velocity to pixels. | ||||||||||||||
| A457 | JP M,CalculateNewPosition_Left | Jump to CalculateNewPosition_Left if the actor is moving left. | ||||||||||||||
| A45A | ADD A,(IX+$03) | Add the X position of the actor. | ||||||||||||||
| A45D | LD E,A | Stash the new X position in E. | ||||||||||||||
| A45E | ADD A,C | Add the width of the actor. | ||||||||||||||
| A45F | JR C,CalculateNewPosition_HitRight | Jump to CalculateNewPosition_HitRight if the actor would go off the right edge of the screen. | ||||||||||||||
|
Work out the new Y position.
|
||||||||||||||||
| CalculateNewPosition_Y | A461 | LD A,(IX+$07) | Fetch the Y velocity of the actor. | |||||||||||||
| A464 | CALL GetWholePixels | Convert the Y velocity to pixels. | ||||||||||||||
| A467 | JP M,CalculateNewPosition_Up | Jump to CalculateNewPosition_Up if the actor is moving up. | ||||||||||||||
| A46A | ADD A,(IX+$04) | Add the Y position of the actor. | ||||||||||||||
| A46D | LD D,A | Stash the new Y position in D. | ||||||||||||||
| A46E | CP $BF | Return if the actor is not off the bottom of the screen (BF). | ||||||||||||||
| A470 | RET C | |||||||||||||||
| A471 | LD D,$BF | Limit the Y position to the bottom of the screen (BF). | ||||||||||||||
| CalculateNewPosition_HitY | A473 | SET 1,B | Set the top or bottom edge flag (bit 1). | |||||||||||||
| A475 | RET | Return. | ||||||||||||||
|
The actor hit the right of the screen.
|
||||||||||||||||
| CalculateNewPosition_HitRight | A476 | LD A,C | Fetch the width of the actor. | |||||||||||||
| A477 | NEG | Negate it to give the X position which puts the actor against the right of the screen. | ||||||||||||||
| A479 | LD E,A | Stash it in E as the new X position. | ||||||||||||||
| A47A | SET 0,B | Set the left or right edge flag (bit 0). | ||||||||||||||
| A47C | RET | Return. | ||||||||||||||
|
The actor is moving left.
|
||||||||||||||||
| CalculateNewPosition_Left | A47D | ADD A,(IX+$03) | Add the X position of the actor. | |||||||||||||
| A480 | LD E,A | Stash the new X position in E. | ||||||||||||||
| A481 | JR C,CalculateNewPosition_Y | Jump to CalculateNewPosition_Y if the actor is still on the screen. | ||||||||||||||
| A483 | LD E,$00 | Limit the X position to the left edge of the screen (00). | ||||||||||||||
| A485 | SET 0,B | Set the left or right edge flag (bit 0). | ||||||||||||||
| A487 | RET | Return. | ||||||||||||||
|
The actor is moving up.
|
||||||||||||||||
| CalculateNewPosition_Up | A488 | ADD A,(IX+$04) | Add the Y position of the actor. | |||||||||||||
| A48B | LD D,A | Stash the new Y position in D. | ||||||||||||||
| A48C | CP $27 | Return if the actor is not off the top of the screen (the Y position is 27 or more). | ||||||||||||||
| A48E | RET NC | |||||||||||||||
| A48F | LD D,$27 | Limit the Y position to the top of the screen (27). | ||||||||||||||
| A491 | JR CalculateNewPosition_HitY | Jump to CalculateNewPosition_HitY to set the top or bottom edge flag. | ||||||||||||||
| Prev: A43B | Up: Map | Next: A493 |