Subversion Repositories Kolibri OS

Rev

Rev 5034 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5034 Rev 5041
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;  FT232 SyncBB mode demonstration for KolibriOS               ;;
6
;;  FT232 SyncBB mode demonstration for KolibriOS               ;;
7
;;                                                              ;;
7
;;                                                              ;;
8
;;   Written by gtament@gmail.com                               ;;
8
;;   Written by gtament@gmail.com                               ;;
9
;;                                                              ;;
9
;;                                                              ;;
10
;;         GNU GENERAL PUBLIC LICENSE                           ;;
10
;;         GNU GENERAL PUBLIC LICENSE                           ;;
11
;;          Version 2, June 1991                                ;;
11
;;          Version 2, June 1991                                ;;
12
;;                                                              ;;
12
;;                                                              ;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
 
14
 
15
format binary as ""
15
format binary as ""
16
use32
16
use32
17
org 0x0
17
org 0x0
18
 
18
 
19
; The header
19
; The header
20
 
20
 
21
db 'MENUET01'
21
db 'MENUET01'
22
dd 0x01
22
dd 0x01
23
dd INIT
23
dd INIT
24
dd I_END
24
dd I_END
25
dd 0x100000
25
dd 0x100000
26
dd 0x7fff0
26
dd 0x7fff0
27
dd 0, 0
27
dd 0, 0
28
 
28
 
29
; The code area
29
; The code area
30
 
30
 
31
include '../../macros.inc'
31
include '../../macros.inc'
32
include '../../debug.inc'
32
include '../../debug.inc'
33
 
33
 
34
struct IOCTL
34
struct IOCTL
35
handle			dd	?
35
handle			dd	?
36
io_code 		dd	?
36
io_code 		dd	?
37
input			dd	?
37
input			dd	?
38
inp_size		dd	?
38
inp_size		dd	?
39
output			dd	?
39
output			dd	?
40
out_size		dd	?
40
out_size		dd	?
41
ends
41
ends
42
 
42
 
43
BUTTONXSIZE = 60
43
BUTTONXSIZE = 60
44
BUTTONYSIZE = 60
44
BUTTONYSIZE = 60
45
BUTTONXSTART= 20
45
BUTTONXSTART= 20
46
BUTTONYSTART= 50
46
BUTTONYSTART= 55
47
BUTTONXSPACE= 10
47
BUTTONXSPACE= 10
48
BUTTONCOUNT = 8
48
BUTTONCOUNT = 8
49
ONCOLOR     = 0x0018c015
49
ONCOLOR     = 0x0018c015
50
OFFCOLOR    = 0x00db2521
50
OFFCOLOR    = 0x00db2521
-
 
51
 
-
 
52
;Flags
-
 
53
PIN_CONF_FLAG = 0
51
 
54
 
52
INIT:
55
INIT:
53
	mov	    [btn_state], 0xFF
56
	mov	    [btn_state], 0xFF
54
	mov	    [btn_io], 0xFF
57
	mov	    [btn_io], 0xFF
55
 
58
 
56
	mcall	68, 11
59
	mcall	68, 11
57
	call	draw_window
60
	call	draw_window
58
	mov	    edi, drv_name
61
	mov	    edi, drv_name
59
	mcall	68, 16, edi
62
	mcall	68, 16, edi
60
    cmp     eax, 0
63
    cmp     eax, 0
61
    jnz     @f
64
    jnz     @f
62
    debug_print 'Error while loading driver\n'
65
    debug_print 'Error while loading driver\n'
63
  @@:
66
  @@:
64
    mov     [IOCTLs+IOCTL.handle], eax
67
    mov     [IOCTLs+IOCTL.handle], eax
65
    mov     eax, 8
68
    mov     eax, 8
66
    mov     [IOCTLs+IOCTL.inp_size], eax
69
    mov     [IOCTLs+IOCTL.inp_size], eax
67
    mov     [IOCTLs+IOCTL.out_size], eax
70
    mov     [IOCTLs+IOCTL.out_size], eax
68
    mov 	eax, out_buf
71
    mov 	eax, out_buf
69
    mov 	[IOCTLs+IOCTL.output], eax
72
    mov 	[IOCTLs+IOCTL.output], eax
70
    mov 	eax, in_buf
73
    mov 	eax, in_buf
