Beispiel #1
0
 public GscBGEvent(Gsc game, GscMap map, ByteStream data)
 {
     Y             = data.u8();
     X             = data.u8();
     Function      = (GscBGEventType)data.u8();
     ScriptPointer = data.u16le();
 }
Beispiel #2
0
    public static void IGT(int delay, string path)
    {
        MakeSave();
        IGTResults res = Gsc.IGTCheckParallel(MultiThread.MakeThreads <Gold>(8), 120, new GscIntroSequence(delay, GscStrat.GfSkip, GscStrat.TitleSkip, GscStrat.Continue), 60, gb => gb.Execute(path) == gb.OverworldLoopAddress);

        Console.WriteLine(res.TotalSuccesses + " (RNG: " + res.RNGSuccesses(10) + ")");
    }
Beispiel #3
0
    public GscTileset(Gsc game, byte id, ReadStream data)
    {
        Game = game;
        Id   = id;
        GFX  = data.u8() << 16 | data.u16le();
        Meta = data.u8() << 16 | data.u16le();
        Coll = data.u8() << 16 | data.u16le();
        Anim = data.u16le();
        data.Seek(2);
        PalMap = data.u16le();

        LandPermissions  = new PermissionSet();
        WaterPermissions = new PermissionSet();
        ReadStream collisionData = game.ROM.From("TileCollisionTable");

        for (int i = 0; i < 256; i++)
        {
            CollisionPermissions perms = (CollisionPermissions)(collisionData.u8() & 0xf);  // Ignore the upper nybble as it only indicates whether the tile can be interacted with.
            if (perms == CollisionPermissions.Land)
            {
                LandPermissions.Add((byte)i);
            }
            else if (perms == CollisionPermissions.Water)
            {
                WaterPermissions.Add((byte)i);
            }
        }
    }
Beispiel #4
0
 public GscSpecies(Gsc game, ReadStream data, ReadStream name)   // Names are padded to 10 length using terminator characters.
 {
     Game               = game;
     Name               = game.Charmap.Decode(name.Read(10));
     Id                 = data.u8();
     BaseHP             = data.u8();
     BaseAttack         = data.u8();
     BaseDefense        = data.u8();
     BaseSpeed          = data.u8();
     BaseSpecialAttack  = data.u8();
     BaseSpecialDefense = data.u8();
     Type1              = (GscType)data.u8();
     Type2              = (GscType)data.u8();
     CatchRate          = data.u8();
     BaseExp            = data.u8();
     Item1              = data.u8();
     Item2              = data.u8();
     GenderRatio        = data.u8();
     Unknown1           = data.u8();
     HatchCycles        = data.u8();
     Unknown2           = data.u8();
     FrontSpriteWidth   = data.Nybble();
     FrontSpriteHeight  = data.Nybble();
     data.Seek(4); // 4 unused bytes
     GrowthRate = (GrowthRate)data.u8();
     EggGroup1  = (GscEggGroup)data.Nybble();
     EggGroup2  = (GscEggGroup)data.Nybble();
     data.Seek(8); // TODO: HMs/TMs
 }
Beispiel #5
0
    public static void Execute(this GscStrat strat, Gsc gb)
    {
        switch (strat)
        {
        case GscStrat.GfSkip:
            gb.Hold(Joypad.Start, "GetJoypad");
            gb.Press(Joypad.Start);
            break;

        case GscStrat.TitleSkip:
            gb.Press(Joypad.Start);
            break;

        case GscStrat.MmBack:
            gb.Press(Joypad.B, Joypad.Start);
            break;

        case GscStrat.Continue:
            gb.Press(Joypad.A);
            break;

        case GscStrat.FsBack:
            gb.Press(Joypad.B);
            break;
        }
    }
Beispiel #6
0
 public GscCoordEvent(Gsc game, GscMap map, ByteStream data)
 {
     Map     = map;
     SceneId = data.u8();
     Y       = data.u8();
     X       = data.u8();
     data.Seek(1);
     ScriptPointer = data.u16le();
     data.Seek(2);
 }
Beispiel #7
0
 public static GscPokemon Textboxes(Gsc gb)
 {
     gb.InjectOverworld(Joypad.A);
     gb.AdvanceFrame(Joypad.A);
     gb.Press(Joypad.B);
     gb.ClearText(Joypad.B);
     gb.Press(Joypad.A);
     gb.ClearText(Joypad.B, 3);
     gb.Hold(Joypad.B, "CalcMonStats");
     return(gb.PartyMon1);
 }
