Subversion Repositories Kolibri OS

Rev

Rev 1951 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1951 mario79 1
;*****************************************************************************
2
; Rotate RAW image plugin - for zSea image viewer
3
; Copyright (c) 2009 - 2011, Marat Zakiyanov aka Mario79, aka Mario
4
; All rights reserved.
5
;
6
; Redistribution and use in source and binary forms, with or without
7
; modification, are permitted provided that the following conditions are met:
8
;	 * Redistributions of source code must retain the above copyright
9
;	   notice, this list of conditions and the following disclaimer.
10
;	 * Redistributions in binary form must reproduce the above copyright
11
;	   notice, this list of conditions and the following disclaimer in the
12
;	   documentation and/or other materials provided with the distribution.
13
;	 * Neither the name of the  nor the
14
;	   names of its contributors may be used to endorse or promote products
15
;	   derived from this software without specific prior written permission.
16
;
17
; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
18
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
; DISCLAIMED. IN NO EVENT SHALL  BE LIABLE FOR ANY
21
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
;*****************************************************************************
28
; Rotate 32b, 24b, 16b, 8b
29
 
30
format MS COFF
31
 
32
public EXPORTS
33
 
34
section '.flat' code readable align 16
35
 
36
;include	'macros.inc'
37
include	'../../../../macros.inc'
38
;---------------------------------------------------------------------
39
START:
40
	pushad
1957 mario79 41
	mov	ebx,dword [esp+40]
42
	mov	eax,dword [esp+36]
1951 mario79 43
	mov [pointer],eax
44
; ebx - direction
45
; 1 - clockwise, 2 - counter clockwise
46
; 3 - Left&Right, 4 - Up&Down
47
	mov [direction],ebx
48
	mov eax,[eax+4]
49
	mov [image_file],eax
50
 
51
    mov  esi,[eax+28]
52
    add  esi,eax
53
;	mov  ecx,[eax+32]
54
;	xor  ebx,ebx
55
;	mov  [raw_area],ebx
56
	mov ebx,[eax+12]
57
	cmp  ebx,32
58
	jne  @f
59
	mov  ebp,dword START.32
60
	jmp  .1
61
@@:
62
	cmp  ebx,24
63
	jne  @f
64
	mov  ebp,dword START.24
65
	jmp  .1
66
@@:
67
	cmp  ebx,16
68
	jne  @f
69
	mov  ebp,dword START.16
70
	jmp  .1
71
@@:
72
	cmp  ebx,15
73
	jne  @f
74
	inc  ebx
75
	mov  ebp,dword START.16
76
	jmp  .1
77
@@:
78
	cmp  ebx,8
79
	jne  @f
80
	mov  ebp,dword START.8
81
@@:
82
.1:
83
	shr  ebx,3
84
	mov  [bytes_to_pixel],ebx
85
	mov  ebx,[eax+4]
86
	imul ebx,[bytes_to_pixel]
87
	mov  [size_x],ebx
88
	mov  ebx,[eax+8]
89
	imul ebx,[bytes_to_pixel]
90
	mov  [size_y],ebx
91
 
92
	call .get_memory
93
 
94
	cmp  [direction],1
95
	jne  @f
96
	call .clockwise
97
	jmp .end
98
@@:
99
	cmp  [direction],2
100
	jne  @f
101
	call .counter_clockwise
102
	jmp .end
103
@@:
104
	cmp  [direction],3
105
	jne  @f
106
	call .Left_Right
107
	jmp .end
108
@@:
109
	cmp  [direction],4
110
	jne  .exit
111
	call .Up_Down
112
.end:
113
	xchg esi,edi
114
	mov ecx,[image_file]
115
	mov eax,[ecx+4]
116
	imul eax,[bytes_to_pixel]
117
	imul eax,[ecx+8]
118
 
119
	mov ecx,eax
120
	cld
121
	rep movsb
122
 
123
	mov   ecx,[raw_area]
124
	mcall 68,13
125
;---------------------------------------------------------------------
126
.ret_ok:
127
	cmp  [direction],1
128
	jne  @f
129
	call  .XY_data_exchange
130
	jmp  .exit
131
@@:
132
	cmp  [direction],2
133
	jne  .exit
134
	call  .XY_data_exchange
135
.exit:
136
	popad
1957 mario79 137
	ret	8
