Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Veslyquix committed Apr 19, 2024
1 parent e70d45b commit cf64408
Show file tree
Hide file tree
Showing 8 changed files with 569 additions and 346 deletions.
11 changes: 11 additions & 0 deletions .FE6_Installer.event
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#endif
#endif

#define NeverRandomizeMusic // comment this out if you want music randomized
// it only knows of vanilla song IDs though
ALIGN 4
MaxItems_Link:
WORD 0 // If 0, it'll read through your item editor and count
Expand Down Expand Up @@ -342,3 +344,12 @@ EnemyBossMaxHP:
WORD 80
EnemyMaxHP:
WORD 60

ALIGN 4
Opt7Number:
#ifdef NeverRandomizeMusic
WORD 2
#else
WORD 4
#endif

10 changes: 10 additions & 0 deletions .FE7_Installer.event
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "Patches/FE7_AsmHooks.lyn.event"

//#define TLP // to use this installer on TLP
//#define NeverRandomizeMusic // comment this out if you want music randomized
// it only knows of vanilla song IDs though

ALIGN 4
CasualModeFlag:
Expand Down Expand Up @@ -500,3 +502,11 @@ EnemyBossMaxHP:
WORD 80
EnemyMaxHP:
WORD 60

ALIGN 4
Opt7Number:
#ifdef NeverRandomizeMusic
WORD 2
#else
WORD 4
#endif
13 changes: 13 additions & 0 deletions .FE8_Installer.event
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ MESSAGE Open FE8_Installer and read / config things please
//asdf // add two slashes to comment out this line
#endif

#define NeverRandomizeMusic // comment this out if you want music randomized
// it only knows of vanilla song IDs though

ALIGN 4
CasualModeFlag:
WORD 0xB0
Expand Down Expand Up @@ -203,6 +206,8 @@ PUSH
ORG $A20390
PROC_CALL_ROUTINE_2(FE8_StartDifficultySelection)



ORG $205B24
POIN DisplayPage0|1

Expand Down Expand Up @@ -309,3 +314,11 @@ WORD 80
EnemyMaxHP:
WORD 60


ALIGN 4
Opt7Number:
#ifdef NeverRandomizeMusic
WORD 2
#else
WORD 4
#endif
134 changes: 122 additions & 12 deletions C_code.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ int Div(int a, int b) PUREFUNC;
int Mod(int a, int b) PUREFUNC;
int DivArm(int b, int a) PUREFUNC;
extern u8 gCh;
extern u16 gTurn;
extern u8 gPhase;
extern u8 gResumed;
static char* const TacticianName = (char* const) (0x202BC18); //8 bytes long
extern void SetFlag(int flag); // 80798E4
Expand All @@ -47,6 +49,7 @@ struct RandomizerSettingsB {
u8 shopItems : 1;
u8 disp : 1;
u8 foundItems : 1;
u8 randMusic : 1;
};
#endif

Expand All @@ -55,6 +58,7 @@ struct RandomizerSettingsB {
u8 shopItems : 1;
u8 disp : 1;
u8 foundItems : 1;
u8 randMusic : 1;
};
#endif

Expand Down Expand Up @@ -83,6 +87,83 @@ extern int SkillSysInstalled;
extern int StrMagInstalled;
extern int DefaultConfigToVanilla;

u16 HashByte_Ch(int number, int max, int noise[], int offset);
extern int Opt7Number;
int ShouldRandomizeBGM(void) {
if (Opt7Number != 4) { return false; }
if (!RandBitflagsB.randMusic) { return false; }
return true;
}

#ifdef FE6
u8 static const MapMusicList[] = {4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,36,37,38,49,50,55,69,84};
#endif

#ifdef FE7
u8 static const MapMusicList[] = {4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,36,37,38,49,50,55,69,84};
#endif
#ifdef FE8
u8 static const MapMusicList[] = {4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,36,37,38,49,50,55,69,84};
#endif
extern int GetCurrentMapMusicIndex(void);
int GetBGMTrack(){ // fe7/fe8 only?
if (!ShouldRandomizeBGM()) { return GetCurrentMapMusicIndex(); }
int noise[4] = {1, 2, 0, 0};
int number = gPhase;
//if (gActiveUnit) {
// noise[0] = gActiveUnit->xPos;
// noise[1] = gActiveUnit->yPos;
//}
return MapMusicList[HashByte_Ch(number, sizeof(MapMusicList), noise, gTurn)];
};

void m4aSongNumStart(u16);
extern void StartBgm(int songId, struct Proc* proc);
extern int GetCurrentBgmSong(void);
extern void Sound_FadeOutBGM(int speed);
extern void StartBgmExt(int songId, int speed, struct Proc* proc);
void StartMapSongBgm(void) { // 8015F84, 80163E4
StartBgm(GetBGMTrack(), 0); //8003890, 8003210
return;
}
struct PhaseIntroSubProc {
PROC_HEADER;
/* 29 */ u8 _pad_29[0x4C - 0x29];
/* 4C */ s16 timer;
/* 4E */ s16 stat_index;
};
extern u8 gSfx;
#define PlaySoundEffect(id) \
if (!(gSfx & 0x2)) \
m4aSongNumStart((id)) // 80BE594, 809C860
void PhaseIntroInitText(struct PhaseIntroSubProc *proc)
{
if (GetCurrentBgmSong() != GetBGMTrack()) // 80034DC, 8002F68
Sound_FadeOutBGM(4); // 80035EC,

#ifdef FE8
PlaySoundEffect(0x73); // 803DD98, 8036D08
#endif
#ifdef FE7
PlaySoundEffect(0x393); // 803DD98, 8036D08
#endif
#ifdef FE6
PlaySoundEffect(0x73); // 73 as well apparently
#endif

proc->timer = 15;
}
//! FE8U = 0x080328B0
void sub_80328B0(void) {
int bgmIdx = GetBGMTrack();

if (GetCurrentBgmSong() != bgmIdx) {
StartBgmExt(bgmIdx, 6, NULL); //80038AC, 800322C
}

return;
}

inline int IsClassInvalid(int i) {
return ClassExceptions[i].NeverChangeInto;
}
Expand Down Expand Up @@ -2210,12 +2291,23 @@ const char Option6[OPT6NUM][10] = { // Enemies
"-1"
};

#define OPT7NUM 2
const char Option7[OPT7NUM][10] = { // Enemies

#ifndef FE6
#define OPT7NUM 4
const char Option7[OPT7NUM][22] = {
"Classic",
"Casual",
"Classic & Random BGM",
"Casual & Random BGM",
};

#endif
#ifdef FE6
#define OPT7NUM 4
const char Option7[OPT7NUM][10] = {
"Classic",
"Casual",
};
#endif
const u8 OptionAmounts[9] = { OPT0NUM, OPT1NUM, OPT2NUM, OPT3NUM, OPT4NUM, OPT5NUM, OPT6NUM, OPT7NUM, 0 };

#define MENU_X 18
Expand Down Expand Up @@ -2327,7 +2419,7 @@ Max Growth: 100
PutDrawText(&th[i], TILEMAP_LOCATED(gBG0TilemapBuffer, 14, 1+((i-9)*2)), white, 0, 12, Option4[proc->Option[4]]); i++;
PutDrawText(&th[i], TILEMAP_LOCATED(gBG0TilemapBuffer, 14, 1+((i-9)*2)), white, 0, 14, Option5[proc->Option[5]]); i++;
PutDrawText(&th[i], TILEMAP_LOCATED(gBG0TilemapBuffer, 14, 1+((i-9)*2)), white, 0, 5, Option6[proc->Option[6]]); i++;
PutDrawText(&th[i], TILEMAP_LOCATED(gBG0TilemapBuffer, 14, 1+((i-9)*2)), white, 0, 5, Option7[proc->Option[7]]); i++;
PutDrawText(&th[i], TILEMAP_LOCATED(gBG0TilemapBuffer, 14, 1+((i-9)*2)), white, 0, 14, Option7[proc->Option[7]]); i++;
#endif

TileMap_FillRect(TILEMAP_LOCATED(gBG0TilemapBuffer, NUMBER_X-6, Y_HAND), 9, 2, 0);
Expand Down Expand Up @@ -2441,7 +2533,8 @@ void ConfigMenuLoop(ConfigMenuProc* proc) {
RandBitflagsB.shopItems = ((proc->Option[5] == 1) || (proc->Option[5] == 2));
RandBitflagsB.disp = 1;

if (proc->Option[7]) { SetFlag(CasualModeFlag); }
if ((proc->Option[7] == 1) || (proc->Option[7] == 3)) { SetFlag(CasualModeFlag); }
if (proc->Option[7] > 1) { RandBitflagsB.randMusic = 1; }

Proc_Break((ProcPtr)proc);
//BG_SetPosition(BG_3, 0, 0);
Expand Down Expand Up @@ -2512,14 +2605,31 @@ void ConfigMenuLoop(ConfigMenuProc* proc) {
}

else if (keys & DPAD_RIGHT) {
if (proc->Option[id] < (OptionAmounts[id]-1)) { proc->Option[id]++; }
else { proc->Option[id] = 0; }
proc->redraw = true;
if (id == 7) {
if (proc->Option[id] < (Opt7Number - 1)) { proc->Option[id]++; }
else { proc->Option[id] = 0; }
proc->redraw = true;
}


else {
if (proc->Option[id] < (OptionAmounts[id]-1)) { proc->Option[id]++; }
else { proc->Option[id] = 0; }
proc->redraw = true;
}
}
else if (keys & DPAD_LEFT) {
if (proc->Option[id] > 0) { proc->Option[id]--; }
else { proc->Option[id] = OptionAmounts[id] - 1; }
proc->redraw = true;
if (id == 7) {
if (proc->Option[id] > 0) { proc->Option[id]--; }
else { proc->Option[id] = Opt7Number - 1; }
proc->redraw = true;
}

else {
if (proc->Option[id] > 0) { proc->Option[id]--; }
else { proc->Option[id] = OptionAmounts[id] - 1; }
proc->redraw = true;
}
}
DisplayHand(SRR_CursorLocationTable[id].x, SRR_CursorLocationTable[id].y, 0);
if (proc->redraw) {
Expand Down Expand Up @@ -2657,7 +2767,7 @@ void StartConfigMenu(ProcPtr parent) {
InitText(&th[i], 12); i++;
InitText(&th[i], 14); i++;
InitText(&th[i], 5); i++;
InitText(&th[i], 5); i++;
InitText(&th[i], 14); i++;

//LoadUiFrameGraphics();
LoadObjUIGfx();
Expand Down
24 changes: 22 additions & 2 deletions Definitions.s
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ SET_FUNC GenerateExtendedMovementMap, 0x8019425
SET_DATA TerrainTable_MovCost_BerserkerNormal, 0x860C714
SET_DATA TerrainTable_MovCost_BerserkerRain, 0x860C714
SET_DATA gBmMapMovement, 0x202D20C

SET_DATA gPhase, 0x202AA57
SET_DATA gTurn, 0x202AA58
SET_DATA gSfx, 0x202AA65
SET_FUNC StartBgm, 0x8003211
SET_FUNC GetCurrentBgmSong, 0x8002F69
@SET_FUNC Sound_FadeOutBGM, fe7 0x80035EC // ?
SET_FUNC PhaseIntroInitText, 0x801D03D
SET_FUNC StartBgmExt, 0x800322D
SET_FUNC StartMapSongBgm, 0x80163E5
.endif
.if FE7 == true
SET_FUNC memset, 0x080BFFF9
Expand Down Expand Up @@ -71,7 +79,16 @@ SET_FUNC GenerateExtendedMovementMap, 0x8019C81
SET_DATA TerrainTable_MovCost_BerserkerNormal, 0x8BE398C
SET_DATA TerrainTable_MovCost_BerserkerRain, 0x8BE3DDD
SET_DATA gBmMapMovement, 0x202E3E4

SET_DATA gPhase, 0x202BC07
SET_DATA gTurn, 0x202BC08
SET_DATA gSfx, 0x202BC39
SET_FUNC GetCurrentMapMusicIndex, 0x8015E9D
SET_FUNC StartBgm, 0x8003891
SET_FUNC GetCurrentBgmSong, 0x80034DD
SET_FUNC Sound_FadeOutBGM, 0x80035ED
SET_FUNC StartBgmExt, 0x80038AD
SET_FUNC PhaseIntroInitText, 0x801E5C9
SET_FUNC StartMapSongBgm, 0x8015F85
.endif
.if FE8 == true
SET_DATA SaveMenuProc, 0x8A200B8 @ fe8
Expand Down Expand Up @@ -104,6 +121,9 @@ SET_DATA weatherId, 0x202BD05
SET_DATA gPlaySt, 0x202BCF0
SET_DATA gCh, 0x202BCFE
SET_DATA Ballista_TerrainTable, 0x880BC18
SET_DATA gPhase, 0x202BCFF
SET_DATA gTurn, 0x202BD00
SET_DATA gSfx, 0x202BD31
.endif


Expand Down
Loading

0 comments on commit cf64408

Please sign in to comment.