2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2022-11-01 23:17:11 +00:00
|
|
|
#include "terminal.h"
|
2022-06-06 19:37:25 +00:00
|
|
|
#include "assets/textures/parameter_static/parameter_static.h"
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2024-08-12 07:07:48 +00:00
|
|
|
typedef struct MapMarkInfo {
|
2020-03-17 04:31:30 +00:00
|
|
|
/* 0x00 */ void* texture;
|
|
|
|
/* 0x04 */ u32 imageFormat;
|
|
|
|
/* 0x08 */ u32 imageSize;
|
|
|
|
/* 0x0C */ u32 textureWidth;
|
|
|
|
/* 0x10 */ u32 textureHeight;
|
|
|
|
/* 0x14 */ u32 rectWidth;
|
|
|
|
/* 0x18 */ u32 rectHeight;
|
|
|
|
/* 0x1C */ u32 dsdx;
|
|
|
|
/* 0x20 */ u32 dtdy;
|
|
|
|
} MapMarkInfo; // size = 0x24
|
|
|
|
|
2024-08-12 07:07:48 +00:00
|
|
|
typedef struct MapMarkDataOverlay {
|
2020-03-17 04:31:30 +00:00
|
|
|
/* 0x00 */ void* loadedRamAddr; // original name: "allocp"
|
2024-02-29 13:15:04 +00:00
|
|
|
/* 0x04 */ RomFile file;
|
2020-05-01 15:09:20 +00:00
|
|
|
/* 0x0C */ void* vramStart;
|
|
|
|
/* 0x10 */ void* vramEnd;
|
|
|
|
/* 0x14 */ void* vramTable;
|
2020-03-17 04:31:30 +00:00
|
|
|
} MapMarkDataOverlay; // size = 0x18
|
|
|
|
|
2024-07-17 21:35:37 +00:00
|
|
|
#define GDP_LOADTEXTUREBLOCK_RUNTIME_QUALIFIERS
|
|
|
|
#include "src/code/gDPLoadTextureBlock_Runtime.inc.c"
|
|
|
|
|
|
|
|
MapMarkInfo sMapMarkInfoTable[] = {
|
2021-06-15 17:29:10 +00:00
|
|
|
{ gMapChestIconTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 32, 32, 1 << 10, 1 << 10 }, // Chest Icon
|
|
|
|
{ gMapBossIconTex, G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 32, 32, 1 << 10, 1 << 10 }, // Boss Skull Icon
|
2020-03-17 04:31:30 +00:00
|
|
|
};
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
static MapMarkDataOverlay sMapMarkDataOvl = {
|
2024-02-29 13:15:04 +00:00
|
|
|
NULL, ROM_FILE(ovl_map_mark_data), _ovl_map_mark_dataSegmentStart, _ovl_map_mark_dataSegmentEnd, gMapMarkDataTable,
|
2020-03-17 04:31:30 +00:00
|
|
|
};
|
|
|
|
|
2021-03-29 17:24:08 +00:00
|
|
|
static MapMarkData** sLoadedMarkDataTable;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
void MapMark_Init(PlayState* play) {
|
2020-03-17 04:31:30 +00:00
|
|
|
MapMarkDataOverlay* overlay = &sMapMarkDataOvl;
|
2023-07-10 19:03:01 +00:00
|
|
|
u32 overlaySize = (uintptr_t)overlay->vramEnd - (uintptr_t)overlay->vramStart;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2024-01-09 12:59:03 +00:00
|
|
|
overlay->loadedRamAddr = GAME_STATE_ALLOC(&play->state, overlaySize, "../z_map_mark.c", 235);
|
2024-01-16 14:59:02 +00:00
|
|
|
LOG_UTILS_CHECK_NULL_POINTER("dlftbl->allocp", overlay->loadedRamAddr, "../z_map_mark.c", 236);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2024-02-29 13:15:04 +00:00
|
|
|
Overlay_Load(overlay->file.vromStart, overlay->file.vromEnd, overlay->vramStart, overlay->vramEnd,
|
|
|
|
overlay->loadedRamAddr);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
sLoadedMarkDataTable = gMapMarkDataTable;
|
2023-07-10 19:03:01 +00:00
|
|
|
sLoadedMarkDataTable =
|
|
|
|
(void*)(uintptr_t)((overlay->vramTable != NULL)
|
|
|
|
? (void*)((uintptr_t)overlay->vramTable -
|
|
|
|
(intptr_t)((uintptr_t)overlay->vramStart - (uintptr_t)overlay->loadedRamAddr))
|
|
|
|
: NULL);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
void MapMark_ClearPointers(PlayState* play) {
|
2020-03-17 04:31:30 +00:00
|
|
|
sMapMarkDataOvl.loadedRamAddr = NULL;
|
|
|
|
sLoadedMarkDataTable = NULL;
|
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
void MapMark_DrawForDungeon(PlayState* play) {
|
2020-03-17 04:31:30 +00:00
|
|
|
InterfaceContext* interfaceCtx;
|
2021-03-29 17:24:08 +00:00
|
|
|
MapMarkIconData* mapMarkIconData;
|
2020-03-17 04:31:30 +00:00
|
|
|
MapMarkPoint* markPoint;
|
|
|
|
MapMarkInfo* markInfo;
|
2021-02-14 00:49:40 +00:00
|
|
|
u16 dungeon = gSaveContext.mapIndex;
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 i;
|
|
|
|
s32 rectLeft;
|
|
|
|
s32 rectTop;
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
interfaceCtx = &play->interfaceCtx;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
if ((gMapData != NULL) && (play->interfaceCtx.mapRoomNum >= gMapData->dgnMinimapCount[dungeon])) {
|
2024-08-28 18:01:41 +00:00
|
|
|
PRINTF(VT_COL(RED, WHITE) T("部屋番号がオーバーしてるで,ヤバイで %d/%d \nMapMarkDraw の処理を中断します\n",
|
|
|
|
"Room number exceeded, yikes %d/%d \nMapMarkDraw processing interrupted\n"),
|
2024-01-12 15:38:13 +00:00
|
|
|
VT_RST, play->interfaceCtx.mapRoomNum, gMapData->dgnMinimapCount[dungeon]);
|
2020-03-17 04:31:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-29 17:24:08 +00:00
|
|
|
mapMarkIconData = &sLoadedMarkDataTable[dungeon][interfaceCtx->mapRoomNum][0];
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
OPEN_DISPS(play->state.gfxCtx, "../z_map_mark.c", 303);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
while (true) {
|
2021-04-28 09:10:23 +00:00
|
|
|
if (mapMarkIconData->markType == MAP_MARK_NONE) {
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-10-29 21:31:09 +00:00
|
|
|
gDPPipeSync(OVERLAY_DISP++);
|
|
|
|
gDPSetTextureLUT(OVERLAY_DISP++, G_TT_NONE);
|
|
|
|
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->minimapAlpha);
|
|
|
|
gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, interfaceCtx->minimapAlpha);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2021-05-02 23:15:16 +00:00
|
|
|
markPoint = &mapMarkIconData->points[0];
|
2021-03-29 17:24:08 +00:00
|
|
|
for (i = 0; i < mapMarkIconData->count; i++) {
|
2022-05-21 18:23:43 +00:00
|
|
|
if ((mapMarkIconData->markType != MAP_MARK_CHEST) || !Flags_GetTreasure(play, markPoint->chestFlag)) {
|
2021-03-29 17:24:08 +00:00
|
|
|
markInfo = &sMapMarkInfoTable[mapMarkIconData->markType];
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-10-29 21:31:09 +00:00
|
|
|
gDPPipeSync(OVERLAY_DISP++);
|
2024-07-17 21:35:37 +00:00
|
|
|
gDPLoadTextureBlock_Runtime(OVERLAY_DISP++, markInfo->texture, markInfo->imageFormat,
|
|
|
|
markInfo->imageSize, markInfo->textureWidth, markInfo->textureHeight, 0,
|
|
|
|
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK,
|
|
|
|
G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2024-02-07 16:03:55 +00:00
|
|
|
rectLeft = ((OOT_DEBUG ? GREG(94) : 0) + markPoint->x + 204) << 2;
|
|
|
|
rectTop = ((OOT_DEBUG ? GREG(95) : 0) + markPoint->y + 140) << 2;
|
2020-10-29 21:31:09 +00:00
|
|
|
gSPTextureRectangle(OVERLAY_DISP++, rectLeft, rectTop, markInfo->rectWidth + rectLeft,
|
2020-03-22 21:19:43 +00:00
|
|
|
rectTop + markInfo->rectHeight, G_TX_RENDERTILE, 0, 0, markInfo->dsdx,
|
|
|
|
markInfo->dtdy);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
markPoint++;
|
|
|
|
}
|
2021-03-29 17:24:08 +00:00
|
|
|
mapMarkIconData++;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
CLOSE_DISPS(play->state.gfxCtx, "../z_map_mark.c", 339);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
void MapMark_Draw(PlayState* play) {
|
2022-07-31 23:44:47 +00:00
|
|
|
switch (play->sceneId) {
|
2022-11-26 21:15:41 +00:00
|
|
|
case SCENE_DEKU_TREE:
|
|
|
|
case SCENE_DODONGOS_CAVERN:
|
|
|
|
case SCENE_JABU_JABU:
|
|
|
|
case SCENE_FOREST_TEMPLE:
|
|
|
|
case SCENE_FIRE_TEMPLE:
|
|
|
|
case SCENE_WATER_TEMPLE:
|
|
|
|
case SCENE_SPIRIT_TEMPLE:
|
|
|
|
case SCENE_SHADOW_TEMPLE:
|
|
|
|
case SCENE_BOTTOM_OF_THE_WELL:
|
|
|
|
case SCENE_ICE_CAVERN:
|
|
|
|
case SCENE_DEKU_TREE_BOSS:
|
|
|
|
case SCENE_DODONGOS_CAVERN_BOSS:
|
|
|
|
case SCENE_JABU_JABU_BOSS:
|
|
|
|
case SCENE_FOREST_TEMPLE_BOSS:
|
|
|
|
case SCENE_FIRE_TEMPLE_BOSS:
|
2022-05-21 18:23:43 +00:00
|
|
|
MapMark_DrawForDungeon(play);
|
2021-05-02 23:15:16 +00:00
|
|
|
break;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
}
|