scrcmd.txt from my info dump in the r&d forum:
http://pastebin.com/yhVVej8A
the script commands are at the end, starting with cmd 0, s0000. the array at the top is super-important if you're adding commands. it's a 0x2f3 u8 array(matching the number of script commands) of bitflags for each script command that each one is verified against before executing. the verifier works because it changes for every type of script command- moves, AI, effects, and events. it's part of the virtual machine built before execution starts. see here: http://img.thundaga.com/verify.png green is the verifier that runs first then hands off to the command execution in red.
7 is for a normal script command
1 is an assembly command
0 is for non-existant script commands- there are about 90 or 95 non-existent script command numbers, more than enough to add your own.
the other flags are for fine-grained stuff and aren't relevant for basically anyone besides me.
ex. s0002 ends a script without jumping to the asm handler, so it's a normal script command and is a 7. s0003 pauses the entire script system for a given amount of time- a spinwait kinda thing in C#. it does it via the asm handler in the script virtual machine, so it's a 1 in the verifier array.
the main script environment struct virtual machine is @ 224A140 and looks like this:
struct ScriptEnvironment
{
u16 maxStackDepth;
u16 maxVars;
ScriptCall *cmdArray;
u32 cmdMax;
u32 unk3;
u32 unk4;
u32 unk5;
u8 stackPointer;
u8 executionState;
u8 scriptCmpResult;
u8 padding;
AsmCall funcptr;
u8 *script_pos_ptr;
u8 *script_stack_ptr;
u32 *vars;
ScrcmdEnvironment *scrcmd_ptr;
ScriptCall script_callback_verifier;
void *sys_info;
Arc_Tool *script_arc_file_ptr;
};
or this if you like it in excel: (see info dump download here for the spreadsheet)
Offset Member Size Use 224A140 2257248 224738C 224A004
0x0 Stack size 2 Max size of the script stack- 4 bytes each
0x2 Global/Environment var size 2 Max number of global/script environment vars- 4 bytes each
0x4 Command ptr array 4 Ptr to command array to fetch script functions from
0x8 Command max 4 Total number of commands
0xC
0x10
0x14
0x18 Stack position 1 sp++ every time a value is added to the stack, sp-- when removed
0x19 Environment state 1 Script environment current running state- 0/1/2 end/script/asm
0x1A Compare result 1 Used for loading from compare mode array for conditionals
0x1B Padding 1 Empty, 00
0x1C Asm ptr 4 Ptr to asm routine for script state asm
0x20 Script pos 4 Ptr to current script position to read from
0x24 Stack 4 ptr to stack
0x28 Global/Environment var 4 Global/Environment var ptr
0x2C Scrcmd environment 4 Ptr to info container
0x30 Script callback 4 Ptr to script callback verifier function
0x34 Gamesys 4 Ptr to main gamesystem
0x38 Script file 4 Ptr to beginning of loaded script file via Arc_Tool*
the entire core of the script system: (see scriptHandler_main for the actual script handler with notes)
http://pastebin.com/zk31sJYg
and last, there are up to 4 virtual machines running at once in a struct that looks like this:
struct ScriptSystem
{
u16 vmMax;
u16 vmCount;
ScriptEnvironment *vmachines[4];
};
vmMax is always 4 and the first element of vmachine struct ptrs will always be 224A140. there's a script command that adds to this and creates submachines off the main one: s001B.
(for anyone who hasn't realized it by now, the entire(literally entire) game hinges on a series of structs within structs within structs with structs that are nothing but pointers to other structs. gamefreak is obsessive about it. it also happens to be good practice for an embedded ARM system- reducing literal pools via relative offsetting, etc.)