Imported dolphin/demo except for one function

This commit is contained in:
dbalatoni13 2024-11-12 01:40:59 +01:00
parent ae3ebb8331
commit 36a05264a5
11 changed files with 1866 additions and 0 deletions

72
include/dolphin/demo.h Normal file
View file

@ -0,0 +1,72 @@
#ifndef _DOLPHIN_DEMO
#define _DOLPHIN_DEMO
#include <dolphin/pad.h>
#include <dolphin/gx.h>
struct STRUCT_MENU_ITEM {
/* 0x00 */ char * name;
/* 0x04 */ unsigned long flags;
/* 0x08 */ void (* function)(struct STRUCT_MENU *, unsigned long, unsigned long *);
/* 0x0C */ struct STRUCT_MENU * link;
};
struct STRUCT_MENU {
/* 0x00 */ char * title;
/* 0x04 */ struct STRUCT_DEMOWIN * handle;
/* 0x08 */ struct STRUCT_MENU_ITEM * items;
/* 0x0C */ long max_display_items;
/* 0x10 */ unsigned long flags;
/* 0x14 */ void (* cb_open)(struct STRUCT_MENU *, unsigned long);
/* 0x18 */ void (* cb_move)(struct STRUCT_MENU *, unsigned long);
/* 0x1C */ void (* cb_select)(struct STRUCT_MENU *, unsigned long);
/* 0x20 */ void (* cb_cancel)(struct STRUCT_MENU *, unsigned long);
/* 0x24 */ long num_display_items;
/* 0x28 */ long num_items;
/* 0x2C */ unsigned long max_str_len;
/* 0x30 */ long curr_pos;
/* 0x34 */ long display_pos;
};
typedef struct {
/* 0x00 */ struct PADStatus pads[4];
/* 0x30 */ unsigned long button[4];
/* 0x40 */ unsigned long old_button[4];
/* 0x50 */ unsigned long changed_button[4];
/* 0x60 */ unsigned long repeat_button[4];
/* 0x70 */ unsigned long repeat_ctr[4];
} DEMOWinPadInfo;
struct STRUCT_LISTBOX_ITEM {
/* 0x00 */ char * name; // offset 0x0, size 0x4
/* 0x04 */ unsigned long flags; // offset 0x4, size 0x4
};
struct STRUCT_LISTBOX {
/* 0x00 */ char * title; // offset 0x0, size 0x4
/* 0x04 */ struct STRUCT_DEMOWIN * handle; // offset 0x4, size 0x4
/* 0x08 */ struct STRUCT_LISTBOX_ITEM * items; // offset 0x8, size 0x4
/* 0x0C */ long max_display_items; // offset 0xC, size 0x4
/* 0x10 */ unsigned long flags; // offset 0x10, size 0x4
/* 0x14 */ long num_display_items; // offset 0x14, size 0x4
/* 0x18 */ long num_items; // offset 0x18, size 0x4
/* 0x1C */ unsigned long max_str_len; // offset 0x1C, size 0x4
/* 0x20 */ long curr_pos; // offset 0x20, size 0x4
/* 0x24 */ long display_pos; // offset 0x24, size 0x4
/* 0x28 */ int cursor_state; // offset 0x28, size 0x4
};
extern unsigned long DEMOFontBitmap[768];
#include <dolphin/demo/DEMOInit.h>
#include <dolphin/demo/DEMOPad.h>
#include <dolphin/demo/DEMOPuts.h>
#include <dolphin/demo/DEMOStats.h>
#include <dolphin/demo/DEMOWin.h>
// unsorted externs
extern void DEMOPrintf(s16 x, s16 y, s16 priority, char *str, ...);
extern struct _GXRenderModeObj *DEMOGetRenderModeObj();
#endif

View file

@ -0,0 +1,21 @@
#ifndef _DOLPHIN_DEMOINIT
#define _DOLPHIN_DEMOINIT
#include <dolphin/gx.h>
extern void *DemoFrameBuffer1;
extern void *DemoFrameBuffer2;
extern void *DemoCurrentBuffer;
void DEMOInit(struct _GXRenderModeObj *mode);
void DEMOBeforeRender();
void DEMODoneRender();
void DEMOSwapBuffers();
void DEMOSetTevColorIn(enum _GXTevStageID stage, enum _GXTevColorArg a, enum _GXTevColorArg b, enum _GXTevColorArg c, enum _GXTevColorArg d);
void DEMOSetTevOp(enum _GXTevStageID id, enum _GXTevMode mode);
struct _GXRenderModeObj *DEMOGetRenderModeObj();
u32 DEMOGetCurrentBuffer(void);
void DEMOEnableBypassWorkaround(unsigned long timeoutFrames);
void DEMOReInit(struct _GXRenderModeObj *mode);
#endif

