Prev: D7F8 Up: Map Next: D851
D80A: Next Segment
Used by the routine at DrawTerrain.
Moves on to the next segment of the script, using the address that ReadSegmentShapes stored in ScriptPointer, until the last has been drawn. Then the next tile is started: the vertical offset (and for the third tile the horizontal offset) is changed to move to the position of that tile. After the fourth tile the horizontal offset is put back.
NextSegment D80A LD SP,$5B7A Set the stack pointer to 5B7A.
D80D LD HL,($CE4D) Fetch the word at ScriptPointer into HL.
D810 LD A,($5C20) The segments still to draw.
D813 DEC A Step A back.
D814 LD ($5C20),A Update the segments still to draw.
D817 JP NZ,DrawTerrain_Segment Jump to DrawTerrain_Segment if the zero flag is clear.
This entry point is used by the routine at DrawTerrain.
NextSegment_Tile D81A LD A,($5C1D) The tile number.
D81D INC A Advance A.
D81E LD ($5C1D),A Update the tile number.
D821 CP $04 Jump to NextSegment_Done if A is 04.
D823 JR Z,NextSegment_Done
D825 BIT 0,A Test bit 0 of A.
D827 LD B,$60 B=60.
D829 JR Z,NextSegment_Offset Jump to NextSegment_Offset if the zero flag is set.
D82B LD B,$A0 B=A0.
NextSegment_Offset D82D LD A,($CE42) The vertical offset.
D830 ADD A,B A gains B.
D831 LD ($CE42),A Update the vertical offset.
D834 LD A,($5C1D) The tile number.
D837 CP $02 Jump to DrawTerrain_Record if A is not 02.
D839 JP NZ,DrawTerrain_Record
D83C LD B,$20 B=20.
D83E LD A,($CE41) The horizontal offset.
D841 SUB B Subtract B from A.
D842 LD ($CE41),A Update the horizontal offset.
D845 JP DrawTerrain_Record Jump to DrawTerrain_Record.
NextSegment_Done D848 LD A,($CE41) The horizontal offset.
D84B ADD A,$20 Add 20 to A.
D84D LD ($CE41),A Update the horizontal offset.
D850 RET Return.
Prev: D7F8 Up: Map Next: D851