Subversion Repositories Kolibri OS

Rev

Rev 2087 | Rev 4816 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2087 dunkaist 1
use32
2
    org 0x0
3
    db  'MENUET01'
4
    dd  0x01,start,i_end,e_end,e_end,0,0
5
 
2088 dunkaist 6
include '../../../proc32.inc'
7
include '../../../macros.inc'
2087 dunkaist 8
 
2088 dunkaist 9
BUTTON_SIDE			equ	16	; button are squares
10
BUTTON_SPACE			equ	19	; space between cols and rows
11
BUTTON_ID_SHIFT			equ	2	; button_id = character + BUTTON_ID_SHIFT
12
TABLE_BEGIN_X			equ	2
13
TABLE_BEGIN_Y			equ	2
2087 dunkaist 14
 
2088 dunkaist 15
FOCUS_SQUARE_COLOR		equ	0x000080FF
16
PAGE_SWITCHER_BLINK_COLOR	equ	0x00808080
2087 dunkaist 17
 
2088 dunkaist 18
 
2087 dunkaist 19
start:
20
still:
2088 dunkaist 21
	mcall	10
2087 dunkaist 22
	dec	eax
2088 dunkaist 23
	jz	redraw
24
	dec	eax
25
	jz	key
2087 dunkaist 26
 
2088 dunkaist 27
button:
28
	mcall	17
29
	shr	eax, 8
2087 dunkaist 30
 
2088 dunkaist 31
	cmp	eax, 1
32
	je	quit
33
	cmp	ax, 0xFFAA			; page switcher
34
	je	.switch_page			; any button with a character
35
  .change_focus:
36
	mov	bl, [symbol_focused]
37
	mov	[symbol_unfocused], bl
38
	sub	ax, BUTTON_ID_SHIFT		; get the corresponding character
39
	mov	[symbol_focused], al
40
	stdcall	draw_table, 0
41
	call	draw_codes
42
	jmp	still
43
  .switch_page:
44
	movzx	bx, [symbol_start]
45
	add	bx, BUTTON_ID_SHIFT
46
	mov	cx, 128				; half of page
47
	mov	edx, 0x80000000
48
	mov	dx, bx
49
    @@:	mcall	8
50
	inc	edx
51
	dec	cx
52
	jnz	@b
2087 dunkaist 53
 
2088 dunkaist 54
    @@:	add	[symbol_start], 128		; change page
55
	add	[symbol_focused], 128
56
	stdcall	draw_table, 1			; 1 means redraw the whole table
57
	call	draw_codes
58
	stdcall	draw_page_switcher, 1		; 1 means dark color, for blinking
59
	mcall	5, 10
60
	stdcall	draw_page_switcher, 0		; 0 means usual light color
61
	jmp	still
2087 dunkaist 62
 
2088 dunkaist 63
redraw:
64
	mcall	9, proc_info, -1
65
	mcall	48, 3, sys_colors, 40
2087 dunkaist 66
 
2088 dunkaist 67
	mcall	12, 1
2087 dunkaist 68
 
2088 dunkaist 69
	mcall	48, 4				; get skin height
2087 dunkaist 70
	mov	ecx, 300*0x10000+184
2088 dunkaist 71
	add	ecx, eax
72
	mov	edx, 0x34000000
73
	or	edx, [sys_colors.work]
74
	mov	esi, 0x80000000
75
	or	esi, [sys_colors.grab_text]
76
	mcall	0, <300,315>, , , , window_title
77
	test	[proc_info.wnd_state], 0x04
78
	jnz	@f
2087 dunkaist 79
 
2088 dunkaist 80
	stdcall	draw_table, 1
2087 dunkaist 81
	call	draw_codes
2088 dunkaist 82
	stdcall	draw_page_switcher, 0
2087 dunkaist 83
 
2088 dunkaist 84
    @@:
85
	mcall	12, 2
86
	jmp	still
2087 dunkaist 87
 
88
key:
2088 dunkaist 89
	mcall	2
90
	cmp	ah, 0x09			; TAB key
91
	je	button.switch_page
2087 dunkaist 92
 
2088 dunkaist 93
	cmp	ah, 0xB0			; left
94
	jne	@f
95
	mov	bl, [symbol_focused]
96
	mov	[symbol_unfocused], bl
97
	dec	bl
98
	and	bl, 0x0f
99
	and	[symbol_focused], 0xf0
100
	or	[symbol_focused], bl
101
	stdcall	draw_table, 0
102
	call	draw_codes
103
	jmp	still
