Subversion Repositories Kolibri OS

Rev

Rev 3424 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3418 mario79 1
;*****************************************************************************
2
; Macro for use 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
;*****************************************************************************
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
;---------------------------------------------------------------------
62
;*****************************************************************************
63
macro	ColorDialog_exit
64
{
65
popa
66
ret 4
67
}
68
;*****************************************************************************
69
macro	use_ColorDialog
70
{
71
ColorDialog:
72
cd_type			equ dword [ebp]	; 0-Palette&Tone
73
cd_procinfo		equ dword [ebp+4] ; Process info area for function 9
74
cd_com_area_name	equ dword [ebp+8] ; Name for shared area
75
cd_com_area		equ dword [ebp+12] ; Adress of shared area
76
cd_start_path		equ dword [ebp+16] ; Location path to ColorDialog
77
cd_draw_window		equ dword [ebp+20] ; Adress of procedure - draw_window
78
cd_status		equ dword [ebp+24] ; 0-Cancel, 1-Get color OK, 2-Use alternatives
79
cd_x_size		equ [ebp+28] ; Window X size
80
cd_x_start		equ [ebp+30] ; Window X position
81
cd_y_size		equ [ebp+32] ; Window y size
82
cd_y_start		equ [ebp+34] ; Window Y position
83
cd_color_type		equ [ebp+36] ; 0- RGB, 1 or other - reserved
84
cd_color		equ [ebp+40] ; Selected color
85
;*****************************************************************************
86
.init:
87
	pusha
88
	mov   ebp,dword [esp+36]
89
	mcall	9,cd_procinfo,-1
90
	mov	ebx,[ebx+30]
91
	mov	edi,cd_com_area_name
92
	add	edi,7
93
	std
94
	mov	ecx,4
95
@@:
96
	mov	al,bl
97
	and	al,1111b
98
	add	al,0x30
99
	stosb
100
	mov	al,bl
101
	shr	al,4
102
	and	al,1111b
103
	add	al,0x30
104
	stosb
105
	shr	ebx,8
106
	dec	ecx
107
	jnz	@r
108
	cld
109
 
110
	mcall	68,22,cd_com_area_name,4096,0x09
111
	mov	cd_com_area,eax
112
 
113
ColorDialog_exit
114
;*****************************************************************************
115
;*****************************************************************************
116
.start:
117
	pusha
118
	mov   ebp,dword [esp+36]
119
 
120
	mov	eax,cd_com_area
121
	test	eax,eax
122
	jz	.1
123
	mov	ebx,cd_type
124
	mov	[eax+2],bx
125
 
126
	mov	[eax],word 2	; start ColorDialog
127
 
128
	pusha
129
	mcall	9,cd_procinfo,-1
130
 
131
	mov	eax,[ebx+42] ;main window x size
132
	shr	eax,1
133
	add	eax,[ebx+34] ; main window x start
134
	mov	cx,cd_x_size
135
	shr	cx,1
136
	sub	ax,cx
137
	test	ax,cx
138
	test	eax,0x8000
139
	jz	@f
140
	xor	eax,eax
141
@@:
142
	mov	cd_x_start,ax
143
 
144
	mov	eax,[ebx+46] ;main window y size
145
	shr	eax,1
146
	add	eax,[ebx+38] ; main window y start
147
	mov	cx,cd_y_size
148
	shr	cx,1
149
	sub	ax,cx
150
	test	eax,0x8000
151
	jz	@f
152
	xor	eax,eax
153
@@:
154
	mov	cd_y_start,ax
155
	popa
156
 
157
	mov	ebx,dword cd_x_size
158
	mov	[eax+4],ebx
159
	mov	ebx,dword cd_y_size
160
	mov	[eax+8],ebx
161
 
162
;----------------------------------------------
163
	mov	ebx,cd_procinfo
164
	xor	eax,eax
165
	mov	edi,ebx
166
	mov	ecx,6
167
	cld
168
	rep	stosd
169
	mov	[ebx],dword 7
170
	mov	eax,cd_com_area_name
171
	mov	[ebx+8],eax
172
	mov	eax,cd_start_path
173
	mov	[ebx+21],eax
174
	mcall	70
175
 
176
	shr	eax,31
177
	test	eax,eax
178
	jnz	.1
179
;----------------------------------------------
180
.still:
181
; The main window of application sometimes
182
; is not present the really. For this reason
183
; not use func 10 and 23, because event 1
184
; is not cleared without call of func 0.
185
; In this case is suitable only func 5 and 11!
186
	mcall	5,10
187
	mcall	11
188
	cmp	eax,1
189
	je	.draw
190
	cmp	eax,2
191
	je	.key
192
	cmp	eax,3
193
	je	.button
194
	jmp	.no_draw
195
.key:
196
	mcall	2
197
	jmp	.no_draw
198
.button:
199
	mcall	17
200
	jmp	.no_draw
201
;----------------------------------------------
202
.draw:
203
	pusha
204
	call	cd_draw_window
205
	popa
206
;----------------------------------------------
207
	pusha
208
	call	.prepare_PID
209
	jz	@f
210
 
211
	mov	ecx,eax	; WINDOW SLOT
212
	mcall	18,7
213
	cmp	eax,ecx ; compare ACTIVE and WINDOW SLOT
214
	jne	@f
215
 
216
	mov	eax,cd_com_area
217
	mov	ecx,[eax+12]
218
	test	ecx,ecx
219
	jz	@f
220
	mcall	18,3
221
@@:
222
	popa
223
;----------------------------------------------
224
.no_draw:
225
	mov	eax,cd_com_area
226
	movzx	ebx,word [eax]
227
	test	ebx,ebx
228
	jz	.still
229
	cmp	ebx,3
230
	je	.2
231
	cmp	ebx,1
232
	jne	.still
233
;----------------------------------------------
234
; copy color type and value from shared area
235
	mov	eax,cd_com_area
236
	mov	ebx,[eax+16]
237
	mov	cd_color_type,ebx
238
	mov	ebx,[eax+20]
239
	mov	cd_color,ebx
240
 
241
	mov	cd_status,1
242
;----------------------------------------------
243
	jmp	.3
244
.2:
245
	mov	cd_status,0
246
	jmp	.3
247
.1:
248
	mov	cd_status,2
249
.3:
250
	mov	eax,cd_com_area
251
	mov	ebx,[eax+4]
252
	mov	cd_x_size,ebx
253
	mov	ebx,[eax+8]
254
	mov	cd_y_size, ebx
255
 
256
	call	.prepare_PID
257
	jz	@f
258
	mov	ecx,eax	; WINDOW SLOT
259
	mcall	18,3
260
@@:
261
ColorDialog_exit
262
;----------------------------------------------
263
.prepare_PID:
264
	mcall	9,cd_procinfo,-1
265
	mov	ecx,[ebx+30]	; PID
266
	mcall	18,21
267
	test	eax,eax
268
	ret
269
;----------------------------------------------
270
}
271
;*****************************************************************************