papermario/include/si.h
Ethan Roseman 8c690d23d1
Assorted Morsels (#297)
* bss

* 3 audios

* d5a50 stuff

* some icon funcs

* get_icon_render_pos

* PlayerLandJump

* func_80248170

* cleanup

* splat update prep

* git subrepo pull --force tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "81c4b35b89"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "81c4b35b89"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "9b791a654a"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "9b791a654a"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "2cf2a5e5d8"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "2cf2a5e5d8"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* fix loop in PaperMarioNpcSprites

* git subrepo pull tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "2fab217750"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "2fab217750"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* add sha1 to yaml

* git subrepo pull tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "426b08200d"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "426b08200d"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* varTable -> union :( + player_api funcs

* 6 more

* 4 more

* 5 mo

* 1 mo

* 1 mo 2

* 5 mo

* player_jump

* 3 mo

* some 18F340

* 6 more

* 6 mo

* nm

* 1

* 1 more

* some PR feedback

* symbol addr update

* UnsetCamera0Flag1000

* SetPlayerSpriteSet2

* action 18

* encounter + a smol hammer

* git subrepo pull (merge) tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "8cf482fe57"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "4c0a93eaed"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* 3 and cleanup

* undo yucky union

* PR comments

* get_enemy_safe

* cleanup

* move VirtualEntity

* attempt to fix doxygen

* 3, cleanup

* broken

* fixed!

* progress

* 2

* 3 and cleanup

* 6 map_api funcs

* 3 map api

* CreateNpc

* BringPartnerOut & NpcFlyTo

* npc_api complete

* update_scripts

* 4 si bois inc si_execute_next_command

* update symbol_addrs

* 2 more and cleanup

* camera struct & do_camera_type_0

* PR feedback

* small tidying
2021-06-21 13:30:57 +09:00

150 lines
6.8 KiB
C

#ifndef _SI_H_
#define _SI_H_
#include "ultra64.h"
typedef s32 Bytecode;
typedef s32 ScriptID;
typedef enum ScriptOpcode {
ScriptOpcode_END = 0x01,
ScriptOpcode_RETURN,
ScriptOpcode_LABEL, ///< Args: index
ScriptOpcode_GOTO, ///< Args: index
ScriptOpcode_LOOP, ///< Args: number of repeats (0 = infinite)
ScriptOpcode_END_LOOP,
ScriptOpcode_BREAK_LOOP,
ScriptOpcode_SLEEP_FRAMES,
ScriptOpcode_SLEEP_SECS,
ScriptOpcode_IF_EQ, ///< Args: a, b
ScriptOpcode_IF_NE, ///< Args: a, b
ScriptOpcode_IF_LT, ///< Args: a, b
ScriptOpcode_IF_GT, ///< Args: a, b
ScriptOpcode_IF_LE, ///< Args: a, b
ScriptOpcode_IF_GE, ///< Args: a, b
ScriptOpcode_IF_FLAG, ///< Args: a, b
ScriptOpcode_IF_NOT_FLAG, ///< Args: a, b
ScriptOpcode_ELSE,
ScriptOpcode_END_IF,
ScriptOpcode_MATCH, ///< Args: expression to test against
ScriptOpcode_MATCH_CONST, ///< Args: value to test against
ScriptOpcode_CASE_EQ, ///< Args: expression to test for
ScriptOpcode_CASE_NE, ///< Args: expression to test for
ScriptOpcode_CASE_LT, ///< Args: expression to test for
ScriptOpcode_CASE_GT, ///< Args: expression to test for
ScriptOpcode_CASE_LE, ///< Args: expression to test for
ScriptOpcode_CASE_GE, ///< Args: expression to test for
ScriptOpcode_CASE_ELSE,
ScriptOpcode_CASE_MULTI_OR_EQ, ///< Args: expression to test for
ScriptOpcode_CASE_MULTI_AND_EQ, ///< Args: expression to test for
ScriptOpcode_CASE_FLAG, ///< Args: expression to test for
ScriptOpcode_END_CASE_MULTI, ///< Ends the case block of ScriptOpcode_CASE_MULTI_OR_EQ condition(s).
ScriptOpcode_CASE_RANGE, ///< Args: from, to
ScriptOpcode_BREAK_MATCH,
ScriptOpcode_END_MATCH,
ScriptOpcode_SET, ///< Args: container, expression
ScriptOpcode_SET_CONST, ///< Args: container, value
ScriptOpcode_SET_F, ///< Args: container, expression
ScriptOpcode_ADD, ///< Args: container, expression to increment by
ScriptOpcode_SUB, ///< Args: container, expression to decrement by
ScriptOpcode_MUL, ///< Args: container, expression to multiply by
ScriptOpcode_DIV, ///< Integer division. Args: container, expression to divide by
ScriptOpcode_MOD, ///< Args: container, expression to divide by
ScriptOpcode_ADD_F, ///< Args: container, expression to increment by
ScriptOpcode_SUB_F, ///< Args: container, expression to decrement by
ScriptOpcode_MUL_F, ///< Args: container, expression to multiply by
ScriptOpcode_DIV_F, ///< Args: container, expression to divide by
ScriptOpcode_USE_BUFFER, ///< Args: s32*
ScriptOpcode_BUFFER_READ_1, /// Args: container
ScriptOpcode_BUFFER_READ_2, /// Args: container, container
ScriptOpcode_BUFFER_READ_3, /// Args: container, container, container
ScriptOpcode_BUFFER_READ_4, /// Args: container, container, container, container
ScriptOpcode_BUFFER_PEEK, ///< Args: index, container
ScriptOpcode_USE_BUFFER_F, ///< Identical to USE_BUFFER. Args: f32*
ScriptOpcode_BUFFER_READ_1_F, /// Args: container
ScriptOpcode_BUFFER_READ_2_F, /// Args: container, container
ScriptOpcode_BUFFER_READ_3_F, /// Args: container, container, container
ScriptOpcode_BUFFER_READ_4_F, /// Args: container, container, container, container
ScriptOpcode_BUFFER_PEEK_F, ///< Args: index, container
ScriptOpcode_USE_ARRAY, ///< Args: *s32
ScriptOpcode_USE_FLAGS, ///< Args: *s32
ScriptOpcode_NEW_ARRAY, ///< Allocates a new array. Args: length, s32*
ScriptOpcode_AND, ///< Args: container, expression to bitwise AND with
ScriptOpcode_AND_CONST, ///< Args: container, value to bitwise AND with
ScriptOpcode_OR, ///< Args: container, expression to bitwise OR with
ScriptOpcode_OR_CONST, ///< Args: container, value to bitwise OR with
ScriptOpcode_CALL, ///< Args: *function, ...
ScriptOpcode_SPAWN_SCRIPT, ///< Args: Script*
ScriptOpcode_SPAWN_GET_ID, ///< Args: Script*, container
ScriptOpcode_AWAIT_SCRIPT, ///< Spawns a script and waits for it to return before continuing. Args: Script*
ScriptOpcode_BIND_TRIGGER, ///< Args: Script*, trigger flags, s32 target, 1, Trigger*
ScriptOpcode_UNBIND, ///< Unbinds any triggers bound to this script.
ScriptOpcode_KILL_SCRIPT, ///< Args: ScriptID
ScriptOpcode_JUMP, ///< Args: Script*
ScriptOpcode_SET_PRIORITY, ///< Args: priority
ScriptOpcode_SET_TIMESCALE, ///< Args: timescale
ScriptOpcode_SET_GROUP, ///< Args: group
ScriptOpcode_BIND_PADLOCK, ///< Args: Script*, trigger flags, s32 target, ItemList*, 0, 1
ScriptOpcode_SUSPEND_GROUP, ///< Args: group
ScriptOpcode_RESUME_GROUP, ///< Args: group
ScriptOpcode_SUSPEND_OTHERS, ///< Args: group
ScriptOpcode_RESUME_OTHERS, ///< Args: group
ScriptOpcode_SUSPEND_SCRIPT, ///< Args: ScriptID
ScriptOpcode_RESUME_SCRIPT, ///< Args: ScriptID
ScriptOpcode_SCRIPT_EXISTS, ///< Args: ScriptID, container
ScriptOpcode_SPAWN_THREAD,
ScriptOpcode_END_SPAWN_THREAD,
ScriptOpcode_PARALLEL_THREAD, ///< Parallel threads are killed as soon as the parent script returns.
ScriptOpcode_END_PARALLEL_THREAD,
ScriptOpcode_90,
ScriptOpcode_DEBUG_PRINT, ///< Args: expression
ScriptOpcode_92,
ScriptOpcode_93,
ScriptOpcode_94,
} ScriptOpcode;
#define SI_VAR(v) ((v - 30000000))
#define SI_MAP_VAR(v) ((v - 50000000))
#define SI_FLAG(v) ((v - 70000000))
#define SI_MAP_FLAG(v) ((v - 90000000))
#define SI_AREA_FLAG(v) ((v - 110000000))
#define SI_SAVE_FLAG(v) ((v - 130000000))
#define SI_AREA_VAR(v) ((v - 150000000))
#define SI_SAVE_VAR(v) ((v - 170000000))
#define SI_ARRAY(v) ((v - 190000000))
#define SI_ARRAY_FLAG(v) ((v - 210000000))
#define SI_FIXED(v) (((v * 1024.0f) + -230000000)) // See float_to_fixed_var
#define MAKE_ENTITY_END 0x80000000
#define STORY_PROGRESS SI_SAVE_VAR(0)
#define WORLD_LOCATION SI_SAVE_VAR(425)
/* Return type of si_execute_next_command */
#define SI_CONTINUE 0 /* Continue to next command */
#define SI_ABORT 1 /* Quit execution */
#define SI_FINISH 255 /* Return from script */
/* Return type of script API functions */
typedef s32 ApiStatus;
#define ApiStatus_BLOCK 0 /* Call again next frame */
#define ApiStatus_DONE1 1 /* Unconditional. Probably only exists to return a bool from functions */
#define ApiStatus_DONE2 2 /* Conditional on ScriptInstance->disableScripts */
#define ApiStatus_REPEAT 3 /* Call again immediately */
#define ApiStatus_FINISH 255 /* Corresponds to SI_FINISH */
#define SI_CMD(opcode, argv...) \
opcode, \
/* argc */ (sizeof((Bytecode[]){argv})/sizeof(Bytecode)), \
##argv
#define EXIT_WALK_SCRIPT(walkDistance, exitIdx, map, entryIdx) \
SCRIPT({ \
group 0x1B; \
UseExitHeading(walkDistance, exitIdx); \
spawn ExitWalk; \
GotoMap(map, entryIdx); \
sleep 100; \
})
#endif