@@ -6,13 +6,22 @@ namespace FF1Lib
66{
77 public partial class FF1Rom : NesRom
88 {
9+ public enum FinalFormation
10+ {
11+ WarMECHsAndFriends ,
12+ KaryAndTiamat ,
13+ TheFundead ,
14+ TimeLoop ,
15+ } ;
16+
917 private const int FormationsOffset = 0x2C400 ;
1018 private const int FormationSize = 16 ;
1119
12- private const int FormationCount = 128 ; // Total formations
13- private const int NormalFormationCount = 115 ; // Number of formations before all the boss encounters.
14- private const int BossFormationCount = 13 ; // Lichx2, Karyx2, Krakenx2, Tiamatx2, Chaos, Vampire, Astos, Pirates, Garland
15- private const int VanillaUnrunnableCount = 13 ; // 13 of the Vanilla normal formations are unrunnable.
20+ private const int FormationCount = 128 ; // Total formations
21+ private const int NormalFormationCount = 115 ; // Number of formations before all the boss encounters.
22+ private const int BossFormationCount = 13 ; // Lichx2, Karyx2, Krakenx2, Tiamatx2, Chaos, Vampire, Astos, Pirates, Garland
23+ private const int VanillaUnrunnableCount = 13 ; // 13 of the Vanilla normal formations are unrunnable.
24+ private const int ChaosFormationIndex = 123 ; // Index of Chaos battle that preceeds The End
1625
1726 // Formation Data Offsets ripped straight from Disch's variables.inc
1827 private const byte TypeOffset = 0x00 ; // battle type (high 4 bits)
@@ -53,6 +62,63 @@ public void ShuffleSurpriseBonus(MT19337 rng)
5362 formations = formations . Zip ( chances , ( formation , chance ) => { formation [ SurpriseOffset ] = chance ; return formation ; } ) . ToList ( ) ;
5463 Put ( FormationsOffset , formations . SelectMany ( formation => formation . ToBytes ( ) ) . ToArray ( ) ) ;
5564 }
65+
66+ public void TransformFinalFormation ( FinalFormation formation )
67+ {
68+ Blob finalBattle = Get ( FormationsOffset + ChaosFormationIndex * FormationSize , FormationSize ) ;
69+
70+ switch ( formation )
71+ {
72+ case FinalFormation . WarMECHsAndFriends :
73+ finalBattle [ TypeOffset ] = 0x2C ; // Big/Small Enemy mix, and the Astos/Madpony/Badman/WarMECH patterns
74+ finalBattle [ GFXOffset ] = 0x03 ; // WarMECH Badman N/A N/A
75+ finalBattle [ IDsOffset + 0 ] = 0x76 ; // WarMECH (battle stats, etc)
76+ finalBattle [ IDsOffset + 1 ] = 0x70 ; // EvilMan
77+ finalBattle [ QuantityOffset + 0 ] = 0x22 ;
78+ finalBattle [ QuantityOffset + 1 ] = 0x66 ;
79+ finalBattle [ PalettesOffset + 0 ] = 0x2F ;
80+ finalBattle [ PalettesOffset + 1 ] = 0x17 ;
81+ finalBattle [ PaletteAsignmentOffset ] = 0x41 ; // Palette Assignment in top nibble, 1 in bottom for unrunnable.
82+ break ;
83+ case FinalFormation . KaryAndTiamat :
84+ finalBattle [ TypeOffset ] = 0x2B ; // Big/Small Enemy mix, and the Dragon2 pattern
85+ finalBattle [ GFXOffset ] = 0x05 ; // Dragon Dragon N/A N/A
86+ finalBattle [ IDsOffset + 0 ] = 0x7A ; // Kary2
87+ finalBattle [ IDsOffset + 1 ] = 0x7E ; // Tiamat2
88+ finalBattle [ QuantityOffset + 0 ] = 0x11 ;
89+ finalBattle [ QuantityOffset + 1 ] = 0x11 ;
90+ finalBattle [ PalettesOffset + 0 ] = 0x08 ;
91+ finalBattle [ PalettesOffset + 1 ] = 0x0A ;
92+ finalBattle [ PaletteAsignmentOffset ] = 0x41 ; // Palette Assignment in top nibble, 1 in bottom for unrunnable.
93+ break ;
94+ case FinalFormation . TheFundead :
95+ finalBattle [ TypeOffset ] = 0x24 ; // Eye pattern
96+ finalBattle [ GFXOffset ] = 0x0B ; // Eye / Geist
97+ finalBattle [ IDsOffset + 0 ] = 0x78 ; // Lich2
98+ finalBattle [ IDsOffset + 1 ] = 0x33 ; // Phantom
99+ finalBattle [ QuantityOffset + 0 ] = 0x22 ;
100+ finalBattle [ QuantityOffset + 1 ] = 0x44 ;
101+ finalBattle [ PalettesOffset + 0 ] = 0x03 ;
102+ finalBattle [ PalettesOffset + 1 ] = 0x17 ;
103+ finalBattle [ PaletteAsignmentOffset ] = 0x41 ; // Palette Assignment in top nibble, 1 in bottom for unrunnable.
104+ break ;
105+ case FinalFormation . TimeLoop :
106+ finalBattle [ TypeOffset ] = 0x0B ; // 9Small + Garland pattern
107+ finalBattle [ GFXOffset ] = 0x2A ; // Garland Garland Garland N/A
108+ finalBattle [ IDsOffset + 0 ] = 0x69 ; // Garland
109+ finalBattle [ IDsOffset + 1 ] = 0x7F ; // Chaos
110+ finalBattle [ IDsOffset + 2 ] = 0x69 ; // Garland
111+ finalBattle [ QuantityOffset + 0 ] = 0x08 ;
112+ finalBattle [ QuantityOffset + 1 ] = 0x11 ;
113+ finalBattle [ QuantityOffset + 2 ] = 0x88 ;
114+ finalBattle [ PalettesOffset + 0 ] = 0x00 ;
115+ finalBattle [ PalettesOffset + 1 ] = 0x00 ;
116+ finalBattle [ PaletteAsignmentOffset ] = 0x01 ; // Palette Assignment in top nibble, 1 in bottom for unrunnable.
117+ break ;
118+ }
119+
120+ Put ( FormationsOffset + ChaosFormationIndex * FormationSize , finalBattle ) ;
121+ }
56122 }
57123
58124}
0 commit comments