2087 dunkaist 104
 
2088 dunkaist 105
    @@:	cmp	ah, 0xB1			; down
106
	jne	@f
107
	mov	bl, [symbol_focused]
108
	mov	[symbol_unfocused], bl
109
	add	bl, 16
110
	and	bl, 0x70
111
	and	[symbol_focused], 0x8f
112
	or	[symbol_focused], bl
113
	stdcall	draw_table, 0
2087 dunkaist 114
	call	draw_codes
2088 dunkaist 115
	jmp	still
2087 dunkaist 116
 
2088 dunkaist 117
    @@:	cmp	ah, 0xB2			; up
118
	jne	@f
2087 dunkaist 119
	mov	bl, [symbol_focused]
120
	mov	[symbol_unfocused], bl
2088 dunkaist 121
	sub	bl, 16
122
	and	bl, 0x70
123
	and	[symbol_focused], 0x8f
124
	or	[symbol_focused], bl
125
	stdcall	draw_table, 0
2087 dunkaist 126
	call	draw_codes
2088 dunkaist 127
	jmp	still
2087 dunkaist 128
 
2088 dunkaist 129
    @@:	cmp	ah, 0xB3			; righ
130
	jne	@f
131
	mov	bl, [symbol_focused]
132
	mov	[symbol_unfocused], bl
133
	inc	bl
134
	and	bl, 0x0f
135
	and	[symbol_focused], 0xf0
136
	or	[symbol_focused], bl
137
	stdcall	draw_table, 0
138
	call	draw_codes
139
	jmp	still
140
	jne	@f
2087 dunkaist 141
 
2088 dunkaist 142
    @@:
143
	jmp	still
2087 dunkaist 144
 
2088 dunkaist 145
 
146
 
147
proc	draw_table _full_redraw
148
 
2087 dunkaist 149
	mov	al, [symbol_start]
150
	mov	[symbol_current], al
151
 
152
  .next_button:
153
 
2088 dunkaist 154
	xor	edi, edi			; character focus flag
2087 dunkaist 155
	mov	al, [symbol_current]
2088 dunkaist 156
	cmp	al, [symbol_focused]
157
	jne	@f
158
	inc	edi
159
    @@:	cmp	[_full_redraw], 1
160
	je	.draw
161
	cmp	al, [symbol_focused]
162
	je	.draw
163
	cmp	al, [symbol_unfocused]		; previously focused, should redraw to clear focus
164
	je	.draw
2087 dunkaist 165
	jmp	.skip				; skip button if it isn't (un)focused
166
 
167
  .draw:
168
	call	draw_button
169
  .skip:
2088 dunkaist 170
	mov	bl, [symbol_start]
171
	add	bl, 127				; end of current page
172
	cmp	[symbol_current], bl		; the last on page?
173
	jne	@f
174
	mov	[button_x], TABLE_BEGIN_X
175
	mov	[button_y], TABLE_BEGIN_Y
2087 dunkaist 176
	ret
177
    @@:	inc	[symbol_current]
178
	add	[button_x], BUTTON_SPACE
179
	cmp	[button_x], 306			; the last in row?
2088 dunkaist 180
	jne	.next_button
181
	add	[button_y], BUTTON_SPACE	; next row
182
	mov	[button_x], TABLE_BEGIN_X
2087 dunkaist 183
	jmp	.next_button
184
	ret
2088 dunkaist 185
endp
2087 dunkaist 186
 
187
 
2088 dunkaist 188
proc	draw_button
189
	mov	ebx, [button_x]
2087 dunkaist 190
	shl	ebx, 16
2088 dunkaist 191
	mov	bx, BUTTON_SIDE
192
	mov	ecx, [button_y]
2087 dunkaist 193
	shl	ecx, 16
2088 dunkaist 194
	mov	cx, BUTTON_SIDE
2087 dunkaist 195
	mov	edx, 0x80000000
2088 dunkaist 196
	mov	dl, [symbol_current]
197
	add	edx, BUTTON_ID_SHIFT
198
	mcall	8, , ,
199
	and	edx, 0x7FFFFFFF
2087 dunkaist 200
	or	edx, 0x20000000
2088 dunkaist 201
	mcall	, , , , [sys_colors.work_button]
2087 dunkaist 202
 
2088 dunkaist 203
	test	edi, edi			; is focused?
204
	jz	.symbol				; draw only character, not selection square
205
  .focus_frame:					; draw a blue square (selection), 8 segments
206
	mov	esi, [button_x]
207
	mov	edi, [button_y]
