Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
3380 mario79 1
;*****************************************************************************
2
; Color Dialog - for Kolibri OS
3
; Copyright (c) 2013, Marat Zakiyanov aka Mario79, aka Mario
4
; All rights reserved.
5
;
6
; Redistribution and use in source and binary forms, with or without
7
; modification, are permitted provided that the following conditions are met:
8
;        * Redistributions of source code must retain the above copyright
9
;          notice, this list of conditions and the following disclaimer.
10
;        * Redistributions in binary form must reproduce the above copyright
11
;          notice, this list of conditions and the following disclaimer in the
12
;          documentation and/or other materials provided with the distribution.
13
;        * Neither the name of the  nor the
14
;          names of its contributors may be used to endorse or promote products
15
;          derived from this software without specific prior written permission.
16
;
17
; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
18
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
; DISCLAIMED. IN NO EVENT SHALL  BE LIABLE FOR ANY
21
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
;*****************************************************************************
3417 mario79 28
;---------------------------------------------------------------------
29
;Some documentation for memory
30
;
31
;area name db 'FFFFFFFF_color_dialog',0 ; FFFFFFFF = PID
32
;
33
; communication area data
34
; flag  ; +0
35
; dw 0   ; 0 - empty, 1 - OK, color selected
36
;          2 - use another method/not found program, 3 - cancel
37
;
38
; type of dialog:  0-Palette&Tone
39
; dw 0 ; +2
40
;
41
; window X size ; +4
42
; dw 0
43
;
44
; window X position ; +6
45
; dw 0
46
;
47
; window y size ; +8
48
; dw 0
49
;
50
; window Y position ; +10
51
; dw 0
52
;
53
; ColorDialog WINDOW SLOT ; +12
54
; dd 0
55
;
56
; Color type ; +16
57
; dd 0
58
;
59
; Color value ; +20
60
; dd 0
61
;---------------------------------------------------------------------
3380 mario79 62
  use32
63
  org	 0x0
64
 
65
  db	 'MENUET01'
66
  dd	 0x01
67
  dd	 START
68
  dd	 IM_END
69
  dd	 I_END
70
  dd	 stacktop
3417 mario79 71
  dd	 param
3380 mario79 72
  dd	 0x0
73
;---------------------------------------------------------------------
74
include '../../macros.inc'
75
;include 'lang.inc'
3417 mario79 76
;include 'debug.inc'
3380 mario79 77
;---------------------------------------------------------------------
78
p_start_x = 10
79
p_start_y = 10
80
 
81
p_size_x = 20
82
p_size_y = 256
83
;--------------------------------------
84
t_start_x = 40
85
t_start_y = 10
86
;--------------------------------------
87
w_start_x = 200
88
w_start_y = 200
89
 
90
w_size_x = 400
91
w_size_y = 350
92
;--------------------------------------
93
c_start_x = t_start_x + p_size_y + 10
94
c_start_y = 10
95
 
96
c_size_x = 40
97
c_size_y = 20
98
;---------------------------------------------------------------------
99
 
100
START:
101
	mcall	68,11
3417 mario79 102
	mcall	66,1,1
103
	mcall	40,0x27
104
	call	get_communication_area
105
 
106
	call	get_active_pocess
3380 mario79 107
 
108
	xor	eax,eax
109
	mov	al,p_size_x
110
	mov	[palette_SIZE_X],eax
111
	mov	ax,p_size_y
112
	mov	[palette_SIZE_Y],eax
113
	mov	[tone_SIZE_X],eax
114
	mov	[tone_SIZE_Y],eax
115
	mov	eax,0xff0000
116
	mov	[tone_color],eax
117
	mov	[selected_color],eax
118
;--------------------------------------
119
	mov	ecx,[palette_SIZE_Y]
120
	imul	ecx,[palette_SIZE_X]
121
	lea	ecx,[ecx*3]
122
	inc	ecx	;reserve for stosd
123
	mcall	68,12
124
	mov	[palette_area],eax
125
;--------------------------------------
126
	call	create_palette
127
;--------------------------------------
128
	mov	ecx,[tone_SIZE_Y]
129
	imul	ecx,[tone_SIZE_X]
130
	lea	ecx,[ecx*3]
131
	inc	ecx	;reserve for stosd
132
	mcall	68,12
133
	mov	[tone_area],eax
134
;--------------------------------------
135
	call    create_tone
136
;---------------------------------------------------------------------
137
align 4
138
red:
139
	call	draw_window
140
;---------------------------------------------------------------------
141
align 4
142
still:
143
	mcall	10
144
 
145
	cmp	eax,1
146
	je	red
147
 
148
	cmp	eax,2
149
	je	key
150
 
151
	cmp	eax,3
152
	jne	still
153
;---------------------------------------------------------------------
154
align 4
155
button:
156
	mcall	17
157
 
158
	cmp	ah, 2
159
	je	palette_button
160
 
