mirror of
https://github.com/irmen/prog8.git
synced 2025-01-24 06:30:24 +00:00
cx16 sprites module: the palette_offset parameter now takes values 0-15 (instead of 0-255) to be more consistent with docs and vera behavior
This commit is contained in:
parent
ddb8346711
commit
112d2d6058
@ -14,6 +14,7 @@ object Cp437Encoding {
|
||||
val mapped = str.map { chr ->
|
||||
when (chr) {
|
||||
'\u0000' -> 0u
|
||||
'\u00a0' -> 255u
|
||||
'☺' -> 1u
|
||||
'☻' -> 2u
|
||||
'♥' -> 3u
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
; note: sprites z-order will be in front of all layers.
|
||||
; note: collision mask is not supported here yet.
|
||||
; note: "palette offset" is counted as 0-15 (vera multiplies the offset by 16 to get at the actual color index)
|
||||
|
||||
sprites {
|
||||
%option ignore_unused
|
||||
@ -21,7 +22,7 @@ sprites {
|
||||
sub init(ubyte spritenum,
|
||||
ubyte databank, uword dataaddr,
|
||||
ubyte width_flag, ubyte height_flag,
|
||||
ubyte colors_flag, ubyte palette_offset_idx) {
|
||||
ubyte colors_flag, ubyte palette_offset) {
|
||||
hide(spritenum)
|
||||
cx16.VERA_DC_VIDEO |= %01000000 ; enable sprites globally
|
||||
dataaddr >>= 5
|
||||
@ -30,7 +31,7 @@ sprites {
|
||||
cx16.vpoke(1, sprite_reg, lsb(dataaddr)) ; address 12:5
|
||||
cx16.vpoke(1, sprite_reg+1, colors_flag | msb(dataaddr)) ; 4 bpp + address 16:13
|
||||
cx16.vpoke(1, sprite_reg+6, %00001100) ; z depth %11 = in front of both layers, no flips
|
||||
cx16.vpoke(1, sprite_reg+7, height_flag<<6 | width_flag<<4 | palette_offset_idx>>4) ; 64x64 pixels, palette offset
|
||||
cx16.vpoke(1, sprite_reg+7, height_flag<<6 | width_flag<<4 | palette_offset&15) ; 64x64 pixels, palette offset
|
||||
}
|
||||
|
||||
sub data(ubyte spritenum, ubyte bank, uword addr) {
|
||||
@ -143,7 +144,7 @@ sprites {
|
||||
}
|
||||
|
||||
sub set_palette_offset(ubyte spritenum, ubyte offset) {
|
||||
cx16.vpoke_mask(1, VERA_SPRITEREGS + 7 + spritenum*$0008, %11110000, offset>>4)
|
||||
cx16.vpoke_mask(1, VERA_SPRITEREGS + 7 + spritenum*$0008, %11110000, offset&15)
|
||||
}
|
||||
|
||||
sub set_mousepointer_hand() {
|
||||
|
@ -1,8 +1,6 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
change meaning of sprite module's palette offset parameter to 0-15
|
||||
|
||||
fix routines such as mult in verafx to return both 16-bit words of the result.
|
||||
|
||||
ubyte x,y compiles to more code than ubyte x + ubyte y
|
||||
|
@ -10,7 +10,7 @@ main {
|
||||
; we choose arbitrary unused vram location for sprite data: $12000
|
||||
const ubyte SPRITE_DATA_BANK = 1
|
||||
const uword SPRITE_DATA_ADDR = $2000
|
||||
const ubyte SPRITE_PALETTE_OFFSET_IDX = 16
|
||||
const ubyte SPRITE_PALETTE_OFFSET = 1 ; sprite palette at color index 16
|
||||
|
||||
sub start() {
|
||||
txt.plot(32,30)
|
||||
@ -18,11 +18,11 @@ main {
|
||||
|
||||
; load the sprite data and color palette directly into Vera ram
|
||||
void diskio.vload_raw("dragonsprite.bin", SPRITE_DATA_BANK, SPRITE_DATA_ADDR)
|
||||
void diskio.vload_raw("dragonsprite.pal", 1, $fa00 + SPRITE_PALETTE_OFFSET_IDX*2)
|
||||
void diskio.vload_raw("dragonsprite.pal", 1, $fa00 + SPRITE_PALETTE_OFFSET*16*2)
|
||||
|
||||
; initialize the dragon sprites
|
||||
sprites.init(1, SPRITE_DATA_BANK, SPRITE_DATA_ADDR, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, SPRITE_PALETTE_OFFSET_IDX)
|
||||
sprites.init(2, SPRITE_DATA_BANK, SPRITE_DATA_ADDR + 64*64/2, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16,SPRITE_PALETTE_OFFSET_IDX)
|
||||
sprites.init(1, SPRITE_DATA_BANK, SPRITE_DATA_ADDR, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, SPRITE_PALETTE_OFFSET)
|
||||
sprites.init(2, SPRITE_DATA_BANK, SPRITE_DATA_ADDR + 64*64/2, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16,SPRITE_PALETTE_OFFSET)
|
||||
|
||||
ubyte tt = 0
|
||||
word xpos = -64
|
||||
|
@ -10,7 +10,7 @@ main {
|
||||
; we choose arbitrary unused vram location for sprite data: $12000
|
||||
const ubyte SPRITE_DATA_BANK = 1
|
||||
const uword SPRITE_DATA_ADDR = $2000
|
||||
const ubyte SPRITE_PALETTE_OFFSET_IDX = 16
|
||||
const ubyte SPRITE_PALETTE_OFFSET = 1 ; sprite palette at color index 16
|
||||
|
||||
const ubyte NUM_DRAGONS = 25
|
||||
word[NUM_DRAGONS*2] xpositions
|
||||
@ -22,13 +22,13 @@ main {
|
||||
|
||||
; load the sprite data and color palette directly into Vera ram
|
||||
void diskio.vload_raw("dragonsprite.bin", SPRITE_DATA_BANK, SPRITE_DATA_ADDR)
|
||||
void diskio.vload_raw("dragonsprite.pal", 1, $fa00 + SPRITE_PALETTE_OFFSET_IDX*2)
|
||||
void diskio.vload_raw("dragonsprite.pal", 1, $fa00 + SPRITE_PALETTE_OFFSET*16*2)
|
||||
|
||||
; initialize the dragon sprites (every dragon needs 2 sprites, top and bottom half)
|
||||
ubyte sprite_num
|
||||
for sprite_num in 0 to NUM_DRAGONS*2-2 step 2 {
|
||||
sprites.init(sprite_num+1, SPRITE_DATA_BANK, SPRITE_DATA_ADDR, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, SPRITE_PALETTE_OFFSET_IDX)
|
||||
sprites.init(sprite_num+2, SPRITE_DATA_BANK, SPRITE_DATA_ADDR + 64*64/2, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, SPRITE_PALETTE_OFFSET_IDX)
|
||||
sprites.init(sprite_num+1, SPRITE_DATA_BANK, SPRITE_DATA_ADDR, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, SPRITE_PALETTE_OFFSET)
|
||||
sprites.init(sprite_num+2, SPRITE_DATA_BANK, SPRITE_DATA_ADDR + 64*64/2, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, SPRITE_PALETTE_OFFSET)
|
||||
|
||||
xpositions[sprite_num] = math.rndw() % (640-64) as word
|
||||
xpositions[sprite_num+1] = xpositions[sprite_num]
|
||||
|
Loading…
x
Reference in New Issue
Block a user