Aha, ready made tiling snippet to the rescue
#constant TILE_WIDTH 64
#constant TILE_HEIGHT 64
#constant GRID_WIDTH 40
#constant GRID_HEIGHT 40
flush video memory
sync on
sync rate 0
hide mouse
BuildBackgroundTile()
BuildSpriteImages()
dim map(GRID_WIDTH-1, GRID_HEIGHT-1) as integer
for x=0 to GRID_WIDTH-1
for y=0 to GRID_HEIGHT-1
map(x,y)=1
next y
next x
x=0
y=0
sprite 1,320,240,2
offset sprite 1,31,31
TilesAcross=screen width() / TILE_WIDTH
TilesDown=screen height() / TILE_HEIGHT
do
if leftkey()=1 and x<0 then inc x,4 : set sprite image 1,4
if rightkey()=1 and x>(0-(TILE_WIDTH*(GRID_WIDTH-TilesAcross))) then dec x,4 : set sprite image 1,5
if upkey()=1 and y<0 then inc y,4 : set sprite image 1,2
if downkey()=1 and y>(0-(TILE_HEIGHT*(GRID_HEIGHT-TilesDown))) then dec y,4 : set sprite image 1,3
DrawMap(x,y)
sync
loop
wait key
function DrawMap(bx as integer, by as integer)
local sx as integer
local sy as integer
local x as integer
local y as integer
for x=0 to GRID_WIDTH-1
sx=bx+(x*TILE_WIDTH)
if sx > 0-TILE_WIDTH and sx < bitmap width()
for y=0 to GRID_HEIGHT-1
sy=by+(y*TILE_HEIGHT)
if sy > 0-TILE_HEIGHT and sy < bitmap height()
paste image map(x,y), sx, sy
text sx, sy, str$(x) + "/" + str$(y)
endif
next y
endif
next x
endfunction
function BuildBackgroundTile()
box 0,0,TILE_WIDTH,TILE_HEIGHT,rgb(255,0,0),rgb(0,0,255),rgb(0,255,0),rgb(127,0,127)
get image 1,0,0,TILE_WIDTH,TILE_HEIGHT,1
endfunction
function BuildSpriteImages()
` Just triangles to give the effect
cls : for x=0 to 63 : line 31,0,x,63 : next x : get image 2,0,0,64,64,1
cls : for x=0 to 63 : line 31,63,x,0 : next x : get image 3,0,0,64,64,1
cls : for x=0 to 63 : line 0,31,63,x : next x : get image 4,0,0,64,64,1
cls : for x=0 to 63 : line 63,31,0,x : next x : get image 5,0,0,64,64,1
endfunction
It doesn't have very good graphics, but you can see it scrolling in eight directions by using the arrow keys. Oh, and the sprite in the centre was just to show how to scroll but keep your character at the centre.
The clipping routine isn't great either, but I didn't have the time to do it properly ... it does run fast enough without it, but with a larger tiling area it would be slow.