Binary script with a separate text table file. A lot like [[2XT-PJADV]], so similar it might even be a successor. {{{#!highlight c++ #include #include #include #include void fread_or_die(void * a, size_t b, int c, FILE * d) { int got = fread(a, b, c, d); if(feof(d)) {puts("feof"); exit(0);} if(ferror(d)) {puts("ferror"); exit(0);} if(got != c) {exit(0);} } int main() { auto fs = fopen("SCRIPT.SRC", "rb"); auto ft = fopen("TEXT.DAT", "rb"); auto fo = fopen("script.txt", "wb"); fseek(fs, 12, SEEK_SET); std::deque stack; while(!feof(fs) and !ferror(fs)) { uint32_t command; fread_or_die(&command, 4, 1, fs); if(command != 0x0001001F and command != 0x00010017) { //fprintf(fo, "skipping %08X at %08X\n", command, ftell(fs)-4); continue; } if(command == 0x0001001F) { uint32_t value; fread_or_die(&value, 4, 1, fs); //fprintf(fo, "pushing %08X at %08X\n", value, ftell(fs)-4); stack.push_front(value); } if(command == 0x00010017) { uint32_t value; fread_or_die(&value, 4, 1, fs); if(value == 0x00020002 || value == 0x0002000F) { stack.pop_front(); stack.pop_front(); uint32_t addr = stack.front()+4; stack.clear(); fseek(ft, addr, SEEK_SET); int c = fgetc(ft); //fprintf(fo, "%08X\n", value); //fprintf(fo, "%08X\n", addr-4); //fprintf(fo, "%08X\n", ftell(fs)); while(c > 0) { fputc(c, fo); c = fgetc(ft); } fputc('\n', fo); } else { //fprintf(fo, "%08X\n", value); } } } } }}}