From 94653e5c8ccf9b70e913cc00c114e2cffe623fe0 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Mon, 24 Feb 2025 23:07:51 +0100 Subject: [PATCH] possible workaround for SMC issue that could make sys.reset_system() and sys.poweroff_system() not work properly --- compiler/res/prog8lib/cx16/syslib.p8 | 13 +++++++++---- docs/source/todo.rst | 1 - examples/test.p8 | 12 +++--------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 5af03be38..f34a0bb61 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -1363,7 +1363,7 @@ _continue iny sub poweroff_system() { ; -- use the SMC to shutdown the computer - void cx16.i2c_write_byte($42, $01, $00) + sys.poweroff_system() } sub set_led_state(bool on) { @@ -1530,16 +1530,21 @@ asmsub set_rasterline(uword line @AY) { ; (note: this is an asmsub on purpose! don't change into a normal sub) %asm {{ sei - ldx #$42 +- ldx #$42 ldy #2 lda #0 - jmp cx16.i2c_write_byte + jsr cx16.i2c_write_byte + bra - ; to work around an issue where the routine does not in fact immediately reset the system + ; !notreached! }} } sub poweroff_system() { ; use the SMC to shutdown the computer - void cx16.i2c_write_byte($42, $01, $00) + ; in a loop for the event where the shutdown command does not in fact immediately shutdown the system + repeat { + void cx16.i2c_write_byte($42, $01, $00) + } } asmsub wait(uword jiffies @AY) clobbers(X) { diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 0f1084904..8a3b7c746 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -37,7 +37,6 @@ Future Things and Ideas IR/VM ----- -- can onetimeInitializationNumericValue be removed from IRStStaticVariable? - getting it in shape for code generation...: the IR file should be able to encode every detail about a prog8 program (the VM doesn't have to actually be able to run all of it though!) - fix call() return value handling - proper code gen for the CALLI instruction and that it (optionally) returns a word value that needs to be assigned to a reg diff --git a/examples/test.p8 b/examples/test.p8 index a449030de..32fee936d 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -3,16 +3,10 @@ %option no_sysinit, romable main { - ubyte[100] @shared array1 - ubyte[100] @shared array2 = [42] *100 - sub start() { - uword @shared pointer = $4000 - ubyte @shared size = 42 - - for cx16.r0L in 5 to size { - @(pointer)++ - @(pointer)-- + repeat { + if cbm.GETIN2()==27 + sys.poweroff_system() } } }