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
|
2021-04-08 17:18:17 +00:00
|
|
|
; out: X register preserved, others clobbered
|
|
|
|
; all flags clobbered
|
2017-01-08 03:35:35 +00:00
|
|
|
;-------------------------------
|
|
|
|
PrintByID
|
2019-04-16 00:15:36 +00:00
|
|
|
stx .x+1
|
2017-01-08 03:35:35 +00:00
|
|
|
ldy #0 ; substitution mode flag
|
|
|
|
tax
|
2019-04-16 00:15:36 +00:00
|
|
|
lda StringTableLow,x
|
2021-04-20 04:27:11 +00:00
|
|
|
sta @print+1
|
2019-04-16 00:15:36 +00:00
|
|
|
lda StringTableHigh,x
|
2021-04-20 04:27:11 +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
|
2021-04-08 17:18:17 +00:00
|
|
|
cpy #0 ; are we in substitution mode or include mdoe?
|
|
|
|
bmi .include ; yes, include mode
|
2021-04-20 04:27:11 +00:00
|
|
|
beq @nosub ; no -> branch
|
2017-01-08 03:35:35 +00:00
|
|
|
ldy #0
|
|
|
|
cmp #"t" ; "%t" = current track
|
2021-04-20 04:27:11 +00:00
|
|
|
bne @sub1
|
2017-01-08 03:35:35 +00:00
|
|
|
lda gTrack
|
2021-04-20 04:27:11 +00:00
|
|
|
bpl @printbyte ; unconditional branch
|
|
|
|
@sub1
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #"s" ; "%s" = current sector
|
2021-04-20 04:27:11 +00:00
|
|
|
bne @sub2
|
2017-01-08 03:35:35 +00:00
|
|
|
lda gSector
|
2021-04-20 04:27:11 +00:00
|
|
|
bpl @printbyte ; unconditional branch
|
|
|
|
@sub2
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #"S" ; write slot
|
2021-04-20 04:27:11 +00:00
|
|
|
bne @sub3
|
2017-01-08 03:35:35 +00:00
|
|
|
lda SLOT
|
2021-04-20 04:27:11 +00:00
|
|
|
bne @printsd ; unconditional branch
|
|
|
|
@sub3
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #"D" ; write drive
|
2021-04-20 04:27:11 +00:00
|
|
|
bne @sub4
|
2017-01-08 03:35:35 +00:00
|
|
|
lda DRIVE
|
2021-04-20 04:27:11 +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
|
2021-04-20 04:27:11 +00:00
|
|
|
@sub4
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #"0" ; "%0" through "%9"
|
2021-04-20 04:27:11 +00:00
|
|
|
bcc @nosub
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #":"
|
2021-04-20 04:27:11 +00:00
|
|
|
bcs @nosub
|
2017-01-08 03:35:35 +00:00
|
|
|
sec
|
|
|
|
sbc #"0"
|
|
|
|
tax
|
|
|
|
lda gDisplayBytes,x
|
2021-04-20 04:27:11 +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
|
2021-04-20 04:27:11 +00:00
|
|
|
@nosub
|
2017-01-08 03:35:35 +00:00
|
|
|
cmp #"%"
|
2017-01-24 00:57:43 +00:00
|
|
|
bne .stillnosub
|
2021-04-08 17:18:17 +00:00
|
|
|
iny ; Y=#$01 (substitution mode, next character will be interpreted)
|
|
|
|
bne .next ; unconditional branch
|
2017-01-24 00:57:43 +00:00
|
|
|
.stillnosub
|
2021-04-08 17:18:17 +00:00
|
|
|
cmp #"@"
|
|
|
|
bne +
|
|
|
|
dey ; Y=#$FF (include mode, next character will be interpreted)
|
|
|
|
bne .next ; unconditional branch
|
|
|
|
+ cmp #$E1
|
2021-04-20 04:27:11 +00:00
|
|
|
bcc @noforce
|
2017-01-08 03:35:35 +00:00
|
|
|
and kForceLower
|
2021-04-20 04:27:11 +00:00
|
|
|
@noforce
|
2017-01-08 03:35:35 +00:00
|
|
|
jsr COUT
|
2017-01-24 00:57:43 +00:00
|
|
|
.next
|
2021-04-20 04:27:11 +00:00
|
|
|
inc @print+1
|
|
|
|
bne @print
|
|
|
|
inc @print+2
|
|
|
|
bne @print ; unconditional branch
|
2017-01-24 00:57:43 +00:00
|
|
|
.done
|
2021-04-08 17:18:17 +00:00
|
|
|
.x ldx #$FD ; SMC
|
2017-01-08 03:35:35 +00:00
|
|
|
rts
|
2021-04-08 17:18:17 +00:00
|
|
|
.include
|
|
|
|
sta .a+1
|
2021-04-20 04:27:11 +00:00
|
|
|
lda @print+1
|
2021-04-08 17:18:17 +00:00
|
|
|
pha
|
2021-04-20 04:27:11 +00:00
|
|
|
lda @print+2
|
2021-04-08 17:18:17 +00:00
|
|
|
pha
|
|
|
|
ldx .x+1
|
|
|
|
.a lda #$FD ; SMC
|
|
|
|
jsr PrintByID
|
|
|
|
pla
|
2021-04-20 04:27:11 +00:00
|
|
|
sta @print+2
|
2021-04-08 17:18:17 +00:00
|
|
|
pla
|
2021-04-20 04:27:11 +00:00
|
|
|
sta @print+1
|
2021-04-08 17:18:17 +00:00
|
|
|
ldy #0
|
|
|
|
beq .next ; unconditional branch
|
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
|
2021-04-20 04:27:11 +00:00
|
|
|
jsr SaveAXY
|
2017-01-08 03:35:35 +00:00
|
|
|
jsr PRBYTE
|
2021-04-20 04:27:11 +00:00
|
|
|
jmp LoadAXY
|
2017-01-08 03:35:35 +00:00
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; 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
|
2021-04-20 04:27:11 +00:00
|
|
|
jsr SaveAXY
|
2017-01-08 03:35:35 +00:00
|
|
|
jsr COUT
|
2021-04-20 04:27:11 +00:00
|
|
|
; /!\ execution falls through here
|
2019-04-16 05:39:12 +00:00
|
|
|
|
2021-04-20 04:27:11 +00:00
|
|
|
LoadAXY
|
2017-01-08 03:35:35 +00:00
|
|
|
lda tmpa
|
|
|
|
ldx tmpx
|
|
|
|
ldy tmpy
|
|
|
|
clv
|
|
|
|
rts
|
|
|
|
|
2021-04-20 04:27:11 +00:00
|
|
|
SaveAXY
|
2019-04-16 05:39:12 +00:00
|
|
|
sta tmpa
|
|
|
|
stx tmpx
|
|
|
|
sty tmpy
|
|
|
|
rts
|
|
|
|
|
2017-01-08 03:35:35 +00:00
|
|
|
;-------------------------------
|
|
|
|
; ClearScreen
|
|
|
|
;-------------------------------
|
|
|
|
ClearScreen
|
|
|
|
jsr TEXT
|
|
|
|
lda $C061
|
2021-04-20 05:10:23 +00:00
|
|
|
bpl @home
|
2017-01-08 03:35:35 +00:00
|
|
|
lda $C062
|
2021-04-20 05:10:23 +00:00
|
|
|
bpl @home
|
|
|
|
@begin
|
2017-01-08 03:35:35 +00:00
|
|
|
ldx #$04
|
|
|
|
stx counter
|
2021-04-20 04:27:11 +00:00
|
|
|
stx @loop+2
|
|
|
|
stx @change+2
|
2017-01-08 03:35:35 +00:00
|
|
|
ldy #$00
|
|
|
|
sty flag
|
2021-04-20 04:27:11 +00:00
|
|
|
@loop
|
2019-04-16 05:39:12 +00:00
|
|
|
ldx $FF00,y ; modified at runtime
|
|
|
|
cpx #$A0
|
2021-04-20 04:27:11 +00:00
|
|
|
beq @nochange
|
|
|
|
bcs @down
|
2019-04-16 05:39:12 +00:00
|
|
|
inx
|
2021-04-20 04:27:11 +00:00
|
|
|
bne @change
|
|
|
|
@down
|
2019-04-16 05:39:12 +00:00
|
|
|
dex
|
2021-04-20 04:27:11 +00:00
|
|
|
@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
|
2021-04-20 04:27:11 +00:00
|
|
|
@nochange
|
2017-01-08 03:35:35 +00:00
|
|
|
iny
|
2021-04-20 04:27:11 +00:00
|
|
|
bne @loop
|
|
|
|
inc @loop+2
|
|
|
|
inc @change+2
|
2017-01-08 03:35:35 +00:00
|
|
|
dec counter
|
2021-04-20 04:27:11 +00:00
|
|
|
bne @loop
|
2017-01-08 03:35:35 +00:00
|
|
|
lda #$01
|
|
|
|
jsr WAIT
|
|
|
|
lda flag
|
2021-04-20 05:10:23 +00:00
|
|
|
bne @begin
|
|
|
|
@home
|
2017-01-08 03:35:35 +00:00
|
|
|
jmp HOME
|