Add CHTYPE and CHTIME

This commit is contained in:
Joshua Bell 2021-03-07 15:29:51 -08:00
parent 9c07b36b09
commit f1caa15b0c
12 changed files with 339 additions and 32 deletions

View File

@ -1,5 +1,5 @@
sudo: enabled sudo: enabled
os: osx os: linux
language: c language: c
install: install:

View File

@ -5,6 +5,7 @@ LDFLAGS = --config apple2-asm.cfg
OUTDIR = out OUTDIR = out
TARGETS = $(OUTDIR)/path.BIN \ TARGETS = $(OUTDIR)/path.BIN \
$(OUTDIR)/chtype.CMD $(OUTDIR)/chtime.CMD \
$(OUTDIR)/bell.CMD $(OUTDIR)/hello.CMD $(OUTDIR)/echo.CMD $(OUTDIR)/online.CMD $(OUTDIR)/bell.CMD $(OUTDIR)/hello.CMD $(OUTDIR)/echo.CMD $(OUTDIR)/online.CMD
.PHONY: clean all package .PHONY: clean all package

View File

@ -21,6 +21,7 @@ Once set, binary files of type `CMD` in the specified directories can be invoked
* CMD file is loaded at $4000 and invoked; should return (`rts`) on completion. * CMD file is loaded at $4000 and invoked; should return (`rts`) on completion.
* The command line will be present at $200 (`GETLN` input buffer). * The command line will be present at $200 (`GETLN` input buffer).
* Supports multi-segment, colon-separated paths, e.g. `/hd/cmds:/hd2/more.cmds` * Supports multi-segment, colon-separated paths, e.g. `/hd/cmds:/hd2/more.cmds`
* Commands can use the BI parser for arguments. See `chtype.cmd.s` for an example.
Example: Example:
``` ```
@ -48,3 +49,10 @@ Sample commands included:
* `BELL` - beeps the speaker * `BELL` - beeps the speaker
* `HELLO` - shows a short message * `HELLO` - shows a short message
* `ONLINE` - lists online volumes (volume name, slot and drive) * `ONLINE` - lists online volumes (volume name, slot and drive)
* `ECHO` - echoes back anything following the command
* `CHTYPE` - change the type/auxtype of a file. e.g. `chtype file,T$F1,A$1234`
* `T` (type) and `A` (auxtype) are optional. If neither is specified, current types are shown.
* `S` and `D` arguments can be used to specify slot and drive.
* `CHTIME` - change the modification date/time of a file. e.g. `chtime file,A$1234,B$5678`
* `A` (date) and `B` (time) are optional. If neither is specified, current values are shown.
* `S` and `D` arguments can be used to specify slot and drive.

View File

@ -1,9 +1,10 @@
.include "apple2.inc" .include "apple2.inc"
.include "more_apple2.inc"
BELL := $FF3A
.org $4000 .org $4000
jsr BELL jsr BELL
clc
rts rts

142
chtime.cmd.s Normal file
View File

