init
This commit is contained in:
commit
5b4815f92e
6 changed files with 69 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.venv
|
||||
/SMS RAM Map.xlsx
|
14
README.md
Normal file
14
README.md
Normal 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
1
docs/CNAME
Normal file
|
@ -0,0 +1 @@
|
|||
res.sms.sup39.dev
|
1
docs/static-variables.json
Normal file
1
docs/static-variables.json
Normal file
File diff suppressed because one or more lines are too long
50
parse.py
Normal file
50
parse.py
Normal 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
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
openpyxl
|
Loading…
Reference in a new issue