#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "read.h"

char* read_next_line(FILE* file, char* character)
{
   char* line = malloc(sizeof(char));
   int ii = 0;
   while ((*character = fgetc(file)) != EOF && *character != '\n')
   {
      line[ii++] = *character;
      line = realloc(line, sizeof(char) * (ii+2));
   }
   line[ii] = '\0';
   return line;
}

char* read_next_word(FILE* file, char* character)
{
   skip_whitespace(file, character);
   char* string = malloc(sizeof(char));
   string[0] = *character;
   int ii = 1;
   while ((*character = fgetc(file)) != EOF)
   {
      if (isspace(*character)) break;
      string[ii++] = *character;
      string = realloc(string, sizeof(char) * (ii+2));
   }
   string[ii] = '\0';

   return string;
}

void skip_whitespace(FILE* file, char* character)
{
   if (isspace(*character))
   {
      while ((*character = fgetc(file)) != EOF)
      {
         if (!isspace(*character)) return;
      }
   }
}
#include <stdio.h>
#include <stdlib.h>
#include "encode.h"
#include "javascript.h"

void write_javascript_file(FILE* file, FILE* encoded_level)
{
   fseek(encoded_level, 0, SEEK_SET);
   write_mode(file, encoded_level);
   write_sub_mode(file, encoded_level);
   write_color_array(file, encoded_level);
   write_beam_array(file, encoded_level);
}

void write_mode(FILE* file, FILE* encoded_level)
{
   u8 mode_sequence;
   fread(&mode_sequence, sizeof(u8), 1, encoded_level);
   fputs(MODE_VARIABLE_LVAL, file);
   switch (mode_sequence)
   {
      case RAINBOW_MODE_BYTE_SEQUENCE:
         fputs(RAINBOW_MODE_STRING, file);
         break;
   }
   fputs("\";\n", file);
}

void write_sub_mode(FILE* file, FILE* encoded_level)
{
   u8 sub_mode_sequence;
   fread(&sub_mode_sequence, sizeof(u8), 1, encoded_level);
   fputs(SUB_MODE_VARIABLE_LVAL, file);
   switch (sub_mode_sequence)
   {
      case RACE_SUB_MODE_BYTE_SEQUENCE:
         fputs(RACE_SUB_MODE_STRING, file);
         break;
   }
   fputs("\";\n", file);
}

void write_color_array(FILE* file, FILE* encoded_level)
{
   u32 color = 0;
   int ii = 0;
   fputs(COLOR_ARRAY_LVAL, file);
   while (ii++ < COLOR_COUNT)
   {
      fread(&color, sizeof(u8), 3, encoded_level);
      fprintf(file, "\"#%06X\"", color);
      if (ii < COLOR_COUNT) fputs(", ", file);
   }
   fputs("];\n", file);
}

void write_beam_array(FILE* file, FILE* encoded_level)
{
   int ii = 0;
   char color;
   u8 position, length, gap_length;

   fputs(BEAM_PROPERTIES_ARRAY_LVAL, file);
   while (fread(&color, sizeof(char), 1, encoded_level))
   {
      fread(&position, sizeof(u8), 1, encoded_level);
      fread(&length, sizeof(u8), 1, encoded_level);
      fread(&gap_length, sizeof(u8), 1, encoded_level);
      if (ii++ > 0) fputs(", ", file);
      fprintf(file, "\"%i%i%i%i\"", color, position, length, gap_length);
   }
   fputs("];\n", file);
}
#include <stdio.h>
#include <stdlib.h>
#include "translate.h"
#include "initialization.h"
#include "encode.h"

int main(int argc, char* argv[])
{
   int decode_flag = FALSE;
   FILE** output_file = malloc(sizeof(FILE*));
   FILE** javascript_file = malloc(sizeof(FILE*));
   FILE* input_file = initialize_translator(
      argv, &decode_flag, output_file, javascript_file);

   if (input_file)
   {
      encode_level(input_file, *output_file);
      write_javascript_file(*javascript_file, *output_file);
   }

   return 0;
}

