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

Function Format40_Decode

src/codec/format40.c:14–60  ·  view source on GitHub ↗

* Decode a memory fragment which is encoded with 'format40'. * @param dst The place the decoded fragment will be loaded. * @param src The encoded fragment. */

Source from the content-addressed store, hash-verified

12 * @param src The encoded fragment.
13 */
14void Format40_Decode(uint8 *dst, uint8 *src)
15{
16 uint16 cmd;
17 uint16 count;
18
19 for (;;) {
20 cmd = *src++; /* 8 bit command code */
21
22 if (cmd == 0) {
23 /* XOR with value */
24 for (count = *src++; count > 0; count--) {
25 *dst++ ^= *src;
26 }
27 src++;
28 } else if ((cmd & 0x80) == 0) {
29 /* XOR with string */
30 for (count = cmd; count > 0; count--) {
31 *dst++ ^= *src++;
32 }
33 } else if (cmd != 0x80) {
34 /* skip bytes */
35 dst += (cmd & 0x7F);
36 } else {
37 /* last byte was 0x80 : read 16 bit value */
38 cmd = *src++;
39 cmd += (*src++) << 8;
40
41 if (cmd == 0) break; /* 0x80 0x00 0x00 => exit code */
42
43 if ((cmd & 0x8000) == 0) {
44 /* skip bytes */
45 dst += cmd;
46 } else if ((cmd & 0x4000) == 0) {
47 /* XOR with string */
48 for (count = cmd & 0x3FFF; count > 0; count--) {
49 *dst++ ^= *src++;
50 }
51 } else {
52 /* XOR with value */
53 for (count = cmd & 0x3FFF; count > 0; count--) {
54 *dst++ ^= *src;
55 }
56 src++;
57 }
58 }
59 }
60}
61
62
63/**

Callers 2

WSA_GotoNextFrameFunction · 0.85
WSA_DisplayFrameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected