Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

P8ZP_SCRATCH_PTR on C64 trashes a frequently used JiffyDOS ZP location. #217

@gillham

Description

@gillham

JiffyDOS uses $9b to indicate if the function keys are active or not. Any non-zero value of P8ZP_SCRATCH_PTR will result in the JiffyDOS funciton keys being disabled when the Prog8 program exits. This occurs with or without %zeropage dontuse since it is a required ZP location.

This behavior of JiffyDOS can be verified by simply pressing F1 to see that it tries to load a disk directory.
Then do POKE 155,1 and try F1 again. It will do nothing.
Do POKE 155,0andF1` should be back to normal.

Currently P8ZP_SCRATCH_REG is using $03 which according to Mapping the Commodore 64 is part of $03/$04 or "ADRAY1" which isn't used by BASIC. Locations $5/$6 are listed as "ADRAY2" and also state they are not used by BASIC.

Image

I would propose using $4/$5 for P8ZP_SCRATCH_PTR since ZP bytes 3/4/5/6 appear to be unused by basic. We are already using one byte from the ADRAY1 vector so I think using the high byte and a byte from the ADRAY2 vector would be better than interfering with JiffyDOS.

Using the following with VICE didn't show any use when running a few basic programs.

break load 0002
break load 0003
break load 0004
break load 0005
break load 0006

I would propose the following patch:

--- a/codeCore/src/prog8/code/target/zp/C64Zeropage.kt
+++ b/codeCore/src/prog8/code/target/zp/C64Zeropage.kt
@@ -9,7 +9,7 @@ class C64Zeropage(options: CompilationOptions) : Zeropage(options) {
     override val SCRATCH_REG = 0x03u     // temp storage for a register byte, must be B1+1
     override val SCRATCH_W1 = 0xfbu      // temp storage 1 for a word  $fb+$fc
     override val SCRATCH_W2 = 0xfdu      // temp storage 2 for a word  $fd+$fe
-    override val SCRATCH_PTR = 0x9bu     // temp storage for a pointer $9b+$9c
+    override val SCRATCH_PTR = 0x04u     // temp storage for a pointer $04+$05

And equivalent changes for the tiny C64 custom target.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions