about summary refs log tree commit diff stats
path: root/data/maps/the_stormy/doors.txtpb
blob: c3ee7cbe8fc897f6b69c14d43978e24cbba35655 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
doors {
  name: "Nuclear Wall"
  type: EVENT
  panels { room: "Center" name: "REACTOR" }
}
doors {
  name: "Rain Wall"
  type: EVENT
  panels { room: "Center" name: "CLOUD" }
}
doors {
  name: "Tornado Wall"
  type: EVENT
  panels { room: "Center" name: "WIND" }
}
doors {
  name: "Volcano Wall"
  type: EVENT
  panels { room: "Center" name: "VOLCANO" }
}
doors {
  name: "Side Doors"
  type: EVENT
  panels { room: "Center" name: "REACTOR" }
  panels { room: "Center" name: "VOLCANO" }
  panels { room: "Center" name: "CLOUD" }
  panels { room: "Center" name: "WIND" }
  panels { room: "Nuclear Side" name: "GERM" }
  panels { room: "Tornado Side" name: "PUDDLE" }
  panels { room: "Rain Side" name: "CLOUD" }
  panels { room: "Rain Side" name: "WIND" }
  panels { room: "Volcano Side" name: "SNOW" }
  panels { room: "Volcano Side" name: "RAIN" }
}
doors {
  name: "X Door"
  type: EVENT
  panels { room: "Nuclear Vestibule" name: "STORM" }
  panels { room: "Tornado Vestibule" name: "SHIP" }
}
und-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * Copyright (C) 2017 hatkirby
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */
#include <gba.h>
#include "gamedata.h"
#include "link.h"
#include "serialize.h"

int main(void)
{
  // This possibly increases stability, I don't rightly know, this is all black
  // magic, will test more later.
  REG_IME = 0;

  initializeLink();

  // Identify the host game.
  if (GAME_RUBY)
  {
    sendS32(1);
  } else if (GAME_SAPP)
  {
    sendS32(2);
  } else if (GAME_FR)
  {
    sendS32(3);
  } else if (GAME_LG)
  {
    sendS32(4);
  } else if (GAME_EM)
  {
    sendS32(5);
  } else {
    sendS32(-1);
    waitForAck();

    return 0;
  }

  waitForAck();

  // Get access to save data.
  struct GameData gameData;

  if (!initSaveData(&gameData))
  {
    // Unsupported game version.
    sendS32(-1);
    waitForAck();

    return 0;
  }

  sendS32(1);
  waitForAck();

  // Send trainer name.
  u8* trainerName = 0;

  if (GAME_RS)
  {
    trainerName = gameData.SaveBlock2->rs.playerName;
  } else if (GAME_FRLG)
  {
    trainerName = gameData.SaveBlock2->frlg.playerName;
  } else if (GAME_EM)
  {
    trainerName = gameData.SaveBlock2->e.playerName;
  }

  u32 tn1 =
      (trainerName[0] << 24)
    | (trainerName[1] << 16)
    | (trainerName[2] << 8)
    | (trainerName[3]);

  u32 tn2 =
      (trainerName[4] << 24)
    | (trainerName[5] << 16)
    | (trainerName[6] << 8)
    | (trainerName[7]);

  sendU32(tn1);
  waitForAck();

  sendU32(tn2);
  waitForAck();

  // Send trainer ID.
  u8* trainerId = 0;
  if (GAME_RS)
  {
    trainerId = gameData.SaveBlock2->rs.playerTrainerId;
  } else if (GAME_FRLG)
  {
    trainerId = gameData.SaveBlock2->frlg.playerTrainerId;
  } else if (GAME_EM)
  {
    trainerId = gameData.SaveBlock2->e.playerTrainerId;
  }

  u16 trainerIdNum =
      (trainerId[1] << 8)
    | (trainerId[0]);

  u16 secretIdNum =
      (trainerId[3] << 8)
    | (trainerId[2]);

  sendU32(trainerIdNum);
  waitForAck();

  // Does the player want to import this game?
  if (waitForResponse() == 0)
  {
    return 0;
  }

  // Send Pokédex data
  u8* pokedexSeen = 0;
  if (GAME_RS)
  {
    pokedexSeen = gameData.SaveBlock2->rs.pokedex.seen;
  } else if (GAME_FRLG)
  {
    pokedexSeen = gameData.SaveBlock2->frlg.pokedex.seen;
  } else if (GAME_EM)
  {
    pokedexSeen = gameData.SaveBlock2->e.pokedex.seen;
  }

  for (int i=0; i<13; i++)
  {
    u32 psi =
        (pokedexSeen[i*4]   << 24)
      | (pokedexSeen[i*4+1] << 16)
      | (pokedexSeen[i*4+2] << 8)
      | (pokedexSeen[i*4+3]);

    directSendU32(psi);
  }

  u8* pokedexCaught = 0;
  if (GAME_RS)
  {
    pokedexCaught = gameData.SaveBlock2->rs.pokedex.owned;
  } else if (GAME_FRLG)
  {
    pokedexCaught = gameData.SaveBlock2->frlg.pokedex.owned;
  } else if (GAME_EM)
  {
    pokedexCaught = gameData.SaveBlock2->e.pokedex.owned;
  }

  for (int i=0; i<13; i++)
  {
    u32 psi =
        (pokedexCaught[i*4]   << 24)
      | (pokedexCaught[i*4+1] << 16)
      | (pokedexCaught[i*4+2] << 8)
      | (pokedexCaught[i*4+3]);

    directSendU32(psi);
  }

  // Start sending over party pokémon.
  struct Pokemon* playerParty = 0;
  if (GAME_RS)
  {
    playerParty = gameData.SaveBlock1->rs.playerParty;
  } else if (GAME_FRLG)
  {
    playerParty = gameData.SaveBlock1->frlg.playerParty;
  } else if (GAME_EM)
  {
    playerParty = gameData.SaveBlock1->e.playerParty;
  }

  waitForResponse();

  u32 partyCount = 1;

  sendU32(partyCount);
  waitForAck();

  for (int pki=0; pki<partyCount; pki++)
  {
    struct Pokemon* pkm = (playerParty + pki);
    struct BoxPokemon* bpkm = &(pkm->box);

    struct PokemonIntermediate pki;

    PokemonIntermediateInit(&pki, bpkm, trainerIdNum, secretIdNum, &gameData);
    PokemonIntermediateStream(&pki);
  }
}