Updated nintendo_ds.py and main.py
main.py - added `Game revision` (DSi only) and info pages. nintendo_ds.py - added `gamerevision` and `region`
This commit is contained in:
parent
fe72c33c5e
commit
3b7e291904
2 changed files with 28 additions and 1 deletions
11
main.py
11
main.py
|
@ -7,7 +7,7 @@ logger = Logger('RomInfo')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) == 2:
|
if len(sys.argv) == 2:
|
||||||
if sys.argv[1].endswith('.nds'):
|
if sys.argv[1].endswith('.nds') or sys.argv[1].endswith('.ids'):
|
||||||
with open(sys.argv[1], mode='rb') as nds:
|
with open(sys.argv[1], mode='rb') as nds:
|
||||||
logger.info('Title : {}'.format(nds_get_info('title', nds)))
|
logger.info('Title : {}'.format(nds_get_info('title', nds)))
|
||||||
logger.info('Game code : {}'.format(nds_get_info('gamecode', nds)))
|
logger.info('Game code : {}'.format(nds_get_info('gamecode', nds)))
|
||||||
|
@ -15,5 +15,14 @@ if __name__ == '__main__':
|
||||||
logger.info('Unit code : {}'.format(nds_get_info('unitcode', nds)))
|
logger.info('Unit code : {}'.format(nds_get_info('unitcode', nds)))
|
||||||
logger.info('Encryption seed : {}'.format(nds_get_info('encryptionseed', nds)))
|
logger.info('Encryption seed : {}'.format(nds_get_info('encryptionseed', nds)))
|
||||||
logger.info('Device capacity : {}'.format(nds_get_info('devicecapacity', nds)))
|
logger.info('Device capacity : {}'.format(nds_get_info('devicecapacity', nds)))
|
||||||
|
if 'DSi ' in nds_get_info('unitcode', nds):
|
||||||
|
logger.info('Game revision : {} (DSi only)'.format(nds_get_info('gamerevision', nds)))
|
||||||
|
logger.info('Game region : {}'.format(nds_get_info('region', nds)))
|
||||||
else:
|
else:
|
||||||
logger.error('No ROM specified. App requires one argument.')
|
logger.error('No ROM specified. App requires one argument.')
|
||||||
|
|
||||||
|
# Info taken from:
|
||||||
|
# https://dsibrew.org/wiki/DSi_cartridge_header
|
||||||
|
# https://scenegate.github.io/Ekona/specs/cartridge/header.html
|
||||||
|
# https://problemkaputt.de/gbatek-ds-cartridge-header.htm
|
||||||
|
# https://gist.github.com/pleonex/6265017
|
|
@ -22,6 +22,12 @@ def nds_get_info(opt: str, inf: BinaryIO):
|
||||||
case 'devicecapacity':
|
case 'devicecapacity':
|
||||||
inf.seek(0x014)
|
inf.seek(0x014)
|
||||||
return _capacity_lookup(int.from_bytes(inf.read(1), 'little'))
|
return _capacity_lookup(int.from_bytes(inf.read(1), 'little'))
|
||||||
|
case 'gamerevision':
|
||||||
|
inf.seek(0x01C)
|
||||||
|
return str(int.from_bytes(inf.read(2), 'little'))
|
||||||
|
case 'region':
|
||||||
|
inf.seek(0x01D)
|
||||||
|
return _region_lookup(int.from_bytes(inf.read(1), 'little'))
|
||||||
case _:
|
case _:
|
||||||
return 'Unknown'
|
return 'Unknown'
|
||||||
|
|
||||||
|
@ -53,3 +59,15 @@ def _capacity_lookup(code: int) -> str: # 512Mbit (67108864 bytes) (09h)
|
||||||
return '{} MB ({})'.format(round(128 * pow(2, code) / 1024), '{}h'.format(str(code).zfill(2)))
|
return '{} MB ({})'.format(round(128 * pow(2, code) / 1024), '{}h'.format(str(code).zfill(2)))
|
||||||
case _:
|
case _:
|
||||||
return 'Unknown ({})'.format(code)
|
return 'Unknown ({})'.format(code)
|
||||||
|
|
||||||
|
|
||||||
|
def _region_lookup(code: int) -> str:
|
||||||
|
match code:
|
||||||
|
case 0:
|
||||||
|
return 'All (0x00 (0))'
|
||||||
|
case 64:
|
||||||
|
return 'Korea (0x40 (64))'
|
||||||
|
case 128:
|
||||||
|
return 'China (0x80 (128))'
|
||||||
|
case _:
|
||||||
|
return 'Unknown ({})'.format(code)
|
||||||
|
|
Loading…
Add table
Reference in a new issue