1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-21 12:54:51 +00:00

Improve the format in z_map_mark_data.c and cleanup mapmark.py (#798)

* Cleanup mapmark.py script

* Rename map mark defines

* Remove unused entries from map_mark_data
This commit is contained in:
Roman971 2021-04-28 11:10:23 +02:00 committed by GitHub
parent 3fbdccbdba
commit 0b8252cfe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 354 additions and 1673 deletions

View File

@ -3,9 +3,9 @@
#include "ultra64.h"
#define MAP_MARK_ICON_NONE -1
#define MAP_MARK_ICON_CHEST 0
#define MAP_MARK_ICON_BOSS 1
#define MAP_MARK_NONE -1
#define MAP_MARK_CHEST 0
#define MAP_MARK_BOSS 1
typedef struct {
/* 0x00 */ s8 chestFlag; // chest icon is only displayed if this flag is not set for the current room

View File

@ -98,7 +98,7 @@ void MapMark_Draw(GlobalContext* globalCtx) {
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_map_mark.c", 303);
while (true) {
if (mapMarkIconData->markType == MAP_MARK_ICON_NONE) {
if (mapMarkIconData->markType == MAP_MARK_NONE) {
break;
}
@ -109,8 +109,7 @@ void MapMark_Draw(GlobalContext* globalCtx) {
markPoint = mapMarkIconData->points;
for (i = 0; i < mapMarkIconData->count; i++) {
if (mapMarkIconData->markType != MAP_MARK_ICON_CHEST ||
!Flags_GetTreasure(globalCtx, markPoint->chestFlag)) {
if ((mapMarkIconData->markType != MAP_MARK_CHEST) || !Flags_GetTreasure(globalCtx, markPoint->chestFlag)) {
markInfo = &sMapMarkInfoTable[mapMarkIconData->markType];
gDPPipeSync(OVERLAY_DISP++);

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,6 @@ 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 = [
@ -29,11 +28,11 @@ HEADER = """\
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)
@ -43,10 +42,10 @@ def GetMapsPerScene(ptrs):
result.append(v)
return result
def GetPoints(data, ptr):
def GetPoints(data, ptr, numPoints):
points = []
off = RamToOff(ptr);
for i in range(12):
for i in range(numPoints):
points.append(struct.unpack_from(">bBB", data[off:off+3]))
off = off + 3
return points
@ -54,14 +53,15 @@ def GetPoints(data, ptr):
def GetIconData(data, ptr):
off = RamToOff(ptr)
v = struct.unpack_from(">bB", data[off:off+2])
points = GetPoints(data, ptr+2)
points = GetPoints(data, ptr+2, v[1])
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)
icon = GetIconData(data, ptr + (i * 0x26))
if icon[0] != 0 or icon[1] > 0:
icons.append(icon)
return icons
def GetSceneMaps(data, ptr, numMaps):
@ -69,38 +69,38 @@ def GetSceneMaps(data, ptr, numMaps):
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"
return "MAP_MARK_CHEST"
if v == 1:
return "MAP_MARK_ICON_BOSS"
return "MAP_MARK_BOSS"
if v == -1:
return "MAP_MARK_ICON_NONE"
return "MAP_MARK_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 + ".."
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)
@ -109,16 +109,14 @@ 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:
if SIMPLIFY_OUTPUT and icon[0] == -1:
cstr += IND(2) + f"{{ {GetIconName(icon[0])}, 0, {{ 0 }} }},\n"
else:
cstr += IND(2) + "{\n"
@ -130,11 +128,11 @@ for scenemap in scenemaps:
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 += "};"
cstr += "};\n"
with open(sys.argv[1], "w") as file:
file.write(cstr)
file.write(cstr)