![]() |
Routines |
| Prev: 52869 | Up: Map | Next: 53125 |
|
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 | 52907 | XOR A | Write 0 to WipedAreaCount. | |
| 52908 | LD (23304),A | |||
| 52911 | PUSH IX | Stash IX on the stack. | ||
| 52913 | LD A,(23319) | Fetch RedrawPanelFlag. | ||
| 52916 | AND A | Jump to DrawChangedObjects_Draw if it is not zero. | ||
| 52917 | JP NZ,DrawChangedObjects_Draw | |||
| 52920 | LD HL,51013 | Point HL at ObjectsToDrawList. | ||
| 52923 | LD (23339),HL | Set DrawingListPointer. | ||
| DrawChangedObjects_Wipe | 52926 | LD HL,(23339) | Fetch DrawingListPointer. | |
| 52929 | LD A,(HL) | Fetch the index of the object. | ||
| 52930 | INC HL | Increment HL. | ||
| 52931 | LD (23339),HL | Set DrawingListPointer. | ||
| 52934 | CP 255 | Jump to DrawChangedObjects_Draw if it is 255. | ||
| 52936 | JP Z,DrawChangedObjects_Draw | |||
| 52939 | CALL FindObjectAddress | Call FindObjectAddress. | ||
| 52942 | PUSH HL | Copy HL to IX (using the stack). | ||
| 52943 | POP IX | |||
| 52945 | BIT 5,(IX+7) | Jump to DrawChangedObjects_Wipe if the object is not flagged to be wiped. | ||
| 52949 | JR Z,DrawChangedObjects_Wipe | |||
| 52951 | RES 5,(IX+7) | 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.
|
||||
| 52955 | LD A,(IX+26) | Subtract the old pixel x from the new. | ||
| 52958 | SUB (IX+30) | |||
| 52961 | JP C,DrawChangedObjects_Left | Jump to DrawChangedObjects_Left if carry is set. | ||
| 52964 | LD C,(IX+30) | Copy the old pixel x to C. | ||
| DrawChangedObjects_Width | 52967 | LD A,(IX+30) | Fetch the old pixel x position. | |
| 52970 | RRCA | Divide it by eight. | ||
| 52971 | RRCA | |||
| 52972 | RRCA | |||
| 52973 | AND %00011111 | Keep bits 0 to 4. | ||
| 52975 | ADD A,(IX+28) | Add the old width in bytes. | ||
| 52978 | LD E,A | Copy it to E. | ||
| 52979 | LD A,(IX+26) | Fetch the new pixel x position. | ||
| 52982 | RRCA | Divide it by eight. | ||
| 52983 | RRCA | |||
| 52984 | RRCA | |||
| 52985 | AND %00011111 | Keep bits 0 to 4. | ||
| 52987 | ADD A,(IX+24) | Add the new width in bytes. | ||
| 52990 | CP E | Jump to DrawChangedObjects_WidthFetchLeft if it is lower than E. | ||
| 52991 | JR C,DrawChangedObjects_WidthFetchLeft | |||
| 52993 | LD E,A | Copy it to E. | ||
| DrawChangedObjects_WidthFetchLeft | 52994 | LD A,C | Fetch C. | |
| 52995 | RRCA | Divide it by eight. | ||
| 52996 | RRCA | |||
| 52997 | RRCA | |||
| 52998 | AND %00011111 | Keep bits 0 to 4. | ||
| 53000 | LD B,A | Copy it to B. | ||
| 53001 | LD A,E | Fetch E. | ||
| 53002 | SUB B | Subtract B. | ||
| 53003 | 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.
|
||||
| 53004 | LD A,(IX+27) | Fetch the new pixel y position. | ||
| 53007 | SUB (IX+31) | Subtract the old pixel y. | ||
| 53010 | JR C,DrawChangedObjects_Bottom | Jump to DrawChangedObjects_Bottom if carry is set. | ||
| 53012 | LD B,(IX+31) | Copy the old pixel y to B. | ||
| DrawChangedObjects_Height | 53015 | LD A,(IX+31) | Fetch the old pixel y position. | |
| 53018 | ADD A,(IX+29) | Add the old height in lines. | ||
| 53021 | LD E,A | Copy it to E. | ||
| 53022 | LD A,(IX+27) | Fetch the new pixel y position. | ||
| 53025 | ADD A,(IX+25) | Add the new height in lines. | ||
| 53028 | CP E | Compare it with E. | ||
| 53029 | JR NC,DrawChangedObjects_HeightTakeBottom | Jump to DrawChangedObjects_HeightTakeBottom if it is E or more. | ||
| 53031 | LD A,E | Fetch E. | ||
| DrawChangedObjects_HeightTakeBottom | 53032 | SUB B | Subtract B. | |
| 53033 | LD L,A | Copy it to L. | ||
| 53034 | LD A,B | Fetch B. | ||
| 53035 | CP 192 | Jump to DrawChangedObjects_Wipe if it is 192 or more. | ||
| 53037 | JR NC,DrawChangedObjects_Wipe | |||
| 53039 | ADD A,L | Add L. | ||
| 53040 | SUB 192 | Subtract 192. | ||
| 53042 | JR C,DrawChangedObjects_Keep | Jump to DrawChangedObjects_Keep if carry is set. | ||
| 53044 | NEG | Negate A. | ||
| 53046 | ADD A,L | Add L. | ||
| 53047 | LD L,A | Copy it to L. | ||
|
Wipe the area and keep it on the stack.
|
||||
| DrawChangedObjects_Keep | 53048 | CALL CalculateScreenAddress | Call CalculateScreenAddress. | |
| 53051 | CALL CalculateBufferAddress | Call CalculateBufferAddress. | ||
| 53054 | LD A,L | Exchange L and C. | ||
| 53055 | LD L,C | |||
| 53056 | LD C,A | |||
| 53057 | LD A,H | Exchange H and B. | ||
| 53058 | LD H,B | |||
| 53059 | LD B,A | |||
| 53060 | LD A,(23304) | Fetch WipedAreaCount. | ||
| 53063 | INC A | Increment A. | ||
| 53064 | LD (23304),A | Set WipedAreaCount. | ||
| 53067 | PUSH BC | Stash BC, DE and HL on the stack. | ||
| 53068 | PUSH DE | |||
| 53069 | PUSH HL | |||
| 53070 | XOR A | Set A to 0. | ||
| 53071 | CALL FillWindow | Call FillWindow. | ||
| 53074 | JP DrawChangedObjects_Wipe | Jump to DrawChangedObjects_Wipe. | ||
| DrawChangedObjects_Left | 53077 | LD C,(IX+26) | Copy the new pixel x to C. | |
| 53080 | JR DrawChangedObjects_Width | Jump to DrawChangedObjects_Width. | ||
| DrawChangedObjects_Bottom | 53082 | LD B,(IX+27) | Copy the new pixel y to B. | |
| 53085 | JR DrawChangedObjects_Height | Jump to DrawChangedObjects_Height. | ||
|
Draw the objects, then copy the wiped areas to the screen.
|
||||
| DrawChangedObjects_Draw | 53087 | CALL DrawObjectsInOrder | Call DrawObjectsInOrder. | |
| 53090 | CALL DisplayObjectsCarried | Call DisplayObjectsCarried. | ||
| 53093 | LD HL,23304 | Point HL at WipedAreaCount. | ||
| 53096 | LD A,(23326) | Fetch ObjectsDrawn. | ||
| 53099 | ADD A,(HL) | Add WipedAreaCount. | ||
| 53100 | LD (23326),A | Set ObjectsDrawn. | ||
| DrawChangedObjects_Copy | 53103 | LD HL,23304 | Point HL at WipedAreaCount. | |
| 53106 | LD A,(HL) | Jump to DrawChangedObjects_Finish if it is zero. | ||
| 53107 | AND A | |||
| 53108 | JR Z,DrawChangedObjects_Finish | |||
| 53110 | DEC (HL) | Decrement WipedAreaCount. | ||
| 53111 | POP HL | Restore HL, DE and BC from the stack. | ||
| 53112 | POP DE | |||
| 53113 | POP BC | |||
| 53114 | LD A,B | Exchange B and C. | ||
| 53115 | LD B,C | |||
| 53116 | LD C,A | |||
| 53117 | CALL CopyBlockToScreen | Call CopyBlockToScreen. | ||
| 53120 | JR DrawChangedObjects_Copy | Jump to DrawChangedObjects_Copy. | ||
| DrawChangedObjects_Finish | 53122 | POP IX | Restore IX from the stack. | |
| 53124 | RET | Return. | ||
|
View the equivalent code in;
|
||||
| Prev: 52869 | Up: Map | Next: 53125 |