the cutting room mirror

Burning Rangers

This article has a talk page!
view on tcrf.net

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&#59;

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

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

  assert(ip != NULL)&#59;
  assert(op != NULL)&#59;

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

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

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

  fclose(ip)&#59;
  fclose(op)&#59;
  fclose(op2)&#59;
 }
 return 0&#59;
}

/* 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&#59;

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

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

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

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

    assert(fwrite(tmp, 1, rc, opr) == rc)&#59;

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

   {
    const char* ext = NULL&#59;

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

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