Prev: 59195 Up: Map Next: 59323
59199: Process Graphic Layout Data
Input
IX Current position in graphic layout data
HL Drawing coordinates (H = x, L = y)
Ordinary tile: if it sits inside the 32×20 window, plot it into the display buffer.
Process_GraphicLayoutData 59199 LD A,(IX+0) Fetch the next graphic-layout byte (tile index / opcode) into A.
59202 CP 238 Is A less than 238? If not, jump to Jump_GraphicLayoutRoutine.
59204 JP NC,Jump_GraphicLayoutRoutine
59207 LD A,H Copy H into A.
59208 CP 32 Is A less than 32? If not, jump to Process_GraphicLayoutDataContinueB5.
59210 JP NC,Process_GraphicLayoutDataContinueB5
59213 LD A,L Copy L into A.
59214 CP 20 Is A less than 20? If not, jump to Process_GraphicLayoutDataContinueB5.
59216 JP NC,Process_GraphicLayoutDataContinueB5
59219 PUSH HL Stash HL on the stack.
59220 LD A,H Copy H into A.
59221 ADD A,A Double A to form a word index into the table.
59222 ADD A,H A+=H.
59223 LD C,A Keep the summed coordinate in C.
59224 LD A,L Copy L into A.
59225 ADD A,A Double A to form a word index into the table.
59226 LD E,A Copy A into E as a saved coordinate / value.
59227 LD D,0 Clear D (high byte of a pointer/offset).
59229 LD B,D Copy D into B.
59230 LD HL,59751 Point HL at Table: Display Buffer Row Offsets (Table_DisplayBufferRowOffsets).
59233 ADD HL,DE HL+=DE.
59234 LD E,(HL) Fetch the word at HL into DE.
59235 INC HL
59236 LD D,(HL)
59237 LD HL,(29429) Load HL with the current display-buffer pointer (Pointer_CurrentDisplayBuffer).
59240 ADD HL,DE HL+=DE.
59241 ADD HL,BC HL+=BC.
59242 EX DE,HL Exchange DE and HL.
Write the current graphic-set index into the buffer cell and advance the layout cursor.
59243 LD A,(29446) Load A with the current graphic-set index (CurrentGraphicSetIndex).
59246 LD (DE),A Set the byte at DE.
59247 INC DE Advance the destination drawing coordinate by one.
59248 LD A,(IX+0) Fetch the current entity's type into A.
59251 LD (DE),A Set the byte at DE.
59252 INC DE Advance the destination drawing coordinate by one.
59253 LD A,(29448) Load A with the current attribute (CurrentAttribute).
59256 OR A Is the current attribute (CurrentAttribute) zero? If not, jump to ProcessLayout_DrawTile.
59257 JR NZ,ProcessLayout_DrawTile
59259 INC IX Advance IX past the graphic-layout operand byte.
59261 LD A,(IX+0) Fetch the current entity's type for the layout path.
Compose the tile's attribute from CurrentAttribute / entity flags and write it into the display buffer.
ProcessLayout_DrawTile 59264 LD L,A Copy A into L.
59265 AND %11000000 A&=192.
59267 LD B,A Keep a copy of A in B.
59268 LD A,L Copy L into A.
59269 AND %00111111 A&=63.
59271 LD C,A Keep the masked attribute bits in C.
59272 AND %00111000 A&=56.
59274 JR NZ,Process_GraphicLayoutDataContinueB Jump to Process_GraphicLayoutDataContinueB to continue if the comparison did not match.
59276 BIT 7,(IX+1) Is bit 7 of the layout step byte at IX+1 set? If so, jump to Process_GraphicLayoutDataContinueB.
59280 JR NZ,Process_GraphicLayoutDataContinueB
59282 LD A,(DE) Load A from the byte at DE.
59283 BIT 6,A Is bit 6 of A set? If not, jump to Process_GraphicLayoutDataContinue.
59285 JR Z,Process_GraphicLayoutDataContinue
59287 ADD A,A Multiply A by 8.
59288 ADD A,A
59289 ADD A,A
Mask the ink/paper bits of the composed attribute before merging.
Process_GraphicLayoutDataContinue 59290 AND 56 A&=56.
Merge the masked attribute halves and store the tile triple in the display buffer.
Process_GraphicLayoutDataContinueB 59292 OR B Set in A every bit that is set in B.
59293 OR C Set in A every bit that is set in C.
59294 LD (DE),A Set the byte at DE.
59295 POP HL Restore HL from the stack.
Apply the layout delta/flags byte to step the drawing coordinates for the next tile.
Process_GraphicLayoutDataContinueB2 59296 LD A,(IX+1) Fetch the layout delta/flags byte at IX+1 into A.
59299 AND %01111111 A&=127.
59301 SUB 32 A-=32.
59303 JR Z,Process_GraphicLayoutDataContinueB3 Jump to Process_GraphicLayoutDataContinueB3 to continue if the comparison matched.
59305 JR NC,Process_GraphicLayoutDataContinueB4 Jump to Process_GraphicLayoutDataContinueB4 if the result did not underflow.
Step the drawing Y down one character when the signed delta underflows.
Process_GraphicLayoutDataContinueB3 59307 INC L Advance the low drawing coordinate by one.
Add the signed X delta into H and continue via Advance_GraphicLayoutPointerByTwo.
Process_GraphicLayoutDataContinueB4 59308 ADD A,H A+=H.
59309 LD H,A Copy A into H.
59310 JP Advance_GraphicLayoutPointerByTwo Jump to Advance_GraphicLayoutPointerByTwo to advance the graphic layout pointer and continue.
Skip drawing an off-screen tile, but still consume its layout operand and delta.
Process_GraphicLayoutDataContinueB5 59313 LD A,(29448) Load A with the current attribute (CurrentAttribute).
59316 OR A Is the current attribute (CurrentAttribute) zero? If not, jump to Process_GraphicLayoutDataContinueB2.
59317 JR NZ,Process_GraphicLayoutDataContinueB2
59319 INC IX Advance IX past the graphic-layout operand byte.
59321 JR Process_GraphicLayoutDataContinueB2 Jump to Process_GraphicLayoutDataContinueB2 to continue this routine.
View the equivalent code in;
Prev: 59195 Up: Map Next: 59323