2087 dunkaist 208
 
2088 dunkaist 209
	mov	bx, si
2087 dunkaist 210
	shl	ebx, 16
2088 dunkaist 211
	mov	bx, si
212
	add	bx, BUTTON_SIDE
213
	mov	cx, di
2087 dunkaist 214
	shl	ecx, 16
2088 dunkaist 215
	mov	cx, di
216
	mcall	38, , , FOCUS_SQUARE_COLOR
217
	add	ecx, 0x00010001
218
	mcall
219
	add	ecx, (BUTTON_SIDE-2)*0x10000+(BUTTON_SIDE-2)
220
	mcall
221
	add	ecx, 0x00010001
222
	mcall
2087 dunkaist 223
 
2088 dunkaist 224
	mov	bx, si
2087 dunkaist 225
	shl	ebx, 16
2088 dunkaist 226
	mov	bx, si
227
	mov	cx, di
2087 dunkaist 228
	shl	ecx, 16
2088 dunkaist 229
	mov	cx, di
230
	add	ecx, 2*0x10000+(BUTTON_SIDE-2)
231
	mcall	38, , ,
232
	add	ebx, 0x00010001
233
	mcall
234
	add	ebx, (BUTTON_SIDE-2)*0x10000+(BUTTON_SIDE-2)
235
	mcall
236
	add	ebx, 0x00010001
237
	mcall
2087 dunkaist 238
 
2088 dunkaist 239
  .symbol:
240
	mov	ebx, [button_x]
241
	add	ebx, 6
2087 dunkaist 242
	shl	ebx, 16
2088 dunkaist 243
	add	ebx, [button_y]
244
	add	ebx, 5
245
	mcall	4, , [sys_colors.work_button_text], symbol_current, 1
2087 dunkaist 246
 
2088 dunkaist 247
	ret
248
endp
2087 dunkaist 249
 
250
 
2088 dunkaist 251
proc	draw_page_switcher _blinking
2087 dunkaist 252
 
2088 dunkaist 253
	mcall	8, , , 0x8000FFAA
2087 dunkaist 254
 
2088 dunkaist 255
	mov	esi, [sys_colors.work_button]
256
	cmp	[_blinking], 1			; blinking?
257
	jne	@f
258
	mov	esi, PAGE_SWITCHER_BLINK_COLOR
259
    @@:	mcall	, <2,60>, <157,19>, 0x2000FFAA
2087 dunkaist 260
 
261
	mov	ecx, 0x80000000
2088 dunkaist 262
	or	ecx, [sys_colors.work_button_text]
2087 dunkaist 263
	mov	edx, string_000_127
2088 dunkaist 264
	cmp	[symbol_start], 0		; first page?
265
	je	@f
266
	mov	edx, string_128_255		; ok, the second one
267
    @@:	mcall	4, <11,164>,
2087 dunkaist 268
	ret
2088 dunkaist 269
endp
2087 dunkaist 270
 
271
 
2088 dunkaist 272
proc	draw_codes
2087 dunkaist 273
 
274
	mov	ecx, 0x80000000
2088 dunkaist 275
	or	ecx, [sys_colors.work_text]
276
	mcall	4, <80,164>, , string_ASCII_CODE
277
	mcall	, <180,164>, , string_ASCII_HEX_CODE
278
	movzx	ecx, [symbol_focused]
279
	mov	esi, 0x40000000
280
	or	esi, [sys_colors.work_text]
281
	mcall	47, 0x00030000, , <152,164>, , [sys_colors.work]
282
	mcall	, 0x00020100, , <276,164>,
2087 dunkaist 283
 
284
	ret
2088 dunkaist 285
endp
2087 dunkaist 286
 
287
 
288
quit:
2088 dunkaist 289
	mcall	-1
2087 dunkaist 290
 
291
 
2088 dunkaist 292
szZ window_title		,'ASCIIVju v0.4'
293
szZ string_000_127		,'000-127'
294
szZ string_128_255		,'128-255'
295
szZ string_ASCII_CODE		,'ASCII Code:    '
296
szZ string_ASCII_HEX_CODE	,'ASCII Hex-Code:   '
2087 dunkaist 297
 
298
button_x		dd 2
299
button_y		dd 2
300
 
301
symbol_current		db 0
302
symbol_start		db 0
303
 
304
symbol_unfocused	db 0
305
symbol_focused		db 0
306
i_end:
2088 dunkaist 307
proc_info		process_information
308
sys_colors		system_colors
309
rb 0x400					;stack
2087 dunkaist 310
e_end: