fceux icon indicating copy to clipboard operation
fceux copied to clipboard

Vs. System emulation problems

Open ClusterM opened this issue 4 years ago • 0 comments

Yesterday I was romhacking Vs. System (Vs. UniSystem) game and I ran into a bunch of problems.

There are no messages about header fixes.

Mapper, mirroring, and other info automatically fixed based on MD5 in https://github.com/TASVideos/fceux/blob/34290e747af3853405f82607f4847d31529d0a79/src/vsuni.cpp#L299 But it's done without any messages! The https://github.com/TASVideos/fceux/blob/34290e747af3853405f82607f4847d31529d0a79/src/ines.cpp#L279 function does the same thing for non-Vs games but it uses FCEU_printf() to notify a user about header changes. I spent an hour trying to understand why the mapper number in the header is totally ignored.

I think that it's better to move all checksum checks from FCEU_VSUniCheck() to CheckHInfo() and use the same code to output messages about the header fixes.

There are no error messages when a user trying to insert a coin or toggle a DIP switch for a non Vs. System game.

I spend much time trying to understand why I can't insert a coin for a hacked ROM.

I think that need to add simple check if (GameInfo->type != GIT_VSUNI) FCEU_DispMessage("Not Vs. System; can't insert coin.", 0); like it's done for FDS controls.

Vs. System flag is totally ignored in the iNES header and even NES 2.0 header.

The only way to emulate Vs. System game is to match hardcoded MD5! Remember, there is no way to know that fceux treaded game as Vs. since there are no messages about it. You can't insert a coin if ROM has not matched hardcoded MD5 and there is no way to know why you can't insert a coin.

I think that need to set GameInfo->type to GIT_VSUNI is "Vs. System" flag is set in the header. At least for NES 2.0. (Are there any iNES dumps with incorrectly set "Vs. System" flag?)

NES 2.0 header PPU field is ignored too.

The solution is very simple: change default_palette_selection variable to the corresponding value if the PPU version is specified in NES 2.0 header. BTW, why RP2C05_004 constant have such a name? It should be RP2C04_004.

There is ancient (and very obscure) code to draw DIP switches on the screen.

https://github.com/TASVideos/fceux/blob/34290e747af3853405f82607f4847d31529d0a79/src/vsuni.cpp#L346 image But it's unreachable code! It's never executed since FCEUI_VSUniToggleDIPView() is unused and DIPS is never changed.

Simple fix:

static int DIPS_howlong = 0;

void FCEU_VSUniToggleDIP(int w) {
	vsdip ^= 1 << w;
	DIPS_howlong = 180;
}

and

void FCEU_VSUniDraw(uint8 *XBuf) {
	uint32 *dest;
	int y, x;

	if (!DIPS_howlong--) return;

Also, it's a good idea to draw message on DIP switch toggle:

void FCEU_VSUniToggleDIP(int w) {
	if (GameInfo->type != GIT_VSUNI) {
		FCEU_DispMessage("Not Vs. System; toggle DIP switch.", 0);
		return;
	}
	vsdip ^= 1 << w;
	DIPS_howlong = 180;
	FCEU_DispMessage("DIP switch %d is %s.", 0, w, vsdip & (1 << w) ? "on" : "off");
}

Unused hotkeys

This is a funny one:

image

Vs. System has no DIP switches 8 and 9. There are only DIP switches 0 to 7. Also, there is no code to check those ghost DIP switches commands:

void FCEU_DoSimpleCommand(int cmd)
{
	switch(cmd)
	{
	case FCEUNPCMD_FDSINSERT: FCEU_FDSInsert();break;
	case FCEUNPCMD_FDSSELECT: FCEU_FDSSelect();break;
	case FCEUNPCMD_VSUNICOIN: FCEU_VSUniCoin(); break;
	case FCEUNPCMD_VSUNIDIP0:
	case FCEUNPCMD_VSUNIDIP0+1:
	case FCEUNPCMD_VSUNIDIP0+2:
	case FCEUNPCMD_VSUNIDIP0+3:
	case FCEUNPCMD_VSUNIDIP0+4:
	case FCEUNPCMD_VSUNIDIP0+5:
	case FCEUNPCMD_VSUNIDIP0+6:
	case FCEUNPCMD_VSUNIDIP0+7:	FCEU_VSUniToggleDIP(cmd - FCEUNPCMD_VSUNIDIP0);break;
	case FCEUNPCMD_POWER: PowerNES();break;
	case FCEUNPCMD_RESET: ResetNES();break;
	}
}

Those two hotkeys are totally unused. It's possible to remove them from FCEUI_CommandTable but backward compatibility with old config files can be broken. Actually, those commands can be replaced with the second coin acceptor and service buttons which are not emulated for now (it's not required by existing games).

The hex editor can't save Vs. System ROM.

Frustrating one. It just doesn't do anything without giving errors: https://github.com/TASVideos/fceux/blob/34290e747af3853405f82607f4847d31529d0a79/src/ines.cpp#L976

I lost an hour of my work, confident that I had saved all the progress. And another hour trying to understand why I can't save it. Vs. System ROMs are fully compatible with iNES/NES 2.0 files, so this line should be replaced to:

if ((GameInfo->type != GIT_CART) && (GameInfo->type != GIT_VSUNI)) return 0;

I can try to fix it all and create a pull request if you okay with it.

ClusterM avatar Jun 14 '21 13:06 ClusterM