Prev: 44358 Up: Map Next: 44478
44360: 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 23), 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 41730. The attribute of the sprite is taken from offset 13, 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 44360 LD (44358),IX Update the current object.
44364 XOR A Clear A.
44365 LD (41730),A No dissolve yet.
44368 CALL FetchFrameSprite Call FetchFrameSprite.
44371 PUSH DE Stash DE on the stack.
44372 CALL FindObjectScreenPosition Call FindObjectScreenPosition.
44375 POP DE Bring DE back off the stack.
44376 BIT 3,(IX+23) Jump to PrepareDraw_Colour if bit 3 of offset 23 of IX is clear.
44380 JR Z,PrepareDraw_Colour
44382 LD A,(IX+23) The second set of flags.
44385 AND %00000111 Keep the bits of A that are set in 7.
44387 INC A Advance A.
44388 LD B,A B=A.
44389 CP 8 Jump to PrepareDraw_Attributes if A is not 8.
44391 JR NZ,PrepareDraw_Attributes
44393 LD (IX+0),255 Store 255 at offset 0 of IX.
44397 RES 7,(IX+16) Reset bit 7 of offset 16 of IX.
44401 JR PrepareDraw_Colour Jump to PrepareDraw_Colour.
PrepareDraw_Attributes 44403 LD A,(IX+23) The second set of flags.
44406 AND %11110000 Keep the bits of A that are set in 240.
44408 OR B Set the bits of A that are set in B.
44409 OR %00001000 Set the bits of A that are set in 8.
44411 LD (IX+23),A Write the second set of flags.
44414 LD A,B A=B.
44415 OR %10000000 Set the bits of A that are set in 128.
44417 LD (41730),A The dissolve step of the explosion.
PrepareDraw_Colour 44420 LD A,(IX+16) The flags.
44423 LD (23601),A Update the contact flags.
44426 BIT 7,A Return if bit 7 of A is clear.
44428 RET Z
44429 LD C,(IX+13) The attribute.
44432 LD A,(39524) The frame counter.
44435 AND %00000001 Keep the bits of A that are set in 1.
44437 JR Z,PrepareDraw_Colour2 Jump to PrepareDraw_Colour2 if the zero flag is set.
44439 LD A,C A=C.
44440 AND %00001000 Keep the bits of A that are set in 8.
44442 ADD A,A Double A.
44443 ADD A,A Double A.
44444 ADD A,A Double A.
44445 LD B,A B=A.
44446 LD A,C A=C.
44447 AND %00000111 Keep the bits of A that are set in 7.
44449 JR PrepareDraw_Attribute Jump to PrepareDraw_Attribute.
PrepareDraw_Colour2 44451 LD A,C A=C.
44452 AND %01110000 Keep the bits of A that are set in 112.
44454 SRL A Shift A right.
44456 SRL A Shift A right.
44458 SRL A Shift A right.
44460 SRL A Shift A right.
44462 LD B,A B=A.
44463 LD A,C A=C.
44464 AND %10000000 Keep the bits of A that are set in 128.
44466 SRL A Shift A right.
PrepareDraw_Attribute 44468 OR B Set the bits of A that are set in B.
44469 LD (44803),A The attribute of the sprite.
44472 CALL ClipSecondSprite Call ClipSecondSprite.
44475 JP SelectDrawSprite Jump to SelectDrawSprite.
Prev: 44358 Up: Map Next: 44478