Beispiel #8
0
 public GscWarp(Gsc game, GscMap map, byte index, ByteStream data)
 {
     Map              = map;
     Index            = index;
     Y                = data.u8();
     X                = data.u8();
     DestinationIndex = (byte)(data.u8() - 1);
     MapGroup         = data.u8();
     MapNumber        = data.u8();
     Allowed          = false;
 }
Beispiel #9
0
 public GscMove(Gsc game, ByteStream data, ByteStream name)
 {
     Game         = game;
     Name         = game.Charmap.Decode(name.Until(Charmap.Terminator));
     Id           = data.u8();
     Effect       = (GscEffect)data.u8();
     Power        = data.u8();
     Type         = (GscType)data.u8();
     Accuracy     = data.u8();
     PP           = data.u8();
     EffectChance = data.u8();
 }
Beispiel #10
0
    public void ExecuteUntilIGT(Gsc gb)
    {
        gb.HardReset(false);
        gb.Hold(Joypad.Left, 0x100);

        foreach (GscStrat strat in this)
        {
            strat.Execute(gb);
        }

        gb.Hold(Joypad.Left, "GetJoypad");
        gb.AdvanceFrames(Delay + 1, Joypad.Left);
    }
Beispiel #11
0
 public GscSprite(Gsc game, GscMap map, byte id, ByteStream data)
 {
     Map              = map;
     Id               = id;
     PictureId        = data.u8();
     Y                = (byte)(data.u8() - 4);
     X                = (byte)(data.u8() - 4);
     MovementFunction = (GscSpriteMovement)data.u8();
     MovementRadiusY  = data.Nybble();
     MovementRadiusX  = data.Nybble();
     H1               = data.u8();
     H2               = data.u8();
     Color            = data.Nybble();
     Function         = (GscSpriteType)data.Nybble();
     SightRange       = data.u8();
     ScriptPointer    = data.u16le();
     EventFlag        = data.u16le();
 }
Beispiel #12
0
    public GscItem(Gsc game, byte id, ReadStream name, ReadStream attributes)
    {
        Game       = game;
        Name       = game.Charmap.Decode(name.Until(Charmap.Terminator));
        Id         = id;
        Price      = attributes.u16le();
        HeldEffect = attributes.u8();
        Parameter  = attributes.u8();
        Property   = attributes.u8();
        Pocket     = (GscPocket)attributes.u8();
        FieldMenu  = attributes.Nybble();
        BattleMenu = attributes.Nybble();

        if (id <= 0xb3)
        {
            ExecutionPointer = 0x3 << 16 | game.ROM.u16le(game.SYM["ItemEffects"] + (byte)(id - 1) * 2);
            if (game.SYM.Contains(ExecutionPointer))
            {
                ExecutionPointerLabel = game.SYM[ExecutionPointer];
            }
        }
    }
Beispiel #13
0
    public static string CleanUpPathParallel <Gb>(Gb[] gbs, IGTResults initialStates, int ss, params Action[] path) where Gb : Gsc
    {
        List <int> aPressIndices = new List <int>();

        for (int i = 0; i < path.Length; i++)
        {
            if ((path[i] & Action.A) > 0)
            {
                aPressIndices.Add(i);
            }
        }

        foreach (int index in aPressIndices)
        {
            path[index] &= ~Action.A;
            int successes = Gsc.IGTCheckParallel(gbs, initialStates, gb => gb.Execute(path) == gb.SYM["OWPlayerInput"]).TotalSuccesses;
            if (successes < ss)
            {
                path[index] |= Action.A;
            }
        }

        return(ActionFunctions.ActionsToPath(path));
    }
Beispiel #14
0
 public GscItem(Gsc game, byte id, ByteStream name)
 {
     Game = game;
     Name = game.Charmap.Decode(name.Until(Charmap.Terminator));
     Id   = id;
 }
Beispiel #15
0
    public GscMap(Gsc game, int group, int number, ReadStream data)
    {
        Game   = game;
        Group  = (byte)group;
        Number = (byte)number;
        Id     = group << 8 | number;
        byte bank = data.u8();

        Tileset      = game.Tilesets[data.u8()];
        Environment  = data.u8();
        Attributes   = bank << 16 | data.u16le();
        Location     = data.u8();
        Music        = data.u8();
        PhoneService = data.Nybble() == 0;
        TimeOfDay    = (GscPalette)data.Nybble();
        FishGroup    = (GscFishGroup)data.u8();

        Name = game.SYM[Attributes];
        Name = Name.Substring(0, Name.IndexOf("_MapAttributes"));

        EnvironmentColorPointer = game.SYM["EnvironmentColorsPointers"] & 0xff0000 | game.ROM.u16le(game.SYM["EnvironmentColorsPointers"] + Environment * 2);

        ReadStream attributesData = game.ROM.From(Attributes);

        BorderBlock     = attributesData.u8();
        Height          = attributesData.u8();
        Width           = attributesData.u8();
        Blocks          = attributesData.u8() << 16 | attributesData.u16le();
        Scripts         = attributesData.u8() << 16 | attributesData.u16le();
        Events          = (Scripts & 0xff0000) | attributesData.u16le();
        ConnectionFlags = attributesData.u8();

        Connections = new GscConnection[4];
        for (int i = 3; i >= 0; i--)
        {
            if (((ConnectionFlags >> i) & 1) == 1)
            {
                Connections[i] = new GscConnection(this, attributesData);
            }
        }

        ReadStream eventsData = game.ROM.From(Events + 2);

        Warps = new DataList <GscWarp>();
        Warps.IndexCallback    = obj => obj.Index;
        Warps.PositionCallback = obj => (obj.X, obj.Y);
        byte numWarps = eventsData.u8();

        for (byte i = 0; i < numWarps; i++)
        {
            Warps.Add(new GscWarp(game, this, i, eventsData));
        }

        CoordEvents = new DataList <GscCoordEvent>();
        CoordEvents.PositionCallback = obj => (obj.X, obj.Y);
        byte numCoordEvents = eventsData.u8();

        for (byte i = 0; i < numCoordEvents; i++)
        {
            CoordEvents.Add(new GscCoordEvent(game, this, eventsData));
        }

        BGEvents = new DataList <GscBGEvent>();
        BGEvents.PositionCallback = obj => (obj.X, obj.Y);
        byte numBGEvents = eventsData.u8();

        for (byte i = 0; i < numBGEvents; i++)
        {
            BGEvents.Add(new GscBGEvent(game, this, eventsData));
        }

        Sprites = new DataList <GscSprite>();
        Sprites.IndexCallback    = obj => obj.Id;
        Sprites.PositionCallback = obj => (obj.X, obj.Y);
        byte numSprites = eventsData.u8();

        for (byte i = 0; i < numSprites; i++)
        {
            Sprites.Add(new GscSprite(game, this, i, eventsData));
        }

        byte[] blocks = game.ROM.Subarray(Blocks, Width * Height);
        Tiles = new GscTile[Width * 2, Height * 2];
        for (int i = 0; i < blocks.Length; i++)
        {
            byte block = blocks[i];
            for (int j = 0; j < 4; j++)
            {
                byte collision      = game.ROM[Tileset.Coll + block * 4 + j];
                int  tileSpaceIndex = i * 2 + (j & 1) + (j >> 1) * (Width * 2) + (i / Width * 2 * Width);
                byte xt             = (byte)(tileSpaceIndex % (Width * 2));
                byte yt             = (byte)(tileSpaceIndex / (Width * 2));
                Tiles[xt, yt] = new GscTile {
                    Map       = this,
                    X         = xt,
                    Y         = yt,
                    Collision = collision,
                };
            }
        }
    }
Beispiel #16
0
 public static void EndSearch(int numThreads, int delay, string path, int ss)
 {
     Gold[]   gbs           = MultiThread.MakeThreads <Gold>(numThreads);
     byte[][] initialStates = Gsc.IGTCheckParallel(gbs, 120, new GscIntroSequence(delay, GscStrat.GfSkip, GscStrat.TitleSkip, GscStrat.Continue), 60, gb => gb.Execute(path) == gb.OverworldLoopAddress).States;
     R29(gbs, initialStates, r29[38, 16]);
 }
Beispiel #17
0
 public void Execute(Gsc gb)
 {
     ExecuteUntilIGT(gb);
     ExecuteAfterIGT(gb);
 }
Beispiel #18
0
 public void ExecuteAfterIGT(Gsc gb)
 {
     gb.Hold(Joypad.A, "OWPlayerInput");
 }