Skip to content

GEMS2MID and GEMSPlay: Two more problematic games

Technical discussion about the VGM format, and all the software you need to handle VGM files.

Moderator: Staff

  • SeregaZ Offline
  • Posts: 98
  • Joined: 2015-08-08, 13:56:52

Post by SeregaZ »

it just ticket was registered will be enough - to know about that was readed. but when no any actions - who knows - maybe it just ignored. so now i am see: no need to worry and check this forum every hour and it was readed.
  • SeregaZ Offline
  • Posts: 98
  • Joined: 2015-08-08, 13:56:52

Post by SeregaZ »

holy level of ValleyBell is going down in my eyes :) so many bugs... you sure any other VB incorporated software organisation programms no have bugs? :)
that retrigger problem, ok... that is fixed, but it was!
sample loop with $75 sample's flag
psg problem
and now new one - volume problem. Comix Zone 003 track is plays not correct. i thought it was Ch3mode problem - it have turn on flag with instrument, but probably it send to wrong channel - not 3... but probably is not. i check - it lays in a 3 channel as is should be. so now i think it is volume problem. it is not obey volume command and play too loud.

i cant find where is in a code place, where depends algoritms is happen changes for volume.
this is instrument setting?

Code: Select all

static void WRITEFM(const UINT8* InsList, UINT8 Bank, UINT8 Channel)
{
	const UINT8* RegList;	// Register BC
	UINT8 CurReg;
	UINT8 CurData;
	UINT8 NoteAtt;
	
	RegList = FMADDRTBL;
	while(*RegList)	// (0 = EOT)
	{
		CurReg = *RegList;
		RegList ++;
		
		//while(YM2612_Read(0) & 0x80)	// spin on busy bit
		//	;
		
		CurReg += Channel;				// add voice num to point at correct register
		YM2612_Write(Bank, CurReg);
		CurData = *RegList;				// get data offset
		if (CurData)					// if data offset 0, just write 0
		{
			if (CurData & 0x80)			// msb indicates total level values
			{
				CurData &= 0x7F;
				if (CARRIERS & 0x01)	// is this a carrier?
				{
					CurData = 127 - InsList[CurData];
					NoteAtt = ((CurData << 1) * noteon.atten) >> 8;
					CurData -= NoteAtt;	// reduce by attenuation amount
					CurData = 127 - CurData;
				}
				else					// no - normal output
				{
					//nottl0:
					//nottl:
					CurData = InsList[CurData];	// (IX+dataoffset)
				}
				CARRIERS >>= 1;			// [the best way to simulate RR + JP NC]
			}
			else
			{
				//nottl:
				CurData = InsList[CurData];	// (IX+dataoffset)
			}
		}
		
		//writefm0:
		YM2612_Write(Bank + 1, CurData);
		RegList ++;
	}
	
	return;
}
especialy this place is scary me: NoteAtt = ((CurData << 1) * noteon.atten) >> 8; - what happen here - i have no idea :)

i cant find place with somekind of this code:

Code: Select all

Select Algorithm
  Case 0 to 3
    ; only 4 operator TL + Mastervolume + Volume
  Case 4
    ; only 2 and 4 (but not sure about order 1, 3, 2, 4 - probably not 2 and 4, but 3 и 4)
  Case 5, 6
    ; only 2, 3, 4
  Case 7
    ; all 4 operators
Endselect
where it is? can it have some bug? for example - send volume to wrong channel and that is why it sounds too loud? i am attach gems banks and rom for tests. it need to be start with Gens - wrong playing, and with Fusion - correct playing. GEMSPlay works as Gens playing - that hihat or whatever FM Ch3mode sound at begin - play too loud.

what buttons i need to press for GEMSPlay to make VGM log to see what happen in that playing? i am press V - but it says no file something like that. i dont know how to set file name for vgm file to save it.
Attachments
comixzone.zip
(26.57 KiB) Downloaded 272 times
  • SeregaZ Offline
  • Posts: 98
  • Joined: 2015-08-08, 13:56:52

Post by SeregaZ »

my comrade ask me to post it here:
https://github.com/infval/GEMSPlay/comm ... 21d1276598

and for fm2612.c:

Code: Select all

OPN->fn_max = (UINT32)( (double)0x20000 * freqbase * (1<<(FREQ_SH-10)) / 4.4);
maybe you have some proffesional remarks, because i am no have any idea what happen here, he is more smart then me, but anyway we not sure about our fixes.
  • SeregaZ Offline
  • Posts: 98
  • Joined: 2015-08-08, 13:56:52