71
    mov 	[IOCTLs+IOCTL.input], eax
74
    mov 	[IOCTLs+IOCTL.input], eax
72
 
75
 
73
    call    drivercomm.getlist
76
    call    drivercomm.getlist
-
 
77
    test    eax, eax
-
 
78
    jnz     @f
-
 
79
    mcall   4, 5 shl 16 + 25, 1 shl 31 + 0xFF shl 16, noftdi_msg
-
 
80
  @@:
74
    call    drivercomm.getlock
81
    call    drivercomm.getlock
-
 
82
    mov     eax, [pid]
-
 
83
    cmp     eax, [out_buf]
-
 
84
    jz	    @f
-
 
85
    mcall   4, 5 shl 16 + 25, 1 shl 31 + 0xFF shl 16, devlkd_msg
-
 
86
    jmp     event_wait
-
 
87
  @@:
-
 
88
    mcall   4, 5 shl 16 + 25, 1 shl 31, welcio_msg
-
 
89
    mov     [flags], 1 shl PIN_CONF_FLAG
75
    call    drivercomm.bitmode
90
    call    draw_window.no_redraw
-
 
91
    jmp     event_wait
-
 
92
  .init_cont:
76
    call    drivercomm.baud
93
    call    draw_window
-
 
94
    mcall   4, 5 shl 16 + 25, 1 shl 31 + ONCOLOR, devrdy_msg
77
 
95
 
78
event_wait:
96
event_wait:
79
	mov	    eax, 10
97
	mov	    eax, 10
80
	mcall
98
	mcall
81
 
99
 
82
	cmp	    eax, 1			; Event redraw request ?
100
	cmp	    eax, 1			; Event redraw request ?
83
	je	    redraw
101
	je	    redraw
84
 
102
 
85
	cmp	    eax, 2			; Event key in buffer ?
103
	cmp	    eax, 2			; Event key in buffer ?
86
	je	    key
104
	je	    key
87
 
105
 
88
	cmp	    eax, 3			; Event button in buffer ?
106
	cmp	    eax, 3			; Event button in buffer ?
89
	je	    button
107
	je	    button
90
 
108
 
91
	jmp	    event_wait
109
	jmp	    event_wait
92
 
110
 
93
redraw:
111
redraw:
94
	call	draw_window
112
	call	draw_window
95
	jmp	    event_wait
113
	jmp	    event_wait
96
 
114
 
97
key:
115
key:
98
	mcall	2
116
	mcall	2
99
    cmp     ah, '8'
117
    cmp     ah, '8'
100
    jg	    event_wait
118
    jg	    event_wait
101
    cmp     ah, '1'
119
    cmp     ah, '1'
102
    jl	    event_wait
120
    jl	    event_wait
103
    sub     ah, 0x2F
121
    sub     ah, 0x2F
104
    jmp     button.noclose
122
    jmp     button.noclose
105
 
123
 
106
button:
124
button:
107
	mov	    eax,17
125
	mov	    eax,17
108
	mcall
126
	mcall
109
 
127
 
110
	cmp	    ah, 1
128
	cmp	    ah, 1
111
	jle	    .noclose
129
	jg	    .noclose
112
    call    drivercomm.unlock
130
    call    drivercomm.unlock
113
	mov	    eax, -1
131
	mov	    eax, -1
114
	mcall
132
	mcall
115
 
133
 
116
 .noclose:
134
 .noclose:
117
	cmp	    ah, 10
135
	cmp	    ah, 10
118
	jge	    .toggleb
136
	jge	    .toggleb
-
 
137
	mov	    ebx, [flags]
-
 
138
	and 	ebx, 1 shl PIN_CONF_FLAG
-
 
139
	jnz	    event_wait
119
	movzx	edx, ah
140
	movzx	edx, ah
120
	dec	    ah
141
	dec	    ah
121
	dec	    ah
142
	dec	    ah
122
	mov	    cl, ah
143
	mov	    cl, ah
123
	mov	    ah ,1
144
	mov	    ah ,1
124
	shl	    ah, cl
145
	shl	    ah, cl
-
 
146
	mov	    al, [btn_io]
-
 
147
	and	    al, ah
-
 
148
	jz	    .input
125
	xor	    byte[btn_state], ah
149
	xor	    byte[btn_state], ah
126
    push    edx
