![]() |
Routines |
| Prev: 813C | Up: Map | Next: 81B3 |
|
Used by the routines at GameInitialise and Handler_SubGame.
|
|||||
|
|||||
| Print_WorldMap | 8146 | LD IX,$F000 | IX=WorldMap_Data. | ||
| 814A | LD HL,$6000 | HL=ShadowBuffer. | |||
| 814D | LD E,$FF | Set E as a bit counter/ mask. | |||
| 814F | LD D,$80 | D is used as a bit mask for the output. | |||
| 8151 | LD A,$00 | Initialise A to 00 which is used for comparisons. | |||
|
Main loop, process the map data.
|
|||||
| WorldMap_Loop | 8153 | INC IX | Increment the map data pointer by one. | ||
| 8155 | LD B,(IX-$01) | Load the current map data byte into B. | |||
| 8158 | INC E | Increment the bit counter by one. | |||
| 8159 | JR Z,WorldMap_ExpandData | Jump to WorldMap_ExpandData if the bit counter wrapped around to zero. | |||
| 815B | LD E,$FF | Reset E to FF if it didn't wrap. | |||
|
Expand map data into pixels.
|
|||||
| WorldMap_ExpandData | 815D | RRC E | Rotate E right (with carry). | ||
| 815F | RL (HL) | Rotate the byte at *HL left one position, including the carry from the previous line. | |||
| 8161 | DEC B | Decrease bits remaining in the current map byte by one. | |||
| 8162 | SRL D | Shift the output bit mask right one position. | |||
| 8164 | JR Z,WorldMap_NextByte | Jump to WorldMap_NextByte if B is zero (the byte is filled). | |||
| 8166 | CP B | Jump to WorldMap_ExpandData if A is not equal to B. | |||
| 8167 | JR NZ,WorldMap_ExpandData | ||||
|
Move to the next map data byte.
|
|||||
| 8169 | JR WorldMap_Loop | Jump to WorldMap_Loop. | |||
|
Move to next shadow buffer byte.
|
|||||
| WorldMap_NextByte | 816B | INC HL | Increment the shadow buffer pointer by one. | ||
| 816C | LD A,$78 | A=78 (high byte of the shadow buffer end address). | |||
| 816E | CP H | Jump to WorldMap_ClearEdge if the end of the shadow buffer has been reached. | |||
| 816F | JR Z,WorldMap_ClearEdge | ||||
| 8171 | LD A,B | Store the remaining bits from the current map byte in A. | |||
| 8172 | CP $08 | Jump to WorldMap_FullByte if A is equal to/ higher than 08. | |||
| 8174 | JR NC,WorldMap_FullByte | ||||
| 8176 | CP $00 | Check if we're done with current map byte. | |||
| 8178 | LD D,$80 | Reset the bit mask in D to 80. | |||
| 817A | JR Z,WorldMap_Loop | Jump to WorldMap_Loop if we are done with the current map byte. | |||
| 817C | LD A,$00 | Reset A for comparison in bit manipulation loop. | |||
| 817E | JR WorldMap_ExpandData | Jump to WorldMap_ExpandData. | |||
|
Handle full byte remaining.
|
|||||
| WorldMap_FullByte | 8180 | LD (HL),E | Store the full byte in the shadow buffer. | ||
| 8181 | SUB $08 | Subtract 08 from the remaining bit count. | |||
| 8183 | LD B,A | ||||
| 8184 | JR WorldMap_NextByte | Jump to WorldMap_NextByte. | |||
|
Due to the way the decompression works, the image is left with a trailing line - this is what it would look like if we didn't clear the right edge of the map.
Clear the right edge of the map.
|
|||||
| WorldMap_ClearEdge | 8186 | LD HL,$601F | HL=601F. | ||
| 8189 | LD DE,$0020 | Set the row width in DE (0020 bytes is one whole row). | |||
| 818C | LD B,$C0 | Set a counter in B of the number of rows to process (C0). | |||
| WorldMap_ClearEdge_Loop | 818E | RES 0,(HL) | Reset bit 0 of *HL. | ||
| 8190 | ADD HL,DE | Move to the next row. | |||
| 8191 | DJNZ WorldMap_ClearEdge_Loop | Decrease the row counter by one and loop back to WorldMap_ClearEdge_Loop until all rows have been processed. | |||
|
Copy the map to the screen buffer.
|
|||||
| 8193 | LD HL,$6000 | Copy 1800 bytes from ShadowBuffer to the screen buffer. | |||
| 8196 | LD DE,$4000 | ||||
| 8199 | LD BC,$1800 | ||||
| 819C | LDIR | ||||
|
Colour the whole of the attribute buffer INK:
YELLOW,
PAPER:
BLUE
(BRIGHT)
.
|
|||||
| 819E | LD HL,$5800 | HL=5800 (attribute buffer location). | |||
| 81A1 | LD DE,$5801 | DE=5801. | |||
| 81A4 | LD BC,$02FF | BC=02FF. | |||
| 81A7 | LD (HL),$4E | Write INK: YELLOW, PAPER: BLUE (BRIGHT) to *HL. | |||
| 81A9 | LDIR | Copy 02FF more bytes to the rest of the attribute buffer. | |||
| 81AB | LD A,$01 | Write 01 to *99CC. | |||
| 81AD | LD ($99CC),A | ||||
| 81B0 | OUT ($FE),A | Set the border to BLUE. | |||
| 81B2 | RET | Return. | |||
| Prev: 813C | Up: Map | Next: 81B3 |