Disable interrupts during aux memory access.

Interrupt handlers rather likely access text screen holes. Especially MSLOT is obligatory for every interrupt handler that requires access to an extension ROM ($C800-$CFFE) in order to be able to re-enable the extension ROM that was enabled when the interrupt occured. Those text screen holes only hold valid values in main memory so interrupts must be disabled while the aux memory text screen is mapped.
This commit is contained in:
Oliver Schmidt
2025-03-12 21:33:13 +01:00
parent fd4c1e193d
commit 7c2671be2a
3 changed files with 22 additions and 10 deletions

View File

@@ -9,6 +9,7 @@
.export _cgetc .export _cgetc
.import cursor, putchardirect .import cursor, putchardirect
.include "zeropage.inc"
.include "apple2.inc" .include "apple2.inc"
_cgetc: _cgetc:
@@ -22,7 +23,7 @@ _cgetc:
.else .else
lda #' ' | $40 ; Blank, flashing lda #' ' | $40 ; Blank, flashing
.endif .endif
jsr putchardirect ; Returns old character in X jsr putchardirect ; Saves old character in tmp3
; Wait for keyboard strobe. ; Wait for keyboard strobe.
: inc RNDL ; Increment random counter low : inc RNDL ; Increment random counter low
@@ -37,7 +38,7 @@ _cgetc:
; Restore old character. ; Restore old character.
pha pha
txa lda tmp3
jsr putchardirect jsr putchardirect
pla pla

View File

@@ -11,18 +11,23 @@
_cpeekc: _cpeekc:
ldy CH ldy CH
.ifdef __APPLE2ENH__ .ifdef __APPLE2ENH__
sec ; Assume main memory
bit RD80VID ; In 80 column mode? bit RD80VID ; In 80 column mode?
bpl peek ; No, just go ahead bpl peek ; No, just go ahead
tya tya
lsr ; Div by 2 lsr ; Div by 2
tay tay
bcs peek ; Odd cols are in main memory bcs peek ; Odd cols are in main memory
php
sei ; No valid MSLOT et al. in aux memory
bit HISCR ; Assume SET80COL bit HISCR ; Assume SET80COL
.endif .endif
peek: lda (BASL),Y ; Get character peek: lda (BASL),Y ; Get character
.ifdef __APPLE2ENH__ .ifdef __APPLE2ENH__
bit LOWSCR ; Doesn't hurt in 40 column mode bcs :+ ; In main memory
.endif bit LOWSCR
plp
: .endif
eor #$80 ; Invert high bit eor #$80 ; Invert high bit
ldx #$00 ldx #>$0000
rts rts

View File

@@ -15,6 +15,7 @@
.import uppercasemask .import uppercasemask
.endif .endif
.include "zeropage.inc"
.include "apple2.inc" .include "apple2.inc"
.macpack cpu .macpack cpu
@@ -87,23 +88,28 @@ putchar:
mask: and INVFLG ; Apply normal, inverse, flash mask: and INVFLG ; Apply normal, inverse, flash
putchardirect: putchardirect:
pha tax
.ifdef __APPLE2ENH__ .ifdef __APPLE2ENH__
lda CH lda CH
sec ; Assume main memory
bit RD80VID ; In 80 column mode? bit RD80VID ; In 80 column mode?
bpl put ; No, just go ahead bpl put ; No, just go ahead
lsr ; Div by 2 lsr ; Div by 2
bcs put ; Odd cols go in main memory bcs put ; Odd cols go in main memory
php
sei ; No valid MSLOT et al. in aux memory
bit HISCR ; Assume SET80COL bit HISCR ; Assume SET80COL
put: tay put: tay
.else .else
ldy CH ldy CH
.endif .endif
lda (BASL),Y ; Get current character lda (BASL),Y ; Get current character
tax ; Return old character for _cgetc sta tmp3 ; Save old character for _cgetc
pla txa
sta (BASL),Y sta (BASL),Y
.ifdef __APPLE2ENH__ .ifdef __APPLE2ENH__
bit LOWSCR ; Doesn't hurt in 40 column mode bcs :+ ; In main memory
.endif bit LOWSCR
plp
: .endif
rts rts