Subversion Repositories Kolibri OS

Rev

Rev 1829 | Rev 3014 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1829 Rev 1900
1
;
1
;
2
;   MyKey. Version 0.2.
2
;   MyKey. Version 0.2.
3
;
3
;
4
;   Author:         Asper
4
;   Author:         Asper
5
;   Date of issue:  29.12.2009
5
;   Date of issue:  29.12.2009
6
;   Compiler:       FASM
6
;   Compiler:       FASM
7
;   Target:         KolibriOS
7
;   Target:         KolibriOS
8
;
8
;
9
 
9
 
10
use32
10
use32
11
	org	0x0
11
	org	0x0
12
 
12
 
13
	db	'MENUET01'	; 8 byte id
13
	db	'MENUET01'	; 8 byte id
14
	dd	38		; required os
14
	dd	38		; required os
15
	dd	STARTAPP	; program start
15
	dd	STARTAPP	; program start
16
	dd	I_END		; program image size
16
	dd	I_END		; program image size
17
	dd	0x1000000	; required amount of memory
17
	dd	0x1000000	; required amount of memory
18
	dd	0x1000000	; stack heap
18
	dd	0x1000000	; stack heap
19
	dd	0x0
19
	dd	0x0
20
	dd	app_path
20
	dd	app_path
21
 
21
 
22
include 'ASPAPI.INC'
22
include 'ASPAPI.INC'
23
include 'string.inc'
23
include 'string.inc'
24
include 'macros.inc'
24
include 'macros.inc'
25
include 'editbox_ex.mac'
25
include 'editbox_ex.mac'
26
include 'load_lib.mac'
26
include 'load_lib.mac'
27
include 'dll.inc'
27
include 'dll.inc'
28
 
28
 
29
include 'debug.inc'
29
include 'debug.inc'
30
DEBUG	 equ 0;1
30
DEBUG	 equ 0;1
31
 
31
 
32
N_KEYCOLOR    equ 0x00EEEEEE ; Normal button color
32
N_KEYCOLOR    equ 0x00EEEEEE ; Normal button color
33
C_KEYCOLOR    equ 0x00CBE1E1 ; Control button color
33
C_KEYCOLOR    equ 0x00CBE1E1 ; Control button color
34
A_KEYCOLOR    equ 0x00FF6400;258778 ; Active button color
34
A_KEYCOLOR    equ 0x00FF6400;258778 ; Active button color
35
C_TEXTCOLOR   equ 0x80000000 ; Button caption color
35
C_TEXTCOLOR   equ 0x80000000 ; Button caption color
36
CA_TEXTCOLOR  equ 0x80FFFFFF ; Active button caption color
36
CA_TEXTCOLOR  equ 0x80FFFFFF ; Active button caption color
37
A_TEXTCOLOR   equ 0x00FFFFFF ; Active text color
37
A_TEXTCOLOR   equ 0x00FFFFFF ; Active text color
38
 
38
 
39
WIN_X	      equ 265
39
WIN_X	      equ 265
40
WIN_Y	      equ 50;175
40
WIN_Y	      equ 50;175
41
WIN_W	      equ 595
41
WIN_W	      equ 595
42
WIN_H	      equ 415 ;570
42
WIN_H	      equ 415 ;570
43
WIN_COLOR     equ 0x040099BB;0x04EEEEEE
43
WIN_COLOR     equ 0x040099BB;0x04EEEEEE
44
 
44
 
45
ITEM_BUTTON_W	      equ 192;100
45
ITEM_BUTTON_W	      equ 192;100
46
ITEM_BUTTON_H	      equ 23
46
ITEM_BUTTON_H	      equ 23
47
ITEM_BUTTON_SPACE     equ 0
47
ITEM_BUTTON_SPACE     equ 0
48
FIRST_ITEM_BUTTON_ID  equ 7
48
FIRST_ITEM_BUTTON_ID  equ 7
49
 
49
 
50
BUT_W	      equ 80
50
BUT_W	      equ 80
51
BUT_H	      equ 20
51
BUT_H	      equ 20
52
 
52
 
53
MAX_HOTKEYS_NUM equ 15 ;  Bad bounding :/. Until we have normal listbox control.
53
MAX_HOTKEYS_NUM equ 15 ;  Bad bounding :/. Until we have normal listbox control.
54
PATH_MAX_CHARS equ 255
54
PATH_MAX_CHARS equ 255
55
 
55
 
56
@use_library
56
@use_library
57
 
57
 
58
STARTAPP:
58
STARTAPP:
59
	; Initialize memory
59
	; Initialize memory
60
	mcall	68, 11
60
	mcall	68, 11
61
	or	eax,eax
61
	or	eax,eax
62
	jz	close_app
62
	jz	close_app
63
	; Import libraries
63
	; Import libraries
64
	sys_load_library  boxlib_name, sys_path, boxlib_name, system_dir0, err_message_found_lib, head_f_l, myimport,err_message_import, head_f_i
64
	sys_load_library  boxlib_name, sys_path, boxlib_name, system_dir0, err_message_found_lib, head_f_l, myimport,err_message_import, head_f_i
65
	cmp	eax,-1
65
	cmp	eax,-1
66
	jz	close_app
66
	jz	close_app
67
	stdcall dll.Load,importTable
67
	stdcall dll.Load,importTable
68
	test	eax, eax
68
	test	eax, eax
69
	jnz	close_app
69
	jnz	close_app
70
 
-
 
71
	; Get memory for editboxes text
70
 
72
	mcall	68, 12, MAX_HOTKEYS_NUM*PATH_MAX_CHARS
71
	mcall	68, 12, MAX_HOTKEYS_NUM*PATH_MAX_CHARS	 ; Get memory for editboxes text
73
	mov	dword [buf_cmd_line], eax
72
	mov	dword [buf_cmd_line], eax
74
	mov	dword [edit1.text],   eax
73
	mov	dword [edit1.text],   eax
75
	mcall	68, 12, MAX_HOTKEYS_NUM*PATH_MAX_CHARS
74
	mcall	68, 12, MAX_HOTKEYS_NUM*PATH_MAX_CHARS
76
	mov	dword [buf_cmd_params], eax
75
	mov	dword [buf_cmd_params], eax
77
	mov	dword [edit2.text],	eax
76
	mov	dword [edit2.text],	eax
78
	mcall	68, 12, MAX_HOTKEYS_NUM*32
77
	mcall	68, 12, MAX_HOTKEYS_NUM*32
79
	mov	dword [it_buf_cmd_line], eax
78
	mov	dword [it_buf_cmd_line], eax
80
	mov	dword [it_edit.text],	 eax
79
	mov	dword [it_edit.text],	 eax
81
 
80
 
82
	call	Load_HotkeyList
81
	call	Load_HotkeyList
83
 
82
 
84
	mcall	66, 1, 1  ; Set keyboard mode to get scancodes.
83
	mcall	66, 1, 1  ; Set keyboard mode to get scancodes.
85
	mcall	26, 2, 1, ascii_keymap
84
	mcall	26, 2, 1, ascii_keymap
86
 
85
 
87
get_mykey_window_slot_number:
86
get_mykey_window_slot_number:
88
	call	draw_window
87
	call	draw_window
89
	mcall	18, 7
88
	mcall	18, 7
90
	mov	[mykey_window], eax
89
	mov	[mykey_window], eax
91
 
90
 
92
set_event_mask:
91
set_event_mask:
93
	mcall	 40, 39
92
	mcall	 40, 39
94
 
93
 
95
red:
94
red:
96
      .test_slot:
95
      .test_slot:
97
	mcall	18, 7
96
	mcall	18, 7
98
	mov	ebx, [mykey_window]
97
	mov	ebx, [mykey_window]
99
	cmp	eax, ebx
98
	cmp	eax, ebx
100
	jne	@f
99
	jne	@f
101
 
100
 
102
	mov	ecx, [it_window]
101
	mov	ecx, [it_window]
103
	cmp	ebx, ecx
102
	cmp	ebx, ecx
104
	je	@f
103
	je	@f
105
      .activate_it_window:
104
      .activate_it_window:
106
	mov	al,  byte [it_alive]
105
	mov	al,  byte [it_alive]
107
	test	al,  al
106
	test	al,  al
108
	jz	@f
107
	jz	@f
109
	mov	byte [it_alive], 0
108
	mov	byte [it_alive], 0
110
 
109
 
111
	mcall	18, 3		      ; Activate input thread window
110
	mcall	18, 3			    ; Activate input thread window
112
      @@:
111
      @@:
113
	call	draw_window
112
	call	draw_window
114
 
113
 
115
still:
114
still:
116
	call	reset_modifiers
115
	call	reset_modifiers
117
 
116
 
118
	mcall	10		 ; Wait for an event in the queue.
117
	mcall	10		 ; Wait for an event in the queue.
119
 
118
 
120
	cmp	al,1		      ; redraw request ?
119
	cmp	al,1		      ; redraw request ?
121
	jz	red
120
	jz	red
122
	cmp	al,2		      ; key in buffer ?
121
	cmp	al,2		      ; key in buffer ?
123
	jz	key
122
	jz	key
124
	cmp	al,3		      ; button in buffer ?
123
	cmp	al,3		      ; button in buffer ?
125
	jz	button
124
	jz	button
126
	cmp	al,6
125
	cmp	al,6
