Subversion Repositories Kolibri OS

Rev

Rev 7861 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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