mirror of
https://github.com/irmen/prog8.git
synced 2024-10-01 22:56:10 +00:00
added color cycling support to iff viewer
This commit is contained in:
parent
48a4c46a6c
commit
8f224afed9
@ -376,6 +376,19 @@ address you specified, and setting the varible will directly modify that memory
|
||||
&word SCREENCOLORS = $d020 ; a 16-bit word at the addres $d020-$d021
|
||||
|
||||
|
||||
Direct access to memory locations
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Normally memory locations are accessed by a *memory mapped* name, such as ``c64.BGCOL0`` that is defined
|
||||
as the memory mapped address $d021.
|
||||
|
||||
If you want to access a memory location directly (by using the address itself), without defining
|
||||
a memory mapped location, you can do so by enclosing the address in ``@(...)``::
|
||||
|
||||
color = @($d020) ; set the variable 'color' to the current c64 screen border color ("peek(53280)")
|
||||
@($d020) = 0 ; set the c64 screen border to black ("poke 53280,0")
|
||||
@(vic+$20) = 6 ; you can also use expressions to 'calculate' the address
|
||||
|
||||
|
||||
Converting types into other types
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@ -536,18 +549,6 @@ a fixed amount of memory which will not change. (You *can* change the value of
|
||||
that there is a loss of precision. You can use builtin functions such as ``round`` and ``lsb`` to convert
|
||||
to a smaller datatype, or revert to integer arithmetic.
|
||||
|
||||
Direct access to memory locations
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Normally memory locations are accessed by a *memory mapped* name, such as ``c64.BGCOL0`` that is defined
|
||||
as the memory mapped address $d021.
|
||||
|
||||
If you want to access a memory location directly (by using the address itself), without defining
|
||||
a memory mapped location, you can do so by enclosing the address in ``@(...)``::
|
||||
|
||||
color = @($d020) ; set the variable 'color' to the current c64 screen border color ("peek(53280)")
|
||||
@($d020) = 0 ; set the c64 screen border to black ("poke 53280,0")
|
||||
@(vic+$20) = 6 ; you can also use expressions to 'calculate' the address
|
||||
|
||||
|
||||
Expressions
|
||||
-----------
|
||||
|
@ -4,13 +4,21 @@
|
||||
%import diskio
|
||||
|
||||
iff_module {
|
||||
ubyte[256] cmap
|
||||
ubyte[256] cmap1
|
||||
ubyte[256] cmap2
|
||||
uword num_colors
|
||||
uword[16] cycle_rates
|
||||
uword[16] cycle_rate_ticks
|
||||
ubyte[16] cycle_reverseflags
|
||||
ubyte[16] cycle_lows
|
||||
ubyte[16] cycle_highs
|
||||
ubyte num_cycles
|
||||
|
||||
sub show_image(uword filenameptr) -> ubyte {
|
||||
ubyte load_ok = false
|
||||
uword size
|
||||
ubyte[32] buffer
|
||||
ubyte[256] cmap
|
||||
ubyte[256] cmap1
|
||||
ubyte[256] cmap2
|
||||
uword camg = 0
|
||||
str chunk_id = "????"
|
||||
uword chunk_size_hi
|
||||
@ -20,12 +28,12 @@ iff_module {
|
||||
uword width
|
||||
uword height
|
||||
ubyte num_planes
|
||||
uword num_colors
|
||||
ubyte compression
|
||||
ubyte have_cmap = false
|
||||
cmap[0] = 0
|
||||
cmap1[0] = 0
|
||||
cmap2[0] = 0
|
||||
num_cycles = 0
|
||||
|
||||
if diskio.f_open(8, filenameptr) {
|
||||
size = diskio.f_read(buffer, 12)
|
||||
@ -54,6 +62,16 @@ iff_module {
|
||||
have_cmap = true
|
||||
void diskio.f_read(&cmap, chunk_size_lo)
|
||||
}
|
||||
else if chunk_id == "crng" {
|
||||
; DeluxePaint color cycle range
|
||||
void diskio.f_read(buffer, chunk_size_lo)
|
||||
cycle_rates[num_cycles] = mkword(buffer[2], buffer[3])
|
||||
cycle_rate_ticks[num_cycles] = 1
|
||||
cycle_lows[num_cycles] = buffer[6]
|
||||
cycle_highs[num_cycles] = buffer[7]
|
||||
cycle_reverseflags[num_cycles] = (buffer[5] & 2)!=0
|
||||
num_cycles += 1
|
||||
}
|
||||
else if chunk_id == "body" {
|
||||
graphics.clear_screen(1, 0)
|
||||
if camg & $0004
|
||||
@ -247,4 +265,68 @@ _masks .byte 128, 64, 32, 16, 8, 4, 2, 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub cycle_colors_each_jiffy() {
|
||||
if num_cycles==0
|
||||
return
|
||||
|
||||
ubyte changed = false
|
||||
ubyte ci
|
||||
for ci in 0 to num_cycles-1 {
|
||||
; TODO COMPILER: cycle_rate_ticks[ci]-- is broken!!!!!!!!!!
|
||||
uword ticks = cycle_rate_ticks[ci]
|
||||
ticks--
|
||||
cycle_rate_ticks[ci] = ticks
|
||||
if ticks==0 {
|
||||
changed = true
|
||||
cycle_rate_ticks[ci] = 16384 / cycle_rates[ci]
|
||||
do_cycle(cycle_lows[ci], cycle_highs[ci], cycle_reverseflags[ci])
|
||||
}
|
||||
}
|
||||
|
||||
if changed
|
||||
palette.set_rgb8(&cmap, num_colors) ; set the new palette
|
||||
|
||||
sub do_cycle(uword low, uword high, ubyte reversed) {
|
||||
low *= 3
|
||||
high *= 3
|
||||
uword bytecount = high-low
|
||||
uword cptr
|
||||
ubyte red
|
||||
ubyte green
|
||||
ubyte blue
|
||||
|
||||
if reversed {
|
||||
cptr = &cmap + low
|
||||
red = @(cptr)
|
||||
green = @(cptr+1)
|
||||
blue = @(cptr+2)
|
||||
repeat bytecount {
|
||||
@(cptr) = @(cptr+3)
|
||||
cptr++
|
||||
}
|
||||
@(cptr) = red
|
||||
cptr++
|
||||
@(cptr) = green
|
||||
cptr++
|
||||
@(cptr) = blue
|
||||
} else {
|
||||
cptr = &cmap + high
|
||||
red = @(cptr)
|
||||
cptr++
|
||||
green = @(cptr)
|
||||
cptr++
|
||||
blue = @(cptr)
|
||||
repeat bytecount {
|
||||
@(cptr) = @(cptr-3)
|
||||
cptr--
|
||||
}
|
||||
@(cptr) = blue
|
||||
cptr--
|
||||
@(cptr) = green
|
||||
cptr--
|
||||
@(cptr) = red
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
;; %import ci_module
|
||||
|
||||
|
||||
; TODO use the gfx2 graphics module for full-screen 320x240 display instead of 320x200 truncated.
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
; trick to check if we're running on sdcard or host system shared folder
|
||||
@ -61,7 +63,14 @@ main {
|
||||
txt.clear_screen()
|
||||
else
|
||||
txt.print("load error!\n")
|
||||
cx16.wait(120)
|
||||
if iff_module.num_cycles {
|
||||
repeat 400 {
|
||||
cx16.wait(1)
|
||||
iff_module.cycle_colors_each_jiffy()
|
||||
}
|
||||
}
|
||||
else
|
||||
cx16.wait(120)
|
||||
}
|
||||
else if strcmp(extension, ".pcx")==0 {
|
||||
txt.print("loading ")
|
||||
|
@ -8,6 +8,11 @@
|
||||
|
||||
main {
|
||||
|
||||
|
||||
|
||||
; TODO COMPILER: cycle_rate_ticks[ci]-- is broken!!!!!!!!!!
|
||||
|
||||
|
||||
; TODO asmsub version generates LARGER CODE , why is this?
|
||||
sub vpoke(ubyte bank, uword address, ubyte value) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user