mirror of
https://github.com/irmen/prog8.git
synced 2024-12-18 07:29:36 +00:00
add palette.set_rgb_nosplit() and set_rbg_be_nosplit()
fix stream-wav missing rts which corrupted playback fix showbmx example palette and image centering
This commit is contained in:
parent
8644a4ae91
commit
1e9bbd662b
@ -22,7 +22,18 @@ palette {
|
||||
}
|
||||
|
||||
sub set_rgb_be(uword palette_ptr, uword num_colors, ubyte startindex) {
|
||||
; 1 word per color entry, $0rgb in big endian format
|
||||
; 1 word per color entry, $0rgb in big endian format (split arrays)
|
||||
cx16.vaddr(1, $fa00+(startindex as uword * 2), 0, 1)
|
||||
repeat num_colors {
|
||||
cx16.VERA_DATA0 = @(palette_ptr+num_colors)
|
||||
cx16.VERA_DATA0 = @(palette_ptr)
|
||||
palette_ptr++
|
||||
}
|
||||
cx16.VERA_ADDR_H &= 1
|
||||
}
|
||||
|
||||
sub set_rgb_be_nosplit(uword palette_ptr, uword num_colors, ubyte startindex) {
|
||||
; 1 word per color entry, $0rgb in big endian format (linear arrays)
|
||||
cx16.vaddr(1, $fa00+(startindex as uword * 2), 0, 1)
|
||||
repeat num_colors {
|
||||
cx16.VERA_DATA0 = @(palette_ptr+1)
|
||||
@ -33,7 +44,18 @@ palette {
|
||||
}
|
||||
|
||||
sub set_rgb(uword palette_words_ptr, uword num_colors, ubyte startindex) {
|
||||
; 1 word per color entry (in little endian format as layed out in video memory, so $gb;$0r)
|
||||
; 1 word per color entry (in little endian format as layed out in video memory, so $gb;$0r) (split arrays)
|
||||
cx16.vaddr(1, $fa00+(startindex as uword * 2), 0, 1)
|
||||
repeat num_colors {
|
||||
cx16.VERA_DATA0 = @(palette_words_ptr)
|
||||
cx16.VERA_DATA0 = @(palette_words_ptr+num_colors)
|
||||
palette_words_ptr++
|
||||
}
|
||||
cx16.VERA_ADDR_H &= 1
|
||||
}
|
||||
|
||||
sub set_rgb_nosplit(uword palette_words_ptr, uword num_colors, ubyte startindex) {
|
||||
; 1 word per color entry (in little endian format as layed out in video memory, so $gb;$0r) (linear arrays)
|
||||
cx16.vaddr(1, $fa00+(startindex as uword * 2), 0, 1)
|
||||
repeat num_colors {
|
||||
cx16.VERA_DATA0 = @(palette_words_ptr)
|
||||
@ -188,7 +210,7 @@ palette {
|
||||
|
||||
sub set_c64pepto() {
|
||||
; set first 16 colors to the "Pepto" PAL commodore-64 palette http://www.pepto.de/projects/colorvic/
|
||||
uword[] colors = [
|
||||
uword[] @nosplit colors = [
|
||||
$000, ; 0 = black
|
||||
$FFF, ; 1 = white
|
||||
$833, ; 2 = red
|
||||
@ -206,12 +228,12 @@ palette {
|
||||
$76e, ; 14 = light blue
|
||||
$bbb ; 15 = light grey
|
||||
]
|
||||
set_rgb(colors, len(colors), 0)
|
||||
set_rgb_nosplit(colors, len(colors), 0)
|
||||
}
|
||||
|
||||
sub set_c64ntsc() {
|
||||
; set first 16 colors to a NTSC commodore-64 palette
|
||||
uword[] colors = [
|
||||
uword[] @nosplit colors = [
|
||||
$000, ; 0 = black
|
||||
$FFF, ; 1 = white
|
||||
$934, ; 2 = red
|
||||
@ -229,12 +251,12 @@ palette {
|
||||
$36f, ; 14 = light blue
|
||||
$ccc ; 15 = light grey
|
||||
]
|
||||
set_rgb(colors, len(colors), 0)
|
||||
set_rgb_nosplit(colors, len(colors), 0)
|
||||
}
|
||||
|
||||
sub set_default16() {
|
||||
; set first 16 colors to the defaults on the X16
|
||||
uword[] colors = [
|
||||
uword[] @nosplit colors = [
|
||||
$000, ; 0 = black
|
||||
$fff, ; 1 = white
|
||||
$800, ; 2 = red
|
||||
@ -252,6 +274,6 @@ palette {
|
||||
$08f, ; 14 = light blue
|
||||
$bbb ; 15 = light grey
|
||||
]
|
||||
set_rgb(colors, len(colors), 0)
|
||||
set_rgb_nosplit(colors, len(colors), 0)
|
||||
}
|
||||
}
|
||||
|
@ -950,9 +950,9 @@ On the other targets, it only contains the definition of the 16 memory-mapped vi
|
||||
|
||||
bmx (cx16 only)
|
||||
----------------
|
||||
Routines to load and save "BMX" files, the CommanderX16 bitmap file format.
|
||||
Specification available here: https://cx16forum.com/forum/viewtopic.php?t=6945
|
||||
Only *uncompressed* bitmaps are supported in this library for now.
|
||||
Routines to load and save "BMX" files, the CommanderX16 bitmap file format:
|
||||
`BMX file format specification <https://cx16forum.com/forum/viewtopic.php?t=6945>`_
|
||||
Only the *uncompressed* bitmaps variant is supported in this library for now.
|
||||
|
||||
The routines are designed to be fast and bulk load/save the data directly into or from vram,
|
||||
without the need to buffer something in main memory.
|
||||
|
@ -2,20 +2,18 @@ TODO
|
||||
====
|
||||
|
||||
- DONE: make word arrays split by default (remove @split tag) and use new @nosplit tag to make an array use the old storage format?
|
||||
- DONE: invert -splitarrays command line option to -dontsplitarrays
|
||||
- DONE: remove "splitarrays" %option switch
|
||||
- DONE: &splitarray will give you the start address of the lsb-array (which is immediately followed by the msb-array)
|
||||
- DONE: invert -splitarrays command line option: -dontsplitarrays and remove "splitarrays" %option switch
|
||||
- DONE: added sprites.pos_batch_nosplit when the x/y arrays are linear instead of split word arrays
|
||||
- update Syntax files + Document all of this (also that word arrays can then have length 256 by default as well, and that @linear will reduce it to half.)
|
||||
- test all examples and projects
|
||||
- (paint has wrong palette colors)
|
||||
- cx16/balloonflight is black
|
||||
- cx16/bubbleunivers,kefrenbars has wrong colors
|
||||
- cx16 stream-wav has broken playback?
|
||||
- benchmark program became slower!? (did get smaller, just slower????)
|
||||
- showbmx example has wrong colors and doesn't center the picture correctly (robocat4.bmx) (imageviewer is fine?)
|
||||
- cx16/tehtriz should be better centered vertically
|
||||
- DONE: add palette.set_rgb_nosplit() and set_rbg_be_nosplit() for linear instead of split word arrays
|
||||
- update Syntax files + Document all of this (also that word arrays can then have length 256 by default as well, and that @nosplit will reduce it to half.)
|
||||
- also document that kernal routines such as FB_set_palette() expect a @nosplit word array otherwise colors turn up bad
|
||||
- benchmark program became slower!? (did get smaller)
|
||||
- add &< and &> operators to get the address of the lsb-array and msb-array, respectively.
|
||||
|
||||
- remove the error when using @split and make it so that @split always splits the array even when the dontsplit option is enabled. (ast check that you can only put this on word arrays)
|
||||
|
||||
- announce prog8 on the 6502.org site?
|
||||
|
||||
...
|
||||
|
||||
|
@ -124,9 +124,9 @@ spritedata {
|
||||
for cx16.r0 in 0 to 32*32/2-1
|
||||
cx16.VERA_DATA0 = @(&moonsprite + cx16.r0)
|
||||
|
||||
for cx16.r1L in 0 to 15 {
|
||||
palette.set_color(cx16.r1L + 16, balloon_pallette[cx16.r1L])
|
||||
palette.set_color(cx16.r1L + 32, moon_pallette[cx16.r1L])
|
||||
for cx16.r4L in 0 to 15 {
|
||||
palette.set_color(cx16.r4L + 16, balloon_pallette[cx16.r4L])
|
||||
palette.set_color(cx16.r4L + 32, moon_pallette[cx16.r4L])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ main {
|
||||
const ubyte s = 60
|
||||
float t
|
||||
|
||||
uword[] palette = [$000, $000, $00f, $f0f, $0ff, $fff]
|
||||
uword[] @nosplit palette = [$000, $000, $00f, $f0f, $0ff, $fff]
|
||||
cx16.FB_set_palette(palette, 0, len(palette))
|
||||
|
||||
repeat {
|
||||
|
@ -278,8 +278,7 @@ stereo {
|
||||
lda p8v_right_msb,y
|
||||
sta cx16.VERA_AUDIO_DATA
|
||||
iny
|
||||
iny
|
||||
cpy #16
|
||||
cpy #8
|
||||
bne -
|
||||
}}
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ _lp2 lda $ffff,y
|
||||
inc _lp2+2
|
||||
dex
|
||||
bne _loop
|
||||
; !notreached!
|
||||
rts
|
||||
}}
|
||||
; original prog8 code:
|
||||
; uword @requirezp ptr = main.start.buffer
|
||||
@ -391,8 +391,7 @@ _lp2 lda $ffff,y
|
||||
lda p8v_right_msb,y
|
||||
sta cx16.VERA_AUDIO_DATA
|
||||
iny
|
||||
iny
|
||||
cpy #16
|
||||
cpy #8
|
||||
bne -
|
||||
}}
|
||||
}
|
||||
|
@ -58,6 +58,12 @@ main {
|
||||
; need to use the slower load routine that does padding
|
||||
; center the image on the screen nicely
|
||||
uword offset = (320-bmx.width)/2 + (240-bmx.height)/2*320
|
||||
when(bmx.bitsperpixel) {
|
||||
1 -> offset /= 8
|
||||
2 -> offset /= 4
|
||||
4 -> offset /= 2
|
||||
else -> {}
|
||||
}
|
||||
if bmx.continue_load_stamp(0, offset, 320) {
|
||||
activate_palette()
|
||||
void txt.waitkey()
|
||||
@ -78,16 +84,16 @@ main {
|
||||
}
|
||||
|
||||
sub activate_palette() {
|
||||
; copies the pallette data from the memory buffer into vram
|
||||
; copies the palette data from the memory buffer into vram
|
||||
cx16.VERA_DC_BORDER = bmx.border
|
||||
cx16.r1 = bmx.palette_buffer_ptr
|
||||
cx16.r2L = bmx.palette_start
|
||||
cx16.r3L = lsb(bmx.palette_entries)
|
||||
cx16.r4 = bmx.palette_buffer_ptr
|
||||
cx16.r5L = bmx.palette_start
|
||||
cx16.r6L = lsb(bmx.palette_entries)
|
||||
do {
|
||||
palette.set_color(cx16.r2L, peekw(cx16.r1))
|
||||
cx16.r1+=2
|
||||
cx16.r2L++
|
||||
cx16.r3L--
|
||||
} until cx16.r3L==0
|
||||
palette.set_color(cx16.r5L, peekw(cx16.r4))
|
||||
cx16.r4+=2
|
||||
cx16.r5L++
|
||||
cx16.r6L--
|
||||
} until cx16.r6L==0
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
main {
|
||||
|
||||
const ubyte boardOffsetX = 14
|
||||
const ubyte boardOffsetY = 3
|
||||
const ubyte boardOffsetY = 5
|
||||
const ubyte boardWidth = 10
|
||||
const ubyte boardHeight = 20
|
||||
const ubyte startXpos = boardOffsetX + 3
|
||||
@ -306,25 +306,26 @@ waitkey:
|
||||
}
|
||||
|
||||
sub gameOver() {
|
||||
const ubyte yoffset = 7
|
||||
sound.gameover()
|
||||
txt.plot(7, 7)
|
||||
txt.plot(7, yoffset)
|
||||
txt.chrout('U')
|
||||
txt.print("────────────────────────")
|
||||
txt.chrout('I')
|
||||
txt.plot(7, 8)
|
||||
txt.plot(7, yoffset+1)
|
||||
txt.print("│*** g a m e o v e r ***│")
|
||||
txt.plot(7, 9)
|
||||
txt.plot(7, yoffset+2)
|
||||
txt.chrout('J')
|
||||
txt.print("────────────────────────")
|
||||
txt.chrout('K')
|
||||
|
||||
txt.plot(7, 18)
|
||||
txt.plot(7, yoffset+11)
|
||||
txt.chrout('U')
|
||||
txt.print("────────────────────────")
|
||||
txt.chrout('I')
|
||||
txt.plot(7, 19)
|
||||
txt.plot(7, yoffset+12)
|
||||
txt.print("│ f1/start for new game │")
|
||||
txt.plot(7, 20)
|
||||
txt.plot(7, yoffset+13)
|
||||
txt.chrout('J')
|
||||
txt.print("────────────────────────")
|
||||
txt.chrout('K')
|
||||
@ -367,36 +368,37 @@ waitkey:
|
||||
}
|
||||
|
||||
sub drawBoard() {
|
||||
const ubyte yoffset = 2
|
||||
txt.clear_screen()
|
||||
txt.color(7)
|
||||
txt.plot(1,1)
|
||||
txt.plot(1,1+yoffset)
|
||||
txt.print("* tehtriz *")
|
||||
txt.color(5)
|
||||
txt.plot(6,4)
|
||||
txt.plot(6,4+yoffset)
|
||||
txt.print("hold:")
|
||||
txt.plot(2,22)
|
||||
txt.plot(2,22+yoffset)
|
||||
txt.print("speed: ")
|
||||
txt.plot(28,3)
|
||||
txt.plot(28,3+yoffset)
|
||||
txt.print("next:")
|
||||
txt.plot(28,10)
|
||||
txt.plot(28,10+yoffset)
|
||||
txt.print("lines:")
|
||||
txt.plot(28,14)
|
||||
txt.plot(28,14+yoffset)
|
||||
txt.print("score:")
|
||||
txt.color(12)
|
||||
txt.plot(27,18)
|
||||
txt.plot(27,18+yoffset)
|
||||
txt.print("controls:")
|
||||
txt.color(11)
|
||||
txt.plot(28,19)
|
||||
txt.plot(28,19+yoffset)
|
||||
txt.print(",/ move")
|
||||
txt.plot(28,20)
|
||||
txt.plot(28,20+yoffset)
|
||||
txt.print("zx rotate")
|
||||
txt.plot(29,21)
|
||||
txt.plot(29,21+yoffset)
|
||||
txt.print(". descend")
|
||||
txt.plot(27,22)
|
||||
txt.plot(27,22+yoffset)
|
||||
txt.print("spc drop")
|
||||
txt.plot(29,23)
|
||||
txt.plot(29,23+yoffset)
|
||||
txt.print("c hold")
|
||||
txt.plot(25,24)
|
||||
txt.plot(25,24+yoffset)
|
||||
txt.print("or joystick #1")
|
||||
|
||||
txt.setcc(boardOffsetX-1, boardOffsetY-2, 255, 0) ; invisible barrier
|
||||
@ -423,25 +425,26 @@ waitkey:
|
||||
for i in len(colors)-1 downto 0 {
|
||||
ubyte x
|
||||
for x in 5 downto 0 {
|
||||
txt.setcc(6+x-i, 11+2*i, 102, colors[i])
|
||||
txt.setcc(6+x-i, 11+2*i+yoffset, 102, colors[i])
|
||||
}
|
||||
}
|
||||
drawScore()
|
||||
}
|
||||
|
||||
sub drawScore() {
|
||||
const ubyte yoffset=2
|
||||
txt.color(1)
|
||||
txt.plot(30,11)
|
||||
txt.plot(30,11+yoffset)
|
||||
txt.print_uw(lines)
|
||||
txt.plot(30,15)
|
||||
txt.plot(30,15+yoffset)
|
||||
txt.print_uw(score)
|
||||
txt.plot(9,22)
|
||||
txt.plot(9,22+yoffset)
|
||||
txt.print_ub(speedlevel)
|
||||
}
|
||||
|
||||
sub drawNextBlock() {
|
||||
const ubyte nextBlockXpos = 29
|
||||
const ubyte nextBlockYpos = 5
|
||||
const ubyte nextBlockYpos = 7
|
||||
ubyte x
|
||||
for x in nextBlockXpos+3 downto nextBlockXpos {
|
||||
txt.setcc2(x, nextBlockYpos, ' ', 0)
|
||||
@ -457,7 +460,7 @@ waitkey:
|
||||
|
||||
sub drawHoldBlock() {
|
||||
const ubyte holdBlockXpos = 7
|
||||
const ubyte holdBlockYpos = 6
|
||||
const ubyte holdBlockYpos = 8
|
||||
ubyte x
|
||||
for x in holdBlockXpos+3 downto holdBlockXpos {
|
||||
txt.setcc2(x, holdBlockYpos, '@', 0)
|
||||
|
@ -1,14 +1,12 @@
|
||||
%import textio
|
||||
%import palette
|
||||
%zeropage basicsafe
|
||||
%option no_sysinit
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
uword[] addresses = [scores2, start]
|
||||
uword[] scores1 = [10, 25, 50, 100]
|
||||
uword[] scores2 = [100, 250, 500, 1000]
|
||||
|
||||
cx16.r0 = &scores1
|
||||
cx16.r1 = &scores2
|
||||
cx16.r2 = &addresses
|
||||
palette.set_c64pepto()
|
||||
sys.wait(100)
|
||||
palette.set_default16()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user