passport/src/print.a

173 lines
4.0 KiB
Plaintext
Raw Normal View History

2017-01-08 03:35:35 +00:00
kForceLower !byte $FF ; AND mask for lowercase letters
; (set at program startup)
;-------------------------------
; PrintByID
; Print a string from the string table;
; handles string substitutions and
; auto-uppercases on older machines
; in: A = string ID
; out: C clear if string was printed
2017-01-08 03:35:35 +00:00
; C set if string ID was invalid
; all other flags clobbered
; X register preserved, others clobbered
;-------------------------------
!zone {
2017-01-08 03:35:35 +00:00
PrintByID
stx .x+1
2017-01-08 03:35:35 +00:00
ldy #0 ; substitution mode flag
cmp #STRINGCOUNT
bcs .error
2017-01-08 03:35:35 +00:00
tax
lda StringTableLow,x
sta .print+1
lda StringTableHigh,x
sta .print+2
.print
2017-01-08 03:35:35 +00:00
lda $FFFF ; modified at runtime
beq .done
2017-01-08 03:35:35 +00:00
cpy #0 ; are we in substitution mode?
beq .nosub ; no -> branch
2017-01-08 03:35:35 +00:00
ldy #0
cmp #"t" ; "%t" = current track
bne .sub1
2017-01-08 03:35:35 +00:00
lda gTrack
bpl .printbyte ; unconditional branch
.sub1
2017-01-08 03:35:35 +00:00
cmp #"s" ; "%s" = current sector
bne .sub2
2017-01-08 03:35:35 +00:00
lda gSector
bpl .printbyte ; unconditional branch
.sub2
2017-01-08 03:35:35 +00:00
cmp #"S" ; write slot
bne .sub3
2017-01-08 03:35:35 +00:00
lda SLOT
bne .printsd ; unconditional branch
.sub3
2017-01-08 03:35:35 +00:00
cmp #"D" ; write drive
bne .sub4
2017-01-08 03:35:35 +00:00
lda DRIVE
.printsd
2017-01-08 03:35:35 +00:00
ora #$80
jsr PrintA
bvc .next ; unconditional branch
.sub4
2017-01-08 03:35:35 +00:00
cmp #"0" ; "%0" through "%9"
bcc .nosub
2017-01-08 03:35:35 +00:00
cmp #":"
bcs .nosub
2017-01-08 03:35:35 +00:00
sec
sbc #"0"
tax
lda gDisplayBytes,x
.printbyte
2017-01-08 03:35:35 +00:00
jsr PrintByte
bvc .next ; unconditional branch
.nosub
2017-01-08 03:35:35 +00:00
cmp #"%"
bne .stillnosub
2017-01-08 03:35:35 +00:00
iny ; switch to substitution mode
bne .next ; (next character will be interpreted)
.stillnosub
2017-01-08 03:35:35 +00:00
cmp #$E1
bcc .noforce
2017-01-08 03:35:35 +00:00
and kForceLower
.noforce
2017-01-08 03:35:35 +00:00
jsr COUT
.next
inc .print+1
bne .print
inc .print+2
bne .print
.done
2017-01-08 03:35:35 +00:00
clc
.error
.x ldx #$d1
2017-01-08 03:35:35 +00:00
rts
;-------------------------------
; PrintByte
; print a hexadecimal byte
; in: A contains byte to print
; out: all registers preserved
2017-01-08 03:35:35 +00:00
; all flags clobbered
; @tmpa clobbered
; @tmpx clobbered
; @tmpy clobbered
;-------------------------------
PrintByte
2019-04-16 05:39:12 +00:00
jsr .saveAXY
2017-01-08 03:35:35 +00:00
jsr PRBYTE
2019-04-16 05:39:12 +00:00
jmp .loadAXY
2017-01-08 03:35:35 +00:00
;-------------------------------
; PrintA
; print a single character through COUT
; in: A contains character to print
; out: all registers preserved
2017-01-08 03:35:35 +00:00
; all flags clobbered
; @tmpa clobbered
; @tmpx clobbered
; @tmpy clobbered
;-------------------------------
PrintA
2019-04-16 05:39:12 +00:00
jsr .saveAXY
2017-01-08 03:35:35 +00:00
jsr COUT
2019-04-16 05:39:12 +00:00
.loadAXY
2017-01-08 03:35:35 +00:00
lda tmpa
ldx tmpx
ldy tmpy
clv
rts
2019-04-16 05:39:12 +00:00
.saveAXY
sta tmpa
stx tmpx
sty tmpy
rts
2017-01-08 03:35:35 +00:00
;-------------------------------
; ClearScreen
;-------------------------------
ClearScreen
jsr TEXT
lda $C061
bpl .home
2017-01-08 03:35:35 +00:00
lda $C062
bpl .home
.begin
2017-01-08 03:35:35 +00:00
ldx #$04
stx counter
stx .loop+2
stx .change+2
2017-01-08 03:35:35 +00:00
ldy #$00
sty flag
.loop
2019-04-16 05:39:12 +00:00
ldx $FF00,y ; modified at runtime
cpx #$A0
beq .nochange
bcs .down
2019-04-16 05:39:12 +00:00
inx
bne .change
.down
2019-04-16 05:39:12 +00:00
dex
.change
2019-04-16 05:39:12 +00:00
txa
2017-01-08 03:35:35 +00:00
sta $FF00,y ; modified at runtime
sta flag
.nochange
2017-01-08 03:35:35 +00:00
iny
bne .loop
inc .loop+2
inc .change+2
2017-01-08 03:35:35 +00:00
dec counter
bne .loop
2017-01-08 03:35:35 +00:00
lda #$01
jsr WAIT
lda flag
bne .begin
.home
2017-01-08 03:35:35 +00:00
jmp HOME
}