Subversion Repositories Kolibri OS

Rev

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

Rev 2748 Rev 2758
1
format MS COFF
1
format MS COFF
2
public EXPORTS
2
public EXPORTS
3
section '.flat' code readable align 16
3
section '.flat' code readable align 16
4
 
4
 
5
include '../../../../macros.inc'
5
include '../../../../macros.inc'
6
include '../../../../proc32.inc'
6
include '../../../../proc32.inc'
7
 
7
 
8
;-----------------------------------------------------------------------------
8
;-----------------------------------------------------------------------------
9
mem.alloc   dd ? ;äã­ªæ¨ï ¤«ï ¢ë¤¥«¥­¨ï ¯ ¬ïâ¨
9
mem.alloc   dd ? ;äã­ªæ¨ï ¤«ï ¢ë¤¥«¥­¨ï ¯ ¬ïâ¨
10
mem.free    dd ? ;äã­ªæ¨ï ¤«ï ®á¢®¡®¦¤¥­¨ï ¯ ¬ïâ¨
10
mem.free    dd ? ;äã­ªæ¨ï ¤«ï ®á¢®¡®¦¤¥­¨ï ¯ ¬ïâ¨
11
mem.realloc dd ? ;äã­ªæ¨ï ¤«ï ¯¥à¥à á¯à¥¤¥«¥­¨ï ¯ ¬ïâ¨
11
mem.realloc dd ? ;äã­ªæ¨ï ¤«ï ¯¥à¥à á¯à¥¤¥«¥­¨ï ¯ ¬ïâ¨
12
dll.load    dd ?
12
dll.load    dd ?
13
 
13
 
14
BUF_STRUCT_SIZE equ 21
14
BUF_STRUCT_SIZE equ 21
15
buf2d_data equ dword[edi] ;¤ ­­ë¥ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
15
buf2d_data equ dword[edi] ;¤ ­­ë¥ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
16
buf2d_w equ dword[edi+8] ;è¨à¨­  ¡ãä¥à 
16
buf2d_w equ dword[edi+8] ;è¨à¨­  ¡ãä¥à 
17
buf2d_h equ dword[edi+12] ;¢ëá®â  ¡ãä¥à 
17
buf2d_h equ dword[edi+12] ;¢ëá®â  ¡ãä¥à 
18
buf2d_l equ word[edi+4]
18
buf2d_l equ word[edi+4]
19
buf2d_t equ word[edi+6] ;®âáâ㯠ᢥàåã
19
buf2d_t equ word[edi+6] ;®âáâ㯠ᢥàåã
20
buf2d_size_lt equ dword[edi+4] ;®âáâ㯠᫥¢  ¨ á¯à ¢  ¤«ï ¡ãä¥à 
20
buf2d_size_lt equ dword[edi+4] ;®âáâ㯠᫥¢  ¨ á¯à ¢  ¤«ï ¡ãä¥à 
21
buf2d_color equ dword[edi+16] ;梥â ä®­  ¡ãä¥à 
21
buf2d_color equ dword[edi+16] ;梥â ä®­  ¡ãä¥à 
22
buf2d_bits equ byte[edi+20] ;ª®«¨ç¥á⢮ ¡¨â ¢ 1-© â®çª¥ ¨§®¡à ¦¥­¨ï
22
buf2d_bits equ byte[edi+20] ;ª®«¨ç¥á⢮ ¡¨â ¢ 1-© â®çª¥ ¨§®¡à ¦¥­¨ï
23
 
23
 
24
struct buf_2d_header
24
struct buf_2d_header
25
	img_data dd ?
25
	img_data dd ?
26
	left dw ? ;+4 left
26
	left dw ? ;+4 left
27
	top dw ? ;+6 top
27
	top dw ? ;+6 top
28
	size_x dd ? ;+8 w
28
	size_x dd ? ;+8 w
29
	size_y dd ? ;+12 h
29
	size_y dd ? ;+12 h
30
	color dd ? ;+16 color
30
	color dd ? ;+16 color
31
	bit_pp db ? ;+21 bit in pixel
31
	bit_pp db ? ;+21 bit in pixel
32
ends
32
ends
33
 
33
 
34
macro swap v1, v2 {
34
macro swap v1, v2 {
35
  push v1
35
  push v1
36
  push v2
36
  push v2
37
  pop v1
37
  pop v1
38
  pop v2
38
  pop v2
39
}
39
}
40
 
40
 
41
;ä« £¨, ¤«ï ä㭪樨 ®¡à¥§ ­¨ï ¡ãä¥à 
41
;ä« £¨, ¤«ï ä㭪樨 ®¡à¥§ ­¨ï ¡ãä¥à 
42
BUF2D_OPT_CROP_TOP equ 1 ;®¡à¥§ª  ᢥàåã
42
BUF2D_OPT_CROP_TOP equ 1 ;®¡à¥§ª  ᢥàåã
43
BUF2D_OPT_CROP_LEFT equ 2 ;®¡à¥§ª  á«¥¢ 
43
BUF2D_OPT_CROP_LEFT equ 2 ;®¡à¥§ª  á«¥¢ 
44
BUF2D_OPT_CROP_BOTTOM equ 4 ;®¡à¥§ª  á­¨§ã
44
BUF2D_OPT_CROP_BOTTOM equ 4 ;®¡à¥§ª  á­¨§ã
45
BUF2D_OPT_CROP_RIGHT equ 8 ;®¡à¥§ª  á¯à ¢ 
45
BUF2D_OPT_CROP_RIGHT equ 8 ;®¡à¥§ª  á¯à ¢ 
46
BUF2D_BIT_OPT_CROP_TOP equ 0
46
BUF2D_BIT_OPT_CROP_TOP equ 0
47
BUF2D_BIT_OPT_CROP_LEFT equ 1
47
BUF2D_BIT_OPT_CROP_LEFT equ 1
48
BUF2D_BIT_OPT_CROP_BOTTOM equ 2
48
BUF2D_BIT_OPT_CROP_BOTTOM equ 2
49
BUF2D_BIT_OPT_CROP_RIGHT equ 3
49
BUF2D_BIT_OPT_CROP_RIGHT equ 3
50
 
50
 
51
vox_offs_tree_table equ 4
51
vox_offs_tree_table equ 4
52
vox_offs_data equ 12
52
vox_offs_data equ 12
53
 
53
 
54
;input:
54
;input:
55
; eax = 㪠§ â¥«ì ­  äã­ªæ¨î ¢ë¤¥«¥­¨ï ¯ ¬ïâ¨
55
; eax = 㪠§ â¥«ì ­  äã­ªæ¨î ¢ë¤¥«¥­¨ï ¯ ¬ïâ¨
56
; ebx = ... ®á¢®¡®¦¤¥­¨ï ¯ ¬ïâ¨
56
; ebx = ... ®á¢®¡®¦¤¥­¨ï ¯ ¬ïâ¨
57
; ecx = ... ¯¥à¥à á¯à¥¤¥«¥­¨ï ¯ ¬ïâ¨
57
; ecx = ... ¯¥à¥à á¯à¥¤¥«¥­¨ï ¯ ¬ïâ¨
58
; edx = ... § £à㧪¨ ¡¨¡«¨®â¥ª¨ (¯®ª  ­¥ ¨á¯®«ì§ã¥âáï)
58
; edx = ... § £à㧪¨ ¡¨¡«¨®â¥ª¨ (¯®ª  ­¥ ¨á¯®«ì§ã¥âáï)
59
align 16
59
align 16
60
lib_init:
60
lib_init:
61
	mov dword[mem.alloc], eax
61
	mov dword[mem.alloc], eax
62
	mov dword[mem.free], ebx
62
	mov dword[mem.free], ebx
63
	mov dword[mem.realloc], ecx
63
	mov dword[mem.realloc], ecx
64
	mov dword[dll.load], edx
64
	mov dword[dll.load], edx
65
	ret
65
	ret
66
 
66
 
67
;input:
67
;input:
68
; ebx = coord x
68
; ebx = coord x
69
; ecx = coord y
69
; ecx = coord y
70
; edx = pixel color
70
; edx = pixel color
71
; edi = pointer to buffer struct
71
; edi = pointer to buffer struct
72
align 4
72
align 4
73
draw_pixel:
73
draw_pixel:
74
	;cmp buf2d_bits,24
74
	;cmp buf2d_bits,24
75
	;jne @f
75
	;jne @f
76
	bt ebx,31
76
	bt ebx,31
77
	jc @f
77
	jc @f
78
	bt ecx,31
78
	bt ecx,31
79
	jc @f
79
	jc @f
80
	cmp ebx,buf2d_w
80
	cmp ebx,buf2d_w
81
	jge @f
81
	jge @f
82
	cmp ecx,buf2d_h
82
	cmp ecx,buf2d_h
83
	jge @f
83
	jge @f
84
	push esi
84
	push esi
85
		mov esi,buf2d_w ;size x
85
		mov esi,buf2d_w ;size x
86
		imul esi,ecx ;size_x*y
86
		imul esi,ecx ;size_x*y
87
		add esi,ebx	 ;size_x*y+x
87
		add esi,ebx	 ;size_x*y+x
88
		cmp buf2d_bits,8
88
		cmp buf2d_bits,8
89
		je .beg8
89
		je .beg8
90
		cmp buf2d_bits,32
90
		cmp buf2d_bits,32
91
		je .beg32
91
		je .beg32
92
			lea esi,[esi+esi*2] ;(size_x*y+x)*3
92
			lea esi,[esi+esi*2] ;(size_x*y+x)*3
93
			add esi,buf2d_data  ;ptr+(size_x*y+x)*3
93
			add esi,buf2d_data  ;ptr+(size_x*y+x)*3
94
			mov word[esi],dx ;copy pixel color
94
			mov word[esi],dx ;copy pixel color
95
			ror edx,16
95
			ror edx,16
96
			mov byte[esi+2],dl
96
			mov byte[esi+2],dl
97
			ror edx,16
97
			ror edx,16
98
			jmp .end_draw
98
			jmp .end_draw
99
		.beg8: ;à¨á®¢ ­¨¥ â®çª¨ ¢ 8 ¡¨â­®¬ ¡ãä¥à¥
99
		.beg8: ;à¨á®¢ ­¨¥ â®çª¨ ¢ 8 ¡¨â­®¬ ¡ãä¥à¥
100
			add esi,buf2d_data  ;ptr+(size_x*y+x)
100
			add esi,buf2d_data  ;ptr+(size_x*y+x)
101
			mov byte[esi],dl
101
			mov byte[esi],dl
102
			jmp .end_draw
102
			jmp .end_draw
103
		.beg32: ;à¨á®¢ ­¨¥ â®çª¨ ¢ 32 ¡¨â­®¬ ¡ãä¥à¥
103
		.beg32: ;à¨á®¢ ­¨¥ â®çª¨ ¢ 32 ¡¨â­®¬ ¡ãä¥à¥
104
			shl esi,2
104
			shl esi,2
105
			add esi,buf2d_data  ;ptr+(size_x*y+x)
105
			add esi,buf2d_data  ;ptr+(size_x*y+x)
106
			mov dword[esi],edx
106
			mov dword[esi],edx
107
		.end_draw:
107
		.end_draw:
108
	pop esi
108
	pop esi
109
	@@:
109
	@@:
110
	ret
110
	ret
111
 
111
 
112
;input:
112
;input:
113
; ebx = coord x
113
; ebx = coord x
114
; ecx = coord y
114
; ecx = coord y
115
; edi = pointer to buffer struct
115
; edi = pointer to buffer struct
116
;output:
116
;output:
117
; eax = 梥â â®çª¨
117
; eax = 梥â â®çª¨
118
; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
118
; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
119
align 4
119
align 4
120
get_pixel_8:
120
get_pixel_8:
121
	mov eax,0xffffffff
121
	mov eax,0xffffffff
122
 
122
 
123
	bt ebx,31
123
	bt ebx,31
124
	jc @f
124
	jc @f
125
	bt ecx,31
125
	bt ecx,31
126
	jc @f
126
	jc @f
127
	cmp ebx,buf2d_w
127
	cmp ebx,buf2d_w
128
	jge @f
128
	jge @f
129
	cmp ecx,buf2d_h
129
	cmp ecx,buf2d_h
130
	jge @f
130
	jge @f
131
	push esi
131
	push esi
132
		mov esi,buf2d_w ;size x
132
		mov esi,buf2d_w ;size x
133
		imul esi,ecx ;size_x*y
133
		imul esi,ecx ;size_x*y
134
		add esi,ebx	 ;size_x*y+x
134
		add esi,ebx	 ;size_x*y+x
135
		add esi,buf2d_data  ;ptr+(size_x*y+x)
135
		add esi,buf2d_data  ;ptr+(size_x*y+x)
136
 
136
 
137
		movzx eax,byte[esi] ;copy pixel color
137
		movzx eax,byte[esi] ;copy pixel color
138
	pop esi
138
	pop esi
139
	@@:
139
	@@:
140
	ret
140
	ret
141
 
141
 
142
;input:
142
;input:
143
; ebx = coord x
143
; ebx = coord x
144
; ecx = coord y
144
; ecx = coord y
145
; edi = pointer to buffer struct
145
; edi = pointer to buffer struct
146
;output:
146
;output:
147
; eax = 梥â â®çª¨
147
; eax = 梥â â®çª¨
148
; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
148
; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
149
align 4
149
align 4
150
get_pixel_24:
150
get_pixel_24:
151
	mov eax,0xffffffff
151
	mov eax,0xffffffff
152
 
152
 
153
	bt ebx,31
153
	bt ebx,31
154
	jc @f
154
	jc @f
155
	bt ecx,31
155
	bt ecx,31
156
	jc @f
156
	jc @f
157
	cmp ebx,buf2d_w
157
	cmp ebx,buf2d_w
158
	jge @f
158
	jge @f
159
	cmp ecx,buf2d_h
159
	cmp ecx,buf2d_h
160
	jge @f
160
	jge @f
161
	push esi
161
	push esi
162
		mov esi,buf2d_w ;size x
162
		mov esi,buf2d_w ;size x
163
		imul esi,ecx ;size_x*y
163
		imul esi,ecx ;size_x*y
164
		add esi,ebx	 ;size_x*y+x
164
		add esi,ebx	 ;size_x*y+x
165
		lea esi,[esi+esi*2] ;(size_x*y+x)*3
165
		lea esi,[esi+esi*2] ;(size_x*y+x)*3
166
		add esi,buf2d_data  ;ptr+(size_x*y+x)*3
166
		add esi,buf2d_data  ;ptr+(size_x*y+x)*3
167
 
167
 
168
		xor eax,eax
168
		xor eax,eax
169
		mov ax,word[esi] ;copy pixel color
169
		mov ax,word[esi] ;copy pixel color
170
		ror eax,16
170
		ror eax,16
171
		mov al,byte[esi+2]
171
		mov al,byte[esi+2]
172
		ror eax,16
172
		ror eax,16
173
	pop esi
173
	pop esi
174
	@@:
174
	@@:
175
	ret
175
	ret
176
 
176
 
177
;input:
177
;input:
178
; ebx = coord x
178
; ebx = coord x
179
; ecx = coord y
179
; ecx = coord y
180
; edi = pointer to buffer struct
180
; edi = pointer to buffer struct
181
;output:
181
;output:
182
; eax = 梥â â®çª¨
182
; eax = 梥â â®çª¨
183
; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
183
; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
184
align 4
184
align 4
185
get_pixel_32:
185
get_pixel_32:
186
	mov eax,0xffffffff
186
	mov eax,0xffffffff
187
 
187
 
188
	bt ebx,31
188
	bt ebx,31
189
	jc @f
189
	jc @f
190
	bt ecx,31
190
	bt ecx,31
191
	jc @f
191
	jc @f
192
	cmp ebx,buf2d_w
192
	cmp ebx,buf2d_w
193
	jge @f
193
	jge @f
194
	cmp ecx,buf2d_h
194
	cmp ecx,buf2d_h
195
	jge @f
195
	jge @f
196
	push esi
196
	push esi
197
		mov esi,buf2d_w ;size x
197
		mov esi,buf2d_w ;size x
198
		imul esi,ecx ;size_x*y
198
		imul esi,ecx ;size_x*y
199
		add esi,ebx	 ;size_x*y+x
199
		add esi,ebx	 ;size_x*y+x
200
		shl esi,2
200
		shl esi,2
201
		add esi,buf2d_data  ;ptr+(size_x*y+x)*4
201
		add esi,buf2d_data  ;ptr+(size_x*y+x)*4
202
 
202
 
203
		mov eax,dword[esi] ;copy pixel color
203
		mov eax,dword[esi] ;copy pixel color
204
	pop esi
204
	pop esi
205
	@@:
205
	@@:
206
	ret
206
	ret
207
 
207
 
208
;input:
208
;input:
209
; ebx = coord x
209
; ebx = coord x
210
; ecx = coord y
210
; ecx = coord y
211
; edx = pixel color + transparent
211
; edx = pixel color + transparent
212
; edi = pointer to buffer struct
212
; edi = pointer to buffer struct
213
; t_prop, m_prop - ª®íä¨æ¨¥­âë ­¥®¡å®¤¨¬ë¥ ¤«ï ¢ëç¨á«¥­¨ï á⥯¥­¨ ¯à®§à ç­®áâ¨
213
; t_prop, m_prop - ª®íä¨æ¨¥­âë ­¥®¡å®¤¨¬ë¥ ¤«ï ¢ëç¨á«¥­¨ï á⥯¥­¨ ¯à®§à ç­®áâ¨
214
align 4
214
align 4
215
transp_32 dd 0 ;梥â à¨á㥬®© â®çª¨ + ¯à®§à ç­®áâì
215
transp_32 dd 0 ;梥â à¨á㥬®© â®çª¨ + ¯à®§à ç­®áâì
216
align 4
216
align 4
217
proc draw_pixel_transp, t_prop:dword, m_prop:dword
217
proc draw_pixel_transp, t_prop:dword, m_prop:dword
218
	;cmp buf2d_bits,24
218
	;cmp buf2d_bits,24
219
	;jne @f
219
	;jne @f
220
	bt ebx,31
220
	bt ebx,31
221
	jc @f
221
	jc @f
222
	bt ecx,31
222
	bt ecx,31
223
	jc @f
223
	jc @f
224
	cmp ebx,buf2d_w
224
	cmp ebx,buf2d_w
225
	jge @f
225
	jge @f
226
	cmp ecx,buf2d_h
226
	cmp ecx,buf2d_h
227
	jge @f
227
	jge @f
228
	push eax ebx edx edi esi
228
	push eax ebx edx edi esi
229
		mov esi,buf2d_w ;size x
229
		mov esi,buf2d_w ;size x
230
		imul esi,ecx ;size_x*y
230
		imul esi,ecx ;size_x*y
231
		add esi,ebx	 ;size_x*y+x
231
		add esi,ebx	 ;size_x*y+x
232
		lea esi,[esi+esi*2] ;(size_x*y+x)*3
232
		lea esi,[esi+esi*2] ;(size_x*y+x)*3
233
		add esi,buf2d_data  ;ptr+(size_x*y+x)*3
233
		add esi,buf2d_data  ;ptr+(size_x*y+x)*3
234
 
234
 
235
		mov edi,esi ;㪠§ â¥«ì ­  梥â ä®­ 
235
		mov edi,esi ;㪠§ â¥«ì ­  梥â ä®­ 
236
		mov dword[transp_32],edx ;梥â à¨á㥬®© â®çª¨
236
		mov dword[transp_32],edx ;梥â à¨á㥬®© â®çª¨
237
 
237
 
238
		xor edx,edx
238
		xor edx,edx
239
		mov eax,[t_prop]
239
		mov eax,[t_prop]
240
		shl eax,8 ;*=256
240
		shl eax,8 ;*=256
241
		mov ebx,[m_prop]
241
		mov ebx,[m_prop]
242
		div ebx ;¢ëç¨á«ï¥¬ ª®íä. ¯à®§à ç­®á⨠(¤®«¦¥­ ¡ëâì ®â 0 ¤® 255)
242
		div ebx ;¢ëç¨á«ï¥¬ ª®íä. ¯à®§à ç­®á⨠(¤®«¦¥­ ¡ëâì ®â 0 ¤® 255)
243
		bt ax,8
243
		bt ax,8
244
		jnc .over_255
244
		jnc .over_255
245
			;¥á«¨ ª®¥ä. ¯à®§à ç­®á⨠>=256 ⮠㬥­ìè ¥¬ ¥£® ¤® 255
245
			;¥á«¨ ª®¥ä. ¯à®§à ç­®á⨠>=256 ⮠㬥­ìè ¥¬ ¥£® ¤® 255
246
			mov al,0xff
246
			mov al,0xff
247
		.over_255:
247
		.over_255:
248
 
248
 
249
		mov byte[transp_32+3],al ;¯à®§à ç­®áâì à¨á㥬®© â®çª¨
249
		mov byte[transp_32+3],al ;¯à®§à ç­®áâì à¨á㥬®© â®çª¨
250
		mov esi,dword transp_32 ;㪠§ â¥«ì ­  梥â à¨á㥬®© â®çª¨
250
		mov esi,dword transp_32 ;㪠§ â¥«ì ­  梥â à¨á㥬®© â®çª¨
251
 
251
 
252
		call combine_colors
252
		call combine_colors
253
	pop esi edi edx ebx eax
253
	pop esi edi edx ebx eax
254
	@@:
254
	@@:
255
	ret
255
	ret
256
endp
256
endp
257
 
257
 
258
;ᮧ¤ ­¨¥ ¡ãä¥à 
258
;ᮧ¤ ­¨¥ ¡ãä¥à 
259
align 4
259
align 4
260
proc buf_create, buf_struc:dword
260
proc buf_create, buf_struc:dword
261
	pushad
261
	pushad
262
	mov edi,dword[buf_struc]
262
	mov edi,dword[buf_struc]
263
	mov ecx,buf2d_w
263
	mov ecx,buf2d_w
264
	mov ebx,buf2d_h
264
	mov ebx,buf2d_h
265
	imul ecx,ebx
265
	imul ecx,ebx
266
	cmp buf2d_bits,24
266
	cmp buf2d_bits,24
267
	jne @f
267
	jne @f
268
		lea ecx,[ecx+ecx*2] ; 24 bit = 3
268
		lea ecx,[ecx+ecx*2] ; 24 bit = 3
269
		;;;inc ecx ;§ ¯ á­®© ¡ ©â ¢ ª®­æ¥ ¡ãä¥à , çâ®-¡ë ­¥ £«î稫¨ ­¥ª®â®àë¥ ä㭪樨 ­  ¨§®¡à ¦¥­¨ïå ªà â­ëå 4Š
269
		;;;inc ecx ;§ ¯ á­®© ¡ ©â ¢ ª®­æ¥ ¡ãä¥à , çâ®-¡ë ­¥ £«î稫¨ ­¥ª®â®àë¥ ä㭪樨 ­  ¨§®¡à ¦¥­¨ïå ªà â­ëå 4Š
270
	@@:
270
	@@:
271
	cmp buf2d_bits,32
271
	cmp buf2d_bits,32
272
	jne @f
272
	jne @f
273
		shl ecx,2 ; 32 bit = 4
273
		shl ecx,2 ; 32 bit = 4
274
	@@:
274
	@@:
275
	invoke mem.alloc,ecx
275
	invoke mem.alloc,ecx
276
	mov buf2d_data,eax
276
	mov buf2d_data,eax
277
 
277
 
278
	stdcall buf_clear,edi,buf2d_color ;®ç¨á⪠ ¡ãä¥à  ä®­®¢ë¬ 梥⮬
278
	stdcall buf_clear,edi,buf2d_color ;®ç¨á⪠ ¡ãä¥à  ä®­®¢ë¬ 梥⮬
279
	popad
279
	popad
280
	ret
280
	ret
281
endp
281
endp
282
 
282
 
283
;ᮧ¤ ­¨¥ ¡ãä¥à  ­  ®á­®¢¥ ¨§®¡à ¦¥­¨ï rgb
283
;ᮧ¤ ­¨¥ ¡ãä¥à  ­  ®á­®¢¥ ¨§®¡à ¦¥­¨ï rgb
284
align 4
284
align 4
285
proc buf_create_f_img, buf_struc:dword, rgb_data:dword
285
proc buf_create_f_img, buf_struc:dword, rgb_data:dword
286
	pushad
286
	pushad
287
	mov edi,dword[buf_struc]
287
	mov edi,dword[buf_struc]
288
	mov ecx,buf2d_w
288
	mov ecx,buf2d_w
289
	mov ebx,buf2d_h
289
	mov ebx,buf2d_h
290
	imul ecx,ebx
290
	imul ecx,ebx
291
	cmp buf2d_bits,24
291
	cmp buf2d_bits,24
292
	jne @f
292
	jne @f
293
		lea ecx,[ecx+ecx*2] ; 24 bit = 3
293
		lea ecx,[ecx+ecx*2] ; 24 bit = 3
294
		;;;inc ecx ;§ ¯ á­®© ¡ ©â ¢ ª®­æ¥ ¡ãä¥à , çâ®-¡ë ­¥ £«î稫¨ ­¥ª®â®àë¥ ä㭪樨 ­  ¨§®¡à ¦¥­¨ïå ªà â­ëå 4Š
294
		;;;inc ecx ;§ ¯ á­®© ¡ ©â ¢ ª®­æ¥ ¡ãä¥à , çâ®-¡ë ­¥ £«î稫¨ ­¥ª®â®àë¥ ä㭪樨 ­  ¨§®¡à ¦¥­¨ïå ªà â­ëå 4Š
295
	@@:
295
	@@:
296
	cmp buf2d_bits,32
296
	cmp buf2d_bits,32
297
	jne @f
297
	jne @f
298
		shl ecx,2 ; 32 bit = 4
298
		shl ecx,2 ; 32 bit = 4
299
	@@:
299
	@@:
300
	invoke mem.alloc,ecx
300
	invoke mem.alloc,ecx
301
	mov buf2d_data,eax
301
	mov buf2d_data,eax
302
 
302
 
303
	cmp buf2d_bits,24
303
	cmp buf2d_bits,24
304
	jne @f
304
	jne @f
305
		cld
305
		cld
306
		mov esi,[rgb_data]
306
		mov esi,[rgb_data]
307
		mov edi,eax ;eax=buf2d_data
307
		mov edi,eax ;eax=buf2d_data
308
		rep movsb ;ª®¯¨à㥬 ¡¨âë ¨§®¡à ¦¥­¨ï ¢ ¡ãä¥à
308
		rep movsb ;ª®¯¨à㥬 ¡¨âë ¨§®¡à ¦¥­¨ï ¢ ¡ãä¥à
309
		jmp .end_create
309
		jmp .end_create
310
	@@:
310
	@@:
311
		stdcall buf_clear,edi,buf2d_color ;®ç¨á⪠ ¡ãä¥à  ä®­®¢ë¬ 梥⮬
311
		stdcall buf_clear,edi,buf2d_color ;®ç¨á⪠ ¡ãä¥à  ä®­®¢ë¬ 梥⮬
312
	.end_create:
312
	.end_create:
313
	popad
313
	popad
314
	ret
314
	ret
315
endp
315
endp
316
 
316
 
317
align 4
317
align 4
318
proc buf_clear, buf_struc:dword, color:dword ;®ç¨á⪠ ¡ãä¥à  § ¤ ­ë¬ 梥⮬
318
proc buf_clear, buf_struc:dword, color:dword ;®ç¨á⪠ ¡ãä¥à  § ¤ ­ë¬ 梥⮬
319
	pushad
319
	pushad
320
	mov edi,dword[buf_struc]
320
	mov edi,dword[buf_struc]
321
 
321
 
322
	mov ecx,buf2d_w
322
	mov ecx,buf2d_w
323
	mov ebx,buf2d_h
323
	mov ebx,buf2d_h
324
	imul ecx,ebx
324
	imul ecx,ebx
325
 
325
 
326
	cld
326
	cld
327
 
327
 
328
	cmp buf2d_bits,8
328
	cmp buf2d_bits,8
329
	jne .end_clear_8
329
	jne .end_clear_8
330
		mov edi,buf2d_data
330
		mov edi,buf2d_data
331
		mov al,byte[color]
331
		mov al,byte[color]
332
		rep stosb
332
		rep stosb
333
		jmp .end_clear_32
333
		jmp .end_clear_32
334
	.end_clear_8:
334
	.end_clear_8:
335
 
335
 
336
	cmp buf2d_bits,24
336
	cmp buf2d_bits,24
337
	jne .end_clear_24
337
	jne .end_clear_24
338
		mov edi,buf2d_data
338
		mov edi,buf2d_data
339
		mov eax,dword[color]
339
		mov eax,dword[color]
340
		mov ebx,eax
340
		mov ebx,eax
341
		shr ebx,16
341
		shr ebx,16
342
		@@:
342
		@@:
343
			stosw
343
			stosw
344
			mov byte[edi],bl
344
			mov byte[edi],bl
345
			inc edi
345
			inc edi
346
			loop @b
346
			loop @b
347
		jmp .end_clear_32
347
		jmp .end_clear_32
348
	.end_clear_24:
348
	.end_clear_24:
349
 
349
 
350
	cmp buf2d_bits,32
350
	cmp buf2d_bits,32
351
	jne .end_clear_32
351
	jne .end_clear_32
352
		mov edi,buf2d_data
352
		mov edi,buf2d_data
353
		mov eax,dword[color]
353
		mov eax,dword[color]
354
		rep stosd
354
		rep stosd
355
		;jmp .end_clear_32
355
		;jmp .end_clear_32
356
	.end_clear_32:
356
	.end_clear_32:
357
	popad
357
	popad
358
	ret
358
	ret
359
endp
359
endp
360
 
360
 
361
;äã­ªæ¨ï ¤«ï ®¡à¥§ ­¨ï ¡ãä¥à®¢ 8 ¨ 24 ¡¨â­ëå, ¯® § ¤ ­®¬ã 梥âã.
361
;äã­ªæ¨ï ¤«ï ®¡à¥§ ­¨ï ¡ãä¥à®¢ 8 ¨ 24 ¡¨â­ëå, ¯® § ¤ ­®¬ã 梥âã.
362
;¯ à ¬¥âà opt § ¤ ¥âáï ª®¬¡¨­ æ¨¥© ª®­áâ ­â:
362
;¯ à ¬¥âà opt § ¤ ¥âáï ª®¬¡¨­ æ¨¥© ª®­áâ ­â:
363
; BUF2D_OPT_CROP_TOP - ®¡à¥§ª  ᢥàåã
363
; BUF2D_OPT_CROP_TOP - ®¡à¥§ª  ᢥàåã
364
; BUF2D_OPT_CROP_LEFT - ®¡à¥§ª  á«¥¢ 
364
; BUF2D_OPT_CROP_LEFT - ®¡à¥§ª  á«¥¢ 
365
; BUF2D_OPT_CROP_BOTTOM - ®¡à¥§ª  á­¨§ã
365
; BUF2D_OPT_CROP_BOTTOM - ®¡à¥§ª  á­¨§ã
366
; BUF2D_OPT_CROP_RIGHT - ®¡à¥§ª  á¯à ¢ 
366
; BUF2D_OPT_CROP_RIGHT - ®¡à¥§ª  á¯à ¢ 
367
align 4
367
align 4
368
proc buf_crop_color, buf_struc:dword, color:dword, opt:dword
368
proc buf_crop_color, buf_struc:dword, color:dword, opt:dword
369
locals
369
locals
370
	crop_r dd ?
370
	crop_r dd ?
371
endl
371
endl
372
	pushad
372
	pushad
373
	mov edi,dword[buf_struc]
373
	mov edi,dword[buf_struc]
374
	cmp buf2d_bits,24
374
	cmp buf2d_bits,24
375
	jne .24end_f
375
	jne .24end_f
376
 
376
 
377
	bt dword[opt],BUF2D_BIT_OPT_CROP_BOTTOM
377
	bt dword[opt],BUF2D_BIT_OPT_CROP_BOTTOM
378
	jae .24no_crop_bottom
378
	jae .24no_crop_bottom
379
		mov eax,dword[color]
379
		mov eax,dword[color]
380
		mov edx,eax ;ax = colors - r,g
380
		mov edx,eax ;ax = colors - r,g
381
		shr edx,16 ;dl = color - b
381
		shr edx,16 ;dl = color - b
382
		mov ecx,buf2d_h
382
		mov ecx,buf2d_h
383
		cmp ecx,1
383
		cmp ecx,1
384
		jle .24no_crop_bottom ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
384
		jle .24no_crop_bottom ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
385
		mov ebx,buf2d_w
385
		mov ebx,buf2d_w
386
		imul ecx,ebx
386
		imul ecx,ebx
387
		lea esi,[ecx+ecx*2] ;esi=3*ecx
387
		lea esi,[ecx+ecx*2] ;esi=3*ecx
388
		add esi,buf2d_data
388
		add esi,buf2d_data
389
		cld
389
		cld
390
		@@:
390
		@@:
391
			sub esi,3
391
			sub esi,3
392
			cmp word[esi],ax
392
			cmp word[esi],ax
393
			jne @f
393
			jne @f
394
			cmp byte[esi+2],dl
394
			cmp byte[esi+2],dl
395
			jne @f
395
			jne @f
396
			loop @b
396
			loop @b
397
		@@:
397
		@@:
398
		lea ebx,[ebx+ebx*2]
398
		lea ebx,[ebx+ebx*2]
399
		xor edx,edx
399
		xor edx,edx
400
		mov eax,buf2d_h
400
		mov eax,buf2d_h
401
		imul eax,ebx
401
		imul eax,ebx
402
		add eax,buf2d_data ;eax - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
402
		add eax,buf2d_data ;eax - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
403
		@@:
403
		@@:
404
			add esi,ebx
404
			add esi,ebx
405
			cmp esi,eax
405
			cmp esi,eax
406
			jge @f
406
			jge @f
407
			inc edx ;¢ëç¨á«ï¥¬ ç¨á«® ¯®«­ëå áâப ¤«ï ®¡à¥§ ­¨ï
407
			inc edx ;¢ëç¨á«ï¥¬ ç¨á«® ¯®«­ëå áâப ¤«ï ®¡à¥§ ­¨ï
408
			loop @b
408
			loop @b
409
		@@:
409
		@@:
410
		cmp edx,0
410
		cmp edx,0
411
		je .24no_crop_bottom
411
		je .24no_crop_bottom
412
			cmp edx,buf2d_h
412
			cmp edx,buf2d_h
413
			jge .24no_crop_bottom ;çâ®-¡ë ­¥ ¯®«ãç¨âì ¯ãá⮩ ¡ãä¥à
413
			jge .24no_crop_bottom ;çâ®-¡ë ­¥ ¯®«ãç¨âì ¯ãá⮩ ¡ãä¥à
414
			sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
414
			sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
415
			mov ecx,buf2d_h
415
			mov ecx,buf2d_h
416
			imul ecx,ebx ;ecx = ­®¢ë© à §¬¥à ¨§®¡à ¦¥­¨ï
416
			imul ecx,ebx ;ecx = ­®¢ë© à §¬¥à ¨§®¡à ¦¥­¨ï
417
			invoke mem.realloc,buf2d_data,ecx
417
			invoke mem.realloc,buf2d_data,ecx
418
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
418
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
419
	.24no_crop_bottom:
419
	.24no_crop_bottom:
420
 
420
 
421
	bt dword[opt],BUF2D_BIT_OPT_CROP_TOP
421
	bt dword[opt],BUF2D_BIT_OPT_CROP_TOP
422
	jae .24no_crop_top
422
	jae .24no_crop_top
423
		mov eax,dword[color]
423
		mov eax,dword[color]
424
		mov edx,eax ;ax = colors - r,g
424
		mov edx,eax ;ax = colors - r,g
425
		shr edx,16 ;dl = color - b
425
		shr edx,16 ;dl = color - b
426
		mov esi,buf2d_data
426
		mov esi,buf2d_data
427
		mov ecx,buf2d_h
427
		mov ecx,buf2d_h
428
		cmp ecx,1
428
		cmp ecx,1
429
		jle .24no_crop_top ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
429
		jle .24no_crop_top ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
430
		dec ecx ;¯à¨ ®¡à¥§ ­¨¨ ¤®«¦­  ®áâ âìáï ¬¨­¨¬ã¬ 1-­  áâப  ¯¨ªá¥«¥©
430
		dec ecx ;¯à¨ ®¡à¥§ ­¨¨ ¤®«¦­  ®áâ âìáï ¬¨­¨¬ã¬ 1-­  áâப  ¯¨ªá¥«¥©
431
		mov ebx,buf2d_w
431
		mov ebx,buf2d_w
432
		imul ecx,ebx
432
		imul ecx,ebx
433
		cld
433
		cld
434
		@@:
434
		@@:
435
			cmp word[esi],ax
435
			cmp word[esi],ax
436
			jne @f
436
			jne @f
437
			cmp byte[esi+2],dl
437
			cmp byte[esi+2],dl
