2015-09-19 20:23:41 +00:00
|
|
|
;
|
2015-09-21 04:29:43 +00:00
|
|
|
; online.asm
|
2015-09-19 20:23:41 +00:00
|
|
|
;
|
|
|
|
; Copyright (c) 2015 Rob Greene. All rights reserved.
|
|
|
|
;
|
|
|
|
|
|
|
|
.PC02 ; Enable 65C02 instructions
|
|
|
|
|
|
|
|
; ASCII string with high-bit set, terminated by a zero
|
|
|
|
.macro asciizh string
|
|
|
|
.repeat .strlen(string),i
|
|
|
|
.byte .strat(string,i) | $80
|
|
|
|
.endrep
|
|
|
|
.byte 0
|
|
|
|
.endmacro
|
|
|
|
|
2015-09-21 04:29:43 +00:00
|
|
|
; ASCII string with high-bit set
|
|
|
|
.macro asciih string
|
|
|
|
.repeat .strlen(string),i
|
|
|
|
.byte .strat(string,i) | $80
|
|
|
|
.endrep
|
|
|
|
.endmacro
|
|
|
|
|
2015-09-19 20:23:41 +00:00
|
|
|
; Dextral (right-most) Character Inverted
|
|
|
|
.macro dci string
|
|
|
|
.repeat .strlen(string),i
|
|
|
|
.if .strlen(string) = i
|
|
|
|
.byte .strat(string,i) | $80
|
|
|
|
.else
|
|
|
|
.byte .strat(string,i) & $7f
|
|
|
|
.endif
|
|
|
|
.endrep
|
|
|
|
.endmacro
|
|
|
|
|
|
|
|
; BASIC.SYSTEM locations:
|
|
|
|
|
|
|
|
inbuf = $0200
|
|
|
|
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
|
|
|
|
vslot = $be61
|
|
|
|
vdriv = $be62
|
|
|
|
gosystem = $be70
|
|
|
|
sonline = $bec6 ; BASIC.SYSTEM ONLINE parameter table
|
|
|
|
sunitnum = $bec7
|
|
|
|
sbufadr = $bec8
|
|
|
|
getbufr = $bef5
|
|
|
|
|
|
|
|
; MONITOR locations:
|
|
|
|
|
|
|
|
crout = $fd8e
|
|
|
|
prbyte = $fdda
|
|
|
|
cout = $fded
|
|
|
|
|
2015-09-19 22:26:44 +00:00
|
|
|
; Application stuff:
|
|
|
|
|
|
|
|
buffer = $6800
|
|
|
|
|
2015-09-19 20:23:41 +00:00
|
|
|
|
|
|
|
.org $2000
|
|
|
|
|
|
|
|
install:
|
2015-09-21 04:29:43 +00:00
|
|
|
|
|
|
|
; Requires 65C02 or later:
|
|
|
|
sed
|
|
|
|
lda #$99
|
|
|
|
clc
|
|
|
|
adc #$01
|
|
|
|
cld
|
|
|
|
bmi @6502
|
|
|
|
|
|
|
|
; Move code to destination address:
|
|
|
|
; TODO: Get address from BASIC.SYSTEM and move there, relocate code
|
2015-09-19 22:26:44 +00:00
|
|
|
ldy #0
|
|
|
|
: lda _CodeStartAddress,y
|
|
|
|
sta _CodeBeginAddress,y
|
|
|
|
iny
|
|
|
|
cpy #(_CodeEndAddress-_CodeBeginAddress)
|
|
|
|
bne :-
|
|
|
|
|
2015-09-21 04:29:43 +00:00
|
|
|
; Setup BASIC.SYSTEM hooks:
|
|
|
|
; 1. Save EXTRNCMD
|
|
|
|
lda extrncmd+2
|
2015-09-19 20:23:41 +00:00
|
|
|
sta nextcmd+1
|
2015-09-21 04:29:43 +00:00
|
|
|
lda extrncmd+1
|
2015-09-19 20:23:41 +00:00
|
|
|
sta nextcmd
|
2015-09-21 04:29:43 +00:00
|
|
|
; 2. Place our hook into EXTRNCMD
|
2015-09-19 20:23:41 +00:00
|
|
|
lda #>entry
|
2015-09-21 04:29:43 +00:00
|
|
|
sta extrncmd+2
|
2015-09-19 20:23:41 +00:00
|
|
|
lda #<entry
|
2015-09-21 04:29:43 +00:00
|
|
|
sta extrncmd+1
|
2015-09-19 22:26:44 +00:00
|
|
|
|
2015-09-21 04:29:43 +00:00
|
|
|
; Notify user:
|
|
|
|
ldy #0
|
|
|
|
: lda msgInstalled,y
|
|
|
|
beq :+
|
|
|
|
jsr cout
|
|
|
|
iny
|
|
|
|
bne :-
|
|
|
|
: rts
|
|
|
|
|
|
|
|
@6502:
|
|
|
|
ldy #0
|
|
|
|
: lda err6502,y
|
|
|
|
beq :+
|
|
|
|
jsr cout
|
|
|
|
iny
|
|
|
|
bne :-
|
|
|
|
: rts
|
|
|
|
|
|
|
|
err6502:
|
|
|
|
asciizh "ERR: MUST HAVE ENHANCED //E, //C, OR IIGS"
|
|
|
|
msgInstalled:
|
|
|
|
asciizh "ONLINE COMMAND INSTALLED"
|
2015-09-19 20:23:41 +00:00
|
|
|
|
2015-09-19 22:26:44 +00:00
|
|
|
_CodeStartAddress:
|
2015-09-19 20:23:41 +00:00
|
|
|
.org $6000
|
|
|
|
|
2015-09-19 22:26:44 +00:00
|
|
|
_CodeBeginAddress:
|
2015-09-19 20:23:41 +00:00
|
|
|
entry:
|
|
|
|
ldx #0
|
2015-09-21 04:29:43 +00:00
|
|
|
: lda inbuf,x
|
|
|
|
cmp #$e0 ; Force input to UPPERCASE for comparison
|
|
|
|
bcc :+
|
|
|
|
and #$df
|
|
|
|
: cmp cmdtable,x
|
|
|
|
bne notOurCommand
|
2015-09-19 20:23:41 +00:00
|
|
|
inx
|
2015-09-21 04:29:43 +00:00
|
|
|
cpx #cmdlen
|
|
|
|
bne :--
|
2015-09-19 20:23:41 +00:00
|
|
|
|
2015-09-21 04:29:43 +00:00
|
|
|
lda #cmdlen-1
|
|
|
|
sta xlen
|
|
|
|
lda #<online
|
2015-09-19 20:23:41 +00:00
|
|
|
sta xtrnaddr
|
2015-09-21 04:29:43 +00:00
|
|
|
lda #>online
|
2015-09-19 20:23:41 +00:00
|
|
|
sta xtrnaddr+1
|
|
|
|
stz xcnum
|
2015-09-21 04:29:43 +00:00
|
|
|
lda #$10 ; Filename is optional
|
2015-09-19 20:23:41 +00:00
|
|
|
sta pbits
|
2015-09-21 04:29:43 +00:00
|
|
|
lda #$04 ; Slot and drive numbers
|
2015-09-19 20:23:41 +00:00
|
|
|
sta pbits+1
|
|
|
|
stz vslot
|
|
|
|
stz vdriv
|
|
|
|
clc
|
|
|
|
rts
|
|
|
|
|
2015-09-21 04:29:43 +00:00
|
|
|
notOurCommand:
|
|
|
|
sec
|
|
|
|
jmp (nextcmd)
|
2015-09-19 20:23:41 +00:00
|
|
|
|
2015-09-21 04:29:43 +00:00
|
|
|
nextcmd: .word 0
|
|
|
|
|
|
|
|
cmdtable:
|
|
|
|
asciih "ONLINE"
|
|
|
|
cmdlen = *-cmdtable
|
2015-09-19 20:23:41 +00:00
|
|
|
|
|
|
|
;
|
|
|
|
; Perform ONLINE command
|
|
|
|
; Note we use the input buffer address
|
|
|
|
;
|
|
|
|
; Buffer format is:
|
|
|
|
; +000 DSSSLLLL D=Drive, SSS=Slot, LLLL=Length
|
|
|
|
; +001 CHAR1 Name... or error code
|
|
|
|
; ...
|
|
|
|
; +015 CHAR15
|
|
|
|
;
|
|
|
|
; Output:
|
|
|
|
; S7 D1 /HDD
|
2015-09-21 04:29:43 +00:00
|
|
|
; S6 D1 ERR=$28
|
|
|
|
; S5 D1 ERR=$57 (S7 D1)
|
2015-09-19 20:23:41 +00:00
|
|
|
;
|
|
|
|
online:
|
2015-09-21 04:29:43 +00:00
|
|
|
lda vdriv
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
ora vslot
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
sta sunitnum
|
2015-09-19 20:23:41 +00:00
|
|
|
stz sbufadr
|
2015-09-19 22:26:44 +00:00
|
|
|
lda #>buffer
|
2015-09-19 20:23:41 +00:00
|
|
|
sta sbufadr+1
|
2015-09-19 20:25:35 +00:00
|
|
|
lda #$C5 ; ONLINE system command
|
2015-09-19 20:23:41 +00:00
|
|
|
jsr gosystem
|
|
|
|
bcc @continue
|
|
|
|
rts
|
|
|
|
|
|
|
|
@continue:
|
|
|
|
ldx #0
|
|
|
|
@loop:
|
2015-09-19 22:26:44 +00:00
|
|
|
ldy buffer,x
|
2015-09-19 20:23:41 +00:00
|
|
|
beq @exit
|
2015-09-19 22:26:44 +00:00
|
|
|
jsr printsd
|
2015-09-19 22:55:34 +00:00
|
|
|
lda #' '|$80
|
|
|
|
jsr cout
|
2015-09-19 20:23:41 +00:00
|
|
|
tya
|
|
|
|
and #$0f
|
|
|
|
beq @deverr
|
|
|
|
tay
|
2015-09-19 22:55:34 +00:00
|
|
|
lda #'/'|$80
|
|
|
|
: jsr cout
|
|
|
|
inx
|
2015-09-19 22:26:44 +00:00
|
|
|
lda buffer,x
|
|
|
|
ora #$80
|
2015-09-19 20:23:41 +00:00
|
|
|
dey
|
2015-09-19 22:55:34 +00:00
|
|
|
bpl :-
|
2015-09-19 20:23:41 +00:00
|
|
|
@adjust:
|
|
|
|
jsr crout
|
|
|
|
txa
|
2015-09-19 22:55:34 +00:00
|
|
|
and #$0f ; Check if we advanced past this buffer
|
|
|
|
beq @loop
|
|
|
|
txa
|
2015-09-19 20:23:41 +00:00
|
|
|
and #$f0
|
2015-09-19 22:55:34 +00:00
|
|
|
clc
|
|
|
|
adc #$10
|
|
|
|
tax
|
|
|
|
bne @loop
|
|
|
|
@exit:
|
|
|
|
jmp crout
|
2015-09-19 20:23:41 +00:00
|
|
|
; A device error message
|
|
|
|
@deverr:
|
|
|
|
lda #'E'|$80
|
|
|
|
jsr cout
|
2015-09-19 22:26:44 +00:00
|
|
|
lda #'R'|$80
|
2015-09-19 20:23:41 +00:00
|
|
|
jsr cout
|
|
|
|
jsr cout
|
|
|
|
lda #'='|$80
|
|
|
|
jsr cout
|
|
|
|
inx
|
2015-09-19 22:26:44 +00:00
|
|
|
lda buffer,x
|
2015-09-19 20:23:41 +00:00
|
|
|
tay ; short-term save
|
|
|
|
jsr prbyte
|
|
|
|
tya
|
|
|
|
cmp #$57 ; duplicate volume error
|
|
|
|
bne @adjust
|
|
|
|
lda #' '|$80
|
|
|
|
jsr cout
|
|
|
|
lda #'('|$80
|
|
|
|
jsr cout
|
|
|
|
inx
|
2015-09-19 22:26:44 +00:00
|
|
|
ldy buffer,x
|
2015-09-19 20:23:41 +00:00
|
|
|
jsr printsd
|
|
|
|
lda #')'|$80
|
|
|
|
jsr cout
|
|
|
|
bra @adjust
|
|
|
|
|
|
|
|
printsd:
|
|
|
|
lda #'S'|$80
|
|
|
|
jsr cout
|
|
|
|
tya
|
|
|
|
and #$70
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
ora #'0'|$80
|
|
|
|
jsr cout
|
2015-09-19 22:55:34 +00:00
|
|
|
lda #','|$80
|
2015-09-19 20:23:41 +00:00
|
|
|
jsr cout
|
|
|
|
lda #'D'|$80
|
|
|
|
jsr cout
|
|
|
|
tya
|
|
|
|
and #$80
|
2015-09-19 22:26:44 +00:00
|
|
|
asl ; Drive 2 will set carry...
|
|
|
|
adc #'1'|$80 ; ... making the '1' a '2'
|
2015-09-19 20:23:41 +00:00
|
|
|
jmp cout
|
|
|
|
|
2015-09-19 22:26:44 +00:00
|
|
|
_CodeEndAddress:
|
2015-09-19 20:23:41 +00:00
|
|
|
|