127
	jz	mouse
126
	jz	mouse
128
 
127
 
129
	jmp	still
128
	jmp	still
130
 
129
 
131
key:
130
key:
132
	mcall	2
131
	mcall	2
133
 
132
 
134
	push	eax
133
	push	eax
135
	mcall	66, 3
134
	mcall	66, 3
-
 
135
	;mov     edx, eax
-
 
136
	;and     edx, 0x00000FF;F
136
	mov	dword [modifiers], eax
137
	mov	dword [modifiers], eax;edx
137
	pop	eax
138
	pop	eax
138
 
139
 
139
	test	word [edit1.flags], 10b
140
	test	word [edit1.flags], 10b
140
	jnz	.editbox_input
141
	jnz	.editbox_input
141
	test	word [edit2.flags], 10b
142
	test	word [edit2.flags], 10b
142
	jz	@f
143
	jz	@f
143
     .editbox_input:
144
     .editbox_input:
144
	cmp	ah, 0x80 ;if key up
145
	cmp	ah, 0x80 ;if key up
145
	ja	still
146
	ja	still
146
	cmp	ah, 42 ;LShift
147
	cmp	ah, 42 ;LShift
147
	je	still
148
	je	still
148
	cmp	ah, 54 ;RShift
149
	cmp	ah, 54 ;RShift
149
	je	still
150
	je	still
150
	cmp	ah, 56 ;Alt
151
	cmp	ah, 56 ;Alt
151
	je	still
152
	je	still
152
	cmp	ah, 29 ;Ctrl
153
	cmp	ah, 29 ;Ctrl
153
	je	still
154
	je	still
154
	cmp	ah, 69 ;Pause/Break
155
	cmp	ah, 69 ;Pause/Break
155
	je	still
156
	je	still
156
 
157
 
157
       mov     esi, ascii_keymap
158
       mov     esi, ascii_keymap
158
       call    Scan2ASCII
159
       call    Scan2ASCII
159
 
160
 
160
       push dword edit1
161
       push dword edit1
161
       call [edit_box_key]
162
       call [edit_box_key]
162
 
163
 
163
       push dword edit2
164
       push dword edit2
164
       call [edit_box_key]
165
       call [edit_box_key]
165
       jmp still
166
       jmp still
166
     @@:
167
     @@:
167
 
168
 
168
      ;------------------------
169
      ;------------------------
169
	mov	cl, byte [hotkeys_num]
170
	mov	cl, byte [hotkeys_num]
170
     .test_next_hotkey:
171
     .test_next_hotkey:
171
	dec	cl
172
	dec	cl
172
	mov	bl, cl
173
	mov	bl, cl
173
	and	ebx, 0xFF
174
	and	ebx, 0xFF
174
	shl	ebx, 2
175
	shl	ebx, 2;5
-
 
176
;        mov     esi, ebx
175
	add	ebx, dword Hotkeys.codes
177
	add	ebx, dword Hotkeys.codes
176
 
178
 
177
	mov	edx, dword [ebx]
179
	mov	edx, dword [ebx]
178
	cmp	ah, dl
180
	cmp	ah, dl
179
	jne	@f
181
	jne	@f
180
 
182
 
181
	shr	edx, 8
183
	shr	edx, 8
182
	cmp	edx, dword [modifiers]
184
	cmp	edx, dword [modifiers]
183
	jne	@f
185
	jne	@f
184
 
186
 
185
	push	eax
187
	push	eax
186
	mov	eax, PATH_MAX_CHARS
188
	mov	eax, PATH_MAX_CHARS
187
	mul	cl
189
	mul	cl
188
	mov	edx, eax
190
	mov	edx, eax
189
	add	edx, dword [buf_cmd_params]
191
	add	edx, dword [buf_cmd_params]
190
	add	eax, dword [buf_cmd_line]
192
	add	eax, dword [buf_cmd_line]
191
	mov	esi, eax
193
	mov	esi, eax
192
	pop	eax
194
	pop	eax
193
	call	RunProgram
195
	call	RunProgram
194
	jmp	.end_test
196
	jmp	.end_test
195
     @@:
197
     @@:
196
	or	cl, cl
198
	or	cl, cl
197
	jnz	.test_next_hotkey
199
	jnz	.test_next_hotkey
198
     .end_test:
200
     .end_test:
199
      ;------------------------
201
      ;------------------------
200
 
202
 
201
	jmp	still
203
	jmp	still
202
 
204
 
203
button:
205
button:
204
	mcall	17	       ; Get pressed button code
206
	mcall	17	       ; Get pressed button code
205
	cmp	ah, 1		    ; Test x button
207
	cmp	ah, 1		    ; Test x button
206
	je	close_app
208
	je	close_app
207
 
209
 
208
	cmp	ah, 2
210
	cmp	ah, 2
209
	jne	@f
211
	jne	@f
210
	call	AddHotKey
212
	call	AddHotKey
211
	jmp	red
213
	jmp	red
212
       @@:
214
       @@:
213
	cmp	ah, 5
215
	cmp	ah, 5
214
	jne	@f
216
	jne	@f
215
	call	Load_HotkeyList
217
	call	Load_HotkeyList
216
	jmp	red
218
	jmp	red
217
       @@:
219
       @@:
218
	cmp	ah, 6
220
	cmp	ah, 6
219
	jne	@f
221
	jne	@f
220
	call	WriteIni
222
	call	WriteIni
221
	xor	edx, edx
223
	xor	edx, edx
222
	mov	esi, aRamSaver
224
	mov	esi, aRamSaver
223
	call	RunProgram
225
	call	RunProgram
224
       @@:
226
       @@:
225
 
227
 
226
	cmp	ah, FIRST_ITEM_BUTTON_ID     ; Test if pressed buttons
228
	cmp	ah, FIRST_ITEM_BUTTON_ID     ; Test if pressed buttons
227
	jb	still			     ; is a HotKey button...
229
	jb	still			     ; is a HotKey button...
228
	mov	al, ah
230
	mov	al, ah
229
	sub	al, FIRST_ITEM_BUTTON_ID
231
	sub	al, FIRST_ITEM_BUTTON_ID
230
	cmp	al, byte [hotkeys_num]
232
	cmp	al, byte [hotkeys_num]
231
	jnb	still			     ; ...so, if not then still,
233
	jnb	still			     ; ...so, if not then still,
232
 
234
 
233
 
235
 
234
	mov	byte [butt], ah 	  ; if yes then save pressed button ID
236
	mov	byte [butt], ah 	  ; if yes then save pressed button ID
235
	and	eax, 0xFF
237
	and	eax, 0xFF
236
	mov	cl, byte PATH_MAX_CHARS
238
	mov	cl, byte PATH_MAX_CHARS
237
	mul	cl
239
	mul	cl
238
	mov	ebx, eax
240
	mov	ebx, eax
239
	add	ebx, dword [buf_cmd_params]
241
	add	ebx, dword [buf_cmd_params]
240
	add	eax, dword [buf_cmd_line]
242
	add	eax, dword [buf_cmd_line]
241
 
243
 
242
	mov	dword [edit1.text], eax
244
	mov	dword [edit1.text], eax
243
	mov	dword [edit2.text], ebx
245
	mov	dword [edit2.text], ebx
244
 
246
 
245
	mov	esi, eax
247
	mov	esi, eax
246
	call	strlen
248
	call	strlen
247
	mov	dword [edit1.size], ecx
249
	mov	dword [edit1.size], ecx
248
	mov	dword [edit1.pos], ecx
250
	mov	dword [edit1.pos], ecx
249
 
251
 
250
	mov	esi, ebx
252
	mov	esi, ebx
251
	call	strlen
253
	call	strlen
252
	mov	dword [edit2.size], ecx
254
	mov	dword [edit2.size], ecx
253
	mov	dword [edit2.pos], ecx
255
	mov	dword [edit2.pos], ecx
254
 
256
 
255
	jmp	red
257
	jmp	red
256
 
258
 
257
mouse:
259
mouse:
258
	push	dword edit1
260
	push	dword edit1
259
	call	[edit_box_mouse]
261
	call	[edit_box_mouse]
260
	push	dword edit2
262
	push	dword edit2
261
	call	[edit_box_mouse]
263
	call	[edit_box_mouse]
262
 
264
 
263
	jmp	still
265
	jmp	still
264
 
266
 
265
 
267
 
266
close_app:
268
close_app:
267
	mov	eax,-1			; close this program
269
	mov	eax,-1			; close this program
268
	int	0x40
270
	int	0x40
269
 
271
 
270
 
272
 
271
draw_window:
273
draw_window:
272
	start_draw_window WIN_X,WIN_Y,WIN_W,WIN_H,WIN_COLOR,labelt, 11;labellen-labelt
274
	start_draw_window WIN_X,WIN_Y,WIN_W,WIN_H,WIN_COLOR,labelt, 11;labellen-labelt
273
 
275
 
274
	;bar         5, 24, 585, 385, 0x800000 or 0x90D2
276
	;bar         5, 24, 585, 385, 0x800000 or 0x90D2
275
	;rectangle2  6, 25, 585, 385, 0xFFFFFF, 0
277
	;rectangle2  6, 25, 585, 385, 0xFFFFFF, 0
276
 
278
 
277
	;bar         5, 24, BUT_W+4, 350, 0x008C00D2;0x800000 or A_KEYCOLOR
