diff --git a/src/aliases/,aliases_ram_lowmem.s b/src/aliases/,aliases_ram_lowmem.s index cc4d80ff..e82c13be 100644 --- a/src/aliases/,aliases_ram_lowmem.s +++ b/src/aliases/,aliases_ram_lowmem.s @@ -153,7 +153,7 @@ !addr KEYTAB = $F5 ; $F5-$F6 pointer to keyboard lookup table !addr RIBUF = $F7 ; $F7-$F8 -- WIP -- RS-232 receive buffer pointer !addr ROBUF = $F9 ; $F9-$FA -- WIP -- RS-232 send buffer pointer - ; $FB $FB-$FE -- UNUSED -- free for user software + ; $FB $FB-$FE -- UNUSED -- free for user software !addr BASZPT = $FF ; -- NOT IMPLEMENTED -- ; diff --git a/src/aliases/,aliases_ram_over64K_m65.s b/src/aliases/,aliases_ram_over64K_m65.s index 63a1ffcd..63d14ad2 100644 --- a/src/aliases/,aliases_ram_over64K_m65.s +++ b/src/aliases/,aliases_ram_over64K_m65.s @@ -20,5 +20,12 @@ ; (2KB) - color RAM mirror, not useable ; $20000-$2FFFF (64KB) - ROM, the essential part ; $30000-$4FFFF (64KB) - ROM, additions - ; $50000-$57FFF (32KB) - reserved for graphics screen + ; $50000-$57F71 (32KB) - reserved for graphics screen + ; $57F72-$57FFF - shadow location for BASIC zeropage + +!set MEMCONF_SHADOW_BZP_0 = $72 +!set MEMCONF_SHADOW_BZP_1 = $7F +!set MEMCONF_SHADOW_BZP_2 = $05 +!set MEMCONF_SHADOW_BZP_3 = $00 + ; $58000-... - extended BASIC variables, RAM disk, etc. diff --git a/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s b/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s index 68767abe..699a48c5 100644 --- a/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s +++ b/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s @@ -26,6 +26,7 @@ !addr VK1__M65_CLRSCR = $4000 + 2 * 12 !addr VK1__M65_CLRWIN = $4000 + 2 * 13 !addr VK1__m65_screen_upd_txtrow_off = $4000 + 2 * 14 + !addr VK1__m65_shadow_BZP = $4000 + 2 * 15 } else { @@ -60,4 +61,5 @@ !word M65_CLRSCR !word M65_CLRWIN !word m65_screen_upd_txtrow_off + !word m65_shadow_BZP } diff --git a/src/kernal/board_m65/mega65_monitor.s b/src/kernal/board_m65/mega65_monitor.s index 5ffcfe6a..04aa63d6 100644 --- a/src/kernal/board_m65/mega65_monitor.s +++ b/src/kernal/board_m65/mega65_monitor.s @@ -4,7 +4,8 @@ MONITOR: + jsr m65_shadow_BZP jsr map_MON_1 jmp ($4000) - ; Monitor knows, that it should exit via map_NORMAL + ; Monitor knows, that it should exit via m65_shadow_BZP diff --git a/src/kernal/board_m65/mega65_shadow_bzp.s b/src/kernal/board_m65/mega65_shadow_bzp.s new file mode 100644 index 00000000..07f529db --- /dev/null +++ b/src/kernal/board_m65/mega65_shadow_bzp.s @@ -0,0 +1,80 @@ +;; #LAYOUT# M65 KERNAL_0 #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE + +; Exchanges BASIC part of the zero page with it's shadow location; tries to destroy as little memory as possible + + +m65_shadow_BZP: + +!ifdef SEGMENT_M65_KERNAL_0 { + + jsr map_KERNAL_1 + jsr (VK1__m65_shadow_BZP) + jmp map_NORMAL + +} else { + + + ; Preserve CPU status and registers + + php + phz + pha + phx + + ; We need a 4-byte pointer on the zero page; let's use the ones starting from FNLEN + + ldx #$03 +@1: + lda FNLEN,x + pha + dex + bpl @1 + + ; Store the address of the ZP shadow location + + lda #MEMCONF_SHADOW_BZP_0 + sta FNLEN+0 + lda #MEMCONF_SHADOW_BZP_1 + sta FNLEN+1 + lda #MEMCONF_SHADOW_BZP_2 + sta FNLEN+2 + lda #MEMCONF_SHADOW_BZP_3 + sta FNLEN+3 + + ; Exchange the ZP content + + ldz #$00 + ldx #$00 +@2: + lda [FNLEN],z + pha + lda $02,x + sta [FNLEN],z + pla + sta $02,x + inz + inx + cpx #$8E + bne @2 + + ; Restore FNLEN and further bytes + + ldx #$00 +@3: + pla + sta FNLEN,x + inx + cpx #$04 + bne @3 + + ; Restore registers and quit + + plx + pla + plz + plp + + rts +} diff --git a/src/mon_m65/,imports_monitor.s b/src/mon_m65/,imports_monitor.s index 139f9d09..30e6b316 100644 --- a/src/mon_m65/,imports_monitor.s +++ b/src/mon_m65/,imports_monitor.s @@ -9,6 +9,7 @@ ;; #ALIAS# map_NORMAL = KERNAL_0.map_NORMAL ;; #ALIAS# map_MON_1 = KERNAL_0.map_MON_1 +;; #ALIAS# m65_shadow_BZP = KERNAL_0.m65_shadow_BZP ;; #ALIAS# CHRIN = KERNAL_0.proxy_M1_CHRIN ;; #ALIAS# CHROUT = KERNAL_0.proxy_M1_CHROUT diff --git a/src/mon_m65/bsmon.s b/src/mon_m65/bsmon.s index 3f4d3e9c..1862d4a0 100644 --- a/src/mon_m65/bsmon.s +++ b/src/mon_m65/bsmon.s @@ -60,8 +60,8 @@ !addr MODE_80 = $d7 ; 80 column / 40 volumn flag ; XXX add routine to detect this -!addr Disk_Status = $40A ; BCD value of status -!addr Disk_Msg = $410 ; 40 bytes, disk status as text message ; XXX get rid of this buffer +!addr Disk_Status = $40A ; BCD value of status +!addr Disk_Msg = $410 ; 40 bytes, disk status as text message ; XXX get rid of this buffer ; ******* @@ -109,8 +109,8 @@ Mon_Call ; set default PC to monitor exit point - LDA #map_NORMAL + LDA #m65_shadow_BZP STA PCL STA MON_XVEC STX PCH