Prev: 53046 Up: Map Next: 53327
53048: Colour Segment
Used by the routine at FinishSegment.
Colours the attribute cells that a segment covers, one step at a time. Nothing is coloured if ScrollInFlag is set or if the drawing record has no screen address or no length. The number of cells across at each step (one to three) chooses the routine that paints the cells of a column: a flat segment is painted three cells across. The colour is TopTileColour for a tile on the top row and BottomTileColour for one on the bottom row, with the colours at SkyAttribute and UndergroundAttribute used for some of the tiles on map rows 11 and 12.
Input
IX Address of the drawing record at ScrollWorld_Record
ColourSegment 53048 LD A,(23612) The scroll-in flag.
53051 AND A Return if A is not zero.
53052 RET NZ
53053 LD A,(IX+1) Read offset 1 of IX.
53056 AND A Return if A is zero.
53057 RET Z
53058 LD A,(IX+2) Read offset 2 of IX.
53061 AND A Return if A is zero.
53062 RET Z
53063 LD A,(52825) The horizontal step copy.
53066 AND A Jump to ColourSegment_Cells if A is not zero.
53067 JR NZ,ColourSegment_Cells
53069 LD (52790),A Update the column step.
53072 INC A Advance A.
53073 LD (23588),A Update the column step size.
ColourSegment_Cells 53076 LD A,(23588) The column step size.
53079 INC A Advance A.
53080 LD C,A C=A.
53081 LD A,(58395) The slope direction.
53084 CP 255 Jump to ColourSegment_Painter if A is 255.
53086 JR Z,ColourSegment_Painter
53088 LD A,(IX+0) Read offset 0 of IX.
53091 SUB 2 Subtract 2 from A.
53093 AND %11111000 Keep the bits of A that are set in 248.
53095 LD (IX+0),A Write A to offset 0 of IX.
ColourSegment_Painter 53098 LD A,C A=C.
53099 LD IY,53327 The paint one column.
53103 CP 1 Jump to ColourSegment_Rows if A is 1.
53105 JR Z,ColourSegment_Rows
53107 LD IY,53347 The paint two columns.
53111 CP 2 Jump to ColourSegment_Rows if A is 2.
53113 JR Z,ColourSegment_Rows
53115 LD IY,53378 The paint three columns.
ColourSegment_Rows 53119 LD A,(52791) The vertical step.
53122 SRL A Shift A right.
53124 SRL A Shift A right.
53126 SRL A Shift A right.
53128 LD (52826),A Update the vertical step copy.
53131 LD L,(IX+0) Read offset 0 of IX into L.
53134 LD H,(IX+1) Read offset 1 of IX into H.
53137 LD A,(52826) The vertical step copy.
53140 LD (52798),A Update the attribute rows.
53143 LD A,H A=H.
53144 AND %00000111 Keep the bits of A that are set in 7.
53146 XOR %00000111 Flip the bits of A that are set in 7.
53148 JR Z,ColourSegment_Flat Jump to ColourSegment_Flat if the zero flag is set.
53150 LD A,(52798) The attribute rows.
53153 INC A Advance A.
53154 LD (52798),A Update the attribute rows.
ColourSegment_Flat 53157 LD A,(IX+3) Read offset 3 of IX.
53160 AND A Jump to ColourSegment_FlatCells if A is zero.
53161 JR Z,ColourSegment_FlatCells
53163 CP 7 Jump to ColourSegment_Address if A is not 7.
53165 JR NZ,ColourSegment_Address
ColourSegment_FlatCells 53167 LD IY,53378 The paint three columns.
53171 XOR A Clear A.
53172 LD (52826),A Update the vertical step copy.
53175 LD A,H A=H.
53176 SUB 11 Subtract 11 from A.
53178 LD B,A B=A.
53179 LD A,H A=H.
53180 OR %00000111 Set the bits of A that are set in 7.
53182 SUB B Subtract B from A.
53183 SRL A Shift A right.
53185 SRL A Shift A right.
53187 SRL A Shift A right.
53189 LD (52798),A Update the attribute rows.
ColourSegment_Address 53192 LD B,L B=L.
53193 LD A,L A=L.
53194 CP 240 Jump to ColourSegment_Convert if A is less than 240.
53196 JR C,ColourSegment_Convert
53198 LD L,0 Clear L.
ColourSegment_Convert 53200 CALL AttributeAddress Call AttributeAddress.
53203 LD A,B A=B.
53204 CP 240 Jump to ColourSegment_Colour if A is less than 240.
53206 JR C,ColourSegment_Colour
53208 DEC HL Step HL back.
ColourSegment_Colour 53209 LD A,(23610) The top-tile colour.
53212 LD C,A C=A.
53213 LD A,(23581) The tile number.
53216 BIT 0,A Jump to ColourSegment_Row if bit 0 of A is clear.
53218 JR Z,ColourSegment_Row
53220 LD A,(23611) The bottom-tile colour.
53223 LD C,A C=A.
ColourSegment_Row 53224 LD A,(52824) The map row.
53227 CP 11 Jump to ColourSegment_Special if A is 11.
53229 JR Z,ColourSegment_Special
53231 CP 12 Jump to ColourSegment_Paint if A is not 12.
53233 JR NZ,ColourSegment_Paint
53235 LD A,(23581) The tile number.
53238 BIT 0,A Jump to ColourSegment_Paint if bit 0 of A is set.
53240 JR NZ,ColourSegment_Paint
53242 JR ColourSegment_Alternate Jump to ColourSegment_Alternate.
ColourSegment_Special 53244 LD A,(23581) The tile number.
53247 BIT 0,A Jump to ColourSegment_Paint if bit 0 of A is clear.
53249 JR Z,ColourSegment_Paint
ColourSegment_Alternate 53251 LD A,(56470) The underground attribute.
53254 LD C,A C=A.
53255 LD A,(52796) The vertical edge in the tile.
53258 CP 103 Jump to ColourSegment_Paint if A is 103 or more.
53260 JR NC,ColourSegment_Paint
53262 LD A,(56469) The sky attribute.
53265 LD C,A C=A.
ColourSegment_Paint 53266 LD DE,32 DE=32.
53269 LD B,(IX+2) Read offset 2 of IX into B.
ColourSegment_Loop 53272 PUSH BC Stash BC on the stack.
53273 LD A,(52798) The attribute rows.
53276 LD B,A B=A.
53277 PUSH HL Stash HL on the stack.
53278 CALL JumpToPainter Call JumpToPainter.
53281 POP HL Bring HL back off the stack.
53282 LD A,(52826) The vertical step copy.
53285 AND A Jump to ColourSegment_Across if A is zero.
53286 JR Z,ColourSegment_Across
53288 LD B,A B=A.
ColourSegment_Up 53289 AND A Is A zero?
53290 SBC HL,DE Subtract DE and the carry from HL.
53292 DJNZ ColourSegment_Up Decrease B and jump to ColourSegment_Up until none remain.
ColourSegment_Across 53294 LD A,(52790) The column step.
53297 LD C,A C=A.
53298 LD B,0 Clear B.
53300 BIT 7,A Jump to ColourSegment_Advance if bit 7 of A is clear.
53302 JR Z,ColourSegment_Advance
53304 DEC B Step B back.
ColourSegment_Advance 53305 ADD HL,BC HL gains BC.
53306 POP BC Bring BC back off the stack.
53307 DJNZ ColourSegment_Loop Decrease B and jump to ColourSegment_Loop until none remain.
53309 LD A,(23604) The segment end shape.
53312 AND %01111111 Keep the bits of A that are set in 127.
53314 CP 19 Return if A is not 19.
53316 RET NZ
53317 LD A,(52801) The horizontal offset.
53320 AND %00000111 Keep the bits of A that are set in 7.
53322 RET Z Return if the zero flag is set.
ColourSegment_Edge 53323 LD A,(52798) The attribute rows.
53326 LD B,A B=A.
Continue on to PaintOneColumn.
Prev: 53046 Up: Map Next: 53327