Subversion Repositories Kolibri OS

Rev

Rev 1580 | Rev 1728 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1580 Rev 1593
Line 71... Line 71...
71
;> _length = data length                                                                          ;;
71
;> _length = data length                                                                          ;;
72
;;------------------------------------------------------------------------------------------------;;
72
;;------------------------------------------------------------------------------------------------;;
73
;< eax = 0 (error) or pointer to image                                                            ;;
73
;< eax = 0 (error) or pointer to image                                                            ;;
74
;;================================================================================================;;
74
;;================================================================================================;;
75
locals
75
locals
76
;  IMGwidth      dd ?
-
 
77
;  IMGheight     dd ?
-
 
78
;  IMGbpp        dd ?
-
 
79
buf                 rb      1
-
 
80
nplanes             rd      1
76
nplanes             rd      1
81
xsize               rw      1
77
xsize               rw      1
82
ysize               rw      1
78
ysize               rw      1
83
stxsize             rw      1
-
 
84
stysize             rw      1
79
bpl                 rw      1
85
total_bpl           rd      1
80
total_bpl           rd      1
86
total_bpl_tmp       rd      1
-
 
87
line_begin          rd      1
81
line_begin          rd      1
88
retvalue            rd      1
82
retvalue            rd      1                       ; 0 (error) or pointer to image 
89
 
-
 
90
endl
83
endl
Line 91... Line 84...
91
 
84
 
Line 92... Line 85...
92
    pusha
85
    pusha
93
 
-
 
94
    mov     esi,    [_data]
-
 
95
 
-
 
96
    cmp     [esi+pcx_header.bpp],   1
-
 
97
     jz     monochrome
-
 
98
    cmp     byte[esi+pcx_header.nplanes],   3
-
 
99
     jnz    indexed
-
 
100
 
-
 
101
 
-
 
102
 
-
 
103
  _24bit:
86
 
104
    xor     eax,   eax
87
    mov     esi,    [_data]
105
    mov     al,    byte[esi+pcx_header.nplanes]
88
    movzx   eax,    byte[esi+pcx_header.nplanes]
-
 
89
    mov     [nplanes],  eax
-
 
90
    mov     bx,  word[esi+pcx_header.bpl]
-
 
91
    mov     [bpl],  bx
-
 
92
    mul     bx
-
 
93
    shl     eax,    16
106
    mov     [nplanes],  eax
94
    mov     ax,     dx
Line 107... Line 95...
107
    mul     word[esi+pcx_header.bpl]
95
    ror     eax,    16
108
    mov     [total_bpl],    eax
96
    mov     [total_bpl],    eax
109
 
97
 
Line 115... Line 103...
115
    movzx   ebx,    word[esi+pcx_header.ymax]
103
    movzx   ebx,    word[esi+pcx_header.ymax]
116
    inc     bx
104
    inc     bx
117
    sub     bx,     word[esi+pcx_header.ymin]
105
    sub     bx,     word[esi+pcx_header.ymin]
118
    mov     [ysize],    bx
106
    mov     [ysize],    bx
Line -... Line 107...
-
 
107
 
-
 
108
 
-
 
109
    cmp     [esi+pcx_header.bpp],   1
-
 
110
     jz     .monochrome
-
 
111
    cmp     byte[esi+pcx_header.nplanes],   3
-
 
112
     jnz    .indexed
-
 
113
 
-
 
114
 
-
 
115
  ._24bit:
119
 
116
 
120
      stdcall   img.create, eax, ebx, Image.bpp24
117
      stdcall   img.create, eax, ebx, Image.bpp24
121
    mov     [retvalue], eax
118
    mov     [retvalue], eax
122
    test    eax,    eax
119
    test    eax,    eax
Line 132... Line 129...
132
    mov     [eax+Image.Checksum],   ebx
129
    mov     [eax+Image.Checksum],   ebx
Line 133... Line 130...
133
 
130
 
134
 
131
 
135
    mov     esi,    [_data]
132
    mov     esi,    [_data]
