-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhexterm.aii
More file actions
214 lines (177 loc) · 3.41 KB
/
hexterm.aii
File metadata and controls
214 lines (177 loc) · 3.41 KB
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
*******************************************************
***
*** Hex Output Terminal Tool
*** Copyright (C) 1992 Morgan Davis
*** MPW IIGS Assembler
***
MACHINE M65C02
longa off
longi off
case on
INCLUDE 'OMM.equ'
INCLUDE 'PortTool.equ'
a1 equ $3c
prmtbl equ $e0
chrget equ $b1
chrgot equ $b7
ch80 equ $057b
kbd equ $c000
strb equ $c010
cmdkey equ $c061
chkcom equ $debe
getbyte equ $e6f8
bs equ $fc10
up equ $fc1a
lf equ $fc66
prbyte equ $fdda
cout equ $fded
crout equ $fd8e
term PROC
hVERS DC.W $0000
hID DC.W 'tm'
hSIZE DC.W END-START
hORG DC.W START
hAMPC DC.W amperc
hKIND DC.W $0000
hRSRV1 DC.W $0000
hRSRV2 DC.W $0000
START cmp #MSG_AMPR ;ampersand call?
beq doampr ;yes
cmp #MSG_DIED ;module death?
beq dodeath
cmp #MSG_BORN ;module birth?
beq dobirth
cmp #MSG_INFO ;get info string?
bne ctrts
doinfo lda a_info
sta a1
lda a_info+1
sta a1+1
ctrts rts
callpt ldx ptindex ;function in Y
beq ctrts ;oops no tool!
jmp OMMVEC ;call the Port Tool
dobirth
dodeath
lda #<PT_ID ;get port tool index
sta a1
lda #>PT_ID
sta a1+1
jsr ommid
stx ptindex ;save it
rts
ommid ldx #OMM_ID
ldy #OMM_GETID
jmp OMMVEC
*------------------------------*
* Ampersand Command Dispatcher *
*------------------------------*
doampr jsr nextarg ;eat up all the arguments
bne doampr ;
jsr crout ; print cr
*------------------------------*
* Terminal Mode Loop *
*------------------------------*
termread
jsr updateTerm ;update display
ldy #SerGetDCD ;check DCD
jsr callpt
bcc tmnocar ;none, so quit
keyread
lda kbd ;check keyboard
bpl termread
bit cmdkey ;check Command key
sta strb ;clear keyboard
bmi tmq ;got a command
and #$7F ;send key to port
sta prmtbl
ldy #SerWriteChar
jsr callpt
bra termread ;loop back for more
*------------------------------*
* Exit Terminal Mode *
*------------------------------*
tmnocar lda #0
tmq sta result ;save exit code
jsr chrgot ;return it?
beq elret ;no
lda result
sta a1
stz a1+1
ldy #OMM_PUTWORD
ldx #OMM_ID
jmp OMMVEC ;return result code
*------------------------------*
* Update Display *
*------------------------------*
updateTerm
ldy #SerReadChar ;serial input?
jsr callpt
bcs termout ;yes
elret rts
termout pha
ora #$80 ;make it printable
cmp #$A0 ;check for control
bcs tocout
and #$7F ;invert controls
ora #$40
tocout jsr cout ;print character
jsr bs ;back up
jsr lf ;go down
pla ;get real byte
jsr prbyte ;print it in hex
lda ch80 ;check for wrap
beq elret
jmp up ;no wrap, so go up
; get the amersand command argument.
; TERM [ (number1)] [,number2]
; number1 = full(0) or half(1) duplex echo
; number2 = exit code
nextarg
jsr chrgot
beq @eol1
cmp #'('
beq @lparen
cmp #')'
beq @rparen
cmp #','
bne @skip
@lparen
jsr chrget
@skip
jsr getbyte
txa
beq @zero
ldx #-1
@zero
lda #1
@eol1
rts
; ')' must be followed by , or eol.
; in either case, return 0 to stop parsing.
@rparen
jsr chrget
jsr chrgot ; redundant!
beq @eol2
jsr chkcom ; syntax error if not comma
lda #0
@eol2
rts
*------------------------------*
* Data Section *
*------------------------------*
dc.b $00 ;start of immed
table
a_info dc.w info
dc.w $0000 ;start of data
amperc dc.b 'TERM',0 ;&TERM invokes this
dc.b -1
msb on
info dc.b '20-May-94 HexTerm 3.1'
dc.b $00 ; cstring
msb off
ptindex ds.b 1 ;index to Port Tool
result ds.b 1 ;exit code
END
ENDP
END