Skip to content

Commit

Permalink
Print Catalog and Screen Dump: Improve SSC/IW2 usage
Browse files Browse the repository at this point in the history
Handful of things applied to both of these accessories:

* Rather than using the PR#1 and COUT entry points to talk to the
  printer, use the documented SSC assembly language entry points, per
  ImageWriter II manual.

* Rather than controlling "automatic LF after CR" using the SSC, use
  the documented ImageWriter II sequence.

* Consistently output an extra CR/LF after the output, but nothing
  before.
  • Loading branch information
inexorabletash committed Oct 20, 2024
1 parent 7a30989 commit 213c4d4
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 111 deletions.
3 changes: 2 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Project Page: https://github.com/a2stuff/a2d
* About This Apple II
* Detect Microdigital TK-3000 //e
* Detect Pravetz 8A/C
* Screen Dump: Restore CR/LF state after printing.
* Screen Dump: Improve use of SSC and IW2.
* Print Catalog: Improve use of SSC and IW2.

## 1.4

Expand Down
91 changes: 49 additions & 42 deletions desk.acc/print.catalog.s
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@

SLOT1 := $C100

;; SSC entry point lookup table
PInit = $0D
PRead = $0E
PWrite = $0F
PStatus = $10

.scope
ptr := $06

Expand Down Expand Up @@ -113,10 +119,19 @@ no_windows:
continue:
JUMP_TABLE_MGTK_CALL MGTK::SetCursor, MGTK::SystemCursor::watch

ldy #PInit
jsr GoCard

;; Init IW2 settings
ldx #0
: lda iw2_init,x
jsr COut
inx
cpx #kLenIW2Init
bne :-

;; Recurse and print
jsr PRNum1
jsr PrintCatalog
jsr RestoreCOutHook

JUMP_TABLE_MGTK_CALL MGTK::SetCursor, MGTK::SystemCursor::pointer
rts
Expand All @@ -143,7 +158,6 @@ PrintCatalog:
next:
ldx #0
: lda searchPath+1,x
ora #$80
jsr COut
inx
cpx searchPath
Expand All @@ -161,7 +175,7 @@ next:
bcc next
END_IF

finish: rts
finish: jmp CROut
.endscope

ch: .byte 0 ; cursor horizontal position
Expand All @@ -177,6 +191,10 @@ str_header:
kTypeWidth = 3
kColBlocks = 41 ; Right aligned

iw2_init:
.byte CHAR_ESCAPE, 'Z', $80, $00 ; disable automatic LF after CR
kLenIW2Init = * - iw2_init

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

;;; Input: A,X = pointer to table (num, offset, mask, value, offset, mask, value, ...)
Expand Down Expand Up @@ -451,7 +469,7 @@ OpenDone:
jsr PrintName

ldx #kColType
lda #' '|$80
lda #' '
: jsr COut
cpx ch
bcs :-
Expand All @@ -468,7 +486,7 @@ OpenDone:
;; Print indentation
ldx indent
IF_NOT_ZERO
lda #' '|$80
lda #' '
: jsr COut
jsr COut
dex
Expand All @@ -482,7 +500,6 @@ OpenDone:
tax
ldy #1
: lda (entPtr),y
ora #$80
jsr COut
iny
dex
Expand Down Expand Up @@ -523,7 +540,7 @@ OpenDone:

;; Left-pad it
ldx #kColBlocks - kColType - kTypeWidth
lda #' '|$80
lda #' '
: jsr COut
dex
cpx str_from_int
Expand All @@ -546,7 +563,7 @@ OpenDone:
.proc VisitDir

jsr PrintName
lda #'/'|$80
lda #'/'
jsr COut
jsr CROut

Expand Down Expand Up @@ -840,66 +857,56 @@ fail:

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

.proc PRNum1
;;; Inputs: Y = entry point, A = char to output (for `PWrite`)
.proc GoCard
;; Normal banking
sta ALTZPOFF
bit ROMIN2

copy16 COUT_HOOK, old_hook
copy16 #SLOT1, COUT_HOOK
lda #(CHAR_RETURN | $80)
jsr SLOT1
ldx SLOT1,Y
stx vector+1
ldx #>SLOT1 ; X = $Cn
ldy #((>SLOT1)<<4)&%11110000 ; Y = $n0
vector: jsr SLOT1 ; self-modified

;; Back to what DeskTop expects
sta ALTZPON
bit LCBANK1
bit LCBANK1

rts
.endproc ; PRNum1
.endproc ; GoCard

.proc CROut
lda #0
sta ch

lda #$8D ; CR
lda #CHAR_RETURN
jsr COut
lda #CHAR_DOWN
FALL_THROUGH_TO COut
.endproc ; CROut

.proc COut
inc ch

;; Normal banking
sta ALTZPOFF
bit ROMIN2
sta asave
stx xsave
sty ysave

jsr COUT
ldy #PWrite
jsr GoCard

;; Back to what DeskTop expects
sta ALTZPON
bit LCBANK1
bit LCBANK1
lda asave
ldx xsave
ldy ysave

rts
.endproc ; COut

.proc RestoreCOutHook
;; Normal banking
sta ALTZPOFF
bit ROMIN2

copy16 old_hook, COUT_HOOK

;; Back to what DeskTop expects
sta ALTZPON
bit LCBANK1
bit LCBANK1

rts
.endproc ; RestoreCOutHook

old_hook:
.word 0
asave: .byte 0
xsave: .byte 0
ysave: .byte 0
.endproc ; COut

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

Expand Down
Loading

0 comments on commit 213c4d4

Please sign in to comment.