Subversion Repositories Kolibri OS

Rev

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

Rev 6210 Rev 6211
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
;input:
51
;input:
52
; eax = 㪠§ â¥«ì ­  äã­ªæ¨î ¢ë¤¥«¥­¨ï ¯ ¬ïâ¨
52
; eax = 㪠§ â¥«ì ­  äã­ªæ¨î ¢ë¤¥«¥­¨ï ¯ ¬ïâ¨
53
; ebx = ... ®á¢®¡®¦¤¥­¨ï ¯ ¬ïâ¨
53
; ebx = ... ®á¢®¡®¦¤¥­¨ï ¯ ¬ïâ¨
54
; ecx = ... ¯¥à¥à á¯à¥¤¥«¥­¨ï ¯ ¬ïâ¨
54
; ecx = ... ¯¥à¥à á¯à¥¤¥«¥­¨ï ¯ ¬ïâ¨
55
; edx = ... § £à㧪¨ ¡¨¡«¨®â¥ª¨ (¯®ª  ­¥ ¨á¯®«ì§ã¥âáï)
55
; edx = ... § £à㧪¨ ¡¨¡«¨®â¥ª¨ (¯®ª  ­¥ ¨á¯®«ì§ã¥âáï)
56
align 16
56
align 16
57
lib_init:
57
lib_init:
58
	mov dword[mem.alloc], eax
58
	mov dword[mem.alloc], eax
59
	mov dword[mem.free], ebx
59
	mov dword[mem.free], ebx
60
	mov dword[mem.realloc], ecx
60
	mov dword[mem.realloc], ecx
61
	mov dword[dll.load], edx
61
	mov dword[dll.load], edx
62
	ret
62
	ret
63
 
63
 
64
include 'fun_draw.inc' ;ä㭪樨 à¨á®¢ ­¨ï ¢ ¡ãä¥à¥
64
include 'fun_draw.inc' ;ä㭪樨 à¨á®¢ ­¨ï ¢ ¡ãä¥à¥
65
 
65
 
66
;ᮧ¤ ­¨¥ ¡ãä¥à 
66
;ᮧ¤ ­¨¥ ¡ãä¥à 
67
align 4
67
align 4
68
proc buf_create, buf_struc:dword
68
proc buf_create, buf_struc:dword
69
	pushad
69
	pushad
70
	mov edi,dword[buf_struc]
70
	mov edi,dword[buf_struc]
71
	mov ecx,buf2d_w
71
	mov ecx,buf2d_w
72
	mov ebx,buf2d_h
72
	mov ebx,buf2d_h
73
	imul ecx,ebx
73
	imul ecx,ebx
74
	cmp buf2d_bits,24
74
	cmp buf2d_bits,24
75
	jne @f
75
	jne @f
76
		lea ecx,[ecx+ecx*2] ; 24 bit = 3
76
		lea ecx,[ecx+ecx*2] ; 24 bit = 3
77
		;;;inc ecx ;§ ¯ á­®© ¡ ©â ¢ ª®­æ¥ ¡ãä¥à , çâ®-¡ë ­¥ £«î稫¨ ­¥ª®â®àë¥ ä㭪樨 ­  ¨§®¡à ¦¥­¨ïå ªà â­ëå 4Š
77
		;;;inc ecx ;§ ¯ á­®© ¡ ©â ¢ ª®­æ¥ ¡ãä¥à , çâ®-¡ë ­¥ £«î稫¨ ­¥ª®â®àë¥ ä㭪樨 ­  ¨§®¡à ¦¥­¨ïå ªà â­ëå 4Š
78
	@@:
78
	@@:
79
	cmp buf2d_bits,32
79
	cmp buf2d_bits,32
80
	jne @f
80
	jne @f
81
		shl ecx,2 ; 32 bit = 4
81
		shl ecx,2 ; 32 bit = 4
82
	@@:
82
	@@:
83
	invoke mem.alloc,ecx
83
	invoke mem.alloc,ecx
84
	mov buf2d_data,eax
84
	mov buf2d_data,eax
85
 
85
 
86
	stdcall buf_clear,edi,buf2d_color ;®ç¨á⪠ ¡ãä¥à  ä®­®¢ë¬ 梥⮬
86
	stdcall buf_clear,edi,buf2d_color ;®ç¨á⪠ ¡ãä¥à  ä®­®¢ë¬ 梥⮬
87
	popad
87
	popad
88
	ret
88
	ret
89
endp
89
endp
90
 
90
 
91
;ᮧ¤ ­¨¥ ¡ãä¥à  ­  ®á­®¢¥ ¨§®¡à ¦¥­¨ï rgb
91
;ᮧ¤ ­¨¥ ¡ãä¥à  ­  ®á­®¢¥ ¨§®¡à ¦¥­¨ï rgb
92
align 4
92
align 4
93
proc buf_create_f_img, buf_struc:dword, rgb_data:dword
93
proc buf_create_f_img, buf_struc:dword, rgb_data:dword
94
	pushad
94
	pushad
95
	mov edi,dword[buf_struc]
95
	mov edi,dword[buf_struc]
96
	mov ecx,buf2d_w
96
	mov ecx,buf2d_w
97
	cmp ecx,1
97
	cmp ecx,1
98
	jl .end_create
98
	jl .error
99
	mov ebx,buf2d_h
99
	mov ebx,buf2d_h
100
	cmp ebx,1
100
	cmp ebx,1
101
	jl .end_create
101
	jl .error
102
	imul ecx,ebx
102
	imul ecx,ebx
103
	cmp buf2d_bits,24
103
	cmp buf2d_bits,24
104
	jne @f
104
	jne @f
105
		lea ecx,[ecx+ecx*2] ; 24 bit = 3
105
		lea ecx,[ecx+ecx*2] ; 24 bit = 3
106
	@@:
106
	@@:
107
	cmp buf2d_bits,32
107
	cmp buf2d_bits,32
108
	jne @f
108
	jne @f
109
		shl ecx,2 ; 32 bit = 4
109
		shl ecx,2 ; 32 bit = 4
110
	@@:
110
	@@:
111
	invoke mem.alloc,ecx
111
	invoke mem.alloc,ecx
112
	mov buf2d_data,eax
112
	mov buf2d_data,eax
113
 
113
 
114
	cmp buf2d_bits,24
114
	cmp buf2d_bits,24
115
	jne @f
115
	jne @f
116
		cld
116
		cld
117
		mov esi,[rgb_data]
117
		mov esi,[rgb_data]
-
 
118
		or esi,esi
-
 
119
		jz @f
118
		mov edi,eax ;eax=buf2d_data
120
		mov edi,eax ;eax=buf2d_data
119
		rep movsb ;ª®¯¨à㥬 ¡¨âë ¨§®¡à ¦¥­¨ï ¢ ¡ãä¥à
121
		rep movsb ;ª®¯¨à㥬 ¡¨âë ¨§®¡à ¦¥­¨ï ¢ ¡ãä¥à
120
		jmp .end_create
122
		jmp .end_create
121
	@@:
123
	@@:
122
		stdcall buf_clear,edi,buf2d_color ;®ç¨á⪠ ¡ãä¥à  ä®­®¢ë¬ 梥⮬
124
		stdcall buf_clear,edi,buf2d_color ;®ç¨á⪠ ¡ãä¥à  ä®­®¢ë¬ 梥⮬
123
		jmp .end_create
125
		jmp .end_create
124
	.error:
126
	.error:
125
		stdcall print_err,sz_buf2d_create_f_img,txt_err_size_0
127
		stdcall print_err,sz_buf2d_create_f_img,txt_err_size_0
126
	.end_create:
128
	.end_create:
127
	popad
129
	popad
128
	ret
130
	ret
129
endp
131
endp
130
 
132
 
131
;äã­ªæ¨ï ¤«ï ®¡à¥§ ­¨ï ¡ãä¥à®¢ 8 ¨ 24 ¡¨â­ëå, ¯® § ¤ ­®¬ã 梥âã.
133
;äã­ªæ¨ï ¤«ï ®¡à¥§ ­¨ï ¡ãä¥à®¢ 8 ¨ 24 ¡¨â­ëå, ¯® § ¤ ­®¬ã 梥âã.
132
;¯ à ¬¥âà opt § ¤ ¥âáï ª®¬¡¨­ æ¨¥© ª®­áâ ­â:
134
;¯ à ¬¥âà opt § ¤ ¥âáï ª®¬¡¨­ æ¨¥© ª®­áâ ­â:
133
; BUF2D_OPT_CROP_TOP - ®¡à¥§ª  ᢥàåã
135
; BUF2D_OPT_CROP_TOP - ®¡à¥§ª  ᢥàåã
134
; BUF2D_OPT_CROP_LEFT - ®¡à¥§ª  á«¥¢ 
136
; BUF2D_OPT_CROP_LEFT - ®¡à¥§ª  á«¥¢ 
135
; BUF2D_OPT_CROP_BOTTOM - ®¡à¥§ª  á­¨§ã
137
; BUF2D_OPT_CROP_BOTTOM - ®¡à¥§ª  á­¨§ã
136
; BUF2D_OPT_CROP_RIGHT - ®¡à¥§ª  á¯à ¢ 
138
; BUF2D_OPT_CROP_RIGHT - ®¡à¥§ª  á¯à ¢ 
137
align 4
139
align 4
138
proc buf_crop_color, buf_struc:dword, color:dword, opt:dword
140
proc buf_crop_color, buf_struc:dword, color:dword, opt:dword
139
locals
141
locals
140
	crop_r dd ?
142
	crop_r dd ?
141
endl
143
endl
142
	pushad
144
	pushad
143
	mov edi,dword[buf_struc]
145
	mov edi,dword[buf_struc]
144
	cmp buf2d_bits,24
146
	cmp buf2d_bits,24
145
	jne .24end_f
147
	jne .24end_f
146
 
148
 
147
	bt dword[opt],BUF2D_BIT_OPT_CROP_BOTTOM
149
	bt dword[opt],BUF2D_BIT_OPT_CROP_BOTTOM
148
	jae .24no_crop_bottom
150
	jae .24no_crop_bottom
149
		mov eax,dword[color]
151
		mov eax,dword[color]
150
		mov edx,eax ;ax = colors - r,g
152
		mov edx,eax ;ax = colors - r,g
151
		shr edx,16 ;dl = color - b
153
		shr edx,16 ;dl = color - b
152
		mov ecx,buf2d_h
154
		mov ecx,buf2d_h
153
		cmp ecx,1
155
		cmp ecx,1
154
		jle .24no_crop_bottom ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
156
		jle .24no_crop_bottom ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
155
		mov ebx,buf2d_w
157
		mov ebx,buf2d_w
156
		imul ecx,ebx
158
		imul ecx,ebx
157
		lea esi,[ecx+ecx*2] ;esi=3*ecx
159
		lea esi,[ecx+ecx*2] ;esi=3*ecx
158
		add esi,buf2d_data
160
		add esi,buf2d_data
159
		cld
161
		cld
160
		@@:
162
		@@:
161
			sub esi,3
163
			sub esi,3
162
			cmp word[esi],ax
164
			cmp word[esi],ax
163
			jne @f
165
			jne @f
164
			cmp byte[esi+2],dl
166
			cmp byte[esi+2],dl
165
			jne @f
167
			jne @f
166
			loop @b
168
			loop @b
167
		@@:
169
		@@:
168
		lea ebx,[ebx+ebx*2]
170
		lea ebx,[ebx+ebx*2]
169
		xor edx,edx
171
		xor edx,edx
170
		mov eax,buf2d_h
172
		mov eax,buf2d_h
171
		imul eax,ebx
173
		imul eax,ebx
172
		add eax,buf2d_data ;eax - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
174
		add eax,buf2d_data ;eax - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
173
		@@:
175
		@@:
174
			add esi,ebx
176
			add esi,ebx
175
			cmp esi,eax
177
			cmp esi,eax
176
			jge @f
178
			jge @f
177
			inc edx ;¢ëç¨á«ï¥¬ ç¨á«® ¯®«­ëå áâப ¤«ï ®¡à¥§ ­¨ï
179
			inc edx ;¢ëç¨á«ï¥¬ ç¨á«® ¯®«­ëå áâப ¤«ï ®¡à¥§ ­¨ï
178
			loop @b
180
			loop @b
179
		@@:
181
		@@:
180
		cmp edx,0
182
		cmp edx,0
181
		je .24no_crop_bottom
183
		je .24no_crop_bottom
182
			cmp edx,buf2d_h
184
			cmp edx,buf2d_h
183
			jge .24no_crop_bottom ;çâ®-¡ë ­¥ ¯®«ãç¨âì ¯ãá⮩ ¡ãä¥à
185
			jge .24no_crop_bottom ;çâ®-¡ë ­¥ ¯®«ãç¨âì ¯ãá⮩ ¡ãä¥à
184
			sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
186
			sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
185
			mov ecx,buf2d_h
187
			mov ecx,buf2d_h
186
			imul ecx,ebx ;ecx = ­®¢ë© à §¬¥à ¨§®¡à ¦¥­¨ï
188
			imul ecx,ebx ;ecx = ­®¢ë© à §¬¥à ¨§®¡à ¦¥­¨ï
187
			invoke mem.realloc,buf2d_data,ecx
189
			invoke mem.realloc,buf2d_data,ecx
188
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
190
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
189
	.24no_crop_bottom:
191
	.24no_crop_bottom:
190
 
192
 
191
	bt dword[opt],BUF2D_BIT_OPT_CROP_TOP
193
	bt dword[opt],BUF2D_BIT_OPT_CROP_TOP
192
	jae .24no_crop_top
194
	jae .24no_crop_top
193
		mov eax,dword[color]
195
		mov eax,dword[color]
194
		mov edx,eax ;ax = colors - r,g
196
		mov edx,eax ;ax = colors - r,g
195
		shr edx,16 ;dl = color - b
197
		shr edx,16 ;dl = color - b
196
		mov esi,buf2d_data
198
		mov esi,buf2d_data
197
		mov ecx,buf2d_h
199
		mov ecx,buf2d_h
198
		cmp ecx,1
200
		cmp ecx,1
199
		jle .24no_crop_top ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
201
		jle .24no_crop_top ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
200
		dec ecx ;¯à¨ ®¡à¥§ ­¨¨ ¤®«¦­  ®áâ âìáï ¬¨­¨¬ã¬ 1-­  áâப  ¯¨ªá¥«¥©
202
		dec ecx ;¯à¨ ®¡à¥§ ­¨¨ ¤®«¦­  ®áâ âìáï ¬¨­¨¬ã¬ 1-­  áâப  ¯¨ªá¥«¥©
201
		mov ebx,buf2d_w
203
		mov ebx,buf2d_w
202
		imul ecx,ebx
204
		imul ecx,ebx
203
		cld
205
		cld
204
		@@:
206
		@@:
205
			cmp word[esi],ax
207
			cmp word[esi],ax
206
			jne @f
208
			jne @f
207
			cmp byte[esi+2],dl
209
			cmp byte[esi+2],dl
208
			jne @f
210
			jne @f
209
			add esi,3
211
			add esi,3
210
			loop @b
212
			loop @b
211
		@@:
213
		@@:
212
		lea ebx,[ebx+ebx*2]
214
		lea ebx,[ebx+ebx*2]
213
		xor edx,edx
215
		xor edx,edx
214
		@@:
216
		@@:
215
			sub esi,ebx
217
			sub esi,ebx
216
			cmp esi,buf2d_data
218
			cmp esi,buf2d_data
217
			jl @f
219
			jl @f
218
			inc edx ;¢ëç¨á«ï¥¬ ç¨á«® ¯®«­ëå áâப ¤«ï ®¡à¥§ ­¨ï
220
			inc edx ;¢ëç¨á«ï¥¬ ç¨á«® ¯®«­ëå áâப ¤«ï ®¡à¥§ ­¨ï
219
			loop @b
221
			loop @b
220
		@@:
222
		@@:
221
		cmp edx,0
223
		cmp edx,0
222
		je .24no_crop_top
224
		je .24no_crop_top
223
			xor eax,eax
225
			xor eax,eax
224
			sub eax,edx
226
			sub eax,edx
225
			mov ebx,buf2d_h
227
			mov ebx,buf2d_h
226
			sub ebx,edx
228
			sub ebx,edx
227
			stdcall buf_offset_h, edi, eax, edx, ebx ;ᤢ¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢ ¡ãä¥à¥ ¢¢¥àå (eax<0)
229
			stdcall buf_offset_h, edi, eax, edx, ebx ;ᤢ¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢ ¡ãä¥à¥ ¢¢¥àå (eax<0)
228
			sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
230
			sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
229
			mov ecx,buf2d_h
231
			mov ecx,buf2d_h
230
			add buf2d_t,dx ;ᤢ¨£ ¥¬ ®âáâ㯠¢­¨§, ­  ç¨á«® ®¡à¥§ ­­ëå áâப
232
			add buf2d_t,dx ;ᤢ¨£ ¥¬ ®âáâ㯠¢­¨§, ­  ç¨á«® ®¡à¥§ ­­ëå áâப
231
			mov ebx,buf2d_w
233
			mov ebx,buf2d_w
232
			imul ecx,ebx
234
			imul ecx,ebx
233
			lea ecx,[ecx+ecx*2]
235
			lea ecx,[ecx+ecx*2]
234
			invoke mem.realloc,buf2d_data,ecx
236
			invoke mem.realloc,buf2d_data,ecx
235
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
237
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
236
	.24no_crop_top:
238
	.24no_crop_top:
237
 
239
 
238
	bt dword[opt],BUF2D_BIT_OPT_CROP_RIGHT
240
	bt dword[opt],BUF2D_BIT_OPT_CROP_RIGHT
239
	jae .24no_crop_right
241
	jae .24no_crop_right
240
		mov eax,dword[color]
242
		mov eax,dword[color]
241
		mov edx,eax ;ax = colors - r,g
243
		mov edx,eax ;ax = colors - r,g
242
		shr edx,16 ;dl = color - b
244
		shr edx,16 ;dl = color - b
243
		mov ebx,buf2d_w
245
		mov ebx,buf2d_w
244
		cmp ebx,1
246
		cmp ebx,1
245
		jle .24no_crop_right ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
247
		jle .24no_crop_right ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
246
		lea ebx,[ebx+ebx*2]
248
		lea ebx,[ebx+ebx*2]
247
		mov esi,ebx
249
		mov esi,ebx
248
		imul esi,buf2d_h
250
		imul esi,buf2d_h
249
		add esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
251
		add esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
250
		mov dword[crop_r],0
252
		mov dword[crop_r],0
251
		cld
253
		cld
252
		.24found_beg_right:
254
		.24found_beg_right:
253
		sub esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
255
		sub esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
254
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
256
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
255
		@@:
257
		@@:
256
			cmp word[esi],ax
258
			cmp word[esi],ax
257
			jne .24found_right
259
			jne .24found_right
258
			cmp byte[esi+2],dl
260
			cmp byte[esi+2],dl
259
			jne .24found_right
261
			jne .24found_right
260
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
262
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
261
			loop @b
263
			loop @b
262
		inc dword[crop_r]
264
		inc dword[crop_r]
263
 
265
 
264
		mov ecx,buf2d_w
266
		mov ecx,buf2d_w
265
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
267
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
266
		cmp dword[crop_r],ecx
268
		cmp dword[crop_r],ecx
267
		jge .24found_right
269
		jge .24found_right
268
 
270
 
269
		sub esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
271
		sub esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
270
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
272
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
271
		@@:
273
		@@:
272
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
274
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
273
			cmp word[esi],ax
275
			cmp word[esi],ax
274
			jne .24found_right
276
			jne .24found_right
275
			cmp byte[esi+2],dl
277
			cmp byte[esi+2],dl
276
			jne .24found_right
278
			jne .24found_right
277
			loop @b
279
			loop @b
278
		inc dword[crop_r]
280
		inc dword[crop_r]
279
 
281
 
280
		mov ecx,buf2d_w
282
		mov ecx,buf2d_w
281
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
283
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
282
		cmp dword[crop_r],ecx
284
		cmp dword[crop_r],ecx
283
		jl .24found_beg_right
285
		jl .24found_beg_right
284
 
286
 
285
		.24found_right:
287
		.24found_right:
286
		cmp dword[crop_r],0
288
		cmp dword[crop_r],0
287
		je .24no_crop_right
289
		je .24no_crop_right
288
			mov ecx,buf2d_w
290
			mov ecx,buf2d_w
289
			sub ecx,dword[crop_r]
291
			sub ecx,dword[crop_r]
290
			stdcall img_rgb_crop_r, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
292
			stdcall img_rgb_crop_r, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
291
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
293
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
292
			mov ebx,buf2d_h
294
			mov ebx,buf2d_h
293
			imul ecx,ebx
295
			imul ecx,ebx
294
			lea ecx,[ecx+ecx*2]
296
			lea ecx,[ecx+ecx*2]
295
			invoke mem.realloc,buf2d_data,ecx
297
			invoke mem.realloc,buf2d_data,ecx
296
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
298
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
297
	.24no_crop_right:
299
	.24no_crop_right:
298
 
300
 
299
	bt dword[opt],BUF2D_BIT_OPT_CROP_LEFT
301
	bt dword[opt],BUF2D_BIT_OPT_CROP_LEFT
300
	jae .24no_crop_left
302
	jae .24no_crop_left
301
		mov eax,dword[color]
303
		mov eax,dword[color]
302
		mov edx,eax ;ax = colors - r,g
304
		mov edx,eax ;ax = colors - r,g
303
		shr edx,16 ;dl = color - b
305
		shr edx,16 ;dl = color - b
304
		mov ebx,buf2d_w
306
		mov ebx,buf2d_w
305
		cmp ebx,1
307
		cmp ebx,1
306
		jle .24no_crop_left ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
308
		jle .24no_crop_left ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
307
		lea ebx,[ebx+ebx*2]
309
		lea ebx,[ebx+ebx*2]
308
		mov esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ­ ç®«® ¡ãä¥à  ¨§®¡à ¦¥­¨ï
310
		mov esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ­ ç®«® ¡ãä¥à  ¨§®¡à ¦¥­¨ï
309
		mov dword[crop_r],0
311
		mov dword[crop_r],0
310
		cld
312
		cld
311
		.24found_beg_left:
313
		.24found_beg_left:
312
 
314
 
313
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
315
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
314
		@@:
316
		@@:
315
			cmp word[esi],ax
317
			cmp word[esi],ax
316
			jne .24found_left
318
			jne .24found_left
317
			cmp byte[esi+2],dl
319
			cmp byte[esi+2],dl
318
			jne .24found_left
320
			jne .24found_left
319
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
321
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
320
			loop @b
322
			loop @b
321
		inc dword[crop_r]
323
		inc dword[crop_r]
322
		add esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
324
		add esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
323
 
325
 
324
		mov ecx,buf2d_w
326
		mov ecx,buf2d_w
325
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
327
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
326
		cmp dword[crop_r],ecx
328
		cmp dword[crop_r],ecx
327
		jge .24found_left
329
		jge .24found_left
328
 
330
 
329
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
331
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
330
		@@:
332
		@@:
331
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
333
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
332
			cmp word[esi],ax
334
			cmp word[esi],ax
333
			jne .24found_left
335
			jne .24found_left
334
			cmp byte[esi+2],dl
336
			cmp byte[esi+2],dl
335
			jne .24found_left
337
			jne .24found_left
336
			loop @b
338
			loop @b
337
		inc dword[crop_r]
339
		inc dword[crop_r]
338
		add esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
340
		add esi,3 ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
339
 
341
 
340
		mov ecx,buf2d_w
342
		mov ecx,buf2d_w
341
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
343
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
342
		cmp dword[crop_r],ecx
344
		cmp dword[crop_r],ecx
343
		jl .24found_beg_left
345
		jl .24found_beg_left
344
 
346
 
345
		.24found_left:
347
		.24found_left:
346
		cmp dword[crop_r],0
348
		cmp dword[crop_r],0
347
		je .24no_crop_left
349
		je .24no_crop_left
348
			mov ecx,buf2d_w
350
			mov ecx,buf2d_w
349
			sub ecx,dword[crop_r]
351
			sub ecx,dword[crop_r]
350
			stdcall img_rgb_crop_l, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
352
			stdcall img_rgb_crop_l, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
351
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
353
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
352
			mov ebx,buf2d_h
354
			mov ebx,buf2d_h
353
			imul ecx,ebx
355
			imul ecx,ebx
354
			lea ecx,[ecx+ecx*2]
356
			lea ecx,[ecx+ecx*2]
355
			invoke mem.realloc,buf2d_data,ecx
357
			invoke mem.realloc,buf2d_data,ecx
356
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
358
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
357
			mov eax,dword[crop_r]
359
			mov eax,dword[crop_r]
358
			add buf2d_l,ax
360
			add buf2d_l,ax
359
	.24no_crop_left:
361
	.24no_crop_left:
360
 
362
 
361
	.24end_f:
363
	.24end_f:
362
 
364
 
363
 
365
 
364
	cmp buf2d_bits,8
366
	cmp buf2d_bits,8
365
	jne .8end_f
367
	jne .8end_f
366
 
368
 
367
	bt dword[opt],BUF2D_BIT_OPT_CROP_BOTTOM
369
	bt dword[opt],BUF2D_BIT_OPT_CROP_BOTTOM
368
	jae .8no_crop_bottom
370
	jae .8no_crop_bottom
369
		mov eax,dword[color]
371
		mov eax,dword[color]
370
		mov esi,buf2d_data
372
		mov esi,buf2d_data
371
		mov ecx,buf2d_h
373
		mov ecx,buf2d_h
372
		cmp ecx,1
374
		cmp ecx,1
373
		jle .8no_crop_bottom ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
375
		jle .8no_crop_bottom ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
374
		mov ebx,buf2d_w
376
		mov ebx,buf2d_w
375
		imul ecx,ebx
377
		imul ecx,ebx
376
		mov esi,ecx
378
		mov esi,ecx
377
		add esi,buf2d_data
379
		add esi,buf2d_data
378
		cld
380
		cld
379
		@@:
381
		@@:
380
			dec esi
382
			dec esi
381
			cmp byte[esi],al
383
			cmp byte[esi],al
382
			jne @f
384
			jne @f
383
			loop @b
385
			loop @b
384
		@@:
386
		@@:
385
		xor edx,edx
387
		xor edx,edx
386
		mov eax,buf2d_h
388
		mov eax,buf2d_h
387
		imul eax,ebx
389
		imul eax,ebx
388
		add eax,buf2d_data ;eax - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
390
		add eax,buf2d_data ;eax - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
389
		@@:
391
		@@:
390
			add esi,ebx
392
			add esi,ebx
391
			cmp esi,eax
393
			cmp esi,eax
392
			jge @f
394
			jge @f
393
			inc edx
395
			inc edx
394
			loop @b
396
			loop @b
395
		@@:
397
		@@:
396
		cmp edx,0
398
		cmp edx,0
397
		je .8no_crop_bottom
399
		je .8no_crop_bottom
398
			cmp edx,buf2d_h
400
			cmp edx,buf2d_h
399
			jge .8no_crop_bottom ;çâ®-¡ë ­¥ ¯®«ãç¨âì ¯ãá⮩ ¡ãä¥à
401
			jge .8no_crop_bottom ;çâ®-¡ë ­¥ ¯®«ãç¨âì ¯ãá⮩ ¡ãä¥à
400
			sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
402
			sub buf2d_h,edx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
401
			mov ecx,buf2d_h
403
			mov ecx,buf2d_h
402
			imul ecx,ebx ;ecx = ­®¢ë© à §¬¥à ¨§®¡à ¦¥­¨ï
404
			imul ecx,ebx ;ecx = ­®¢ë© à §¬¥à ¨§®¡à ¦¥­¨ï
403
			invoke mem.realloc,buf2d_data,ecx
405
			invoke mem.realloc,buf2d_data,ecx
404
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
406
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
405
	.8no_crop_bottom:
407
	.8no_crop_bottom:
406
 
408
 
407
	bt dword[opt],BUF2D_BIT_OPT_CROP_TOP
409
	bt dword[opt],BUF2D_BIT_OPT_CROP_TOP
408
	jae .8no_crop_top
410
	jae .8no_crop_top
409
		mov eax,dword[color]
411
		mov eax,dword[color]
410
		mov esi,buf2d_data
412
		mov esi,buf2d_data
411
		mov ecx,buf2d_h
413
		mov ecx,buf2d_h
412
		cmp ecx,1
414
		cmp ecx,1
413
		jle .8no_crop_top ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
415
		jle .8no_crop_top ;¯à®¢¥à塞 ­  á«ãç © ¥á«¨ ¢ëá®â  ¡ãä¥à  1 ¯¨ªá¥«ì
414
		dec ecx ;¯à¨ ®¡à¥§ ­¨¨ ¤®«¦­  ®áâ âìáï ¬¨­¨¬ã¬ 1-­  áâப  ¯¨ªá¥«¥©
416
		dec ecx ;¯à¨ ®¡à¥§ ­¨¨ ¤®«¦­  ®áâ âìáï ¬¨­¨¬ã¬ 1-­  áâப  ¯¨ªá¥«¥©
415
		mov ebx,buf2d_w
417
		mov ebx,buf2d_w
416
		imul ecx,ebx
418
		imul ecx,ebx
417
		cld
419
		cld
418
		@@:
420
		@@:
419
			cmp byte[esi],al
421
			cmp byte[esi],al
420
			jne @f
422
			jne @f
421
			inc esi
423
			inc esi
422
			loop @b
424
			loop @b
423
		@@:
425
		@@:
424
		xor edx,edx
426
		xor edx,edx
425
		@@:
427
		@@:
426
			sub esi,ebx
428
			sub esi,ebx
427
			cmp esi,buf2d_data
429
			cmp esi,buf2d_data
428
			jl @f
430
			jl @f
429
			inc edx
431
			inc edx
430
			loop @b
432
			loop @b
431
		@@:
433
		@@:
432
		cmp edx,0
434
		cmp edx,0
433
		je .8no_crop_top
435
		je .8no_crop_top
434
			xor eax,eax
436
			xor eax,eax
435
			sub eax,edx
437
			sub eax,edx
436
			mov ebx,buf2d_h
438
			mov ebx,buf2d_h
437
			sub ebx,edx
439
			sub ebx,edx
438
			stdcall buf_offset_h, edi, eax, edx, ebx
440
			stdcall buf_offset_h, edi, eax, edx, ebx
439
			mov ecx,buf2d_h
441
			mov ecx,buf2d_h
440
			sub ecx,edx
442
			sub ecx,edx
441
			mov buf2d_h,ecx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
443
			mov buf2d_h,ecx ;㬥­ìè ¥¬ ¢ëá®âã ¡ãä¥à 
442
			add buf2d_t,dx ;ᤢ¨£ ¥¬ ®âáâ㯠¢­¨§, ­  ç¨á«® ®¡à¥§ ­­ëå áâப
444
			add buf2d_t,dx ;ᤢ¨£ ¥¬ ®âáâ㯠¢­¨§, ­  ç¨á«® ®¡à¥§ ­­ëå áâப
443
			mov ebx,buf2d_w
445
			mov ebx,buf2d_w
444
			imul ecx,ebx
446
			imul ecx,ebx
445
			invoke mem.realloc,buf2d_data,ecx
447
			invoke mem.realloc,buf2d_data,ecx
446
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
448
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
447
	.8no_crop_top:
449
	.8no_crop_top:
448
 
450
 
449
	bt dword[opt],BUF2D_BIT_OPT_CROP_RIGHT
451
	bt dword[opt],BUF2D_BIT_OPT_CROP_RIGHT
450
	jae .8no_crop_right
452
	jae .8no_crop_right
451
		mov eax,dword[color]
453
		mov eax,dword[color]
452
		mov ebx,buf2d_w
454
		mov ebx,buf2d_w
453
		cmp ebx,1
455
		cmp ebx,1
454
		jle .8no_crop_right ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
456
		jle .8no_crop_right ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
455
		mov esi,ebx
457
		mov esi,ebx
456
		imul esi,buf2d_h
458
		imul esi,buf2d_h
457
		add esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
459
		add esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ª®­¥æ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
458
		xor edx,edx
460
		xor edx,edx
459
		cld
461
		cld
460
 
462
 
461
		.8found_beg:
463
		.8found_beg:
462
		dec esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
464
		dec esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
463
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
465
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
464
		@@:
466
		@@:
465
			cmp byte[esi],al
467
			cmp byte[esi],al
466
			jne .8found
468
			jne .8found
467
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
469
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
468
			loop @b
470
			loop @b
469
		inc edx
471
		inc edx
470
		mov ecx,buf2d_w
472
		mov ecx,buf2d_w
471
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
473
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
472
		cmp edx,ecx
474
		cmp edx,ecx
473
		jge .8found
475
		jge .8found
474
 
476
 
475
		dec esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
477
		dec esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢«¥¢®
476
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
478
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
477
		@@:
479
		@@:
478
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
480
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
479
			cmp byte[esi],al
481
			cmp byte[esi],al
480
			jne .8found
482
			jne .8found
481
			loop @b
483
			loop @b
482
		inc edx
484
		inc edx
483
 
485
 
484
		mov ecx,buf2d_w
486
		mov ecx,buf2d_w
485
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
487
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
486
		cmp edx,ecx
488
		cmp edx,ecx
487
		jl .8found_beg
489
		jl .8found_beg
488
 
490
 
489
		.8found:
491
		.8found:
490
		cmp edx,0
492
		cmp edx,0
491
		je .8no_crop_right
493
		je .8no_crop_right
492
			mov ecx,buf2d_w
494
			mov ecx,buf2d_w
493
			sub ecx,edx
495
			sub ecx,edx
494
			stdcall img_gray_crop_r, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
496
			stdcall img_gray_crop_r, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
495
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
497
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
496
			mov ebx,buf2d_h
498
			mov ebx,buf2d_h
497
			imul ecx,ebx
499
			imul ecx,ebx
498
			invoke mem.realloc,buf2d_data,ecx
500
			invoke mem.realloc,buf2d_data,ecx
499
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
501
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
500
	.8no_crop_right:
502
	.8no_crop_right:
501
 
503
 
502
	bt dword[opt],BUF2D_BIT_OPT_CROP_LEFT
504
	bt dword[opt],BUF2D_BIT_OPT_CROP_LEFT
503
	jae .8no_crop_left
505
	jae .8no_crop_left
504
		mov eax,dword[color]
506
		mov eax,dword[color]
505
		mov ebx,buf2d_w
507
		mov ebx,buf2d_w
506
		cmp ebx,1
508
		cmp ebx,1
507
		jle .8no_crop_left ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
509
		jle .8no_crop_left ;­  á«ãç © ¥á«¨ è¨à¨­  ¡ãä¥à  1 ¯¨ªá¥«ì
508
		mov esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ­ ç®«® ¡ãä¥à  ¨§®¡à ¦¥­¨ï
510
		mov esi,buf2d_data ;esi - 㪠§ â¥«ì ­  ­ ç®«® ¡ãä¥à  ¨§®¡à ¦¥­¨ï
509
		mov edx,0
511
		mov edx,0
510
		cld
512
		cld
511
		.8found_beg_left:
513
		.8found_beg_left:
512
 
514
 
513
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
515
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
514
		@@:
516
		@@:
515
			cmp word[esi],ax
517
			cmp word[esi],ax
516
			jne .8found_left
518
			jne .8found_left
517
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
519
			add esi,ebx ;¯à룠¥¬ ­  ­¨¦­îî áâபã
518
			loop @b
520
			loop @b
519
		inc edx
521
		inc edx
520
		inc esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
522
		inc esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
521
 
523
 
522
		mov ecx,buf2d_w
524
		mov ecx,buf2d_w
523
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
525
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
524
		cmp edx,ecx
526
		cmp edx,ecx
525
		jge .8found_left
527
		jge .8found_left
526
 
528
 
527
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
529
		mov ecx,buf2d_h ;¢®ááâ ­®¢«¥­¨¥ ecx ¤«ï ­®¢®£® 横« 
528
		@@:
530
		@@:
529
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
531
			sub esi,ebx ;¯à룠¥¬ ­  ¢¥àå­îî áâபã
530
			cmp word[esi],ax
532
			cmp word[esi],ax
531
			jne .8found_left
533
			jne .8found_left
532
			loop @b
534
			loop @b
533
		inc edx
535
		inc edx
534
		inc esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
536
		inc esi ;¤¢¨£ ¥¬áï ­  1-­ã ª®«®­ªã ¢¯à ¢®
535
 
537
 
536
		mov ecx,buf2d_w
538
		mov ecx,buf2d_w
537
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
539
		dec ecx ;1 ª®«®­ª  ­  § ¯ á
538
		cmp edx,ecx
540
		cmp edx,ecx
539
		jl .8found_beg_left
541
		jl .8found_beg_left
540
 
542
 
541
		.8found_left:
543
		.8found_left:
542
		cmp edx,0
544
		cmp edx,0
543
		je .8no_crop_left
545
		je .8no_crop_left
544
			mov ecx,buf2d_w
546
			mov ecx,buf2d_w
545
			sub ecx,edx
547
			sub ecx,edx
546
			stdcall img_gray_crop_l, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
548
			stdcall img_gray_crop_l, buf2d_data, buf2d_w, ecx, buf2d_h ;®¡à¥§ ¥¬ ¡ãä¥à, ¯® ­®¢®¬ã à §¬¥àã
547
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
549
			mov buf2d_w,ecx ;áâ ¢¨¬ ­®¢ãî è¨à¨­ã ¤«ï ¡ãä¥à 
548
			mov ebx,buf2d_h
550
			mov ebx,buf2d_h
549
			imul ecx,ebx
551
			imul ecx,ebx
550
			invoke mem.realloc,buf2d_data,ecx
552
			invoke mem.realloc,buf2d_data,ecx
551
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
553
			mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
552
			mov eax,edx
554
			mov eax,edx
553
			add buf2d_l,ax
555
			add buf2d_l,ax
554
	.8no_crop_left:
556
	.8no_crop_left:
555
 
557
 
556
	.8end_f:
558
	.8end_f:
557
 
559
 
558
	popad
560
	popad
559
	ret
561
	ret
560
endp
562
endp
561
 
563
 
562
;®¡à¥§ ¥¬ 梥⭮¥ ¨§®¡à ¦¥­¨¥ á ¯à ¢®© áâ®à®­ë
564
;®¡à¥§ ¥¬ 梥⭮¥ ¨§®¡à ¦¥­¨¥ á ¯à ¢®© áâ®à®­ë
563
;input:
565
;input:
564
;data_rgb - pointer to rgb data
566
;data_rgb - pointer to rgb data
565
;size_w_old - width img in pixels
567
;size_w_old - width img in pixels
566
;size_w_new - new width img in pixels
568
;size_w_new - new width img in pixels
567
;size_h - height img in pixels
569
;size_h - height img in pixels
568
align 4
570
align 4
569
proc img_rgb_crop_r, data_rgb:dword, size_w_old:dword, size_w_new:dword, size_h:dword
571
proc img_rgb_crop_r, data_rgb:dword, size_w_old:dword, size_w_new:dword, size_h:dword
570
	pushad
572
	pushad
571
	mov eax, dword[size_w_old]
573
	mov eax, dword[size_w_old]
572
	lea eax, dword[eax+eax*2] ;eax = width(old) * 3(rgb)
574
	lea eax, dword[eax+eax*2] ;eax = width(old) * 3(rgb)
573
	mov ebx, dword[size_w_new]
575
	mov ebx, dword[size_w_new]
574
	lea ebx, dword[ebx+ebx*2] ;ebx = width(new) * 3(rgb)
576
	lea ebx, dword[ebx+ebx*2] ;ebx = width(new) * 3(rgb)
575
	mov edx, dword[size_h]
577
	mov edx, dword[size_h]
576
	mov edi, dword[data_rgb] ;edi - ¯®«ã砥⠤ ­­ë¥
578
	mov edi, dword[data_rgb] ;edi - ¯®«ã砥⠤ ­­ë¥
577
	mov esi, edi
579
	mov esi, edi
578
	add edi, ebx
580
	add edi, ebx
579
	add esi, eax
581
	add esi, eax
580
	cld
582
	cld
581
	@@:
583
	@@:
582
		dec edx ;㬥­ìè ¥¬ áç¥â稪 ®áâ ¢è¨åáï áâப ­  1
584
		dec edx ;㬥­ìè ¥¬ áç¥â稪 ®áâ ¢è¨åáï áâப ­  1
583
		cmp edx,0
585
		cmp edx,0
584
		jle @f
586
		jle @f
585
		mov ecx, ebx
587
		mov ecx, ebx
586
		rep movsb ;¯¥à¥­®á (ª®¯¨à®¢ ­¨¥) áâப¨ ¯¨ªá¥«¥©
588
		rep movsb ;¯¥à¥­®á (ª®¯¨à®¢ ­¨¥) áâப¨ ¯¨ªá¥«¥©
587
		add esi,eax ;¯¥à¥å®¤ ­  ­®¢ãî áâà®çªã ¨§®¡à ¦¥­¨ï
589
		add esi,eax ;¯¥à¥å®¤ ­  ­®¢ãî áâà®çªã ¨§®¡à ¦¥­¨ï
588
		sub esi,ebx
590
		sub esi,ebx
589
		jmp @b
591
		jmp @b
590
	@@:
592
	@@:
591
	popad
593
	popad
592
	ret
594
	ret
593
endp
595
endp
594
 
596
 
595
;®¡à¥§ ¥¬ á¥à®¥ ¨§®¡à ¦¥­¨¥ á ¯à ¢®© áâ®à®­ë
597
;®¡à¥§ ¥¬ á¥à®¥ ¨§®¡à ¦¥­¨¥ á ¯à ¢®© áâ®à®­ë
596
;input:
598
;input:
597
;data_gray - pointer to gray data
599
;data_gray - pointer to gray data
598
;size_w_old - width img in pixels
600
;size_w_old - width img in pixels
599
;size_w_new - new width img in pixels
601
;size_w_new - new width img in pixels
600
;size_h - height img in pixels
602
;size_h - height img in pixels
601
align 4
603
align 4
602
proc img_gray_crop_r, data_gray:dword, size_w_old:dword, size_w_new:dword, size_h:dword
604
proc img_gray_crop_r, data_gray:dword, size_w_old:dword, size_w_new:dword, size_h:dword
603
	pushad
605
	pushad
604
	mov eax, dword[size_w_old]
606
	mov eax, dword[size_w_old]
605
	mov ebx, dword[size_w_new]
607
	mov ebx, dword[size_w_new]
606
	mov edx, dword[size_h]
608
	mov edx, dword[size_h]
607
	mov edi, dword[data_gray] ;edi - ¯®«ã砥⠤ ­­ë¥
609
	mov edi, dword[data_gray] ;edi - ¯®«ã砥⠤ ­­ë¥
608
	mov esi, edi
610
	mov esi, edi
609
	add edi, ebx
611
	add edi, ebx
610
	add esi, eax
612
	add esi, eax
611
	cld
613
	cld
612
	@@:
614
	@@:
613
		dec edx ;㬥­ìè ¥¬ áç¥â稪 ®áâ ¢è¨åáï áâப ­  1
615
		dec edx ;㬥­ìè ¥¬ áç¥â稪 ®áâ ¢è¨åáï áâப ­  1
614
		cmp edx,0
616
		cmp edx,0
615
		jle @f
617
		jle @f
616
		mov ecx, ebx
618
		mov ecx, ebx
617
		rep movsb ;¯¥à¥­®á (ª®¯¨à®¢ ­¨¥) áâப¨ ¯¨ªá¥«¥©
619
		rep movsb ;¯¥à¥­®á (ª®¯¨à®¢ ­¨¥) áâப¨ ¯¨ªá¥«¥©
618
		add esi,eax ;¯¥à¥å®¤ ­  ­®¢ãî áâà®çªã ¨§®¡à ¦¥­¨ï
620
		add esi,eax ;¯¥à¥å®¤ ­  ­®¢ãî áâà®çªã ¨§®¡à ¦¥­¨ï
619
		sub esi,ebx
621
		sub esi,ebx
620
		jmp @b
622
		jmp @b
621
	@@:
623
	@@:
622
	popad
624
	popad
623
	ret
625
	ret
624
endp
626
endp
625
 
627
 
626
;®¡à¥§ ¥¬ 梥⭮¥ ¨§®¡à ¦¥­¨¥ á «¥¢®© áâ®à®­ë
628
;®¡à¥§ ¥¬ 梥⭮¥ ¨§®¡à ¦¥­¨¥ á «¥¢®© áâ®à®­ë
627
;input:
629
;input:
628
;data_rgb - pointer to rgb data
630
;data_rgb - pointer to rgb data
629
;size_w_old - width img in pixels
631
;size_w_old - width img in pixels
630
;size_w_new - new width img in pixels
632
;size_w_new - new width img in pixels
631
;size_h - height img in pixels
633
;size_h - height img in pixels
632
align 4
634
align 4
633
proc img_rgb_crop_l, data_rgb:dword, size_w_old:dword, size_w_new:dword, size_h:dword
635
proc img_rgb_crop_l, data_rgb:dword, size_w_old:dword, size_w_new:dword, size_h:dword
634
	pushad
636
	pushad
635
	mov edi,dword[data_rgb]
637
	mov edi,dword[data_rgb]
636
	mov esi,edi
638
	mov esi,edi
637
	mov eax,dword[size_w_old]
639
	mov eax,dword[size_w_old]
638
	mov ebx,dword[size_w_new]
640
	mov ebx,dword[size_w_new]
639
	cmp eax,ebx
641
	cmp eax,ebx
640
	jle .end_f ;áâ àë© à §¬¥à ¨§®¡à ¦¥­¨ï ­¥ ¬®¦¥â ¡ëâì ¬¥­ìè¥ ­®¢®£® (¯à¨ ãá«®¢¨¨ ®¡à¥§ ­¨ï ª à⨭ª¨)
642
	jle .end_f ;áâ àë© à §¬¥à ¨§®¡à ¦¥­¨ï ­¥ ¬®¦¥â ¡ëâì ¬¥­ìè¥ ­®¢®£® (¯à¨ ãá«®¢¨¨ ®¡à¥§ ­¨ï ª à⨭ª¨)
641
		lea eax,[eax+eax*2]
643
		lea eax,[eax+eax*2]
642
		lea ebx,[ebx+ebx*2]
644
		lea ebx,[ebx+ebx*2]
643
		sub eax,ebx
645
		sub eax,ebx
644
		mov edx,dword[size_h] ;¢ëá®â  ¨§®¡à ¦¥­¨ï
646
		mov edx,dword[size_h] ;¢ëá®â  ¨§®¡à ¦¥­¨ï
645
		cld
647
		cld
646
		@@:
648
		@@:
647
			add esi,eax
649
			add esi,eax
648
			mov ecx,ebx
650
			mov ecx,ebx
649
			rep movsb
651
			rep movsb
650
			dec edx
652
			dec edx
651
			cmp edx,0
653
			cmp edx,0
652
			jg @b
654
			jg @b
653
	.end_f:
655
	.end_f:
654
	popad
656
	popad
655
	ret
657
	ret
656
endp
658
endp
657
 
659
 
658
;®¡à¥§ ¥¬ á¥à®¥ ¨§®¡à ¦¥­¨¥ á «¥¢®© áâ®à®­ë
660
;®¡à¥§ ¥¬ á¥à®¥ ¨§®¡à ¦¥­¨¥ á «¥¢®© áâ®à®­ë
659
;input:
661
;input:
660
;data_gray - pointer to gray data
662
;data_gray - pointer to gray data
661
;size_w_old - width img in pixels
663
;size_w_old - width img in pixels
662
;size_w_new - new width img in pixels
664
;size_w_new - new width img in pixels
663
;size_h - height img in pixels
665
;size_h - height img in pixels
664
align 4
666
align 4
665
proc img_gray_crop_l, data_gray:dword, size_w_old:dword, size_w_new:dword, size_h:dword
667
proc img_gray_crop_l, data_gray:dword, size_w_old:dword, size_w_new:dword, size_h:dword
666
	pushad
668
	pushad
667
	mov edi,dword[data_gray]
669
	mov edi,dword[data_gray]
668
	mov esi,edi
670
	mov esi,edi
669
	mov eax,dword[size_w_old]
671
	mov eax,dword[size_w_old]
670
	mov ebx,dword[size_w_new]
672
	mov ebx,dword[size_w_new]
671
	cmp eax,ebx
673
	cmp eax,ebx
672
	jle .end_f ;áâ àë© à §¬¥à ¨§®¡à ¦¥­¨ï ­¥ ¬®¦¥â ¡ëâì ¬¥­ìè¥ ­®¢®£® (¯à¨ ãá«®¢¨¨ ®¡à¥§ ­¨ï ª à⨭ª¨)
674
	jle .end_f ;áâ àë© à §¬¥à ¨§®¡à ¦¥­¨ï ­¥ ¬®¦¥â ¡ëâì ¬¥­ìè¥ ­®¢®£® (¯à¨ ãá«®¢¨¨ ®¡à¥§ ­¨ï ª à⨭ª¨)
673
		sub eax,ebx
675
		sub eax,ebx
674
		mov edx,dword[size_h] ;¢ëá®â  ¨§®¡à ¦¥­¨ï
676
		mov edx,dword[size_h] ;¢ëá®â  ¨§®¡à ¦¥­¨ï
675
		cld
677
		cld
676
		@@:
678
		@@:
677
			add esi,eax
679
			add esi,eax
678
			mov ecx,ebx
680
			mov ecx,ebx
679
			rep movsb
681
			rep movsb
680
			dec edx
682
			dec edx
681
			cmp edx,0
683
			cmp edx,0
682
			jg @b
684
			jg @b
683
	.end_f:
685
	.end_f:
684
	popad
686
	popad
685
	ret
687
	ret
686
endp
688
endp
687
 
689
 
688
;hoffs - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ­  ª®âàë¥ ¯®¤­¨¬ ¥âáï/®¯ã᪠¥âáï ¨§®¡à ¦¥­¨¥
690
;hoffs - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ­  ª®âàë¥ ¯®¤­¨¬ ¥âáï/®¯ã᪠¥âáï ¨§®¡à ¦¥­¨¥
689
;img_t - ¢ëá®â , á ª®â®à®© ­ ç¨­ ¥âáï ¤¢¨£ îé ïáï ç áâì ¨§®¡à ¦¥­¨ï
691
;img_t - ¢ëá®â , á ª®â®à®© ­ ç¨­ ¥âáï ¤¢¨£ îé ïáï ç áâì ¨§®¡à ¦¥­¨ï
690
align 4
692
align 4
691
proc buf_offset_h, buf_struc:dword, hoffs:dword, img_t:dword, img_h:dword ;ᤢ¨£ ¥â ¨§®¡à ¦¥­¨¥ ¯® ¢ëá®â¥
693
proc buf_offset_h, buf_struc:dword, hoffs:dword, img_t:dword, img_h:dword ;ᤢ¨£ ¥â ¨§®¡à ¦¥­¨¥ ¯® ¢ëá®â¥
692
	pushad
694
	pushad
693
	mov edi,dword[buf_struc]
695
	mov edi,dword[buf_struc]
694
	cmp buf2d_bits,24
696
	cmp buf2d_bits,24
695
	jne .end_move_24
697
	jne .end_move_24
696
 
698
 
697
	mov eax,[hoffs]
699
	mov eax,[hoffs]
698
	cmp eax,0
700
	cmp eax,0
699
	je .end_move_24
701
	je .end_move_24
700
		mov ebx,buf2d_w
702
		mov ebx,buf2d_w
701
		mov edx,dword[img_t]
703
		mov edx,dword[img_t]
702
			mov ecx,dword[img_h] ;ecx - ¢ëá®â  ᤢ¨£ ¥¬ëå ¤ ­­ëå
704
			mov ecx,dword[img_h] ;ecx - ¢ëá®â  ᤢ¨£ ¥¬ëå ¤ ­­ëå
703
			cmp ecx,buf2d_h
705
			cmp ecx,buf2d_h
704
			jge .end_f ;®è¨¡®ç­®¥ ãá«®¢¨¥, ¢ëá®â  ¨§®¡à ¦¥­¨ï ¬¥­ìè¥ ç¥¬ ¢ëá®â  ᤢ¨£ ¥¬®£® ¨§®¡à ¦¥­¨ï
706
			jge .end_f ;®è¨¡®ç­®¥ ãá«®¢¨¥, ¢ëá®â  ¨§®¡à ¦¥­¨ï ¬¥­ìè¥ ç¥¬ ¢ëá®â  ᤢ¨£ ¥¬®£® ¨§®¡à ¦¥­¨ï
705
			imul ecx,ebx ;ecx - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ ᤢ¨£ ¥¬ëå ¤ ­­ëå
707
			imul ecx,ebx ;ecx - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ ᤢ¨£ ¥¬ëå ¤ ­­ëå
706
			lea ecx,[ecx+ecx*2]
708
			lea ecx,[ecx+ecx*2]
707
		imul ebx,edx
709
		imul ebx,edx
708
		lea ebx,[ebx+ebx*2]
710
		lea ebx,[ebx+ebx*2]
709
		mov esi,buf2d_data
711
		mov esi,buf2d_data
710
		add esi,ebx
712
		add esi,ebx
711
 
713
 
712
		add edx,eax ;edx = img_t+hoffs (hoffs<0)
714
		add edx,eax ;edx = img_t+hoffs (hoffs<0)
713
		mov ebx,buf2d_w
715
		mov ebx,buf2d_w
714
		imul ebx,edx
716
		imul ebx,edx
715
		lea ebx,[ebx+ebx*2]
717
		lea ebx,[ebx+ebx*2]
716
		mov edi,buf2d_data ;¯®§¨æ¨ï, ªã¤  ¡ã¤¥â ¤¢¨£ âìáï ¨§®¡à ¦¥­¨¥
718
		mov edi,buf2d_data ;¯®§¨æ¨ï, ªã¤  ¡ã¤¥â ¤¢¨£ âìáï ¨§®¡à ¦¥­¨¥
717
		add edi,ebx
719
		add edi,ebx
718
 
720
 
719
		cmp eax,0
721
		cmp eax,0
720
		jg .move_down_24
722
		jg .move_down_24
721
			;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢¢¥àå
723
			;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢¢¥àå
722
			cld
724
			cld
723
			rep movsb
725
			rep movsb
724
			jmp .end_f
726
			jmp .end_f
725
		.move_down_24:
727
		.move_down_24:
726
			;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢­¨§
728
			;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢­¨§
727
			add esi,ecx
729
			add esi,ecx
728
			dec esi
730
			dec esi
729
			add edi,ecx
731
			add edi,ecx
730
			dec edi
732
			dec edi
731
			std
733
			std
732
			rep movsb
734
			rep movsb
733
			jmp .end_f
735
			jmp .end_f
734
	.end_move_24:
736
	.end_move_24:
735
 
737
 
736
;stdcall print_err,sz_buf2d_offset_h,txt_err_n24b
738
;stdcall print_err,sz_buf2d_offset_h,txt_err_n24b
737
 
739
 
738
	cmp buf2d_bits,8
740
	cmp buf2d_bits,8
739
	jne .end_move_8
741
	jne .end_move_8
740
 
742
 
741
	mov eax,[hoffs]
743
	mov eax,[hoffs]
742
	cmp eax,0
744
	cmp eax,0
743
	je .end_move_8
745
	je .end_move_8
744
		;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢¢¥àå
746
		;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢¢¥àå
745
		mov ebx,buf2d_w
747
		mov ebx,buf2d_w
746
		mov edx,dword[img_t]
748
		mov edx,dword[img_t]
747
			mov ecx,dword[img_h] ;ecx - ¢ëá®â  ᤢ¨£ ¥¬ëå ¤ ­­ëå
749
			mov ecx,dword[img_h] ;ecx - ¢ëá®â  ᤢ¨£ ¥¬ëå ¤ ­­ëå
748
			cmp ecx,buf2d_h
750
			cmp ecx,buf2d_h
749
			jge .end_f ;®è¨¡®ç­®¥ ãá«®¢¨¥, ¢ëá®â  ¨§®¡à ¦¥­¨ï ¬¥­ìè¥ ç¥¬ ¢ëá®â  ᤢ¨£ ¥¬®£® ¨§®¡à ¦¥­¨ï
751
			jge .end_f ;®è¨¡®ç­®¥ ãá«®¢¨¥, ¢ëá®â  ¨§®¡à ¦¥­¨ï ¬¥­ìè¥ ç¥¬ ¢ëá®â  ᤢ¨£ ¥¬®£® ¨§®¡à ¦¥­¨ï
750
			imul ecx,ebx ;ecx - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ ᤢ¨£ ¥¬ëå ¤ ­­ëå
752
			imul ecx,ebx ;ecx - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ ᤢ¨£ ¥¬ëå ¤ ­­ëå
751
		imul ebx,edx
753
		imul ebx,edx
752
		mov esi,buf2d_data
754
		mov esi,buf2d_data
753
		add esi,ebx
755
		add esi,ebx
754
 
756
 
755
		add edx,eax ;edx = img_t+hoffs (hoffs<0)
757
		add edx,eax ;edx = img_t+hoffs (hoffs<0)
756
		mov ebx,buf2d_w
758
		mov ebx,buf2d_w
757
		imul ebx,edx
759
		imul ebx,edx
758
		mov edi,buf2d_data ;¯®§¨æ¨ï, ªã¤  ¡ã¤¥â ¤¢¨£ âìáï ¨§®¡à ¦¥­¨¥
760
		mov edi,buf2d_data ;¯®§¨æ¨ï, ªã¤  ¡ã¤¥â ¤¢¨£ âìáï ¨§®¡à ¦¥­¨¥
759
		add edi,ebx
761
		add edi,ebx
760
 
762
 
761
		cmp eax,0
763
		cmp eax,0
762
		jg .move_down_8
764
		jg .move_down_8
763
			cld
765
			cld
764
			rep movsb
766
			rep movsb
765
			jmp .end_f
767
			jmp .end_f
766
		.move_down_8:
768
		.move_down_8:
767
			;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢­¨§
769
			;¤¢¨£ ¥¬ ¨§®¡à ¦¥­¨¥ ¢­¨§
768
			add esi,ecx
770
			add esi,ecx
769
			dec esi
771
			dec esi
770
			add edi,ecx
772
			add edi,ecx
771
			dec edi
773
			dec edi
772
			std
774
			std
773
			rep movsb
775
			rep movsb
774
			jmp .end_f
776
			jmp .end_f
775
	.end_move_8:
777
	.end_move_8:
776
 
778
 
777
	.end_f:
779
	.end_f:
778
	popad
780
	popad
779
	ret
781
	ret
780
endp
782
endp
781
 
783
 
782
align 4
784
align 4
783
proc buf_delete, buf_struc:dword
785
proc buf_delete, buf_struc:dword
784
	push eax edi
786
	push eax edi
785
	mov edi,dword[buf_struc]
787
	mov edi,dword[buf_struc]
786
	invoke mem.free,buf2d_data
788
	invoke mem.free,buf2d_data
787
	pop edi eax
789
	pop edi eax
788
	ret
790
	ret
789
endp
791
endp
790
 
792
 
791
;input:
793
;input:
792
; new_w - ­®¢ ï è¨à¨­  (¥á«¨ 0 â® ­¥ ¬¥­ï¥âáï)
794
; new_w - ­®¢ ï è¨à¨­  (¥á«¨ 0 â® ­¥ ¬¥­ï¥âáï)
793
; new_h - ­®¢ ï ¢ëá®â  (¥á«¨ 0 â® ­¥ ¬¥­ï¥âáï)
795
; new_h - ­®¢ ï ¢ëá®â  (¥á«¨ 0 â® ­¥ ¬¥­ï¥âáï)
794
; options - ¯ à ¬¥âàë ¨§¬¥­¥­¨ï ¡ãä¥à  (1 - ¨§¬¥­ïâì à §¬¥à ¡ãä¥à ,
796
; options - ¯ à ¬¥âàë ¨§¬¥­¥­¨ï ¡ãä¥à  (1 - ¨§¬¥­ïâì à §¬¥à ¡ãä¥à ,
795
;    2 - ¨§¬¥­ïâì ¨§®¡à ¦¥­¨¥ ¢ ¡ãä¥à¥, 3 - ¨§¬¥­ïâì ¡ãä¥à ¨ ¨§®¡à ¦¥­¨¥)
797
;    2 - ¨§¬¥­ïâì ¨§®¡à ¦¥­¨¥ ¢ ¡ãä¥à¥, 3 - ¨§¬¥­ïâì ¡ãä¥à ¨ ¨§®¡à ¦¥­¨¥)
796
align 4
798
align 4
797
proc buf_resize, buf_struc:dword, new_w:dword, new_h:dword, options:dword
799
proc buf_resize, buf_struc:dword, new_w:dword, new_h:dword, options:dword
798
	pushad
