annotate frbl/reconst/convert.c @ 329:63d3afd14523

frbl/reconst/serial.c: 0x7a static function reconstructed
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 06 Mar 2020 07:42:09 +0000
parents 6e442ed0f64d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
319
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include "main/sys_types.h"
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include "convert.h"
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 static SYS_UWORD8 *bss_0;
322
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
5 static enum {NO_STRING, IN_STRING} bss_4;
319
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 static SYS_UWORD16 bss_8;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 static SYS_UWORD8 bss_0xa;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 static SYS_UWORD32 bss_0xc;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 long
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 con_get_command_from_string(SYS_UWORD8 byte_to_analyze, SYS_UWORD8 *command)
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 {
322
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
13 long command_built = 0;
319
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 switch (bss_4) {
322
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
16 case NO_STRING:
319
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 /* 0x10 */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (byte_to_analyze == 0xAA) {
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 /* 0x18 */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 bss_0xc = (bss_0xc + 1) & 1;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 } else {
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 /* 0x26 */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 if (bss_0xc == 0)
322
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
24 break;
319
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 bss_0 = command + 1;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 bss_0xa = 0;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 bss_8 = byte_to_analyze;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 bss_0xc = 0;
322
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
29 bss_4 = IN_STRING;
319
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
322
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
31 break;
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
32 case IN_STRING:
319
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 /* 0x52 */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (byte_to_analyze == 0xAA) {
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 /* 0x5a */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (bss_0xc) {
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 /* 0x62 */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 *bss_0++ = byte_to_analyze;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 bss_0xa++;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 bss_0xc = 0;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 } else {
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 /* 0x7a */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 bss_0xc = 1;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 } else {
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 /* 0x82 */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 if (bss_0xc) {
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 /* 0x8a */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 bss_0 = command + 1;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 bss_0xa = 0;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 bss_8 = byte_to_analyze + 1;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 bss_0xc = 0;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 } else {
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 /* 0xa6 */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 *bss_0++ = byte_to_analyze;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 bss_0xa++;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 }
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 }
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 /* 0xbc */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 bss_8--;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 if (bss_8)
322
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
62 break;
319
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 *command = bss_0xa;
322
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
64 command_built = 1;
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
65 bss_4 = NO_STRING;
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
66 bss_0xc = 0;
319
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 /* FLUID hack */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 if (command[0] == 0x01 && command[1] == 0xDD)
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 fluid_bootloader();
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 /* end FLUID hack */
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 }
322
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
72 return command_built;
319
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 }
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 void
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 con_build_string_from_command(SYS_UWORD8 *command, SYS_UWORD8 *string,
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 SYS_UWORD16 *string_length)
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 {
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 SYS_UWORD16 sp12;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 SYS_UWORD8 *sp16;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 SYS_UWORD8 *sp20;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 sp16 = string + 1;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 sp20 = command++;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 *string = 0xAA;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 string += 2;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 *string_length = 0;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 for (sp12 = 0; sp12 < *sp20; sp12++) {
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 if (*command == 0xAA) {
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 *string++ = 0xAA;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 *string_length += 1;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 }
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 *string++ = *command++;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 *string_length += 1;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 }
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 *sp16 = *string_length;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 *string_length += 2;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 }
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 void
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 con_initialize_conversion(void)
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 {
322
6e442ed0f64d frbl/reconst/convert.c: perfect match to TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 320
diff changeset
103 bss_4 = NO_STRING;
319
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 bss_0xc = 0;
f9482000b838 frbl/reconst/convert.c: almost perfect reconstruction
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 }