136
    add     esi,    128
133
    add     esi,    128
137
    mov     edi,    [retvalue]
134
;    mov     edi,    [retvalue]
138
    mov     edi,    [edi+Image.Data]
135
    mov     edi,    [eax+Image.Data]
139
    add     edi,    2
136
    add     edi,    2
Line 140... Line 137...
140
    mov     [line_begin],   edi
137
    mov     [line_begin],   edi
141
    mov     ebx,    [total_bpl]
138
    mov     ebx,    [total_bpl]
142
 
-
 
143
  .begin:
139
 
144
    mov     eax,    [_data]
-
 
145
    mov     ax,     word[eax+pcx_header.bpl]
-
 
146
  .decode:
-
 
147
    mov     dl,     byte[esi]
-
 
148
    inc     esi
-
 
149
    mov     [buf],  dl
-
 
150
    and     dl,     0xC0
140
  ._24bit.begin:
151
    cmp     dl,     0xC0
-
 
152
     jne    @f
-
 
153
    mov     dl,     byte[buf]
-
 
154
    and     dl,     0x3F
-
 
155
    mov     dh,     [esi]
141
    mov     ax,     word[bpl]
156
    inc     esi
142
  ._24bit.decode:
157
 
143
      call      get_byte
158
  .write_sequence:
-
 
159
    mov     [edi], dh
144
  ._24bit.write_sequence:
160
    dec     ax
145
    mov     [edi],  dl
161
    dec     ebx
-
 
162
    add     edi,    [nplanes]
146
    dec     ax
Line 163... Line 147...
163
    dec     dl
147
    add     edi,    [nplanes]
164
    test    dl,     dl
148
    dec     dh
165
     jnz    .write_sequence
-
 
166
 
-
 
167
    test    ax,     ax
-
 
168
     jz     .end_color_line
-
 
169
     jmp    .decode
-
 
170
  @@:
-
 
171
    mov     dl,     byte[buf]
-
 
172
    mov     [edi],  dl
-
 
173
    add     edi, [nplanes]
149
     jnz    ._24bit.write_sequence
Line 174... Line 150...
174
    dec     ebx
150
 
175
    dec     ax
151
    test    ax,     ax
176
     jz     .end_color_line
152
     jz     ._24bit.end_color_line
177
     jmp    .decode
153
     jmp    ._24bit.decode
178
 
154
 
179
 .end_color_line:
155
 ._24bit.end_color_line:
Line 180... Line 156...
180
    test    ebx,    ebx
156
    test    ebx,    ebx
181
     jz     .end_full_line
157
     jz     ._24bit.end_full_line
182
    dec     [line_begin]
158
    dec     [line_begin]
183
    mov     edi,    [line_begin]
159
    mov     edi,    [line_begin]
184
     jmp    .begin
160
     jmp    ._24bit.begin
185
 
161
 
186
  .end_full_line:
162
  ._24bit.end_full_line:
187
    dec     word[ysize]
-
 
188
     jz     .quit
-
 
189
    mov     ebx,    [total_bpl]
-
 
190
    add     edi,    2
-
 
191
    mov     [line_begin],   edi
-
 
192
     jmp    .begin
-
 
193
 
-
 
Line 194... Line -...
194
  .quit:
-
 
195
    popa
-
 
196
    mov     eax,    [retvalue]
-
 
197
    ret
-
 
198
 
-
 
Line 199... Line -...
199
  indexed:
-
 
200
 
-
 
201
    xor     eax,   eax
-
 
202
    mov     al,    byte[esi+pcx_header.nplanes]
-
 
203
    mov     [nplanes],  eax
-
 
204
    mul     word[esi+pcx_header.bpl]
-
 
205
    mov     [total_bpl],    eax
163
    dec     word[ysize]
206
 
-
 
207
    movzx   eax,    word[esi+pcx_header.xmax]
-
 
Line 208... Line 164...
208
    inc     ax
164
     jz     .quit
209
    sub     ax,     word[esi+pcx_header.xmin]