279
	;bar         5, 24, BUT_W+4, 350, 0x008C00D2;0x800000 or A_KEYCOLOR
278
	;rectangle2  6, 25, BUT_W+4, 350, 0xFFFFFF, 0
280
	;rectangle2  6, 25, BUT_W+4, 350, 0xFFFFFF, 0
279
 
281
 
280
 
282
 
281
	push	dword edit1
283
	push	dword edit1
282
	call	[edit_box_draw]
284
	call	[edit_box_draw]
283
	push	dword edit2
285
	push	dword edit2
284
	call	[edit_box_draw]
286
	call	[edit_box_draw]
285
 
287
 
286
	stdcall draw_button,   7,WIN_H-BUT_H-10,BUT_W,BUT_H,2,0x0050D250,AddKeyText,   0,C_TEXTCOLOR	; Add Hotkey.
288
	stdcall draw_button,   7,WIN_H-BUT_H-10,BUT_W,BUT_H,2,0x0050D250,AddKeyText,   0,C_TEXTCOLOR	; Add Hotkey.
287
    if 0
289
    if 0
288
	stdcall draw_button,  90,WIN_H-BUT_H-10,BUT_W,BUT_H,3,C_KEYCOLOR,DeleteKeyText,0,C_TEXTCOLOR	; Delete Hotkey.
290
	stdcall draw_button,  90,WIN_H-BUT_H-10,BUT_W,BUT_H,3,C_KEYCOLOR,DeleteKeyText,0,C_TEXTCOLOR	; Delete Hotkey.
289
	stdcall draw_button, 173,WIN_H-BUT_H-10,BUT_W,BUT_H,4,C_KEYCOLOR,ManageKeyText,0,C_TEXTCOLOR	; Manage Hotkey.
291
	stdcall draw_button, 173,WIN_H-BUT_H-10,BUT_W,BUT_H,4,C_KEYCOLOR,ManageKeyText,0,C_TEXTCOLOR	; Manage Hotkey.
290
    end if
292
    end if
291
	stdcall draw_button,   WIN_W-BUT_W*2-14,WIN_H-BUT_H-10,BUT_W,BUT_H,5,0x0050D250,ReloadKeyText,	 0,C_TEXTCOLOR	  ; Save Hotkeys list.
293
	stdcall draw_button,   WIN_W-BUT_W*2-14,WIN_H-BUT_H-10,BUT_W,BUT_H,5,0x0050D250,ReloadKeyText,	 0,C_TEXTCOLOR	  ; Save Hotkeys list.
292
	stdcall draw_button,   WIN_W-BUT_W-7,WIN_H-BUT_H-10,BUT_W,BUT_H,6,0x0050D250,SaveKeyText,   0,C_TEXTCOLOR    ; Save Hotkeys list.
294
	stdcall draw_button,   WIN_W-BUT_W-7,WIN_H-BUT_H-10,BUT_W,BUT_H,6,0x0050D250,SaveKeyText,   0,C_TEXTCOLOR    ; Save Hotkeys list.
293
 
295
 
294
	movzx	ecx, byte [hotkeys_num]
296
	movzx	ecx, byte [hotkeys_num]
295
	cmp	ecx, MAX_HOTKEYS_NUM
297
	cmp	ecx, MAX_HOTKEYS_NUM
296
	jng	@f
298
	jng	@f
297
	mov	ecx, MAX_HOTKEYS_NUM
299
	mov	ecx, MAX_HOTKEYS_NUM
298
     @@:
300
     @@:
299
	mov	eax, 30
301
	mov	eax, 30
300
	mov	ebx, FIRST_ITEM_BUTTON_ID
302
	mov	ebx, FIRST_ITEM_BUTTON_ID
301
     @@:
303
     @@:
302
	or	cl, cl
304
	or	cl, cl
303
	jz	@f
305
	jz	@f
304
 
306
 
305
	mov	edx, ebx
307
	mov	edx, ebx
306
	sub	edx, FIRST_ITEM_BUTTON_ID
308
	sub	edx, FIRST_ITEM_BUTTON_ID
307
	shl	edx, 5; edx=edx*32
309
	shl	edx, 5; edx=edx*32
308
	add	edx, dword Hotkeys
310
	add	edx, dword Hotkeys
309
 
311
 
310
	cmp	bl, byte [butt]
312
	cmp	bl, byte [butt]
311
	jne	.l1
313
	jne	.l1
312
	stdcall draw_button, 7,eax,ITEM_BUTTON_W,ITEM_BUTTON_H,ebx,A_KEYCOLOR  ,edx,0,CA_TEXTCOLOR
314
	stdcall draw_button, 7,eax,ITEM_BUTTON_W,ITEM_BUTTON_H,ebx,A_KEYCOLOR  ,edx,0,CA_TEXTCOLOR
313
	bar	    220, 70, 350, 30, 0x00C8E1F0 ;0x800000 or A_KEYCOLOR
315
	bar	    220, 70, 350, 30, 0x00C8E1F0 ;0x800000 or A_KEYCOLOR
314
	rectangle2  221, 71, 350, 30, 0xFFFFFF, 0
316
	rectangle2  221, 71, 350, 30, 0xFFFFFF, 0
315
	mov	esi, Hotkeys.code_names
317
	mov	esi, Hotkeys.code_names
316
	sub	edx, dword Hotkeys
318
	sub	edx, dword Hotkeys
317
	shl	edx, 1
319
	shl	edx, 1
318
	add	esi, edx
320
	add	esi, edx
319
	stdcall outtextxy, 225, 80, esi, 64, C_TEXTCOLOR
321
	stdcall outtextxy, 225, 80, esi, 64, C_TEXTCOLOR
320
	jmp	.l2
322
	jmp	.l2
321
     .l1:
323
     .l1:
322
	stdcall draw_button, 7,eax,ITEM_BUTTON_W,ITEM_BUTTON_H,ebx,N_KEYCOLOR,edx,0,C_TEXTCOLOR
324
	stdcall draw_button, 7,eax,ITEM_BUTTON_W,ITEM_BUTTON_H,ebx,N_KEYCOLOR,edx,0,C_TEXTCOLOR
323
     .l2:
325
     .l2:
324
 
326
 
325
	add	eax, ITEM_BUTTON_H+ITEM_BUTTON_SPACE
327
	add	eax, ITEM_BUTTON_H+ITEM_BUTTON_SPACE
326
	inc	ebx
328
	inc	ebx
327
	dec	cl
329
	dec	cl
328
	jmp	@b
330
	jmp	@b
329
      @@:
331
      @@:
330
	end_draw_window
332
	end_draw_window
331
ret
333
ret
332
 
334
 
333
 
335
 
334
AddHotKey:
336
AddHotKey:
335
	mov	al, byte [hotkeys_num]
337
	mov	al, byte [hotkeys_num]
336
	cmp	al, MAX_HOTKEYS_NUM
338
	cmp	al, MAX_HOTKEYS_NUM
337
	jge	.end
339
	jge	.end
338
	inc	al
340
	inc	al
339
	mov	byte [hotkeys_num], al
341
	mov	byte [hotkeys_num], al
340
 
342
 
341
	mcall	51, 1, dword start_input_thread, dword input_thread_stack_top
343
	mcall	51, 1, dword start_input_thread, dword input_thread_stack_top
342
    .end:
344
    .end:
343
ret
345
ret
344
 
346
 
345
 
347
 
346
Load_HotkeyList:
348
Load_HotkeyList:
347
	call	ReadIni
349
	call	ReadIni
348
 
350
 
349
	mov	al, byte [butt]
351
	mov	al, byte [butt]
350
	mov	ah, byte [hotkeys_num]
-
 
351
	cmp	al, ah
-
 
352
	jle	@f
-
 
353
	mov	al, ah
-
 
354
      @@:
-
 
355
	and	eax, 0xFF
352
	and	eax, 0xFF
356
	sub	al, FIRST_ITEM_BUTTON_ID
353
	sub	al, FIRST_ITEM_BUTTON_ID
357
	mov	cl, byte PATH_MAX_CHARS
354
	mov	cl, byte PATH_MAX_CHARS
358
	mul	cl
355
	mul	cl
359
	mov	ebx, eax
356
	mov	ebx, eax
360
	add	eax, dword [buf_cmd_line]
357
	add	eax, dword [buf_cmd_line]
361
	add	ebx, dword [buf_cmd_params]
358
	add	ebx, dword [buf_cmd_params]
362
 
359
 
-
 
360
 
363
 
361
	;mov  [butt], FIRST_ITEM_BUTTON_ID
364
	mov	esi, eax
362
	mov	esi, eax
365
	call	strlen
363
	call	strlen
366
	mov	dword [edit1.size], ecx
364
	mov	dword [edit1.size], ecx
367
	mov	dword [edit1.pos], ecx
365
	mov	dword [edit1.pos], ecx
368
 
366
 
369
	mov	esi, ebx
367
	mov	esi, ebx
370
	call	strlen
368
	call	strlen
371
	mov	dword [edit2.size], ecx
369
	mov	dword [edit2.size], ecx
372
	mov	dword [edit2.pos], ecx
370
	mov	dword [edit2.pos], ecx
373
ret
371
ret
374
 
372
 
375
 
373
 
376
reset_modifiers:
374
reset_modifiers:
377
	pusha