161
	cmp	ah, 3
162
	je	tone_button
3417 mario79 163
 
164
	cmp	ah, 4
165
	je	color_button
3380 mario79 166
 
167
	cmp	ah, 1
168
	jne	still
169
 
170
.exit:
3417 mario79 171
	mov	eax,[communication_area]
172
	mov	[eax],word 3
173
; dps "CD flag value: cancel "
174
 
175
.exit_1:
176
 
177
	mov	ax,[eax]
178
	and	eax,0xffff
179
; dps "CD flag value: "
180
; dpd eax
181
; newline
182
 
3380 mario79 183
	mcall	-1
184
;---------------------------------------------------------------------
185
align 4
3417 mario79 186
get_communication_area:
187
	xor	eax,eax
188
	mov	al,[param]
189
	test	eax,eax
190
	jz	@f
191
	mcall	68,22,param,,0x01
192
	mov	[communication_area],eax
193
;	movzx	ebx,word [eax+2]
194
;	mov	[color_dialog_type],ebx
195
 
196
;	mov	ebx,[eax+4]
197
;	cmp	bx,word x_minimal_size ;300
198
;	jb	@f
199
;	mov	[window_x],ebx
200
;	mov	ebx,[eax+8]
201
;	cmp	bx,word y_minimal_size ;200
202
;	jb	@f
203
;	mov	[window_y],ebx
204
@@:
205
	ret
206
;---------------------------------------------------------------------
207
align 4
208
get_active_pocess:
209
	mcall	9,procinfo,-1
210
	mov	ecx,[ebx+30]	; PID
211
	mcall	18,21
212
	mov	[active_process],eax	; WINDOW SLOT
213
	mov	ebx,[communication_area]
214
	test	ebx,ebx
215
	jz	.1
216
	mov	[ebx+12],eax	; WINDOW SLOT to com. area
217
.1:
218
	ret
219
;---------------------------------------------------------------------
220
align 4
3380 mario79 221
palette_button:
222
	mcall	37,1
223
	and	eax,0xffff
224
	sub	eax,p_start_y
225
	imul	eax,p_size_x
226
	dec	eax
227
	lea	eax,[eax+eax*2]
228
	add	eax,[palette_area]
229
	mov	eax,[eax]
230
	mov	[tone_color],eax
231
	mov	[selected_color],eax
232
	call	create_and_draw_tone
233
	call	draw_selected_color
234
	jmp	still
235
;---------------------------------------------------------------------
236
align 4
237
tone_button:
238
	mcall	37,1
239
	mov	ebx,eax
240
	and	eax,0xffff
241
	shr	ebx,16
242
	sub	eax,t_start_y
243
	imul	eax,p_size_y
244
	sub	ebx,t_start_x
245
	add	eax,ebx
246
	lea	eax,[eax+eax*2]
247
	add	eax,[tone_area]
248
	mov	eax,[eax]
249
	mov	[selected_color],eax
250
	call	draw_selected_color
251
	jmp	still
252
;---------------------------------------------------------------------
253
align 4
3417 mario79 254
color_button:
255
	mov	eax,[communication_area]
256
	mov	[eax],word 1
257
	mov	ebx,[selected_color]
258
	mov	[eax+20],ebx
259
; dps "CD flag value: OK "
260
	jmp	button.exit_1
261
;---------------------------------------------------------------------
262
align 4
3380 mario79 263
key:
264
	mcall	2
265
	jmp	still
266
;---------------------------------------------------------------------
267
align 4
268
draw_selected_color:
269
	mcall	13,,,[selected_color]
3417 mario79 270
	mcall	8,,,0x60000004
3380 mario79 271
	ret
272
;---------------------------------------------------------------------
273
align 4
274
create_and_draw_tone:
275
	call    create_tone
276
	call    draw_tone
277
	ret
278
;---------------------------------------------------------------------
279
align 4
280
draw_tone:
281
	mcall	65,[tone_area],<[tone_SIZE_X],[tone_SIZE_Y]>,,24
282
	ret
283
;---------------------------------------------------------------------
284
align 4
285
draw_window:
286
	mcall	12,1
287
	mcall	0, , , 0x33AABBCC,,title
288
	mcall	8,,,0x60000002
289
	mcall	,,,0x60000003
290
	mcall	65,[palette_area],<[palette_SIZE_X],[palette_SIZE_Y]>,,24
291
	call	draw_tone
292
	call	draw_selected_color
293
	mcall	12,2
294
	ret
295
;---------------------------------------------------------------------
296
include 'palette.inc'
297
;---------------------------------------------------------------------
298
include 'tone.inc'
299
;---------------------------------------------------------------------
300
include 'i_data.inc'
301
;---------------------------------------------------------------------
302
IM_END:
303
;---------------------------------------------------------------------
304
include 'u_data.inc'
305
;---------------------------------------------------------------------
306
I_END:
307
;---------------------------------------------------------------------