punesemu / puNES

Qt-based Nintendo Entertaiment System emulator and NSF/NSF2/NSFe Music Player (Linux, FreeBSD, OpenBSD and Windows)
GNU General Public License v2.0
597 stars 40 forks source link

[NSFE] Illegal opcode 0xF2@0xEFFE #386

Closed nelsonhef closed 3 months ago

nelsonhef commented 3 months ago

Hi!

The following NSFe file (Kirby's Adventure CRC: b02b8838) doesn't output sound and returns a illegal opcode 0xF2 in the latest WIP (74252dea) and below. Tried all relevant commits down to the 0.111 release and all gave the same error although at different PC. The 0.110 release plays fine.

WIP 74252dea - cpu : alert PC = 0xEFFE, CODEOP = 0xF2 0.111 release - cpu: alert PC = 0xFA39, CODEOP = 0x52 0.110 release - works.

nosound.zip

punesemu commented 3 months ago

Hi @nelsonhef , try with the last WIP.

nelsonhef commented 3 months ago

Hi @punesemu, i tried the latest WIP (a51c9f4) and now the NSFE file produces sound output, but i had another Illegal opcode 0x02@0xA566 while playing Song 0 (Green Fields). I was able to find two ways to reproduce the issue:

punesemu commented 3 months ago

Thx @nelsonhef, can you test the last WIP? P.S. This NSFe executes a JMP $ABS instruction at address 0xFFF9. This instruction occupies 3 bytes and therefore occupies the memory area that goes from 0xFFF9 and 0xFFFB but the addresses 0xFFFA and 0xFFFB should be occupied by the NMI vector and, according to the NSF specifications, are reserved for the player.

nelsonhef commented 3 months ago

Fixed in b6dc62f1. Thank you for the fix and the detailed explanation of the issue.