Prev: B939 Up: Map Next: B9A9
B969: Prepare Draw 2 Byte Sprite
Used by the routines at DrawEntity and DisplayEntity.
Gets the registers ready to draw the sprite of the entity that IX points at, at its current position.
It does what PrepDraw23 does for the old sprite, but it uses the position and the sprite of the entity, changes the operand of the jump at DrawNewEntityRow_0 (used by the code at DrawNewEntityRow) and stores the number of rows in New_Sprite_Row_Count and New_Sprite_Height. The number of character cells that the sprite covers in each row (one more than the width if the sprite is not aligned to a character boundary) is stored in New_Sprite_Width.
Input
IX Actor record
Output
B Page of the shift table
C 00
DE Address of the pixel data
HL Screen address of the bottom row
PrepDraw2 B969 CALL FetchActorSprite Fetch the address of the sprite data in DE.
B96C LD L,(IX+$03) Fetch the X position of the entity into L.
B96F LD H,(IX+$04) Fetch the Y position of the entity into H.
B972 LD A,L A=L.
B973 DEC A Subtract one.
B974 RLCA Multiply by two (rotate left).
B975 AND %00001110 Keep only bits 1-3.
B977 OR %11110000 Set bits 4-7 to point at the pages F0 to FF.
B979 LD B,A Store the page of the shift table in B.
B97A LD A,L A=L.
B97B AND %00000111 Keep only the pixel offset (bits 0-2).
B97D LD A,(DE) Fetch the width of the sprite in bytes.
B97E JR Z,PrepDraw2_StoreCells Jump to PrepDraw2_StoreCells if the sprite starts on a character boundary.
B980 INC A Add one for the extra cell that the shifted sprite needs.
PrepDraw2_StoreCells B981 LD ($96A6),A Write the number of cells in each row to New_Sprite_Width.
B984 LD A,(DE) Fetch the width of the sprite in bytes.
B985 INC DE Move on to the height of the sprite.
B986 NEG Negate the width.
B988 AND %00000111 Keep only bits 0-2.
B98A ADD A,A Multiply by four.
B98B ADD A,A
B98C LD C,A Store the result in C.
B98D ADD A,A Multiply by two.
B98E ADD A,C Add the result so that it is multiplied by twelve (the size of the code for one byte of the row).
B98F LD C,A Store the offset in C.
B990 LD A,L A=L.
B991 AND %00000111 Keep only the pixel offset (bits 0-2).
B993 LD A,C Fetch the offset.
B994 JR NZ,PrepDraw2_SetJump Jump to PrepDraw2_SetJump if the sprite does not start on a character boundary.
B996 ADD A,$06 Add 06 to the offset to skip the first six bytes of the code for the first byte of the row, as no cell to the left is needed.
PrepDraw2_SetJump B998 LD ($BA92),A Change the operand of the jump at DrawNewEntityRow_0.
B99B LD A,(DE) Fetch the height of the sprite.
B99C INC DE Move on to the pixel data.
B99D LD ($96A4),A Write the number of rows of the new sprite to New_Sprite_Row_Count.
B9A0 LD ($96A5),A Write the height of the sprite to New_Sprite_Height.
B9A3 CALL ScreenAddress Convert the position into the screen address.
B9A6 LD C,$00 C=00.
B9A8 RET Return.
View the equivalent code in;
Prev: B939 Up: Map Next: B9A9