MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Format40_Decode_ToScreen

Function Format40_Decode_ToScreen

src/codec/format40.c:156–235  ·  view source on GitHub ↗

* Copy a rectangle from a format40 compressed data source to the screen. * @param base Base of the rectangle (top-left pixel). * @param src Data source. * @param width Width of the rectangle. */

Source from the content-addressed store, hash-verified

154 * @param width Width of the rectangle.
155 */
156void Format40_Decode_ToScreen(uint8 *dst, uint8 *src, uint16 width)
157{
158 uint16 length;
159 uint16 cmd;
160 uint16 count;
161
162 length = 0;
163
164 for (;;) {
165 cmd = *src++; /* 8 bit command code */
166
167 if (cmd == 0) {
168 /* fill with value */
169 for (count = *src++; count > 0; count--) {
170 *dst++ = *src;
171 length++;
172 if (length == width) {
173 length = 0;
174 dst += (SCREEN_WIDTH - width);
175 }
176 }
177 src++;
178 } else if ((cmd & 0x80) == 0) {
179 /* copy string */
180 for (count = cmd & 0x7F; count > 0; count--) {
181 *dst++ = *src++;
182 length++;
183 if (length == width) {
184 length = 0;
185 dst += (SCREEN_WIDTH - width);
186 }
187 }
188 } else if (cmd != 0x80) {
189 /* skip bytes */
190 dst += cmd & 0x7F;
191 length += cmd & 0x7F;
192 while (length >= width) {
193 length -= width;
194 dst += (SCREEN_WIDTH - width);
195 }
196 } else {
197 /* last byte was 0x80 : read 16 bit value */
198 cmd = *src++;
199 cmd += (*src++) << 8;
200
201 if (cmd == 0) break; /* 0x80 0x00 0x00 => exit code */
202
203 if ((cmd & 0x8000) == 0) {
204 /* skip bytes */
205 dst += cmd;
206 length += cmd;
207 while (length >= width) {
208 length -= width;
209 dst += (SCREEN_WIDTH - width);
210 }
211 } else if ((cmd & 0x4000) == 0) {
212 /* copy string */
213 for (count = cmd & 0x3FFF; count > 0; count--) {

Callers 1

WSA_DisplayFrameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected