sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

debug_utils.h (3156B)


      1 #ifndef GD_DEBUGGING_UTILS_H
      2 #define GD_DEBUGGING_UTILS_H
      3 
      4 #include <PR/ultratypes.h>
      5 
      6 #include "gd_types.h"
      7 #include "macros.h"
      8 
      9 #define GD_NUM_MEM_TRACKERS 32
     10 #define GD_NUM_TIMERS 32
     11 
     12 // structs
     13 struct MemTracker {
     14     /* 0x00 */ const char *name;  // name (used as an identifier)
     15     /* 0x04 */ f32 begin;         // used heap space (in bytes) before allocating memory
     16     /* 0x08 */ f32 end;           // used heap space (in bytes) after allocating memory
     17     /* 0x0C */ f32 total;         // total memory (in bytes) allocated between all start_memtracker/stop_memtracker calls
     18 };
     19 
     20 struct GdTimer {
     21     /* 0x00 */ s32 start;   // in cycles
     22     /* 0x04 */ s32 end;     // in cycles
     23     /* 0x08 */ s32 total;   // in cycles
     24     /* 0x0C */ f32 unused;
     25     /* 0x10 */ f32 scaledTotal;  // total / sTimeScaleFactor (1.0f) Unused function modified value
     26     /* 0x14 */ f32 prevScaledTotal;
     27     /* 0x18 */ const char *name;
     28     /* 0x1C */ s32 gadgetColourNum;  // color of gadget that represents timer?
     29     /* 0x20 */ s32 resetCount;
     30 }; // sizeof = 0x24
     31 
     32 union PrintVal {
     33     f32 f;
     34     s32 i;
     35     s64 pad;
     36 };
     37 
     38 /* based on fields set in gd_fopen; gd_malloc_perm(84) for size */
     39 struct GdFile {
     40     /* 0x00 */ u8  filler1[4];
     41     /* 0x04 */ u32 pos;
     42     /* 0x08 */ s8 *stream;
     43     /* Known Flags for +0xC field:
     44     ** 1 : write mode
     45     ** 2 : binary mode
     46     ** 4 : eof */
     47     /* 0x0C */ u32 flags;
     48     /* 0x10 */ u8  filler2[64];
     49     /* 0x50 */ u32 size;
     50 }; /* sizeof() = 0x54 */
     51 
     52 // bss
     53 extern u8 *gGdStreamBuffer;
     54 
     55 // functions
     56 extern struct MemTracker *start_memtracker(const char *);
     57 extern u32 stop_memtracker(const char *);
     58 extern void remove_all_memtrackers(void);
     59 extern struct MemTracker *get_memtracker_by_index(s32);
     60 extern void print_all_memtrackers(void);
     61 extern void print_all_timers(void);
     62 extern void deactivate_timing(void);
     63 extern void activate_timing(void);
     64 extern void remove_all_timers(void);
     65 extern struct GdTimer *get_timer(const char *);
     66 extern struct GdTimer *get_timernum(s32);
     67 extern void start_timer(const char *);
     68 extern void restart_timer(const char *);
     69 extern void split_timer(const char *);
     70 extern void stop_timer(const char *);
     71 extern f32 get_scaled_timer_total(const char *);
     72 extern void fatal_print(const char *) NORETURN;
     73 extern void fatal_printf(const char *, ...) NORETURN;
     74 extern void imin(const char *);
     75 extern void imout(void);
     76 extern f32 gd_rand_float(void);
     77 extern s32 gd_atoi(const char *);
     78 extern f64 gd_lazy_atof(const char *, u32 *);
     79 extern char *sprint_val_withspecifiers(char *, union PrintVal, char *);
     80 extern void gd_strcpy(char *, const char *);
     81 extern char *gd_strdup(const char *);
     82 extern u32 gd_strlen(const char *);
     83 extern char *gd_strcat(char *, const char *);
     84 extern s32 gd_str_not_equal(const char *, const char *);
     85 extern s32 gd_str_contains(const char *, const char *);
     86 extern s32 gd_feof(struct GdFile *);
     87 extern struct GdFile *gd_fopen(const char *, const char *);
     88 extern s32 gd_fread(s8 *, s32, s32, struct GdFile *);
     89 extern void gd_fclose(struct GdFile *);
     90 extern u32 gd_get_file_size(struct GdFile *);
     91 extern s32 gd_fread_line(char *, u32, struct GdFile *);
     92 
     93 #endif // GD_DEBUGGING_UTILS_H