From b72877d59d9eaa245d420ed0192b363ae9ceef5d Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 6 Apr 2025 15:14:04 +0200 Subject: [PATCH] cx16: added routines to get and set the default palette (new rom 49+ extapi) --- compiler/res/prog8lib/cx16/palette.p8 | 9 +++++++++ compiler/res/prog8lib/cx16/syslib.p8 | 21 +++++++++++++++++++++ docs/source/todo.rst | 2 ++ 3 files changed, 32 insertions(+) diff --git a/compiler/res/prog8lib/cx16/palette.p8 b/compiler/res/prog8lib/cx16/palette.p8 index d715384ff..ecc04f307 100644 --- a/compiler/res/prog8lib/cx16/palette.p8 +++ b/compiler/res/prog8lib/cx16/palette.p8 @@ -257,6 +257,7 @@ palette { sub set_default16() { ; set first 16 colors to the defaults on the X16 + ; (doesn't use the rom table so this works on roms older than 49 as well) uword[] @nosplit colors = [ $000, ; 0 = black $fff, ; 1 = white @@ -277,4 +278,12 @@ palette { ] set_rgb_nosplit(colors, len(colors), 0) } + + ; set the full 256 colors in the palette back to its default values on the X16 + ; NOTE: this routine requires rom version 49+ + alias set_default = cx16.set_default_palette + + ; get the bank and address of the word-array containing the 256 default palette colors + ; NOTE: this routine requires rom version 49+ + alias get_default = cx16.get_default_palette } diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 19552a2f0..4ab091257 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -670,12 +670,33 @@ asmsub scnsiz(ubyte width @X, ubyte heigth @Y) clobbers(A,X,Y) { } asmsub memory_decompress_from_func(uword datafunction @R4, uword output @R1) clobbers(A,X,Y) -> uword @R1 { + ; requires rom v49+ %asm {{ lda #EXTAPI_memory_decompress_from_func jmp cx16.extapi }} } +asmsub get_default_palette() -> ubyte @A, uword @XY { + ; returns memory address of default palette; bank in A and address in XY + ; requires rom v49+ + %asm {{ + sec + lda #EXTAPI_default_palette + jmp cx16.extapi + }} +} + +asmsub set_default_palette() { + ; sets default palette in to the Vera + ; requires rom v49+ + %asm {{ + clc + lda #EXTAPI_default_palette + jmp cx16.extapi + }} +} + asmsub get_charset() -> ubyte @A { ;Get charset mode. result: 0=unknown, 1=ISO, 2=PETSCII upper case/gfx, 3=PETSCII lowercase. %asm {{ diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 963b54129..4073d15f2 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,6 +1,8 @@ TODO ==== +symboldump doesn't include aliased symbols (like palette.set_default) + atari customtarget: default output should be .xex not .prg (10.5 still did it correctly) test irqs on various targets: set_irq, set_rasterirq