]> Shamusworld >> Repos - virtualjaguar/blob - src/include/fbmpop4p.h
Initial revision
[virtualjaguar] / src / include / fbmpop4p.h
1                 int count=0;
2                 uint32 c;
3                 paletteRam+=idx*4;
4                 if (flags&FLAGS_READMODIFY)
5                 {
6                         if (flags&FLAGS_HFLIP)
7                         {
8                                 if (flags&FLAGS_TRANSPARENT)
9                                 {
10                                         while (iwidth)
11                                         {
12                                                 c=jaguar_byte_read(ptr++);
13                                                 uint32 cl=c>>4;
14                                                 uint32 ch=c&0x0f;
15                                                 if (cl)
16                                                 {
17                                                         *current_line_buffer--=BLEND_Y(*current_line_buffer,paletteRam[(cl<<1)+0]);
18                                                         *current_line_buffer--=BLEND_CC(*current_line_buffer,paletteRam[(cl<<1)+1]);
19                                                 }
20                                                 else
21                                                         current_line_buffer-=2;
22                                                 if (ch)
23                                                 {
24                                                         *current_line_buffer--=BLEND_Y(*current_line_buffer,paletteRam[(ch<<1)+0]);
25                                                         *current_line_buffer--=BLEND_CC(*current_line_buffer,paletteRam[(ch<<1)+1]);
26                                                 }
27                                                 else
28                                                         current_line_buffer-=2;
29                                                 count+=1;
30                                                 if (count==8) // 8 bytes = a phrase (64 bits)
31                                                 {
32                                                         ptr-=8*(pitch-1);
33                                                         count=0;
34                                                 }
35                                                 iwidth--;
36                                         }
37                                 }
38                                 else
39                                 {
40                                         while (iwidth)
41                                         {
42                                                 c=jaguar_byte_read(ptr++);
43                                                 uint32 cl=c>>4;
44                                                 uint32 ch=c&0x0f;
45                                                 *current_line_buffer--=BLEND_Y(*current_line_buffer,paletteRam[(cl<<1)+0]);
46                                                 *current_line_buffer--=BLEND_CC(*current_line_buffer,paletteRam[(cl<<1)+1]);
47                                                 *current_line_buffer--=BLEND_Y(*current_line_buffer,paletteRam[(ch<<1)+0]);
48                                                 *current_line_buffer--=BLEND_CC(*current_line_buffer,paletteRam[(ch<<1)+1]);
49                                                 count+=1;
50                                                 if (count==8) // 8 bytes = a phrase (64 bits)
51                                                 {
52                                                         ptr-=8*(pitch-1);
53                                                         count=0;
54                                                 }
55                                                 iwidth--;
56                                         }
57                                 }
58                         }
59                         else
60                         {
61                                 if (flags&FLAGS_TRANSPARENT)
62                                 {
63                                         while (iwidth)
64                                         {
65                                                 c=jaguar_byte_read(ptr++);
66                                                 uint32 cl=c>>4;
67                                                 uint32 ch=c&0x0f;
68                                                 if (cl)
69                                                 {
70                                                         *current_line_buffer++=BLEND_Y(*current_line_buffer,paletteRam[(cl<<1)+0]);
71                                                         *current_line_buffer++=BLEND_CC(*current_line_buffer,paletteRam[(cl<<1)+1]);
72                                                 }
73                                                 else
74                                                         current_line_buffer+=2;
75                                                 if (ch)
76                                                 {
77                                                         *current_line_buffer++=BLEND_Y(*current_line_buffer,paletteRam[(ch<<1)+0]);
78                                                         *current_line_buffer++=BLEND_CC(*current_line_buffer,paletteRam[(ch<<1)+1]);
79                                                 }
80                                                 else
81                                                         current_line_buffer+=2;
82                                                 count+=1;
83                                                 if (count==8) // 8 bytes = a phrase (64 bits)
84                                                 {
85                                                         ptr+=8*(pitch-1);
86                                                         count=0;
87                                                 }
88                                                 iwidth--;
89                                         }
90                                 }
91                                 else
92                                 {
93                                         while (iwidth)
94                                         {
95                                                 c=jaguar_byte_read(ptr++);
96                                                 uint32 cl=c>>4;
97                                                 uint32 ch=c&0x0f;
98                                                 *current_line_buffer++=BLEND_Y(*current_line_buffer,paletteRam[(cl<<1)+0]);
99                                                 *current_line_buffer++=BLEND_CC(*current_line_buffer,paletteRam[(cl<<1)+1]);
100                                                 *current_line_buffer++=BLEND_Y(*current_line_buffer,paletteRam[(ch<<1)+0]);
101                                                 *current_line_buffer++=BLEND_CC(*current_line_buffer,paletteRam[(ch<<1)+1]);
102                                                 iwidth--;
103                                                 count+=1;
104                                                 if (count==8) // 8 bytes = a phrase (64 bits)
105                                                 {
106                                                         ptr+=8*(pitch-1);
107                                                         count=0;
108                                                 }
109                                         }
110                                 }
111                         }
112                 }
113                 else
114                 {
115                         if (flags&FLAGS_HFLIP)
116                         {
117                                 if (flags&FLAGS_TRANSPARENT)
118                                 {
119                                         while (iwidth)
120                                         {
121                                                 c=jaguar_byte_read(ptr++);
122                                                 uint32 cl=c>>4;
123                                                 uint32 ch=c&0x0f;
124                                                 if (cl)
125                                                 {
126                                                         *current_line_buffer--=paletteRam[(cl<<1)+0];
127                                                         *current_line_buffer--=paletteRam[(cl<<1)+1];
128                                                 }
129                                                 else
130                                                         current_line_buffer-=2;
131                                                 if (ch)
132                                                 {
133                                                         *current_line_buffer--=paletteRam[(ch<<1)+0];
134                                                         *current_line_buffer--=paletteRam[(ch<<1)+1];
135                                                 }
136                                                 else
137                                                         current_line_buffer-=2;
138                                                 count+=1;
139                                                 if (count==8) // 8 bytes = a phrase (64 bits)
140                                                 {
141                                                         ptr-=8*(pitch-1);
142                                                         count=0;
143                                                 }
144                                                 iwidth--;
145                                         }
146                                 }
147                                 else
148                                 {
149                                         while (iwidth)
150                                         {
151                                                 c=jaguar_byte_read(ptr++);
152                                                 uint32 cl=c>>4;
153                                                 uint32 ch=c&0x0f;
154                                                 *current_line_buffer--=paletteRam[(cl<<1)+0];
155                                                 *current_line_buffer--=paletteRam[(cl<<1)+1];
156                                                 *current_line_buffer--=paletteRam[(ch<<1)+0];
157                                                 *current_line_buffer--=paletteRam[(ch<<1)+1];
158                                                 count+=1;
159                                                 if (count==8) // 8 bytes = a phrase (64 bits)
160                                                 {
161                                                         ptr-=8*(pitch-1);
162                                                         count=0;
163                                                 }
164                                                 iwidth--;
165                                         }
166                                 }
167                         }
168                         else
169                         {
170                                 if (flags&FLAGS_TRANSPARENT)
171                                 {
172                                         while (iwidth)
173                                         {
174                                                 c=jaguar_byte_read(ptr++);
175                                                 uint32 cl=c>>4;
176                                                 uint32 ch=c&0x0f;
177                                                 if (cl)
178                                                 {
179                                                         *current_line_buffer++=paletteRam[(cl<<1)+0];
180                                                         *current_line_buffer++=paletteRam[(cl<<1)+1];
181                                                 }
182                                                 else
183                                                         current_line_buffer+=2;
184                                                 if (ch)
185                                                 {
186                                                         *current_line_buffer++=paletteRam[(ch<<1)+0];
187                                                         *current_line_buffer++=paletteRam[(ch<<1)+1];
188                                                 }
189                                                 else
190                                                         current_line_buffer+=2;
191                                                 count+=1;
192                                                 if (count==8) // 8 bytes = a phrase (64 bits)
193                                                 {
194                                                         ptr+=8*(pitch-1);
195                                                         count=0;
196                                                 }
197                                                 iwidth--;
198                                         }
199                                 }
200                                 else
201                                 {
202                                         while (iwidth)
203                                         {
204                                                 c=jaguar_byte_read(ptr++);
205                                                 uint32 cl=c>>4;
206                                                 uint32 ch=c&0x0f;
207                                                 *current_line_buffer++=paletteRam[(cl<<1)+0];
208                                                 *current_line_buffer++=paletteRam[(cl<<1)+1];
209                                                 *current_line_buffer++=paletteRam[(ch<<1)+0];
210                                                 *current_line_buffer++=paletteRam[(ch<<1)+1];
211                                                 count+=1;
212                                                 if (count==8) // 8 bytes = a phrase (64 bits)
213                                                 {
214                                                         ptr+=8*(pitch-1);
215                                                         count=0;
216                                                 }
217                                                 iwidth--;
218                                         }
219                                 }
220                         }
221                 }