438
			jne @f
438
			jne @f
439
			add esi,3
439
			add esi,3
440
			loop @b
440
			loop @b
441
		@@:
441
		@@:
442
		lea ebx,[ebx+ebx*2]
442
		lea ebx,[ebx+ebx*2]
443
		xor edx,edx
443
		xor edx,edx
444
		@@:
444
		@@:
445
			sub esi,ebx
445
			sub esi,ebx
446
			cmp esi,buf2d_data
446
			cmp esi,buf2d_data
447
			jl @f
447
			jl @f
448
			inc edx ;¢ëç¨á«ï¥¬ ç¨á«® ¯®«­ëå áâப ¤«ï ®¡à¥§ ­¨ï
448
			inc edx ;¢ëç¨á«ï¥¬ ç¨á«® ¯®«­ëå áâப ¤«ï ®¡à¥§ ­¨ï
449
			loop @b
449
			loop @b
450
		@@:
450
		@@:
451
		cmp edx,0
451
		cmp edx,0
452
		je .24no_crop_top
452
		je .24no_crop_top
453
			xor eax,eax
453
			xor eax,eax
454
			sub eax,edx
454
			sub eax,edx
455
			mov ebx,buf2d_h
455
			mov ebx,buf2d_h
456
			sub ebx,edx
456
			sub ebx,edx
457
			stdcall buf_offset_h, edi, eax, edx, ebx ;ᤢ¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢ ¡ãä¥à¥ ¢¢¥àå (eax<0)
457
			stdcall buf_offset_h, edi, eax, edx, ebx ;ᤢ¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢ ¡ãä¥à¥ ¢¢¥àå (eax<0)
458
			sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
458
			sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
459
			mov ecx,buf2d_h
459
			mov ecx,buf2d_h
460
			add buf2d_t,dx ;ᤢ¨£ ¥¬ ®âáâ㯠¢­¨§, ­  ç¨á«® ®¡à¥§ ­­ëå áâப
460
			add buf2d_t,dx ;ᤢ¨£ ¥¬ ®âáâ㯠¢­¨§, ­  ç¨á«® ®¡à¥§ ­­ëå áâப
461
			mov ebx,buf2d_w
461
			mov ebx,buf2d_w
462
			imul ecx,ebx
462
			imul ecx,ebx
463
			lea ecx,[ecx+ecx*2]
463
			lea ecx,[ecx+ecx*2]
464
			invoke mem.realloc,buf2d_data,ecx
464
			invoke mem.realloc,buf2d_data,ecx
465
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
465
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
466
	.24no_crop_top:
466
	.24no_crop_top:
467
 
467
 
468
	bt dword[opt],BUF2D_BIT_OPT_CROP_RIGHT
468
	bt dword[opt],BUF2D_BIT_OPT_CROP_RIGHT
469
	jae .24no_crop_right
469
	jae .24no_crop_right
470
		mov eax,dword[color]
470
		mov eax,dword[color]
471
		mov edx,eax ;ax = colors - r,g
471
		mov edx,eax ;ax = colors - r,g
472
		shr edx,16 ;dl = color - b
472
		shr edx,16 ;dl = color - b
473
		mov ebx,buf2d_w
473
		mov ebx,buf2d_w
474
		cmp ebx,1
474
		cmp ebx,1
475
		jle .24no_crop_right ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
475
		jle .24no_crop_right ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
476
		lea ebx,[ebx+ebx*2]
476
		lea ebx,[ebx+ebx*2]
477
		mov esi,ebx
477
		mov esi,ebx
478
		imul esi,buf2d_h
478
		imul esi,buf2d_h
479
		add esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
479
		add esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
480
		mov dword[crop_r],0
480
		mov dword[crop_r],0
481
		cld
481
		cld
482
		.24found_beg_right:
482
		.24found_beg_right:
483
		sub esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
483
		sub esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
484
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
484
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
485
		@@:
485
		@@:
486
			cmp word[esi],ax
486
			cmp word[esi],ax
487
			jne .24found_right
487
			jne .24found_right
488
			cmp byte[esi+2],dl
488
			cmp byte[esi+2],dl
489
			jne .24found_right
489
			jne .24found_right
490
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
490
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
491
			loop @b
491
			loop @b
492
		inc dword[crop_r]
492
		inc dword[crop_r]
493
 
493
 
494
		mov ecx,buf2d_w
494
		mov ecx,buf2d_w
495
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
495
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
496
		cmp dword[crop_r],ecx
496
		cmp dword[crop_r],ecx
497
		jge .24found_right
497
		jge .24found_right
498
 
498
 
499
		sub esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
499
		sub esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
500
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
500
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
501
		@@:
501
		@@:
502
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
502
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
503
			cmp word[esi],ax
503
			cmp word[esi],ax
504
			jne .24found_right
504
			jne .24found_right
505
			cmp byte[esi+2],dl
505
			cmp byte[esi+2],dl
506
			jne .24found_right
506
			jne .24found_right
507
			loop @b
507
			loop @b
508
		inc dword[crop_r]
508
		inc dword[crop_r]
509
 
509
 
510
		mov ecx,buf2d_w
510
		mov ecx,buf2d_w
511
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
511
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
512
		cmp dword[crop_r],ecx
512
		cmp dword[crop_r],ecx
513
		jl .24found_beg_right
513
		jl .24found_beg_right
514
 
514
 
515
		.24found_right:
515
		.24found_right:
516
		cmp dword[crop_r],0
516
		cmp dword[crop_r],0
517
		je .24no_crop_right
517
		je .24no_crop_right
518
			mov ecx,buf2d_w
518
			mov ecx,buf2d_w
519
			sub ecx,dword[crop_r]
519
			sub ecx,dword[crop_r]
520
			stdcall img_rgb_crop_r, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
520
			stdcall img_rgb_crop_r, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
521
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
521
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
522
			mov ebx,buf2d_h
522
			mov ebx,buf2d_h
523
			imul ecx,ebx
523
			imul ecx,ebx
524
			lea ecx,[ecx+ecx*2]
524
			lea ecx,[ecx+ecx*2]
525
			invoke mem.realloc,buf2d_data,ecx
525
			invoke mem.realloc,buf2d_data,ecx
526
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
526
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
527
	.24no_crop_right:
527
	.24no_crop_right:
528
 
528
 
529
	bt dword[opt],BUF2D_BIT_OPT_CROP_LEFT
529
	bt dword[opt],BUF2D_BIT_OPT_CROP_LEFT
530
	jae .24no_crop_left
530
	jae .24no_crop_left
531
		mov eax,dword[color]
531
		mov eax,dword[color]
532
		mov edx,eax ;ax = colors - r,g
532
		mov edx,eax ;ax = colors - r,g
533
		shr edx,16 ;dl = color - b
533
		shr edx,16 ;dl = color - b
534
		mov ebx,buf2d_w
534
		mov ebx,buf2d_w
535
		cmp ebx,1
535
		cmp ebx,1
536
		jle .24no_crop_left ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
536
		jle .24no_crop_left ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
537
		lea ebx,[ebx+ebx*2]
537
		lea ebx,[ebx+ebx*2]
538
		mov esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ­ ç®«® ¡ãä¥à  ¨§®¡à ¦¥­¨ï
538
		mov esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ­ ç®«® ¡ãä¥à  ¨§®¡à ¦¥­¨ï
539
		mov dword[crop_r],0
539
		mov dword[crop_r],0
540
		cld
540
		cld
541
		.24found_beg_left:
541
		.24found_beg_left:
542
 
542
 
543
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
543
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
544
		@@:
544
		@@:
545
			cmp word[esi],ax
545
			cmp word[esi],ax
546
			jne .24found_left
546
			jne .24found_left
547
			cmp byte[esi+2],dl
547
			cmp byte[esi+2],dl
548
			jne .24found_left
548
			jne .24found_left
549
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
549
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
550
			loop @b
550
			loop @b
551
		inc dword[crop_r]
551
		inc dword[crop_r]
552
		add esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
552
		add esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
553
 
553
 
554
		mov ecx,buf2d_w
554
		mov ecx,buf2d_w
555
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
555
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
556
		cmp dword[crop_r],ecx
556
		cmp dword[crop_r],ecx
557
		jge .24found_left
557
		jge .24found_left
558
 
558
 
559
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
559
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
560
		@@:
560
		@@:
561
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
561
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
562
			cmp word[esi],ax
562
			cmp word[esi],ax
563
			jne .24found_left
563
			jne .24found_left
564
			cmp byte[esi+2],dl
564
			cmp byte[esi+2],dl
565
			jne .24found_left
565
			jne .24found_left
566
			loop @b
566
			loop @b
567
		inc dword[crop_r]
567
		inc dword[crop_r]
568
		add esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
568
		add esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
569
 
569
 
570
		mov ecx,buf2d_w
570
		mov ecx,buf2d_w
571
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
571
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
572
		cmp dword[crop_r],ecx
572
		cmp dword[crop_r],ecx
573
		jl .24found_beg_left
573
		jl .24found_beg_left
574
 
574
 
575
		.24found_left:
575
		.24found_left:
576
		cmp dword[crop_r],0
576
		cmp dword[crop_r],0
577
		je .24no_crop_left
577
		je .24no_crop_left
578
			mov ecx,buf2d_w
578
			mov ecx,buf2d_w
579
			sub ecx,dword[crop_r]
579
			sub ecx,dword[crop_r]
580
			stdcall img_rgb_crop_l, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
580
			stdcall img_rgb_crop_l, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
581
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
581
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
582
			mov ebx,buf2d_h
582
			mov ebx,buf2d_h
583
			imul ecx,ebx
583
			imul ecx,ebx
584
			lea ecx,[ecx+ecx*2]
584
			lea ecx,[ecx+ecx*2]
585
			invoke mem.realloc,buf2d_data,ecx
585
			invoke mem.realloc,buf2d_data,ecx
586
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
586
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
587
			mov eax,dword[crop_r]
587
			mov eax,dword[crop_r]
588
			add buf2d_l,ax
588
			add buf2d_l,ax
589
	.24no_crop_left:
589
	.24no_crop_left:
590
 
590
 
591
	.24end_f:
591
	.24end_f:
592
 
592
 
593
 
593
 
594
	cmp buf2d_bits,8
594
	cmp buf2d_bits,8
595
	jne .8end_f
595
	jne .8end_f
596
 
596
 
597
	bt dword[opt],BUF2D_BIT_OPT_CROP_BOTTOM
597
	bt dword[opt],BUF2D_BIT_OPT_CROP_BOTTOM
598
	jae .8no_crop_bottom
598
	jae .8no_crop_bottom
599
		mov eax,dword[color]
599
		mov eax,dword[color]
600
		mov esi,buf2d_data
600
		mov esi,buf2d_data
601
		mov ecx,buf2d_h
601
		mov ecx,buf2d_h
602
		cmp ecx,1
602
		cmp ecx,1
603
		jle .8no_crop_bottom ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
603
		jle .8no_crop_bottom ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
604
		mov ebx,buf2d_w
604
		mov ebx,buf2d_w
605
		imul ecx,ebx
605
		imul ecx,ebx
606
		mov esi,ecx
606
		mov esi,ecx
607
		add esi,buf2d_data
607
		add esi,buf2d_data
608
		cld
608
		cld
609
		@@:
609
		@@:
610
			dec esi
610
			dec esi
611
			cmp byte[esi],al
611
			cmp byte[esi],al
612
			jne @f
612
			jne @f
613
			loop @b
613
			loop @b
614
		@@:
614
		@@:
615
		xor edx,edx
615
		xor edx,edx
616
		mov eax,buf2d_h
616
		mov eax,buf2d_h
617
		imul eax,ebx
617
		imul eax,ebx
618
		add eax,buf2d_data ;eax - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
618
		add eax,buf2d_data ;eax - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
619
		@@:
619
		@@:
620
			add esi,ebx
620
			add esi,ebx
621
			cmp esi,eax
621
			cmp esi,eax
622
			jge @f
622
			jge @f
623
			inc edx
623
			inc edx
624
			loop @b
624
			loop @b
625
		@@:
625
		@@:
626
		cmp edx,0
626
		cmp edx,0
627
		je .8no_crop_bottom
627
		je .8no_crop_bottom
628
			cmp edx,buf2d_h
628
			cmp edx,buf2d_h
629
			jge .8no_crop_bottom ;çâ®-¡ë ­¥ ¯®«ãç¨âì ¯ãá⮩ ¡ãä¥à
629
			jge .8no_crop_bottom ;çâ®-¡ë ­¥ ¯®«ãç¨âì ¯ãá⮩ ¡ãä¥à
630
			sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
630
			sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
631
			mov ecx,buf2d_h
631
			mov ecx,buf2d_h
632
			imul ecx,ebx ;ecx = ­®¢ë© à §¬¥à ¨§®¡à ¦¥­¨ï
632
			imul ecx,ebx ;ecx = ­®¢ë© à §¬¥à ¨§®¡à ¦¥­¨ï
633
			invoke mem.realloc,buf2d_data,ecx
633
			invoke mem.realloc,buf2d_data,ecx
634
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
634
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
635
	.8no_crop_bottom:
635
	.8no_crop_bottom:
636
 
636
 
637
	bt dword[opt],BUF2D_BIT_OPT_CROP_TOP
637
	bt dword[opt],BUF2D_BIT_OPT_CROP_TOP
638
	jae .8no_crop_top
638
	jae .8no_crop_top
639
		mov eax,dword[color]
639
		mov eax,dword[color]
640
		mov esi,buf2d_data
640
		mov esi,buf2d_data
641
		mov ecx,buf2d_h
641
		mov ecx,buf2d_h
642
		cmp ecx,1
642
		cmp ecx,1
643
		jle .8no_crop_top ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
643
		jle .8no_crop_top ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
644
		dec ecx ;¯à¨ ®¡à¥§ ­¨¨ ¤®«¦­  ®áâ âìáï ¬¨­¨¬ã¬ 1-­  áâப  ¯¨ªá¥«¥©
644
		dec ecx ;¯à¨ ®¡à¥§ ­¨¨ ¤®«¦­  ®áâ âìáï ¬¨­¨¬ã¬ 1-­  áâப  ¯¨ªá¥«¥©
645
		mov ebx,buf2d_w
645
		mov ebx,buf2d_w
646
		imul ecx,ebx
646
		imul ecx,ebx
647
		cld
647
		cld
648
		@@:
648
		@@:
649
			cmp byte[esi],al
649
			cmp byte[esi],al
650
			jne @f
650
			jne @f
651
			inc esi
651
			inc esi
652
			loop @b
652
			loop @b
653
		@@:
653
		@@:
654
		xor edx,edx
654
		xor edx,edx
655
		@@:
655
		@@:
656
			sub esi,ebx
656
			sub esi,ebx
657
			cmp esi,buf2d_data
657
			cmp esi,buf2d_data
658
			jl @f
658
			jl @f
659
			inc edx
659
			inc edx
660
			loop @b
660
			loop @b
661
		@@:
661
		@@:
662
		cmp edx,0
662
		cmp edx,0
663
		je .8no_crop_top
663
		je .8no_crop_top
664
			xor eax,eax
664
			xor eax,eax
665
			sub eax,edx
665
			sub eax,edx
666
			mov ebx,buf2d_h
666
			mov ebx,buf2d_h
667
			sub ebx,edx
667
			sub ebx,edx
668
			stdcall buf_offset_h, edi, eax, edx, ebx
668
			stdcall buf_offset_h, edi, eax, edx, ebx
669
			mov ecx,buf2d_h
669
			mov ecx,buf2d_h
670
			sub ecx,edx
670
			sub ecx,edx
671
			mov buf2d_h,ecx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
671
			mov buf2d_h,ecx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
672
			add buf2d_t,dx ;ᤢ¨£ ¥¬ ®âáâ㯠¢­¨§, ­  ç¨á«® ®¡à¥§ ­­ëå áâப
672
			add buf2d_t,dx ;ᤢ¨£ ¥¬ ®âáâ㯠¢­¨§, ­  ç¨á«® ®¡à¥§ ­­ëå áâப
673
			mov ebx,buf2d_w
673
			mov ebx,buf2d_w
674
			imul ecx,ebx
674
			imul ecx,ebx
675
			invoke mem.realloc,buf2d_data,ecx
675
			invoke mem.realloc,buf2d_data,ecx
676
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
676
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
677
	.8no_crop_top:
677
	.8no_crop_top:
678
 
678
 
679
	bt dword[opt],BUF2D_BIT_OPT_CROP_RIGHT
679
	bt dword[opt],BUF2D_BIT_OPT_CROP_RIGHT
680
	jae .8no_crop_right
680
	jae .8no_crop_right
681
		mov eax,dword[color]
681
		mov eax,dword[color]
682
		mov ebx,buf2d_w
682
		mov ebx,buf2d_w
683
		cmp ebx,1
683
		cmp ebx,1
684
		jle .8no_crop_right ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
684
		jle .8no_crop_right ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
685
		mov esi,ebx
685
		mov esi,ebx
686
		imul esi,buf2d_h
686
		imul esi,buf2d_h
687
		add esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
687
		add esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
688
		xor edx,edx
688
		xor edx,edx
689
		cld
689
		cld
690
 
690
 
691
		.8found_beg:
691
		.8found_beg:
692
		dec esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
692
		dec esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
693
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
693
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
694
		@@:
694
		@@:
695
			cmp byte[esi],al
695
			cmp byte[esi],al
696
			jne .8found
696
			jne .8found
697
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
697
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
698
			loop @b
698
			loop @b
699
		inc edx
699
		inc edx
700
		mov ecx,buf2d_w
700
		mov ecx,buf2d_w
701
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
701
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
702
		cmp edx,ecx
702
		cmp edx,ecx
703
		jge .8found
703
		jge .8found
704
 
704
 
705
		dec esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
705
		dec esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
706
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
706
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
707
		@@:
707
		@@:
708
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
708
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
709
			cmp byte[esi],al
709
			cmp byte[esi],al
710
			jne .8found
710
			jne .8found
711
			loop @b
711
			loop @b
712
		inc edx
712
		inc edx
713
 
713
 
714
		mov ecx,buf2d_w
714
		mov ecx,buf2d_w
715
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
715
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
716
		cmp edx,ecx
716
		cmp edx,ecx
717
		jl .8found_beg
717
		jl .8found_beg
718
 
718
 
719
		.8found:
719
		.8found:
720
		cmp edx,0
720
		cmp edx,0
721
		je .8no_crop_right
721
		je .8no_crop_right
722
			mov ecx,buf2d_w
722
			mov ecx,buf2d_w
723
			sub ecx,edx
723
			sub ecx,edx
724
			stdcall img_gray_crop_r, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
724
			stdcall img_gray_crop_r, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
725
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
725
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
726
			mov ebx,buf2d_h
726
			mov ebx,buf2d_h
727
			imul ecx,ebx
727
			imul ecx,ebx
728
			invoke mem.realloc,buf2d_data,ecx
728
			invoke mem.realloc,buf2d_data,ecx
729
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
729
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
730
	.8no_crop_right:
730
	.8no_crop_right:
731
 
731
 
732
	bt dword[opt],BUF2D_BIT_OPT_CROP_LEFT
732
	bt dword[opt],BUF2D_BIT_OPT_CROP_LEFT
733
	jae .8no_crop_left
733
	jae .8no_crop_left
734
		mov eax,dword[color]
734
		mov eax,dword[color]
735
		mov ebx,buf2d_w
735
		mov ebx,buf2d_w
736
		cmp ebx,1
736
		cmp ebx,1
737
		jle .8no_crop_left ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
737
		jle .8no_crop_left ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
738
		mov esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ­ ç®«® ¡ãä¥à  ¨§®¡à ¦¥­¨ï
738
		mov esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ­ ç®«® ¡ãä¥à  ¨§®¡à ¦¥­¨ï
739
		mov edx,0
739
		mov edx,0
740
		cld
740
		cld
741
		.8found_beg_left:
741
		.8found_beg_left:
742
 
742
 
743
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
743
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
744
		@@:
744
		@@:
745
			cmp word[esi],ax
745
			cmp word[esi],ax
746
			jne .8found_left
746
			jne .8found_left
747
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
747
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
748
			loop @b
748
			loop @b
749
		inc edx
749
		inc edx
750
		inc esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
750
		inc esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
751
 
751
 
752
		mov ecx,buf2d_w
752
		mov ecx,buf2d_w
753
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
753
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
754
		cmp edx,ecx
754
		cmp edx,ecx
755
		jge .8found_left
755
		jge .8found_left
756
 
756
 
757
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
757
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
758
		@@:
758
		@@:
759
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
759
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
760
			cmp word[esi],ax
760
			cmp word[esi],ax
761
			jne .8found_left
761
			jne .8found_left
762
			loop @b
762
			loop @b
763
		inc edx
763
		inc edx
764
		inc esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
764
		inc esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
765
 
765
 
766
		mov ecx,buf2d_w
766
		mov ecx,buf2d_w
767
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
767
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
768
		cmp edx,ecx
768
		cmp edx,ecx
769
		jl .8found_beg_left
769
		jl .8found_beg_left
770
 
770
 
771
		.8found_left:
771
		.8found_left:
772
		cmp edx,0
772
		cmp edx,0
773
		je .8no_crop_left
773
		je .8no_crop_left
774
			mov ecx,buf2d_w
774
			mov ecx,buf2d_w
775
			sub ecx,edx
775
			sub ecx,edx
776
			stdcall img_gray_crop_l, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
776
			stdcall img_gray_crop_l, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
777
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
777
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
778
			mov ebx,buf2d_h
778
			mov ebx,buf2d_h
779
			imul ecx,ebx
779
			imul ecx,ebx
780
			invoke mem.realloc,buf2d_data,ecx
780
			invoke mem.realloc,buf2d_data,ecx
781
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
781
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
782
			mov eax,edx
782
			mov eax,edx
783
			add buf2d_l,ax
783
			add buf2d_l,ax
784
	.8no_crop_left:
784
	.8no_crop_left:
785
 
785
 
786
	.8end_f:
786
	.8end_f:
787
 
787
 
788
	popad
788
	popad
789
	ret
789
	ret
790
endp
790
endp
791
 
791
 
792
;®¡à¥§ ¥¬ 梥⭮¥ ¨§®¡à ¦¥­¨¥ á ¯à ¢®© áâ®à®­ë
792
;®¡à¥§ ¥¬ 梥⭮¥ ¨§®¡à ¦¥­¨¥ á ¯à ¢®© áâ®à®­ë
793
;input:
793
;input:
794
;data_rgb - pointer to rgb data
794
;data_rgb - pointer to rgb data
795
;size_w_old - width img in pixels
795
;size_w_old - width img in pixels
796
;size_w_new - new width img in pixels
796
;size_w_new - new width img in pixels
797
;size_h - height img in pixels
797
;size_h - height img in pixels
798
align 4
798
align 4
799
proc img_rgb_crop_r, data_rgb:dword, size_w_old:dword, size_w_new:dword, size_h:dword
799
proc img_rgb_crop_r, data_rgb:dword, size_w_old:dword, size_w_new:dword, size_h:dword
800
	pushad
800
	pushad
801
	mov eax, dword[size_w_old]
801
	mov eax, dword[size_w_old]
802
	lea eax, dword[eax+eax*2] ;eax = width(old) * 3(rgb)
802
	lea eax, dword[eax+eax*2] ;eax = width(old) * 3(rgb)
803
	mov ebx, dword[size_w_new]
803
	mov ebx, dword[size_w_new]
804
	lea ebx, dword[ebx+ebx*2] ;ebx = width(new) * 3(rgb)
804
	lea ebx, dword[ebx+ebx*2] ;ebx = width(new) * 3(rgb)
805
	mov edx, dword[size_h]
805
	mov edx, dword[size_h]
806
	mov edi, dword[data_rgb] ;edi - ¯®«ã砥⠤ ­­ë¥
806
	mov edi, dword[data_rgb] ;edi - ¯®«ã砥⠤ ­­ë¥
807
	mov esi, edi
807
	mov esi, edi
808
	add edi, ebx
808
	add edi, ebx
809
	add esi, eax
809
	add esi, eax
810
	cld
810
	cld
811
	@@:
811
	@@:
812
		dec edx ;㬥­ìè ¥¬ áç¥â稪 ®áâ ¢è¨åáï áâப ­  1
812
		dec edx ;㬥­ìè ¥¬ áç¥â稪 ®áâ ¢è¨åáï áâப ­  1
813
		cmp edx,0
813
		cmp edx,0
814
		jle @f
814
		jle @f
815
		mov ecx, ebx
815
		mov ecx, ebx
816
		rep movsb ;¯¥à¥­®á (ª®¯¨à®¢ ­¨¥) áâப¨ ¯¨ªá¥«¥©
816
		rep movsb ;¯¥à¥­®á (ª®¯¨à®¢ ­¨¥) áâப¨ ¯¨ªá¥«¥©
817
		add esi,eax ;¯¥à¥å®¤ ­  ­®¢ãî áâà®çªã ¨§®¡à ¦¥­¨ï
817
		add esi,eax ;¯¥à¥å®¤ ­  ­®¢ãî áâà®çªã ¨§®¡à ¦¥­¨ï
818
		sub esi,ebx
818
		sub esi,ebx
819
		jmp @b
819
		jmp @b
820
	@@:
820
	@@:
821
	popad
821
	popad
822
	ret
822
	ret
823
endp
823
endp
824
 
824
 
825
;®¡à¥§ ¥¬ á¥à®¥ ¨§®¡à ¦¥­¨¥ á ¯à ¢®© áâ®à®­ë
825
;®¡à¥§ ¥¬ á¥à®¥ ¨§®¡à ¦¥­¨¥ á ¯à ¢®© áâ®à®­ë
826
;input:
826
;input:
827
;data_gray - pointer to gray data
827
;data_gray - pointer to gray data
828
;size_w_old - width img in pixels
828
;size_w_old - width img in pixels
829
;size_w_new - new width img in pixels
829
;size_w_new - new width img in pixels
830
;size_h - height img in pixels
830
;size_h - height img in pixels
831
align 4
831
align 4
832
proc img_gray_crop_r, data_gray:dword, size_w_old:dword, size_w_new:dword, size_h:dword
832
proc img_gray_crop_r, data_gray:dword, size_w_old:dword, size_w_new:dword, size_h:dword
833
	pushad
833
	pushad
834
	mov eax, dword[size_w_old]
834
	mov eax, dword[size_w_old]
835
	mov ebx, dword[size_w_new]
835
	mov ebx, dword[size_w_new]
836
	mov edx, dword[size_h]
836
	mov edx, dword[size_h]
837
	mov edi, dword[data_gray] ;edi - ¯®«ã砥⠤ ­­ë¥
837
	mov edi, dword[data_gray] ;edi - ¯®«ã砥⠤ ­­ë¥
838
	mov esi, edi
838
	mov esi, edi
839
	add edi, ebx
839
	add edi, ebx
840
	add esi, eax
840
	add esi, eax
841
	cld
841
	cld
842
	@@:
842
	@@:
843
		dec edx ;㬥­ìè ¥¬ áç¥â稪 ®áâ ¢è¨åáï áâப ­  1
843
		dec edx ;㬥­ìè ¥¬ áç¥â稪 ®áâ ¢è¨åáï áâப ­  1
844
		cmp edx,0
844
		cmp edx,0
845
		jle @f
845
		jle @f
846
		mov ecx, ebx
846
		mov ecx, ebx
847
		rep movsb ;¯¥à¥­®á (ª®¯¨à®¢ ­¨¥) áâப¨ ¯¨ªá¥«¥©
847
		rep movsb ;¯¥à¥­®á (ª®¯¨à®¢ ­¨¥) áâப¨ ¯¨ªá¥«¥©
848
		add esi,eax ;¯¥à¥å®¤ ­  ­®¢ãî áâà®çªã ¨§®¡à ¦¥­¨ï
848
		add esi,eax ;¯¥à¥å®¤ ­  ­®¢ãî áâà®çªã ¨§®¡à ¦¥­¨ï
849
		sub esi,ebx
849
		sub esi,ebx
850
		jmp @b
850
		jmp @b
851
	@@:
851
	@@:
852
	popad
852
	popad
853
	ret
853
	ret
854
endp
854
endp
855
 
855
 
856
;®¡à¥§ ¥¬ 梥⭮¥ ¨§®¡à ¦¥­¨¥ á «¥¢®© áâ®à®­ë
856
;®¡à¥§ ¥¬ 梥⭮¥ ¨§®¡à ¦¥­¨¥ á «¥¢®© áâ®à®­ë
857
;input:
857
;input:
858
;data_rgb - pointer to rgb data
858
;data_rgb - pointer to rgb data
859
;size_w_old - width img in pixels
859
;size_w_old - width img in pixels
860
;size_w_new - new width img in pixels
860
;size_w_new - new width img in pixels
861
;size_h - height img in pixels
861
;size_h - height img in pixels
862
align 4
862
align 4
863
proc img_rgb_crop_l, data_rgb:dword, size_w_old:dword, size_w_new:dword, size_h:dword
863
proc img_rgb_crop_l, data_rgb:dword, size_w_old:dword, size_w_new:dword, size_h:dword
864
	pushad
864
	pushad
865
	mov edi,dword[data_rgb]
865
	mov edi,dword[data_rgb]
866
	mov esi,edi
866
	mov esi,edi
867
	mov eax,dword[size_w_old]
867
	mov eax,dword[size_w_old]
868
	mov ebx,dword[size_w_new]
868
	mov ebx,dword[size_w_new]
869
	cmp eax,ebx
869
	cmp eax,ebx
870
	jle .end_f ;áâ àë© à §¬¥à ¨§®¡à ¦¥­¨ï ­¥ ¬®¦¥â ¡ëâì ¬¥­ìè¥ ­®¢®£® (¯à¨ ãá«®¢¨¨ ®¡à¥§ ­¨ï ª à⨭ª¨)
870
	jle .end_f ;áâ àë© à §¬¥à ¨§®¡à ¦¥­¨ï ­¥ ¬®¦¥â ¡ëâì ¬¥­ìè¥ ­®¢®£® (¯à¨ ãá«®¢¨¨ ®¡à¥§ ­¨ï ª à⨭ª¨)
871
		lea eax,[eax+eax*2]
871
		lea eax,[eax+eax*2]
872
		lea ebx,[ebx+ebx*2]
872
		lea ebx,[ebx+ebx*2]
873
		sub eax,ebx
873
		sub eax,ebx
874
		mov edx,dword[size_h] ;¢ëá®â  ¨§®¡à ¦¥­¨ï
874
		mov edx,dword[size_h] ;¢ëá®â  ¨§®¡à ¦¥­¨ï
875
		cld
875
		cld
876
		@@:
876
		@@:
877
			add esi,eax
877
			add esi,eax
878
			mov ecx,ebx
878
			mov ecx,ebx
879
			rep movsb
879
			rep movsb
880
			dec edx
880
			dec edx
881
			cmp edx,0
881
			cmp edx,0
882
			jg @b
882
			jg @b
883
	.end_f:
883
	.end_f:
884
	popad
884
	popad
885
	ret
885
	ret
886
endp
886
endp
887
 
887
 
888
;®¡à¥§ ¥¬ á¥à®¥ ¨§®¡à ¦¥­¨¥ á «¥¢®© áâ®à®­ë
888
;®¡à¥§ ¥¬ á¥à®¥ ¨§®¡à ¦¥­¨¥ á «¥¢®© áâ®à®­ë
889
;input:
889
;input:
890
;data_gray - pointer to gray data
890
;data_gray - pointer to gray data
891
;size_w_old - width img in pixels
891
;size_w_old - width img in pixels
892
;size_w_new - new width img in pixels
892
;size_w_new - new width img in pixels
893
;size_h - height img in pixels
893
;size_h - height img in pixels
894
align 4
894
align 4
895
proc img_gray_crop_l, data_gray:dword, size_w_old:dword, size_w_new:dword, size_h:dword
895
proc img_gray_crop_l, data_gray:dword, size_w_old:dword, size_w_new:dword, size_h:dword
896
	pushad
896
	pushad
897
	mov edi,dword[data_gray]
897
	mov edi,dword[data_gray]
898
	mov esi,edi
898
	mov esi,edi
899
	mov eax,dword[size_w_old]
899
	mov eax,dword[size_w_old]
900
	mov ebx,dword[size_w_new]
900
	mov ebx,dword[size_w_new]
901
	cmp eax,ebx
901
	cmp eax,ebx
902
	jle .end_f ;áâ àë© à §¬¥à ¨§®¡à ¦¥­¨ï ­¥ ¬®¦¥â ¡ëâì ¬¥­ìè¥ ­®¢®£® (¯à¨ ãá«®¢¨¨ ®¡à¥§ ­¨ï ª à⨭ª¨)
902
	jle .end_f ;áâ àë© à §¬¥à ¨§®¡à ¦¥­¨ï ­¥ ¬®¦¥â ¡ëâì ¬¥­ìè¥ ­®¢®£® (¯à¨ ãá«®¢¨¨ ®¡à¥§ ­¨ï ª à⨭ª¨)
903
		sub eax,ebx
903
		sub eax,ebx
904
		mov edx,dword[size_h] ;¢ëá®â  ¨§®¡à ¦¥­¨ï
904
		mov edx,dword[size_h] ;¢ëá®â  ¨§®¡à ¦¥­¨ï
905
		cld
905
		cld
906
		@@:
906
		@@:
907
			add esi,eax
907
			add esi,eax
908
			mov ecx,ebx
908
			mov ecx,ebx
909
			rep movsb
909
			rep movsb
910
			dec edx
910
			dec edx
911
			cmp edx,0
911
			cmp edx,0
912
			jg @b
912
			jg @b
913
	.end_f:
913
	.end_f:
914
	popad
914
	popad
915
	ret
915
	ret
916
endp
916
endp
917
 
917
 
918
;hoffs - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ­  ª®âàë¥ ¯®¤­¨¬ ¥âáï/®¯ã᪠¥âáï ¨§®¡à ¦¥­¨¥
918
;hoffs - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ­  ª®âàë¥ ¯®¤­¨¬ ¥âáï/®¯ã᪠¥âáï ¨§®¡à ¦¥­¨¥
919
;img_t - ¢ëá®â , á ª®â®à®© ­ ç¨­ ¥âáï ¤¢¨£ îé ïáï ç áâì ¨§®¡à ¦¥­¨ï
919
;img_t - ¢ëá®â , á ª®â®à®© ­ ç¨­ ¥âáï ¤¢¨£ îé ïáï ç áâì ¨§®¡à ¦¥­¨ï
920
align 4
920
align 4
921
proc buf_offset_h, buf_struc:dword, hoffs:dword, img_t:dword, img_h:dword ;ᤢ¨£ ¥â ¨§®¡à ¦¥­¨¥ ¯® ¢ëá®â¥
921
proc buf_offset_h, buf_struc:dword, hoffs:dword, img_t:dword, img_h:dword ;ᤢ¨£ ¥â ¨§®¡à ¦¥­¨¥ ¯® ¢ëá®â¥
922
	pushad
922
	pushad
923
	mov edi,dword[buf_struc]
923
	mov edi,dword[buf_struc]
924
	cmp buf2d_bits,24
924
	cmp buf2d_bits,24
925
	jne .end_move_24
925
	jne .end_move_24
926
 
926
 
927
	mov eax,[hoffs]
927
	mov eax,[hoffs]
928
	cmp eax,0
928
	cmp eax,0
929
	je .end_move_24
929
	je .end_move_24
930
		mov ebx,buf2d_w
930
		mov ebx,buf2d_w
931
		mov edx,dword[img_t]
931
		mov edx,dword[img_t]
932
			mov ecx,dword[img_h] ;ecx - ¢ëá®â  ᤢ¨£ ¥¬ëå ¤ ­­ëå
932
			mov ecx,dword[img_h] ;ecx - ¢ëá®â  ᤢ¨£ ¥¬ëå ¤ ­­ëå
933
			cmp ecx,buf2d_h
933
			cmp ecx,buf2d_h
934
			jge .end_f ;®è¨¡®ç­®¥ ãá«®¢¨¥, ¢ëá®â  ¨§®¡à ¦¥­¨ï ¬¥­ìè¥ ç¥¬ ¢ëá®â  ᤢ¨£ ¥¬®£® ¨§®¡à ¦¥­¨ï
934
			jge .end_f ;®è¨¡®ç­®¥ ãá«®¢¨¥, ¢ëá®â  ¨§®¡à ¦¥­¨ï ¬¥­ìè¥ ç¥¬ ¢ëá®â  ᤢ¨£ ¥¬®£® ¨§®¡à ¦¥­¨ï
935
			imul ecx,ebx ;ecx - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ ᤢ¨£ ¥¬ëå ¤ ­­ëå
935
			imul ecx,ebx ;ecx - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ ᤢ¨£ ¥¬ëå ¤ ­­ëå
936
			lea ecx,[ecx+ecx*2]
936
			lea ecx,[ecx+ecx*2]
937
		imul ebx,edx
937
		imul ebx,edx
938
		lea ebx,[ebx+ebx*2]
938
		lea ebx,[ebx+ebx*2]
939
		mov esi,buf2d_data
939
		mov esi,buf2d_data
940
		add esi,ebx
940
		add esi,ebx
941
 
941
 
942
		add edx,eax ;edx = img_t+hoffs (hoffs<0)
942
		add edx,eax ;edx = img_t+hoffs (hoffs<0)
943
		mov ebx,buf2d_w
943
		mov ebx,buf2d_w
944
		imul ebx,edx
944
		imul ebx,edx
945
		lea ebx,[ebx+ebx*2]
945
		lea ebx,[ebx+ebx*2]
946
		mov edi,buf2d_data ;¯®§¨æ¨ï, ªã¤  ¡ã¤¥â ¤¢¨£ âìáï ¨§®¡à ¦¥­¨¥
946
		mov edi,buf2d_data ;¯®§¨æ¨ï, ªã¤  ¡ã¤¥â ¤¢¨£ âìáï ¨§®¡à ¦¥­¨¥
947
		add edi,ebx
947
		add edi,ebx
948
 
948
 
949
		cmp eax,0
949
		cmp eax,0
950
		jg .move_down_24
950
		jg .move_down_24
951
			;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢¢¥àå
951
			;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢¢¥àå
952
			cld
952
			cld
953
			rep movsb
953
			rep movsb
954
			jmp .end_f
954
			jmp .end_f
955
		.move_down_24:
955
		.move_down_24:
956
			;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢­¨§
956
			;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢­¨§
957
			add esi,ecx
957
			add esi,ecx
958
			dec esi
958
			dec esi
959
			add edi,ecx
959
			add edi,ecx
960
			dec edi
960
			dec edi
961
			std
961
			std
962
			rep movsb
962
			rep movsb
963
			jmp .end_f
963
			jmp .end_f
964
	.end_move_24:
964
	.end_move_24:
965
 
965
 
966
;stdcall print_err,sz_buf2d_offset_h,txt_err_n24b
966
;stdcall print_err,sz_buf2d_offset_h,txt_err_n24b
967
 
967
 
968
	cmp buf2d_bits,8
968
	cmp buf2d_bits,8
969
	jne .end_move_8
969
	jne .end_move_8
970
 
970
 
971
	mov eax,[hoffs]
971
	mov eax,[hoffs]
972
	cmp eax,0
972
	cmp eax,0
973
	je .end_move_8
973
	je .end_move_8
974
		;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢¢¥àå
974
		;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢¢¥àå
975
		mov ebx,buf2d_w
975
		mov ebx,buf2d_w
976
		mov edx,dword[img_t]
976
		mov edx,dword[img_t]
977
			mov ecx,dword[img_h] ;ecx - ¢ëá®â  ᤢ¨£ ¥¬ëå ¤ ­­ëå
977
			mov ecx,dword[img_h] ;ecx - ¢ëá®â  ᤢ¨£ ¥¬ëå ¤ ­­ëå
978
			cmp ecx,buf2d_h
978
			cmp ecx,buf2d_h
979
			jge .end_f ;®è¨¡®ç­®¥ ãá«®¢¨¥, ¢ëá®â  ¨§®¡à ¦¥­¨ï ¬¥­ìè¥ ç¥¬ ¢ëá®â  ᤢ¨£ ¥¬®£® ¨§®¡à ¦¥­¨ï
979
			jge .end_f ;®è¨¡®ç­®¥ ãá«®¢¨¥, ¢ëá®â  ¨§®¡à ¦¥­¨ï ¬¥­ìè¥ ç¥¬ ¢ëá®â  ᤢ¨£ ¥¬®£® ¨§®¡à ¦¥­¨ï
980
			imul ecx,ebx ;ecx - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ ᤢ¨£ ¥¬ëå ¤ ­­ëå
980
			imul ecx,ebx ;ecx - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ ᤢ¨£ ¥¬ëå ¤ ­­ëå
981
		imul ebx,edx
981
		imul ebx,edx
982
		mov esi,buf2d_data
982
		mov esi,buf2d_data
983
		add esi,ebx
983
		add esi,ebx
984
 
984
 
985
		add edx,eax ;edx = img_t+hoffs (hoffs<0)
985
		add edx,eax ;edx = img_t+hoffs (hoffs<0)
986
		mov ebx,buf2d_w
986
		mov ebx,buf2d_w
987
		imul ebx,edx
987
		imul ebx,edx
988
		mov edi,buf2d_data ;¯®§¨æ¨ï, ªã¤  ¡ã¤¥â ¤¢¨£ âìáï ¨§®¡à ¦¥­¨¥
988
		mov edi,buf2d_data ;¯®§¨æ¨ï, ªã¤  ¡ã¤¥â ¤¢¨£ âìáï ¨§®¡à ¦¥­¨¥
989
		add edi,ebx
989
		add edi,ebx
990
 
990
 
991
		cmp eax,0
991
		cmp eax,0
992
		jg .move_down_8
992
		jg .move_down_8
993
			cld
993
			cld
994
			rep movsb
994
			rep movsb
995
			jmp .end_f
995
			jmp .end_f
996
		.move_down_8:
996
		.move_down_8:
997
			;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢­¨§
997
			;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢­¨§
998
			add esi,ecx
998
			add esi,ecx
999
			dec esi
999
			dec esi
1000
			add edi,ecx
1000
			add edi,ecx
1001
			dec edi
1001
			dec edi
1002
			std
1002
			std
1003
			rep movsb
1003
			rep movsb
1004
			jmp .end_f
1004
			jmp .end_f
1005
	.end_move_8:
1005
	.end_move_8:
1006
 
1006
 
1007
	.end_f:
1007
	.end_f:
1008
	popad
1008
	popad
1009
	ret
1009
	ret
1010
endp
1010
endp
1011
 
1011
 
1012
 
1012
 
1013
align 4
1013
align 4
1014
proc buf_draw_buf, buf_struc:dword
1014
proc buf_draw_buf, buf_struc:dword
1015
	pushad
1015
	pushad
1016
	mov edi,dword[buf_struc]
1016
	mov edi,dword[buf_struc]
1017
	cmp buf2d_bits,24
1017
	cmp buf2d_bits,24
1018
	jne .error
1018
	jne .error
1019
		mov eax,7
1019
		mov eax,7
1020
		mov ebx,buf2d_data
1020
		mov ebx,buf2d_data
1021
 
1021
 
1022
		mov ecx,buf2d_w
1022
		mov ecx,buf2d_w
1023
		ror ecx,16
1023
		ror ecx,16
1024
		mov edx,buf2d_h
1024
		mov edx,buf2d_h
1025
		mov cx,dx
1025
		mov cx,dx
1026
 
1026
 
1027
		mov edx,buf2d_size_lt
1027
		mov edx,buf2d_size_lt
1028
		ror edx,16
1028
		ror edx,16
1029
		int 0x40
1029
		int 0x40
1030
		jmp .end_draw_24
1030
		jmp .end_draw_24
1031
	.error:
1031
	.error:
1032
		stdcall print_err,sz_buf2d_draw,txt_err_n24b
1032
		stdcall print_err,sz_buf2d_draw,txt_err_n24b
1033
	.end_draw_24:
1033
	.end_draw_24:
1034
	popad
1034
	popad
1035
	ret
1035
	ret
1036
endp
1036
endp
1037
 
1037
 
1038
align 4
1038
align 4
1039
proc buf_delete, buf_struc:dword
1039
proc buf_delete, buf_struc:dword
1040
	push eax edi
1040
	push eax edi
1041
	mov edi,dword[buf_struc]
1041
	mov edi,dword[buf_struc]
1042
	invoke mem.free,buf2d_data
1042
	invoke mem.free,buf2d_data
1043
	pop edi eax
1043
	pop edi eax
1044
	ret
1044
	ret
1045
endp
1045
endp
1046
 
1046
 
1047
align 4
1047
align 4
1048
proc buf_resize, buf_struc:dword, new_w:dword, new_h:dword
1048
proc buf_resize, buf_struc:dword, new_w:dword, new_h:dword
1049
	pushad
1049
	pushad
1050
	mov edi,dword[buf_struc]
1050
	mov edi,dword[buf_struc]
1051
	cmp buf2d_bits,24
1051
	cmp buf2d_bits,24
1052
	jne .24bit
1052
	jne .24bit
1053
		mov eax,dword[new_w]
1053
		mov eax,dword[new_w]
1054
		cmp eax,1
1054
		cmp eax,1
1055
		jl @f
1055
		jl @f
1056
			mov buf2d_w,eax
1056
			mov buf2d_w,eax
1057
		@@:
1057
		@@:
1058
		mov ecx,buf2d_w
1058
		mov ecx,buf2d_w
1059
		mov eax,dword[new_h]
1059
		mov eax,dword[new_h]
1060
		cmp eax,1
1060
		cmp eax,1
1061
		jl @f
1061
		jl @f
1062
			mov buf2d_h,eax
1062
			mov buf2d_h,eax
1063
		@@:
1063
		@@:
1064
		mov ebx,buf2d_h
1064
		mov ebx,buf2d_h
1065
		imul ecx,ebx
1065
		imul ecx,ebx
1066
		lea ecx,[ecx+ecx*2] ; 24 bit = 3
1066
		lea ecx,[ecx+ecx*2] ; 24 bit = 3
1067
		invoke mem.realloc,buf2d_data,ecx ;¨§¬¥­ï¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
1067
		invoke mem.realloc,buf2d_data,ecx ;¨§¬¥­ï¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
1068
		mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
1068
		mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
1069
	.24bit:
1069
	.24bit:
1070
	popad
1070
	popad
1071
	ret
1071
	ret
1072
endp
1072
endp
1073
 
1073
 
1074
align 4
1074
align 4
1075
proc buf_line_brs, buf_struc:dword, coord_x0:dword, coord_y0:dword, coord_x1:dword, coord_y1:dword, color:dword
1075
proc buf_line_brs, buf_struc:dword, coord_x0:dword, coord_y0:dword, coord_x1:dword, coord_y1:dword, color:dword
1076
locals
1076
locals
1077
	loc_1 dd ?
1077
	loc_1 dd ?
1078
	loc_2 dd ?
1078
	loc_2 dd ?
1079
	napravl db ?
1079
	napravl db ?
1080
endl
1080
endl
1081
	pushad
1081
	pushad
1082
		mov eax,dword[coord_x1]
1082
		mov eax,dword[coord_x1]
1083
		sub eax,dword[coord_x0]
1083
		sub eax,dword[coord_x0]
1084
		bt eax,31
1084
		bt eax,31
1085
		jae @f
1085
		jae @f
1086
			neg eax
1086
			neg eax
1087
			inc eax
1087
			inc eax
1088
		@@:
1088
		@@:
1089
		mov ebx,dword[coord_y1]
1089
		mov ebx,dword[coord_y1]
1090
		sub ebx,dword[coord_y0]
1090
		sub ebx,dword[coord_y0]
1091
		jnz @f
1091
		jnz @f
1092
			;¥á«¨ § ¤ ­  £®à¨§®­â «ì­ ï «¨­¨ï y0=y1
1092
			;¥á«¨ § ¤ ­  £®à¨§®­â «ì­ ï «¨­¨ï y0=y1
1093
			stdcall buf_line_h, [buf_struc], [coord_x0], [coord_y0], [coord_x1], [color]
1093
			stdcall buf_line_h, [buf_struc], [coord_x0], [coord_y0], [coord_x1], [color]
1094
			jmp .coord_end
1094
			jmp .coord_end
1095
		@@:
1095
		@@:
1096
		bt ebx,31
1096
		bt ebx,31
1097
		jae @f
1097
		jae @f
1098
			neg ebx
1098
			neg ebx
1099
			inc ebx
1099
			inc ebx
1100
		@@:
1100
		@@:
1101
		mov edx,dword[color]
1101
		mov edx,dword[color]
1102
 
1102
 
1103
		mov [napravl],byte 0 ;bool steep=false
1103
		mov [napravl],byte 0 ;bool steep=false
1104
		cmp eax,ebx
1104
		cmp eax,ebx
1105
		jle @f
1105
		jle @f
1106
			mov [napravl],byte 1 ;bool steep=true
1106
			mov [napravl],byte 1 ;bool steep=true
1107
			swap dword[coord_x0],dword[coord_y0] ;swap(x0, y0);
1107
			swap dword[coord_x0],dword[coord_y0] ;swap(x0, y0);
1108
			swap dword[coord_x1],dword[coord_y1] ;swap(x1, y1);
1108
			swap dword[coord_x1],dword[coord_y1] ;swap(x1, y1);
1109
		@@:
1109
		@@:
1110
		mov eax,dword[coord_y0] ;x0
1110
		mov eax,dword[coord_y0] ;x0
1111
		cmp eax,dword[coord_y1] ;if(x0>x1)
1111
		cmp eax,dword[coord_y1] ;if(x0>x1)
1112
		jle @f
1112
		jle @f
1113
			swap dword[coord_y0],dword[coord_y1] ;swap(x0, x1);
1113
			swap dword[coord_y0],dword[coord_y1] ;swap(x0, x1);
1114
			swap dword[coord_x0],dword[coord_x1] ;swap(y0, y1);
1114
			swap dword[coord_x0],dword[coord_x1] ;swap(y0, y1);
1115
		@@:
1115
		@@:
1116
 
1116
 
1117
; int deltax esi
1117
; int deltax esi
1118
; int deltay edi
1118
; int deltay edi
1119
; int error  ebp-6
1119
; int error  ebp-6
1120
; int ystep  ebp-8
1120
; int ystep  ebp-8
1121
 
1121
 
1122
		mov eax,dword[coord_y0]
1122
		mov eax,dword[coord_y0]
1123
		mov esi,dword[coord_y1]
1123
		mov esi,dword[coord_y1]
1124
		sub esi,eax ;deltax = y1-y0
1124
		sub esi,eax ;deltax = y1-y0
1125
		mov ebx,esi
1125
		mov ebx,esi
1126
		shr ebx,1
1126
		shr ebx,1
1127
		mov [loc_1],ebx ;error = deltax/2
1127
		mov [loc_1],ebx ;error = deltax/2
1128
 
1128
 
1129
		mov eax,dword[coord_x0]
1129
		mov eax,dword[coord_x0]
1130
		mov edi,dword[coord_x1]
1130
		mov edi,dword[coord_x1]
1131
		mov [loc_2],dword -1 ;ystep = -1
1131
		mov [loc_2],dword -1 ;ystep = -1