165
    mov     ebx,    [total_bpl]
210
    mov     [xsize],    ax
166
    add     edi,    2
211
 
167
    mov     [line_begin],   edi
Line -... Line 168...
-
 
168
     jmp    ._24bit.begin
-
 
169
 
-
 
170
 
-
 
171
  .indexed:
-
 
172
 
-
 
173
      stdcall   img.create, eax, ebx, Image.bpp8
-
 
174
    mov     [retvalue], eax
-
 
175
    test    eax,    eax
-
 
176
     jz     .quit
212
    movzx   ebx,    word[esi+pcx_header.ymax]
177
 
213
    inc     bx
178
    movzx   ebx,    [xsize]
214
    sub     bx,     word[esi+pcx_header.ymin]
179
    movzx   ecx,    [ysize]
215
    mov     [ysize],    bx
180
    mov     edx,    [eax+Image.Data]
216
 
181
 
217
      stdcall   img.create, eax, ebx, Image.bpp8
182
    rol     ebx,    16
218
    mov     [retvalue], eax
183
    or      ebx,    ecx
219
    test    eax,    eax
-
 
220
     jz     .quit
184
    xor     ebx,    [edx]
221
 
185
    mov     [eax+Image.Checksum],   ebx
222
    mov     esi,    [_data]
186
 
223
    add     esi,    [_length]
187
    mov     esi,    [_data]
224
    sub     esi,    768
188
    add     esi,    [_length]
225
    mov     edi,    [eax+Image.Palette]
189
    sub     esi,    768
226
    mov     ecx,    256
190
    mov     edi,    [eax+Image.Palette]
Line 227... Line -...
227
  @@:
-
 
228
    mov     ebx,    [esi]
-
 
229
    and     ebx,    0x00ffffff
-
 
230
    bswap   ebx
-
 
231
    shr     ebx,    8
-
 
232
    mov     [edi],  ebx
-
 
233
    add     edi,    4
-
 
234
    add     esi,    3
-
 
235
    dec     ecx
-
 
236
     jnz    @b
-
 
237
 
191
    mov      cx,    256
238
    movzx   ebx,    [xsize]
192
  @@:
239
    movzx   ecx,    [ysize]
193
    mov     ebx,    [esi]
240
    mov     edx,    [eax+Image.Data]
194
    bswap   ebx
241
 
-
 
242
    rol     ebx,    16
-
 
243
    or      ebx,    ecx
-
 
244
    xor     ebx,    [edx]
-
 
245
    mov     [eax+Image.Checksum],   ebx
-
 
246
 
-
 
247
 
-
 
248
    mov     esi,    [_data]
-
 
249
    add     esi,    128
-
 
250
    mov     edi,    [retvalue]
-
 
251
    mov     edi,    [edi+Image.Data]
-
 
252
 
-
 
253
  .begin:
-
 
254
    mov     eax,    [_data]
-
 
255
    mov     ax,     word[eax+pcx_header.bpl]
-
 
Line -... Line 195...
-
 
195
    shr     ebx,    8
-
 
196
    mov     [edi],  ebx
-
 
197
    add     edi,    4
-
 
198
    add     esi,    3
256
  .decode:
199
    dec     cx
257
    mov     dl,     byte[esi]
200
     jnz    @b
258
    inc     esi
201
 
259
    mov     [buf],  dl
202
    mov     esi,    [_data]
260
    and     dl,     0xC0
203
    add     esi,    128
261
    cmp     dl,     0xC0
204
;    mov     edi,    [retvalue]
Line 262... Line 205...
262
     jne    @f
205
    mov     edi,    [eax+Image.Data]
263
    mov     dl,     [buf]
206
 
264
    and     dl,     0x3F
207
  .indexed.begin:
265
    mov     dh,     [esi]
-
 
266
    inc     esi
-
 
267
 
-
 
268
  .write_sequence:
-
 
269
    mov     [edi], dh
-
 
270
    inc     edi
-
 
271
    dec     ax
-
 
Line 272... Line 208...
272
    dec     dl
