Error in the latest version of FamiTone2?

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

Moderator: Moderators

Post Reply
User avatar
DRW
Posts: 1914
Joined: Sat Sep 07, 2013 2:59 pm

Error in the latest version of FamiTone2?

Post by DRW » Fri Aug 23, 2019 3:44 am

Is it possible that the latest version of FamiTone2 has a bug that wasn't in the old version?

I have always been using the version v1.15 10'15 for my projects. And everything was fine.

Now I tried v1.15 04'17 (the current one). And the music sounds completely off.

I noticed one thing:
The file "famitone2.s" is identical in both versions, except that the new version declares the constants FT_TEMP_SIZE and FT_BASE_SIZE, that it never uses, though. So, the code is exactly the same.

But the text2data tool outputs slightly different data:

Code: Select all

.instruments:
	.db $30 ;instrument $1b
becomes:

Code: Select all

.instruments:
	.db $f0 ;instrument $1b
(This is done in every line where there is an ;instrument xx comment.)

Why does the conversion tool generate different data, even though the actual code that interprets the data hasn't changed at all? Does the code only read the lower nibble of the value $30/$f0, so that the upper nibble is unimportant?

I've attached an FTM file. This sounds fine when I use the older version. But it sounds metallic when I use the latest version. Maybe someone can include it in his own ROM and tell me whether he has the same effect.

By the way, I even included the new song into the demo program that is in the FamiTone zip file. I replaced my own song with one of the existing songs: Same effect in the new version, everything fine in the old version.

You can find the old version of FamiTone2 that I'm using here:
https://web.archive.org/web/20160216023 ... itone2.zip
Attachments
Test.ftm
(20.87 KiB) Downloaded 129 times
Available now: My game "City Trouble".
Sales website: https://megacatstudios.com/products/city-trouble
Gameplay: https://youtu.be/Eee0yurkIW4
Download website: http://www.denny-r-walter.de/city.htm

User avatar
dougeff
Posts: 2628
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Error in the latest version of FamiTone2?

Post by dougeff » Fri Aug 23, 2019 5:57 am

The first byte of an instrument definition is the duty cycle.

These bits should be the duty (the Xs)
xx00 0000

These bits should always be set.
0011 0000

These bits should be zero. (the Xs)
0000 xxxx

Later, this is ORA ed with the volume from the volume envelope.

I'm away from my computer, so I can't look at the file.
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
DRW
Posts: 1914
Joined: Sat Sep 07, 2013 2:59 pm

Re: Error in the latest version of FamiTone2?

Post by DRW » Fri Aug 23, 2019 6:32 am

dougeff wrote:These bits should be the duty (the Xs)
xx00 0000
In this case, the newer text2data tool outputs a different value than the old one:
$30 = %00110000
$F0 = %11110000

Since the actual source code of the FamiTone driver didn't change and since every one of the songs in my ROMs always worked with the older version while a bunch of them sound strange with the new version, I assume the new text2data has a bug.
Either this, or he forgot to ship his "famitone2.asm" file correctly.
Available now: My game "City Trouble".
Sales website: https://megacatstudios.com/products/city-trouble
Gameplay: https://youtu.be/Eee0yurkIW4
Download website: http://www.denny-r-walter.de/city.htm

User avatar
DRW
Posts: 1914
Joined: Sat Sep 07, 2013 2:59 pm

Re: Error in the latest version of FamiTone2?

Post by DRW » Sat Aug 31, 2019 4:39 am

Looks like nobody cares that the latest version of FamiTone2 introduced strange behavior that wasn't there in the previous version. (Including shiru himself who hasn't replied to my mail.)

Well, in case somebody does encounter issues with this driver, let me confirm again that there must be a problem in the text2data tool: The source code ("famitone2.asm"/".s") is the same, yet the text2data tool creates different files.

