Exemplo n.º 1
0
        public frmWarp(Program.GameTypes g, GBHL.GBFile gbf, byte f)
        {
            InitializeComponent();
            game = g;
            if (g == Program.GameTypes.Ages)
            {
                foreach (string s in agesGroupNames)
                {
                    cboArea.Items.Add(s);
                }
            }
            else
            {
                foreach (string s in seasonsGroupNames)
                {
                    cboArea.Items.Add(s);
                }
            }

            cboArea.SelectedIndex = 0;
            flag2      = f;
            gb         = gbf;
            warpLoader = new WarpLoader(gb);
            mapLoader  = new MapLoader(gb);
        }
Exemplo n.º 2
0
 public void loadMap(int index, int group, int season, bool flag, Program.GameTypes game)
 {
     room = new Room();
     getMapArea(index, group, season, game);
     loadMapHeader(index, group, season, flag, game);
     if (room.type == RoomTypes.Small)
     {
         LoadSmallMap();
     }
     else
     {
         if (!flag)
         {
             LoadDungeonMap();
         }
         else
         {
             room.dungeon      = new DungeonBlock[176];
             room.decompressed = gb.ReadBytes(room.dataLocation, 176);
             for (int i = 0; i < 176; i++)
             {
                 room.dungeon[i].id = room.decompressed[i];
                 room.dungeon[i].x  = (byte)(i % 16);
                 room.dungeon[i].y  = (byte)(i / 16);
             }
         }
     }
 }
Exemplo n.º 3
0
        public void getMapArea(int index, int group, int season, Program.GameTypes game)
        {
            //CC2D - map group
            //CC30 - map index
            //CD24 - map area
            //FF8D - area | 0x80, and later that & 0x7f - compression type?
            //FF8B - area

            int indexBase = 0x10000 + (game == Program.GameTypes.Ages ? 0x0F9C : 0x0C84);

            //4:6d7a - start of procedure
            gb.BufferLocation = 0x10000 + (game == Program.GameTypes.Ages ? 0x12D4 : 0x133C) + (group * 2);
            //6da1
            gb.BufferLocation = 0x10000 + gb.ReadByte() + ((gb.ReadByte() - 0x40) * 0x100) + index;
            byte a    = gb.ReadByte();
            byte area = (byte)(a & 0x7F);

            gb.BufferLocation = indexBase + area * 8;
            if (game == Program.GameTypes.Seasons)
            {
                if (gb.ReadByte() == 0xFF)
                {
                    gb.BufferLocation  = 0x10000 + gb.ReadByte() + ((gb.ReadByte() - 0x40) * 0x100);
                    gb.BufferLocation += season * 8;
                }
                else
                {
                    gb.BufferLocation--;
                }
            }
            AreaLoader.Area ar = new AreaLoader.Area();
            ar        = areaLoader.loadArea(gb.BufferLocation, area, game);
            room.area = ar;
        }
Exemplo n.º 4
0
 public frmDungeonPortal(GBHL.GBFile g, Program.GameTypes game)
 {
     gb        = g;
     this.game = game;
     InitializeComponent();
     nDungeon_ValueChanged(null, null);
 }
Exemplo n.º 5
0
 public void saveMusic(int map, int group, byte music, Program.GameTypes game)
 {
     gb.BufferLocation  = (game == Program.GameTypes.Ages ? 0x1095C : 0x1083C) + group * 2;
     gb.BufferLocation  = 0x10000 + gb.ReadByte() + ((gb.ReadByte() - 0x40) * 0x100);
     gb.BufferLocation += map;
     gb.WriteByte(music);
 }
Exemplo n.º 6
0
        public InteractionLoader(GBHL.GBFile g, Program.GameTypes game)
        {
            gb         = g;
            loadedGame = game;

            if (game == Program.GameTypes.Ages)
            {
                // Check if patch has been applied
                if (gb.ReadByte(0x54328) == 0xc3)
                {
                    enableExtraInteractionBank();
                }

                // Many maps point here when they have no data.
                // But this isn't treated as a special case anymore.
                //noLocation = 0x49977;
            }
            else
            {
                if (gb.ReadByte(0x458dc) == 0xcd)
                {
                    enableExtraInteractionBank();
                }

                //noLocation = 0x4634b;
            }

            loadInteractions(0, 0);
        }
Exemplo n.º 7
0
 public static void ExtraInteractionBank(GBFile gb, Program.GameTypes game)
 {
     if (game == Program.GameTypes.Ages)
     {
         // Call ASM script
         gb.WriteBytes(0x54328, new byte[] { 0xC3, 0xFC, 0x7B });
         // ASM script
         gb.WriteBytes(0x57bfc, new byte[] {
             0x56, 0x5F, 0xCB, 0x7A, 0xC8, 0xCB, 0xBA, 0x62, 0x6B, 0x0E, 0x08, 0x11,
             0x00, 0xC3, 0x06, 0xFA, 0xCD, 0x83, 0x1A, 0x0D, 0x20, 0xF8, 0x11, 0x00,
             0xC3, 0xC9
         });
     }
     else // Seasons
     {
         // Call ASM script
         gb.WriteBytes(0x458d7, new byte[] { 0x1E, 0x7F, 0x21, 0x00, 0x40, 0xCD, 0x8A, 0x00 });
         // ASM script
         gb.WriteBytes(0x1fc000, new byte[] {
             0xFA, 0x49, 0xCC, 0x21, 0x3B, 0x5B, 0xDF, 0x06, 0x11, 0x11, 0x00, 0xC3,
             0xD5, 0xCD, 0x49, 0x1A, 0xE1, 0x54, 0x5D, 0x2A, 0x66, 0x6F, 0xFA, 0x4C,
             0xCC, 0xDF, 0x06, 0x11, 0xD5, 0xCD, 0x49, 0x1A, 0xE1, 0x2A, 0x56, 0x5F,
             0xCB, 0x7A, 0xC8, 0xCB, 0xBA, 0x62, 0x6B, 0x06, 0x00, 0x11, 0x00, 0xC3,
             0xD5, 0xCD, 0x62, 0x04, 0xD1, 0xC9, 0xFF
         });
     }
 }
Exemplo n.º 8
0
 public int getGroupSize(int groupIndex, Program.GameTypes game)
 {
     if (getFloor(groupIndex, game) == -1)
     {
         return(16);
     }
     return(8);
 }
Exemplo n.º 9
0
 public frmChest(GBHL.GBFile g, int grp, int m, Program.GameTypes game)
 {
     gb    = g;
     chest = new ChestLoader(gb, game);
     group = grp;
     map   = m;
     InitializeComponent();
 }
Exemplo n.º 10
0
 public int getFloor(int groupIndex, Program.GameTypes game)
 {
     if (groupIndex < (game == Program.GameTypes.Ages ? 4 : 5))
     {
         return(-1);
     }
     groupIndex -= (game == Program.GameTypes.Ages ? 4 : 5);
     return(groupIndex);
 }
Exemplo n.º 11
0
 public frmAreaFlags(GBHL.GBFile g, Program.GameTypes gm, AreaLoader a, int area)
 {
     InitializeComponent();
     gb          = g;
     game        = gm;
     areaLoader  = a;
     nArea.Value = area;
     nArea_ValueChanged(null, null);
 }
Exemplo n.º 12
0
 public frmWarpProps(WarpLoader w, int g, int la, Program.GameTypes gm, GBHL.GBFile gbf)
 {
     game        = gm;
     warpLoader  = w;
     group       = g;
     lastAddress = la;
     gb          = gbf;
     InitializeComponent();
 }
Exemplo n.º 13
0
 public frmInteractions(InteractionLoader i, int grp, int mp, Program.GameTypes game, GBHL.GBFile g)
 {
     InitializeComponent();
     this.game         = game;
     interactionLoader = i;
     gb    = g;
     group = grp;
     map   = mp;
 }
Exemplo n.º 14
0
        public void saveAreaIndex(int index, int group, byte newArea, Program.GameTypes game)
        {
            int indexBase = 0x10000 + (game == Program.GameTypes.Ages ? 0x0F9C : 0x0C84);

            //4:6d7a - start of procedure
            gb.BufferLocation = 0x10000 + (game == Program.GameTypes.Ages ? 0x12D4 : 0x133C) + (group * 2);
            //6da1
            gb.BufferLocation = 0x10000 + gb.ReadByte() + ((gb.ReadByte() - 0x40) * 0x100) + index;
            gb.WriteByte(newArea);
        }
Exemplo n.º 15
0
        public static int GetDungeon(int group, int areaFlag, Program.GameTypes game)
        {
            if (game == Program.GameTypes.Seasons)
            {
                if (group < 5)
                {
                    return(0xFF);
                }
                return(areaFlag & 0xF);
            }
            if (group < 4)
            {
                return(0xFF);
            }
            return(areaFlag & 0xF);

            /*if (game == Program.GameTypes.Seasons)
             * {
             *  return 0;
             * }
             * if (index < 4)
             *  return 0xFF; //The game has it as FF if in no dungeon
             * index -= 4;
             * switch (index)
             * {
             *  case 0: return 0;
             *  case 1: return 0xD;
             *  case 2: return 1;
             *  case 3: return 2;
             *  case 4: return 2;
             *  case 5: return 3;
             *  case 6: return 3;
             *  case 7: return 4;
             *  case 8: return 4;
             *  case 9: return 5;
             *  case 10: return 5;
             *  case 11: return 0xB;
             *  case 12: return 0xB;
             *  case 13: return 0xF;
             *  case 14: return 6;
             *  case 15: return 0xC;
             *  case 16: return 0xC;
             *  case 17: return 7;
             *  case 18: return 7;
             *  case 19: return 7;
             *  case 20: return 8;
             *  case 21: return 8;
             *  case 22: return 8;
             *  case 23: return 8;
             *  case 24: return 0xE;
             *  case 25: return 0xA;
             * }
             * return 0xFF;*/
        }
Exemplo n.º 16
0
 public int getHeaderLocation(int tileset, Program.GameTypes game) //VRAM Header
 {
     if (game == Program.GameTypes.Ages)
     {
         return(0x69DA + (tileset * 2));
     }
     else
     {
         return(0x6926 + (tileset * 2));
     }
 }
Exemplo n.º 17
0
        public Warp loadWarpProps(int refByte, int destGroup, Program.GameTypes game)
        {
            Warp w = new Warp();

            gb.BufferLocation  = (game == Program.GameTypes.Ages ? 0x12F5B : 0x12D4E) + (destGroup * 2);
            gb.BufferLocation  = 0x10000 + gb.ReadByte() + ((gb.ReadByte() - 0x40) * 0x100);
            gb.BufferLocation += refByte * 3;
            w.map              = gb.ReadByte();
            w.pos              = gb.ReadByte();
            w.unknown          = gb.ReadByte();
            return(w);
        }
Exemplo n.º 18
0
        public frmRepointInteractions(GBFile g, InteractionLoader i, int map, int group, Program.GameTypes game)
        {
            InitializeComponent();
            gb         = g;
            loader     = i;
            this.map   = map;
            this.group = group;
            this.game  = game;

            i.loadInteractions(map, group);
            nAddress.Value = i.getInteractionLocation();
        }
Exemplo n.º 19
0
        public byte[] getMinimapIndexes(int groupIndex, Program.GameTypes game)
        {
            if (!dungeon(groupIndex, game))
            {
                return(null);
            }
            int f   = getFloor(groupIndex, game);
            int loc = (game == Program.GameTypes.Ages ? 0x4FCE : 0x4F41) + (f * 0x40);

            gb.BufferLocation = loc;
            return(gb.ReadBytes(0x40));
        }
