From a6756d2cea29061a00f6e09760d3325c3b9ad005 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 19 Nov 2023 18:59:03 +0100 Subject: [PATCH] removed diskio.set_drive(), just set the diskio.drivenumber variable directly there already wasn't a getter --- compiler/res/prog8lib/cx16/diskio.p8 | 6 +----- compiler/res/prog8lib/cx16/syslib.p8 | 2 +- compiler/res/prog8lib/diskio.p8 | 6 +----- .../src/prog8/compiler/astprocessing/AstChecker.kt | 2 +- docs/source/libraries.rst | 4 ++++ docs/source/targetsystem.rst | 5 ++++- docs/source/todo.rst | 4 ++++ examples/dirlist.p8 | 14 ++++++-------- 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/compiler/res/prog8lib/cx16/diskio.p8 b/compiler/res/prog8lib/cx16/diskio.p8 index 712c91ea2..630e9ebaa 100644 --- a/compiler/res/prog8lib/cx16/diskio.p8 +++ b/compiler/res/prog8lib/cx16/diskio.p8 @@ -21,11 +21,7 @@ diskio { const ubyte READ_IO_CHANNEL=12 const ubyte WRITE_IO_CHANNEL=13 - ubyte drivenumber = 8 - - sub set_drive(ubyte number) { - drivenumber = number - } + ubyte drivenumber = 8 ; user programs can set this to the drive number they want to load/save to! sub reset_read_channel() { void cbm.CHKIN(READ_IO_CHANNEL) diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 96e675a64..995a35d96 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -21,7 +21,7 @@ romsub $FF93 = SECOND(ubyte address @ A) clobbers(A) ; (alias: LSTNSA romsub $FF96 = TKSA(ubyte address @ A) clobbers(A) ; (alias: TALKSA) send secondary address after TALK romsub $FF99 = MEMTOP(uword address @ XY, bool dir @ Pc) -> uword @ XY ; read/set top of memory pointer. NOTE: as a Cx16 extension, also returns the number of RAM memory banks in register A ! See cx16.numbanks() romsub $FF9C = MEMBOT(uword address @ XY, bool dir @ Pc) -> uword @ XY ; read/set bottom of memory pointer -romsub $FF9F = SCNKEY() clobbers(A,X,Y) ; scan the keyboard +romsub $FF9F = SCNKEY() clobbers(A,X,Y) ; scan the keyboard, also called kbd_scan romsub $FFA2 = SETTMO(ubyte timeout @ A) ; set time-out flag for IEEE bus romsub $FFA5 = ACPTR() -> ubyte @ A ; (alias: IECIN) input byte from serial bus romsub $FFA8 = CIOUT(ubyte databyte @ A) ; (alias: IECOUT) output byte to serial bus diff --git a/compiler/res/prog8lib/diskio.p8 b/compiler/res/prog8lib/diskio.p8 index 15ffb91b2..dcdab86d3 100644 --- a/compiler/res/prog8lib/diskio.p8 +++ b/compiler/res/prog8lib/diskio.p8 @@ -10,11 +10,7 @@ diskio { const ubyte READ_IO_CHANNEL=12 const ubyte WRITE_IO_CHANNEL=13 - ubyte drivenumber = 8 - - sub set_drive(ubyte number) { - drivenumber = number - } + ubyte drivenumber = 8 ; user programs can set this to the drive number they want to load/save to! sub reset_read_channel() { void cbm.CHKIN(READ_IO_CHANNEL) diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index d92b45df7..d736734f5 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -313,7 +313,7 @@ internal class AstChecker(private val program: Program, err("cannot redefine a built-in function") if(subroutine.parameters.size>6 && !subroutine.isAsmSubroutine && !subroutine.definingBlock.isInLibrary) - errors.warn("subroutine has a large number of parameters, this slows down code execution a lot", subroutine.position) + errors.warn("subroutine has a large number of parameters, this is slow if called often", subroutine.position) val uniqueNames = subroutine.parameters.asSequence().map { it.name }.toSet() if(uniqueNames.size!=subroutine.parameters.size) diff --git a/docs/source/libraries.rst b/docs/source/libraries.rst index 9b2a68528..e917a92d8 100644 --- a/docs/source/libraries.rst +++ b/docs/source/libraries.rst @@ -193,6 +193,10 @@ to see what's in there. (Note: slight variations for different compiler targets) routines, please first try again with an SD-card image instead of HostFs. It is possible that there are still small differences between HostFS and actual CBM DOS in the X16 emulator. +.. note:: + You can set the active disk drive number so it supports multiple drives, + but it does not support multiple open files at the same time. + .. attention:: Error handling is peculiar on CBM dos systems (C64, C128, cx16, PET). Read the descriptions for the various methods in this library for details and tips. diff --git a/docs/source/targetsystem.rst b/docs/source/targetsystem.rst index 785b02f7e..152cd80e1 100644 --- a/docs/source/targetsystem.rst +++ b/docs/source/targetsystem.rst @@ -154,7 +154,9 @@ They take care of saving and restoring the Vera state of the interrupted main pr will corrupt any Vera operations that were going on in the main program. The routines are:: cx16.save_vera_context() - ; ... do your work that uses vera here... + ; perhaps also cx16.save_virtual_registers() here... + ; ... do your work that uses vera here!... + ; perhaps also cx16.restore_virtual_registers() here... cx16.restore_vera_context() .. caution:: @@ -162,6 +164,7 @@ will corrupt any Vera operations that were going on in the main program. The rou So you should make sure that the handler routine does NOT use these registers, or do some sort of saving/restoring yourself of the ones that you do need in the IRQ handler. There are two utility routines in cx16 that save and restore *all* 16 registers so it's a bit inefficient but safe. + (these are ``save_virtual_registers()`` and ``restore_virtual_registers()``) It is also advised to not use floating point calculations inside IRQ handler routines. Beside them being very slow, there are intricate requirements such as having the diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 32b2a45d7..0c806d314 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,6 +2,10 @@ TODO ==== +- IRQ callback should return boolean to tell Prog8 to call the kernal ISR or not. + +- Is there a way to tell prog8 not to optimize out a function that is only called from within %asm{{}}? like a @shared but for subs? + - [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 .... ... diff --git a/examples/dirlist.p8 b/examples/dirlist.p8 index 39d11f9f0..e65c5333a 100644 --- a/examples/dirlist.p8 +++ b/examples/dirlist.p8 @@ -8,15 +8,13 @@ main { sub start() { - diskio.set_drive(8) - txt.print("showing the full directory of drive ") - txt.print_ub(diskio.drivenumber) - txt.print(":\n") + diskio.drivenumber = 8 + txt.print("showing the full directory of drive 8:\n") void diskio.directory() txt.nl() - if diskio.lf_start_list("cub*") { - txt.print("\nfiles starting with 'cub':\n") + if diskio.lf_start_list("test*") { + txt.print("\nfiles starting with 'test':\n") while diskio.lf_next_entry() { txt.print(diskio.list_filename) txt.print(" ") @@ -28,8 +26,8 @@ main { txt.print("error\n") } - if diskio.lf_start_list("*gfx") { - txt.print("\nfiles ending with 'gfx':\n") + if diskio.lf_start_list("*bin") { + txt.print("\nfiles ending with 'bin':\n") while diskio.lf_next_entry() { txt.print(diskio.list_filename) txt.print(" ")