Reading Stan's Thread is a prerequisite to reading this one. Come back once you've read it. Alright, you ready? Throw most of that knowledge out.
Intro: A (FE5) Proc
Surprise, surprise, these little popup windows are handled with procs in FE5, too. Procs in FE5 are a bit different from the GBAFE ones.
Here's the format of a proc type:
+00 word: 2 letter ascii proc name
+02 word: start routine pointer
+04 word: on-cycle routine pointer
+06 word: proc code pointer
There's something very goofy going on here, though. Each of these pointers can only point to things within the current bank. This'll be important later. All of this data gets copied into the proc state stuct, so let's move on to that.
Just like GBAFE procs, FE5 procs have a proc state struct in RAM. Rather than being a contiguous block like GBAFE, each word in a single struct is spaced every 0x20 bytes (There'll be a visualization of that in a moment, don't worry). Here's the layout:
$055B - (2*n) : type structure offset lower word
$057B - (2*n) : type structure offset bank
$059B - (2*n) : two letter name
$05BB - (2*n) : state bits
$05DB - (2*n) : on-cycle pointer
$05FB - (2*n) : proc code pointer
$061B - (2*n) : sleep timer
$063B - (2*n) : Body usage depends on proc
$065B - (2*n) :
$067B - (2*n) :
$069B - (2*n) :
$06BB - (2*n) :
$06DB - (2*n) :
$06FB - (2*n) :
$071B - (2*n) :
$073B - (2*n) :
Procs are added in reverse order, where the first proc has its type lower word at $055B, the second at $0559, etc. This lower word is used to determine if a proc slot is occupied, and is cleared on the proc's destruction. There is room for 0x20 procs.
Here's what this popup looks like in RAM:
This format is pretty readable with there are only a few active.
An important difference between GBAFE procs and FE5 procs is that FE5 procs need no proc code at all. They can mix and match having a start routine, an on-cycle routine, and a proc code (You could have a proc that has none of these, but that's pretty pointless). Start routines are executed immediately after the proc state is written, and then the on-cycle routine is executed before moving on.
A little bit about the proc code:
FE5's proc code isn't as convenient as GBAFE's. There are two types of codes, the first being timer numbers. A timer number simply sets the timer in the proc state. They're a word long.
The other type is rather annoying. GBAFE proc instructions are an index in a table of routines, whereas FE5 instructions are pointers to routines.
Routine pointers are also only a word long. Remember when I said that the pointers in the proc type referred to the bank the type was in? Proc code routine pointers all point to things in bank $82 (mapped). To get around this limitation, these routines usually take parameters like long pointers to other routines. Anyway, each instruction being a short pointer in bank $82 leaves me to hunt down possible routines, so I don't have a convenient list, yet.
Confused? I'll have an example ready soon.
This is super WIP and will be updated as I learn things.