Skip to content

Instantly share code, notes, and snippets.

@michaelengel
Created August 22, 2020 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelengel/79c0e998b53d460a8833d7e27f4a0692 to your computer and use it in GitHub Desktop.
Save michaelengel/79c0e998b53d460a8833d7e27f4a0692 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#define BASE 48
#define STOP_BASE 35
int main(void) {
char line[128];
int factor;
int rest;
int div;
uint8_t c, byte;
gets(line); printf("%s\n", line);
gets(line);
factor = 1;
div = 256;
while (1) {
if (gets(line) == 0) break;
for (int i=0; i<strlen(line); i++) {
c = (uint8_t)line[i];
if (c >= BASE + 64) break;
byte = c - BASE;
if (factor != 1) {
putchar(rest + (byte % div) * factor);
rest = byte / div;
div = div * 4;
factor = factor / 4;
} else {
rest = byte;
div = 4;
factor = 64;
}
}
}
byte = c - STOP_BASE;
int ok = ((byte == 0) & (div == 256)) | ((byte == 1) && (div = 16)) | ((byte == 2) && (div == 64) && (rest == 0));
if (!ok) {
fprintf(stderr, "decode failed!\n");
}
}
@michaelengel
Copy link
Author

A quick and dirty decoder to convert "AsciiCoder"-encoded (similar to base64) uncompressedd Oberon .Cod files to .Mod files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment