-
Notifications
You must be signed in to change notification settings - Fork 0
/
afp.userprefix.s
177 lines (173 loc) · 6.31 KB
/
afp.userprefix.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
; %help
; afp.userprefix - Display or set the AFP user prefix.
;
; options: -s <path> Set to <path>, normally only if not already set.
; -f Force setting even if it is already set.
; -c Set current prefix to user prefix.
;
; Note that setting the user prefix uses undocumented features of the
; AppleTalk stack.
; %hend
.pc02
.include "davex-mg.inc"
sptr = xczpage
setflag = sptr+2
pfxbuf = filebuff2
DX_start dx_mg_auto_origin ; load address
DX_info $01,$12,dx_cc_iie_or_iigs,$00
DX_ptab
DX_parm 's',t_path ; path to set
DX_parm 'f',t_nil ; force setting
DX_parm 'c',t_nil ; set prefix
DX_end_ptab
DX_desc "Display or set AFP User Prefix."
DX_main
cli ; appletalk requires interrupts
ATcall inforeq
bcc :+
jmp noatalk
: stz setflag
lda #'s'|$80
jsr xgetparm_ch
bcs :+ ; set not requested
inc setflag
: lda #'f'|$80
jsr xgetparm_ch
bcs getit ; not being forced to set
lda setflag
beq :+ ; user said -f without -s, go to error
jmp setpfx ; -s and -f, set prefix
: lda #$01
jsr xredirect
jsr xmess
asc_hi "-f without -s!"
.byte $00
bra exiterr
getit: stz dirflag ; make sure we are getting, not setting
ATcall pfxreq ; get user prefix
bcc :+ ; if no error
lda setflag ; error, see if we should try setting it?
beq pfxerr ; nope, error out
bra tryset ; otherwise, try setting
: lda #<pfxbuf ; set sptr to prefix buffer
sta sptr
lda #>pfxbuf
sta sptr+1
ldy #$00 ; index of length byte
lda (sptr),y ; check length
beq :+ ; no prefix, see if we should set it
stz setflag ; have a prefix already, so flag don't set
jsr prpas ; and print
: lda setflag ; user wants prefix set?
beq :+ ; no, so skip doing it
tryset: jmp setpfx ; go to the set routine
: lda #'c'|$80
jsr xgetparm_ch ; change to wanted?
bcs :+ ; nope, skip to the end
P8call $c6,p8pfxreq ; enact the change
bcc :+ ; all good, skip error
jmp xProDOS_err ; if something went pear-shaped
: rts ; buhbye
pfxerr: lda #$01
jsr xredirect
jsr xmess
asc_hi "Get/set user prefix error!"
.byte $00
bra exiterr
noatalk: lda #$01
jsr xredirect
jsr xmess
asc_hi "AppleTalk offline!"
.byte $00
exiterr: lda #$ff
jsr xredirect
jmp xerr
;
setpfx: lda #'s'|$80 ; get the pointer to option
jsr xgetparm_ch
bcs badpath ; shouldn't happen here!!!
sty sptr ; set sptr to check length
sty parm1 ; and parm1 for copy
sta sptr+1
sta parm1+1
lda (sptr),y ; check length
beq badpath ; and if zero, it must be bad
jsr xpmgr ; copy from user option to pfxbuf
.byte pm_copy ; davex function
parm1: .addr pfxbuf ; source, initially something not entirely insane
.addr pfxbuf ; destination
P8call $c4,fileinfo ; P8 GET_FILE_INFO
bcc :+ ; no error, continue
jmp xProDOS_err ; something went pear-shaped
: lda fitype ; get file type
cmp #$0f ; is directory?
bne badpath ; nope... error out
lda #$aa ; undocumented, found in LOGON program
sta dirflag
ATcall pfxreq ; set user prefix
bcc :+ ; all good, skip error
jmp pfxerr ; sigh... error out
: stz setflag ; avoid infinite loop
jmp getit ; wind back to get/print/maybe change dir
badpath: lda #$01
jsr xredirect
jsr xmess
asc_hi "Bad new prefix!"
.byte $00
bra exiterr
; increment sptr by a
.proc addsptr
clc
adc sptr
sta sptr
bcc :+
inc sptr+1
: rts
.endproc
; print pascal string at sptr
; leave sptr pointed at one past end
; of string
.proc prpas
ldy #$00
lda (sptr),y ; get length
tax
next: lda #$01
jsr addsptr
dex
bpl :+
rts
: lda (sptr),y ; get char
ora #$80 ; make printable
jsr cout
bra next
.endproc
;
inforeq: .byte 0,2 ; sync GetInfo
.word $0000 ; result code
.dword $00000000 ; completion address
thisnet: .word $0000 ; this network #
abridge: .byte $00 ; local bridge
hwid: .byte $00 ; hardware ID, IIgs only
romver: .word $00 ; ROM version, IIgs only
nodenum: .byte $00 ; node number
;
pfxreq: .byte 0,$2a ; sync FIUserPrefix
.word $0000 ; result
dirflag: .byte $00 ; direction flag (bit 7)
.dword pfxbuf ; buffer (at least 64 bytes)
;
p8pfxreq: .byte $01
.addr pfxbuf
;
fileinfo: .byte $0a
.addr pfxbuf ; buffer
.byte $00 ; access
fitype: .byte $00 ; want to see $0f
.word $0000 ; aux type
.byte $00 ; storage type
.word $0000 ; blocks used
.word $0000 ; mod date
.word $0000 ; mod time
.word $0000 ; create date
.word $0000 ; create time
DX_end