AMOS TOME Series IV Manual Index | 13 |
Before starting your main loop, use the command Map Handle Init, which resets the various internal registers used by the Map Handle Command.
At the start of your main loop, you will need to take your current map co-ordinates (in pixels), and turn each into two values, the number of tiles and the remainder in pixels.
TOME has 4 commands to help you with this, =Map Hx(px) and =Map Hx(py) which return the number of tiles, and =Map Fx(px) and =Map Fy(py) which return the remainder.
The number of tiles is passed to the Map Handle command, along with the screen to display on. e.g
(MX & MY are the maps pixel co-ordinates)
HX=Map Hx(MX) HY=Map Hy(MY) FX=Map Fx(MX) FY=Map Fy(MY) Screen 1 Map Handle 1,HX,HY
You would then switch to screen 0 (your double buffered screen), and display any bobs (remember to turn Bob Update Off before the main loop), and you then do the screen copy, which copies the hidden version of the map to the double buffered screen, handling the pixel offset as it does it:
Screen Copy 1,FX,FY,Width+FX,Height+FY To Logic(0),0,0
Width and Height in the above command are the Width and Height of the area you want to see.
To finish off, you then do a Bob Draw command (To update the bobs) and a Screen Swap (To flip the screen to the front so that you can see it).
To move around this map, you simply have to add and subtract from the MX and MY variables. Any time you want to jump to a particular position in the map, do a Map Handle Init first.
For an example of using Map Handle to scroll, see the Map_Handle_Demo.Amos program on the TOME disk.