Prev: A1EA Up: Map Next: A21C
A1FB: Clip Sprite Vertically
Used by the routines at ClipSecondSprite and ClipFirstSprite.
Clips a sprite so that it lies between 17 and B7 on the vertical axis, which is the playfield. The position of a sprite is its bottom row and its rows go up from there, so rows below the playfield are skipped by moving on the address of the data, and rows above it are not drawn.
Input
A Vertical position
B Number of rows
DE Address of the first row of data
H Width in bytes
Output
B Number of rows to draw
DE Address of the first row of data to draw
L Vertical position of the first row to draw
ClipSpriteVertically A1FB LD L,A Store the vertical position.
A1FC SUB $17 Subtract 17, the top of the playfield.
A1FE SUB B Subtract the number of rows.
A1FF JR NC,ClipSpriteVertically_Top Jump to ClipSpriteVertically_Top if the sprite does not go past the top.
A201 LD A,L Fetch the vertical position.
A202 SUB $17 Subtract 17 to get the number of rows that fit.
A204 LD B,A Store it as the number of rows.
A205 RET Return.
ClipSpriteVertically_Top A206 LD A,L Fetch the vertical position.
A207 SUB $B7 Subtract B7, the bottom of the playfield.
A209 RET Z Return if the sprite starts exactly at the bottom.
A20A RET C Return if the sprite starts above the bottom.
A20B LD L,A Store the number of rows that are below the bottom.
A20C LD A,B Fetch the number of rows.
A20D SUB L Take off the rows that are below the bottom.
A20E LD B,A Store it.
A20F XOR A Clear A.
ClipSpriteVertically_Skip A210 ADD A,H Add the width for each row that is below the bottom.
A211 DEC L Count down.
A212 JR NZ,ClipSpriteVertically_Skip Loop back to ClipSpriteVertically_Skip for each row.
A214 EX DE,HL Put the address of the data in HL.
A215 CALL AddAToHL Skip the data for the rows below the bottom.
A218 EX DE,HL Put the address back in DE.
A219 LD L,$B7 Start at the bottom of the playfield.
A21B RET Return.
Prev: A1EA Up: Map Next: A21C