diff --git a/online.asm b/online.asm index eca9024..8740a0f 100644 --- a/online.asm +++ b/online.asm @@ -1,8 +1,6 @@ ; -; main.s -; cd-online-basic-system-integration +; online.asm ; -; Created by Rob Greene on 9/14/15. ; Copyright (c) 2015 Rob Greene. All rights reserved. ; @@ -16,6 +14,13 @@ .byte 0 .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 .macro dci string .repeat .strlen(string),i @@ -57,6 +62,17 @@ buffer = $6800 .org $2000 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 : lda _CodeStartAddress,y sta _CodeBeginAddress,y @@ -64,17 +80,40 @@ install: cpy #(_CodeEndAddress-_CodeBeginAddress) bne :- - lda extrncmd+1 +; Setup BASIC.SYSTEM hooks: +; 1. Save EXTRNCMD + lda extrncmd+2 sta nextcmd+1 - lda extrncmd + lda extrncmd+1 sta nextcmd - +; 2. Place our hook into EXTRNCMD lda #>entry - sta extrncmd + sta extrncmd+2 lda #online + sta xtrnaddr+1 + 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: sec @@ -106,33 +153,9 @@ notOurCommand: 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: - asciizh "CD" - .addr cd - asciizh "ONLINE" - .addr online - -; -; Perform CD command -; -cd: - rts + asciih "ONLINE" +cmdlen = *-cmdtable ; ; Perform ONLINE command @@ -146,11 +169,20 @@ cd: ; ; Output: ; S7 D1 /HDD -; S6 D1 Err=$28 -; S5 D1 Err=$57 (S7 D1) +; S6 D1 ERR=$28 +; S5 D1 ERR=$57 (S7 D1) ; online: - stz sunitnum + lda vdriv + asl + asl + asl + ora vslot + asl + asl + asl + asl + sta sunitnum stz sbufadr lda #>buffer sta sbufadr+1