208
    mov     ax,     word[bpl]
273
     jnz    .write_sequence
209
  .indexed.decode:
274
 
210
      call      get_byte
275
    test    ax,     ax
211
  .indexed.write_sequence:
Line 276... Line -...
276
     jz     .end_line
-
 
277
     jmp    .decode
-
 
278
  @@:
-
 
279
    mov     dl,     byte[buf]
-
 
280
    mov     [edi],  dl
-
 
281
    inc     edi
-
 
282
    dec     ax
-
 
283
     jz     .end_line
-
 
284
     jmp    .decode
-
 
285
 
-
 
286
  .end_line:
-
 
287
    dec     word[ysize]
-
 
288
     jz     .quit
-
 
289
     jmp    .begin
-
 
290
 
-
 
291
  .quit:
-
 
Line 292... Line -...
292
    popa
-
 
293
    mov     eax,    [retvalue]
212
    mov     [edi], dl
294
    ret
-
 
295
 
-
 
Line 296... Line 213...
296
 
213
    inc     edi
297
  monochrome:
214
    dec     ax
298
 
215
    dec     dh
299
    xor     eax,    eax
216
     jnz    .indexed.write_sequence
Line 300... Line -...
300
    mov     ax,     word[esi+pcx_header.bpl]
-
 
301
    mov     [total_bpl],    eax
-
 
302
 
-
 
303
    movzx   eax,    word[esi+pcx_header.xmax]
-
 
304
    inc     ax
217
 
305
    sub     ax,     word[esi+pcx_header.xmin]
218
    test    ax,     ax
306
    mov     [xsize],    ax
219
     jz     .indexed.end_line
Line 307... Line 220...
307
 
220
     jmp    .indexed.decode
308
    movzx   ebx,    word[esi+pcx_header.ymax]
221
 
309
    inc     bx
222
  .indexed.end_line:
310
    sub     bx,     word[esi+pcx_header.ymin]
223
    dec     word[ysize]
Line -... Line 224...
-
 
224
     jz     .quit
-
 
225
     jmp    .indexed.begin
-
 
226
 
Line 311... Line 227...
311
    mov     [ysize],    bx
227
 
312
 
228
  .monochrome:
313
      stdcall   img.create, eax, ebx, Image.bpp8
229
 
314
    mov     [retvalue], eax
230
      stdcall   img.create, eax, ebx, Image.bpp1
315
    test    eax,    eax
-
 
316
     jz     .quit
-
 
317
 
-
 
318
    mov     edi,    [eax+Image.Palette]
-
 
319
    mov     [edi],  dword   0x00000000
-
 
320
    mov     [edi+4],    dword   0x00ffffff
-
 
321
 
-
 
Line 322... Line -...
322
    movzx   ebx,    [xsize]
-
 
323
    movzx   ecx,    [ysize]
-
 
324
    mov     edx,    [eax+Image.Data]
-
 
325
 
-
 
326
    rol     ebx,    16
-
 
327
    or      ebx,    ecx
-
 
328
    xor     ebx,    [edx]
-
 
329
    mov     [eax+Image.Checksum],   ebx
-
 
330
 
-
 
331
 
-
 
332
    mov     esi,    [_data]
-
 
333
    add     esi,    128
-
 
334
    mov     edi,    [retvalue]
-
 
335
    mov     edi,    [edi+Image.Data]
-
 
336
 
-
 
337
  .begin:
-
 
338
    mov     eax,    [total_bpl]
-
 
339
    mov     [total_bpl_tmp],    eax
-
 
340
    mov     ax,     [xsize]
-
 
341
 
-
 
Line -... Line 231...
-
 
231
    mov     [retvalue], eax
-
 
232
    test    eax,    eax
-
 
233
     jz     .quit
Line 342... Line 234...
342
  .decode:
234
 
343
 
235
    movzx   ebx,    [xsize]
344
    mov     dh,     byte[esi]
-
 
345
    inc     esi
-
 
346
    mov     [buf],  dh
-
 
