Prev: 43784 Up: Map Next: 43882
43800: 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 43800 LD A,(41575) Fetch the stage number.
43803 AND A Test whether this is a stage outside the town, which is the duel or the bonus stage.
43804 RET Z Return if it is, as it has no scenery.
Set the origin from the sheriff's cell.
43805 LD A,(41599) Fetch the horizontal cell of the sheriff.
43808 AND %11111110 Make it an even number.
43810 LD L,A Keep the even horizontal cell in L.
43811 LD A,(41601) Fetch the vertical cell of the sheriff.
43814 AND %11111110 Make it an even number.
43816 LD H,A Keep the even vertical cell in H.
43817 LD (41556),HL Store the cell as the origin for working out screen positions.
43820 CALL ProjectCell Work out where the origin is on the screen.
43823 LD HL,43882 Point HL at SceneryList.
Draw each scenery sprite that is on the screen.
DrawScenery_Loop 43826 LD A,(HL) Fetch the number of the sprite and its flip flag.
43827 AND A Test whether this is the end of the list.
43828 RET Z Return if it is.
43829 AND %01000000 Keep the flip flag.
43831 LD (41554),A Store the flip flag for the sprite drawing routine.
43834 LD A,(HL) Fetch the number of the sprite again.
43835 AND %00111111 Keep the number of the sprite.
43837 INC HL Move on to the horizontal offset.
43838 EX AF,AF' Keep the number of the sprite in the alternate accumulator.
43839 LD E,(HL) Fetch the horizontal offset of the sprite.
43840 INC HL Move on to the vertical offset.
43841 LD A,(41550) Fetch the horizontal position of the origin.
43844 ADD A,E Add the offset to find the horizontal position of the sprite.
43845 CP 208 Jump to DrawScenery_Skip to skip the sprite if it is off the right edge.
43847 JR NC,DrawScenery_Skip
43849 CP 16 Jump to DrawScenery_Skip to skip the sprite if it is off the left edge.
43851 JR C,DrawScenery_Skip
43853 LD E,A Copy the horizontal position into E.
43854 LD D,(HL) Fetch the vertical offset of the sprite.
43855 INC HL Move on to the next sprite in the list.
43856 LD A,(41552) Fetch the vertical position of the origin.
43859 ADD A,D Add the offset to find the vertical position of the sprite.
43860 AND %01111111 Wrap it into the range 0 to 127.
43862 ADD A,64 Move it down the screen.
43864 LD D,A Copy the vertical position into D.
43865 EX AF,AF' Retrieve the number of the sprite.
43866 PUSH HL Stash the address in the list on the stack.
43867 LD BC,26734 Point BC at ScenerySpritePointers.
43870 CALL GetTableEntry Point HL at the sprite.
43873 CALL DrawStripGraphic Draw the sprite.
43876 POP HL Retrieve the address in the list.
43877 JR DrawScenery_Loop Go back for the next sprite in the list.
Skip a sprite that is off the edge.
DrawScenery_Skip 43879 INC HL Skip the vertical offset of the sprite.
43880 JR DrawScenery_Loop Go back for the next sprite in the list.
Prev: 43784 Up: Map Next: 43882