BI Error constants; coding style

This commit is contained in:
Joshua Bell 2021-04-15 19:47:41 -07:00
parent 827d121ef2
commit 9971792f12
6 changed files with 73 additions and 57 deletions

View File

@ -58,15 +58,15 @@ execute:
;; FN2. So REL,/ABS becomes /PFX/REL,/PFX//ABS (oops!) and
;; /ABS,REL remains /ABS,REL (still relative!).
jsr get_prefix
jsr GetPrefix
bcs rts1
lda VPATH1
ldx VPATH1+1
jsr fix_path
jsr FixPath
lda VPATH2
ldx VPATH2+1
jsr fix_path
jsr FixPath
;; Get FN1 info
lda #$A
@ -77,9 +77,9 @@ execute:
;; Reject directory file
lda FIFILID
cmp #$F ; DIR
cmp #FT_DIR
bne :+
lda #$D ; FILE TYPE MISMATCH
lda #BI_ERR_FILE_TYPE_MISMATCH
sec
rts1: rts
:
@ -124,16 +124,16 @@ rts1: rts
jsr GOSYSTEM
bcs :+
lda #$13 ; DUPLICATE FILE NAME
lda #BI_ERR_DUPLICATE_FILE_NAME
err: pha
jsr close
jsr CloseFiles
pla
sec
rts
: cmp #6 ; BI Errors 6 and 7 cover
beq :+ ; vol dir, pathname, or filename
cmp #7 ; not found.
: cmp #BI_ERR_PATH_NOT_FOUND
beq :+
cmp #BI_ERR_VOLUME_DIR_NOT_FOUND
bne err ; Otherwise - fail.
:
@ -176,7 +176,7 @@ read: lda FN1REF
lda #READ
jsr GOSYSTEM
bcc :+
cmp #5 ; END OF DATA
cmp #BI_ERR_END_OF_DATA
beq finish
:
@ -197,11 +197,11 @@ read: lda FN1REF
jmp err
finish: jsr close
finish: jsr CloseFiles
clc
rts
.proc close
.proc CloseFiles
lda FN1REF
sta CFREFNUM
lda #CLOSE
@ -215,7 +215,7 @@ finish: jsr close
;;; Leave PREFIX at INBUF; infers it the same way as BI if empty.
;;; Returns with Carry set on failure.
.proc get_prefix
.proc GetPrefix
;; Try fetching prefix
MLI_CALL GET_PREFIX, get_prefix_params
lda INBUF
@ -263,7 +263,7 @@ unit: .byte 0
.endproc
;;; Fix path passed in A,X if it's relative. Uses prefix in INBUF
.proc fix_path
.proc FixPath
ptr := $06
ptr2 := $08

View File

@ -31,7 +31,9 @@ start:
;;; TIME: |0 0 0| hour | |0 0| minute |
;;; +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
MLI_CALL GET_TIME, 0
lda #GET_TIME
jsr GOSYSTEM
lda DATELO
ora DATEHI
beq not_set
@ -48,20 +50,20 @@ start:
rol a
rol a
and #%00001111
jsr cout_number
jsr PrintNumber
lda #'/'|$80 ; /
jsr COUT
pla ; day
and #%00011111
jsr cout_number
jsr PrintNumber
lda #'/'|$80 ; /
jsr COUT
pla ; year
jsr cout_number
jsr PrintNumber
lda #' '|$80 ;
jsr COUT
@ -71,14 +73,14 @@ start:
lda TIMELO+1 ; hour
and #%00011111
jsr cout_number
jsr PrintNumber
lda #':'|$80 ; ':'
jsr COUT
lda TIMELO ; minute
and #%00111111
jsr cout_number
jsr PrintNumber
finish: jsr CROUT
@ -100,7 +102,7 @@ msg: .byte "<NO DATE>", 0
;;; ============================================================
;;; Print a 2-digit number, with leading zeros
.proc cout_number
.proc PrintNumber
;; Reduce to 2 digits
: cmp #100
bcc :+

View File

@ -8,7 +8,7 @@
ldx #0
;; Skip any leading spaces
jsr skip_spaces
jsr SkipSpaces
;; Invoked with "-" ?
lda INBUF,x
@ -17,7 +17,7 @@
inx
:
;; Skip any more leading spaces
jsr skip_spaces
jsr SkipSpaces
;; Skip command name (i.e. "echo")
txa
@ -26,7 +26,7 @@
tax
;; Skip leading spaces before string to echo
jsr skip_spaces
jsr SkipSpaces
;; Echo string
: lda INBUF,x
@ -39,13 +39,13 @@
exit: clc
rts
.proc skip_spaces
lda INBUF,x
.proc SkipSpaces
repeat: lda INBUF,x
cmp #' '|$80
beq :+
rts
: inx
jmp skip_spaces
jmp repeat
.endproc
cmd_length = .strlen("echo")

26
path.s
View File

@ -35,7 +35,7 @@ CASE_MASK = $DF
lda #handler_pages
jsr GETBUFR
bcc :+
lda #$C ; NO BUFFERS AVAILABLE
lda #BI_ERR_NO_BUFFERS_AVAILABLE
rts
: sta new_page ; A = MSB of new page
@ -145,12 +145,12 @@ page_delta:
;; Check for this command, character by character.
reloc_point *+2
jsr skip_leading_spaces
jsr SkipLeadingSpaces
ldy #0 ; position in command string
reloc_point *+2
nxtchr: jsr to_upper_ascii
nxtchr: jsr ToUpperASCII
reloc_point *+2
cmp command_string,y
@ -193,9 +193,9 @@ check_if_token:
beq not_ours
reloc_point *+2
jsr skip_leading_spaces
jsr SkipLeadingSpaces
reloc_point *+2
jsr to_upper_ascii
jsr ToUpperASCII
cmp #'A'
bcc not_ours
@ -223,7 +223,7 @@ mloop: iny ; Advance through token table
;; Check for match
next_char:
reloc_point *+2
jsr to_upper_ascii ; Next character
jsr ToUpperASCII ; Next character
;; NOTE: Does not skip over spaces, unlike BASIC tokenizer
@ -238,7 +238,7 @@ next_char:
;; without preventing 'RUN100' from being typed.
inx
jsr to_upper_ascii
jsr ToUpperASCII
cmp #'A'
bcc not_ours
cmp #'Z'+1
@ -247,7 +247,7 @@ next_char:
;; Otherwise, advance to next token
next_token:
reloc_point *+2
jsr skip_leading_spaces
jsr SkipLeadingSpaces
sloop: lda (tptr),y ; Scan table looking for a high bit set
iny
bne :+
@ -302,9 +302,9 @@ compose:
;; Name from command line
reloc_point *+2
jsr skip_leading_spaces
jsr SkipLeadingSpaces
reloc_point *+2
: jsr to_upper_ascii
: jsr ToUpperASCII
cmp #'.'
beq ok
cmp #'0'
@ -341,7 +341,7 @@ notok: dey
;; Check to see if type is CMD.
lda FIFILID
cmp #$F0 ; CMD
cmp #FT_CMD
bne compose ; wrong type - try next path directory
;; Tell BASIC.SYSTEM it was handled.
@ -454,7 +454,7 @@ set_path:
;;; Returns INBUF,x with high bit stripped and up-cased
;;; (also converts {|}~DEL to [\]^_ but that's okay)
.proc to_upper_ascii
.proc ToUpperASCII
lda INBUF,x
and #$7F
cmp #'a'
@ -466,7 +466,7 @@ skip: rts
;;; Returns with X pointing at first non-space in INBUF,
;;; and that character loaded in A.
.proc skip_leading_spaces
.proc SkipLeadingSpaces
ldx #$FF
: inx
lda INBUF,x

View File

@ -27,6 +27,11 @@ CLOSE = $CC
.addr params
.endmacro
FT_TXT = $04
FT_DIR = $0F
FT_CMD = $F0
FT_BAS = $FC
;;; ============================================================
;;; BASIC.SYSTEM Global Page
@ -132,3 +137,12 @@ CCCSPARE := $BEDF
GETBUFR := $BEF5
FREEBUFR := $BEF8
RSHIMEM := $BEFB
;;; Error Codes
BI_ERR_END_OF_DATA = 5
BI_ERR_PATH_NOT_FOUND = 6
BI_ERR_VOLUME_DIR_NOT_FOUND = 7 ; Also shows as PATH NOT FOUND
BI_ERR_NO_BUFFERS_AVAILABLE = 12
BI_ERR_FILE_TYPE_MISMATCH = 13
BI_ERR_DUPLICATE_FILE_NAME = 19

View File

@ -53,9 +53,9 @@ execute:
;; Reject directory file
lda FIFILID
cmp #$F ; DIR
cmp #FT_DIR
bne :+
lda #$D ; FILE TYPE MISMATCH
lda #BI_ERR_FILE_TYPE_MISMATCH
sec
rts1: rts
:
@ -86,11 +86,11 @@ rts1: rts
sta LINUM+1
lda FIFILID ; File type
cmp #$04 ; TXT
beq text
cmp #$FC ; BAS
cmp #FT_TXT
beq Text
cmp #FT_BAS
bne :+
jmp basic
jmp Basic
:
;; fall through
@ -98,8 +98,8 @@ rts1: rts
;;; ============================================================
;;; Generic (Binary) file
.proc binary
jsr ReadByte
.proc Binary
repeat: jsr ReadByte
bcc :+
jmp Exit
: pha
@ -155,31 +155,31 @@ cloop: lda INBUF,x
bcc :+
inc LINUM+1
:
jmp binary
jmp Binary
.endproc
;;; ============================================================
;;; Text file
.proc text
jsr ReadByte
.proc Text
repeat: jsr ReadByte
bcs Exit
ora #$80
cmp #$8D ; CR?
beq :+
cmp #' '|$80 ; other control character?
bcc text ; yes, ignore
bcc repeat ; yes, ignore
: jsr COUT
jmp text
jmp repeat
.endproc
;;; ============================================================
;;; BASIC file
.proc basic
jsr CROUT
.proc Basic
repeat: jsr CROUT
jsr ReadByte ; first two bytes are pointer to next line
jsr ReadByte
bcs Exit ; EOF
@ -196,7 +196,7 @@ cloop: lda INBUF,x
;; Line contents: EOL, token, or character?
lloop: jsr ReadByte
beq basic ; EOL
beq repeat ; EOL
bmi token ; token
cout: ora #$80