The whole screen flickers if I don't use double buffering, but the way I do double buffering now is probably very inefficient. I'm trying to figure out how to do 8way scrolling with a large tilemap, I haven't found any example how to do this. I was thinking of using blockscroll and drawing only blocks coming in. It's working in one direction now but probably very inefficient. This is my code:
Code:
; TILEMAP TEST
#bm_map_width = 22
#bm_map_height = 14
; Set default type to word
DEFTYPE .w
BitMap 0,352,224,4 ; Create bitmap1
BitMap 1,352,224,4 ; Create bitmap2
BitMap 2,192,128,4 ; Bitmap for tiles, create and set as used
LoadBitMap 2,"set.iff"
LoadPalette 0,"set.iff"
; Get shapes from the bitmap containing tiles (increase the max number of shapes in compiler options to 200)
i = 0
For y = 0 To 7
For x = 0 To 11
GetaShape i, x LSL 4, y LSL 4, 16, 16
i = i + 1
Next
Next
; Free the shapes bitmap
Free BitMap 2
; Use bitmap 0 (shown on screen)
Use BitMap 0
; Read the tile map
map_xmax = 0
map_ymax = 0
If ReadFile(0,"tilemap102x74.map")
ReadMem 0, &map_xmax, 2 ; width in tiles
ReadMem 0, &map_ymax, 2 ; height in tiles
map_xmax-1 ; same as map_xmax = map_xmax - 1;
map_ymax-1
Dim mapa.b(map_xmax, map_ymax)
ReadMem 0, &mapa.b(0,0), (map_xmax+1)*(map_ymax+1)
CloseFile 0
EndIf
BLITZ ; Go into blitz mode
;Mouse On ; Turn on mouse
; Create the main slice (the bitmap width must be a multiple of 16, otherwise the graphics becomes scrambled)
; slice#, ypos, width, height, flags, bitplanes, sprites, colors, bitmap1_width, bitmap2_width
Slice 0,44,320,192,$fff8,4,8,16,352,352
Use Palette 0
; Draw tiles to fill the whole bitmap
For y = 0 to #bm_map_height-1
For x = 0 to #bm_map_width-1
; Map is exported from Tiled, there 0 means no tile, because of that the tile value is reduced by one
Block mapa(x,y)-1, x LSL 4, y LSL 4
Next
Next
x_map = 1
y_map = 1
x_slice = 16
y_slice = 16
db = 0
; }
Repeat
VWait
Show db, x_slice, y_slice ; Show the slice
CopyBitMap db, 1-db
db = 1-db
Use BitMap db
If Joyx(1) = 1
x_slice + 1
If x_slice MOD 16 = 0
BlockScroll 32,16,320,192,16,16
For y = 1 to #bm_map_height-2
Block mapa(mapposx+#bm_map_width,y)-1, 336, y LSL 4
Next
mapposx + 1
x_slice = 16
EndIf
End If
Until Joyb(1) > 0