From 06d15701422ea1c78e7ddce10c8f31017debd4c7 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 19 May 2023 22:06:49 +0200 Subject: [PATCH] cx16: added diskio.save_raw() headerless save routine --- compiler/res/prog8lib/cx16/diskio.p8 | 20 ++++++++++++++++++-- compiler/res/prog8lib/cx16/syslib.p8 | 3 ++- docs/source/libraries.rst | 1 + docs/source/programming.rst | 3 +++ docs/source/todo.rst | 4 ++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/compiler/res/prog8lib/cx16/diskio.p8 b/compiler/res/prog8lib/cx16/diskio.p8 index 1385b78f5..5f2bfd950 100644 --- a/compiler/res/prog8lib/cx16/diskio.p8 +++ b/compiler/res/prog8lib/cx16/diskio.p8 @@ -462,7 +462,18 @@ io_error: goto done } + + ; saves a block of memory to disk, including the default 2 byte prg header. sub save(uword filenameptr, uword address, uword size) -> bool { + return internal_save_routine(filenameptr, address, size, false) + } + + ; like save() but omits the 2 byte prg header. + sub save_raw(uword filenameptr, uword address, uword size) -> bool { + return internal_save_routine(filenameptr, address, size, true) + } + + sub internal_save_routine(uword filenameptr, uword address, uword size, bool headerless) -> bool { cbm.SETNAM(string.length(filenameptr), filenameptr) cbm.SETLFS(1, drivenumber, 0) uword @shared end_address = address + size @@ -474,11 +485,16 @@ io_error: lda address+1 sta P8ZP_SCRATCH_W1+1 stx P8ZP_SCRATCH_REG - lda # ubyte @ A ; (via 804 ($324)) input a character (for keyboard, read a whole line from the screen) A=byte read. romsub $FFD2 = CHROUT(ubyte char @ A) ; (via 806 ($326)) output a character romsub $FFD5 = LOAD(ubyte verify @ A, uword address @ XY) -> bool @Pc, ubyte @ A, uword @ XY ; (via 816 ($330)) load from device -romsub $FFD8 = SAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) -> bool @ Pc, ubyte @ A ; (via 818 ($332)) save to a device +romsub $FFD8 = SAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) clobbers (X, Y) -> bool @ Pc, ubyte @ A ; (via 818 ($332)) save to a device romsub $FFDB = SETTIM(ubyte low @ A, ubyte middle @ X, ubyte high @ Y) ; set the software clock romsub $FFDE = RDTIM() -> ubyte @ A, ubyte @ X, ubyte @ Y ; read the software clock (A=lo,X=mid,Y=high) romsub $FFE1 = STOP() clobbers(X) -> bool @ Pz, ubyte @ A ; (via 808 ($328)) check the STOP key (and some others in A) @@ -364,6 +364,7 @@ romsub $ff1a = FB_filter_pixels(uword pointer @ R0, uword count @R1) clobbers(A romsub $ff1d = FB_move_pixels(uword sx @R0, uword sy @R1, uword tx @R2, uword ty @R3, uword count @R4) clobbers(A,X,Y) ; misc +romsub $FEBA = BSAVE(ubyte zp_startaddr @ A, uword endaddr @ XY) clobbers (X, Y) -> bool @ Pc, ubyte @ A ; like cbm.SAVE, but omits the 2-byte prg header romsub $fec6 = i2c_read_byte(ubyte device @X, ubyte offset @Y) clobbers (X,Y) -> ubyte @A, bool @Pc romsub $fec9 = i2c_write_byte(ubyte device @X, ubyte offset @Y, ubyte data @A) clobbers (A,X,Y) -> bool @Pc romsub $fef0 = sprite_set_image(uword pixels @R0, uword mask @R1, ubyte bpp @R2, ubyte number @A, ubyte width @X, ubyte height @Y, bool apply_mask @Pc) clobbers(A,X,Y) -> bool @Pc diff --git a/docs/source/libraries.rst b/docs/source/libraries.rst index c894e759a..e798c88d9 100644 --- a/docs/source/libraries.rst +++ b/docs/source/libraries.rst @@ -151,6 +151,7 @@ Provides several routines that deal with disk drive I/O, such as: - send arbitrary CbmDos command to disk drive Commander X16 additions: +Headerless load and save routines are available (load_raw, save_raw). On the Commander X16 it tries to use that machine's fast Kernal loading routines if possible. Routines to directly load data into video ram are also present (vload and vload_raw). Also contains a helper function to calculate the file size of a loaded file (although that is truncated diff --git a/docs/source/programming.rst b/docs/source/programming.rst index a094dd9b4..3083ad1e8 100644 --- a/docs/source/programming.rst +++ b/docs/source/programming.rst @@ -943,6 +943,9 @@ Library routines There are many routines available in the compiler libraries. Some are used internally by the compiler as well. + +The most important ones can be found in the :doc:`libraries` chapter. + There's too many to list here, just have a look through the source code of the library modules to see what's there. (They can be found in the compiler/res directory) diff --git a/docs/source/todo.rst b/docs/source/todo.rst index d7066ff22..12ecac39e 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,6 +1,9 @@ TODO ==== +FIX: pokew(table + 64 + pos*2, ($000a-pos)*200) generates wrong code? + + For 9.0 major changes ^^^^^^^^^^^^^^^^^^^^^ - DONE: added 'cbm' block in the syslib module that now contains all CBM compatible kernal routines and variables @@ -13,6 +16,7 @@ For 9.0 major changes - DONE: drivenumber parameter removed from all routines in diskio module. The drive to work on is now simply stored as a diskio.drivenumber variable, which defaults to 8. - DONE: for loops now skip the whole loop if from value already outside the loop range (this is what all other programming languages also do) - DONE: asmsub params or return values passed in cpu flags (like carry) now must be declared as booleans (previously ubyte was still accepted). +- DONE: (on cx16) added diskio.save_raw() to save without the 2 byte prg header - [much work:] add special (u)word array type (or modifier such as @fast? ) that puts the array into memory as 2 separate byte-arrays 1 for LSB 1 for MSB -> allows for word arrays of length 256 and faster indexing this is an enormous amout of work, if this type is to be treated equally as existing (u)word , because all expression / lookup / assignment routines need to know about the distinction....