more consistent about the system reset routine

This commit is contained in:
Irmen de Jong 2020-09-21 22:35:07 +02:00
parent 8a99e75299
commit cf49cbd1f8
6 changed files with 38 additions and 8 deletions

View File

@ -259,6 +259,16 @@ asmsub init_system() {
}}
}
asmsub reset_system() {
; Soft-reset the system back to Basic prompt.
%asm {{
sei
lda #14
sta $01 ; bank the kernal in
jmp (c64.RESET_VEC)
}}
}
asmsub set_irqvec_excl() clobbers(A) {
%asm {{
sei

View File

@ -277,4 +277,15 @@ asmsub init_system() {
}}
}
asmsub reset_system() {
; Soft-reset the system back to Basic prompt.
%asm {{
sei
lda #14
sta $01
stz cx16.d1prb ; bank the kernal in
jmp (cx16.RESET_VEC)
}}
}
}

View File

@ -154,6 +154,13 @@ asmsub scroll_left (ubyte dummy @ Pc) clobbers(A, Y) {
; ---- scroll the whole screen 1 character to the left
; contents of the rightmost column are unchanged, you should clear/refill this yourself
; Carry flag is a dummy on the cx16
%asm {{
phx
jsr c64.SCREEN
plx
rts
}}
}
asmsub scroll_right (ubyte dummy @ Pc) clobbers(A) {
@ -166,6 +173,7 @@ asmsub scroll_up (ubyte dummy @ Pc) clobbers(A, Y) {
; ---- scroll the whole screen 1 character up
; contents of the bottom row are unchanged, you should refill/clear this yourself
; Carry flag is a dummy on the cx16
; TODO maybe a version without using intermediate buffer is faster? (avoid double store/read)
%asm {{
phx
jsr c64.SCREEN
@ -265,6 +273,7 @@ asmsub scroll_down (ubyte dummy @ Pc) clobbers(A, Y) {
; ---- scroll the whole screen 1 character down
; contents of the top row are unchanged, you should refill/clear this yourself
; Carry flag is a dummy on the cx16
; TODO maybe a version without using intermediate buffer is faster? (avoid double store/read)
%asm {{
phx
jsr c64.SCREEN

View File

@ -17,8 +17,8 @@ internal interface CompilationTarget {
fun encodeString(str: String, altEncoding: Boolean): List<Short>
fun decodeString(bytes: List<Short>, altEncoding: Boolean): String
fun asmGenerator(program: Program, errors: ErrorReporter, zp: Zeropage, options: CompilationOptions, path: Path): IAssemblyGenerator
val asmForSystemReset: String
val initProcName: String?
val resetProcName: String?
companion object {
lateinit var instance: CompilationTarget
@ -35,8 +35,8 @@ internal object C64Target: CompilationTarget {
if(altEncoding) Petscii.decodeScreencode(bytes, true) else Petscii.decodePetscii(bytes, true)
override fun asmGenerator(program: Program, errors: ErrorReporter, zp: Zeropage, options: CompilationOptions, path: Path) =
AsmGen(program, errors, zp, options, path)
override val asmForSystemReset = " sei | lda #14 | sta $1 | jmp (c64.RESET_VEC)"
override val initProcName = "c64.init_system"
override val resetProcName = "c64.reset_system"
}
internal object Cx16Target: CompilationTarget {
@ -48,6 +48,6 @@ internal object Cx16Target: CompilationTarget {
if(altEncoding) Petscii.decodeScreencode(bytes, true) else Petscii.decodePetscii(bytes, true)
override fun asmGenerator(program: Program, errors: ErrorReporter, zp: Zeropage, options: CompilationOptions, path: Path) =
AsmGen(program, errors, zp, options, path)
override val asmForSystemReset = " sei | stz cx16.d1prb | jmp (cx16.RESET_VEC)"
override val initProcName = "cx16.init_system"
override val resetProcName = "cx16.reset_system"
}

View File

@ -163,7 +163,7 @@ internal class AsmGen(private val program: Program,
}
Zeropage.ExitProgramStrategy.SYSTEM_RESET -> {
out(" jsr main.start\t; call program entrypoint")
out(CompilationTarget.instance.asmForSystemReset)
out(" jmp ${CompilationTarget.instance.resetProcName}")
}
}
}

View File

@ -1,7 +1,7 @@
%import syslib
; %import graphics
%import textio
%zeropage basicsafe
; %zeropage basicsafe
main {
@ -16,9 +16,9 @@ main {
; }
; }
repeat 60 {
txt.setcc(rnd() % 80, 59, 81, 5)
txt.scroll_up(true)
repeat txt.DEFAULT_WIDTH {
txt.setcc(txt.DEFAULT_WIDTH-1, rnd() % txt.DEFAULT_HEIGHT, 81, 2)
txt.scroll_left(true)
repeat 5000 {
x++