Exemplo n.º 20
0
        public static int GetPaletteAddress(GBHL.GBFile gb, Program.GameTypes game, int index)
        {
            int baseColorAddress = (game == Program.GameTypes.Ages ? (0x17 * 0x4000) : (0x16 * 0x4000));

            gb.BufferLocation  = (game == Program.GameTypes.Ages ? 0x632C : 0x6290);
            gb.BufferLocation += index * 2;
            gb.BufferLocation  = gb.ReadByte() + gb.ReadByte() * 0x100;

            byte a = gb.ReadByte();

            gb.BufferLocation = baseColorAddress + gb.ReadByte() + ((gb.ReadByte() - 0x40) * 0x100);

            return((gb.BufferLocation % 0x4000) + 0x4000);
        }
Exemplo n.º 21
0
        public void loadTileset(int tileset, Program.GameTypes game)
        {
            bool flag = tileset > 0xFF;

            tileset &= 0xFF;

            loadSmallTiles(tileset, game);
            decompressSmallTiles(game);

            if (flag && game == Program.GameTypes.Ages)
            {
                replacePast();
            }
        }
Exemplo n.º 22
0
        public void loadTilesetMidTiles(int midTiles, Program.GameTypes game)
        {
            gb.BufferLocation = 0x10000;
            FF97Value         = 4;
            byte a = (byte)midTiles;

            a &= 0x7F;
            if (a == 0)
            {
                return;
            }
            gb.BufferLocation  = 0x10000 + (game == Program.GameTypes.Ages ? 0x1B28 : 0x195E);
            gb.BufferLocation += a * 2;
            gb.BufferLocation  = 0x10000 + gb.ReadByte() + ((gb.ReadByte() - 0x40) * 0x100);
Loop:
            a  = gb.ReadByte();
            a |= a;
            //jr z 487f
            ushort bc = a;

            FF8CValue = (byte)bc;
            bc        = (ushort)((gb.ReadByte() * 0x100) + gb.ReadByte());
            ushort de = (ushort)((gb.ReadByte() * 0x100) + gb.ReadByte());

            a = gb.ReadByte();
            gb.BufferLocation--;
            a        &= 0x7F;
            FF8DValue = a;
            int    pushedHL = gb.BufferLocation;
            ushort pushedDE = de;

            gb.BufferLocation = 0x10000 + bc;
            bc = (ushort)(a * 0x100 + FF8CValue);
            a  = (byte)(bc & 0xFF);
            de = 0xD807;
            loadTilesetHeader(0, 0, false, pushedDE, bc, ref a);

            de = pushedDE;
            gb.BufferLocation = pushedHL;
            a = gb.ReadByte();

            bool carry = (a + a > 255);

            a += a;
            if (carry)
            {
                goto Loop;
            }
        }
Exemplo n.º 23
0
 public bool dungeon(int groupIndex, Program.GameTypes game)
 {
     if (game == Program.GameTypes.Seasons)
     {
         if (groupIndex >= 5)
         {
             return(true);
         }
         return(false);
     }
     if (groupIndex >= 4)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 24
0
        public frmPalette(PaletteLoader p, Form1 f, int tileset, int pal, Program.GameTypes game)
        {
            g       = game;
            pLoader = p;
            form1   = f; //To call the LoadTileset method

            InitializeComponent();
            nTileset.Enabled = nPalette.Enabled = false;

            nTileset.Value = tileset;
            nPalette.Value = pal;
            pLoader        = new PaletteLoader(f.gb);

            palette = pLoader.LoadPalette((int)nPalette.Value, g);
            drawPalette();
            pTileset.Image = f.loadTileset(tileset);
        }
Exemplo n.º 25
0
 public int getSideWarpHeaderAddress(int group, int map, Program.GameTypes game)
 {
     gb.BufferLocation = (game == Program.GameTypes.Ages ? 0x1359E : 0x13457) + (group * 2); //TODO: Seasons
     gb.BufferLocation = 0x10000 + gb.ReadByte() + ((gb.ReadByte() - 0x40) * 0x100);
     while (gb.ReadByte() != 0xFF && gb.BufferLocation < 0x14000)
     {
         if (gb.ReadByte() == map)
         {
             return(gb.BufferLocation - 2);
         }
         else
         {
             gb.BufferLocation += 2;
         }
     }
     return(-1);
 }
Exemplo n.º 26
0
 public int getRealMapGroup(int groupIndex, Program.GameTypes game)
 {
     if (game == Program.GameTypes.Seasons)
     {
         if (groupIndex < 4)
         {
             return(0);
         }
         if (groupIndex == 4)
         {
             return(1);
         }
         if (groupIndex < 19)
         {
             return(4);
         }
         if (groupIndex < 27)
         {
             return(5);
         }
         if (groupIndex == 27)
         {
             return(4);
         }
         return(5);
     }
     if (groupIndex < 4)
     {
         return(groupIndex);
     }
     groupIndex -= 4;
     if (groupIndex >= 26)
     {
         return(4 + (groupIndex & 1));
     }
     if (groupIndex >= 14)
     {
         return(5);
     }
     else
     {
         return(4);
     }
 }
Exemplo n.º 27
0
        public void loadTileset(int headerAddress, int midTiles, int animation, Program.GameTypes game)
        {
            //3828 - start of procedure
            decompressedBuffer = vramBuffer = new byte[256 * 16];
            byte a = 0;

            loadTilesetHeader(headerAddress, 1, true, 0, 0, ref a);
            if (vramBuffer == null)
            {
                vramBuffer = new byte[4096];
                Array.Copy(decompressedBuffer, vramBuffer, decompressedBuffer.Length);
            }

            //Load mid-tile stuff
            loadTilesetMidTiles(midTiles, game);

            //Load animated tiles
            loadAnimatedTiles(animation, game);
        }
Exemplo n.º 28
0
 public frmTransitions(TransitionLoader tl, GBHL.GBFile g, Program.GameTypes ga)
 {
     InitializeComponent();
     gb               = g;
     game             = ga;
     transitionLoader = tl;
     nIndex.Maximum   = tl.transitions.Count - 1;
     if (tl.transitions.Count == 0)
     {
         groupBox1.Enabled = false;
     }
     else
     {
         nMap.Value = transitionLoader.transitions[(int)nIndex.Value].map;
         cboDirection.SelectedIndex = transitionLoader.transitions[(int)nIndex.Value].direction;
         nFrom.Value = PaletteLoader.GetPaletteIndex(gb, game, transitionLoader.transitions[(int)nIndex.Value].from);
         nTo.Value   = PaletteLoader.GetPaletteIndex(gb, game, transitionLoader.transitions[(int)nIndex.Value].to);
     }
 }
Exemplo n.º 29
0
        public void saveRoomPack(int map, int group, byte roompack, Program.GameTypes game)
        {
            if (!((game == Program.GameTypes.Ages && group < 2) ||
                  (game == Program.GameTypes.Seasons && group < 4)))
            {
                return;
            }
            if (game == Program.GameTypes.Ages)
            {
                gb.BufferLocation  = 0x1075C;
                gb.BufferLocation += (0x100 * group);
            }
            else
            {
                gb.BufferLocation = 0x1073C;
            }

            gb.BufferLocation += map;
            gb.WriteByte(roompack);
        }
Exemplo n.º 30
0
        public static int GetPaletteIndex(GBHL.GBFile gb, Program.GameTypes game, int dest)
        {
            int baseColorAddress = (game == Program.GameTypes.Ages ? (0x17 * 0x4000) : (0x16 * 0x4000));

            for (int i = 0; i < 255; i++)
            {
                gb.BufferLocation  = (game == Program.GameTypes.Ages ? 0x632C : 0x6290);
                gb.BufferLocation += i * 2;
                gb.BufferLocation  = gb.ReadByte() + gb.ReadByte() * 0x100;

                byte a = gb.ReadByte();

                gb.BufferLocation = baseColorAddress + gb.ReadByte() + ((gb.ReadByte() - 0x40) * 0x100);
                if ((gb.BufferLocation % 0x4000) + 0x4000 == dest)
                {
                    return(i);
                }
            }
            return(-1);
        }