diff --git a/STATUS.md b/STATUS.md index 9d4aa3c9..d42254f5 100644 --- a/STATUS.md +++ b/STATUS.md @@ -299,6 +299,7 @@ Not all of them - only these we want to have implemented. | `$AB1E` | `STROUT` | DONE | | | `$AD9E` | `FRMEVL` | PARTIAL | | | `$BDCD` | `LINPRT` | DONE | temporary implementation | +| `$E3A2` | `MOVCHG` | DONE | memory model 38K only | | `$E3BF` | `INIT` | NOT DONE | | | `$E422` | `INITMSG` | DONE | | | `$E453` | `RVECT` | NOT DONE | | diff --git a/src/aliases/,aliases_ram_lowmem.s b/src/aliases/,aliases_ram_lowmem.s index cc1b4ce7..cf78801a 100644 --- a/src/aliases/,aliases_ram_lowmem.s +++ b/src/aliases/,aliases_ram_lowmem.s @@ -74,7 +74,8 @@ !addr ARISGN = $6F ; -- NOT IMPLEMENTED -- !addr FACOV = $70 ; FAC1 low order mantissa !addr FBUFPT = $71 ; $71-$72 -- NOT IMPLEMENTED -- - !addr CHRGET = $73 ; $73-$8A -- NOT IMPLEMENTED -- + !addr CHRGET = $73 ; $73-$8A copied from $E3A2 during cold start + !addr CHRGOT = $79 ; same area as CHRGET !addr TXTPTR = $7A ; $7A-$7B current BASIC statement pointer !addr RNDX = $8B ; $8B-$8F random number seed diff --git a/src/basic/init/basic_cold_start_internal.s b/src/basic/init/basic_cold_start_internal.s index c9c3536d..69905ddc 100644 --- a/src/basic/init/basic_cold_start_internal.s +++ b/src/basic/init/basic_cold_start_internal.s @@ -11,7 +11,7 @@ basic_cold_start_internal: ; Setup vectors at $300 ldy #$0B -@1: +@1 lda basic_vector_defaults_1, y sta IERROR, y dey @@ -44,5 +44,13 @@ basic_cold_start_internal: ; Initialize other variables by performing NEW jsr do_new +!ifdef CONFIG_MEMORY_MODEL_38K { + + ; Copy CHRGET to the zero page + ; This is for maximum C64 compatibility + jsr copy_CHRGET + +} + ; jump into warm start loop jmp basic_warm_start diff --git a/src/basic/init/e394.basic_cold_start.s b/src/basic/init/e394.basic_cold_start.s index ef12b162..3f3a94fb 100644 --- a/src/basic/init/e394.basic_cold_start.s +++ b/src/basic/init/e394.basic_cold_start.s @@ -8,7 +8,13 @@ basic_cold_start: -!ifdef ROM_LAYOUT_STD { ; skip on non-sgtandard ROM layouts - they produce single image nevertheless +!ifdef ROM_LAYOUT_STD { ; skip on non-standard ROM layouts - they produce single image nevertheless + +!ifdef CONFIG_MEMORY_MODEL_38K { + ; Special version in high memory for the 38K memory layout + jsr revision_check +} else { + ; Before doing anything, check if we have a compatible BASIC/KERNAL pair @@ -23,6 +29,7 @@ basic_cold_start: @2: dey bpl @1 +} } ; Remaining part would not fit here diff --git a/src/basic/init/e3a2.MOVCHG.s b/src/basic/init/e3a2.MOVCHG.s new file mode 100644 index 00000000..a9c6e6cc --- /dev/null +++ b/src/basic/init/e3a2.MOVCHG.s @@ -0,0 +1,39 @@ +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE + + +; init - This is the implementation of the CHARGET and CHARGOT functions +; The basic cold start will copy this into the zero page +; We will only use this for the 38K memory model for maximum C64 compatibility +; +; Input: Nothing +; Output: Nothing +; Clobbers: A, X +; +; See also: +; https://www.c64-wiki.com/wiki/CHRGET +; + +!ifdef CONFIG_MEMORY_MODEL_38K { + +MOVCHG: + + inc TXTPTR + bne @1 + inc TXTPTR+1 + +@1: + + lda $0000 ; The address in this instruction will be at TXTPTR in the zero page + beq @2 ; If NULL byte + cmp #$20 ; Is space? + beq MOVCHG + cmp #$30 ; is less than '0'? + bcc @2 + cmp #$3A ; '9' + 1 and also ':' + rts +@2: + sec + rts +} diff --git a/src/basic/init/e3a2.interop b/src/basic/init/e3a2.interop new file mode 100644 index 00000000..cb171a16 --- /dev/null +++ b/src/basic/init/e3a2.interop @@ -0,0 +1,4 @@ +The MOVCHG function has a well known address and it has been used for different BASIC wedge techniques + +https://www.lemon64.com/forum/viewtopic.php?t=47824 +https://www.pagetable.com/c64ref/c64mem/ diff --git a/src/basic/init/e3e0.copy_CHRGET.s b/src/basic/init/e3e0.copy_CHRGET.s new file mode 100644 index 00000000..92a7db2c --- /dev/null +++ b/src/basic/init/e3e0.copy_CHRGET.s @@ -0,0 +1,26 @@ +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE + +; init - copy CHRGET and CHRGOT from ROM to zero page +; We only use this for the 38K memory model for maximum C64 compatibility +; +; Input: Nothing +; Output: Nothing +; Clobbers: A, Y +; +; See also: +; https://www.c64-wiki.com/wiki/CHRGET +; + +!ifdef CONFIG_MEMORY_MODEL_38K { + +copy_CHRGET: + ldy #23 ; Last index to copy +@1: lda MOVCHG,Y + sta CHRGET,Y + dey + bpl @1 + rts + +} diff --git a/src/basic/init/revision_check_38K.s b/src/basic/init/revision_check_38K.s new file mode 100644 index 00000000..03bed006 --- /dev/null +++ b/src/basic/init/revision_check_38K.s @@ -0,0 +1,29 @@ +;; #LAYOUT# STD * #TAKE-HIGH +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE + +; +; A high memory version of the revision check specific to the 38K memory layout +; + + +!ifdef CONFIG_MEMORY_MODEL_38K { +!ifdef ROM_LAYOUT_STD { + +revision_check: + ; Before doing anything, check if we have a compatible BASIC/KERNAL pair + + ldy #(__rom_revision_basic_end - rom_revision_basic - 1) +@1: + lda rom_revision_basic, y + cmp rom_revision_kernal, y + beq @2 + + +panic P_ERR_ROM_MISMATCH + +@2: + dey + bpl @1 + rts +} +} diff --git a/strings/61D0034CFB b/strings/61D0034CFB new file mode 100644 index 00000000..c43484fd --- /dev/null +++ b/strings/61D0034CFB @@ -0,0 +1,3 @@ +fragment + BNE 03 + JMP fragment + +Fragments of a long conditional jump - trivial diff --git a/strings/7AD002E67BAD b/strings/7AD002E67BAD new file mode 100644 index 00000000..52fae7ef --- /dev/null +++ b/strings/7AD002E67BAD @@ -0,0 +1,3 @@ +$7A + BNE 2 + INC $7B + LDA(abs) + +Fragment of common code to increment a 16-bit pointer, trivial and non-copyrightable diff --git a/strings/94E37BE3 b/strings/94E37BE3 new file mode 100644 index 00000000..968cf42b --- /dev/null +++ b/strings/94E37BE3 @@ -0,0 +1,3 @@ +$E394 + $E37B Address of basic cold start and address of basic warm start + +Addresses to well known functions. Trivial. diff --git a/strings/A000911460 b/strings/A000911460 new file mode 100644 index 00000000..c3f43992 --- /dev/null +++ b/strings/A000911460 @@ -0,0 +1,3 @@ +LDY #0 + BCC $14 + RTS + +Fragment of special case termination of subroutine. Trivial diff --git a/strings/CA10F860 b/strings/CA10F860 new file mode 100644 index 00000000..03140c2d --- /dev/null +++ b/strings/CA10F860 @@ -0,0 +1,3 @@ +DEX + BPL back + RTS + +Loop fragment. Not copyrightable.