diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-10-11 03:18:42 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-10-11 03:18:42 +0100 |
commit | 26b57fbea1a969ef6405365ff78391e9d3605621 (patch) | |
tree | b6f14f5c083d0fbb42c5495eea7c74099ff45315 /command_line/CmdLine/Src/MacEmul/ResourceStrings.c | |
parent | 7d4bee5f8f28b72610c8518e5cb9dc145c68b816 (diff) | |
download | MWCC-26b57fbea1a969ef6405365ff78391e9d3605621.tar.gz MWCC-26b57fbea1a969ef6405365ff78391e9d3605621.zip |
add cmakelists for CLion, tons and tons of reorganisation using new info from the Pro8 compiler
Diffstat (limited to '')
-rw-r--r-- | command_line/CmdLine/Src/MacEmul/ResourceStrings.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/command_line/CmdLine/Src/MacEmul/ResourceStrings.c b/command_line/CmdLine/Src/MacEmul/ResourceStrings.c new file mode 100644 index 0000000..bdf3735 --- /dev/null +++ b/command_line/CmdLine/Src/MacEmul/ResourceStrings.c @@ -0,0 +1,68 @@ +#include "mwcc_decomp.h" + +typedef struct { + const char *name; + SInt16 rsrcid; + const char **strings; +} Res; + +static Res rlist[16]; + +void Res_Initialize() { + memset(rlist, 0, sizeof(rlist)); +} + +int Res_AddResource(const char *name, SInt16 rsrcid, const char **strings) { + int scan; + + for (scan = 0; scan < 16 && rlist[scan].rsrcid; scan++) { + if (rsrcid == rlist[scan].rsrcid) { + fprintf(stderr, "Resource %d is already added!\n", rsrcid); + return 0; + } + } + + if (scan >= 16) + return 0; + + rlist[scan].name = name; + rlist[scan].rsrcid = rsrcid; + rlist[scan].strings = strings; + return 1; +} + +enum { MaxRes = 16 }; + +const char *Res_GetResource(SInt16 rsrcid, SInt16 index) { + // Does not match, absolutely hopeless + int scan, find; + static char err[256]; + + scan = 0; + do { + if (rsrcid == rlist[scan].rsrcid) { + find = 0; + if ((SInt16) (index - 1) < 0) { + snprintf(err, sizeof(err), "[Illegal string index #%d in list '%s' (%d)]", (SInt16) (index - 1), rlist[scan].name, rsrcid); + return err; + } + + while (find <= (index - 1)) { + if (!rlist[scan].strings[find]) { + snprintf(err, sizeof(err), "[String #%d not found in resource '%s' (%d)]", (SInt16) (index - 1), rlist[scan].name, rsrcid); + return err; + } + if (find == (index - 1)) { + return rlist[scan].strings[find]; + } else { + find++; + } + } + } + } while (scan++ < MaxRes); + + return 0; +} + +void Res_Cleanup() { +} |