Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3470 mario79 1
;**************************************************************
2
; Frame Macro 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
macro frame_start
29
{
30
	pusha
31
	mov	edi,dword [esp+36]
32
}
33
;*****************************************************************************
34
macro frame_exit
35
{
36
popa
37
ret 4
38
}
39
;*****************************************************************************
40
macro use_frame
41
{
42
frame:
43
fr_type			equ [edi]	;dword
44
fr_size_x		equ [edi+4]	;word
45
fr_start_x		equ [edi+6]	;word
46
fr_size_y		equ [edi+8]	;word
47
fr_start_y		equ [edi+10]	;word
48
fr_ext_fr_col		equ [edi+12]	;dword
49
fr_int_fr_col		equ [edi+16]	;dword
50
fr_draw_text_flag	equ [edi+20]	;dword 0-not,1-yes
51
fr_text_pointer		equ [edi+24]	;dword
52
fr_text_position	equ [edi+28]	;dword 0-up,1-bottom
53
fr_font_number		equ [edi+32]	;dword 0-monospace,1-variable
54
fr_font_size_y		equ [edi+36]	;dword
55
fr_font_color		equ [edi+40]	;dword
56
fr_font_backgr_color	equ [edi+44]	;dword
57
;*****************************************************************************
58
;*****************************************************************************
59
; draw event
60
;*****************************************************************************
61
;*****************************************************************************
62
align 4
63
.draw:
64
frame_start
65
;-------------------------------------
66
; in
67
; ebx = [coordinate on axis x]*65536 + [size on axis x]
68
; ecx = [coordinate on axis y]*65536 + [size on axis y]
69
;--------------------------------------
70
; top
71
	mov	bx,fr_start_x
72
	shl	ebx,16
73
	mov	bx,fr_start_x
74
	add	bx,fr_size_x
3471 mario79 75
	dec	bx
3470 mario79 76
 
77
	mov	cx,fr_start_y
78
	shl	ecx,16
79
	mov	cx,fr_start_y
80
 
81
	mcall	38,,,fr_ext_fr_col
82
 
83
	add	ecx,1 shl 16 +1
84
	add	ebx,1 shl 16
85
	dec	ebx
86
 
87
	mcall	,,,fr_int_fr_col
88
;--------------------------------------
89
; bottom
90
	mov	bx,fr_start_x
91
	shl	ebx,16
92
	mov	bx,fr_start_x
93
	add	bx,fr_size_x
3471 mario79 94
	dec	bx
3470 mario79 95
 
96
	mov	cx,fr_start_y
97
	add	cx,fr_size_y
3471 mario79 98
	dec	cx
3470 mario79 99
	shl	ecx,16
100
	mov	cx,fr_start_y
101
	add	cx,fr_size_y
3471 mario79 102
	dec	cx
3470 mario79 103
 
104
	mcall	,,,fr_ext_fr_col
105
 
106
	sub	ecx,1 shl 16 +1
107
	add	ebx,1 shl 16
108
	dec	ebx
109
 
110
	mcall	,,,fr_int_fr_col
111
;--------------------------------------
112
; left
113
	mov	bx,fr_start_x
114
	shl	ebx,16
115
	mov	bx,fr_start_x
116
 
117
	mov	cx,fr_start_y
118
	shl	ecx,16
119
	mov	cx,fr_start_y
120
	add	cx,fr_size_y
3471 mario79 121
	dec	cx
3470 mario79 122
 
123
	mcall	,,,fr_ext_fr_col
124
 
125
	add	ebx,1 shl 16 +1
126
	add	ecx,1 shl 16
127
	dec	ecx
128
 
129
	mcall	,,,fr_int_fr_col
130
 
131
;--------------------------------------
132
; right
133
	mov	bx,fr_start_x
134
	add	bx,fr_size_x
3471 mario79 135
	dec	bx
3470 mario79 136
	shl	ebx,16
137
	mov	bx,fr_start_x
138
	add	bx,fr_size_x
3471 mario79 139
	dec	bx
3470 mario79 140
 
141
	mov	cx,fr_start_y
142
	shl	ecx,16
143
	mov	cx,fr_start_y
144
	add	cx,fr_size_y
3471 mario79 145
	dec	cx
3470 mario79 146
 
147
	mcall	,,,fr_ext_fr_col
148
 
149
	sub	ebx,1 shl 16 +1
150
	add	ecx,1 shl 16
151
	dec	ecx
152
 
153
	mcall	,,,fr_int_fr_col
154
;----------------------------------------------------------------------
155
	cmp	fr_draw_text_flag,dword 0
156
	je	.exit
157
 
158
	mov	ecx,0xC0000000
159
	mov	eax,fr_font_number
160
	and	eax,11b
161
	shl	eax,28
162
	add	ecx,eax
163
	mov	eax,fr_font_color
164
	and	eax,0xffffff
165
	add	ecx,eax
166
 
167
	mov	edx,fr_text_pointer
168
 
169
	mov	eax,fr_font_backgr_color
170
	and	eax,0xffffff
171
 
172
	xor	esi,esi
173
 
174
	mov	bx,fr_start_x
175
	add	bx,10
176
	shl	ebx,16
177
	mov	bx,fr_font_size_y
178
	shr	bx,1
179
 
180
	not	bx
181
	add	bx,fr_start_y
182
 
183
	test	fr_font_size_y,word 1b
184
	jz	@f
185
 
186
	inc	bx
187
;--------------------------------------
188
align 4
189
@@:
190
	cmp	fr_text_position,dword 0
191
	je	.draw_1
192
 
193
	add	bx,fr_size_y
194
;--------------------------------------
195
align 4
196
.draw_1:
197
	push	edi
198
	mov	edi,eax
199
	mcall	4
200
	pop	edi
201
;----------------------------------------------------------------------
202
align 4
203
.exit:
204
frame_exit
205
}
206
;*****************************************************************************