Prev: CE85 Up: Map Next: CF85
CEAB: Draw Changed Objects
Used by the routine at RunGame.
Updates the playing area for the objects that have changed. First the sprites of the objects that moved are wiped out of the screen buffer: for each object in the list at ObjectsToDrawList that is flagged to be wiped, the area covered by the old and the new position of its sprite is cleared, and the area is kept on the stack. Then the objects are drawn in order and the objects that the player is carrying are shown. Last, each of the areas that were kept is copied from the buffer to the screen. When the panel is to be drawn again, the whole screen is going to be drawn, so none of the areas are wiped.
Wipe each flagged sprite, unless the panel is to be drawn again.
DrawChangedObjects CEAB XOR A Write 00 to WipedAreaCount.
CEAC LD ($5B08),A
CEAF PUSH IX Stash IX on the stack.
CEB1 LD A,($5B17) Fetch RedrawPanelFlag.
CEB4 AND A Jump to DrawChangedObjects_Draw if it is not zero.
CEB5 JP NZ,DrawChangedObjects_Draw
CEB8 LD HL,$C745 Point HL at ObjectsToDrawList.
CEBB LD ($5B2B),HL Set DrawingListPointer.
DrawChangedObjects_Wipe CEBE LD HL,($5B2B) Fetch DrawingListPointer.
CEC1 LD A,(HL) Fetch the index of the object.
CEC2 INC HL Increment HL.
CEC3 LD ($5B2B),HL Set DrawingListPointer.
CEC6 CP $FF Jump to DrawChangedObjects_Draw if it is FF.
CEC8 JP Z,DrawChangedObjects_Draw
CECB CALL FindObjectAddress Call FindObjectAddress.
CECE PUSH HL Copy HL to IX (using the stack).
CECF POP IX
CED1 BIT 5,(IX+$07) Jump to DrawChangedObjects_Wipe if the object is not flagged to be wiped.
CED5 JR Z,DrawChangedObjects_Wipe
CED7 RES 5,(IX+$07) Reset bit 5 of the flags.
The left edge of the area is the lower of the old and the new pixel x position. The width is worked out in bytes of the screen from there to the higher of the old and the new right edge.
CEDB LD A,(IX+$1A) Subtract the old pixel x from the new.
CEDE SUB (IX+$1E)
CEE1 JP C,DrawChangedObjects_Left Jump to DrawChangedObjects_Left if carry is set.
CEE4 LD C,(IX+$1E) Copy the old pixel x to C.
DrawChangedObjects_Width CEE7 LD A,(IX+$1E) Fetch the old pixel x position.
CEEA RRCA Divide it by eight.
CEEB RRCA
CEEC RRCA
CEED AND %00011111 Keep bits 0 to 4.
CEEF ADD A,(IX+$1C) Add the old width in bytes.
CEF2 LD E,A Copy it to E.
CEF3 LD A,(IX+$1A) Fetch the new pixel x position.
CEF6 RRCA Divide it by eight.
CEF7 RRCA
CEF8 RRCA
CEF9 AND %00011111 Keep bits 0 to 4.
CEFB ADD A,(IX+$18) Add the new width in bytes.
CEFE CP E Jump to DrawChangedObjects_WidthFetchLeft if it is lower than E.
CEFF JR C,DrawChangedObjects_WidthFetchLeft
CF01 LD E,A Copy it to E.
DrawChangedObjects_WidthFetchLeft CF02 LD A,C Fetch C.
CF03 RRCA Divide it by eight.
CF04 RRCA
CF05 RRCA
CF06 AND %00011111 Keep bits 0 to 4.
CF08 LD B,A Copy it to B.
CF09 LD A,E Fetch E.
CF0A SUB B Subtract B.
CF0B LD H,A Copy it to H.
The bottom edge of the area is the lower of the old and the new pixel y position. The height is worked out from there to the higher of the old and the new top edge.
CF0C LD A,(IX+$1B) Fetch the new pixel y position.
CF0F SUB (IX+$1F) Subtract the old pixel y.
CF12 JR C,DrawChangedObjects_Bottom Jump to DrawChangedObjects_Bottom if carry is set.
CF14 LD B,(IX+$1F) Copy the old pixel y to B.
DrawChangedObjects_Height CF17 LD A,(IX+$1F) Fetch the old pixel y position.
CF1A ADD A,(IX+$1D) Add the old height in lines.
CF1D LD E,A Copy it to E.
CF1E LD A,(IX+$1B) Fetch the new pixel y position.
CF21 ADD A,(IX+$19) Add the new height in lines.
CF24 CP E Compare it with E.
CF25 JR NC,DrawChangedObjects_HeightTakeBottom Jump to DrawChangedObjects_HeightTakeBottom if it is E or more.
CF27 LD A,E Fetch E.
DrawChangedObjects_HeightTakeBottom CF28 SUB B Subtract B.
CF29 LD L,A Copy it to L.
CF2A LD A,B Fetch B.
CF2B CP $C0 Jump to DrawChangedObjects_Wipe if it is C0 or more.
CF2D JR NC,DrawChangedObjects_Wipe
CF2F ADD A,L Add L.
CF30 SUB $C0 Subtract C0.
CF32 JR C,DrawChangedObjects_Keep Jump to DrawChangedObjects_Keep if carry is set.
CF34 NEG Negate A.
CF36 ADD A,L Add L.
CF37 LD L,A Copy it to L.
Wipe the area and keep it on the stack.
DrawChangedObjects_Keep CF38 CALL CalculateScreenAddress Call CalculateScreenAddress.
CF3B CALL CalculateBufferAddress Call CalculateBufferAddress.
CF3E LD A,L Exchange L and C.
CF3F LD L,C
CF40 LD C,A
CF41 LD A,H Exchange H and B.
CF42 LD H,B
CF43 LD B,A
CF44 LD A,($5B08) Fetch WipedAreaCount.
CF47 INC A Increment A.
CF48 LD ($5B08),A Set WipedAreaCount.
CF4B PUSH BC Stash BC, DE and HL on the stack.
CF4C PUSH DE
CF4D PUSH HL
CF4E XOR A Set A to 00.
CF4F CALL FillWindow Call FillWindow.
CF52 JP DrawChangedObjects_Wipe Jump to DrawChangedObjects_Wipe.
DrawChangedObjects_Left CF55 LD C,(IX+$1A) Copy the new pixel x to C.
CF58 JR DrawChangedObjects_Width Jump to DrawChangedObjects_Width.
DrawChangedObjects_Bottom CF5A LD B,(IX+$1B) Copy the new pixel y to B.
CF5D JR DrawChangedObjects_Height Jump to DrawChangedObjects_Height.
Draw the objects, then copy the wiped areas to the screen.
DrawChangedObjects_Draw CF5F CALL DrawObjectsInOrder Call DrawObjectsInOrder.
CF62 CALL DisplayObjectsCarried Call DisplayObjectsCarried.
CF65 LD HL,$5B08 Point HL at WipedAreaCount.
CF68 LD A,($5B1E) Fetch ObjectsDrawn.
CF6B ADD A,(HL) Add WipedAreaCount.
CF6C LD ($5B1E),A Set ObjectsDrawn.
DrawChangedObjects_Copy CF6F LD HL,$5B08 Point HL at WipedAreaCount.
CF72 LD A,(HL) Jump to DrawChangedObjects_Finish if it is zero.
CF73 AND A
CF74 JR Z,DrawChangedObjects_Finish
CF76 DEC (HL) Decrement WipedAreaCount.
CF77 POP HL Restore HL, DE and BC from the stack.
CF78 POP DE
CF79 POP BC
CF7A LD A,B Exchange B and C.
CF7B LD B,C
CF7C LD C,A
CF7D CALL CopyBlockToScreen Call CopyBlockToScreen.
CF80 JR DrawChangedObjects_Copy Jump to DrawChangedObjects_Copy.
DrawChangedObjects_Finish CF82 POP IX Restore IX from the stack.
CF84 RET Return.
View the equivalent code in;
Prev: CE85 Up: Map Next: CF85