Skip to content

[TUTORIAL] porting romsets from hbmame #7

@barbudreadmon

Description

@barbudreadmon

So i wanted to sync kof98pfe with the hbmame version (having a hack of a hack just to get it working is no good, i won't keep it in the core if it's not fixed), and i thought it would be a good idea to open an issue that might become a reference for @SumavisionQ5 or whoever who want to add support for more hacks in the future.

First, here is the original romset from hbmame :

ROM_START( kof98pfe ) // px,s1,m1,c1,2,7,8 confirmed
	ROM_REGION( 0x720000, "maincpu", 0 )
	ROM_LOAD16_WORD_SWAP( "242pfe.p1", 0x000000, 0x100000, CRC(23876d95) SHA1(1e3bcd98d861618fa8b02503f1c8d342d6d45768) )
	ROM_LOAD16_WORD_SWAP( "242pfe.p2", 0x100000, 0x400000, CRC(adbaa852) SHA1(afcc76da85c0598e6f5c96ad112c458a4ed59941) )
	ROM_LOAD16_WORD_SWAP( "242pfe.p3", 0x700000, 0x020000, CRC(930ea34e) SHA1(8eb58c20a6854a8feba454ef280147eb1319c0c5) )
	// patch out protection
	ROM_FILL(0x701af4,1,0x4e)
	ROM_FILL(0x701af5,1,0x71)
	ROM_FILL(0x701b18,1,0x60)
	ROM_FILL(0x701ca2,1,0x60)

	NEO_SFIX_128K( "242pfe.s1", CRC(7f4dbf23) SHA1(bce6dcea6dc40d4072afe67682c7dacde2edce8d) )

	NEO_BIOS_AUDIO_256K( "242-mg1.m1", CRC(4e7a6b1b) SHA1(b54d08f88713ed0271aa06f9f7c9c572ef555b1a) )

	ROM_REGION( 0x1000000, "ymsnd", 0 )
	ROM_LOAD( "242.v1", 0x000000, 0x400000, CRC(b9ea8051) SHA1(49606f64eb249263b3341b4f50cc1763c390b2af) )
	ROM_LOAD( "242.v2", 0x400000, 0x400000, CRC(cc11106e) SHA1(d3108bc05c9bf041d4236b2fa0c66b013aa8db1b) )
	ROM_LOAD( "242.v3", 0x800000, 0x400000, CRC(044ea4e1) SHA1(062a2f2e52098d73bc31c9ad66f5db8080395ce8) )
	ROM_LOAD( "242.v4", 0xc00000, 0x400000, CRC(7985ea30) SHA1(54ed5f0324de6164ea81943ebccb3e8d298368ec) )

	ROM_REGION( 0x4000000, "sprites", 0 )
	ROM_LOAD16_BYTE( "242hx73.c1", 0x0000000, 0x800000, CRC(379654a5) SHA1(fe5d9f1d3072ac83224382abd7f371cf065a8366) )
	ROM_LOAD16_BYTE( "242hx73.c2", 0x0000001, 0x800000, CRC(9c71fa3d) SHA1(1ccbab3378aeef5445fa73d6c59b93c6f9d65557) )
	ROM_LOAD16_BYTE( "242.c3", 0x1000000, 0x800000, CRC(22127b4f) SHA1(bd0d00f889d9da7c6ac48f287d9ed8c605ae22cf) )
	ROM_LOAD16_BYTE( "242.c4", 0x1000001, 0x800000, CRC(0b4fa044) SHA1(fa13c3764fae6b035a626601bc43629f1ebaaffd) )
	ROM_LOAD16_BYTE( "242.c5", 0x2000000, 0x800000, CRC(9d10bed3) SHA1(4d44addc7c808649bfb03ec45fb9529da413adff) )
	ROM_LOAD16_BYTE( "242.c6", 0x2000001, 0x800000, CRC(da07b6a2) SHA1(9c3f0da7cde1ffa8feca89efc88f07096e502acf) )
	ROM_LOAD16_BYTE( "242pfe.c7", 0x3000000, 0x800000, CRC(02f09b2e) SHA1(f72246873e425f4b78c453f30b78eabc5a244fd3) )
	ROM_LOAD16_BYTE( "242pfe.c8", 0x3000001, 0x800000, CRC(d43ab3e6) SHA1(90fbc49c687245fcde1b3e58289b3b0728dc6b0c) )
ROM_END

I think there are 2 difficulties in this romset, which weren't handled correctly in the present implementation from @SumavisionQ5 (hence the modified 242pfe.p2 and 242pfe.p3 files).
The first one is that the 2 files aren't contiguous in memory (hence the 2M padding), iirc the correct way to do this would be more like this (updated with latest version + some comments) :

static struct BurnRomInfo kof98pfeRomDesc[] = {
	{ "242pfe.p1",  0x100000, 0x23876d95, 1 | BRF_ESS | BRF_PRG }, //  1 68K code
	{ "242pfe.p2",  0x400000, 0xadbaa852, 1 | BRF_ESS | BRF_PRG }, //  1 68K code
	{ "242pfe.p3",  0x020000, 0x930ea34e, 1 | BRF_ESS | BRF_PRG }, //  1 68K code