1132
		cmp eax,edi ;if (x0
1132
		cmp eax,edi ;if (x0
1133
		jge @f
1133
		jge @f
1134
			mov [loc_2],dword 1 ;ystep = 1
1134
			mov [loc_2],dword 1 ;ystep = 1
1135
		@@:
1135
		@@:
1136
		sub edi,eax ;x1-x0
1136
		sub edi,eax ;x1-x0
1137
 
1137
 
1138
		bts edi,31
1138
		bts edi,31
1139
		jae @f
1139
		jae @f
1140
			neg edi
1140
			neg edi
1141
			inc edi
1141
			inc edi
1142
		@@:
1142
		@@:
1143
		and edi,0x7fffffff ;deltay = abs(x1-x0)
1143
		and edi,0x7fffffff ;deltay = abs(x1-x0)
1144
 
1144
 
1145
		mov eax,edi
1145
		mov eax,edi
1146
		mov edi,[buf_struc]
1146
		mov edi,[buf_struc]
1147
		cmp buf2d_bits,8
1147
		cmp buf2d_bits,8
1148
		je @f
1148
		je @f
1149
		cmp buf2d_bits,24
1149
		cmp buf2d_bits,24
1150
		je @f
1150
		je @f
1151
			jmp .coord_end
1151
			jmp .coord_end
1152
		@@:
1152
		@@:
1153
 
1153
 
1154
		cmp [napravl],0
1154
		cmp [napravl],0
1155
		jne .coord_yx
1155
		jne .coord_yx
1156
			mov ebx,dword[coord_x0]
1156
			mov ebx,dword[coord_x0]
1157
			mov ecx,dword[coord_y0]
1157
			mov ecx,dword[coord_y0]
1158
 
1158
 
1159
			@@: ;for (x=x0 ; x
1159
			@@: ;for (x=x0 ; x
1160
				cmp ecx,dword[coord_y1]
1160
				cmp ecx,dword[coord_y1]
1161
				jg @f ;jge ???
1161
				jg @f ;jge ???
1162
				call draw_pixel
1162
				call draw_pixel
1163
 
1163
 
1164
				sub dword[loc_1],eax ;error -= deltay
1164
				sub dword[loc_1],eax ;error -= deltay
1165
				cmp dword[loc_1],0 ;if(error<0)
1165
				cmp dword[loc_1],0 ;if(error<0)
1166
				jge .if0
1166
				jge .if0
1167
					add ebx,[loc_2] ;y += ystep
1167
					add ebx,[loc_2] ;y += ystep
1168
					add [loc_1],esi ;error += deltax
1168
					add [loc_1],esi ;error += deltax
1169
				.if0:
1169
				.if0:
1170
				inc ecx
1170
				inc ecx
1171
				jmp @b
1171
				jmp @b
1172
			@@:
1172
			@@:
1173
			jmp .coord_end
1173
			jmp .coord_end
1174
		.coord_yx:
1174
		.coord_yx:
1175
			mov ebx,dword[coord_y0]
1175
			mov ebx,dword[coord_y0]
1176
			mov ecx,dword[coord_x0]
1176
			mov ecx,dword[coord_x0]
1177
 
1177
 
1178
			@@: ;for (x=x0 ; x
1178
			@@: ;for (x=x0 ; x
1179
				cmp ebx,dword[coord_y1]
1179
				cmp ebx,dword[coord_y1]
1180
				jg @f ;jge ???
1180
				jg @f ;jge ???
1181
				call draw_pixel
1181
				call draw_pixel
1182
 
1182
 
1183
				sub dword[loc_1],eax ;error -= deltay
1183
				sub dword[loc_1],eax ;error -= deltay
1184
				cmp dword[loc_1],0 ;if(error<0)
1184
				cmp dword[loc_1],0 ;if(error<0)
1185
				jge .if1
1185
				jge .if1
1186
					add ecx,[loc_2] ;y += ystep
1186
					add ecx,[loc_2] ;y += ystep
1187
					add [loc_1],esi ;error += deltax
1187
					add [loc_1],esi ;error += deltax
1188
				.if1:
1188
				.if1:
1189
				inc ebx
1189
				inc ebx
1190
				jmp @b
1190
				jmp @b
1191
			@@:
1191
			@@:
1192
	.coord_end:
1192
	.coord_end:
1193
	popad
1193
	popad
1194
	ret
1194
	ret
1195
endp
1195
endp
1196
 
1196
 
1197
;à¨á®¢ ­¨¥ ᣫ ¦¥­­®© «¨­¨¨
1197
;à¨á®¢ ­¨¥ ᣫ ¦¥­­®© «¨­¨¨
1198
align 4
1198
align 4
1199
proc buf_line_brs_sm, buf_struc:dword, coord_x0:dword, coord_y0:dword, coord_x1:dword, coord_y1:dword, color:dword
1199
proc buf_line_brs_sm, buf_struc:dword, coord_x0:dword, coord_y0:dword, coord_x1:dword, coord_y1:dword, color:dword
1200
locals
1200
locals
1201
	loc_1 dd ?
1201
	loc_1 dd ?
1202
	loc_2 dd ?
1202
	loc_2 dd ?
1203
	napravl db ?
1203
	napravl db ?
1204
endl
1204
endl
1205
	pushad
1205
	pushad
1206
		mov eax,dword[coord_x1]
1206
		mov eax,dword[coord_x1]
1207
		sub eax,dword[coord_x0]
1207
		sub eax,dword[coord_x0]
1208
		bt eax,31
1208
		bt eax,31
1209
		jae @f
1209
		jae @f
1210
			neg eax
1210
			neg eax
1211
			inc eax
1211
			inc eax
1212
		@@:
1212
		@@:
1213
		mov ebx,dword[coord_y1]
1213
		mov ebx,dword[coord_y1]
1214
		sub ebx,dword[coord_y0]
1214
		sub ebx,dword[coord_y0]
1215
		jnz @f
1215
		jnz @f
1216
			;¥á«¨ § ¤ ­  £®à¨§®­â «ì­ ï «¨­¨ï y0=y1
1216
			;¥á«¨ § ¤ ­  £®à¨§®­â «ì­ ï «¨­¨ï y0=y1
1217
			stdcall buf_line_h, [buf_struc], [coord_x0], [coord_y0], [coord_x1], [color]
1217
			stdcall buf_line_h, [buf_struc], [coord_x0], [coord_y0], [coord_x1], [color]
1218
			jmp .coord_end
1218
			jmp .coord_end
1219
		@@:
1219
		@@:
1220
		bt ebx,31
1220
		bt ebx,31
1221
		jae @f
1221
		jae @f
1222
			neg ebx
1222
			neg ebx
1223
			inc ebx
1223
			inc ebx
1224
		@@:
1224
		@@:
1225
		mov edx,dword[color]
1225
		mov edx,dword[color]
1226
 
1226
 
1227
		mov [napravl],byte 0 ;bool steep=false
1227
		mov [napravl],byte 0 ;bool steep=false
1228
		cmp eax,ebx
1228
		cmp eax,ebx
1229
		jle @f
1229
		jle @f
1230
			mov [napravl],byte 1 ;bool steep=true
1230
			mov [napravl],byte 1 ;bool steep=true
1231
			swap dword[coord_x0],dword[coord_y0] ;swap(x0, y0);
1231
			swap dword[coord_x0],dword[coord_y0] ;swap(x0, y0);
1232
			swap dword[coord_x1],dword[coord_y1] ;swap(x1, y1);
1232
			swap dword[coord_x1],dword[coord_y1] ;swap(x1, y1);
1233
		@@:
1233
		@@:
1234
		mov eax,dword[coord_y0] ;x0
1234
		mov eax,dword[coord_y0] ;x0
1235
		cmp eax,dword[coord_y1] ;if(x0>x1)
1235
		cmp eax,dword[coord_y1] ;if(x0>x1)
1236
		jle @f
1236
		jle @f
1237
			swap dword[coord_y0],dword[coord_y1] ;swap(x0, x1);
1237
			swap dword[coord_y0],dword[coord_y1] ;swap(x0, x1);
1238
			swap dword[coord_x0],dword[coord_x1] ;swap(y0, y1);
1238
			swap dword[coord_x0],dword[coord_x1] ;swap(y0, y1);
1239
		@@:
1239
		@@:
1240
 
1240
 
1241
; int deltax esi
1241
; int deltax esi
1242
; int deltay edi
1242
; int deltay edi
1243
; int error  ebp-6
1243
; int error  ebp-6
1244
; int ystep  ebp-8
1244
; int ystep  ebp-8
1245
 
1245
 
1246
		mov eax,dword[coord_y0]
1246
		mov eax,dword[coord_y0]
1247
		mov esi,dword[coord_y1]
1247
		mov esi,dword[coord_y1]
1248
		sub esi,eax ;deltax = y1-y0
1248
		sub esi,eax ;deltax = y1-y0
1249
		mov ebx,esi
1249
		mov ebx,esi
1250
		shr ebx,1
1250
		shr ebx,1
1251
		mov [loc_1],ebx ;error = deltax/2
1251
		mov [loc_1],ebx ;error = deltax/2
1252
 
1252
 
1253
		mov eax,dword[coord_x0]
1253
		mov eax,dword[coord_x0]
1254
		mov edi,dword[coord_x1]
1254
		mov edi,dword[coord_x1]
1255
		mov [loc_2],dword -1 ;ystep = -1
1255
		mov [loc_2],dword -1 ;ystep = -1
1256
		cmp eax,edi ;if (x0
1256
		cmp eax,edi ;if (x0
1257
		jge @f
1257
		jge @f
1258
			mov [loc_2],dword 1 ;ystep = 1
1258
			mov [loc_2],dword 1 ;ystep = 1
1259
		@@:
1259
		@@:
1260
		sub edi,eax ;x1-x0
1260
		sub edi,eax ;x1-x0
1261
 
1261
 
1262
		bts edi,31
1262
		bts edi,31
1263
		jae @f
1263
		jae @f
1264
			neg edi
1264
			neg edi
1265
			inc edi
1265
			inc edi
1266
		@@:
1266
		@@:
1267
		and edi,0x7fffffff ;deltay = abs(x1-x0)
1267
		and edi,0x7fffffff ;deltay = abs(x1-x0)
1268
 
1268
 
1269
		mov eax,edi
1269
		mov eax,edi
1270
		mov edi,[buf_struc]
1270
		mov edi,[buf_struc]
1271
		cmp buf2d_bits,24
1271
		cmp buf2d_bits,24
1272
		jne .coord_end
1272
		jne .coord_end
1273
 
1273
 
1274
		cmp [napravl],0
1274
		cmp [napravl],0
1275
		jne .coord_yx
1275
		jne .coord_yx
1276
			mov ebx,dword[coord_x0]
1276
			mov ebx,dword[coord_x0]
1277
			mov ecx,dword[coord_y0]
1277
			mov ecx,dword[coord_y0]
1278
 
1278
 
1279
			@@: ;for (x=x0 ; x
1279
			@@: ;for (x=x0 ; x
1280
				cmp ecx,dword[coord_y1]
1280
				cmp ecx,dword[coord_y1]
1281
				jg @f ;jge ???
1281
				jg @f ;jge ???
1282
				push eax
1282
				push eax
1283
					mov eax,esi
1283
					mov eax,esi
1284
					sub eax,[loc_1]
1284
					sub eax,[loc_1]
1285
					stdcall draw_pixel_transp, eax,esi
1285
					stdcall draw_pixel_transp, eax,esi
1286
				pop eax
1286
				pop eax
1287
				add ebx,[loc_2]
1287
				add ebx,[loc_2]
1288
				stdcall draw_pixel_transp, [loc_1],esi
1288
				stdcall draw_pixel_transp, [loc_1],esi
1289
				sub ebx,[loc_2]
1289
				sub ebx,[loc_2]
1290
 
1290
 
1291
				sub dword[loc_1],eax ;error -= deltay
1291
				sub dword[loc_1],eax ;error -= deltay
1292
				cmp dword[loc_1],0 ;if(error<0)
1292
				cmp dword[loc_1],0 ;if(error<0)
1293
				jge .if0
1293
				jge .if0
1294
					add ebx,[loc_2] ;y += ystep
1294
					add ebx,[loc_2] ;y += ystep
1295
					add [loc_1],esi ;error += deltax
1295
					add [loc_1],esi ;error += deltax
1296
				.if0:
1296
				.if0:
1297
				inc ecx
1297
				inc ecx
1298
				jmp @b
1298
				jmp @b
1299
			@@:
1299
			@@:
1300
			jmp .coord_end
1300
			jmp .coord_end
1301
		.coord_yx:
1301
		.coord_yx:
1302
			mov ebx,dword[coord_y0]
1302
			mov ebx,dword[coord_y0]
1303
			mov ecx,dword[coord_x0]
1303
			mov ecx,dword[coord_x0]
1304
 
1304
 
1305
			@@: ;for (x=x0 ; x
1305
			@@: ;for (x=x0 ; x
1306
				cmp ebx,dword[coord_y1]
1306
				cmp ebx,dword[coord_y1]
1307
				jg @f ;jge ???
1307
				jg @f ;jge ???
1308
				push eax
1308
				push eax
1309
					mov eax,esi
1309
					mov eax,esi
1310
					sub eax,[loc_1]
1310
					sub eax,[loc_1]
1311
					stdcall draw_pixel_transp, eax,esi
1311
					stdcall draw_pixel_transp, eax,esi
1312
				pop eax
1312
				pop eax
1313
				add ecx,[loc_2]
1313
				add ecx,[loc_2]
1314
				stdcall draw_pixel_transp, [loc_1],esi
1314
				stdcall draw_pixel_transp, [loc_1],esi
1315
				sub ecx,[loc_2]
1315
				sub ecx,[loc_2]
1316
 
1316
 
1317
				sub dword[loc_1],eax ;error -= deltay
1317
				sub dword[loc_1],eax ;error -= deltay
1318
				cmp dword[loc_1],0 ;if(error<0)
1318
				cmp dword[loc_1],0 ;if(error<0)
1319
				jge .if1
1319
				jge .if1
1320
					add ecx,[loc_2] ;y += ystep
1320
					add ecx,[loc_2] ;y += ystep
1321
					add [loc_1],esi ;error += deltax
1321
					add [loc_1],esi ;error += deltax
1322
				.if1:
1322
				.if1:
1323
				inc ebx
1323
				inc ebx
1324
				jmp @b
1324
				jmp @b
1325
			@@:
1325
			@@:
1326
	.coord_end:
1326
	.coord_end:
1327
	popad
1327
	popad
1328
	ret
1328
	ret
1329
endp
1329
endp
1330
 
1330
 
1331
;à¨á®¢ ­¨¥ £®à¨§®­â «ì­®© «¨­¨¨, ¯®â®¬ã ­¥â ¯ à ¬¥âà  coord_y1
1331
;à¨á®¢ ­¨¥ £®à¨§®­â «ì­®© «¨­¨¨, ¯®â®¬ã ­¥â ¯ à ¬¥âà  coord_y1
1332
align 4
1332
align 4
1333
proc buf_line_h, buf_struc:dword, coord_x0:dword, coord_y0:dword, coord_x1:dword, color:dword
1333
proc buf_line_h, buf_struc:dword, coord_x0:dword, coord_y0:dword, coord_x1:dword, color:dword
1334
	pushad
1334
	pushad
1335
	pushfd
1335
	pushfd
1336
		mov edi,[buf_struc]
1336
		mov edi,[buf_struc]
1337
		cmp buf2d_bits,8
1337
		cmp buf2d_bits,8
1338
		je @f
1338
		je @f
1339
		cmp buf2d_bits,24
1339
		cmp buf2d_bits,24
1340
		je @f
1340
		je @f
1341
			jmp .end24
1341
			jmp .end24
1342
		@@: ;®¯à¥¤¥«¥­¨¥ ª®®à¤¨­ â «¨­¨¨ ®â­®á¨â¥«ì­® ¡ãä¥à 
1342
		@@: ;®¯à¥¤¥«¥­¨¥ ª®®à¤¨­ â «¨­¨¨ ®â­®á¨â¥«ì­® ¡ãä¥à 
1343
 
1343
 
1344
		mov ecx,dword[coord_y0]
1344
		mov ecx,dword[coord_y0]
1345
		bt ecx,31
1345
		bt ecx,31
1346
		jc .end24 ;¥á«¨ ª®®à¤¨­ â  y0 ®âà¨æ â¥«ì­ ï
1346
		jc .end24 ;¥á«¨ ª®®à¤¨­ â  y0 ®âà¨æ â¥«ì­ ï
1347
		cmp ecx,buf2d_h
1347
		cmp ecx,buf2d_h
1348
		jge .end24 ;¥á«¨ ª®®à¤¨­ â  y0 ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
1348
		jge .end24 ;¥á«¨ ª®®à¤¨­ â  y0 ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
1349
 
1349
 
1350
		mov ebx,dword[coord_x0]
1350
		mov ebx,dword[coord_x0]
1351
		mov esi,dword[coord_x1]
1351
		mov esi,dword[coord_x1]
1352
		cmp ebx,esi
1352
		cmp ebx,esi
1353
		jle @f
1353
		jle @f
1354
			xchg ebx,esi ;¥á«¨ x0 > x1 â® ¬¥­ï¥¬ ¬¥áâ ¬¨ x0 ¨ x1
1354
			xchg ebx,esi ;¥á«¨ x0 > x1 â® ¬¥­ï¥¬ ¬¥áâ ¬¨ x0 ¨ x1
1355
		@@:
1355
		@@:
1356
		bt ebx,31
1356
		bt ebx,31
1357
		jae @f
1357
		jae @f
1358
			;¥á«¨ ª®®à¤¨­ â  x0 ®âà¨æ â¥«ì­ ï
1358
			;¥á«¨ ª®®à¤¨­ â  x0 ®âà¨æ â¥«ì­ ï
1359
			xor ebx,ebx
1359
			xor ebx,ebx
1360
		@@:
1360
		@@:
1361
		cmp esi,buf2d_w
1361
		cmp esi,buf2d_w
1362
		jl @f
1362
		jl @f
1363
			;¥á«¨ ª®®à¤¨­ â  x0 ¡®«ìè¥ è¨à¨­ë ¡ãä¥à 
1363
			;¥á«¨ ª®®à¤¨­ â  x0 ¡®«ìè¥ è¨à¨­ë ¡ãä¥à 
1364
			mov esi,buf2d_w
1364
			mov esi,buf2d_w
1365
			dec esi
1365
			dec esi
1366
		@@:
1366
		@@:
1367
		cmp ebx,esi
1367
		cmp ebx,esi
1368
		jg .end24 ;¥á«¨ x0 > x1 ¬®¦¥â ¢®§­¨ª­ãâì ª®£¤  ®¡¥ ª®®à¤¨­ âë x0, x1 ­ å®¤¨«¨áì §  ®¤­¨¬ ¨§ ¯à¥¤¥«®¢ ¡ãä¥à 
1368
		jg .end24 ;¥á«¨ x0 > x1 ¬®¦¥â ¢®§­¨ª­ãâì ª®£¤  ®¡¥ ª®®à¤¨­ âë x0, x1 ­ å®¤¨«¨áì §  ®¤­¨¬ ¨§ ¯à¥¤¥«®¢ ¡ãä¥à 
1369
 
1369
 
1370
		cmp buf2d_bits,24
1370
		cmp buf2d_bits,24
1371
		je .beg24
1371
		je .beg24
1372
			;à¨á®¢ ­¨¥ ¢ 8 ¡¨â­®¬ ¡ãä¥à¥
1372
			;à¨á®¢ ­¨¥ ¢ 8 ¡¨â­®¬ ¡ãä¥à¥
1373
			;¢ edx ¢ëç¨á«ï¥¬ ­ ç «® 1-© â®çª¨ «¨­¨¨ ¢ ¡ãä¥à¥ ¨§®¡à ¦¥­¨ï
1373
			;¢ edx ¢ëç¨á«ï¥¬ ­ ç «® 1-© â®çª¨ «¨­¨¨ ¢ ¡ãä¥à¥ ¨§®¡à ¦¥­¨ï
1374
			mov edx,buf2d_w ;size x
1374
			mov edx,buf2d_w ;size x
1375
			imul edx,ecx ;size_x*y
1375
			imul edx,ecx ;size_x*y
1376
			add edx,ebx	 ;size_x*y+x
1376
			add edx,ebx	 ;size_x*y+x
1377
			add edx,buf2d_data ;ptr+(size_x*y+x)
1377
			add edx,buf2d_data ;ptr+(size_x*y+x)
1378
			mov edi,edx ;⥯¥àì ¬®¦¥¬ ¯®àâ¨âì 㪠§ â¥«ì ­  ¡ãä¥à
1378
			mov edi,edx ;⥯¥àì ¬®¦¥¬ ¯®àâ¨âì 㪠§ â¥«ì ­  ¡ãä¥à
1379
 
1379
 
1380
			mov ecx,esi
1380
			mov ecx,esi
1381
			sub ecx,ebx ;¢ ecx ª®««¨ç¥á⢮ â®ç¥ª «¨­¨¨ ¢ë¢®¤¨¬ëå ¢ ¡ãä¥à
1381
			sub ecx,ebx ;¢ ecx ª®««¨ç¥á⢮ â®ç¥ª «¨­¨¨ ¢ë¢®¤¨¬ëå ¢ ¡ãä¥à
1382
			inc ecx ;çâ®-¡ë ¯®á«¥¤­ïï â®çª  «¨­¨¨ â ª¦¥ ®â®¡à ¦ « áì
1382
			inc ecx ;çâ®-¡ë ¯®á«¥¤­ïï â®çª  «¨­¨¨ â ª¦¥ ®â®¡à ¦ « áì
1383
			mov eax,dword[color] ;¡ã¤¥¬ ¨á¯®«ì§®¢ âì ⮫쪮 §­ ç¥­¨¥ ¢ al
1383
			mov eax,dword[color] ;¡ã¤¥¬ ¨á¯®«ì§®¢ âì ⮫쪮 §­ ç¥­¨¥ ¢ al
1384
			cld
1384
			cld
1385
			rep stosb ;横« ¯® ®á¨ x ®â x0 ¤® x1 (¢ª«îç ï x1)
1385
			rep stosb ;横« ¯® ®á¨ x ®â x0 ¤® x1 (¢ª«îç ï x1)
1386
			jmp .end24
1386
			jmp .end24
1387
 
1387
 
1388
		.beg24: ;à¨á®¢ ­¨¥ ¢ 24 ¡¨â­®¬ ¡ãä¥à¥
1388
		.beg24: ;à¨á®¢ ­¨¥ ¢ 24 ¡¨â­®¬ ¡ãä¥à¥
1389
		;¢ eax ¢ëç¨á«ï¥¬ ­ ç «® 1-© â®çª¨ «¨­¨¨ ¢ ¡ãä¥à¥ ¨§®¡à ¦¥­¨ï
1389
		;¢ eax ¢ëç¨á«ï¥¬ ­ ç «® 1-© â®çª¨ «¨­¨¨ ¢ ¡ãä¥à¥ ¨§®¡à ¦¥­¨ï
1390
		mov eax,buf2d_w ;size x
1390
		mov eax,buf2d_w ;size x
1391
		imul eax,ecx ;size_x*y
1391
		imul eax,ecx ;size_x*y
1392
		add eax,ebx	 ;size_x*y+x
1392
		add eax,ebx	 ;size_x*y+x
1393
		lea eax,[eax+eax*2] ;(size_x*y+x)*3
1393
		lea eax,[eax+eax*2] ;(size_x*y+x)*3
1394
		add eax,buf2d_data  ;ptr+(size_x*y+x)*3
1394
		add eax,buf2d_data  ;ptr+(size_x*y+x)*3
1395
 
1395
 
1396
		mov ecx,esi
1396
		mov ecx,esi
1397
		sub ecx,ebx ;¢ ecx ª®««¨ç¥á⢮ â®ç¥ª «¨­¨¨ ¢ë¢®¤¨¬ëå ¢ ¡ãä¥à
1397
		sub ecx,ebx ;¢ ecx ª®««¨ç¥á⢮ â®ç¥ª «¨­¨¨ ¢ë¢®¤¨¬ëå ¢ ¡ãä¥à
1398
		inc ecx ;çâ®-¡ë ¯®á«¥¤­ïï â®çª  «¨­¨¨ â ª¦¥ ®â®¡à ¦ « áì
1398
		inc ecx ;çâ®-¡ë ¯®á«¥¤­ïï â®çª  «¨­¨¨ â ª¦¥ ®â®¡à ¦ « áì
1399
		mov edx,dword[color]
1399
		mov edx,dword[color]
1400
		mov ebx,edx ;ª®®à¤¨­ â  x0 ¢ ebx 㦥 ­¥ ­ã¦­ 
1400
		mov ebx,edx ;ª®®à¤¨­ â  x0 ¢ ebx 㦥 ­¥ ­ã¦­ 
1401
		ror edx,16 ;¯®¢®à ç¨¢ ¥¬ ॣ¨áâà çâ® ¡ë 3-© ¡ ©â ¯®¯ « ¢ dl
1401
		ror edx,16 ;¯®¢®à ç¨¢ ¥¬ ॣ¨áâà çâ® ¡ë 3-© ¡ ©â ¯®¯ « ¢ dl
1402
		cld
1402
		cld
1403
		@@: ;横« ¯® ®á¨ x ®â x0 ¤® x1 (¢ª«îç ï x1)
1403
		@@: ;横« ¯® ®á¨ x ®â x0 ¤® x1 (¢ª«îç ï x1)
1404
			mov word[eax],bx ;copy pixel color
1404
			mov word[eax],bx ;copy pixel color
1405
			mov byte[eax+2],dl
1405
			mov byte[eax+2],dl
1406
			add eax,3
1406
			add eax,3
1407
			loop @b
1407
			loop @b
1408
		.end24:
1408
		.end24:
1409
	popfd
1409
	popfd
1410
	popad
1410
	popad
1411
	ret
1411
	ret
1412
endp
1412
endp
1413
 
1413
 
1414
align 4
1414
align 4
1415
proc buf_rect_by_size, buf_struc:dword, coord_x:dword,coord_y:dword,w:dword,h:dword, color:dword
1415
proc buf_rect_by_size, buf_struc:dword, coord_x:dword,coord_y:dword,w:dword,h:dword, color:dword
1416
pushad
1416
pushad
1417
	mov edi,[buf_struc]
1417
	mov edi,[buf_struc]
1418
	cmp buf2d_bits,8
1418
	cmp buf2d_bits,8
1419
	je @f
1419
	je @f
1420
	cmp buf2d_bits,24
1420
	cmp buf2d_bits,24
1421
	je @f
1421
	je @f
1422
		jmp .coord_end
1422
		jmp .coord_end
1423
	@@:
1423
	@@:
1424
 
1424
 
1425
		mov eax,[coord_x]
1425
		mov eax,[coord_x]
1426
		mov ebx,[coord_y]
1426
		mov ebx,[coord_y]
1427
		mov ecx,[w]
1427
		mov ecx,[w]
1428
		;cmp ecx,1
1428
		;cmp ecx,1
1429
		;jl .coord_end
1429
		;jl .coord_end
1430
		cmp ecx,0
1430
		cmp ecx,0
1431
		je .coord_end
1431
		je .coord_end
1432
		jg @f
1432
		jg @f
1433
			add eax,ecx
1433
			add eax,ecx
1434
			inc eax
1434
			inc eax
1435
			neg ecx
1435
			neg ecx
1436
		@@:
1436
		@@:
1437
		add ecx,eax
1437
		add ecx,eax
1438
		dec ecx
1438
		dec ecx
1439
		mov edx,[h]
1439
		mov edx,[h]
1440
		;cmp edx,1
1440
		;cmp edx,1
1441
		;jl .coord_end
1441
		;jl .coord_end
1442
		cmp edx,0
1442
		cmp edx,0
1443
		je .coord_end
1443
		je .coord_end
1444
		jg @f
1444
		jg @f
1445
			add ebx,edx
1445
			add ebx,edx
1446
			inc ebx
1446
			inc ebx
1447
			neg edx
1447
			neg edx
1448
		@@:
1448
		@@:
1449
 
1449
 
1450
		add edx,ebx
1450
		add edx,ebx
1451
		dec edx
1451
		dec edx
1452
		mov esi,dword[color]
1452
		mov esi,dword[color]
1453
		stdcall buf_line_h, edi, eax, ebx, ecx, esi ;«¨­¨ï -
1453
		stdcall buf_line_h, edi, eax, ebx, ecx, esi ;«¨­¨ï -
1454
		stdcall buf_line_brs, edi, eax, ebx, eax, edx, esi ;«¨­¨ï |
1454
		stdcall buf_line_brs, edi, eax, ebx, eax, edx, esi ;«¨­¨ï |
1455
		stdcall buf_line_h, edi, eax, edx, ecx, esi ;«¨­¨ï -
1455
		stdcall buf_line_h, edi, eax, edx, ecx, esi ;«¨­¨ï -
1456
		stdcall buf_line_brs, edi, ecx, ebx, ecx, edx, esi ;«¨­¨ï |
1456
		stdcall buf_line_brs, edi, ecx, ebx, ecx, edx, esi ;«¨­¨ï |
1457
	.coord_end:
1457
	.coord_end:
1458
popad
1458
popad
1459
	ret
1459
	ret
1460
endp
1460
endp
1461
 
1461
 
1462
align 4
1462
align 4
1463
proc buf_filled_rect_by_size, buf_struc:dword, coord_x:dword,coord_y:dword,w:dword,h:dword, color:dword
1463
proc buf_filled_rect_by_size, buf_struc:dword, coord_x:dword,coord_y:dword,w:dword,h:dword, color:dword
1464
pushad
1464
pushad
1465
	mov edi,[buf_struc]
1465
	mov edi,[buf_struc]
1466
	cmp buf2d_bits,8
1466
	cmp buf2d_bits,8
1467
	je @f
1467
	je @f
1468
	cmp buf2d_bits,24
1468
	cmp buf2d_bits,24
1469
	je @f
1469
	je @f
1470
		jmp .coord_end
1470
		jmp .coord_end
1471
	@@:
1471
	@@:
1472
		mov eax,[coord_x]
1472
		mov eax,[coord_x]
1473
		mov ebx,[coord_y]
1473
		mov ebx,[coord_y]
1474
		mov edx,[w]
1474
		mov edx,[w]
1475
		cmp edx,0
1475
		cmp edx,0
1476
		je .coord_end ;¥á«¨ ¢ëá®â  0 ¯¨ªá¥«¥©
1476
		je .coord_end ;¥á«¨ ¢ëá®â  0 ¯¨ªá¥«¥©
1477
		jg @f ;¥á«¨ ¢ëá®â  ¯®«®¦¨â¥«ì­ ï
1477
		jg @f ;¥á«¨ ¢ëá®â  ¯®«®¦¨â¥«ì­ ï
1478
			add eax,edx
1478
			add eax,edx
1479
			inc eax
1479
			inc eax
1480
			neg edx ;è¨à¨­ã ¤¥« ¥¬ ¯®«®¦¨â¥«ì­®©
1480
			neg edx ;è¨à¨­ã ¤¥« ¥¬ ¯®«®¦¨â¥«ì­®©
1481
			;inc edx ;¯®ç¥¬ã âãâ ­¥ ¤®¡ ¢«ï¥¬ 1-æã ï ­¥ §­ î, ­® á ­¥© à ¡®â ¥â ­¥ ¯à ¢¨«ì­®
1481
			;inc edx ;¯®ç¥¬ã âãâ ­¥ ¤®¡ ¢«ï¥¬ 1-æã ï ­¥ §­ î, ­® á ­¥© à ¡®â ¥â ­¥ ¯à ¢¨«ì­®
1482
		@@:
1482
		@@:
1483
		add edx,eax
1483
		add edx,eax
1484
		dec edx
1484
		dec edx
1485
		mov ecx,[h]
1485
		mov ecx,[h]
1486
		cmp ecx,0
1486
		cmp ecx,0
1487
		je .coord_end ;¥á«¨ ¢ëá®â  0 ¯¨ªá¥«¥©
1487
		je .coord_end ;¥á«¨ ¢ëá®â  0 ¯¨ªá¥«¥©
1488
		jg @f ;¥á«¨ ¢ëá®â  ¯®«®¦¨â¥«ì­ ï
1488
		jg @f ;¥á«¨ ¢ëá®â  ¯®«®¦¨â¥«ì­ ï
1489
			add ebx,ecx ;ᤢ¨£ ¥¬ ¢¥àå­îî ª®®à¤¨­ âã ¯àאַ㣮«ì­¨ª 
1489
			add ebx,ecx ;ᤢ¨£ ¥¬ ¢¥àå­îî ª®®à¤¨­ âã ¯àאַ㣮«ì­¨ª 
1490
			inc ebx
1490
			inc ebx
1491
			neg ecx ;¢ëá®âã ¤¥« ¥¬ ¯®«®¦¨â¥«ì­®©
1491
			neg ecx ;¢ëá®âã ¤¥« ¥¬ ¯®«®¦¨â¥«ì­®©
1492
			;inc ecx ;¯®ç¥¬ã âãâ ­¥ ¤®¡ ¢«ï¥¬ 1-æã ï ­¥ §­ î, ­® á ­¥© à ¡®â ¥â ­¥ ¯à ¢¨«ì­®
1492
			;inc ecx ;¯®ç¥¬ã âãâ ­¥ ¤®¡ ¢«ï¥¬ 1-æã ï ­¥ §­ î, ­® á ­¥© à ¡®â ¥â ­¥ ¯à ¢¨«ì­®
1493
		@@:
1493
		@@:
1494
		mov esi,dword[color]
1494
		mov esi,dword[color]
1495
		cld
1495
		cld
1496
		@@:
1496
		@@:
1497
			stdcall buf_line_h, edi, eax, ebx, edx, esi ;«¨­¨ï -
1497
			stdcall buf_line_h, edi, eax, ebx, edx, esi ;«¨­¨ï -
1498
			inc ebx
1498
			inc ebx
1499
			loop @b
1499
			loop @b
1500
	.coord_end:
1500
	.coord_end:
1501
popad
1501
popad
1502
	ret
1502
	ret
1503
endp
1503
endp
1504
 
1504
 
1505
align 4
1505
align 4
1506
proc buf_circle, buf_struc:dword, coord_x:dword, coord_y:dword, r:dword, color:dword
1506
proc buf_circle, buf_struc:dword, coord_x:dword, coord_y:dword, r:dword, color:dword
1507
locals
1507
locals
1508
	po_x dd ?
1508
	po_x dd ?
1509
	po_y dd ?
1509
	po_y dd ?
1510
endl
1510
endl
1511
	pushad
1511
	pushad
1512
	mov edi,dword[buf_struc]
1512
	mov edi,dword[buf_struc]
1513
	cmp buf2d_bits,8
1513
	cmp buf2d_bits,8
1514
	je @f
1514
	je @f
1515
	cmp buf2d_bits,24
1515
	cmp buf2d_bits,24
1516
	je @f
1516
	je @f
1517
		jmp .error
1517
		jmp .error
1518
	@@:
1518
	@@:
1519
		mov edx,dword[color]
1519
		mov edx,dword[color]
1520
 
1520
 
1521
		finit
1521
		finit
1522
		fild dword[coord_x]
1522
		fild dword[coord_x]
1523
		fild dword[coord_y]
1523
		fild dword[coord_y]
1524
		fild dword[r]
1524
		fild dword[r]
1525
		fldz ;px=0
1525
		fldz ;px=0
1526
		fld st1 ;py=r
1526
		fld st1 ;py=r
1527
 
1527
 
1528
		fldpi
1528
		fldpi
1529
		fmul st0,st3
1529
		fmul st0,st3
1530
		fistp dword[po_x]
1530
		fistp dword[po_x]
1531
		mov esi,dword[po_x] ;esi=pi*r
1531
		mov esi,dword[po_x] ;esi=pi*r
1532
		shl esi,1 ;esi=2*pi*r
1532
		shl esi,1 ;esi=2*pi*r
1533
 
1533
 
1534
		;st0 = py
1534
		;st0 = py
1535
		;st1 = px
1535
		;st1 = px
1536
		;st2 = r
1536
		;st2 = r
1537
		;st3 = y
1537
		;st3 = y
1538
		;st4 = x
1538
		;st4 = x
1539
 
1539
 
1540
		@@:
1540
		@@:
1541
			;Point(px + x, y - py)
1541
			;Point(px + x, y - py)
1542
			fld st1 ;st0=px
1542
			fld st1 ;st0=px
1543
			fadd st0,st5 ;st0=px+x
1543
			fadd st0,st5 ;st0=px+x
1544
			fistp dword[po_x]
1544
			fistp dword[po_x]
1545
			mov ebx,dword[po_x]
1545
			mov ebx,dword[po_x]
1546
			fld st3 ;st0=y
1546
			fld st3 ;st0=y
1547
			fsub st0,st1 ;st0=y-py
1547
			fsub st0,st1 ;st0=y-py
1548
			fistp dword[po_y]
1548
			fistp dword[po_y]
1549
			mov ecx,dword[po_y]
1549
			mov ecx,dword[po_y]
1550
			call draw_pixel
1550
			call draw_pixel
1551
			;px += py/r
1551
			;px += py/r
1552
			fld st0 ;st0=py
1552
			fld st0 ;st0=py
1553
			fdiv st0,st3 ;st0=py/r
1553
			fdiv st0,st3 ;st0=py/r
1554
			faddp st2,st0 ;st3+=st0
1554
			faddp st2,st0 ;st3+=st0
1555
			;py -= px/r
1555
			;py -= px/r
1556
			fld st1 ;st0=px
1556
			fld st1 ;st0=px
1557
			fdiv st0,st3 ;st0=px/r
1557
			fdiv st0,st3 ;st0=px/r
1558
			fsubp st1,st0 ;st2-=st0
1558
			fsubp st1,st0 ;st2-=st0
1559
 
1559
 
1560
			dec esi
1560
			dec esi
1561
			cmp esi,0
1561
			cmp esi,0
1562
			jge @b
1562
			jge @b
1563
		jmp .exit_fun
1563
		jmp .exit_fun
1564
	.error:
1564
	.error:
1565
		stdcall print_err,sz_buf2d_circle,txt_err_n8_24b
1565
		stdcall print_err,sz_buf2d_circle,txt_err_n8_24b
1566
	.exit_fun:
1566
	.exit_fun:
1567
 
1567
 
1568
	popad
1568
	popad
1569
	ret
1569
	ret
1570
endp
1570
endp
1571
 
1571
 
1572
;äã­ªæ¨ï ¤«ï § «¨¢ª¨ ®¡« á⨠¢ë¡à ­­ë¬ 梥⮬
1572
;äã­ªæ¨ï ¤«ï § «¨¢ª¨ ®¡« á⨠¢ë¡à ­­ë¬ 梥⮬
1573
align 4
1573
align 4
1574
proc buf_flood_fill, buf_struc:dword, coord_x:dword, coord_y:dword, mode:dword, color_f:dword, color_b:dword
1574
proc buf_flood_fill, buf_struc:dword, coord_x:dword, coord_y:dword, mode:dword, color_f:dword, color_b:dword
1575
	pushad
1575
	pushad
1576
		mov edi,[buf_struc]
1576
		mov edi,[buf_struc]
1577
		cmp buf2d_bits,24
1577
		cmp buf2d_bits,24
1578
		jne .end24
1578
		jne .end24
1579
 
1579
 
1580
			mov ebx,dword[coord_x]
1580
			mov ebx,dword[coord_x]
1581
			mov ecx,dword[coord_y]
1581
			mov ecx,dword[coord_y]
1582
			mov edx,dword[color_f]
1582
			mov edx,dword[color_f]
1583
			mov esi,dword[color_b]
1583
			mov esi,dword[color_b]
1584
 
1584
 
1585
			cmp dword[mode],1 ;¢ § ¢¨á¨¬®á⨠®â 'mode' ®¯à¥¤¥«ï¥¬ ª ª¨¬  «£®à¨â¬®¬ ¡ã¤¥¬ ¯®«ì§®¢ âìáï
1585
			cmp dword[mode],1 ;¢ § ¢¨á¨¬®á⨠®â 'mode' ®¯à¥¤¥«ï¥¬ ª ª¨¬  «£®à¨â¬®¬ ¡ã¤¥¬ ¯®«ì§®¢ âìáï
1586
			je @f
1586
			je @f
1587
				call buf_flood_fill_recurs_0 ;§ «¨¢ ¥¬ ¤® ¯¨ªá¥«¥© æ¢¥â  esi
1587
				call buf_flood_fill_recurs_0 ;§ «¨¢ ¥¬ ¤® ¯¨ªá¥«¥© æ¢¥â  esi
1588
				jmp .end24
1588
				jmp .end24
1589
			@@:
1589
			@@:
1590
				call buf_flood_fill_recurs_1 ;§ «¨¢ ¥¬ ¯¨ªá¥«¨ ¨¬¥î騥 梥â esi
1590
				call buf_flood_fill_recurs_1 ;§ «¨¢ ¥¬ ¯¨ªá¥«¨ ¨¬¥î騥 梥â esi
1591
 
1591
 
1592
		.end24:
1592
		.end24:
1593
	popad
1593
	popad
1594
	ret
1594
	ret
1595
endp
1595
endp
1596
 
1596
 
1597
;input:
1597
;input:
1598
; ebx = coord_x
1598
; ebx = coord_x
1599
; ecx = coord_y
1599
; ecx = coord_y
1600
; edx = 梥⠧ «¨¢ª¨
1600
; edx = 梥⠧ «¨¢ª¨
1601
; esi = 梥⠣࠭¨æë, ¤® ª®â®à®© ¡ã¤¥â ¨â¨ § «¨¢ª 
1601
; esi = 梥⠣࠭¨æë, ¤® ª®â®à®© ¡ã¤¥â ¨â¨ § «¨¢ª 
1602
; edi = buf_struc
1602
; edi = buf_struc
1603
;output:
1603
;output:
1604
; eax = ¯®àâ¨âáï
1604
; eax = ¯®àâ¨âáï
1605
align 4
1605
align 4
1606
buf_flood_fill_recurs_0:
1606
buf_flood_fill_recurs_0:
1607
	call get_pixel_24
1607
	call get_pixel_24
1608
	cmp eax,0xffffffff ;if error coords
1608
	cmp eax,0xffffffff ;if error coords
1609
	je .end_fun
1609
	je .end_fun
1610
	cmp eax,edx ;¥á«¨ 梥⠯¨ªá¥«ï ᮢ¯ « á 梥⮬ § «¨¢ª¨, §­ ç¨â § «¨¢ª  ¢ í⮩ ®¡« á⨠㦥 ¡ë«  ᤥ« ­ 
1610
	cmp eax,edx ;¥á«¨ 梥⠯¨ªá¥«ï ᮢ¯ « á 梥⮬ § «¨¢ª¨, §­ ç¨â § «¨¢ª  ¢ í⮩ ®¡« á⨠㦥 ¡ë«  ᤥ« ­ 
1611
	je .end_fun
1611
	je .end_fun
1612
 
1612
 
1613
		call draw_pixel
1613
		call draw_pixel
1614
 
1614
 
1615
		dec ebx
1615
		dec ebx
1616
		call get_pixel_24
1616
		call get_pixel_24
1617
		cmp eax,esi
1617
		cmp eax,esi
1618
		je @f
1618
		je @f
1619
			call buf_flood_fill_recurs_0
1619
			call buf_flood_fill_recurs_0
1620
		@@:
1620
		@@:
1621
		inc ebx
1621
		inc ebx
1622
 
1622
 
1623
 
1623
 
1624
		inc ebx
1624
		inc ebx
1625
		call get_pixel_24
1625
		call get_pixel_24
1626
		cmp eax,esi
1626
		cmp eax,esi
1627
		je @f
1627
		je @f
1628
			call buf_flood_fill_recurs_0
1628
			call buf_flood_fill_recurs_0
1629
		@@:
1629
		@@:
1630
		dec ebx
1630
		dec ebx
1631
 
1631
 
1632
		dec ecx
1632
		dec ecx
1633
		call get_pixel_24
1633
		call get_pixel_24
1634
		cmp eax,esi
1634
		cmp eax,esi
1635
		je @f
1635
		je @f
1636
			call buf_flood_fill_recurs_0
1636
			call buf_flood_fill_recurs_0
1637
		@@:
1637
		@@:
1638
		inc ecx
1638
		inc ecx
1639
 
1639
 
1640
		inc ecx
1640
		inc ecx
1641
		call get_pixel_24
1641
		call get_pixel_24
1642
		cmp eax,esi
1642
		cmp eax,esi
1643
		je @f
1643
		je @f
1644
			call buf_flood_fill_recurs_0
1644
			call buf_flood_fill_recurs_0
1645
		@@:
1645
		@@:
1646
		dec ecx
1646
		dec ecx
1647
 
1647
 
1648
	.end_fun:
1648
	.end_fun:
1649
	ret
1649
	ret
1650
 
1650
 
1651
;input:
1651
;input:
1652
; ebx = coord_x
1652
; ebx = coord_x
1653
; ecx = coord_y
1653
; ecx = coord_y
1654
; edx = 梥⠧ «¨¢ª¨
1654
; edx = 梥⠧ «¨¢ª¨
1655
; esi = 梥⠯¨ªá¥«¥©, ¯® ª®â®àë¬ ¡ã¤¥â ¨â¨ § «¨¢ª 
1655
; esi = 梥⠯¨ªá¥«¥©, ¯® ª®â®àë¬ ¡ã¤¥â ¨â¨ § «¨¢ª 
1656
; edi = buf_struc
1656
; edi = buf_struc
1657
;output:
1657
;output:
1658
; eax = ¯®àâ¨âáï
1658
; eax = ¯®àâ¨âáï
1659
align 4
1659
align 4
1660
buf_flood_fill_recurs_1:
1660
buf_flood_fill_recurs_1:
1661
	call get_pixel_24
1661
	call get_pixel_24
1662
	cmp eax,0xffffffff ;if error coords
1662
	cmp eax,0xffffffff ;if error coords
1663
	je .end_fun
1663
	je .end_fun
1664
	cmp eax,edx ;¥á«¨ 梥⠯¨ªá¥«ï ᮢ¯ « á 梥⮬ § «¨¢ª¨, §­ ç¨â § «¨¢ª  ¢ í⮩ ®¡« á⨠㦥 ¡ë«  ᤥ« ­ 
1664
	cmp eax,edx ;¥á«¨ 梥⠯¨ªá¥«ï ᮢ¯ « á 梥⮬ § «¨¢ª¨, §­ ç¨â § «¨¢ª  ¢ í⮩ ®¡« á⨠㦥 ¡ë«  ᤥ« ­ 
1665
	je .end_fun
1665
	je .end_fun
1666
	cmp eax,esi ;¥á«¨ 梥⠯¨ªá¥«ï ­¥ ᮢ¯ « á § «¨¢ ¥¬ë¬ 梥⮬ § «¨¢ª¨, â® ¯à¥ªà é ¥¬ § «¨¢ªã
1666
	cmp eax,esi ;¥á«¨ 梥⠯¨ªá¥«ï ­¥ ᮢ¯ « á § «¨¢ ¥¬ë¬ 梥⮬ § «¨¢ª¨, â® ¯à¥ªà é ¥¬ § «¨¢ªã
1667
	jne .end_fun
1667
	jne .end_fun
1668
 
1668
 
1669
		call draw_pixel
1669
		call draw_pixel
1670
 
1670
 
1671
		dec ebx
1671
		dec ebx
1672
		call get_pixel_24
1672
		call get_pixel_24
1673
		cmp eax,esi
1673
		cmp eax,esi
1674
		jne @f
1674
		jne @f
1675
			call buf_flood_fill_recurs_1
1675
			call buf_flood_fill_recurs_1
1676
		@@:
1676
		@@:
1677
		inc ebx
1677
		inc ebx
1678
 
1678
 
1679
 
1679
 
1680
		inc ebx
1680
		inc ebx
1681
		call get_pixel_24
1681
		call get_pixel_24
1682
		cmp eax,esi
1682
		cmp eax,esi
1683
		jne @f
1683
		jne @f
1684
			call buf_flood_fill_recurs_1
1684
			call buf_flood_fill_recurs_1
1685
		@@:
1685
		@@:
1686
		dec ebx
1686
		dec ebx
1687
 
1687
 
1688
		dec ecx
1688
		dec ecx
1689
		call get_pixel_24
1689
		call get_pixel_24
1690
		cmp eax,esi
1690
		cmp eax,esi
1691
		jne @f
1691
		jne @f
1692
			call buf_flood_fill_recurs_1
1692
			call buf_flood_fill_recurs_1
1693
		@@:
1693
		@@:
1694
		inc ecx
1694
		inc ecx
1695
 
1695
 
1696
		inc ecx
1696
		inc ecx
1697
		call get_pixel_24
1697
		call get_pixel_24
1698
		cmp eax,esi
1698
		cmp eax,esi
1699
		jne @f
1699
		jne @f
1700
			call buf_flood_fill_recurs_1
1700
			call buf_flood_fill_recurs_1
1701
		@@:
1701
		@@:
1702
		dec ecx
1702
		dec ecx
1703
 
1703
 
1704
	.end_fun:
1704
	.end_fun:
1705
	ret
1705
	ret
1706
 
1706
 
1707
;äã­ªæ¨ï ¤«ï à¨á®¢ ­¨ï â®çª¨
1707
;äã­ªæ¨ï ¤«ï à¨á®¢ ­¨ï â®çª¨
1708
align 4
1708
align 4
1709
proc buf_set_pixel uses ebx ecx edx edi, buf_struc:dword, coord_x:dword, coord_y:dword, color:dword
1709
proc buf_set_pixel uses ebx ecx edx edi, buf_struc:dword, coord_x:dword, coord_y:dword, color:dword
1710
	mov edi,dword[buf_struc]
1710
	mov edi,dword[buf_struc]
1711
	mov ebx,dword[coord_x]
1711
	mov ebx,dword[coord_x]
1712
	mov ecx,dword[coord_y]
1712
	mov ecx,dword[coord_y]
1713
	mov edx,dword[color]
1713
	mov edx,dword[color]
1714
	call draw_pixel
1714
	call draw_pixel
1715
	ret
1715
	ret
1716
endp
1716
endp
1717
 
1717
 
1718
;output:
1718
;output:
1719
; eax = 梥â â®çª¨
1719
; eax = 梥â â®çª¨
1720
; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
1720
; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
1721
align 4
1721
align 4
1722
proc buf_get_pixel uses ebx ecx edi, buf_struc:dword, coord_x:dword, coord_y:dword
1722
proc buf_get_pixel uses ebx ecx edi, buf_struc:dword, coord_x:dword, coord_y:dword
1723
	mov edi,dword[buf_struc]
1723
	mov edi,dword[buf_struc]
1724
	mov ebx,[coord_x]
1724
	mov ebx,[coord_x]
1725
	mov ecx,[coord_y]
1725
	mov ecx,[coord_y]
1726
 
1726
 
1727
	cmp buf2d_bits,8
1727
	cmp buf2d_bits,8
1728
	jne @f
1728
	jne @f
1729
		call get_pixel_8
1729
		call get_pixel_8
1730
		jmp .end_fun
1730
		jmp .end_fun
1731
	@@:
1731
	@@:
1732
	cmp buf2d_bits,24
1732
	cmp buf2d_bits,24
1733
	jne @f
1733
	jne @f
1734
		call get_pixel_24
1734
		call get_pixel_24
1735
		jmp .end_fun
1735
		jmp .end_fun
1736
	@@:
1736
	@@:
1737
	cmp buf2d_bits,32
1737
	cmp buf2d_bits,32
1738
	jne @f
1738
	jne @f
1739
		call get_pixel_32
1739
		call get_pixel_32
1740
		;jmp .end_fun
1740
		;jmp .end_fun
1741
	@@:
1741
	@@:
1742
	.end_fun:
1742
	.end_fun:
1743
	ret
1743
	ret
1744
endp
1744
endp
1745
 
1745
 
1746
align 4
1746
align 4
1747
proc buf_img_wdiv2, buf_struc:dword
1747
proc buf_img_wdiv2, buf_struc:dword
1748
	pushad
1748
	pushad
1749
	mov edi,dword[buf_struc]
1749
	mov edi,dword[buf_struc]
1750
	cmp buf2d_bits,24
1750
	cmp buf2d_bits,24
1751
	jne .end_draw_24
1751
	jne .end_draw_24
1752
		mov eax,buf2d_w
1752
		mov eax,buf2d_w
1753
		mov ecx,buf2d_h
1753
		mov ecx,buf2d_h
1754
		imul ecx,eax
1754
		imul ecx,eax
1755
		stdcall img_rgb24_wdiv2, buf2d_data,ecx
1755
		stdcall img_rgb24_wdiv2, buf2d_data,ecx
1756
	.end_draw_24:
1756
	.end_draw_24:
1757
	popad
1757
	popad
1758
	ret
1758
	ret
1759
endp
1759
endp
1760
 
1760
 
1761
;input:
1761
;input:
1762
;data_rgb - pointer to rgb data
1762
;data_rgb - pointer to rgb data
1763
;size - count img pixels (size img data / 3(rgb) )
1763
;size - count img pixels (size img data / 3(rgb) )
1764
align 4
1764
align 4
1765
proc img_rgb24_wdiv2 data_rgb:dword, size:dword
1765
proc img_rgb24_wdiv2 data_rgb:dword, size:dword
1766
  ;push eax ebx ecx edx
1766
  ;push eax ebx ecx edx
1767
  mov eax,dword[data_rgb]
1767
  mov eax,dword[data_rgb]
1768
  mov ecx,dword[size] ;ecx = size
1768
  mov ecx,dword[size] ;ecx = size
1769
  lea ecx,[ecx+ecx*2]
1769
  lea ecx,[ecx+ecx*2]
1770
  cld
1770
  cld
1771
  @@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
1771
  @@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
1772
		shr byte[eax],1
1772
		shr byte[eax],1
1773
		inc eax
1773
		inc eax
1774
		loop @b
1774
		loop @b
1775
 
1775
 
1776
  mov eax,dword[data_rgb]
1776
  mov eax,dword[data_rgb]
1777
  mov ecx,dword[size] ;ecx = size
1777
  mov ecx,dword[size] ;ecx = size
1778
  shr ecx,1
1778
  shr ecx,1
1779
  @@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
1779
  @@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
1780
		mov bx,word[eax+3] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
1780
		mov bx,word[eax+3] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
1781
		add word[eax],bx
1781
		add word[eax],bx
1782
		mov bl,byte[eax+5] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
1782
		mov bl,byte[eax+5] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
1783
		add byte[eax+2],bl
1783
		add byte[eax+2],bl
1784
		add eax,6 ;=2*3
1784
		add eax,6 ;=2*3
1785
		loop @b
1785
		loop @b
1786
 
1786
 
1787
  mov eax,dword[data_rgb]
1787
  mov eax,dword[data_rgb]
1788
  add eax,3
1788
  add eax,3
1789
  mov ebx,eax
1789
  mov ebx,eax
1790
  add ebx,3
1790
  add ebx,3
1791
  mov ecx,dword[size] ;ecx = size
1791
  mov ecx,dword[size] ;ecx = size
1792
  shr ecx,1
1792
  shr ecx,1
1793
  dec ecx ;«¨è­¨© ¯¨ªá¥«ì
1793
  dec ecx ;«¨è­¨© ¯¨ªá¥«ì
1794
  @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1794
  @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1795
		mov edx,dword[ebx]
1795
		mov edx,dword[ebx]
1796
		mov word[eax],dx
1796
		mov word[eax],dx
1797
		shr edx,16
1797
		shr edx,16
1798
		mov byte[eax+2],dl
1798
		mov byte[eax+2],dl
1799
 
1799
 
1800
		add eax,3
1800
		add eax,3
1801
		add ebx,6
1801
		add ebx,6
1802
		loop @b
1802
		loop @b
1803
  ;pop edx ecx ebx eax
1803
  ;pop edx ecx ebx eax
1804
  ret
1804
  ret
1805
endp
1805
endp
1806
 
1806
 
1807
align 4
1807
align 4
1808
proc buf_img_hdiv2, buf_struc:dword
1808
proc buf_img_hdiv2, buf_struc:dword
1809
	pushad
1809
	pushad
1810
	mov edi,dword[buf_struc]
1810
	mov edi,dword[buf_struc]
1811
	cmp buf2d_bits,24
1811
	cmp buf2d_bits,24
1812
	jne .end_draw_24
1812
	jne .end_draw_24
1813
		mov eax,buf2d_w
1813
		mov eax,buf2d_w
1814
		mov ecx,buf2d_h
1814
		mov ecx,buf2d_h
1815
		imul ecx,eax
1815
		imul ecx,eax
1816
		stdcall img_rgb24_hdiv2, buf2d_data,ecx,eax
1816
		stdcall img_rgb24_hdiv2, buf2d_data,ecx,eax
1817
	.end_draw_24:
1817
	.end_draw_24:
1818
	popad
1818
	popad
1819
	ret
1819
	ret
1820
endp
1820
endp
1821
 
1821
 
1822
;input:
1822
;input:
1823
;data_rgb - pointer to rgb data
1823
;data_rgb - pointer to rgb data
1824
;size - count img pixels (size img data / 3(rgb) )
1824
;size - count img pixels (size img data / 3(rgb) )
1825
;size_w - width img in pixels
1825
;size_w - width img in pixels
1826
align 4
1826
align 4
1827
proc img_rgb24_hdiv2, data_rgb:dword, size:dword, size_w:dword
1827
proc img_rgb24_hdiv2, data_rgb:dword, size:dword, size_w:dword
1828
  ;pushad
1828
  ;pushad
1829
 
1829
 
1830
  mov eax,dword[data_rgb] ;eax =
1830
  mov eax,dword[data_rgb] ;eax =
1831
  mov ecx,dword[size]	  ;ecx = size
1831
  mov ecx,dword[size]	  ;ecx = size
1832
  lea ecx,[ecx+ecx*2]
1832
  lea ecx,[ecx+ecx*2]
1833
  cld
1833
  cld
1834
  @@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
1834
  @@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
1835
    shr byte[eax],1
1835
    shr byte[eax],1
1836
    inc eax
1836
    inc eax
1837
    loop @b
1837
    loop @b
1838
 
1838
 
1839
  mov eax,dword[data_rgb] ;eax =
1839
  mov eax,dword[data_rgb] ;eax =
1840
  mov edi,dword[size_w]
1840
  mov edi,dword[size_w]
1841
  lea esi,[edi+edi*2] ;esi = width*3(rgb)
1841
  lea esi,[edi+edi*2] ;esi = width*3(rgb)
1842
  mov ebx,esi
1842
  mov ebx,esi
1843
  add ebx,eax
1843
  add ebx,eax
1844
  mov ecx,dword[size]  ;ecx = size
1844
  mov ecx,dword[size]  ;ecx = size
1845
  shr ecx,1
1845
  shr ecx,1
1846
  xor edi,edi
1846
  xor edi,edi
1847
  @@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
1847
  @@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
1848
    mov dx,word[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1848
    mov dx,word[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1849
    add word[eax],dx
1849
    add word[eax],dx
1850
    mov dl,byte[ebx+2] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1850
    mov dl,byte[ebx+2] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1851
    add byte[eax+2],dl
1851
    add byte[eax+2],dl
1852
 
1852
 
1853
    add eax,3
1853
    add eax,3
1854
    add ebx,3
1854
    add ebx,3
1855
    inc edi
1855
    inc edi
1856
    cmp edi,dword[size_w]
1856
    cmp edi,dword[size_w]
1857
    jl .old_line
1857
    jl .old_line
1858
      add eax,esi
1858
      add eax,esi
1859
      add ebx,esi
1859
      add ebx,esi
1860
      xor edi,edi
1860
      xor edi,edi
1861
    .old_line:
1861
    .old_line:
1862
    loop @b
1862
    loop @b
1863
 
1863
 
1864
 
1864
 
1865
  mov eax,dword[data_rgb] ;eax =
1865
  mov eax,dword[data_rgb] ;eax =
1866
  add eax,esi ;esi = width*3(rgb)
1866
  add eax,esi ;esi = width*3(rgb)
1867
  mov ebx,esi
1867
  mov ebx,esi
1868
  add ebx,eax
1868
  add ebx,eax
1869
  mov ecx,dword[size] ;ecx = size
1869
  mov ecx,dword[size] ;ecx = size
1870
  shr ecx,1
1870
  shr ecx,1
1871
  sub ecx,dword[size_w] ;«¨è­ïï áâப  ¯¨ªá¥«¥©
1871
  sub ecx,dword[size_w] ;«¨è­ïï áâப  ¯¨ªá¥«¥©
1872
  xor edi,edi
1872
  xor edi,edi
1873
  @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1873
  @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1874
    mov edx,dword[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1874
    mov edx,dword[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1875
    mov word[eax],dx
1875
    mov word[eax],dx
1876
    shr edx,16
1876
    shr edx,16
1877
    mov byte[eax+2],dl
1877
    mov byte[eax+2],dl
1878
 
1878
 
1879
    add eax,3
1879
    add eax,3
1880
    add ebx,3
1880
    add ebx,3
1881
    inc edi
1881
    inc edi
1882
    cmp edi,dword[size_w]
1882
    cmp edi,dword[size_w]
1883
    jl .old_line_2
1883
    jl .old_line_2
1884
      add ebx,esi
1884
      add ebx,esi
1885
      xor edi,edi
1885
      xor edi,edi
1886
    .old_line_2:
1886
    .old_line_2:
1887
    loop @b
1887
    loop @b
1888
 
1888
 
1889
  ;popad
1889
  ;popad
1890
  ret
1890
  ret
1891
endp
1891
endp
1892
 
1892
 
1893
;¯à¥®¡à §®¢ ­¨¥ ¡ãä¥à  ¨§ 24-¡¨â­®£® ¢ 8-¡¨â­ë©
1893
;¯à¥®¡à §®¢ ­¨¥ ¡ãä¥à  ¨§ 24-¡¨â­®£® ¢ 8-¡¨â­ë©
1894
; spectr - ®¯à¥¤¥«ï¥â ª ª®© ᯥªâà ¡à âì ¯à¨ ¯à¥®¡à §®¢ ­¨¨ 0-ᨭ¨©, 1-§¥«¥­ë©, 2-ªà á­ë©
1894
; spectr - ®¯à¥¤¥«ï¥â ª ª®© ᯥªâà ¡à âì ¯à¨ ¯à¥®¡à §®¢ ­¨¨ 0-ᨭ¨©, 1-§¥«¥­ë©, 2-ªà á­ë©
1895
align 4
1895
align 4
1896
proc buf_conv_24_to_8, buf_struc:dword, spectr:dword
1896
proc buf_conv_24_to_8, buf_struc:dword, spectr:dword
1897
	pushad
1897
	pushad
1898
	mov edi,dword[buf_struc]
1898
	mov edi,dword[buf_struc]
1899
	cmp buf2d_bits,24
1899
	cmp buf2d_bits,24
1900
	jne .error
1900
	jne .error
1901
		mov eax,buf2d_w
1901
		mov eax,buf2d_w
1902
		mov ecx,buf2d_h
1902
		mov ecx,buf2d_h
1903
		imul ecx,eax
1903
		imul ecx,eax
1904
		mov esi,ecx
1904
		mov esi,ecx
1905
		;ebx - ¯ ¬ïâì ¨§ ª®â®à®© ª®¯¨àã¥âáï
1905
		;ebx - ¯ ¬ïâì ¨§ ª®â®à®© ª®¯¨àã¥âáï
1906
		;edx - ¯ ¬ïâì ªã¤  ª®¯¨àã¥âáï
1906
		;edx - ¯ ¬ïâì ªã¤  ª®¯¨àã¥âáï
1907
		mov edx,buf2d_data
1907
		mov edx,buf2d_data
1908
		mov ebx,edx
1908
		mov ebx,edx
1909
		cmp [spectr],3
1909
		cmp [spectr],3
1910
		jge @f
1910
		jge @f
1911
			add ebx,[spectr]
1911
			add ebx,[spectr]
1912
		@@:
1912
		@@:
1913
			mov al,byte[ebx]
1913
			mov al,byte[ebx]
1914
			mov byte[edx],al
1914
			mov byte[edx],al
1915
			add ebx,3
1915
			add ebx,3
1916
			inc edx
1916
			inc edx
1917
			loop @b
1917
			loop @b
1918
		mov buf2d_bits,8
1918
		mov buf2d_bits,8
1919
		invoke mem.realloc,buf2d_data,esi ;㬥­ìè ¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
1919
		invoke mem.realloc,buf2d_data,esi ;㬥­ìè ¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
1920
		jmp .end_conv
1920
		jmp .end_conv
1921
	.error:
1921
	.error:
1922
		stdcall print_err,sz_buf2d_conv_24_to_8,txt_err_n24b
1922
		stdcall print_err,sz_buf2d_conv_24_to_8,txt_err_n24b
1923
	.end_conv:
1923
	.end_conv:
1924
	popad
1924
	popad
1925
	ret
1925
	ret
1926
endp
1926
endp
1927
 
1927
 
1928
;¯à¥®¡à §®¢ ­¨¥ ¡ãä¥à  ¨§ 24-¡¨â­®£® ¢ 32-¡¨â­ë©
1928
;¯à¥®¡à §®¢ ­¨¥ ¡ãä¥à  ¨§ 24-¡¨â­®£® ¢ 32-¡¨â­ë©
1929
align 4
1929
align 4
1930
proc buf_conv_24_to_32, buf_struc:dword, buf_str8:dword
1930
proc buf_conv_24_to_32, buf_struc:dword, buf_str8:dword
1931
	pushad
1931
	pushad
1932
	mov edi,dword[buf_struc]
1932
	mov edi,dword[buf_struc]
1933
	cmp buf2d_bits,24
1933
	cmp buf2d_bits,24
1934
	jne .error1
1934
	jne .error1
1935
		mov ecx,buf2d_w
1935
		mov ecx,buf2d_w
1936
		mov ebx,buf2d_h
1936
		mov ebx,buf2d_h
1937
		imul ebx,ecx
1937
		imul ebx,ecx
1938
		mov ecx,ebx ;ecx = size  8 b
1938
		mov ecx,ebx ;ecx = size  8 b
1939
		shl ebx,2   ;ebx = size 32 b
1939
		shl ebx,2   ;ebx = size 32 b
1940
		invoke mem.realloc,buf2d_data,ebx ;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
1940
		invoke mem.realloc,buf2d_data,ebx ;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
1941
		mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
1941
		mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
1942
		mov buf2d_bits,32
1942
		mov buf2d_bits,32
1943
		mov edx,ebx ;edx = size 32 b
1943
		mov edx,ebx ;edx = size 32 b
1944
		sub ebx,ecx ;ebx = size 24 b
1944
		sub ebx,ecx ;ebx = size 24 b
1945
		mov eax,ecx
1945
		mov eax,ecx
1946
		;eax - à §¬¥à  8 ¡¨â­ëå ¤ ­­ëå
1946
		;eax - à §¬¥à  8 ¡¨â­ëå ¤ ­­ëå
1947
		;ebx - à §¬¥à 24 ¡¨â­ëå ¤ ­­ëå
1947
		;ebx - à §¬¥à 24 ¡¨â­ëå ¤ ­­ëå
1948
		;edx - à §¬¥à 32 ¡¨â­ëå ¤ ­­ëå
1948
		;edx - à §¬¥à 32 ¡¨â­ëå ¤ ­­ëå
1949
		add ebx,buf2d_data
1949
		add ebx,buf2d_data
1950
		add edx,buf2d_data
1950
		add edx,buf2d_data
1951
		mov edi,dword[buf_str8]
1951
		mov edi,dword[buf_str8]
1952
		cmp buf2d_bits,8
1952
		cmp buf2d_bits,8
1953
		jne .error2
1953
		jne .error2
1954
		add eax,buf2d_data
1954
		add eax,buf2d_data
1955
		mov edi,edx
1955
		mov edi,edx
1956
		;eax - 㪠§ â¥«ì ­  ª®­¥æ  8 ¡¨â­ëå ¤ ­­ëå
1956
		;eax - 㪠§ â¥«ì ­  ª®­¥æ  8 ¡¨â­ëå ¤ ­­ëå
1957
		;ebx - 㪠§ â¥«ì ­  ª®­¥æ 24 ¡¨â­ëå ¤ ­­ëå
1957
		;ebx - 㪠§ â¥«ì ­  ª®­¥æ 24 ¡¨â­ëå ¤ ­­ëå
1958
		;edi - 㪠§ â¥«ì ­  ª®­¥æ 32 ¡¨â­ëå ¤ ­­ëå
1958
		;edi - 㪠§ â¥«ì ­  ª®­¥æ 32 ¡¨â­ëå ¤ ­­ëå
1959
		@@:
1959
		@@:
1960
			sub edi,4 ;®â­¨¬ ¥¬ ¢ ­ ç «¥ 横« ,
1960
			sub edi,4 ;®â­¨¬ ¥¬ ¢ ­ ç «¥ 横« ,
1961
			sub ebx,3 ; ¯®â®¬ã, ç⮠㪠§ â¥«¨ áâ®ïâ
1961
			sub ebx,3 ; ¯®â®¬ã, ç⮠㪠§ â¥«¨ áâ®ïâ
1962
			dec eax   ; §  ¯à¥¤¥« ¬¨ ¡ãä¥à®¢
1962
			dec eax   ; §  ¯à¥¤¥« ¬¨ ¡ãä¥à®¢
1963
			mov edx,dword[ebx]
1963
			mov edx,dword[ebx]
1964
			mov dword[edi],edx
1964
			mov dword[edi],edx
1965
			mov dl,byte[eax]
1965
			mov dl,byte[eax]
1966
			mov byte[edi+3],dl
1966
			mov byte[edi+3],dl
1967
			loop @b
1967
			loop @b
1968
 
1968
 
1969
		jmp .end_conv
1969
		jmp .end_conv
1970
	.error1:
1970
	.error1:
1971
		stdcall print_err,sz_buf2d_conv_24_to_32,txt_err_n24b
1971
		stdcall print_err,sz_buf2d_conv_24_to_32,txt_err_n24b
1972
		jmp .end_conv
1972
		jmp .end_conv
1973
	.error2:
1973
	.error2:
1974
		stdcall print_err,sz_buf2d_conv_24_to_32,txt_err_n8b
1974
		stdcall print_err,sz_buf2d_conv_24_to_32,txt_err_n8b
1975
	.end_conv:
1975
	.end_conv:
1976
	popad
1976
	popad
1977
	ret
1977
	ret
1978
endp
1978
endp
1979
 
1979
 
1980
;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (24b|32b) ¢ buf_destination (24b)
1980
;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (24b|32b) ¢ buf_destination (24b)
1981
; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
1981
; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
1982
; ¯à®§à ç­®áâì ¯à¨ ª®¯¨à®¢ ­¨¨ ­¥ ãç¨â뢠¥âáï
1982
; ¯à®§à ç­®áâì ¯à¨ ª®¯¨à®¢ ­¨¨ ­¥ ãç¨â뢠¥âáï
1983
align 4
1983
align 4
1984
proc buf_bit_blt, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword
1984
proc buf_bit_blt, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword
1985
	locals
1985
	locals
1986
		right_bytes dd ?
1986
		right_bytes dd ?
1987
	endl
1987
	endl
1988
	pushad
1988
	pushad
1989
 
1989
 
1990
	mov edi,[buf_source]
1990
	mov edi,[buf_source]
1991
	cmp buf2d_bits,24
1991
	cmp buf2d_bits,24
1992
	je .sou24
1992
	je .sou24
1993
	cmp buf2d_bits,32
1993
	cmp buf2d_bits,32
1994
	je .sou32
1994
	je .sou32
1995
		jmp .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
1995
		jmp .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
1996
 
1996
 
1997
	.sou24: ;¢ ¨áâ®ç­¨ª¥ 24 ¡¨â­ ï ª à⨭ª 
1997
	.sou24: ;¢ ¨áâ®ç­¨ª¥ 24 ¡¨â­ ï ª à⨭ª 
1998
	mov eax,buf2d_w
1998
	mov eax,buf2d_w
1999
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
1999
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2000
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2000
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2001
 
2001
 
2002
	mov edi,[buf_destination]
2002
	mov edi,[buf_destination]
2003
	cmp buf2d_bits,24
2003
	cmp buf2d_bits,24
2004
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2004
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2005
	mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
2005
	mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
2006
	cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
2006
	cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
2007
	jge .copy_end	  ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
2007
	jge .copy_end	  ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
2008
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2008
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2009
		mov ecx,[coord_y]
2009
		mov ecx,[coord_y]
2010
		cmp ecx,0
2010
		cmp ecx,0
2011
		jge @f
2011
		jge @f
2012
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2012
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2013
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2013
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2014
			cmp edx,0
2014
			cmp edx,0
2015
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2015
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2016
			neg ecx
2016
			neg ecx
2017
			;inc ecx
2017
			;inc ecx
2018
			imul ecx,eax
2018
			imul ecx,eax
2019
			lea ecx,[ecx+ecx*2] ;¯® 3 ¡ ©â  ­  ¯¨ªá¥«ì
2019
			lea ecx,[ecx+ecx*2] ;¯® 3 ¡ ©â  ­  ¯¨ªá¥«ì
2020
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2020
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2021
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2021
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2022
		@@:
2022
		@@:
2023
		cmp ecx,ebx
2023
		cmp ecx,ebx
2024
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2024
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2025
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2025
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2026
		cmp ecx,ebx
2026
		cmp ecx,ebx
2027
		jle @f
2027
		jle @f
2028
			sub ecx,ebx
2028
			sub ecx,ebx
2029
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2029
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2030
		@@:
2030
		@@:
2031
		mov ebx,buf2d_w
2031
		mov ebx,buf2d_w
2032
		mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2032
		mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2033
		cmp ecx,0
2033
		cmp ecx,0
2034
		jg .end_otr_c_y_24
2034
		jg .end_otr_c_y_24
2035
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2035
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2036
			mov ecx,[coord_x]
2036
			mov ecx,[coord_x]
2037
			jmp @f
2037
			jmp @f
2038
		.end_otr_c_y_24:
2038
		.end_otr_c_y_24:
2039
		imul ecx,ebx
2039
		imul ecx,ebx
2040
		add ecx,[coord_x]
2040
		add ecx,[coord_x]
2041
		@@:
2041
		@@:
2042
		lea ecx,[ecx+ecx*2]
2042
		lea ecx,[ecx+ecx*2]
2043
		add ecx,buf2d_data
2043
		add ecx,buf2d_data
2044
		sub ebx,eax
2044
		sub ebx,eax
2045
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2045
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2046
 
2046
 
2047
	mov [right_bytes],0
2047
	mov [right_bytes],0
2048
	mov ecx,[coord_x]
2048
	mov ecx,[coord_x]
2049
	cmp ecx,ebx
2049
	cmp ecx,ebx
2050
	jl @f
2050
	jl @f
2051
		sub ecx,ebx
2051
		sub ecx,ebx
2052
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2052
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2053
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2053
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2054
		lea ecx,[ecx+ecx*2] ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2054
		lea ecx,[ecx+ecx*2] ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2055
		mov [right_bytes],ecx
2055
		mov [right_bytes],ecx
2056
	@@:
2056
	@@:
2057
 
2057
 
2058
	lea eax,[eax+eax*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2058
	lea eax,[eax+eax*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2059
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2059
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2060
 
2060
 
2061
	cld
2061
	cld
2062
	cmp [right_bytes],0
2062
	cmp [right_bytes],0
2063
	jg .copy_1
2063
	jg .copy_1
2064
	.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2064
	.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2065
		mov ecx,eax
2065
		mov ecx,eax
2066
		rep movsb
2066
		rep movsb
2067
		add edi,ebx
2067
		add edi,ebx
2068
		dec edx
2068
		dec edx
2069
		cmp edx,0
2069
		cmp edx,0
2070
		jg .copy_0
2070
		jg .copy_0
2071
	jmp .copy_end
2071
	jmp .copy_end
2072
	.copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
2072
	.copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
2073
		mov ecx,eax
2073
		mov ecx,eax
2074
		rep movsb
2074
		rep movsb
2075
		add edi,ebx
2075
		add edi,ebx
2076
		add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2076
		add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2077
		dec edx
2077
		dec edx
2078
		cmp edx,0
2078
		cmp edx,0
2079
		jg .copy_1
2079
		jg .copy_1
2080
	jmp .copy_end
2080
	jmp .copy_end
2081
 
2081
 
2082
	.sou32: ;¢ ¨áâ®ç­¨ª¥ 32 ¡¨â­ ï ª à⨭ª 
2082
	.sou32: ;¢ ¨áâ®ç­¨ª¥ 32 ¡¨â­ ï ª à⨭ª 
2083
	mov eax,buf2d_w
2083
	mov eax,buf2d_w
2084
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2084
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2085
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2085
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2086
 
2086
 
2087
	mov edi,[buf_destination]
2087
	mov edi,[buf_destination]
2088
	cmp buf2d_bits,24
2088
	cmp buf2d_bits,24
2089
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2089
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2090
	mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
2090
	mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
2091
	cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
2091
	cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
2092
	jge .copy_end	  ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
2092
	jge .copy_end	  ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
2093
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2093
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2094
		mov ecx,[coord_y]
2094
		mov ecx,[coord_y]
2095
		cmp ecx,0
2095
		cmp ecx,0
2096
		jge @f
2096
		jge @f
2097
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2097
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2098
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2098
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2099
			cmp edx,0
2099
			cmp edx,0
2100
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2100
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2101
			neg ecx
2101
			neg ecx
2102
			;inc ecx
2102
			;inc ecx
2103
			imul ecx,eax
2103
			imul ecx,eax
2104
			shl ecx,2 ;¯® 4 ¡ ©â  ­  ¯¨ªá¥«ì
2104
			shl ecx,2 ;¯® 4 ¡ ©â  ­  ¯¨ªá¥«ì
2105
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2105
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2106
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2106
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2107
		@@:
2107
		@@:
2108
		cmp ecx,ebx
2108
		cmp ecx,ebx
2109
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2109
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2110
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2110
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2111
		cmp ecx,ebx
2111
		cmp ecx,ebx
2112
		jle @f
2112
		jle @f
2113
			sub ecx,ebx
2113
			sub ecx,ebx
2114
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2114
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2115
		@@:
2115
		@@:
2116
		mov ebx,buf2d_w
2116
		mov ebx,buf2d_w
2117
		;mov ecx,ebx ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2117
		;mov ecx,ebx ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2118
		;imul ecx,[coord_y]
2118
		;imul ecx,[coord_y]
2119
		;add ecx,[coord_x]
2119
		;add ecx,[coord_x]
2120
		mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2120
		mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2121
		cmp ecx,0
2121
		cmp ecx,0
2122
		jg .end_otr_c_y_32
2122
		jg .end_otr_c_y_32
2123
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2123
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2124
			mov ecx,[coord_x]
2124
			mov ecx,[coord_x]
2125
			jmp @f
2125
			jmp @f
2126
		.end_otr_c_y_32:
2126
		.end_otr_c_y_32:
2127
		imul ecx,ebx
2127
		imul ecx,ebx
2128
		add ecx,[coord_x]
2128
		add ecx,[coord_x]
2129
		@@:
2129
		@@:
2130
		lea ecx,[ecx+ecx*2]
2130
		lea ecx,[ecx+ecx*2]
2131
		add ecx,buf2d_data
2131
		add ecx,buf2d_data
2132
		sub ebx,eax
2132
		sub ebx,eax
2133
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2133
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2134
 
2134
 
2135
	mov [right_bytes],0
2135
	mov [right_bytes],0
2136
	mov ecx,[coord_x]
2136
	mov ecx,[coord_x]
2137
	cmp ecx,ebx
2137
	cmp ecx,ebx
2138
	jl @f
2138
	jl @f
2139
		sub ecx,ebx
2139
		sub ecx,ebx
2140
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2140
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2141
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2141
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2142
		shl ecx,2 ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2142
		shl ecx,2 ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2143
		mov [right_bytes],ecx
2143
		mov [right_bytes],ecx
2144
	@@:
2144
	@@:
2145
 
2145
 
2146
	;eax - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2146
	;eax - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2147
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2147
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2148
 
2148
 
2149
	cld
2149
	cld
2150
	cmp [right_bytes],0
2150
	cmp [right_bytes],0
2151
	jg .copy_3
2151
	jg .copy_3
2152
	.copy_2: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2152
	.copy_2: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2153
		mov ecx,eax
2153
		mov ecx,eax
2154
		@@:
2154
		@@:
2155
			movsw
2155
			movsw
2156
			movsb
2156
			movsb
2157
			inc esi
2157
			inc esi
2158
			loop @b
2158
			loop @b
2159
		add edi,ebx
2159
		add edi,ebx
2160
		dec edx
2160
		dec edx
2161
		cmp edx,0
2161
		cmp edx,0
2162
		jg .copy_2
2162
		jg .copy_2
2163
	jmp .copy_end
2163
	jmp .copy_end
2164
	.copy_3: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
2164
	.copy_3: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
2165
		mov ecx,eax
2165
		mov ecx,eax
2166
		@@:
2166
		@@:
2167
			movsw
2167
			movsw
2168
			movsb
2168
			movsb
2169
			inc esi
2169
			inc esi
2170
			loop @b
2170
			loop @b
2171
		add edi,ebx
2171
		add edi,ebx
2172
		add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2172
		add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2173
		dec edx
2173
		dec edx
2174
		cmp edx,0
2174
		cmp edx,0
2175
		jg .copy_3
2175
		jg .copy_3
2176
 
2176
 
2177
	.copy_end:
2177
	.copy_end:
2178
	popad
2178
	popad
2179
	ret
2179
	ret
2180
endp
2180
endp
2181
 
2181
 
2182
;input:
2182
;input:
2183
; esi = pointer to color1 + transparent
2183
; esi = pointer to color1 + transparent
2184
; edi = pointer to background color2
2184
; edi = pointer to background color2
2185
;output:
2185
;output:
2186
; [edi] = combine color
2186
; [edi] = combine color
2187
align 4
2187
align 4
2188
combine_colors:
2188
combine_colors:
2189
	push ax bx cx dx
2189
	push ax bx cx dx
2190
	mov bx,0x00ff ;---get transparent---
2190
	mov bx,0x00ff ;---get transparent---
2191
	movzx cx,byte[esi+3] ;pro
2191
	movzx cx,byte[esi+3] ;pro
2192
	sub bx,cx ;256-pro
2192
	sub bx,cx ;256-pro
2193
	;---blye---
2193
	;---blye---
2194
	movzx ax,byte[esi]
2194
	movzx ax,byte[esi]
2195
	imul ax,bx
2195
	imul ax,bx
2196
	movzx dx,byte[edi]
2196
	movzx dx,byte[edi]
2197
	imul dx,cx
2197
	imul dx,cx
2198
	add ax,dx
2198
	add ax,dx
2199
	mov byte[edi],ah
2199
	mov byte[edi],ah
2200
	;---green---
2200
	;---green---
2201
	movzx ax,byte[esi+1]
2201
	movzx ax,byte[esi+1]
2202
	imul ax,bx
2202
	imul ax,bx
2203
	movzx dx,byte[edi+1]
2203
	movzx dx,byte[edi+1]
2204
	imul dx,cx
2204
	imul dx,cx
2205
	add ax,dx
2205
	add ax,dx
2206
	mov byte[edi+1],ah
2206
	mov byte[edi+1],ah
2207
	;---red---
2207
	;---red---
2208
	movzx ax,byte[esi+2]
2208
	movzx ax,byte[esi+2]
2209
	imul ax,bx
2209
	imul ax,bx
2210
	movzx dx,byte[edi+2]
2210
	movzx dx,byte[edi+2]
2211
	imul dx,cx
2211
	imul dx,cx
2212
	add ax,dx
2212
	add ax,dx
2213
	mov byte[edi+2],ah
2213
	mov byte[edi+2],ah
2214
 
2214
 
2215
	pop dx cx bx ax
2215
	pop dx cx bx ax
2216
	ret
2216
	ret
2217
 
2217
 
2218
;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (32b) ¢ buf_destination (24b)
2218
;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (32b) ¢ buf_destination (24b)
2219
; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
2219
; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
2220
; ¯à¨ ª®¯¨à®¢ ­¨¨ ãç¨â뢠¥âáï ¯à®§à ç­®áâì
2220
; ¯à¨ ª®¯¨à®¢ ­¨¨ ãç¨â뢠¥âáï ¯à®§à ç­®áâì
2221
align 4
2221
align 4
2222
proc buf_bit_blt_transp, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword
2222
proc buf_bit_blt_transp, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword
2223
	locals
2223
	locals
2224
		right_bytes dd ?
2224
		right_bytes dd ?
2225
	endl
2225
	endl
2226
	pushad
2226
	pushad
2227
 
2227
 
2228
	mov edi,[buf_source]
2228
	mov edi,[buf_source]
2229
	cmp buf2d_bits,32
2229
	cmp buf2d_bits,32
2230
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2230
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2231
	mov eax,buf2d_w
2231
	mov eax,buf2d_w
2232
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2232
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2233
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2233
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2234
 
2234
 
2235
	mov edi,[buf_destination]
2235
	mov edi,[buf_destination]
2236
	cmp buf2d_bits,24
2236
	cmp buf2d_bits,24
2237
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2237
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2238
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2238
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2239
		mov ecx,[coord_y]
2239
		mov ecx,[coord_y]
2240
		cmp ecx,0
2240
		cmp ecx,0
2241
		jge @f
2241
		jge @f
2242
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2242
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2243
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2243
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2244
			cmp edx,0
2244
			cmp edx,0
2245
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2245
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2246
			neg ecx
2246
			neg ecx
2247
			;inc ecx
2247
			;inc ecx
2248
			imul ecx,eax
2248
			imul ecx,eax
2249
			shl ecx,2 ;¯® 4 ¡ ©â  ­  ¯¨ªá¥«ì
2249
			shl ecx,2 ;¯® 4 ¡ ©â  ­  ¯¨ªá¥«ì
2250
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2250
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2251
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2251
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2252
		@@:
2252
		@@:
2253
		cmp ecx,ebx
2253
		cmp ecx,ebx
2254
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2254
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2255
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2255
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2256
		cmp ecx,ebx
2256
		cmp ecx,ebx
2257
		jle @f
2257
		jle @f
2258
			sub ecx,ebx
2258
			sub ecx,ebx
2259
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2259
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2260
		@@:
2260
		@@:
2261
		mov ebx,buf2d_w
2261
		mov ebx,buf2d_w
2262
		mov ecx,ebx ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2262
		mov ecx,ebx ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2263
		cmp [coord_y],0
2263
		cmp [coord_y],0
2264
		jg .end_otr_c_y
2264
		jg .end_otr_c_y
2265
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2265
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2266
			mov ecx,[coord_x]
2266
			mov ecx,[coord_x]
2267
			jmp @f
2267
			jmp @f
2268
		.end_otr_c_y:
2268
		.end_otr_c_y:
2269
		imul ecx,[coord_y]
2269
		imul ecx,[coord_y]
2270
		add ecx,[coord_x]
2270
		add ecx,[coord_x]
2271
		@@:
2271
		@@:
2272
		lea ecx,[ecx+ecx*2]
2272
		lea ecx,[ecx+ecx*2]
2273
		add ecx,buf2d_data
2273
		add ecx,buf2d_data
2274
		sub ebx,eax
2274
		sub ebx,eax
2275
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2275
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2276
 
2276
 
2277
	mov [right_bytes],0
2277
	mov [right_bytes],0
2278
	mov ecx,[coord_x]
2278
	mov ecx,[coord_x]
2279
	cmp ecx,ebx
2279
	cmp ecx,ebx
2280
	jl @f
2280
	jl @f
2281
		sub ecx,ebx
2281
		sub ecx,ebx
2282
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2282
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2283
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2283
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2284
		shl ecx,2 ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2284
		shl ecx,2 ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2285
		mov [right_bytes],ecx
2285
		mov [right_bytes],ecx
2286
	@@:
2286
	@@:
2287
 
2287
 
2288
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2288
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2289
 
2289
 
2290
	cld
2290
	cld
2291
	cmp [right_bytes],0
2291
	cmp [right_bytes],0
2292
	jg .copy_1
2292
	jg .copy_1
2293
	.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2293
	.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2294
		mov ecx,eax
2294
		mov ecx,eax
2295
		@@:
2295
		@@:
2296
			call combine_colors
2296
			call combine_colors
2297
			add edi,3
2297
			add edi,3
2298
			add esi,4
2298
			add esi,4
2299
			loop @b
2299
			loop @b
2300
		add edi,ebx
2300
		add edi,ebx
2301
		dec edx
2301
		dec edx
2302
		cmp edx,0
2302
		cmp edx,0
2303
		jg .copy_0
2303
		jg .copy_0
2304
	jmp .copy_end
2304
	jmp .copy_end
2305
	.copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
2305
	.copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
2306
		mov ecx,eax
2306
		mov ecx,eax
2307
		@@:
2307
		@@:
2308
			call combine_colors
2308
			call combine_colors
2309
			add edi,3
2309
			add edi,3
2310
			add esi,4
2310
			add esi,4
2311
			loop @b
2311
			loop @b
2312
		add edi,ebx
2312
		add edi,ebx
2313
		add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2313
		add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2314
		dec edx
2314
		dec edx
2315
		cmp edx,0
2315
		cmp edx,0
2316
		jg .copy_1
2316
		jg .copy_1
2317
 
2317
 
2318
	.copy_end:
2318
	.copy_end:
2319
	popad
2319
	popad
2320
	ret
2320
	ret
2321
endp
2321
endp
2322
 
2322
 
2323
;input:
2323
;input:
2324
; ebx - color1
2324
; ebx - color1
2325
; esi = pointer to transparent
2325
; esi = pointer to transparent
2326
; edi = pointer to background color2
2326
; edi = pointer to background color2
2327
;output:
2327
;output:
2328
; [edi] = combine color
2328
; [edi] = combine color
2329
align 4
2329
align 4
2330
combine_colors_2:
2330
combine_colors_2:
2331
	push ax ebx cx dx si
2331
	push ax ebx cx dx si
2332
	mov cl,byte[esi] ;pro
2332
	mov cl,byte[esi] ;pro
2333
	xor ch,ch
2333
	xor ch,ch
2334
	mov si,0x00ff ;---get transparent---
2334
	mov si,0x00ff ;---get transparent---
2335
	sub si,cx ;256-pro
2335
	sub si,cx ;256-pro
2336
 
2336
 
2337
		;---blye---
2337
		;---blye---
2338
		movzx ax,bl
2338
		movzx ax,bl
2339
		shr ebx,8
2339
		shr ebx,8
2340
		imul ax,si
2340
		imul ax,si
2341
		movzx dx,byte[edi]
2341
		movzx dx,byte[edi]
2342
		imul dx,cx
2342
		imul dx,cx
2343
		add ax,dx
2343
		add ax,dx
2344
		mov byte[edi],ah
2344
		mov byte[edi],ah
2345
		;---green---
2345
		;---green---
2346
		movzx ax,bl
2346
		movzx ax,bl
2347
		shr ebx,8
2347
		shr ebx,8
2348
		imul ax,si
2348
		imul ax,si
2349
		movzx dx,byte[edi+1]
2349
		movzx dx,byte[edi+1]
2350
		imul dx,cx
2350
		imul dx,cx
2351
		add ax,dx
2351
		add ax,dx
2352
		mov byte[edi+1],ah
2352
		mov byte[edi+1],ah
2353
		;---red---
2353
		;---red---
2354
		movzx ax,bl
2354
		movzx ax,bl
2355
		imul ax,si
2355
		imul ax,si
2356
		movzx dx,byte[edi+2]
2356
		movzx dx,byte[edi+2]
2357
		imul dx,cx
2357
		imul dx,cx
2358
		add ax,dx
2358
		add ax,dx
2359
		mov byte[edi+2],ah
2359
		mov byte[edi+2],ah
2360
 
2360
 
2361
	pop si dx cx ebx ax
2361
	pop si dx cx ebx ax
2362
	ret
2362
	ret
2363
 
2363
 
2364
;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (8b) ¢ buf_destination (24b)
2364
;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (8b) ¢ buf_destination (24b)
2365
; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
2365
; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
2366
align 4
2366
align 4
2367
proc buf_bit_blt_alpha, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword, color:dword
2367
proc buf_bit_blt_alpha, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword, color:dword
2368
	locals
2368
	locals
2369
		lost_bytes dd ? ;ç¨á«® ¯®â¥àï­­ëå ¡ ©â®¢ ¢ áâப¥ ª®¯¨à㥬®£® ¨§®¡à ¦¥­ï (â¥å çâ® ­¥ ¢« §ïâ ¢ ¡ãä¥à)
2369
		lost_bytes dd ? ;ç¨á«® ¯®â¥àï­­ëå ¡ ©â®¢ ¢ áâப¥ ª®¯¨à㥬®£® ¨§®¡à ¦¥­ï (â¥å çâ® ­¥ ¢« §ïâ ¢ ¡ãä¥à)
2370
		dest_w_bytes dd ? ;ª®««¨ç¥á⢮ ¡ ©â ¢ ¡ãä¥à¥ ¯à¨¥¬­¨ª¥ ¯® è¨à¨­¥ - è¨à¨­  ¢áâ ¢«ï¥¬®© ª à⨭ª¨
2370
		dest_w_bytes dd ? ;ª®««¨ç¥á⢮ ¡ ©â ¢ ¡ãä¥à¥ ¯à¨¥¬­¨ª¥ ¯® è¨à¨­¥ - è¨à¨­  ¢áâ ¢«ï¥¬®© ª à⨭ª¨
2371
	endl
2371
	endl
2372
	pushad
2372
	pushad
2373
 
2373
 
2374
	mov edi,[buf_source]
2374
	mov edi,[buf_source]
2375
	cmp buf2d_bits,8
2375
	cmp buf2d_bits,8
2376
	jne .error1 ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2376
	jne .error1 ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2377
	mov eax,buf2d_w ;è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
2377
	mov eax,buf2d_w ;è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
2378
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2378
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2379
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2379
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2380
 
2380
 
2381
	mov edi,[buf_destination]
2381
	mov edi,[buf_destination]
2382
	cmp buf2d_bits,24
2382
	cmp buf2d_bits,24
2383
	jne .error2 ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2383
	jne .error2 ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2384
	mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
2384
	mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
2385
	cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
2385
	cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
2386
	jge .copy_end	  ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
2386
	jge .copy_end	  ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
2387
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2387
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2388
		mov ecx,[coord_y]
2388
		mov ecx,[coord_y]
2389
		cmp ecx,0
2389
		cmp ecx,0
2390
		jge @f
2390
		jge @f
2391
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2391
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2392
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2392
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2393
			cmp edx,0
2393
			cmp edx,0
2394
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2394
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2395
			neg ecx
2395
			neg ecx
2396
			;inc ecx
2396
			;inc ecx
2397
			imul ecx,eax
2397
			imul ecx,eax
2398
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2398
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2399
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2399
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2400
		@@:
2400
		@@:
2401
		cmp ecx,ebx
2401
		cmp ecx,ebx
2402
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2402
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2403
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2403
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2404
		cmp ecx,ebx
2404
		cmp ecx,ebx
2405
		jle @f
2405
		jle @f
2406
			sub ecx,ebx
2406
			sub ecx,ebx
2407
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2407
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2408
		@@:
2408
		@@:
2409
		mov ebx,buf2d_w
2409
		mov ebx,buf2d_w
2410
		mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2410
		mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2411
		cmp ecx,0
2411
		cmp ecx,0
2412
		jg .end_otr_c_y
2412
		jg .end_otr_c_y
2413
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2413
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2414
			mov ecx,[coord_x]
2414
			mov ecx,[coord_x]
2415
			jmp @f
2415
			jmp @f
2416
		.end_otr_c_y:
2416
		.end_otr_c_y:
2417
		imul ecx,ebx
2417
		imul ecx,ebx
2418
		add ecx,[coord_x]
2418
		add ecx,[coord_x]
2419
		@@:
2419
		@@:
2420
		lea ecx,[ecx+ecx*2]
2420
		lea ecx,[ecx+ecx*2]
2421
		add ecx,buf2d_data ;buf2d_data ¤ ­­ë¥ ®á­®¢­®£® ¡ãä¥à 
2421
		add ecx,buf2d_data ;buf2d_data ¤ ­­ë¥ ®á­®¢­®£® ¡ãä¥à 
2422
		sub ebx,eax ;ebx - è¨à¨­  ®á­®¢­®£® ¡ãä¥à  ¬¨­ãá è¨à¨­  à¨á㥬®£® ¡ãä¥à 
2422
		sub ebx,eax ;ebx - è¨à¨­  ®á­®¢­®£® ¡ãä¥à  ¬¨­ãá è¨à¨­  à¨á㥬®£® ¡ãä¥à 
2423
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2423
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2424
 
2424
 
2425
	mov dword[lost_bytes],0
2425
	mov dword[lost_bytes],0
2426
	mov ecx,[coord_x]
2426
	mov ecx,[coord_x]
2427
	cmp ecx,0
2427
	cmp ecx,0
2428
	jge @f
2428
	jge @f
2429
		neg ecx
2429
		neg ecx
2430
		;inc ecx
2430
		;inc ecx
2431
		cmp eax,ecx ;eax - è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
2431
		cmp eax,ecx ;eax - è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
2432
		jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî §  «¥¢®© £à ­¨æ¥© ¡ãä¥à  (coord_x<0 ¨ |coord_x|>buf_source.w)
2432
		jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî §  «¥¢®© £à ­¨æ¥© ¡ãä¥à  (coord_x<0 ¨ |coord_x|>buf_source.w)
2433
		add [lost_bytes],ecx
2433
		add [lost_bytes],ecx
2434
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2434
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2435
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2435
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2436
		add esi,ecx
2436
		add esi,ecx
2437
		lea ecx,[ecx+ecx*2]
2437
		lea ecx,[ecx+ecx*2]
2438
		add edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2438
		add edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2439
		xor ecx,ecx
2439
		xor ecx,ecx
2440
	@@:
2440
	@@:
2441
	cmp ecx,ebx
2441
	cmp ecx,ebx
2442
	jle @f
2442
	jle @f
2443
		sub ecx,ebx
2443
		sub ecx,ebx
2444
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2444
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2445
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2445
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2446
		;ecx - ç¨á«® ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2446
		;ecx - ç¨á«® ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2447
		add [lost_bytes],ecx
2447
		add [lost_bytes],ecx
2448
	@@:
2448
	@@:
2449
 
2449
 
2450
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2450
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2451
	mov [dest_w_bytes],ebx
2451
	mov [dest_w_bytes],ebx
2452
	mov ebx,[color]
2452
	mov ebx,[color]
2453
 
2453
 
2454
	cld
2454
	cld
2455
	cmp dword[lost_bytes],0
2455
	cmp dword[lost_bytes],0
2456
	jg .copy_1
2456
	jg .copy_1
2457
	.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2457
	.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2458
		mov ecx,eax
2458
		mov ecx,eax
2459
		@@:
2459
		@@:
2460
			call combine_colors_2
2460
			call combine_colors_2
2461
			add edi,3
2461
			add edi,3
2462
			inc esi
2462
			inc esi
2463
			loop @b
2463
			loop @b
2464
		add edi,[dest_w_bytes]
2464
		add edi,[dest_w_bytes]
2465
		dec edx
2465
		dec edx
2466
		cmp edx,0
2466
		cmp edx,0
2467
		jg .copy_0
2467
		jg .copy_0
2468
	jmp .copy_end
2468
	jmp .copy_end
2469
	.copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  «¥¢ãî ¨/¨«¨ ¯à ¢ãî áâ®à®­ã)
2469
	.copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  «¥¢ãî ¨/¨«¨ ¯à ¢ãî áâ®à®­ã)
2470
		mov ecx,eax
2470
		mov ecx,eax
2471
		@@:
2471
		@@:
2472
			call combine_colors_2
2472
			call combine_colors_2
2473
			add edi,3
2473
			add edi,3
2474
			inc esi
2474
			inc esi
2475
			loop @b
2475
			loop @b
2476
		add edi,[dest_w_bytes]
2476
		add edi,[dest_w_bytes]
2477
		add esi,[lost_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2477
		add esi,[lost_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2478
		dec edx
2478
		dec edx
2479
		cmp edx,0
2479
		cmp edx,0
2480
		jg .copy_1
2480
		jg .copy_1
2481
 
2481
 
2482
	jmp .copy_end
2482
	jmp .copy_end
2483
	.error1:
2483
	.error1:
2484
		stdcall print_err,sz_buf2d_bit_blt_alpha,txt_err_n8b
2484
		stdcall print_err,sz_buf2d_bit_blt_alpha,txt_err_n8b
2485
		jmp .copy_end
2485
		jmp .copy_end
2486
	.error2:
2486
	.error2:
2487
		stdcall print_err,sz_buf2d_bit_blt_alpha,txt_err_n24b
2487
		stdcall print_err,sz_buf2d_bit_blt_alpha,txt_err_n24b
2488
	.copy_end:
2488
	.copy_end:
2489
	popad
2489
	popad
2490
	ret
2490
	ret
2491
endp
2491
endp
2492
 
2492
 
2493
;¯à¥®¡à §®¢ ­¨¥ 8-¡¨â­®£® ¡ãä¥à  à §¬¥à®¬ 16*16 ¢ à §¬¥à 1*256 ᨬ¢®«®¢
2493
;¯à¥®¡à §®¢ ­¨¥ 8-¡¨â­®£® ¡ãä¥à  à §¬¥à®¬ 16*16 ¢ à §¬¥à 1*256 ᨬ¢®«®¢
2494
align 4
2494
align 4
2495
proc buf_convert_text_matrix, buf_struc:dword
2495
proc buf_convert_text_matrix, buf_struc:dword
2496
	locals
2496
	locals
2497
		tmp_mem dd ?
2497
		tmp_mem dd ?
2498
		c1 dw ?
2498
		c1 dw ?
2499
		c2 dd ?
2499
		c2 dd ?
2500
		c3 dw ?
2500
		c3 dw ?
2501
	endl
2501
	endl
2502
	pushad
2502
	pushad
2503
	mov edi,dword[buf_struc]
2503
	mov edi,dword[buf_struc]
2504
	cmp buf2d_bits,8
2504
	cmp buf2d_bits,8
2505
	jne .error
2505
	jne .error
2506
		mov ecx,buf2d_h
2506
		mov ecx,buf2d_h
2507
		mov ebx,ecx
2507
		mov ebx,ecx
2508
		shr ebx,4 ;¯à¥¤¯®« £ ¥¬ çâ® ¢ ¡ãä¥à¥ 16 áâப á ᨬ¢®« ¬¨, ¯®â®¬ã ¤¥«¨¬ ­  2^4
2508
		shr ebx,4 ;¯à¥¤¯®« £ ¥¬ çâ® ¢ ¡ãä¥à¥ 16 áâப á ᨬ¢®« ¬¨, ¯®â®¬ã ¤¥«¨¬ ­  2^4
2509
		mov edx,buf2d_w
2509
		mov edx,buf2d_w
2510
		imul ecx,edx ;ecx = size  8 b
2510
		imul ecx,edx ;ecx = size  8 b
2511
		invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¢à¥¬¥­­ãî ¯ ¬ïâì
2511
		invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¢à¥¬¥­­ãî ¯ ¬ïâì
2512
		mov [tmp_mem],eax ;eax - new memory
2512
		mov [tmp_mem],eax ;eax - new memory
2513
 
2513
 
2514
		shr edx,4 ;¯à¥¤¯®« £ ¥¬ çâ® ¢ ¡ãä¥à¥ 16 ª®«®­®ª á ᨬ¢®« ¬¨, ¯®â®¬ã ¤¥«¨¬ ­  2^4
2514
		shr edx,4 ;¯à¥¤¯®« £ ¥¬ çâ® ¢ ¡ãä¥à¥ 16 ª®«®­®ª á ᨬ¢®« ¬¨, ¯®â®¬ã ¤¥«¨¬ ­  2^4
2515
		mov eax,ebx
2515
		mov eax,ebx
2516
		imul ebx,edx ;¢ëç¨á«ï¥¬ ª®®«¨ç¥á⢮ ¯¨ªá¥«¥© ­  1 ᨬ¢®«
2516
		imul ebx,edx ;¢ëç¨á«ï¥¬ ª®®«¨ç¥á⢮ ¯¨ªá¥«¥© ­  1 ᨬ¢®«
2517
		;eax = bhe - ¢ëá®â  ¡ãª¢ë
2517
		;eax = bhe - ¢ëá®â  ¡ãª¢ë
2518
		;ebx = bwi*bhe - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ 1-© ¡ãª¢¥
2518
		;ebx = bwi*bhe - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ 1-© ¡ãª¢¥
2519
		;edx = bwi - è¨à¨­  ¡ãª¢ë
2519
		;edx = bwi - è¨à¨­  ¡ãª¢ë
2520
		;ecx,esi,edi - ¨á¯®«ì§ãîâáï ¢ 横«¥ .c_0
2520
		;ecx,esi,edi - ¨á¯®«ì§ãîâáï ¢ 横«¥ .c_0
2521
		shr buf2d_w,4
2521
		shr buf2d_w,4
2522
		shl buf2d_h,4 ;¯à¥®¡à §®¢ë¢ ¥¬ à §¬¥àë ¡ãä¥à 
2522
		shl buf2d_h,4 ;¯à¥®¡à §®¢ë¢ ¥¬ à §¬¥àë ¡ãä¥à 
2523
 
2523
 
2524
		cld
2524
		cld
2525
		mov esi,buf2d_data
2525
		mov esi,buf2d_data
2526
		mov edi,[tmp_mem]
2526
		mov edi,[tmp_mem]
2527
		mov word[c3],16
2527
		mov word[c3],16
2528
		.c_3:
2528
		.c_3:
2529
			mov dword[c2],eax
2529
			mov dword[c2],eax
2530
			.c_2:
2530
			.c_2:
2531
				mov word[c1],16
2531
				mov word[c1],16
2532
				.c_1:
2532
				.c_1:
2533
					mov ecx,edx ;.c_0:
2533
					mov ecx,edx ;.c_0:
2534
					rep movsb
2534
					rep movsb
2535
					add edi,ebx
2535
					add edi,ebx
2536
					sub edi,edx ;edi+=(bwi*bhe-bwi)
2536
					sub edi,edx ;edi+=(bwi*bhe-bwi)
2537
					dec word[c1]
2537
					dec word[c1]
2538
					cmp word[c1],0
2538
					cmp word[c1],0
2539
					jg .c_1
2539
					jg .c_1
2540
				add edi,edx
2540
				add edi,edx
2541
				shl ebx,4
2541
				shl ebx,4
2542
				sub edi,ebx ;edi-=(16*bwi*bhe-bwi)
2542
				sub edi,ebx ;edi-=(16*bwi*bhe-bwi)
2543
				shr ebx,4
2543
				shr ebx,4
2544
				dec dword[c2]
2544
				dec dword[c2]
2545
				cmp dword[c2],0
2545
				cmp dword[c2],0
2546
				jg .c_2
2546
				jg .c_2
2547
			sub edi,ebx
2547
			sub edi,ebx
2548
			shl ebx,4
2548
			shl ebx,4
2549
			add edi,ebx ;edi+=(15*bwi*bhe)
2549
			add edi,ebx ;edi+=(15*bwi*bhe)
2550
			shr ebx,4
2550
			shr ebx,4
2551
			dec word[c3]
2551
			dec word[c3]
2552
			cmp word[c3],0
2552
			cmp word[c3],0
2553
			jg .c_3
2553
			jg .c_3
2554
 
2554
 
2555
		mov edi,dword[buf_struc] ;ª®¯¨à®¢ ­¨¥ ­®¢®© ¬ âà¨æë ¢ ®á­®¢­®© ¡ãä¥à
2555
		mov edi,dword[buf_struc] ;ª®¯¨à®¢ ­¨¥ ­®¢®© ¬ âà¨æë ¢ ®á­®¢­®© ¡ãä¥à
2556
		mov edi,buf2d_data
2556
		mov edi,buf2d_data
2557
		mov esi,[tmp_mem]
2557
		mov esi,[tmp_mem]
2558
		mov ecx,ebx
2558
		mov ecx,ebx
2559
		shl ecx,8
2559
		shl ecx,8
2560
		rep movsb
2560
		rep movsb
2561
		invoke mem.free,[tmp_mem] ;ç¨á⨬ ¢à¥¬¥­­ãî ¯ ¬ïâì
2561
		invoke mem.free,[tmp_mem] ;ç¨á⨬ ¢à¥¬¥­­ãî ¯ ¬ïâì
2562
		jmp .end_conv
2562
		jmp .end_conv
2563
	.error:
2563
	.error:
2564
		stdcall print_err,sz_buf2d_convert_text_matrix,txt_err_n8b
2564
		stdcall print_err,sz_buf2d_convert_text_matrix,txt_err_n8b
2565
	.end_conv:
2565
	.end_conv:
2566
	popad
2566
	popad
2567
	ret
2567
	ret
2568
endp
2568
endp
2569
 
2569
 
2570
align 4
2570
align 4
2571
buf_s_matr buf_2d_header ? ;«®ª «ì­ ï ¬ âà¨æ  ᨬ¢®« 
2571
buf_s_matr buf_2d_header ? ;«®ª «ì­ ï ¬ âà¨æ  ᨬ¢®« 
2572
 
2572
 
2573
align 4
2573
align 4
2574
proc buf_draw_text, buf_struc:dword, buf_t_matr:dword, text:dword, coord_x:dword, coord_y:dword, color:dword
2574
proc buf_draw_text, buf_struc:dword, buf_t_matr:dword, text:dword, coord_x:dword, coord_y:dword, color:dword
2575
	locals
2575
	locals
2576
		buf_t_matr_offs dd ?
2576
		buf_t_matr_offs dd ?
2577
	endl
2577
	endl
2578
	pushad
2578
	pushad
2579
	mov edi,dword[buf_struc]
2579
	mov edi,dword[buf_struc]
2580
	cmp buf2d_bits,24
2580
	cmp buf2d_bits,24
2581
	jne .error2
2581
	jne .error2
2582
	mov edi,dword[buf_t_matr]
2582
	mov edi,dword[buf_t_matr]
2583
	cmp buf2d_bits,8
2583
	cmp buf2d_bits,8
2584
	jne .error1
2584
	jne .error1
2585
		mov edx,buf2d_data
2585
		mov edx,buf2d_data
2586
		mov [buf_t_matr_offs],edx
2586
		mov [buf_t_matr_offs],edx
2587
		mov ecx,BUF_STRUCT_SIZE ;ª®¯¨à㥬 áâàãªâãàã ⥪á⮢®© ¬ âà¨æë
2587
		mov ecx,BUF_STRUCT_SIZE ;ª®¯¨à㥬 áâàãªâãàã ⥪á⮢®© ¬ âà¨æë
2588
		mov esi,edi
2588
		mov esi,edi
2589
		lea edi,[buf_s_matr]
2589
		lea edi,[buf_s_matr]
2590
		cld
2590
		cld
2591
		rep movsb
2591
		rep movsb
2592
		lea edi,[buf_s_matr]
2592
		lea edi,[buf_s_matr]
2593
		shr buf2d_h,8 ;¤¥«¨¬ ¢ëá®âã ᨬ¢®«ì­®£® ¡ãä¥à  ­  256, ¤«ï ­ å®¦¤¥­¨ï ¢ëá®âë 1-£® ᨬ¢®« 
2593
		shr buf2d_h,8 ;¤¥«¨¬ ¢ëá®âã ᨬ¢®«ì­®£® ¡ãä¥à  ­  256, ¤«ï ­ å®¦¤¥­¨ï ¢ëá®âë 1-£® ᨬ¢®« 
2594
		mov ebx,buf2d_h ;¡¥à¥¬ ¢ëá®âã ᨬ¢®« 
2594
		mov ebx,buf2d_h ;¡¥à¥¬ ¢ëá®âã ᨬ¢®« 
2595
		mov ecx,buf2d_w ;¡¥à¥¬ è¨à¨­ã ᨬ¢®« 
2595
		mov ecx,buf2d_w ;¡¥à¥¬ è¨à¨­ã ᨬ¢®« 
2596
 
2596
 
2597
		mov eax,[coord_x]
2597
		mov eax,[coord_x]
2598
		mov esi,[text]
2598
		mov esi,[text]
2599
		cmp byte[esi],0
2599
		cmp byte[esi],0
2600
		je .end_draw ;¥á«¨ ¯ãáâ ï áâப 
2600
		je .end_draw ;¥á«¨ ¯ãáâ ï áâப 
2601
		@@:
2601
		@@:
2602
			xor edx,edx
2602
			xor edx,edx
2603
			mov dl,byte[esi] ;¡¥à¥¬ ª®¤ ᨬ¢®« 
2603
			mov dl,byte[esi] ;¡¥à¥¬ ª®¤ ᨬ¢®« 
2604
			imul edx,ebx ;㬭®¦ ¥¬ ¥£® ­  ¢ëá®âã ᨬ¢®« 
2604
			imul edx,ebx ;㬭®¦ ¥¬ ¥£® ­  ¢ëá®âã ᨬ¢®« 
2605
			imul edx,ecx ;㬭®¦ ¥¬ ­  è¨à¨­ã ᨬ¢®« 
2605
			imul edx,ecx ;㬭®¦ ¥¬ ­  è¨à¨­ã ᨬ¢®« 
2606
			add edx,[buf_t_matr_offs] ;¯à¨¡ ¢«ï¥¬ ᬥ饭¨¥ 0-£® ᨬ¢®« , â. ¥. ¯®«ãç ¥âáï ᬥ饭¨¥ ¢ë¢®¤¨¬®£® ᨬ¢®« 
2606
			add edx,[buf_t_matr_offs] ;¯à¨¡ ¢«ï¥¬ ᬥ饭¨¥ 0-£® ᨬ¢®« , â. ¥. ¯®«ãç ¥âáï ᬥ饭¨¥ ¢ë¢®¤¨¬®£® ᨬ¢®« 
2607
			mov buf2d_data,edx ;¢ «®ª «ì­ë© ¡ãä¥à ᨬ¢®« , áâ ¢¨¬ 㪠§ â¥«ì ­  ­ã¦­ë© ᨬ¢®« ¨§ ¡ãä¥à  buf_t_matr
2607
			mov buf2d_data,edx ;¢ «®ª «ì­ë© ¡ãä¥à ᨬ¢®« , áâ ¢¨¬ 㪠§ â¥«ì ­  ­ã¦­ë© ᨬ¢®« ¨§ ¡ãä¥à  buf_t_matr
2608
			stdcall buf_bit_blt_alpha, [buf_struc], eax,[coord_y], edi,[color]
2608
			stdcall buf_bit_blt_alpha, [buf_struc], eax,[coord_y], edi,[color]
2609
			add eax,ecx
2609
			add eax,ecx
2610
			.new_s:
2610
			.new_s:
2611
				inc esi
2611
				inc esi
2612
				cmp byte[esi],13
2612
				cmp byte[esi],13
2613
				jne .no_13
2613
				jne .no_13
2614
					mov eax,[coord_x]
2614
					mov eax,[coord_x]
2615
					add [coord_y],ebx
2615
					add [coord_y],ebx
2616
					jmp .new_s
2616
					jmp .new_s
2617
				.no_13:
2617
				.no_13:
2618
			cmp byte[esi],0
2618
			cmp byte[esi],0
2619
			jne @b
2619
			jne @b
2620
		jmp .end_draw
2620
		jmp .end_draw
2621
	.error1:
2621
	.error1:
2622
		stdcall print_err,sz_buf2d_draw_text,txt_err_n8b
2622
		stdcall print_err,sz_buf2d_draw_text,txt_err_n8b
2623
		jmp .end_draw
2623
		jmp .end_draw
2624
	.error2:
2624
	.error2:
2625
		stdcall print_err,sz_buf2d_draw_text,txt_err_n24b
2625
		stdcall print_err,sz_buf2d_draw_text,txt_err_n24b
2626
	.end_draw:
2626
	.end_draw:
2627
	popad
2627
	popad
2628
	ret
2628
	ret
2629
endp
2629
endp
2630
 
2630
 
2631
align 4
2631
align 4
2632
proc print_err, fun:dword, mes:dword ;¢ë¢®¤¨¬ á®®¡é¥­¨¥ ®¡ 訡ª¥ ­  ¤®áªã ®â« ¤ª¨
2632
proc print_err, fun:dword, mes:dword ;¢ë¢®¤¨¬ á®®¡é¥­¨¥ ®¡ 訡ª¥ ­  ¤®áªã ®â« ¤ª¨
2633
	pushad
2633
	pushad
2634
	mov eax,63
2634
	mov eax,63
2635
	mov ebx,1
2635
	mov ebx,1
2636
 
2636
 
2637
	mov esi,[fun]
2637
	mov esi,[fun]
2638
	@@:
2638
	@@:
2639
		mov cl,byte[esi]
2639
		mov cl,byte[esi]
2640
		int 0x40
2640
		int 0x40
2641
		inc esi
2641
		inc esi
2642
		cmp byte[esi],0
2642
		cmp byte[esi],0
2643
		jne @b
2643
		jne @b
2644
	mov cl,':'
2644
	mov cl,':'
2645
	int 0x40
2645
	int 0x40
2646
	mov cl,' '
2646
	mov cl,' '
2647
	int 0x40
2647
	int 0x40
2648
	mov esi,[mes]
2648
	mov esi,[mes]
2649
	@@:
2649
	@@:
2650
		mov cl,byte[esi]
2650
		mov cl,byte[esi]
2651
		int 0x40
2651
		int 0x40
2652
		inc esi
2652
		inc esi
2653
		cmp byte[esi],0
2653
		cmp byte[esi],0
2654
		jne @b
2654
		jne @b
2655
	popad
2655
	popad
2656
	ret
2656
	ret
2657
endp
2657
endp
2658
 
2658
 
2659
;input:
2659
;input:
2660
; ebp+8  = p0
2660
; ebp+8  = p0
2661
; ebp+12 = p1
2661
; ebp+12 = p1
2662
align 4
2662
align 4
2663
line_len4i:
2663
line_len4i:
2664
	push ebp
2664
	push ebp
2665
	mov ebp,esp
2665
	mov ebp,esp
2666
		finit
2666
		finit
2667
		fild word [ebp+8]
2667
		fild word [ebp+8]
2668
		fisub word [ebp+12]
2668
		fisub word [ebp+12]
2669
		fmul st0,st0 ;st0=x^2
2669
		fmul st0,st0 ;st0=x^2
2670
		fild word [ebp+10]
2670
		fild word [ebp+10]
2671
		fisub word [ebp+14]
2671
		fisub word [ebp+14]
2672
		fmul st0,st0 ;st0=y^2
2672
		fmul st0,st0 ;st0=y^2
2673
		fadd st0,st1
2673
		fadd st0,st1
2674
		fsqrt
2674
		fsqrt
2675
		fstp dword [ebp+12]
2675
		fstp dword [ebp+12]
2676
	pop ebp
2676
	pop ebp
2677
	ret 4 ;8
2677
	ret 4 ;8
2678
 
2678
 
2679
align 4
2679
align 4
2680
proc buf_curve_bezier, buffer:dword, coord_p0:dword,coord_p1:dword,coord_p2:dword, color:dword
2680
proc buf_curve_bezier, buffer:dword, coord_p0:dword,coord_p1:dword,coord_p2:dword, color:dword
2681
	locals
2681
	locals
2682
		delt_t dd ?
2682
		delt_t dd ?
2683
		opr_param dd ?
2683
		opr_param dd ?
2684
		v_poi_0 dd ?
2684
		v_poi_0 dd ?
2685
	endl
2685
	endl
2686
	pushad
2686
	pushad
2687
 
2687
 
2688
;float t, xt,yt;
2688
;float t, xt,yt;
2689
;for(t=.0;t<1.;t+=.005){
2689
;for(t=.0;t<1.;t+=.005){
2690
;  xt=pow(1.-t,2)*x0+2*t*(1.-t)*x1+pow(t,2)*x2;
2690
;  xt=pow(1.-t,2)*x0+2*t*(1.-t)*x1+pow(t,2)*x2;
2691
;  yt=pow(1.-t,2)*y0+2*t*(1.-t)*y1+pow(t,2)*y2;
2691
;  yt=pow(1.-t,2)*y0+2*t*(1.-t)*y1+pow(t,2)*y2;
2692
;  dc.SetPixel(xt,yt,255L);
2692
;  dc.SetPixel(xt,yt,255L);
2693
;}
2693
;}
2694
 
2694
 
2695
	mov edx,[color] ;set curve color
2695
	mov edx,[color] ;set curve color
2696
	mov edi,[buffer]
2696
	mov edi,[buffer]
2697
	xor ebx,ebx
2697
	xor ebx,ebx
2698
	xor ecx,ecx
2698
	xor ecx,ecx
2699
 
2699
 
2700
	finit
2700
	finit
2701
 
2701
 
2702
	; calculate delta t
2702
	; calculate delta t
2703
	stdcall line_len4i, dword[coord_p1],dword[coord_p0]
2703
	stdcall line_len4i, dword[coord_p1],dword[coord_p0]
2704
	fadd dword[esp]
2704
	fadd dword[esp]
2705
	add esp,4 ;pop ...
2705
	add esp,4 ;pop ...
2706
 
2706
 
2707
	stdcall line_len4i, dword[coord_p2],dword[coord_p1]
2707
	stdcall line_len4i, dword[coord_p2],dword[coord_p1]
2708
	fadd dword[esp]
2708
	fadd dword[esp]
2709
	add esp,4 ;pop ...
2709
	add esp,4 ;pop ...
2710
 
2710
 
2711
	fadd st0,st0 ; len*=2
2711
	fadd st0,st0 ; len*=2
2712
	ftst
2712
	ftst
2713
	fstsw ax
2713
	fstsw ax
2714
 
2714
 
2715
	fld1
2715
	fld1
2716
	sahf
2716
	sahf
2717
	jle @f ;¨§¡¥£ ¥¬ ¤¥«¥­¨ï ­  0
2717
	jle @f ;¨§¡¥£ ¥¬ ¤¥«¥­¨ï ­  0
2718
		fdiv st0,st1
2718
		fdiv st0,st1
2719
	@@:
2719
	@@:
2720
	fstp dword[delt_t]
2720
	fstp dword[delt_t]
2721
 
2721
 
2722
	finit
2722
	finit
2723
 
2723
 
2724
	;fild word[coord_p2+2] ;y2
2724
	;fild word[coord_p2+2] ;y2
2725
	fild word[coord_p1+2] ;y1
2725
	fild word[coord_p1+2] ;y1
2726
	fild word[coord_p0+2] ;y0
2726
	fild word[coord_p0+2] ;y0
2727
	fild word[coord_p2] ;x2
2727
	fild word[coord_p2] ;x2
2728
	fild word[coord_p1] ;x1
2728
	fild word[coord_p1] ;x1
2729
	fild word[coord_p0] ;x0
2729
	fild word[coord_p0] ;x0
2730
	fld dword[delt_t]
2730
	fld dword[delt_t]
2731
	fldz ;t=.0
2731
	fldz ;t=.0
2732
 
2732
 
2733
	@@:
2733
	@@:
2734
		fld1
2734
		fld1
2735
		fsub st0,st1 ;1.-t
2735
		fsub st0,st1 ;1.-t
2736
		fmul st0,st0 ;pow(1.-t,2)
2736
		fmul st0,st0 ;pow(1.-t,2)
2737
		fmul st0,st3 ;...*x0
2737
		fmul st0,st3 ;...*x0
2738
		fstp dword[opr_param]
2738
		fstp dword[opr_param]
2739
 
2739
 
2740
		fld1
2740
		fld1
2741
		fsub st0,st1 ;1.-t
2741
		fsub st0,st1 ;1.-t
2742
		fmul st0,st1 ;(1.-t)*t
2742
		fmul st0,st1 ;(1.-t)*t
2743
		fadd st0,st0
2743
		fadd st0,st0
2744
		fmul st0,st4 ;...*x1
2744
		fmul st0,st4 ;...*x1
2745
		mov esi,dword[opr_param]
2745
		mov esi,dword[opr_param]
2746
		fstp dword[opr_param]
2746
		fstp dword[opr_param]
2747
 
2747
 
2748
		fldz
2748
		fldz
2749
		fadd st0,st1 ;0+t
2749
		fadd st0,st1 ;0+t
2750
		fmul st0,st0 ;t*t
2750
		fmul st0,st0 ;t*t
2751
		fmul st0,st5 ;...*x2
2751
		fmul st0,st5 ;...*x2
2752
 
2752
 
2753
		fadd dword[opr_param]
2753
		fadd dword[opr_param]
2754
		mov dword[opr_param],esi
2754
		mov dword[opr_param],esi
2755
		fadd dword[opr_param]
2755
		fadd dword[opr_param]
2756
		fistp word[v_poi_0] ;x
2756
		fistp word[v_poi_0] ;x
2757
 
2757
 
2758
		fld1
2758
		fld1
2759
		fsub st0,st1 ;1.-t
2759
		fsub st0,st1 ;1.-t
2760
		fmul st0,st0 ;pow(1.-t,2)
2760
		fmul st0,st0 ;pow(1.-t,2)
2761
		fmul st0,st6 ;...*y0
2761
		fmul st0,st6 ;...*y0
2762
		fstp dword[opr_param]
2762
		fstp dword[opr_param]
2763
 
2763
 
2764
		fld1
2764
		fld1
2765
		fsub st0,st1 ;1.-t
2765
		fsub st0,st1 ;1.-t
2766
		fmul st0,st1 ;(1.-t)*t
2766
		fmul st0,st1 ;(1.-t)*t
2767
		fadd st0,st0
2767
		fadd st0,st0
2768
		fmul st0,st7 ;...*y1
2768
		fmul st0,st7 ;...*y1
2769
		mov esi,dword[opr_param]
2769
		mov esi,dword[opr_param]
2770
		fstp dword[opr_param]
2770
		fstp dword[opr_param]
2771
 
2771
 
2772
		fldz
2772
		fldz
2773
		fadd st0,st1 ;0+t
2773
		fadd st0,st1 ;0+t
2774
		fmul st0,st0 ;t*t
2774
		fmul st0,st0 ;t*t
2775
		fimul word[coord_p2+2] ;...*y2
2775
		fimul word[coord_p2+2] ;...*y2
2776
 
2776
 
2777
		fadd dword[opr_param]
2777
		fadd dword[opr_param]
2778
		mov dword[opr_param],esi
2778
		mov dword[opr_param],esi
2779
		fadd dword[opr_param]
2779
		fadd dword[opr_param]
2780
		fistp word[v_poi_0+2] ;y
2780
		fistp word[v_poi_0+2] ;y
2781
 
2781
 
2782
		mov eax,1
2782
		mov eax,1
2783
		mov bx,word[v_poi_0+2]
2783
		mov bx,word[v_poi_0+2]
2784
		mov cx,word[v_poi_0]
2784
		mov cx,word[v_poi_0]
2785
		call draw_pixel
2785
		call draw_pixel
2786
 
2786
 
2787
		fadd st0,st1 ;t+dt
2787
		fadd st0,st1 ;t+dt
2788
 
2788
 
2789
		fld1
2789
		fld1
2790
		fcomp
2790
		fcomp
2791
		fstsw ax
2791
		fstsw ax
2792
		sahf
2792
		sahf
2793
	jae @b
2793
	jae @b
2794
 
2794
 
2795
	popad
2795
	popad
2796
	ret
2796
	ret
2797
endp
2797
endp
2798
 
2798
 
2799
 
2799
 
2800
 
2800
 
2801
;*** ä㭪樨 ¤«ï à ¡®âë á ¢®ªá¥«ì­®© £à ä¨ª®© ***
2801
;*** ä㭪樨 ¤«ï à ¡®âë á ¢®ªá¥«ì­®© £à ä¨ª®© ***
2802
 
2802
 
2803
 
2803
 
2804
 
2804
 
2805
;ᮧ¤ ­¨¥ ¢®ªá¥«ì­ëå ª¨á⥩
2805
;ᮧ¤ ­¨¥ ¢®ªá¥«ì­ëå ª¨á⥩
2806
align 4
2806
align 4
2807
proc vox_brush_create uses eax ebx ecx edi, h_br:dword, buf_z:dword
2807
proc vox_brush_create uses eax ebx ecx edi, h_br:dword, buf_z:dword
2808
	mov edi,[h_br]
2808
	mov edi,[h_br]
2809
	movzx ecx,byte[edi+3]
2809
	movzx ecx,byte[edi+3]
2810
	add edi,4
2810
	add edi,4
2811
 
2811
 
2812
	; *** ᮧ¤ ­¨¥ ¥¤¨­¨ç­®© ª¨á⨠***
2812
	; *** ᮧ¤ ­¨¥ ¥¤¨­¨ç­®© ª¨á⨠***
2813
	mov eax,[buf_z]
2813
	mov eax,[buf_z]
2814
	mov buf2d_data,eax
2814
	mov buf2d_data,eax
2815
	movzx eax,byte[edi-4] ;è¨à¨­  ¥¤¨­¨ç­®© ª¨áâ¨
2815
	movzx eax,byte[edi-4] ;è¨à¨­  ¥¤¨­¨ç­®© ª¨áâ¨
2816
	mov buf2d_w,eax ;è¨à¨­  ¡ãä¥à 
2816
	mov buf2d_w,eax ;è¨à¨­  ¡ãä¥à 
2817
	movzx eax,byte[edi-4+1] ;¢ëá®â  ¥¤¨­¨ç­®© ª¨áâ¨
2817
	movzx eax,byte[edi-4+1] ;¢ëá®â  ¥¤¨­¨ç­®© ª¨áâ¨
2818
	mov buf2d_h,eax ;¢ëá®â  ¡ãä¥à 
2818
	mov buf2d_h,eax ;¢ëá®â  ¡ãä¥à 
2819
	mov buf2d_size_lt,0 ;®âáâ㯠᫥¢  ¨ á¯à ¢  ¤«ï ¡ãä¥à 
2819
	mov buf2d_size_lt,0 ;®âáâ㯠᫥¢  ¨ á¯à ¢  ¤«ï ¡ãä¥à 
2820
	mov buf2d_color,0 ;梥â ä®­  ¡ãä¥à 
2820
	mov buf2d_color,0 ;梥â ä®­  ¡ãä¥à 
2821
	mov buf2d_bits,32 ;ª®«¨ç¥á⢮ ¡¨â ¢ 1-© â®çª¥ ¨§®¡à ¦¥­¨ï
2821
	mov buf2d_bits,32 ;ª®«¨ç¥á⢮ ¡¨â ¢ 1-© â®çª¥ ¨§®¡à ¦¥­¨ï
2822
 
2822
 
2823
	; *** ᮧ¤ ­¨¥ á«¥¤ãîé¨å ª¨á⥩ ***
2823
	; *** ᮧ¤ ­¨¥ á«¥¤ãîé¨å ª¨á⥩ ***
2824
	cmp ecx,1
2824
	cmp ecx,1
2825
	jl .end_creat
2825
	jl .end_creat
2826
	movzx ebx,byte[edi-4+2] ;¢ëá®â  ®á­®¢ ­¨ï ¥¤¨­¨ç­®© ª¨áâ¨
2826
	movzx ebx,byte[edi-4+2] ;¢ëá®â  ®á­®¢ ­¨ï ¥¤¨­¨ç­®© ª¨áâ¨
2827
	shr ebx,1
2827
	shr ebx,1
2828
	cld
2828
	cld
2829
	@@:
2829
	@@:
2830
		mov eax,edi
2830
		mov eax,edi
2831
		add edi,BUF_STRUCT_SIZE
2831
		add edi,BUF_STRUCT_SIZE
2832
		stdcall vox_create_next_brush, eax, edi, ebx
2832
		stdcall vox_create_next_brush, eax, edi, ebx
2833
		shl ebx,1
2833
		shl ebx,1
2834
		loop @b
2834
		loop @b
2835
	.end_creat:
2835
	.end_creat:
2836
	ret
2836
	ret
2837
endp
2837
endp
2838
 
2838
 
2839
;㤠«¥­¨¥ ¢®ªá¥«ì­ëå ª¨á⥩
2839
;㤠«¥­¨¥ ¢®ªá¥«ì­ëå ª¨á⥩
2840
align 4
2840
align 4
2841
proc vox_brush_delete uses ecx edi, h_br:dword
2841
proc vox_brush_delete uses ecx edi, h_br:dword
2842
	mov edi,[h_br]
2842
	mov edi,[h_br]
2843
	movzx ecx,byte[edi+3]
2843
	movzx ecx,byte[edi+3]
2844
	add edi,4
2844
	add edi,4
2845
 
2845
 
2846
	; *** 㤠«¥­¨¥ ª¨á⥩ ***
2846
	; *** 㤠«¥­¨¥ ª¨á⥩ ***
2847
	cmp ecx,1
2847
	cmp ecx,1
2848
	jl .end_delete
2848
	jl .end_delete
2849
	cld
2849
	cld
2850
	@@:
2850
	@@:
2851
		add edi,BUF_STRUCT_SIZE
2851
		add edi,BUF_STRUCT_SIZE
2852
		stdcall buf_delete, edi
2852
		stdcall buf_delete, edi
2853
		loop @b
2853
		loop @b
2854
	.end_delete:
2854
	.end_delete:
2855
	ret
2855
	ret
2856
endp
2856
endp
2857
 
2857
 
2858
;äã­ªæ¨ï ¤«ï ᮧ¤ ­¨ï ¢®ªá¥«ï á«¥¤ãî饣® ¯®à浪 
2858
;äã­ªæ¨ï ¤«ï ᮧ¤ ­¨ï ¢®ªá¥«ï á«¥¤ãî饣® ¯®à浪 
2859
; buf_v1 - ¡ãä¥à á ¨á室­ë¬ ¢®ªá¥«¥¬
2859
; buf_v1 - ¡ãä¥à á ¨á室­ë¬ ¢®ªá¥«¥¬
2860
; buf_v2 - ¡ãä¥à á 㢥«¨ç¥­ë¬ ¢®ªá¥«¥¬
2860
; buf_v2 - ¡ãä¥à á 㢥«¨ç¥­ë¬ ¢®ªá¥«¥¬
2861
; h - ¢ëá®â  ®á­®¢ ­¨ï ¨á室­®£® ¢®ªá¥«ï : 2
2861
; h - ¢ëá®â  ®á­®¢ ­¨ï ¨á室­®£® ¢®ªá¥«ï : 2
2862
align 4
2862
align 4
2863
proc vox_create_next_brush uses eax ebx ecx edx edi, buf_v1:dword, buf_v2:dword, h:dword
2863
proc vox_create_next_brush uses eax ebx ecx edx edi, buf_v1:dword, buf_v2:dword, h:dword
2864
	mov edi,[buf_v1]
2864
	mov edi,[buf_v1]
2865
	mov ebx,buf2d_h
2865
	mov ebx,buf2d_h
2866
	mov ecx,buf2d_w
2866
	mov ecx,buf2d_w
2867
	mov edi,[buf_v2]
2867
	mov edi,[buf_v2]
2868
	mov buf2d_h,ebx
2868
	mov buf2d_h,ebx
2869
	shl buf2d_h,1
2869
	shl buf2d_h,1
2870
	mov buf2d_w,ecx
2870
	mov buf2d_w,ecx
2871
	shl buf2d_w,1
2871
	shl buf2d_w,1
2872
	mov buf2d_color,0
2872
	mov buf2d_color,0
2873
	mov buf2d_bits,32
2873
	mov buf2d_bits,32
2874
 
2874
 
2875
	stdcall buf_create, [buf_v2] ;ᮧ¤ ­¨¥ ¡ãä¥à  £«ã¡¨­ë
2875
	stdcall buf_create, [buf_v2] ;ᮧ¤ ­¨¥ ¡ãä¥à  £«ã¡¨­ë
2876
	shr ecx,1
2876
	shr ecx,1
2877
	mov edx,[h]
2877
	mov edx,[h]
2878
	shl edx,1
2878
	shl edx,1
2879
	sub ebx,edx
2879
	sub ebx,edx
2880
	;ecx - è¨à¨­  ¨á室­®£® ¢®ªá¥«ï : 2
2880
	;ecx - è¨à¨­  ¨á室­®£® ¢®ªá¥«ï : 2
2881
	;ebx - ¢ëá®â  ¨á室­®£® ¢®ªá¥«ï (¡¥§ ®á­®¢ ­¨ï)
2881
	;ebx - ¢ëá®â  ¨á室­®£® ¢®ªá¥«ï (¡¥§ ®á­®¢ ­¨ï)
2882
	;edx - ¢ëá®â  ®á­®¢ ­¨ï ¨á室­®£® ¢®ªá¥«ï
2882
	;edx - ¢ëá®â  ®á­®¢ ­¨ï ¨á室­®£® ¢®ªá¥«ï
2883
	stdcall vox_add, [buf_v2], [buf_v1], ecx,0,0
2883
	stdcall vox_add, [buf_v2], [buf_v1], ecx,0,0
2884
	stdcall vox_add, [buf_v2], [buf_v1], ecx,ebx,0
2884
	stdcall vox_add, [buf_v2], [buf_v1], ecx,ebx,0
2885
 
2885
 
2886
	mov eax,[h]
2886
	mov eax,[h]
2887
	stdcall vox_add, [buf_v2], [buf_v1], 0,eax,eax
2887
	stdcall vox_add, [buf_v2], [buf_v1], 0,eax,eax
2888
	push eax ;stdcall ...
2888
	push eax ;stdcall ...
2889
	add eax,ebx
2889
	add eax,ebx
2890
	stdcall vox_add, [buf_v2], [buf_v1], 0,eax ;,...
2890
	stdcall vox_add, [buf_v2], [buf_v1], 0,eax ;,...
2891
	sub eax,ebx
2891
	sub eax,ebx
2892
 
2892
 
2893
	shl ecx,1
2893
	shl ecx,1
2894
	;ecx - è¨à¨­  ¨á室­®£® ¢®ªá¥«ï
2894
	;ecx - è¨à¨­  ¨á室­®£® ¢®ªá¥«ï
2895
	mov eax,[h]
2895
	mov eax,[h]
2896
	stdcall vox_add, [buf_v2], [buf_v1], ecx,eax,eax
2896
	stdcall vox_add, [buf_v2], [buf_v1], ecx,eax,eax
2897
	push eax ;stdcall ...,[h]
2897
	push eax ;stdcall ...,[h]
2898
	add eax,ebx
2898
	add eax,ebx
2899
	stdcall vox_add, [buf_v2], [buf_v1], ecx,eax;,[h]
2899
	stdcall vox_add, [buf_v2], [buf_v1], ecx,eax;,[h]
2900
	;sub eax,ebx
2900
	;sub eax,ebx
2901
	shr ecx,1
2901
	shr ecx,1
2902
 
2902
 
2903
	;ecx - è¨à¨­  ¨á室­®£® ¢®ªá¥«ï : 2
2903
	;ecx - è¨à¨­  ¨á室­®£® ¢®ªá¥«ï : 2
2904
	stdcall vox_add, [buf_v2], [buf_v1], ecx,edx,edx
2904
	stdcall vox_add, [buf_v2], [buf_v1], ecx,edx,edx
2905
	add ebx,edx
2905
	add ebx,edx
2906
	stdcall vox_add, [buf_v2], [buf_v1], ecx,ebx,edx
2906
	stdcall vox_add, [buf_v2], [buf_v1], ecx,ebx,edx
2907
 
2907
 
2908
	ret
2908
	ret
2909
endp
2909
endp
2910
 
2910
 
2911
;
2911
;
2912
align 4
2912
align 4
2913
proc vox_add uses ebx ecx, buf_v1:dword, buf_v2:dword, coord_x:dword, coord_y:dword, coord_z:dword
2913
proc vox_add, buf_v1:dword, buf_v2:dword, coord_x:dword, coord_y:dword, coord_z:dword
2914
pushad
2914
pushad
2915
	mov eax,[coord_x]
2915
	mov eax,[coord_x]
2916
	mov ebx,[coord_y]
2916
	mov ebx,[coord_y]
2917
	mov edi,[buf_v2]
2917
	mov edi,[buf_v2]
2918
	mov ecx,buf2d_h
2918
	mov ecx,buf2d_h
2919
	mov esi,buf2d_w
2919
	mov esi,buf2d_w
2920
	imul ecx,esi
2920
	imul ecx,esi
2921
	add esi,eax
2921
	add esi,eax
2922
	mov edx,buf2d_data
2922
	mov edx,buf2d_data
2923
	cld
2923
	cld
2924
	;ecx - count pixels in voxel
2924
	;ecx - count pixels in voxel
2925
	;edx - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢ ¢®ªá¥«ì­®¬ ¡ãä¥à¥
2925
	;edx - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢ ¢®ªá¥«ì­®¬ ¡ãä¥à¥
2926
	;edi - 㪠§ â¥«ì ­  ¢®ªá¥«ì­ë© ¡ãä¥à
2926
	;edi - 㪠§ â¥«ì ­  ¢®ªá¥«ì­ë© ¡ãä¥à
2927
	;esi - width voxel buffer add coord x
2927
	;esi - width voxel buffer add coord x
2928
	.cycle:
2928
	.cycle:
2929
		cmp dword[edx],0
2929
		cmp dword[edx],0
2930
		je @f
2930
		je @f
2931
			;¯à®¢¥à塞 ¡ãä¥à £«ã¡¨­ë
2931
			;¯à®¢¥à塞 ¡ãä¥à £«ã¡¨­ë
2932
			push eax ecx esi
2932
			push eax ecx esi
2933
			mov ecx,eax
2933
			mov ecx,eax
2934
			stdcall buf_get_pixel, [buf_v1],ecx,ebx
2934
			stdcall buf_get_pixel, [buf_v1],ecx,ebx
2935
			mov esi,[edx]
2935
			mov esi,[edx]
2936
			add esi,[coord_z]
2936
			add esi,[coord_z]
2937
			cmp eax,esi
2937
			cmp eax,esi
2938
			jge .end_draw
2938
			jge .end_draw
2939
			stdcall buf_set_pixel, [buf_v1],ecx,ebx,esi ;esi = new coord z
2939
			stdcall buf_set_pixel, [buf_v1],ecx,ebx,esi ;esi = new coord z
2940
			.end_draw:
2940
			.end_draw:
2941
			pop esi ecx eax
2941
			pop esi ecx eax
2942
		@@:
2942
		@@:
2943
		add edx,4
2943
		add edx,4
2944
		inc eax
2944
		inc eax
2945
		cmp eax,esi
2945
		cmp eax,esi
2946
		jl @f
2946
		jl @f
2947
			inc ebx
2947
			inc ebx
2948
			sub eax,buf2d_w
2948
			sub eax,buf2d_w
2949
		@@:
2949
		@@:
2950
		loop .cycle
2950
		loop .cycle
2951
popad
2951
popad
2952
	ret
2952
	ret
2953
endp
2953
endp
-
 
2954
 
-
 
2955
;description:
-
 
2956
; ¢®§¢à è ¥â è¨à¨­ã ¢®ªá¥«ì­®£® ¨§®¡à ¦¥­¨ï á 3-¬ï £à ­ï¬¨
-
 
2957
; ¯à¨­¨¬ ¥â 㪠§ â¥«ì ­  ª¨áâì ¨ ¬ áèâ ¡
-
 
2958
align 4
-
 
2959
proc buf_vox_obj_get_img_w_3g uses ecx, h_br:dword,k_scale:dword
-
 
2960
	mov ecx,[h_br]
-
 
2961
 
-
 
2962
	movzx eax,byte[ecx]
-
 
2963
	cmp dword[k_scale],1
-
 
2964
	jl .end_c0
-
 
2965
		mov ecx,[k_scale]
-
 
2966
		shl eax,cl
-
 
2967
	.end_c0:
-
 
2968
	ret
-
 
2969
endp
-
 
2970
 
-
 
2971
;description:
-
 
2972
; ¢®§¢à è ¥â ¢ëá®âã ¢®ªá¥«ì­®£® ¨§®¡à ¦¥­¨ï á 3-¬ï £à ­ï¬¨
-
 
2973
; ¯à¨­¨¬ ¥â 㪠§ â¥«ì ­  ª¨áâì ¨ ¬ áèâ ¡
-
 
2974
align 4
-
 
2975
proc buf_vox_obj_get_img_h_3g uses ecx, h_br:dword,k_scale:dword
-
 
2976
	mov ecx,[h_br]
-
 
2977
 
-
 
2978
	movzx eax,byte[ecx+1]
-
 
2979
	cmp dword[k_scale],1
-
 
2980
	jl .end_c0
-
 
2981
		mov ecx,[k_scale]
-
 
2982
		shl eax,cl
-
 
2983
	.end_c0:
-
 
2984
	ret
-
 
2985
endp
-
 
2986
 
-
 
2987
;description:
-
 
2988
; äã­ªæ¨ï à¨áãîé ï ¢®ªá¥«ì­ë© ®¡ê¥ªâ
-
 
2989
;input:
-
 
2990
; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
-
 
2991
; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
-
 
2992
; h_br - ª¨áâì á ¨§®¡à ¦¥­¨ï¬¨ ¢®ªá¥«¥© (32 ¡¨â )
-
 
2993
; v_obj - ¢®ªá¥«ì­ë© ®¡ê¥ªâ
-
 
2994
; k_scale - ª®íä. ¤«ï ¬ áèâ ¡¨à®¢ ­¨ï ¨§®¡à ¦¥­¨ï
-
 
2995
align 4
-
 
2996
proc buf_vox_obj_draw_3g, buf_i:dword, buf_z:dword, h_br:dword, v_obj:dword,\
-
 
2997
coord_x:dword, coord_y:dword, coord_z:dword, k_scale:dword
-
 
2998
pushad
-
 
2999
	mov edi,[v_obj]
-
 
3000
	mov ecx,[k_scale]
-
 
3001
	mov ebx,[coord_x]
-
 
3002
 
-
 
3003
;---
-
 
3004
	;â¥á⮢ ï à ¬ª 
-
 
3005
	mov eax,[h_br]
-
 
3006
 
-
 
3007
	movzx edx,byte[eax]
-
 
3008
	movzx esi,byte[eax+1]
-
 
3009
	cmp ecx,1
-
 
3010
	jl .end_c0
-
 
3011
		shl edx,cl
-
 
3012
		shl esi,cl
-
 
3013
	.end_c0:
-
 
3014
	stdcall buf_rect_by_size, [buf_i], ebx,[coord_y],edx,esi, 0xd0d0d0
-
 
3015
;---
-
 
3016
 
-
 
3017
	mov edx,[coord_y]
-
 
3018
	add edi,vox_offs_data
-
 
3019
 
-
 
3020
	mov esi,[coord_z]
-
 
3021
	stdcall vox_go_in_node, [buf_i], [buf_z], [h_br], [v_obj]
-
 
3022
 
-
 
3023
popad
-
 
3024
	ret
-
 
3025
endp
-
 
3026
 
-
 
3027
;description:
-
 
3028
; äã­ªæ¨ï à¨áãîé ï ç áâì ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
-
 
3029
;input:
-
 
3030
; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
-
 
3031
; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
-
 
3032
; h_br - ª¨áâì á ¨§®¡à ¦¥­¨ï¬¨ ¢®ªá¥«¥© (32 ¡¨â )
-
 
3033
; v_obj - ¢®ªá¥«ì­ë© ®¡ê¥ªâ
-
 
3034
; k_scale - ª®íä. ¤«ï ¬ áèâ ¡¨à®¢ ­¨ï ¨§®¡à ¦¥­¨ï
-
 
3035
align 4
-
 
3036
proc buf_vox_obj_draw_3g_scaled, buf_i:dword, buf_z:dword, h_br:dword, v_obj:dword,\
-
 
3037
coord_x:dword, coord_y:dword, coord_z:dword, k_scale:dword,\
-
 
3038
s_c_x:dword, s_c_y:dword, s_c_z:dword, s_k_scale:dword,b_color:dword
-
 
3039
pushad
-
 
3040
locals
-
 
3041
	p_node dd 0 ;த¨â¥«ì᪨© 㧥«
-
 
3042
endl
-
 
3043
	mov edi,[v_obj]
-
 
3044
	add edi,vox_offs_data
-
 
3045
 
-
 
3046
	mov ecx,[k_scale]
-
 
3047
	mov ebx,[coord_x]
-
 
3048
 
-
 
3049
	;â¥á⮢ ï à ¬ª 
-
 
3050
	mov eax,[h_br]
-
 
3051
 
-
 
3052
	movzx edx,byte[eax]
-
 
3053
	movzx esi,byte[eax+1]
-
 
3054
	cmp ecx,1
-
 
3055
	jl .end_c0
-
 
3056
		shl edx,cl
-
 
3057
		shl esi,cl
-
 
3058
	.end_c0:
-
 
3059
	;stdcall buf_rect_by_size, [buf_i], ebx,[coord_y],edx,esi, [b_color]
-
 
3060
 
-
 
3061
	;¢¥à⨪ «ì­ ï ¯®«®á 
-
 
3062
	add ebx,edx
-
 
3063
	shr edx,cl
-
 
3064
	stdcall buf_rect_by_size, [buf_i], ebx,[coord_y],edx,esi, [b_color]
-
 
3065
	mov ecx,[s_k_scale]
-
 
3066
	shr esi,cl
-
 
3067
	xor eax,eax
-
 
3068
	inc eax
-
 
3069
	shl eax,cl
-
 
3070
	dec eax
-
 
3071
	sub eax,[s_c_z] ;§­ ç¥­¨ï ¯® ®á¨ z ¢®§à áâ îâ á ­¨§ã ¢¢¥àå
-
 
3072
	imul eax,esi
-
 
3073
	add eax,[coord_y]
-
 
3074
	stdcall buf_filled_rect_by_size, [buf_i], ebx,eax,edx,esi, [b_color]
-
 
3075
	mov ebx,[coord_y]
-
 
3076
	shl esi,cl
-
 
3077
	add ebx,esi
-
 
3078
	stdcall buf_vox_obj_get_img_w_3g, [h_br],[k_scale]
-
 
3079
	shr eax,1
-
 
3080
	mov esi,[h_br]
-
 
3081
	movzx esi,byte[esi+1]
-
 
3082
	;¯®«§ã­®ª
-
 
3083
	stdcall draw_polz_hor, [buf_i], [coord_x],ebx,eax,esi, [s_c_x], [s_k_scale], [b_color]
-
 
3084
	mov edx,[coord_x]
-
 
3085
	add edx,eax
-
 
3086
	;¯®«§ã­®ª
-
 
3087
	stdcall draw_polz_hor, [buf_i], edx,ebx,eax,esi, [s_c_y], [s_k_scale], [b_color]
-
 
3088
;---
-
 
3089
 
-
 
3090
	mov esi,[s_k_scale]
-
 
3091
	cmp esi,1
-
 
3092
	jl .end_2
-
 
3093
 
-
 
3094
	; *** (1) ***
-
 
3095
	.found:
-
 
3096
	stdcall vox_obj_get_node_position, [v_obj],[s_c_x],[s_c_y],[s_c_z],esi
-
 
3097
	movzx bx,byte[edi+3]
-
 
3098
	mov [p_node],edi
-
 
3099
	add edi,4
-
 
3100
	cmp eax,0
-
 
3101
	je .end_1
-
 
3102
	mov ecx,eax
-
 
3103
	cld
-
 
3104
	@@: ;横« ¤«ï ¯à®¯ã᪠ ¯à¥¤ë¤ãé¨å ¯®¤¤¥à¥¢ì¥¢ ¢ 㧫¥
-
 
3105
		bt bx,0 ;¯à®¢¥à塞 ¥áâì «¨ ¤®ç¥à­¨¥ 㧫ë
-
 
3106
		jnc .end_0
-
 
3107
			xor eax,eax
-
 
3108
			stdcall vox_obj_rec0 ;¢ eax ¢ëç¨á«ï¥âáï ç¨á«® ¤®ç¥à­¨å 㧫®¢, ¢ ¤ ­­®© ¢¥â¢¨
-
 
3109
		.end_0:
-
 
3110
		shr bx,1
-
 
3111
		loop @b
-
 
3112
	.end_1:
-
 
3113
	bt bx,0
-
 
3114
	jnc .end_2 ;¥á«¨ ¯®¤¤¥à¥¢  ­¥ áãé¥áâ¢ã¥â
-
 
3115
	dec esi
-
 
3116
	cmp esi,0
-
 
3117
	jg .found
-
 
3118
 
-
 
3119
	; *** (2) ***
-
 
3120
	;à¨á®¢ ­¨¥ ç á⨠®¡ê¥ªâ 
-
 
3121
	mov ecx,[k_scale]
-
 
3122
	mov ebx,[coord_x]
-
 
3123
	mov edx,[coord_y]
-
 
3124
	mov esi,[coord_z]
-
 
3125
	stdcall vox_go_in_node, [buf_i], [buf_z], [h_br], [v_obj]
-
 
3126
	.end_2:
-
 
3127
 
-
 
3128
popad
-
 
3129
	ret
-
 
3130
endp
-
 
3131
 
-
 
3132
;input:
-
 
3133
; h_br - ª¨áâì á ¨§®¡à ¦¥­¨ï¬¨ ¢®ªá¥«¥© (32 ¡¨â )
-
 
3134
; ebx - coord_x
-
 
3135
; edx - coord_y
-
 
3136
; esi - coord_z
-
 
3137
; ecx - ã஢¥­ì ⥪ã襣® 㧫 
-
 
3138
; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
-
 
3139
align 4
-
 
3140
proc vox_go_in_node, buf_i:dword, buf_z:dword, h_br:dword, v_obj:dword
-
 
3141
	cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
-
 
3142
	je .sub_trees
-
 
3143
		;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
-
 
3144
		push eax edx
-
 
3145
 
-
 
3146
		;¯à®à¨á®¢ª  à ¬ª¨ ¥á«¨ à §¬¥à 㧫  = 1
-
 
3147
		cmp ecx,0
-
 
3148
		jne .end_2
-
 
3149
			push eax
-
 
3150
				stdcall vox_get_sub_brush,[h_br],0 ;®¯à¥¤¥«ï¥¬ ª¨áâì ¤«ï à¨á®¢ ­¨ï
-
 
3151
				cmp eax,0 ;¥á«¨ ª¨áâì ­¥ ­ ©¤¥­ 
-
 
3152
				je @f
-
 
3153
					stdcall draw_vox, [buf_i], [buf_z], eax, ebx,edx,esi, [edi]
-
 
3154
				@@:
-
 
3155
			pop eax
-
 
3156
		.end_2:
-
 
3157
 
-
 
3158
		;¢å®¤ ¢­ãâàì 㧫 
-
 
3159
		dec ecx
-
 
3160
;---
-
 
3161
		push ebx
-
 
3162
			;mov eax,(h-h_osn/2)
-
 
3163
			mov ebx,[h_br]
-
 
3164
			movzx eax,byte[ebx+1]
-
 
3165
			movzx ebx,byte[ebx+2]
-
 
3166
			shr ebx,1
-
 
3167
			sub eax,ebx
-
 
3168
		cmp ecx,1
-
 
3169
		jl .end_c1
-
 
3170
			shl eax,cl
-
 
3171
			shl ebx,cl
-
 
3172
		.end_c1:
-
 
3173
		add esi,ebx
-
 
3174
		pop ebx
-
 
3175
		add edx,eax ;ª®à¥ªâ¨à®¢ª  ¢ëá®âë ¯®¤ ¢®ªá¥«ì ­¨¦­¥£® ã஢­ï
-
 
3176
;---
-
 
3177
		mov ah,byte[edi+3]
-
 
3178
		add edi,4
-
 
3179
		mov al,8
-
 
3180
		.cycle:
-
 
3181
			bt ax,8 ;â¥áâ¨à㥬 ⮫쪮 ah
-
 
3182
			jnc .c_next
-
 
3183
				push ebx edx esi
-
 
3184
				stdcall vox_corect_coords, [h_br], [v_obj]
-
 
3185
				stdcall vox_go_in_node, [buf_i], [buf_z], [h_br], [v_obj]
-
 
3186
				pop esi edx ebx
-
 
3187
			.c_next:
-
 
3188
			shr ah,1
-
 
3189
			dec al
-
 
3190
			jnz .cycle
-
 
3191
 
-
 
3192
		;¢ë室 ¨§ 㧫 
-
 
3193
		inc ecx
-
 
3194
		pop edx eax
-
 
3195
 
-
 
3196
		jmp .end_f
-
 
3197
	.sub_trees:
-
 
3198
		;à¨á㥬 㧥«
-
 
3199
		push eax
-
 
3200
			stdcall vox_get_sub_brush,[h_br],ecx ;®¯à¥¤¥«ï¥¬ ª¨áâì ¤«ï à¨á®¢ ­¨ï
-
 
3201
			cmp eax,0 ;¥á«¨ ª¨áâì ­¥ ­ ©¤¥­ 
-
 
3202
			je @f
-
 
3203
				stdcall draw_vox, [buf_i], [buf_z], eax, ebx,edx,esi, [edi]
-
 
3204
			@@:
-
 
3205
		pop eax
-
 
3206
 
-
 
3207
		add edi,4
-
 
3208
	.end_f:
-
 
3209
	ret
-
 
3210
endp
-
 
3211
 
-
 
3212
;description:
-
 
3213
; äã­ªæ¨ï à¨áãîé ï ®¤¨­®ç­ë© ¢®ªá¥«
-
 
3214
;input:
-
 
3215
; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
-
 
3216
; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
-
 
3217
; buf_v - ¡ãä¥à á ¨§®¡à ¦¥­¨¥¬ ¢®ªá¥«ï (32 ¡¨â )
-
 
3218
; v_color - 梥â
-
 
3219
align 4
-
 
3220
proc draw_vox, buf_i:dword, buf_z:dword, buf_v:dword,\
-
 
3221
coord_x:dword, coord_y:dword, coord_z:dword, v_color:dword
-
 
3222
pushad
-
 
3223
	mov eax,[coord_x]
-
 
3224
	mov ebx,[coord_y]
-
 
3225
	mov edi,[buf_v]
-
 
3226
	mov ecx,buf2d_h
-
 
3227
	mov esi,buf2d_w
-
 
3228
	imul ecx,esi
-
 
3229
	add esi,eax
-
 
3230
	mov edx,buf2d_data
-
 
3231
	cld
-
 
3232
	;ecx - count pixels in voxel
-
 
3233
	;edx - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢ ¢®ªá¥«ì­®¬ ¡ãä¥à¥
-
 
3234
	;edi - 㪠§ â¥«ì ­  ¢®ªá¥«ì­ë© ¡ãä¥à
-
 
3235
	;esi - width voxel buffer add coord x
-
 
3236
	.cycle:
-
 
3237
		cmp dword[edx],0
-
 
3238
		je @f
-
 
3239
			;¯à®¢¥à塞 ¡ãä¥à £«ã¡¨­ë
-
 
3240
			push eax
-
 
3241
			stdcall buf_get_pixel, [buf_z],eax,ebx
-
 
3242
			sub eax,[coord_z]
-
 
3243
			cmp eax,[edx]
-
 
3244
			jl .dr_pixel
-
 
3245
				pop eax
-
 
3246
				jmp @f
-
 
3247
			.dr_pixel:
-
 
3248
				;à¨á㥬 â®çªã
-
 
3249
				pop eax
-
 
3250
				stdcall buf_set_pixel, [buf_i],eax,ebx,[v_color]
-
 
3251
				push ecx
-
 
3252
				mov ecx,[coord_z]
-
 
3253
				add ecx,[edx]
-
 
3254
				stdcall buf_set_pixel, [buf_z],eax,ebx,ecx
-
 
3255
				pop ecx
-
 
3256
		@@:
-
 
3257
		add edx,4
-
 
3258
		inc eax
-
 
3259
		cmp eax,esi
-
 
3260
		jl @f
-
 
3261
			inc ebx
-
 
3262
			sub eax,buf2d_w
-
 
3263
		@@:
-
 
3264
		loop .cycle
-
 
3265
popad
-
 
3266
	ret
-
 
3267
endp
-
 
3268
 
-
 
3269
;description:
-
 
3270
;äã­ªæ¨ï ¤«ï ª®à¥ªâ¨à®¢ª¨ ª®®à¤¨­ â
-
 
3271
;­ ¯à ¢«¥­¨ï ®á¥© ª®®à¤¨­ â ¢ ¢®ªá¥«¥:
-
 
3272
;*z
-
 
3273
;|
-
 
3274
;+
-
 
3275
;  * y
-
 
3276
; /
-
 
3277
;+
-
 
3278
; \
-
 
3279
;  * x
-
 
3280
;input:
-
 
3281
;  al - ­®¬¥à 㧫  ¢ ¤¥à¥¢¥ (®â 1 ¤® 8)
-
 
3282
; ebx - ª®®à¤¨­ â  x
-
 
3283
; edx - ª®®à¤¨­ â  y
-
 
3284
; esi - ª®®à¤¨­ â  z
-
 
3285
; ecx - ã஢¥­ì ⥪ã襣® 㧫 
-
 
3286
;output:
-
 
3287
; ebx - ­®¢ ï ª®®à¤¨­ â  x
-
 
3288
; edx - ­®¢ ï ª®®à¤¨­ â  y
-
 
3289
; esi - ­®¢ ï ª®®à¤¨­ â  z
-
 
3290
align 4
-
 
3291
proc vox_corect_coords, h_br:dword, v_obj:dword
-
 
3292
locals
-
 
3293
	osn_w_2 dd ? ;è¨à¨­  ®á­®¢ ­¨ï ¥¤¨­¨ç­®£® ¢®ªá¥«ï : 2
-
 
3294
	vox_h dd ? ;¢ëá®â  ¥¤¨­¨ç­®£® ¢®ªá¥«ï
-
 
3295
endl
-
 
3296
	cmp ecx,0
-
 
3297
	jl .end_f ;¤«ï ã᪮७¨ï ®âà¨á®¢ª¨
-
 
3298
 
-
 
3299
	push eax edi
-
 
3300
	and eax,15 ;¢ë¤¥«ï¥¬ ­®¬¥à 㧫  ¢ ¤¥à¥¢¥
-
 
3301
	mov edi,[v_obj]
-
 
3302
	add edi,vox_offs_tree_table
-
 
3303
	add edi,8
-
 
3304
	sub edi,eax
-
 
3305
 
-
 
3306
	push ebx ecx
-
 
3307
		mov ebx,[h_br]
-
 
3308
 
-
 
3309
		movzx ecx,byte[ebx]
-
 
3310
		shr ecx,1
-
 
3311
		mov dword[osn_w_2],ecx
-
 
3312
 
-
 
3313
		movzx ecx,byte[ebx+2]
-
 
3314
		movzx ebx,byte[ebx+1]
-
 
3315
		sub ebx,ecx
-
 
3316
		mov dword[vox_h],ebx
-
 
3317
		shr ecx,1
-
 
3318
		mov eax,ecx ;eax - ¢ëá®â  ®á­®¢ ­¨ï ¥¤¨­¨ç­®£® ¢®ªá¥«ï : 2
-
 
3319
	pop ecx ebx
-
 
3320
 
-
 
3321
	cmp ecx,1
-
 
3322
	jl .no_scale ;¢® ¨§¡¥¦ ­¨¥ § æ¨ª«¨¢ ­¨ï
-
 
3323
		shl eax,cl
-
 
3324
		shl dword[osn_w_2],cl
-
 
3325
		shl dword[vox_h],cl
-
 
3326
	.no_scale:
-
 
3327
 
-
 
3328
;	add esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z (ª®¬¯¥­á æ¨ï ¤«ï ª®®à¤¨­ âë y)
-
 
3329
	bt word[edi],0 ;test voxel coord x
-
 
3330
	jnc @f
-
 
3331
		add ebx,[osn_w_2]
-
 
3332
		add edx,eax
-
 
3333
		add esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
-
 
3334
	@@:
-
 
3335
	bt word[edi],1 ;test voxel coord y
-
 
3336
	jnc @f
-
 
3337
		add ebx,[osn_w_2]
-
 
3338
		sub edx,eax
-
 
3339
		sub esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
-
 
3340
	@@:
-
 
3341
	bt word[edi],2 ;test voxel coord z
-
 
3342
	jnc @f
-
 
3343
		sub edx,[vox_h]
-
 
3344
	@@:
-
 
3345
	pop edi eax
-
 
3346
	.end_f:
-
 
3347
	ret
-
 
3348
endp
-
 
3349
 
-
 
3350
;¨§¢«¥ª ¥¬ ¨§ h_br 㪠§ â¥«ì ­  ¡ãä¥à á ¨§®¡à ¦¥­¨¥¬ ¢®ªá¥«ï, 㪠§ ­­®£® ¯®à浪  n
-
 
3351
align 4
-
 
3352
proc vox_get_sub_brush uses ebx ecx, h_br:dword, n:dword
-
 
3353
	xor eax,eax
-
 
3354
	mov ebx,[n]
-
 
3355
	cmp ebx,0
-
 
3356
	jl @f
-
 
3357
	mov ecx,[h_br]
-
 
3358
	cmp bl,byte[ecx+3]
-
 
3359
	jg @f
-
 
3360
		add ecx,4
-
 
3361
		imul ebx,BUF_STRUCT_SIZE
-
 
3362
		mov eax,ebx
-
 
3363
		add eax,ecx
-
 
3364
	@@:
-
 
3365
	ret
-
 
3366
endp
-
 
3367
 
-
 
3368
;description:
-
 
3369
; äã­ªæ¨ï à¨áãîé ï á१ ¢®ªá¥«ì­®£® ®¡ì¥ªâ 
-
 
3370
;input:
-
 
3371
; v_size - à §¬¥à ª¢ ¤à â  á ¢®ªá¥«¥¬
-
 
3372
; k_scale - á⥯¥­ì ¤¥â «¨§ æ¨¨ ¨§®¡à ¦¥­¨ï
-
 
3373
; n_plane - ­®¬¥à ¯«®áª®á⨠á¥ç­¨ï (¢ ¯à¥¤¥« å ®â 0 ¤® 2^k_scale - 1)
-
 
3374
; b_color - 梥⠣࠭¨æë
-
 
3375
align 4
-
 
3376
proc buf_vox_obj_draw_pl, buf_i:dword, v_obj:dword, coord_x:dword,\
-
 
3377
coord_y:dword, v_size:dword, k_scale:dword, n_plane:dword, b_color:dword
-
 
3378
	cmp [k_scale],0
-
 
3379
	jl .end_f
-
 
3380
pushad
-
 
3381
	mov eax,[v_size]
-
 
3382
	mov ecx,[k_scale]
-
 
3383
	mov ebx,eax
-
 
3384
	cmp ecx,1
-
 
3385
	jl @f
-
 
3386
		shl ebx,cl
-
 
3387
	@@:
-
 
3388
	;ebx - ¯®«­ë© à §¬¥à ¨§®¡à ¦¥­¨ï
-
 
3389
	stdcall buf_rect_by_size, [buf_i], [coord_x],[coord_y],ebx,ebx, [b_color] ;à ¬ª  ­  à¨áã­®ª
-
 
3390
	mov edx,ebx
-
 
3391
	add ebx,[coord_y]
-
 
3392
	stdcall draw_polz_hor, [buf_i], [coord_x],ebx,edx,eax, [n_plane], [k_scale], [b_color] ;¯®«§ã­®ª, ¯®ª §ë¢ î騩 ­®¬¥à á¥ç¥­¨ï
-
 
3393
 
-
 
3394
	;à¨á®¢ ­¨¥ â®ç¥ª ¤«ï á¥âª¨
-
 
3395
	push ecx
-
 
3396
	mov edi,1
-
 
3397
	cmp ecx,1
-
 
3398
	jl @f
-
 
3399
		shl edi,cl
-
 
3400
	@@:
-
 
3401
	dec edi
-
 
3402
	cmp edi,1
-
 
3403
	jl .end_0
-
 
3404
	mov ecx,edi
-
 
3405
	imul ecx,edi
-
 
3406
	mov ebx,[coord_x]
-
 
3407
	mov edx,[coord_y]
-
 
3408
	add edx,eax
-
 
3409
	xor esi,esi
-
 
3410
	cld
-
 
3411
	@@:
-
 
3412
		add ebx,eax
-
 
3413
		inc esi
-
 
3414
		stdcall buf_set_pixel, [buf_i], ebx,edx, [b_color]
-
 
3415
		cmp esi,edi
-
 
3416
		jl .end_1
-
 
3417
			;¯¥à¥å®¤ â®ç¥ª ­  ­®¢ãî áâபã
-
 
3418
			xor esi,esi
-
 
3419
			mov ebx,[coord_x]
-
 
3420
			add edx,eax
-
 
3421
		.end_1:
-
 
3422
		loop @b
-
 
3423
	.end_0:
-
 
3424
	pop ecx
-
 
3425
 
-
 
3426
	;eax - à §¬¥à ®¤­®£® ª¢ ¤à â 
-
 
3427
	;edi - 㪠§ â¥«ì à¨áã¥¬ë¥ ¤ ­­ë¥ ¨§ ®¡ê¥ªâ 
-
 
3428
	mov ebx,[coord_x]
-
 
3429
	mov edx,[coord_y]
-
 
3430
	mov edi,[v_obj]
-
 
3431
	add edi,vox_offs_data
-
 
3432
	xor esi,esi
-
 
3433
	push eax
-
 
3434
	imul eax,[n_plane]
-
 
3435
	stdcall draw_sub_vox_obj_pl, [buf_i],[v_obj], eax
-
 
3436
popad
-
 
3437
	.end_f:
-
 
3438
	ret
-
 
3439
endp
-
 
3440
 
-
 
3441
;description:
-
 
3442
; äã­ªæ¨ï à¨áãîé ï á१ ç á⨠¢®ªá¥«ì­®£® ®¡ì¥ªâ 
-
 
3443
;input:
-
 
3444
; s_c_x, s_c_y, s_c_z, s_k_scale - ¯ à ¬¥âàë ®¯à¥¤¥«ïî騥 ç áâì ¢®ªá¥«ì­®£® ®¡ê¥ªâ , ª®â®à ï ¡ã¤¥â à¨á®¢ âìáï
-
 
3445
align 4
-
 
3446
proc buf_vox_obj_draw_pl_scaled, buf_i:dword, v_obj:dword, coord_x:dword,\
-
 
3447
coord_y:dword, v_size:dword, k_scale:dword, n_plane:dword, b_color:dword,\
-
 
3448
s_c_x:dword, s_c_y:dword, s_c_z:dword, s_k_scale:dword
-
 
3449
	cmp [k_scale],0
-
 
3450
	jl .end_f
-
 
3451
pushad
-
 
3452
locals
-
 
3453
	p_node dd 0 ;த¨â¥«ì᪨© 㧥«
-
 
3454
endl
-
 
3455
	mov eax,[v_size]
-
 
3456
	mov ecx,[k_scale]
-
 
3457
	mov ebx,eax
-
 
3458
	cmp ecx,1
-
 
3459
	jl @f
-
 
3460
		shl ebx,cl
-
 
3461
	@@:
-
 
3462
	;ebx - ¯®«­ë© à §¬¥à ¨§®¡à ¦¥­¨ï
-
 
3463
	stdcall buf_rect_by_size, [buf_i], [coord_x],[coord_y],ebx,ebx, [b_color] ;à ¬ª  ­  à¨áã­®ª
-
 
3464
	mov edx,ebx
-
 
3465
	add ebx,[coord_y]
-
 
3466
	stdcall draw_polz_hor, [buf_i], [coord_x],ebx,edx,eax, [n_plane], [k_scale], [b_color] ;¯®«§ã­®ª, ¯®ª §ë¢ î騩 ­®¬¥à á¥ç¥­¨ï
-
 
3467
 
-
 
3468
	;à¨á®¢ ­¨¥ â®ç¥ª ¤«ï á¥âª¨
-
 
3469
	push ecx
-
 
3470
	mov edi,1
-
 
3471
	cmp ecx,1
-
 
3472
	jl @f
-
 
3473
		shl edi,cl
-
 
3474
	@@:
-
 
3475
	dec edi
-
 
3476
	cmp edi,1
-
 
3477
	jl .end_3
-
 
3478
	mov ecx,edi
-
 
3479
	imul ecx,edi
-
 
3480
	mov ebx,[coord_x]
-
 
3481
	mov edx,[coord_y]
-
 
3482
	add edx,eax
-
 
3483
	xor esi,esi
-
 
3484
	cld
-
 
3485
	@@:
-
 
3486
		add ebx,eax
-
 
3487
		inc esi
-
 
3488
		stdcall buf_set_pixel, [buf_i], ebx,edx, [b_color]
-
 
3489
		cmp esi,edi
-
 
3490
		jl .end_4
-
 
3491
			;¯¥à¥å®¤ â®ç¥ª ­  ­®¢ãî áâபã
-
 
3492
			xor esi,esi
-
 
3493
			mov ebx,[coord_x]
-
 
3494
			add edx,eax
-
 
3495
		.end_4:
-
 
3496
		loop @b
-
 
3497
	.end_3:
-
 
3498
	pop ecx
-
 
3499
 
-
 
3500
	mov esi,[s_k_scale]
-
 
3501
	cmp esi,1
-
 
3502
	jl .end_2
-
 
3503
	mov edi,[v_obj]
-
 
3504
	add edi,vox_offs_data
-
 
3505
 
-
 
3506
	; *** (1) ***
-
 
3507
	.found:
-
 
3508
	stdcall vox_obj_get_node_position, [v_obj],[s_c_x],[s_c_y],[s_c_z],esi
-
 
3509
	movzx bx,byte[edi+3]
-
 
3510
	mov [p_node],edi
-
 
3511
	add edi,4
-
 
3512
	cmp eax,0
-
 
3513
	je .end_1
-
 
3514
	mov ecx,eax
-
 
3515
	cld
-
 
3516
	@@: ;横« ¤«ï ¯à®¯ã᪠ ¯à¥¤ë¤ãé¨å ¯®¤¤¥à¥¢ì¥¢ ¢ 㧫¥
-
 
3517
		bt bx,0 ;¯à®¢¥à塞 ¥áâì «¨ ¤®ç¥à­¨¥ 㧫ë
-
 
3518
		jnc .end_0
-
 
3519
			xor eax,eax
-
 
3520
			stdcall vox_obj_rec0 ;¢ eax ¢ëç¨á«ï¥âáï ç¨á«® ¤®ç¥à­¨å 㧫®¢, ¢ ¤ ­­®© ¢¥â¢¨
-
 
3521
		.end_0:
-
 
3522
		shr bx,1
-
 
3523
		loop @b
-
 
3524
	.end_1:
-
 
3525
	bt bx,0
-
 
3526
	jnc .end_2 ;¥á«¨ ¯®¤¤¥à¥¢  ­¥ áãé¥áâ¢ã¥â
-
 
3527
	dec esi
-
 
3528
	cmp esi,0
-
 
3529
	jg .found
-
 
3530
 
-
 
3531
	mov eax,[v_size]
-
 
3532
	;eax - à §¬¥à ®¤­®£® ª¢ ¤à â 
-
 
3533
	;edi - 㪠§ â¥«ì à¨áã¥¬ë¥ ¤ ­­ë¥ ¨§ ®¡ê¥ªâ 
-
 
3534
	mov ecx,[k_scale]
-
 
3535
	mov ebx,[coord_x]
-
 
3536
	mov edx,[coord_y]
-
 
3537
	xor esi,esi
-
 
3538
	push eax
-
 
3539
	imul eax,[n_plane]
-
 
3540
	stdcall draw_sub_vox_obj_pl, [buf_i],[v_obj], eax
-
 
3541
 
-
 
3542
	.end_2:
-
 
3543
popad
-
 
3544
	.end_f:
-
 
3545
	ret
-
 
3546
endp
-
 
3547
 
-
 
3548
;description:
-
 
3549
; ®¯à¥¤¥«¥­¨¥ ¯®§¨æ¨¨ 㧫  ¢ ¤¥à¥¢¥ (®â 0 ¤® 7)
-
 
3550
align 4
-
 
3551
proc vox_obj_get_node_position uses ebx ecx edi, v_obj:dword,\
-
 
3552
coord_x:dword,coord_y:dword,coord_z:dword,k_scale:dword
-
 
3553
	mov ecx,[k_scale]
-
 
3554
	dec ecx
-
 
3555
	mov eax,[coord_x]
-
 
3556
	mov ebx,[coord_y]
-
 
3557
	mov edi,[coord_z]
-
 
3558
	cmp ecx,1
-
 
3559
	jl .end_0
-
 
3560
		shr eax,cl
-
 
3561
		shr ebx,cl
-
 
3562
		shr edi,cl
-
 
3563
	.end_0:
-
 
3564
	and eax,1
-
 
3565
	bt ebx,0
-
 
3566
	jnc @f
-
 
3567
		bts eax,1
-
 
3568
	@@:
-
 
3569
	bt edi,0
-
 
3570
	jnc @f
-
 
3571
		bts eax,2
-
 
3572
	@@:
-
 
3573
 
-
 
3574
	mov edi,[v_obj]
-
 
3575
	add edi,vox_offs_tree_table
-
 
3576
	@@:
-
 
3577
		cmp al,byte[edi]
-
 
3578
		je @f
-
 
3579
		inc edi
-
 
3580
		jmp @b
-
 
3581
	@@:
-
 
3582
	sub edi,[v_obj]
-
 
3583
	sub edi,vox_offs_tree_table
-
 
3584
	mov eax,edi
-
 
3585
	
-
 
3586
	ret
-
 
3587
endp
-
 
3588
 
-
 
3589
;input:
-
 
3590
; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
-
 
3591
;output:
-
 
3592
; eax - eax + ç¨á«® 㧫®¢ ¢ ¤ ­­ëå ¢®ªá. ®¡ê¥ªâ 
-
 
3593
; edi - 㪠§ â¥«ì ­  ᬥ饭­ë¥ ¤ ­­ë¥ ¢®ªá. ®¡ê¥ªâ 
-
 
3594
align 4
-
 
3595
proc vox_obj_rec0
-
 
3596
	inc eax
-
 
3597
	cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
-
 
3598
	je .sub_trees
-
 
3599
 
-
 
3600
		;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
-
 
3601
		push ebx ecx
-
 
3602
		mov bh,byte[edi+3]
-
 
3603
		add edi,4
-
 
3604
		mov bl,8
-
 
3605
		.cycle:
-
 
3606
			bt bx,8 ;â¥áâ¨à㥬 ⮫쪮 bh
-
 
3607
			jnc .c_next
-
 
3608
				stdcall vox_obj_rec0
-
 
3609
			.c_next:
-
 
3610
			shr bh,1
-
 
3611
			dec bl
-
 
3612
			jnz .cycle
-
 
3613
		pop ecx ebx
-
 
3614
 
-
 
3615
		jmp .end_f
-
 
3616
	.sub_trees:
-
 
3617
		add edi,4
-
 
3618
	.end_f:
-
 
3619
	ret
-
 
3620
endp
-
 
3621
 
-
 
3622
;description:
-
 
3623
; äã­ªæ¨ï à¨áãîé ï £®à¨§®­â «ì­ãî ¯®«®áã á ¯®«§ã­ª®¬
-
 
3624
align 4
-
 
3625
proc draw_polz_hor uses eax ebx ecx, buf:dword, coord_x:dword, coord_y:dword,\
-
 
3626
size_x:dword, size_y:dword, pos:dword, k_scale:dword, color:dword
-
 
3627
	mov ebx,[size_x]
-
 
3628
	stdcall buf_rect_by_size, [buf], [coord_x],[coord_y],ebx,[size_y], [color]
-
 
3629
	mov ecx,[k_scale]
-
 
3630
	shr ebx,cl
-
 
3631
	mov eax,[pos]
-
 
3632
	imul eax,ebx
-
 
3633
	add eax,[coord_x]
-
 
3634
	stdcall buf_filled_rect_by_size, [buf], eax,[coord_y],ebx,[size_y], [color]
-
 
3635
	ret
-
 
3636
endp
-
 
3637
 
-
 
3638
;input:
-
 
3639
; ebx - coord_x
-
 
3640
; edx - coord_y
-
 
3641
; esi - coord_z
-
 
3642
; ecx - ã஢¥­ì ⥪ã襣® 㧫 
-
 
3643
; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
-
 
3644
align 4
-
 
3645
proc draw_sub_vox_obj_pl, buf_i:dword, v_obj:dword, clip_z:dword,\
-
 
3646
v_size:dword
-
 
3647
	cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
-
 
3648
	je .sub_trees
-
 
3649
 
-
 
3650
		;¯à®à¨á®¢ª  à ¬ª¨ ¥á«¨ à §¬¥à 㧫  = 1
-
 
3651
		cmp ecx,0
-
 
3652
		jne @f
-
 
3653
		;¯à®¢¥àª  £«ã¡¨­ë esi
-
 
3654
		;clip_z=n_plane*v_size
-
 
3655
		stdcall vox_is_clip, [clip_z],[v_size]
-
 
3656
		cmp eax,0
-
 
3657
		je @f
-
 
3658
			push ecx
-
 
3659
			mov ecx,dword[edi]
-
 
3660
			and ecx,0xffffff
-
 
3661
			stdcall buf_rect_by_size, [buf_i], ebx,edx, [v_size],[v_size],ecx
-
 
3662
			pop ecx
-
 
3663
		@@:
-
 
3664
 
-
 
3665
		;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
-
 
3666
		push edx
-
 
3667
 
-
 
3668
		;¢å®¤ ¢­ãâàì 㧫 
-
 
3669
		dec ecx
-
 
3670
 
-
 
3671
		mov eax,[v_size]
-
 
3672
		cmp ecx,1
-
 
3673
		jl @f
-
 
3674
			shl eax,cl
-
 
3675
		@@:
-
 
3676
		add edx,eax ;ª®à¥ªâ¨à®¢ª  ¢ëá®âë ¯®¤ ¢®ªá¥«ì ­¨¦­¥£® ã஢­ï
-
 
3677
 
-
 
3678
		mov ah,byte[edi+3]
-
 
3679
		add edi,4
-
 
3680
		mov al,8
-
 
3681
		.cycle:
-
 
3682
			bt ax,8 ;â¥áâ¨à㥬 ⮫쪮 ah
-
 
3683
			jnc .c_next
-
 
3684
				push eax ebx edx esi
-
 
3685
				stdcall vox_corect_coords_pl, [v_obj],[v_size]
-
 
3686
				stdcall draw_sub_vox_obj_pl, [buf_i],[v_obj],[clip_z],[v_size]
-
 
3687
				pop esi edx ebx eax
-
 
3688
			.c_next:
-
 
3689
			shr ah,1
-
 
3690
			dec al
-
 
3691
			jnz .cycle
-
 
3692
 
-
 
3693
		;¢ë室 ¨§ 㧫 
-
 
3694
		inc ecx
-
 
3695
		pop edx
-
 
3696
 
-
 
3697
		jmp .end_f
-
 
3698
	.sub_trees:
-
 
3699
		cmp ecx,0
-
 
3700
		jl .end_0 ;­¥ à¨á㥬 ®ç¥­ì ¬ «¥­ìª¨¥ ¢®ªá¥«¨
-
 
3701
 
-
 
3702
		;¯à®¢¥àª  £«ã¡¨­ë esi
-
 
3703
		;clip_z=n_plane*v_size
-
 
3704
		stdcall vox_is_clip, [clip_z],[v_size]
-
 
3705
		cmp eax,0
-
 
3706
		je .end_0
-
 
3707
 
-
 
3708
		;à¨á㥬 㧥«
-
 
3709
		mov eax,[edi]
-
 
3710
		and eax,0xffffff
-
 
3711
		push eax ;梥â 㧫 
-
 
3712
 
-
 
3713
		mov eax,[v_size]
-
 
3714
		cmp ecx,1
-
 
3715
		jl @f
-
 
3716
			;ª¢ ¤à â ¡®«ìè¥ â¥ªã饣® ¬ áèâ ¡ 
-
 
3717
			shl eax,cl ;à §¬¥à 㧫 
-
 
3718
			stdcall buf_filled_rect_by_size, [buf_i], ebx,edx, eax,eax
-
 
3719
			push ebx edx esi
-
 
3720
			mov esi,eax
-
 
3721
			inc ebx
-
 
3722
			inc edx
-
 
3723
			sub esi,2
-
 
3724
			mov eax,[buf_i]
-
 
3725
			push dword 128
-
 
3726
			push dword[eax+16] ;+16 - b_color
-
 
3727
			stdcall combine_colors_3,[edi]
-
 
3728
			stdcall buf_rect_by_size, [buf_i], ebx,edx, esi,esi,eax
-
 
3729
			pop esi edx ebx
-
 
3730
			jmp .end_0
-
 
3731
		@@:
-
 
3732
			;ª¢ ¤à â ⥪ã饣® ¬ áèâ ¡ 
-
 
3733
			stdcall buf_filled_rect_by_size, [buf_i], ebx,edx, eax,eax
-
 
3734
 
-
 
3735
		.end_0:
-
 
3736
		add edi,4
-
 
3737
	.end_f:
-
 
3738
	ret
-
 
3739
endp
-
 
3740
 
-
 
3741
;description:
-
 
3742
; ¢á¯®¬®£ â¥«ì­ ï äã­ªæ¨ï ¤«ï ¯à®¢¥àª¨ £«ã¡¨­ë esi
-
 
3743
;input:
-
 
3744
; ecx - ã஢¥­ì ⥪ã襣® 㧫 
-
 
3745
; esi - coord z
-
 
3746
; clip_z - n_plane*v_size
-
 
3747
;output:
-
 
3748
; eax - 0 if no draw, 1 if draw
-
 
3749
align 4
-
 
3750
proc vox_is_clip uses ebx edi, clip_z:dword, v_size:dword
-
 
3751
	xor eax,eax
-
 
3752
	mov ebx,[clip_z]
-
 
3753
	mov edi,[v_size]
-
 
3754
	cmp ecx,1
-
 
3755
	jl @f
-
 
3756
		shl edi,cl
-
 
3757
	@@:
-
 
3758
	;edi = 2^ecx
-
 
3759
	add edi,esi
-
 
3760
	cmp edi,ebx ;if (esi+2^ecx*v_size <= (n_plane*v_size)) no draw
-
 
3761
	jle @f
-
 
3762
	add ebx,[v_size]
-
 
3763
	cmp esi,ebx ;if (esi >= (n_plane+1)*v_size) no draw
-
 
3764
	jge @f
-
 
3765
		inc eax
-
 
3766
	@@:
-
 
3767
	ret
-
 
3768
endp
-
 
3769
 
-
 
3770
;äã­ªæ¨ï ¤«ï ª®à¥ªâ¨à®¢ª¨ ª®®à¤¨­ â
-
 
3771
;­ ¯à ¢«¥­¨ï ®á¥© ª®®à¤¨­ â ¢ ¢®ªá¥«¥:
-
 
3772
;*z
-
 
3773
;|
-
 
3774
;+-* x
-
 
3775
;input:
-
 
3776
;  al - ­®¬¥à 㧫  ¢ ¤¥à¥¢¥ (®â 1 ¤® 8)
-
 
3777
; ebx - ª®®à¤¨­ â  x
-
 
3778
; edx - ª®®à¤¨­ â  y
-
 
3779
; esi - ª®®à¤¨­ â  z
-
 
3780
; ecx - ã஢¥­ì ⥪ã襣® 㧫 
-
 
3781
;output:
-
 
3782
; ebx - ­®¢ ï ª®®à¤¨­ â  x
-
 
3783
; edx - ­®¢ ï ª®®à¤¨­ â  y
-
 
3784
; esi - ­®¢ ï ª®®à¤¨­ â  z
-
 
3785
align 4
-
 
3786
proc vox_corect_coords_pl, v_obj:dword, v_size:dword
-
 
3787
	cmp ecx,0
-
 
3788
	jl .end_f ;¤«ï ã᪮७¨ï ®âà¨á®¢ª¨
-
 
3789
 
-
 
3790
	push eax edi
-
 
3791
	and eax,15 ;¢ë¤¥«ï¥¬ ­®¬¥à 㧫  ¢ ¤¥à¥¢¥
-
 
3792
	mov edi,[v_obj]
-
 
3793
	add edi,vox_offs_tree_table
-
 
3794
	add edi,8
-
 
3795
	sub edi,eax
-
 
3796
 
-
 
3797
	mov eax,[v_size] ;eax - ¢ëá®â  ®á­®¢ ­¨ï ¥¤¨­¨ç­®£® ¢®ªá¥«ï
-
 
3798
	cmp ecx,1
-
 
3799
	jl @f ;¢® ¨§¡¥¦ ­¨¥ § æ¨ª«¨¢ ­¨ï
-
 
3800
		shl eax,cl
-
 
3801
	@@:
-
 
3802
 
-
 
3803
	bt word[edi],0 ;test voxel coord x
-
 
3804
	jnc @f
-
 
3805
		add ebx,eax
-
 
3806
	@@:
-
 
3807
	bt word[edi],1 ;test voxel coord y
-
 
3808
	jnc @f
-
 
3809
		add esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
-
 
3810
	@@:
-
 
3811
	bt word[edi],2 ;test voxel coord z
-
 
3812
	jnc @f
-
 
3813
		sub edx,eax
-
 
3814
	@@:
-
 
3815
	pop edi eax
-
 
3816
	.end_f:
-
 
3817
	ret
-
 
3818
endp
-
 
3819
 
-
 
3820
;description:
-
 
3821
; äã­ªæ¨ï à¨áãîé ï ⥭¨
-
 
3822
;input:
-
 
3823
; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
-
 
3824
; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
-
 
3825
; h_br - ª¨áâì á ¨§®¡à ¦¥­¨ï¬¨ ¢®ªá¥«¥© (32 ¡¨â )
-
 
3826
; k_scale - ª®íä. ¤«ï ¬ áèâ ¡¨à®¢ ­¨ï ¨§®¡à ¦¥­¨ï
-
 
3827
align 4
-
 
3828
proc buf_vox_obj_draw_3g_shadows, buf_i:dword, buf_z:dword, h_br:dword, \
-
 
3829
coord_x:dword, coord_y:dword, color:dword, k_scale:dword, prop:dword
-
 
3830
locals
-
 
3831
	correct_z dd 0 ;ª®à¥ªâ¨à®¢ª  ¤«ï ¡ãä¥à  £«ã¡¨­ë
-
 
3832
endl
-
 
3833
pushad
-
 
3834
	mov eax,[k_scale]
-
 
3835
	add eax,[prop]
-
 
3836
	mov dword[correct_z],8
-
 
3837
	sub [correct_z],eax
-
 
3838
	mov ebx,[coord_x]
-
 
3839
	;correct_z = 8-k_scale-prop
-
 
3840
 
-
 
3841
	stdcall buf_vox_obj_get_img_w_3g, [h_br],[k_scale]
-
 
3842
	mov edx,eax ;edx - è¨à¨­  ¨§®¡à ¦¥­¨ï
-
 
3843
	stdcall buf_vox_obj_get_img_h_3g, [h_br],[k_scale]
-
 
3844
	mov esi,eax
-
 
3845
 
-
 
3846
	mov edi,[coord_y]
-
 
3847
	mov ecx,edx
-
 
3848
	add edx,ebx ;è¨à¨­  + ®âáâ㯠᫥¢ 
-
 
3849
	imul ecx,esi
-
 
3850
	cld
-
 
3851
	.cycle_0:
-
 
3852
		stdcall buf_get_pixel, [buf_z],ebx,edi
-
 
3853
		cmp eax,0
-
 
3854
		je @f
-
 
3855
			stdcall vox_correct_z, [correct_z]
-
 
3856
			push eax
-
 
3857
			stdcall buf_get_pixel, [buf_i],ebx,edi
-
 
3858
			stdcall combine_colors_3,eax,[color] ;,eax
-
 
3859
			stdcall buf_set_pixel, [buf_i],ebx,edi,eax
-
 
3860
		@@:
-
 
3861
		inc ebx
-
 
3862
		cmp ebx,edx
-
 
3863
		jl @f
-
 
3864
			mov ebx,[coord_x]
-
 
3865
			inc edi
-
 
3866
		@@:
-
 
3867
		loop .cycle_0
-
 
3868
 
-
 
3869
popad
-
 
3870
	ret
-
 
3871
endp
-
 
3872
 
-
 
3873
;output:
-
 
3874
; eax - scaled coord z
-
 
3875
align 4
-
 
3876
proc vox_correct_z uses ecx, correct_z:dword
-
 
3877
	mov ecx,[correct_z]
-
 
3878
	cmp ecx,0
-
 
3879
	je .end_f
-
 
3880
	jl .end_0
-
 
3881
		shl eax,cl
-
 
3882
		jmp .end_f
-
 
3883
	.end_0:
-
 
3884
		neg ecx
-
 
3885
		inc ecx
-
 
3886
		shr eax,cl
-
 
3887
	.end_f:
-
 
3888
	ret
-
 
3889
endp
-
 
3890
 
-
 
3891
;output:
-
 
3892
; eax - color
-
 
3893
align 4
-
 
3894
proc combine_colors_3 uses ebx ecx edx edi esi, col_0:dword, col_1:dword, alpha:dword
-
 
3895
 
-
 
3896
	mov ebx,[col_0]
-
 
3897
	mov ecx,[col_1]
-
 
3898
	movzx di,byte[alpha] ;pro
-
 
3899
	mov si,0x00ff ;---get transparent---
-
 
3900
	sub si,di ;256-pro
-
 
3901
 
-
 
3902
	;---blye---
-
 
3903
	movzx ax,bl
-
 
3904
	imul ax,si
-
 
3905
	movzx dx,cl
-
 
3906
	imul dx,di
-
 
3907
	add ax,dx
-
 
3908
	mov cl,ah
-
 
3909
	;---green---
-
 
3910
	movzx ax,bh
-
 
3911
	imul ax,si
-
 
3912
	movzx dx,ch
-
 
3913
	imul dx,di
-
 
3914
	add ax,dx
-
 
3915
	mov ch,ah
-
 
3916
	shr ebx,16
-
 
3917
	ror ecx,16
-
 
3918
	;---red---
-
 
3919
	movzx ax,bl
-
 
3920
	imul ax,si
-
 
3921
	movzx dx,cl
-
 
3922
	imul dx,di
-
 
3923
	add ax,dx
-
 
3924
 
-
 
3925
	shl eax,8
-
 
3926
	ror ecx,16
-
 
3927
	mov ax,cx
-
 
3928
	and eax,0xffffff
-
 
3929
 
-
 
3930
	ret
-
 
3931
endp
2954
 
3932
 
2955
txt_err_n8b db 'need buffer 8 bit',13,10,0
3933
txt_err_n8b db 'need buffer 8 bit',13,10,0
2956
txt_err_n24b db 'need buffer 24 bit',13,10,0
3934
txt_err_n24b db 'need buffer 24 bit',13,10,0
2957
txt_err_n8_24b db 'need buffer 8 or 24 bit',13,10,0
3935
txt_err_n8_24b db 'need buffer 8 or 24 bit',13,10,0
2958
 
3936
 
2959
align 16
3937
align 16
2960
EXPORTS:
3938
EXPORTS:
2961
	dd sz_lib_init, lib_init
3939
	dd sz_lib_init, lib_init
2962
	dd sz_buf2d_create, buf_create
3940
	dd sz_buf2d_create, buf_create
2963
	dd sz_buf2d_create_f_img, buf_create_f_img
3941
	dd sz_buf2d_create_f_img, buf_create_f_img
2964
	dd sz_buf2d_clear, buf_clear
3942
	dd sz_buf2d_clear, buf_clear
2965
	dd sz_buf2d_draw, buf_draw_buf
3943
	dd sz_buf2d_draw, buf_draw_buf
2966
	dd sz_buf2d_delete, buf_delete
3944
	dd sz_buf2d_delete, buf_delete
2967
	dd sz_buf2d_resize, buf_resize
3945
	dd sz_buf2d_resize, buf_resize
2968
	dd sz_buf2d_line, buf_line_brs
3946
	dd sz_buf2d_line, buf_line_brs
2969
	dd sz_buf2d_line_sm, buf_line_brs_sm
3947
	dd sz_buf2d_line_sm, buf_line_brs_sm
2970
	dd sz_buf2d_rect_by_size, buf_rect_by_size
3948
	dd sz_buf2d_rect_by_size, buf_rect_by_size
2971
	dd sz_buf2d_filled_rect_by_size, buf_filled_rect_by_size
3949
	dd sz_buf2d_filled_rect_by_size, buf_filled_rect_by_size
2972
	dd sz_buf2d_circle, buf_circle
3950
	dd sz_buf2d_circle, buf_circle
2973
	dd sz_buf2d_img_hdiv2, buf_img_hdiv2
3951
	dd sz_buf2d_img_hdiv2, buf_img_hdiv2
2974
	dd sz_buf2d_img_wdiv2, buf_img_wdiv2
3952
	dd sz_buf2d_img_wdiv2, buf_img_wdiv2
2975
	dd sz_buf2d_conv_24_to_8, buf_conv_24_to_8
3953
	dd sz_buf2d_conv_24_to_8, buf_conv_24_to_8
2976
	dd sz_buf2d_conv_24_to_32, buf_conv_24_to_32
3954
	dd sz_buf2d_conv_24_to_32, buf_conv_24_to_32
2977
	dd sz_buf2d_bit_blt, buf_bit_blt
3955
	dd sz_buf2d_bit_blt, buf_bit_blt
2978
	dd sz_buf2d_bit_blt_transp, buf_bit_blt_transp
3956
	dd sz_buf2d_bit_blt_transp, buf_bit_blt_transp
2979
	dd sz_buf2d_bit_blt_alpha, buf_bit_blt_alpha
3957
	dd sz_buf2d_bit_blt_alpha, buf_bit_blt_alpha
2980
	dd sz_buf2d_curve_bezier, buf_curve_bezier
3958
	dd sz_buf2d_curve_bezier, buf_curve_bezier
2981
	dd sz_buf2d_convert_text_matrix, buf_convert_text_matrix
3959
	dd sz_buf2d_convert_text_matrix, buf_convert_text_matrix
2982
	dd sz_buf2d_draw_text, buf_draw_text
3960
	dd sz_buf2d_draw_text, buf_draw_text
2983
	dd sz_buf2d_crop_color, buf_crop_color
3961
	dd sz_buf2d_crop_color, buf_crop_color
2984
	dd sz_buf2d_offset_h, buf_offset_h
3962
	dd sz_buf2d_offset_h, buf_offset_h
2985
	dd sz_buf2d_flood_fill, buf_flood_fill
3963
	dd sz_buf2d_flood_fill, buf_flood_fill
2986
	dd sz_buf2d_set_pixel, buf_set_pixel
3964
	dd sz_buf2d_set_pixel, buf_set_pixel
2987
	dd sz_buf2d_get_pixel, buf_get_pixel
3965
	dd sz_buf2d_get_pixel, buf_get_pixel
2988
	dd sz_buf2d_vox_brush_create, vox_brush_create
3966
	dd sz_buf2d_vox_brush_create, vox_brush_create
2989
	dd sz_buf2d_vox_brush_delete, vox_brush_delete
3967
	dd sz_buf2d_vox_brush_delete, vox_brush_delete
-
 
3968
	dd sz_buf2d_vox_obj_get_img_w_3g, buf_vox_obj_get_img_w_3g
-
 
3969
	dd sz_buf2d_vox_obj_get_img_h_3g, buf_vox_obj_get_img_h_3g
-
 
3970
	dd sz_buf2d_vox_obj_draw_3g, buf_vox_obj_draw_3g
-
 
3971
	dd sz_buf2d_vox_obj_draw_3g_scaled, buf_vox_obj_draw_3g_scaled
-
 
3972
	dd sz_buf2d_vox_obj_draw_pl, buf_vox_obj_draw_pl
-
 
3973
	dd sz_buf2d_vox_obj_draw_pl_scaled, buf_vox_obj_draw_pl_scaled
-
 
3974
	dd sz_buf2d_vox_obj_draw_3g_shadows, buf_vox_obj_draw_3g_shadows
2990
	dd 0,0
3975
	dd 0,0
2991
	sz_lib_init db 'lib_init',0
3976
	sz_lib_init db 'lib_init',0
2992
	sz_buf2d_create db 'buf2d_create',0
3977
	sz_buf2d_create db 'buf2d_create',0
2993
	sz_buf2d_create_f_img db 'buf2d_create_f_img',0
3978
	sz_buf2d_create_f_img db 'buf2d_create_f_img',0
2994
	sz_buf2d_clear db 'buf2d_clear',0 ;®ç¨á⪠ ¡ãä¥à  㪠§ ­­ë¬ 梥⮬
3979
	sz_buf2d_clear db 'buf2d_clear',0 ;®ç¨á⪠ ¡ãä¥à  㪠§ ­­ë¬ 梥⮬
2995
	sz_buf2d_draw db 'buf2d_draw',0
3980
	sz_buf2d_draw db 'buf2d_draw',0
2996
	sz_buf2d_delete db 'buf2d_delete',0
3981
	sz_buf2d_delete db 'buf2d_delete',0
2997
	sz_buf2d_resize db 'buf2d_resize',0
3982
	sz_buf2d_resize db 'buf2d_resize',0
2998
	sz_buf2d_line db 'buf2d_line',0 ;à¨á®¢ ­¨¥ «¨­¨¨
3983
	sz_buf2d_line db 'buf2d_line',0 ;à¨á®¢ ­¨¥ «¨­¨¨
2999
	sz_buf2d_line_sm db 'buf2d_line_sm',0 ;à¨á®¢ ­¨¥ ᣫ ¦¥­­®© «¨­¨¨
3984
	sz_buf2d_line_sm db 'buf2d_line_sm',0 ;à¨á®¢ ­¨¥ ᣫ ¦¥­­®© «¨­¨¨
3000
	sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0 ;à¨á®¢ ­¨¥ à ¬ª¨ ¯àאַ㣮«ì­¨ª , 2-ï ª®®à¤¨­ â  § ¤ ­  ¯® à §¬¥àã
3985
	sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0 ;à¨á®¢ ­¨¥ à ¬ª¨ ¯àאַ㣮«ì­¨ª , 2-ï ª®®à¤¨­ â  § ¤ ­  ¯® à §¬¥àã
3001
	sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0 ;à¨á®¢ ­¨¥ § «¨â®£® ¯àאַ㣮«ì­¨ª , 2-ï ª®®à¤¨­ â  § ¤ ­  ¯® à §¬¥àã
3986
	sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0 ;à¨á®¢ ­¨¥ § «¨â®£® ¯àאַ㣮«ì­¨ª , 2-ï ª®®à¤¨­ â  § ¤ ­  ¯® à §¬¥àã
3002
	sz_buf2d_circle db 'buf2d_circle',0 ;à¨á®¢ ­¨¥ ®ªà㦭®áâ¨
3987
	sz_buf2d_circle db 'buf2d_circle',0 ;à¨á®¢ ­¨¥ ®ªà㦭®áâ¨
3003
	sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0 ;ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® ¢ëá®â¥ ¢ 2 à §  (à §¬¥à ¡ãä¥à  ­¥ ¬¥­ï¥âáï)
3988
	sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0 ;ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® ¢ëá®â¥ ¢ 2 à §  (à §¬¥à ¡ãä¥à  ­¥ ¬¥­ï¥âáï)
3004
	sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0 ;ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® è¨à¨­¥ ¢ 2 à §  (à §¬¥à ¡ãä¥à  ­¥ ¬¥­ï¥âáï)
3989
	sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0 ;ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® è¨à¨­¥ ¢ 2 à §  (à §¬¥à ¡ãä¥à  ­¥ ¬¥­ï¥âáï)
3005
	sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
3990
	sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
3006
	sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0 
3991
	sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0 
3007
	sz_buf2d_bit_blt db 'buf2d_bit_blt',0
3992
	sz_buf2d_bit_blt db 'buf2d_bit_blt',0
3008
	sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
3993
	sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
3009
	sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
3994
	sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
3010
	sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
3995
	sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
3011
	sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
3996
	sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
3012
	sz_buf2d_draw_text db 'buf2d_draw_text',0
3997
	sz_buf2d_draw_text db 'buf2d_draw_text',0
3013
	sz_buf2d_crop_color db 'buf2d_crop_color',0
3998
	sz_buf2d_crop_color db 'buf2d_crop_color',0
3014
	sz_buf2d_offset_h db 'buf2d_offset_h',0
3999
	sz_buf2d_offset_h db 'buf2d_offset_h',0
3015
	sz_buf2d_flood_fill db 'buf2d_flood_fill',0
4000
	sz_buf2d_flood_fill db 'buf2d_flood_fill',0
3016
	sz_buf2d_set_pixel db 'buf2d_set_pixel',0
4001
	sz_buf2d_set_pixel db 'buf2d_set_pixel',0
3017
	sz_buf2d_get_pixel db 'buf2d_get_pixel',0
4002
	sz_buf2d_get_pixel db 'buf2d_get_pixel',0
3018
	sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
4003
	sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
3019
	sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
4004
	sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
-
 
4005
	sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
-
 
4006
	sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
-
 
4007
	sz_buf2d_vox_obj_draw_3g db 'buf2d_vox_obj_draw_3g',0
-
 
4008
	sz_buf2d_vox_obj_draw_3g_scaled db 'buf2d_vox_obj_draw_3g_scaled',0
-
 
4009
	sz_buf2d_vox_obj_draw_pl db 'buf2d_vox_obj_draw_pl',0
-
 
4010
	sz_buf2d_vox_obj_draw_pl_scaled db 'buf2d_vox_obj_draw_pl_scaled',0
-
 
4011
	sz_buf2d_vox_obj_draw_3g_shadows db 'buf2d_vox_obj_draw_3g_shadows',0
3020
;>
4012
;>
3021
>
4013
>
3022
>
4014
>
3023
>
4015
>
3024
>
4016
>
3025
>
4017
>
3026
>
4018
>
3027
>
4019
>