From c9cbeced5b3f2bdd7407e29c0811e65954132540 Mon Sep 17 00:00:00 2001 From: Root THC Date: Tue, 24 Feb 2026 12:42:47 +0000 Subject: initial --- other/Kermit/src/readsym.cpp | 123 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 other/Kermit/src/readsym.cpp (limited to 'other/Kermit/src/readsym.cpp') diff --git a/other/Kermit/src/readsym.cpp b/other/Kermit/src/readsym.cpp new file mode 100644 index 0000000..541d594 --- /dev/null +++ b/other/Kermit/src/readsym.cpp @@ -0,0 +1,123 @@ +/* + * readsym.cpp: + * written by palmers / teso + */ +#include +#include +#include + +#define PROGRAM "readsym" +#define VERSION "0.1" +#define AUTHOR "palmers / teso" + + +void dump_c_array (char *arr, char *b, int x) +{ + int y; + cout.setf (ios::hex, ios::basefield); + cout << "char " << arr << "[] = {" << endl; + for (y = 0; y < x; y++) + { + cout << "0x" << ((int) b[y] & 0xff); + if (y != (x - 1)) + cout << ", "; + if (!(y % 10)) + cout << endl; + } + cout << endl << "};" << endl; + cout.setf (ios::dec, ios::basefield); +} + + +void dump (char *a, int x) +{ + int y; + cout.setf (ios::hex, ios::basefield); + + for (y = 0; y < x; y++) + { + if ((a[y] & 0xff) < 16) + cout << '0'; + cout << ((int) a[y] & 0xff) << ' '; + } + cout.setf (ios::dec, ios::basefield); + cout << endl; +} + +void usage (char *a) +{ + cout << PROGRAM << VERSION << " by " << AUTHOR << endl; + cout << endl; + cout << "Usage: " << a << " [options] " << endl; + cout << "Options:" << endl; + cout << "\t-x:\t where x is 1, 2, 3: the amount of ram in GB the system is ought to run" << endl; + cout << "\t-c :\t dump the read data as a c array" << endl; + cout << endl; + exit (0); +} + + +int main (int argc, char **argv) +{ + rwKernel *rw = NULL; + char *inBuf = NULL, + *arr_name = NULL; + unsigned long length = 0, + offset = CONF_1GB; + int x = 0; + + if (argc < 4) + usage (argv[0]); + + while (x < argc) + { + if (argv[x][0] == '-') + { + switch (argv[x][1]) + { + case '1': + offset = CONF_1GB; + break; + case '2': + offset = CONF_2GB; + break; + case '3': + offset = CONF_3GB; + break; + case 'c': + arr_name = argv[x + 1]; + x++; + break; + case 'h': + usage (argv[0]); + break; + default: + usage (argv[0]); + break; + } + } + x++; + } + + if (argv[argc - 3][0] == 'd') + rw = new rwKernel (DEVMEM, offset); + else if (argv[argc - 3][0] == 'p') + rw = new rwKernel (PROCKCORE, offset); + + offset = stoi16 (string (argv[argc - 2])); + length = stoi16 (string (argv[argc - 1])); + + inBuf = new char[length + 1]; + rw->read (inBuf, length, offset); + + if (arr_name != NULL) + { + dump_c_array (arr_name, inBuf, length); + delete inBuf; + exit (0); + } + + dump (inBuf, length); + delete inBuf; + return 0; +} -- cgit v1.3