[FE7] ASMC Routine Parameters

The game actually seems to have parameters to the ASMC routines – maybe we should figure out what they are?

ASMC 0xB85D5:

My events are:

OpeningScene:
OOBB
LOU1 Good
STAL 0x10
ASMC 0xB85D5 //Offset of asmc routine to test
ENUT 0x65
ENDA

r0 = 02024F00 (Pointer to 08B90D88)
r1 = 080B85D5
r2 = 00
r3 = 02024F50

they’re data from the event engine

i would guess that r0 is a link register to return to the next event code to execute
r1 is jsut a to be bx’d to
r2 and r3 look like scratch

No, since r14 = 0x800D38D.

Also, [quote=“CT075, post:2, topic:380”]
i would guess that r0 is a link register to return to the next event code to execute
[/quote]
Possibly, since r4 = r0. Though r0 is scratch. It’s also used as a parameter in that ASMC, though.

$800D37C is the event code routine for ASMC; r1 is just the parameter of the ASMC routine in this case; r2 and r3 are scratch.

r4 is the offset of event execution data, containing things like the a pointer to the current event code and the start of the current event branch; FE8 additionally has a bitfield for event execution, but FE7 doesn’t have such a feature. After calling the ASM routine, the ASMC code loads the pointer to the current event code from [r4,0x30] and increases it by the amount of space the command took up. Other commands like STAL will do different things with this, but generally that’s what r4 is for.

FE8 does this automatically based on the event command’s ID, but in FE7 every single event command routine has to do this sort of thing internally which takes up a good chunk of space.

that would be because r1 has already been bx’d to

asmc works similarly to a jump table

Oh that’s what you meant. Nvm then.