mirror of
https://github.com/buhman/nds.git
synced 2025-06-18 06:25:40 -04:00

Before this commit, attempting to start the rom on real NDS/DSi hardware would result in the display of a solid white screen, with no apparent evidence of the arm9 program running. After much testing, I found that this issue was directly caused "main mmeory" bus contention. Because arm7 and arm9 are both attempting to read instructions from ewram at the same time, and arm9 bus access stalls completely. I also found that this could not be mitigated with giving arm9 priority in EXMEMCNT. The solution appears to be to relocate arm7 code execution from main/shared memory to an arm7-internal memory. After this commit, the examples now function as intended on real NDS/DSi hardware.
70 lines
2.5 KiB
Python
70 lines
2.5 KiB
Python
import struct
|
|
import sys
|
|
|
|
fields = [
|
|
("game title", 0x000, 0xc),
|
|
("game code", 0x00c, 0x4),
|
|
("maker code", 0x010, 0x2),
|
|
("main unit code", 0x012, 0x1),
|
|
("device type", 0x013, 0x1),
|
|
("device capacity", 0x014, 0x1),
|
|
("reserved 015", 0x015, 0x8),
|
|
("specific", 0x01d, 0x1),
|
|
("rom version", 0x01e, 0x1),
|
|
("reserved 01f", 0x01f, 0x1),
|
|
("arm9 resident module rom offset", 0x020, 0x4),
|
|
("arm9 resident module entry address", 0x024, 0x4),
|
|
("arm9 resident module ram address", 0x028, 0x4),
|
|
("arm9 resident module rom size", 0x02c, 0x4),
|
|
("arm7 resident module rom offset", 0x030, 0x4),
|
|
("arm7 resident module entry address", 0x034, 0x4),
|
|
("arm7 resident module ram address", 0x038, 0x4),
|
|
("arm7 resident module rom size", 0x03c, 0x4),
|
|
("file name table rom offset", 0x040, 0x4),
|
|
("file name table rom size", 0x044, 0x4),
|
|
("file allocation table rom offset", 0x048, 0x4),
|
|
("file allocation table rom size", 0x04c, 0x4),
|
|
("arm9 overlay table rom offset", 0x050, 0x4),
|
|
("arm9 overlay table rom size", 0x054, 0x4),
|
|
("arm7 overlay table rom offset", 0x058, 0x4),
|
|
("arm7 overlay table rom size", 0x05c, 0x4),
|
|
("rom control information 060", 0x060, 0x4),
|
|
("rom control information 064", 0x064, 0x4),
|
|
("banner file rom offset", 0x068, 0x4),
|
|
("secure area crc", 0x06c, 0x2),
|
|
("rom control information 06e", 0x06e, 0x2),
|
|
("arm9 auto load list ram address", 0x070, 0x4),
|
|
("arm7 auto load list ram address", 0x074, 0x4),
|
|
("rom information reserved region", 0x078, 0x8),
|
|
("application", 0x080, 0x4),
|
|
("rom header size", 0x084, 0x4),
|
|
("arm9 module parameter address", 0x088, 0x4),
|
|
("arm7 module parameter address", 0x08c, 0x4),
|
|
]
|
|
|
|
with open(sys.argv[1], 'rb') as f:
|
|
buf = f.read()
|
|
|
|
file_offset = 0
|
|
|
|
for name, offset, size in fields:
|
|
assert offset == file_offset, (hex(offset), hex(file_offset))
|
|
file_offset += size
|
|
pad = ' ' * (35 - len(name))
|
|
print(f"{name}: {pad}", end='')
|
|
if size < 16:
|
|
for i in range(size):
|
|
b = buf[offset + i]
|
|
print(f'{b:02x}', end='')
|
|
|
|
pad = ' ' * (17 * 2 - size * 2)
|
|
if name in {'game title', 'game code'}:
|
|
print(pad, buf[offset:offset+size], end='')
|
|
elif size == 4:
|
|
n, = struct.unpack('<I', buf[offset:offset+size])
|
|
print(pad, f"0x{n:08x}", end='')
|
|
elif size == 2:
|
|
n, = struct.unpack('<H', buf[offset:offset+size])
|
|
print(pad, f"0x{n:04x}", end='')
|
|
print()
|