View file

@ -0,0 +1,26 @@
#ifndef _DOLPHIN_DEMOPAD
#define _DOLPHIN_DEMOPAD
#include <dolphin/pad.h>
typedef struct {
/* 0x00 */ struct PADStatus pst;
/* 0x0C */ u16 buttonDown;
/* 0x0E */ u16 buttonUp;
/* 0x10 */ u16 dirs;
/* 0x12 */ u16 dirsNew;
/* 0x14 */ u16 dirsReleased;
/* 0x16 */ s16 stickDeltaX;
/* 0x18 */ s16 stickDeltaY;
/* 0x1A */ s16 substickDeltaX;
/* 0x1C */ s16 substickDeltaY;
} DEMODMPad;
extern DEMODMPad DemoPad[4];
extern u32 DemoNumValidPads;
void DEMOPadRead();
void DEMOPadInit();
#endif

View file

@ -0,0 +1,27 @@
#ifndef _DOLPHIN_DEMOPUTS
#define _DOLPHIN_DEMOPUTS
#include <dolphin/gx.h>
typedef enum {
DMTF_POINTSAMPLE,
DMTF_BILERP,
} DMTexFlt;
typedef enum { DM_FT_OPQ, DM_FT_RVS, DM_FT_XLU } DMFontType;
void DEMOSetFontType(DMFontType attr);
void DEMOLoadFont(enum _GXTexMapID texMap, enum _GXTexMtx texMtx, DMTexFlt texFlt);
void DEMOSetupScrnSpc(long width, long height, float depth);
void DEMOInitCaption(long font_type, long width, long height);
void DEMOPuts(s16 x, s16 y, s16 z, char *string);
void DEMOPrintf(s16 x, s16 y, s16 z, char *fmt, ...);
struct OSFontHeader *DEMOInitROMFont();
void DEMOSetROMFontSize(s16 size, s16 space);
int DEMORFPuts(s16 x, s16 y, s16 z, char *string);
int DEMORFPutsEx(s16 x, s16 y, s16 z, char *string, s16 maxWidth, int length);
int DEMORFPrintf(s16 x, s16 y, s16 z, char *fmt, ...);
char *DEMODumpROMFont(char *string);
int DEMOGetRFTextWidth(char *string);
#endif

View file

@ -0,0 +1,38 @@
#ifndef _DOLPHIN_DEMOSTATS
#define _DOLPHIN_DEMOSTATS
typedef enum DEMO_STAT_TYPE {
DEMO_STAT_GP0 = 0,
DEMO_STAT_GP1 = 1,
DEMO_STAT_MEM = 2,
DEMO_STAT_PIX = 3,
DEMO_STAT_VC = 4,
DEMO_STAT_FR = 5,
DEMO_STAT_TBW = 6,
DEMO_STAT_TBP = 7,
DEMO_STAT_MYC = 8,
DEMO_STAT_MYR = 9,
} DEMO_STAT_TYPE;
typedef struct DemoStatData {
char text[50];
DEMO_STAT_TYPE stat_type;
unsigned long stat;
unsigned long count;
} DemoStatData;
typedef enum {
DEMO_STAT_TL = 0,
DEMO_STAT_BL = 1,
DEMO_STAT_TLD = 2,
DEMO_STAT_BLD = 3,
DEMO_STAT_IO = 4,
} DEMO_STAT_DISP;
extern unsigned char DemoStatEnable;
void DEMOSetStats(DemoStatData * stat, unsigned long nstats, DEMO_STAT_DISP disp);
void DEMOUpdateStats(unsigned char inc);
void DEMOPrintStats(void);
#endif

View file

@ -0,0 +1,77 @@
#ifndef _DOLPHIN_DEMOWIN
#define _DOLPHIN_DEMOWIN
#include <dolphin/demo.h>
#include <dolphin/gx.h>
enum DEMOWinItem {
DEMOWIN_ITEM_CAP,
DEMOWIN_ITEM_BKGND,
DEMOWIN_ITEM_BORDER,
DEMOWIN_ITEM_DEFAULT
};
// flags
#define DEMOWIN_FLAGS_INIT (1 << 0)
#define DEMOWIN_FLAGS_OPENED (1 << 1)
struct STRUCT_DEMOWIN {
/* 0x00 */ long x1;
/* 0x04 */ long y1;
/* 0x08 */ long x2;
/* 0x0C */ long y2;
/* 0x10 */ unsigned long priority;
/* 0x14 */ unsigned long flags;
/* 0x18 */ unsigned short x_cal;
/* 0x1A */ unsigned short y_cal;
/* 0x1C */ unsigned short pixel_width;
/* 0x1E */ unsigned short pixel_height;
/* 0x20 */ unsigned short char_width;
/* 0x22 */ unsigned short char_height;
/* 0x24 */ unsigned short num_scroll_lines;
/* 0x26 */ unsigned short total_lines;
/* 0x28 */ unsigned short curr_output_line;
/* 0x2A */ unsigned short curr_output_col;
/* 0x2C */ unsigned short curr_view_line;
/* 0x2E */ signed short cursor_line;
/* 0x30 */ char * caption;
/* 0x34 */ unsigned char * buffer;
/* 0x38 */ GXColor bkgnd;
/* 0x3C */ GXColor cap;
/* 0x40 */ GXColor border;
/* 0x44 */ void (* refresh)(struct STRUCT_DEMOWIN *);
/* 0x48 */ struct STRUCT_DEMOWIN * next;
/* 0x4C */ struct STRUCT_DEMOWIN * prev;
/* 0x50 */ void * parent;
};
// functions
void DEMOWinInit();
struct STRUCT_DEMOWIN * DEMOWinCreateWindow(s32 x1, s32 y1, s32 x2, s32 y2, char * caption, u16 scroll, void * func);
void DEMOWinDestroyWindow(struct STRUCT_DEMOWIN * handle);
void DEMOWinOpenWindow(struct STRUCT_DEMOWIN * handle);
void DEMOWinCloseWindow(struct STRUCT_DEMOWIN * handle);
void DEMOWinSetWindowColor(struct STRUCT_DEMOWIN * handle, enum DEMOWinItem item, u8 r, u8 g, u8 b, u8 a);
void DEMOWinLogPrintf(struct STRUCT_DEMOWIN * handle, char * fmt, ...);
void DEMOWinPrintfXY(struct STRUCT_DEMOWIN * handle, u16 col, u16 row, char * fmt, ...);
void DEMOWinScrollWindow(struct STRUCT_DEMOWIN * handle, u32 dir);
void DEMOWinBringToFront(struct STRUCT_DEMOWIN * handle);
void DEMOWinSendToBack(struct STRUCT_DEMOWIN * handle);
void DEMOWinClearRow(struct STRUCT_DEMOWIN * handle, u16 row);
void DEMOWinClearWindow(struct STRUCT_DEMOWIN * handle);
void DEMOWinClearBuffer(struct STRUCT_DEMOWIN * handle);
void DEMOWinRefresh();
struct STRUCT_MENU * DEMOWinCreateMenuWindow(struct STRUCT_MENU * menu, u16 x, u16 y);
void DEMOWinDestroyMenuWindow(struct STRUCT_MENU * menu);
u32 DEMOWinMenuChild(struct STRUCT_MENU * menu, int child_flag);
void DEMOWinPadInit(DEMOWinPadInfo *p);
void DEMOWinPadRead(DEMOWinPadInfo *p);
void DEMOWinSetRepeat(unsigned long threshold, unsigned long rate);
void DEMOWinResetRepeat();
struct STRUCT_LISTBOX * DEMOWinCreateListWindow(struct STRUCT_LISTBOX * list, unsigned short x, unsigned short y);
void DEMOWinDestroyListWindow(struct STRUCT_LISTBOX * list);
void DEMOWinListSetCursor(struct STRUCT_LISTBOX * list, int x);
long DEMOWinListScrollList(struct STRUCT_LISTBOX * list, unsigned long dir);
long DEMOWinListMoveCursor(struct STRUCT_LISTBOX * list, unsigned long dir);
#endif

View file

@ -0,0 +1,11 @@
#ifndef _DOLPHIN_DEMOTYPES
#define _DOLPHIN_DEMOTYPES
#include <dolphin/demo.h>
extern struct STRUCT_DEMOWIN * __first_node;
extern struct STRUCT_DEMOWIN * __last_node;
extern struct STRUCT_DEMOWIN * __curr_node;
extern struct _GXRenderModeObj * __rmp;
#endif