150
  .input:
-
 
151
    call    draw_window.oloop_entry
127
    call    drivercomm.write
152
    call    drivercomm.write
128
    call    drivercomm.read
153
    call    drivercomm.read
129
    pop     edx
-
 
130
	call	redraw_obutton
154
    ;call    drivercomm.pins
131
	jmp	    event_wait
155
	jmp	    event_wait
132
 
156
 
133
  .toggleb:
157
  .toggleb:
134
    cmp     ah, 18
158
    cmp     ah, 19
135
    jg	    event_wait
159
    jg	    .pinconf
136
    movzx	edx, ah
160
    movzx	edx, ah
137
	mov	    cl, ah
161
	mov	    cl, ah
138
	sub	    cl, 10
162
	sub	    cl, 10
139
	mov	    ah, 1
163
	mov	    ah, 1
140
	shl	    ah, cl
164
	shl	    ah, cl
141
	xor	    byte[btn_io], ah
165
	xor	    byte[btn_io], ah
142
	call	draw_tbutton
166
	call	draw_tbutton
143
	jmp	    event_wait
167
	jmp	    event_wait
-
 
168
 
-
 
169
  .pinconf:
-
 
170
    cmp     ah, 20
-
 
171
    mov     eax, [flags]
-
 
172
    and     eax, 1 shl PIN_CONF_FLAG
-
 
173
    jz	    .no_conf
-
 
174
    call    drivercomm.bitmode
-
 
175
    call    drivercomm.baud
-
 
176
  .no_conf:
-
 
177
    xor     [flags], 1 shl PIN_CONF_FLAG
-
 
178
    jmp     INIT.init_cont
144
 
179
 
145
drivercomm:				;Driver communication procs
180
drivercomm:				;Driver communication procs
146
  .baud:
181
  .baud:
147
    mov     [IOCTLs+IOCTL.io_code], 10
182
    mov     [IOCTLs+IOCTL.io_code], 10
148
    mov     edi, in_buf
183
    mov     edi, in_buf
149
    mov     eax, [pid]
184
    mov     eax, [pid]
150
    mov     [edi], eax
185
    mov     [edi], eax
151
    mov     eax, [dev]
186
    mov     eax, [dev]
152
    mov     [edi+4], eax
187
    mov     [edi+4], eax
153
    mov     [edi+8], dword 9600
188
    mov     [edi+8], dword 9600
154
    mcall   68, 17, IOCTLs
189
    mcall   68, 17, IOCTLs
155
    ret
190
    ret
156
 
191
 
157
  .write:
192
  .write:
158
    mov     [IOCTLs+IOCTL.io_code], 8
193
    mov     [IOCTLs+IOCTL.io_code], 8
159
    mov     edi, in_buf
194
    mov     edi, in_buf
160
    mov     eax, [pid]
195
    mov     eax, [pid]
161
    mov     [edi], eax
196
    mov     [edi], eax
162
    mov     eax, [dev]
197
    mov     eax, [dev]
163
    mov     [edi+4], eax
198
    mov     [edi+4], eax
164
    mov     [edi+8], dword 1
199
    mov     [edi+8], dword 1
165
    mov     al, [btn_state]
200
    mov     al, [btn_state]
166
    mov     byte[edi+12], al
201
    mov     ecx, 4
-
 
202
    add     edi, 12
-
 
203
    rep     stosb
167
    mcall   68, 17, IOCTLs
204
    mcall   68, 17, IOCTLs
168
    ret
205
    ret
169
 
206
 
170
  .read:
207
  .read:
171
    mov     [IOCTLs+IOCTL.io_code], 9
208
    mov     [IOCTLs+IOCTL.io_code], 9
172
    mov     edi, in_buf
209
    mov     edi, in_buf
173
    mov     eax, [pid]
210
    mov     eax, [pid]
174
    mov     [edi], eax
211
    mov     [edi], eax
175
    mov     eax, [dev]
212
    mov     eax, [dev]
176
    mov     [edi+4], eax
213
    mov     [edi+4], eax
177
    mov     [edi+8], dword 1
214
    mov     [edi+8], dword 3
178
    mcall   68, 17, IOCTLs
215
    mcall   68, 17, IOCTLs
179
    mov     al, byte[out_buf]
216
    test    eax, eax
180
    mov     [btn_state], al
217
    jz	    .read_ok
-
 
218
    debug_print 'Error'
181
    newline
219
    newline
-
 
220
 .read_ok:
-
 
221
    mov     al, byte[out_buf+2]
-
 
222
    mov     [btn_state], al
182
    ret
223
    ret
183
 
224
 
184
  .getlock:
225
  .getlock:
185
    mcall	9, thread_inf, 0
226
    mcall	9, thread_inf, 0
186
    mov     eax, dword[thread_inf+30]
227
    mov     eax, dword[thread_inf+30]
187
    mov     [pid], eax
228
    mov     [pid], eax
188
    mov     edi, in_buf
229
    mov     edi, in_buf
189
    mov     [edi], eax
230
    mov     [edi], eax
190
    mov     eax, 2
231
    mov     eax, 2
191
    mov     [IOCTLs+IOCTL.io_code], eax
232
    mov     [IOCTLs+IOCTL.io_code], eax
192
    mov     eax, [dev]
233
    mov     eax, [dev]
193
    mov     [edi+4], eax
234
    mov     [edi+4], eax
194
    mov     eax, 8
235
    mov     eax, 8
195
    mov     [IOCTLs+IOCTL.inp_size], eax
236
    mov     [IOCTLs+IOCTL.inp_size], eax
196
    mcall   68, 17, IOCTLs
237
    mcall   68, 17, IOCTLs
197
    ret
238
    ret
198
 
239
 
199
  .getlist:
240
  .getlist:
200
    mov     eax, 1
241
    mov     eax, 1
201
    mov     [IOCTLs+IOCTL.io_code], eax
242
    mov     [IOCTLs+IOCTL.io_code], eax
202
    mcall   68, 17, IOCTLs
243
    mcall   68, 17, IOCTLs
203
    mov     edi, out_buf
244
    mov     edi, out_buf
204
    mov     eax, [edi+12]
245
    mov     eax, [edi+12]
205
    mov     [dev], eax
246
    mov     [dev], eax
-
 
247
    mov     eax, [edi]
206
    ret
248
    ret
207
 
249
 
208
  .bitmode:
250
  .bitmode:
209
	mov		[IOCTLs+IOCTL.io_code], 11
251
	mov		[IOCTLs+IOCTL.io_code], 11
210
    mov     edi, in_buf
252
    mov     edi, in_buf
211
	mov	    eax, [pid]
253
	mov	    eax, [pid]
212
	mov	    [edi], eax
254
	mov	    [edi], eax
213
	mov	    eax, [dev]
255
	mov	    eax, [dev]
214
	mov	    [edi+4], eax
256
	mov	    [edi+4], eax
215
	xor	    eax, eax
257
	xor	    eax, eax
216
	mov	    al, [btn_io]
258
	mov	    ah, [btn_io]
217
	mov	    ah, 0x04
259
	mov	    al, 0x01
218
	mov	    [edi+8], eax
260
	mov	    [edi+8], eax
219
    mcall   68, 17, IOCTLs
261
    mcall   68, 17, IOCTLs
220
    ret
262
    ret
-
 
263
 
-
 
264
  .pins:
-
 
265
    mov [IOCTLs+IOCTL.io_code], 22
-
 
266
    mov edi, in_buf
-
 
267
    mov eax, [pid]
-
 
268
    mov [edi], eax
-
 
269
    mov eax, [dev]
-
 
270
    mov [edi+4], eax
-
 
271
    mcall 68, 17, IOCTLs
-
 
272
    mov al, byte[out_buf]
-
 
273
    mov [btn_state], al
-
 
274
    ret
221
 
275
 
222
  .unlock:
276
  .unlock:
223
    mov     eax, [pid]
277
    mov     eax, [pid]
224
    mov     edi, in_buf
278
    mov     edi, in_buf
225
    mov     [edi], eax
279
    mov     [edi], eax
226
    mov     eax, 3
280
    mov     eax, 3
227
    mov     [IOCTLs+IOCTL.io_code], eax
281
    mov     [IOCTLs+IOCTL.io_code], eax
228
    mov     eax, [dev]
282
    mov     eax, [dev]
229
    mov     [edi+4], eax
283
    mov     [edi+4], eax
230
    mov     eax, 8
284
    mov     eax, 8
231
    mov     [IOCTLs+IOCTL.inp_size], eax
