Prev: D990 Up: Map Next: DB26
D9A8: Draw Vertical Edge
Used by the routine at FinishSegment.
Draws the edge of the terrain when the world is scrolling vertically, for the steps of a segment that have been counted in StepsDrawn. A strip across the segment is filled with either a chequered pattern (55AA) or blank (zero), depending on whether the vertical speed in VerticalSpeed and the direction are the same, using FillTwoEdgeRows or FillFourEdgeRows. The routine finally carries on with FinishSegment_Colour. Purpose not yet known for the details of the positions.
DrawVerticalEdge D9A8 LD IY,$DB49 The fill four edge rows.
D9AC LD A,($CE3F) The vertical distance.
D9AF CP $04 Jump to DrawVerticalEdge_Pattern if A is 04.
D9B1 JR Z,DrawVerticalEdge_Pattern
D9B3 LD IY,$DB41 The fill two edge rows.
DrawVerticalEdge_Pattern D9B7 LD DE,$0000 DE=00.
D9BA LD A,($CCBA) The vertical scroll speed.
D9BD LD B,A B=A.
D9BE LD A,($5C35) The upside-down segment flag.
D9C1 XOR B Flip the bits of A that are set in B.
D9C2 BIT 7,A Jump to DrawVerticalEdge_Address if bit 7 of A is clear.
D9C4 JR Z,DrawVerticalEdge_Address
D9C6 LD DE,$55AA DE=55AA.
DrawVerticalEdge_Address D9C9 LD HL,($CE55) Fetch the word at StartColumn into HL.
D9CC LD A,($CE59) The horizontal step copy.
D9CF AND A Jump to DrawVerticalEdge_Rows if A is not zero.
D9D0 JR NZ,DrawVerticalEdge_Rows
D9D2 LD A,($E41B) The slope direction.
D9D5 CP $01 Jump to DrawVerticalEdge_Count if A is 01.
D9D7 JR Z,DrawVerticalEdge_Count
D9D9 LD A,L A=L.
D9DA ADD A,$07 Add 07 to A.
D9DC LD L,A L=A.
DrawVerticalEdge_Count D9DD LD A,($CE54) The steps already drawn.
D9E0 LD B,A B=A.
D9E1 XOR A Clear A.
DrawVerticalEdge_Rows2 D9E2 ADD A,$10 Add 10 to A.
D9E4 DJNZ DrawVerticalEdge_Rows2 Decrease B and jump to DrawVerticalEdge_Rows2 until none remain.
D9E6 LD ($CE5A),A Update the vertical step copy.
D9E9 LD A,$01 A=01.
D9EB LD ($CE54),A Update the steps already drawn.
D9EE LD DE,$55AA DE=55AA.
D9F1 LD A,($E41B) The slope direction.
D9F4 LD B,A B=A.
D9F5 LD A,($CCBB) The horizontal scroll speed.
D9F8 AND A Jump to DrawVerticalEdge_Rows if A is zero.
D9F9 JR Z,DrawVerticalEdge_Rows
D9FB XOR B Flip the bits of A that are set in B.
D9FC BIT 7,A Jump to FinishSegment_Colour if bit 7 of A is set.
D9FE JP NZ,FinishSegment_Colour
DrawVerticalEdge_Rows DA01 LD A,($CCBA) The vertical scroll speed.
DA04 BIT 7,A Test bit 7 of A.
DA06 LD A,($CE3F) The vertical distance.
DA09 JR NZ,DrawVerticalEdge_Row Jump to DrawVerticalEdge_Row if the zero flag is clear.
DA0B LD A,($CE5A) The vertical step copy.
DA0E NEG Negate A.
DrawVerticalEdge_Row DA10 ADD A,H A gains H.
DA11 LD H,A H=A.
DA12 LD ($CE44),A Update the segment row.
DA15 LD ($BA8D),HL The edge position.
DA18 LD A,($CE37) The vertical step.
DA1B AND A Jump to DrawVerticalEdge_Sloped if A is not zero.
DA1C JR NZ,DrawVerticalEdge_Sloped
DA1E LD A,($CCBB) The horizontal scroll speed.
DA21 NEG Negate A.
DA23 ADD A,L A gains L.
DA24 LD L,A L=A.
DA25 LD A,($CE54) The steps already drawn.
DA28 LD B,A B=A.
DA29 LD A,$01 A=01.
DA2B LD ($CE54),A Update the steps already drawn.
DA2E LD A,($D85D) The edge flag.
DA31 AND A Jump to DrawVerticalEdge_Width if A is zero.
DA32 JR Z,DrawVerticalEdge_Width
DA34 LD A,($5C34) The segment end shape.
DA37 AND %01111111 Keep the bits of A that are set in 7F.
DA39 CP $13 Jump to DrawVerticalEdge_Width if A is not 13.
DA3B JR NZ,DrawVerticalEdge_Width
DA3D LD A,E A=E.
DA3E AND A Jump to DrawVerticalEdge_Width if A is zero.
DA3F JR Z,DrawVerticalEdge_Width
DA41 LD A,$01 A=01.
DA43 JR DrawVerticalEdge_Columns Jump to DrawVerticalEdge_Columns.
DrawVerticalEdge_Width DA45 LD A,$01 A=01.
DrawVerticalEdge_Cells DA47 ADD A,$03 Add 03 to A.
DA49 DJNZ DrawVerticalEdge_Cells Decrease B and jump to DrawVerticalEdge_Cells until none remain.
DrawVerticalEdge_Columns DA4B LD ($5C24),A Update the column step size.
DA4E DEC A Step A back.
DA4F LD ($8384),A The extra columns of the edge.
DrawVerticalEdge_Sloped DA52 LD A,($CE59) The horizontal step copy.
DA55 AND A Jump to DrawVerticalEdge_Start if A is zero.
DA56 JP Z,DrawVerticalEdge_Start
DA59 LD A,(IX+$01) Read offset 01 of IX.
DA5C AND A Jump to DrawVerticalEdge_Start if A is not zero.
DA5D JR NZ,DrawVerticalEdge_Start
DA5F LD A,E A=E.
DA60 AND A Jump to DrawVerticalEdge_Move if A is zero.
DA61 JR Z,DrawVerticalEdge_Move
DA63 LD A,($5C32) The last contact flags.
DA66 AND A Jump to DrawVerticalEdge_Move if A is zero.
DA67 JR Z,DrawVerticalEdge_Move
DA69 LD A,H A=H.
DA6A CP $1F Jump to DrawVerticalEdge_Flags if A is 1F or more.
DA6C JR NC,DrawVerticalEdge_Flags
DrawVerticalEdge_Move DA6E LD A,($CCBB) The horizontal scroll speed.
DA71 NEG Negate A.
DA73 ADD A,L A gains L.
DA74 LD L,A L=A.
DrawVerticalEdge_Flags DA75 LD A,($5C32) The last contact flags.
DA78 AND A Jump to DrawVerticalEdge_Start if A is zero.
DA79 JR Z,DrawVerticalEdge_Start
DA7B CP $01 Jump to DrawVerticalEdge_Same if A is 01.
DA7D JR Z,DrawVerticalEdge_Same
DA7F LD A,($E41B) The slope direction.
DA82 CP $01 Jump to DrawVerticalEdge_Align if A is 01.
DA84 JR Z,DrawVerticalEdge_Align
DrawVerticalEdge_Reverse DA86 NEG Negate A.
DA88 LD ($E41B),A Update the slope direction.
DA8B JR DrawVerticalEdge_Align Jump to DrawVerticalEdge_Align.
DrawVerticalEdge_Same DA8D LD A,($E41B) The slope direction.
DA90 CP $01 Jump to DrawVerticalEdge_Reverse if A is 01.
DA92 JR Z,DrawVerticalEdge_Reverse
DrawVerticalEdge_Align DA94 LD A,L A=L.
DA95 AND %00000111 Keep the bits of A that are set in 07.
DA97 JR Z,DrawVerticalEdge_Start Jump to DrawVerticalEdge_Start if the zero flag is set.
DA99 LD A,($5C24) The column step size.
DA9C INC A Advance A.
DA9D LD ($5C24),A Update the column step size.
DrawVerticalEdge_Start DAA0 LD A,($CE37) The vertical step.
DAA3 AND A Call AdjustTerrainSlope if A is zero.
DAA4 CALL Z,AdjustTerrainSlope
DAA7 LD B,$00 Clear B.
DAA9 LD A,L A=L.
DAAA LD ($5C1C),A Update the screen column.
DAAD CP $F0 Jump to DrawVerticalEdge_Screen if A is less than F0.
DAAF JR C,DrawVerticalEdge_Screen
DAB1 LD L,B L=B.
DAB2 INC B Advance B.
DrawVerticalEdge_Screen DAB3 CALL GetScreenAddress Call GetScreenAddress.
DAB6 LD A,L A=L.
DAB7 SUB B Subtract B from A.
DAB8 LD L,A L=A.
DAB9 LD A,($5C24) The column step size.
DABC LD C,A C=A.
DABD LD A,($CE59) The horizontal step copy.
DAC0 AND A Jump to DrawVerticalEdge_Fill if A is zero.
DAC1 JP Z,DrawVerticalEdge_Fill
DAC4 LD A,($CE37) The vertical step.
DAC7 AND A Jump to DrawVerticalEdge_Flat if A is zero.
DAC8 JR Z,DrawVerticalEdge_Flat
DACA LD A,(IX+$01) Read offset 01 of IX.
DACD AND A Jump to DrawVerticalEdge_Slope if A is zero.
DACE JP Z,DrawVerticalEdge_Slope
DAD1 LD A,($5C1C) The screen column.
DAD4 AND %00000111 Keep the bits of A that are set in 07.
DAD6 JP NZ,DrawVerticalEdge_Slope Jump to DrawVerticalEdge_Slope if the zero flag is clear.
DAD9 LD A,($CCBB) The horizontal scroll speed.
DADC AND A Jump to DrawVerticalEdge_Draw if A is zero.
DADD JR Z,DrawVerticalEdge_Draw
DADF LD B,A B=A.
DAE0 LD A,($CCBA) The vertical scroll speed.
DAE3 XOR B Flip the bits of A that are set in B.
DAE4 LD B,A B=A.
DAE5 LD A,($E41B) The slope direction.
DAE8 XOR B Flip the bits of A that are set in B.
DAE9 BIT 7,A Jump to DrawVerticalEdge_Draw if bit 7 of A is clear.
DAEB JR Z,DrawVerticalEdge_Draw
DAED DEC L Step L back.
DAEE LD A,($CCBB) The horizontal scroll speed.
DAF1 BIT 7,A Jump to DrawVerticalEdge_Draw if bit 7 of A is clear.
DAF3 JR Z,DrawVerticalEdge_Draw
DAF5 INC L Advance L.
DAF6 INC L Advance L.
DrawVerticalEdge_Draw DAF7 JP DrawVerticalEdge_Fill Jump to DrawVerticalEdge_Fill.
DrawVerticalEdge_Flat DAFA LD A,(IX+$01) Read offset 01 of IX.
DAFD AND A Call AdjustEdgeAddress if A is zero.
DAFE CALL Z,AdjustEdgeAddress
DB01 JR DrawVerticalEdge_Fill Jump to DrawVerticalEdge_Fill.
DrawVerticalEdge_Slope DB03 LD A,($CE37) The vertical step.
DB06 AND A Jump to DrawVerticalEdge_Fill if A is zero.
DB07 JR Z,DrawVerticalEdge_Fill
DB09 LD A,($E41B) The slope direction.
DB0C CP $01 Compare A with 01.
DB0E LD A,($CCBA) The vertical scroll speed.
DB11 JR NZ,DrawVerticalEdge_Check Jump to DrawVerticalEdge_Check if the zero flag is clear.
DB13 NEG Negate A.
DrawVerticalEdge_Check DB15 BIT 7,A Jump to DrawVerticalEdge_Fill if bit 7 of A is clear.
DB17 JR Z,DrawVerticalEdge_Fill
DB19 INC L Advance L.
DrawVerticalEdge_Fill DB1A EXX Switch to the alternate registers.
DB1B LD A,($CE54) The steps already drawn.
DB1E LD B,A B=A.
DB1F CALL CallEdgePainter Call CallEdgePainter.
DB22 EXX Switch to the alternate registers.
DB23 JP FinishSegment_Colour Jump to FinishSegment_Colour.
Prev: D990 Up: Map Next: DB26