If I compile my game "City Trouble" by using the new "famitone2.s" (which doesn't make a difference) and the new text2data tool, the music sounds wrong. It sounds fine with the version with which it was originally compiled.
Available now: My game "City Trouble".
Sales website: https://megacatstudios.com/products/city-trouble
Gameplay: https://youtu.be/Eee0yurkIW4
Download website: http://www.denny-r-walter.de/city.htm

User avatar
dougeff
Posts: 2628
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Error in the latest version of FamiTone2?

Post by dougeff » Sat Aug 31, 2019 9:44 am

You could use my build/fork of famitone2 text2data.exe (v1.15)

https://github.com/nesdoug/famitone2d?files=1
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
DRW
Posts: 1914
Joined: Sat Sep 07, 2013 2:59 pm

Re: Error in the latest version of FamiTone2?

Post by DRW » Sat Aug 31, 2019 5:26 pm

Well, the information that there's another version out there doesn't clear up the question whether the current official FamiTone2 from shiru's website is actually buggy or whether I did something wrong or what's up here.

Also, I already said that the previous version of the official FamiTone2 works fine, so it's not like I'm in actual need of anything. It's more about finding out in general what's the deal with the current official version.


Unrelated remark:

I had a look at your "famitone2.s" and this is quite dangerous:

Code: Select all

FT_BASE_ADR		= $0300	;page in the RAM used for FT2 variables, should be $xx00
FT_TEMP			= $fd ;3 bytes in zeropage used by the library as a scratchpad
In cc65, segments are declared via a config file.

In the original FamiTone2, those lines were all commented out. So, a programmer who includes the original code file into his project would get compiler errors because of undefined constants. It is then in his responsibility to define the values in their assembler-specific way.

For example, in a file called "FamiToneWrapper.s", I did this in my source code:

Code: Select all

.segment "ZEROPAGE"
    FT_TEMP: .res 3

.segment "FAMITONE"
    FT_BASE_ADR: .res 186
and in the config file, I had this:

Code: Select all

FAMITONE: load = RAM, type = bss, align = $0100;
BSS:      load = RAM, type = bss;
But your current version simply defines those variables as fixed values inside the "famitone2.s" file itself.
A programmer who includes your file doesn't get an indication that he has to define the variables himself. Instead, your code simply accesses the memory of whatever is located at address $0300 and completely circumvents the config file approach without any warnings.
Available now: My game "City Trouble".
Sales website: https://megacatstudios.com/products/city-trouble
Gameplay: https://youtu.be/Eee0yurkIW4
Download website: http://www.denny-r-walter.de/city.htm

jong21
Posts: 1
Joined: Thu Jan 23, 2020 5:03 am

Re: Error in the latest version of FamiTone2?

Post by jong21 » Thu Jan 23, 2020 5:04 am

DRW wrote:
Fri Aug 23, 2019 3:44 am
Is it possible that the latest version of FamiTone2 has a bug that wasn't in the old version?

I have always been using the version v1.15 10'15 for my projects. And everything was fine.

Now I tried v1.15 04'17 (the current one). And the music sounds completely off.

I noticed one thing:
The file "famitone2.s" is identical in both versions, except that the new version declares the constants FT_TEMP_SIZE and FT_BASE_SIZE, that it never uses, though. So, the code is exactly the same.

But the text2data tool outputs slightly different data:

Code: Select all

.instruments:
	.db $30 ;instrument $1b
becomes:

Code: Select all

.instruments:
	.db $f0 ;instrument $1b
(This is done in every line where there is an ;instrument xx comment.)

Why does the conversion tool generate different data, even though the actual code that interprets the data hasn't changed at all? Does the code only read the lower nibble of the value $30/$f0, so that the upper nibble is unimportant?

I've attached an FTM file. This sounds fine when I use the older version. But it sounds metallic when I use the latest version. Maybe someone can include it in his own ROM and tell me whether he has the same effect.

By the way, I even included the new song into the demo program that is in the FamiTone zip file. I replaced my own song with one of the existing songs: Same effect in the new version, everything fine in the old version.

You can find the old version of FamiTone2 that I'm using here:
https://web.archive.org/web/20160216023 ... itone2.zip
was going through same issue.

Post Reply