If you appreciate the work done within the wiki, please consider supporting The Cutting Room Floor on Patreon. Thanks for all your support!

Notes:Burning Rangers

From The Cutting Room Floor
Jump to navigation Jump to search

This page contains notes for the game Burning Rangers.

Web Page Extraction Code


/* gcc -Wall -O2 -o wavstrip wavstrip.c */
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#undef NDEBUG
#include <assert.h>

int main(int argc, char* argv[])
{
 int i;

 for(i = 1; i < argc; i++)
 {
  static char buf[8192];
  static char buf2[8192];
  FILE* ip;
  FILE* op;
  FILE* op2;
  unsigned char tmp[4];
  unsigned junkoffs;
  int c;

  snprintf(buf, sizeof(buf), "%s-JUNK", argv[i]);
  snprintf(buf2, sizeof(buf2), "%s-ALJNK", argv[i]);
  assert(strlen(buf) > strlen(argv[i]));
  assert(strlen(buf2) > strlen(argv[i]));
  ip = fopen(argv[i], "rb");
  op = fopen(buf, "wb");
  op2 = fopen(buf2, "wb");

  assert(ip != NULL);
  assert(op != NULL);

  assert(fseek(ip, 4, SEEK_SET) == 0);
  assert(fread(tmp, 1, 4, ip) == 4);
  junkoffs = 8 + (tmp[0] | (tmp[1] << 8) | (tmp[2] << 16) | (tmp[3] << 24));
  assert(fseek(ip, junkoffs, SEEK_SET) == 0);

  while((c = fgetc(ip)) >= 0)
   fputc(c, op);

  assert(fseek(ip, (junkoffs + 32767) &~ 32767, SEEK_SET) == 0);
  while((c = fgetc(ip)) >= 0)
   fputc(c, op2);

  fclose(ip);
  fclose(op);
  fclose(op2);
 }
 return 0;
}

/* gcc -Wall -O2 -o junkextract junkextract.c */
/* Use on *ALJNK */
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#undef NDEBUG
#include <assert.h>

int main(int argc, char* argv[])
{
 int i;

 for(i = 1; i < argc; i++)
 {
  static char fn[8192];
  FILE* ip;
  FILE* op = NULL;
  static char tmp[32768];
  unsigned counter = 0;
  size_t rc;
  unsigned cluster_counter = 0;

  ip = fopen(argv[i], "rb");
  assert(ip != NULL);

  while((rc = fread(tmp, 1, 32768, ip)) > 0)
  {
#if 0
   {
    FILE* opr;

    snprintf(fn, sizeof(fn), "%s-%u.raw", argv[i], cluster_counter);
    assert(strlen(fn) > strlen(argv[i]));
    opr = fopen(fn, "wb");
    assert(opr != NULL);

    assert(fwrite(tmp, 1, rc, opr) == rc);

    fclose(opr);
    cluster_counter++;
   }
#endif

   {
    const char* ext = NULL;

    if(!strncasecmp(tmp, "<HTML>", 6) || !strncasecmp(tmp, "<!DOCTYPE", 9))
     ext = ".html";
    else if(!strncmp(tmp, "GIF87a", 6) || !strncmp(tmp, "GIF89a", 6))
     ext = ".gif";
    else if((unsigned char)tmp[0] == 0xFF && !strncmp(&tmp[6], "JFIF", 4))
     ext = ".jpg";
#if 0
    printf("%.6s %s\n", tmp, ext);
#endif
    if(ext)
    {
     if(op)
      fclose(op);
     snprintf(fn, sizeof(fn), "%s-%u%s", argv[i], counter, ext);
     op = fopen(fn, "wb");
     assert(op != NULL);
     counter++;
    }
   }

   if(op)
    assert(fwrite(tmp, 1, rc, op) == rc);
  }
  if(op)
   fclose(op);
  fclose(ip);
 }
 return 0;
}