Use BI's buffers. Add ECHO, that shows INBUF problem

This commit is contained in:
Joshua Bell 2019-01-08 18:36:52 -08:00
parent e612444c4b
commit 76178cf0a8
4 changed files with 78 additions and 73 deletions

View File

@ -5,7 +5,8 @@ CCFLAGS = --config apple2-asm.cfg
OUTDIR = out OUTDIR = out
TARGETS = $(OUTDIR)/path.BIN $(OUTDIR)/bell.CMD $(OUTDIR)/hello.CMD TARGETS = $(OUTDIR)/path.BIN \
$(OUTDIR)/bell.CMD $(OUTDIR)/hello.CMD $(OUTDIR)/echo.CMD
.PHONY: clean all .PHONY: clean all
all: $(OUTDIR) $(TARGETS) all: $(OUTDIR) $(TARGETS)

22
echo.cmd.s Normal file
View File

@ -0,0 +1,22 @@
.include "apple2.inc"
CROUT := $FD8E
COUT := $FDED
INBUF := $200
.org $4000
jsr CROUT
ldx #cmd_length
: lda INBUF,x
inx
jsr COUT
cmp #$8D
bne :-
rts
cmd_length = .strlen("echo")

112
path.s
View File

@ -245,60 +245,30 @@ not_ours:
;;; ============================================================ ;;; ============================================================
cmd_path_buffer := $280
.proc get_file_info_params
param_count: .byte $A
pathname: .addr cmd_path_buffer
access: .byte 0
file_type: .byte 0
aux_type: .word 0
storage_type: .byte 0
blocks_used: .word 0
mod_date: .word 0
mod_time: .word 0
create_date: .word 0
create_time: .word 0
.endproc
.proc open_params
param_count: .byte 3
pathname: .addr cmd_path_buffer
io_buffer: .addr 0
ref_num: .byte 0
.endproc
.proc read_params
param_count: .byte 4
ref_num: .byte 0
data_buffer: .addr cmd_load_addr
request_count: .word max_cmd_size
trans_count: .word 0
.endproc
.proc close_params
param_count: .byte 1
ref_num: .byte 0
.endproc
maybe_invoke: maybe_invoke:
lda VPATH1
sta ptr
lda VPATH1+1
sta ptr+1
;; Compose path ;; Compose path
ldx #0 ldx #0
ldy #1
page_num12 := *+2 ; address needing updating page_num12 := *+2 ; address needing updating
: lda path_buffer+1,x : lda path_buffer+1,x
sta cmd_path_buffer+1,x
inx inx
sta (ptr),y
iny
page_num14 := *+2 ; address needing updating page_num14 := *+2 ; address needing updating
cpx path_buffer cpx path_buffer
bne :- bne :-
lda #'/' lda #'/'
sta cmd_path_buffer+1,x sta (ptr),y
inx iny
ldy #0 ldx #0
: lda INBUF,y : lda INBUF,x
and #$7F and #$7F
cmp #'.' cmp #'.'
beq ok beq ok
@ -315,18 +285,22 @@ maybe_invoke:
cmp #'z'+1 cmp #'z'+1
bcs notok bcs notok
ok: sta cmd_path_buffer+1,x ok: sta (ptr),y
iny iny
inx inx
cpx #65 ; Maximum path length+1 cpx #65 ; Maximum path length+1
bcc :- bcc :-
bcs fail_gfi bcs fail_gfi
notok: stx cmd_path_buffer notok: dey
tya
ldy #0
sta (ptr),y
;; Check to see if path exists. ;; Check to see if path exists.
page_num19 := *+5 lda #$A ; param length
MLI_CALL GET_FILE_INFO, get_file_info_params sta SSGINFO
MLI_CALL GET_FILE_INFO, SSGINFO
beq :+ beq :+
fail_gfi: fail_gfi:
@ -334,8 +308,7 @@ fail_gfi:
rts rts
;; Check to see if type is CMD. ;; Check to see if type is CMD.
page_num23 := *+2 : lda FIFILID
: lda get_file_info_params::file_type
cmp #$F0 ; CMD cmp #$F0 ; CMD
bne fail_gfi ; wrong type - ignore it bne fail_gfi ; wrong type - ignore it
@ -357,27 +330,33 @@ fail_gfi:
bcc :+ bcc :+
lda #$C ; NO BUFFERS AVAILABLE lda #$C ; NO BUFFERS AVAILABLE
rts rts
page_num27 := *+2 : sta OSYSBUF+1
: sta open_params::io_buffer+1
;; Now try to open/read/close and invoke it ;; Now try to open/read/close and invoke it
page_num20 := *+5 MLI_CALL OPEN, SOPEN
MLI_CALL OPEN, open_params
bne fail_load bne fail_load
page_num24 := *+2 lda OREFNUM
lda open_params::ref_num sta RWREFNUM
page_num25 := *+2 sta CFREFNUM
sta read_params::ref_num
page_num26 := *+2
sta close_params::ref_num
page_num21 := *+5
MLI_CALL READ, read_params lda #<cmd_load_addr
sta RWDATA
lda #>cmd_load_addr
sta RWDATA+1
lda #<max_cmd_size
sta RWCOUNT
lda #>max_cmd_size
sta RWCOUNT+1
MLI_CALL READ, SREAD
bne fail_load bne fail_load
page_num22 := *+5 ;; CLOSE call trashes INBUF ????
MLI_CALL CLOSE, close_params
MLI_CALL CLOSE, SCLOSE
jsr FREEBUFR jsr FREEBUFR
;; Invoke command ;; Invoke command
@ -483,13 +462,4 @@ relocation_table:
.addr handler::page_num12 .addr handler::page_num12
.addr handler::page_num14 .addr handler::page_num14
.addr handler::page_num18 .addr handler::page_num18
.addr handler::page_num19
.addr handler::page_num20
.addr handler::page_num21
.addr handler::page_num22
.addr handler::page_num23
.addr handler::page_num24
.addr handler::page_num25
.addr handler::page_num26
.addr handler::page_num27
table_end := * table_end := *

View File

@ -60,9 +60,21 @@ GOSYSTEM := $BE70 ; Use instead of MLI
XRETURN := $BE9E ; Handy RTS XRETURN := $BE9E ; Handy RTS
SSGINFO := $BEB4 ; Get Info Parameter block SSGINFO := $BEB4 ; GET_FILE_INFO Parameter block
FIFILID := $BEB8 ; (set size $A) FIFILID := $BEB8 ; (set size $A)
SOPEN := $BECB ; OPEN
OSYSBUF := $BECE
OREFNUM := $BED0
SREAD := $BED5 ; READ
RWREFNUM := $BED6
RWDATA := $BED7
RWCOUNT := $BED9
SCLOSE := $BEDD ; CLOSE
CFREFNUM := $BEDE
GETBUFR := $BEF5 GETBUFR := $BEF5
FREEBUFR := $BEF8 FREEBUFR := $BEF8
RSHIMEM := $BEFB RSHIMEM := $BEFB