Prev: AD46 Up: Map Next: ADBE
AD48: Prepare Draw
Used by the routines at ProcessObjectFlags, UpdateObject and UpdateMapObjects.
Sets up the drawing of the new sprite of an object. Finds the sprite from its type and state, and its position on the screen (which frees the slot if it is off screen). If the object is exploding (bit 3 of offset 17), the explosion count in the bottom three bits is increased and the slot is freed when it reaches eight; the count is also used as the dissolve step in A302. The attribute of the sprite is taken from offset 0D, which holds two colours; the choice between them depends on bit 0 of the frame counter at FrameCounter.
Input
IX Address of the object
PrepareDraw AD48 LD ($AD46),IX Update the current object.
AD4C XOR A Clear A.
AD4D LD ($A302),A No dissolve yet.
AD50 CALL FetchFrameSprite Call FetchFrameSprite.
AD53 PUSH DE Stash DE on the stack.
AD54 CALL FindObjectScreenPosition Call FindObjectScreenPosition.
AD57 POP DE Bring DE back off the stack.
AD58 BIT 3,(IX+$17) Jump to PrepareDraw_Colour if bit 3 of offset 17 of IX is clear.
AD5C JR Z,PrepareDraw_Colour
AD5E LD A,(IX+$17) The second set of flags.
AD61 AND %00000111 Keep the bits of A that are set in 07.
AD63 INC A Advance A.
AD64 LD B,A B=A.
AD65 CP $08 Jump to PrepareDraw_Attributes if A is not 08.
AD67 JR NZ,PrepareDraw_Attributes
AD69 LD (IX+$00),$FF Store FF at offset 00 of IX.
AD6D RES 7,(IX+$10) Reset bit 7 of offset 10 of IX.
AD71 JR PrepareDraw_Colour Jump to PrepareDraw_Colour.
PrepareDraw_Attributes AD73 LD A,(IX+$17) The second set of flags.
AD76 AND %11110000 Keep the bits of A that are set in F0.
AD78 OR B Set the bits of A that are set in B.
AD79 OR %00001000 Set the bits of A that are set in 08.
AD7B LD (IX+$17),A Write the second set of flags.
AD7E LD A,B A=B.
AD7F OR %10000000 Set the bits of A that are set in 80.
AD81 LD ($A302),A The dissolve step of the explosion.
PrepareDraw_Colour AD84 LD A,(IX+$10) The flags.
AD87 LD ($5C31),A Update the contact flags.
AD8A BIT 7,A Return if bit 7 of A is clear.
AD8C RET Z
AD8D LD C,(IX+$0D) The attribute.
AD90 LD A,($9A64) The frame counter.
AD93 AND %00000001 Keep the bits of A that are set in 01.
AD95 JR Z,PrepareDraw_Colour2 Jump to PrepareDraw_Colour2 if the zero flag is set.
AD97 LD A,C A=C.
AD98 AND %00001000 Keep the bits of A that are set in 08.
AD9A ADD A,A Double A.
AD9B ADD A,A Double A.
AD9C ADD A,A Double A.
AD9D LD B,A B=A.
AD9E LD A,C A=C.
AD9F AND %00000111 Keep the bits of A that are set in 07.
ADA1 JR PrepareDraw_Attribute Jump to PrepareDraw_Attribute.
PrepareDraw_Colour2 ADA3 LD A,C A=C.
ADA4 AND %01110000 Keep the bits of A that are set in 70.
ADA6 SRL A Shift A right.
ADA8 SRL A Shift A right.
ADAA SRL A Shift A right.
ADAC SRL A Shift A right.
ADAE LD B,A B=A.
ADAF LD A,C A=C.
ADB0 AND %10000000 Keep the bits of A that are set in 80.
ADB2 SRL A Shift A right.
PrepareDraw_Attribute ADB4 OR B Set the bits of A that are set in B.
ADB5 LD ($AF03),A The attribute of the sprite.
ADB8 CALL ClipSecondSprite Call ClipSecondSprite.
ADBB JP SelectDrawSprite Jump to SelectDrawSprite.
Prev: AD46 Up: Map Next: ADBE