34 lines
900 B
Python
34 lines
900 B
Python
from typing import BinaryIO
|
|
|
|
|
|
# TODO: Implement hactool to fetch more XCI info
|
|
|
|
def switch_get_info(opt: str, inf: BinaryIO):
|
|
match opt.lower():
|
|
case 'title':
|
|
inf.seek(0x1000)
|
|
return inf.read(0x100)
|
|
case 'capacity':
|
|
inf.seek(0x10D)
|
|
return _get_rom_size(inf.read(0x1))
|
|
case 'magic':
|
|
inf.seek(0x100)
|
|
return inf.read(0x4)
|
|
|
|
|
|
def _get_rom_size(size):
|
|
match size:
|
|
case b'\xfa':
|
|
return '1 GB ({})'.format(size)
|
|
case b'\xf8':
|
|
return '2 GB ({})'.format(size)
|
|
case b'\xf0':
|
|
return '4 GB ({})'.format(size)
|
|
case b'\xe0':
|
|
return '8 GB ({})'.format(size)
|
|
case b'\xe1':
|
|
return '16 GB ({})'.format(size)
|
|
case b'\xe2':
|
|
return '32 GB ({})'.format(size)
|
|
case _:
|
|
return size
|