void print_usage()
{
   printf("Usage: translate [-d] FILE\n");
}
var MODE = "RAINBOW";
var SUB_MODE = "RACE";
var COLORS = ["#123456", "#789012", "#345678", "#901234", "#567890", "#123456", "#789012"];
var BEAM_PROPERTIES = ["0170", "1261", "2350", "3441", "4530", "5621", "6710", "0171", "1260", "2351", "3440", "4531", "5620", "6711", "0170", "1261", "2350", "3441", "4530", "5621", "6710", "0171", "1260", "2351", "3440", "4531", "5620", "6711", "0170", "1261", "2350", "3441", "4530", "5621", "6710", "0171", "1260", "2351", "3440", "4531", "5620", "6711", "0170", "1261", "2350", "3441", "4530", "5621", "6710", "0171", "1260", "2351", "3440", "4531", "5620", "6711", "0170", "1261", "2350", "3441", "4530", "5621", "6710", "0171", "1260", "2351", "3440", "4531", "5620", "6711"];
var MODE = "RAINBOW";
var SUB_MODE = "RACE";
var COLORS = ["#EF0000", "#FFA800", "#FFEF00", "#00E000", "#0000E8", "#6F00FF", "#8F00FF"];
var BEAM_PROPERTIES = ["0761", "2362", "5261", "0562", "2261", "5462", "0161", "2362", "5261", "0562", "2561", "5662", "0761", "2362", "5261", "0562", "2261", "5662", "0361", "2162", "5761", "0162", "2261", "5762", "0361", "2262", "5561", "0262", "2461", "5162", "0361", "2262", "5561", "3562", "1661", "3762", "6361", "3262", "1561", "3262", "6661", "3362", "1161", "3762", "6161", "3262", "1761", "3362", "6261", "3562", "1261", "3462", "6161", "3362", "1261", "3562", "6561", "3662", "1761", "3362", "6261", "3562", "1261", "3662", "6361", "3162", "1761", "3162", "6261", "3762", "1361", "3262", "6561", "0262", "2461", "5162", "0361", "2262", "5561", "0562", "2661", "5762", "0361", "2262", "5561", "0262", "2661", "5362", "0161", "2762", "5161", "0262", "2761", "5362", "0261", "2562", "5261", "0462", "2161", "5362", "0261", "2562", "5561", "0662", "2761", "5362", "3261", "1562", "3261", "6662", "3361", "1162", "3761", "6162", "3261", "1762", "3361", "6262", "3561", "1262", "3461", "6162", "3361", "1262", "3561", "6562", "3661", "1762", "3361", "6262", "3561", "1262", "3661", "6362", "3161", "1762", "3161", "6262", "3761", "1362", "3261", "6562", "3261", "1462", "3161", "6362", "0261", "2562", "5561", "0662", "2761", "5362", "0261", "2562", "5261", "0662", "2361", "5162", "0761", "2162", "5261", "0762", "2361", "5262", "0561", "2262", "5461", "0162", "2361", "5262", "0561", "2562", "5661", "0762", "2361", "5262", "0561", "2262", "5661", "3362", "1161", "3762", "6161", "3262", "1761", "3362", "6261", "3562", "1261", "3462", "6161", "3362", "1261", "3562", "6561", "3662", "1761", "3362", "6261", "3562", "1261", "3662", "6361", "3162", "1761", "3162", "6261", "3762", "1361", "3262", "6561", "3262", "1461", "3162", "6361", "3262", "1561", "3562", "6661", "0762", "2361", "5262", "0561", "2262", "5661", "0362", "2161", "5762", "0161", "2262", "5761", "0362", "2261", "5562", "0261", "2462", "5161", "0362", "2261", "5562", "0561", "2662", "5761", "0362", "2261", "5562", "0261", "2662", "5361", "0162", "2761", "5162", "3261", "1762", "3361", "6262", "3561", "1262", "3461", "6162", "3361", "1262", "3561", "6562", "3661", "1762", "3361", "6262", "3561", "1262", "3661", "6362", "3161", "1762", "3161", "6262", "3761", "1362", "3261", "6562", "3261", "1462", "3161", "6362", "3261", "1562", "3561", "6662", "3761", "1362", "3261", "6562", "0261", "2662", "5361", "0162", "2761", "5162", "0261", "2762", "5361", "0262", "2561", "5262", "0461", "2162", "5361", "0262", "2561", "5562", "0661", "2762", "5361", "0262", "2561", "5262", "0661", "2362", "5161", "0762", "2161", "5262", "0761", "2362", "5261", "3562", "1261", "3462", "6161", "3362", "1261", "3562", "6561", "3662", "1761", "3362", "6261", "3562", "1261", "3662", "6361", "3162", "1761", "3162", "6261", "3762", "1361", "3262", "6561", "3262", "1461", "3162", "6361", "3262", "1561", "3562", "6661", "3762", "1361", "3262", "6561", "3262", "1661", "3362", "6161", "0762", "2161", "5262", "0761", "2362", "5261", "0562", "2261", "5462", "0161", "2362", "5261", "0562", "2561", "5662", "0761", "2362", "5261", "0562", "2261", "5662", "0361", "2162", "5761", "0162", "2261", "5762", "0361", "2262", "5561", "0262", "2461", "5162", "3361", "1262", "3561", "6562", "3661", "1762", "3361", "6262", "3561", "1262", "3661", "6362", "3161", "1762", "3161", "6262", "3761", "1362", "3261", "6562", "3261", "1462", "3161", "6362", "3261", "1562", "3561", "6662", "3761", "1362", "3261", "6562", "3261", "1662", "3361", "6162", "3761", "1162", "3261", "6762", "0361", "2262", "5561", "0262", "2461", "5162", "0361", "2262", "5561", "0562", "2661", "5762", "0361", "2262", "5561", "0262", "2661", "5362", "0161", "2762", "5161", "0262", "2761", "5362", "0261", "2562", "5261", "0462", "2161", "5362", "0261", "2562", "5561", "3662", "1761", "3362", "6261", "3562", "1261", "3662", "6361", "3162", "1761", "3162", "6261", "3762", "1361", "3262", "6561", "3262", "1461", "3162", "6361", "3262", "1561", "3562", "6661", "3762", "1361", "3262", "6561", "3262", "1661", "3362", "6161", "3762", "1161", "3262", "6761", "3362", "1261", "3562", "6261", "0462", "2161", "5362", "0261", "2562", "5561", "0662", "2761", "5362", "0261", "2562", "5261", "0662", "2361", "5162", "0761", "2162", "5261", "0762", "2361", "5262", "0561", "2262", "5461", "0162", "2361", "5262", "0561", "2562", "5661", "0762", "2361", "5262", "3561", "1262", "3661", "6362", "3161", "1762", "3161", "6262", "3761", "1362", "3261", "6562", "3261", "1462", "3161", "6362", "3261", "1562", "3561", "6662", "3761", "1362", "3261", "6562", "3261", "1662", "3361", "6162", "3761", "1162", "3261", "6762", "3361", "1262", "3561", "6262", "3461", "1162", "3361", "6262", "0561", "2562", "5661", "0762", "2361", "5262", "0561", "2262", "5661", "0362", "2161", "5762", "0161", "2262", "5761", "0362", "2261", "5562", "0261", "2462", "5161", "0362", "2261", "5562", "0561", "2662", "5761", "0362", "2261", "5562", "0261", "2662", "5361", "3162", "1761", "3162", "6261", "3762", "1361", "3262", "6561", "3262", "1461", "3162", "6361", "3262", "1561", "3562", "6661", "3762", "1361", "3262", "6561", "3262", "1661", "3362", "6161", "3762", "1161", "3262", "6761", "3362", "1261", "3562", "6261", "3462", "1161", "3362", "6261", "3562", "1561", "3662", "6761", "0362", "2261", "5562", "0261", "2662", "5361", "0162", "2761", "5162", "0261", "2762", "5361", "0262", "2561", "5262", "0461", "2162", "5361", "0262", "2561", "5562", "0661", "2762", "5361", "0262", "2561", "5262", "0661", "2362", "5161", "0762", "2161", "5262", "3761", "1362", "3261", "6562", "3261", "1462", "3161", "6362", "3261", "1562", "3561", "6662", "3761", "1362", "3261", "6562", "3261", "1662", "3361", "6162", "3761", "1162", "3261", "6762", "3361", "1262", "3561", "6262", "3461", "1162", "3361", "6262", "3561", "1562", "3661", "6762", "3361", "1262", "3561", "6262", "0661", "2362", "5161", "0762", "2161", "5262", "0761", "2362", "5261", "0562", "2261", "5462", "0161", "2362", "5261", "0562", "2561", "5662", "0761", "2362", "5261", "0562", "2261", "5662", "0361", "2162", "5761", "0162", "2261", "5762", "0361", "2262", "5561", "3262", "1461", "3162", "6361", "3262", "1561", "3562", "6661", "3762", "1361", "3262", "6561", "3262", "1661", "3362", "6161", "3762", "1161", "3262", "6761", "3362", "1261", "3562", "6261", "3462", "1161", "3362", "6261", "3562", "1561", "3662", "6761", "3362", "1261", "3562", "6261", "3662", "1361", "3162", "6761", "0162", "2261", "5762", "0361", "2262", "5561", "0262", "2461", "5162", "0361", "2262", "5561", "0562", "2661", "5762", "0361", "2262", "5561", "0262", "2661", "5362", "0161", "2762", "5161", "0262", "2761", "5362", "0261", "2562", "5261", "0462", "2161", "5362", "3261", "1562", "3561", "6662", "3761", "1362", "3261", "6562", "3261", "1662", "3361", "6162", "3761", "1162", "3261", "6762", "3361", "1262", "3561", "6262", "3461", "1162", "3361", "6262", "3561", "1562", "3661", "6762", "3361", "1262", "3561", "6262", "3661", "1362", "3161", "6762", "3161", "1262", "3761", "6362"];
var SOURCE_PATH = "src/game/volatile/src/";

