Prev: 41500 Up: Map Next: 41524
41507: Read Sprite Header
Used by the routines at ClipSecondSprite and ClipFirstSprite.
Reads the width and the number of rows from the header of a sprite and works out which of the routines that draw sprites to use. Sprites that are not aligned to a byte (a horizontal position that has bits 1 and 2 not both clear) need a routine that shifts the sprite, which are the first five entries of the tables at EraseRoutineTable and DrawRoutineTable.
Input
DE Address of the sprite
L Horizontal position
Output
B Number of rows
C Index of the routine that draws the sprite
DE Address of the first row of data
H Width in bytes
ReadSpriteHeader 41507 LD A,(DE) Fetch the width.
41508 LD H,A Store it in H.
41509 LD C,A Copy it to C.
41510 DEC C Take one off to get the index for a sprite that must be shifted.
41511 INC DE Move on to the number of rows.
41512 LD A,(DE) Fetch it.
41513 LD B,A Store it in B.
41514 INC DE Move on to the data.
41515 LD A,L Fetch the horizontal position.
41516 AND %00000110 Only bits 1 and 2.
41518 RET NZ Return if the sprite must be shifted.
41519 LD A,5 Add five to the index for a sprite that is aligned.
41521 ADD A,C Store it in C.
41522 LD C,A
41523 RET Return.
Prev: 41500 Up: Map Next: 41524