Prev: AB08 Up: Map Next: AB6A
AB18: Draw Scenery
Used by the routine at InitialiseGame.
Called every frame. In the town stage it draws the scenery sprites listed at SceneryList, which are fixed in the town and scroll with the view. Sprites which would be off the edge of the screen are skipped.
Return unless this is the town stage.
DrawScenery AB18 LD A,($A267) Fetch the stage number.
AB1B AND A Test whether this is a stage outside the town, which is the duel or the bonus stage.
AB1C RET Z Return if it is, as it has no scenery.
Set the origin from the sheriff's cell.
AB1D LD A,($A27F) Fetch the horizontal cell of the sheriff.
AB20 AND %11111110 Make it an even number.
AB22 LD L,A Keep the even horizontal cell in L.
AB23 LD A,($A281) Fetch the vertical cell of the sheriff.
AB26 AND %11111110 Make it an even number.
AB28 LD H,A Keep the even vertical cell in H.
AB29 LD ($A254),HL Store the cell as the origin for working out screen positions.
AB2C CALL ProjectCell Work out where the origin is on the screen.
AB2F LD HL,$AB6A Point HL at SceneryList.
Draw each scenery sprite that is on the screen.
DrawScenery_Loop AB32 LD A,(HL) Fetch the number of the sprite and its flip flag.
AB33 AND A Test whether this is the end of the list.
AB34 RET Z Return if it is.
AB35 AND %01000000 Keep the flip flag.
AB37 LD ($A252),A Store the flip flag for the sprite drawing routine.
AB3A LD A,(HL) Fetch the number of the sprite again.
AB3B AND %00111111 Keep the number of the sprite.
AB3D INC HL Move on to the horizontal offset.
AB3E EX AF,AF' Keep the number of the sprite in the alternate accumulator.
AB3F LD E,(HL) Fetch the horizontal offset of the sprite.
AB40 INC HL Move on to the vertical offset.
AB41 LD A,($A24E) Fetch the horizontal position of the origin.
AB44 ADD A,E Add the offset to find the horizontal position of the sprite.
AB45 CP $D0 Jump to DrawScenery_Skip to skip the sprite if it is off the right edge.
AB47 JR NC,DrawScenery_Skip
AB49 CP $10 Jump to DrawScenery_Skip to skip the sprite if it is off the left edge.
AB4B JR C,DrawScenery_Skip
AB4D LD E,A Copy the horizontal position into E.
AB4E LD D,(HL) Fetch the vertical offset of the sprite.
AB4F INC HL Move on to the next sprite in the list.
AB50 LD A,($A250) Fetch the vertical position of the origin.
AB53 ADD A,D Add the offset to find the vertical position of the sprite.
AB54 AND %01111111 Wrap it into the range 00 to 7F.
AB56 ADD A,$40 Move it down the screen.
AB58 LD D,A Copy the vertical position into D.
AB59 EX AF,AF' Retrieve the number of the sprite.
AB5A PUSH HL Stash the address in the list on the stack.
AB5B LD BC,$686E Point BC at ScenerySpritePointers.
AB5E CALL GetTableEntry Point HL at the sprite.
AB61 CALL DrawStripGraphic Draw the sprite.
AB64 POP HL Retrieve the address in the list.
AB65 JR DrawScenery_Loop Go back for the next sprite in the list.
Skip a sprite that is off the edge.
DrawScenery_Skip AB67 INC HL Skip the vertical offset of the sprite.
AB68 JR DrawScenery_Loop Go back for the next sprite in the list.
Prev: AB08 Up: Map Next: AB6A