285
    mov     [IOCTLs+IOCTL.inp_size], eax
232
    mcall   68, 17, IOCTLs
286
    mcall   68, 17, IOCTLs
233
    ret
287
    ret
234
 
288
 
235
;  *********************************************
289
;  *********************************************
236
;  ******  WINDOW DEFINITIONS AND DRAW  ********
290
;  ******  WINDOW DEFINITIONS AND DRAW  ********
237
;  *********************************************
291
;  *********************************************
238
 
292
 
239
draw_window:
293
draw_window:
240
	mov	    eax, 12
294
	mov	    eax, 12
241
	mov	    ebx, 1
295
	mov	    ebx, 1
242
	mcall
296
	mcall
243
 
297
 
244
	mov	    eax, 0
298
	mov	    eax, 0
245
	mov	    ebx, 100 * 65536 + (BUTTONXSIZE+BUTTONXSPACE)*BUTTONCOUNT+BUTTONXSTART*2
299
	mov	    ebx, 100 * 65536 + (BUTTONXSIZE+BUTTONXSPACE)*BUTTONCOUNT+BUTTONXSTART*2
246
	mov	    ecx, 100 * 65536 + 120
300
	mov	    ecx, 100 * 65536 + 120
247
	mov	    edx, 0x14E1E1E1
301
	mov	    edx, 0x14E1E1E1
248
	mov	    esi, 0x808899ff
302
	mov	    esi, 0x808899ff
249
	mov	    edi, title
303
	mov	    edi, title
250
	mcall
304
	mcall
251
 
-
 
252
	mov	edx, BUTTONCOUNT+1
305
 
-
 
306
  .no_redraw:
253
  .oloop:
307
	mcall	    8, ((BUTTONXSIZE+BUTTONXSPACE)*BUTTONCOUNT-30) shl 16 + 60, 25 shl 16 + 12, 20, 0x00E1E1E1
254
    push    edx
308
	mov	    eax, [flags]
255
    call    draw_obutton
309
	and	    eax, 1 shl PIN_CONF_FLAG
256
    pop     edx
-
 
257
    dec     edx
310
	jz	    .no_toggles
258
    cmp     edx, 1
-
 
259
    jnz     .oloop
-
 
260
 
311
	mcall	    4, ((BUTTONXSIZE+BUTTONXSPACE)*BUTTONCOUNT-27) shl 16 + 28, 1 shl 31, fnsh_btn
261
	mov	edx, BUTTONCOUNT+9
312
	mov	    edx, BUTTONCOUNT+9
262
  .tloop:
313
  .tloop:
263
    push    edx
314
    push    edx
264
    call    draw_tbutton
315
    call    draw_tbutton
265
    pop     edx
316
    pop     edx
266
    dec     edx
317
    dec     edx
267
    cmp     edx, 9
318
    cmp     edx, 9
268
    jnz     .tloop
319
    jnz     .tloop
-
 
320
    jmp     @f
-
 
321
  .no_toggles:
-
 
322
	mcall 4, ((BUTTONXSIZE+BUTTONXSPACE)*BUTTONCOUNT-27) shl 16 + 28, 1 shl 31, conf_btn
-
 
323
  @@:
-
 
324
  .oloop_entry:
-
 
325
	mov	edx, BUTTONCOUNT+1
-
 
326
  .oloop:
-
 
327
    push    edx
-
 
328
    call    draw_obutton
-
 
329
    pop     edx
-
 
330
    dec     edx
-
 
331
    cmp     edx, 1
-
 
332
    jnz     .oloop
269
 
333
 
270
	mov	    eax, 12
334
	mov	    eax, 12
271
	mov	    ebx, 2
335
	mov	    ebx, 2
272
	mcall
336
	mcall
273
	ret
337
	ret
274
 
338
 
275
redraw_obutton:
339
redraw_obutton:
276
	mov	    eax, 8
340
	mov	    eax, 8
277
    push    edx
341
    push    edx
278
	or	    edx, 0x80 shl 24
342
	or	    edx, 0x80 shl 24
279
	mcall
343
	mcall
280
	pop	    edx
344
	pop	    edx
281
draw_obutton:
345
draw_obutton:
282
	mov	    ecx, edx
346
	mov	    ecx, edx
283
	dec	    ecx
