Prev: 55288 Up: Map Next: 55377
55306: 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 55306 LD SP,23418 Set the stack pointer to 23418.
55309 LD HL,(52813) Fetch the word at ScriptPointer into HL.
55312 LD A,(23584) The segments still to draw.
55315 DEC A Step A back.
55316 LD (23584),A Update the segments still to draw.
55319 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 55322 LD A,(23581) The tile number.
55325 INC A Advance A.
55326 LD (23581),A Update the tile number.
55329 CP 4 Jump to NextSegment_Done if A is 4.
55331 JR Z,NextSegment_Done
55333 BIT 0,A Test bit 0 of A.
55335 LD B,96 B=96.
55337 JR Z,NextSegment_Offset Jump to NextSegment_Offset if the zero flag is set.
55339 LD B,160 B=160.
NextSegment_Offset 55341 LD A,(52802) The vertical offset.
55344 ADD A,B A gains B.
55345 LD (52802),A Update the vertical offset.
55348 LD A,(23581) The tile number.
55351 CP 2 Jump to DrawTerrain_Record if A is not 2.
55353 JP NZ,DrawTerrain_Record
55356 LD B,32 B=32.
55358 LD A,(52801) The horizontal offset.
55361 SUB B Subtract B from A.
55362 LD (52801),A Update the horizontal offset.
55365 JP DrawTerrain_Record Jump to DrawTerrain_Record.
NextSegment_Done 55368 LD A,(52801) The horizontal offset.
55371 ADD A,32 Add 32 to A.
55373 LD (52801),A Update the horizontal offset.
55376 RET Return.
Prev: 55288 Up: Map Next: 55377