possible workaround for SMC issue that could make sys.reset_system() and sys.poweroff_system() not work properly

This commit is contained in:
Irmen de Jong 2025-02-24 23:07:51 +01:00
parent 3e2b2a698d
commit 94653e5c8c
3 changed files with 12 additions and 14 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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()
}
}
}