window.onload = function()
{
   document.body.removeChild(document.getElementById("loading_animation"));
   new EVR();
}

EVR = function()
{
   this.populate();
   this.add_listeners();
}

EVR.prototype.populate = function()
{
   window.console = new EVR.Console();
   console.write(SOURCE_PATH);
   console.write(document.cookie);
   this.field = new EVR.Field(document.body);
   this.sound = new EVR.Sound(this.field, INTRODUCTION_SONG);
   this.emoticon = new EVR.Emoticon(this.field);
   this.title = new EVR.Title(this.field);
   this.history = new EVR.History(this.field);
   this.start_introduction();
   this.delegate = new EVR.Delegate(this);
}

EVR.prototype.start_introduction = function()
{
   this.introduction = new EVR.Animation.Introduction(
      this.field, this.emoticon, this.title);
}

EVR.prototype.add_listeners = function()
{
   var current = this;
   window.onresize = function(event)
   {
      current.delegate.handle_resize_event(event)
   };
   this.enable_key_listeners();
}

EVR.prototype.enable_key_listeners = function()
{
   var current = this;
   document.onkeydown = function(event)
   { 
      current.delegate.handle_key_down(event)
   };
   document.onkeyup = function(event)
   {
      current.delegate.handle_key_up(event)
   };
   document.onkeypress = function(event)
   {
      current.delegate.handle_key_press(event)
   };
}