1951 mario79 138
;---------------------------------------------------------------------
139
.XY_data_exchange:
140
	mov ecx,[image_file]
141
	mov eax,[ecx+4]
142
	mov ebx,[ecx+8]
143
	mov [ecx+8],eax
144
	mov [ecx+4],ebx
145
	ret
146
;---------------------------------------------------------------------
147
.clockwise:
148
	push edi esi
149
 
150
	add  edi,[size_y]
151
	sub  edi,[bytes_to_pixel]
152
.y:
153
	push edi
154
	push ebx
155
.x:
156
	call ebp
157
	add  edi,[size_y]
158
	dec  ebx
159
	jnz  .x
160
 
161
	pop ebx
162
	pop  edi
163
 
164
	sub  edi,[bytes_to_pixel]
165
	dec ecx
166
	jnz .y
167
 
168
	pop esi edi
169
	ret
170
;---------------------------------------------------------------------
171
.counter_clockwise:
172
	push edi esi
173
 
174
	mov  eax,[eax+4]
175
	dec  eax
176
	imul eax,[size_y]
177
	add  edi,eax
178
.y1:
179
	push edi
180
	push ebx
181
.x1:
182
	call ebp
183
	sub  edi,[size_y]
184
	dec  ebx
185
	jnz  .x1
186
 
187
	pop  ebx
188
	pop  edi
189
 
190
	add  edi,[bytes_to_pixel]
191
	dec  ecx
192
	jnz .y1
193
 
194
	pop  esi edi
195
	ret
196
;---------------------------------------------------------------------
197
.Left_Right:
198
	push edi esi
199
	add  edi,[size_x]
200
.y2:
201
	push edi
202
	push ebx
203
.x2:
204
	sub  edi,[bytes_to_pixel]
205
	call ebp
206
	dec  ebx
207
	jnz  .x2
208
 
209
	pop  ebx
210
	pop  edi
211
 
212
	add  edi,[size_x]
213
	dec  ecx
214
	jnz .y2
215
 
216
	pop  esi edi
217
	ret
218
;---------------------------------------------------------------------
219
.Up_Down:
220
	push edi esi
221
 
222
	mov  eax,[eax+8]
223
	dec  eax
224
	imul eax,[size_x]
225
	add  edi,eax
226
.y3:
227
	push edi
228
	push ebx
229
.x3:
230
	call ebp
231
	add  edi,[bytes_to_pixel]
232
	dec  ebx
233
	jnz  .x3
234
 
235
	pop  ebx
236
	pop  edi
237
 
238
	sub  edi,[size_x]
239
	dec  ecx
240
	jnz .y3
241
 
242
	pop  esi edi
243
	ret
244
;---------------------------------------------------------------------
245
.32:
246
	cld
247
	lodsd
248
	mov  [edi],eax
249
 
250
	ret
251
;---------------------------------------------------------------------
252
.24:
253
	cld
254
	lodsw
255
	mov  [edi],ax
256
	lodsb
257
	mov  [edi+2],al
258
	ret
259
;---------------------------------------------------------------------
260
.16:
261
	cld
262
	lodsw
263
	mov  [edi],ax
264
	ret
265
;---------------------------------------------------------------------
266
.8:
267
	cld
268
	lodsb
269
	mov  [edi],al
270
	ret
271
;---------------------------------------------------------------------
272
.get_memory:
273
	mov  ecx,[eax+4]
274
	imul ecx,[eax+8]
275
	imul ecx,[bytes_to_pixel]
276
	push eax
277
	mcall 68,12
278
	mov  [raw_area],eax
279
	mov  edi,eax
280
	pop  eax
281
	mov  ebx,[eax+4]
282
	mov  ecx,[eax+8]
283
	ret
284
;---------------------------------------------------------------------
285
align 16
286
EXPORTS:
287
	dd      szStart,	START
288
	dd      szVersion,	0x00010001
289
	dd      0
290
 
291
szStart		db 'START',0
292
szVersion	db 'version',0
293
 
294
pointer		dd 0
295
image_file	dd 0
296
direction	dd 0
297
size_x		dd 0
298
size_y		dd 0
299
bytes_to_pixel dd 0
300
;delta		dd 0
301
;resolution	dd 0
302
;compression	dd 0
303
raw_area	dd 0