375
	pusha
378
	mov	esi, dword [it_hotkey_addr]
376
	mov	esi, dword [it_hotkey_addr]
379
	test	esi, esi
377
	test	esi, esi
380
	jz	.end_set_mods
378
	jz	.end_set_mods
381
 
379
 
382
	lodsd
380
	lodsd
383
 
381
 
384
	; Set new hotkey for the main thread
382
	; Set new hotkey for the main thread
385
	mov	cl, al
383
	mov	cl, al
386
	shr	eax, 8
384
	shr	eax, 8
387
 
385
 
388
	xor    edx, edx
386
	xor    edx, edx
389
	push	cx
387
	push	cx
390
	mov    cl, 3
388
	mov    cl, 3
391
     .next_pair:
389
     .next_pair:
392
	shl    edx, 4
390
	shl    edx, 4
393
	mov    bl, al
391
	mov    bl, al
394
	and    bl, 3
392
	and    bl, 3
395
 
393
 
396
	or     bl, bl
394
	or     bl, bl
397
	jz     .l1
395
	jz     .l1
398
 
396
 
399
	cmp    bl, 3 ; both?
397
	cmp    bl, 3 ; both?
400
	jne    @f
398
	jne    @f
401
	or     dl, 2
399
	or     dl, 2
402
	jmp    .l1
400
	jmp    .l1
403
      @@:
401
      @@:
404
	add    bl, 2
402
	add    bl, 2
405
	or     dl, bl
403
	or     dl, bl
406
      .l1:
404
      .l1:
407
	shr    eax, 2
405
	shr    eax, 2
408
	dec    cl
406
	dec    cl
409
	test   cl, cl
407
	test   cl, cl
410
	jnz    .next_pair
408
	jnz    .next_pair
411
 
409
 
412
	mov    bx, dx
410
	mov    bx, dx
413
	and    bx, 0xF0F
411
	and    bx, 0xF0F
414
	xchg   bl, bh
412
	xchg   bl, bh
415
	and    dx, 0x0F0
413
	and    dx, 0x0F0
416
	or     dx, bx
414
	or     dx, bx
417
	pop    cx
415
	pop    cx
418
 
416
 
419
	mcall	66, 4
417
	mcall	66, 4
420
	mov	dword [it_hotkey_addr], 0
418
	mov	dword [it_hotkey_addr], 0
421
     .end_set_mods:
419
     .end_set_mods:
422
	popa
420
	popa
423
ret
421
ret
424
 
422
 
425
 
423
 
426
;######################## Input Thread code start  ##########################
424
;######################## Input Thread code start  ##########################
427
 
425
 
428
start_input_thread:
426
start_input_thread:
429
	mov	ecx, 1	   ; to get scancodes.
427
	mov	ecx, 1	   ; to get scancodes.
430
	mcall	26, 2, 1, it_ascii_keymap
428
	mcall	26, 2, 1, it_ascii_keymap
431
	mcall	66, 1	   ; Set keyboard mode
429
	mcall	66, 1	   ; Set keyboard mode
432
	mov	dword [it_hotkey_addr], 0
430
	mov	dword [it_hotkey_addr], 0
433
it_set_editbox:
431
it_set_editbox:
434
	mov	al, byte [hotkeys_num]
432
	mov	al, byte [hotkeys_num]
435
	sub	al, 1
433
	sub	al, 1
436
	and	eax, 0xFF
434
	and	eax, 0xFF
437
	shl	eax, 5
435
	shl	eax, 5
438
	add	eax, dword Hotkeys.names
436
	add	eax, dword Hotkeys.names
439
	mov	dword [it_edit.text], eax
437
	mov	dword [it_edit.text], eax
440
 
438
 
441
	mov	esi, eax
439
	mov	esi, eax
442
	call	strlen
440
	call	strlen
443
	mov	dword [it_edit.size], ecx
441
	mov	dword [it_edit.size], ecx
444
	mov	dword [it_edit.pos], ecx
442
	mov	dword [it_edit.pos], ecx
445
get_it_window_slot_number:
443
get_it_window_slot_number:
446
	call	it_draw_window
444
	call	it_draw_window
447
	mcall	18, 7
445
	mcall	18, 7
448
	mov	[it_window], eax
446
	mov	[it_window], eax
449
 
447
 
450
it_set_event_mask:
448
it_set_event_mask:
451
	mcall	40, 39
449
	mcall	40, 39
452
it_red:
450
it_red:
453
	call	it_draw_window
451
	call	it_draw_window
454
 
452
 
455
it_still:
453
it_still:
456
	mcall	10		 ; Wait for an event in the queue.
454
	mcall	10		 ; Wait for an event in the queue.
457
 
455
 
458
	cmp	al,1		      ; redraw request ?
456
	cmp	al,1		      ; redraw request ?
459
	jz	it_red
457
	jz	it_red
460
	cmp	al,2		      ; key in buffer ?
458
	cmp	al,2		      ; key in buffer ?
461
	jz	it_key
459
	jz	it_key
462
	cmp	al,3		      ; button in buffer ?
460
	cmp	al,3		      ; button in buffer ?
463
	jz	it_button
461
	jz	it_button
464
	cmp	al,6
462
	cmp	al,6
465
	jz	it_mouse
463
	jz	it_mouse
466
 
464
 
467
	jmp	it_still
465
	jmp	it_still
468
 
466
 
469
it_key:
467
it_key:
470
	mcall	2
468
	mcall	2
471
 
469
 
472
	mov	byte [it_keycode], 0
470
	mov	byte [it_keycode], 0
473
	stdcall outtextxy, 10, 100, ctrl_key_names, 35, 0
471
	stdcall outtextxy, 10, 100, ctrl_key_names, 35, 0
474
 
472
 
475
	cmp	ah, 1 ;Esc
473
	cmp	ah, 1 ;Esc
476
	jne	@f
474
	jne	@f
477
	dec	byte [hotkeys_num]
475
	dec	byte [hotkeys_num]
478
	jmp	close_app
476
	jmp	close_app
479
      @@:
477
      @@:
480
 
478
 
481
	cmp	ah, 0x80 ;if key up
479
	cmp	ah, 0x80 ;if key up
482
	ja	.end
480
	ja	.end
483
	cmp	ah, 42 ;[Shift] (left)
481
	cmp	ah, 42 ;[Shift] (left)
484
	je	.end
482
	je	.end
485
	cmp	ah, 54 ;[Shift] (right)
483
	cmp	ah, 54 ;[Shift] (right)
486
	je	.end
484
	je	.end
487
	cmp	ah, 56 ;[Alt]
485
	cmp	ah, 56 ;[Alt]
488
	je	.end
486
	je	.end
489
	cmp	ah, 29 ;[Ctrl]
487
	cmp	ah, 29 ;[Ctrl]
490
	je	.end
488
	je	.end
491
	cmp	ah, 69 ;[Pause Break]
489
	cmp	ah, 69 ;[Pause Break]
492
	je	.end
490
	je	.end
493
 
491
 
494
	mov	byte [it_keycode], ah
492
	mov	byte [it_keycode], ah
495
	mov	esi, it_ascii_keymap
493
	mov	esi, it_ascii_keymap
496
	call	Scan2ASCII
494
	call	Scan2ASCII
497
 
495
 
498
	test	word [it_edit.flags], 10b
496
	test	word [it_edit.flags], 10b
499
	jz	.end
497
	jz	.end
500
	push	dword it_edit
498
	push	dword it_edit
501
	call	[edit_box_key]
499
	call	[edit_box_key]
502
	jmp	it_still
500
	jmp	it_still
503
      .end:
501
      .end:
504
 
502
 
505
	mcall	26, 2, 1, it_ascii_keymap
503
	mcall	26, 2, 1, it_ascii_keymap
506
	call	it_test_key_modifiers
504
	call	it_test_key_modifiers
507
	test	dl, 3
505
	test	dl, 3
508
	jz	@f
506
	jz	@f
509
	push	edx
507
	push	edx
510
	mcall	26, 2, 2, it_ascii_keymap
508
	mcall	26, 2, 2, it_ascii_keymap
511
	pop	edx
509
	pop	edx
512
      @@:
510
      @@:
513
 
511
 
514
	mov	al, byte [it_keycode]
512
	mov	al, byte [it_keycode]
515
	test	al, al
513
	test	al, al
516
	jz	@f
514
	jz	@f
517
	shl	edx, 8
515
	shl	edx, 8
518
	mov	dl, al
516
	mov	dl, al
519
 
517
 
520
	mov	eax, dword [it_hotkey_addr]
518
	mov	eax, dword [it_hotkey_addr]
521
	test	eax, eax
519
	test	eax, eax
522
	jnz	@f
520
	jnz	@f
523
 
521
 
524
	call	it_set_keycode_name
522
	call	it_set_keycode_name
525
 
523
 
526
	mov	al, byte [hotkeys_num]
524
	mov	al, byte [hotkeys_num]
527
	dec	al
525
	dec	al
528
	and	eax, 0xFF
526
	and	eax, 0xFF
529
	shl	eax, 2;5
527
	shl	eax, 2;5
530
	add	eax, dword Hotkeys.codes
528
	add	eax, dword Hotkeys.codes
531
	mov	dword [eax], edx
529
	mov	dword [eax], edx
532
	mov	dword [it_hotkey_addr], eax
530
	mov	dword [it_hotkey_addr], eax
533
 
531
 
534
	mov	cl, dl ; finally set hotkey
532
	mov	cl, dl ; finally set hotkey
535
	shr	edx, 8
533
	shr	edx, 8
536
	mcall	66, 4
534
	mcall	66, 4
537
      @@:
535
      @@:
538
 
536
 
539
	jmp	it_still
537
	jmp	it_still
540
 
538
 
541
 
539
 
542
it_test_key_modifiers:
540
it_test_key_modifiers:
543
	push	eax
541
	push	eax
544
	mcall	66, 3 ;get control keys state
542
	mcall	66, 3 ;get control keys state
545
	mov	edx,  eax
543
	mov	edx,  eax
-
 
544
	;and     edx,  0x00000FFF
546
      .lshift:
545
      .lshift:
547
	test	al, 1  ; LShift ?
546
	test	al, 1  ; LShift ?
548
	jz	.rshift
547
	jz	.rshift
549
	stdcall outtextxy, 10, 100, ctrl_key_names, 6, A_TEXTCOLOR
548
	stdcall outtextxy, 10, 100, ctrl_key_names, 6, A_TEXTCOLOR
550
      .rshift:
549
      .rshift:
551
	test	al, 2  ; RShift ?
550
	test	al, 2  ; RShift ?
552
	jz	.lctrl
551
	jz	.lctrl
553
	stdcall outtextxy, 184, 100, ctrl_key_names+29, 6, A_TEXTCOLOR
552
	stdcall outtextxy, 184, 100, ctrl_key_names+29, 6, A_TEXTCOLOR
554
      .lctrl:
553
      .lctrl:
555
	test	al, 4  ; LCtrl ?
554
	test	al, 4  ; LCtrl ?
556
	jz	.rctrl
555
	jz	.rctrl
557
	stdcall outtextxy, 52, 100, ctrl_key_names+7, 5, A_TEXTCOLOR
556
	stdcall outtextxy, 52, 100, ctrl_key_names+7, 5, A_TEXTCOLOR
558
      .rctrl:
557
      .rctrl:
559
	test	al, 8  ; RCtrl ?
558
	test	al, 8  ; RCtrl ?
560
	jz	.lalt
559
	jz	.lalt
561
	stdcall outtextxy, 148, 100, ctrl_key_names+23, 5, A_TEXTCOLOR
560
	stdcall outtextxy, 148, 100, ctrl_key_names+23, 5, A_TEXTCOLOR
562
      .lalt:
561
      .lalt:
563
	test	al, 0x10  ; LAlt ?
562
	test	al, 0x10  ; LAlt ?
564
	jz	.ralt
563
	jz	.ralt
565
	stdcall outtextxy, 88, 100, ctrl_key_names+13, 4, A_TEXTCOLOR
564
	stdcall outtextxy, 88, 100, ctrl_key_names+13, 4, A_TEXTCOLOR
566
      .ralt:
565
      .ralt:
567
	test	al, 0x20  ; RAlt ?
566
	test	al, 0x20  ; RAlt ?
568
	jz	@f
567
	jz	@f
569
	stdcall outtextxy, 118, 100, ctrl_key_names+18, 4, A_TEXTCOLOR
568
	stdcall outtextxy, 118, 100, ctrl_key_names+18, 4, A_TEXTCOLOR
570
      @@:
569
      @@:
571
	pop	eax
570
	pop	eax
572
ret
571
ret
573
 
572
 
574
 
573
 
575
it_set_keycode_name:
574
it_set_keycode_name:
576
	pusha
575
	pusha
577
	mov	al, byte [hotkeys_num]
576
	mov	al, byte [hotkeys_num]
578
	dec	al
577
	dec	al
579
	and	eax, 0xFF
578
	and	eax, 0xFF
580
	shl	eax, 6
579
	shl	eax, 6
581
	mov	edi, Hotkeys.code_names
580
	mov	edi, Hotkeys.code_names
582
	add	edi, eax
581
	add	edi, eax
583
 
582
 
584
	mov	ecx, 64
583
	mov	ecx, 64
585
	xor	ax, ax
584
	xor	ax, ax
586
	call	strnset
585
	call	strnset
587
	mcall	66, 3 ;get control keys state
586
	mcall	66, 3 ;get control keys state
588
      .lshift:
587
      .lshift:
589
	test	al, 1  ; LShift ?
588
	test	al, 1  ; LShift ?
590
	jz	.rshift
589
	jz	.rshift
591
	mov	esi, ctrl_key_names
590
	mov	esi, ctrl_key_names
592
	mov	ecx, 6
591
	mov	ecx, 6
593
	call	strncat
592
	call	strncat
594
 
593
 
595
	mov	esi, aPlus
594
	mov	esi, aPlus
596
	mov	ecx, 3
595
	mov	ecx, 3
597
	call	strncat
596
	call	strncat
-
 
597
	;stdcall outtextxy, 10, 100, ctrl_key_names, 6, 0x00FF0000
598
      .rshift:
598
      .rshift:
599
	test	al, 2  ; RShift ?
599
	test	al, 2  ; RShift ?
600
	jz	.lctrl
600
	jz	.lctrl
601
	mov	esi, ctrl_key_names+29
601
	mov	esi, ctrl_key_names+29
602
	mov	ecx, 6
602
	mov	ecx, 6
603
	call	strncat
603
	call	strncat
604
 
604
 
605
	mov	esi, aPlus
605
	mov	esi, aPlus
606
	mov	ecx, 3
606
	mov	ecx, 3
607
	call	strncat
607
	call	strncat
-
 
608
	;stdcall outtextxy, 184, 100, ctrl_key_names+29, 6, 0x00FF0000
608
      .lctrl:
609
      .lctrl:
609
	test	al, 4  ; LCtrl ?
610
	test	al, 4  ; LCtrl ?
610
	jz	.rctrl
611
	jz	.rctrl
611
	mov	esi, ctrl_key_names+7
612
	mov	esi, ctrl_key_names+7
612
	mov	ecx, 5
613
	mov	ecx, 5
613
	call	strncat
614
	call	strncat
614
 
615
 
615
	mov	esi, aPlus
616
	mov	esi, aPlus
616
	mov	ecx, 3
617
	mov	ecx, 3
617
	call	strncat
618
	call	strncat
-
 
619
	;stdcall outtextxy, 52, 100, ctrl_key_names+7, 5, 0x00FF0000
618
      .rctrl:
620
      .rctrl:
619
	test	al, 8  ; RCtrl ?
621
	test	al, 8  ; RCtrl ?
620
	jz	.lalt
622
	jz	.lalt
621
	mov	esi, ctrl_key_names+23
623
	mov	esi, ctrl_key_names+23
622
	mov	ecx, 5
624
	mov	ecx, 5
623
	call	strncat
625
	call	strncat
624
 
626
 
625
	mov	esi, aPlus
627
	mov	esi, aPlus
626
	mov	ecx, 3
628
	mov	ecx, 3
627
	call	strncat
629
	call	strncat
-
 
630
	;stdcall outtextxy, 148, 100, ctrl_key_names+23, 5, 0x00FF0000
628
      .lalt:
631
      .lalt:
629
	test	al, 0x10  ; LAlt ?
632
	test	al, 0x10  ; LAlt ?
630
	jz	.ralt
633
	jz	.ralt
631
	mov	esi, ctrl_key_names+13
634
	mov	esi, ctrl_key_names+13
632
	mov	ecx, 4
635
	mov	ecx, 4
633
	call	strncat
636
	call	strncat
634
 
637
 
635
	mov	esi, aPlus
638
	mov	esi, aPlus
636
	mov	ecx, 3
639
	mov	ecx, 3
637
	call	strncat
640
	call	strncat
-
 
641
	;stdcall outtextxy, 88, 100, ctrl_key_names+13, 4, 0x00FF0000
638
      .ralt:
642
      .ralt:
639
	test	al, 0x20  ; RAlt ?
643
	test	al, 0x20  ; RAlt ?
640
	jz	@f
644
	jz	@f
641
	mov	esi, ctrl_key_names+18
645
	mov	esi, ctrl_key_names+18
642
	mov	ecx, 4
646
	mov	ecx, 4
643
	call	strncat
647
	call	strncat
644
 
648
 
645
	mov	esi, aPlus
649
	mov	esi, aPlus
646
	mov	ecx, 3
650
	mov	ecx, 3
647
	call	strncat
651
	call	strncat
-
 
652
	;stdcall outtextxy, 118, 100, ctrl_key_names+18, 4, 0x00FF0000
648
      @@:
653
      @@:
649
	mov	esi, it_ascii_keymap
654
	mov	esi, it_ascii_keymap
650
	and	edx, 0xFF
655
	and	edx, 0xFF
651
	add	esi, edx
656
	add	esi, edx
652
	mov	ecx, 1
657
	mov	ecx, 1
653
	call	strncat
658
	call	strncat
-
 
659
 
-
 
660
	if 1;DEBUG
-
 
661
	  mov	  esi, edi;Hotkeys.code_names
-
 
662
	  call	  SysMsgBoardStr
-
 
663
	  newline
-
 
664
	end if
654
 
665
 
655
	popa
666
	popa
656
ret
667
ret
657
 
668
 
658
 
669
 
659
it_button:
670
it_button:
660
	mcall	17	       ; Get pressed button code
671
	mcall	17	       ; Get pressed button code
661
	cmp	ah, 1	       ; Test x button
672
	cmp	ah, 1		    ; Test x button
662
	jne	@f
673
	jne	@f
663
	jmp	close_app
674
	jmp	close_app
664
      @@:
675
      @@:
665
	jmp	it_still
676
	jmp	it_still
666
 
677
 
667
it_mouse:
678
it_mouse:
668
 
679
 
669
	push	dword it_edit
680
	push	dword it_edit
670
	call	[edit_box_mouse]
681
	call	[edit_box_mouse]
671
 
682
 
672
	jmp	it_still
683
	jmp	it_still
673
 
684
 
674
it_draw_window:
685
it_draw_window:
675
	start_draw_window 450,WIN_Y+250,225,70,WIN_COLOR,it_labelt, 26;labellen-labelt
686
	start_draw_window 450,WIN_Y+250,225,70,WIN_COLOR,it_labelt, 26;labellen-labelt
676
 
687
 
677
	push	dword it_edit
688
	push	dword it_edit
678
	call	[edit_box_draw]
689
	call	[edit_box_draw]
679
 
690
 
680
	stdcall outtextxy, 43, 50, it_hint, 0, 0x323232
691
	stdcall outtextxy, 43, 50, it_hint, 0, 0x323232
681
	stdcall outtextxy, 10, 100, ctrl_key_names, 0, 0
692
	stdcall outtextxy, 10, 100, ctrl_key_names, 0, 0
682
	;stdcall draw_button,   7,WIN_H-30,80,20,2,C_KEYCOLOR,AddKeyText,   0,C_TEXTCOLOR    ; Add Hot key.
693
	;stdcall draw_button,   7,WIN_H-30,80,20,2,C_KEYCOLOR,AddKeyText,   0,C_TEXTCOLOR    ; Add Hot key.
683
	end_draw_window
694
	end_draw_window
684
	mov	byte [it_alive], 1
695
	mov	byte [it_alive], 1
685
ret
696
ret
686
 
697
 
687
;######################## Input Thread code end ##########################
698
;######################## Input Thread code end ##########################
688
 
699
 
689
 
700
 
690
; Read configuration file
701
; Read configuration file
691
ReadIni:
702
ReadIni:
692
	; Get path
703
	; Get path
693
	mov	edi, ini_path
704
	mov	edi, ini_path
694
	mov	esi, app_path
705
	mov	esi, app_path
695
	call	strlen
706
	call	strlen
696
 
707
 
697
      .get_path:
708
      .get_path:
698
	cmp	byte [app_path+ecx-1], '/'
709
	cmp	byte [app_path+ecx-1], '/'
699
	je	@f
710
	je	@f
700
	loop	.get_path
711
	loop	.get_path
701
      @@:
712
      @@:
702
	call	strncpy
713
	call	strncpy
703
	mov	byte [ini_path+ecx], 0
714
	mov	byte [ini_path+ecx], 0
704
	mov	esi, aIni
715
	mov	esi, aIni
705
	call	strlen
716
	call	strlen
706
	call	strncat
717
	call	strncat
707
 
718
 
708
	; Get hotkey number
719
	; Get hotkey number
709
	invoke	ini_get_int, ini_path, aMain, aKeynum, 0
720
	invoke	ini_get_int, ini_path, aMain, aKeynum, 0
710
 
721
 
711
	and	eax, 0xFF
722
	and	eax, 0xFF
712
	test	al, al
723
	test	al, al
713
	jz	.end
724
	jz	.end
714
	cmp	al, MAX_HOTKEYS_NUM
725
	cmp	al, MAX_HOTKEYS_NUM
715
	jle	@f
726
	jle	@f
716
	mov	al, MAX_HOTKEYS_NUM
727
	mov	al, MAX_HOTKEYS_NUM
717
      @@:
728
      @@:
718
	mov	byte [hotkeys_num], al
729
	mov	byte [hotkeys_num], al
719
 
730
 
720
	mov	ecx, eax
731
	mov	ecx, eax
721
	xor	eax, eax
732
	xor	eax, eax
722
      .get_next_hotkey_values:
733
      .get_next_hotkey_values:
723
	call	set_next_hotkey_section_name
734
	call	set_next_hotkey_section_name
724
	; Get hotkey name
735
	; Get hotkey name
725
	mov	edi, eax
736
	mov	edi, eax
726
	shl	edi, 5 ; edi=eax*32
737
	shl	edi, 5 ; edi=eax*32
727
	add	edi, dword Hotkeys
738
	add	edi, dword Hotkeys
728
	push	eax ecx
739
	push	eax ecx
729
	invoke	ini_get_str, ini_path, aHotkey, aName, edi, 32, 0
740
	invoke	ini_get_str, ini_path, aHotkey, aName, edi, 32, 0
730
	pop	ecx eax
741
	pop	ecx eax
731
	; Get hotkey code
742
	; Get hotkey code
732
	mov	edi, eax
743
	mov	edi, eax
733
	shl	edi, 2 ; edi=eax*4
744
	shl	edi, 2 ; edi=eax*4
734
	add	edi, dword Hotkeys.codes
745
	add	edi, dword Hotkeys.codes
735
	push	eax ecx edx
746
	push	eax ecx edx
736
	invoke	ini_get_int, ini_path, aHotkey, aKeycode, 0
747
	invoke	ini_get_int, ini_path, aHotkey, aKeycode, 0
737
	mov	dword [it_hotkey_addr], edi
748
	mov	dword [it_hotkey_addr], edi
738
	stosd
749
	stosd
739
	; set hotkey
750
	; set hotkey
740
	call	reset_modifiers
751
	call	reset_modifiers
741
	pop	edx ecx eax
752
	pop	edx ecx eax
742
	; Get hotkey code_name
753
	; Get hotkey code_name
743
	mov	edi, eax
754
	mov	edi, eax
744
	shl	edi, 6 ; edi=eax*64
755
	shl	edi, 6 ; edi=eax*64
745
	add	edi, dword Hotkeys.code_names
756
	add	edi, dword Hotkeys.code_names
746
	push	eax ecx
757
	push	eax ecx
747
	invoke	ini_get_str, ini_path, aHotkey, aKeycodeName, edi, 64, 0
758
	invoke	ini_get_str, ini_path, aHotkey, aKeycodeName, edi, 64, 0
748
	pop	ecx eax
759
	pop	ecx eax
749
	; Get hotkey path and param
760
	; Get hotkey path and param
750
	push	eax ecx
761
	push	eax ecx
751
	mov	cl, byte PATH_MAX_CHARS
762
	mov	cl, byte PATH_MAX_CHARS
752
	mul	cl
763
	mul	cl
753
	mov	edi, eax
764
	mov	edi, eax
754
	push	edi
765
	push	edi
755
	add	edi, dword [buf_cmd_line]
766
	add	edi, dword [buf_cmd_line]
756
	invoke	ini_get_str, ini_path, aHotkey, aPath, edi, 32, 0
767
	invoke	ini_get_str, ini_path, aHotkey, aPath, edi, 32, 0
757
	pop	edi
768
	pop	edi
758
	add	edi, dword [buf_cmd_params]
769
	add	edi, dword [buf_cmd_params]
759
	invoke	ini_get_str, ini_path, aHotkey, aParam, edi, 32, 0
770
	invoke	ini_get_str, ini_path, aHotkey, aParam, edi, 32, 0
760
	pop	ecx eax
771
	pop	ecx eax
761
 
772
 
762
	inc	al
773
	inc	al
763
	dec	ecx
774
	dec	ecx
764
	test	ecx, ecx
775
	test	ecx, ecx
765
	jnz    .get_next_hotkey_values
776
	jnz    .get_next_hotkey_values
766
    .end:
777
    .end:
767
ret
778
ret
768
 
779
 
769
 
780
 
770
; Write configuration file
781
; Write configuration file
771
WriteIni:
782
WriteIni:
772
	mov	edi, ini_path
783
	mov	edi, ini_path
773
	; Set hotkey number
784
	; Set hotkey number
774
	movzx	ecx, byte [hotkeys_num]
785
	movzx	ecx, byte [hotkeys_num]
775
	invoke	ini_set_int, ini_path, aMain, aKeynum, ecx
786
	invoke	ini_set_int, ini_path, aMain, aKeynum, ecx
776
 
787
 
777
	xor	eax, eax
788
	xor	eax, eax
778
      .get_next_hotkey_values:
789
      .get_next_hotkey_values:
779
	call	set_next_hotkey_section_name
790
	call	set_next_hotkey_section_name
780
	; Set hotkey name
791
	; Set hotkey name
781
	push	eax ecx
792
	push	eax ecx
782
	mov	esi, eax
793
	mov	esi, eax
783
	shl	esi, 5 ; edi=eax*32
794
	shl	esi, 5 ; edi=eax*32
784
	add	esi, dword Hotkeys
795
	add	esi, dword Hotkeys
785
	call	strlen
796
	call	strlen
786
	invoke	ini_set_str, ini_path, aHotkey, aName, esi, ecx
797
	invoke	ini_set_str, ini_path, aHotkey, aName, esi, ecx
787
	pop	ecx eax
798
	pop	ecx eax
