' problem with palettes 1
' Soleil
dim camera(1,1) as integer ' 0 = Position, 1 = Velocity
global grid(63,63) as integer
' Main
setgfxplane SCROLL_B
palettes soleil_pallette,0,0,16
loadtiles soleil_tiles,16,0
for i=0 to 127
grid(rnd(63),rnd(63)) = rnd(3)+1
next
render 0,0,20,14
render 0,0,20,14
' ******************************************************************************************************
setgfxplane SCROLL_A
pallettes fondf_pal,1,0,16 ' problem with palettes 1 ; 16 couleurs
loadtiles fondf,32,16 ' image d'une taille de 64*32 (64/8=8 et 32/8=4) donc 8*4 = 32 tiles ;
Drawtilesinc 16,0,0,8,4 ' 64/8 = 8 ; 32/8 = 4 ; 8*4 = 32 Tiles (0 � 31)
' ******************************************************************************************************
chti=addsprite(4,3) ' 4 sprites de haut sur 3 sprites de large (1 sprite = 8*8 pixel)
'palettes soleil_pallette,1,0,16
pallettes chti_pal,2,0,16 ' palette 1 ; 16 couleurs
loadtiles chti,12,552 ' image d'une taille de 24*32 donc 3*4 = 12 tiles ;
propsprite chti,552,2 ' 536 = tile vram offset ; palette 2
xplayer=160:movesprite chti,xplayer,250
' ******************************************************************************************************
while 1
Drawtilesinc 16,0,0,8,4 ' 64/8 = 8 ; 32/8 = 4 ; 8*4 = 32 Tiles (0 � 31)
joypad = joypad(0)
camera(0,1) = (joypad.3-joypad.2)*12
camera(1,1) = (joypad.1-joypad.0)*12
camera(0,0)+= camera(0,1)
camera(1,0)+= camera(1,1)
cx = divide(camera(0,0),16)
cy = divide(camera(1,0),16)
render cx ,cy,cx ,cy+13
render cx+20,cy,cx+20,cy+13
render cx,cy ,cx+20,cy
render cx,cy+14,cx+20,cy+14
scroll left,camera(0,1)
scroll up,camera(1,1)
sleep 1
wend
' Divide
declare function divide(x as integer, d as integer)
if x < 32768 then
return x/d
else
return -1-((0-x)/d)
endif
end function
' Render
declare sub render(x1 as integer, y1 as integer, x2 as integer, y2 as integer)
for x=x1 to x2
for y=y1 to y2
if x > 63 or y > 63 then
drawtiles tile_map,4,x*2,y*2,2,2
else
drawtiles tile_map,grid(x,y)*4,x*2,y*2,2,2
endif
next
next
exit sub
end sub
' **** DATA ****
fondf_pal:
DATAINT $000E,$02E0,$0EE0,$0E00,$0000,$0EEE,$0AAA,$0666
DATAINT $00EE,$0088,$0CCA,$0080,$08CE,$028E,$002E,$0866
' Picture size 64*32
fondf:
DATALONG $00000000 ' Tile #0
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000 ' Tile #1
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $11111111 ' Tile #2
DATALONG $11111111
DATALONG $11111111
DATALONG $11111111
DATALONG $11110000
DATALONG $11110000
DATALONG $11110000
DATALONG $11110000
DATALONG $11111111 ' Tile #3
DATALONG $11111111
DATALONG $11111111
DATALONG $11111111
DATALONG $00001111
DATALONG $00001111
DATALONG $00001111
DATALONG $00001111
DATALONG $22222222 ' Tile #4
DATALONG $22222222
DATALONG $22222222
DATALONG $22222222
DATALONG $22220000
DATALONG $22220000
DATALONG $22220000
DATALONG $22220000
DATALONG $22222222 ' Tile #5
DATALONG $22222222
DATALONG $22222222
DATALONG $22222222
DATALONG $00002222
DATALONG $00002222
DATALONG $00002222
DATALONG $00002222
DATALONG $33333333 ' Tile #6
DATALONG $33333333
DATALONG $33333333
DATALONG $33333333
DATALONG $33330000
DATALONG $33330000
DATALONG $33330000
DATALONG $33330000
DATALONG $33333333 ' Tile #7
DATALONG $33333333
DATALONG $33333333
DATALONG $33333333
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $00000000 ' Tile #8
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000 ' Tile #9
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $04444555
DATALONG $04444555
DATALONG $11110000 ' Tile #10
DATALONG $11110000
DATALONG $11110000
DATALONG $11110000
DATALONG $11110000
DATALONG $11110000
DATALONG $56666777
DATALONG $56666777
DATALONG $00001111 ' Tile #11
DATALONG $00001111
DATALONG $00001111
DATALONG $00001111
DATALONG $00001111
DATALONG $00001111
DATALONG $78888999
DATALONG $78888999
DATALONG $22220000 ' Tile #12
DATALONG $22220000
DATALONG $22220000
DATALONG $22220000
DATALONG $22220000
DATALONG $22220000
DATALONG $9AAAABBB
DATALONG $9AAAABBB
DATALONG $00002222 ' Tile #13
DATALONG $00002222
DATALONG $00002222
DATALONG $00002222
DATALONG $00002222
DATALONG $00002222
DATALONG $BCCCCDDD
DATALONG $BCCCCDDD
DATALONG $33330000 ' Tile #14
DATALONG $33330000
DATALONG $33330000
DATALONG $33330000
DATALONG $33330000
DATALONG $33330000
DATALONG $DEEEE000
DATALONG $DEEEE000
DATALONG $00003333 ' Tile #15
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $00000000 ' Tile #16
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $04444555 ' Tile #17
DATALONG $04444555
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $56666777 ' Tile #18
DATALONG $56666777
DATALONG $11110000
DATALONG $11110000
DATALONG $11110000
DATALONG $11110000
DATALONG $11110000
DATALONG $11110000
DATALONG $78888999 ' Tile #19
DATALONG $78888999
DATALONG $00001111
DATALONG $00001111
DATALONG $00001111
DATALONG $00001111
DATALONG $00001111
DATALONG $00001111
DATALONG $9AAAABBB ' Tile #20
DATALONG $9AAAABBB
DATALONG $22220000
DATALONG $22220000
DATALONG $22220000
DATALONG $22220000
DATALONG $22220000
DATALONG $22220000
DATALONG $BCCCCDDD ' Tile #21
DATALONG $BCCCCDDD
DATALONG $00002222
DATALONG $00002222
DATALONG $00002222
DATALONG $00002222
DATALONG $00002222
DATALONG $00002222
DATALONG $DEEEE000 ' Tile #22
DATALONG $DEEEE000
DATALONG $33330000
DATALONG $33330000
DATALONG $33330000
DATALONG $33330000
DATALONG $33330000
DATALONG $33330000
DATALONG $00003333 ' Tile #23
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $00000000 ' Tile #24
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000 ' Tile #25
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $00000000
DATALONG $11110000 ' Tile #26
DATALONG $11110000
DATALONG $11110000
DATALONG $11110000
DATALONG $11111111
DATALONG $11111111
DATALONG $11111111
DATALONG $11111111
DATALONG $00001111 ' Tile #27
DATALONG $00001111
DATALONG $00001111
DATALONG $00001111
DATALONG $11111111
DATALONG $11111111
DATALONG $11111111
DATALONG $11111111
DATALONG $22220000 ' Tile #28
DATALONG $22220000
DATALONG $22220000
DATALONG $22220000
DATALONG $22222222
DATALONG $22222222
DATALONG $22222222
DATALONG $22222222
DATALONG $00002222 ' Tile #29
DATALONG $00002222
DATALONG $00002222
DATALONG $00002222
DATALONG $22222222
DATALONG $22222222
DATALONG $22222222
DATALONG $22222222
DATALONG $33330000 ' Tile #30
DATALONG $33330000
DATALONG $33330000
DATALONG $33330000
DATALONG $33333333
DATALONG $33333333
DATALONG $33333333
DATALONG $33333333
DATALONG $00003333 ' Tile #31
DATALONG $00003333
DATALONG $00003333
DATALONG $00003333
DATALONG $33333333
DATALONG $33333333
DATALONG $33333333
DATALONG $33333333
chti_pal:
DATAINT $0E0E,$0000,$0A00,$0E44,$0EAA,$004A,$04AE,$0EEE
DATAINT $006E,$0000,$0000,$0000,$0000,$0000,$0000,$0000
chti:
'tiledata_sprite:
DATALONG $00000000 ' Tile #0
DATALONG $00000000
DATALONG $00011111
DATALONG $00123233
DATALONG $01232333
DATALONG $01223233
DATALONG $01232333
DATALONG $01223233
DATALONG $01232333 ' Tile #1
DATALONG $01223233
DATALONG $01231111
DATALONG $01111111
DATALONG $01555155
DATALONG $01555166
DATALONG $01555166
DATALONG $01555166
DATALONG $01555166 ' Tile #2
DATALONG $00155166
DATALONG $00011111
DATALONG $00000122
DATALONG $00000122
DATALONG $00000122
DATALONG $00000122
DATALONG $00000122
DATALONG $00000122 ' Tile #3
DATALONG $00000122
DATALONG $00000122
DATALONG $00000111
DATALONG $00000155
DATALONG $00000155
DATALONG $00000111
DATALONG $00000000
DATALONG $00000000 ' Tile #4
DATALONG $00000000
DATALONG $11111111
DATALONG $33344444
DATALONG $33333333
DATALONG $33333333
DATALONG $33333333
DATALONG $33333333
DATALONG $33331111 ' Tile #5
DATALONG $11112333
DATALONG $22222223
DATALONG $11111111
DATALONG $55555555
DATALONG $66666666
DATALONG $77116677
DATALONG $77116677
DATALONG $66666666 ' Tile #6
DATALONG $66111166
DATALONG $11111111
DATALONG $22222222
DATALONG $32333333
DATALONG $23333333
DATALONG $32333333
DATALONG $23333333
DATALONG $32333333 ' Tile #7
DATALONG $23333333
DATALONG $32333333
DATALONG $11111111
DATALONG $85888881
DATALONG $58588881
DATALONG $11111111
DATALONG $00000000
DATALONG $00000000 ' Tile #8
DATALONG $00000000
DATALONG $10000000
DATALONG $41000000
DATALONG $34100000
DATALONG $33410000
DATALONG $33410000
DATALONG $31110000
DATALONG $13441000 ' Tile #9
DATALONG $34333100
DATALONG $33333310
DATALONG $11111110
DATALONG $55551000
DATALONG $66661000
DATALONG $11661000
DATALONG $11661000
DATALONG $66661000 ' Tile #10
DATALONG $66661000
DATALONG $11111000
DATALONG $23100000
DATALONG $34100000
DATALONG $34100000
DATALONG $34100000
DATALONG $34100000
DATALONG $34100000 ' Tile #11
DATALONG $34100000
DATALONG $34100000
DATALONG $11100000
DATALONG $58100000
DATALONG $58100000
DATALONG $11100000
DATALONG $00000000
' Map
tile_map:
data 0, 1
data 2, 3
' Data
soleil_pallette:
dataint $04CA,$06AA,$04CA,$08EE,$0466,$0664,$04A6,$0EEE
dataint $026A,$068A,$0468,$0000,$0000,$0000,$0000,$0000
soleil_tiles:
datalong $21232232
datalong $32323222
datalong $23212232
datalong $22222323
datalong $32323232
datalong $22322122
datalong $23233232
datalong $32322323
datalong $23223212
datalong $22232323
datalong $23221232
datalong $32322222
datalong $23232323
datalong $22122322
datalong $23233232
datalong $32322323
datalong $32322323
datalong $23233232
datalong $22122322
datalong $23232323
datalong $32322222
datalong $23221232
datalong $22232323
datalong $23223212
datalong $32322323
datalong $23233232
datalong $22322122
datalong $32323232
datalong $22222323
datalong $23212232
datalong $32323222
datalong $21232232
datalong $22222245
datalong $55522225
datalong $25655252
datalong $22626546
datalong $22562645
datalong $55555644
datalong $52335542
datalong $25623452
datalong $25222555
datalong $24225364
datalong $46553252
datalong $55432642
datalong $54426542
datalong $54325445
datalong $44265455
datalong $34254542
datalong $22562452
datalong $25646456
datalong $52364456
datalong $65236546
datalong $24523645
datalong $26452254
datalong $22264554
datalong $22226645
datalong $24654455
datalong $23644632
datalong $22446326
datalong $62443265
datalong $66462652
datalong $56455562
datalong $45554622
datalong $55462222
datalong $25555555
datalong $51333333
datalong $53777777
datalong $51333333
datalong $51344343
datalong $51333333
datalong $51343443
datalong $51333333
datalong $55555552
datalong $33333315
datalong $77777735
datalong $33333315
datalong $34344315
datalong $33333315
datalong $34434315
datalong $33333315
datalong $58888888
datalong $65555555
datalong $66666644
datalong $26666649
datalong $22262249
datalong $2622224A
datalong $22226264
datalong $22222226
datalong $88888885
datalong $55555556
datalong $44666666
datalong $94666662
datalong $94226222
datalong $A4222262
datalong $46262222
datalong $62222222
datalong $22222555
datalong $22625333
datalong $62253AAA
datalong $2253A44A
datalong $25434444
datalong $25434444
datalong $5A493444
datalong $4A949333
datalong $55522222
datalong $33352622
datalong $AAA35226
datalong $A44A3522
datalong $44443452
datalong $44443452
datalong $444394A5
datalong $333949A4
datalong $4A99A999
datalong $4A919AAA
datalong $54911999
datalong $54A91111
datalong $654A9999
datalong $2654AAAA
datalong $22654444
datalong $22265555
datalong $999A99A4
datalong $AAA919A4
datalong $99911945
datalong $11119A45
datalong $9999A456
datalong $AAAA4562
datalong $44445622
datalong $55556222