16
« on: 2022-12-19 13:45:07 »
Lot to unpack here.
1. You are correct on all counts. Keep in mind the game will process an entire script in a single frame. Rather, it will not draw the next actor/background animation frame until the current script is complete. For the PC that means halting the entire battle, for the PSX that just means halting the actor models. Only one script is run per frame just by design. When an enemy's timer is full, it will run its main script after the current active battle action is complete. If everyone is idle then the script will execute immediately. Enemies get queued on their order to execute their scripts based on these timers. Counter action scripts will run in battle index order (Actor 4, Actor 5, etc). General counters first, then physical/magic counter script depending on the type of damage that they took.
2. This is actually an excellent question and one I didn't look into much. NOT masking a bit range has limited uses so I never saw a 02 data type on the stack. However, keep in mind that these are word arguments. They are represented as, say,01 4160
in most disassemblers it will look like 01 60 41
in a hex editor.
3. There is a distinction between global values and global variables. It's might be more accurate to call the 2XXX addresses to be the actions' metadata. The 20A0 address contains a bitmap of all the active targets the current script owner considers an opponent. This does not include dead/nullified opponents. There is only room for a two-byte value here so an enemy will find the value of 0007 during their turn (assuming all playable characters are alive and not petrified). This is set at the beginning of script execution and can be modified, though that's not the desired function.
4. I'm not great with video editing, but I have done a considerable amount of reversing the scripts and can tell you how all of it works. We can keep the conversation here rather than DMs or Discord. I just don't check those as often.