mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-13 04:39:36 +00:00
"decompile" ovl_map_mark_data, make minor tweaks to z_map_mark.c (#704)
* "decompile" ovl_map_mark_data, make minor tweaks to z_map_mark.c * implement some suggestions * eliminate wrapping braces
This commit is contained in:
parent
f4499a8de2
commit
86f16cf662
9 changed files with 2944 additions and 62 deletions
File diff suppressed because one or more lines are too long
|
@ -3541,7 +3541,6 @@ extern u8 gGfxSPTaskStack[0x400]; // 0x400 bytes
|
||||||
extern GfxPool gGfxPools[2]; // 0x24820 bytes
|
extern GfxPool gGfxPools[2]; // 0x24820 bytes
|
||||||
extern u8 gAudioHeap[0x38000]; // 0x38000 bytes
|
extern u8 gAudioHeap[0x38000]; // 0x38000 bytes
|
||||||
extern u8 gSystemHeap[];
|
extern u8 gSystemHeap[];
|
||||||
extern MapMarksData* gMapMarkDataTable[];
|
|
||||||
//extern ? D_A4040004;
|
//extern ? D_A4040004;
|
||||||
//extern ? D_A4040008;
|
//extern ? D_A4040008;
|
||||||
//extern ? D_A404000C;
|
//extern ? D_A404000C;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "z64animation.h"
|
#include "z64animation.h"
|
||||||
#include "z64dma.h"
|
#include "z64dma.h"
|
||||||
#include "z64math.h"
|
#include "z64math.h"
|
||||||
|
#include "z64map_mark.h"
|
||||||
#include "z64transition.h"
|
#include "z64transition.h"
|
||||||
#include "bgm.h"
|
#include "bgm.h"
|
||||||
#include "sfx.h"
|
#include "sfx.h"
|
||||||
|
@ -1167,19 +1168,6 @@ typedef struct {
|
||||||
/* 0x6C */ s16* skullFloorIconY; // dungeon big skull icon Y pos
|
/* 0x6C */ s16* skullFloorIconY; // dungeon big skull icon Y pos
|
||||||
} MapData; // size = 0x70
|
} MapData; // size = 0x70
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
/* 0x00 */ s8 chestFlag; // chest icon is only displayed if this flag is not set for the current room
|
|
||||||
/* 0x01 */ u8 x, y; // coordinates to place the icon (top-left corner), relative to the minimap texture
|
|
||||||
} MapMarkPoint; // size = 0x3
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
/* 0x00 */ s8 markType; // 0 for the chest icon, 1 for the boss skull icon, -1 for none
|
|
||||||
/* 0x01 */ u8 count; // number of icons to display
|
|
||||||
/* 0x02 */ MapMarkPoint points[12];
|
|
||||||
} MapMarkData; // size = 0x26
|
|
||||||
|
|
||||||
typedef MapMarkData MapMarksData[3]; // size = 0x72
|
|
||||||
|
|
||||||
typedef struct DebugDispObject {
|
typedef struct DebugDispObject {
|
||||||
/* 0x00 */ Vec3f pos;
|
/* 0x00 */ Vec3f pos;
|
||||||
/* 0x0C */ Vec3s rot;
|
/* 0x0C */ Vec3s rot;
|
||||||
|
|
25
include/z64map_mark.h
Normal file
25
include/z64map_mark.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#ifndef _Z64MAP_MARK_H_
|
||||||
|
#define _Z64MAP_MARK_H_
|
||||||
|
|
||||||
|
#include "ultra64.h"
|
||||||
|
|
||||||
|
#define MAP_MARK_ICON_NONE -1
|
||||||
|
#define MAP_MARK_ICON_CHEST 0
|
||||||
|
#define MAP_MARK_ICON_BOSS 1
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/* 0x00 */ s8 chestFlag; // chest icon is only displayed if this flag is not set for the current room
|
||||||
|
/* 0x01 */ u8 x, y; // coordinates to place the icon (top-left corner), relative to the minimap texture
|
||||||
|
} MapMarkPoint; // size = 0x3
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/* 0x00 */ s8 markType; // 0 for the chest icon, 1 for the boss skull icon, -1 for none
|
||||||
|
/* 0x01 */ u8 count; // number of icons to display
|
||||||
|
/* 0x02 */ MapMarkPoint points[12];
|
||||||
|
} MapMarkIconData; // size = 0x26
|
||||||
|
|
||||||
|
typedef MapMarkIconData MapMarkData[3]; // size = 0x72
|
||||||
|
|
||||||
|
extern MapMarkData* gMapMarkDataTable[];
|
||||||
|
|
||||||
|
#endif
|
3
spec
3
spec
|
@ -583,7 +583,8 @@ endseg
|
||||||
|
|
||||||
beginseg
|
beginseg
|
||||||
name "ovl_map_mark_data"
|
name "ovl_map_mark_data"
|
||||||
include "build/asm/overlays/data/ovl_map_mark_data/z_map_mark_data.o"
|
include "build/src/overlays/ovl_map_mark_data/z_map_mark_data.o"
|
||||||
|
include "build/src/overlays/ovl_map_mark_data/ovl_map_mark_data_reloc.o"
|
||||||
endseg
|
endseg
|
||||||
|
|
||||||
beginseg
|
beginseg
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "vt.h"
|
#include "vt.h"
|
||||||
|
#include "textures/parameter_static/parameter_static.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ void* texture;
|
/* 0x00 */ void* texture;
|
||||||
|
@ -37,8 +38,8 @@ static u32 sLineBytesImageSizes[] = { 0, 1, 2, 2 };
|
||||||
#define G_IM_SIZ_MARK_LINE_BYTES sLineBytesImageSizes[markInfo->imageSize]
|
#define G_IM_SIZ_MARK_LINE_BYTES sLineBytesImageSizes[markInfo->imageSize]
|
||||||
|
|
||||||
static MapMarkInfo sMapMarkInfoTable[] = {
|
static MapMarkInfo sMapMarkInfoTable[] = {
|
||||||
{ D_02002580, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 32, 32, 1024, 1024 }, // Chest Icon
|
{ gHUDTreasureMarkerTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 32, 32, 1024, 1024 }, // Chest Icon
|
||||||
{ D_02002900, G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 32, 32, 1024, 1024 }, // Boss Skull Icon
|
{ gHUDBossMarkerTex, G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 32, 32, 1024, 1024 }, // Boss Skull Icon
|
||||||
};
|
};
|
||||||
|
|
||||||
static MapMarkDataOverlay sMapMarkDataOvl = {
|
static MapMarkDataOverlay sMapMarkDataOvl = {
|
||||||
|
@ -50,7 +51,7 @@ static MapMarkDataOverlay sMapMarkDataOvl = {
|
||||||
gMapMarkDataTable,
|
gMapMarkDataTable,
|
||||||
};
|
};
|
||||||
|
|
||||||
static MapMarksData** sLoadedMarkDataTable;
|
static MapMarkData** sLoadedMarkDataTable;
|
||||||
|
|
||||||
void MapMark_Init(GlobalContext* globalCtx) {
|
void MapMark_Init(GlobalContext* globalCtx) {
|
||||||
MapMarkDataOverlay* overlay = &sMapMarkDataOvl;
|
MapMarkDataOverlay* overlay = &sMapMarkDataOvl;
|
||||||
|
@ -75,7 +76,7 @@ void MapMark_ClearPointers(GlobalContext* globalCtx) {
|
||||||
|
|
||||||
void MapMark_Draw(GlobalContext* globalCtx) {
|
void MapMark_Draw(GlobalContext* globalCtx) {
|
||||||
InterfaceContext* interfaceCtx;
|
InterfaceContext* interfaceCtx;
|
||||||
MapMarkData* mapMarkData;
|
MapMarkIconData* mapMarkIconData;
|
||||||
MapMarkPoint* markPoint;
|
MapMarkPoint* markPoint;
|
||||||
MapMarkInfo* markInfo;
|
MapMarkInfo* markInfo;
|
||||||
u16 dungeon = gSaveContext.mapIndex;
|
u16 dungeon = gSaveContext.mapIndex;
|
||||||
|
@ -85,19 +86,19 @@ void MapMark_Draw(GlobalContext* globalCtx) {
|
||||||
|
|
||||||
interfaceCtx = &globalCtx->interfaceCtx;
|
interfaceCtx = &globalCtx->interfaceCtx;
|
||||||
|
|
||||||
if ((gMapData != NULL) && (globalCtx->interfaceCtx.mapRoomNum >= gMapData->dgnMinimapCount[dungeon])) {
|
if (gMapData != NULL && globalCtx->interfaceCtx.mapRoomNum >= gMapData->dgnMinimapCount[dungeon]) {
|
||||||
// Translates to: "ROOM NUMBER EXCEEDED, YIKES %d/%d MapMarkDraw PROCESSING INTERRUPTED"
|
// Translates to: "ROOM NUMBER EXCEEDED, YIKES %d/%d MapMarkDraw PROCESSING INTERRUPTED"
|
||||||
osSyncPrintf(VT_COL(RED, WHITE) "部屋番号がオーバーしてるで,ヤバイで %d/%d \nMapMarkDraw の処理を中断します\n",
|
osSyncPrintf(VT_COL(RED, WHITE) "部屋番号がオーバーしてるで,ヤバイで %d/%d \nMapMarkDraw の処理を中断します\n",
|
||||||
VT_RST, globalCtx->interfaceCtx.mapRoomNum, gMapData->dgnMinimapCount[dungeon]);
|
VT_RST, globalCtx->interfaceCtx.mapRoomNum, gMapData->dgnMinimapCount[dungeon]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapMarkData = &sLoadedMarkDataTable[dungeon][interfaceCtx->mapRoomNum][0];
|
mapMarkIconData = &sLoadedMarkDataTable[dungeon][interfaceCtx->mapRoomNum][0];
|
||||||
|
|
||||||
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_map_mark.c", 303);
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_map_mark.c", 303);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (mapMarkData->markType == -1) {
|
if (mapMarkIconData->markType == MAP_MARK_ICON_NONE) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,10 +107,11 @@ void MapMark_Draw(GlobalContext* globalCtx) {
|
||||||
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->minimapAlpha);
|
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->minimapAlpha);
|
||||||
gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, interfaceCtx->minimapAlpha);
|
gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, interfaceCtx->minimapAlpha);
|
||||||
|
|
||||||
markPoint = &mapMarkData->points[0];
|
markPoint = mapMarkIconData->points;
|
||||||
for (i = 0; i < mapMarkData->count; i++) {
|
for (i = 0; i < mapMarkIconData->count; i++) {
|
||||||
if ((mapMarkData->markType != 0) || !Flags_GetTreasure(globalCtx, markPoint->chestFlag)) {
|
if (mapMarkIconData->markType != MAP_MARK_ICON_CHEST ||
|
||||||
markInfo = &sMapMarkInfoTable[mapMarkData->markType];
|
!Flags_GetTreasure(globalCtx, markPoint->chestFlag)) {
|
||||||
|
markInfo = &sMapMarkInfoTable[mapMarkIconData->markType];
|
||||||
|
|
||||||
gDPPipeSync(OVERLAY_DISP++);
|
gDPPipeSync(OVERLAY_DISP++);
|
||||||
gDPLoadTextureBlock(OVERLAY_DISP++, markInfo->texture, markInfo->imageFormat, G_IM_SIZ_MARK,
|
gDPLoadTextureBlock(OVERLAY_DISP++, markInfo->texture, markInfo->imageFormat, G_IM_SIZ_MARK,
|
||||||
|
@ -124,7 +126,7 @@ void MapMark_Draw(GlobalContext* globalCtx) {
|
||||||
}
|
}
|
||||||
markPoint++;
|
markPoint++;
|
||||||
}
|
}
|
||||||
mapMarkData++;
|
mapMarkIconData++;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_map_mark.c", 339);
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_map_mark.c", 339);
|
||||||
|
|
2
src/overlays/ovl_map_mark_data/overlay.cfg
Normal file
2
src/overlays/ovl_map_mark_data/overlay.cfg
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ovl_map_mark_data
|
||||||
|
z_map_mark_data.c
|
2760
src/overlays/ovl_map_mark_data/z_map_mark_data.c
Normal file
2760
src/overlays/ovl_map_mark_data/z_map_mark_data.c
Normal file
File diff suppressed because it is too large
Load diff
140
tools/overlayhelpers/mapmark.py
Normal file
140
tools/overlayhelpers/mapmark.py
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import os
|
||||||
|
import struct
|
||||||
|
import sys
|
||||||
|
|
||||||
|
NUM_SCENES = 10
|
||||||
|
SIMPLIFY_OUTPUT = True # setting to True reduces the final output by ~9k lines
|
||||||
|
MAP_MARK_RAM = 0x80858B70
|
||||||
|
MAP_MARK_ROM = 0x00C27940
|
||||||
|
gMapMarkDataTable = 0x8085F5E8
|
||||||
|
|
||||||
|
DUNGEON_NAMES = [
|
||||||
|
("DekuTree", "Deku Tree"),
|
||||||
|
("DodongosCavern", "Dodongo's Cavern"),
|
||||||
|
("JabuJabuBelly", "Jabu-Jabu's Belly"),
|
||||||
|
("ForestTemple", "Forest Temple"),
|
||||||
|
("FireTemple", "Fire Temple"),
|
||||||
|
("WaterTemple", "Water Temple"),
|
||||||
|
("SpiritTemple", "Spirit Temple"),
|
||||||
|
("ShadowTemple", "Shadow Temple"),
|
||||||
|
("BottomWell", "Bottom of the Well"),
|
||||||
|
("IceCavern", "Ice Cavern")
|
||||||
|
]
|
||||||
|
|
||||||
|
HEADER = """\
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def RamToOff(vram):
|
||||||
|
return vram - MAP_MARK_RAM
|
||||||
|
|
||||||
|
def GetMapPtrs(data):
|
||||||
|
off = RamToOff(gMapMarkDataTable)
|
||||||
|
return struct.unpack_from(">10L", data[off:off+(NUM_SCENES * 4)])
|
||||||
|
|
||||||
|
def GetMapsPerScene(ptrs):
|
||||||
|
result = []
|
||||||
|
endAddr = list(ptrs)
|
||||||
|
endAddr.append(gMapMarkDataTable)
|
||||||
|
for i, ptr in enumerate(ptrs):
|
||||||
|
v = (endAddr[i+1] - ptr) // 0x72
|
||||||
|
result.append(v)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def GetPoints(data, ptr):
|
||||||
|
points = []
|
||||||
|
off = RamToOff(ptr);
|
||||||
|
for i in range(12):
|
||||||
|
points.append(struct.unpack_from(">bBB", data[off:off+3]))
|
||||||
|
off = off + 3
|
||||||
|
return points
|
||||||
|
|
||||||
|
def GetIconData(data, ptr):
|
||||||
|
off = RamToOff(ptr)
|
||||||
|
v = struct.unpack_from(">bB", data[off:off+2])
|
||||||
|
points = GetPoints(data, ptr+2)
|
||||||
|
return [v[0], v[1], points]
|
||||||
|
|
||||||
|
def GetSceneMap(data, ptr):
|
||||||
|
icons = []
|
||||||
|
for i in range(3):
|
||||||
|
icon = GetIconData(data, ptr+(i * 0x26))
|
||||||
|
icons.append(icon)
|
||||||
|
return icons
|
||||||
|
|
||||||
|
def GetSceneMaps(data, ptr, numMaps):
|
||||||
|
maps = []
|
||||||
|
for i in range(numMaps):
|
||||||
|
maps.append(GetSceneMap(data, ptr + (i * 0x72)))
|
||||||
|
return maps
|
||||||
|
|
||||||
|
def GetDungeonSymbol(i):
|
||||||
|
return f"sMapMark{DUNGEON_NAMES[i][0]}"
|
||||||
|
|
||||||
|
def GetDungeonName(i):
|
||||||
|
return DUNGEON_NAMES[i][1]
|
||||||
|
|
||||||
|
def GetIconName(v):
|
||||||
|
if v == 0:
|
||||||
|
return "MAP_MARK_ICON_CHEST"
|
||||||
|
if v == 1:
|
||||||
|
return "MAP_MARK_ICON_BOSS"
|
||||||
|
if v == -1:
|
||||||
|
return "MAP_MARK_ICON_NONE"
|
||||||
|
return v
|
||||||
|
|
||||||
|
def IND(n):
|
||||||
|
return ' ' * 4 * n
|
||||||
|
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print("Script requires an output filename for the generated .c file")
|
||||||
|
quit()
|
||||||
|
|
||||||
|
scriptDir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
repo = scriptDir + os.sep + ".." + os.sep + ".."
|
||||||
|
|
||||||
|
|
||||||
|
map_mark_data = []
|
||||||
|
with open(repo + "/baserom/ovl_map_mark_data", "rb") as file:
|
||||||
|
map_mark_data = bytearray(file.read())
|
||||||
|
|
||||||
|
scenemaps = []
|
||||||
|
|
||||||
|
scenemap_ptrs = GetMapPtrs(map_mark_data)
|
||||||
|
maps_per_scene = GetMapsPerScene(scenemap_ptrs)
|
||||||
|
for i in range(NUM_SCENES):
|
||||||
|
scenemaps.append((i, GetSceneMaps(map_mark_data, scenemap_ptrs[i], maps_per_scene[i])))
|
||||||
|
|
||||||
|
cstr = HEADER
|
||||||
|
|
||||||
|
for scenemap in scenemaps:
|
||||||
|
cstr += f"MapMarkData {GetDungeonSymbol(scenemap[0])}[] = {{\n"
|
||||||
|
for mapId, map in enumerate(scenemap[1]):
|
||||||
|
cstr += IND(1) + f"// {GetDungeonName(scenemap[0])} minimap {mapId}\n"
|
||||||
|
cstr += IND(1) + "{\n"
|
||||||
|
for icon in map:
|
||||||
|
if SIMPLIFY_OUTPUT and icon[0] == 0 and icon[1] == 0:
|
||||||
|
cstr += IND(2) + "{ 0 },\n"
|
||||||
|
elif SIMPLIFY_OUTPUT and icon[0] == -1:
|
||||||
|
cstr += IND(2) + f"{{ {GetIconName(icon[0])}, 0, {{ 0 }} }},\n"
|
||||||
|
else:
|
||||||
|
cstr += IND(2) + "{\n"
|
||||||
|
cstr += IND(3) + f"{GetIconName(icon[0])}, {icon[1]},\n"
|
||||||
|
cstr += IND(3) + "{\n"
|
||||||
|
for point in icon[2]:
|
||||||
|
cstr += IND(4) + f"{{ {point[0]}, {point[1]}, {point[2]} }},\n"
|
||||||
|
cstr += IND(3) + "}\n"
|
||||||
|
cstr += IND(2) + "},\n"
|
||||||
|
cstr += IND(1) + "},\n"
|
||||||
|
cstr += "};\n\n"
|
||||||
|
|
||||||
|
cstr += "MapMarkData* gMapMarkDataTable[] = {\n"
|
||||||
|
for scenemap in scenemaps:
|
||||||
|
cstr += f" {GetDungeonSymbol(scenemap[0])},\n"
|
||||||
|
cstr += "};"
|
||||||
|
|
||||||
|
with open(sys.argv[1], "w") as file:
|
||||||
|
file.write(cstr)
|
Loading…
Reference in a new issue