-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharctrl.s
324 lines (259 loc) · 4.08 KB
/
charctrl.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
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
lst off
rel
xc
xc
mx %00
use E16.Control
* lst on
tbx on
ldax mac
if #=]1
lda ]1
ldx ^]1
else
lda ]1
ldx ]1+2
fin
eom
stax mac
sta ]1
stx ]1+2
eom
res = 0
dum 1
ptr ds 4
rtlb ds 4
handle ds 4
param ds 4
code ds 2
rv ds 4
locals = 4
params = 4+4+2
dend
char_control ent
* Inputs: On entry, the parameters are passed to us on the stack.
*
* | | Previous Contents
* |-------------------|
* | ReturnValue | LONG - Space for return value
* |-------------------|
* | CtlCode | WORD - operation to perform
* |-------------------|
* | CtlParam | LONG - add'l parameter
* |-------------------|
* | theCtlHandle | LONG - Handle to control record
* |-------------------|
* | RtnAddr | 3 BYTES - RTL address
* |-------------------|
* | | <-- Stack pointer
*
* Outputs: Put something into ReturnValue, pull off the parameters,
* and return to the Control Manager.
*
* | | Previous Contents
* |-------------------|
* | ReturnValue | LONG - Space for return value
* |-------------------|
* | RtnAddr | 3 BYTES - RTL address
* |-------------------|
* | | <-- Stack pointer
do res
pha
pha
psl #char_control
_FindHandle
_HLock
fin
phb
phk
plb
tsc
do locals
sec
sbc #locals
tcs
fin
phd
tcd
stz rv
stz rv+2
stz ptr
stz ptr+2
lda code
cmp #:table_size+1
bcs :exit
:deref
asl
tax
lda :table,x
beq :exit
cpx #recSize*2
beq :exec
ldy #2
lda [handle]
sta ptr
lda [handle],y
sta ptr+2
ldy #control_size-2
:loop lda [ptr],y
sta control,y
dey
dey
bpl :loop
:exec
jsr (:table,x)
stax rv
:exit
do res
pha
pha
psl #char_control
_FindHandle
_HUnlock
fin
lda rtlb
sta rv-4
lda rtlb+2
sta rv-2
pld
tsc
clc
adc #params+locals
tcs
plb
rtl
:rts
lda #0
ldx #0
rts
:table
dw do_draw ; drawCtl
dw 0 ; calcCRect
dw 0 ; testCtl
dw do_init ; initCtl
dw 0 ; dispCtl
dw 0 ; posCtl
dw 0 ; thumbCtl
dw 0 ; dragCtl
dw 0 ; autoTrack
dw do_draw ; newValue
dw 0 ; setParams
dw 0 ; moveCtl
dw do_recsize ; recSize
dw 0 ; ctlHandleEvent
dw 0 ; ctlChangeTarget
dw 0 ; ctlChangeBounds
dw 0 ; ctlWindChangeSize
dw 0 ; ctlHandleTab
dw 0 ; ctlNotifyMultiPart
dw 0 ; ctlWinStateChange
:table_size = {*-:table}/2
control
ds 4 ; next control
ds 4 ; window
ds 8 ; rect
ds 1 ; flags
ds 1 ; hilite
ds 2 ; value
ds 4 ; proc
ds 4 ; action
ds 4 ; data
ds 4 ; refcon
ds 4 ; colors
ds 16 ; reserved
ds 4 ; id
ds 2 ; more flags
ds 2 ; version
control_size equ *-control
do_recsize
ldax #control_size
rts
do_init
lda #0
ldy #octlValue
sta [ptr],y
ldy #octlData
sta [ptr],y
iny
iny
sta [ptr],y
ldax #0
rts
do_draw
dum 0
y1 ds 2
x1 ds 2
y2 ds 2
x2 ds 2
dend
* brk $ea
* check if we need to draw
lda control+oCtlFlag
bit ctlInVis
beq :visi
]rts ldax #0
rts
:visi
* need to set the background pattern / foreground pattern?
pha
pha
_GetPort
pha
_GetFontFlags
pha
_GetTextMode
psl control+octlOwner
_SetPort
_PenNormal
psw #4
_SetFontFlags
psw #$4444 ; red
_SetForeColor
psw #$ffff
_SetBackColor
psw #0
_SetTextMode
* erase the rect
* psw #4
* _SetSolidBackPat
psl #control+octlRect
_EraseRect
lda control+octlValue
and #$00ff
beq :rts
cmp #' '+1
bcc :rts
* find the center of the rectangle. should have left/right/center options.
pea #0
pha
_CharWidth
pla
sta :w
cmp #0
beq :rts
lda control+octlRect+x2
sec
sbc control+octlRect+x1
* sta :rw
sbc :w
lsr ; /= 2
clc
adc control+octlRect+x1
pha ; x
lda control+octlRect+y2
sec
sbc #4
pha ; y
_MoveTo
psw control+octlValue
_DrawChar
:rts
_SetTextMode
_SetFontFlags
_SetPort
ldax #0
rts
:w ds 2
*:rw ds 2
sav charctrl.l
sym