Function works, but BASIC.SYSTEM ProDOS hooks appear to be generating error. Need to verify and maybe call ProDOS directly.

This commit is contained in:
Rob Greene 2015-09-20 23:29:43 -05:00
parent 06a4db46e3
commit 9f38bb4c43
1 changed files with 86 additions and 54 deletions

View File

@ -1,8 +1,6 @@
; ;
; main.s ; online.asm
; cd-online-basic-system-integration
; ;
; Created by Rob Greene on 9/14/15.
; Copyright (c) 2015 Rob Greene. All rights reserved. ; Copyright (c) 2015 Rob Greene. All rights reserved.
; ;
@ -16,6 +14,13 @@
.byte 0 .byte 0
.endmacro .endmacro
; ASCII string with high-bit set
.macro asciih string
.repeat .strlen(string),i
.byte .strat(string,i) | $80
.endrep
.endmacro
; Dextral (right-most) Character Inverted ; Dextral (right-most) Character Inverted
.macro dci string .macro dci string
.repeat .strlen(string),i .repeat .strlen(string),i
@ -57,6 +62,17 @@ buffer = $6800
.org $2000 .org $2000
install: install:
; 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
ldy #0 ldy #0
: lda _CodeStartAddress,y : lda _CodeStartAddress,y
sta _CodeBeginAddress,y sta _CodeBeginAddress,y
@ -64,17 +80,40 @@ install:
cpy #(_CodeEndAddress-_CodeBeginAddress) cpy #(_CodeEndAddress-_CodeBeginAddress)
bne :- bne :-
lda extrncmd+1 ; Setup BASIC.SYSTEM hooks:
; 1. Save EXTRNCMD
lda extrncmd+2
sta nextcmd+1 sta nextcmd+1
lda extrncmd lda extrncmd+1
sta nextcmd sta nextcmd
; 2. Place our hook into EXTRNCMD
lda #>entry lda #>entry
sta extrncmd sta extrncmd+2
lda #<entry lda #<entry
sta extrncmd sta extrncmd+1
rts ; 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"
_CodeStartAddress: _CodeStartAddress:
.org $6000 .org $6000
@ -82,23 +121,31 @@ _CodeStartAddress:
_CodeBeginAddress: _CodeBeginAddress:
entry: entry:
ldx #0 ldx #0
@again: : lda inbuf,x
ldy #0 cmp #$e0 ; Force input to UPPERCASE for comparison
: lda cmdtable,x bcc :+
beq ourcommand and #$df
cmp inbuf,y : cmp cmdtable,x
bne @nextcmd bne notOurCommand
inx inx
iny cpx #cmdlen
bra :- bne :--
@nextcmd:
inx lda #cmdlen-1
lda cmdtable,x sta xlen
bne @nextcmd lda #<online
inx ; Skip jumps sta xtrnaddr
inx lda #>online
lda cmdtable,x sta xtrnaddr+1
bne @again stz xcnum
lda #$10 ; Filename is optional
sta pbits
lda #$04 ; Slot and drive numbers
sta pbits+1
stz vslot
stz vdriv
clc
rts
notOurCommand: notOurCommand:
sec sec
@ -106,33 +153,9 @@ notOurCommand:
nextcmd: .word 0 nextcmd: .word 0
ourcommand:
stx xlen
lda cmdtable,x
sta xtrnaddr
lda cmdtable+1,x
sta xtrnaddr+1
stz xcnum
lda #$10
sta pbits
lda #$04
sta pbits+1
stz vslot
stz vdriv
clc
rts
cmdtable: cmdtable:
asciizh "CD" asciih "ONLINE"
.addr cd cmdlen = *-cmdtable
asciizh "ONLINE"
.addr online
;
; Perform CD command
;
cd:
rts
; ;
; Perform ONLINE command ; Perform ONLINE command
@ -146,11 +169,20 @@ cd:
; ;
; Output: ; Output:
; S7 D1 /HDD ; S7 D1 /HDD
; S6 D1 Err=$28 ; S6 D1 ERR=$28
; S5 D1 Err=$57 (S7 D1) ; S5 D1 ERR=$57 (S7 D1)
; ;
online: online:
stz sunitnum lda vdriv
asl
asl
asl
ora vslot
asl
asl
asl
asl
sta sunitnum
stz sbufadr stz sbufadr
lda #>buffer lda #>buffer
sta sbufadr+1 sta sbufadr+1