I finally got a way to fix the triangle channel bug in Ufouria!

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

User avatar
SusiKette
Posts: 138
Joined: Fri Mar 16, 2018 1:52 pm
Location: Finland

Re: I finally got a way to fix the triangle channel bug in Ufouria!

Post by SusiKette » Sat Nov 28, 2020 5:34 am

The NSF for Hebereke (and probably Ufouria too) has two versions of the title screen theme. One with the triangle channel and one without. I was wondering if both exist in the ROM as separate tracks or if the other was added to the NSF manually.
Avatar is pixel art of Noah Prime from Astral Chain

User avatar
UD2
Posts: 2
Joined: Fri Jan 15, 2021 9:02 pm

Re: I finally got a way to fix the triangle channel bug in Ufouria!

Post by UD2 » Fri Jan 22, 2021 11:53 pm

I have a somewhat less hacky fix. The root cause of this issue is a missing command to configure the triangle's linear counter. We can't insert the missing command into the existing music data stream since there's no free space, but there's a few bytes free at the end of the fixed bank right before the interrupt vector that we can use.

To fix it, we first need to redirect the initialization vector to the end of the ROM.
The relevant bytes in the sound initialization table are at $989C within PRG bank 8 (offset $118AC in the .nes file), where the sound driver lives. Change $55 $9A to $60 $FF.

Now, we can write our missing command, followed by a jump command to point the music data stream back at the original start.
The commands we'll be adding are as follows:
$EC $FF: set linear counter setup to constant $FF
$FC $55 $9A: jump to $9A55
Write the above 5 bytes to $FF60 (offset $1FF70 within the .nes file).

The triangle channel will now play the melody correctly!
Attachments
hebereke_triangle_fix.ips
(25 Bytes) Downloaded 22 times

Post Reply