mirror of
https://github.com/irmen/prog8.git
synced 2024-12-25 08:29:25 +00:00
added C64 'koala' image viewer example for Cx16
This commit is contained in:
parent
3e63a29c59
commit
a303b39cf0
BIN
examples/cx16/imgviewer/I01-BLUBB-SPHINX.BIN
Executable file
BIN
examples/cx16/imgviewer/I01-BLUBB-SPHINX.BIN
Executable file
Binary file not shown.
BIN
examples/cx16/imgviewer/I02-BUGJAM-JSL.BIN
Executable file
BIN
examples/cx16/imgviewer/I02-BUGJAM-JSL.BIN
Executable file
Binary file not shown.
BIN
examples/cx16/imgviewer/I03-DINOTHAWR-AR.BIN
Executable file
BIN
examples/cx16/imgviewer/I03-DINOTHAWR-AR.BIN
Executable file
Binary file not shown.
BIN
examples/cx16/imgviewer/I04-FOX-LEON.BIN
Executable file
BIN
examples/cx16/imgviewer/I04-FOX-LEON.BIN
Executable file
Binary file not shown.
BIN
examples/cx16/imgviewer/I05-HUNTER-AGOD.BIN
Executable file
BIN
examples/cx16/imgviewer/I05-HUNTER-AGOD.BIN
Executable file
Binary file not shown.
BIN
examples/cx16/imgviewer/I06-JAZZMAN-JDS.BIN
Executable file
BIN
examples/cx16/imgviewer/I06-JAZZMAN-JDS.BIN
Executable file
Binary file not shown.
BIN
examples/cx16/imgviewer/I07-KATAKIS-JEGG.BIN
Executable file
BIN
examples/cx16/imgviewer/I07-KATAKIS-JEGG.BIN
Executable file
Binary file not shown.
BIN
examples/cx16/imgviewer/TEST.PCX
Executable file
BIN
examples/cx16/imgviewer/TEST.PCX
Executable file
Binary file not shown.
112
examples/cx16/imgviewer/koalaviewer.p8
Normal file
112
examples/cx16/imgviewer/koalaviewer.p8
Normal file
@ -0,0 +1,112 @@
|
||||
%target cx16
|
||||
%import graphics
|
||||
%import textio
|
||||
%import diskio
|
||||
|
||||
main {
|
||||
const uword load_location = $4000
|
||||
ubyte screen_color
|
||||
|
||||
sub start() {
|
||||
|
||||
str[] pictures = [
|
||||
"i01-blubb-sphinx.bin",
|
||||
"i02-bugjam-jsl.bin",
|
||||
"i03-dinothawr-ar.bin",
|
||||
"i04-fox-leon.bin",
|
||||
"i05-hunter-agod.bin",
|
||||
"i06-jazzman-jds.bin",
|
||||
"i07-katakis-jegg.bin"
|
||||
]
|
||||
|
||||
graphics.enable_bitmap_mode()
|
||||
repeat {
|
||||
ubyte file_idx
|
||||
for file_idx in 0 to len(pictures)-1 {
|
||||
load_image(pictures[file_idx])
|
||||
wait()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub wait() {
|
||||
uword jiffies = 0
|
||||
c64.SETTIM(0,0,0)
|
||||
|
||||
while jiffies < 180 {
|
||||
; read clock
|
||||
%asm {{
|
||||
stx P8ZP_SCRATCH_REG
|
||||
jsr c64.RDTIM
|
||||
sta jiffies
|
||||
stx jiffies+1
|
||||
ldx P8ZP_SCRATCH_REG
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
sub load_image(uword filenameptr) {
|
||||
uword length = diskio.load(8, filenameptr, load_location)
|
||||
|
||||
if length != 10001 {
|
||||
txt.print_uw(length)
|
||||
txt.print("\nload error\n")
|
||||
diskio.status(8)
|
||||
exit(1)
|
||||
}
|
||||
convert_koalapic()
|
||||
}
|
||||
|
||||
sub convert_koalapic() {
|
||||
ubyte cx
|
||||
ubyte cy
|
||||
uword cy_times_forty = 0
|
||||
ubyte bb
|
||||
ubyte c0
|
||||
ubyte c1
|
||||
ubyte c2
|
||||
ubyte c3
|
||||
uword bitmap = load_location
|
||||
|
||||
screen_color = @(load_location + 8000 + 1000 + 1000) & 15
|
||||
|
||||
for cy in 0 to 24 {
|
||||
for cx in 0 to 39 {
|
||||
for bb in 0 to 7 {
|
||||
cx16.r0 = cx * $0008
|
||||
cx16.r1 = cy * 8 + bb
|
||||
cx16.FB_cursor_position()
|
||||
get_4_pixels()
|
||||
cx16.FB_set_pixel(c0)
|
||||
cx16.FB_set_pixel(c0)
|
||||
cx16.FB_set_pixel(c1)
|
||||
cx16.FB_set_pixel(c1)
|
||||
cx16.FB_set_pixel(c2)
|
||||
cx16.FB_set_pixel(c2)
|
||||
cx16.FB_set_pixel(c3)
|
||||
cx16.FB_set_pixel(c3)
|
||||
bitmap++
|
||||
}
|
||||
}
|
||||
cy_times_forty += 40
|
||||
}
|
||||
|
||||
sub get_4_pixels() {
|
||||
c0 = mcol(@(bitmap)>>6)
|
||||
c1 = mcol(@(bitmap)>>4)
|
||||
c2 = mcol(@(bitmap)>>2)
|
||||
c3 = mcol(@(bitmap))
|
||||
|
||||
sub mcol(ubyte b) -> ubyte {
|
||||
ubyte color
|
||||
when b & 3 {
|
||||
0 -> color = screen_color
|
||||
1 -> color = @(load_location + 8000 + cy_times_forty + cx) >>4
|
||||
2 -> color = @(load_location + 8000 + cy_times_forty + cx) & 15
|
||||
else -> color = @(load_location + 8000 + 1000 + cy_times_forty + cx) & 15
|
||||
}
|
||||
return color
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
58
examples/loadsave.p8
Normal file
58
examples/loadsave.p8
Normal file
@ -0,0 +1,58 @@
|
||||
%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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -8,5 +8,34 @@ main {
|
||||
sub start() {
|
||||
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