Thanks for the quick reply, that sorted the problem, unfortunatly I have another problem. The code runs but gets stuck in a Do, While loop and I can't work out why. Here is the code, in debug mode "sx" gets stuck at 250 and then doesnt seem to increase...
Function RenderMap(map,x_offset,y_offset)
ty = y_offset / TileHeight(map)
sy = -(y_offset Mod TileHeight(map))
While sy < SCREEN_HEIGHT
ty = ty Mod MapHeight(map)
tx = x_offset / TileWidth(map)
sx = -(x_offset Mod TileWidth(map))
While sx < SCREEN_WIDTH
tile = GetTile(map,tx Mod MapWidth(map),ty Mod MapHeight(map))
If tile >= 0 then DrawTile(map, sx, sy, tile)
tx = tx + 1
sx = sx + TileWidth(map)
EndWhile
ty = ty + 1
sy = sy + TileHeight(map)
EndWhile
EndFunction
the tile width is 32 and so sx should be geting increased by 32 each loop. the x/y offset will be 0 in debug mode as they are values passed in after being evaluated based on user key input left, right up and down arrows. ie x-offset is increased when the user holds the right arrow. I have attached the files with this. As i said I am just trying to get this to work so i can then implement it.