#include <stdio.h>
#include <stdlib.h>
#include "encode.h"
#include "read.h"
#include "pattern.h"

int encode_level(FILE* input_file, FILE* output_file)
{
   char character[1] = {' '};
   char* mode_string = encode_mode_string(input_file, output_file, character);
   if (!mode_string) return -1;
   if (!encode_sub_mode_string(input_file, output_file, character)) return -1;
   if (!encode_color_values(input_file, output_file, character)) return -1;
   if (!strcmp(mode_string, RAINBOW_MODE_STRING))
   {
      int ii = 0;
      char* beam_patterns[BEAM_PATTERN_COUNT];
      while (ii < BEAM_PATTERN_COUNT)
      {
         beam_patterns[ii++] = parse_pattern(input_file, character);
      }
      encode_course(beam_patterns, output_file);
   }
}

void encode_course(char** beam_patterns, FILE* output_file)
{
   int ii = 0, jj = 0, kk = 0, ll = 0;
   u8 color_index, position, length, gap;
   char* color_pattern = beam_patterns[0];
   char* position_pattern = beam_patterns[1];
   char* length_pattern = beam_patterns[2];
   char* gap_pattern = beam_patterns[3];
   while (color_pattern[ii])
   {
      if (!position_pattern[jj]) jj = 0;
      if (!length_pattern[kk]) kk = 0;
      if (!gap_pattern[ll]) ll = 0;
      printf(
         "%c%c%c%c ", color_pattern[ii], position_pattern[jj],
         length_pattern[kk], gap_pattern[ll]);
      color_index =  color_pattern[ii++] - 'A';
      position = position_pattern[jj++] - '0';
      length = length_pattern[kk++] - '0';
      gap = gap_pattern[ll++] - '0';
      fwrite(&color_index, sizeof(u8), 1, output_file);
      fwrite(&position, sizeof(u8), 1, output_file);
      fwrite(&length, sizeof(u8), 1, output_file);
      fwrite(&gap, sizeof(u8), 1, output_file);
   }
   printf("\n");
}

int encode_color_values(FILE* input_file, FILE* output_file, char* character)
{
   int ii;
   u32 byte_sequence;
   char* color_string;
   for (ii = 0; ii < COLOR_COUNT; ii++)
   {
      color_string = read_next_word(input_file, character);
      byte_sequence = strtol(color_string, NULL, 16);
      fwrite(&byte_sequence, sizeof(u8), 3, output_file);
      if (*character == '\n') break;
   }
   while (++ii < COLOR_COUNT)
   {
      byte_sequence = determine_color_from_index(output_file, ii);
      fwrite(&byte_sequence, sizeof(u8), 3, output_file);
   }
}

u32 determine_color_from_index(FILE* file, int ii)
{
   switch (ii)
   {
      case 0: return COLOR_RED;
      case 1: return COLOR_ORANGE;
      case 2: return COLOR_YELLOW;
      case 3: return COLOR_GREEN;
      case 4: return COLOR_BLUE;
      case 5: return COLOR_INDIGO;
      case 6: return COLOR_VIOLET;
   }
}
         

int encode_sub_mode_string(FILE* input_file, FILE* output_file, char* character)
{
   u8 byte_sequence;
   char* survival_sub_mode_string = read_next_word(input_file, character);
   if (!strcmp(survival_sub_mode_string, RACE_SUB_MODE_STRING))
   {
      byte_sequence = RACE_SUB_MODE_BYTE_SEQUENCE;
   }
   else if (!strcmp(survival_sub_mode_string, SURVIVAL_SUB_MODE_STRING))
   {
      byte_sequence = SURVIVAL_SUB_MODE_BYTE_SEQUENCE;
   }
   else
   {
      printf("Unrecognized sub-mode value in level definition\n");
      return -1;
   }
   fwrite(&byte_sequence, sizeof(u8), 1, output_file);
}

char* encode_mode_string(FILE* input_file, FILE* output_file, char* character)
{
   u8 byte_sequence;
   char* mode_string = read_next_word(input_file, character);
   if (!strcmp(mode_string, RAINBOW_MODE_STRING))
   {
      byte_sequence = RAINBOW_MODE_BYTE_SEQUENCE;
   }
   else
   {
      printf("Unrecognized mode value in level definition\n");
      return NULL;
   }
   fwrite(&byte_sequence, sizeof(u8), 1, output_file);
   return mode_string;
}
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "initialization.h"

FILE* initialize_translator(
   char* argv[], int* decode_flag, FILE** output_file, FILE** javascript_file)
{
   char output_method[3], input_method[3];
   determine_methods(output_method, input_method, *decode_flag);

   FILE* input_file = NULL;
   char* input_file_path = parse_arguments(argv, decode_flag);
   char* output_file_path;
   char* javascript_file_path;
   if (input_file_path)
   {
      input_file = open_file(input_file_path, input_method);
      if (input_file)
      {
         output_file_path =
            build_output_file_name(input_file_path, *decode_flag);
         *output_file = open_file(output_file_path, output_method);
         javascript_file_path =
            replace_extension(
               input_file_path, LEVEL_EXTENSION, JAVASCRIPT_EXTENSION);
         *javascript_file = open_file(javascript_file_path, "w");
      }
   }

   return input_file;
}

void determine_methods(
   char* output_method, char* input_method, int decode_flag)
{
   if (decode_flag)
   {
      strcpy(input_method, "rb");
      strcpy(output_method, "w");
   }
   else
   {
      strcpy(input_method, "r");
      strcpy(output_method, "wb+");
   }
}

// I think you may be wrong there *wink*
FILE* open_file(char* file_name, char* mode)
{
   FILE* file = fopen(file_name, mode);
   if (file == NULL)
   {
      printf("File could not be opened: %s\n", file_name);
   }
   return file;
}

char* build_output_file_name(char* input_file_path, int decode_flag)
{
   if (input_file_path == NULL) return;
   char* output_file_path = decode_flag ?
      replace_extension(input_file_path, ENCODED_EXTENSION, LEVEL_EXTENSION) :
      replace_extension(input_file_path, LEVEL_EXTENSION, ENCODED_EXTENSION);

   return output_file_path;
}

char* replace_extension(char* path, char* extension, char* replacement)
{
   int new_length = strlen(path) + strlen(replacement) - strlen(extension);
   char* new_path = malloc(sizeof(char) * (new_length+1));
   strcpy(new_path, path);
   char* truncate_position = strstr(new_path, extension);
   *truncate_position = '\0';
   strcat(new_path, replacement);
   return new_path;
}

char* parse_arguments(char* argv[], int* decode_flag)
{
   int ii;
   for (ii = 1; argv[ii]; ii++)
   {
      if (argv[ii][0] == '-')
      {
         if (argv[ii][1] == DECODE_OPTION_INDICATOR) *decode_flag = TRUE;
      }
      else return argv[ii];
   }
   print_usage();
   return NULL;
}
3.238.70.175
3.238.70.175
3.238.70.175
 
May 17, 2018

Line Wobbler Advance is a demake of Line Wobbler for Game Boy Advance that started as a demo for Synchrony. It contains remakes of the original Line Wobbler levels and adds a challenging advance mode with levels made by various designers.


f1. Wobble at home or on-the-go with Line Wobbler Advance

This project was originally meant to be a port of Line Wobbler and kind of a joke (demaking a game made for even lower level hardware), but once the original levels were complete, a few elements were added, including a timer, different line styles and new core mechanics, such as reactive A.I.


f2. Notes on Line Wobbler

I reverse engineered the game by mapping the LED strip on paper and taking notes on each level. Many elements of the game are perfectly translated, such as enemy and lava positions and speeds and the sizes of the streams. The boss spawns enemies at precisely the same rate in both versions. Thanks in part to this effort, Line Wobbler Advance was awarded first prize in the Wild category at Synchrony.


f3. First prize at Synchrony

Advance mode is a series of levels by different designers implementing their visions of the Line Wobbler universe. This is the part of the game that got the most attention. It turned into a twitchy gauntlet filled with variations on the core mechanics, cinematic interludes and new elements, such as enemies that react to the character's movements. Most of the levels are much harder than the originals and require a lot of retries.

Thanks Robin Baumgarten for giving permission to make custom levels and share this project, and thanks to the advance mode designers Prashast Thapan, Charles Huang, John Rhee, Lillyan Ling, GJ Lee, Emily Koonce, Yuxin Gao, Brian Chung, Paloma Dawkins, Gus Boehling, Dennis Carr, Shuichi Aizawa, Blake Andrews and mushbuh!

DOWNLOAD ROM
You will need an emulator to play. Try Mednafen (Windows/Linux) or Boycott Advance (OS X)