347
	dec	    ecx
284
	dec	    ecx
348
	dec	    ecx
285
	xor	    ebx, ebx
349
	xor	    ebx, ebx
286
	mov	    bl, [btn_state]
350
	mov	    bl, [btn_state]
287
	mov	    bh, 1
351
	mov	    bh, 1
288
	shl	    bh, cl
352
	shl	    bh, cl
289
	and	    bl, bh
353
	and	    bl, bh
290
	jz	    .off
354
	jz	    .off
291
	mov	    esi, ONCOLOR
355
	mov	    esi, ONCOLOR
292
	jmp	    .aftercolor
356
	jmp	    .aftercolor
293
  .off:
357
  .off:
294
	mov	    esi, OFFCOLOR
358
	mov	    esi, OFFCOLOR
295
  .aftercolor:
359
  .aftercolor:
296
	mov	    bl, [btn_io]
360
	mov	    bl, [btn_io]
297
	and	    bl, bh
361
	and	    bl, bh
298
	jne	.output
362
	jne	.output
299
	or	    edx, 1 shl 29
363
	or	    edx, 1 shl 29
300
  .output:
364
  .output:
301
	push	ecx
365
	push	ecx
302
	imul	bx, cx, word(BUTTONXSPACE+BUTTONXSIZE)
366
	imul	bx, cx, word(BUTTONXSPACE+BUTTONXSIZE)
303
	add	    bx, BUTTONXSTART
367
	add	    bx, BUTTONXSTART
304
	imul	ebx, 65536
368
	imul	ebx, 65536
305
	add	    ebx, BUTTONXSIZE
369
	add	    ebx, BUTTONXSIZE
306
	mov	    ecx, BUTTONYSTART*65536+BUTTONYSIZE
370
	mov	    ecx, BUTTONYSTART*65536+BUTTONYSIZE
307
	mcall	8
371
	mcall	8
308
	pop	    ecx
372
	pop	    ecx
309
	xor	    ebx, ebx
373
	xor	    ebx, ebx
310
	mov	    bl, [btn_io]
374
	mov	    bl, [btn_io]
311
	mov	    bh, 1
375
	mov	    bh, 1
312
	shl	    bh, cl
376
	shl	    bh, cl
313
	and	    bl, bh
377
	and	    bl, bh
314
	jnz	    .text
378
	jnz	    .text
315
	ret
379
	ret
316
  .text:
380
  .text:
317
	mov	    bl, [btn_state]
381
	mov	    bl, [btn_state]
318
	and	    bl, bh
382
	and	    bl, bh
319
	jz	    .off_text
383
	jz	    .off_text
320
	mov	    edx, on_text
384
	mov	    edx, on_text
321
	jmp	    .aftertext
385
	jmp	    .aftertext
322
  .off_text:
386
  .off_text:
323
	mov	    edx, off_text
387
	mov	    edx, off_text
324
  .aftertext:
388
  .aftertext:
325
	imul	bx, cx, word(BUTTONXSPACE+BUTTONXSIZE)
389
	imul	bx, cx, word(BUTTONXSPACE+BUTTONXSIZE)
326
	add	    bx, (BUTTONXSTART + (BUTTONXSIZE/2)-5)
390
	add	    bx, (BUTTONXSTART + (BUTTONXSIZE/2)-5)
327
	shl	    ebx, 16
391
	shl	    ebx, 16
328
	add	    ebx, BUTTONYSTART + (BUTTONYSIZE/2)
392
	add	    ebx, BUTTONYSTART + (BUTTONYSIZE/2)
329
	mcall	4,,1 shl 31
393
	mcall	4,,1 shl 31
330
	ret
394
	ret
331
 
395
 
332
draw_tbutton:
396
draw_tbutton:
333
	mov	    ecx, edx
397
	mov	    ecx, edx
334
	sub	    ecx, 10
398
	sub	    ecx, 10
335
	push	edx ecx
399
	push	edx ecx
336
	or	    edx, 1 shl 31
400
	or	    edx, 1 shl 31
337
	mcall	8
401
	mcall	8
338
	xor	    edi, edi
402
	xor	    edi, edi
339
	imul	di, cx, word(BUTTONXSPACE+BUTTONXSIZE)
403
	imul	di, cx, word(BUTTONXSPACE+BUTTONXSIZE)
