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 }
public GscSprite(Gsc game, GscMap map, byte id, ReadStream 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(); }
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]; } } }
public RbySpecies(Rby game, byte indexNumber, ReadStream data) : this(game, indexNumber) { Game = game; PokedexNumber = data.u8(); BaseHP = data.u8(); BaseAttack = data.u8(); BaseDefense = data.u8(); BaseSpeed = data.u8(); BaseSpecial = data.u8(); Type1 = (RbyType)data.u8(); Type2 = (RbyType)data.u8(); CatchRate = data.u8(); BaseExp = data.u8(); FrontSpriteWidth = data.Nybble(); FrontSpriteHeight = data.Nybble(); FrontSpritePointer = data.u16le(); BackSpritePointer = data.u16le(); BaseMoves = new RbyMove[] { Game.Moves[data.u8()], Game.Moves[data.u8()], Game.Moves[data.u8()], Game.Moves[data.u8()] }; GrowthRate = (GrowthRate)data.u8(); data.Seek(8); // TODO: HMs/TMs }
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, }; } } }