Skip to content

Commit

Permalink
1.1 (#28)
Browse files Browse the repository at this point in the history
* Fix savewarp

* add fix for plentiful

* Fix typo

* Added support for damage multiplier in seed data.

- Update libtp dependency.

* Update trap items to consider damage multiplier on initial damage.

* Add parenthesis for clarity

* Add ammo to verifyItemFunctions

- If the player does not have the item that can use the ammo being obtained, it changes to a blue rupee so that the check doesn't completely go to waste

* Add a fix for ooccoo sotflock

* Fix skybook and minor typos

* Added functionality for lantern meter to match light color.

- Also re-ran clang on main.cpp to appropriately format the file.
- Update libtp

* Update supported minor version

* Fix not properly detecting incompatible seeds

* Use makefile variables for major and minor versions

* Added code to support Bonks doing damage.

* Fix golden wolves not displaying the correct progressive item

* Add code optimizations per Zeph's request.
  • Loading branch information
lunarsoap5 authored Jan 6, 2024
1 parent f5f9082 commit 802510d
Show file tree
Hide file tree
Showing 19 changed files with 334 additions and 54 deletions.
4 changes: 2 additions & 2 deletions GameCube/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export BUILDID:='"$(shell date +'%Y%m%d%H%M')"'

# Version
export _VERSION_MAJOR:=1
export _VERSION_MINOR:=0
export _VERSION_PATCH:=1
export _VERSION_MINOR:=1
export _VERSION_PATCH:=0
export _VERSION:='"$(_VERSION_MAJOR).$(_VERSION_MINOR).$(_VERSION_PATCH)"'
# Variant: i.e. Public, NoLogic, Race, etc.
#export _VARIANT:= public
Expand Down
12 changes: 12 additions & 0 deletions GameCube/assets/eu.lst
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@
80138ec4:setWolfLockDomeModel
800d0434:getSpinnerActor
800b7f58:searchBouDoor
800c0884:checkCastleTownUseItem
800d7414:damageMagnification
800c5120:procFrontRollCrashInit
8012dacc:procWolfDashReverseInit
8013cad4:procWolfAttackReverseInit

// data
8039038C:climbVars
Expand All @@ -150,6 +155,12 @@
80432164:wZButtonPtr
8021e388:resetMiniGameItem

//d_meter2_draw.o
80215178:drawKanteraScreen

//d_pane_class.o
80254ee0:setBlackWhite

// d_menu_collect.o
801B3598:setWalletMaxNum
801b09a4:dMenuCollect_screenSet
Expand Down Expand Up @@ -338,6 +349,7 @@
803ae280:item_resource
803b0a58:item_info
803afa68:field_item_res
800993b4:item_func_ASHS_SCRIBBLING

//processor.o
802a8a54:getResource_groupID
Expand Down
12 changes: 12 additions & 0 deletions GameCube/assets/jp.lst
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@
80138d04:setWolfLockDomeModel
800d0260:getSpinnerActor
800b7d84:searchBouDoor
800c06b0:checkCastleTownUseItem
800d7240:damageMagnification
800c4f4c:procFrontRollCrashInit
8012d90c:procWolfDashReverseInit
8013c914:procWolfAttackReverseInit

// data
80388C0C:climbVars
Expand Down Expand Up @@ -329,6 +334,7 @@
803a7ee8:field_item_res
803a92d8:item_func_ptr
803a8ed8:item_info
800992c4:item_func_ASHS_SCRIBBLING

// d_menu_ring.o
801eb424:dMenuRing__draw
Expand Down Expand Up @@ -386,6 +392,12 @@
8042a2c8:g_meter2_info
8021e81c:resetMiniGameItem

//d_meter2_draw.o
80215584:drawKanteraScreen

//d_pane_class.o
802567d0:setBlackWhite

// d_a_player.o
8044b158:m_midnaActor

Expand Down
12 changes: 12 additions & 0 deletions GameCube/assets/us.lst
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
803AC5A0:item_resource
803ADD88:field_item_res
803AED78:item_info
80099284:item_func_ASHS_SCRIBBLING

// d_a_alink.h
800B271C:setStickData
Expand Down Expand Up @@ -144,6 +145,11 @@
80138cb8:setWolfLockDomeModel
800d0228:getSpinnerActor
800b7d4c:searchBouDoor
800c0678:checkCastleTownUseItem
800d7208:damageMagnification
800c4f14:procFrontRollCrashInit
8012d8c0:procWolfDashReverseInit
8013c8c8:procWolfAttackReverseInit

// data
8038EB8C:climbVars
Expand Down Expand Up @@ -335,6 +341,12 @@
804301A4:wZButtonPtr
8021e0c4:resetMiniGameItem

//d_meter2_draw.o
80214eb4:drawKanteraScreen

//d_pane_class.o
80254458:setBlackWhite

//d_a_shop_item_static.o
803792e8:shopItemData

Expand Down
5 changes: 5 additions & 0 deletions GameCube/include/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "tp/m_do_controller_pad.h"
#include "tp/rel/d_a_obj_Lv5Key.h"
#include "tp/f_op_actor_iter.h"
#include "tp/d_meter2_draw.h"

namespace mod::events
{
Expand Down Expand Up @@ -129,6 +130,10 @@ namespace mod::events
*/
void setSaveFileEventFlag(uint16_t flag);

void modifyLanternMeterColor(libtp::tp::d_pane_class::CPaneMgr* panePtr,
libtp::tp::JUtility::TColor* color1,
libtp::tp::JUtility::TColor* color2);

void onAdjustFieldItemParams(libtp::tp::f_op_actor::fopAc_ac_c* fopAC, void* daObjLife);

void onAdjustCreateItemParams(void* daDitem);
Expand Down
21 changes: 21 additions & 0 deletions GameCube/include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ namespace mod
extern bool instantTextEnabled;
extern bool increaseSpinnerSpeed;
extern bool transformAnywhereEnabled;
extern uint8_t damageMultiplier;
extern bool bonksDoDamage;

#ifdef TP_EU
extern libtp::tp::d_s_logo::Languages currentLanguage;
Expand All @@ -98,6 +100,7 @@ namespace mod
float intToFloat(int32_t value);
void handleInput(uint32_t inputs);
void handleFoolishItem();
void handleBonkDamage();

// Inline getConsole, as it's just a shortcut to get a reference to the console variable
inline libtp::display::Console& getConsole()
Expand Down Expand Up @@ -290,6 +293,9 @@ namespace mod
int32_t handle_checkItemGet(uint8_t item, int32_t defaultValue);
extern int32_t (*return_checkItemGet)(uint8_t item, int32_t defaultValue);

void handle_item_func_ASHS_SCRIBBLING();
extern void (*return_item_func_ASHS_SCRIBBLING)();

// Message functions
bool handle_setMessageCode_inSequence(libtp::tp::control::TControl* control,
const void* TProcessor,
Expand Down Expand Up @@ -383,9 +389,24 @@ namespace mod
void handle_setWolfLockDomeModel(libtp::tp::d_a_alink::daAlink* daALink);
extern void (*return_setWolfLockDomeModel)(libtp::tp::d_a_alink::daAlink* daALink);

bool handle_procFrontRollCrashInit(libtp::tp::d_a_alink::daAlink* daALink);
extern bool (*return_procFrontRollCrashInit)(libtp::tp::d_a_alink::daAlink* daALink);

bool handle_procWolfDashReverseInit(libtp::tp::d_a_alink::daAlink* daALink, bool param_1);
extern bool (*return_procWolfDashReverseInit)(libtp::tp::d_a_alink::daAlink* daALink, bool param_1);

bool handle_procWolfAttackReverseInit(libtp::tp::d_a_alink::daAlink* daALink);
extern bool (*return_procWolfAttackReverseInit)(libtp::tp::d_a_alink::daAlink* daALink);

libtp::tp::f_op_actor::fopAc_ac_c* handle_searchBouDoor(libtp::tp::f_op_actor::fopAc_ac_c* actrPtr);
extern libtp::tp::f_op_actor::fopAc_ac_c* (*return_searchBouDoor)(libtp::tp::f_op_actor::fopAc_ac_c* actrPtr);

bool handle_checkCastleTownUseItem(uint16_t item_id);
extern bool (*return_checkCastleTownUseItem)(uint16_t item_id);

float handle_damageMagnification(libtp::tp::d_a_alink::daAlink* daALink, int32_t param_1, int32_t param_2);
extern float (*return_damageMagnification)(libtp::tp::d_a_alink::daAlink* daALink, int32_t param_1, int32_t param_2);

// Audio functions
void handle_loadSeWave(void* Z2SceneMgr, uint32_t waveID);
extern void (*return_loadSeWave)(void* Z2SceneMgr, uint32_t waveID);
Expand Down
18 changes: 11 additions & 7 deletions GameCube/include/rando/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ namespace mod::rando

struct Header
{
/* 0x00 */ uint16_t versionMajor; // SeedData version major
/* 0x02 */ uint16_t versionMinor; // SeedData version minor
/* 0x00 */ uint32_t version; // SeedData version major and minor; uint16_t for each. Need to handle as a single variable
// to get around a compiler warning about comparing an unsigned value to 0

/* 0x04 */ uint16_t headerSize; // Total size of the header in bytes
/* 0x06 */ uint16_t dataSize; // Total number of bytes of seed data
/* 0x08 */ uint32_t totalSize; // Total number of bytes in the GCI
Expand Down Expand Up @@ -63,16 +64,19 @@ namespace mod::rando
/* 0x52 */ uint8_t castleRequirements;
/* 0x53 */ uint8_t palaceRequirements;
/* 0x54 */ uint8_t mapClearBits;
/* 0x55 */ uint8_t padding[3];
/* 0x55 */ uint8_t damageMagnification;
/* 0x56 */ uint8_t bonksDoDamage;
/* 0x57 */ uint8_t padding;
} __attribute__((__packed__));

// Minimum amount of data needed for keeping track of a seed
struct MinSeedInfo
{
uint16_t versionMajor; // SeedData version major
uint16_t versionMinor; // SeedData version minor
uint32_t totalSize; // Total number of bytes in the GCI
uint8_t fileIndex; // (0-126)
uint32_t version; // SeedData version major and minor; uint16_t for each. Need to handle as a single variable
// to get around a compiler warning about comparing an unsigned value to 0

uint32_t totalSize; // Total number of bytes in the GCI
uint8_t fileIndex; // (0-126)
char fileName[CARD_FILENAME_MAX + 1];
uint8_t padding[2];
} __attribute__((__packed__));
Expand Down
19 changes: 0 additions & 19 deletions GameCube/include/rando/seedlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,6 @@

#define SEED_MAX_ENTRIES CARD_MAX_FILE

// SeedData version (Major.Minor) which this version of the Randomizer
// supports.
#define SUPPORTED_SEED_DATA_VER_MAJOR 1
#define SUPPORTED_SEED_DATA_VER_MINOR 0

// Defines to help with version comparisions, as otherwise we get: "error:
// comparison is always true due to limited range of data type
// [-Werror=type-limits]" when the macro values are 0.
#if SUPPORTED_SEED_DATA_VER_MAJOR == 0
#define CHECK_SUPPORTED_SEED_DATA_VER_MAJOR(version) 1
#else
#define CHECK_SUPPORTED_SEED_DATA_VER_MAJOR(version) static_cast<uint16_t>(version) == SUPPORTED_SEED_DATA_VER_MAJOR
#endif

#if SUPPORTED_SEED_DATA_VER_MINOR == 0
#define CHECK_SUPPORTED_SEED_DATA_VER_MINOR(version) 1
#else
#define CHECK_SUPPORTED_SEED_DATA_VER_MINOR(version) static_cast<uint16_t>(version) == SUPPORTED_SEED_DATA_VER_MINOR
#endif

namespace mod::rando
{
Expand Down
22 changes: 22 additions & 0 deletions GameCube/source/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "tp/rel/ids.h"
#include "rando/customItems.h"
#include "tp/f_op_actor_iter.h"
#include "tp/d_pane_class.h"

namespace mod::events
{
Expand Down Expand Up @@ -1534,6 +1535,27 @@ namespace mod::events
return true;
}

KEEP_FUNC void modifyLanternMeterColor(libtp::tp::d_pane_class::CPaneMgr* panePtr,
libtp::tp::JUtility::TColor* color1,
libtp::tp::JUtility::TColor* color2)
{
mod::rando::Seed* seed;

if (seed = getCurrentSeed(randomizer), seed)
{
rando::RawRGBTable* rawRGBListPtr = randomizer->m_Seed->m_RawRGBTable;

uint8_t* lanternColor = reinterpret_cast<uint8_t*>(&rawRGBListPtr->lanternColor);
color1->r = lanternColor[0];
color1->g = lanternColor[1];
color1->b = lanternColor[2];
color2->r = lanternColor[0];
color2->g = lanternColor[1];
color2->b = lanternColor[2];
}
libtp::tp::d_pane_class::setBlackWhite(panePtr, color1, color2);
}

KEEP_FUNC void performStaticASMReplacement(uint32_t memoryOffset, uint32_t value)
{
*reinterpret_cast<uint32_t*>(memoryOffset) = value;
Expand Down
73 changes: 59 additions & 14 deletions GameCube/source/game_patch/04_verifyItemFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,23 @@ namespace mod::game_patch
{
using namespace rando::customItems;
using namespace libtp::data::items;

static const uint8_t progressiveSkyBooksList[] = {Ancient_Sky_Book_Empty,
Ancient_Sky_Book_First_Character,
Ancient_Sky_Book_Second_Character,
Ancient_Sky_Book_Third_Character,
Ancient_Sky_Book_Fourth_Character,
Ancient_Sky_Book_Fifth_Character};

constexpr uint32_t listLength = sizeof(progressiveSkyBooksList) / sizeof(progressiveSkyBooksList[0]);
for (uint32_t i = 0; i < listLength; i++)
if (!events::haveItem(Ancient_Sky_Book_Completed))
{
const uint32_t item = progressiveSkyBooksList[i];
if (!events::haveItem(item))
static const uint8_t progressiveSkyBooksList[] = {Ancient_Sky_Book_Empty,
Ancient_Sky_Book_First_Character,
Ancient_Sky_Book_Second_Character,
Ancient_Sky_Book_Third_Character,
Ancient_Sky_Book_Fourth_Character,
Ancient_Sky_Book_Fifth_Character};

constexpr uint32_t listLength = sizeof(progressiveSkyBooksList) / sizeof(progressiveSkyBooksList[0]);
for (uint32_t i = 0; i < listLength; i++)
{
return item;
const uint32_t item = progressiveSkyBooksList[i];
if (!events::haveItem(item))
{
return item;
}
}
}

Expand Down Expand Up @@ -207,7 +209,7 @@ namespace mod::game_patch
case Clawshot:
case Double_Clawshots:
{
if (events::haveItem(Clawshot))
if (events::haveItem(Clawshot) || events::haveItem(Double_Clawshots))
{
itemID = Double_Clawshots;
}
Expand Down Expand Up @@ -312,6 +314,49 @@ namespace mod::game_patch
break;
}

// For ammo, if we don't have the item that can use the ammo, turn it into a blue rupee so that the check
// doesn't completely go to waste.
case Arrows_10:
case Arrows_20:
case Arrows_30:
{
if (!events::haveItem(Heros_Bow))
{
itemID = Blue_Rupee;
}
break;
}

case Bombling_1:
case Bomblings_10:
case Bomblings_3:
case Bomblings_5:
case Water_Bombs_10:
case Water_Bombs_15:
case Water_Bombs_3:
case Water_Bombs_5:
case Bombs_10:
case Bombs_20:
case Bombs_30:
case Bombs_5:
{
if (!events::haveItem(Goron_Bomb_Bag)) // This is the specific bomb bag that the rando uses when giving
// bombs to the player.
{
itemID = Blue_Rupee;
}
break;
}

case Seeds_50:
{
if (!events::haveItem(Slingshot))
{
itemID = Blue_Rupee;
}
break;
}

default:
{
break;
Expand Down
Loading

0 comments on commit 802510d

Please sign in to comment.