In case anyone was wondering, kov2p is not encrypted the same way as kov2. Actually, the code to decrypt it isn't even in MAME.
Anyway...
static const unsigned char kov2p_tab[256] = {
0x44, 0x47, 0xB8, 0x28, 0x03, 0xA2, 0x21, 0xBC, 0x17, 0x32, 0x4E, 0xE2, 0xDF, 0x69, 0x35, 0xC7,
0xA2, 0x06, 0xEC, 0x36, 0xD2, 0x44, 0x12, 0x6A, 0x8D, 0x51, 0x6B, 0x20, 0x69, 0x01, 0xCA, 0xF0,
0x71, 0xC4, 0x34, 0xDC, 0x6B, 0xD6, 0x42, 0x2A, 0x5D, 0xB5, 0xC7, 0x6F, 0x4F, 0xD8, 0xB3, 0xED,
0x51, 0x9E, 0x37, 0x1E, 0xC0, 0x85, 0x2A, 0x91, 0xC6, 0x9C, 0xAC, 0xF5, 0x20, 0x3B, 0x09, 0x74,
0x24, 0xF1, 0xE0, 0x42, 0x02, 0xBE, 0x84, 0x75, 0x4A, 0x82, 0xA2, 0x17, 0xAE, 0xB6, 0x24, 0x79,
0x0A, 0x5A, 0x56, 0xCB, 0xA1, 0x2E, 0x47, 0xEA, 0xA9, 0x25, 0x73, 0x79, 0x0B, 0x17, 0x9E, 0x33,
0x64, 0xB6, 0x03, 0x7F, 0x4F, 0xC3, 0xAE, 0x45, 0xE6, 0x82, 0x27, 0x01, 0x86, 0x6B, 0x50, 0x16,
0xD3, 0x22, 0x90, 0x64, 0xFC, 0xA9, 0x31, 0x1C, 0x41, 0xD5, 0x07, 0xD3, 0xB2, 0xFE, 0x53, 0xD6,
0x39, 0xFB, 0xE6, 0xBE, 0xDA, 0x4D, 0x8A, 0x44, 0x3A, 0x9B, 0x9D, 0x56, 0x5E, 0x5F, 0xFF, 0x6A,
0xB6, 0xDE, 0x2F, 0x12, 0x5A, 0x5D, 0xB0, 0xD0, 0x93, 0x92, 0xB2, 0x2C, 0x9D, 0x59, 0xEE, 0x05,
0xAB, 0xA8, 0xD2, 0x25, 0x2C, 0xC5, 0xDE, 0x18, 0x4D, 0xB6, 0x4E, 0x3D, 0xBF, 0xFA, 0xF9, 0x1D,
0xBA, 0x76, 0x79, 0xFC, 0x42, 0xB2, 0x8C, 0xAE, 0xA9, 0x45, 0xBA, 0xAC, 0x55, 0x8E, 0x38, 0x67,
0xC3, 0xA5, 0x0D, 0xDC, 0xCC, 0x91, 0x73, 0x69, 0x27, 0xBC, 0x80, 0xDF, 0x30, 0xA4, 0x05, 0xD8,
0xE7, 0xD2, 0xB7, 0x4B, 0x3C, 0x10, 0x8C, 0x5D, 0x8A, 0xD7, 0x68, 0x7A, 0x61, 0x07, 0xF9, 0xA5,
0x88, 0xDA, 0xDF, 0x0C, 0x42, 0x1B, 0x11, 0xE0, 0xD1, 0x93, 0x7C, 0x63, 0x39, 0xC5, 0xED, 0x43,
0x46, 0xDB, 0x30, 0x26, 0xD0, 0xDF, 0x7A, 0x86, 0x3E, 0x2E, 0x04, 0xBF, 0x49, 0x2A, 0xF9, 0x66
};
void pgm_kov2p_decrypt()
{
unsigned short *rom = (unsigned short*)USER0;
for (int i = 0; i < 0x200000 / 2; i++) {
int x = kov2p_tab[(i >> 1) & 0xff] << 8;
if ((i & 0x040080) != 0x000080) x |= 0x0001;
if ((i & 0x004008) == 0x004008) x |= 0x0002;
if ((i & 0x080030) == 0x080010) x |= 0x0004;
if ((i & 0x000242) != 0x000042) x |= 0x0008;
if ((i & 0x008100) == 0x008000) x |= 0x0010;
if ((i & 0x002004) != 0x000004) x |= 0x0020;
if ((i & 0x011800) != 0x010000) x |= 0x0040;
if ((i & 0x000820) == 0x000820) x |= 0x0080;
rom[i] ^= x;
}
}
Nebula also patches the external arm7 rom with these:
static void kov2pHack()
{
unsigned char *src = USER0;
src[0x4ED8] = 0xA8;// B0
src[0x4EDC] = 0x9C;// A4
src[0x4EE0] = 0x5C;// 64
src[0x4EE4] = 0x94;// 9C
src[0x4EE8] = 0xE8;// F0
src[0x4EEC] = 0x6C;// 74
src[0x4EF0] = 0xD4;// DC
src[0x4EF4] = 0x50;// 58
src[0x4EF8] = 0x80;// 88
src[0x4EFC] = 0x9C;// A4
src[0x4F00] = 0x28;// 30
src[0x4F04] = 0x30;// 38
src[0x4F08] = 0x34;// 3C
src[0x4F0C] = 0x1C;// 24
}
Still doesn't mean it works in FBA or MAME though...