Start extracting demo data

This commit is contained in:
YohannDR 2023-03-13 16:15:56 +01:00
parent c265cd35cb
commit 90c449ee0c
10 changed files with 4267 additions and 21 deletions

View File

@ -5,6 +5,7 @@ This is a work in progress decompilation of Metroid - Zero Mission.
2236/2721 functions decompiled (82.18%, 485 left)
Progress can be seen here : https://docs.google.com/spreadsheets/d/1X8XarD5evY8ZI7r_GQqh1pYmdVMbBcINYfRBUlogmKY/edit#gid=0
**THE ROM IS TEMPORARLY NON-MATCHING**
**This decomp is not shiftable, don't use it as a base to work on anything**
This produces the following ROMs:

View File

@ -931,7 +931,7 @@ Blob_908e0_2b0c93.bin;2229171;0x908e0;1
Blob_2ceaa8_2cfd9f.bin;4856;0x2ceaa8;1
Blob_2d5ba0_2d7ae7.bin;7988;0x2d5ba0;1
Blob_34099c_345868.bin;20172;0x34099c;1
Blob_3603e8_367924.bin;30012;0x3603e8;1
Blob_363cf8_367924.bin;15404;0x363cf8;1
Blob_375cc4_386f60.bin;70300;0x375cc4;1
Blob_3f0390_411400.bin;135280;0x3f0390;1
Blob_415460_446d68.bin;203016;0x415460;1

30
include/data/demo_data.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef DEMO_DATA_H
#define DEMO_DATA_H
#include "structs/demo.h"
#include "structs/save_file.h"
#define MAX_AMOUNT_OF_DEMOS 16
extern const struct SaveDemo sDemo0_Ram;
extern const struct SaveDemo sDemo1_Ram;
extern const struct SaveDemo sDemo2_Ram;
extern const struct SaveDemo sDemo3_Ram;
extern const struct SaveDemo sDemo4_Ram;
extern const struct SaveDemo sDemo5_Ram;
extern const struct SaveDemo sDemo6_Ram;
extern const struct SaveDemo sDemo7_Ram;
extern const struct SaveDemo sDemo8_Ram;
extern const struct SaveDemo sDemo9_Ram;
extern const struct SaveDemo sDemo10_Ram;
extern const struct SaveDemo sDemo11_Ram;
extern const struct SaveDemo sDemo12_Ram;
extern const struct SaveDemo sDemo13_Ram;
extern const struct SaveDemo sDemo14_Ram;
extern const struct SaveDemo sDemo15_Ram;
extern const struct DemoEntry sDemoEntries[MAX_AMOUNT_OF_DEMOS];
extern const u8 sDemoNumbers[MAX_AMOUNT_OF_DEMOS];
#endif /* DEMO_DATA_H */

View File

@ -10,6 +10,13 @@ struct Demo {
u32 unk_3:4;
};
struct DemoEntry {
const u16* const pInputs;
u16 inputsSize;
const u16* const pDuration;
u16 durationSize;
};
extern u8 gDemoState;
extern struct Demo gCurrentDemo;

View File

@ -120,6 +120,9 @@ struct SaveDemo {
u8 currentArea;
u8 lastDoorUsed;
u8 unk_2;
u8 unk_3;
struct SamusData samusData;
struct WeaponInfo samusWeaponInfo;
struct SamusEcho samusEcho;
@ -128,12 +131,12 @@ struct SaveDemo {
struct HazardDamage hazardDamage;
struct EnvironmentalEffect environmentalEffects[5];
u32 visitedMinimapTiles[32];
u32 hatchesOpened[8];
u8 visitedMinimapTiles[128];
u8 hatchesOpened[32];
u8 text[8];
u8 useMotherShipDoors;
u8 padding_241[60];
u8 padding_241[63];
};
struct SaveFileScreenOptions {

View File

@ -635,7 +635,8 @@ SECTIONS {
src/data/animated_graphics_data.o(.rodata);
src/data/hatch_data.o(.rodata);
src/data/in_game_cutscene_data.o(.rodata);
/* 3603e8-367924 */
src/data/demo_data.o(.rodata);
/* 363cf8-367924 */
src/data/samus_close_up_data.o(.rodata);
src/data/cutscenes/cutscenes_data.o(.rodata);
src/data/cutscenes/kraid_rising_data.o(.rodata);

4121
src/data/demo_data.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -167,5 +167,3 @@ const struct InGameCutsceneData sInGameCutsceneData[32] = {
.pSubroutine = NULL
}
};
const u8 sTemparray_3603e8[0x753c] = INCBIN_U8("data/Blob_3603e8_367924.bin");

View File

@ -17,9 +17,10 @@ def Func():
result = ""
for x in range(1, size + 1):
result += str(sign(int.from_bytes(file.read(2), "little")))
# result += str(int.from_bytes(file.read(2), "little"))
result += hex(int.from_bytes(file.read(1), "little"))
if x % 10 == 0 and x != 0:
if x % 16 == 0 and x != 0:
result += ",\n"
else:
result += ", "

View File

@ -6,25 +6,109 @@ def sign(value):
return value
file = open("../mzm_us_baserom.gba", "rb")
def extractInput(value):
result = ""
def Func():
addr = 0x3461fc
if value & 0x1:
result = "KEY_A"
file.seek(addr)
if value & 0x2:
if result == "":
result = "KEY_B"
else:
result += " | KEY_B"
result = "const i16* const sHaze_PowerBomb_WindowValuesPointers[161] = {\n\t"
for x in range(5, 161):
result += "sHaze_PowerBomb_Values"
result += str(x)
result += ",\n\t"
if value & 0x4:
if result == "":
result = "KEY_SELECT"
else:
result += " | KEY_SELECT"
result += "};"
if value & 0x8:
if result == "":
result = "KEY_START"
else:
result += " | KEY_START"
if value & 0x10:
if result == "":
result = "KEY_RIGHT"
else:
result += " | KEY_RIGHT"
if value & 0x20:
if result == "":
result = "KEY_LEFT"
else:
result += " | KEY_LEFT"
if value & 0x40:
if result == "":
result = "KEY_UP"
else:
result += " | KEY_UP"
if value & 0x80:
if result == "":
result = "KEY_DOWN"
else:
result += " | KEY_DOWN"
if value & 0x100:
if result == "":
result = "KEY_R"
else:
result += " | KEY_R"
if value & 0x200:
if result == "":
result = "KEY_L"
else:
result += " | KEY_L"
if result == "":
result = "KEY_NONE"
return result
f = open("haze.txt", "w")
file = open("../mzm_us_baserom.gba", "rb")
def Func():
addr = 0x3603e8
file.seek(addr)
sizes = [104, 88, 80, 64, 64, 40, 32, 40, 136, 48, 88, 32, 48, 40, 24, 96]
result = ""
for x in range(0, len(sizes)):
result += "static const u16 sDemo"
result += str(x)
result += "_Inputs[] = {\n\t"
for y in range(0, sizes[x]):
result += extractInput(int.from_bytes(file.read(2), "little"))
result += ",\n\t"
result += "};\n\n"
result += "static const u16 sDemo"
result += str(x)
result += "_Durations[ARRAY_SIZE(sDemo"
result += str(x)
result += "_Inputs)"
result += "] = {\n\t"
for y in range(0, sizes[x]):
result += str(int.from_bytes(file.read(2), "little"))
result += ",\n\t"
result += "};\n\n"
return result
f = open("demos.txt", "w")
f.write(Func())
f.close()