Prev: 41141 Up: Map Next: 41271
41173: Paint room layout data entry's terrain interaction parameters then advance to next entry (room drawing)
Used by the routine at 39158.
See also analogous routine at 40937 (RLE attribute data painting)
Input
HL Points to entry in lookup table for RLE terrain interaction data (room layout graphics) at 60889
41173 PUSH HL Store HL (pointer to entry in lookup table for RLE terrain interaction data)
41174 LD HL,23410 Modify instruction at 41219 to load x-coordinate of graphic's right edge into A...
41177 LD (41220),HL ...i.e. set end x-coordinate for painting left-to-right
41180 LD HL,41240 Modify instruction at 41223 to jump to 41240...
41183 LD (41224),HL ...i.e. advance HL down one character row in terrain interaction data table at 23808
41186 LD A,35 Modify instruction at 41226 with opcode 35 (INC HL)...
41188 LD (41226),A ...
41191 POP HL Restore HL (pointer to entry in lookup table for RLE terrain interaction data)
41192 CALL 41035 Store coordinates of area to be coloured and point IX at RLE terrain interaction data
41195 LD BC,(23408) Load BC with x- and y-coordinates (top-left) defined in current room layout data entry
This entry point is used by the routines at 41081, 41109 and 41141.
At this point, BC holds the initial coordinates in characters, from which to start painting terrain interaction parameters. IX points to the required RLE terrain interaction data.
41199 PUSH BC Store BC (B = current y-coordinate, C = initial x-coordinate)
41200 CALL 63233 Point HL at terrain interaction data table address for character coordinates x=C, y=B
41203 LD A,(IX+0) Load A with repeat count value
41206 OR A If repeat count is zero...
41207 JP Z,41236 ...then jump to 41236
41210 LD B,A Load B with repeat count
41211 LD C,(IX+1) Load C with terrain interaction parameter to paint
41214 LD (HL),C Apply terrain interaction parameter in C to current terrain interaction data table location in HL
41215 LD A,L Load E with x-coordinate (characters) of current terrain interaction data location...
41216 AND 31 ...
41218 LD E,A ...
The operand of the instruction at 41219 is modified by instructions at 41085, 41113, 41145, 41177, to 23408 (x-coordinate of left edge), 23410 (x-coordinate of right edge), 23408 (x-coordinate of left edge), or 23410 (x-coordinate of right edge) respectively.
41219 LD A,(23410) Load A with end x-coordinate for painting...
41222 CP E ...and if this is the same as the x-coordinate...
The operand of the instruction at 41223 (i.e. the destination of the jump) is modified by the instructions at 41091, 41119, 41151 and 41183 to be 41261 (move up one character row), 41261 (move up one character row), 41240 (move down one character row) or 41240 (move down one character row) respectively.
41223 JP Z,41240 ...then jump to routine to move up or down one character row
The instruction at 41226 is modified by the instructions at 41096, 41124, 41156 and 41188 to 43 (DEC HL), 35 (INC HL), 43 (DEC HL) or 35 (INC HL) respectively.
41226 INC HL Advance HL to next (or previous) byte in terrain interaction data table
41227 DJNZ 41214 Decrease B (repeat count) and loop back to 41214 if not zero
41229 INC IX Advance IX by two bytes in RLE terrain interaction data...
41231 INC IX ...
41233 JP 41203 Loop back to 41203 for this new data
41236 POP BC Restore BC (B = current y-coordinate, C = initial x-coordinate)
41237 JP 39183 Advance IX to start of next room layout data entry and jump back to 39067 to paint its attributes / terrain interaction data
Move down one character row
41240 EXX Switch registers
41241 LD A,(23411) Load A with one more than y-coordinate of bottom edge of area to paint...
41244 INC A ...
41245 POP BC Restore BC (B = current y-coordinate, C = initial x-coordinate)
41246 INC B Increase B (i.e. move down a character row)
41247 PUSH BC Store BC (B = updated y-coordinate, C = initial x-coordinate)
41248 CP B If B is the same as A (i.e. we are now outside the area to be painted)...
41249 JP Z,41236 ...then jump to 41236
41252 CALL 63233 Load HL with terrain interaction data table address for coordinates (C, B) and load E with x-coordinate (characters)
41255 PUSH HL Store HL (new terrain interaction data table address)
41256 EXX Switch registers
41257 POP HL Restore HL (new terrain interaction data table address)
41258 JP 41227 Jump back to 41227 and continue painting
Move up one character row
41261 EXX Switch registers
41262 LD A,(23409) Load A with one less than y-coordinate of top edge of area to paint...
41265 DEC A ...
41266 POP BC Restore BC (B = current y-coordinate, C = initial x-coordinate)
41267 DEC B Increase B (i.e. move down a character row)
41268 JP 41247 Jump back to 41247
Prev: 41141 Up: Map Next: 41271