![]() |
Routines |
| Prev: CF36 | Up: Map | Next: D04F |
|
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 0B and 0C.
|
||||||||
| ColourSegment | CF38 | LD A,($5C3C) | The scroll-in flag. | |||||
| CF3B | AND A | Return if A is not zero. | ||||||
| CF3C | RET NZ | |||||||
| CF3D | LD A,(IX+$01) | Read offset 01 of IX. | ||||||
| CF40 | AND A | Return if A is zero. | ||||||
| CF41 | RET Z | |||||||
| CF42 | LD A,(IX+$02) | Read offset 02 of IX. | ||||||
| CF45 | AND A | Return if A is zero. | ||||||
| CF46 | RET Z | |||||||
| CF47 | LD A,($CE59) | The horizontal step copy. | ||||||
| CF4A | AND A | Jump to ColourSegment_Cells if A is not zero. | ||||||
| CF4B | JR NZ,ColourSegment_Cells | |||||||
| CF4D | LD ($CE36),A | Update the column step. | ||||||
| CF50 | INC A | Advance A. | ||||||
| CF51 | LD ($5C24),A | Update the column step size. | ||||||
| ColourSegment_Cells | CF54 | LD A,($5C24) | The column step size. | |||||
| CF57 | INC A | Advance A. | ||||||
| CF58 | LD C,A | C=A. | ||||||
| CF59 | LD A,($E41B) | The slope direction. | ||||||
| CF5C | CP $FF | Jump to ColourSegment_Painter if A is FF. | ||||||
| CF5E | JR Z,ColourSegment_Painter | |||||||
| CF60 | LD A,(IX+$00) | Read offset 00 of IX. | ||||||
| CF63 | SUB $02 | Subtract 02 from A. | ||||||
| CF65 | AND %11111000 | Keep the bits of A that are set in F8. | ||||||
| CF67 | LD (IX+$00),A | Write A to offset 00 of IX. | ||||||
| ColourSegment_Painter | CF6A | LD A,C | A=C. | |||||
| CF6B | LD IY,$D04F | The paint one column. | ||||||
| CF6F | CP $01 | Jump to ColourSegment_Rows if A is 01. | ||||||
| CF71 | JR Z,ColourSegment_Rows | |||||||
| CF73 | LD IY,$D063 | The paint two columns. | ||||||
| CF77 | CP $02 | Jump to ColourSegment_Rows if A is 02. | ||||||
| CF79 | JR Z,ColourSegment_Rows | |||||||
| CF7B | LD IY,$D082 | The paint three columns. | ||||||
| ColourSegment_Rows | CF7F | LD A,($CE37) | The vertical step. | |||||
| CF82 | SRL A | Shift A right. | ||||||
| CF84 | SRL A | Shift A right. | ||||||
| CF86 | SRL A | Shift A right. | ||||||
| CF88 | LD ($CE5A),A | Update the vertical step copy. | ||||||
| CF8B | LD L,(IX+$00) | Read offset 00 of IX into L. | ||||||
| CF8E | LD H,(IX+$01) | Read offset 01 of IX into H. | ||||||
| CF91 | LD A,($CE5A) | The vertical step copy. | ||||||
| CF94 | LD ($CE3E),A | Update the attribute rows. | ||||||
| CF97 | LD A,H | A=H. | ||||||
| CF98 | AND %00000111 | Keep the bits of A that are set in 07. | ||||||
| CF9A | XOR %00000111 | Flip the bits of A that are set in 07. | ||||||
| CF9C | JR Z,ColourSegment_Flat | Jump to ColourSegment_Flat if the zero flag is set. | ||||||
| CF9E | LD A,($CE3E) | The attribute rows. | ||||||
| CFA1 | INC A | Advance A. | ||||||
| CFA2 | LD ($CE3E),A | Update the attribute rows. | ||||||
| ColourSegment_Flat | CFA5 | LD A,(IX+$03) | Read offset 03 of IX. | |||||
| CFA8 | AND A | Jump to ColourSegment_FlatCells if A is zero. | ||||||
| CFA9 | JR Z,ColourSegment_FlatCells | |||||||
| CFAB | CP $07 | Jump to ColourSegment_Address if A is not 07. | ||||||
| CFAD | JR NZ,ColourSegment_Address | |||||||
| ColourSegment_FlatCells | CFAF | LD IY,$D082 | The paint three columns. | |||||
| CFB3 | XOR A | Clear A. | ||||||
| CFB4 | LD ($CE5A),A | Update the vertical step copy. | ||||||
| CFB7 | LD A,H | A=H. | ||||||
| CFB8 | SUB $0B | Subtract 0B from A. | ||||||
| CFBA | LD B,A | B=A. | ||||||
| CFBB | LD A,H | A=H. | ||||||
| CFBC | OR %00000111 | Set the bits of A that are set in 07. | ||||||
| CFBE | SUB B | Subtract B from A. | ||||||
| CFBF | SRL A | Shift A right. | ||||||
| CFC1 | SRL A | Shift A right. | ||||||
| CFC3 | SRL A | Shift A right. | ||||||
| CFC5 | LD ($CE3E),A | Update the attribute rows. | ||||||
| ColourSegment_Address | CFC8 | LD B,L | B=L. | |||||
| CFC9 | LD A,L | A=L. | ||||||
| CFCA | CP $F0 | Jump to ColourSegment_Convert if A is less than F0. | ||||||
| CFCC | JR C,ColourSegment_Convert | |||||||
| CFCE | LD L,$00 | Clear L. | ||||||
| ColourSegment_Convert | CFD0 | CALL AttributeAddress | Call AttributeAddress. | |||||
| CFD3 | LD A,B | A=B. | ||||||
| CFD4 | CP $F0 | Jump to ColourSegment_Colour if A is less than F0. | ||||||
| CFD6 | JR C,ColourSegment_Colour | |||||||
| CFD8 | DEC HL | Step HL back. | ||||||
| ColourSegment_Colour | CFD9 | LD A,($5C3A) | The top-tile colour. | |||||
| CFDC | LD C,A | C=A. | ||||||
| CFDD | LD A,($5C1D) | The tile number. | ||||||
| CFE0 | BIT 0,A | Jump to ColourSegment_Row if bit 0 of A is clear. | ||||||
| CFE2 | JR Z,ColourSegment_Row | |||||||
| CFE4 | LD A,($5C3B) | The bottom-tile colour. | ||||||
| CFE7 | LD C,A | C=A. | ||||||
| ColourSegment_Row | CFE8 | LD A,($CE58) | The map row. | |||||
| CFEB | CP $0B | Jump to ColourSegment_Special if A is 0B. | ||||||
| CFED | JR Z,ColourSegment_Special | |||||||
| CFEF | CP $0C | Jump to ColourSegment_Paint if A is not 0C. | ||||||
| CFF1 | JR NZ,ColourSegment_Paint | |||||||
| CFF3 | LD A,($5C1D) | The tile number. | ||||||
| CFF6 | BIT 0,A | Jump to ColourSegment_Paint if bit 0 of A is set. | ||||||
| CFF8 | JR NZ,ColourSegment_Paint | |||||||
| CFFA | JR ColourSegment_Alternate | Jump to ColourSegment_Alternate. | ||||||
| ColourSegment_Special | CFFC | LD A,($5C1D) | The tile number. | |||||
| CFFF | BIT 0,A | Jump to ColourSegment_Paint if bit 0 of A is clear. | ||||||
| D001 | JR Z,ColourSegment_Paint | |||||||
| ColourSegment_Alternate | D003 | LD A,($DC96) | The underground attribute. | |||||
| D006 | LD C,A | C=A. | ||||||
| D007 | LD A,($CE3C) | The vertical edge in the tile. | ||||||
| D00A | CP $67 | Jump to ColourSegment_Paint if A is 67 or more. | ||||||
| D00C | JR NC,ColourSegment_Paint | |||||||
| D00E | LD A,($DC95) | The sky attribute. | ||||||
| D011 | LD C,A | C=A. | ||||||
| ColourSegment_Paint | D012 | LD DE,$0020 | DE=20. | |||||
| D015 | LD B,(IX+$02) | Read offset 02 of IX into B. | ||||||
| ColourSegment_Loop | D018 | PUSH BC | Stash BC on the stack. | |||||
| D019 | LD A,($CE3E) | The attribute rows. | ||||||
| D01C | LD B,A | B=A. | ||||||
| D01D | PUSH HL | Stash HL on the stack. | ||||||
| D01E | CALL JumpToPainter | Call JumpToPainter. | ||||||
| D021 | POP HL | Bring HL back off the stack. | ||||||
| D022 | LD A,($CE5A) | The vertical step copy. | ||||||
| D025 | AND A | Jump to ColourSegment_Across if A is zero. | ||||||
| D026 | JR Z,ColourSegment_Across | |||||||
| D028 | LD B,A | B=A. | ||||||
| ColourSegment_Up | D029 | AND A | Is A zero? | |||||
| D02A | SBC HL,DE | Subtract DE and the carry from HL. | ||||||
| D02C | DJNZ ColourSegment_Up | Decrease B and jump to ColourSegment_Up until none remain. | ||||||
| ColourSegment_Across | D02E | LD A,($CE36) | The column step. | |||||
| D031 | LD C,A | C=A. | ||||||
| D032 | LD B,$00 | Clear B. | ||||||
| D034 | BIT 7,A | Jump to ColourSegment_Advance if bit 7 of A is clear. | ||||||
| D036 | JR Z,ColourSegment_Advance | |||||||
| D038 | DEC B | Step B back. | ||||||
| ColourSegment_Advance | D039 | ADD HL,BC | HL gains BC. | |||||
| D03A | POP BC | Bring BC back off the stack. | ||||||
| D03B | DJNZ ColourSegment_Loop | Decrease B and jump to ColourSegment_Loop until none remain. | ||||||
| D03D | LD A,($5C34) | The segment end shape. | ||||||
| D040 | AND %01111111 | Keep the bits of A that are set in 7F. | ||||||
| D042 | CP $13 | Return if A is not 13. | ||||||
| D044 | RET NZ | |||||||
| D045 | LD A,($CE41) | The horizontal offset. | ||||||
| D048 | AND %00000111 | Keep the bits of A that are set in 07. | ||||||
| D04A | RET Z | Return if the zero flag is set. | ||||||
| ColourSegment_Edge | D04B | LD A,($CE3E) | The attribute rows. | |||||
| D04E | LD B,A | B=A. | ||||||
|
Continue on to PaintOneColumn.
|
||||||||
| Prev: CF36 | Up: Map | Next: D04F |