mirror of
https://github.com/a2-4am/passport.git
synced 2024-09-07 23:54:47 +00:00
373 lines
8.5 KiB
Plaintext
Executable File
373 lines
8.5 KiB
Plaintext
Executable File
;-------------------------------
|
|
; PrintByID
|
|
; Print a string from the string table
|
|
;
|
|
; Handles string substitutions and
|
|
; auto-uppercases on older machines
|
|
;
|
|
; fully re-entrant to support nested
|
|
; string substitutions (see strings/en.a)
|
|
;
|
|
; in: string ID (byte) on stack
|
|
; out: all registers preserved
|
|
; oVerflow bit clear
|
|
; all other flags clobbered
|
|
; stack set to after params
|
|
;-------------------------------
|
|
PrintByID
|
|
sta @tmpa+1
|
|
sty @tmpy+1
|
|
; get pointer to stack-based params then move the stack beyond them
|
|
pla
|
|
sta $00
|
|
clc
|
|
adc #$01
|
|
tay
|
|
pla
|
|
sta $01
|
|
adc #$00
|
|
pha
|
|
tya
|
|
pha
|
|
; save all registers and this routine's internal pointers
|
|
; (can't use SaveAXY because this routine needs to be re-entrant)
|
|
@tmpa lda #$FD ; SMC
|
|
pha
|
|
@tmpy lda #$FD ; SMC
|
|
pha
|
|
txa
|
|
pha
|
|
lda @print+1
|
|
pha
|
|
lda @print+2
|
|
pha
|
|
ldy #1
|
|
lda ($00), y ; get ID of string to print
|
|
tax
|
|
lda StringTableLow, x
|
|
sta @print+1
|
|
lda StringTableHigh, x
|
|
sta @print+2
|
|
dey ; Y=0
|
|
@print
|
|
lda $FFFF ; modified at runtime
|
|
beq @done
|
|
cpy #0 ; are we in substitution mode or include mode?
|
|
bmi @include ; yes, include mode
|
|
beq @nosub ; no -> branch
|
|
ldy #0
|
|
cmp #"t" ; "%t" = current track
|
|
bne @sub1
|
|
lda gTrack
|
|
bpl @printbyte ; unconditional branch
|
|
@sub1
|
|
cmp #"s" ; "%s" = current sector
|
|
bne @sub2
|
|
lda gSector
|
|
bpl @printbyte ; unconditional branch
|
|
@sub2
|
|
cmp #"S" ; write slot
|
|
bne @sub3
|
|
lda SLOT
|
|
bne @printsd ; unconditional branch
|
|
@sub3
|
|
cmp #"D" ; write drive
|
|
bne @sub4
|
|
lda DRIVE
|
|
@printsd
|
|
ora #$80
|
|
jsr PrintA
|
|
bvc @next ; unconditional branch
|
|
@sub4
|
|
cmp #"0" ; "%0" through "%9"
|
|
bcc @nosub
|
|
cmp #":"
|
|
bcs @nosub
|
|
tax
|
|
lda gDisplayBytes-$B0, x
|
|
@printbyte
|
|
jsr PrintByte
|
|
bvc @next ; unconditional branch
|
|
@nosub
|
|
cmp #"%"
|
|
bne @stillnosub
|
|
iny ; Y=#$01 (substitution mode, next character will be interpreted)
|
|
bne @next ; unconditional branch
|
|
@stillnosub
|
|
cmp #"@"
|
|
bne +
|
|
dey ; Y=#$FF (include mode, next character will be interpreted)
|
|
bne @next ; unconditional branch
|
|
+ cmp #$E1
|
|
bcc @noforce
|
|
and kForceLower
|
|
@noforce
|
|
jsr COUT
|
|
@next
|
|
inc @print+1
|
|
bne @print
|
|
inc @print+2
|
|
bne @print ; unconditional branch
|
|
@done
|
|
pla
|
|
sta @print+2
|
|
pla
|
|
sta @print+1
|
|
pla
|
|
tax
|
|
pla
|
|
tay
|
|
pla
|
|
clv
|
|
rts
|
|
@include
|
|
sta @id
|
|
jsr PrintByID
|
|
@id !byte $FD ; SMC
|
|
ldy #0
|
|
beq @next ; unconditional branch
|
|
|
|
;-------------------------------
|
|
; PrintByte
|
|
; print a hexadecimal byte
|
|
; in: A contains byte to print
|
|
; out: all registers preserved
|
|
; all flags clobbered
|
|
; @tmpa clobbered
|
|
; @tmpx clobbered
|
|
; @tmpy clobbered
|
|
;-------------------------------
|
|
PrintByte
|
|
jsr SaveAXY
|
|
jsr PRBYTE
|
|
bcc LoadAXY ; always branches
|
|
|
|
;-------------------------------
|
|
; PrintA
|
|
; print a single character through COUT
|
|
; in: A contains character to print
|
|
; out: all registers preserved
|
|
; all flags clobbered
|
|
; @tmpa clobbered
|
|
; @tmpx clobbered
|
|
; @tmpy clobbered
|
|
;-------------------------------
|
|
PrintA
|
|
jsr SaveAXY
|
|
jsr COUT
|
|
; /!\ execution falls through here
|
|
LoadAXY
|
|
lda tmpa
|
|
ldx tmpx
|
|
ldy tmpy
|
|
; /!\ execution falls through here
|
|
SaveAXY
|
|
sta tmpa
|
|
stx tmpx
|
|
sty tmpy
|
|
clv
|
|
rts
|
|
|
|
;-------------------------------
|
|
; ClearScreen
|
|
;-------------------------------
|
|
ClearScreen
|
|
jsr TEXT
|
|
lda $C061
|
|
bmi +
|
|
lda $C062
|
|
bpl @home
|
|
+ inc gMode
|
|
@home jmp HOME
|
|
|
|
;-------------------------------
|
|
; CheckCache
|
|
; Intercept text about to be scrolled off the screen
|
|
; Cache it in spare LC space for viewing later
|
|
;-------------------------------
|
|
CheckCache
|
|
ldx $25
|
|
cpx #$17
|
|
bne .nocache
|
|
ldx $24
|
|
cpx #$27
|
|
beq .docache
|
|
cmp #$8D
|
|
bne .nocache
|
|
.docache
|
|
pha
|
|
cmp #$8D
|
|
beq .skipcr
|
|
sta $7F7
|
|
.skipcr
|
|
bit $C081
|
|
bit $C081
|
|
ldx #$27
|
|
cachesrc
|
|
lda $700, x
|
|
CacheDst
|
|
sta $D400, x
|
|
dex
|
|
bpl cachesrc
|
|
lda CacheDst+1
|
|
adc #$27
|
|
sta CacheDst+1
|
|
bcc .skiphi
|
|
inc CacheDst+2
|
|
.skiphi
|
|
pla
|
|
|
|
.nocache
|
|
jmp $FDF0
|
|
|
|
;-------------------------------
|
|
; CheckLogKeys
|
|
; Enable scrolling of log, if more than once screen worth
|
|
; Left/Right (all)
|
|
; Up/Down (not II or II+)
|
|
;-------------------------------
|
|
|
|
CheckLogKeys
|
|
ldx CacheDst+1
|
|
ldy CacheDst+2
|
|
stx .startline1+1
|
|
sty .startline1+2
|
|
stx .startline2+1
|
|
sty .startline2+2
|
|
cpy #$D4
|
|
bne .skipkey
|
|
cpx #0
|
|
bne .skipkey
|
|
|
|
.nolog
|
|
rts
|
|
|
|
.checkkey
|
|
jsr WaitForKey
|
|
|
|
.skipkey
|
|
cmp #k_up
|
|
beq .checkup
|
|
cmp #k_right
|
|
beq .checkdown
|
|
cmp #k_down
|
|
beq .checkdown
|
|
cmp #k_left
|
|
bne .nolog
|
|
|
|
.checkup
|
|
lda .startline1+2
|
|
cmp #$D4
|
|
bne .scrollup
|
|
lda .startline1+1
|
|
beq .checkkey
|
|
|
|
.scrollup
|
|
jsr .substart
|
|
bit $C081
|
|
bit $C081
|
|
ldx #$27
|
|
.copyend1
|
|
lda $7D0,x
|
|
.endline1
|
|
sta $D428,x
|
|
dex
|
|
bpl .copyend1
|
|
|
|
ldx #22
|
|
.scrollscreen
|
|
txa
|
|
jsr $FBC1 ;BASCALC
|
|
lda $28
|
|
sta $2A
|
|
lda $29
|
|
sta $2B
|
|
inx
|
|
txa
|
|
jsr $FBC1 ;BASCALC
|
|
ldy #$27
|
|
.copyline
|
|
lda ($2A),y
|
|
sta ($28),y
|
|
dey
|
|
bpl .copyline
|
|
dex
|
|
dex
|
|
cpx #5
|
|
bne .scrollscreen
|
|
bit $C083
|
|
ldx #$27
|
|
.copystart1
|
|
.startline1
|
|
lda $D400,x
|
|
sta $700,x
|
|
dex
|
|
bpl .copystart1
|
|
bit $C081
|
|
jmp .checkkey
|
|
|
|
.checkdown
|
|
lda .startline1+2
|
|
cmp CacheDst+2
|
|
bne .scrolldown
|
|
lda .startline1+1
|
|
cmp CacheDst+1
|
|
beq .checkkey
|
|
|
|
.scrolldown
|
|
bit $C081
|
|
bit $C081
|
|
ldx #$27
|
|
.copystart2
|
|
lda $700,x
|
|
.startline2
|
|
sta $D400,x
|
|
dex
|
|
bpl .copystart2
|
|
lda #$8D
|
|
jsr $FDF0
|
|
bit $C083
|
|
bit $C083
|
|
ldx #$27
|
|
.copyend2
|
|
.endline2
|
|
lda $D428,x
|
|
sta $7D0,x
|
|
dex
|
|
bpl .copyend2
|
|
bit $C081
|
|
jsr .addstart
|
|
jmp .checkkey
|
|
|
|
.substart
|
|
sec
|
|
lda .startline1+1
|
|
sta .endline1+1
|
|
sta .endline2+1
|
|
sbc #$28
|
|
sta .startline1+1
|
|
sta .startline2+1
|
|
lda .startline1+2
|
|
sta .endline1+2
|
|
sta .endline2+2
|
|
sbc #0
|
|
sta .startline1+2
|
|
sta .startline2+2
|
|
rts
|
|
|
|
.addstart
|
|
clc
|
|
lda .endline1+1
|
|
sta .startline1+1
|
|
sta .startline2+1
|
|
adc #$28
|
|
sta .endline1+1
|
|
sta .endline2+1
|
|
lda .endline1+2
|
|
sta .startline1+2
|
|
sta .startline2+2
|
|
adc #0
|
|
sta .endline1+2
|
|
sta .endline2+2
|
|
rts
|