EVR.prototype.repopulate = function()
{
   this.field.repopulate();
   !!this.introduction && this.introduction.redraw();
   this.emoticon.draw();
   this.sound.draw();
   !!this.menu && this.menu.attached && this.menu.draw();
   !!this.current_level && this.current_level.draw();
   !!this.instructions && this.instructions.draw();
   !!this.about && this.about.draw();
   this.history.attached && this.history.draw();
   !!this.ending && this.ending.draw();
}

EVR.prototype.build_start_menu = function()
{
   if (!!this.introduction && !this.introduction.cleared)
   {
      this.introduction.clear();
   }
   if (!!!this.menu)
   {
      this.menu = new EVR.Menu(this, this.field, this.emoticon);
      this.delegate.menu = this.menu;
//       this.field.fader.play();
   }
}

EVR.prototype.load_level = function(id, practice)
{
   if (!!this.current_level)
   {
      this.current_level.remove();
   }
   this.current_level = new EVR.Level(this, this.field, id, practice);
   this.delegate.level = this.current_level;
   this.destroy_start_menu();
   this.title.attached && this.title.remove();
}

EVR.prototype.destroy_start_menu = function()
{
   !!this.menu && this.menu.attached && this.menu.remove();
   this.delegate.menu = null;
   this.menu = null;
}

EVR.prototype.unload_level = function()
{
   this.current_level.remove();
   this.title.append();
   this.build_start_menu();
   this.current_level = null;
   this.delegate.level = null;
   this.sound.set_song(INTRODUCTION_SONG);
   this.reset_field_color();
}

EVR.prototype.reset_field_color = function()
{
   this.field.set_color(FIELD_COLORS[0]);
}

EVR.prototype.load_album = function(index)
{
   if (!!!this.album)
   {
      this.album = new EVR.Album(this.field);
      this.delegate.album = this.album;
   }
   this.menu.remove();
   this.album.append(index);
   this.sound.hide();
   this.sound.set_song(ALBUM_SONG);
}

EVR.prototype.unload_album = function()
{
   !!this.album && this.album.remove();
   this.menu.append();
   this.sound.show();
   this.sound.set_song(INTRODUCTION_SONG);
}

EVR.prototype.load_instructions = function()
{
   if (!!!this.instructions)
   {
      this.instructions = new EVR.Instructions(this.field);
      this.delegate.instructions = this.instructions;
   }
   this.menu.remove();
   this.instructions.append();
}

EVR.prototype.unload_instructions = function()
{
   this.instructions.remove();
   this.menu.append();
}

EVR.prototype.load_history = function()
{
   this.menu.remove();
   this.history.append();
}

EVR.prototype.unload_history = function()
{
   this.history.remove();
   this.menu.append();
}

EVR.prototype.load_about = function()
{
   if (!!!this.about)
   {
      this.about = new EVR.About(this);
      this.delegate.about = this.about;
   }
   this.menu.remove();
   this.about.append();
}

EVR.prototype.unload_about = function()
{
   this.about.remove();
   this.menu.append();
}

EVR.prototype.load_ending = function()
{
   if (!!this.current_level)
   {
      this.unload_level();
   }
   this.title.attached && this.title.remove();
   this.menu.attached && this.menu.remove();
   if (!!!this.ending)
   {
      this.ending = new EVR.Animation.Ending(this);
      this.delegate.ending = this.ending;
   }
   this.sound.set_song(ENDING_SONG);
   this.ending.play();
}

EVR.prototype.unload_ending = function()
{
   this.ending.clear();
   this.menu.append();
   this.title.append();
   this.sound.set_song(INTRODUCTION_SONG);
}

EVR.prototype.load_account = function()
{
   if (!!!this.account)
   {
      this.account = new EVR.Account(this);
      this.delegate.account = this.account;
   }
   this.disable_key_listeners();
   this.menu.remove();
   this.account.append();
}

EVR.prototype.disable_key_listeners = function()
{
   document.onkeydown = null;
   document.onkeyup = null;
   document.onkeypress = null;
}

EVR.prototype.unload_account = function()
{
   this.enable_key_listeners();
   this.account.remove();
   this.destroy_start_menu();
   this.build_start_menu();
}

EVR.prototype.toggle_sound = function()
{
   var sound = this.sound;
   sound.audio.mute();
   sound.controls.update();
}

EVR.prototype.log_in = function()
{
   if (this.account.attached)
   {
      this.unload_account();
   }
   this.history.load();
}

EVR.prototype.log_out = function()
{
   document.cookie = "hash=;expiration=0;path=/";
   this.destroy_start_menu();
   this.build_start_menu();
   this.history.load();
   !!this.album && this.album.initialize_pages();
}

EVR.inherit = function(child, parent)
{
   for (var method in parent.prototype)
   {
      if (method != "toString")
      {
	 child.prototype[method] = parent.prototype[method];
      }
   }
}

EVR.include = function(file_path)
{
   var tag = "<script language=\"javascript\" type=\"text/javascript\"";
   tag += " src=\"" + SOURCE_PATH + file_path + "\"></script>";
   document.write(tag);
}

EVR.prototype.toString = function()
{
   return "[object EVR]";
}

EVR.include("definitions.js");
EVR.include("Math.js");
EVR.include("Color.js");
EVR.include("time/Time.js");
EVR.include("Requester.js");
EVR.include("element/Element.js");
EVR.include("element/Component.js");
EVR.include("element/Table.js");
EVR.include("element/graphic/Graphic.js");
EVR.include("element/graphic/Aligner.js");
EVR.include("element/pop_up/Pop_Up.js");
EVR.include("Console.js");
EVR.include("Prompt.js");
EVR.include("animation/Animation.js");
EVR.include("field/Field.js");
EVR.include("sound/Sound.js");
EVR.include("emoticon/Emoticon.js");
EVR.include("title/Title.js");
EVR.include("history/History.js");
EVR.include("menu/Menu.js");
EVR.include("level/Level.js");
EVR.include("album/Album.js");
EVR.include("account/Account.js");
EVR.include("instructions/Instructions.js");
EVR.include("about/About.js");
EVR.include("delegate/Delegate.js");
54.234.13.175
54.234.13.175
54.234.13.175
 
June 7, 2018


↠ RSS Feed ↞