This commit is contained in:
sup39 2023-03-13 21:01:56 +09:00
commit 5b4815f92e
6 changed files with 69 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.venv
/SMS RAM Map.xlsx

14
README.md Normal file
View file

@ -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
```

1
docs/CNAME Normal file
View file

@ -0,0 +1 @@
res.sms.sup39.dev

File diff suppressed because one or more lines are too long

50
parse.py Normal file
View file

@ -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')

1
requirements.txt Normal file
View file

@ -0,0 +1 @@
openpyxl