788
	; Set hotkey code
799
	; Set hotkey code
789
	mov	esi, eax
800
	mov	esi, eax
790
	shl	esi, 2 ; edi=eax*4
801
	shl	esi, 2 ; edi=eax*4
791
	add	esi, dword Hotkeys.codes
802
	add	esi, dword Hotkeys.codes
792
	push	eax ecx edx
803
	push	eax ecx edx
793
	invoke	ini_set_int, ini_path, aHotkey, aKeycode, dword [esi]
804
	invoke	ini_set_int, ini_path, aHotkey, aKeycode, dword [esi]
794
	pop	edx ecx eax
805
	pop	edx ecx eax
795
	; Set hotkey code_name
806
	; Set hotkey code_name
796
	mov	esi, eax
807
	mov	esi, eax
797
	shl	esi, 6 ; edi=eax*64
808
	shl	esi, 6 ; edi=eax*64
798
	add	esi, dword Hotkeys.code_names
809
	add	esi, dword Hotkeys.code_names
799
	push	eax ecx
810
	push	eax ecx
800
	call	strlen
811
	call	strlen
801
	invoke	ini_set_str, ini_path, aHotkey, aKeycodeName, esi, ecx
812
	invoke	ini_set_str, ini_path, aHotkey, aKeycodeName, esi, ecx
802
	pop	ecx eax
813
	pop	ecx eax
803
	; Set hotkey path and param
814
	; Set hotkey path and param
804
	push	eax ecx
815
	push	eax ecx
805
	;inc     al
816
	;inc     al
806
	mov	cl, byte PATH_MAX_CHARS
817
	mov	cl, byte PATH_MAX_CHARS
807
	mul	cl
818
	mul	cl
808
	mov	esi, eax
819
	mov	esi, eax
809
	push	esi
820
	push	esi
810
	add	esi, dword [buf_cmd_line]
821
	add	esi, dword [buf_cmd_line]
811
	call	strlen
822
	call	strlen
812
	invoke	ini_set_str, ini_path, aHotkey, aPath, esi, ecx
823
	invoke	ini_set_str, ini_path, aHotkey, aPath, esi, ecx
813
	pop	esi
824
	pop	esi
814
	add	esi, dword [buf_cmd_params]
825
	add	esi, dword [buf_cmd_params]
815
	call	strlen
826
	call	strlen
816
	invoke	ini_set_str, ini_path, aHotkey, aParam, esi, ecx
827
	invoke	ini_set_str, ini_path, aHotkey, aParam, esi, ecx
817
	pop	ecx eax
828
	pop	ecx eax
818
 
829
 
819
	inc	al
830
	inc	al
820
	dec	ecx
831
	dec	ecx
821
	test	ecx, ecx
832
	test	ecx, ecx
822
	jnz    .get_next_hotkey_values
833
	jnz    .get_next_hotkey_values
823
    .end:
834
    .end:
824
ret
835
ret
825
 
836
 
826
 
837
 
827
set_next_hotkey_section_name:		;(eax - num)
838
set_next_hotkey_section_name:		;(eax - num)
828
; this code mainly from debug.inc
839
; this code mainly from debug.inc
829
	push	eax ecx edi
840
	push	eax ecx edi
830
	mov	edi, aHotkey
841
	mov	edi, aHotkey
831
	add	edi, 6 ; + strlen("hotkey")
842
	add	edi, 6 ; + strlen("hotkey")
832
	mov	ecx, 10
843
	mov	ecx, 10
833
	push	-'0'
844
	push	-'0'
834
    .l0:
845
    .l0:
835
	xor	edx, edx
846
	xor	edx, edx
836
	div	ecx
847
	div	ecx
837
	push	edx
848
	push	edx
838
	test	eax, eax
849
	test	eax, eax
839
	jnz	.l0
850
	jnz	.l0
840
    .l1:
851
    .l1:
841
	pop	eax
852
	pop	eax
842
	add	al, '0'
853
	add	al, '0'
843
	;call   debug_outchar
854
	;call   debug_outchar
844
	stosb
855
	stosb
845
	jnz	.l1
856
	jnz	.l1
846
	pop	edi ecx eax
857
	pop	edi ecx eax
847
ret
858
ret
848
 
859
 
849
 
860
 
850
;****************************************
861
;****************************************
851
;*  input:  esi = pointer to keymap     *
862
;*  input:  esi = pointer to keymap     *
852
;*           ah  = scan code            *
863
;*           ah  = scan code            *
853
;*  output:  ah  = ascii code           *
864
;*  output:  ah  = ascii code           *
854
;****************************************
865
;****************************************
855
Scan2ASCII:
866
Scan2ASCII:
856
	push	esi
867
	push	esi
857
	shr	eax, 8
868
	shr	eax, 8
858
	add	esi, eax
869
	add	esi, eax
859
	lodsb
870
	lodsb
860
	shl	eax, 8
871
	shl	eax, 8
861
	pop	esi
872
	pop	esi
862
ret
873
ret
863
 
874
 
864
 
875
 
865
 
876
 
866
;********************************************
877
;********************************************
867
;*  input:  esi = pointer to the file name  *
878
;*  input:  esi = pointer to the file name  *
868
;*          edx = pointer to the parametrs  *
879
;*          edx = pointer to the parametrs  *
869
;********************************************
880
;********************************************
870
 
881
 
871
RunProgram:
882
RunProgram:
872
    pusha
883
    pusha
873
    mov      dword [InfoStructure],    7   ; run program
884
    mov      dword [InfoStructure],    7   ; run program
874
    mov      dword [InfoStructure+4],  0   ; flags
885
    mov      dword [InfoStructure+4],  0   ; flags
875
    mov      dword [InfoStructure+8],  edx ; pointer to the parametrs
886
    mov      dword [InfoStructure+8],  edx ; pointer to the parametrs
876
    mov      dword [InfoStructure+12], 0   ; reserved
887
    mov      dword [InfoStructure+12], 0   ; reserved
877
    mov      dword [InfoStructure+16], 0   ; reserved
888
    mov      dword [InfoStructure+16], 0   ; reserved
878
    mov      dword [InfoStructure+20], 0   ; reserved
889
    mov      dword [InfoStructure+20], 0   ; reserved
879
    mov      dword [InfoStructure+21], esi ; pointer to the file name
890
    mov      dword [InfoStructure+21], esi ; pointer to the file name
880
    mcall    70, InfoStructure
891
    mcall    70, InfoStructure
881
    cmp      eax, 0
892
    cmp      eax, 0
882
    jl	     .err_out
893
    jl	     .err_out
883
  .out:
894
  .out:
884
    popa
895
    popa
885
    clc
896
    clc
886
    ret
897
    ret
887
  .err_out:
898
  .err_out:
888
    print    "Can't load program"
899
    print    "Can't load program"
889
    popa
900
    popa
890
    stc
901
    stc
891
    ret
902
    ret
892
 
903
 
893
 
904
 
894
; DATA AREA
905
; DATA AREA
895
 
906
 
896
; Application Title
907
; Application Title
897
labelt		db	'MyKey v.0.2'
908
labelt		db	'MyKey v.0.2'
898
mykey_window	dd	0	   ; Slot number of MyKey main thread
909
mykey_window	dd	0	   ; Slot number of MyKey
899
 
910
 
900
 
911
 
901
;########### Input Thread data start ############
912
;########### Input Thread data start ############
902
 
913
 
903
; Input Thread Title
914
; Input Thread Title
904
it_labelt	db	"Input hotkey and it's name"
915
it_labelt	db	"Input hotkey and it's name"
905
;labellen:
916
;labellen:
906
it_edit edit_box 180, 20, 30, 0xffffff, 0xAA80, 0x0000ff, 0x0, 0x0, 31, it_buf_cmd_line, 0, 0
917
it_edit edit_box 180, 20, 30, 0xffffff, 0xAA80, 0x0000ff, 0x0, 0x0, 31, it_buf_cmd_line, 0, 0
907
it_buf_cmd_line   dd	  0 ;db MAX_HOTKEYS_NUM*32 dup(0)  ; !Make it dynamic!!!
918
it_buf_cmd_line   dd	  0 ;db MAX_HOTKEYS_NUM*32 dup(0)  ; !Make it dynamic!!!
908
it_window	  dd	  0	     ; Slot number of the input thread
919
it_window	  dd	  0	     ; Slot number of the input thread
909
it_alive	  db	  0	     ; Flag of the input thread existance
920
it_alive	  db	  0	     ; Flag of the input thread existance
910
it_keycode	  db	  0
921
it_keycode	  db	  0
911
it_hotkey_addr	  dd	  0
922
it_hotkey_addr	  dd	  0
912
it_hint 	  db	  'or press Esc to cancel',0
923
it_hint 	  db	  'or press Esc to cancel',0
913
;########### Input Thread data end   ############
924
;########### Input Thread data end   ############
914
 
925
 
915
;Button names
926
;Button names
916
AddKeyText	db 'Add',0
927
AddKeyText	db 'Add',0
917
ReloadKeyText	db 'Reload',0
928
ReloadKeyText	db 'Reload',0
918
SaveKeyText	db 'Save',0
929
SaveKeyText	db 'Save',0
919
;DeleteKeyText   db 'Delete',0
930
;DeleteKeyText   db 'Delete',0
920
;ManageKeyText   db 'Manage',0
931
;ManageKeyText   db 'Manage',0
921
 