340
	push	edi
404
	push	edi
341
	shl	    edi, 16
405
	shl	    edi, 16
342
	mov	    ebx, (BUTTONXSTART)*65536+BUTTONYSTART-12
406
	mov	    ebx, (BUTTONXSTART)*65536+BUTTONYSTART-12
343
	add	    ebx, edi
407
	add	    ebx, edi
344
	mcall	4,, 1 shl 31, i_text
408
	mcall	4,, 1 shl 31, i_text
345
	mov	    ebx, (BUTTONXSTART+5)*65536+BUTTONXSIZE-5*2
409
	mov	    ebx, (BUTTONXSTART+5)*65536+BUTTONXSIZE-5*2
346
	add	    ebx, edi
410
	add	    ebx, edi
347
	mcall	13,, (BUTTONYSTART-13)*65536+9, 0xFFFFFF
411
	mcall	13,, (BUTTONYSTART-13)*65536+9, 0xFFFFFF
348
	mov	    ebx, (BUTTONXSTART+BUTTONXSIZE-4)*65536+BUTTONYSTART-12
412
	mov	    ebx, (BUTTONXSTART+BUTTONXSIZE-4)*65536+BUTTONYSTART-12
349
	add	    ebx, edi
413
	add	    ebx, edi
350
	mcall	4,, 1 shl 31, o_text
414
	mcall	4,, 1 shl 31, o_text
351
	pop	    edi ecx edx
415
	pop	    edi ecx edx
352
	mov	    ebx, edi
416
	mov	    ebx, edi
353
	add	    ebx, (BUTTONXSTART+7)
417
	add	    ebx, (BUTTONXSTART+7)
354
	mov	    al, [btn_io]
418
	mov	    al, [btn_io]
355
	mov	    ah, 1
419
	mov	    ah, 1
356
	shl	    ah, cl
420
	shl	    ah, cl
357
	and	    al, ah
421
	and	    al, ah
358
	jz	    .input
422
	jz	    .input
359
	add	    ebx, (BUTTONXSIZE-14)/2
423
	add	    ebx, (BUTTONXSIZE-14)/2
360
  .input:
424
  .input:
361
	shl	    ebx, 16
425
	shl	    ebx, 16
362
	add	    ebx, (BUTTONXSIZE-14)/2
426
	add	    ebx, (BUTTONXSIZE-14)/2
363
	mcall	8,,(BUTTONYSTART-12)*65536+6,, 0x00576B8C
427
	mcall	8,,(BUTTONYSTART-12)*65536+6,, 0x00576B8C
364
	ret
428
	ret
365
 
429
 
366
;  *********************************************
430
;  *********************************************
367
;  *************   DATA AREA   *****************
431
;  *************   DATA AREA   *****************
368
;  *********************************************
432
;  *********************************************
369
 
433
 
370
btn_state   db ?
434
btn_state   db ?
371
btn_io	    db ?
435
btn_io	    db ?
372
dev		    dd ?
436
dev		dd ?
373
pid			dd ?
437
pid		dd ?
374
counter     dd ?
438
flags	    dd ?
375
drv_name    db 'usbother', 0
439
drv_name    db 'usbother', 0
-
 
440
noftdi_msg  db 'No FTDI connected', 0
-
 
441
devrdy_msg  db 'First FTDI is ready', 0
-
 
442
devlkd_msg  db 'First FTDI is locked', 0
-
 
443
welcio_msg  db 'Please, choose pin state', 0
-
 
444
conf_btn    db 'Configure', 0
-
 
445
fnsh_btn    db 'Finish', 0
376
off_text    db 'OFF', 0
446
off_text    db 'OFF', 0
377
on_text     db 'ON', 0
447
on_text     db 'ON', 0
378
i_text	    db 'I', 0
448
i_text	    db 'I', 0
379
o_text	    db 'O', 0
449
o_text	    db 'O', 0
380
out_buf     rd 10
450
out_buf     rd 10
381
in_buf	    rd 10
451
in_buf	    rd 10
382
IOCTLs	    rd 6
452
IOCTLs	    rd 6
383
thread_inf  rb 1024
453
thread_inf  rb 1024
384
title	    db "FT232 Control Center", 0
454
title	    db "FT232 Control Center", 0
385
 
455
 
386
I_END:
456
I_END: