![]() |
Routines |
| Prev: 54964 | Up: Map | Next: 55139 |
|
Used by the routine at Game_Loop.
|
||||||||
|
Start by clearing the screen and attribute buffers.
|
||||||||
| UnpackScreenData | 55052 | PUSH HL | Stash the pointer to the image data on the stack temporarily. | |||||
| 55053 | LD HL,22528 | HL=22528 (attribute buffer location). | ||||||
| 55056 | LD DE,22529 | DE=22529. | ||||||
| 55059 | LD (HL),0 | Write 0 to *HL. | ||||||
| 55061 | LD BC,767 | Copy 0 to 767 more bytes, filling the whole of the attribute buffer. | ||||||
| 55064 | LDIR | |||||||
| 55066 | POP HL | Restore the pointer to the image data from the stack. | ||||||
| 55067 | LD DE,16384 | Initialise the target screen buffer location (16384) in DE. | ||||||
|
The main loop
|
||||||||
| UnpackScreenData_Loop | 55070 | LD A,(HL) | Jump to Handler_Zeroes if *HL is equal to 0. | |||||
| 55071 | CP 0 | |||||||
| 55073 | JR Z,Handler_Zeroes | |||||||
| 55075 | LD (DE),A | Write A to *DE. | ||||||
| 55076 | INC HL | Increment HL by one. | ||||||
| 55077 | INC DE | Increment DE by one. | ||||||
| 55078 | JR UnpackScreenData_Loop | Jump to UnpackScreenData_Loop. | ||||||
|
Handle multiple zeroes.
|
||||||||
| Handler_Zeroes | 55080 | INC HL | Move the pointer to the length byte. | |||||
| 55081 | LD A,(HL) | Load the length into A. | ||||||
| 55082 | CP 0 | Jump to Handler_Attributes if *A is equal to 0. | ||||||
| 55084 | JR Z,Handler_Attributes | |||||||
| 55086 | LD B,A | Store the length in B. | ||||||
| 55087 | XOR A | Set A to 0 the value to write. | ||||||
|
Write the zeroes to the screen buffer.
|
||||||||
| Write_Zeroes | 55088 | LD (DE),A | Write 0 to the screen buffer location held by *DE. | |||||
| 55089 | INC DE | Increment the screen buffer pointer by one. | ||||||
| 55090 | DJNZ Write_Zeroes | Decrease counter by one and loop back to Write_Zeroes until counter is zero. | ||||||
| 55092 | INC HL | Increment HL by one. | ||||||
| 55093 | JR UnpackScreenData_Loop | Jump to UnpackScreenData_Loop. | ||||||
|
Process attributes.
|
||||||||
| Handler_Attributes | 55095 | INC HL | Increment HL by one. | |||||
| 55096 | PUSH HL | IX=HL (using the stack). | ||||||
| 55097 | POP IX | |||||||
| 55099 | LD HL,22528 | HL=22528 (attribute buffer location). | ||||||
| 55102 | LD B,24 | Initialise B to 24 (number of character rows). | ||||||
| Handler_Attributes_Loop | 55104 | PUSH BC | Stash the row counter and attribute buffer pointer on the stack. | |||||
| 55105 | PUSH HL | |||||||
| 55106 | LD A,0 | Initialise the column counter in A to 0. | ||||||
|
Process the attribute bytes in a row.
|
||||||||
| UnpackScreenData_ProcessAttributesRow | 55108 | LD C,(IX+0) | C=attribute value. | |||||
| 55111 | INC IX | |||||||
| 55113 | LD B,(IX+0) | B=run length. | ||||||
| 55116 | INC IX | |||||||
| 55118 | ADD A,B | A=run length plus the column counter. | ||||||
|
Write the run of attributes.
|
||||||||
| UnpackScreenData_WriteAttributes_Loop | 55119 | LD (HL),C | Write attribute byte to the attribute buffer. | |||||
| 55120 | INC HL | Increment the attribute pointer by one. | ||||||
| 55121 | DJNZ UnpackScreenData_WriteAttributes_Loop | Decrease the length counter by one and loop back to UnpackScreenData_WriteAttributes_Loop until counter is zero. | ||||||
| 55123 | CP 32 | Jump to UnpackScreenData_ProcessAttributesRow if A is not equal to 32. | ||||||
| 55125 | JR NZ,UnpackScreenData_ProcessAttributesRow | |||||||
| 55127 | POP HL | Restore the start of the row into HL from the stack. | ||||||
| 55128 | LD BC,32 | Move HL 0032 bytes to point to the next row. | ||||||
| 55131 | ADD HL,BC | |||||||
| 55132 | POP BC | Restore the row counter from the stack. | ||||||
| 55133 | DJNZ Handler_Attributes_Loop | Decrease the row counter by one and loop back to Handler_Attributes_Loop until all the rows have been processed. | ||||||
| 55135 | PUSH IX | BC=current position in attribute data (using the stack). | ||||||
| 55137 | POP BC | |||||||
| 55138 | RET | Return. | ||||||
| Prev: 54964 | Up: Map | Next: 55139 |