mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
c64/c128 targets: perform cleanup at program exit such as re-enabling run-stop key and character set switching.
This commit is contained in:
parent
d1a707df57
commit
0bf00d1ca4
@ -127,9 +127,27 @@ internal class ProgramAndVarsGen(
|
||||
"cx16" -> {
|
||||
if(options.floats)
|
||||
asmgen.out(" lda #4 | sta $01") // to use floats, make sure Basic rom is banked in
|
||||
asmgen.out(" jsr main.start | lda #4 | sta $01 | rts")
|
||||
asmgen.out(" jsr main.start | lda #4 | sta $01")
|
||||
if(!options.noSysInit)
|
||||
asmgen.out(" jmp ${compTarget.name}.cleanup_at_exit")
|
||||
else
|
||||
asmgen.out(" rts")
|
||||
}
|
||||
"c64" -> {
|
||||
asmgen.out(" jsr main.start | lda #31 | sta $01")
|
||||
if(!options.noSysInit)
|
||||
asmgen.out(" jmp ${compTarget.name}.cleanup_at_exit")
|
||||
else
|
||||
asmgen.out(" rts")
|
||||
}
|
||||
"c128" -> {
|
||||
asmgen.out(" jsr main.start")
|
||||
// TODO c128: how to bank basic+kernal back in?
|
||||
if(!options.noSysInit)
|
||||
asmgen.out(" jmp ${compTarget.name}.cleanup_at_exit")
|
||||
else
|
||||
asmgen.out(" rts")
|
||||
}
|
||||
"c64" -> asmgen.out(" jsr main.start | lda #31 | sta $01 | rts")
|
||||
else -> asmgen.jmp("main.start")
|
||||
}
|
||||
}
|
||||
|
@ -274,6 +274,16 @@ asmsub disable_runstop_and_charsetswitch() clobbers(A) {
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub enable_runstop_and_charsetswitch() clobbers(A) {
|
||||
%asm {{
|
||||
lda #0
|
||||
sta 247 ; enable charset switching
|
||||
lda #110
|
||||
sta 808 ; enable run/stop key
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub set_irq(uword handler @AY, ubyte useKernal @Pc) clobbers(A) {
|
||||
%asm {{
|
||||
sta _modified+1
|
||||
@ -481,6 +491,13 @@ asmsub init_system_phase2() {
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub cleanup_at_exit() {
|
||||
; executed when the main subroutine does rts
|
||||
%asm {{
|
||||
jmp c64.enable_runstop_and_charsetswitch
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub disable_basic() clobbers(A) {
|
||||
%asm {{
|
||||
lda $0a04 ; disable BASIC shadow registers
|
||||
@ -681,7 +698,10 @@ _longcopy
|
||||
inline asmsub exit(ubyte returnvalue @A) {
|
||||
; -- immediately exit the program with a return code in the A register
|
||||
%asm {{
|
||||
;lda #14
|
||||
;sta $01 ; bank the kernal in TODO c128 how to do this?
|
||||
jsr c64.CLRCHN ; reset i/o channels
|
||||
jsr c64.enable_runstop_and_charsetswitch
|
||||
ldx prog8_lib.orig_stackpointer
|
||||
txs
|
||||
rts ; return to original caller
|
||||
|
@ -300,6 +300,13 @@ asmsub init_system_phase2() {
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub cleanup_at_exit() {
|
||||
; executed when the main subroutine does rts
|
||||
%asm {{
|
||||
jmp c64.enable_runstop_and_charsetswitch
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub disable_runstop_and_charsetswitch() clobbers(A) {
|
||||
%asm {{
|
||||
lda #$80
|
||||
@ -310,6 +317,16 @@ asmsub disable_runstop_and_charsetswitch() clobbers(A) {
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub enable_runstop_and_charsetswitch() clobbers(A) {
|
||||
%asm {{
|
||||
lda #0
|
||||
sta 657 ; enable charset switching
|
||||
lda #237
|
||||
sta 808 ; enable run/stop key
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub set_irq(uword handler @AY, ubyte useKernal @Pc) clobbers(A) {
|
||||
%asm {{
|
||||
sta _modified+1
|
||||
@ -646,7 +663,10 @@ _longcopy
|
||||
inline asmsub exit(ubyte returnvalue @A) {
|
||||
; -- immediately exit the program with a return code in the A register
|
||||
%asm {{
|
||||
lda #31
|
||||
sta $01 ; bank the kernal in
|
||||
jsr c64.CLRCHN ; reset i/o channels
|
||||
jsr c64.enable_runstop_and_charsetswitch
|
||||
ldx prog8_lib.orig_stackpointer
|
||||
txs
|
||||
rts ; return to original caller
|
||||
|
@ -641,6 +641,14 @@ asmsub init_system_phase2() {
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub cleanup_at_exit() {
|
||||
; executed when the main subroutine does rts
|
||||
; just an rts here, nothing special to clean up on cx16
|
||||
%asm {{
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub set_irq(uword handler @AY, ubyte useKernal @Pc) clobbers(A) {
|
||||
%asm {{
|
||||
sta _modified+1
|
||||
|
@ -3,7 +3,6 @@ TODO
|
||||
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- c64 target: after exit, switching charset case is still disabled. Don't disable this by default in startup?
|
||||
- vm: check array type in PtAssignTarget
|
||||
- vm: animals example game breaks after adding first new animal...
|
||||
- vm: add more instructions operating directly on memory instead of only registers? (translate assignment self-assigns)
|
||||
|
@ -32,7 +32,6 @@ main {
|
||||
|
||||
|
||||
sub start() {
|
||||
c64.disable_runstop_and_charsetswitch()
|
||||
;@(650) = 128 ; set all keys to repeat
|
||||
sound.init()
|
||||
newGame()
|
||||
|
@ -31,7 +31,9 @@ main {
|
||||
|
||||
txt.print(name)
|
||||
txt.nl()
|
||||
name=other
|
||||
uword otherptr = &other + 2
|
||||
name = otherptr
|
||||
|
||||
txt.print(name)
|
||||
txt.nl()
|
||||
txt.nl()
|
||||
|
Loading…
Reference in New Issue
Block a user