[SOLVED] FE8 _SETVAL question

copypasterino from SF

Does anyone know where in memory the data used in FE8’s “_SETVAL” command is stored? A rudimentary search didn’t turn up anything, and I figured I’d ask around (there was definitely someone who had this information) before I cracked open my debugger.

Setval is pretty interesting, it sets the value of four bytes in the $030004B8 area to anything you want; so _SETVAL 0x2 0xABCDEFGH will write GHEFCDAB at ($030004B8+ 4*2 = $030004C0). Some commands will automatically use values from a fixed memory slot (LOAD_WHATEVER 0x1 uses slot 0x2, coordinate-based commands like tile changes, MOVE and LOMA will use slot 0xB…), while some commands require that you define the slot to read from.

It was probably introduced to save space, since the event used to load reinforcements in this game is pretty bulky and it’d take up a lot of space to write it out for every reinforcement. So, instead each reinforcement just says _SETVAL 0x2 0x(unit pointer) and calls the reinforcement loader at the same place.

For events which use up a lot of different values at once (for instance, ones that change the AI of many units at once), the _SAVEFORBATTLE command is also used; this stores the value in slot 0x1 in a queue, and you can have multiple values stored at one this way. This is useful for loops (like the AI changing). You also see it in scripted battles and in Rennac’s recruitment, if you talk to him with your Lord.

Finally, note that Memory slot 0x0 is cleared at the beginning of every event command, so don’t store data in it.

1 Like

Congratulations Venno, you’ve just been impersonated.

I like having the stuff actually on here instead of links to SF, lol.

1 Like

Whoa Arch, stop possessing people, that’s creepy
We should call an exorcist

@Crazycolorz5 Here’s what I was talking about in your ASM topic.
In FE8 there isn’t the equivalent of IFAF or IFAT. But there are several _SETCONDITION that compare the bytes stored in some specific memory slots.

[quote][11/07/2014 01:52:39] David Hyatt: the setcondition command loads its values from data there
[11/07/2014 01:52:49] David Hyatt: according to the command’s parameters
[11/07/2014 01:53:35] David Hyatt: SETCONDITION usually loads from memory slots 0xC and 0x0
[11/07/2014 01:53:47] MarkyJoe1990: Hm.
[11/07/2014 01:56:48] MarkyJoe1990: So with my ASM, I’d have to write r0’s value into one of those spots.
[11/07/2014 01:57:11] Alfred Cm’on!: I think so?
[11/07/2014 01:57:13] MarkyJoe1990: And then Alfred would have to make a SETCONDITION thingy that compares it’s value to 1
[11/07/2014 01:57:39] David Hyatt: yeah, you could just do SETVAL 0x1 0x1
[11/07/2014 01:57:49] David Hyatt: and have your code write to slot 0xC
[11/07/2014 02:00:35] Alfred Cm’on!: brb gotta get some coffee


[11/07/2014 02:00:52] MarkyJoe1990: So then I write the value of r0 to $030004BC, and then Alfred does the _SETCONDITION thing.
[11/07/2014 02:01:05] MarkyJoe1990: $030004BC being slot 0 presumably[/quote]

_SETVAL 0x1 0x1
ASMC 0x1082FC1
CALL hungryboy
ELSE 0x1
ENIF 0x0
CALL croissantforya
ENIF 0x1

Note: the ASMC wrote the data in slot C in the end, because we realized that slot 0 clears itself almost instantly. With this, I write “1” (the value of true?) in memory slot 1, then we call the ASMC and write the result in memory slot C, and compare the bytes in slots 1 and C. If they’re identical, it calls an event, if they differ, it calls another one.

Also, many many thanks to @Venno and @MarkyJoe1990 who helped me with this. :slight_smile:

1 Like