347
    and     dh,     0xC0
236
    movzx   ecx,    [ysize]
348
    cmp     dh,     0xC0
-
 
349
     je    .cycle1
-
 
350
    mov     dh,     1
237
    mov     edx,    [eax+Image.Data]
351
    mov     dl,     [buf]
-
 
352
     jmp    .exit1
238
 
353
  .cycle1:
-
 
354
    mov     dh,     [buf]
-
 
355
    and     dh,     0x3F
-
 
356
    mov     dl,     byte[esi]
-
 
357
    inc     esi
-
 
358
  .exit1:
-
 
359
    push    eax
-
 
360
    xor     eax,    eax
-
 
361
    mov     al,     dh
-
 
362
    sub     [total_bpl_tmp],    eax
-
 
363
    pop     eax
239
    rol     ebx,    16
364
 
240
    or      ebx,    ecx
365
 
241
    xor     ebx,    [edx]
366
  .write_sequence:
-
 
367
    mov     ecx,    7
-
 
368
  .go:
-
 
369
    bt      edx,    ecx
-
 
370
     jnc    @f
-
 
371
    mov     [edi],  byte    0x01
-
 
372
     jmp    .later
242
    mov     [eax+Image.Checksum],   ebx
373
  @@:
-
 
374
    mov     [edi],  byte    0x00
-
 
375
  .later:
-
 
376
    inc     edi
-
 
377
    dec     ax
243
 
378
     jnz    .lol
244
    mov     edi,    [eax+Image.Palette]
Line -... Line 245...
-
 
245
    mov     [edi],  dword   0x00000000
-
 
246
    mov     [edi+4],    dword   0x00ffffff
379
  @@:
247
 
-
 
248
    mov     esi,    [_data]
-
 
249
    add     esi,    128
380
    cmp     [total_bpl_tmp],    0
250
;    mov     edi,    [retvalue]
381
     jng    @f
251
    mov     edi,    [eax+Image.Data]
382
 
252
 
383
    mov     dh,     byte[esi]
253
 
384
    inc     esi
254
  .monochrome.begin:
385
    mov     [buf],  dh
-
 
386
    and     dh,     0xC0
-
 
387
    cmp     dh,     0xC0
-
 
388
     je    .cycle2
-
 
389
    mov     dh,     1
-
 
390
    mov     dl,     [buf]
-
 
Line 391... Line 255...
391
     jmp    .exit2
255
    mov     ebx,    [total_bpl]
392
  .cycle2:
256
    mov     ax,     [xsize]
393
    mov     dh,     [buf]
257
 
394
    and     dh,     0x3F
258
  .monochrome.decode:
Line 443... Line 307...
443
;;================================================================================================;;
307
;;================================================================================================;;
444
;! Below are private procs you should never call directly from your code                          ;;
308
;! Below are private procs you should never call directly from your code                          ;;
445
;;================================================================================================;;
309
;;================================================================================================;;
446
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
310
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
447
;;================================================================================================;;
311
;;================================================================================================;;
-
 
312
proc get_byte
-
 
313
 
-
 
314
    mov     dh,     byte[esi]
-
 
315
    inc     esi
-
 
316
    cmp     dh,     0xC0
-
 
317
     jnb    .cycle1
-
 
318
    mov     dl,     dh
-
 
319
    mov     dh,     1
-
 
320
     jmp    .exit1
-
 
321
  .cycle1:
-
 
322
    and     dh,     0x3F
-
 
323
    mov     dl,     byte[esi]
-
 
324
    inc     esi
-
 
325
  .exit1:
-
 
326
    movzx   ecx,     dh
-
 
327
    sub     ebx,    ecx
Line -... Line 328...
-
 
328
 
-
 
329
    ret
448
 
330
endp
449
;;================================================================================================;;
331
;;================================================================================================;;
450
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
332
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
451
;;================================================================================================;;
333
;;================================================================================================;;
452
;! Below is private data you should never use directly from your code                             ;;
334
;! Below is private data you should never use directly from your code                             ;;