Post by SeregaZ »

aaa... and something about "phase overflow".
  • SeregaZ Offline
  • Posts: 98
  • Joined: 2015-08-08, 13:56:52

Post by SeregaZ »

UINT8 LoopID = 0; inside void PreparseGemsSeq(UINT8 SongNo). variable LoopID is not inizilis...howitnames, but used.
  • SeregaZ Offline
  • Posts: 98
  • Joined: 2015-08-08, 13:56:52

Post by SeregaZ »

and it need to cut 7 bit from value, that is Ch3mode for instrument. because it makes some gitter or noise after playing. for Nightmare Circus 019 and 020 tracks this Ch3mode value have $FF value. it is not correct, because ym2612 $27 register cant have 7 bit value - it is illegal. only up to 6th bit.
https://www.smspower.org/maxim/Documents/YM2612#reg27
that Nightmare Circus is sets this illegal value and chip start make noice.
  • User avatar
  • ValleyBell Offline
  • Posts: 4810
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

I finally found some time and had a look at all the bug reports.
I also started a GitHub repository that contains the current version of the GEMSPlay source code. (There is no EXE release for now - might do one at a later date.)
  • DAC looping is fixed now (based on the original Z80 assembly source - had it already fixed when you posted a link to infval's repo)
  • Your "Select Algorithm" is done by doing bit checks on the CARRIERS variable. In Z80 ASM, this is faster then checking for 0..3, 4, 5..6 and 7 separately.
  • VGMs are written into a folder called "dumps" that must be in the current directory.
    I just made a fix in the Git repo, so that the folder is created automatically when enabling VGM logging.
  • The problem with Comix Zone is unfortunately an emulation related. That particular instrument requires the YM2612 to be emulated at its native sample rate, 53267 Hz.
    However due to the way GEMSPlay is written, it can only be emulated at 44100 Hz. (This is also what Gens usually does.)
    Thus, the bug won't go away unless GEMSPlay gets a major rewrite regarding audio processing.
  • Bit 7 from the value for register $27 will be kept for now, because GEMSPlay aims at an accurate reproduction of the original GEMS sound engine and this bug is present in the original as well.
Thanks for posting infval's GEMSPlay repo, btw. It made me notice a few additional bugs left.
Feel free to invite him to the vgmrips IRC, in case he has questions about GEMSPlay or other GEMS related stuff.

About bugs in general:
Every software has bugs. The reason for such obvious bugs in GEMSPlay is just the lack of testing.
I lost interest in GEMS music shortly after finishing GEMSPlay. I went on to write SMPSPlay instead.
And apparently also nobody used GEMSPlay between 2013 and 2019, so the bugs weren't noticed until now.
  • SeregaZ Offline
  • Posts: 98
  • Joined: 2015-08-08, 13:56:52

Post by SeregaZ »

you sure about that 7th bit? because when it removed - it plays fine. and emulator play fine, but GEMSPlay is not. it add at the end of playing some noise. like some PSG noise channel do :) and it is change noise frequency with different cases.

and as i can see - Gens have some bug playing of this rom - it plays twice. but Fusion play once. (attach have rom for tests, and GEMS banks for GEMSPlay test. what exactly version of GEMSPlay - i dont know... for our version we just cut that bit and it plays fine. i think for more sure it need to test what value GEMS is send for that $27 inside Fusion to know sure - it send $FF, or cut it into $7F)
Attachments
gitter.zip
(62.3 KiB) Downloaded 266 times
  • SeregaZ Offline
  • Posts: 98
  • Joined: 2015-08-08, 13:56:52

Post by SeregaZ »

The problem with Comix Zone is unfortunately an emulation related. That particular instrument requires the YM2612 to be emulated at its native sample rate, 53267 Hz.
However due to the way GEMSPlay is written, it can only be emulated at 44100 Hz. (This is also what Gens usually does.)
Thus, the bug won't go away unless GEMSPlay gets a major rewrite regarding audio processing.
what do you think for changing this place:

Code: Select all

OPN->fn_max = (UINT32)( (double)0x20000 * freqbase * (1<<(FREQ_SH-10)) );
into this one:

Code: Select all

