From 118196a0bf9370f5435773b07d51b7d3a11f9d14 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Mon, 24 Jan 2022 18:31:18 +0100 Subject: [PATCH] library API change: moved cx16.vload() to cx16diskio module --- compiler/res/prog8lib/cx16/cx16diskio.p8 | 38 +++++++++++++++++++++++ compiler/res/prog8lib/cx16/syslib.p8 | 39 ------------------------ compiler/res/version.txt | 2 +- docs/source/todo.rst | 1 - 4 files changed, 39 insertions(+), 41 deletions(-) diff --git a/compiler/res/prog8lib/cx16/cx16diskio.p8 b/compiler/res/prog8lib/cx16/cx16diskio.p8 index edf2ad805..3cc1081d2 100644 --- a/compiler/res/prog8lib/cx16/cx16diskio.p8 +++ b/compiler/res/prog8lib/cx16/cx16diskio.p8 @@ -34,4 +34,42 @@ cx16diskio { sub load_size(ubyte startbank, uword startaddress, uword endaddress) -> uword { return $2000 * (cx16.getrambank() - startbank) + endaddress - startaddress } + + asmsub vload(str name @R0, ubyte device @Y, ubyte bank @A, uword address @R1) -> ubyte @A { + ; -- like the basic command VLOAD "filename",device,bank,address + ; loads a file into Vera's video memory in the given bank:address, returns success in A + %asm {{ + ; -- load a file into video ram + phx + pha + tya + tax + lda #1 + ldy #0 + jsr c64.SETLFS + lda cx16.r0 + ldy cx16.r0+1 + jsr prog8_lib.strlen + tya + ldx cx16.r0 + ldy cx16.r0+1 + jsr c64.SETNAM + pla + clc + adc #2 + ldx cx16.r1 + ldy cx16.r1+1 + stz P8ZP_SCRATCH_B1 + jsr c64.LOAD + bcs + + inc P8ZP_SCRATCH_B1 + + jsr c64.CLRCHN + lda #1 + jsr c64.CLOSE + plx + lda P8ZP_SCRATCH_B1 + rts + }} + } + } diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 4673dda18..443ac50c4 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -533,45 +533,6 @@ asmsub vpoke_xor(ubyte bank @A, uword address @R0, ubyte value @Y) clobbers (A) }} } -asmsub vload(str name @R0, ubyte device @Y, ubyte bank @A, uword address @R1) -> ubyte @A { - ; -- like the basic command VLOAD "filename",device,bank,address - ; loads a file into video memory in the given bank:address, returns success in A - ; !! NOTE !! the V38 ROMs contain a bug in the LOAD code that makes the load address not work correctly, - ; it works fine when loading from local filesystem - %asm {{ - ; -- load a file into video ram - phx - pha - tya - tax - lda #1 - ldy #0 - jsr c64.SETLFS - lda cx16.r0 - ldy cx16.r0+1 - jsr prog8_lib.strlen - tya - ldx cx16.r0 - ldy cx16.r0+1 - jsr c64.SETNAM - pla - clc - adc #2 - ldx cx16.r1 - ldy cx16.r1+1 - stz P8ZP_SCRATCH_B1 - jsr c64.LOAD - bcs + - inc P8ZP_SCRATCH_B1 -+ jsr c64.CLRCHN - lda #1 - jsr c64.CLOSE - plx - lda P8ZP_SCRATCH_B1 - rts - }} -} - inline asmsub joystick_get2(ubyte joynr @A) clobbers(Y) -> uword @AX { ; convenience routine to get the joystick state without requiring inline assembly that deals with the multiple return values. ; Also disables interrupts to avoid the IRQ race condition mentioned here: https://github.com/commanderx16/x16-rom/issues/203 diff --git a/compiler/res/version.txt b/compiler/res/version.txt index 5942a0d3a..fa234972b 100644 --- a/compiler/res/version.txt +++ b/compiler/res/version.txt @@ -1 +1 @@ -7.7.1 +7.8-dev diff --git a/docs/source/todo.rst b/docs/source/todo.rst index a192a8b0d..e68578ac5 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -21,7 +21,6 @@ Blocked by an official Commander-x16 r39 release Future Things and Ideas ^^^^^^^^^^^^^^^^^^^^^^^ -- move vload() to cx16diskio module - nameInAssemblyCode() should search smarter - string.find should return index of found character + carry set if found, carry clear if not found. (fix cx16assem, it uses current behavior. Also fix docs!) - if char in "string" should fall back to string.find if string is longer than... 16?