Prev: 39216 Up: Map Next: 39366
39291: Draw run of 2 × 2 blocks vertically
The parameters for block drawing start at the byte after the address in IX. These are:
Byte offset from IX Effect
0 126 (start vertical block drawing)
1 Start x-coordinate (characters)
2 Start y-coordinate (characters)
3 - n Block data
n + 1 End marker (255)
The block data is comprised of one or more byte values.
If a block data byte has its most significant bit reset, then it is interpreted as a block style index corresponding to an entry in the table of block style definitions at 49794, and a single such block is drawn before the next byte is processed.
If a block data byte has its most significant bit set, then bits 0-6 are interpreted as a run-length (e.g. a value of 144 means a run-length of 16 2 × 2 blocks) and the following data byte represents the index of the entry in the table of block style definitions at 49794 to repeatedly use throughout the run. Once the run of blocks has been drawn, the next byte is processed.
When the value 255, the end marker, is encountered, the vertical drawing ends.
Used by the routine at 39047.
Input
IX Current position in room layout data
39291 INC IX Advance IX to x-coordinate...
39293 LD L,(IX+0) ...and load into L
39296 INC IX Advance IX to y-coordinate...
39298 LD H,(IX+0) ...and load into H
39301 INC IX Advance IX to first block layout data byte
39303 LD (23463),HL Store coordinates of top-left of block at 23463
39306 LD A,(IX+0) Load A with next block layout data...
39309 CP 255 ...and if this is 255 (end marker)...
39311 JR Z,39332 ...then skip ahead to 39332
39313 BIT 7,A If draw-run flag is set...
39315 JR NZ,39337 ...then skip ahead to 39337
39317 CALL 39366 Draw 2 × 2 block with style index A at coordinates stored at 23463 then move right two characters
39320 INC IX Advance IX to next block layout data
39322 LD HL,(23463) Load HL with coordinates of top-left of block just drawn...
39325 INC H ...add two to y-coordinate...
39326 INC H ...
39327 LD (23463),HL ...and store updated coordinates at 23463
39330 JR 39306 Loop back to 39306 to process next block layout data
End marker encountered
39332 INC IX Advance IX to next byte in room layout data...
39334 JP 39067 ...and jump to 39067 to process
Draw-run flag set
39337 AND 127 Reset draw-run flag...
39339 LD B,A ...and load B with run length
39340 INC IX Advance IX to block style index...
39342 LD A,(IX+0) ...and load into A
39345 INC IX Advance IX to next block layout data
39347 PUSH BC Store BC (B = remaining number of blocks to draw)
39348 PUSH AF Store AF
39349 CALL 39366 Draw 2 × 2 block with style index A at coordinates stored at 23463 then move right two characters
39352 LD HL,(23463) Load HL with coordinates of top-left of block just drawn...
39355 INC H ...add two to y-coordinate...
39356 INC H ...
39357 LD (23463),HL ...and store updated coordinates at 23463
39360 POP AF Restore AF
39361 POP BC Restore BC (B = remaining number of blocks to draw)
39362 DJNZ 39347 Decrease remaining number of blocks and loop back to 39347 if not zero
39364 JR 39306 Loop back to 39306 for next block layout data
Prev: 39216 Up: Map Next: 39366