@ -0,0 +1,142 @@
;;; ============================================================
;;;
;;; CHTIME - File modification time changing command for ProDOS-8
;;;
;;; Usage: CHTIME filename[,Adate][,Btime][,S#][,D#]
;;;
;;; * filename can be relative or absolute path
;;; * specify A$nnnn to set file date
;;; * specify B$nnnn to set file time
;;; * with neither A nor B option, prints current values
;;;
;;; ============================================================
.include "apple2.inc"
.include "more_apple2.inc"
.include "prodos.inc"
;;; ============================================================
.org $4000
;; NOTE: Assumes XLEN is set by PATH
;; Point BI's parser at the command execution routine.
lda #<execute
sta XTRNADDR
page_num2 := *+1 ; address needing updating
lda #>execute
sta XTRNADDR+1
;; Mark command as external (zero).
lda #0
sta XCNUM
;; Set accepted parameter flags
lda #PBitsFlags::FN1 ; Filename
sta PBITS
;; Address, Byte, Slot & Drive handling
lda #PBitsFlags::AD | PBitsFlags::B | PBitsFlags::SD
sta PBITS+1
clc ; Success (so far)
rts ; Return to BASIC.SYSTEM
;;; ============================================================
not_ours:
sec ; Signal failure...
next_command := *+1
jmp $ffff ; Execute next command in chain
;;; ============================================================
execute:
;; Verify required arguments
lda FBITS
and #PBitsFlags::FN1 ; Filename?
bne :+
lda #$10 ; SYNTAX ERROR
sec
rts1: rts
:
;;; --------------------------------------------------
;; Get the existing file info
lda #$A
sta SSGINFO
lda #GET_FILE_INFO
jsr GOSYSTEM
bcs rts1
;;; --------------------------------------------------
;; Apply options
ldy #0 ; count number of options
;; Apply optional Address argument as new date
lda FBITS+1
and #PBitsFlags::AD ; Address set?
beq :+
iny
lda VADDR
sta FIMDATE
lda VADDR+1
sta FIMDATE+1
:
;; Apply optional Byte argument as new time
lda FBITS+1
and #PBitsFlags::B ; Type set?
beq :+
iny
lda VBYTE
sta FIMDATE+2
lda VBYTE+1
sta FIMDATE+3
:
;; If no options were used, show current details instead.
cpy #0
beq show
;; Set new file info
lda #$7
sta SSGINFO
lda #SET_FILE_INFO
jmp GOSYSTEM
;;; --------------------------------------------------
show:
lda #'A'|$80
jsr COUT
lda #'='|$80
jsr COUT
lda #'$'|$80
jsr COUT
lda FIMDATE+1
jsr PRBYTE
lda FIMDATE
jsr PRBYTE
jsr CROUT
lda #'B'|$80
jsr COUT
lda #'='|$80
jsr COUT
lda #'$'|$80
jsr COUT
lda FIMDATE+3
jsr PRBYTE
lda FIMDATE+2
jsr PRBYTE
jsr CROUT
clc
rts

138
chtype.cmd.s Normal file
View File

@ -0,0 +1,138 @@
;;; ============================================================
;;;
;;; CHTYPE - File type changing command for ProDOS-8
;;;
;;; Usage: CHTYPE filename[,Ttype][,Aaux][,S#][,D#]
;;;
;;; * filename can be relative or absolute path
;;; * specify T$nn to set file type
;;; * specify A$nnnn to set aux type info
;;; * type can be BIN, SYS, TXT (etc) or $nn
;;; * with neither T nor A option, prints current values
;;;
;;; ============================================================
.include "apple2.inc"
.include "more_apple2.inc"
.include "prodos.inc"
;;; ============================================================
.org $4000
;; NOTE: Assumes XLEN is set by PATH
;; Point BI's parser at the command execution routine.
lda #<execute
sta XTRNADDR
page_num2 := *+1 ; address needing updating
lda #>execute
sta XTRNADDR+1
;; Mark command as external (zero).
lda #0
sta XCNUM
;; Set accepted parameter flags (Name, Type, Address)
lda #PBitsFlags::T | PBitsFlags::FN1 ; Filename and Type
sta PBITS
lda #PBitsFlags::AD | PBitsFlags::SD ; Address, Slot & Drive handling
sta PBITS+1
clc ; Success (so far)
rts ; Return to BASIC.SYSTEM
;;; ============================================================
execute:
;; Verify required arguments
lda FBITS
and #PBitsFlags::FN1 ; Filename?
bne :+
lda #$10 ; SYNTAX ERROR
sec
rts1: rts
:
;;; --------------------------------------------------
;; Get the existing file info
lda #$A
sta SSGINFO
lda #GET_FILE_INFO
jsr GOSYSTEM
bcs rts1
;;; --------------------------------------------------
;; Apply options
ldy #0 ; count number of options
;; Apply optional Type argument as new file type
lda FBITS
and #PBitsFlags::T ; Type set?
beq :+
iny
lda VTYPE
sta FIFILID
:
;; Apply optional Address argument as new aux type
lda FBITS+1
and #PBitsFlags::AD ; Address set?
beq :+
iny
lda VADDR
sta FIAUXID
lda VADDR+1
sta FIAUXID+1
:
;; If no options were used, show current details instead.
cpy #0
beq show
;; Apply current date/time
ldx #3
: lda DATE,x
sta FIMDATE,x
dex
bpl :-
;; Set new file info
lda #$7
sta SSGINFO
lda #SET_FILE_INFO
jmp GOSYSTEM
;;; --------------------------------------------------
show:
lda #'T'|$80
jsr COUT
lda #'='|$80
jsr COUT
lda #'$'|$80
jsr COUT
lda FIFILID
jsr PRBYTE
jsr CROUT
lda #'A'|$80
jsr COUT
lda #'='|$80
jsr COUT
lda #'$'|$80
jsr COUT
lda FIAUXID+1
jsr PRBYTE
lda FIAUXID
jsr PRBYTE
jsr CROUT
clc
rts

View File

@ -1,9 +1,6 @@
.include "apple2.inc" .include "apple2.inc"
.include "more_apple2.inc"
CROUT := $FD8E
COUT := $FDED
INBUF := $200
.org $4000 .org $4000
@ -39,7 +36,8 @@ INBUF := $200
inx inx
jmp :- jmp :-
exit: rts exit: clc
rts
.proc skip_spaces .proc skip_spaces
lda INBUF,x lda INBUF,x

View File

@ -1,8 +1,6 @@
.include "apple2.inc" .include "apple2.inc"
.include "more_apple2.inc"
CROUT := $FD8E
COUT := $FDED
.org $4000 .org $4000
@ -16,6 +14,8 @@ COUT := $FDED
jmp :- jmp :-
done: jsr CROUT done: jsr CROUT
clc
rts rts
str: .byte "Hello, world!", 0 str: .byte "Hello, world!", 0

23
more_apple2.inc Normal file
View File

@ -0,0 +1,23 @@
;;; ============================================================
;;; Memory locations
INBUF := $200
;;; ============================================================
;;; Monitor ROM routines
CROUT := $FD8E
PRBYTE := $FDDA
COUT := $FDED
MOVE := $FE2C ; call with Y=0
MOVE_SRC := $3C
MOVE_END := $3E
MOVE_DST := $42
BELL := $FF3A
;;; ============================================================
;;; Applesoft ROM locations
TOKEN_NAME_TABLE := $D0D0

View File

@ -1,10 +1,8 @@
.include "apple2.inc" .include "apple2.inc"
.include "more_apple2.inc"
.include "prodos.inc" .include "prodos.inc"
CROUT := $FD8E ; Issue a carriage return.
COUT := $FDED ; Output a character.
.org $4000 .org $4000
;;; ============================================================ ;;; ============================================================
@ -83,7 +81,8 @@ next: dec count
sta ptr+1 sta ptr+1
jmp loop jmp loop
exit: rts exit: clc
rts
;;; ============================================================ ;;; ============================================================

23
path.s
View File

@ -9,6 +9,7 @@
.org $2000 .org $2000
.include "apple2.inc" .include "apple2.inc"
.include "more_apple2.inc"
.include "prodos.inc" .include "prodos.inc"
;;; ============================================================ ;;; ============================================================
@ -16,21 +17,6 @@
cmd_load_addr := $4000 cmd_load_addr := $4000
max_cmd_size = $2000 max_cmd_size = $2000
;;; ============================================================
;;; Monitor ROM routines/locations
INBUF := $200 ; GETLN input buffer
CROUT := $FD8E
COUT := $FDED
MOVE := $FE2C ; call with Y=0
MOVE_SRC := $3C
MOVE_END := $3E
MOVE_DST := $42
TOKEN_NAME_TABLE := $D0D0
CASE_MASK = $DF CASE_MASK = $DF
;;; ============================================================ ;;; ============================================================
@ -342,6 +328,10 @@ notok: dey
ldy #0 ldy #0
sta (ptr),y sta (ptr),y
;; Indicate end of command string for BI's parser (if command uses it)
dex
stx XLEN
;; Check to see if path exists. ;; Check to see if path exists.
lda #$A ; param length lda #$A ; param length
sta SSGINFO sta SSGINFO
@ -363,7 +353,7 @@ notok: dey
lda #>XRETURN lda #>XRETURN
sta XTRNADDR+1 sta XTRNADDR+1
;; MLI/BI trashes part of INBUF, so stash it in upper half. ;; MLI/BI trashes part of INBUF (clock driver?), so stash it in upper half.
ldx #$7F ldx #$7F
: lda INBUF,x : lda INBUF,x
sta INBUF+$80,x sta INBUF+$80,x
@ -411,7 +401,6 @@ notok: dey
;; Invoke command ;; Invoke command
jsr cmd_load_addr jsr cmd_load_addr
clc ; success
rts ; Return to BASIC.SYSTEM rts ; Return to BASIC.SYSTEM
fail_load: fail_load:

View File

@ -2,7 +2,9 @@
;;; ProDOS MLI / Global Page ;;; ProDOS MLI / Global Page
MLI := $BF00 MLI := $BF00
DATE := $BF90
SET_FILE_INFO = $C3
GET_FILE_INFO = $C4 GET_FILE_INFO = $C4
ON_LINE = $C5 ON_LINE = $C5
OPEN = $C8 OPEN = $C8
@ -55,6 +57,10 @@ FBITS := $BE56 ; Found parameter bits
;; paths must be used if no prefix is set. ;; paths must be used if no prefix is set.
.endenum .endenum
VADDR := $BE58 ; Address parameter
VBYTE := $BE5A ; Byte parameter
VSLOT := $BE61 ; Slot parameter
VTYPE := $BE6A ; Type parameter
VPATH1 := $BE6C ; Pathname buffer VPATH1 := $BE6C ; Pathname buffer
GOSYSTEM := $BE70 ; Use instead of MLI GOSYSTEM := $BE70 ; Use instead of MLI
@ -63,6 +69,8 @@ XRETURN := $BE9E ; Handy RTS
SSGINFO := $BEB4 ; GET_FILE_INFO Parameter block SSGINFO := $BEB4 ; GET_FILE_INFO Parameter block
FIFILID := $BEB8 ; (set size $A) FIFILID := $BEB8 ; (set size $A)
FIAUXID := $BEB9
FIMDATE := $BEBE
SOPEN := $BECB ; OPEN SOPEN := $BECB ; OPEN
OSYSBUF := $BECE OSYSBUF := $BECE