	{ "242pfe.s1",  0x020000, 0x7f4dbf23, 2 | BRF_GRA },           //  2 Text layer tiles / TC531000

	{ "242hx73.c1", 0x800000, 0x379654a5, 3 | BRF_GRA },           //  3 Sprite data
	{ "242hx73.c2", 0x800000, 0x9c71fa3d, 3 | BRF_GRA },           //  4 
	{ "242.c3",     0x800000, 0x22127b4f, 3 | BRF_GRA },           //  5 
	{ "242.c4",     0x800000, 0x0b4fa044, 3 | BRF_GRA },           //  6 
	{ "242.c5",     0x800000, 0x9d10bed3, 3 | BRF_GRA },           //  7 
	{ "242.c6",     0x800000, 0xda07b6a2, 3 | BRF_GRA },           //  8 
	{ "242pfe.c7",  0x800000, 0x02f09b2e, 3 | BRF_GRA },           //  9 
	{ "242pfe.c8",  0x800000, 0xd43ab3e6, 3 | BRF_GRA },           // 10 

	{ "242-mg1.m1", 0x040000, 0x4e7a6b1b, 4 | BRF_ESS | BRF_PRG }, // 11 Z80 code

	{ "242.v1",     0x400000, 0xb9ea8051, 5 | BRF_SND },           // 12 Sound data
	{ "242.v2",     0x400000, 0xcc11106e, 5 | BRF_SND },           // 13 
	{ "242.v3",     0x400000, 0x044ea4e1, 5 | BRF_SND },           // 14 
	{ "242.v4",     0x400000, 0x7985ea30, 5 | BRF_SND },           // 15 
};

STDROMPICKEXT(kof98pfe, kof98pfe, neogeo)
STD_ROM_FN(kof98pfe)

static UINT8 *kof98pfeExtraROM;

static void kof98pfeCallback()
{
	BurnLoadRom(Neo68KROMActive + 0x700000, 2, 1); // Third 68k code rom needs to be loaded at the 0x700000 offset
	Neo68KROMActive[0x701af4] = 0x4e; // Soft patching rom
	Neo68KROMActive[0x701af5] = 0x71; // Soft patching rom
	Neo68KROMActive[0x701b18] = 0x60; // Soft patching rom
	Neo68KROMActive[0x701ca2] = 0x60; // Soft patching rom
}

static INT32 kof98pfeInit()
{
	NeoCallbackActive->pInitialise = kof98pfeCallback; // Use this callback when loading the romset

	INT32 nRet = NeoInit();

	if (nRet == 0) {
		kof98pfeExtraROM = (UINT8*)BurnMalloc(0x20000);

		if (BurnLoadRom(kof98pfeExtraROM, 2, 1)) return 1;

		UINT16 *rom = (UINT16*)kof98pfeExtraROM;
		for (INT32 i = 0; i < 0x20000/2; i++) {
			if (rom[i] == 0x4e7d) rom[i] = 0x4e71;
			if (rom[i] == 0x4e7c) rom[i] = 0x4e75;
		}

		rom = (UINT16*)Neo68KROMActive;

		for (INT32 i = 0; i < 0x100000/2; i++) {
			if (rom[i] == 0x4e7d) rom[i] = 0x4e71;
			if (rom[i] == 0x4e7c) rom[i] = 0x4e75;
		}
		
		SekOpen(0);
		SekMapMemory(kof98pfeExtraROM, 0x900000, 0x91ffff, MAP_ROM);
		SekClose();
	}

	return nRet;
}

static INT32 kof98pfeExit()
{
	BurnFree (kof98pfeExtraROM);

	return NeoExit();
}

struct BurnDriver BurnDrvkof98pfe = {
	"kof98pfe", "kof98", "neogeo", NULL, "2017",
	"Kof'98 (Plus Final Edition)(2017-07-23)(Korean board)\0", NULL, "hack", "Miscellaneous",
	NULL, NULL, NULL, NULL,
	BDF_GAME_WORKING | BDF_CLONE | BDF_HACK, 2, HARDWARE_PREFIX_CARTRIDGE | HARDWARE_SNK_NEOGEO, GBF_VSFIGHT, FBF_KOF,
	NULL, kof98pfeRomInfo, kof98pfeRomName, NULL, NULL, NULL, NULL, neogeoInputInfo, neogeoDIPInfo,
	kof98pfeInit, kof98pfeExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
	0x1000,	320, 224, 4, 3
};

@dinkc64 correct me if i'm wrong, but the callback + burnloadrom thing allows to load a rom at a specific offset ? (that's what i used for the kof2k2omg hacks)

The second issue would be the ROM_FILL thing from hbmame, i think it's something like replacing data at a specific offset ? How should i deal with this in fba ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationGuiding lines to do something

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions