[FE8] FreeMovement Rework

FreeMovementControlProc is not being properly initialized.

Because procs are placed in memory dynamically, there is no guarantee that the proc previously occupying the same space didn’t leave behind data. in pFMU_OnInit, it is assumed that FMUnit is initialized to 0. If a proc has previously placed a value here, then the unit pointer used ends up being junk data:

Solution: Add initialization to pFMU_InitTimer

void pFMU_InitTimer(struct FMUProc* proc){
	proc->uTimer = 0;
	proc->FMUnit = 0; //fix
	return;
}

This runs once prior to pFMU_OnInit, which means the field is always initialized to 0 as expected

5 Likes

I endure the quirks of free roam so everyone else doesn’t have to.

got it

1 Like

pFMU_InitTimer seems to run when changing units, meaning the currently controlled unit can’t change beyond the first in the unit array. Instead I initialized proc->FMUnit to 0 in a new function in the first block of the proc code. So far so good.

	FreeMovementControlProc:
	_6C_SET_NAME(FreeMovementProcName)
	_6C_SET_MARK(2)
	_6C_YIELD
    _6C_CALL_ROUTINE(pFMU_InitFMUnit)
	_6C_CALL_ROUTINE($801C895) // ClearActionAndSave
    .
    .
    .

Really thought I was going mad with this one. The blue menu background is drawn on BG1.

  • The tiles are in VRAM.
  • Priority-wise it made sense, BG1 should be drawn over BG3.
  • Window0 was enabled, but disabling it still didn’t get BG1 to show.
  • No HBlankHandlers are active, LCDIOBuffer should reflect memory block 4 exactly.
  • Everything adds up, why doesn’t BG1 show!?
    Turns out BG1 was blending with BG3, so much so that BG1 was invisible. Suddenly feel nostalgic; Somehow I always overlook blending as an option when it comes to these display errors. Anywho, the issue can be solved by clearing windows and blend/BLDY effects before starting the menu.
bool FMU_OnButton_StartMenu(FMUProc* proc){
    gLCDIOBuffer.dispControl.enableWin0 = 0;
    gLCDIOBuffer.dispControl.enableWin1 = 0;
    gLCDIOBuffer.dispControl.enableObjWin = 0;
    gLCDIOBuffer.blendControl.effect = 0;
	StartMenuAdjusted(&FreeMovementLMenu,0,0,0);
	return 1;
}
4 Likes