Handling switches correctly.

This commit is contained in:
Rob Greene 2015-09-22 22:07:48 -05:00
parent 9f38bb4c43
commit 7c2c18bb43
1 changed files with 57 additions and 28 deletions

View File

@ -39,7 +39,8 @@ extrncmd = $be06 ; External command JMP vector
xtrnaddr = $be50 ; Execution address of external command
xlen = $be52 ; Length of command string-1
xcnum = $be53 ; BASIC cmd number (external command = 0)
pbits = $be54 ; Parameter bits
pbits = $be54 ; Parameter bits allowed (2 bytes)
fbits = $be56 ; Parameter bits found
vslot = $be61
vdriv = $be62
gosystem = $be70
@ -48,6 +49,27 @@ sunitnum = $bec7
sbufadr = $bec8
getbufr = $bef5
; Parameter bits flags (note setup for two bytes and for lo/hi usage)
pfix = $0080 ; Prefix needs fetching, pathname optional
slot = $0040 ; No parameters to be processed
rrun = $0020 ; Command only valid during program
fnopt = $0010 ; Filename is optional
crflg = $0008 ; CREATE allowed
t = $0004 ; File type
fn2 = $0002 ; Filename #2 for RENAME
fn1 = $0001 ; Filename expected
ad = $8000 ; Address
b = $4000 ; Byte
e = $2000 ; End address
l = $1000 ; Length
line = $0800 ; '@' line number
sd = $0400 ; Slot and drive numbers
f = $0200 ; Field
r = $0100 ; Record
v = $0000 ; Volume number ignored
; MONITOR locations:
crout = $fd8e
@ -131,6 +153,8 @@ entry:
cpx #cmdlen
bne :--
; Setup for BASIC.SYSTEM to parse
opts = fnopt|sd ; Filename is optional (due to glitch) and slot and drive
lda #cmdlen-1
sta xlen
lda #<online
@ -138,12 +162,10 @@ entry:
lda #>online
sta xtrnaddr+1
stz xcnum
lda #$10 ; Filename is optional
lda #<opts
sta pbits
lda #$04 ; Slot and drive numbers
lda #>opts
sta pbits+1
stz vslot
stz vdriv
clc
rts
@ -151,12 +173,6 @@ notOurCommand:
sec
jmp (nextcmd)
nextcmd: .word 0
cmdtable:
asciih "ONLINE"
cmdlen = *-cmdtable
;
; Perform ONLINE command
; Note we use the input buffer address
@ -173,8 +189,11 @@ cmdlen = *-cmdtable
; S5 D1 ERR=$57 (S7 D1)
;
online:
lda vdriv
asl
lda #>sd
bit fbits+1
beq @1 ; Bit was NOT set
lda vdriv ; 1 or 2, use 2nd bit to toggle drive (then drive 1 has bit off, drive 2 has bit on)
and #%00000010
asl
asl
ora vslot
@ -183,13 +202,13 @@ online:
asl
asl
sta sunitnum
stz sbufadr
@1: stz sbufadr
lda #>buffer
sta sbufadr+1
lda #$C5 ; ONLINE system command
; Note: if we have a specific unit, this is not zero terminated -- fake it!
stz buffer+16
lda #$C5 ; ONLINE system command
jsr gosystem
bcc @continue
rts
@continue:
ldx #0
@ -197,8 +216,7 @@ online:
ldy buffer,x
beq @exit
jsr printsd
lda #' '|$80
jsr cout
jsr printspc
tya
and #$0f
beq @deverr
@ -225,22 +243,20 @@ online:
jmp crout
; A device error message
@deverr:
lda #'E'|$80
ldy #0
: lda msgERR,y
beq :+
jsr cout
lda #'R'|$80
jsr cout
jsr cout
lda #'='|$80
jsr cout
inx
iny
bne :-
: inx
lda buffer,x
tay ; short-term save
jsr prbyte
tya
cmp #$57 ; duplicate volume error
bne @adjust
lda #' '|$80
jsr cout
jsr printspc
lda #'('|$80
jsr cout
inx
@ -271,5 +287,18 @@ printsd:
adc #'1'|$80 ; ... making the '1' a '2'
jmp cout
printspc:
lda #' '|$80
jmp cout
msgERR:
asciizh "ERR=$"
cmdtable:
asciih "ONLINE"
cmdlen = *-cmdtable
nextcmd: .word 0
_CodeEndAddress: