mirror of
https://github.com/a2stuff/prodos-path.git
synced 2024-12-27 13:29:22 +00:00
BI Error constants; coding style
This commit is contained in:
parent
827d121ef2
commit
9971792f12
30
copy.cmd.s
30
copy.cmd.s
@ -58,15 +58,15 @@ execute:
|
|||||||
;; FN2. So REL,/ABS becomes /PFX/REL,/PFX//ABS (oops!) and
|
;; FN2. So REL,/ABS becomes /PFX/REL,/PFX//ABS (oops!) and
|
||||||
;; /ABS,REL remains /ABS,REL (still relative!).
|
;; /ABS,REL remains /ABS,REL (still relative!).
|
||||||
|
|
||||||
jsr get_prefix
|
jsr GetPrefix
|
||||||
bcs rts1
|
bcs rts1
|
||||||
|
|
||||||
lda VPATH1
|
lda VPATH1
|
||||||
ldx VPATH1+1
|
ldx VPATH1+1
|
||||||
jsr fix_path
|
jsr FixPath
|
||||||
lda VPATH2
|
lda VPATH2
|
||||||
ldx VPATH2+1
|
ldx VPATH2+1
|
||||||
jsr fix_path
|
jsr FixPath
|
||||||
|
|
||||||
;; Get FN1 info
|
;; Get FN1 info
|
||||||
lda #$A
|
lda #$A
|
||||||
@ -77,9 +77,9 @@ execute:
|
|||||||
|
|
||||||
;; Reject directory file
|
;; Reject directory file
|
||||||
lda FIFILID
|
lda FIFILID
|
||||||
cmp #$F ; DIR
|
cmp #FT_DIR
|
||||||
bne :+
|
bne :+
|
||||||
lda #$D ; FILE TYPE MISMATCH
|
lda #BI_ERR_FILE_TYPE_MISMATCH
|
||||||
sec
|
sec
|
||||||
rts1: rts
|
rts1: rts
|
||||||
:
|
:
|
||||||
@ -124,16 +124,16 @@ rts1: rts
|
|||||||
jsr GOSYSTEM
|
jsr GOSYSTEM
|
||||||
bcs :+
|
bcs :+
|
||||||
|
|
||||||
lda #$13 ; DUPLICATE FILE NAME
|
lda #BI_ERR_DUPLICATE_FILE_NAME
|
||||||
err: pha
|
err: pha
|
||||||
jsr close
|
jsr CloseFiles
|
||||||
pla
|
pla
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
|
|
||||||
: cmp #6 ; BI Errors 6 and 7 cover
|
: cmp #BI_ERR_PATH_NOT_FOUND
|
||||||
beq :+ ; vol dir, pathname, or filename
|
beq :+
|
||||||
cmp #7 ; not found.
|
cmp #BI_ERR_VOLUME_DIR_NOT_FOUND
|
||||||
bne err ; Otherwise - fail.
|
bne err ; Otherwise - fail.
|
||||||
:
|
:
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ read: lda FN1REF
|
|||||||
lda #READ
|
lda #READ
|
||||||
jsr GOSYSTEM
|
jsr GOSYSTEM
|
||||||
bcc :+
|
bcc :+
|
||||||
cmp #5 ; END OF DATA
|
cmp #BI_ERR_END_OF_DATA
|
||||||
beq finish
|
beq finish
|
||||||
:
|
:
|
||||||
|
|
||||||
@ -197,11 +197,11 @@ read: lda FN1REF
|
|||||||
jmp err
|
jmp err
|
||||||
|
|
||||||
|
|
||||||
finish: jsr close
|
finish: jsr CloseFiles
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.proc close
|
.proc CloseFiles
|
||||||
lda FN1REF
|
lda FN1REF
|
||||||
sta CFREFNUM
|
sta CFREFNUM
|
||||||
lda #CLOSE
|
lda #CLOSE
|
||||||
@ -215,7 +215,7 @@ finish: jsr close
|
|||||||
|
|
||||||
;;; Leave PREFIX at INBUF; infers it the same way as BI if empty.
|
;;; Leave PREFIX at INBUF; infers it the same way as BI if empty.
|
||||||
;;; Returns with Carry set on failure.
|
;;; Returns with Carry set on failure.
|
||||||
.proc get_prefix
|
.proc GetPrefix
|
||||||
;; Try fetching prefix
|
;; Try fetching prefix
|
||||||
MLI_CALL GET_PREFIX, get_prefix_params
|
MLI_CALL GET_PREFIX, get_prefix_params
|
||||||
lda INBUF
|
lda INBUF
|
||||||
@ -263,7 +263,7 @@ unit: .byte 0
|
|||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
;;; Fix path passed in A,X if it's relative. Uses prefix in INBUF
|
;;; Fix path passed in A,X if it's relative. Uses prefix in INBUF
|
||||||
.proc fix_path
|
.proc FixPath
|
||||||
ptr := $06
|
ptr := $06
|
||||||
ptr2 := $08
|
ptr2 := $08
|
||||||
|
|
||||||
|
16
date.cmd.s
16
date.cmd.s
@ -31,7 +31,9 @@ start:
|
|||||||
;;; TIME: |0 0 0| hour | |0 0| minute |
|
;;; TIME: |0 0 0| hour | |0 0| minute |
|
||||||
;;; +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
|
;;; +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
MLI_CALL GET_TIME, 0
|
lda #GET_TIME
|
||||||
|
jsr GOSYSTEM
|
||||||
|
|
||||||
lda DATELO
|
lda DATELO
|
||||||
ora DATEHI
|
ora DATEHI
|
||||||
beq not_set
|
beq not_set
|
||||||
@ -48,20 +50,20 @@ start:
|
|||||||
rol a
|
rol a
|
||||||
rol a
|
rol a
|
||||||
and #%00001111
|
and #%00001111
|
||||||
jsr cout_number
|
jsr PrintNumber
|
||||||
|
|
||||||
lda #'/'|$80 ; /
|
lda #'/'|$80 ; /
|
||||||
jsr COUT
|
jsr COUT
|
||||||
|
|
||||||
pla ; day
|
pla ; day
|
||||||
and #%00011111
|
and #%00011111
|
||||||
jsr cout_number
|
jsr PrintNumber
|
||||||
|
|
||||||
lda #'/'|$80 ; /
|
lda #'/'|$80 ; /
|
||||||
jsr COUT
|
jsr COUT
|
||||||
|
|
||||||
pla ; year
|
pla ; year
|
||||||
jsr cout_number
|
jsr PrintNumber
|
||||||
|
|
||||||
lda #' '|$80 ;
|
lda #' '|$80 ;
|
||||||
jsr COUT
|
jsr COUT
|
||||||
@ -71,14 +73,14 @@ start:
|
|||||||
|
|
||||||
lda TIMELO+1 ; hour
|
lda TIMELO+1 ; hour
|
||||||
and #%00011111
|
and #%00011111
|
||||||
jsr cout_number
|
jsr PrintNumber
|
||||||
|
|
||||||
lda #':'|$80 ; ':'
|
lda #':'|$80 ; ':'
|
||||||
jsr COUT
|
jsr COUT
|
||||||
|
|
||||||
lda TIMELO ; minute
|
lda TIMELO ; minute
|
||||||
and #%00111111
|
and #%00111111
|
||||||
jsr cout_number
|
jsr PrintNumber
|
||||||
|
|
||||||
finish: jsr CROUT
|
finish: jsr CROUT
|
||||||
|
|
||||||
@ -100,7 +102,7 @@ msg: .byte "<NO DATE>", 0
|
|||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; Print a 2-digit number, with leading zeros
|
;;; Print a 2-digit number, with leading zeros
|
||||||
|
|
||||||
.proc cout_number
|
.proc PrintNumber
|
||||||
;; Reduce to 2 digits
|
;; Reduce to 2 digits
|
||||||
: cmp #100
|
: cmp #100
|
||||||
bcc :+
|
bcc :+
|
||||||
|
12
echo.cmd.s
12
echo.cmd.s
@ -8,7 +8,7 @@
|
|||||||
ldx #0
|
ldx #0
|
||||||
|
|
||||||
;; Skip any leading spaces
|
;; Skip any leading spaces
|
||||||
jsr skip_spaces
|
jsr SkipSpaces
|
||||||
|
|
||||||
;; Invoked with "-" ?
|
;; Invoked with "-" ?
|
||||||
lda INBUF,x
|
lda INBUF,x
|
||||||
@ -17,7 +17,7 @@
|
|||||||
inx
|
inx
|
||||||
:
|
:
|
||||||
;; Skip any more leading spaces
|
;; Skip any more leading spaces
|
||||||
jsr skip_spaces
|
jsr SkipSpaces
|
||||||
|
|
||||||
;; Skip command name (i.e. "echo")
|
;; Skip command name (i.e. "echo")
|
||||||
txa
|
txa
|
||||||
@ -26,7 +26,7 @@
|
|||||||
tax
|
tax
|
||||||
|
|
||||||
;; Skip leading spaces before string to echo
|
;; Skip leading spaces before string to echo
|
||||||
jsr skip_spaces
|
jsr SkipSpaces
|
||||||
|
|
||||||
;; Echo string
|
;; Echo string
|
||||||
: lda INBUF,x
|
: lda INBUF,x
|
||||||
@ -39,13 +39,13 @@
|
|||||||
exit: clc
|
exit: clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.proc skip_spaces
|
.proc SkipSpaces
|
||||||
lda INBUF,x
|
repeat: lda INBUF,x
|
||||||
cmp #' '|$80
|
cmp #' '|$80
|
||||||
beq :+
|
beq :+
|
||||||
rts
|
rts
|
||||||
: inx
|
: inx
|
||||||
jmp skip_spaces
|
jmp repeat
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
cmd_length = .strlen("echo")
|
cmd_length = .strlen("echo")
|
26
path.s
26
path.s
@ -35,7 +35,7 @@ CASE_MASK = $DF
|
|||||||
lda #handler_pages
|
lda #handler_pages
|
||||||
jsr GETBUFR
|
jsr GETBUFR
|
||||||
bcc :+
|
bcc :+
|
||||||
lda #$C ; NO BUFFERS AVAILABLE
|
lda #BI_ERR_NO_BUFFERS_AVAILABLE
|
||||||
rts
|
rts
|
||||||
: sta new_page ; A = MSB of new page
|
: sta new_page ; A = MSB of new page
|
||||||
|
|
||||||
@ -145,12 +145,12 @@ page_delta:
|
|||||||
|
|
||||||
;; Check for this command, character by character.
|
;; Check for this command, character by character.
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
jsr skip_leading_spaces
|
jsr SkipLeadingSpaces
|
||||||
|
|
||||||
ldy #0 ; position in command string
|
ldy #0 ; position in command string
|
||||||
|
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
nxtchr: jsr to_upper_ascii
|
nxtchr: jsr ToUpperASCII
|
||||||
|
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
cmp command_string,y
|
cmp command_string,y
|
||||||
@ -193,9 +193,9 @@ check_if_token:
|
|||||||
beq not_ours
|
beq not_ours
|
||||||
|
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
jsr skip_leading_spaces
|
jsr SkipLeadingSpaces
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
jsr to_upper_ascii
|
jsr ToUpperASCII
|
||||||
|
|
||||||
cmp #'A'
|
cmp #'A'
|
||||||
bcc not_ours
|
bcc not_ours
|
||||||
@ -223,7 +223,7 @@ mloop: iny ; Advance through token table
|
|||||||
;; Check for match
|
;; Check for match
|
||||||
next_char:
|
next_char:
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
jsr to_upper_ascii ; Next character
|
jsr ToUpperASCII ; Next character
|
||||||
|
|
||||||
;; NOTE: Does not skip over spaces, unlike BASIC tokenizer
|
;; NOTE: Does not skip over spaces, unlike BASIC tokenizer
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ next_char:
|
|||||||
;; without preventing 'RUN100' from being typed.
|
;; without preventing 'RUN100' from being typed.
|
||||||
|
|
||||||
inx
|
inx
|
||||||
jsr to_upper_ascii
|
jsr ToUpperASCII
|
||||||
cmp #'A'
|
cmp #'A'
|
||||||
bcc not_ours
|
bcc not_ours
|
||||||
cmp #'Z'+1
|
cmp #'Z'+1
|
||||||
@ -247,7 +247,7 @@ next_char:
|
|||||||
;; Otherwise, advance to next token
|
;; Otherwise, advance to next token
|
||||||
next_token:
|
next_token:
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
jsr skip_leading_spaces
|
jsr SkipLeadingSpaces
|
||||||
sloop: lda (tptr),y ; Scan table looking for a high bit set
|
sloop: lda (tptr),y ; Scan table looking for a high bit set
|
||||||
iny
|
iny
|
||||||
bne :+
|
bne :+
|
||||||
@ -302,9 +302,9 @@ compose:
|
|||||||
|
|
||||||
;; Name from command line
|
;; Name from command line
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
jsr skip_leading_spaces
|
jsr SkipLeadingSpaces
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
: jsr to_upper_ascii
|
: jsr ToUpperASCII
|
||||||
cmp #'.'
|
cmp #'.'
|
||||||
beq ok
|
beq ok
|
||||||
cmp #'0'
|
cmp #'0'
|
||||||
@ -341,7 +341,7 @@ notok: dey
|
|||||||
|
|
||||||
;; Check to see if type is CMD.
|
;; Check to see if type is CMD.
|
||||||
lda FIFILID
|
lda FIFILID
|
||||||
cmp #$F0 ; CMD
|
cmp #FT_CMD
|
||||||
bne compose ; wrong type - try next path directory
|
bne compose ; wrong type - try next path directory
|
||||||
|
|
||||||
;; Tell BASIC.SYSTEM it was handled.
|
;; Tell BASIC.SYSTEM it was handled.
|
||||||
@ -454,7 +454,7 @@ set_path:
|
|||||||
;;; Returns INBUF,x with high bit stripped and up-cased
|
;;; Returns INBUF,x with high bit stripped and up-cased
|
||||||
;;; (also converts {|}~DEL to [\]^_ but that's okay)
|
;;; (also converts {|}~DEL to [\]^_ but that's okay)
|
||||||
|
|
||||||
.proc to_upper_ascii
|
.proc ToUpperASCII
|
||||||
lda INBUF,x
|
lda INBUF,x
|
||||||
and #$7F
|
and #$7F
|
||||||
cmp #'a'
|
cmp #'a'
|
||||||
@ -466,7 +466,7 @@ skip: rts
|
|||||||
;;; Returns with X pointing at first non-space in INBUF,
|
;;; Returns with X pointing at first non-space in INBUF,
|
||||||
;;; and that character loaded in A.
|
;;; and that character loaded in A.
|
||||||
|
|
||||||
.proc skip_leading_spaces
|
.proc SkipLeadingSpaces
|
||||||
ldx #$FF
|
ldx #$FF
|
||||||
: inx
|
: inx
|
||||||
lda INBUF,x
|
lda INBUF,x
|
||||||
|
14
prodos.inc
14
prodos.inc
@ -27,6 +27,11 @@ CLOSE = $CC
|
|||||||
.addr params
|
.addr params
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
FT_TXT = $04
|
||||||
|
FT_DIR = $0F
|
||||||
|
FT_CMD = $F0
|
||||||
|
FT_BAS = $FC
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; BASIC.SYSTEM Global Page
|
;;; BASIC.SYSTEM Global Page
|
||||||
|
|
||||||
@ -132,3 +137,12 @@ CCCSPARE := $BEDF
|
|||||||
GETBUFR := $BEF5
|
GETBUFR := $BEF5
|
||||||
FREEBUFR := $BEF8
|
FREEBUFR := $BEF8
|
||||||
RSHIMEM := $BEFB
|
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
|
||||||
|
32
type.cmd.s
32
type.cmd.s
@ -53,9 +53,9 @@ execute:
|
|||||||
|
|
||||||
;; Reject directory file
|
;; Reject directory file
|
||||||
lda FIFILID
|
lda FIFILID
|
||||||
cmp #$F ; DIR
|
cmp #FT_DIR
|
||||||
bne :+
|
bne :+
|
||||||
lda #$D ; FILE TYPE MISMATCH
|
lda #BI_ERR_FILE_TYPE_MISMATCH
|
||||||
sec
|
sec
|
||||||
rts1: rts
|
rts1: rts
|
||||||
:
|
:
|
||||||
@ -86,11 +86,11 @@ rts1: rts
|
|||||||
sta LINUM+1
|
sta LINUM+1
|
||||||
|
|
||||||
lda FIFILID ; File type
|
lda FIFILID ; File type
|
||||||
cmp #$04 ; TXT
|
cmp #FT_TXT
|
||||||
beq text
|
beq Text
|
||||||
cmp #$FC ; BAS
|
cmp #FT_BAS
|
||||||
bne :+
|
bne :+
|
||||||
jmp basic
|
jmp Basic
|
||||||
:
|
:
|
||||||
|
|
||||||
;; fall through
|
;; fall through
|
||||||
@ -98,8 +98,8 @@ rts1: rts
|
|||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; Generic (Binary) file
|
;;; Generic (Binary) file
|
||||||
|
|
||||||
.proc binary
|
.proc Binary
|
||||||
jsr ReadByte
|
repeat: jsr ReadByte
|
||||||
bcc :+
|
bcc :+
|
||||||
jmp Exit
|
jmp Exit
|
||||||
: pha
|
: pha
|
||||||
@ -155,31 +155,31 @@ cloop: lda INBUF,x
|
|||||||
bcc :+
|
bcc :+
|
||||||
inc LINUM+1
|
inc LINUM+1
|
||||||
:
|
:
|
||||||
jmp binary
|
jmp Binary
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; Text file
|
;;; Text file
|
||||||
|
|
||||||
.proc text
|
.proc Text
|
||||||
jsr ReadByte
|
repeat: jsr ReadByte
|
||||||
bcs Exit
|
bcs Exit
|
||||||
|
|
||||||
ora #$80
|
ora #$80
|
||||||
cmp #$8D ; CR?
|
cmp #$8D ; CR?
|
||||||
beq :+
|
beq :+
|
||||||
cmp #' '|$80 ; other control character?
|
cmp #' '|$80 ; other control character?
|
||||||
bcc text ; yes, ignore
|
bcc repeat ; yes, ignore
|
||||||
|
|
||||||
: jsr COUT
|
: jsr COUT
|
||||||
jmp text
|
jmp repeat
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; BASIC file
|
;;; BASIC file
|
||||||
|
|
||||||
.proc basic
|
.proc Basic
|
||||||
jsr CROUT
|
repeat: jsr CROUT
|
||||||
jsr ReadByte ; first two bytes are pointer to next line
|
jsr ReadByte ; first two bytes are pointer to next line
|
||||||
jsr ReadByte
|
jsr ReadByte
|
||||||
bcs Exit ; EOF
|
bcs Exit ; EOF
|
||||||
@ -196,7 +196,7 @@ cloop: lda INBUF,x
|
|||||||
|
|
||||||
;; Line contents: EOL, token, or character?
|
;; Line contents: EOL, token, or character?
|
||||||
lloop: jsr ReadByte
|
lloop: jsr ReadByte
|
||||||
beq basic ; EOL
|
beq repeat ; EOL
|
||||||
bmi token ; token
|
bmi token ; token
|
||||||
|
|
||||||
cout: ora #$80
|
cout: ora #$80
|
||||||
|
Loading…
Reference in New Issue
Block a user