public static void Init() { Rom.Seek(Address); Entries = Rom.ReadUShort(); MasterEntries = Rom.ReadUShort(); Bgs = new GfxBattleBg[Entries]; Masters = new MasterEntry[MasterEntries]; for (int i = 0; i < Entries; i++) { var bg = new GfxBattleBg(); bg.index = i; bg.GfxEntry = Rom.ReadUShort(); bg.ArrEntry = Rom.ReadUShort(); bg.Palette = Rom.ReadPals(2); bg.PalDir = Rom.ReadUShort(); Rom.SeekAdd(2); bg.PalStart = Rom.ReadUShort(); bg.PalEnd = Rom.ReadUShort(); bg.PalDelay = Rom.ReadUShort(); Rom.SeekAdd(0x26); bg.DriftH = Rom.ReadShort(); bg.DriftV = Rom.ReadShort(); Rom.SeekAdd(4); bg.AmplH = Rom.ReadShort(); bg.AmplV = Rom.ReadShort(); bg.WavenumH = Rom.ReadShort(); bg.WavenumV = Rom.ReadShort(); bg.FreqH = Rom.ReadShort(); bg.FreqV = Rom.ReadShort(); Rom.SeekAdd(8); Bgs[i] = bg; } for (int i = 0; i < MasterEntries; i++) { Masters[i] = new MasterEntry(); Masters[i].index = i; Masters[i].Layer[0] = Rom.ReadUShort(); Masters[i].Layer[1] = Rom.ReadUShort(); Masters[i].Alpha[0] = Rom.ReadUShort(); Masters[i].Alpha[1] = Rom.ReadUShort(); Rom.SeekAdd(4); } }
public static void UpdatePal(MPalette pal, GfxBattleBg bg, int t) { // Rotate pal to the t'th frame if ((t > 0) && (bg.PalDelay > 0)) { t = t % (((bg.PalEnd - bg.PalStart) + 1) * bg.PalDelay); for (int i = bg.PalDelay; i < t; i += bg.PalDelay) { RotatePal(pal, bg); } } }
public static void RotatePal(MPalette pal, GfxBattleBg bg) { if (bg.PalDir == 2) { // Forward Color tmp = pal.GetColorAt(bg.PalEnd); for (int j = bg.PalEnd; j > bg.PalStart; j--) { pal.SetColorAt(j, pal.GetColorAt(j - 1)); } pal.SetColorAt(bg.PalStart, tmp); } else { // Backward Color tmp = pal.GetColorAt(bg.PalStart); for (int j = bg.PalStart; j < bg.PalEnd; j++) { pal.SetColorAt(j, pal.GetColorAt(j + 1)); } pal.SetColorAt(bg.PalEnd, tmp); } }
public static int LoadRom(string filename) { if (!File.Exists(filename)) { return(-1); } try { Rom = File.ReadAllBytes(filename); } catch { return(-2); } if (Rom.Length != 0x2000000) { return(-3); } string header = "MOTHER3\0\0\0\0\0A3UJ"; string headerTest = string.Empty; for (int i = 0xA0; i < 0xB0; i++) { headerTest += (char)Rom[i]; } if (!header.Equals(headerTest)) { return(-4); } IsLoaded = true; switch (Rom[0x124C18]) { case 0x9C: Version = RomVersion.English; break; case 0x1C: Version = RomVersion.Englishv12; break; default: Version = RomVersion.Japanese; break; } if (Rom[0x1DB4] == 0x73) { DecodeAddress = 0x13C5F2; DecodeMod = 0x10E; } else { DecodeAddress = 0x13C5D8; DecodeMod = 0x126; } GfxProvider.RomTileCache.Clear(); M3CC.Init(); TextProvider.Init(); TextItemNames.Init(); TextEnemyNames.Init(); TextEnemyShortNames.Init(); TextMusicNames.Init(); TextItemDescriptions.Init(); TextEnemyDescriptions.Init(); TextBattle.Init(); TextMain.Init(); TextMapNames.Init(); TextPsiNames.Init(); TextCharNames.Init(); TextDontCareNames.Init(); GfxBattleTable.Init(); GfxBattleSprites.Init(); GfxItems.Init(); GfxBattleAnimations.Init(); GfxBattleBgTable.Init(); GfxBattleBg.Init(); GfxTownMaps.Init(); GfxLogoTitle.Init(); SpriteData.Init(); MusicPlayerTable.Init(); ActionTable.Init(); SongTable.Init(); return(0); }