1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-02 15:55:59 +00:00
oot/src/code/z_map_mark.c

155 lines
5.7 KiB
C
Raw Normal View History

#include "global.h"
#include "vt.h"
#include "assets/textures/parameter_static/parameter_static.h"
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
typedef struct {
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
2020-03-22 21:19:43 +00:00
typedef struct {
2020-03-17 04:31:30 +00:00
/* 0x00 */ void* loadedRamAddr; // original name: "allocp"
/* 0x04 */ uintptr_t vromStart;
/* 0x08 */ uintptr_t vromEnd;
/* 0x0C */ void* vramStart;
/* 0x10 */ void* vramEnd;
/* 0x14 */ void* vramTable;
2020-03-17 04:31:30 +00:00
} MapMarkDataOverlay; // size = 0x18
2020-03-22 21:19:43 +00:00
static u32 sBaseImageSizes[] = { 0, 1, 2, 3 };
2020-03-17 04:31:30 +00:00
static u32 sLoadBlockImageSizes[] = { 2, 2, 2, 3 };
2020-03-22 21:19:43 +00:00
static u32 sIncrImageSizes[] = { 3, 1, 0, 0 };
static u32 sShiftImageSizes[] = { 2, 1, 0, 0 };
static u32 sBytesImageSizes[] = { 0, 1, 2, 4 };
2020-03-17 04:31:30 +00:00
static u32 sLineBytesImageSizes[] = { 0, 1, 2, 2 };
2020-03-22 21:19:43 +00:00
#define G_IM_SIZ_MARK sBaseImageSizes[markInfo->imageSize]
#define G_IM_SIZ_MARK_LOAD_BLOCK sLoadBlockImageSizes[markInfo->imageSize]
#define G_IM_SIZ_MARK_INCR sIncrImageSizes[markInfo->imageSize]
#define G_IM_SIZ_MARK_SHIFT sShiftImageSizes[markInfo->imageSize]
#define G_IM_SIZ_MARK_BYTES sBytesImageSizes[markInfo->imageSize]
#define G_IM_SIZ_MARK_LINE_BYTES sLineBytesImageSizes[markInfo->imageSize]
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
static MapMarkInfo sMapMarkInfoTable[] = {
{ 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 = {
2020-03-17 04:31:30 +00:00
NULL,
(uintptr_t)_ovl_map_mark_dataSegmentRomStart,
(uintptr_t)_ovl_map_mark_dataSegmentRomEnd,
_ovl_map_mark_dataSegmentStart,
_ovl_map_mark_dataSegmentEnd,
gMapMarkDataTable,
2020-03-17 04:31:30 +00:00
};
static MapMarkData** sLoadedMarkDataTable;
2020-03-17 04:31:30 +00:00
void MapMark_Init(PlayState* play) {
2020-03-17 04:31:30 +00:00
MapMarkDataOverlay* overlay = &sMapMarkDataOvl;
u32 overlaySize = (u32)overlay->vramEnd - (u32)overlay->vramStart;
2020-03-17 04:31:30 +00:00
overlay->loadedRamAddr = GameState_Alloc(&play->state, overlaySize, "../z_map_mark.c", 235);
2020-03-17 04:31:30 +00:00
LogUtils_CheckNullPointer("dlftbl->allocp", overlay->loadedRamAddr, "../z_map_mark.c", 236);
2020-03-22 21:19:43 +00:00
Overlay_Load(overlay->vromStart, overlay->vromEnd, overlay->vramStart, overlay->vramEnd, overlay->loadedRamAddr);
2020-03-17 04:31:30 +00:00
sLoadedMarkDataTable = gMapMarkDataTable;
2022-02-12 23:29:48 +00:00
sLoadedMarkDataTable = (void*)(u32)(
(overlay->vramTable != NULL)
? (void*)((u32)overlay->vramTable - (s32)((u32)overlay->vramStart - (u32)overlay->loadedRamAddr))
: NULL);
2020-03-17 04:31:30 +00:00
}
void MapMark_ClearPointers(PlayState* play) {
2020-03-17 04:31:30 +00:00
sMapMarkDataOvl.loadedRamAddr = NULL;
sLoadedMarkDataTable = NULL;
}
void MapMark_DrawForDungeon(PlayState* play) {
2020-03-17 04:31:30 +00:00
InterfaceContext* interfaceCtx;
MapMarkIconData* mapMarkIconData;
2020-03-17 04:31:30 +00:00
MapMarkPoint* markPoint;
MapMarkInfo* markInfo;
u16 dungeon = gSaveContext.mapIndex;
2020-03-17 04:31:30 +00:00
s32 i;
s32 rectLeft;
s32 rectTop;
interfaceCtx = &play->interfaceCtx;
2020-03-17 04:31:30 +00:00
if ((gMapData != NULL) && (play->interfaceCtx.mapRoomNum >= gMapData->dgnMinimapCount[dungeon])) {
// "Room number exceeded, yikes %d/%d MapMarkDraw processing interrupted"
2020-03-22 21:19:43 +00:00
osSyncPrintf(VT_COL(RED, WHITE) "部屋番号がオーバーしてるで,ヤバイで %d/%d \nMapMarkDraw の処理を中断します\n",
VT_RST, play->interfaceCtx.mapRoomNum, gMapData->dgnMinimapCount[dungeon]);
2020-03-17 04:31:30 +00:00
return;
}
mapMarkIconData = &sLoadedMarkDataTable[dungeon][interfaceCtx->mapRoomNum][0];
2020-03-17 04:31:30 +00:00
OPEN_DISPS(play->state.gfxCtx, "../z_map_mark.c", 303);
2020-03-17 04:31:30 +00:00
while (true) {
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
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
markPoint = &mapMarkIconData->points[0];
for (i = 0; i < mapMarkIconData->count; i++) {
if ((mapMarkIconData->markType != MAP_MARK_CHEST) || !Flags_GetTreasure(play, markPoint->chestFlag)) {
markInfo = &sMapMarkInfoTable[mapMarkIconData->markType];
2020-03-17 04:31:30 +00:00
gDPPipeSync(OVERLAY_DISP++);
gDPLoadTextureBlock(OVERLAY_DISP++, markInfo->texture, markInfo->imageFormat, G_IM_SIZ_MARK,
2020-03-22 21:19:43 +00:00
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
rectLeft = (GREG(94) + markPoint->x + 204) << 2;
rectTop = (GREG(95) + markPoint->y + 140) << 2;
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++;
}
mapMarkIconData++;
2020-03-17 04:31:30 +00:00
}
CLOSE_DISPS(play->state.gfxCtx, "../z_map_mark.c", 339);
2020-03-17 04:31:30 +00:00
}
void MapMark_Draw(PlayState* play) {
switch (play->sceneId) {
2020-03-17 04:31:30 +00:00
case SCENE_YDAN:
case SCENE_DDAN:
case SCENE_BDAN:
case SCENE_BMORI1:
case SCENE_HIDAN:
case SCENE_MIZUSIN:
case SCENE_JYASINZOU:
case SCENE_HAKADAN:
case SCENE_HAKADANCH:
case SCENE_ICE_DOUKUTO:
case SCENE_YDAN_BOSS:
case SCENE_DDAN_BOSS:
case SCENE_BDAN_BOSS:
case SCENE_MORIBOSSROOM:
case SCENE_FIRE_BS:
MapMark_DrawForDungeon(play);
break;
2020-03-17 04:31:30 +00:00
}
}