Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
FINALLY, sub menus support (depth 1 only but that should be wayyyy en…
Browse files Browse the repository at this point in the history
…ough) and original debug menu available as a sub menu, now we can talk
  • Loading branch information
Nahelam committed Sep 23, 2023
1 parent dad76db commit fd1b86c
Show file tree
Hide file tree
Showing 31 changed files with 291 additions and 104 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
EE_TOOL_PREFIX = mips64r5900el-ps2-elf-
EE_CC := $(EE_TOOL_PREFIX)gcc

EE_OBJS = b4p_debug_menu_pages.o \
EE_OBJS = b4p_debug_main_menu_page.o \
b4p_debug_menu_page_manager.o \
b4p_debug_menu_pages.o \
b4p_debug_menu_state.o \
b4p_debug_original_menu_page.o \
b4p_debug_test_menu_page.o \
b4p_debug_vselect_component.o \
b4p_debug_vselect_option_component.o \
Expand Down
2 changes: 1 addition & 1 deletion include/b4p_debug_background_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct CB4DebugBackgroundComponent { // 0xC
// B4 Functions
// --------------------------------

typedef void (*const CB4DebugBackgroundComponent__Prepare_t)(CB4DebugBackgroundComponent* _this);
typedef void (*CB4DebugBackgroundComponent__Prepare_t)(CB4DebugBackgroundComponent* _this);

extern CB4DebugBackgroundComponent__Prepare_t CB4DebugBackgroundComponent__Prepare;

Expand Down
24 changes: 20 additions & 4 deletions include/b4p_debug_main_menu_page.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#ifndef B4P_DEBUG_MENU_COMPONENT_BASE_H_INCLUDED
#define B4P_DEBUG_MENU_COMPONENT_BASE_H_INCLUDED
#ifndef B4P_DEBUG_MAIN_MENU_PAGE_H_INCLUDED
#define B4P_DEBUG_MAIN_MENU_PAGE_H_INCLUDED

#include <stdint.h>
#include <stdbool.h>
#include "b4p_debug_menu_page_base.h"

// --------------------------------
// Enums
Expand All @@ -13,11 +12,28 @@
// Structs
// --------------------------------

typedef struct CB4DebugMainMenuPage CB4DebugMainMenuPage;
typedef struct CB4DebugMainMenuPage__vtable CB4DebugMainMenuPage__vtable;

struct CB4DebugMainMenuPage { // 0x28
CB4DebugMenuPageBase mBase;
};

struct CB4DebugMainMenuPage__vtable { // 0x18
CB4DebugMenuPageBase__vtable __vtable;
};

// --------------------------------
// Declarations
// --------------------------------

extern CB4DebugMainMenuPage gDebugMainMenuPage;
extern CB4DebugMainMenuPage__vtable gDebugMainMenuPage__vtable;

void CB4DebugMainMenuPage__Prepare(CB4DebugMainMenuPage* _this);
void CB4DebugMainMenuPage__Update(CB4DebugMainMenuPage* _this);
void CB4DebugMainMenuPage__Release(CB4DebugMainMenuPage* _this);
void CB4DebugMainMenuPage__ApplyVSelectOption(CB4DebugMainMenuPage* _this);

// --------------------------------
// B4 Variables
Expand Down
3 changes: 3 additions & 0 deletions include/b4p_debug_menu_component_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ struct CB4DebugMenuComponentBase { // 0xC
// B4 Functions
// --------------------------------

typedef void (*CB4DebugMenuComponentBase__Release_t)(CB4DebugMenuComponentBase* _this);

extern CB4DebugMenuComponentBase__Release_t CB4DebugMenuComponentBase__Release;

#endif
15 changes: 10 additions & 5 deletions include/b4p_debug_menu_page_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
#define B4P_DEBUG_MENU_PAGE_BASE_H_INCLUDED

#include <stdint.h>
#include <stddef.h>
#include "b4p_vtable.h"

#define COUNT_OF(x) ((sizeof(x) / sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))

// --------------------------------
// Enums
// --------------------------------
Expand All @@ -16,11 +19,12 @@
typedef struct CB4DebugMenuPageBase CB4DebugMenuPageBase;
typedef struct CB4DebugMenuPageBase__vtable CB4DebugMenuPageBase__vtable;

// Take advantage of these 8 unused bytes to add a custom vtable (ApplyVSelectOption)
struct CB4DebugMenuPageBase__vtable { // 0x18
__vtbl_ptr_type ApplyVSelectOption; // uint8_t __pad0[8];
// Added "Prepare" and "ApplyVSelectOption" methods to the original vtable structure
struct CB4DebugMenuPageBase__vtable { // 0x20
__vtbl_ptr_type Prepare; // uint8_t __pad0[8];
__vtbl_ptr_type Update;
__vtbl_ptr_type Release;
__vtbl_ptr_type ApplyVSelectOption;
};

struct CB4DebugMenuPageBase { // 0x4
Expand All @@ -31,7 +35,8 @@ struct CB4DebugMenuPageBase { // 0x4
// Declarations
// --------------------------------

typedef void (*ApplyVSelectOption_t)(CB4DebugMenuPageBase *_this);
typedef void (*CB4DebugMenuPageBase__ApplyVSelectOption_t)(CB4DebugMenuPageBase* _this);
typedef void (*CB4DebugMenuPageBase__Release_t)(CB4DebugMenuPageBase* _this);

// --------------------------------
// B4 Variables
Expand All @@ -42,7 +47,7 @@ typedef void (*ApplyVSelectOption_t)(CB4DebugMenuPageBase *_this);
// B4 Functions
// --------------------------------

typedef void (*const CB4DebugMenuPageBase__Prepare_t)(CB4DebugMenuPageBase* _this);
typedef void (*CB4DebugMenuPageBase__Prepare_t)(CB4DebugMenuPageBase* _this);

extern CB4DebugMenuPageBase__Prepare_t CB4DebugMenuPageBase__Prepare;

Expand Down
3 changes: 2 additions & 1 deletion include/b4p_debug_menu_page_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct CB4DebugMenuPageManager { // 0x10
// Declarations
// --------------------------------

void CB4DebugMenuPageManager__ImmediateLeadOut2(CB4DebugMenuPageManager* _this, EB4MenuFlowEvents leEvent);

// --------------------------------
// B4 Variables
Expand All @@ -37,7 +38,7 @@ extern CB4DebugMenuPageManager* gDebugMenuPageManager;
// B4 Functions
// --------------------------------

typedef void (*const CB4DebugMenuPageManager__ImmediateLeadOut_t)(void* _this, EB4MenuFlowEvents leEvent);
typedef void (*CB4DebugMenuPageManager__ImmediateLeadOut_t)(CB4DebugMenuPageManager* _this, EB4MenuFlowEvents leEvent);

extern CB4DebugMenuPageManager__ImmediateLeadOut_t CB4DebugMenuPageManager__ImmediateLeadOut;

Expand Down
6 changes: 5 additions & 1 deletion include/b4p_debug_menu_pages.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stdint.h>
#include "b4p_debug_original_menu_page.h"

#define NB_PAGES 3

// --------------------------------
// Enums
// --------------------------------
Expand All @@ -30,6 +32,8 @@ struct CB4DebugMenuPages { // 0x70
// Declarations
// --------------------------------

extern CB4DebugMenuPageBase* gapDebugMenuPagesBases[];

void CB4DebugMenuPages__InitHook();

// --------------------------------
Expand All @@ -42,7 +46,7 @@ extern CB4DebugMenuPages* gDebugMenuPages;
// B4 Functions
// --------------------------------

typedef void (*const CB4DebugMenuPages__Init_t)();
typedef void (*CB4DebugMenuPages__Init_t)();

extern CB4DebugMenuPages__Init_t CB4DebugMenuPages__Init;

Expand Down
2 changes: 1 addition & 1 deletion include/b4p_debug_menu_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void CB4DebugMenuState__ActionHook(CB4DebugMenuState* _this, EGtStateAction leAc
// B4 Functions
// --------------------------------

typedef void (*const CB4DebugMenuState__Action_t)(CB4DebugMenuState* _this, EGtStateAction leAction, void* lpOwner, void* lpActionData, void* lpUserData);
typedef void (*CB4DebugMenuState__Action_t)(CB4DebugMenuState* _this, EGtStateAction leAction, void* lpOwner, void* lpActionData, void* lpUserData);

extern CB4DebugMenuState__Action_t CB4DebugMenuState__Action;

Expand Down
5 changes: 3 additions & 2 deletions include/b4p_debug_original_menu_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct CB4DebugOriginalMenuPage { // 0x28
// Declarations
// --------------------------------

void CB4DebugOriginalMenuPage__UpdateHook(CB4DebugOriginalMenuPage* _this);

// --------------------------------
// B4 Variables
Expand All @@ -45,8 +46,8 @@ struct CB4DebugOriginalMenuPage { // 0x28
// B4 Functions
// --------------------------------

typedef void (*const CB4DebugOriginalMenuPage__Prepare_t)(CB4DebugOriginalMenuPage* _this);
typedef void (*const CB4DebugOriginalMenuPage__Update_t)(CB4DebugOriginalMenuPage* _this);
typedef void (*CB4DebugOriginalMenuPage__Prepare_t)(CB4DebugOriginalMenuPage* _this);
typedef void (*CB4DebugOriginalMenuPage__Update_t)(CB4DebugOriginalMenuPage* _this);

extern CB4DebugOriginalMenuPage__Prepare_t CB4DebugOriginalMenuPage__Prepare;
extern CB4DebugOriginalMenuPage__Update_t CB4DebugOriginalMenuPage__Update;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,79 +1,67 @@
#ifndef B4P_DEBUG_TEST_MENU_ENTRIES_H_INCLUDED
#define B4P_DEBUG_TEST_MENU_ENTRIES_H_INCLUDED

static const char* gapcDebugMenuEntryNames[] = {
"Video Mode",
"Speedometer Unit",
"Test Entry 3",
"Test Entry 4",
"Test Entry 5",
"Test Entry 6 (no options)",
"Test Entry 7 (no options)"
};

static CB4DebugVSelectEntry gaDebugTestMenuEntries[sizeof(gapcDebugMenuEntryNames) / sizeof(gapcDebugMenuEntryNames[0])];

static const char* gapcDebugMenuNoOptions[] = {
static const char* kapcDebugTestMenuNoOptions[] = {
" "
};

static const char* gapcDebugMenuEntryVideoModeOptions[] = {
static const char* kapcDebugTestMenuEntryVideoModeOptions[] = {
"NTSC",
"480p",
"PAL"
};

static const char* gapcDebugMenuEntryOnOffOptions[] = {
static const char* kapcDebugTestMenuEntryOnOffOptions[] = {
"On",
"Off"
};

static const char* gapcDebugMenuEntrySpeedoUnitOptions[] = {
static const char* kapcDebugTestMenuEntrySpeedoUnitOptions[] = {
"MPH",
"KPH"
};

static const char* gapcDebugMenuEntry1Options[] = {
static const char* kapcDebugTestMenuEntry1Options[] = {
"Entry 1 Test Option 1",
"Entry 1 Test Option 2",
"Entry 1 Test Option 3",
"Entry 1 Test Option 4",
"Entry 1 Test Option 5"
};

static const char* gapcDebugMenuEntry2Options[] = {
static const char* kapcDebugTestMenuEntry2Options[] = {
"Entry 2 Test Option 1",
"Entry 2 Test Option 2",
"Entry 2 Test Option 3",
"Entry 2 Test Option 4",
"Entry 2 Test Option 5"
};

static const char* gapcDebugMenuEntry3Options[] = {
static const char* kapcDebugTestMenuEntry3Options[] = {
"Entry 3 Test Option 1",
"Entry 3 Test Option 2",
"Entry 3 Test Option 3",
"Entry 3 Test Option 4",
"Entry 3 Test Option 5"
};

static const char* gapcDebugMenuEntry4Options[] = {
static const char* kapcDebugTestMenuEntry4Options[] = {
"Entry 4 Test Option 1",
"Entry 4 Test Option 2",
"Entry 4 Test Option 3",
"Entry 4 Test Option 4",
"Entry 4 Test Option 5"
};

static const char* gapcDebugMenuEntry5Options[] = {
static const char* kapcDebugTestMenuEntry5Options[] = {
"Entry 5 Test Option 1",
"Entry 5 Test Option 2",
"Entry 5 Test Option 3",
"Entry 5 Test Option 4",
"Entry 5 Test Option 5"
};

static const char* gapcDebugMenuEntry0To100Options[] = {
static const char* kapcDebugTestMenuEntry0To100Options[] = {
"0",
"1",
"2",
Expand Down
2 changes: 0 additions & 2 deletions include/b4p_debug_test_menu_page.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef B4P_DEBUG_TEST_MENU_PAGE_H_INCLUDED
#define B4P_DEBUG_TEST_MENU_PAGE_H_INCLUDED

#include <stdint.h>
#include <stdbool.h>
#include "b4p_debug_menu_page_base.h"
#include "b4p_debug_vselect_option_component.h"

Expand Down
4 changes: 2 additions & 2 deletions include/b4p_debug_vselect_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void CB4DebugVSelectComponent__UpdateHook(CB4DebugVSelectComponent* _this);
// B4 Functions
// --------------------------------

typedef void (*const CB4DebugVSelectComponent__Prepare_t)(CB4DebugVSelectComponent* _this, const char** lppcEntriesList, int lnNumEntries);
typedef void (*const CB4DebugVSelectComponent__Update_t)(CB4DebugVSelectComponent* _this);
typedef void (*CB4DebugVSelectComponent__Prepare_t)(CB4DebugVSelectComponent* _this, const char** lppcEntriesList, int lnNumEntries);
typedef void (*CB4DebugVSelectComponent__Update_t)(CB4DebugVSelectComponent* _this);

extern CB4DebugVSelectComponent__Prepare_t CB4DebugVSelectComponent__Prepare;
extern CB4DebugVSelectComponent__Update_t CB4DebugVSelectComponent__Update;
Expand Down
6 changes: 3 additions & 3 deletions include/b4p_debug_vselect_option_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ void CB4DebugVSelectOptionComponent__UpdateHook(CB4DebugVSelectOptionComponent*
// B4 Functions
// --------------------------------

typedef void (*const CB4DebugVSelectOptionComponent__Prepare_t)(CB4DebugVSelectOptionComponent* _this, CB4DebugVSelectEntry* lpEntries, int lnNumEntries);
typedef void (*const CB4DebugVSelectOptionComponent__Update_t)(CB4DebugVSelectOptionComponent* _this);
typedef void (*const CB4DebugVSelectEntry__Prepare_t)(CB4DebugVSelectEntry* _this, const char* lpcEntryName, const char** lppcOptionsList, int lnNumOptions, int lnInitialOptionSelection);
typedef void (*CB4DebugVSelectOptionComponent__Prepare_t)(CB4DebugVSelectOptionComponent* _this, CB4DebugVSelectEntry* lpEntries, int lnNumEntries);
typedef void (*CB4DebugVSelectOptionComponent__Update_t)(CB4DebugVSelectOptionComponent* _this);
typedef void (*CB4DebugVSelectEntry__Prepare_t)(CB4DebugVSelectEntry* _this, const char* lpcEntryName, const char** lppcOptionsList, int lnNumOptions, int lnInitialOptionSelection);

extern CB4DebugVSelectOptionComponent__Prepare_t CB4DebugVSelectOptionComponent__Prepare;
extern CB4DebugVSelectOptionComponent__Update_t CB4DebugVSelectOptionComponent__Update;
Expand Down
4 changes: 2 additions & 2 deletions include/b4p_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ extern void* gInputManager;
// B4 Functions
// --------------------------------

typedef float (*const CB4ControllerMapping__GetPadControl_t)(void* _this, EGtPS2DualShockDeviceControl lePadControl, bool lbDebounced, uint8_t ln8Player);
typedef bool (*const CB4InputManager__GetMenuButton_t)(void* _this, EMenuControls leMenuButton, int8_t ln8Player);
typedef float (*CB4ControllerMapping__GetPadControl_t)(void* _this, EGtPS2DualShockDeviceControl lePadControl, bool lbDebounced, uint8_t ln8Player);
typedef bool (*CB4InputManager__GetMenuButton_t)(void* _this, EMenuControls leMenuButton, int8_t ln8Player);

extern CB4ControllerMapping__GetPadControl_t CB4ControllerMapping__GetPadControl;
extern CB4InputManager__GetMenuButton_t CB4InputManager__GetMenuButton;
Expand Down
4 changes: 2 additions & 2 deletions include/b4p_main_menu_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void CB4MainMenuState__ActionHook(CB4MainMenuState* _this, EGtStateAction leActi
// B4 Functions
// --------------------------------

typedef void (*const CB4MainMenuState__Action_t)(CB4MainMenuState* _this, EGtStateAction leAction, void* lpOwner, void* lpActionData, void* lpUserData);
typedef void (*const CB4MainMenuState__InitiateConfirm_t)(CB4MainMenuState* _this, uint64_t lDestinationState);
typedef void (*CB4MainMenuState__Action_t)(CB4MainMenuState* _this, EGtStateAction leAction, void* lpOwner, void* lpActionData, void* lpUserData);
typedef void (*CB4MainMenuState__InitiateConfirm_t)(CB4MainMenuState* _this, uint64_t lDestinationState);

extern CB4MainMenuState__Action_t CB4MainMenuState__Action;
extern CB4MainMenuState__InitiateConfirm_t CB4MainMenuState__InitiateConfirm;
Expand Down
2 changes: 1 addition & 1 deletion include/b4p_menu_flow_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extern CB4MenuFlowManager* gMenuFlowManager;
// B4 Functions
// --------------------------------

typedef void (*const CB4MenuFlowManager__ApplyEvent_t)(CB4MenuFlowManager* _this, uint32_t lnEventID, void* lpUserData);
typedef void (*CB4MenuFlowManager__ApplyEvent_t)(CB4MenuFlowManager* _this, uint32_t lnEventID, void* lpUserData);

extern CB4MenuFlowManager__ApplyEvent_t CB4MenuFlowManager__ApplyEvent;

Expand Down
4 changes: 2 additions & 2 deletions include/b4p_menu_selection_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ struct CB4MenuSelectionData { // 0x4
// B4 Functions
// --------------------------------

typedef bool (*const CB4MenuSelectionData__SelectNext_t)(CB4MenuSelectionData* _this);
typedef bool (*const CB4MenuSelectionData__SelectPrev_t)(CB4MenuSelectionData* _this);
typedef bool (*CB4MenuSelectionData__SelectNext_t)(CB4MenuSelectionData* _this);
typedef bool (*CB4MenuSelectionData__SelectPrev_t)(CB4MenuSelectionData* _this);

extern CB4MenuSelectionData__SelectNext_t CB4MenuSelectionData__SelectNext;
extern CB4MenuSelectionData__SelectPrev_t CB4MenuSelectionData__SelectPrev;
Expand Down
6 changes: 3 additions & 3 deletions include/b4p_other.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ extern void* gGame;
// B4 Functions
// --------------------------------

typedef void (*const CB4GraphicsManager__SetVideoMode_t)(CB4GraphicsManager* _this, EB4VideoMode leVideoMode);
typedef void (*const CB4AptManager__SetScreenSettings_t)(void* _this);
typedef void (*const CB4Game__SetFrontendFrameRate_t)(void* _this, bool lbSetFrontendFrameRate);
typedef void (*CB4GraphicsManager__SetVideoMode_t)(CB4GraphicsManager* _this, EB4VideoMode leVideoMode);
typedef void (*CB4AptManager__SetScreenSettings_t)(void* _this);
typedef void (*CB4Game__SetFrontendFrameRate_t)(void* _this, bool lbSetFrontendFrameRate);

extern CB4GraphicsManager__SetVideoMode_t CB4GraphicsManager__SetVideoMode;
extern CB4AptManager__SetScreenSettings_t CB4AptManager__SetScreenSettings;
Expand Down
2 changes: 1 addition & 1 deletion include/b4p_sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern void* gHUDSoundManager;
// B4 Functions
// --------------------------------

typedef void (*const CB4HUDSoundManager__HandleFESound_t)(void* _this, eSoundFEGeneral leSound);
typedef void (*CB4HUDSoundManager__HandleFESound_t)(void* _this, eSoundFEGeneral leSound);

extern CB4HUDSoundManager__HandleFESound_t CB4HUDSoundManager__HandleFESound;

Expand Down
6 changes: 3 additions & 3 deletions include/b4p_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ extern uint64_t* kB4DebugMenuStateID;
// B4 Functions
// --------------------------------

typedef CGtState* (*const CGtFSM__GetStateFromID_t)(CGtFSM* _this, uint64_t lStateID);
typedef void (*const CGtFSM__StateEnter_t)(CGtFSM* _this, CGtState* lpOldState, void* lpUserData);
typedef void (*const CGtFSM__StateLeave_t)(CGtFSM* _this, CGtState* lpNewState, void* lpUserData);
typedef CGtState* (*CGtFSM__GetStateFromID_t)(CGtFSM* _this, uint64_t lStateID);
typedef void (*CGtFSM__StateEnter_t)(CGtFSM* _this, CGtState* lpOldState, void* lpUserData);
typedef void (*CGtFSM__StateLeave_t)(CGtFSM* _this, CGtState* lpNewState, void* lpUserData);

extern CGtFSM__GetStateFromID_t CGtFSM__GetStateFromID;
extern CGtFSM__StateEnter_t CGtFSM__StateEnter;
Expand Down
Loading

0 comments on commit fd1b86c

Please sign in to comment.