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
|
2017-01-24 00:57:43 +00:00
|
|
|
; 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
|
|
|
|
;-------------------------------
|
2017-01-24 00:57:43 +00:00
|
|
|
!zone {
|
2017-01-08 03:35:35 +00:00
|
|
|
PrintByID
|
2017-01-24 00:57:43 +00:00
|
|
|
stx .x
|
2017-01-08 03:35:35 +00:00
|
|
|
ldy #0 ; substitution mode flag
|
|
|
|
cmp #STRINGCOUNT
|
2017-01-24 00:57:43 +00:00
|
|
|
bcs .error
|
2017-01-08 03:35:35 +00:00
|
|
|
asl
|
|
|
|
tax
|
|
|
|
lda StringTable,x
|
2017-01-24 00:57:43 +00:00
|
|
|
sta .print+1
|
2017-01-08 03:35:35 +00:00
|
|
|
lda StringTable+1,x
|
2017-01-24 00:57:43 +00:00
|
|
|
sta .print+2
|
|
|
|
.print
|
2017-01-08 03:35:35 +00:00
|
|
|
lda $FFFF ; modified at runtime
|
2017-01-24 00:57:43 +00:00
|
|
|
beq .done
|
2017-01-08 03:35:35 +00:00
|
|
|
cpy #0 ; are we in substitution mode?
|
2017-01-24 00:57:43 +00:00
|
|
|
beq .nosub ; no -> branch
|
2017-01-08 03:35:35 +00:00
|
|
|
ldy #0
|
|
|
|
cmp #"t" ; "%t" = current track
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .sub1
|
2017-01-08 03:35:35 +00:00
|
|
|
lda gTrack
|
2017-01-24 00:57:43 +00:00
|
|
|
bpl .printbyte ; unconditional branch
|
|
|
|
.sub1
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #"s" ; "%s" = current sector
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .sub2
|
2017-01-08 03:35:35 +00:00
|
|
|
lda gSector
|
2017-01-24 00:57:43 +00:00
|
|
|
bpl .printbyte ; unconditional branch
|
|
|
|
.sub2
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #"S" ; write slot
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .sub3
|
2017-01-08 03:35:35 +00:00
|
|
|
lda SLOT
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .printsd ; unconditional branch
|
|
|
|
.sub3
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #"D" ; write drive
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .sub4
|
2017-01-08 03:35:35 +00:00
|
|
|
lda DRIVE
|
2017-01-24 00:57:43 +00:00
|
|
|
.printsd
|
2017-01-08 03:35:35 +00:00
|
|
|
ora #$80
|
|
|
|
jsr PrintA
|
2017-01-24 00:57:43 +00:00
|
|
|
bvc .next ; unconditional branch
|
|
|
|
.sub4
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #"0" ; "%0" through "%9"
|
2017-01-24 00:57:43 +00:00
|
|
|
bcc .nosub
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #":"
|
2017-01-24 00:57:43 +00:00
|
|
|
bcs .nosub
|
2017-01-08 03:35:35 +00:00
|
|
|
sec
|
|
|
|
sbc #"0"
|
|
|
|
tax
|
|
|
|
lda gDisplayBytes,x
|
2017-01-24 00:57:43 +00:00
|
|
|
.printbyte
|
2017-01-08 03:35:35 +00:00
|
|
|
jsr PrintByte
|
2017-01-24 00:57:43 +00:00
|
|
|
bvc .next ; unconditional branch
|
|
|
|
.nosub
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #"%"
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .stillnosub
|
2017-01-08 03:35:35 +00:00
|
|
|
iny ; switch to substitution mode
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .next ; (next character will be interpreted)
|
|
|
|
.stillnosub
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #$E1
|
2017-01-24 00:57:43 +00:00
|
|
|
bcc .noforce
|
2017-01-08 03:35:35 +00:00
|
|
|
and kForceLower
|
2017-01-24 00:57:43 +00:00
|
|
|
.noforce
|
2017-01-08 03:35:35 +00:00
|
|
|
jsr COUT
|
2017-01-24 00:57:43 +00:00
|
|
|
.next
|
|
|
|
inc .print+1
|
|
|
|
bne .print
|
|
|
|
inc .print+2
|
|
|
|
bne .print
|
|
|
|
.done
|
2017-01-08 03:35:35 +00:00
|
|
|
clc
|
2017-01-24 00:57:43 +00:00
|
|
|
.error
|
|
|
|
ldx .x
|
2017-01-08 03:35:35 +00:00
|
|
|
rts
|
2017-01-24 00:57:43 +00:00
|
|
|
.x !byte 00
|
2017-01-08 03:35:35 +00:00
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; PrintByte
|
|
|
|
; print a hexadecimal byte
|
2017-01-24 00:57:43 +00:00
|
|
|
; 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
|
|
|
|
sta tmpa
|
|
|
|
stx tmpx
|
|
|
|
sty tmpy
|
|
|
|
jsr PRBYTE
|
|
|
|
lda tmpa
|
|
|
|
ldx tmpx
|
|
|
|
ldy tmpy
|
|
|
|
clv
|
|
|
|
rts
|
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; PrintA
|
|
|
|
; print a single character through COUT
|
2017-01-24 00:57:43 +00:00
|
|
|
; 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
|
|
|
|
sta tmpa
|
|
|
|
stx tmpx
|
|
|
|
sty tmpy
|
|
|
|
jsr COUT
|
|
|
|
lda tmpa
|
|
|
|
ldx tmpx
|
|
|
|
ldy tmpy
|
|
|
|
clv
|
|
|
|
rts
|
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; ClearScreen
|
|
|
|
;-------------------------------
|
|
|
|
ClearScreen
|
|
|
|
jsr TEXT
|
|
|
|
lda $C061
|
2017-01-24 00:57:43 +00:00
|
|
|
bpl .home
|
2017-01-08 03:35:35 +00:00
|
|
|
lda $C062
|
2017-01-24 00:57:43 +00:00
|
|
|
bpl .home
|
|
|
|
.begin
|
2017-01-08 03:35:35 +00:00
|
|
|
ldx #$04
|
|
|
|
stx counter
|
2017-01-24 00:57:43 +00:00
|
|
|
stx .loop+2
|
|
|
|
stx .change+2
|
2017-01-08 03:35:35 +00:00
|
|
|
ldy #$00
|
|
|
|
sty flag
|
2017-01-24 00:57:43 +00:00
|
|
|
.loop
|
2017-01-08 03:35:35 +00:00
|
|
|
lda $FF00,y ; modified at runtime
|
|
|
|
cmp #$A0
|
2017-01-24 00:57:43 +00:00
|
|
|
beq .nochange
|
|
|
|
bcs .down
|
2017-01-08 03:35:35 +00:00
|
|
|
clc
|
|
|
|
adc #$01
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .change
|
|
|
|
.down
|
2017-01-08 03:35:35 +00:00
|
|
|
sec
|
|
|
|
sbc #$01
|
2017-01-24 00:57:43 +00:00
|
|
|
.change
|
2017-01-08 03:35:35 +00:00
|
|
|
sta $FF00,y ; modified at runtime
|
|
|
|
sta flag
|
2017-01-24 00:57:43 +00:00
|
|
|
.nochange
|
2017-01-08 03:35:35 +00:00
|
|
|
iny
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .loop
|
|
|
|
inc .loop+2
|
|
|
|
inc .change+2
|
2017-01-08 03:35:35 +00:00
|
|
|
dec counter
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .loop
|
2017-01-08 03:35:35 +00:00
|
|
|
lda #$01
|
|
|
|
jsr WAIT
|
|
|
|
lda flag
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .begin
|
|
|
|
.home
|
2017-01-08 03:35:35 +00:00
|
|
|
jmp HOME
|
2017-01-24 00:57:43 +00:00
|
|
|
}
|