mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-08-13 17:03:47 -04:00
Make palette address part of texture cache key
This commit is contained in:
parent
9ef130eb40
commit
f709ffa99a
@ -490,8 +490,8 @@ void gfx_texture_cache_clear()
|
|||||||
gfx_texture_cache.lru.clear();
|
gfx_texture_cache.lru.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_texture_cache_lookup(int i, TextureCacheNode **n, const uint8_t *orig_addr, uint32_t fmt, uint32_t siz, uint32_t palette_index) {
|
static bool gfx_texture_cache_lookup(int i, TextureCacheNode **n, const uint8_t *orig_addr, const uint8_t *palette_addr, uint32_t fmt, uint32_t siz, uint32_t palette_index) {
|
||||||
TextureCacheKey key = { orig_addr, fmt, siz, palette_index };
|
TextureCacheKey key = { orig_addr, palette_addr, fmt, siz, palette_index };
|
||||||
auto it = gfx_texture_cache.map.find(key);
|
auto it = gfx_texture_cache.map.find(key);
|
||||||
|
|
||||||
if (it != gfx_texture_cache.map.end()) {
|
if (it != gfx_texture_cache.map.end()) {
|
||||||
@ -815,7 +815,7 @@ static void import_texture(int i, int tile) {
|
|||||||
// if (ModInternal::callBindHook(0))
|
// if (ModInternal::callBindHook(0))
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
if (gfx_texture_cache_lookup(i, &rendering_state.textures[i], rdp.loaded_texture[tmem_index].addr, fmt, siz, rdp.texture_tile[tile].palette))
|
if (gfx_texture_cache_lookup(i, &rendering_state.textures[i], rdp.loaded_texture[tmem_index].addr, fmt == G_IM_FMT_CI ? rdp.palette : nullptr, fmt, siz, rdp.texture_tile[tile].palette))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ struct GfxDimensions
|
|||||||
|
|
||||||
struct TextureCacheKey {
|
struct TextureCacheKey {
|
||||||
const uint8_t* texture_addr;
|
const uint8_t* texture_addr;
|
||||||
|
const uint8_t* palette_addr;
|
||||||
uint8_t fmt, siz;
|
uint8_t fmt, siz;
|
||||||
uint8_t palette_index;
|
uint8_t palette_index;
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ namespace Ship {
|
|||||||
|
|
||||||
if (!this->TextureCache.contains(path)) this->TextureCache[path].resize(10);
|
if (!this->TextureCache.contains(path)) this->TextureCache[path].resize(10);
|
||||||
|
|
||||||
TextureCacheKey key = { orig_addr, static_cast<uint8_t>(fmt), static_cast<uint8_t>(siz), static_cast<uint8_t>(palette) };
|
TextureCacheKey key = { orig_addr, nullptr, static_cast<uint8_t>(fmt), static_cast<uint8_t>(siz), static_cast<uint8_t>(palette) };
|
||||||
TextureCacheValue value = { api->new_texture(), 0, 0, false };
|
TextureCacheValue value = { api->new_texture(), 0, 0, false };
|
||||||
const auto entry = new TextureCacheNode(key, value);
|
const auto entry = new TextureCacheNode(key, value);
|
||||||
api->select_texture(tile, entry->second.texture_id);
|
api->select_texture(tile, entry->second.texture_id);
|
||||||
|
@ -336,16 +336,17 @@ typedef enum {
|
|||||||
} SkyboxId;
|
} SkyboxId;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x000 */ char unk_00[0x128];
|
char unk_00[0x128];
|
||||||
/* 0x128 */ void* textures[2][6];
|
s16 skyboxId;
|
||||||
/* 0x130 */ void* palettes[6];
|
void* textures[2][6];
|
||||||
/* 0x134 */ Gfx (*dListBuf)[150];
|
void* palettes[6];
|
||||||
/* 0x138 */ Gfx* unk_138;
|
Gfx (*dListBuf)[150];
|
||||||
/* 0x13C */ Vtx* roomVtx;
|
Gfx* unk_138;
|
||||||
/* 0x140 */ s16 unk_140;
|
Vtx* roomVtx;
|
||||||
/* 0x144 */ Vec3f rot;
|
s16 unk_140;
|
||||||
/* 0x150 */ char unk_150[0x10];
|
Vec3f rot;
|
||||||
} SkyboxContext; // size = 0x160
|
char unk_150[0x10];
|
||||||
|
} SkyboxContext;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/* 0 */ OCARINA_SONG_MINUET,
|
/* 0 */ OCARINA_SONG_MINUET,
|
||||||
|
@ -679,6 +679,8 @@ void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, Environment
|
|||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
LoadSkyboxTex(skyboxCtx, 0, i, entryA.textures[i], 128, i == 4 ? 128 : 64, 128, 64);
|
LoadSkyboxTex(skyboxCtx, 0, i, entryA.textures[i], 128, i == 4 ? 128 : 64, 128, 64);
|
||||||
|
|
||||||
|
Skybox_Update(skyboxCtx);
|
||||||
|
|
||||||
envCtx->skybox1Index = newSkybox1Index;
|
envCtx->skybox1Index = newSkybox1Index;
|
||||||
|
|
||||||
//size = gSkyboxFiles[newSkybox1Index].file.vromEnd - gSkyboxFiles[newSkybox1Index].file.vromStart;
|
//size = gSkyboxFiles[newSkybox1Index].file.vromEnd - gSkyboxFiles[newSkybox1Index].file.vromStart;
|
||||||
@ -697,6 +699,8 @@ void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, Environment
|
|||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
LoadSkyboxTex(skyboxCtx, 1, i, entryA.textures[i], 128, i == 4 ? 128 : 64, 128, 64);
|
LoadSkyboxTex(skyboxCtx, 1, i, entryA.textures[i], 128, i == 4 ? 128 : 64, 128, 64);
|
||||||
|
|
||||||
|
Skybox_Update(skyboxCtx);
|
||||||
|
|
||||||
envCtx->skybox2Index = newSkybox2Index;
|
envCtx->skybox2Index = newSkybox2Index;
|
||||||
|
|
||||||
//size = gSkyboxFiles[newSkybox2Index].file.vromEnd - gSkyboxFiles[newSkybox2Index].file.vromStart;
|
//size = gSkyboxFiles[newSkybox2Index].file.vromEnd - gSkyboxFiles[newSkybox2Index].file.vromStart;
|
||||||
@ -712,7 +716,7 @@ void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, Environment
|
|||||||
if ((newSkybox1Index & 1) ^ ((newSkybox1Index & 4) >> 2)) {
|
if ((newSkybox1Index & 1) ^ ((newSkybox1Index & 4) >> 2)) {
|
||||||
|
|
||||||
SkyboxTableEntry entryA = sSkyboxTable[newSkybox1Index];
|
SkyboxTableEntry entryA = sSkyboxTable[newSkybox1Index];
|
||||||
LoadSkyboxPalette(globalCtx, skyboxCtx, 0, entryA.palettes[0], 16, 8);
|
LoadSkyboxPalette(skyboxCtx, 0, entryA.palettes[0], 16, 8);
|
||||||
|
|
||||||
//size = gSkyboxFiles[newSkybox1Index].palette.vromEnd - gSkyboxFiles[newSkybox1Index].palette.vromStart;
|
//size = gSkyboxFiles[newSkybox1Index].palette.vromEnd - gSkyboxFiles[newSkybox1Index].palette.vromStart;
|
||||||
//osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1);
|
//osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1);
|
||||||
@ -721,7 +725,7 @@ void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, Environment
|
|||||||
//"../z_kankyo.c", 1307);
|
//"../z_kankyo.c", 1307);
|
||||||
} else {
|
} else {
|
||||||
SkyboxTableEntry entryA = sSkyboxTable[newSkybox1Index];
|
SkyboxTableEntry entryA = sSkyboxTable[newSkybox1Index];
|
||||||
LoadSkyboxPalette(globalCtx, skyboxCtx, 1, entryA.palettes[0], 16, 8);
|
LoadSkyboxPalette(skyboxCtx, 1, entryA.palettes[0], 16, 8);
|
||||||
|
|
||||||
//size = gSkyboxFiles[newSkybox1Index].palette.vromEnd - gSkyboxFiles[newSkybox1Index].palette.vromStart;
|
//size = gSkyboxFiles[newSkybox1Index].palette.vromEnd - gSkyboxFiles[newSkybox1Index].palette.vromStart;
|
||||||
//osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1);
|
//osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1);
|
||||||
@ -729,6 +733,8 @@ void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, Environment
|
|||||||
//gSkyboxFiles[newSkybox1Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL,
|
//gSkyboxFiles[newSkybox1Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL,
|
||||||
//"../z_kankyo.c", 1320);
|
//"../z_kankyo.c", 1320);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Skybox_Update(skyboxCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (envCtx->skyboxDmaState == SKYBOX_DMA_FILE2_DONE) {
|
if (envCtx->skyboxDmaState == SKYBOX_DMA_FILE2_DONE) {
|
||||||
@ -737,7 +743,7 @@ void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, Environment
|
|||||||
if ((newSkybox2Index & 1) ^ ((newSkybox2Index & 4) >> 2))
|
if ((newSkybox2Index & 1) ^ ((newSkybox2Index & 4) >> 2))
|
||||||
{
|
{
|
||||||
SkyboxTableEntry entryA = sSkyboxTable[newSkybox2Index];
|
SkyboxTableEntry entryA = sSkyboxTable[newSkybox2Index];
|
||||||
LoadSkyboxPalette(globalCtx, skyboxCtx, 0, entryA.palettes[0], 16, 8);
|
LoadSkyboxPalette(skyboxCtx, 0, entryA.palettes[0], 16, 8);
|
||||||
|
|
||||||
/*size = gSkyboxFiles[newSkybox2Index].palette.vromEnd - gSkyboxFiles[newSkybox2Index].palette.vromStart;
|
/*size = gSkyboxFiles[newSkybox2Index].palette.vromEnd - gSkyboxFiles[newSkybox2Index].palette.vromStart;
|
||||||
osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1);
|
osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1);
|
||||||
@ -747,7 +753,7 @@ void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, Environment
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
SkyboxTableEntry entryA = sSkyboxTable[newSkybox2Index];
|
SkyboxTableEntry entryA = sSkyboxTable[newSkybox2Index];
|
||||||
LoadSkyboxPalette(globalCtx, skyboxCtx, 1, entryA.palettes[0], 16, 8);
|
LoadSkyboxPalette(skyboxCtx, 1, entryA.palettes[0], 16, 8);
|
||||||
|
|
||||||
/*size = gSkyboxFiles[newSkybox2Index].palette.vromEnd - gSkyboxFiles[newSkybox2Index].palette.vromStart;
|
/*size = gSkyboxFiles[newSkybox2Index].palette.vromEnd - gSkyboxFiles[newSkybox2Index].palette.vromStart;
|
||||||
osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1);
|
osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1);
|
||||||
@ -755,6 +761,8 @@ void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, Environment
|
|||||||
gSkyboxFiles[newSkybox2Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL,
|
gSkyboxFiles[newSkybox2Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL,
|
||||||
"../z_kankyo.c", 1355);*/
|
"../z_kankyo.c", 1355);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Skybox_Update(skyboxCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((envCtx->skyboxDmaState == SKYBOX_DMA_FILE1_START) || (envCtx->skyboxDmaState == SKYBOX_DMA_FILE2_START)) {
|
if ((envCtx->skyboxDmaState == SKYBOX_DMA_FILE1_START) || (envCtx->skyboxDmaState == SKYBOX_DMA_FILE2_START)) {
|
||||||
|
@ -945,6 +945,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox
|
|||||||
void Skybox_Init(GameState* state, SkyboxContext* skyboxCtx, s16 skyboxId) {
|
void Skybox_Init(GameState* state, SkyboxContext* skyboxCtx, s16 skyboxId) {
|
||||||
GlobalContext* globalCtx = (GlobalContext*)state;
|
GlobalContext* globalCtx = (GlobalContext*)state;
|
||||||
|
|
||||||
|
skyboxCtx->skyboxId = skyboxId;
|
||||||
skyboxCtx->unk_140 = 0;
|
skyboxCtx->unk_140 = 0;
|
||||||
skyboxCtx->rot.x = skyboxCtx->rot.y = skyboxCtx->rot.z = 0.0f;
|
skyboxCtx->rot.x = skyboxCtx->rot.y = skyboxCtx->rot.z = 0.0f;
|
||||||
|
|
||||||
@ -984,3 +985,20 @@ void Skybox_Init(GameState* state, SkyboxContext* skyboxCtx, s16 skyboxId) {
|
|||||||
osSyncPrintf(VT_RST);
|
osSyncPrintf(VT_RST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Skybox_Update(SkyboxContext* skyboxCtx) {
|
||||||
|
if (skyboxCtx->skyboxId != SKYBOX_NONE) {
|
||||||
|
osSyncPrintf(VT_FGCOL(GREEN));
|
||||||
|
|
||||||
|
if (skyboxCtx->unk_140 != 0) {
|
||||||
|
func_800AEFC8(skyboxCtx, skyboxCtx->skyboxId);
|
||||||
|
} else {
|
||||||
|
if (skyboxCtx->skyboxId == SKYBOX_CUTSCENE_MAP) {
|
||||||
|
func_800AF178(skyboxCtx, 6);
|
||||||
|
} else {
|
||||||
|
func_800AF178(skyboxCtx, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
osSyncPrintf(VT_RST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user