From 6a9269111edfa3cf8ed81d3faa75af9fdafd037a Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 15 Mar 2024 01:04:51 +0100 Subject: [PATCH] some changes in SMC routines for the cx16: sys.poweroff_system() moved to cx16 sys.set_leds_brightness() moved to cx16 and changed to set_led_brightness, you can only change the activity led brightness. --- compiler/res/prog8lib/cx16/syslib.p8 | 18 ++++++++++++-- docs/source/libraries.rst | 15 +++++++----- docs/source/todo.rst | 2 ++ examples/cx16/diskspeed.p8 | 24 +++++++++---------- examples/test.p8 | 36 +++++++++++----------------- 5 files changed, 53 insertions(+), 42 deletions(-) diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 5f65d95ef..f20e5e729 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -1214,6 +1214,20 @@ _continue iny }} } + sub reset_system() { + ; Soft-reset the system back to initial power-on Basic prompt. + sys.reset_system() + } + + sub poweroff_system() { + ; use the SMC to shutdown the computer + void cx16.i2c_write_byte($42, $01, $00) + } + + sub set_led_brightness(ubyte brightness) { + void cx16.i2c_write_byte($42, $05, brightness) + } + } sys { @@ -1413,13 +1427,13 @@ asmsub set_rasterline(uword line @AY) { asmsub reset_system() { ; Soft-reset the system back to initial power-on Basic prompt. ; We do this via the SMC so that a true reset is performed that also resets the Vera fully. + ; (note: this is an asmsub on purpose! don't change into a normal sub) %asm {{ sei ldx #$42 ldy #2 lda #0 - jsr cx16.i2c_write_byte - bra * + jmp cx16.i2c_write_byte }} } diff --git a/docs/source/libraries.rst b/docs/source/libraries.rst index 0f45fd85c..4342b83df 100644 --- a/docs/source/libraries.rst +++ b/docs/source/libraries.rst @@ -135,12 +135,6 @@ sys (part of syslib) Soft-reset the system back to initial power-on BASIC prompt. (called automatically by Prog8 when the main subroutine returns and the program is not using basicsafe zeropage option) -``poweroff_system ()`` (commander x16 only) - Powers down the computer. - -``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. @@ -582,6 +576,15 @@ On the other targets, it only contains the definition of the 16 memory mapped vi ``cpu_is_65816()`` Returns true if the CPU in the computer is a 65816, false otherwise (6502 cpu). +``reset_system ()`` + Soft-reset the system back to initial power-on BASIC prompt. (same as the routine in sys) + +``poweroff_system ()`` + Powers down the computer. + +``set_led_brightness (ubyte brightness)`` + Sets the brightness of the activity led on the computer. + bmx (cx16 only) ---------------- diff --git a/docs/source/todo.rst b/docs/source/todo.rst index de4be414b..caa5f7aa5 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,6 +1,8 @@ TODO ==== +add more verifications to diskspeed.p8 + ... diff --git a/examples/cx16/diskspeed.p8 b/examples/cx16/diskspeed.p8 index 4f701a644..1d9d13b02 100644 --- a/examples/cx16/diskspeed.p8 +++ b/examples/cx16/diskspeed.p8 @@ -139,18 +139,18 @@ main { txt.print(diskio.status()) txt.print("\ndone.\n") -; diskio.delete("benchmark0.dat") -; diskio.delete("benchmark1.dat") -; diskio.delete("benchmark2.dat") -; diskio.delete("benchmark3.dat") -; diskio.delete("benchmark4.dat") -; diskio.delete("benchmark5.dat") -; diskio.delete("benchmark6.dat") -; diskio.delete("benchmark7.dat") -; diskio.delete("benchmark8.dat") -; diskio.delete("benchmark9.dat") -; diskio.delete("benchmark64.dat") -; diskio.delete("benchmark256.dat") + diskio.delete("benchmark0.dat") + diskio.delete("benchmark1.dat") + diskio.delete("benchmark2.dat") + diskio.delete("benchmark3.dat") + diskio.delete("benchmark4.dat") + diskio.delete("benchmark5.dat") + diskio.delete("benchmark6.dat") + diskio.delete("benchmark7.dat") + diskio.delete("benchmark8.dat") + diskio.delete("benchmark9.dat") + diskio.delete("benchmark64.dat") + diskio.delete("benchmark256.dat") } sub verify_20k(str filename, uword crc32_low, uword crc32_high) { diff --git a/examples/test.p8 b/examples/test.p8 index 5821cf9d7..8f4cd8b0e 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -4,32 +4,24 @@ main { sub start() { - ; TODO func is not called 4 times!!!!! FIX!!! - if (not func(1)) - or (not func(1)) - or (not func(1)) - or (not func(1)) { - txt.print("done1\n") + cx16.reset_system() + repeat { + for cx16.r0L in 0 to 255 { + cx16.set_led_brightness(cx16.r0L) + delay() } - - ; TODO func is not called 4 times!!!!! FIX!!! - if func(2) - and func(2) - and func(2) - and func(2) { - txt.print("done2\n") + for cx16.r0L in 255 downto 0 { + cx16.set_led_brightness(cx16.r0L) + delay() } - - ; TODO func is not called 4 times!!!!! FIX!!! - if func(3) and func(3) and func(3) and func(3) { - txt.print("done3\n") } } - sub func(ubyte x) -> bool { - txt.print("func ") - txt.print_ub(x) - txt.nl() - return true + sub delay() { + repeat 2000 { + %asm {{ + nop + }} + } } }