![]() |
Routines |
| Prev: B29A | Up: Map | Next: B2EE |
|
Used by the routines at DrawObject, CalculateSpriteSize, DropObject, CreateCreature and RunHelperSource.
Works out the pixel position of an object on the screen from its x, y and z positions. The pixel x position is x + y - 80 and the pixel y position (from the bottom of the screen) is half of y - x + 80, plus z, less 68, each with the adjustments of the object added. The pixel x position is set to zero if it would be below zero.
|
||||||||||||
|
Work out the pixel x position.
|
||||||||||||
| CalculatePixelCoordinates | B2C5 | LD A,(IX+$01) | Fetch the x position of the object. | |||||||||
| B2C8 | ADD A,(IX+$02) | Add the y position. | ||||||||||
| B2CB | SUB $80 | Subtract 80 to centre the room on the screen. | ||||||||||
| B2CD | ADD A,(IX+$12) | Add the horizontal sprite offset. | ||||||||||
| B2D0 | JR C,CalculatePixelCoordinates_SetX | Jump to CalculatePixelCoordinates_SetX if the result is not below zero. | ||||||||||
| B2D2 | XOR A | Set A to 00. | ||||||||||
| CalculatePixelCoordinates_SetX | B2D3 | LD (IX+$1A),A | Write the screen x co-ordinate of the object. | |||||||||
|
Work out the pixel y position.
|
||||||||||||
| B2D6 | LD A,(IX+$02) | Fetch the y position of the object. | ||||||||||
| B2D9 | SUB (IX+$01) | Subtract the x position. | ||||||||||
| B2DC | ADD A,$80 | Add 80. | ||||||||||
| B2DE | SRL A | Halve it. | ||||||||||
| B2E0 | ADD A,(IX+$03) | Add the height of the object. | ||||||||||
| B2E3 | SUB $68 | Subtract 68 to put the floor at the bottom of the screen. | ||||||||||
| B2E5 | ADD A,(IX+$13) | Add the vertical sprite offset. | ||||||||||
| B2E8 | LD (IX+$1B),A | Write the screen y co-ordinate of the object. | ||||||||||
| B2EB | CP $C0 | Compare it with C0, the number of lines on the screen. | ||||||||||
| B2ED | RET | Return, with the carry flag set when the sprite is on the screen. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: B29A | Up: Map | Next: B2EE |