From 31177a2b1b6cb1cc4175393bdfe3a7010b98585d Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Mon, 6 Nov 2023 23:55:49 +0100 Subject: [PATCH] added sys.disable_caseswitch() and sys.enable_caseswitch() --- compiler/res/prog8lib/atari/syslib.p8 | 8 ++++++++ compiler/res/prog8lib/c128/syslib.p8 | 14 ++++++++++++++ compiler/res/prog8lib/c64/syslib.p8 | 14 ++++++++++++++ compiler/res/prog8lib/cx16/syslib.p8 | 16 ++++++++++++++++ compiler/res/prog8lib/pet32/syslib.p8 | 8 ++++++++ compiler/res/prog8lib/virtual/syslib.p8 | 7 +++++++ docs/source/libraries.rst | 3 +++ docs/source/todo.rst | 1 - 8 files changed, 70 insertions(+), 1 deletion(-) diff --git a/compiler/res/prog8lib/atari/syslib.p8 b/compiler/res/prog8lib/atari/syslib.p8 index 7d7b369e2..ead2eb7ce 100644 --- a/compiler/res/prog8lib/atari/syslib.p8 +++ b/compiler/res/prog8lib/atari/syslib.p8 @@ -198,6 +198,14 @@ _longcopy }} } + sub disable_caseswitch() { + ; no-op + } + + sub enable_caseswitch() { + ; no-op + } + inline asmsub exit(ubyte returnvalue @A) { ; -- immediately exit the program with a return code in the A register ; TODO diff --git a/compiler/res/prog8lib/c128/syslib.p8 b/compiler/res/prog8lib/c128/syslib.p8 index 1c4f1633b..f9f97539b 100644 --- a/compiler/res/prog8lib/c128/syslib.p8 +++ b/compiler/res/prog8lib/c128/syslib.p8 @@ -734,6 +734,20 @@ _longcopy }} } + inline asmsub disable_caseswitch() { + %asm {{ + lda #$80 + sta 247 + }} + } + + inline asmsub enable_caseswitch() { + %asm {{ + lda #0 + sta 247 + }} + } + inline asmsub exit(ubyte returnvalue @A) { ; -- immediately exit the program with a return code in the A register %asm {{ diff --git a/compiler/res/prog8lib/c64/syslib.p8 b/compiler/res/prog8lib/c64/syslib.p8 index a13599bd5..3cfa7ec86 100644 --- a/compiler/res/prog8lib/c64/syslib.p8 +++ b/compiler/res/prog8lib/c64/syslib.p8 @@ -737,6 +737,20 @@ _longcopy }} } + inline asmsub disable_caseswitch() { + %asm {{ + lda #$80 + sta 657 + }} + } + + inline asmsub enable_caseswitch() { + %asm {{ + lda #0 + sta 657 + }} + } + inline asmsub exit(ubyte returnvalue @A) { ; -- immediately exit the program with a return code in the A register %asm {{ diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 9b5dfee36..ef54b4c4d 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -873,6 +873,8 @@ asmsub init_system() { jsr cbm.CHROUT lda #147 ; clear screen jsr cbm.CHROUT + lda #8 ; disable charset case switch + jsr cbm.CHROUT lda #PROG8_VARSHIGH_RAMBANK sta $00 ; select ram bank lda #0 @@ -1250,6 +1252,20 @@ _longcopy }} } + inline asmsub disable_caseswitch() { + %asm {{ + lda #8 + jsr cbm.CHROUT + }} + } + + inline asmsub enable_caseswitch() { + %asm {{ + lda #9 + jsr cbm.CHROUT + }} + } + inline asmsub exit(ubyte returnvalue @A) { ; -- immediately exit the program with a return code in the A register %asm {{ diff --git a/compiler/res/prog8lib/pet32/syslib.p8 b/compiler/res/prog8lib/pet32/syslib.p8 index d5117456e..21026c19a 100644 --- a/compiler/res/prog8lib/pet32/syslib.p8 +++ b/compiler/res/prog8lib/pet32/syslib.p8 @@ -297,6 +297,14 @@ _longcopy }} } + sub disable_caseswitch() { + ; PET doesn't have a key to swap case, so no-op + } + + sub enable_caseswitch() { + ; PET doesn't have a key to swap case, so no-op + } + inline asmsub exit(ubyte returnvalue @A) { ; -- immediately exit the program with a return code in the A register %asm {{ diff --git a/compiler/res/prog8lib/virtual/syslib.p8 b/compiler/res/prog8lib/virtual/syslib.p8 index 6c5b7ead4..03837faa3 100644 --- a/compiler/res/prog8lib/virtual/syslib.p8 +++ b/compiler/res/prog8lib/virtual/syslib.p8 @@ -79,6 +79,13 @@ sys { }} } + sub disable_caseswitch() { + ; no-op + } + + sub enable_caseswitch() { + ; no-op + } sub gfx_enable(ubyte mode) { %ir {{ diff --git a/docs/source/libraries.rst b/docs/source/libraries.rst index 07c07c738..d3005d698 100644 --- a/docs/source/libraries.rst +++ b/docs/source/libraries.rst @@ -132,6 +132,9 @@ sys (part of syslib) ``set_leds_brightness (ubyte activity, ubyte power)`` (commander x16 only) Sets the brightness of the activity and power leds on the computer. +``disable_caseswitch()`` and ``enable_caseswitch()`` + Disable or enable the ability to switch character set case using a keyboard combination. + conv ---- diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 388c9bda6..0b1de6096 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,7 +1,6 @@ TODO ==== -- optimize when in case of constant value (only keep choice that matches) - revisit the seek example to see if write-seeking now works? - remove unused interned strings in the resulting code (for example from removed if/else blocks) - [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....