From 5b4815f92ead2bd7ca9ee89f54494005342a3afa Mon Sep 17 00:00:00 2001 From: sup39 Date: Mon, 13 Mar 2023 21:01:56 +0900 Subject: [PATCH] init --- .gitignore | 2 ++ README.md | 14 +++++++++++ docs/CNAME | 1 + docs/static-variables.json | 1 + parse.py | 50 ++++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 6 files changed, 69 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 docs/CNAME create mode 100644 docs/static-variables.json create mode 100644 parse.py create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..849e364 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.venv +/SMS RAM Map.xlsx diff --git a/README.md b/README.md new file mode 100644 index 0000000..0b102b7 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# res.sms.sup39.dev +JSON files generated from [SMS RAM Map](https://docs.google.com/spreadsheets/d/1ElTW-akaTUF9OC2pIFR9-7aVPwpJ54AdEVJyJ_jvg0E/edit) for tool development + +## Files +- [`static-variables.json`](docs/static-variables.json): [Static variables](https://docs.google.com/spreadsheets/d/1ElTW-akaTUF9OC2pIFR9-7aVPwpJ54AdEVJyJ_jvg0E/edit#gid=1727422135) + +## Build +```bash +## Install dependencies +pip install -r requirements.txt + +## Run +python parse.py +``` diff --git a/docs/CNAME b/docs/CNAME new file mode 100644 index 0000000..908ba87 --- /dev/null +++ b/docs/CNAME @@ -0,0 +1 @@ +res.sms.sup39.dev diff --git a/docs/static-variables.json b/docs/static-variables.json new file mode 100644 index 0000000..e823440 --- /dev/null +++ b/docs/static-variables.json @@ -0,0 +1 @@ +{"gpApplication": {"type": "TApplication", "GMSJ01": 2151571456, "GMSE01": 2151585536, "GMSP01": 2151551168, "GMSJ0A": 2151524576}, "mPadStatus": {"type": "PADStatus", "GMSJ01": 2151681360, "GMSE01": 2151695444, "GMSP01": 2151660532, "GMSJ0A": 2151633960}, "mPadButton": {"type": "JUTGamePad::CButton[4]", "GMSJ01": 2151681408, "GMSE01": 2151695492, "GMSP01": 2151660580, "GMSJ0A": 2151634008}, "mPadMStick": {"type": "JUTGamePad::CStick[4]", "GMSJ01": 2151681600, "GMSE01": 2151695684, "GMSP01": 2151660772, "GMSJ0A": 2151634200}, "mPadSStick": {"type": "JUTGamePad::CStick[4]", "GMSJ01": 2151681664, "GMSE01": 2151695748, "GMSP01": 2151660836, "GMSJ0A": 2151634264}, "next": {"type": "int", "GMSJ01": 2151714032, "GMSE01": 2151730736, "GMSP01": 2151695760, "GMSJ0A": 2151669128}, "JKRHeap::sCurrentHeap": {"type": "JKRHeap*", "GMSJ01": 2151716908, "GMSE01": 2151735956, "GMSP01": 2151700844, "GMSJ0A": 2151674164}, "JKRHeap::sRootHeap": {"type": "JKRExpHeap*", "GMSJ01": 2151716912, "GMSE01": 2151735960, "GMSP01": 2151700848, "GMSJ0A": 2151674168}, "JDrama::TNameRefGen::instance": {"type": "TMarNameRefGen*", "GMSJ01": 2151717280, "GMSE01": 2151736328, "GMSP01": 2151701216, "GMSJ0A": 2151674536}, "__AID_Callback": {"type": null, "GMSJ01": 2151718780, "GMSE01": 2151737676, "GMSP01": 2151702564, "GMSJ0A": 2151675884}, "gpSilhouetteManager": {"type": null, "GMSJ01": 2151719432, "GMSE01": 2151735440, "GMSP01": 2151700312, "GMSJ0A": 2151673648}, "gpLightManager": {"type": null, "GMSJ01": 2151719468, "GMSE01": 2151735476, "GMSP01": 2151700348, "GMSJ0A": 2151673684}, "gpAfterEffect": {"type": null, "GMSJ01": 2151719472, "GMSE01": 2151735480, "GMSP01": 2151700352, "GMSJ0A": 2151673688}, "gpScreenTexture": {"type": null, "GMSJ01": 2151719476, "GMSE01": 2151735484, "GMSP01": 2151700356, "GMSJ0A": 2151673692}, "gpBindShadowManager": {"type": null, "GMSJ01": 2151719480, "GMSE01": 2151735488, "GMSP01": 2151700360, "GMSJ0A": 2151673696}, "gpMarioParticleManager": {"type": null, "GMSJ01": 2151719512, "GMSE01": 2151735632, "GMSP01": 2151700504, "GMSJ0A": 2151673840}, "TFlagManager::smInstance": {"type": "TFlagManager*", "GMSJ01": 2151719568, "GMSE01": 2151735648, "GMSP01": 2151700520, "GMSJ0A": 2151673856}, "gpSceneCmnDat": {"type": null, "GMSJ01": 2151719576, "GMSE01": 2151735656, "GMSP01": 2151700528, "GMSJ0A": 2151673864}, "gpSceneCmnDatSize": {"type": null, "GMSJ01": 2151719580, "GMSE01": 2151735660, "GMSP01": 2151700532, "GMSJ0A": 2151673868}, "gpMarDirector": {"type": "TMarDirector*", "GMSJ01": 2151719592, "GMSE01": 2151735672, "GMSP01": 2151700544, "GMSJ0A": 2151673880}, "gpMSound": {"type": null, "GMSJ01": 2151719596, "GMSE01": 2151735676, "GMSP01": 2151700548, "GMSJ0A": 2151673884}, "gpSetupThreadStack": {"type": null, "GMSJ01": 2151719600, "GMSE01": 2151735680, "GMSP01": 2151700552, "GMSJ0A": 2151673888}, "gpCardManager": {"type": "TCardManager*", "GMSJ01": 2151719604, "GMSE01": 2151735684, "GMSP01": 2151700556, "GMSJ0A": 2151673892}, "gpSystemFont": {"type": null, "GMSJ01": 2151719608, "GMSE01": 2151735688, "GMSP01": 2151700560, "GMSJ0A": 2151673896}, "gpRomFont": {"type": null, "GMSJ01": 2151719612, "GMSE01": 2151735692, "GMSP01": 2151700564, "GMSJ0A": 2151673900}, "gpPositionHolder": {"type": null, "GMSJ01": 2151719664, "GMSE01": 2151735744, "GMSP01": 2151700632, "GMSJ0A": 2151673952}, "gpResourceManager": {"type": null, "GMSJ01": 2151719696, "GMSE01": 2151735776, "GMSP01": 2151700664, "GMSJ0A": 2151673984}, "gpEmitterManager4D2": {"type": null, "GMSJ01": 2151719700, "GMSE01": 2151735780, "GMSP01": 2151700668, "GMSJ0A": 2151673988}, "gpTargetArrow": {"type": null, "GMSJ01": 2151719752, "GMSE01": 2151735840, "GMSP01": 2151700728, "GMSJ0A": 2151674048}, "gpObjHitCheck": {"type": null, "GMSJ01": 2151719760, "GMSE01": 2151735408, "GMSP01": 2151700280, "GMSJ0A": 2151673616}, "gpStrategy": {"type": null, "GMSJ01": 2151719776, "GMSE01": 2151735424, "GMSP01": 2151700296, "GMSJ0A": 2151673632}, "gpQuestionManager": {"type": null, "GMSJ01": 2151719784, "GMSE01": 2151735432, "GMSP01": 2151700304, "GMSJ0A": 2151673640}, "gpMarioForCallBack": {"type": null, "GMSJ01": 2151719792, "GMSE01": 2151735520, "GMSP01": 2151700392, "GMSJ0A": 2151673728}, "gpMarioOriginal": {"type": "TMario*", "GMSJ01": 2151719800, "GMSE01": 2151735528, "GMSP01": 2151700400, "GMSJ0A": 2151673736}, "gpSplashManager": {"type": null, "GMSJ01": 2151719824, "GMSE01": 2151735552, "GMSP01": 2151700424, "GMSJ0A": 2151673760}, "gpMarioAddress": {"type": "TMario*", "GMSJ01": 2151719832, "GMSE01": 2151735560, "GMSP01": 2151700432, "GMSJ0A": 2151673768}, "gpMarioPos": {"type": "JGeometry::TVec3*", "GMSJ01": 2151719836, "GMSE01": 2151735564, "GMSP01": 2151700436, "GMSJ0A": 2151673772}, "gpMarioAngleX": {"type": "short*", "GMSJ01": 2151719840, "GMSE01": 2151735568, "GMSP01": 2151700440, "GMSJ0A": 2151673776}, "gpMarioAngleY": {"type": "short*", "GMSJ01": 2151719844, "GMSE01": 2151735572, "GMSP01": 2151700444, "GMSJ0A": 2151673780}, "gpMarioAngleZ": {"type": "short*", "GMSJ01": 2151719848, "GMSE01": 2151735576, "GMSP01": 2151700448, "GMSJ0A": 2151673784}, "gpMarioSpeedX": {"type": "float*", "GMSJ01": 2151719852, "GMSE01": 2151735580, "GMSP01": 2151700452, "GMSJ0A": 2151673788}, "gpMarioSpeedY": {"type": "float*", "GMSJ01": 2151719856, "GMSE01": 2151735584, "GMSP01": 2151700456, "GMSJ0A": 2151673792}, "gpMarioSpeedZ": {"type": "float*", "GMSJ01": 2151719860, "GMSE01": 2151735588, "GMSP01": 2151700460, "GMSJ0A": 2151673796}, "gpMarioLightID": {"type": null, "GMSJ01": 2151719864, "GMSE01": 2151735592, "GMSP01": 2151700464, "GMSJ0A": 2151673800}, "gpMarioFlag": {"type": null, "GMSJ01": 2151719868, "GMSE01": 2151735596, "GMSP01": 2151700468, "GMSJ0A": 2151673804}, "gpMarioThrowPower": {"type": null, "GMSJ01": 2151719872, "GMSE01": 2151735600, "GMSP01": 2151700472, "GMSJ0A": 2151673808}, "gpMarioGroundPlane": {"type": null, "GMSJ01": 2151719876, "GMSE01": 2151735604, "GMSP01": 2151700476, "GMSJ0A": 2151673812}, "gpModelWaterManager": {"type": null, "GMSJ01": 2151719880, "GMSE01": 2151735608, "GMSP01": 2151700480, "GMSJ0A": 2151673816}, "gpCurrentNpc": {"type": null, "GMSJ01": 2151719912, "GMSE01": 2151735208, "GMSP01": 2151700080, "GMSJ0A": 2151673416}, "gpMareJellyFishManager": {"type": null, "GMSJ01": 2151719944, "GMSE01": 2151735240, "GMSP01": 2151700112, "GMSJ0A": 2151673448}, "gpMapObjManager": {"type": null, "GMSJ01": 2151720144, "GMSE01": 2151735048, "GMSP01": 2151699920, "GMSJ0A": 2151673256}, "gpItemManager": {"type": "TItemManager*", "GMSJ01": 2151720152, "GMSE01": 2151735056, "GMSP01": 2151699928, "GMSJ0A": 2151673264}, "gpMapObjSwitch": {"type": null, "GMSJ01": 2151720160, "GMSE01": 2151735064, "GMSP01": 2151699936, "GMSJ0A": 2151673272}, "gpCurObject": {"type": null, "GMSJ01": 2151720176, "GMSE01": 2151735080, "GMSP01": 2151699952, "GMSJ0A": 2151673288}, "gpMapObjFlagManager": {"type": null, "GMSJ01": 2151720200, "GMSE01": 2151735104, "GMSP01": 2151699976, "GMSJ0A": 2151673312}, "gpMapObjWave": {"type": null, "GMSJ01": 2151720220, "GMSE01": 2151735124, "GMSP01": 2151699996, "GMSJ0A": 2151673332}, "gpMapObjGrassManager": {"type": null, "GMSJ01": 2151720260, "GMSE01": 2151735164, "GMSP01": 2151700036, "GMSJ0A": 2151673372}, "gpMapObjPoleManager": {"type": null, "GMSJ01": 2151720264, "GMSE01": 2151735168, "GMSP01": 2151700040, "GMSJ0A": 2151673376}, "gpPoolManager": {"type": null, "GMSJ01": 2151720288, "GMSE01": 2151735184, "GMSP01": 2151700056, "GMSJ0A": 2151673392}, "gpMap": {"type": "TMap*", "GMSJ01": 2151720304, "GMSE01": 2151734936, "GMSP01": 2151699808, "GMSJ0A": 2151673144}, "gpMapCollisionData": {"type": null, "GMSJ01": 2151720312, "GMSE01": 2151734944, "GMSP01": 2151699816, "GMSJ0A": 2151673152}, "gpMirrorModelManager": {"type": null, "GMSJ01": 2151720320, "GMSE01": 2151734952, "GMSP01": 2151699824, "GMSJ0A": 2151673160}, "gpMapWireManager": {"type": "TMapWireManager*", "GMSJ01": 2151720336, "GMSE01": 2151734968, "GMSP01": 2151699840, "GMSJ0A": 2151673176}, "gpPollution": {"type": null, "GMSJ01": 2151720360, "GMSE01": 2151734992, "GMSP01": 2151699864, "GMSJ0A": 2151673200}, "gpTalk2D": {"type": null, "GMSJ01": 2151720488, "GMSE01": 2151734744, "GMSP01": 2151699544, "GMSJ0A": 2151672880}, "gpCardLoad": {"type": null, "GMSJ01": 2151720496, "GMSE01": 2151734752, "GMSP01": 2151699552, "GMSJ0A": 2151672888}, "gpConductor": {"type": null, "GMSJ01": 2151720680, "GMSE01": 2151731472, "GMSP01": 2151696496, "GMSJ0A": 2151669832}, "gpEffectObjManager": {"type": null, "GMSJ01": 2151720688, "GMSE01": 2151731480, "GMSP01": 2151696504, "GMSJ0A": 2151669840}, "gpCurGesso": {"type": null, "GMSJ01": 2151720696, "GMSE01": 2151731488, "GMSP01": 2151696512, "GMSJ0A": 2151669848}, "gpCurNameKuri": {"type": null, "GMSJ01": 2151721064, "GMSE01": 2151731856, "GMSP01": 2151696760, "GMSJ0A": 2151670096}, "gpCurPakkun": {"type": null, "GMSJ01": 2151721128, "GMSE01": 2151731920, "GMSP01": 2151696824, "GMSJ0A": 2151670160}, "gpCurPakkunSeed": {"type": null, "GMSJ01": 2151721132, "GMSE01": 2151731924, "GMSP01": 2151696828, "GMSJ0A": 2151670164}, "gpCurTobiPuku": {"type": null, "GMSJ01": 2151721808, "GMSE01": 2151732600, "GMSP01": 2151697504, "GMSJ0A": 2151670840}, "gpCurChuuHana": {"type": null, "GMSJ01": 2151722032, "GMSE01": 2151732816, "GMSP01": 2151697720, "GMSJ0A": 2151671056}, "gpCurRollEnemy": {"type": null, "GMSJ01": 2151722128, "GMSE01": 2151732912, "GMSP01": 2151697816, "GMSJ0A": 2151671152}, "gpCurKiller": {"type": null, "GMSJ01": 2151722640, "GMSE01": 2151733424, "GMSP01": 2151698328, "GMSJ0A": 2151671664}, "gpBeamManager": {"type": "TBeamManager*", "GMSJ01": 2151722672, "GMSE01": 2151733456, "GMSP01": 2151698360, "GMSJ0A": 2151671696}, "gpCurSamboHead": {"type": null, "GMSJ01": 2151722684, "GMSE01": 2151733468, "GMSP01": 2151698372, "GMSJ0A": 2151671708}, "gpCurPopo": {"type": null, "GMSJ01": 2151722784, "GMSE01": 2151733568, "GMSP01": 2151698472, "GMSJ0A": 2151671808}, "gpCurHauntLeg": {"type": null, "GMSJ01": 2151723072, "GMSE01": 2151733856, "GMSP01": 2151698760, "GMSJ0A": 2151672096}, "gpCamera": {"type": "CPolarSubCamera*", "GMSJ01": 2151723888, "GMSE01": 2151731368, "GMSP01": 2151696392, "GMSJ0A": 2151676472}, "gpCameraMario": {"type": "TCameraMarioData*", "GMSJ01": 2151723896, "GMSE01": 2151731376, "GMSP01": 2151696400, "GMSJ0A": 2151676480}, "gpCameraShake": {"type": "TCameraShake*", "GMSJ01": 2151723904, "GMSE01": 2151731384, "GMSP01": 2151696408, "GMSJ0A": 2151676488}, "gpSunMgr": {"type": null, "GMSJ01": 2151723912, "GMSE01": 2151731392, "GMSP01": 2151696416, "GMSJ0A": 2151676496}, "gpSunModel": {"type": null, "GMSJ01": 2151723920, "GMSE01": 2151731400, "GMSP01": 2151696424, "GMSJ0A": 2151676504}, "gpCubeCamera": {"type": null, "GMSJ01": 2151723928, "GMSE01": 2151731408, "GMSP01": 2151696432, "GMSJ0A": 2151676512}, "gpCubeMirror": {"type": null, "GMSJ01": 2151723932, "GMSE01": 2151731412, "GMSP01": 2151696436, "GMSJ0A": 2151676516}, "gpCubeWire": {"type": null, "GMSJ01": 2151723936, "GMSE01": 2151731416, "GMSP01": 2151696440, "GMSJ0A": 2151676520}, "gpCubeStream": {"type": null, "GMSJ01": 2151723940, "GMSE01": 2151731420, "GMSP01": 2151696444, "GMSJ0A": 2151676524}, "gpCubeShadow": {"type": null, "GMSJ01": 2151723944, "GMSE01": 2151731424, "GMSP01": 2151696448, "GMSJ0A": 2151676528}, "gpCubeArea": {"type": null, "GMSJ01": 2151723948, "GMSE01": 2151731428, "GMSP01": 2151696452, "GMSJ0A": 2151676532}, "gpCubeFastA": {"type": null, "GMSJ01": 2151723952, "GMSE01": 2151731432, "GMSP01": 2151696456, "GMSJ0A": 2151676536}, "gpCubeFastB": {"type": null, "GMSJ01": 2151723956, "GMSE01": 2151731436, "GMSP01": 2151696460, "GMSJ0A": 2151676540}, "gpCubeFastC": {"type": null, "GMSJ01": 2151723960, "GMSE01": 2151731440, "GMSP01": 2151696464, "GMSJ0A": 2151676544}, "gpCubeSoundChange": {"type": null, "GMSJ01": 2151723964, "GMSE01": 2151731444, "GMSP01": 2151696468, "GMSJ0A": 2151676548}, "gpCubeSoundEffect": {"type": null, "GMSJ01": 2151723968, "GMSE01": 2151731448, "GMSP01": 2151696472, "GMSJ0A": 2151676552}, "gpCamMapToolTable": {"type": null, "GMSJ01": 2151723976, "GMSE01": 2151731456, "GMSP01": 2151696480, "GMSJ0A": 2151676560}, "gpCameraOption": {"type": null, "GMSJ01": 2151723984, "GMSE01": 2151731464, "GMSP01": 2151696488, "GMSJ0A": 2151676568}} \ No newline at end of file diff --git a/parse.py b/parse.py new file mode 100644 index 0000000..e774bd0 --- /dev/null +++ b/parse.py @@ -0,0 +1,50 @@ +import pathlib +import openpyxl +import json + +def parse_hex_value(s): + if type(s) != str: s = str(int(s)) + return int(s, 16) +def prepare_directory(path): + path = pathlib.Path(path) + path.parent.mkdir(parents=True, exist_ok=True) + +''' +r13db = { + 'type': None, + 'GMSJ01': 0x80410AC0, + 'GMSE01': 0x804141C0, + 'GMSP01': 0x8040B960, + 'GMSJ0A': 0x804051A0, +} +''' +def parse_static_variables(wb, out_path): + ws = wb['Static variables'] + itr_row = ws.rows + db = {} + ## Row 1 + row1 = next(itr_row) + colidx = {c.value: ic for ic, c in enumerate(row1)} + ic_name = colidx['Name'] + ic_type = colidx['Type'] + ic_addr = colidx['Absolute address'] + ## Row 2 + row2 = next(itr_row) + versions = ['GMSJ01', 'GMSE01', 'GMSP01', 'GMSJ0A'] # FIXME read from file + ## entries + for row in itr_row: + db[row[ic_name].value] = { + 'type': row[ic_type].value, + **{ + ver: parse_hex_value(row[ic].value) + for ic, ver in enumerate(versions, start=ic_addr) + }, + } + ## write + prepare_directory(out_path) + with open(out_path, 'w') as f: + json.dump(db, f) + +if __name__ == '__main__': + wb = openpyxl.open('SMS RAM Map.xlsx') + parse_static_variables(wb, 'docs/static-variables.json') diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..794cc3d --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +openpyxl