retroenv / nesgodisasm

Nintendo Entertainment System ROM disassembler written in Golang
Apache License 2.0
14 stars 2 forks source link

Integer divide by zero #68

Closed LeviLovie closed 1 week ago

LeviLovie commented 1 year ago

I have tried to Disassemble The Legend of Zelda 1. And got an panic: runtime error: integer divide by zero error

I had download v0.2.1 release source code and compile it and ran it for the .nes file: sudo ./nesgodisasm/nesgodisasm -a ca65 -o tloz.asm tloz.nes And got this output:

[------------------------------------]
[ nesgodisasm - NES ROM disassembler ]
[------------------------------------]

2023-07-26 19:19:35  INFO    Build info {"version":"dev built with: go1.20.6"}
2023-07-26 19:19:35  INFO    Processing ROM {"file":"tloz.nes"}
panic: runtime error: integer divide by zero

goroutine 1 [running]:
github.com/retroenv/nesgodisasm/internal.(*Disasm).addressToIndex(...)
    tloz_1_decompile/nesgodisasm/internal/disasm.go:261
github.com/retroenv/nesgodisasm/internal.(*Disasm).readMemory(0x1012b85?, 0xf9a6?)
    tloz_1_decompile/nesgodisasm/internal/memory.go:18 +0x85
github.com/retroenv/nesgodisasm/internal.(*Disasm).readMemoryWord(0xc00010c1b8?, 0xfffa)
    tloz_1_decompile/nesgodisasm/internal/memory.go:28 +0x25
github.com/retroenv/nesgodisasm/internal.(*Disasm).initializeIrqHandlers(0xc0016ac000)
    tloz_1_decompile/nesgodisasm/internal/disasm.go:157 +0x3b
github.com/retroenv/nesgodisasm/internal.New(0xc000054390, 0xc000128070, 0xc000024300)
    tloz_1_decompile/nesgodisasm/internal/disasm.go:103 +0x3f5
main.disasmFile(0xc000054390, 0xc000014300, 0xc000024300)
    tloz_1_decompile/nesgodisasm/main.go:155 +0x305
main.main()
    tloz_1_decompile/nesgodisasm/main.go:45 +0x125

I use this application for the first time, and maybe didn't understand how to use that.

cornelk commented 1 year ago

You are using the tool right (beside the sudo - that should never be needed for this tool) but it lacks support for any mapper beside NROM. I will add a warning to the output if the ROM uses any other mapper.

I started the work for adding multi bank support so please check back in the future for an update that should make it work with Zelda (which uses MMC1)!

LeviLovie commented 1 year ago

Thanks for the reply, I'll wait for the next release :)

cornelk commented 1 week ago

The crash has been fixed in the latest version, multi bank support is still WIP and tracked in #6