mirror of
https://github.com/irmen/prog8.git
synced 2024-11-27 03:50:27 +00:00
added c64colors module. added vpeek/vpoke to cx16 syslib. koalaviewer example now uses better c64 color palette.
This commit is contained in:
parent
a303b39cf0
commit
6f74fb49bd
87
compiler/res/prog8lib/cx16/c64colors.p8
Normal file
87
compiler/res/prog8lib/cx16/c64colors.p8
Normal file
@ -0,0 +1,87 @@
|
||||
%target cx16
|
||||
|
||||
c64colors {
|
||||
uword[] colorpalette_dark = [ ; this is a darker palette with more contrast
|
||||
$000, ; 0 = black
|
||||
$FFF, ; 1 = white
|
||||
$632, ; 2 = red
|
||||
$7AB, ; 3 = cyan
|
||||
$638, ; 4 = purple
|
||||
$584, ; 5 = green
|
||||
$327, ; 6 = blue
|
||||
$BC6, ; 7 = yellow
|
||||
$642, ; 8 = orange
|
||||
$430, ; 9 = brown
|
||||
$965, ; 10 = light red
|
||||
$444, ; 11 = dark grey
|
||||
$666, ; 12 = medium grey
|
||||
$9D8, ; 13 = light green
|
||||
$65B, ; 14 = light blue
|
||||
$999 ; 15 = light grey
|
||||
]
|
||||
|
||||
uword[] colorpalette_pepto = [ ; # this is Pepto's Commodore-64 palette http://www.pepto.de/projects/colorvic/
|
||||
$000, ; 0 = black
|
||||
$FFF, ; 1 = white
|
||||
$833, ; 2 = red
|
||||
$7cc, ; 3 = cyan
|
||||
$839, ; 4 = purple
|
||||
$5a4, ; 5 = green
|
||||
$229, ; 6 = blue
|
||||
$ef7, ; 7 = yellow
|
||||
$852, ; 8 = orange
|
||||
$530, ; 9 = brown
|
||||
$c67, ; 10 = light red
|
||||
$444, ; 11 = dark grey
|
||||
$777, ; 12 = medium grey
|
||||
$af9, ; 13 = light green
|
||||
$76e, ; 14 = light blue
|
||||
$bbb ; 15 = light grey
|
||||
]
|
||||
|
||||
uword[] colorpalette_light = [ ; this is a lighter palette
|
||||
$000, ; 0 = black
|
||||
$FFF, ; 1 = white
|
||||
$944, ; 2 = red
|
||||
$7CC, ; 3 = cyan
|
||||
$95A, ; 4 = purple
|
||||
$6A5, ; 5 = green
|
||||
$549, ; 6 = blue
|
||||
$CD8, ; 7 = yellow
|
||||
$963, ; 8 = orange
|
||||
$650, ; 9 = brown
|
||||
$C77, ; 10 = light red
|
||||
$666, ; 11 = dark grey
|
||||
$888, ; 12 = medium grey
|
||||
$AE9, ; 13 = light green
|
||||
$87C, ; 14 = light blue
|
||||
$AAA ; 15 = light grey
|
||||
]
|
||||
|
||||
ubyte color
|
||||
|
||||
sub set_palette_pepto() {
|
||||
for color in 0 to 15 {
|
||||
uword cc = colorpalette_pepto[color]
|
||||
cx16.vpoke(1, $fa00 + color*2, lsb(cc)) ; G, B
|
||||
cx16.vpoke(1, $fa01 + color*2, msb(cc)) ; R
|
||||
}
|
||||
}
|
||||
|
||||
sub set_palette_light() {
|
||||
for color in 0 to 15 {
|
||||
uword cc = colorpalette_light[color]
|
||||
cx16.vpoke(1, $fa00 + color*2, lsb(cc)) ; G, B
|
||||
cx16.vpoke(1, $fa01 + color*2, msb(cc)) ; R
|
||||
}
|
||||
}
|
||||
|
||||
sub set_palette_dark() {
|
||||
for color in 0 to 15 {
|
||||
uword cc = colorpalette_dark[color]
|
||||
cx16.vpoke(1, $fa00 + color*2, lsb(cc)) ; G, B
|
||||
cx16.vpoke(1, $fa01 + color*2, msb(cc)) ; R
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -242,9 +242,44 @@ romsub $fecf = entropy_get() -> ubyte @A, ubyte @X, ubyte @Y
|
||||
romsub $fecc = monitor() clobbers(A,X,Y)
|
||||
|
||||
|
||||
|
||||
; ---- end of kernal routines ----
|
||||
|
||||
; ---- utilities -----
|
||||
asmsub vpeek(ubyte bank @A, uword address @XY) -> ubyte @A {
|
||||
; -- get a byte from VERA's video memory
|
||||
; note: inefficient when reading multiple sequential bytes!
|
||||
%asm {{
|
||||
stz cx16.VERA_CTRL
|
||||
and #1
|
||||
sta cx16.VERA_ADDR_H
|
||||
sty cx16.VERA_ADDR_M
|
||||
stx cx16.VERA_ADDR_L
|
||||
lda cx16.VERA_DATA0
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
sub vpoke(ubyte bank, uword address, ubyte value) {
|
||||
; -- write a single byte to VERA's video memory
|
||||
; note: inefficient when writing multiple sequential bytes!
|
||||
%asm {{
|
||||
stz cx16.VERA_CTRL
|
||||
lda bank
|
||||
and #1
|
||||
sta cx16.VERA_ADDR_H
|
||||
lda address
|
||||
sta cx16.VERA_ADDR_L
|
||||
lda address+1
|
||||
sta cx16.VERA_ADDR_M
|
||||
lda value
|
||||
sta cx16.VERA_DATA0
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
|
||||
; ---- system stuff -----
|
||||
|
||||
asmsub init_system() {
|
||||
; Initializes the machine to a sane starting state.
|
||||
; Called automatically by the loader program logic.
|
||||
|
@ -88,6 +88,15 @@ A 'fun' module that contains the Commander X16 logo and that allows you
|
||||
to print it anywhere on the screen.
|
||||
|
||||
|
||||
c64colors
|
||||
---------
|
||||
Available for the CommanderX16 target, a module that contains a few better
|
||||
color palettes for how the colors of the VIC-II looked on the Commodore-64.
|
||||
There are subroutines to activate one of the several palettes of your liking.
|
||||
The Commander X16's default colors for this (the first 16 colors) are too saturated
|
||||
and are quite different than how a C-64 looked.
|
||||
|
||||
|
||||
prog8_lib
|
||||
---------
|
||||
Low level language support. You should not normally have to bother with this directly.
|
||||
|
@ -2,6 +2,7 @@
|
||||
%import graphics
|
||||
%import textio
|
||||
%import diskio
|
||||
%import c64colors
|
||||
|
||||
main {
|
||||
const uword load_location = $4000
|
||||
@ -19,6 +20,8 @@ main {
|
||||
"i07-katakis-jegg.bin"
|
||||
]
|
||||
|
||||
; set a better C64 color palette, the Cx16's default is too saturated
|
||||
c64colors.set_palette_pepto()
|
||||
graphics.enable_bitmap_mode()
|
||||
repeat {
|
||||
ubyte file_idx
|
||||
|
@ -1,58 +0,0 @@
|
||||
%import textio
|
||||
%import diskio
|
||||
%import test_stack
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
repeat 80 {
|
||||
txt.print("screen .1. ")
|
||||
}
|
||||
|
||||
diskio.delete(8, "screen1.bin")
|
||||
diskio.delete(8, "screen2.bin")
|
||||
|
||||
if not diskio.save(8, "screen1.bin", $0400, 40*25) {
|
||||
txt.print("can't save screen1\n")
|
||||
diskio.status(8)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
repeat 80 {
|
||||
txt.print("screen *2* ")
|
||||
}
|
||||
|
||||
if not diskio.save(8, "screen2.bin", $0400, 40*25) {
|
||||
txt.print("can't save screen2\n")
|
||||
diskio.status(8)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
txt.clear_screen()
|
||||
uword length = diskio.load(8, "screen1.bin", $0400)
|
||||
txt.print_uw(length)
|
||||
txt.chrout('\n')
|
||||
if not length {
|
||||
txt.print("can't load screen1\n")
|
||||
diskio.status(8)
|
||||
exit(1)
|
||||
}
|
||||
length = diskio.load(8, "screen2.bin", $0400)
|
||||
txt.print_uw(length)
|
||||
txt.chrout('\n')
|
||||
if not length {
|
||||
txt.print("can't load screen2\n")
|
||||
diskio.status(8)
|
||||
exit(1)
|
||||
}
|
||||
length = diskio.load(8, "screen3.bin", $0400)
|
||||
txt.print_uw(length)
|
||||
txt.chrout('\n')
|
||||
if not length {
|
||||
txt.print("can't load screen3\n")
|
||||
diskio.status(8)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -4,38 +4,12 @@
|
||||
%import test_stack
|
||||
|
||||
main {
|
||||
|
||||
sub start() {
|
||||
uword foo = [1,2,3,4] ; TODO SYNTAX ERROR
|
||||
uword bar = "sdfadsaf" ; TODO SYNTAX ERROR
|
||||
|
||||
|
||||
|
||||
txt.print("hello\n")
|
||||
}
|
||||
sub convert_koalapic() {
|
||||
ubyte cx ; TODO when making this a word, the code size increases drastically
|
||||
ubyte cy
|
||||
uword xx
|
||||
ubyte yy
|
||||
ubyte bb
|
||||
uword bitmap = $6000
|
||||
|
||||
ubyte c0
|
||||
ubyte c1
|
||||
ubyte c2
|
||||
ubyte c3
|
||||
|
||||
for cy in 0 to 24 {
|
||||
for cx in 0 to 39 {
|
||||
for bb in 0 to 7 {
|
||||
yy = cy * 8 + bb
|
||||
xx = cx * $0008
|
||||
graphics.plot(xx, yy)
|
||||
graphics.plot(xx+1, yy)
|
||||
graphics.plot(xx+2, yy)
|
||||
graphics.plot(xx+3, yy)
|
||||
graphics.plot(xx+4, yy)
|
||||
graphics.plot(xx+5, yy)
|
||||
graphics.plot(xx+6, yy)
|
||||
graphics.plot(xx+7, yy)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user