OPN->fn_max = (UINT32)( (double)0x20000 * freqbase * (1<<(FREQ_SH-10)) / 4.5);
(first time it was 4.4, but after your comment it comes more clear so 4.4 is going to 4.5)
  • User avatar
  • ValleyBell Offline
  • Posts: 4810
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

Yes, I'm sure about Reg 27 Bit 7.
I used Kega Fusion to log a VGM of that ROM you attached and it sounds the same as the VGM logged with GEMSPlay.

I also converted the VGM logs to text and they match. (except for additional "wait" commands in the Fusion log)

Kega Fusion VGM log:

Code: Select all

0x0000042A: 50 FF       SN76496:	Latch/Data: Volume Ch 3 -> 0xF = 0%
0x0000042C: 61 40 05    Wait:	1344 samples (   30.48 ms)	(total	112710 (00:02.56))
0x0000042F: 52 27 FF    YM2612:		CSM Mode: Enable, 3 Slot Mode: Enable, Enable Timer: AB, Timer IRQ Enable: AB, Reset Timer Status: AB
0x00000432: 72          Wait:	 3 sample(s) (   0.07 ms)	(total	112713 (00:02.56))
0x00000433: 52 22 0B    YM2612:		Low Frequency Oscillator: 6.37 Hz
0x00000436: 71          Wait:	 2 sample(s) (   0.05 ms)	(total	112715 (00:02.56))
0x00000437: 52 B2 08    YM2612:		Ch 2 Feedback: PI / 16, Algorithm: 0
GEMSPlay VGM log:

Code: Select all

0x00000046: 50 FF       SN76496:	Latch/Data: Volume Ch 3 -> 0xF = 0%
0x00000048: 62          Wait:	735 samples (1/60 s)	(total	735 (00:00.02))
0x00000049: 62          Wait:	735 samples (1/60 s)	(total	1470 (00:00.03))
0x0000004A: 52 27 FF    YM2612:		CSM Mode: Enable, 3 Slot Mode: Enable, Enable Timer: AB, Timer IRQ Enable: AB, Reset Timer Status: AB
0x0000004D: 52 22 0B    YM2612:		Low Frequency Oscillator: 6.37 Hz
0x00000050: 52 B2 08    YM2612:		Ch 2 Feedback: PI / 16, Algorithm: 0
Thus I conclude that this is a bug of the original sound data and it just gets hidden by Kega Fusion in some way.

I don't intend to touch the actual YM2612 sound emulation. I have no idea what sort of additional/unintended side effects the change of that fn_max value may cause.
  • SeregaZ Offline
  • Posts: 98
  • Joined: 2015-08-08, 13:56:52

Post by SeregaZ »

about that noise - one comrade is give some idea - to send into 0x27 register 0 value, after finish playing. but i think to cut that 7th bit was right. what if that sound is not as single sfx, but part of melody? and it is note, pause, note? that pause probably will have noise sound.
  • SeregaZ Offline
  • Posts: 98
  • Joined: 2015-08-08, 13:56:52

Post by SeregaZ »

why rom plays fine, but GEMSPlay is not, when order of command a little wrong?

original sfx:

Code: Select all

 SECTION HEADER
 dc.b 1
 dc.t channel_0

 SECTION CODE
channel_0:
 delay 0
 patch patch_06
 priority 79
 volume 27
 loop $7F
 delay 0
 nop
 duration 24
 note $33
 delay 24
 loopend
 eos
we need this part:
duration 24
note $33
delay 24

theory duration and delay need to be near each other.
duration 24
delay 24
note $33

with this orders all play fine. but it have some pulse playing. first variant play as line - no pulse. but GEMSPlay cant play it. attach have this "line" version. rom file too for emulator tests.

this is 038 track (sfx) for Super Battle Tank - War in the Gulf.
Attachments
038.zip
(62.25 KiB) Downloaded 274 times
  • User avatar
  • ValleyBell Offline
  • Posts: 4810
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

It does not play in GEMSPlay, because you are crashing the sound driver.

The "delay 24" command has no effect, because "loopend" does not cause additional delays.
So you have only a "nop" (with delay 0) and a "note" (again with delay 0).
You end up with an infinite loop that keeps playing the same note over and over.
The only reason it plays in the emulator is, that emulation time advances between the note being retriggered.
As you're crashing the sound driver, GEMSPlay won't be able to render any sound. And in the emulator you won't be able to even pause the sound driver.

(Having a detection for such things in GEMSPlay would be nice though.)
Post Reply