800
	pushad
799
	mov edi,dword[buf_struc]
801
	mov edi,dword[buf_struc]
800
	cmp buf2d_bits,8
802
	cmp buf2d_bits,8
801
	jne .8bit
803
	jne .8bit
802
		bt dword[options],1 ;ᦠ⨥ ¨§®¡à.
804
		bt dword[options],1 ;ᦠ⨥ ¨§®¡à.
803
		jnc @f
805
		jnc @f
804
			;...
806
			;...
805
		@@:
807
		@@:
806
		bt dword[options],0 ;¨§¬¥­. ¡ãä¥à
808
		bt dword[options],0 ;¨§¬¥­. ¡ãä¥à
807
		jnc .end_f
809
		jnc .end_f
808
			;...
810
			;...
809
		jmp .end_f
811
		jmp .end_f
810
	.8bit:
812
	.8bit:
811
	cmp buf2d_bits,24
813
	cmp buf2d_bits,24
812
	jne .24bit
814
	jne .24bit
813
		bt dword[options],1 ;ᦠ⨥ ¨§®¡à.
815
		bt dword[options],1 ;ᦠ⨥ ¨§®¡à.
814
		jnc .24_end_r
816
		jnc .24_end_r
815
			mov eax,dword[new_w]
817
			mov eax,dword[new_w]
816
			cmp eax,1
818
			cmp eax,1
817
			jl @f
819
			jl @f
818
			cmp eax,buf2d_w
820
			cmp eax,buf2d_w
819
			jge @f
821
			jge @f
820
				;ᦠ⨥ ¯® è¨à¨­¥
822
				;ᦠ⨥ ¯® è¨à¨­¥
821
				stdcall img_rgb24_wresize, buf2d_data,buf2d_w,buf2d_h,eax
823
				stdcall img_rgb24_wresize, buf2d_data,buf2d_w,buf2d_h,eax
822
				jmp .24_r_h
824
				jmp .24_r_h
823
			@@:
825
			@@:
824
			mov eax,buf2d_w
826
			mov eax,buf2d_w
825
			.24_r_h: ;eax - è¨à¨­  ¡ãä¥à  ¨«¨ è¨à¨­  ᦠ⮣® ¨§®¡à ¦¥­¨ï
827
			.24_r_h: ;eax - è¨à¨­  ¡ãä¥à  ¨«¨ è¨à¨­  ᦠ⮣® ¨§®¡à ¦¥­¨ï
826
			mov ebx,dword[new_h]
828
			mov ebx,dword[new_h]
827
			cmp ebx,1
829
			cmp ebx,1
828
			jl @f
830
			jl @f
829
			cmp ebx,buf2d_h
831
			cmp ebx,buf2d_h
830
			jge @f
832
			jge @f
831
				;ᦠ⨥ ¯® ¢ëá®â¥
833
				;ᦠ⨥ ¯® ¢ëá®â¥
832
				stdcall img_rgb24_hresize, buf2d_data,eax,buf2d_h,ebx
834
				stdcall img_rgb24_hresize, buf2d_data,eax,buf2d_h,ebx
833
			@@:
835
			@@:
834
		.24_end_r:
836
		.24_end_r:
835
		bt dword[options],0 ;¨§¬¥­. ¡ãä¥à
837
		bt dword[options],0 ;¨§¬¥­. ¡ãä¥à
836
		jnc .end_f
838
		jnc .end_f
837
		mov eax,dword[new_w]
839
		mov eax,dword[new_w]
838
		cmp eax,1
840
		cmp eax,1
839
		jl @f
841
		jl @f
840
			mov buf2d_w,eax
842
			mov buf2d_w,eax
841
		@@:
843
		@@:
842
		mov ecx,buf2d_w
844
		mov ecx,buf2d_w
843
		mov eax,dword[new_h]
845
		mov eax,dword[new_h]
844
		cmp eax,1
846
		cmp eax,1
845
		jl @f
847
		jl @f
846
			mov buf2d_h,eax
848
			mov buf2d_h,eax
847
		@@:
849
		@@:
848
		mov ebx,buf2d_h
850
		mov ebx,buf2d_h
849
		imul ecx,ebx
851
		imul ecx,ebx
850
		lea ecx,[ecx+ecx*2] ; 24 bit = 3
852
		lea ecx,[ecx+ecx*2] ; 24 bit = 3
851
		invoke mem.realloc,buf2d_data,ecx ;¨§¬¥­ï¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
853
		invoke mem.realloc,buf2d_data,ecx ;¨§¬¥­ï¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
852
		mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
854
		mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
853
	.24bit:
855
	.24bit:
854
	.end_f:
856
	.end_f:
855
	popad
857
	popad
856
	ret
858
	ret
857
endp
859
endp
858
 
860
 
859
align 4
861
align 4
860
rot_table: ;â ¡«¨æ  ¤«ï 㪠§ ­¨ï ­  ¯®¤ä㭪樨 ¤«ï ¯®¢®à®â®¢
862
rot_table: ;â ¡«¨æ  ¤«ï 㪠§ ­¨ï ­  ¯®¤ä㭪樨 ¤«ï ¯®¢®à®â®¢
861
	dd buf_rotate.8b90,buf_rotate.24b90,buf_rotate.32b90,\
863
	dd buf_rotate.8b90,buf_rotate.24b90,buf_rotate.32b90,\
862
	buf_rotate.8b180,buf_rotate.24b180,buf_rotate.32b180
864
	buf_rotate.8b180,buf_rotate.24b180,buf_rotate.32b180
863
 
865
 
864
;¯®¢®à®â ¨§®¡à ¦¥­¨ï ­  90 ¨«¨ 180 £à ¤ãᮢ
866
;¯®¢®à®â ¨§®¡à ¦¥­¨ï ­  90 ¨«¨ 180 £à ¤ãᮢ
865
align 4
867
align 4
866
proc buf_rotate, buf_struc:dword, angle:dword
868
proc buf_rotate, buf_struc:dword, angle:dword
867
locals
869
locals
868
	n_data dd ?
870
	n_data dd ?
869
	dec_h dd ? ;ç¨á«® ¡ ©â, ¤«ï 㬥­ì襭¨ï ª®®à¤¨­ âë y
871
	dec_h dd ? ;ç¨á«® ¡ ©â, ¤«ï 㬥­ì襭¨ï ª®®à¤¨­ âë y
870
endl
872
endl
871
	pushad
873
	pushad
872
	mov edi,[buf_struc]
874
	mov edi,[buf_struc]
873
	mov ebx,buf2d_w
875
	mov ebx,buf2d_w
874
	mov ecx,buf2d_h
876
	mov ecx,buf2d_h
875
 
877
 
876
	lea eax,[rot_table]
878
	lea eax,[rot_table]
877
	cmp dword[angle],90 ;¯à®¢¥àª  㣫  ¯®¢®à®â 
879
	cmp dword[angle],90 ;¯à®¢¥àª  㣫  ¯®¢®à®â 
878
	je .beg_0
880
	je .beg_0
879
	cmp dword[angle],180
881
	cmp dword[angle],180
880
	jne @f
882
	jne @f
881
		add eax,12
883
		add eax,12
882
		jmp .beg_0
884
		jmp .beg_0
883
	@@:
885
	@@:
884
	jmp .end_f
886
	jmp .end_f
885
	.beg_0: ;¯à®¢¥àª  ¡¨â­®á⨠¡ãä¥à 
887
	.beg_0: ;¯à®¢¥àª  ¡¨â­®á⨠¡ãä¥à 
886
	cmp buf2d_bits,8
888
	cmp buf2d_bits,8
887
	jne @f
889
	jne @f
888
		jmp dword[eax]
890
		jmp dword[eax]
889
	@@:
891
	@@:
890
	cmp buf2d_bits,24
892
	cmp buf2d_bits,24
891
	jne @f
893
	jne @f
892
		add eax,4
894
		add eax,4
893
		jmp dword[eax]
895
		jmp dword[eax]
894
	@@:
896
	@@:
895
	cmp buf2d_bits,32
897
	cmp buf2d_bits,32
896
	jne @f
898
	jne @f
897
		add eax,8
899
		add eax,8
898
		jmp dword[eax]
900
		jmp dword[eax]
899
	@@:
901
	@@:
900
	jmp .end_f
902
	jmp .end_f
901
 
903
 
902
	.8b90: ;¯®¢®à®â 8 ¡¨â­®£® ¡ãä¥à  ­  90 £à ¤ãᮢ
904
	.8b90: ;¯®¢®à®â 8 ¡¨â­®£® ¡ãä¥à  ­  90 £à ¤ãᮢ
903
		mov edx,ecx ;edx - buf_h
905
		mov edx,ecx ;edx - buf_h
904
		imul ecx,ebx
906
		imul ecx,ebx
905
		invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¢à¥¬¥­­ãî ¯ ¬ïâì
907
		invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¢à¥¬¥­­ãî ¯ ¬ïâì
906
		cmp eax,0
908
		cmp eax,0
907
		je .end_f
909
		je .end_f
908
		mov [n_data],eax
910
		mov [n_data],eax
909
		mov [dec_h],ecx
911
		mov [dec_h],ecx
910
		inc dword[dec_h]
912
		inc dword[dec_h]
911
 
913
 
912
		;copy buf --> mem
914
		;copy buf --> mem
913
		mov edi,[buf_struc]
915
		mov edi,[buf_struc]
914
		mov esi,buf2d_data
916
		mov esi,buf2d_data
915
		mov edi,eax ;[n_data]
917
		mov edi,eax ;[n_data]
916
		dec edx ;ª®à¥ªâ¨à㥬 edx ­  1 ¡ ©â, ¤«ï ª®¬¯¥­á æ¨¨ ᤢ¨£  ¢ movsb
918
		dec edx ;ª®à¥ªâ¨à㥬 edx ­  1 ¡ ©â, ¤«ï ª®¬¯¥­á æ¨¨ ᤢ¨£  ¢ movsb
917
		add edi,edx
919
		add edi,edx
918
		xor eax,eax
920
		xor eax,eax
919
		cld
921
		cld
920
		.cycle_0:
922
		.cycle_0:
921
			movsb
923
			movsb
922
			add edi,edx
924
			add edi,edx
923
			inc eax
925
			inc eax
924
			cmp eax,ebx
926
			cmp eax,ebx
925
			jl @f
927
			jl @f
926
				xor eax,eax
928
				xor eax,eax
927
				sub edi,[dec_h]
929
				sub edi,[dec_h]
928
			@@:
930
			@@:
929
			loop .cycle_0
931
			loop .cycle_0
930
 
932
 
931
		;change buf_w <---> buf_h
933
		;change buf_w <---> buf_h
932
		mov esi,[n_data]
934
		mov esi,[n_data]
933
		mov edi,[buf_struc]
935
		mov edi,[buf_struc]
934
		mov edi,buf2d_data
936
		mov edi,buf2d_data
935
		mov ecx,ebx
937
		mov ecx,ebx
936
		inc edx ;¨á¯à ¢«ï¥¬ ᪮४â¨à®¢ ­­ë© edx
938
		inc edx ;¨á¯à ¢«ï¥¬ ᪮४â¨à®¢ ­­ë© edx
937
		imul ecx,edx
939
		imul ecx,edx
938
		;copy buf <-- mem
940
		;copy buf <-- mem
939
		;cld
941
		;cld
940
		rep movsb
942
		rep movsb
941
		invoke mem.free,[n_data]
943
		invoke mem.free,[n_data]
942
		jmp .change_w_h
944
		jmp .change_w_h
943
	.24b90: ;¯®¢®à®â 24 ¡¨â­®£® ¡ãä¥à  ­  90 £à ¤ãᮢ
945
	.24b90: ;¯®¢®à®â 24 ¡¨â­®£® ¡ãä¥à  ­  90 £à ¤ãᮢ
944
		mov esi,ecx
946
		mov esi,ecx
945
		imul esi,ebx
947
		imul esi,ebx
946
		lea ecx,[ecx+ecx*2]
948
		lea ecx,[ecx+ecx*2]
947
		mov edx,ecx ;edx - buf_h * 3
949
		mov edx,ecx ;edx - buf_h * 3
948
		imul ecx,ebx
950
		imul ecx,ebx
949
		invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¢à¥¬¥­­ãî ¯ ¬ïâì
951
		invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¢à¥¬¥­­ãî ¯ ¬ïâì
950
		cmp eax,0
952
		cmp eax,0
951
		je .end_f
953
		je .end_f
952
		mov [n_data],eax
954
		mov [n_data],eax
953
		mov [dec_h],ecx
955
		mov [dec_h],ecx
954
		add dword[dec_h],3
956
		add dword[dec_h],3
955
 
957
 
956
		;copy buf --> mem
958
		;copy buf --> mem
957
		
959
		
958
		mov edi,[buf_struc]
960
		mov edi,[buf_struc]
959
		mov ecx,esi
961
		mov ecx,esi
960
		mov esi,buf2d_data
962
		mov esi,buf2d_data
961
		mov edi,eax ;[n_data]
963
		mov edi,eax ;[n_data]
962
		sub edx,3 ;ª®à¥ªâ¨à㥬 edx ­  3 ¡ ©â , ¤«ï ª®¬¯¥­á æ¨¨ ᤢ¨£ 
964
		sub edx,3 ;ª®à¥ªâ¨à㥬 edx ­  3 ¡ ©â , ¤«ï ª®¬¯¥­á æ¨¨ ᤢ¨£ 
963
		add edi,edx
965
		add edi,edx
964
		xor eax,eax
966
		xor eax,eax
965
		cld
967
		cld
966
		.cycle_1:
968
		.cycle_1:
967
			movsw
969
			movsw
968
			movsb
970
			movsb
969
			add edi,edx
971
			add edi,edx
970
			inc eax
972
			inc eax
971
			cmp eax,ebx
973
			cmp eax,ebx
972
			jl @f
974
			jl @f
973
				xor eax,eax
975
				xor eax,eax
974
				sub edi,[dec_h]
976
				sub edi,[dec_h]
975
			@@:
977
			@@:
976
			loop .cycle_1
978
			loop .cycle_1
977
 
979
 
978
		;copy buf <-- mem
980
		;copy buf <-- mem
979
		mov esi,[n_data]
981
		mov esi,[n_data]
980
		mov edi,[buf_struc]
982
		mov edi,[buf_struc]
981
		mov edi,buf2d_data
983
		mov edi,buf2d_data
982
		mov ecx,ebx
984
		mov ecx,ebx
983
		add edx,3 ;¨á¯à ¢«ï¥¬ ᪮४â¨à®¢ ­­ë© edx
985
		add edx,3 ;¨á¯à ¢«ï¥¬ ᪮४â¨à®¢ ­­ë© edx
984
		imul ecx,edx
986
		imul ecx,edx
985
		;cld
987
		;cld
986
		rep movsb
988
		rep movsb
987
		invoke mem.free,[n_data]
989
		invoke mem.free,[n_data]
988
		jmp .change_w_h
990
		jmp .change_w_h
989
	.32b90: ;¯®¢®à®â 32 ¡¨â­®£® ¡ãä¥à  ­  90 £à ¤ãᮢ
991
	.32b90: ;¯®¢®à®â 32 ¡¨â­®£® ¡ãä¥à  ­  90 £à ¤ãᮢ
990
		shl ecx,2
992
		shl ecx,2
991
		mov edx,ecx ;edx - buf_h * 4
993
		mov edx,ecx ;edx - buf_h * 4
992
		imul ecx,ebx
994
		imul ecx,ebx
993
		invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¢à¥¬¥­­ãî ¯ ¬ïâì
995
		invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¢à¥¬¥­­ãî ¯ ¬ïâì
994
		cmp eax,0
996
		cmp eax,0
995
		je .end_f
997
		je .end_f
996
		mov [n_data],eax
998
		mov [n_data],eax
997
		mov [dec_h],ecx
999
		mov [dec_h],ecx
998
		add dword[dec_h],4
1000
		add dword[dec_h],4
999
 
1001
 
1000
		;copy buf --> mem
1002
		;copy buf --> mem
1001
		mov edi,[buf_struc]
1003
		mov edi,[buf_struc]
1002
		shr ecx,2
1004
		shr ecx,2
1003
		mov esi,buf2d_data
1005
		mov esi,buf2d_data
1004
		mov edi,eax ;[n_data]
1006
		mov edi,eax ;[n_data]
1005
		sub edx,4 ;ª®à¥ªâ¨à㥬 edx ­  4 ¡ ©â , ¤«ï ª®¬¯¥­á æ¨¨ ᤢ¨£  ¢ movsd
1007
		sub edx,4 ;ª®à¥ªâ¨à㥬 edx ­  4 ¡ ©â , ¤«ï ª®¬¯¥­á æ¨¨ ᤢ¨£  ¢ movsd
1006
		add edi,edx
1008
		add edi,edx
1007
		xor eax,eax
1009
		xor eax,eax
1008
		cld
1010
		cld
1009
		.cycle_2:
1011
		.cycle_2:
1010
			movsd
1012
			movsd
1011
			add edi,edx
1013
			add edi,edx
1012
			inc eax
1014
			inc eax
1013
			cmp eax,ebx
1015
			cmp eax,ebx
1014
			jl @f
1016
			jl @f
1015
				xor eax,eax
1017
				xor eax,eax
1016
				sub edi,[dec_h]
1018
				sub edi,[dec_h]
1017
			@@:
1019
			@@:
1018
			loop .cycle_2
1020
			loop .cycle_2
1019
 
1021
 
1020
		;copy buf <-- mem
1022
		;copy buf <-- mem
1021
		mov esi,[n_data]
1023
		mov esi,[n_data]
1022
		mov edi,[buf_struc]
1024
		mov edi,[buf_struc]
1023
		mov edi,buf2d_data
1025
		mov edi,buf2d_data
1024
		mov ecx,ebx
1026
		mov ecx,ebx
1025
		add edx,4 ;¨á¯à ¢«ï¥¬ ᪮४â¨à®¢ ­­ë© edx
1027
		add edx,4 ;¨á¯à ¢«ï¥¬ ᪮४â¨à®¢ ­­ë© edx
1026
		imul ecx,edx
1028
		imul ecx,edx
1027
		shr ecx,2
1029
		shr ecx,2
1028
		;cld
1030
		;cld
1029
		rep movsd
1031
		rep movsd
1030
		invoke mem.free,[n_data]
1032
		invoke mem.free,[n_data]
1031
		;jmp .change_w_h
1033
		;jmp .change_w_h
1032
	.change_w_h: ;change buf_w <---> buf_h
1034
	.change_w_h: ;change buf_w <---> buf_h
1033
		mov edi,[buf_struc]
1035
		mov edi,[buf_struc]
1034
		mov eax,buf2d_w
1036
		mov eax,buf2d_w
1035
		mov ebx,buf2d_h
1037
		mov ebx,buf2d_h
1036
		mov buf2d_h,eax
1038
		mov buf2d_h,eax
1037
		mov buf2d_w,ebx
1039
		mov buf2d_w,ebx
1038
		jmp .end_f
1040
		jmp .end_f
1039
	.8b180: ;¯®¢®à®â 8 ¡¨â­®£® ¡ãä¥à  ­  180 £à ¤ãᮢ
1041
	.8b180: ;¯®¢®à®â 8 ¡¨â­®£® ¡ãä¥à  ­  180 £à ¤ãᮢ
1040
		mov edi,buf2d_data
1042
		mov edi,buf2d_data
1041
		mov esi,edi
1043
		mov esi,edi
1042
		imul ecx,ebx
1044
		imul ecx,ebx
1043
		add esi,ecx
1045
		add esi,ecx
1044
		dec esi
1046
		dec esi
1045
		shr ecx,1 ;ecx - ç¨á«® ¯¨ªá¥«¥© ¡ãä¥à  : 2
1047
		shr ecx,1 ;ecx - ç¨á«® ¯¨ªá¥«¥© ¡ãä¥à  : 2
1046
		std
1048
		std
1047
		@@:
1049
		@@:
1048
			lodsb
1050
			lodsb
1049
			mov ah,byte[edi]
1051
			mov ah,byte[edi]
1050
			mov byte[esi+1],ah
1052
			mov byte[esi+1],ah
1051
			mov byte[edi],al
1053
			mov byte[edi],al
1052
			inc edi
1054
			inc edi
1053
			loop @b
1055
			loop @b
1054
			jmp .end_f
1056
			jmp .end_f
1055
	.24b180: ;¯®¢®à®â 24 ¡¨â­®£® ¡ãä¥à  ­  180 £à ¤ãᮢ
1057
	.24b180: ;¯®¢®à®â 24 ¡¨â­®£® ¡ãä¥à  ­  180 £à ¤ãᮢ
1056
		mov esi,buf2d_data
1058
		mov esi,buf2d_data
1057
		mov edi,esi
1059
		mov edi,esi
1058
		imul ecx,ebx
1060
		imul ecx,ebx
1059
		mov eax,ecx
1061
		mov eax,ecx
1060
		lea ecx,[ecx+ecx*2]
1062
		lea ecx,[ecx+ecx*2]
1061
		add edi,ecx
1063
		add edi,ecx
1062
		sub edi,3
1064
		sub edi,3
1063
		shr eax,1
1065
		shr eax,1
1064
		mov ecx,eax ;ecx - ç¨á«® ¯¨ªá¥«¥© ¡ãä¥à  : 2
1066
		mov ecx,eax ;ecx - ç¨á«® ¯¨ªá¥«¥© ¡ãä¥à  : 2
1065
		cld
1067
		cld
1066
		@@:
1068
		@@:
1067
			lodsw
1069
			lodsw
1068
			mov edx,eax
1070
			mov edx,eax
1069
			lodsb
1071
			lodsb
1070
			mov bx,word[edi]
1072
			mov bx,word[edi]
1071
			mov word[esi-3],bx
1073
			mov word[esi-3],bx
1072
			mov bl,byte[edi+2]
1074
			mov bl,byte[edi+2]
1073
			mov byte[esi-1],bl
1075
			mov byte[esi-1],bl
1074
			mov byte[edi+2],al
1076
			mov byte[edi+2],al
1075
			mov word[edi],dx
1077
			mov word[edi],dx
1076
			sub edi,3
1078
			sub edi,3
1077
			loop @b
1079
			loop @b
1078
			jmp .end_f
1080
			jmp .end_f
1079
	.32b180: ;¯®¢®à®â 32 ¡¨â­®£® ¡ãä¥à  ­  180 £à ¤ãᮢ
1081
	.32b180: ;¯®¢®à®â 32 ¡¨â­®£® ¡ãä¥à  ­  180 £à ¤ãᮢ
1080
		mov edi,buf2d_data
1082
		mov edi,buf2d_data
1081
		mov esi,edi
1083
		mov esi,edi
1082
		imul ecx,ebx
1084
		imul ecx,ebx
1083
		shl ecx,2
1085
		shl ecx,2
1084
		add esi,ecx
1086
		add esi,ecx
1085
		sub esi,4
1087
		sub esi,4
1086
		shr ecx,3 ;ecx - ç¨á«® ¯¨ªá¥«¥© ¡ãä¥à  : 2
1088
		shr ecx,3 ;ecx - ç¨á«® ¯¨ªá¥«¥© ¡ãä¥à  : 2
1087
		std
1089
		std
1088
		@@:
1090
		@@:
1089
			lodsd
1091
			lodsd
1090
			mov ebx,dword[edi]
1092
			mov ebx,dword[edi]
1091
			mov dword[esi+4],ebx
1093
			mov dword[esi+4],ebx
1092
			mov dword[edi],eax
1094
			mov dword[edi],eax
1093
			add edi,4
1095
			add edi,4
1094
			loop @b
1096
			loop @b
1095
		;jmp .end_f
1097
		;jmp .end_f
1096
 
1098
 
1097
	.end_f:
1099
	.end_f:
1098
	popad
1100
	popad
1099
	ret
1101
	ret
1100
endp
1102
endp
1101
 
1103
 
1102
align 4
1104
align 4
1103
proc buf_flip_h, buf_struc:dword
1105
proc buf_flip_h, buf_struc:dword
1104
pushad
1106
pushad
1105
	mov edi,[buf_struc]
1107
	mov edi,[buf_struc]
1106
	cmp buf2d_bits,24
1108
	cmp buf2d_bits,24
1107
	jne .end_24
1109
	jne .end_24
1108
		mov esi,buf2d_data
1110
		mov esi,buf2d_data
1109
		mov eax,buf2d_w
1111
		mov eax,buf2d_w
1110
		mov ecx,eax
1112
		mov ecx,eax
1111
		shr ecx,1
1113
		shr ecx,1
1112
		dec eax
1114
		dec eax
1113
		lea eax,[eax+eax*2]
1115
		lea eax,[eax+eax*2]
1114
		mov ebx,buf2d_h
1116
		mov ebx,buf2d_h
1115
		mov edi,esi		
1117
		mov edi,esi		
1116
		add esi,eax
1118
		add esi,eax
1117
		add eax,3
1119
		add eax,3
1118
		cld
1120
		cld
1119
		.cycle_24:
1121
		.cycle_24:
1120
		push ecx edi esi
1122
		push ecx edi esi
1121
align 4
1123
align 4
1122
		@@:
1124
		@@:
1123
			;swap word[edi] <-> word[esi]
1125
			;swap word[edi] <-> word[esi]
1124
			mov dx,[edi]
1126
			mov dx,[edi]
1125
			movsw
1127
			movsw
1126
			mov [esi-2],dx
1128
			mov [esi-2],dx
1127
			;swap byte[edi] <-> byte[esi]
1129
			;swap byte[edi] <-> byte[esi]
1128
			mov dl,[edi]
1130
			mov dl,[edi]
1129
			movsb
1131
			movsb
1130
			mov [esi-1],dl
1132
			mov [esi-1],dl
1131
			sub esi,6
1133
			sub esi,6
1132
		loop @b
1134
		loop @b
1133
		pop esi edi ecx
1135
		pop esi edi ecx
1134
		add edi,eax
1136
		add edi,eax
1135
		add esi,eax
1137
		add esi,eax
1136
		dec ebx
1138
		dec ebx
1137
		or ebx,ebx
1139
		or ebx,ebx
1138
		jnz .cycle_24
1140
		jnz .cycle_24
1139
		jmp .end_32
1141
		jmp .end_32
1140
	.end_24:
1142
	.end_24:
1141
	cmp buf2d_bits,32
1143
	cmp buf2d_bits,32
1142
	jne .end_32
1144
	jne .end_32
1143
		mov esi,buf2d_data
1145
		mov esi,buf2d_data
1144
		mov eax,buf2d_w
1146
		mov eax,buf2d_w
1145
		dec eax
1147
		dec eax
1146
		shl eax,2
1148
		shl eax,2
1147
		mov ebx,buf2d_h
1149
		mov ebx,buf2d_h
1148
		mov edi,esi
1150
		mov edi,esi
1149
		add esi,eax
1151
		add esi,eax
1150
		add eax,4
1152
		add eax,4
1151
		cld
1153
		cld
1152
		.cycle_32:
1154
		.cycle_32:
1153
		mov ecx,eax
1155
		mov ecx,eax
1154
		shr ecx,3
1156
		shr ecx,3
1155
		push edi esi
1157
		push edi esi
1156
align 4
1158
align 4
1157
		@@:
1159
		@@:
1158
			;swap dword[edi] <-> dword[esi]
1160
			;swap dword[edi] <-> dword[esi]
1159
			mov edx,[edi]
1161
			mov edx,[edi]
1160
			movsd
1162
			movsd
1161
			mov [esi-4],edx
1163
			mov [esi-4],edx
1162
			sub esi,8
1164
			sub esi,8
1163
		loop @b
1165
		loop @b
1164
		pop esi edi
1166
		pop esi edi
1165
		add edi,eax
1167
		add edi,eax
1166
		add esi,eax
1168
		add esi,eax
1167
		dec ebx
1169
		dec ebx
1168
		or ebx,ebx
1170
		or ebx,ebx
1169
		jnz .cycle_32
1171
		jnz .cycle_32
1170
	.end_32:
1172
	.end_32:
1171
popad
1173
popad
1172
	ret
1174
	ret
1173
endp
1175
endp
1174
 
1176
 
1175
;®âà §¨âì ¯® ¢¥à⨪ «¨ (¢¥àå ¨ ­¨§ ¬¥­ïîâáï ¬¥áâ ¬¨)
1177
;®âà §¨âì ¯® ¢¥à⨪ «¨ (¢¥àå ¨ ­¨§ ¬¥­ïîâáï ¬¥áâ ¬¨)
1176
align 4
1178
align 4
1177
proc buf_flip_v, buf_struc:dword
1179
proc buf_flip_v, buf_struc:dword
1178
locals
1180
locals
1179
	line_pix dd ? ;ª®«. ¯¨ªá¥«¥© ¢ «¨­¨¨ ¡ãä¥à 
1181
	line_pix dd ? ;ª®«. ¯¨ªá¥«¥© ¢ «¨­¨¨ ¡ãä¥à 
1180
	line_2byte dd ? ;ª®«. ¡ ©â ¢ «¨­¨¨ ¡ãä¥à  * 2
1182
	line_2byte dd ? ;ª®«. ¡ ©â ¢ «¨­¨¨ ¡ãä¥à  * 2
1181
endl
1183
endl
1182
	pushad
1184
	pushad
1183
	mov edi,[buf_struc]
1185
	mov edi,[buf_struc]
1184
	cmp buf2d_bits,24
1186
	cmp buf2d_bits,24
1185
	jne .end_24
1187
	jne .end_24
1186
		mov edx,buf2d_w
1188
		mov edx,buf2d_w
1187
		mov [line_pix],edx
1189
		mov [line_pix],edx
1188
		mov ebx,buf2d_h
1190
		mov ebx,buf2d_h
1189
		lea edx,[edx+edx*2]
1191
		lea edx,[edx+edx*2]
1190
		mov esi,edx
1192
		mov esi,edx
1191
		imul esi,ebx
1193
		imul esi,ebx
1192
		sub esi,edx
1194
		sub esi,edx
1193
		add esi,buf2d_data ;㪠§ â¥«ì ­  ­¨¦­îî «¨­¨î
1195
		add esi,buf2d_data ;㪠§ â¥«ì ­  ­¨¦­îî «¨­¨î
1194
		shr ebx,1 ;ª®«. «¨­¥©­ëå 横«®¢
1196
		shr ebx,1 ;ª®«. «¨­¥©­ëå 横«®¢
1195
		shl edx,1
1197
		shl edx,1
1196
		mov [line_2byte],edx
1198
		mov [line_2byte],edx
1197
		mov edi,buf2d_data
1199
		mov edi,buf2d_data
1198
		xchg edi,esi
1200
		xchg edi,esi
1199
		cld
1201
		cld
1200
		.flip_24:
1202
		.flip_24:
1201
		cmp ebx,0
1203
		cmp ebx,0
1202
		jle .end_32 ;§¤¥áì ¢ë室 ¨§ ä㭪樨 (¯®â®¬ã .end_24 ­¥ ¯®¤å®¤¨â)
1204
		jle .end_32 ;§¤¥áì ¢ë室 ¨§ ä㭪樨 (¯®â®¬ã .end_24 ­¥ ¯®¤å®¤¨â)
1203
		mov ecx,[line_pix]
1205
		mov ecx,[line_pix]
1204
align 4
1206
align 4
1205
		@@:
1207
		@@:
1206
			lodsw
1208
			lodsw
1207
			mov dx,word[edi]
1209
			mov dx,word[edi]
1208
			mov word[esi-2],dx
1210
			mov word[esi-2],dx
1209
			stosw
1211
			stosw
1210
			lodsb
1212
			lodsb
1211
			mov ah,byte[edi]
1213
			mov ah,byte[edi]
1212
			mov byte[esi-1],ah
1214
			mov byte[esi-1],ah
1213
			stosb
1215
			stosb
1214
			loop @b
1216
			loop @b
1215
		sub edi,[line_2byte]
1217
		sub edi,[line_2byte]
1216
		dec ebx
1218
		dec ebx
1217
		jmp .flip_24
1219
		jmp .flip_24
1218
	.end_24:
1220
	.end_24:
1219
	cmp buf2d_bits,32
1221
	cmp buf2d_bits,32
1220
	jne .end_32
1222
	jne .end_32
1221
		mov edx,buf2d_w
1223
		mov edx,buf2d_w
1222
		mov [line_pix],edx
1224
		mov [line_pix],edx
1223
		mov ebx,buf2d_h
1225
		mov ebx,buf2d_h
1224
		shl edx,2
1226
		shl edx,2
1225
		mov esi,edx
1227
		mov esi,edx
1226
		imul esi,ebx
1228
		imul esi,ebx
1227
		sub esi,edx
1229
		sub esi,edx
1228
		add esi,buf2d_data ;㪠§ â¥«ì ­  ­¨¦­îî «¨­¨î
1230
		add esi,buf2d_data ;㪠§ â¥«ì ­  ­¨¦­îî «¨­¨î
1229
		shr ebx,1 ;ª®«. «¨­¥©­ëå 横«®¢
1231
		shr ebx,1 ;ª®«. «¨­¥©­ëå 横«®¢
1230
		shl edx,1
1232
		shl edx,1
1231
		mov [line_2byte],edx
1233
		mov [line_2byte],edx
1232
		mov edi,buf2d_data
1234
		mov edi,buf2d_data
1233
		xchg edi,esi
1235
		xchg edi,esi
1234
		cld
1236
		cld
1235
		.flip_32:
1237
		.flip_32:
1236
		cmp ebx,0
1238
		cmp ebx,0
1237
		jle .end_32
1239
		jle .end_32
1238
		mov ecx,[line_pix]
1240
		mov ecx,[line_pix]
1239
align 4
1241
align 4
1240
		@@:
1242
		@@:
1241
			lodsd
1243
			lodsd
1242
			mov edx,dword[edi]
1244
			mov edx,dword[edi]
1243
			mov dword[esi-4],edx
1245
			mov dword[esi-4],edx
1244
			stosd
1246
			stosd
1245
			loop @b
1247
			loop @b
1246
		sub edi,[line_2byte]
1248
		sub edi,[line_2byte]
1247
		dec ebx
1249
		dec ebx
1248
		jmp .flip_32
1250
		jmp .flip_32
1249
	.end_32:
1251
	.end_32:
1250
	popad
1252
	popad
1251
	ret
1253
	ret
1252
endp
1254
endp
1253
 
1255
 
1254
;description:
1256
;description:
1255
; ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® è¨à¨­¥ ¢ 2 à §  (à §¬¥àë ¡ãä¥à  ­¥ ¬¥­ïîâáï)
1257
; ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® è¨à¨­¥ ¢ 2 à §  (à §¬¥àë ¡ãä¥à  ­¥ ¬¥­ïîâáï)
1256
align 4
1258
align 4
1257
proc buf_img_wdiv2, buf_struc:dword
1259
proc buf_img_wdiv2, buf_struc:dword
1258
	pushad
1260
	pushad
1259
	mov edi,dword[buf_struc]
1261
	mov edi,dword[buf_struc]
1260
	cmp buf2d_bits,8
1262
	cmp buf2d_bits,8
1261
	jne @f
1263
	jne @f
1262
		mov eax,buf2d_w
1264
		mov eax,buf2d_w
1263
		mov ecx,buf2d_h
1265
		mov ecx,buf2d_h
1264
		imul ecx,eax
1266
		imul ecx,eax
1265
		stdcall img_8b_wdiv2, buf2d_data,ecx
1267
		stdcall img_8b_wdiv2, buf2d_data,ecx
1266
	@@:
1268
	@@:
1267
	cmp buf2d_bits,24
1269
	cmp buf2d_bits,24
1268
	jne @f
1270
	jne @f
1269
		mov eax,buf2d_w
1271
		mov eax,buf2d_w
1270
		mov ecx,buf2d_h
1272
		mov ecx,buf2d_h
1271
		imul ecx,eax
1273
		imul ecx,eax
1272
		stdcall img_rgb24_wdiv2, buf2d_data,ecx
1274
		stdcall img_rgb24_wdiv2, buf2d_data,ecx
1273
	@@:
1275
	@@:
1274
	cmp buf2d_bits,32
1276
	cmp buf2d_bits,32
1275
	jne @f
1277
	jne @f
1276
		mov eax,buf2d_w
1278
		mov eax,buf2d_w
1277
		mov ecx,buf2d_h
1279
		mov ecx,buf2d_h
1278
		imul ecx,eax
1280
		imul ecx,eax
1279
		stdcall img_rgba32_wdiv2, buf2d_data,ecx
1281
		stdcall img_rgba32_wdiv2, buf2d_data,ecx
1280
	@@:
1282
	@@:
1281
	popad
1283
	popad
1282
	ret
1284
	ret
1283
endp
1285
endp
1284
 
1286
 
1285
;input:
1287
;input:
1286
;data_8b - pointer to rgb data
1288
;data_8b - pointer to rgb data
1287
;size - count img pixels (size img data / 3(rgb) )
1289
;size - count img pixels (size img data / 3(rgb) )
1288
align 4
1290
align 4
1289
proc img_8b_wdiv2 data_8b:dword, size:dword
1291
proc img_8b_wdiv2 data_8b:dword, size:dword
1290
	mov eax,dword[data_8b]
1292
	mov eax,dword[data_8b]
1291
	mov ecx,dword[size] ;ecx = size
1293
	mov ecx,dword[size] ;ecx = size
1292
	cld
1294
	cld
1293
	@@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
1295
	@@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
1294
		shr byte[eax],1
1296
		shr byte[eax],1
1295
		inc eax
1297
		inc eax
1296
		loop @b
1298
		loop @b
1297
 
1299
 
1298
	mov eax,dword[data_8b]
1300
	mov eax,dword[data_8b]
1299
	mov ecx,dword[size] ;ecx = size
1301
	mov ecx,dword[size] ;ecx = size
1300
	shr ecx,1
1302
	shr ecx,1
1301
	@@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
1303
	@@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
1302
		mov bl,byte[eax+1] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
1304
		mov bl,byte[eax+1] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
1303
		add byte[eax],bl
1305
		add byte[eax],bl
1304
		add eax,2
1306
		add eax,2
1305
		loop @b
1307
		loop @b
1306
 
1308
 
1307
	mov eax,dword[data_8b]
1309
	mov eax,dword[data_8b]
1308
	inc eax
1310
	inc eax
1309
	mov ebx,eax
1311
	mov ebx,eax
1310
	inc ebx
1312
	inc ebx
1311
	mov ecx,dword[size] ;ecx = size
1313
	mov ecx,dword[size] ;ecx = size
1312
	shr ecx,1
1314
	shr ecx,1
1313
	dec ecx ;«¨è­¨© ¯¨ªá¥«ì
1315
	dec ecx ;«¨è­¨© ¯¨ªá¥«ì
1314
	@@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1316
	@@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1315
		mov dl,byte[ebx]
1317
		mov dl,byte[ebx]
1316
		mov byte[eax],dl
1318
		mov byte[eax],dl
1317
 
1319
 
1318
		inc eax
1320
		inc eax
1319
		add ebx,2
1321
		add ebx,2
1320
		loop @b
1322
		loop @b
1321
	ret
1323
	ret
1322
endp
1324
endp
1323
 
1325
 
1324
;input:
1326
;input:
1325
;data_rgb - pointer to rgb data
1327
;data_rgb - pointer to rgb data
1326
;size - count img pixels (size img data / 3(rgb) )
1328
;size - count img pixels (size img data / 3(rgb) )
1327
align 4
1329
align 4
1328
proc img_rgb24_wdiv2 data_rgb:dword, size:dword
1330
proc img_rgb24_wdiv2 data_rgb:dword, size:dword
1329
  mov eax,dword[data_rgb]
1331
  mov eax,dword[data_rgb]
1330
  mov ecx,dword[size] ;ecx = size
1332
  mov ecx,dword[size] ;ecx = size
1331
  lea ecx,[ecx+ecx*2]
1333
  lea ecx,[ecx+ecx*2]
1332
  cld
1334
  cld
1333
  @@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
1335
  @@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
1334
		shr byte[eax],1
1336
		shr byte[eax],1
1335
		inc eax
1337
		inc eax
1336
		loop @b
1338
		loop @b
1337
 
1339
 
1338
  mov eax,dword[data_rgb]
1340
  mov eax,dword[data_rgb]
1339
  mov ecx,dword[size] ;ecx = size
1341
  mov ecx,dword[size] ;ecx = size
1340
  shr ecx,1
1342
  shr ecx,1
1341
  @@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
1343
  @@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
1342
		mov bx,word[eax+3] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
1344
		mov bx,word[eax+3] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
1343
		add word[eax],bx
1345
		add word[eax],bx
1344
		mov bl,byte[eax+5] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
1346
		mov bl,byte[eax+5] ;ª®¯¨à㥬 梥â á®á¥¤­¥£® ¯¨ªá¥«ï
1345
		add byte[eax+2],bl
1347
		add byte[eax+2],bl
1346
		add eax,6 ;=2*3
1348
		add eax,6 ;=2*3
1347
		loop @b
1349
		loop @b
1348
 
1350
 
1349
  mov eax,dword[data_rgb]
1351
  mov eax,dword[data_rgb]
1350
  add eax,3
1352
  add eax,3
1351
  mov ebx,eax
1353
  mov ebx,eax
1352
  add ebx,3
1354
  add ebx,3
1353
  mov ecx,dword[size] ;ecx = size
1355
  mov ecx,dword[size] ;ecx = size
1354
  shr ecx,1
1356
  shr ecx,1
1355
  dec ecx ;«¨è­¨© ¯¨ªá¥«ì
1357
  dec ecx ;«¨è­¨© ¯¨ªá¥«ì
1356
  @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1358
  @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1357
		mov edx,dword[ebx]
1359
		mov edx,dword[ebx]
1358
		mov word[eax],dx
1360
		mov word[eax],dx
1359
		shr edx,16
1361
		shr edx,16
1360
		mov byte[eax+2],dl
1362
		mov byte[eax+2],dl
1361
 
1363
 
1362
		add eax,3
1364
		add eax,3
1363
		add ebx,6
1365
		add ebx,6
1364
		loop @b
1366
		loop @b
1365
  ret
1367
  ret
1366
endp
1368
endp
1367
 
1369
 
1368
;input:
1370
;input:
1369
;data_rgba - pointer to rgba data
1371
;data_rgba - pointer to rgba data
1370
;size - count img pixels (size img data / 4(rgba) )
1372
;size - count img pixels (size img data / 4(rgba) )
1371
align 4
1373
align 4
1372
proc img_rgba32_wdiv2 data_rgba:dword, size:dword
1374
proc img_rgba32_wdiv2 data_rgba:dword, size:dword
1373
	mov eax,dword[data_rgba]
1375
	mov eax,dword[data_rgba]
1374
 
1376
 
1375
	mov eax,dword[data_rgba]
1377
	mov eax,dword[data_rgba]
1376
	mov ebx,eax
1378
	mov ebx,eax
1377
	add ebx,4
1379
	add ebx,4
1378
	mov ecx,dword[size] ;ecx = size
1380
	mov ecx,dword[size] ;ecx = size
1379
	shr ecx,1
1381
	shr ecx,1
1380
	@@: ;ᬥ訢 ­¨¥ 梥⮢ ¯¨ªá¥«¥©
1382
	@@: ;ᬥ訢 ­¨¥ 梥⮢ ¯¨ªá¥«¥©
1381
		call combine_colors_1
1383
		call combine_colors_1
1382
		mov [eax],edx
1384
		mov [eax],edx
1383
		add eax,8 ;=2*4
1385
		add eax,8 ;=2*4
1384
		add ebx,8
1386
		add ebx,8
1385
		loop @b
1387
		loop @b
1386
 
1388
 
1387
	mov eax,dword[data_rgba]
1389
	mov eax,dword[data_rgba]
1388
	add eax,4
1390
	add eax,4
1389
	mov ebx,eax
1391
	mov ebx,eax
1390
	add ebx,4
1392
	add ebx,4
1391
	mov ecx,dword[size] ;ecx = size
1393
	mov ecx,dword[size] ;ecx = size
1392
	shr ecx,1
1394
	shr ecx,1
1393
	dec ecx ;«¨è­¨© ¯¨ªá¥«ì
1395
	dec ecx ;«¨è­¨© ¯¨ªá¥«ì
1394
	@@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1396
	@@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1395
		mov edx,dword[ebx]
1397
		mov edx,dword[ebx]
1396
		mov dword[eax],edx
1398
		mov dword[eax],edx
1397
 
1399
 
1398
		add eax,4
1400
		add eax,4
1399
		add ebx,8
1401
		add ebx,8
1400
		loop @b
1402
		loop @b
1401
	ret
1403
	ret
1402
endp
1404
endp
1403
 
1405
 
1404
;description:
1406
;description:
1405
; ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® ¢ëá®â¥ ¢ 2 à §  (¢ëá®â  ¡ãä¥à  ­¥ ¬¥­ï¥âáï)
1407
; ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® ¢ëá®â¥ ¢ 2 à §  (¢ëá®â  ¡ãä¥à  ­¥ ¬¥­ï¥âáï)
1406
align 4
1408
align 4
1407
proc buf_img_hdiv2, buf_struc:dword
1409
proc buf_img_hdiv2, buf_struc:dword
1408
	pushad
1410
	pushad
1409
	mov edi,dword[buf_struc]
1411
	mov edi,dword[buf_struc]
1410
	cmp buf2d_bits,8
1412
	cmp buf2d_bits,8
1411
	jne @f
1413
	jne @f
1412
		mov eax,buf2d_w
1414
		mov eax,buf2d_w
1413
		mov ecx,buf2d_h
1415
		mov ecx,buf2d_h
1414
		imul ecx,eax
1416
		imul ecx,eax
1415
		stdcall img_8b_hdiv2, buf2d_data,ecx,eax
1417
		stdcall img_8b_hdiv2, buf2d_data,ecx,eax
1416
		jmp .end_f ;edi ¯®àâ¨âáï ¢ ä㭪樨, ¯®â®¬ã ¨á¯®«ì§®¢ ­¨¥ buf2d_bits ®¯ á­®
1418
		jmp .end_f ;edi ¯®àâ¨âáï ¢ ä㭪樨, ¯®â®¬ã ¨á¯®«ì§®¢ ­¨¥ buf2d_bits ®¯ á­®
1417
	@@:
1419
	@@:
1418
	cmp buf2d_bits,24
1420
	cmp buf2d_bits,24
1419
	jne @f
1421
	jne @f
1420
		mov eax,buf2d_w
1422
		mov eax,buf2d_w
1421
		mov ecx,buf2d_h
1423
		mov ecx,buf2d_h
1422
		imul ecx,eax
1424
		imul ecx,eax
1423
		stdcall img_rgb24_hdiv2, buf2d_data,ecx,eax
1425
		stdcall img_rgb24_hdiv2, buf2d_data,ecx,eax
1424
		jmp .end_f
1426
		jmp .end_f
1425
	@@:
1427
	@@:
1426
	cmp buf2d_bits,32
1428
	cmp buf2d_bits,32
1427
	jne @f
1429
	jne @f
1428
		mov eax,buf2d_w
1430
		mov eax,buf2d_w
1429
		mov ecx,buf2d_h
1431
		mov ecx,buf2d_h
1430
		imul ecx,eax
1432
		imul ecx,eax
1431
		shl eax,2
1433
		shl eax,2
1432
		stdcall img_rgba32_hdiv2, buf2d_data,ecx,eax
1434
		stdcall img_rgba32_hdiv2, buf2d_data,ecx,eax
1433
		;jmp .end_f
1435
		;jmp .end_f
1434
	@@:
1436
	@@:
1435
	.end_f:
1437
	.end_f:
1436
	popad
1438
	popad
1437
	ret
1439
	ret
1438
endp
1440
endp
1439
 
1441
 
1440
;input:
1442
;input:
1441
;data_8b - pointer to 8 bit data
1443
;data_8b - pointer to 8 bit data
1442
;size - count img pixels (size img data)
1444
;size - count img pixels (size img data)
1443
;size_w - width img in pixels
1445
;size_w - width img in pixels
1444
align 4
1446
align 4
1445
proc img_8b_hdiv2, data_8b:dword, size:dword, size_w:dword
1447
proc img_8b_hdiv2, data_8b:dword, size:dword, size_w:dword
1446
 
1448
 
1447
	mov eax,dword[data_8b] ;eax =
1449
	mov eax,dword[data_8b] ;eax =
1448
	mov ecx,dword[size]
1450
	mov ecx,dword[size]
1449
	cld
1451
	cld
1450
	@@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
1452
	@@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
1451
		shr byte[eax],1
1453
		shr byte[eax],1
1452
		inc eax
1454
		inc eax
1453
		loop @b
1455
		loop @b
1454
 
1456
 
1455
	mov eax,dword[data_8b] ;eax =
1457
	mov eax,dword[data_8b] ;eax =
1456
	mov esi,dword[size_w]
1458
	mov esi,dword[size_w]
1457
	mov ebx,esi
1459
	mov ebx,esi
1458
	add ebx,eax
1460
	add ebx,eax
1459
	mov ecx,dword[size]  ;ecx = size
1461
	mov ecx,dword[size]  ;ecx = size
1460
	shr ecx,1
1462
	shr ecx,1
1461
	xor edi,edi
1463
	xor edi,edi
1462
	@@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
1464
	@@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
1463
		mov dl,byte[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1465
		mov dl,byte[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1464
		add byte[eax],dl
1466
		add byte[eax],dl
1465
 
1467
 
1466
		inc eax
1468
		inc eax
1467
		inc ebx
1469
		inc ebx
1468
		inc edi
1470
		inc edi
1469
		cmp edi,dword[size_w]
1471
		cmp edi,dword[size_w]
1470
		jl .old_line
1472
		jl .old_line
1471
			add eax,esi
1473
			add eax,esi
1472
			add ebx,esi
1474
			add ebx,esi
1473
			xor edi,edi
1475
			xor edi,edi
1474
		.old_line:
1476
		.old_line:
1475
		loop @b
1477
		loop @b
1476
 
1478
 
1477
 
1479
 
1478
	mov eax,dword[data_8b] ;eax =
1480
	mov eax,dword[data_8b] ;eax =
1479
	add eax,esi ;esi = width*3(rgb)
1481
	add eax,esi ;esi = width*3(rgb)
1480
	mov ebx,eax
1482
	mov ebx,eax
1481
	add ebx,esi
1483
	add ebx,esi
1482
	mov ecx,dword[size] ;ecx = size
1484
	mov ecx,dword[size] ;ecx = size
1483
	shr ecx,1
1485
	shr ecx,1
1484
	sub ecx,dword[size_w] ;«¨è­ïï áâப  ¯¨ªá¥«¥©
1486
	sub ecx,dword[size_w] ;«¨è­ïï áâப  ¯¨ªá¥«¥©
1485
	xor edi,edi
1487
	xor edi,edi
1486
	@@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1488
	@@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1487
		mov dl,byte[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1489
		mov dl,byte[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1488
		mov byte[eax],dl
1490
		mov byte[eax],dl
1489
 
1491
 
1490
		inc eax
1492
		inc eax
1491
		inc ebx
1493
		inc ebx
1492
		inc edi
1494
		inc edi
1493
		cmp edi,dword[size_w]
1495
		cmp edi,dword[size_w]
1494
		jl .old_line_2
1496
		jl .old_line_2
1495
			add ebx,esi
1497
			add ebx,esi
1496
			xor edi,edi
1498
			xor edi,edi
1497
		.old_line_2:
1499
		.old_line_2:
1498
		loop @b
1500
		loop @b
1499
	ret
1501
	ret
1500
endp
1502
endp
1501
 
1503
 
1502
;input:
1504
;input:
1503
;data_rgb - pointer to rgb data
1505
;data_rgb - pointer to rgb data
1504
;size - count img pixels (size img data / 3(rgb) )
1506
;size - count img pixels (size img data / 3(rgb) )
1505
;size_w - width img in pixels
1507
;size_w - width img in pixels
1506
align 4
1508
align 4
1507
proc img_rgb24_hdiv2, data_rgb:dword, size:dword, size_w:dword
1509
proc img_rgb24_hdiv2, data_rgb:dword, size:dword, size_w:dword
1508
 
1510
 
1509
  mov eax,dword[data_rgb] ;eax =
1511
  mov eax,dword[data_rgb] ;eax =
1510
  mov ecx,dword[size]	  ;ecx = size
1512
  mov ecx,dword[size]	  ;ecx = size
1511
  lea ecx,[ecx+ecx*2]
1513
  lea ecx,[ecx+ecx*2]
1512
  cld
1514
  cld
1513
  @@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
1515
  @@: ;§ â¥¬­¥­¨¥ æ¢¥â  ¯¨ªá¥«¥©
1514
    shr byte[eax],1
1516
    shr byte[eax],1
1515
    inc eax
1517
    inc eax
1516
    loop @b
1518
    loop @b
1517
 
1519
 
1518
  mov eax,dword[data_rgb] ;eax =
1520
  mov eax,dword[data_rgb] ;eax =
1519
  mov esi,dword[size_w]
1521
  mov esi,dword[size_w]
1520
  lea esi,[esi+esi*2] ;esi = width*3(rgb)
1522
  lea esi,[esi+esi*2] ;esi = width*3(rgb)
1521
  mov ebx,esi
1523
  mov ebx,esi
1522
  add ebx,eax
1524
  add ebx,eax
1523
  mov ecx,dword[size]  ;ecx = size
1525
  mov ecx,dword[size]  ;ecx = size
1524
  shr ecx,1
1526
  shr ecx,1
1525
  xor edi,edi
1527
  xor edi,edi
1526
  @@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
1528
  @@: ;á«®¦¥­¨¥ 梥⮢ ¯¨ªá¥«¥©
1527
    mov dx,word[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1529
    mov dx,word[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1528
    add word[eax],dx
1530
    add word[eax],dx
1529
    mov dl,byte[ebx+2] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1531
    mov dl,byte[ebx+2] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1530
    add byte[eax+2],dl
1532
    add byte[eax+2],dl
1531
 
1533
 
1532
    add eax,3
1534
    add eax,3
1533
    add ebx,3
1535
    add ebx,3
1534
    inc edi
1536
    inc edi
1535
    cmp edi,dword[size_w]
1537
    cmp edi,dword[size_w]
1536
    jl .old_line
1538
    jl .old_line
1537
      add eax,esi
1539
      add eax,esi
1538
      add ebx,esi
1540
      add ebx,esi
1539
      xor edi,edi
1541
      xor edi,edi
1540
    .old_line:
1542
    .old_line:
1541
    loop @b
1543
    loop @b
1542
 
1544
 
1543
  mov eax,dword[data_rgb] ;eax =
1545
  mov eax,dword[data_rgb] ;eax =
1544
  add eax,esi ;esi = width*3(rgb)
1546
  add eax,esi ;esi = width*3(rgb)
1545
  mov ebx,eax
1547
  mov ebx,eax
1546
  add ebx,esi
1548
  add ebx,esi
1547
  mov ecx,dword[size] ;ecx = size
1549
  mov ecx,dword[size] ;ecx = size
1548
  shr ecx,1
1550
  shr ecx,1
1549
  sub ecx,dword[size_w] ;«¨è­ïï áâப  ¯¨ªá¥«¥©
1551
  sub ecx,dword[size_w] ;«¨è­ïï áâப  ¯¨ªá¥«¥©
1550
  xor edi,edi
1552
  xor edi,edi
1551
  @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1553
  @@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1552
    mov edx,dword[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1554
    mov edx,dword[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1553
    mov word[eax],dx
1555
    mov word[eax],dx
1554
    shr edx,16
1556
    shr edx,16
1555
    mov byte[eax+2],dl
1557
    mov byte[eax+2],dl
1556
 
1558
 
1557
    add eax,3
1559
    add eax,3
1558
    add ebx,3
1560
    add ebx,3
1559
    inc edi
1561
    inc edi
1560
    cmp edi,dword[size_w]
1562
    cmp edi,dword[size_w]
1561
    jl .old_line_2
1563
    jl .old_line_2
1562
      add ebx,esi
1564
      add ebx,esi
1563
      xor edi,edi
1565
      xor edi,edi
1564
    .old_line_2:
1566
    .old_line_2:
1565
    loop @b
1567
    loop @b
1566
  ret
1568
  ret
1567
endp
1569
endp
1568
 
1570
 
1569
;input:
1571
;input:
1570
;data_rgba - pointer to rgba data
1572
;data_rgba - pointer to rgba data
1571
;size - count img pixels (size img data / 4(rgba) )
1573
;size - count img pixels (size img data / 4(rgba) )
1572
;size_w_b - width img in bytes
1574
;size_w_b - width img in bytes
1573
align 4
1575
align 4
1574
proc img_rgba32_hdiv2, data_rgba:dword, size:dword, size_w_b:dword
1576
proc img_rgba32_hdiv2, data_rgba:dword, size:dword, size_w_b:dword
1575
 
1577
 
1576
	mov eax,dword[data_rgba] ;eax =
1578
	mov eax,dword[data_rgba] ;eax =
1577
	mov ebx,dword[size_w_b]
1579
	mov ebx,dword[size_w_b]
1578
	add ebx,eax
1580
	add ebx,eax
1579
	mov ecx,dword[size]  ;ecx = size
1581
	mov ecx,dword[size]  ;ecx = size
1580
	shr ecx,1
1582
	shr ecx,1
1581
	xor edi,edi
1583
	xor edi,edi
1582
	@@: ;ᬥ訢 ­¨¥ 梥⮢ ¯¨ªá¥«¥©
1584
	@@: ;ᬥ訢 ­¨¥ 梥⮢ ¯¨ªá¥«¥©
1583
		call combine_colors_1
1585
		call combine_colors_1
1584
		mov dword[eax],edx
1586
		mov dword[eax],edx
1585
 
1587
 
1586
		add eax,4
1588
		add eax,4
1587
		add ebx,4
1589
		add ebx,4
1588
		add edi,4
1590
		add edi,4
1589
		cmp edi,dword[size_w_b]
1591
		cmp edi,dword[size_w_b]
1590
		jl .old_line
1592
		jl .old_line
1591
			add eax,dword[size_w_b]
1593
			add eax,dword[size_w_b]
1592
			add ebx,dword[size_w_b]
1594
			add ebx,dword[size_w_b]
1593
			xor edi,edi
1595
			xor edi,edi
1594
		.old_line:
1596
		.old_line:
1595
		loop @b
1597
		loop @b
1596
 
1598
 
1597
	mov eax,dword[data_rgba] ;eax =
1599
	mov eax,dword[data_rgba] ;eax =
1598
	mov ebx,dword[size_w_b]
1600
	mov ebx,dword[size_w_b]
1599
	add eax,ebx
1601
	add eax,ebx
1600
	add ebx,eax
1602
	add ebx,eax
1601
	mov ecx,dword[size] ;ecx = size
1603
	mov ecx,dword[size] ;ecx = size
1602
	shl ecx,1
1604
	shl ecx,1
1603
	sub ecx,dword[size_w_b] ;«¨è­ïï áâப  ¯¨ªá¥«¥©
1605
	sub ecx,dword[size_w_b] ;«¨è­ïï áâப  ¯¨ªá¥«¥©
1604
	shr ecx,2
1606
	shr ecx,2
1605
	xor edi,edi
1607
	xor edi,edi
1606
	@@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1608
	@@: ;¯®¤¦ â¨¥ ¯¨ªá¥«¥©
1607
		mov edx,dword[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1609
		mov edx,dword[ebx] ;ª®¯¨à㥬 梥⠭¨¦­¥£® ¯¨ªá¥«ï
1608
		mov dword[eax],edx
1610
		mov dword[eax],edx
1609
 
1611
 
1610
		add eax,4
1612
		add eax,4
1611
		add ebx,4
1613
		add ebx,4
1612
		add edi,4
1614
		add edi,4
1613
		cmp edi,dword[size_w_b]
1615
		cmp edi,dword[size_w_b]
1614
		jl .old_line_2
1616
		jl .old_line_2
1615
			add ebx,dword[size_w_b]
1617
			add ebx,dword[size_w_b]
1616
			xor edi,edi
1618
			xor edi,edi
1617
		.old_line_2:
1619
		.old_line_2:
1618
		loop @b
1620
		loop @b
1619
	ret
1621
	ret
1620
endp
1622
endp
1621
 
1623
 
1622
;input:
1624
;input:
1623
; eax - 㪠§ â¥«ì ­  32-¡¨â­ë© 梥â
1625
; eax - 㪠§ â¥«ì ­  32-¡¨â­ë© 梥â
1624
; ebx - 㪠§ â¥«ì ­  32-¡¨â­ë© 梥â
1626
; ebx - 㪠§ â¥«ì ­  32-¡¨â­ë© 梥â
1625
;output:
1627
;output:
1626
; edx - 32-¡¨â­ë© 梥â ᬥ蠭­ë© á ãç¥â®¬ ¯à®§à ç­®áâ¨
1628
; edx - 32-¡¨â­ë© 梥â ᬥ蠭­ë© á ãç¥â®¬ ¯à®§à ç­®áâ¨
1627
;destroy:
1629
;destroy:
1628
; esi
1630
; esi
1629
align 4
1631
align 4
1630
proc combine_colors_1 uses ecx edi
1632
proc combine_colors_1 uses ecx edi
1631
locals
1633
locals
1632
	c_blye dd ?
1634
	c_blye dd ?
1633
	c_green dd ?
1635
	c_green dd ?
1634
	c_red dd ?
1636
	c_red dd ?
1635
endl		
1637
endl		
1636
	movzx edi,byte[eax+3]
1638
	movzx edi,byte[eax+3]
1637
	cmp edi,255
1639
	cmp edi,255
1638
	je .c0z
1640
	je .c0z
1639
	movzx esi,byte[ebx+3]
1641
	movzx esi,byte[ebx+3]
1640
	cmp esi,255
1642
	cmp esi,255
1641
	je .c1z
1643
	je .c1z
1642
	cmp edi,esi
1644
	cmp edi,esi
1643
	je .c0_c1
1645
	je .c0_c1
1644
 
1646
 
1645
	;¯¥à¥¢®à ç¨¢ ¥¬ §­ ç¥­¨ï ¯à®§à ç­®á⥩
1647
	;¯¥à¥¢®à ç¨¢ ¥¬ §­ ç¥­¨ï ¯à®§à ç­®á⥩
1646
	neg edi
1648
	neg edi
1647
	inc edi
1649
	inc edi
1648
	add edi,255
1650
	add edi,255
1649
	neg esi
1651
	neg esi
1650
	inc esi
1652
	inc esi
1651
	add esi,255
1653
	add esi,255
1652
 
1654
 
1653
	movzx ecx,byte[eax]
1655
	movzx ecx,byte[eax]
1654
	imul ecx,edi
1656
	imul ecx,edi
1655
	mov [c_blye],ecx
1657
	mov [c_blye],ecx
1656
	movzx ecx,byte[ebx]
1658
	movzx ecx,byte[ebx]
1657
	imul ecx,esi
1659
	imul ecx,esi
1658
	add [c_blye],ecx
1660
	add [c_blye],ecx
1659
 
1661
 
1660
	movzx ecx,byte[eax+1]
1662
	movzx ecx,byte[eax+1]
1661
	imul ecx,edi
1663
	imul ecx,edi
1662
	mov [c_green],ecx
1664
	mov [c_green],ecx
1663
	movzx ecx,byte[ebx+1]
1665
	movzx ecx,byte[ebx+1]
1664
	imul ecx,esi
1666
	imul ecx,esi
1665
	add [c_green],ecx
1667
	add [c_green],ecx
1666
 
1668
 
1667
	movzx ecx,byte[eax+2]
1669
	movzx ecx,byte[eax+2]
1668
	imul ecx,edi
1670
	imul ecx,edi
1669
	mov [c_red],ecx
1671
	mov [c_red],ecx
1670
	movzx ecx,byte[ebx+2]
1672
	movzx ecx,byte[ebx+2]
1671
	imul ecx,esi
1673
	imul ecx,esi
1672
	add [c_red],ecx
1674
	add [c_red],ecx
1673
 
1675
 
1674
push eax ebx
1676
push eax ebx
1675
	xor ebx,ebx
1677
	xor ebx,ebx
1676
	mov eax,[c_red]
1678
	mov eax,[c_red]
1677
	xor edx,edx
1679
	xor edx,edx
1678
	mov ecx,edi
1680
	mov ecx,edi
1679
	add ecx,esi
1681
	add ecx,esi
1680
	div ecx
1682
	div ecx
1681
	mov bl,al
1683
	mov bl,al
1682
	shl ebx,16
1684
	shl ebx,16
1683
	mov eax,[c_green]
1685
	mov eax,[c_green]
1684
	xor edx,edx
1686
	xor edx,edx
1685
	div ecx
1687
	div ecx
1686
	mov bh,al
1688
	mov bh,al
1687
	mov eax,[c_blye]
1689
	mov eax,[c_blye]
1688
	xor edx,edx
1690
	xor edx,edx
1689
	div ecx
1691
	div ecx
1690
	mov bl,al
1692
	mov bl,al
1691
 
1693
 
1692
	shr ecx,1
1694
	shr ecx,1
1693
	;¯¥à¥¢®à ç¨¢ ¥¬ §­ ç¥­¨ï ¯à®§à ç­®áâ¨
1695
	;¯¥à¥¢®à ç¨¢ ¥¬ §­ ç¥­¨ï ¯à®§à ç­®áâ¨
1694
	neg ecx
1696
	neg ecx
1695
	inc ecx
1697
	inc ecx
1696
	add ecx,255
1698
	add ecx,255
1697
 
1699
 
1698
	shl ecx,24
1700
	shl ecx,24
1699
	add ebx,ecx
1701
	add ebx,ecx
1700
	mov edx,ebx
1702
	mov edx,ebx
1701
pop ebx eax
1703
pop ebx eax
1702
 
1704
 
1703
	jmp .end_f
1705
	jmp .end_f
1704
	.c0_c1: ;¥á«¨ ¯à®§à ç­®á⨠®¡®¨å 梥⮢ ᮢ¯ ¤ îâ
1706
	.c0_c1: ;¥á«¨ ¯à®§à ç­®á⨠®¡®¨å 梥⮢ ᮢ¯ ¤ îâ
1705
		mov edx,dword[eax]
1707
		mov edx,dword[eax]
1706
		shr edx,1
1708
		shr edx,1
1707
		and edx,011111110111111101111111b
1709
		and edx,011111110111111101111111b
1708
		mov esi,dword[ebx]
1710
		mov esi,dword[ebx]
1709
		shr esi,1
1711
		shr esi,1
1710
		and esi,011111110111111101111111b
1712
		and esi,011111110111111101111111b
1711
		add edx,esi
1713
		add edx,esi
1712
		ror edi,8 ;¯¥à¥¬¥é ¥¬ §­ ç¥­¨¥ ¯à®§à ç­®á⨠¢ áâ à訩 ¡ ©â edi
1714
		ror edi,8 ;¯¥à¥¬¥é ¥¬ §­ ç¥­¨¥ ¯à®§à ç­®á⨠¢ áâ à訩 ¡ ©â edi
1713
		or edx,edi
1715
		or edx,edi
1714
		jmp .end_f
1716
		jmp .end_f
1715
	.c0z: ;¥á«¨ 梥⠢ eax ¯à®§à ç­ë©
1717
	.c0z: ;¥á«¨ 梥⠢ eax ¯à®§à ç­ë©
1716
		mov edx,dword[ebx]
1718
		mov edx,dword[ebx]
1717
		movzx edi,byte[ebx+3]
1719
		movzx edi,byte[ebx+3]
1718
		jmp @f
1720
		jmp @f
1719
	.c1z: ;¥á«¨ 梥⠢ ebx ¯à®§à ç­ë©
1721
	.c1z: ;¥á«¨ 梥⠢ ebx ¯à®§à ç­ë©
1720
		mov edx,dword[eax]
1722
		mov edx,dword[eax]
1721
	@@:
1723
	@@:
1722
		add edi,255 ;¤¥« ¥¬ 梥⠭  ¯®«®¢¨­ã ¯à®§à ç­ë¬
1724
		add edi,255 ;¤¥« ¥¬ 梥⠭  ¯®«®¢¨­ã ¯à®§à ç­ë¬
1723
		shr edi,1
1725
		shr edi,1
1724
		cmp edi,255
1726
		cmp edi,255
1725
		jl @f
1727
		jl @f
1726
			mov edi,255 ;¬ ªá¨¬ «ì­ ï ¯à®§à ç­®áâì ­¥ ¡®«¥¥ 255
1728
			mov edi,255 ;¬ ªá¨¬ «ì­ ï ¯à®§à ç­®áâì ­¥ ¡®«¥¥ 255
1727
		@@:
1729
		@@:
1728
		shl edi,24
1730
		shl edi,24
1729
		and edx,0xffffff ;á­¨¬ ¥¬ áâ àãî ¯à®§à ç­®áâì
1731
		and edx,0xffffff ;á­¨¬ ¥¬ áâ àãî ¯à®§à ç­®áâì
1730
		add edx,edi
1732
		add edx,edi
1731
	.end_f:
1733
	.end_f:
1732
	ret
1734
	ret
1733
endp
1735
endp
1734
 
1736
 
1735
;description:
1737
;description:
1736
; ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® è¨à¨­¥ (à §¬¥àë ¡ãä¥à  ­¥ ¬¥­ïîâáï)
1738
; ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® è¨à¨­¥ (à §¬¥àë ¡ãä¥à  ­¥ ¬¥­ïîâáï)
1737
;input:
1739
;input:
1738
; data_rgb - pointer to rgb data
1740
; data_rgb - pointer to rgb data
1739
; size_w - width img in pixels
1741
; size_w - width img in pixels
1740
; size_h - height img in pixels
1742
; size_h - height img in pixels
1741
; size_w_new - new width img in pixels
1743
; size_w_new - new width img in pixels
1742
align 16
1744
align 16
1743
proc img_rgb24_wresize, data_rgb:dword, size_w:dword, size_h:dword, size_w_new:dword
1745
proc img_rgb24_wresize, data_rgb:dword, size_w:dword, size_h:dword, size_w_new:dword
1744
locals
1746
locals
1745
	pr dd 0
1747
	pr dd 0
1746
	pg dd 0
1748
	pg dd 0
1747
	pb dd 0
1749
	pb dd 0
1748
	img_n dd ? ;㪠§ â¥«ì ­  ¤ ­­ë¥ ­®¢®£® ¨§®¡à ¦¥­¨ï
1750
	img_n dd ? ;㪠§ â¥«ì ­  ¤ ­­ë¥ ­®¢®£® ¨§®¡à ¦¥­¨ï
1749
	lines dd ?
1751
	lines dd ?
1750
endl
1752
endl
1751
pushad
1753
pushad
1752
;eax - delta for inp. img
1754
;eax - delta for inp. img
1753
;ebx - delta for outp. img
1755
;ebx - delta for outp. img
1754
;esi - pointer to data_rgb
1756
;esi - pointer to data_rgb
1755
	mov esi,[data_rgb]
1757
	mov esi,[data_rgb]
1756
	mov [img_n],esi
1758
	mov [img_n],esi
1757
	mov eax,[size_h]
1759
	mov eax,[size_h]
1758
	mov [lines],eax
1760
	mov [lines],eax
1759
align 4
1761
align 4
1760
	.cycyle_0:
1762
	.cycyle_0:
1761
	mov eax,[size_w_new]
1763
	mov eax,[size_w_new]
1762
	mov ecx,[size_w]
1764
	mov ecx,[size_w]
1763
	mov ebx,ecx
1765
	mov ebx,ecx
1764
align 4
1766
align 4
1765
	.cycyle_1:
1767
	.cycyle_1:
1766
		cmp eax,ebx
1768
		cmp eax,ebx
1767
		jg .else_0
1769
		jg .else_0
1768
			;ª®¯¨àã¥¬ë© ¯¨ªá¥«ì ¬ ªá¨¬ «ì­® ¢«¨ï¥â ­  १ã«ìâ â
1770
			;ª®¯¨àã¥¬ë© ¯¨ªá¥«ì ¬ ªá¨¬ «ì­® ¢«¨ï¥â ­  १ã«ìâ â
1769
			;­ ª ¯«¨¢ ¥¬ rgb ¤«ï ¨­â¥à¯®«ï樨 ¯¨ªá¥«¥©
1771
			;­ ª ¯«¨¢ ¥¬ rgb ¤«ï ¨­â¥à¯®«ï樨 ¯¨ªá¥«¥©
1770
			mov edx,[size_w_new]
1772
			mov edx,[size_w_new]
1771
			movzx edi,byte[esi]
1773
			movzx edi,byte[esi]
1772
			imul edi,edx
1774
			imul edi,edx
1773
			add [pb],edi
1775
			add [pb],edi
1774
			movzx edi,byte[esi+1]
1776
			movzx edi,byte[esi+1]
1775
			imul edi,edx
1777
			imul edi,edx
1776
			add [pg],edi
1778
			add [pg],edi
1777
			movzx edi,byte[esi+2]
1779
			movzx edi,byte[esi+2]
1778
			imul edi,edx
1780
			imul edi,edx
1779
			add [pr],edi
1781
			add [pr],edi
1780
			cmp eax,ebx
1782
			cmp eax,ebx
1781
			je .d2_add
1783
			je .d2_add
1782
			jmp .if_0_end
1784
			jmp .if_0_end
1783
		.else_0:
1785
		.else_0:
1784
			;ª®¯¨àã¥¬ë© ¯¨ªá¥«ì ¯®¯ ¤¥â ­  £à ­¨æã ¯¨ªá¥«¥©
1786
			;ª®¯¨àã¥¬ë© ¯¨ªá¥«ì ¯®¯ ¤¥â ­  £à ­¨æã ¯¨ªá¥«¥©
1785
			mov edx,ebx
1787
			mov edx,ebx
1786
			sub edx,eax
1788
			sub edx,eax
1787
			add edx,[size_w_new]
1789
			add edx,[size_w_new]
1788
			movzx edi,byte[esi]
1790
			movzx edi,byte[esi]
1789
			imul edi,edx
1791
			imul edi,edx
1790
			add [pb],edi
1792
			add [pb],edi
1791
			movzx edi,byte[esi+1]
1793
			movzx edi,byte[esi+1]
1792
			imul edi,edx
1794
			imul edi,edx
1793
			add [pg],edi
1795
			add [pg],edi
1794
			movzx edi,byte[esi+2]
1796
			movzx edi,byte[esi+2]
1795
			imul edi,edx
1797
			imul edi,edx
1796
			add [pr],edi
1798
			add [pr],edi
1797
			;á®å࠭塞 £®â®¢®¥ rgb
1799
			;á®å࠭塞 £®â®¢®¥ rgb
1798
			.d2_add:
1800
			.d2_add:
1799
			push eax
1801
			push eax
1800
				mov edi,[img_n]
1802
				mov edi,[img_n]
1801
				mov eax,[pb]
1803
				mov eax,[pb]
1802
				xor edx,edx
1804
				xor edx,edx
1803
				div dword[size_w] ;eax /= [size_w]
1805
				div dword[size_w] ;eax /= [size_w]
1804
				stosb
1806
				stosb
1805
				mov eax,[pg]
1807
				mov eax,[pg]
1806
				xor edx,edx
1808
				xor edx,edx
1807
				div dword[size_w] ;eax /= [size_w]
1809
				div dword[size_w] ;eax /= [size_w]
1808
				stosb
1810
				stosb
1809
				mov eax,[pr]
1811
				mov eax,[pr]
1810
				xor edx,edx
1812
				xor edx,edx
1811
				div dword[size_w] ;eax /= [size_w]
1813
				div dword[size_w] ;eax /= [size_w]
1812
				stosb
1814
				stosb
1813
			pop eax
1815
			pop eax
1814
			add dword[img_n],3 ;next pixel
1816
			add dword[img_n],3 ;next pixel
1815
			;®¡­®¢«ï¥¬ rgb ¤«ï ­®¢®£® ¯¨ªá¥«ï
1817
			;®¡­®¢«ï¥¬ rgb ¤«ï ­®¢®£® ¯¨ªá¥«ï
1816
			mov edx,eax
1818
			mov edx,eax
1817
			sub edx,ebx
1819
			sub edx,ebx
1818
			movzx edi,byte[esi]
1820
			movzx edi,byte[esi]
1819
			imul edi,edx
1821
			imul edi,edx
1820
			mov [pb],edi
1822
			mov [pb],edi
1821
			movzx edi,byte[esi+1]
1823
			movzx edi,byte[esi+1]
1822
			imul edi,edx
1824
			imul edi,edx
1823
			mov [pg],edi
1825
			mov [pg],edi
1824
			movzx edi,byte[esi+2]
1826
			movzx edi,byte[esi+2]
1825
			imul edi,edx
1827
			imul edi,edx
1826
			mov [pr],edi
1828
			mov [pr],edi
1827
			add ebx,[size_w]
1829
			add ebx,[size_w]
1828
		.if_0_end:
1830
		.if_0_end:
1829
		add eax,[size_w_new]
1831
		add eax,[size_w_new]
1830
		add esi,3 ;next pixel
1832
		add esi,3 ;next pixel
1831
		dec ecx
1833
		dec ecx
1832
		jnz .cycyle_1
1834
		jnz .cycyle_1
1833
	dec dword[lines]
1835
	dec dword[lines]
1834
	jnz .cycyle_0
1836
	jnz .cycyle_0
1835
popad
1837
popad
1836
	ret
1838
	ret
1837
endp
1839
endp
1838
 
1840
 
1839
;description:
1841
;description:
1840
; ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® ¢ëá®â¥ (à §¬¥àë ¡ãä¥à  ­¥ ¬¥­ïîâáï)
1842
; ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® ¢ëá®â¥ (à §¬¥àë ¡ãä¥à  ­¥ ¬¥­ïîâáï)
1841
;input:
1843
;input:
1842
; data_rgb - pointer to rgb data
1844
; data_rgb - pointer to rgb data
1843
; size_w - width img in pixels
1845
; size_w - width img in pixels
1844
; size_h - height img in pixels
1846
; size_h - height img in pixels
1845
; size_h_new - new height img in pixels
1847
; size_h_new - new height img in pixels
1846
align 16
1848
align 16
1847
proc img_rgb24_hresize, data_rgb:dword, size_w:dword, size_h:dword, size_h_new:dword
1849
proc img_rgb24_hresize, data_rgb:dword, size_w:dword, size_h:dword, size_h_new:dword
1848
locals
1850
locals
1849
	pr dd 0
1851
	pr dd 0
1850
	pg dd 0
1852
	pg dd 0
1851
	pb dd 0
1853
	pb dd 0
1852
	img_n dd ? ;㪠§ â¥«ì ­  ¤ ­­ë¥ ­®¢®£® ¨§®¡à ¦¥­¨ï
1854
	img_n dd ? ;㪠§ â¥«ì ­  ¤ ­­ë¥ ­®¢®£® ¨§®¡à ¦¥­¨ï
1853
	cols dd ?
1855
	cols dd ?
1854
	lin_b dd ? ;à §¬¥à «¨­¨¨ ¨§®¡à ¦¥­¨ï ¢ ¡ ©â å
1856
	lin_b dd ? ;à §¬¥à «¨­¨¨ ¨§®¡à ¦¥­¨ï ¢ ¡ ©â å
1855
	data_n dd ? ;㪠§ â¥«ì ­  ¤ ­­ë¥ ¤«ï ­®¢®£® á⮫¡æ  ¯¨ªá¥«¥©
1857
	data_n dd ? ;㪠§ â¥«ì ­  ¤ ­­ë¥ ¤«ï ­®¢®£® á⮫¡æ  ¯¨ªá¥«¥©
1856
endl
1858
endl
1857
pushad
1859
pushad
1858
;eax - delta for inp. img
1860
;eax - delta for inp. img
1859
;ebx - delta for outp. img
1861
;ebx - delta for outp. img
1860
;esi - pointer to data_rgb
1862
;esi - pointer to data_rgb
1861
	mov esi,[data_rgb]
1863
	mov esi,[data_rgb]
1862
	mov [data_n],esi
1864
	mov [data_n],esi
1863
	mov eax,[size_w]
1865
	mov eax,[size_w]
1864
	mov [cols],eax
1866
	mov [cols],eax
1865
	lea eax,[eax+eax*2]
1867
	lea eax,[eax+eax*2]
1866
	mov [lin_b],eax
1868
	mov [lin_b],eax
1867
align 4
1869
align 4
1868
	.cycyle_0:
1870
	.cycyle_0:
1869
	mov eax,[size_h_new]
1871
	mov eax,[size_h_new]
1870
	mov ecx,[size_h]
1872
	mov ecx,[size_h]
1871
	mov ebx,ecx
1873
	mov ebx,ecx
1872
	mov esi,[data_n]
1874
	mov esi,[data_n]
1873
	mov [img_n],esi
1875
	mov [img_n],esi
1874
	add dword[data_n],3 ;¯¥à¥å®¤ ­  á«¥¤ãî騩 á⮫¡¥æ ¯¨ªá¥«¥©
1876
	add dword[data_n],3 ;¯¥à¥å®¤ ­  á«¥¤ãî騩 á⮫¡¥æ ¯¨ªá¥«¥©
1875
align 4
1877
align 4
1876
	.cycyle_1:
1878
	.cycyle_1:
1877
		cmp eax,ebx
1879
		cmp eax,ebx
1878
		jg .else_0
1880
		jg .else_0
1879
			;ª®¯¨àã¥¬ë© ¯¨ªá¥«ì ¬ ªá¨¬ «ì­® ¢«¨ï¥â ­  १ã«ìâ â
1881
			;ª®¯¨àã¥¬ë© ¯¨ªá¥«ì ¬ ªá¨¬ «ì­® ¢«¨ï¥â ­  १ã«ìâ â
1880
			;­ ª ¯«¨¢ ¥¬ rgb ¤«ï ¨­â¥à¯®«ï樨 ¯¨ªá¥«¥©
1882
			;­ ª ¯«¨¢ ¥¬ rgb ¤«ï ¨­â¥à¯®«ï樨 ¯¨ªá¥«¥©
1881
			mov edx,[size_h_new]
1883
			mov edx,[size_h_new]
1882
			movzx edi,byte[esi]
1884
			movzx edi,byte[esi]
1883
			imul edi,edx
1885
			imul edi,edx
1884
			add [pb],edi
1886
			add [pb],edi
1885
			movzx edi,byte[esi+1]
1887
			movzx edi,byte[esi+1]
1886
			imul edi,edx
1888
			imul edi,edx
1887
			add [pg],edi
1889
			add [pg],edi
1888
			movzx edi,byte[esi+2]
1890
			movzx edi,byte[esi+2]
1889
			imul edi,edx
1891
			imul edi,edx
1890
			add [pr],edi
1892
			add [pr],edi
1891
			cmp eax,ebx
1893
			cmp eax,ebx
1892
			je .d2_add
1894
			je .d2_add
1893
			jmp .if_0_end
1895
			jmp .if_0_end
1894
		.else_0:
1896
		.else_0:
1895
			;ª®¯¨àã¥¬ë© ¯¨ªá¥«ì ¯®¯ ¤¥â ­  £à ­¨æã ¯¨ªá¥«¥©
1897
			;ª®¯¨àã¥¬ë© ¯¨ªá¥«ì ¯®¯ ¤¥â ­  £à ­¨æã ¯¨ªá¥«¥©
1896
			mov edx,ebx
1898
			mov edx,ebx
1897
			sub edx,eax
1899
			sub edx,eax
1898
			add edx,[size_h_new]
1900
			add edx,[size_h_new]
1899
			movzx edi,byte[esi]
1901
			movzx edi,byte[esi]
1900
			imul edi,edx
1902
			imul edi,edx
1901
			add [pb],edi
1903
			add [pb],edi
1902
			movzx edi,byte[esi+1]
1904
			movzx edi,byte[esi+1]
1903
			imul edi,edx
1905
			imul edi,edx
1904
			add [pg],edi
1906
			add [pg],edi
1905
			movzx edi,byte[esi+2]
1907
			movzx edi,byte[esi+2]
1906
			imul edi,edx
1908
			imul edi,edx
1907
			add [pr],edi
1909
			add [pr],edi
1908
			;á®å࠭塞 £®â®¢®¥ rgb
1910
			;á®å࠭塞 £®â®¢®¥ rgb
1909
			.d2_add:
1911
			.d2_add:
1910
			push eax
1912
			push eax
1911
				mov edi,[img_n]
1913
				mov edi,[img_n]
1912
				mov eax,[pb]
1914
				mov eax,[pb]
1913
				xor edx,edx
1915
				xor edx,edx
1914
				div dword[size_h] ;eax /= [size_h]
1916
				div dword[size_h] ;eax /= [size_h]
1915
				stosb
1917
				stosb
1916
				mov eax,[pg]
1918
				mov eax,[pg]
1917
				xor edx,edx
1919
				xor edx,edx
1918
				div dword[size_h] ;eax /= [size_h]
1920
				div dword[size_h] ;eax /= [size_h]
1919
				stosb
1921
				stosb
1920
				mov eax,[pr]
1922
				mov eax,[pr]
1921
				xor edx,edx
1923
				xor edx,edx
1922
				div dword[size_h] ;eax /= [size_h]
1924
				div dword[size_h] ;eax /= [size_h]
1923
				stosb
1925
				stosb
1924
			pop eax
1926
			pop eax
1925
			mov edx,[lin_b]
1927
			mov edx,[lin_b]
1926
			add dword[img_n],edx ;next pixel
1928
			add dword[img_n],edx ;next pixel
1927
			;®¡­®¢«ï¥¬ rgb ¤«ï ­®¢®£® ¯¨ªá¥«ï
1929
			;®¡­®¢«ï¥¬ rgb ¤«ï ­®¢®£® ¯¨ªá¥«ï
1928
			mov edx,eax
1930
			mov edx,eax
1929
			sub edx,ebx
1931
			sub edx,ebx
1930
			movzx edi,byte[esi]
1932
			movzx edi,byte[esi]
1931
			imul edi,edx
1933
			imul edi,edx
1932
			mov [pb],edi
1934
			mov [pb],edi
1933
			movzx edi,byte[esi+1]
1935
			movzx edi,byte[esi+1]
1934
			imul edi,edx
1936
			imul edi,edx
1935
			mov [pg],edi
1937
			mov [pg],edi
1936
			movzx edi,byte[esi+2]
1938
			movzx edi,byte[esi+2]
1937
			imul edi,edx
1939
			imul edi,edx
1938
			mov [pr],edi
1940
			mov [pr],edi
1939
			add ebx,[size_h]
1941
			add ebx,[size_h]
1940
		.if_0_end:
1942
		.if_0_end:
1941
		add eax,[size_h_new]
1943
		add eax,[size_h_new]
1942
		add esi,[lin_b] ;next pixel
1944
		add esi,[lin_b] ;next pixel
1943
		dec ecx
1945
		dec ecx
1944
		jnz .cycyle_1
1946
		jnz .cycyle_1
1945
	dec dword[cols]
1947
	dec dword[cols]
1946
	jnz .cycyle_0
1948
	jnz .cycyle_0
1947
popad
1949
popad
1948
	ret
1950
	ret
1949
endp
1951
endp
1950
 
1952
 
1951
;¯à¥®¡à §®¢ ­¨¥ ¡ãä¥à  ¨§ 24-¡¨â­®£® ¢ 8-¡¨â­ë©
1953
;¯à¥®¡à §®¢ ­¨¥ ¡ãä¥à  ¨§ 24-¡¨â­®£® ¢ 8-¡¨â­ë©
1952
; spectr - ®¯à¥¤¥«ï¥â ª ª®© ᯥªâà ¡à âì ¯à¨ ¯à¥®¡à §®¢ ­¨¨ 0-ᨭ¨©, 1-§¥«¥­ë©, 2-ªà á­ë©
1954
; spectr - ®¯à¥¤¥«ï¥â ª ª®© ᯥªâà ¡à âì ¯à¨ ¯à¥®¡à §®¢ ­¨¨ 0-ᨭ¨©, 1-§¥«¥­ë©, 2-ªà á­ë©
1953
align 4
1955
align 4
1954
proc buf_conv_24_to_8, buf_struc:dword, spectr:dword
1956
proc buf_conv_24_to_8, buf_struc:dword, spectr:dword
1955
	pushad
1957
	pushad
1956
	mov edi,dword[buf_struc]
1958
	mov edi,dword[buf_struc]
1957
	cmp buf2d_bits,24
1959
	cmp buf2d_bits,24
1958
	jne .error0
1960
	jne .error0
1959
		mov eax,buf2d_w
1961
		mov eax,buf2d_w
1960
		cmp eax,1
1962
		cmp eax,1
1961
		jl .error1
1963
		jl .error1
1962
		mov ecx,buf2d_h
1964
		mov ecx,buf2d_h
1963
		cmp ecx,1
1965
		cmp ecx,1
1964
		jl .error1
1966
		jl .error1
1965
		imul ecx,eax
1967
		imul ecx,eax
1966
		mov esi,ecx
1968
		mov esi,ecx
1967
		;ebx - ¯ ¬ïâì ¨§ ª®â®à®© ª®¯¨àã¥âáï
1969
		;ebx - ¯ ¬ïâì ¨§ ª®â®à®© ª®¯¨àã¥âáï
1968
		;edx - ¯ ¬ïâì ªã¤  ª®¯¨àã¥âáï
1970
		;edx - ¯ ¬ïâì ªã¤  ª®¯¨àã¥âáï
1969
		mov edx,buf2d_data
1971
		mov edx,buf2d_data
1970
		mov ebx,edx
1972
		mov ebx,edx
1971
		cmp [spectr],3
1973
		cmp [spectr],3
1972
		jge @f
1974
		jge @f
1973
			add ebx,[spectr]
1975
			add ebx,[spectr]
1974
		@@:
1976
		@@:
1975
			mov al,byte[ebx]
1977
			mov al,byte[ebx]
1976
			mov byte[edx],al
1978
			mov byte[edx],al
1977
			add ebx,3
1979
			add ebx,3
1978
			inc edx
1980
			inc edx
1979
			loop @b
1981
			loop @b
1980
		mov buf2d_bits,8
1982
		mov buf2d_bits,8
1981
		invoke mem.realloc,buf2d_data,esi ;㬥­ìè ¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
1983
		invoke mem.realloc,buf2d_data,esi ;㬥­ìè ¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
1982
		jmp .end_conv
1984
		jmp .end_conv
1983
	.error0:
1985
	.error0:
1984
		stdcall print_err,sz_buf2d_conv_24_to_8,txt_err_n24b
1986
		stdcall print_err,sz_buf2d_conv_24_to_8,txt_err_n24b
1985
		jmp .end_conv
1987
		jmp .end_conv
1986
	.error1:
1988
	.error1:
1987
		stdcall print_err,sz_buf2d_conv_24_to_8,txt_err_size_0
1989
		stdcall print_err,sz_buf2d_conv_24_to_8,txt_err_size_0
1988
	.end_conv:
1990
	.end_conv:
1989
	popad
1991
	popad
1990
	ret
1992
	ret
1991
endp
1993
endp
1992
 
1994
 
1993
;¯à¥®¡à §®¢ ­¨¥ ¡ãä¥à  ¨§ 24-¡¨â­®£® ¢ 32-¡¨â­ë©
1995
;¯à¥®¡à §®¢ ­¨¥ ¡ãä¥à  ¨§ 24-¡¨â­®£® ¢ 32-¡¨â­ë©
1994
align 4
1996
align 4
1995
proc buf_conv_24_to_32, buf_struc:dword, buf_str8:dword
1997
proc buf_conv_24_to_32, buf_struc:dword, buf_str8:dword
1996
	pushad
1998
	pushad
1997
	mov edi,dword[buf_struc]
1999
	mov edi,dword[buf_struc]
1998
	cmp buf2d_bits,24
2000
	cmp buf2d_bits,24
1999
	jne .error1
2001
	jne .error1
2000
		mov ecx,buf2d_w
2002
		mov ecx,buf2d_w
2001
		mov ebx,buf2d_h
2003
		mov ebx,buf2d_h
2002
		imul ebx,ecx
2004
		imul ebx,ecx
2003
		mov ecx,ebx ;ecx = size  8 b
2005
		mov ecx,ebx ;ecx = size  8 b
2004
		shl ebx,2   ;ebx = size 32 b
2006
		shl ebx,2   ;ebx = size 32 b
2005
		invoke mem.realloc,buf2d_data,ebx ;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
2007
		invoke mem.realloc,buf2d_data,ebx ;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì § ­¨¬ ¥¬ãî ¡ãä¥à®¬
2006
		mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
2008
		mov buf2d_data,eax ;­  á«ãç © ¥á«¨ ¨§¬¥­¨«áï 㪠§ â¥«ì ­  ¤ ­­ë¥
2007
		mov buf2d_bits,32
2009
		mov buf2d_bits,32
2008
		mov edx,ebx ;edx = size 32 b
2010
		mov edx,ebx ;edx = size 32 b
2009
		sub ebx,ecx ;ebx = size 24 b
2011
		sub ebx,ecx ;ebx = size 24 b
2010
		mov eax,ecx
2012
		mov eax,ecx
2011
		;eax - à §¬¥à  8 ¡¨â­ëå ¤ ­­ëå
2013
		;eax - à §¬¥à  8 ¡¨â­ëå ¤ ­­ëå
2012
		;ebx - à §¬¥à 24 ¡¨â­ëå ¤ ­­ëå
2014
		;ebx - à §¬¥à 24 ¡¨â­ëå ¤ ­­ëå
2013
		;edx - à §¬¥à 32 ¡¨â­ëå ¤ ­­ëå
2015
		;edx - à §¬¥à 32 ¡¨â­ëå ¤ ­­ëå
2014
		add ebx,buf2d_data
2016
		add ebx,buf2d_data
2015
		add edx,buf2d_data
2017
		add edx,buf2d_data
2016
		mov edi,dword[buf_str8]
2018
		mov edi,dword[buf_str8]
2017
		cmp buf2d_bits,8
2019
		cmp buf2d_bits,8
2018
		jne .error2
2020
		jne .error2
2019
		add eax,buf2d_data
2021
		add eax,buf2d_data
2020
		mov edi,edx
2022
		mov edi,edx
2021
		;eax - 㪠§ â¥«ì ­  ª®­¥æ  8 ¡¨â­ëå ¤ ­­ëå
2023
		;eax - 㪠§ â¥«ì ­  ª®­¥æ  8 ¡¨â­ëå ¤ ­­ëå
2022
		;ebx - 㪠§ â¥«ì ­  ª®­¥æ 24 ¡¨â­ëå ¤ ­­ëå
2024
		;ebx - 㪠§ â¥«ì ­  ª®­¥æ 24 ¡¨â­ëå ¤ ­­ëå
2023
		;edi - 㪠§ â¥«ì ­  ª®­¥æ 32 ¡¨â­ëå ¤ ­­ëå
2025
		;edi - 㪠§ â¥«ì ­  ª®­¥æ 32 ¡¨â­ëå ¤ ­­ëå
2024
		@@:
2026
		@@:
2025
			sub edi,4 ;®â­¨¬ ¥¬ ¢ ­ ç «¥ 横« ,
2027
			sub edi,4 ;®â­¨¬ ¥¬ ¢ ­ ç «¥ 横« ,
2026
			sub ebx,3 ; ¯®â®¬ã, ç⮠㪠§ â¥«¨ áâ®ïâ
2028
			sub ebx,3 ; ¯®â®¬ã, ç⮠㪠§ â¥«¨ áâ®ïâ
2027
			dec eax   ; §  ¯à¥¤¥« ¬¨ ¡ãä¥à®¢
2029
			dec eax   ; §  ¯à¥¤¥« ¬¨ ¡ãä¥à®¢
2028
			mov edx,dword[ebx]
2030
			mov edx,dword[ebx]
2029
			mov dword[edi],edx
2031
			mov dword[edi],edx
2030
			mov dl,byte[eax]
2032
			mov dl,byte[eax]
2031
			mov byte[edi+3],dl
2033
			mov byte[edi+3],dl
2032
			loop @b
2034
			loop @b
2033
 
2035
 
2034
		jmp .end_conv
2036
		jmp .end_conv
2035
	.error1:
2037
	.error1:
2036
		stdcall print_err,sz_buf2d_conv_24_to_32,txt_err_n24b
2038
		stdcall print_err,sz_buf2d_conv_24_to_32,txt_err_n24b
2037
		jmp .end_conv
2039
		jmp .end_conv
2038
	.error2:
2040
	.error2:
2039
		stdcall print_err,sz_buf2d_conv_24_to_32,txt_err_n8b
2041
		stdcall print_err,sz_buf2d_conv_24_to_32,txt_err_n8b
2040
	.end_conv:
2042
	.end_conv:
2041
	popad
2043
	popad
2042
	ret
2044
	ret
2043
endp
2045
endp
2044
 
2046
 
2045
;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (24b|32b) ¢ buf_destination (24b)
2047
;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (24b|32b) ¢ buf_destination (24b)
2046
; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
2048
; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
2047
; ¯à®§à ç­®áâì ¯à¨ ª®¯¨à®¢ ­¨¨ ­¥ ãç¨â뢠¥âáï
2049
; ¯à®§à ç­®áâì ¯à¨ ª®¯¨à®¢ ­¨¨ ­¥ ãç¨â뢠¥âáï
2048
align 4
2050
align 4
2049
proc buf_bit_blt, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword
2051
proc buf_bit_blt, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword
2050
	locals
2052
	locals
2051
		right_bytes dd ?
2053
		right_bytes dd ?
2052
	endl
2054
	endl
2053
	pushad
2055
	pushad
2054
 
2056
 
2055
	mov edi,[buf_source]
2057
	mov edi,[buf_source]
2056
	cmp buf2d_bits,24
2058
	cmp buf2d_bits,24
2057
	je .sou24
2059
	je .sou24
2058
	cmp buf2d_bits,32
2060
	cmp buf2d_bits,32
2059
	je .sou32
2061
	je .sou32
2060
		jmp .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2062
		jmp .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2061
 
2063
 
2062
	.sou24: ;¢ ¨áâ®ç­¨ª¥ 24 ¡¨â­ ï ª à⨭ª 
2064
	.sou24: ;¢ ¨áâ®ç­¨ª¥ 24 ¡¨â­ ï ª à⨭ª 
2063
	mov eax,buf2d_w
2065
	mov eax,buf2d_w
2064
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2066
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2065
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2067
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2066
 
2068
 
2067
	mov edi,[buf_destination]
2069
	mov edi,[buf_destination]
2068
	cmp buf2d_bits,24
2070
	cmp buf2d_bits,24
2069
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2071
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2070
	mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
2072
	mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
2071
	cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
2073
	cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
2072
	jge .copy_end	  ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
2074
	jge .copy_end	  ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
2073
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2075
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2074
		mov ecx,[coord_y]
2076
		mov ecx,[coord_y]
2075
		cmp ecx,0
2077
		cmp ecx,0
2076
		jge @f
2078
		jge @f
2077
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2079
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2078
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2080
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2079
			cmp edx,0
2081
			cmp edx,0
2080
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2082
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2081
			neg ecx
2083
			neg ecx
2082
			;inc ecx
2084
			;inc ecx
2083
			imul ecx,eax
2085
			imul ecx,eax
2084
			lea ecx,[ecx+ecx*2] ;¯® 3 ¡ ©â  ­  ¯¨ªá¥«ì
2086
			lea ecx,[ecx+ecx*2] ;¯® 3 ¡ ©â  ­  ¯¨ªá¥«ì
2085
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2087
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2086
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2088
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2087
		@@:
2089
		@@:
2088
		cmp ecx,ebx
2090
		cmp ecx,ebx
2089
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2091
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2090
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2092
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2091
		cmp ecx,ebx
2093
		cmp ecx,ebx
2092
		jle @f
2094
		jle @f
2093
			sub ecx,ebx
2095
			sub ecx,ebx
2094
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2096
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2095
		@@:
2097
		@@:
2096
		mov ebx,buf2d_w
2098
		mov ebx,buf2d_w
2097
		mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2099
		mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2098
		cmp ecx,0
2100
		cmp ecx,0
2099
		jg .end_otr_c_y_24
2101
		jg .end_otr_c_y_24
2100
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2102
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2101
			mov ecx,[coord_x]
2103
			mov ecx,[coord_x]
2102
			jmp @f
2104
			jmp @f
2103
		.end_otr_c_y_24:
2105
		.end_otr_c_y_24:
2104
		imul ecx,ebx
2106
		imul ecx,ebx
2105
		add ecx,[coord_x]
2107
		add ecx,[coord_x]
2106
		@@:
2108
		@@:
2107
		lea ecx,[ecx+ecx*2]
2109
		lea ecx,[ecx+ecx*2]
2108
		add ecx,buf2d_data
2110
		add ecx,buf2d_data
2109
		sub ebx,eax
2111
		sub ebx,eax
2110
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2112
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2111
 
2113
 
2112
	mov [right_bytes],0
2114
	mov [right_bytes],0
2113
	mov ecx,[coord_x]
2115
	mov ecx,[coord_x]
2114
	cmp ecx,ebx
2116
	cmp ecx,ebx
2115
	jl @f
2117
	jl @f
2116
		sub ecx,ebx
2118
		sub ecx,ebx
2117
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2119
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2118
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2120
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2119
		lea ecx,[ecx+ecx*2] ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2121
		lea ecx,[ecx+ecx*2] ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2120
		mov [right_bytes],ecx
2122
		mov [right_bytes],ecx
2121
	@@:
2123
	@@:
2122
 
2124
 
2123
	lea eax,[eax+eax*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2125
	lea eax,[eax+eax*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2124
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2126
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2125
 
2127
 
2126
	cld
2128
	cld
2127
	cmp [right_bytes],0
2129
	cmp [right_bytes],0
2128
	jg .copy_1
2130
	jg .copy_1
2129
	.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2131
	.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2130
		mov ecx,eax
2132
		mov ecx,eax
2131
		rep movsb
2133
		rep movsb
2132
		add edi,ebx
2134
		add edi,ebx
2133
		dec edx
2135
		dec edx
2134
		cmp edx,0
2136
		cmp edx,0
2135
		jg .copy_0
2137
		jg .copy_0
2136
	jmp .copy_end
2138
	jmp .copy_end
2137
	.copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
2139
	.copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
2138
		mov ecx,eax
2140
		mov ecx,eax
2139
		rep movsb
2141
		rep movsb
2140
		add edi,ebx
2142
		add edi,ebx
2141
		add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2143
		add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2142
		dec edx
2144
		dec edx
2143
		cmp edx,0
2145
		cmp edx,0
2144
		jg .copy_1
2146
		jg .copy_1
2145
	jmp .copy_end
2147
	jmp .copy_end
2146
 
2148
 
2147
	.sou32: ;¢ ¨áâ®ç­¨ª¥ 32 ¡¨â­ ï ª à⨭ª 
2149
	.sou32: ;¢ ¨áâ®ç­¨ª¥ 32 ¡¨â­ ï ª à⨭ª 
2148
	mov eax,buf2d_w
2150
	mov eax,buf2d_w
2149
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2151
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2150
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2152
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2151
 
2153
 
2152
	mov edi,[buf_destination]
2154
	mov edi,[buf_destination]
2153
	cmp buf2d_bits,24
2155
	cmp buf2d_bits,24
2154
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2156
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2155
	mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
2157
	mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
2156
	cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
2158
	cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
2157
	jge .copy_end	  ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
2159
	jge .copy_end	  ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
2158
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2160
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2159
		mov ecx,[coord_y]
2161
		mov ecx,[coord_y]
2160
		cmp ecx,0
2162
		cmp ecx,0
2161
		jge @f
2163
		jge @f
2162
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2164
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2163
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2165
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2164
			cmp edx,0
2166
			cmp edx,0
2165
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2167
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2166
			neg ecx
2168
			neg ecx
2167
			;inc ecx
2169
			;inc ecx
2168
			imul ecx,eax
2170
			imul ecx,eax
2169
			shl ecx,2 ;¯® 4 ¡ ©â  ­  ¯¨ªá¥«ì
2171
			shl ecx,2 ;¯® 4 ¡ ©â  ­  ¯¨ªá¥«ì
2170
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2172
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2171
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2173
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2172
		@@:
2174
		@@:
2173
		cmp ecx,ebx
2175
		cmp ecx,ebx
2174
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2176
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2175
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2177
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2176
		cmp ecx,ebx
2178
		cmp ecx,ebx
2177
		jle @f
2179
		jle @f
2178
			sub ecx,ebx
2180
			sub ecx,ebx
2179
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2181
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2180
		@@:
2182
		@@:
2181
		mov ebx,buf2d_w
2183
		mov ebx,buf2d_w
2182
		;mov ecx,ebx ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2184
		;mov ecx,ebx ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2183
		;imul ecx,[coord_y]
2185
		;imul ecx,[coord_y]
2184
		;add ecx,[coord_x]
2186
		;add ecx,[coord_x]
2185
		mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2187
		mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2186
		cmp ecx,0
2188
		cmp ecx,0
2187
		jg .end_otr_c_y_32
2189
		jg .end_otr_c_y_32
2188
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2190
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2189
			mov ecx,[coord_x]
2191
			mov ecx,[coord_x]
2190
			jmp @f
2192
			jmp @f
2191
		.end_otr_c_y_32:
2193
		.end_otr_c_y_32:
2192
		imul ecx,ebx
2194
		imul ecx,ebx
2193
		add ecx,[coord_x]
2195
		add ecx,[coord_x]
2194
		@@:
2196
		@@:
2195
		lea ecx,[ecx+ecx*2]
2197
		lea ecx,[ecx+ecx*2]
2196
		add ecx,buf2d_data
2198
		add ecx,buf2d_data
2197
		sub ebx,eax
2199
		sub ebx,eax
2198
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2200
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2199
 
2201
 
2200
	mov [right_bytes],0
2202
	mov [right_bytes],0
2201
	mov ecx,[coord_x]
2203
	mov ecx,[coord_x]
2202
	cmp ecx,ebx
2204
	cmp ecx,ebx
2203
	jl @f
2205
	jl @f
2204
		sub ecx,ebx
2206
		sub ecx,ebx
2205
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2207
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2206
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2208
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2207
		shl ecx,2 ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2209
		shl ecx,2 ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2208
		mov [right_bytes],ecx
2210
		mov [right_bytes],ecx
2209
	@@:
2211
	@@:
2210
 
2212
 
2211
	;eax - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2213
	;eax - ª®««¨ç¥á⢮ ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2212
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2214
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2213
 
2215
 
2214
	cld
2216
	cld
2215
	cmp [right_bytes],0
2217
	cmp [right_bytes],0
2216
	jg .copy_3
2218
	jg .copy_3
2217
	.copy_2: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2219
	.copy_2: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2218
		mov ecx,eax
2220
		mov ecx,eax
2219
		@@:
2221
		@@:
2220
			movsw
2222
			movsw
2221
			movsb
2223
			movsb
2222
			inc esi
2224
			inc esi
2223
			loop @b
2225
			loop @b
2224
		add edi,ebx
2226
		add edi,ebx
2225
		dec edx
2227
		dec edx
2226
		cmp edx,0
2228
		cmp edx,0
2227
		jg .copy_2
2229
		jg .copy_2
2228
	jmp .copy_end
2230
	jmp .copy_end
2229
	.copy_3: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
2231
	.copy_3: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
2230
		mov ecx,eax
2232
		mov ecx,eax
2231
		@@:
2233
		@@:
2232
			movsw
2234
			movsw
2233
			movsb
2235
			movsb
2234
			inc esi
2236
			inc esi
2235
			loop @b
2237
			loop @b
2236
		add edi,ebx
2238
		add edi,ebx
2237
		add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2239
		add esi,[right_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2238
		dec edx
2240
		dec edx
2239
		cmp edx,0
2241
		cmp edx,0
2240
		jg .copy_3
2242
		jg .copy_3
2241
 
2243
 
2242
	.copy_end:
2244
	.copy_end:
2243
	popad
2245
	popad
2244
	ret
2246
	ret
2245
endp
2247
endp
2246
 
2248
 
2247
;input:
2249
;input:
2248
; esi = pointer to color1 + transparent
2250
; esi = pointer to color1 + transparent
2249
; edi = pointer to background color2
2251
; edi = pointer to background color2
2250
;output:
2252
;output:
2251
; [edi] = combine color
2253
; [edi] = combine color
2252
align 4
2254
align 4
2253
combine_colors_0:
2255
combine_colors_0:
2254
	push ax bx cx dx
2256
	push ax bx cx dx
2255
	mov bx,0x00ff ;---get transparent---
2257
	mov bx,0x00ff ;---get transparent---
2256
	movzx cx,byte[esi+3] ;pro
2258
	movzx cx,byte[esi+3] ;pro
2257
	sub bx,cx ;256-pro
2259
	sub bx,cx ;256-pro
2258
	;---blye---
2260
	;---blye---
2259
	movzx ax,byte[esi]
2261
	movzx ax,byte[esi]
2260
	imul ax,bx
2262
	imul ax,bx
2261
	movzx dx,byte[edi]
2263
	movzx dx,byte[edi]
2262
	imul dx,cx
2264
	imul dx,cx
2263
	add ax,dx
2265
	add ax,dx
2264
	mov byte[edi],ah
2266
	mov byte[edi],ah
2265
	;---green---
2267
	;---green---
2266
	movzx ax,byte[esi+1]
2268
	movzx ax,byte[esi+1]
2267
	imul ax,bx
2269
	imul ax,bx
2268
	movzx dx,byte[edi+1]
2270
	movzx dx,byte[edi+1]
2269
	imul dx,cx
2271
	imul dx,cx
2270
	add ax,dx
2272
	add ax,dx
2271
	mov byte[edi+1],ah
2273
	mov byte[edi+1],ah
2272
	;---red---
2274
	;---red---
2273
	movzx ax,byte[esi+2]
2275
	movzx ax,byte[esi+2]
2274
	imul ax,bx
2276
	imul ax,bx
2275
	movzx dx,byte[edi+2]
2277
	movzx dx,byte[edi+2]
2276
	imul dx,cx
2278
	imul dx,cx
2277
	add ax,dx
2279
	add ax,dx
2278
	mov byte[edi+2],ah
2280
	mov byte[edi+2],ah
2279
 
2281
 
2280
	pop dx cx bx ax
2282
	pop dx cx bx ax
2281
	ret
2283
	ret
2282
 
2284
 
2283
;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (32b) ¢ buf_destination (24b)
2285
;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (32b) ¢ buf_destination (24b)
2284
; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
2286
; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
2285
; ¯à¨ ª®¯¨à®¢ ­¨¨ ãç¨â뢠¥âáï ¯à®§à ç­®áâì
2287
; ¯à¨ ª®¯¨à®¢ ­¨¨ ãç¨â뢠¥âáï ¯à®§à ç­®áâì
2286
align 4
2288
align 4
2287
proc buf_bit_blt_transp, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword
2289
proc buf_bit_blt_transp, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword
2288
	locals
2290
	locals
2289
		lost_bytes dd ?
2291
		lost_bytes dd ?
2290
	endl
2292
	endl
2291
	pushad
2293
	pushad
2292
 
2294
 
2293
	mov edi,[buf_source]
2295
	mov edi,[buf_source]
2294
	cmp buf2d_bits,32
2296
	cmp buf2d_bits,32
2295
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2297
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2296
	mov eax,buf2d_w
2298
	mov eax,buf2d_w
2297
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2299
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2298
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2300
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2299
 
2301
 
2300
	mov edi,[buf_destination]
2302
	mov edi,[buf_destination]
2301
	cmp buf2d_bits,24
2303
	cmp buf2d_bits,24
2302
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2304
	jne .copy_end ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2303
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2305
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2304
		mov ecx,[coord_y]
2306
		mov ecx,[coord_y]
2305
		cmp ecx,0
2307
		cmp ecx,0
2306
		jge @f
2308
		jge @f
2307
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2309
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2308
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2310
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2309
			cmp edx,0
2311
			cmp edx,0
2310
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2312
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2311
			neg ecx
2313
			neg ecx
2312
			;inc ecx
2314
			;inc ecx
2313
			imul ecx,eax
2315
			imul ecx,eax
2314
			shl ecx,2 ;¯® 4 ¡ ©â  ­  ¯¨ªá¥«ì
2316
			shl ecx,2 ;¯® 4 ¡ ©â  ­  ¯¨ªá¥«ì
2315
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2317
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2316
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2318
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2317
		@@:
2319
		@@:
2318
		cmp ecx,ebx
2320
		cmp ecx,ebx
2319
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2321
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2320
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2322
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2321
		cmp ecx,ebx
2323
		cmp ecx,ebx
2322
		jle @f
2324
		jle @f
2323
			sub ecx,ebx
2325
			sub ecx,ebx
2324
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2326
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2325
		@@:
2327
		@@:
2326
		mov ebx,buf2d_w
2328
		mov ebx,buf2d_w
2327
		mov ecx,ebx ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2329
		mov ecx,ebx ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2328
		cmp [coord_y],0
2330
		cmp [coord_y],0
2329
		jg .end_otr_c_y
2331
		jg .end_otr_c_y
2330
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2332
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2331
			mov ecx,[coord_x]
2333
			mov ecx,[coord_x]
2332
			jmp @f
2334
			jmp @f
2333
		.end_otr_c_y:
2335
		.end_otr_c_y:
2334
		imul ecx,[coord_y]
2336
		imul ecx,[coord_y]
2335
		add ecx,[coord_x]
2337
		add ecx,[coord_x]
2336
		@@:
2338
		@@:
2337
		lea ecx,[ecx+ecx*2]
2339
		lea ecx,[ecx+ecx*2]
2338
		add ecx,buf2d_data
2340
		add ecx,buf2d_data
2339
		sub ebx,eax
2341
		sub ebx,eax
2340
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2342
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2341
 
2343
 
2342
	mov dword[lost_bytes],0
2344
	mov dword[lost_bytes],0
2343
	mov ecx,[coord_x]
2345
	mov ecx,[coord_x]
2344
	cmp ecx,0
2346
	cmp ecx,0
2345
	jge @f
2347
	jge @f
2346
		neg ecx
2348
		neg ecx
2347
		;inc ecx
2349
		;inc ecx
2348
		cmp eax,ecx ;eax - è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
2350
		cmp eax,ecx ;eax - è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
2349
		jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî §  «¥¢®© £à ­¨æ¥© ¡ãä¥à  (coord_x<0 ¨ |coord_x|>buf_source.w)
2351
		jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî §  «¥¢®© £à ­¨æ¥© ¡ãä¥à  (coord_x<0 ¨ |coord_x|>buf_source.w)
2350
		shl ecx,2
2352
		shl ecx,2
2351
		mov [lost_bytes],ecx
2353
		mov [lost_bytes],ecx
2352
		add esi,ecx
2354
		add esi,ecx
2353
		shr ecx,2
2355
		shr ecx,2
2354
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2356
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2355
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2357
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2356
		lea ecx,[ecx+ecx*2]
2358
		lea ecx,[ecx+ecx*2]
2357
		add edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2359
		add edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2358
		xor ecx,ecx
2360
		xor ecx,ecx
2359
	@@:
2361
	@@:
2360
	cmp ecx,ebx
2362
	cmp ecx,ebx
2361
	jle @f
2363
	jle @f
2362
		sub ecx,ebx
2364
		sub ecx,ebx
2363
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2365
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2364
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2366
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2365
		shl ecx,2 ;ecx - ç¨á«® ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2367
		shl ecx,2 ;ecx - ç¨á«® ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2366
		add [lost_bytes],ecx
2368
		add [lost_bytes],ecx
2367
	@@:
2369
	@@:
2368
 
2370
 
2369
;	mov [right_bytes],0
2371
;	mov [right_bytes],0
2370
;	mov ecx,[coord_x]
2372
;	mov ecx,[coord_x]
2371
;	cmp ecx,ebx
2373
;	cmp ecx,ebx
2372
;	jl @f
2374
;	jl @f
2373
;		sub ecx,ebx
2375
;		sub ecx,ebx
2374
;		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2376
;		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2375
;		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2377
;		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2376
;		shl ecx,2 ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2378
;		shl ecx,2 ;ecx - ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2377
;		mov [right_bytes],ecx
2379
;		mov [right_bytes],ecx
2378
;	@@:
2380
;	@@:
2379
 
2381
 
2380
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2382
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2381
 
2383
 
2382
	cld
2384
	cld
2383
	cmp [lost_bytes],0
2385
	cmp [lost_bytes],0
2384
	jg .copy_1
2386
	jg .copy_1
2385
	.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2387
	.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2386
		mov ecx,eax
2388
		mov ecx,eax
2387
		@@:
2389
		@@:
2388
			call combine_colors_0
2390
			call combine_colors_0
2389
			add edi,3
2391
			add edi,3
2390
			add esi,4
2392
			add esi,4
2391
			loop @b
2393
			loop @b
2392
		add edi,ebx
2394
		add edi,ebx
2393
		dec edx
2395
		dec edx
2394
		cmp edx,0
2396
		cmp edx,0
2395
		jg .copy_0
2397
		jg .copy_0
2396
	jmp .copy_end
2398
	jmp .copy_end
2397
	.copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
2399
	.copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã)
2398
		mov ecx,eax
2400
		mov ecx,eax
2399
		@@:
2401
		@@:
2400
			call combine_colors_0
2402
			call combine_colors_0
2401
			add edi,3
2403
			add edi,3
2402
			add esi,4
2404
			add esi,4
2403
			loop @b
2405
			loop @b
2404
		add edi,ebx
2406
		add edi,ebx
2405
		add esi,[lost_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2407
		add esi,[lost_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2406
		dec edx
2408
		dec edx
2407
		cmp edx,0
2409
		cmp edx,0
2408
		jg .copy_1
2410
		jg .copy_1
2409
 
2411
 
2410
	.copy_end:
2412
	.copy_end:
2411
	popad
2413
	popad
2412
	ret
2414
	ret
2413
endp
2415
endp
2414
 
2416
 
2415
;input:
2417
;input:
2416
; ebx - color1
2418
; ebx - color1
2417
; esi = pointer to transparent
2419
; esi = pointer to transparent
2418
; edi = pointer to background color2
2420
; edi = pointer to background color2
2419
;output:
2421
;output:
2420
; [edi] = combine color
2422
; [edi] = combine color
2421
align 4
2423
align 4
2422
combine_colors_2:
2424
combine_colors_2:
2423
	push ax ebx cx dx si
2425
	push ax ebx cx dx si
2424
	mov cl,byte[esi] ;pro
2426
	mov cl,byte[esi] ;pro
2425
	xor ch,ch
2427
	xor ch,ch
2426
	mov si,0x00ff ;---get transparent---
2428
	mov si,0x00ff ;---get transparent---
2427
	sub si,cx ;256-pro
2429
	sub si,cx ;256-pro
2428
 
2430
 
2429
		;---blye---
2431
		;---blye---
2430
		movzx ax,bl
2432
		movzx ax,bl
2431
		shr ebx,8
2433
		shr ebx,8
2432
		imul ax,si
2434
		imul ax,si
2433
		movzx dx,byte[edi]
2435
		movzx dx,byte[edi]
2434
		imul dx,cx
2436
		imul dx,cx
2435
		add ax,dx
2437
		add ax,dx
2436
		mov byte[edi],ah
2438
		mov byte[edi],ah
2437
		;---green---
2439
		;---green---
2438
		movzx ax,bl
2440
		movzx ax,bl
2439
		shr ebx,8
2441
		shr ebx,8
2440
		imul ax,si
2442
		imul ax,si
2441
		movzx dx,byte[edi+1]
2443
		movzx dx,byte[edi+1]
2442
		imul dx,cx
2444
		imul dx,cx
2443
		add ax,dx
2445
		add ax,dx
2444
		mov byte[edi+1],ah
2446
		mov byte[edi+1],ah
2445
		;---red---
2447
		;---red---
2446
		movzx ax,bl
2448
		movzx ax,bl
2447
		imul ax,si
2449
		imul ax,si
2448
		movzx dx,byte[edi+2]
2450
		movzx dx,byte[edi+2]
2449
		imul dx,cx
2451
		imul dx,cx
2450
		add ax,dx
2452
		add ax,dx
2451
		mov byte[edi+2],ah
2453
		mov byte[edi+2],ah
2452
 
2454
 
2453
	pop si dx cx ebx ax
2455
	pop si dx cx ebx ax
2454
	ret
2456
	ret
2455
 
2457
 
2456
;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (8b) ¢ buf_destination (24b)
2458
;äã­ªæ¨ï ª®¯¨àã¥â ¨§®¡à ¦¥­¨¥ ¨§ ¡ãä¥à  buf_source (8b) ¢ buf_destination (24b)
2457
; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
2459
; 㪠§ë¢ îâáï ª®®à¤¨­ âë ¢áâ ¢ª¨ ¡ãä¥à  buf_source ®â­®á¨â¥«ì­® buf_destination
2458
align 4
2460
align 4
2459
proc buf_bit_blt_alpha, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword, color:dword
2461
proc buf_bit_blt_alpha, buf_destination:dword, coord_x:dword, coord_y:dword, buf_source:dword, color:dword
2460
	locals
2462
	locals
2461
		lost_bytes dd ? ;ç¨á«® ¯®â¥àï­­ëå ¡ ©â®¢ ¢ áâப¥ ª®¯¨à㥬®£® ¨§®¡à ¦¥­ï (â¥å çâ® ­¥ ¢« §ïâ ¢ ¡ãä¥à)
2463
		lost_bytes dd ? ;ç¨á«® ¯®â¥àï­­ëå ¡ ©â®¢ ¢ áâப¥ ª®¯¨à㥬®£® ¨§®¡à ¦¥­ï (â¥å çâ® ­¥ ¢« §ïâ ¢ ¡ãä¥à)
2462
		dest_w_bytes dd ? ;ª®««¨ç¥á⢮ ¡ ©â ¢ ¡ãä¥à¥ ¯à¨¥¬­¨ª¥ ¯® è¨à¨­¥ - è¨à¨­  ¢áâ ¢«ï¥¬®© ª à⨭ª¨
2464
		dest_w_bytes dd ? ;ª®««¨ç¥á⢮ ¡ ©â ¢ ¡ãä¥à¥ ¯à¨¥¬­¨ª¥ ¯® è¨à¨­¥ - è¨à¨­  ¢áâ ¢«ï¥¬®© ª à⨭ª¨
2463
	endl
2465
	endl
2464
	pushad
2466
	pushad
2465
 
2467
 
2466
	mov edi,[buf_source]
2468
	mov edi,[buf_source]
2467
	cmp buf2d_bits,8
2469
	cmp buf2d_bits,8
2468
	jne .error1 ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2470
	jne .error1 ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2469
	mov eax,buf2d_w ;è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
2471
	mov eax,buf2d_w ;è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
2470
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2472
	mov edx,buf2d_h ;¢ëá®â  ª®¯¨à㥬®© ª à⨭ª¨
2471
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2473
	mov esi,buf2d_data ;¤ ­­ë¥ ª®¯¨à㥬®© ª à⨭ª¨
2472
 
2474
 
2473
	mov edi,[buf_destination]
2475
	mov edi,[buf_destination]
2474
	cmp buf2d_bits,24
2476
	cmp buf2d_bits,24
2475
	jne .error2 ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2477
	jne .error2 ;ä®à¬ â ¡ãä¥à  ­¥ ¯®®¤¥à¦¨¢ ¥âáï
2476
	mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
2478
	mov ebx,[coord_x] ;¢ ebx ¢à¥¬¥­­® áâ ¢¨¬ ®âáâ㯠¨§®¡à ¦¥­¨ï (¤«ï ¯à®¢¥àª¨)
2477
	cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
2479
	cmp ebx,buf2d_w   ;¯à®¢¥à塞 ¢« §¨â «¨ ¨§®¡à ¦¥­¨¥ ¯® è¨à¨­¥
2478
	jge .copy_end	  ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
2480
	jge .copy_end	  ;¥á«¨ ¨§®¡à ¦¥­¨¥ ¯®«­®áâìî ¢ë« §¨â §  ¯à ¢ãî áâ®à®­ã
2479
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2481
		mov ebx,buf2d_h ;ebx - ¢ëá®â  ®á­®¢­®£® ¡ãä¥à 
2480
		mov ecx,[coord_y]
2482
		mov ecx,[coord_y]
2481
		cmp ecx,0
2483
		cmp ecx,0
2482
		jge @f
2484
		jge @f
2483
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2485
			;¥á«¨ ª®®à¤¨­ â  coord_y<0 (1-ï ­ áâனª )
2484
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2486
			add edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨
2485
			cmp edx,0
2487
			cmp edx,0
2486
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2488
			jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî ­ ¤ ¢¥àå­¥© £à ­¨æ¥© ¡ãä¥à  (coord_y<0 ¨ |coord_y|>buf_source.h)
2487
			neg ecx
2489
			neg ecx
2488
			;inc ecx
2490
			;inc ecx
2489
			imul ecx,eax
2491
			imul ecx,eax
2490
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2492
			add esi,ecx ;ᤢ¨£ ¥¬ 㪠§ â¥«ì á ª®¯¨à㥬묨 ¤ ­­ë¬¨, á ãç¥â®¬ ¯à®¯ã襭®© ç áâ¨
2491
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2493
			xor ecx,ecx ;®¡­ã«ï¥¬ ª®®à¤¨­ âã coord_y
2492
		@@:
2494
		@@:
2493
		cmp ecx,ebx
2495
		cmp ecx,ebx
2494
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2496
		jge .copy_end ;¥á«¨ ª®®à¤¨­ â  'y' ¡®«ìè¥ ¢ëá®âë ¡ãä¥à 
2495
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2497
		add ecx,edx ;ecx - ­¨¦­ïï ª®®à¤¨­ â  ª®¯¨à㥬®© ª à⨭ª¨
2496
		cmp ecx,ebx
2498
		cmp ecx,ebx
2497
		jle @f
2499
		jle @f
2498
			sub ecx,ebx
2500
			sub ecx,ebx
2499
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2501
			sub edx,ecx ;㬥­ìè ¥¬ ¢ëá®âã ª®¯¨à㥬®© ª à⨭ª¨, ¢ á«ãç¥ ª®£¤  ®­  ¢ë« §¨â §  ­¨¦­îî £à ­¨æã
2500
		@@:
2502
		@@:
2501
		mov ebx,buf2d_w
2503
		mov ebx,buf2d_w
2502
		mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2504
		mov ecx,[coord_y] ;ecx ¨á¯®«ì§ã¥¬ ¤«ï ¢à¥¬¥­­ëå 楫¥©
2503
		cmp ecx,0
2505
		cmp ecx,0
2504
		jg .end_otr_c_y
2506
		jg .end_otr_c_y
2505
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2507
			;¥á«¨ ª®®à¤¨­ â  coord_y<=0 (2-ï ­ áâனª )
2506
			mov ecx,[coord_x]
2508
			mov ecx,[coord_x]
2507
			jmp @f
2509
			jmp @f
2508
		.end_otr_c_y:
2510
		.end_otr_c_y:
2509
		imul ecx,ebx
2511
		imul ecx,ebx
2510
		add ecx,[coord_x]
2512
		add ecx,[coord_x]
2511
		@@:
2513
		@@:
2512
		lea ecx,[ecx+ecx*2]
2514
		lea ecx,[ecx+ecx*2]
2513
		add ecx,buf2d_data ;buf2d_data ¤ ­­ë¥ ®á­®¢­®£® ¡ãä¥à 
2515
		add ecx,buf2d_data ;buf2d_data ¤ ­­ë¥ ®á­®¢­®£® ¡ãä¥à 
2514
		sub ebx,eax ;ebx - è¨à¨­  ®á­®¢­®£® ¡ãä¥à  ¬¨­ãá è¨à¨­  à¨á㥬®£® ¡ãä¥à 
2516
		sub ebx,eax ;ebx - è¨à¨­  ®á­®¢­®£® ¡ãä¥à  ¬¨­ãá è¨à¨­  à¨á㥬®£® ¡ãä¥à 
2515
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2517
		mov edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2516
 
2518
 
2517
	mov dword[lost_bytes],0
2519
	mov dword[lost_bytes],0
2518
	mov ecx,[coord_x]
2520
	mov ecx,[coord_x]
2519
	cmp ecx,0
2521
	cmp ecx,0
2520
	jge @f
2522
	jge @f
2521
		neg ecx
2523
		neg ecx
2522
		;inc ecx
2524
		;inc ecx
2523
		cmp eax,ecx ;eax - è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
2525
		cmp eax,ecx ;eax - è¨à¨­  ª®¯¨à㥬®© ª à⨭ª¨
2524
		jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî §  «¥¢®© £à ­¨æ¥© ¡ãä¥à  (coord_x<0 ¨ |coord_x|>buf_source.w)
2526
		jle .copy_end ;¥á«¨ ª®¯¨à㥬®¥ ¨§®¡à ¦¥­¨¥ ­ å®¤¨âáï ¯®«­®áâìî §  «¥¢®© £à ­¨æ¥© ¡ãä¥à  (coord_x<0 ¨ |coord_x|>buf_source.w)
2525
		mov [lost_bytes],ecx
2527
		mov [lost_bytes],ecx
2526
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2528
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2527
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2529
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2528
		add esi,ecx
2530
		add esi,ecx
2529
		lea ecx,[ecx+ecx*2]
2531
		lea ecx,[ecx+ecx*2]
2530
		add edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2532
		add edi,ecx ;edi 㪠§ â¥«ì ­  ¤ ­­ë¥ ¡ãä¥à , ªã¤  ¡ã¤¥â ¯à®¨§¢®¤¨âáï ª®¯¨à®¢ ­¨¥
2531
		xor ecx,ecx
2533
		xor ecx,ecx
2532
	@@:
2534
	@@:
2533
	cmp ecx,ebx
2535
	cmp ecx,ebx
2534
	jle @f
2536
	jle @f
2535
		sub ecx,ebx
2537
		sub ecx,ebx
2536
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2538
		sub eax,ecx ;㪮à ç¨¢ ¥¬ ª®¯¨à㥬ãî áâபã
2537
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2539
		add ebx,ecx ;㤫¨­­ï¥¬ áâப㠤«ï ᤢ¨£  £« ¢­®© ª à⨭ª¨ ¡ãä¥à 
2538
		;ecx - ç¨á«® ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2540
		;ecx - ç¨á«® ¯¨ªá¥«¥© ¢ 1-© áâப¥ ª à⨭ª¨, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî áâ®à®­ã
2539
		add [lost_bytes],ecx
2541
		add [lost_bytes],ecx
2540
	@@:
2542
	@@:
2541
 
2543
 
2542
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2544
	lea ebx,[ebx+ebx*2] ;ª®««¨ç¥á⢮ ¡ ©â ¢ 1-© áâப¥ ¡ãä¥à  ¬¨­ãá ç¨á«® ¡ ©â ¢ 1-© áâப¥ ª®¯¨à㥬®© ª à⨭ª¨
2543
	mov [dest_w_bytes],ebx
2545
	mov [dest_w_bytes],ebx
2544
	mov ebx,[color]
2546
	mov ebx,[color]
2545
 
2547
 
2546
	cld
2548
	cld
2547
	cmp dword[lost_bytes],0
2549
	cmp dword[lost_bytes],0
2548
	jg .copy_1
2550
	jg .copy_1
2549
	.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2551
	.copy_0: ;¯à®á⮥ ª®¯¨à®¢ ­¨¥
2550
		mov ecx,eax
2552
		mov ecx,eax
2551
		@@:
2553
		@@:
2552
			call combine_colors_2
2554
			call combine_colors_2
2553
			add edi,3
2555
			add edi,3
2554
			inc esi
2556
			inc esi
2555
			loop @b
2557
			loop @b
2556
		add edi,[dest_w_bytes]
2558
		add edi,[dest_w_bytes]
2557
		dec edx
2559
		dec edx
2558
		cmp edx,0
2560
		cmp edx,0
2559
		jg .copy_0
2561
		jg .copy_0
2560
	jmp .copy_end
2562
	jmp .copy_end
2561
	.copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  «¥¢ãî ¨/¨«¨ ¯à ¢ãî áâ®à®­ã)
2563
	.copy_1: ;­¥ ¯à®á⮥ ª®¯¨à®¢ ­¨¥ (ª à⨭ª  ¢ë« §¨â §  «¥¢ãî ¨/¨«¨ ¯à ¢ãî áâ®à®­ã)
2562
		mov ecx,eax
2564
		mov ecx,eax
2563
		@@:
2565
		@@:
2564
			call combine_colors_2
2566
			call combine_colors_2
2565
			add edi,3
2567
			add edi,3
2566
			inc esi
2568
			inc esi
2567
			loop @b
2569
			loop @b
2568
		add edi,[dest_w_bytes]
2570
		add edi,[dest_w_bytes]
2569
		add esi,[lost_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2571
		add esi,[lost_bytes] ;¤®¡ ¢«ï¥¬ ¡ ©âë, ª®â®àë¥ ¢ë« §ïâ §  ¯à ¢ãî £à ­¨æã
2570
		dec edx
2572
		dec edx
2571
		cmp edx,0
2573
		cmp edx,0
2572
		jg .copy_1
2574
		jg .copy_1
2573
 
2575
 
2574
	jmp .copy_end
2576
	jmp .copy_end
2575
	.error1:
2577
	.error1:
2576
		stdcall print_err,sz_buf2d_bit_blt_alpha,txt_err_n8b
2578
		stdcall print_err,sz_buf2d_bit_blt_alpha,txt_err_n8b
2577
		jmp .copy_end
2579
		jmp .copy_end
2578
	.error2:
2580
	.error2:
2579
		stdcall print_err,sz_buf2d_bit_blt_alpha,txt_err_n24b
2581
		stdcall print_err,sz_buf2d_bit_blt_alpha,txt_err_n24b
2580
	.copy_end:
2582
	.copy_end:
2581
	popad
2583
	popad
2582
	ret
2584
	ret
2583
endp
2585
endp
2584
 
2586
 
2585
align 4
2587
align 4
2586
proc print_err, fun:dword, mes:dword ;¢ë¢®¤¨¬ á®®¡é¥­¨¥ ®¡ 訡ª¥ ­  ¤®áªã ®â« ¤ª¨
2588
proc print_err, fun:dword, mes:dword ;¢ë¢®¤¨¬ á®®¡é¥­¨¥ ®¡ 訡ª¥ ­  ¤®áªã ®â« ¤ª¨
2587
	pushad
2589
	pushad
2588
	mov eax,63
2590
	mov eax,63
2589
	mov ebx,1
2591
	mov ebx,1
2590
 
2592
 
2591
	mov esi,[fun]
2593
	mov esi,[fun]
2592
	@@:
2594
	@@:
2593
		mov cl,byte[esi]
2595
		mov cl,byte[esi]
2594
		int 0x40
2596
		int 0x40
2595
		inc esi
2597
		inc esi
2596
		cmp byte[esi],0
2598
		cmp byte[esi],0
2597
		jne @b
2599
		jne @b
2598
	mov cl,':'
2600
	mov cl,':'
2599
	int 0x40
2601
	int 0x40
2600
	mov cl,' '
2602
	mov cl,' '
2601
	int 0x40
2603
	int 0x40
2602
	mov esi,[mes]
2604
	mov esi,[mes]
2603
	@@:
2605
	@@:
2604
		mov cl,byte[esi]
2606
		mov cl,byte[esi]
2605
		int 0x40
2607
		int 0x40
2606
		inc esi
2608
		inc esi
2607
		cmp byte[esi],0
2609
		cmp byte[esi],0
2608
		jne @b
2610
		jne @b
2609
	popad
2611
	popad
2610
	ret
2612
	ret
2611
endp
2613
endp
2612
 
2614
 
2613
;䨫ìâà
2615
;䨫ìâà
2614
align 4
2616
align 4
2615
proc buf_filter_dither, buffer:dword, algor:dword
2617
proc buf_filter_dither, buffer:dword, algor:dword
2616
	pushad
2618
	pushad
2617
	mov edi,[buffer]
2619
	mov edi,[buffer]
2618
	cmp buf2d_bits,24
2620
	cmp buf2d_bits,24
2619
	jne .error
2621
	jne .error
2620
		mov edx,buf2d_w
2622
		mov edx,buf2d_w
2621
		mov esi,buf2d_h
2623
		mov esi,buf2d_h
2622
		mov edi,buf2d_data
2624
		mov edi,buf2d_data
2623
;edi - pointer to 24bit bitmap
2625
;edi - pointer to 24bit bitmap
2624
;edx - x size
2626
;edx - x size
2625
;esi - y size
2627
;esi - y size
2626
		lea   edx,[edx+edx*2]
2628
		lea   edx,[edx+edx*2]
2627
		imul  esi,edx
2629
		imul  esi,edx
2628
 
2630
 
2629
		;®¯à¥¤¥«ï¥¬ ª ª®©  «£®à¨â¬ ¨á¯®«ì§®¢ âì
2631
		;®¯à¥¤¥«ï¥¬ ª ª®©  «£®à¨â¬ ¨á¯®«ì§®¢ âì
2630
		cmp dword[algor],0
2632
		cmp dword[algor],0
2631
		jne @f
2633
		jne @f
2632
			call dither_0
2634
			call dither_0
2633
			jmp .dither_end
2635
			jmp .dither_end
2634
		@@:
2636
		@@:
2635
		cmp dword[algor],1
2637
		cmp dword[algor],1
2636
		jne @f
2638
		jne @f
2637
			call dither_1
2639
			call dither_1
2638
			jmp .dither_end
2640
			jmp .dither_end
2639
		@@:
2641
		@@:
2640
		cmp dword[algor],2
2642
		cmp dword[algor],2
2641
		jne @f
2643
		jne @f
2642
			call dither_2
2644
			call dither_2
2643
			jmp .dither_end
2645
			jmp .dither_end
2644
		@@:
2646
		@@:
2645
		cmp dword[algor],3
2647
		cmp dword[algor],3
2646
		jne @f
2648
		jne @f
2647
			call dither_3
2649
			call dither_3
2648
			jmp .dither_end
2650
			jmp .dither_end
2649
		@@:
2651
		@@:
2650
		call dither_4
2652
		call dither_4
2651
		jmp .dither_end
2653
		jmp .dither_end
2652
	.error:
2654
	.error:
2653
		stdcall print_err,sz_buf2d_filter_dither,txt_err_n24b
2655
		stdcall print_err,sz_buf2d_filter_dither,txt_err_n24b
2654
	.dither_end:
2656
	.dither_end:
2655
	popad
2657
	popad
2656
	ret
2658
	ret
2657
endp
2659
endp
2658
 
2660
 
2659
align 16
2661
align 16
2660
dither_0: ; Sierra Filter Lite algorithm
2662
dither_0: ; Sierra Filter Lite algorithm
2661
newp_0:   ; Dithering cycle
2663
newp_0:   ; Dithering cycle
2662
	xor   ebx,ebx ; At first threshold
2664
	xor   ebx,ebx ; At first threshold
2663
	movzx ecx,byte[edi]
2665
	movzx ecx,byte[edi]
2664
	cmp   cl,255
2666
	cmp   cl,255
2665
	je    newp_0.next
2667
	je    newp_0.next
2666
	test  cl,cl
2668
	test  cl,cl
2667
	jz    newp_0.next
2669
	jz    newp_0.next
2668
	jns   @f
2670
	jns   @f
2669
	dec   ebx
2671
	dec   ebx
2670
	sub   ecx,255
2672
	sub   ecx,255
2671
@@:
2673
@@:
2672
	mov   [edi],bl               ; putpixel
2674
	mov   [edi],bl               ; putpixel
2673
 
2675
 
2674
	sar   ecx,1                  ; error/2
2676
	sar   ecx,1                  ; error/2
2675
	;adc   ecx,0                  ; round to integer
2677
	;adc   ecx,0                  ; round to integer
2676
 
2678
 
2677
	movzx eax,byte[edi+3]        ; pixel (x+1;y)
2679
	movzx eax,byte[edi+3]        ; pixel (x+1;y)
2678
	add   eax,ecx                ; add error/2 to (x+1;y)
2680
	add   eax,ecx                ; add error/2 to (x+1;y)
2679
	jge   @f                     ; check_overflow
2681
	jge   @f                     ; check_overflow
2680
	xor   eax,eax
2682
	xor   eax,eax
2681
	jmp   .ok
2683
	jmp   .ok
2682
@@:
2684
@@:
2683
	cmp   eax,255
2685
	cmp   eax,255
2684
	jle   .ok
2686
	jle   .ok
2685
	or    al,255
2687
	or    al,255
2686
.ok:
2688
.ok:
2687
	mov   [edi+3],al             ; putpixel
2689
	mov   [edi+3],al             ; putpixel
2688
 
2690
 
2689
	sar   ecx,1                  ; error/4
2691
	sar   ecx,1                  ; error/4
2690
	adc   ecx,0                  ; round to integer
2692
	adc   ecx,0                  ; round to integer
2691
 
2693
 
2692
	movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
2694
	movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
2693
	add   eax,ecx                ; add error/4 to (x-1;y+1)
2695
	add   eax,ecx                ; add error/4 to (x-1;y+1)
2694
	jge   @f                     ; check_overflow
2696
	jge   @f                     ; check_overflow
2695
	xor   eax,eax
2697
	xor   eax,eax
2696
	jmp   .ok1
2698
	jmp   .ok1
2697
@@:
2699
@@:
2698
	cmp   eax,255
2700
	cmp   eax,255
2699
	jle   .ok1
2701
	jle   .ok1
2700
	or    al,255
2702
	or    al,255
2701
.ok1:
2703
.ok1:
2702
	mov   [edi+edx-3],al         ; putpixel
2704
	mov   [edi+edx-3],al         ; putpixel
2703
 
2705
 
2704
	movzx eax,byte[edi+edx]      ; pixel (x;y+1)
2706
	movzx eax,byte[edi+edx]      ; pixel (x;y+1)
2705
	add   eax,ecx                ; add error/4 to (x;y+1)
2707
	add   eax,ecx                ; add error/4 to (x;y+1)
2706
	jge   @f                     ; check_overflow
2708
	jge   @f                     ; check_overflow
2707
	xor   eax,eax
2709
	xor   eax,eax
2708
	jmp   .ok2
2710
	jmp   .ok2
2709
@@:
2711
@@:
2710
	cmp   eax,255
2712
	cmp   eax,255
2711
	jle   .ok2
2713
	jle   .ok2
2712
	or    al,255
2714
	or    al,255
2713
.ok2:
2715
.ok2:
2714
	mov   [edi+edx],al           ; putpixel
2716
	mov   [edi+edx],al           ; putpixel
2715
 
2717
 
2716
.next:
2718
.next:
2717
	inc   edi
2719
	inc   edi
2718
	dec   esi
2720
	dec   esi
2719
	jnz   newp_0
2721
	jnz   newp_0
2720
	ret
2722
	ret
2721
 
2723
 
2722
align 16
2724
align 16
2723
dither_1: ; Floyd-Steinberg algorithm
2725
dither_1: ; Floyd-Steinberg algorithm
2724
newp_1:   ; Dithering cycle
2726
newp_1:   ; Dithering cycle
2725
	xor   ebx,ebx ; At first threshold
2727
	xor   ebx,ebx ; At first threshold
2726
	movzx ecx,byte[edi]
2728
	movzx ecx,byte[edi]
2727
	cmp   cl,255
2729
	cmp   cl,255
2728
	je    newp_1.next
2730
	je    newp_1.next
2729
	test  cl,cl
2731
	test  cl,cl
2730
	jz    newp_1.next
2732
	jz    newp_1.next
2731
	jns   @f
2733
	jns   @f
2732
	dec   ebx
2734
	dec   ebx
2733
	sub   ecx,255
2735
	sub   ecx,255
2734
@@:
2736
@@:
2735
	mov   [edi],bl               ; putpixel
2737
	mov   [edi],bl               ; putpixel
2736
 
2738
 
2737
	sar   ecx,4                  ; error/16
2739
	sar   ecx,4                  ; error/16
2738
	adc   ecx,0                  ; round to integer
2740
	adc   ecx,0                  ; round to integer
2739
	mov   ebx,ecx
2741
	mov   ebx,ecx
2740
 
2742
 
2741
	movzx eax,byte[edi+edx+3]    ; pixel (x+1;y+1)
2743
	movzx eax,byte[edi+edx+3]    ; pixel (x+1;y+1)
2742
	add   eax,ecx                ; add error/16 to (x+1;y+1)
2744
	add   eax,ecx                ; add error/16 to (x+1;y+1)
2743
	jge   @f                     ; check_overflow
2745
	jge   @f                     ; check_overflow
2744
	xor   eax,eax
2746
	xor   eax,eax
2745
	jmp   .ok
2747
	jmp   .ok
2746
@@:
2748
@@:
2747
	cmp   eax,255
2749
	cmp   eax,255
2748
	jle   .ok
2750
	jle   .ok
2749
	or    al,255
2751
	or    al,255
2750
.ok:
2752
.ok:
2751
	mov   [edi+edx+3],al         ;putpixel
2753
	mov   [edi+edx+3],al         ;putpixel
2752
 
2754
 
2753
	imul  ecx,3
2755
	imul  ecx,3
2754
	movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
2756
	movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
2755
	add   eax,ecx                ; add 3*error/16 to (x-1;y+1)
2757
	add   eax,ecx                ; add 3*error/16 to (x-1;y+1)
2756
	jge   @f                     ; check_overflow
2758
	jge   @f                     ; check_overflow
2757
	xor   eax,eax
2759
	xor   eax,eax
2758
	jmp   .ok1
2760
	jmp   .ok1
2759
@@:
2761
@@:
2760
	cmp   eax,255
2762
	cmp   eax,255
2761
	jle   .ok1
2763
	jle   .ok1
2762
	or    al,255
2764
	or    al,255
2763
.ok1:
2765
.ok1:
2764
	mov   [edi+edx-3],al         ;putpixel
2766
	mov   [edi+edx-3],al         ;putpixel
2765
 
2767
 
2766
	mov   ecx,ebx
2768
	mov   ecx,ebx
2767
	imul  ecx,5
2769
	imul  ecx,5
2768
	movzx eax,byte[edi+edx]      ; pixel (x;y+1)
2770
	movzx eax,byte[edi+edx]      ; pixel (x;y+1)
2769
	add   eax,ecx                ; add 5*error/16 to (x;y+1)
2771
	add   eax,ecx                ; add 5*error/16 to (x;y+1)
2770
	jge   @f                     ; check_overflow
2772
	jge   @f                     ; check_overflow
2771
	xor   eax,eax
2773
	xor   eax,eax
2772
	jmp   .ok2
2774
	jmp   .ok2
2773
@@:
2775
@@:
2774
	cmp   eax,255
2776
	cmp   eax,255
2775
	jle   .ok2
2777
	jle   .ok2
2776
	or    al,255
2778
	or    al,255
2777
.ok2:
2779
.ok2:
2778
	mov   [edi+edx],al           ;putpixel
2780
	mov   [edi+edx],al           ;putpixel
2779
 
2781
 
2780
	mov   ecx,ebx
2782
	mov   ecx,ebx
2781
	imul  ecx,7
2783
	imul  ecx,7
2782
	movzx eax,byte[edi+3]        ; pixel (x+1;y)
2784
	movzx eax,byte[edi+3]        ; pixel (x+1;y)
2783
	add   eax,ecx                ; add 7*error/16 to (x+1;y)
2785
	add   eax,ecx                ; add 7*error/16 to (x+1;y)
2784
	jge   @f                     ; check_overflow
2786
	jge   @f                     ; check_overflow
2785
	xor   eax,eax
2787
	xor   eax,eax
2786
	jmp   .ok3
2788
	jmp   .ok3
2787
@@:
2789
@@:
2788
	cmp   eax,255
2790
	cmp   eax,255
2789
	jle   .ok3
2791
	jle   .ok3
2790
	or    al,255
2792
	or    al,255
2791
.ok3:
2793
.ok3:
2792
	mov   [edi+3],al             ;putpixel
2794
	mov   [edi+3],al             ;putpixel
2793
 
2795
 
2794
.next:
2796
.next:
2795
	inc  edi
2797
	inc  edi
2796
	dec  esi
2798
	dec  esi
2797
	jnz  newp_1
2799
	jnz  newp_1
2798
	ret
2800
	ret
2799
 
2801
 
2800
align 16
2802
align 16
2801
dither_2: ; Burkes algorithm
2803
dither_2: ; Burkes algorithm
2802
newp_2:   ; Dithering cycle
2804
newp_2:   ; Dithering cycle
2803
	xor   ebx,ebx ; At first threshold
2805
	xor   ebx,ebx ; At first threshold
2804
	movsx ecx,byte[edi]
2806
	movsx ecx,byte[edi]
2805
	cmp   cl,255
2807
	cmp   cl,255
2806
	je    newp_2.next
2808
	je    newp_2.next
2807
	test  cl,cl
2809
	test  cl,cl
2808
	jz    newp_2.next
2810
	jz    newp_2.next
2809
	jns   @f
2811
	jns   @f
2810
	dec   ebx
2812
	dec   ebx
2811
@@:
2813
@@:
2812
	mov   [edi],bl               ; putpixel
2814
	mov   [edi],bl               ; putpixel
2813
 
2815
 
2814
	sar   ecx,2                  ; error/4
2816
	sar   ecx,2                  ; error/4
2815
	adc   ecx,0                  ; round to integer
2817
	adc   ecx,0                  ; round to integer
2816
 
2818
 
2817
	movzx eax,byte[edi+3]        ; pixel (x+1;y)
2819
	movzx eax,byte[edi+3]        ; pixel (x+1;y)
2818
	add   eax,ecx                ; add error/4 to (x+1;y)
2820
	add   eax,ecx                ; add error/4 to (x+1;y)
2819
	jge   @f                     ; check_overflow
2821
	jge   @f                     ; check_overflow
2820
	xor   eax,eax
2822
	xor   eax,eax
2821
	jmp   .ok
2823
	jmp   .ok
2822
@@:
2824
@@:
2823
	cmp   eax,255
2825
	cmp   eax,255
2824
	jle   .ok
2826
	jle   .ok
2825
	or    al,255
2827
	or    al,255
2826
.ok:
2828
.ok:
2827
	mov   [edi+3],al             ; putpixel
2829
	mov   [edi+3],al             ; putpixel
2828
 
2830
 
2829
	movzx eax,byte[edi+edx]      ; pixel (x;y+1)
2831
	movzx eax,byte[edi+edx]      ; pixel (x;y+1)
2830
	add   eax,ecx                ; add error/4 to (x;y+1)
2832
	add   eax,ecx                ; add error/4 to (x;y+1)
2831
	jge   @f                     ; check_overflow
2833
	jge   @f                     ; check_overflow
2832
	xor   eax,eax
2834
	xor   eax,eax
2833
	jmp   .ok1
2835
	jmp   .ok1
2834
@@:
2836
@@:
2835
	cmp   eax,255
2837
	cmp   eax,255
2836
	jle   .ok1
2838
	jle   .ok1
2837
	or    al,255
2839
	or    al,255
2838
.ok1:
2840
.ok1:
2839
	mov   [edi+edx],al           ; putpixel
2841
	mov   [edi+edx],al           ; putpixel
2840
 
2842
 
2841
	sar   ecx,1                  ; error/8
2843
	sar   ecx,1                  ; error/8
2842
	adc   ecx,0                  ; round to integer
2844
	adc   ecx,0                  ; round to integer
2843
 
2845
 
2844
	movzx eax,byte[edi+6]        ; pixel (x+2;y)
2846
	movzx eax,byte[edi+6]        ; pixel (x+2;y)
2845
	add   eax,ecx                ; add error/8 to (x+2;y)
2847
	add   eax,ecx                ; add error/8 to (x+2;y)
2846
	jge   @f                     ; check_overflow
2848
	jge   @f                     ; check_overflow
2847
	xor   eax,eax
2849
	xor   eax,eax
2848
	jmp   .ok2
2850
	jmp   .ok2
2849
@@:
2851
@@:
2850
	cmp   eax,255
2852
	cmp   eax,255
2851
	jle   .ok2
2853
	jle   .ok2
2852
	or    al,255
2854
	or    al,255
2853
.ok2:
2855
.ok2:
2854
	mov   [edi+6],al             ; putpixel
2856
	mov   [edi+6],al             ; putpixel
2855
 
2857
 
2856
	movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
2858
	movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
2857
	add   eax,ecx                ; add error/8 to (x-1;y+1)
2859
	add   eax,ecx                ; add error/8 to (x-1;y+1)
2858
	jge   @f                     ; check_overflow
2860
	jge   @f                     ; check_overflow
2859
	xor   eax,eax
2861
	xor   eax,eax
2860
	jmp   .ok3
2862
	jmp   .ok3
2861
@@:
2863
@@:
2862
	cmp   eax,255
2864
	cmp   eax,255
2863
	jle   .ok3
2865
	jle   .ok3
2864
	or    al,255
2866
	or    al,255
2865
.ok3:
2867
.ok3:
2866
	mov   [edi+edx-3],al         ; putpixel
2868
	mov   [edi+edx-3],al         ; putpixel
2867
 
2869
 
2868
	movzx eax,byte[edi+edx+3]    ; pixel (x+1;y+1)
2870
	movzx eax,byte[edi+edx+3]    ; pixel (x+1;y+1)
2869
	add   eax,ecx                ; add error/8 to (x+1;y+1)
2871
	add   eax,ecx                ; add error/8 to (x+1;y+1)
2870
	jge   @f                     ; check_overflow
2872
	jge   @f                     ; check_overflow
2871
	xor   eax,eax
2873
	xor   eax,eax
2872
	jmp   .ok4
2874
	jmp   .ok4
2873
@@:
2875
@@:
2874
	cmp   eax,255
2876
	cmp   eax,255
2875
	jle   .ok4
2877
	jle   .ok4
2876
	or    al,255
2878
	or    al,255
2877
.ok4:
2879
.ok4:
2878
	mov   [edi+edx+3],al         ; putpixel
2880
	mov   [edi+edx+3],al         ; putpixel
2879
 
2881
 
2880
	sar   ecx,1                  ; error/16
2882
	sar   ecx,1                  ; error/16
2881
	;adc   ecx,0                  ; round to integer
2883
	;adc   ecx,0                  ; round to integer
2882
 
2884
 
2883
	movzx eax,byte[edi+edx-6]    ; pixel (x-2;y+1)
2885
	movzx eax,byte[edi+edx-6]    ; pixel (x-2;y+1)
2884
	add   eax,ecx                ; add error/16 to (x-2;y+1)
2886
	add   eax,ecx                ; add error/16 to (x-2;y+1)
2885
	jge   @f                     ; check_overflow
2887
	jge   @f                     ; check_overflow
2886
	xor   eax,eax
2888
	xor   eax,eax
2887
	jmp   .ok5
2889
	jmp   .ok5
2888
@@:
2890
@@:
2889
	cmp   eax,255
2891
	cmp   eax,255
2890
	jle   .ok5
2892
	jle   .ok5
2891
	or    al,255
2893
	or    al,255
2892
.ok5:
2894
.ok5:
2893
	mov   [edi+edx-6],al         ; putpixel
2895
	mov   [edi+edx-6],al         ; putpixel
2894
 
2896
 
2895
	movzx eax,byte[edi+edx+6]    ; pixel (x+2;y+1)
2897
	movzx eax,byte[edi+edx+6]    ; pixel (x+2;y+1)
2896
	add   eax,ecx                ; add error/16 to (x+2;y+1)
2898
	add   eax,ecx                ; add error/16 to (x+2;y+1)
2897
	jge   @f                     ; check_overflow
2899
	jge   @f                     ; check_overflow
2898
	xor   eax,eax
2900
	xor   eax,eax
2899
	jmp   .ok6
2901
	jmp   .ok6
2900
@@:
2902
@@:
2901
	cmp   eax,255
2903
	cmp   eax,255
2902
	jle   .ok6
2904
	jle   .ok6
2903
	or    al,255
2905
	or    al,255
2904
.ok6:
2906
.ok6:
2905
	mov   [edi+edx+6],al         ; putpixel
2907
	mov   [edi+edx+6],al         ; putpixel
2906
 
2908
 
2907
.next:
2909
.next:
2908
	inc   edi
2910
	inc   edi
2909
	dec   esi
2911
	dec   esi
2910
	jnz   newp_2
2912
	jnz   newp_2
2911
	ret
2913
	ret
2912
 
2914
 
2913
 
2915
 
2914
align 16
2916
align 16
2915
dither_3:                        ; Heavyiron_mod algorithm
2917
dither_3:                        ; Heavyiron_mod algorithm
2916
 newp_3:                         ; Dithering cycle
2918
 newp_3:                         ; Dithering cycle
2917
    xor   ebx,ebx                ; At first threshold
2919
    xor   ebx,ebx                ; At first threshold
2918
    movzx ecx,byte[edi]
2920
    movzx ecx,byte[edi]
2919
    cmp   cl,255
2921
    cmp   cl,255
2920
    je   .next
2922
    je   .next
2921
    test  cl,cl
2923
    test  cl,cl
2922
    jz    .next
2924
    jz    .next
2923
    jns   @f
2925
    jns   @f
2924
    dec   ebx
2926
    dec   ebx
2925
    sub   ecx,255
2927
    sub   ecx,255
2926
  @@:
2928
  @@:
2927
    mov   [edi],bl               ; putpixel
2929
    mov   [edi],bl               ; putpixel
2928
 
2930
 
2929
    sar   ecx,2                  ; error/4
2931
    sar   ecx,2                  ; error/4
2930
 
2932
 
2931
    movzx eax,byte[edi+3]        ; pixel (x+1;y)
2933
    movzx eax,byte[edi+3]        ; pixel (x+1;y)
2932
    add   eax,ecx                ; add error/4 to (x+1;y)
2934
    add   eax,ecx                ; add error/4 to (x+1;y)
2933
    jge   @f                     ; check_overflow
2935
    jge   @f                     ; check_overflow
2934
    xor   eax,eax
2936
    xor   eax,eax
2935
    jmp   .ok
2937
    jmp   .ok
2936
  @@:
2938
  @@:
2937
    cmp   eax,255
2939
    cmp   eax,255
2938
    jle   .ok
2940
    jle   .ok
2939
    or    al,255
2941
    or    al,255
2940
  .ok:
2942
  .ok:
2941
    mov   [edi+3],al             ; putpixel
2943
    mov   [edi+3],al             ; putpixel
2942
 
2944
 
2943
    movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
2945
    movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
2944
    add   eax,ecx                ; add error/4 to (x-1;y+1)
2946
    add   eax,ecx                ; add error/4 to (x-1;y+1)
2945
    jge   @f                     ; check_overflow
2947
    jge   @f                     ; check_overflow
2946
    xor   eax,eax
2948
    xor   eax,eax
2947
    jmp   .ok1
2949
    jmp   .ok1
2948
  @@:
2950
  @@:
2949
    cmp   eax,255
2951
    cmp   eax,255
2950
    jle   .ok1
2952
    jle   .ok1
2951
    or    al,255
2953
    or    al,255
2952
  .ok1:
2954
  .ok1:
2953
    mov   [edi+edx-3],al         ; putpixel
2955
    mov   [edi+edx-3],al         ; putpixel
2954
 
2956
 
2955
    movzx eax,byte[edi+edx]      ; pixel (x;y+1)
2957
    movzx eax,byte[edi+edx]      ; pixel (x;y+1)
2956
    add   eax,ecx                ; add error/4 to (x;y+1)
2958
    add   eax,ecx                ; add error/4 to (x;y+1)
2957
    jge   @f                     ; check_overflow
2959
    jge   @f                     ; check_overflow
2958
    xor   eax,eax
2960
    xor   eax,eax
2959
    jmp   .ok2
2961
    jmp   .ok2
2960
  @@:
2962
  @@:
2961
    cmp   eax,255
2963
    cmp   eax,255
2962
    jle   .ok2
2964
    jle   .ok2
2963
    or    al,255
2965
    or    al,255
2964
  .ok2:
2966
  .ok2:
2965
    mov   [edi+edx],al           ; putpixel
2967
    mov   [edi+edx],al           ; putpixel
2966
 
2968
 
2967
  .next:
2969
  .next:
2968
    inc   edi
2970
    inc   edi
2969
    dec   esi
2971
    dec   esi
2970
    jnz   newp_3
2972
    jnz   newp_3
2971
    ret
2973
    ret
2972
 
2974
 
2973
align 16
2975
align 16
2974
dither_4:                        ; Atkinson algorithm
2976
dither_4:                        ; Atkinson algorithm
2975
 newp_4:                         ; Dithering cycle
2977
 newp_4:                         ; Dithering cycle
2976
 
2978
 
2977
    xor   ebx,ebx                ; At first threshold
2979
    xor   ebx,ebx                ; At first threshold
2978
    movsx ecx,byte[edi]
2980
    movsx ecx,byte[edi]
2979
    cmp   cl,255
2981
    cmp   cl,255
2980
    je   .next
2982
    je   .next
2981
    test  cl,cl
2983
    test  cl,cl
2982
    jz    .next
2984
    jz    .next
2983
    jns   @f
2985
    jns   @f
2984
    dec   ebx
2986
    dec   ebx
2985
  @@:
2987
  @@:
2986
    mov   [edi],bl               ; putpixel
2988
    mov   [edi],bl               ; putpixel
2987
 
2989
 
2988
    sar   ecx,3                  ; error/8
2990
    sar   ecx,3                  ; error/8
2989
 
2991
 
2990
    movzx eax,byte[edi+3]        ; pixel (x+1;y)
2992
    movzx eax,byte[edi+3]        ; pixel (x+1;y)
2991
    add   eax,ecx                ; add error/8 to (x+1;y)
2993
    add   eax,ecx                ; add error/8 to (x+1;y)
2992
    jge   @f                     ; check_overflow
2994
    jge   @f                     ; check_overflow
2993
    xor   eax,eax
2995
    xor   eax,eax
2994
    jmp   .ok
2996
    jmp   .ok
2995
  @@:
2997
  @@:
2996
    cmp   eax,255
2998
    cmp   eax,255
2997
    jle   .ok
2999
    jle   .ok
2998
    or    al,255
3000
    or    al,255
2999
  .ok:
3001
  .ok:
3000
    mov   [edi+3],al             ; putpixel
3002
    mov   [edi+3],al             ; putpixel
3001
 
3003
 
3002
    movzx eax,byte[edi+edx]      ; pixel (x;y+1)
3004
    movzx eax,byte[edi+edx]      ; pixel (x;y+1)
3003
    add   eax,ecx                ; add error/8 to (x;y+1)
3005
    add   eax,ecx                ; add error/8 to (x;y+1)
3004
    jge   @f                     ; check_overflow
3006
    jge   @f                     ; check_overflow
3005
    xor   eax,eax
3007
    xor   eax,eax
3006
    jmp   .ok1
3008
    jmp   .ok1
3007
  @@:
3009
  @@:
3008
    cmp   eax,255
3010
    cmp   eax,255
3009
    jle   .ok1
3011
    jle   .ok1
3010
    or    al,255
3012
    or    al,255
3011
  .ok1:
3013
  .ok1:
3012
    mov   [edi+edx],al           ; putpixel
3014
    mov   [edi+edx],al           ; putpixel
3013
 
3015
 
3014
    movzx eax,byte[edi+6]        ; pixel (x+2;y)
3016
    movzx eax,byte[edi+6]        ; pixel (x+2;y)
3015
    add   eax,ecx                ; add error/8 to (x+2;y)
3017
    add   eax,ecx                ; add error/8 to (x+2;y)
3016
    jge   @f                     ; check_overflow
3018
    jge   @f                     ; check_overflow
3017
    xor   eax,eax
3019
    xor   eax,eax
3018
    jmp   .ok2
3020
    jmp   .ok2
3019
  @@:
3021
  @@:
3020
    cmp   eax,255
3022
    cmp   eax,255
3021
    jle   .ok2
3023
    jle   .ok2
3022
    or    al,255
3024
    or    al,255
3023
  .ok2:
3025
  .ok2:
3024
    mov   [edi+6],al             ; putpixel
3026
    mov   [edi+6],al             ; putpixel
3025
 
3027
 
3026
    movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
3028
    movzx eax,byte[edi+edx-3]    ; pixel (x-1;y+1)
3027
    add   eax,ecx                ; add error/8 to (x-1;y+1)
3029
    add   eax,ecx                ; add error/8 to (x-1;y+1)
3028
    jge   @f                     ; check_overflow
3030
    jge   @f                     ; check_overflow
3029
    xor   eax,eax
3031
    xor   eax,eax
3030
    jmp   .ok3
3032
    jmp   .ok3
3031
  @@:
3033
  @@:
3032
    cmp   eax,255
3034
    cmp   eax,255
3033
    jle   .ok3
3035
    jle   .ok3
3034
    or    al,255
3036
    or    al,255
3035
  .ok3:
3037
  .ok3:
3036
    mov   [edi+edx-3],al         ; putpixel
3038
    mov   [edi+edx-3],al         ; putpixel
3037
 
3039
 
3038
    movzx eax,byte[edi+edx+3]    ; pixel (x+1;y+1)
3040
    movzx eax,byte[edi+edx+3]    ; pixel (x+1;y+1)
3039
    add   eax,ecx                ; add error/8 to (x+1;y+1)
3041
    add   eax,ecx                ; add error/8 to (x+1;y+1)
3040
    jge   @f                     ; check_overflow
3042
    jge   @f                     ; check_overflow
3041
    xor   eax,eax
3043
    xor   eax,eax
3042
    jmp   .ok4
3044
    jmp   .ok4
3043
  @@:
3045
  @@:
3044
    cmp   eax,255
3046
    cmp   eax,255
3045
    jle   .ok4
3047
    jle   .ok4
3046
    or    al,255
3048
    or    al,255
3047
  .ok4:
3049
  .ok4:
3048
    mov   [edi+edx+3],al         ; putpixel
3050
    mov   [edi+edx+3],al         ; putpixel
3049
 
3051
 
3050
 
3052
 
3051
    movzx eax,byte[edi+edx+edx]    ; pixel (x;y+2)
3053
    movzx eax,byte[edi+edx+edx]    ; pixel (x;y+2)
3052
    add   eax,ecx                ; add error/8 to (x;y+2)
3054
    add   eax,ecx                ; add error/8 to (x;y+2)
3053
    jge   @f                     ; check_overflow
3055
    jge   @f                     ; check_overflow
3054
    xor   eax,eax
3056
    xor   eax,eax
3055
    jmp   .ok5
3057
    jmp   .ok5
3056
  @@:
3058
  @@:
3057
    cmp   eax,255
3059
    cmp   eax,255
3058
    jle   .ok5
3060
    jle   .ok5
3059
    or    al,255
3061
    or    al,255
3060
  .ok5:
3062
  .ok5:
3061
    mov   [edi+edx+edx],al         ; putpixel
3063
    mov   [edi+edx+edx],al         ; putpixel
3062
 
3064
 
3063
  .next:
3065
  .next:
3064
    inc   edi
3066
    inc   edi
3065
    dec   esi
3067
    dec   esi
3066
    jnz   newp_4
3068
    jnz   newp_4
3067
    ret
3069
    ret
3068
 
3070
 
3069
 
3071
 
3070
 
3072
 
3071
include 'fun_voxel.inc' ;ä㭪樨 ¤«ï à ¡®âë á ¢®ªá¥«ì­®© £à ä¨ª®©
3073
include 'fun_voxel.inc' ;ä㭪樨 ¤«ï à ¡®âë á ¢®ªá¥«ì­®© £à ä¨ª®©
3072
 
3074
 
3073
txt_err_size_0 db 'image size < 1 pixel',13,10,0
3075
txt_err_size_0 db 'image size < 1 pixel',13,10,0
3074
txt_err_n8b db 'need buffer 8 bit',13,10,0
3076
txt_err_n8b db 'need buffer 8 bit',13,10,0
3075
txt_err_n24b db 'need buffer 24 bit',13,10,0
3077
txt_err_n24b db 'need buffer 24 bit',13,10,0
3076
txt_err_n32b db 'need buffer 32 bit',13,10,0
3078
txt_err_n32b db 'need buffer 32 bit',13,10,0
3077
txt_err_n8_24b db 'need buffer 8 or 24 bit',13,10,0
3079
txt_err_n8_24b db 'need buffer 8 or 24 bit',13,10,0
3078
 
3080
 
3079
align 16
3081
align 16
3080
EXPORTS:
3082
EXPORTS:
3081
	dd sz_lib_init, lib_init
3083
	dd sz_lib_init, lib_init
3082
	dd sz_buf2d_create, buf_create
3084
	dd sz_buf2d_create, buf_create
3083
	dd sz_buf2d_create_f_img, buf_create_f_img
3085
	dd sz_buf2d_create_f_img, buf_create_f_img
3084
	dd sz_buf2d_clear, buf_clear
3086
	dd sz_buf2d_clear, buf_clear
3085
	dd sz_buf2d_draw, buf_draw_buf
3087
	dd sz_buf2d_draw, buf_draw_buf
3086
	dd sz_buf2d_delete, buf_delete
3088
	dd sz_buf2d_delete, buf_delete
3087
	dd sz_buf2d_resize, buf_resize
3089
	dd sz_buf2d_resize, buf_resize
3088
	dd sz_buf2d_rotate, buf_rotate
3090
	dd sz_buf2d_rotate, buf_rotate
3089
	dd sz_buf2d_line, buf_line_brs
3091
	dd sz_buf2d_line, buf_line_brs
3090
	dd sz_buf2d_line_sm, buf_line_brs_sm
3092
	dd sz_buf2d_line_sm, buf_line_brs_sm
3091
	dd sz_buf2d_rect_by_size, buf_rect_by_size
3093
	dd sz_buf2d_rect_by_size, buf_rect_by_size
3092
	dd sz_buf2d_filled_rect_by_size, buf_filled_rect_by_size
3094
	dd sz_buf2d_filled_rect_by_size, buf_filled_rect_by_size
3093
	dd sz_buf2d_circle, buf_circle
3095
	dd sz_buf2d_circle, buf_circle
3094
	dd sz_buf2d_img_hdiv2, buf_img_hdiv2
3096
	dd sz_buf2d_img_hdiv2, buf_img_hdiv2
3095
	dd sz_buf2d_img_wdiv2, buf_img_wdiv2
3097
	dd sz_buf2d_img_wdiv2, buf_img_wdiv2
3096
	dd sz_buf2d_conv_24_to_8, buf_conv_24_to_8
3098
	dd sz_buf2d_conv_24_to_8, buf_conv_24_to_8
3097
	dd sz_buf2d_conv_24_to_32, buf_conv_24_to_32
3099
	dd sz_buf2d_conv_24_to_32, buf_conv_24_to_32
3098
	dd sz_buf2d_bit_blt, buf_bit_blt
3100
	dd sz_buf2d_bit_blt, buf_bit_blt
3099
	dd sz_buf2d_bit_blt_transp, buf_bit_blt_transp
3101
	dd sz_buf2d_bit_blt_transp, buf_bit_blt_transp
3100
	dd sz_buf2d_bit_blt_alpha, buf_bit_blt_alpha
3102
	dd sz_buf2d_bit_blt_alpha, buf_bit_blt_alpha
3101
	dd sz_buf2d_curve_bezier, buf_curve_bezier
3103
	dd sz_buf2d_curve_bezier, buf_curve_bezier
3102
	dd sz_buf2d_convert_text_matrix, buf_convert_text_matrix
3104
	dd sz_buf2d_convert_text_matrix, buf_convert_text_matrix
3103
	dd sz_buf2d_draw_text, buf_draw_text
3105
	dd sz_buf2d_draw_text, buf_draw_text
3104
	dd sz_buf2d_crop_color, buf_crop_color
3106
	dd sz_buf2d_crop_color, buf_crop_color
3105
	dd sz_buf2d_offset_h, buf_offset_h
3107
	dd sz_buf2d_offset_h, buf_offset_h
3106
	dd sz_buf2d_flood_fill, buf_flood_fill
3108
	dd sz_buf2d_flood_fill, buf_flood_fill
3107
	dd sz_buf2d_set_pixel, buf_set_pixel
3109
	dd sz_buf2d_set_pixel, buf_set_pixel
3108
	dd sz_buf2d_get_pixel, buf_get_pixel
3110
	dd sz_buf2d_get_pixel, buf_get_pixel
3109
	dd sz_buf2d_flip_h, buf_flip_h
3111
	dd sz_buf2d_flip_h, buf_flip_h
3110
	dd sz_buf2d_flip_v, buf_flip_v
3112
	dd sz_buf2d_flip_v, buf_flip_v
3111
	dd sz_buf2d_filter_dither, buf_filter_dither
3113
	dd sz_buf2d_filter_dither, buf_filter_dither
3112
	dd sz_buf2d_vox_brush_create, vox_brush_create
3114
	dd sz_buf2d_vox_brush_create, vox_brush_create
3113
	dd sz_buf2d_vox_brush_delete, vox_brush_delete
3115
	dd sz_buf2d_vox_brush_delete, vox_brush_delete
3114
	dd sz_buf2d_vox_obj_get_img_w_3g, buf_vox_obj_get_img_w_3g
3116
	dd sz_buf2d_vox_obj_get_img_w_3g, buf_vox_obj_get_img_w_3g
3115
	dd sz_buf2d_vox_obj_get_img_h_3g, buf_vox_obj_get_img_h_3g
3117
	dd sz_buf2d_vox_obj_get_img_h_3g, buf_vox_obj_get_img_h_3g
3116
	dd sz_buf2d_vox_obj_draw_1g, buf_vox_obj_draw_1g
3118
	dd sz_buf2d_vox_obj_draw_1g, buf_vox_obj_draw_1g
3117
	dd sz_buf2d_vox_obj_draw_3g, buf_vox_obj_draw_3g
3119
	dd sz_buf2d_vox_obj_draw_3g, buf_vox_obj_draw_3g
3118
	dd sz_buf2d_vox_obj_draw_3g_scaled, buf_vox_obj_draw_3g_scaled
3120
	dd sz_buf2d_vox_obj_draw_3g_scaled, buf_vox_obj_draw_3g_scaled
3119
	dd sz_buf2d_vox_obj_draw_pl, buf_vox_obj_draw_pl
3121
	dd sz_buf2d_vox_obj_draw_pl, buf_vox_obj_draw_pl
3120
	dd sz_buf2d_vox_obj_draw_pl_scaled, buf_vox_obj_draw_pl_scaled
3122
	dd sz_buf2d_vox_obj_draw_pl_scaled, buf_vox_obj_draw_pl_scaled
3121
	dd sz_buf2d_vox_obj_draw_3g_shadows, buf_vox_obj_draw_3g_shadows
3123
	dd sz_buf2d_vox_obj_draw_3g_shadows, buf_vox_obj_draw_3g_shadows
3122
	dd 0,0
3124
	dd 0,0
3123
	sz_lib_init db 'lib_init',0
3125
	sz_lib_init db 'lib_init',0
3124
	sz_buf2d_create db 'buf2d_create',0
3126
	sz_buf2d_create db 'buf2d_create',0
3125
	sz_buf2d_create_f_img db 'buf2d_create_f_img',0
3127
	sz_buf2d_create_f_img db 'buf2d_create_f_img',0
3126
	sz_buf2d_clear db 'buf2d_clear',0 ;®ç¨á⪠ ¡ãä¥à  㪠§ ­­ë¬ 梥⮬
3128
	sz_buf2d_clear db 'buf2d_clear',0 ;®ç¨á⪠ ¡ãä¥à  㪠§ ­­ë¬ 梥⮬
3127
	sz_buf2d_draw db 'buf2d_draw',0
3129
	sz_buf2d_draw db 'buf2d_draw',0
3128
	sz_buf2d_delete db 'buf2d_delete',0
3130
	sz_buf2d_delete db 'buf2d_delete',0
3129
	sz_buf2d_resize db 'buf2d_resize',0
3131
	sz_buf2d_resize db 'buf2d_resize',0
3130
	sz_buf2d_rotate db 'buf2d_rotate',0
3132
	sz_buf2d_rotate db 'buf2d_rotate',0
3131
	sz_buf2d_line db 'buf2d_line',0 ;à¨á®¢ ­¨¥ «¨­¨¨
3133
	sz_buf2d_line db 'buf2d_line',0 ;à¨á®¢ ­¨¥ «¨­¨¨
3132
	sz_buf2d_line_sm db 'buf2d_line_sm',0 ;à¨á®¢ ­¨¥ ᣫ ¦¥­­®© «¨­¨¨
3134
	sz_buf2d_line_sm db 'buf2d_line_sm',0 ;à¨á®¢ ­¨¥ ᣫ ¦¥­­®© «¨­¨¨
3133
	sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0 ;à¨á®¢ ­¨¥ à ¬ª¨ ¯àאַ㣮«ì­¨ª , 2-ï ª®®à¤¨­ â  § ¤ ­  ¯® à §¬¥àã
3135
	sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0 ;à¨á®¢ ­¨¥ à ¬ª¨ ¯àאַ㣮«ì­¨ª , 2-ï ª®®à¤¨­ â  § ¤ ­  ¯® à §¬¥àã
3134
	sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0 ;à¨á®¢ ­¨¥ § «¨â®£® ¯àאַ㣮«ì­¨ª , 2-ï ª®®à¤¨­ â  § ¤ ­  ¯® à §¬¥àã
3136
	sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0 ;à¨á®¢ ­¨¥ § «¨â®£® ¯àאַ㣮«ì­¨ª , 2-ï ª®®à¤¨­ â  § ¤ ­  ¯® à §¬¥àã
3135
	sz_buf2d_circle db 'buf2d_circle',0 ;à¨á®¢ ­¨¥ ®ªà㦭®áâ¨
3137
	sz_buf2d_circle db 'buf2d_circle',0 ;à¨á®¢ ­¨¥ ®ªà㦭®áâ¨
3136
	sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0 ;ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® ¢ëá®â¥ ¢ 2 à §  (à §¬¥à ¡ãä¥à  ­¥ ¬¥­ï¥âáï)
3138
	sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0 ;ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® ¢ëá®â¥ ¢ 2 à §  (à §¬¥à ¡ãä¥à  ­¥ ¬¥­ï¥âáï)
3137
	sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0 ;ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® è¨à¨­¥ ¢ 2 à §  (à §¬¥à ¡ãä¥à  ­¥ ¬¥­ï¥âáï)
3139
	sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0 ;ᦠ⨥ ¨§®¡à ¦¥­¨ï ¯® è¨à¨­¥ ¢ 2 à §  (à §¬¥à ¡ãä¥à  ­¥ ¬¥­ï¥âáï)
3138
	sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
3140
	sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
3139
	sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0 
3141
	sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0 
3140
	sz_buf2d_bit_blt db 'buf2d_bit_blt',0
3142
	sz_buf2d_bit_blt db 'buf2d_bit_blt',0
3141
	sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
3143
	sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
3142
	sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
3144
	sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
3143
	sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
3145
	sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
3144
	sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
3146
	sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
3145
	sz_buf2d_draw_text db 'buf2d_draw_text',0
3147
	sz_buf2d_draw_text db 'buf2d_draw_text',0
3146
	sz_buf2d_crop_color db 'buf2d_crop_color',0
3148
	sz_buf2d_crop_color db 'buf2d_crop_color',0
3147
	sz_buf2d_offset_h db 'buf2d_offset_h',0
3149
	sz_buf2d_offset_h db 'buf2d_offset_h',0
3148
	sz_buf2d_flood_fill db 'buf2d_flood_fill',0
3150
	sz_buf2d_flood_fill db 'buf2d_flood_fill',0
3149
	sz_buf2d_set_pixel db 'buf2d_set_pixel',0
3151
	sz_buf2d_set_pixel db 'buf2d_set_pixel',0
3150
	sz_buf2d_get_pixel db 'buf2d_get_pixel',0
3152
	sz_buf2d_get_pixel db 'buf2d_get_pixel',0
3151
	sz_buf2d_flip_h db 'buf2d_flip_h',0
3153
	sz_buf2d_flip_h db 'buf2d_flip_h',0
3152
	sz_buf2d_flip_v db 'buf2d_flip_v',0
3154
	sz_buf2d_flip_v db 'buf2d_flip_v',0
3153
	sz_buf2d_filter_dither db 'buf2d_filter_dither',0
3155
	sz_buf2d_filter_dither db 'buf2d_filter_dither',0
3154
	sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
3156
	sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
3155
	sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
3157
	sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
3156
	sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
3158
	sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
3157
	sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
3159
	sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
3158
	sz_buf2d_vox_obj_draw_1g db 'buf2d_vox_obj_draw_1g',0
3160
	sz_buf2d_vox_obj_draw_1g db 'buf2d_vox_obj_draw_1g',0
3159
	sz_buf2d_vox_obj_draw_3g db 'buf2d_vox_obj_draw_3g',0
3161
	sz_buf2d_vox_obj_draw_3g db 'buf2d_vox_obj_draw_3g',0
3160
	sz_buf2d_vox_obj_draw_3g_scaled db 'buf2d_vox_obj_draw_3g_scaled',0
3162
	sz_buf2d_vox_obj_draw_3g_scaled db 'buf2d_vox_obj_draw_3g_scaled',0
3161
	sz_buf2d_vox_obj_draw_pl db 'buf2d_vox_obj_draw_pl',0
3163
	sz_buf2d_vox_obj_draw_pl db 'buf2d_vox_obj_draw_pl',0
3162
	sz_buf2d_vox_obj_draw_pl_scaled db 'buf2d_vox_obj_draw_pl_scaled',0
3164
	sz_buf2d_vox_obj_draw_pl_scaled db 'buf2d_vox_obj_draw_pl_scaled',0
3163
	sz_buf2d_vox_obj_draw_3g_shadows db 'buf2d_vox_obj_draw_3g_shadows',0
3165
	sz_buf2d_vox_obj_draw_3g_shadows db 'buf2d_vox_obj_draw_3g_shadows',0
3164
>
3166
>
3165
>
3167
>
3166
>
3168
>