mirror of
https://github.com/irmen/prog8.git
synced 2024-11-25 19:31:36 +00:00
cleanup c64 sprite examples
This commit is contained in:
parent
1f2d46628e
commit
40ce7725a1
@ -1,8 +1,6 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- rewrite c64 sprite examples to use the new @align64
|
||||
|
||||
- add docs for @alignxxx. Note: uninitialized (bss) variables are also correctly aligned (%option align docs say they're not, but that is fixed)
|
||||
- add docs for %align. Note: the directive doesn't modify variable declarations that may follow it!
|
||||
|
||||
|
@ -11,8 +11,8 @@ main {
|
||||
|
||||
sub start() {
|
||||
uword moon_x = 310
|
||||
c64.set_sprite_ptr(0, $0f00) ; alternatively, set directly: c64.SPRPTR[0] = $0f00 / 64
|
||||
c64.set_sprite_ptr(1, $0f00+64) ; alternatively, set directly: c64.SPRPTR[0] = $0f00 / 64
|
||||
c64.set_sprite_ptr(0, &spritedata.balloonsprite) ; alternatively, set directly: c64.SPRPTR[0] = $0f00 / 64
|
||||
c64.set_sprite_ptr(1, &spritedata.moonsprite) ; alternatively, set directly: c64.SPRPTR[0] = $0f00 / 64
|
||||
c64.SPENA = %00000011
|
||||
c64.SP0COL = 14
|
||||
c64.SP1COL = 7
|
||||
@ -156,55 +156,53 @@ irq {
|
||||
}
|
||||
|
||||
|
||||
spritedata $0f00 {
|
||||
; this memory block contains the sprite data. it must start on an address aligned to 64 bytes.
|
||||
; for simplicity, it's currently statically located at $0f00 (not far in memory after the program code),
|
||||
; but there are ways to do this more dynamically.
|
||||
%option force_output ; make sure the data in this block appears in the resulting program
|
||||
spritedata {
|
||||
; this block contains the sprite data. Sprites must start on an address aligned to 64 bytes.
|
||||
ubyte[] @align64 balloonsprite = [
|
||||
%00000000,%01111111,%00000000,
|
||||
%00000001,%11111111,%11000000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000111,%11011101,%11110000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000010,%11111111,%10100000,
|
||||
%00000001,%01111111,%01000000,
|
||||
%00000001,%00111110,%01000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00011100,%00000000
|
||||
]
|
||||
|
||||
ubyte[] balloonsprite = [ %00000000,%01111111,%00000000,
|
||||
%00000001,%11111111,%11000000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000111,%11011101,%11110000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000010,%11111111,%10100000,
|
||||
%00000001,%01111111,%01000000,
|
||||
%00000001,%00111110,%01000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00011100,%00000000,
|
||||
0]
|
||||
|
||||
ubyte[] moonsprite = [ %00000000,%00000110,%00000000,
|
||||
%00000000,%00011100,%00000000,
|
||||
%00000000,%01111000,%00000000,
|
||||
%00000000,%11111000,%00000000,
|
||||
%00000001,%11110000,%00000000,
|
||||
%00000011,%11110000,%00000000,
|
||||
%00000011,%11110000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000011,%11110000,%00000000,
|
||||
%00000011,%11110000,%00000000,
|
||||
%00000001,%11110000,%00000000,
|
||||
%00000000,%11111000,%00000000,
|
||||
%00000000,%01111000,%00000000,
|
||||
%00000000,%00011100,%00000000,
|
||||
%00000000,%00000110,%00000000,
|
||||
0]
|
||||
ubyte[] @align64 moonsprite = [
|
||||
%00000000,%00000110,%00000000,
|
||||
%00000000,%00011100,%00000000,
|
||||
%00000000,%01111000,%00000000,
|
||||
%00000000,%11111000,%00000000,
|
||||
%00000001,%11110000,%00000000,
|
||||
%00000011,%11110000,%00000000,
|
||||
%00000011,%11110000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000111,%11100000,%00000000,
|
||||
%00000011,%11110000,%00000000,
|
||||
%00000011,%11110000,%00000000,
|
||||
%00000001,%11110000,%00000000,
|
||||
%00000000,%11111000,%00000000,
|
||||
%00000000,%01111000,%00000000,
|
||||
%00000000,%00011100,%00000000,
|
||||
%00000000,%00000110,%00000000
|
||||
]
|
||||
}
|
||||
|
@ -2,64 +2,6 @@
|
||||
%import textio
|
||||
%import math
|
||||
|
||||
|
||||
spritedata $2000 {
|
||||
; this memory block contains the sprite data
|
||||
; it must start on an address aligned to 64 bytes.
|
||||
%option force_output ; make sure the data in this block appears in the resulting program
|
||||
|
||||
ubyte[] sprites = [
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00111100,%00000000,
|
||||
%00000000,%11111111,%00000000,
|
||||
%00000001,%11111101,%10000000,
|
||||
%00000001,%11111111,%10000000,
|
||||
%00000011,%11111111,%11000000,
|
||||
%00000011,%11111111,%11000000,
|
||||
%00000011,%11111111,%11000000,
|
||||
%00000001,%11111111,%10000000,
|
||||
%00000001,%11111111,%10000000,
|
||||
%00000000,%11111111,%00000000,
|
||||
%00000000,%00111100,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
|
||||
0,
|
||||
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%11111111,%10000000,
|
||||
%00000001,%11111110,%11000000,
|
||||
%00000011,%11111111,%01100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000111,%11111111,%11110000,
|
||||
%00000111,%11111111,%11110000,
|
||||
%00000111,%11111111,%11110000,
|
||||
%00000111,%11111111,%11110000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000001,%11111111,%11000000,
|
||||
%00000000,%11111111,%10000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
|
||||
0
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
main {
|
||||
|
||||
const uword width = 255
|
||||
@ -170,11 +112,63 @@ main {
|
||||
|
||||
; because we want speed, we don't use the dynamic c64.set_sprite_ptr() here
|
||||
if(zc < 30*128)
|
||||
c64.SPRPTR[i] = $2000/64 +1 ; large ball
|
||||
c64.SPRPTR[i] = lsb(&spritedata.sprite_large/64)
|
||||
else
|
||||
c64.SPRPTR[i] = $2000/64 ; small ball
|
||||
c64.SPRPTR[i] = lsb(&spritedata.sprite_small/64)
|
||||
|
||||
c64.SPCOL[i] = spritecolors[(zc>>13) as ubyte + 4] ; further away=darker color
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spritedata {
|
||||
; this memory block contains the sprite data
|
||||
; it must start on an address aligned to 64 bytes.
|
||||
ubyte[] @align64 sprite_small = [
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00111100,%00000000,
|
||||
%00000000,%11111111,%00000000,
|
||||
%00000001,%11111101,%10000000,
|
||||
%00000001,%11111111,%10000000,
|
||||
%00000011,%11111111,%11000000,
|
||||
%00000011,%11111111,%11000000,
|
||||
%00000011,%11111111,%11000000,
|
||||
%00000001,%11111111,%10000000,
|
||||
%00000001,%11111111,%10000000,
|
||||
%00000000,%11111111,%00000000,
|
||||
%00000000,%00111100,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000
|
||||
]
|
||||
|
||||
ubyte[] @align64 sprite_large = [
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%11111111,%10000000,
|
||||
%00000001,%11111110,%11000000,
|
||||
%00000011,%11111111,%01100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000111,%11111111,%11110000,
|
||||
%00000111,%11111111,%11110000,
|
||||
%00000111,%11111111,%11110000,
|
||||
%00000111,%11111111,%11110000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000001,%11111111,%11000000,
|
||||
%00000000,%11111111,%10000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000,
|
||||
%00000000,%00000000,%00000000
|
||||
]
|
||||
}
|
||||
|
@ -3,35 +3,6 @@
|
||||
%import math
|
||||
%zeropage basicsafe
|
||||
|
||||
|
||||
spritedata $0a00 {
|
||||
; this memory block contains the sprite data
|
||||
; it must start on an address aligned to 64 bytes.
|
||||
%option force_output ; make sure the data in this block appears in the resulting program
|
||||
|
||||
ubyte[] balloonsprite = [ %00000000,%01111111,%00000000,
|
||||
%00000001,%11111111,%11000000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000111,%11011101,%11110000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000010,%11111111,%10100000,
|
||||
%00000001,%01111111,%01000000,
|
||||
%00000001,%00111110,%01000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00011100,%00000000 ]
|
||||
}
|
||||
|
||||
main {
|
||||
|
||||
sub start() {
|
||||
@ -40,7 +11,7 @@ main {
|
||||
|
||||
ubyte @zp i
|
||||
for i in 0 to 7 {
|
||||
c64.set_sprite_ptr(i, $0a00) ; alternatively, set directly: c64.SPRPTR[i] = $0a00 / 64
|
||||
c64.set_sprite_ptr(i, &spritedata.balloonsprite) ; alternatively, set directly: c64.SPRPTR[i] = $0a00 / 64
|
||||
c64.SPXY[i*2] = 50+25*i
|
||||
c64.SPXY[i*2+1] = math.rnd()
|
||||
}
|
||||
@ -72,3 +43,32 @@ irq {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
spritedata {
|
||||
; this memory block contains the sprite data
|
||||
; it must start on an address aligned to 64 bytes.
|
||||
|
||||
ubyte[] @align64 balloonsprite = [
|
||||
%00000000,%01111111,%00000000,
|
||||
%00000001,%11111111,%11000000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000111,%11011101,%11110000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000010,%11111111,%10100000,
|
||||
%00000001,%01111111,%01000000,
|
||||
%00000001,%00111110,%01000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00011100,%00000000
|
||||
]
|
||||
}
|
||||
|
@ -2,40 +2,11 @@
|
||||
%import math
|
||||
%zeropage basicsafe
|
||||
|
||||
|
||||
spritedata $0a00 {
|
||||
; this memory block contains the sprite data
|
||||
; it must start on an address aligned to 64 bytes.
|
||||
%option force_output ; make sure the data in this block appears in the resulting program
|
||||
|
||||
ubyte[] balloonsprite = [ %00000000,%01111111,%00000000,
|
||||
%00000001,%11111111,%11000000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000111,%11011101,%11110000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000010,%11111111,%10100000,
|
||||
%00000001,%01111111,%01000000,
|
||||
%00000001,%00111110,%01000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00011100,%00000000 ]
|
||||
}
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
ubyte i
|
||||
for i in 0 to 7 {
|
||||
c64.set_sprite_ptr(i, $0a00) ; alternatively, set directly: c64.SPRPTR[i] = $0a00 / 64
|
||||
c64.set_sprite_ptr(i, &spritedata.balloonsprite) ; alternatively, set directly: c64.SPRPTR[i] = $0a00 / 64
|
||||
}
|
||||
c64.SPENA = 255 ; enable all sprites
|
||||
sys.set_rasterirq(&irq.irqhandler, 230) ; enable animation
|
||||
@ -65,3 +36,33 @@ irq {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
spritedata {
|
||||
; this memory block contains the sprite data
|
||||
; it must start on an address aligned to 64 bytes.
|
||||
|
||||
ubyte[] @align64 balloonsprite = [
|
||||
%00000000,%01111111,%00000000,
|
||||
%00000001,%11111111,%11000000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000111,%11011101,%11110000,
|
||||
%00000111,%11011100,%11110000,
|
||||
%00000011,%11100011,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000011,%11111111,%11100000,
|
||||
%00000010,%11111111,%10100000,
|
||||
%00000001,%01111111,%01000000,
|
||||
%00000001,%00111110,%01000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%10011100,%10000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%01001001,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00111110,%00000000,
|
||||
%00000000,%00011100,%00000000
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user