Advertisement
TerusTheBird

tiny actor

Feb 2nd, 2020
624
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.86 KB | None | 0 0
  1.  
  2. #include <z64ovl/oot/u10.h>
  3.  
  4. typedef struct {
  5.     z64_actor_t actor;
  6. } entity_t;
  7.  
  8. typedef union {
  9.     void* dp_void;
  10.     u8*   dp_u8;
  11.     u16*  dp_u16;
  12.     u32*  dp_u32;
  13.     u64*  dp_u64;
  14.     s8*   dp_s8;
  15.     s16*  dp_s16;
  16.     s32*  dp_s32;
  17.     s64*  dp_s64;
  18.     u8    bytes[ 4 ];
  19.     u32   word;
  20. } dp_types;
  21.  
  22. typedef union {
  23.     u8 bytes[ 11 ];
  24.     struct {
  25.         u8* ptr;
  26.         u8  padding[ 7 ];
  27.     } c00_data;
  28.     struct {
  29.         u8  number_of_bytes;
  30.         u8  bytes[ 10 ];
  31.     } c01_data;
  32.     struct {
  33.         u64 number_of_zeroes;
  34.         u8  padding[ 3 ];
  35.     } c02_data;
  36.     struct {
  37.         // ?????
  38.     } c03_data;
  39.     struct {
  40.         void (*func_pointer)(void);
  41.         u8 padding[ 7 ];
  42.     } c04_data;
  43. } pad_data_t;
  44. // sizeof(pad_data_t) == 11
  45.  
  46. static volatile dp_types data_pointer;
  47.  
  48. static void step( entity_t* entity, z64_global_t* global ) {
  49.     volatile pad_data_t temp;
  50.     union {
  51.         struct {
  52.             u8 big_endian_padding;
  53.             u8 ll_command;
  54.             u8 byte2;
  55.             u8 byte1;
  56.         };
  57.         u32 word;
  58.     } leftover;
  59.     #define padb( pad, byte ) ( ((u8*)&(global->common.input[ pad ].raw))[ byte ] )
  60.    
  61.     temp.bytes[ 0 ] = padb( 1, 0 );
  62.     temp.bytes[ 1 ] = padb( 1, 2 );
  63.     temp.bytes[ 2 ] = padb( 1, 3 );
  64.     temp.bytes[ 3 ] = padb( 2, 0 );
  65.     temp.bytes[ 4 ] = padb( 2, 2 );
  66.     temp.bytes[ 5 ] = padb( 2, 3 );
  67.     temp.bytes[ 6 ] = padb( 3, 0 );
  68.     temp.bytes[ 7 ] = padb( 3, 2 );
  69.     temp.bytes[ 8 ] = padb( 3, 3 );
  70.    
  71.     leftover.word  = padb( 1, 1 ); leftover.word <<= 6;
  72.     leftover.word |= padb( 2, 1 ); leftover.word <<= 6;
  73.     leftover.word |= padb( 3, 1 );
  74.    
  75.     temp.bytes[  9 ] = leftover.byte1;
  76.     temp.bytes[ 10 ] = leftover.byte2;
  77.    
  78.     switch( leftover.ll_command ) {
  79.         case 0: {
  80.            
  81.         } break;
  82.     }
  83. }
  84.  
  85. const z64_actor_init_t init_vars = {
  86.     .number = 0xDEAD, .padding = 0xBEEF,
  87.     .type = 0x06, // stage prop
  88.     .room = 0x00,
  89.     .flags = 0x00000030,
  90.     .object = 1,
  91.     .instance_size = sizeof(entity_t),
  92.     .init = NULL,
  93.     .dest = NULL,
  94.     .main = step,
  95.     .draw = NULL
  96. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement