Guest User

Hextator

a guest
Feb 19th, 2009
378
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Beast data type
  2.  
  3. union Word
  4. {
  5.     unsigned char byte[4];
  6.     unsigned short halfword[2];
  7.     unsigned int word;
  8.     signed char sbyte[4];
  9.     signed short shalfword[2];
  10.     signed int sword;
  11.     float single;
  12.     void * pointer;
  13. };
  14.  
  15. //Globals
  16.  
  17. #define MAIN_CHAR_DATA_PTR  ((void *) 0x801C84A0)   //Purpose unknown
  18. #define AUX_CHAR_DATA_PTR   ((void *) 0x801DA300)   //Purpose unknown
  19.  
  20. #define PSFE_ROUTINE_PTR     0x80022FD0
  21. #define DEATH_FLASH_ROUTINE_PTR  0x80025B4C
  22. #define HIGHLIGHT_ROUTINE_PTR    0x80027090
  23. #define DEAL_DAMAGE_ROUTINE_PTR  0x80028390
  24. #define UDQ_ROUTINE_PTR      0x800503DC
  25.  
  26. #define SFE_G_SKULLTULA_HIT  0x0000386B
  27. #define SFE_G_SKULLTULA_KILLED   0x00003885
  28.  
  29. //Limit notes
  30.  
  31. #define MAX_CHAR_OBJS        0x????????
  32. #define CHAR_OBJ_SIZE        0x000001F0
  33.  
  34. //Character labels
  35.  
  36. //Structure definitions
  37.  
  38. class charObj
  39. {
  40. public:
  41.     Word data[CHAR_OBJ_SIZE>>2];
  42.  
  43. //Character struct labels
  44.  
  45. #define INTERACTION_FLAGS_1 data[0x000>>2].byte[0]
  46. #define INTERACTION_FLAGS_2 data[0x000>>2].byte[1]
  47. #define INTERACTION_FLAGS_3 data[0x000>>2].byte[2]
  48. #define INTERACTION_FLAGS_4 data[0x000>>2].byte[3]
  49. #define UNK_WORD_1      data[0x004>>2].word
  50. #define X_POSITION      data[0x038>>2].single
  51. #define Z_POSITION      data[0x03C>>2].single
  52. #define Y_POSITION      data[0x040>>2].single
  53. #define X_SCALE         data[0x050>>2].single
  54. #define Z_SCALE         data[0x054>>2].single
  55. #define Y_SCALE         data[0x058>>2].single
  56. #define DAMAGE_TABLE_PTR    data[0x098>>2].pointer
  57. #define WEIGHT          data[0x0AC>>2].byte[2]
  58. #define HEALTH          data[0x0AC>>2].byte[3]
  59. #define DAMAGE_QUEUE        data[0x0B0>>2].byte[0]
  60. #define ANGLE_FACING        data[0x0B4>>2].word
  61. #define ANGLE_FACING_LO     data[0x0B4>>2].shalfword[1]
  62. #define DAMAGE_ROUTINE_PTR  data[0x130>>2].pointer
  63. #define MOVEMENT_DATA_PTR   data[0x144>>2].pointer
  64.  
  65. //Character methods
  66.  
  67. inline void updateDamageQueue()
  68. {
  69.     (
  70.         (
  71.             void (*)
  72.             (
  73.                 void * mainCharDataPtr,
  74.                 void * auxCharDataPtr,
  75.                 void * mainCharObjRefPtr,
  76.                 void * auxCharObjRefPtr
  77.             )
  78.         )
  79.         UDQ_ROUTINE_PTR
  80.     )
  81.     (
  82.         MAIN_CHAR_DATA_PTR,
  83.         AUX_CHAR_DATA_PTR,
  84.         (void *) ((int) this + 0x294),
  85.         (void *) ((int) this + 0x2B4)
  86.     );
  87. }
  88.  
  89. inline void highlightChar()
  90. {
  91.     (
  92.         (
  93.             void (*)
  94.             (
  95.                 charObj * charObjPtr,
  96.                 unsigned short hue,
  97.                 unsigned short duration,
  98.                 unsigned short unkInt
  99.             )
  100.         )
  101.         HIGHLIGHT_ROUTINE_PTR
  102.     )
  103.     (
  104.         this,
  105.         0x4000,
  106.         0x00C8,
  107.         0x0000
  108.     );
  109. }
  110.  
  111. inline void playSoundEffect(unsigned short SFEToPlay)
  112. {
  113.     (
  114.         (
  115.             void (*)
  116.             (
  117.                 charObj * charObjPtr,
  118.                 unsigned short SFEID
  119.             )
  120.         )
  121.         PSFE_ROUTINE_PTR
  122.     )
  123.     (
  124.         this,
  125.         SFEToPlay
  126.     );
  127. }
  128.  
  129. inline void deathFlash()
  130. {
  131.     (
  132.         (
  133.             void (*)
  134.             (
  135.                 void * mainCharDataPtr,
  136.                 charObj * charObjPtr
  137.             )
  138.         )
  139.         DEATH_FLASH_ROUTINE_PTR
  140.     )
  141.     (
  142.         MAIN_CHAR_DATA_PTR,
  143.         this
  144.     );
  145. }
  146.  
  147. inline void dealDamage()
  148. {
  149.     (
  150.         (
  151.             void (*)
  152.             (
  153.                 charObj * charObjPtr
  154.             )
  155.         )
  156.         DEAL_DAMAGE_ROUTINE_PTR
  157.     )
  158.     (
  159.         this
  160.     );
  161. }
  162. };
  163.  
  164. class controllerInput
  165. {
  166. public:
  167.     Word padButtons;
  168.  
  169. //Player input defintions
  170.  
  171. #define PAD_BUTTON_A         0x00008000
  172. #define PAD_BUTTON_B         0x00004000
  173. #define PAD_TRIGGER_Z        0x00002000
  174. #define PAD_BUTTON_START     0x00001000
  175. #define PAD_BUTTON_UP        0x00000800
  176. #define PAD_BUTTON_DOWN      0x00000400
  177. #define PAD_BUTTON_LEFT      0x00000200
  178. #define PAD_BUTTON_RIGHT     0x00000100
  179. #define PAD_TRIGGER_L        0x00000020
  180. #define PAD_TRIGGER_R        0x00000010
  181. #define PAD_C_UP         0x00000008
  182. #define PAD_C_DOWN       0x00000004
  183. #define PAD_C_LEFT       0x00000002
  184. #define PAD_C_RIGHT      0x00000001
  185.  
  186. #define PAD_BUTTON_A_UPPER   0x00000080
  187. #define PAD_BUTTON_B_UPPER   0x00000040
  188. #define PAD_TRIGGER_Z_UPPER  0x00000020
  189. #define PAD_BUTTON_START_UPPER   0x00000010
  190. #define PAD_BUTTON_UP_UPPER  0x00000008
  191. #define PAD_BUTTON_DOWN_UPPER    0x00000004
  192. #define PAD_BUTTON_LEFT_UPPER    0x00000002
  193. #define PAD_BUTTON_RIGHT_UPPER   0x00000001
  194.  
  195. //Player input methods
  196.  
  197. inline bool PAD_AreButtonsHeld(unsigned short buttons)
  198. {
  199.     return (padButtons.halfword[0] & buttons) == buttons;
  200. }
  201.  
  202. inline bool PAD_AreUpperHeld(unsigned char buttons)
  203. {
  204.     return (padButtons.byte[0] & buttons) == buttons;
  205. }
  206.  
  207. inline bool PAD_AreLowerHeld(unsigned char buttons)
  208. {
  209.     return (padButtons.byte[1] & buttons) == buttons;
  210. }
  211. };
  212.  
  213. //Memory labels
  214.  
  215. //charObj * characters = (charObj *) 0x????????;
  216. //controllerInput * player1Input = (controllerInput *) 0x????????;
  217.  
  218. //Memory label corrections
  219.  
  220. #define PLAYER_1_INPUT      (* player1Input).padButtons.halfword[0]
  221. #define PLAYER_1_UPPER_INPUT    (* player1Input).padButtons.byte[0]
  222. #define PLAYER_1_LOWER_INPUT    (* player1Input).padButtons.byte[1]
  223.  
  224. //Global functions
  225.  
  226. inline void updateDamageQueue(charObj * targetChar)
  227. {
  228.     (
  229.         (
  230.             void (*)
  231.             (
  232.                 void * mainCharDataPtr,
  233.                 void * auxCharDataPtr,
  234.                 void * mainCharObjRefPtr,
  235.                 void * auxCharObjRefPtr
  236.             )
  237.         )
  238.         UDQ_ROUTINE_PTR
  239.     )
  240.     (
  241.         MAIN_CHAR_DATA_PTR,
  242.         AUX_CHAR_DATA_PTR,
  243.         (void *) ((int) targetChar + 0x294),
  244.         (void *) ((int) targetChar + 0x2B4)
  245.     );
  246. }
  247.  
  248. inline void highlightChar(charObj * targetChar)
  249. {
  250.     (
  251.         (
  252.             void (*)
  253.             (
  254.                 charObj * charObjPtr,
  255.                 unsigned short hue,
  256.                 unsigned short duration,
  257.                 unsigned short unkInt
  258.             )
  259.         )
  260.         HIGHLIGHT_ROUTINE_PTR
  261.     )
  262.     (
  263.         targetChar,
  264.         0x4000,
  265.         0x00C8,
  266.         0x0000
  267.     );
  268. }
  269.  
  270. inline void playSoundEffect(charObj * targetChar, unsigned short SFEToPlay)
  271. {
  272.     (
  273.         (
  274.             void (*)
  275.             (
  276.                 charObj * charObjPtr,
  277.                 unsigned short SFEID
  278.             )
  279.         )
  280.         PSFE_ROUTINE_PTR
  281.     )
  282.     (
  283.         targetChar,
  284.         SFEToPlay
  285.     );
  286. }
  287.  
  288. inline void deathFlash(charObj * targetChar)
  289. {
  290.     (
  291.         (
  292.             void (*)
  293.             (
  294.                 void * mainCharDataPtr,
  295.                 charObj * charObjPtr
  296.             )
  297.         )
  298.         DEATH_FLASH_ROUTINE_PTR
  299.     )
  300.     (
  301.         MAIN_CHAR_DATA_PTR,
  302.         targetChar
  303.     );
  304. }
  305.  
  306. inline void dealDamage(charObj * targetChar)
  307. {
  308.     (
  309.         (
  310.             void (*)
  311.             (
  312.                 charObj * charObjPtr
  313.             )
  314.         )
  315.         DEAL_DAMAGE_ROUTINE_PTR
  316.     )
  317.     (
  318.         targetChar
  319.     );
  320. }
  321.  
  322. int main()
  323. {
  324. #define SOME_CHAR       ((charObj *) 0x00000000)
  325.     SOME_CHAR->highlightChar();
  326.     SOME_CHAR->playSoundEffect(SFE_G_SKULLTULA_KILLED);
  327.     SOME_CHAR->deathFlash();
  328.     SOME_CHAR->dealDamage();
  329. }
  330.  
RAW Paste Data