Word Unperfect
public
Read
Owner: themaster
Branch: main
Commits: 0
Git CLI clone URL
git clone https://www.xt-emporium.com/git/word-unperfect.git
Fullscreen desktop URL
Code
Commits
History
Branches
Bug Reports
Discussions
Compare
Settings
word-unperfect
/
rev
/
wp_fixed_codes.c
File editor
#include "wp_fixed_codes.h" #include <stddef.h> #include <stdio.h> static const WpFixedCodeInfo s_fixed_codes[] = { /* firmware_io_scanner_word_route_step @ 3000:1189: b==0xC0 => uVar9=4. */ {0xC0U, 4U, 2U, true, "Extended character"}, /* The decompiled scanner routes 0xC1-0xCF through a fixed-length table * before the 0xD0+ variable-record path. The table rows below are the * concrete mirrored packet shapes recovered from the bundled WP51 document, * tutorial, and workbook streams. Treating these as packets prevents their * payload bytes/trailers from leaking into the text/export stream. */ {0xC1U, 9U, 7U, true, "Fixed C1 format packet"}, {0xC2U, 11U, 9U, true, "Fixed C2 format packet"}, {0xC3U, 3U, 1U, true, "Fixed C3 begin/on packet"}, {0xC4U, 3U, 1U, true, "Fixed C4 end/off packet"}, {0xC5U, 5U, 3U, true, "Fixed C5 format packet"}, {0xC6U, 6U, 4U, true, "Fixed C6 format packet"}, {0xC8U, 1U, 0U, false, "Fixed C8 packet"} }; const WpFixedCodeInfo *wp_fixed_code_info(uint8_t code) { size_t i; for (i = 0; i < sizeof(s_fixed_codes) / sizeof(s_fixed_codes[0]); ++i) { if (s_fixed_codes[i].code == code) { return &s_fixed_codes[i]; } } return 0; } uint16_t wp_fixed_code_total_length(uint8_t code) { const WpFixedCodeInfo *info = wp_fixed_code_info(code); return info != 0 ? info->total_length : 0U; } const char *wp_fixed_code_name(uint8_t code) { const WpFixedCodeInfo *info = wp_fixed_code_info(code); return info != 0 ? info->name : "Fixed-length format code"; } bool wp_fixed_code_is_known(uint8_t code) { return wp_fixed_code_info(code) != 0; } bool wp_fixed_code_describe_payload(uint8_t code, const uint8_t *payload, uint16_t payload_length, char *out, size_t out_size) { if (out == 0 || out_size == 0U) { return false; } out[0] = '\0'; if (payload == 0 && payload_length != 0U) { return false; } switch (code) { case 0xC0U: if (payload_length >= 2U) { snprintf(out, out_size, "ext-set=0x%02X ext-index=0x%02X", (unsigned)payload[0], (unsigned)payload[1]); return true; } break; case 0xC1U: if (payload_length >= 7U) { snprintf(out, out_size, "c1-fields=%02X %02X %02X %02X %02X %02X %02X", (unsigned)payload[0], (unsigned)payload[1], (unsigned)payload[2], (unsigned)payload[3], (unsigned)payload[4], (unsigned)payload[5], (unsigned)payload[6]); return true; } break; case 0xC2U: if (payload_length >= 9U) { snprintf(out, out_size, "c2-fields=%02X %02X %02X %02X %02X %02X %02X %02X %02X", (unsigned)payload[0], (unsigned)payload[1], (unsigned)payload[2], (unsigned)payload[3], (unsigned)payload[4], (unsigned)payload[5], (unsigned)payload[6], (unsigned)payload[7], (unsigned)payload[8]); return true; } break; case 0xC3U: case 0xC4U: if (payload_length >= 1U) { snprintf(out, out_size, "paired-code=0x%02X", (unsigned)payload[0]); return true; } break; case 0xC5U: if (payload_length >= 3U) { snprintf(out, out_size, "c5-fields=%02X %02X %02X", (unsigned)payload[0], (unsigned)payload[1], (unsigned)payload[2]); return true; } break; case 0xC6U: if (payload_length >= 4U) { snprintf(out, out_size, "c6-fields=%02X %02X %02X %02X", (unsigned)payload[0], (unsigned)payload[1], (unsigned)payload[2], (unsigned)payload[3]); return true; } break; case 0xC8U: (void)payload_length; snprintf(out, out_size, "zero-payload fixed packet"); return true; default: break; } return false; }
Commit message
This repository is read-only for this account.
Repository snapshot
Current branch
main
Visibility
public
Your access
Read
Remote
None
File activity
View file history