diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 37165c411..21aebd43f 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -289,6 +289,23 @@ romsub $fecc = monitor() clobbers(A,X,Y) ; ---- utilities ----- + +inline asmsub rombank(ubyte rombank @A) { + ; -- set the rom banks + %asm {{ + sta $01 ; rom bank register (new) + sta cx16.d1prb ; rom bank register (old) + }} +} + +inline asmsub rambank(ubyte rambank @A) { + ; -- set the ram bank + %asm {{ + sta $00 ; ram bank register (new) + sta cx16.d1pra ; ram bank register (old) + }} +} + 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! diff --git a/examples/cx16/assembler/assem.p8 b/examples/cx16/assembler/assem.p8 index 366069016..a8228c2fd 100644 --- a/examples/cx16/assembler/assem.p8 +++ b/examples/cx16/assembler/assem.p8 @@ -12,7 +12,7 @@ main { sub start() { - txt.print("\nCommanderX16 65c02 file based assembler.\n\nfilename or enter for interactive: ") + txt.print("\ncommander-x16 65c02 file based assembler.\n\nfilename or enter for interactive: ") str filename = "?" * 20 if txt.input_chars(filename) @@ -20,6 +20,8 @@ main { else user_input() + cx16.rombank(4) ; switch back to basic rom + test_stack.test() } @@ -57,6 +59,8 @@ main { txt.print(filename) txt.spc() + cx16.rombank(0) ; switch to kernal rom for faster file i/o + if diskio.f_open(8, filename) { c64.SETTIM(0,0,0) uword line=0 diff --git a/examples/cx16/assembler/testload.asm b/examples/cx16/assembler/testload.asm index 625d109bb..da06c823a 100644 --- a/examples/cx16/assembler/testload.asm +++ b/examples/cx16/assembler/testload.asm @@ -8,6 +8,7 @@ start + stz $9f60 ; switch to kernal bank for faster i/o phx ldx #<_filename @@ -48,6 +49,9 @@ _eof lda #1 jsr $FFC3 ;CLOSE + lda #4 + sta $9f60 + ; print the time taken jsr $FFDE ; RDTIM -> A,X,Y tay diff --git a/examples/cx16/imageviewer/imageviewer.p8 b/examples/cx16/imageviewer/imageviewer.p8 index d47e8ecfb..c52f17ab2 100644 --- a/examples/cx16/imageviewer/imageviewer.p8 +++ b/examples/cx16/imageviewer/imageviewer.p8 @@ -12,6 +12,9 @@ main { sub start() { + + cx16.rombank(0) ; switch to kernal rom (for faster file i/o) + ; trick to check if we're running on sdcard or host system shared folder txt.print("\nimage viewer for commander x16\nformats supported: .iff, .pcx, .bmp, .koa (c64 koala)\n\n") if string.length(diskio.status(8)) { @@ -30,6 +33,8 @@ main { gfx2.screen_mode(255) ; back to default text mode and palette txt.print("that was all folks!\n") + + cx16.rombank(4) ; switch back to basic rom } sub show_pics_sdcard() {