added ZP shadowing for monitor and Z80 CPU emulator

This commit is contained in:
FeralChild64 committed 2020-12-16 23:54:43 +01:00
1 parent 6c5a6f6327
commit 18c5bbbafb
7 files changed
+98 -7

No files matched your search

@@ -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
}
+2 -1
View File
@@ -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
+80
View File
@@ -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
}