932
 
922
 
933
 
923
hotkeys_num   db 0;15
934
hotkeys_num   db 0;15
-
 
935
;keyboard_mode db 0       ; Scan or ASCII keys to send ?  0 - ASCII , 1 - Scan
924
butt	      db FIRST_ITEM_BUTTON_ID	    ; Pressed button ID
936
butt	      db FIRST_ITEM_BUTTON_ID	    ; Pressed button ID
925
modifiers     dd 0
937
modifiers     dd 0
926
 
938
 
927
;Data structures for loadlib.mac and editbox_ex.mac [
939
;Data structures for loadlib.mac and editbox_ex.mac [
928
edit1 edit_box 350, 220, 30, 0xffffff, 0xAA80, 0x0000ff, 0x0, 0x0, PATH_MAX_CHARS+1, buf_cmd_line, 0, 0
940
edit1 edit_box 350, 220, 30, 0xffffff, 0xAA80, 0x0000ff, 0x0, 0x0, PATH_MAX_CHARS+1, buf_cmd_line, 0, 0
929
edit2 edit_box 350, 220, 50, 0xffffff, 0xAA80, 0x0000ff, 0x0, 0x0, PATH_MAX_CHARS+1, buf_cmd_params, 0, 0
941
edit2 edit_box 350, 220, 50, 0xffffff, 0xAA80, 0x0000ff, 0x0, 0x0, PATH_MAX_CHARS+1, buf_cmd_params, 0, 0
930
 
942
 
931
buf_cmd_line   dd 0
943
buf_cmd_line   dd 0 ;db MAX_HOTKEYS_NUM*PATH_MAX_CHARS dup(0)  ; !Make it dynamic!!!
932
buf_cmd_params dd 0
944
buf_cmd_params dd 0 ;db MAX_HOTKEYS_NUM*PATH_MAX_CHARS dup(0)  ; !Make it dynamic!!!
933
 
945
 
934
sys_path:
946
sys_path:
935
system_dir0 db '/sys/lib/'
947
system_dir0 db '/sys/lib/'
936
boxlib_name db 'box_lib.obj',0
948
boxlib_name db 'box_lib.obj',0
937
 
949
 
938
err_message_found_lib	db "Can't find box_lib.obj",0
950
err_message_found_lib	db "Can't find box_lib.obj",0
939
head_f_i:
951
head_f_i:
940
head_f_l		db 'System error',0
952
head_f_l		db 'System error',0
941
err_message_import	db 'Error on import box_lib.obj',0
953
err_message_import	db 'Error on import box_lib.obj',0
942
 
954
 
943
align 4
955
align 4
944
myimport:
956
myimport:
945
edit_box_draw	dd  aEdit_box_draw
957
edit_box_draw	dd  aEdit_box_draw
946
edit_box_key	dd  aEdit_box_key
958
edit_box_key	dd  aEdit_box_key
947
edit_box_mouse	dd  aEdit_box_mouse
959
edit_box_mouse	dd  aEdit_box_mouse
948
version_ed	dd  aVersion_ed
960
version_ed	dd  aVersion_ed
949
		dd  0,0
961
		dd  0,0
950
 
962
 
951
aEdit_box_draw	db 'edit_box',0
963
aEdit_box_draw	db 'edit_box',0
952
aEdit_box_key	db 'edit_box_key',0
964
aEdit_box_key	db 'edit_box_key',0
953
aEdit_box_mouse db 'edit_box_mouse',0
965
aEdit_box_mouse db 'edit_box_mouse',0
954
aVersion_ed	db 'version_ed',0
966
aVersion_ed	db 'version_ed',0
955
 
967
 
956
align 16
968
align 16
957
importTable:
969
importTable:
958
library 						\
970
library 						\
959
	libini, 'libini.obj';,                           \
971
	libini, 'libini.obj';,                           \
960
;        boxlib, 'boxlib.obj'                            \
972
;        boxlib, 'boxlib.obj',                           \
-
 
973
;        libio, 'libio.obj',                            \
961
 
974
 
962
;import  boxlib, \
975
;import  boxlib, \
963
;edit_box_draw  , 'edit_box', \
976
;edit_box_draw  , 'edit_box', \
964
;edit_box_key   , 'edit_box_key', \
977
;edit_box_key   , 'edit_box_key', \
965
;edit_box_mouse , 'edit_box_mouse', \
978
;edit_box_mouse , 'edit_box_mouse', \
966
;version_ed     , 'version_ed'
979
;version_ed     , 'version_ed'
967
 
980
 
968
 
981
 
969
import	libini, \
982
import	libini, \
970
	ini_get_str  ,'ini_get_str', \
983
	ini_get_str  ,'ini_get_str', \
971
	ini_set_str  ,'ini_set_str', \
984
	ini_set_str  ,'ini_set_str', \
972
	ini_get_int  ,'ini_get_int', \
985
	ini_get_int  ,'ini_get_int', \
973
	ini_set_int  ,'ini_set_int';, \
986
	ini_set_int  ,'ini_set_int';, \
974
;        ini_get_color,'ini_get_color', \
987
;        ini_get_color,'ini_get_color', \
975
;        ini_set_color,'ini_set_color'
988
;        ini_set_color,'ini_set_color'
976
 
989
 
977
 
990
 
978
;] Data structures for loadlib.mac and editbox_ex.mac
991
;] Data structures for loadlib.mac and editbox_ex.mac
979
 
992
 
980
InfoStructure:
993
InfoStructure:
981
		     dd      0x0     ; subfunction number
994
		     dd      0x0     ; subfunction number
982
		     dd      0x0     ; position in the file in bytes
995
		     dd      0x0     ; position in the file in bytes
983
		     dd      0x0     ; upper part of the position address
996
		     dd      0x0     ; upper part of the position address
984
		     dd      0x0     ; number of     bytes to read
997
		     dd      0x0     ; number of     bytes to read
985
		     dd      0x0     ; pointer to the buffer to write data
998
		     dd      0x0     ; pointer to the buffer to write data
986
		     db      0
999
		     db      0
987
		     dd      0	     ; pointer to the filename
1000
		     dd      0	     ; pointer to the filename
988
 
1001
 
989
 
1002
 
990
I_END:			  ; End of application code and data marker
1003
I_END:			  ; End of application code and data marker
991
 
1004
 
992
   rb 300 ;input thread stack size
1005
   rb 300 ;input thread stack size
993
input_thread_stack_top:
1006
input_thread_stack_top:
994
 
1007
 
995
ascii_keymap:
1008
ascii_keymap:
996
	     db 128 dup(?)
1009
	     db 128 dup(?)
997
ctrl_key_names db  'LShift LCtrl LAlt RAlt RCtrl RShift',0
1010
ctrl_key_names db  'LShift LCtrl LAlt RAlt RCtrl RShift',0
998
aPlus	       db  ' + ',0
1011
aPlus	       db  ' + ',0
999
aIni	       db  'mykey.ini',0
1012
aIni	       db  'mykey.ini',0
1000
aMain	       db  'main',0
1013
aMain	       db  'main',0
1001
aKeynum        db  'keynum',0
1014
aKeynum        db  'keynum',0
1002
aHotkey        db  'hotkey',0,0,0
1015
aHotkey        db  'hotkey',0,0,0
1003
aName	       db  'name',0
1016
aName	       db  'name',0
1004
aKeycode       db  'keycode',0
1017
aKeycode       db  'keycode',0
1005
aKeycodeName   db  'keycode_name',0
1018
aKeycodeName   db  'keycode_name',0
1006
aPath	       db  'path',0
1019
aPath	       db  'path',0
1007
aParam	       db  'param',0
1020
aParam	       db  'param',0
1008
aRamSaver      db  '/sys/rdsave',0
1021
aRamSaver      db  '/sys/rdsave',0
1009
 
1022
 
1010
app_path       rb  255
1023
app_path       rb  255
1011
ini_path       rb  255
1024
ini_path       rb  255
1012
 
1025
 
1013
Hotkeys:  ;(name = 32 b) + (modifiers = 3 b) + (keycode = 1 b) + (keycode_name = 64 b) = 100 bytes for 1 hotkey
1026
Hotkeys:  ;(name = 32 b) + (modifiers = 3 b) + (keycode = 1 b) = 36 byte for 1 hotkey
1014
    .names:
1027
    .names:
1015
	     db 'My1',0
1028
	     db 'My1',0
1016
	     rb 28
1029
	     rb 28
1017
	     db 'My2',0
1030
	     db 'My2',0
1018
	     rb 28
1031
	     rb 28
1019
	     db 'My3',0
1032
	     db 'My3',0
1020
	     rb 28
1033
	     rb 28
1021
	     rb MAX_HOTKEYS_NUM*32-3
1034
	     rb MAX_HOTKEYS_NUM*32-3
1022
    .codes:
1035
    .codes:
1023
	     dd MAX_HOTKEYS_NUM dup (0)
1036
	     dd MAX_HOTKEYS_NUM dup (0)
1024
    .code_names:
1037
    .code_names:
1025
	     rb MAX_HOTKEYS_NUM*64
1038
	     rb MAX_HOTKEYS_NUM*64
1026
 
1039
 
1027
it_ascii_keymap:
1040
it_ascii_keymap: