Skip to content

Instantly share code, notes, and snippets.

@caseif
Last active July 18, 2025 03:32
Show Gist options
  • Save caseif/4b4890ba86c03e942c48a51ff18f6f1e to your computer and use it in GitHub Desktop.
Save caseif/4b4890ba86c03e942c48a51ff18f6f1e to your computer and use it in GitHub Desktop.
# type replacements
s/\bfloat\b/f32/g
s/\bushort\b/u16/g
s/\bshort\b/s16/g
s/\buint\b/u32/g
s/\bint\b/s32/g
s/\blonglong\b/s32/g
s/\bulong\b/u32/g
s/\blong\b/s32/g
s/\bbyte\b/u8/g
s/\buchar\b/u8/g
# clean up character literals
s/'\\0'/0/g
s/'\\\x\([0-9a-f]\+\)'/0x\1/g
s/'\a'/7/g
s/'\b'/8/g
s/'\t'/9/g
s/'\n'/10/g
s/'\v'/11/g
s/'\f'/12/g
s/'\r'/13/g
s/'\e'/27/g
# add f suffix to float literals
s/\([0-9]\+\.[0-9]\+\)\([^f0-9]\)/\1f\2/g
# transform access to fopAc_ac_c::current by offset
s/\((cXyz \?\*)\)\?(\?\([A-Za-z0-9]\+\) + 0x4d4)\?/\2->current.pos/g
# remove cXyz dtors and ghidra-inserted decls
/cs\?Xyz [A-Za-z0-9_]\+\( \?\[\\d\+\]\)\?/d
/cs\?Xyz::~cs\?Xyz(&.\+)\;/d
# strip leading ::
s/ ::/ /g
# cXyz/csXyz decl
s/c\(s\?\)Xyz::cs\?Xyz(&\?\([^,]\+\));/c\1Xyz \2;/
# cXyz/csXyz decl+assignment
s/c\(s\?\)Xyz::cs\?Xyz(&\?\([^,]\+\),&\?\([^,]\+\));/c\1Xyz \2 = \3;/
# cXyz/csXyz memberwise ctor
s/c\(s\?\)Xyz::cs\?Xyz(&\?\([^,]\+\),\([^,]\+\),\([^,]\+\),\([^,]\+\));/c\1Xyz \2(\3, \4, \5);/
# cXyz/csXyz::set
s/cs\?Xyz::set(&\?\([^,]\+\),\([^,]\+\),\([^,]\+\),\([^,]\+\));/\1.set(\2, \3, \4);/
# cXyz/csXyz operators
s/cs\?Xyz::operator_\? \?\([+\-\*/]\)\? \?=(&\?\([^,]\+\),&\?\([^,]\+\));/\2 \1= \3;/
s/cs\?Xyz::operator_\? \?\([+\-\*/]\) \?(&\?\([^,]\+\),&\?\([^,]\+\),&\?\([^,]\+\));/\2 = \3 \1 \4;/
# remove this->actor references (assuming actor is a superclass but included as a member in ghidra)
s/(this->actor)\.//g
# remove unneeded pointer casts
s/\*([A-Za-z0-9_ *]\+)&//g
s/(Vec \?\*)//g
s/\bcurrent\([^.]\)/current.pos\1/g
# remove namespaces
s/d_a_alink:://g
s/d_a_obj_item//g
s/d_camera:://g
s/d_event:://g
s/d_resorce//g
s/d_shop_system:://g
s/d_stage:://g
s/f_op_actor:://g
s/f_op_actor_mng:://g
s/f_pc_base:://g
s/m_Do_graphic:://g
s/SComponentD:://g
# replace HIO access (short)
s/d_s_play::g_regHIO.mChildReg\[0\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/TREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[1\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/DREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[2\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/IREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[3\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/SREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[4\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/UREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[5\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/OREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[6\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/YREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[7\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/KREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[8\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/BREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[9\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/MREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0xa\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/AREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0xb\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/PREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0xc\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/NREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0xd\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/WREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0xe\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/JREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0xf\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/HREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x10\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/VREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x11\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/XREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x12\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/ZREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x13\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/nREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x14\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/kREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x15\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/oREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x16\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/yREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x17\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/aREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x18\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/hREG_S(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x19\]\.mShortReg\[\(\(0x\)\?[0-9a-f]\+\)\]/tREG_S(\1)/g
# replace HIO access (float)
s/d_s_play::g_regHIO.mChildReg\[0\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/TREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[1\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/DREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[2\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/IREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[3\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/SREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[4\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/UREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[5\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/OREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[6\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/YREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[7\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/KREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[8\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/BREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[9\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/MREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0xa\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/AREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0xb\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/PREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0xc\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/NREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0xd\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/WREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0xe\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/JREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0xf\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/HREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x10\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/VREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x11\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/XREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x12\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/ZREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x13\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/nREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x14\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/kREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x15\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/oREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x16\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/yREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x17\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/aREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x18\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/hREG_F(\1)/g
s/d_s_play::g_regHIO.mChildReg\[0x19\]\.mFloatReg\[\(\(0x\)\?[0-9a-f]\+\)\]/tREG_F(\1)/g
# individual field replacements, these vary by file
# Example:
# s/this->field144_0x780/field_0x748/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment