Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SceneDB [WIP Do not merge] #4460

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Rozelette
Copy link
Contributor

@Rozelette Rozelette commented Oct 21, 2024

This is a WIP PR for SceneDB -- dynamic scene IDs that will pave the way for custom scenes.

Currently, I need to clean up the code and remove TODOs, as well as test it by doing a full playthrough with normal and MQ dungeons, as well as some random settings.

Build Artifacts

@Malkierian Malkierian added the do not merge Not ready or not valid changes label Oct 21, 2024
@Rozelette Rozelette force-pushed the scene-test4 branch 7 times, most recently from 04df12b to ad535b1 Compare December 6, 2024 01:57
@@ -1675,7 +1675,8 @@ typedef struct PreNMIContext {
} PreNMIContext; // size = 0xAC

typedef enum {
/* 1 */ F_8F = 1,
/* 0 */ F_NA,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have deviated from decomp documentation to add a value to this enum. All dungeons have 8 floors and 0 is used to represent invalid/unused floors. Having an actual enum value saves a lot of static_casts for the scene table.

@@ -48,8 +48,8 @@ typedef struct {
/* 0x28 */ u16 equipment; // a mask where each nibble corresponds to a type of equipment `EquipmentType`, and each bit to an owned piece `EquipInv*`
/* 0x2C */ u32 upgrades;
/* 0x30 */ u32 questItems;
/* 0x34 */ u8 dungeonItems[20];
/* 0x48 */ s8 dungeonKeys[19];
/* 0x34 */ u8* dungeonItems;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are now dynamically sized to support any number of scenes. Fun side effect: all scenes can now have small keys, etc. This was easier and less invasive than restricting it to dungeons and making a mapping from scene id to dungeonItems index.

@@ -1882,9 +1884,16 @@ namespace Rando {

void Logic::NewSaveContext() {
if (mSaveContext != nullptr && mSaveContext != &gSaveContext) {
free(mSaveContext);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed free to delete as you should always match malloc/free, new/delete

@@ -84,15 +83,15 @@ static void Entrance_SeparateOGCFairyFountainExit(void) {
//Overwrite unused entrance 0x03E8 (ENTR_POTION_SHOP_KAKARIKO_1) with values from 0x0340 (ENTR_CASTLE_GROUNDS_GREAT_FAIRY_EXIT) to use it as the
//exit from OGC Great Fairy Fountain -> Castle Grounds
for (size_t i = 0; i < 4; ++i) {
gEntranceTable[ENTR_POTION_SHOP_KAKARIKO_1 + i] = gEntranceTable[ENTR_CASTLE_GROUNDS_GREAT_FAIRY_EXIT + i];
EntranceDB_Copy(ENTR_CASTLE_GROUNDS_GREAT_FAIRY_EXIT + i, ENTR_POTION_SHOP_KAKARIKO_1 + i);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the order is reversed compared to assignment. This is to better match the verbiage of "copy from X to Y".

u8 startTransition;
} EntranceDBEntry;

#define SCENEDB_ISBOSS(entry) ((entry)->bossData.mapScene != -1)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have elected to infer traits about scenes based on the data instead of having a "type" field. I wanted to avoid data invariants. Instead, if a scene has data for a thing, it is that thing.

SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &this->actor.world.pos,
&this->actor.projectedPos, &this->actor.projectedW);
}
SceneDBEntry* entry = SceneDB_Retrieve(play->sceneNum);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a giant array of valid epona spawn locations, they are stored per-scene.

@@ -86,9 +88,6 @@ void KaleidoScope_DrawDungeonMap(PlayState* play, GraphicsContext* gfxCtx) {
pauseCtx->cursorX[PAUSE_MAP] = 0;
pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->dungeonMapSlot;
osSyncPrintf("kscope->cursor_point=%d\n", pauseCtx->cursorPoint[PAUSE_MAP]);
R_MAP_TEX_INDEX =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no longer an array of dungeon map textures. Each scene store it's own. R_MAP_TEX_INDEX is used to present what room link is in in some of the UI code, so it's removal has repercussions. Luckily, there are other things we can use.

@@ -56,122 +64,98 @@ void PauseMapMark_DrawForDungeon(PlayState* play) {
PauseMapMarkInfo* markInfo;
f32 scale;
s32 i = 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is largely reworked for the same reasons as the minimap map mark function.

@@ -1421,11 +1421,11 @@ void func_80A053F0(Actor* thisx, PlayState* play) {
} else {
this->actionFunc(this, play);
thisx->shape.rot.y = this->unk_2BC;
nREG(80) = gSaveContext.sceneFlags[127].chest;
nREG(80) = HIGH_SCORE(HS_HBA);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an OOB that we now have to fix. This is an odd way to access a highscore, and decomp went with this because of the debug comment. Decomp has a comment explaining it now, but for SceneDB, we have to fix this.

break;
SceneDBEntry* entry = SceneDB_Retrieve(mapIndex);

if (SCENEDB_ISOVERWORLD(entry)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handles special cases for overworld minimaps (filling the lake, discovering ST entrance, etc.). I have reworked it a bit to handle the logic and have hard-coded the special values that were originally in a tables past the normal ends. I have elected not to have this data in the SceneDB because I felt like these were too much of a niche case. For mods, I think this will be best handled with a hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Not ready or not valid changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants