Prev: 40905 Up: Map Next: 41035
40937: Paint room layout data entry's attributes (room drawing)
Used by the routine at 39047.
See also analogous routine at 41173 (RLE terrain interaction data painting)
Input
HL Points to entry in lookup table for RLE attribute data (room layout graphics) at 60487
DE Points to entry in lookup table for RLE terrain interaction data (room layout graphics) at 60889
40937 PUSH HL Store HL (pointer to entry in lookup table for RLE attribute data)
40938 LD HL,23410 Modify instruction at 40983 to load x-coordinate of graphic's right edge into A...
40941 LD (40984),HL ...i.e. set end x-coordinate for painting left-to-right
40944 LD HL,41004 Modify instruction at 40987 to jump to 41004...
40947 LD (40988),HL ...i.e. advance HL down one character row in attribute file
40950 LD A,35 Modify instruction at 40990 with opcode 35 (INC HL)...
40952 LD (40990),A ...
40955 POP HL Restore HL (pointer to entry in lookup table for RLE attribute data)
40956 CALL 41035 Store coordinates of area to be coloured and point IX at RLE attribute data
40959 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 40845, 40873 and 40905.
At this point, BC holds the initial coordinates in characters, from which to start painting attributes. IX points to the required RLE attribute data.
40963 PUSH BC Store BC (B = current y-coordinate, C = initial x-coordinate)
40964 CALL 63219 Point HL at attribute file address for character coordinates (C, B)
40967 LD A,(IX+0) Load A with repeat count value
40970 OR A If repeat count is zero...
40971 JP Z,41000 ...then jump to 41000
40974 LD B,A Load B with repeat count
40975 LD C,(IX+1) Load C with attribute to paint
40978 LD (HL),C Apply attribute in C to current attribute file location in HL
40979 LD A,L Load E with x-coordinate (characters) of current attribute file location...
40980 AND 31 ...
40982 LD E,A ...
The operand of the instruction at 40983 is modified by instructions at 40849, 40877, 40909, 40941, 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.
40983 LD A,(23410) Load A with end x-coordinate for painting...
40986 CP E ...and if this is the same as the x-coordinate...
The operand of the instruction at 40987 (i.e. the destination of the jump) is modified by the instructions at 40855, 40883, 40915 and 40947 to be 41025 (move up one character row), 41025 (move up one character row), 41004 (move down one character row) or 41004 (move down one character row) respectively.
40987 JP Z,41004 ...then jump to routine to move up or down one character row
The instruction at 40990 is modified by the instructions at 40860, 40888, 40920 and 40952 to 43 (DEC HL), 35 (INC HL), 43 (DEC HL) or 35 (INC HL) respectively.
40990 INC HL Advance HL to next (or previous) byte in attribute file
40991 DJNZ 40978 Decrease B (repeat count) and loop back to 40978 if not zero
40993 INC IX Advance IX by two bytes in RLE attribute data...
40995 INC IX ...
40997 JP 40967 Loop back to 40967 for this new data
41000 POP BC Restore BC (B = current y-coordinate, C = initial x-coordinate)
41001 JP 39158 Advance to next room layout data entry and paint its attributes
Move down one character row
41004 EXX Switch registers
41005 LD A,(23411) Load A with one more than y-coordinate of bottom edge of area to paint...
41008 INC A ...
41009 POP BC Restore BC (B = current y-coordinate, C = initial x-coordinate)
41010 INC B Increase B (i.e. move down a character row)
41011 PUSH BC Store BC (B = updated y-coordinate, C = initial x-coordinate)
41012 CP B If B is the same as A (i.e. we are now outside the area to be painted)...
41013 JP Z,41000 ...then jump to 41000
41016 CALL 63219 Load HL with attribute file address for coordinates (C, B) and load E with x-coordinate (characters)
41019 PUSH HL Store HL (new attribute file address)
41020 EXX Switch registers
41021 POP HL Restore HL (new attribute file address)
41022 JP 40991 Jump back to 40991 and continue painting
Move up one character row
41025 EXX Switch registers
41026 LD A,(23409) Load A with one less than y-coordinate of top edge of area to paint...
41029 DEC A ...
41030 POP BC Restore BC (B = current y-coordinate, C = initial x-coordinate)
41031 DEC B Increase B (i.e. move down a character row)
41032 JP 41011 Jump back to 41011
Prev: 40905 Up: Map Next: 41035