Skip to content

Commit

Permalink
Screen Dump: Fix corruption of "File" on menu bar
Browse files Browse the repository at this point in the history
It appears that initializing and other calls to the Super Serial Card
firmware while 80-column mode is active causes the text screen to be
cleared. MGTK uses that memory for pattern caches which are then
corrupted, leading to mispaints if unless GrafPorts are swapped.

Work around this by saving/restoring the text page (main and aux)
around the SSC usage, and proactively apply the same logic to the
Print Catalog accessory.

Understanding exactly what causes the SSC to do this would be ideal;
I have not spotted the culprit in the firmware. Also note that the
issue only occurs with real SSC firmware; the problem reproduces in
MAME but not in Virtual ][.

Fixes #810
  • Loading branch information
inexorabletash committed Dec 25, 2024
1 parent 25431d3 commit 5d54e40
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Project Page: https://github.com/a2stuff/a2d
* Screen Dump
* Improve use of SSC and IW2.
* Show alert on startup if no SSC found.
* Don't corrupt "File" on menu bar. ([#810](https://github.com/a2stuff/a2d/issues/810))
* Print Catalog
* Improve use of SSC and IW2.
* Show alert on startup if no printer card found.
Expand Down
4 changes: 4 additions & 0 deletions desk.acc/print.catalog.s
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ no_windows:

continue:
JUMP_TABLE_MGTK_CALL MGTK::SetCursor, MGTK::SystemCursor::watch
;; SSC operations trash the text page (if 80 col firmware active?)
jsr SaveTextPage

ldy #SSC::PInit
jsr GoCard
Expand All @@ -128,6 +130,7 @@ continue:
;; Recurse and print
jsr PrintCatalog

jsr RestoreTextPage
JUMP_TABLE_MGTK_CALL MGTK::SetCursor, MGTK::SystemCursor::pointer
rts

Expand Down Expand Up @@ -917,6 +920,7 @@ str_from_int: PASCAL_STRING "000,000" ; Filled in by IntToString

.include "../lib/filetypestring.s"
.include "../lib/inttostring.s"
.include "../lib/save_textpage.s"

;;; ============================================================

Expand Down
8 changes: 8 additions & 0 deletions desk.acc/screen.dump.s
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ sig_bytes:
sta ALTZPOFF
bit ROMIN2

;; SSC operations trash the text page (if 80 col firmware active?)
jsr SaveTextPage
jsr PrintScreen
jsr RestoreTextPage

sta ALTZPON
bit LCBANK1
Expand Down Expand Up @@ -114,6 +117,9 @@ init_graphics:
sta mask
copy16 #0, x_coord

;; Uses PAGE2 flag to control main/aux reads
sta SET80STORE

col_loop:
lda #4 ; 8 vertical pixels per row (doubled)
sta count
Expand Down Expand Up @@ -282,6 +288,8 @@ restore_sequence:

.endproc ; DumpScreen

.include "../lib/save_textpage.s"

;;; ============================================================

DA_END_MAIN_SEGMENT
Expand Down
61 changes: 61 additions & 0 deletions lib/save_textpage.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
;;; ============================================================
;;; Save/Restore Text Page
;;;
;;; Used in accessories to preserve MGTK caches when operations
;;; might trash the text page (e.g. initializing SSC)
;;; ============================================================

;;; Saves text page (except screen holes)
.proc SaveTextPage
lda RD80STORE
pha
sta SET80STORE

ldx #0
loop:
.repeat 8, i
sta PAGE2ON
lda $400 + (i*$80),x
sta _textpage_aux_buf + (i*$78),x
sta PAGE2OFF
lda $400 + (i*$80),x
sta _textpage_main_buf + (i*$78),x
.endrepeat
inx
cpx #$78
jne loop

pla
bmi :+
sta CLR80STORE
: rts
.endproc

;;; Restores text page (except screen holes)
.proc RestoreTextPage
lda RD80STORE
pha
sta SET80STORE

ldx #0
loop:
.repeat 8, i
sta PAGE2ON
lda _textpage_aux_buf + (i*$78),x
sta $400 + (i*$80),x
sta PAGE2OFF
lda _textpage_main_buf + (i*$78),x
sta $400 + (i*$80),x
.endrepeat
inx
cpx #$78
jne loop

pla
bmi :+
sta CLR80STORE
: rts
.endproc

_textpage_main_buf: .res 40*24
_textpage_aux_buf: .res 40*24
1 change: 1 addition & 0 deletions res/notes/testplan.md
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ With Sci.Calc:
* Configure a system with an SSC in Slot 1 and an ImageWriter II. Invoke the Screen Dump DA. Verify it prints a screenshot.
* Configure a system with a non-SSC in Slot 1. Invoke the Screen Dump DA. Verify nothing happens.
* Configure a system with an SSC in Slot 1 and an ImageWriter II. Invoke the Screen Dump DA. Invoke the Print Catalog DA. Verify that the catalog is printed on separate lines, not all overprinted on the same line onto one.
* Using MAME (e.g. via Ample), configure a system with an SSC in Slot 1 and a Serial Printer. Invoke the Screen Dump DA. Verify that the File menu is not corrupted.

# Shortcuts (Module)

Expand Down

0 comments on commit 5d54e40

Please sign in to comment.