Skip to content

Commit

Permalink
Spoiler Test (#72)
Browse files Browse the repository at this point in the history
Testing Spoiler Menu
  • Loading branch information
Tacoman369 authored and PhlexPlexico committed Sep 5, 2023
1 parent b2a2ab7 commit 43b3ed9
Show file tree
Hide file tree
Showing 12 changed files with 1,853 additions and 35 deletions.
90 changes: 71 additions & 19 deletions code/include/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,83 @@
#define SPACING_Y 11
#define SPACING_X 6

#define SPACING_SMALL_Y 9
#define SPACING_SMALL_X 6
#define RGB8(r, g, b) (((b)&0xFF) | (((g)&0xFF) << 8) | (((r)&0xFF) << 16))

#define COLOR_TITLE RGB8(0x33, 0x33, 0xFF)
#define COLOR_WHITE RGB8(0xFF, 0xFF, 0xFF)
#define COLOR_RED RGB8(0xFF, 0x00, 0x00)
#define COLOR_GREEN RGB8(0x00, 0xFF, 0x00)
#define COLOR_BLACK RGB8(0x00, 0x00, 0x00)
#define COLOR_TITLE RGB8(0x33, 0x33, 0xFF)
#define COLOR_WHITE RGB8(0xFF, 0xFF, 0xFF)
#define COLOR_RED RGB8(0xFF, 0x00, 0x00)
#define COLOR_GREEN RGB8(0x00, 0xFF, 0x00)
#define COLOR_BLUE RGB8(0x56, 0xB4, 0xE9)
#define COLOR_ORANGE RGB8(0xE6, 0x9F, 0x00)
#define COLOR_YELLOW RGB8(0xF0, 0xE4, 0x42)
#define COLOR_PINK RGB8(0xCC, 0x79, 0xA7)
#define COLOR_BLACK RGB8(0x00, 0x00, 0x00)
#define COLOR_DARK_GRAY RGB8(0x29, 0x29, 0x29)
#define COLOR_LIGHT_GRAY RGB8(0x71, 0x71, 0x71)

#define DRAW_MAX_FORMATTED_STRING_SIZE 512

void Draw_Lock(void);
void Draw_Unlock(void);
typedef enum {
DISPLAY_0 = 0x400,
DISPLAY_1 = 0x401,
DISPLAY_BOTH = 0x402,
DISPLAY0_EXT = 0x410,
} Draw_Display;

void Draw_DrawCharacter(u32 posX, u32 posY, u32 color, char character);
u32 Draw_DrawString(u32 posX, u32 posY, u32 color, const char* string);
u32 Draw_DrawFormattedString(u32 posX, u32 posY, u32 color, const char* fmt, ...);
typedef enum {
ICON_SMALL_KEY,
ICON_BOSS_KEY,
ICON_TRIFORCE,
ICON_FOOL,
ICON_CHECK,
ICON_NO,
ICON_VANILLA,
ICON_MASTER_QUEST,
ICON_MAP,
ICON_COMPASS,
ICON_BUTTON_R,
ICON_BUTTON_R_WIDE_1,
ICON_BUTTON_R_WIDE_2,
ICON_BUTTON_L,
ICON_BUTTON_L_WIDE_1,
ICON_BUTTON_L_WIDE_2,
ICON_BUTTON_A,
ICON_BUTTON_B,
ICON_BUTTON_X,
ICON_BUTTON_Y,
ICON_BUTTON_DPAD,
ICON_BUTTON_FACE,
ICON_BUTTON_FACEH,
ICON_BUTTON_FACEV,
ICON_BUTTON_JOYSTICK,
ICONS_COUNT
} Draw_IconType;

void Draw_DrawCharacterTop(u32 posX, u32 posY, u32 color, char character);
u32 Draw_DrawStringTop(u32 posX, u32 posY, u32 color, const char* string);
u32 Draw_DrawFormattedStringTop(u32 posX, u32 posY, u32 color, const char* fmt, ...);
//void Draw_Lock(void);
//void Draw_Unlock(void);

void Draw_FillFramebuffer(u32 value);
void Draw_ClearFramebuffer(void);
void Draw_SetupFramebuffer(void);
void Draw_FlushFramebuffer(void);
void Draw_FlushFramebufferTop(void);
//void Draw_DrawIcon(u32 posX, u32 posY, u32 color, Draw_IconType icon);
//void Draw_DrawRect(u32 posX, u32 posY, u32 width, u32 height, u32 color);
//void Draw_DrawCharacter(u32 posX, u32 posY, u32 color, char character);
//u32 Draw_DrawString(u32 posX, u32 posY, u32 color, const char* string);
//u32 Draw_DrawString_Small(u32 posX, u32 posY, u32 color, const char* string);
//u32 Draw_DrawFormattedString(u32 posX, u32 posY, u32 color, const char* fmt, ...);
//u32 Draw_DrawFormattedString_Small(u32 posX, u32 posY, u32 color, const char* fmt, ...);

//void Draw_DrawCharacterTop(u32 posX, u32 posY, u32 color, char character);
//u32 Draw_DrawStringTop(u32 posX, u32 posY, u32 color, const char* string);
//u32 Draw_DrawFormattedStringTop(u32 posX, u32 posY, u32 color, const char* fmt, ...);

//void Draw_FillFramebuffer(u32 value);
//void Draw_ClearFramebuffer(void);
//void Draw_SetupFramebuffer(void);
//void Draw_FillBackBuffer(void);
//void Draw_ClearBackbuffer(void);
//void Draw_CopyBackBuffer(void);
//void Draw_FlushFramebuffer(void);
//void Draw_FlushFramebufferTop(void);

struct FramebufferAddress {
u8* a;
Expand Down Expand Up @@ -97,4 +148,5 @@ struct Graphics {
Framebuffer top1;
Framebuffer top2;
Framebuffer bottom;
};
};

4 changes: 4 additions & 0 deletions code/include/hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,9 @@ typedef struct {
#define BUTTON_L1 (1 << 9)
#define BUTTON_X (1 << 10)
#define BUTTON_Y (1 << 11)
#define CPAD_RIGHT (1 << 28)
#define CPAD_LEFT (1 << 29)
#define CPAD_UP (1 << 30)
#define CPAD_DOWN (1 << 31)

#endif // HID_H
20 changes: 20 additions & 0 deletions code/include/rnd/custom_message.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef _RND_CUSTOM_MESSAGE_H_
#define _RND_CUSTOM_MESSAGE_H_

#include "common/utils.h"

#define MAX_MSG_SIZE 512

void CustomMessage_Init(void);

typedef struct {
char data[MAX_MSG_SIZE];
u16 size;
} CustomMessage;

/*----- Custom Message Declarations -----*/
extern CustomMessage iceTrapMsg;
extern CustomMessage kokiriSwordMsg;
/*----- Custom Message Declarations -----*/

#endif
15 changes: 15 additions & 0 deletions code/include/rnd/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,23 @@ namespace rnd {
SHUFFLEKOKIRISWORD_VANILLA,
SHUFFLEKOKIRISWROD_ANYWHERE,
};

typedef enum {
DUNGEON_NEITHER,
DUNGEON_BARREN,
DUNGEON_WOTH,
} DungeonInfo;

typedef enum {
PLAY_ON_CONSOLE,
PLAY_ON_CITRA,
} PlayOption;

typedef struct {
u8 hashIndexes[5];

u8 playOption;

u8 logic;
u8 locationsReachable;

Expand Down Expand Up @@ -282,6 +296,7 @@ namespace rnd {
u8 gossipStoneHints;
u8 chestAnimations;
u8 chestSize;
u8 compassesShowWotH;
u8 generateSpoilerLog;
u8 ingameSpoilers;
u8 menuOpeningButton;
Expand Down
26 changes: 24 additions & 2 deletions code/include/rnd/spoiler_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "z3d/z3DVec.h"

#define SPOILER_LOCDATS 2
#define SPOILER_SPHERES_MAX 50
#define SPOILER_ITEMS_MAX 512
#define SPOILER_STRING_DATA_SIZE 16384
Expand All @@ -29,9 +30,7 @@ namespace rnd {
// Location groups for checks, used to group the checks by logical location
typedef enum {
GROUP_NO_GROUP,
GROUP_STARTING_ITEM,
GROUP_DEKU_PALACE,
GROUP_EAST_CLOCK_TOWN,
GROUP_DUNGEON_WOODFALL_TEMPLE,
GROUP_DUNGEON_SNOWHEAD_TEMPLE,
GROUP_E_CLOCK_TOWN,
Expand Down Expand Up @@ -74,13 +73,27 @@ namespace rnd {
// Grottos are all 0x3E
} SpoilerCollectionCheckGroup;

typedef enum {
COLLECTTYPE_NORMAL,
COLLECTTYPE_REPEATABLE,
COLLECTTYPE_NEVER,
} SpoilerItemCollectType;

typedef enum {
REVEALTYPE_NORMAL,
REVEALTYPE_SCENE,
REVEALTYPE_ALWAYS,
} SpoilerItemRevealType;

typedef struct {
u16 LocationStrOffset;
u16 ItemStrOffset;
SpoilerCollectionCheckType CollectionCheckType;
u8 LocationScene;
u8 LocationFlag;
SpoilerCollectionCheckGroup Group;
SpoilerItemCollectType CollectType;
SpoilerItemRevealType RevealType;
} SpoilerItemLocation;

typedef struct {
Expand All @@ -99,8 +112,16 @@ namespace rnd {
u16 GroupOffsets[SPOILER_COLLECTION_GROUP_COUNT];
} SpoilerData;

typedef struct {
SpoilerItemLocation ItemLocations[SPOILER_ITEMS_MAX];
char StringData[SPOILER_STRING_DATA_SIZE];
} SpoilerDataLocs;

extern "C" SpoilerData gSpoilerData;

SpoilerItemLocation* SpoilerData_ItemLoc(u16 itemIndex);
char* SpoilerData_StringData(u16 itemIndex);

char* SpoilerData_GetItemLocationString(u16 itemIndex);
char* SpoilerData_GetItemNameString(u16 itemIndex);
SpoilerItemLocation GetSpoilerItemLocation(u8 sphere, u16 itemIndex);
Expand All @@ -115,6 +136,7 @@ namespace rnd {
u8 SpoilerData_ScrubCheck(SpoilerItemLocation itemLoc);
u8 SpoilerData_ShopItemCheck(SpoilerItemLocation itemLoc);
u8 SpoilerData_MagicBeansCheck(SpoilerItemLocation itemLoc);
u8 SpoilerData_GetIsItemLocationRevealed(u16 itemIndex);
} // namespace rnd

#endif // _RND_SPOILER_DATA_H_
4 changes: 4 additions & 0 deletions code/mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ SECTIONS{
*(.patch_HandleOcarinaHooks)
}

.patch_Gfx_Update 0x310254 : {
*(.patch_Gfx_Update)
}

. = 0x61CD8C;
/* Addr already 4 byte aligned! */
/* . = ALIGN(4); */
Expand Down
27 changes: 27 additions & 0 deletions code/source/asm/hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,33 @@ normalText:
mov r1,#0xA2
b 0x1867C8

<<<<<<< Updated upstream
=======
.global hook Gfx_Update
hook_Gfx_Update:
push {r0-r12, lr}
bl Gfx_Update
pop {r0-r12, lr}
pop {r4-r8, pc}

.global hook_Gfx_SleepQueryCallback
hook_Gfx_SleepQueryCallback:
push {r0-r12, lr}
bl Gfx_SleepQueryCallback
pop {r0-r12, lr}
add r0,r0,#0x9C
b 0x3FD6C8

.global hook_Gfx_AwakeCallback
hook_Gfx_AwakeCallback
push {r0-r12, lr}
bl Gfx_AwakeCallback
pop {r0-r12, lr}
add r0,r0,#0x9C
b 0x3FD440


>>>>>>> Stashed changes
.section .loader
.global hook_into_loader
hook_into_loader:
Expand Down
15 changes: 15 additions & 0 deletions code/source/asm/patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,18 @@ patch_OverrideBankerWalletReward:
.global loader_patch
loader_patch:
b hook_into_loader

.section .patch_Gfx_Update
.global Gfx_Update_patch
Gfx_Update_patch:
b hook_Gfx_Update

.section .patch_SleepQueryCallback
.global SleepQueryCallback_patch
SleepQueryCallback_patch:
b hook_Gfx_SleepQueryCallback

.section .patch_AwakeCallback
.global AwakeCallback_patch
AwakeCallback_patch:
b hook_Gfx_AwakeCallback
Loading

0 comments on commit 43b3ed9

Please sign in to comment.