diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt index f8a170be7..15d49bd4a 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt @@ -435,7 +435,7 @@ internal class AssignmentAsmGen(private val program: PtProgram, require(it.type == DataType.UBYTE) val scopeName = (scope as PtNamedNode).scopedName val comparison = PtRpn(DataType.UBYTE, assign.position) - comparison.addRpnNode(PtIdentifier("$scopeName.$leftvar", it.type, value.position)) + comparison.addRpnNode(PtIdentifier("$scopeName.$leftvar", it.leftType, value.position)) comparison.addRpnNode(PtIdentifier("$scopeName.$rightvar", it.rightType, value.position)) comparison.addRpnNode(PtRpnOperator(it.operator, it.type, it.leftType, it.rightType, it.position)) comparison.parent = scope diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 010b3df3b..8046b421d 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -394,6 +394,11 @@ romsub $ff53 = joystick_scan() clobbers(A, X, Y) romsub $ff56 = joystick_get(ubyte joynr @A) -> ubyte @A, ubyte @X, ubyte @Y romsub $ff56 = joystick_get2(ubyte joynr @A) clobbers(Y) -> uword @AX ; alternative to above to not have the hassle to deal with multiple return values +; Audio (bank 10) +romsub $C09F = audio_init() -> ubyte @Pc ; (re)initialize PSG and YM audio chips +; TODO: add more of the audio routines here. + + asmsub kbdbuf_clear() { ; -- convenience helper routine to clear the keyboard buffer %asm {{ @@ -641,8 +646,9 @@ asmsub init_system() { lda VERA_DC_VIDEO and #%00000111 ; retain chroma + output mode sta P8ZP_SCRATCH_REG - lda #$80 - sta VERA_CTRL ; reset vera + lda #$0a + sta $01 ; rom bank 10 (audio) + jsr audio_init ; silence stz $01 ; rom bank 0 (kernal) jsr c64.IOINIT jsr c64.RESTOR @@ -650,7 +656,7 @@ asmsub init_system() { lda VERA_DC_VIDEO and #%11111000 ora P8ZP_SCRATCH_REG - sta VERA_DC_VIDEO ; keep old output mode + sta VERA_DC_VIDEO ; restore old output mode lda #$90 ; black jsr c64.CHROUT lda #1 @@ -907,8 +913,6 @@ sys { %asm {{ sei stz $01 ; bank the kernal in - lda #$80 - sta cx16.VERA_CTRL ; reset Vera (kernal doesn't do this?) jmp (cx16.RESET_VEC) }} } diff --git a/docs/source/index.rst b/docs/source/index.rst index d2ae32de6..bca4071cd 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -21,7 +21,7 @@ while still being low level enough to create high performance programs. You can compile programs for various machines with this CPU: * Commodore 64 -* Commander X16 +* Commander X16 (release R42 or newer is required) * Commodore 128 (limited support for now) * Atari 800 XL (limited support for now) diff --git a/docs/source/targetsystem.rst b/docs/source/targetsystem.rst index a15a08308..40bd3e010 100644 --- a/docs/source/targetsystem.rst +++ b/docs/source/targetsystem.rst @@ -159,7 +159,7 @@ And for the Commander X16:: cx16.restore_irq() ; set everything back to the systems default irq handler -The Commander X16 syslib provides two additional routines that should be used *in your IRQ handler routine* if it uses the Vera registers. +The Commander X16 syslib does provides two additional routines that should be used *in your IRQ handler routine* if it uses the Vera registers. They take care of saving and restoring the Vera state of the interrupted main program, otherwise the IRQ handler's manipulation will corrupt any Vera operations that were going on in the main program. The routines are:: @@ -168,7 +168,11 @@ will corrupt any Vera operations that were going on in the main program. The rou cx16.pop_vera_context() .. caution:: - It is advised to not use floating point calculations inside IRQ handler routines. + The Commander X16's 16 'virtual registers' R0-R15 are located in zeropage and *are not preserved* in the IRQ handler! + So you should make sure that the handler routine does NOT use these registers, or do some sort of saving/restoring yourself + of the ones that you do need in the IRQ handler. + + It is also advised to not use floating point calculations inside IRQ handler routines. Beside them being very slow, there are intricate requirements such as having the correct ROM bank enabled to be able to successfully call them (and making sure the correct ROM bank is reset at the end of the handler), and the possibility diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 3197e3560..0f0ad61de 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -12,12 +12,9 @@ RPN: Fix the TODO RPN routines to be optimized assembly in RpnExpressionAsmGen.k RPN: check BinExprSplitter disablement any effect for RPN? RPN: Implement RPN codegen for IR. -- Move asmExtra vars into BSS as well, now are .byte 0 allocated - - For next minor release ^^^^^^^^^^^^^^^^^^^^^^ -- should X16 R0-R15 be saved in IRQ routine? At least document that you should not use them in IRQ handler? +- Move asmExtra vars into BSS as well, now are .byte 0 allocated ...