vgmrips

The forum about vgm files
It is currently 2017-11-23, 20:34:24

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 2017-05-08, 0:23:00 

Contributors Contributors
Smack talkers Smack talkers
Offline

Joined: 2016-12-27, 3:21:40
Posts: 54
Many .NSF files available online fail to include the initialization of the SOFTCLK ($4017) register, potentially causing triangle channel notes to be played incorrectly, among other subtle problems.

I noticed this while creating a pack of Wizards & Warriors, where this makes quite an audible difference. When creating a pack from a .NSF file, be sure to always check whether the game writes something to $4017, and if it does, check whether the .NSF from that game does as well, and if not, then add that instruction to the .NSF file yourself, or look for a "fixed" version of that .NSF, for example on this website.

I have not checked how many existing packs are affected, but if they are, it should be possible to fix them by just adding the appropriate write to the beginning of each .VGM file.


Last edited by NewRisingSun2 on 2017-05-08, 18:31:16, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: 2017-05-08, 8:01:10 

Staff Staff
Programmers Programmers
Musicians Musicians
Contributors Contributors
Offline
User avatar

Joined: 2011-12-01, 20:20:07
Posts: 2853
Location: Germany
Looking at vgm_trim, the register write is probably missing in next to all tracks due to being trimmed off.
I just added it to the list of important commands that vgm_trim restores when trimming them off.

(Most of the VGM tools were written based on the current MAME emulation cores at that time and the MAME NES APU core doesn't do anything with the step_mode variable, so I didn't consider it being important.)

tl;dr: I assume that next to none of the packs has SOFTCLK register writes unless the sound driver resends it when starting a new song.


Top
 Profile  
 
 Post subject:
PostPosted: 2017-05-08, 18:33:09 

Contributors Contributors
Smack talkers Smack talkers
Offline

Joined: 2016-12-27, 3:21:40
Posts: 54
Apparently, value $00 is the default value, so only games that write $80 or $C0 would need to have their packs updated.

Here is the same song with the $4017 write, and with only that write removed.


Attachments:
Wizards&Warriors-Potion_With4017.vgm [2.09 KiB]
Downloaded 17 times
Wizards&Warriors-Potion_Without4017.vgm [2.09 KiB]
Downloaded 16 times
Top
 Profile  
 
 Post subject:
PostPosted: 2017-05-13, 7:36:43 

Contributors Contributors
Smack talkers Smack talkers
Offline

Joined: 2016-12-27, 3:21:40
Posts: 54
vgm4017 adds the $4017 write with the value given as the first command line argument in hexadecimal notation to the beginning of each of a set of .VGM or .VGZ files. If the .VGM file already contains a $4017 write, no changes are made to that file.

Example: vgm4017 C0 *.vgz

Unlike the vgm tools, vgm4017 always overwrites files, so keep a backup.

To find out the correct $4017 value for a game, load the game in FCEUX, set a write trap to 4017 in its debugger, and run the game until a write is made. Press "Run" at least a second time to make sure you catch the last $4017 write, not the first one, which may be just a clearing of the entire address space to $00.

Some games do not write to $4017 at all; their .VGMs of course should then contain no such write either. Nintendo's first-party games interestingly write to $4017 during every vblank, so vgm4017 is not needed for them. Most games however write to $4017 only at bootup and then never again; vgm4017 is for them. Famicom Disk System games usually don't write anything to $4017, as the FDS BIOS writes $C0 to the register every time the disk is accessed. This needs to be replicated in FDS .VGM files.

Note that the lack/presence of a $4017 write will only make an audible difference if the game sets $4017 to $80 or $C0 (as the default value seems to be $00), and uses APU envelopes instead of manually setting volumes during each tick of its playback handler.


Attachments:
vgm4017.zip [25.43 KiB]
Downloaded 17 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group