-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchtype.cmd.s
127 lines (103 loc) · 3.04 KB
/
chtype.cmd.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
;;; ============================================================
;;;
;;; 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
lda #>execute
sta XTRNADDR+1
;; Mark command as external (zero).
lda #0
sta XCNUM
;; Set accepted parameter flags
;; Filename and Type
lda #PBitsFlags::T | PBitsFlags::FN1
sta PBITS
;; Address (used as AuxType), Slot & Drive handling
lda #PBitsFlags::AD | PBitsFlags::SD
sta PBITS+1
clc ; Success (so far)
rts1: rts ; Return to BASIC.SYSTEM
;;; ============================================================
execute:
;; 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