]> icculus.org git repositories - btb/d2x.git/blob - 2d/bitmap.h
fixed gr_remap_font, minor stuff
[btb/d2x.git] / 2d / bitmap.h
1 #ifndef _BITMAP_H
2 #define _BITMAP_H
3
4 #ifndef NO_ASM
5 #ifdef __WATCOMC__
6 void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count );
7 #pragma aux decode_data_asm parm [esi] [ecx] [edi] [ebx] modify exact [esi edi eax ebx ecx] = \
8 "again_ddn:"                            \
9     "xor    eax,eax"                \
10     "mov    al,[esi]"           \
11     "inc    dword ptr [ebx+eax*4]"      \
12     "mov    al,[edi+eax]"       \
13     "mov    [esi],al"           \
14     "inc    esi"                    \
15     "dec    ecx"                    \
16     "jne    again_ddn"
17 #elif defined __GNUC__
18 static inline void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count ) {
19         int dummy[4];
20    __asm__ __volatile__ (
21     "xorl   %%eax,%%eax;"
22 "0:;"
23     "movb   (%%esi), %%al;"
24     "incl   (%%ebx, %%eax, 4);"
25     "movb   (%%edi, %%eax), %%al;"
26     "movb   %%al, (%%esi);"
27     "incl   %%esi;"
28     "decl   %%ecx;"
29     "jne    0b"
30     : "=S" (dummy[0]), "=c" (dummy[1]), "=D" (dummy[2]), "=b" (dummy[3])
31         : "0" (data), "1" (num_pixels), "2" (colormap), "3" (count)
32         : "%eax");
33 }
34 #elif defined _MSC_VER
35 __inline void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count )
36 {
37   __asm {
38         mov esi,[data]
39         mov ecx,[num_pixels]
40         mov edi,[colormap]
41         mov ebx,[count]
42 again_ddn:
43         xor eax,eax
44         mov al,[esi]
45         inc dword ptr [ebx+eax*4]
46         mov al,[edi+eax]
47         mov [esi],al
48         inc esi
49         dec ecx
50         jne again_ddn
51   }
52 }
53 #else
54 #define NO_ASM 1 // We really do want no assembler...
55 #endif
56 #endif
57
58 #ifdef NO_ASM
59 static void decode_data_asm(ubyte *data, int num_pixels, ubyte *colormap, int *count)
60 {
61         int i;
62         ubyte mapped;
63         
64         for (i = 0; i < num_pixels; i++) {
65                 count[*data]++;
66                 mapped = *data;
67                 *data = colormap[mapped];
68                 data++;
69         }
70 }
71 #endif
72 #endif