315
src/boards/164.c
315
src/boards/164.c
@@ -41,301 +41,6 @@ static SFORMAT StateRegs[] =
|
|||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static int16 step_size[49] = {
|
|
||||||
16, 17, 19, 21, 23, 25, 28, 31, 34, 37,
|
|
||||||
41, 45, 50, 55, 60, 66, 73, 80, 88, 97,
|
|
||||||
107, 118, 130, 143, 157, 173, 190, 209, 230, 253,
|
|
||||||
279, 307, 337, 371, 408, 449, 494, 544, 598, 658,
|
|
||||||
724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552
|
|
||||||
}; //49 items
|
|
||||||
static int32 step_adj[16] = { -1, -1, -1, -1, 2, 5, 7, 9, -1, -1, -1, -1, 2, 5, 7, 9 };
|
|
||||||
|
|
||||||
//decode stuff
|
|
||||||
static int32 jedi_table[16 * 49];
|
|
||||||
static int32 acc = 0; //ADPCM accumulator, initial condition must be 0
|
|
||||||
static int32 decstep = 0; //ADPCM decoding step, initial condition must be 0
|
|
||||||
|
|
||||||
static void jedi_table_init() {
|
|
||||||
int step, nib;
|
|
||||||
|
|
||||||
for (step = 0; step < 49; step++) {
|
|
||||||
for (nib = 0; nib < 16; nib++) {
|
|
||||||
int value = (2 * (nib & 0x07) + 1) * step_size[step] / 8;
|
|
||||||
jedi_table[step * 16 + nib] = ((nib & 0x08) != 0) ? -value : value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8 decode(uint8 code) {
|
|
||||||
acc += jedi_table[decstep + code];
|
|
||||||
if ((acc & ~0x7ff) != 0) // acc is > 2047
|
|
||||||
acc |= ~0xfff;
|
|
||||||
else acc &= 0xfff;
|
|
||||||
decstep += step_adj[code & 7] * 16;
|
|
||||||
if (decstep < 0) decstep = 0;
|
|
||||||
if (decstep > 48 * 16) decstep = 48 * 16;
|
|
||||||
return (acc >> 8) & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
const EEPROM_interface eeprom_interface. =
|
|
||||||
{
|
|
||||||
9, // address bits 9
|
|
||||||
8, // data bits 8
|
|
||||||
"*110", // read 1 10 aaaaaaaaa
|
|
||||||
"*101", // write 1 01 aaaaaaaaa dddddddd
|
|
||||||
"*10000xxxxxxx", // lock 1 00 00xxxxxxx
|
|
||||||
"*10011xxxxxxx", // unlock 1 00 11xxxxxxx
|
|
||||||
1,
|
|
||||||
5
|
|
||||||
};
|
|
||||||
|
|
||||||
static const EEPROM_interface *intf;
|
|
||||||
|
|
||||||
static int serial_count = 0;
|
|
||||||
static u8 serial_buffer[SERIAL_BUFFER_LENGTH];
|
|
||||||
|
|
||||||
static int eeprom_data_bits;
|
|
||||||
static int eeprom_clock_count;
|
|
||||||
static int eeprom_read_address;
|
|
||||||
static u8 *eeprom_data;
|
|
||||||
|
|
||||||
static int latch = 0;
|
|
||||||
static int locked = 1;
|
|
||||||
static int sending = 0;
|
|
||||||
static int reset_line = ASSERT_LINE;
|
|
||||||
static int clock_line = ASSERT_LINE;
|
|
||||||
static int reset_delay;
|
|
||||||
|
|
||||||
void EEPROM_Init(u8 *data, u8 bit)
|
|
||||||
{
|
|
||||||
eeprom_data = data;
|
|
||||||
if(bit == 8)
|
|
||||||
intf = &eeprom_interface_93C46_8;
|
|
||||||
else
|
|
||||||
intf = &eeprom_interface_93C46_16;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 *EEPROM_GetData()
|
|
||||||
{
|
|
||||||
return eeprom_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int EEPROM_command_match(const char *buf, const char *cmd, int len)
|
|
||||||
{
|
|
||||||
if ( cmd == 0 ) return 0;
|
|
||||||
if ( len == 0 ) return 0;
|
|
||||||
|
|
||||||
for (;len>0;)
|
|
||||||
{
|
|
||||||
char b = *buf;
|
|
||||||
char c = *cmd;
|
|
||||||
|
|
||||||
if ((b==0) || (c==0))
|
|
||||||
return (b==c);
|
|
||||||
|
|
||||||
switch ( c )
|
|
||||||
{
|
|
||||||
case '0':
|
|
||||||
case '1':
|
|
||||||
if (b != c) return 0;
|
|
||||||
case 'X':
|
|
||||||
case 'x':
|
|
||||||
buf++;
|
|
||||||
len--;
|
|
||||||
cmd++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '*':
|
|
||||||
c = cmd[1];
|
|
||||||
switch( c )
|
|
||||||
{
|
|
||||||
case '0':
|
|
||||||
case '1':
|
|
||||||
if (b == c) { cmd++; }
|
|
||||||
else { buf++; len--; }
|
|
||||||
break;
|
|
||||||
default: return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (*cmd==0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void EEPROM_write(int bit)
|
|
||||||
{
|
|
||||||
if (serial_count >= SERIAL_BUFFER_LENGTH-1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
serial_buffer[serial_count++] = (bit ? '1' : '0');
|
|
||||||
serial_buffer[serial_count] = 0;
|
|
||||||
|
|
||||||
if ( (serial_count > intf->address_bits) &&
|
|
||||||
EEPROM_command_match((char*)serial_buffer,intf->cmd_read,(int)strlen((char*)serial_buffer)-intf->address_bits) )
|
|
||||||
{
|
|
||||||
int i,address;
|
|
||||||
|
|
||||||
address = 0;
|
|
||||||
for (i = serial_count-intf->address_bits;i < serial_count;i++)
|
|
||||||
{
|
|
||||||
address <<= 1;
|
|
||||||
if (serial_buffer[i] == '1') address |= 1;
|
|
||||||
}
|
|
||||||
if (intf->data_bits == 16)
|
|
||||||
eeprom_data_bits = (eeprom_data[2*address+0] << 8) + eeprom_data[2*address+1];
|
|
||||||
else
|
|
||||||
eeprom_data_bits = eeprom_data[address];
|
|
||||||
eeprom_read_address = address;
|
|
||||||
eeprom_clock_count = 0;
|
|
||||||
sending = 1;
|
|
||||||
serial_count = 0;
|
|
||||||
}
|
|
||||||
else if ( (serial_count > intf->address_bits) &&
|
|
||||||
EEPROM_command_match((char*)serial_buffer,intf->cmd_erase,(int)strlen((char*)serial_buffer)-intf->address_bits) )
|
|
||||||
{
|
|
||||||
int i,address;
|
|
||||||
|
|
||||||
address = 0;
|
|
||||||
for (i = serial_count-intf->address_bits;i < serial_count;i++)
|
|
||||||
{
|
|
||||||
address <<= 1;
|
|
||||||
if (serial_buffer[i] == '1') address |= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (locked == 0)
|
|
||||||
{
|
|
||||||
if (intf->data_bits == 16)
|
|
||||||
{
|
|
||||||
eeprom_data[2*address+0] = 0x00;
|
|
||||||
eeprom_data[2*address+1] = 0x00;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
eeprom_data[address] = 0x00;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
serial_count = 0;
|
|
||||||
}
|
|
||||||
else if ( (serial_count > (intf->address_bits + intf->data_bits)) &&
|
|
||||||
EEPROM_command_match((char*)serial_buffer,intf->cmd_write,(int)strlen((char*)serial_buffer)-(intf->address_bits + intf->data_bits)) )
|
|
||||||
{
|
|
||||||
int i,address,data;
|
|
||||||
|
|
||||||
address = 0;
|
|
||||||
for (i = serial_count-intf->data_bits-intf->address_bits;i < (serial_count-intf->data_bits);i++)
|
|
||||||
{
|
|
||||||
address <<= 1;
|
|
||||||
if (serial_buffer[i] == '1') address |= 1;
|
|
||||||
}
|
|
||||||
data = 0;
|
|
||||||
for (i = serial_count-intf->data_bits;i < serial_count;i++)
|
|
||||||
{
|
|
||||||
data <<= 1;
|
|
||||||
if (serial_buffer[i] == '1') data |= 1;
|
|
||||||
}
|
|
||||||
if (locked == 0)
|
|
||||||
{
|
|
||||||
if (intf->data_bits == 16)
|
|
||||||
{
|
|
||||||
eeprom_data[2*address+0] = data >> 8;
|
|
||||||
eeprom_data[2*address+1] = data & 0xff;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
eeprom_data[address] = data;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
serial_count = 0;
|
|
||||||
}
|
|
||||||
else if ( EEPROM_command_match((char*)serial_buffer,intf->cmd_lock,(int)strlen((char*)serial_buffer)) )
|
|
||||||
{
|
|
||||||
locked = 1;
|
|
||||||
serial_count = 0;
|
|
||||||
}
|
|
||||||
else if ( EEPROM_command_match((char*)serial_buffer,intf->cmd_unlock,(int)strlen((char*)serial_buffer)) )
|
|
||||||
{
|
|
||||||
locked = 0;
|
|
||||||
serial_count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void EEPROM_reset()
|
|
||||||
{
|
|
||||||
serial_count = 0;
|
|
||||||
sending = 0;
|
|
||||||
reset_delay = intf->reset_delay;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EEPROM_set_cs_line(int state)
|
|
||||||
{
|
|
||||||
reset_line = state;
|
|
||||||
|
|
||||||
if (reset_line != CLEAR_LINE)
|
|
||||||
EEPROM_reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EEPROM_set_clock_line(int state)
|
|
||||||
{
|
|
||||||
if (state == PULSE_LINE || (clock_line == CLEAR_LINE && state != CLEAR_LINE))
|
|
||||||
{
|
|
||||||
if (reset_line == CLEAR_LINE)
|
|
||||||
{
|
|
||||||
if (sending)
|
|
||||||
{
|
|
||||||
if (eeprom_clock_count == intf->data_bits)
|
|
||||||
{
|
|
||||||
if(intf->enable_multi_read)
|
|
||||||
{
|
|
||||||
eeprom_read_address = (eeprom_read_address + 1) & ((1 << intf->address_bits) - 1);
|
|
||||||
if (intf->data_bits == 16)
|
|
||||||
eeprom_data_bits = (eeprom_data[2*eeprom_read_address+0] << 8) + eeprom_data[2*eeprom_read_address+1];
|
|
||||||
else
|
|
||||||
eeprom_data_bits = eeprom_data[eeprom_read_address];
|
|
||||||
eeprom_clock_count = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sending = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
eeprom_data_bits = (eeprom_data_bits << 1) | 1;
|
|
||||||
eeprom_clock_count++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
EEPROM_write(latch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clock_line = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void EEPROM_write_bit(int bit)
|
|
||||||
{
|
|
||||||
latch = bit;
|
|
||||||
}
|
|
||||||
|
|
||||||
int EEPROM_read_bit(void)
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
|
|
||||||
if (sending)
|
|
||||||
res = (eeprom_data_bits >> intf->data_bits) & 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (reset_delay > 0)
|
|
||||||
{
|
|
||||||
reset_delay--;
|
|
||||||
res = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void Sync(void) {
|
static void Sync(void) {
|
||||||
setprg8r(0x10, 0x6000, 0);
|
setprg8r(0x10, 0x6000, 0);
|
||||||
setprg32(0x8000, (reg[0] << 4) | (reg[1] & 0xF));
|
setprg32(0x8000, (reg[0] << 4) | (reg[1] & 0xF));
|
||||||
@@ -351,7 +56,7 @@ static DECLFR(ReadLow) {
|
|||||||
case 0x5100: return reg[2] | reg[0] | reg[1] | (reg[3] ^ 0xff); break;
|
case 0x5100: return reg[2] | reg[0] | reg[1] | (reg[3] ^ 0xff); break;
|
||||||
case 0x5500:
|
case 0x5500:
|
||||||
if (trigger)
|
if (trigger)
|
||||||
return reg[2] | reg[1]; // Lei Dian Huang Bi Ka Qiu Chuan Shuo (NJ046) may broke other games
|
return reg[2] | reg[1]; /* Lei Dian Huang Bi Ka Qiu Chuan Shuo (NJ046) may broke other games */
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -367,8 +72,8 @@ static void M163HB(void) {
|
|||||||
setchr4(0x0000, 1);
|
setchr4(0x0000, 1);
|
||||||
setchr4(0x1000, 1);
|
setchr4(0x1000, 1);
|
||||||
}
|
}
|
||||||
/*
|
#if 0
|
||||||
if(scanline>=127) // Hu Lu Jin Gang (NJ039) (Ch) [!] don't like it
|
if(scanline>=127) /* Hu Lu Jin Gang (NJ039) (Ch) [!] don't like it */
|
||||||
{
|
{
|
||||||
setchr4(0x0000,1);
|
setchr4(0x0000,1);
|
||||||
setchr4(0x1000,1);
|
setchr4(0x1000,1);
|
||||||
@@ -378,7 +83,7 @@ static void M163HB(void) {
|
|||||||
setchr4(0x0000,0);
|
setchr4(0x0000,0);
|
||||||
setchr4(0x1000,0);
|
setchr4(0x1000,0);
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,14 +137,14 @@ static DECLFW(Write2) {
|
|||||||
trigger ^= 1;
|
trigger ^= 1;
|
||||||
}
|
}
|
||||||
laststrobe = V;
|
laststrobe = V;
|
||||||
} else if (A == 0x5100 && V == 6) //damn thoose protected games
|
} else if (A == 0x5100 && V == 6) /* damn thoose protected games */
|
||||||
setprg32(0x8000, 3);
|
setprg32(0x8000, 3);
|
||||||
else
|
else
|
||||||
switch (A & 0x7300) {
|
switch (A & 0x7300) {
|
||||||
case 0x5200: /*FCEU_printf("%04x %02x (5000 = %02x)\n", A, V, reg[1]); */ reg[0] = V; WSync(); break;
|
case 0x5200: reg[0] = V; WSync(); break;
|
||||||
case 0x5000: reg[1] = V; WSync(); if (!(reg[1] & 0x80) && (scanline < 128)) setchr8(0); /* setchr8(0); */ break;
|
case 0x5000: reg[1] = V; WSync(); if (!(reg[1] & 0x80) && (scanline < 128)) setchr8(0); /* setchr8(0); */ break;
|
||||||
case 0x5300: /*FCEU_printf("%04x %02x (5000 = %02x)\n", A, V, reg[1]);*/ reg[2] = V; break;
|
case 0x5300: reg[2] = V; break;
|
||||||
case 0x5100: /*FCEU_printf("%04x %02x (5000 = %02x)\n", A, V, reg[1]);*/ reg[3] = V; /*pcmwrite(0x4011, (decode(reg[0]) & 0xf) << 3);*/ WSync(); break;
|
case 0x5100: reg[3] = V; WSync(); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,8 +166,6 @@ void Mapper163_Init(CartInfo *info) {
|
|||||||
WSync = Sync;
|
WSync = Sync;
|
||||||
GameHBIRQHook = M163HB;
|
GameHBIRQHook = M163HB;
|
||||||
|
|
||||||
// jedi_table_init();
|
|
||||||
|
|
||||||
WRAMSIZE = 8192;
|
WRAMSIZE = 8192;
|
||||||
WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE);
|
WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE);
|
||||||
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
|
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
|
||||||
@@ -492,7 +195,7 @@ static void Sync3(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static DECLFW(Write3) {
|
static DECLFW(Write3) {
|
||||||
// FCEU_printf("bs %04x %02x\n",A,V);
|
/* FCEU_printf("bs %04x %02x\n",A,V); */
|
||||||
reg[(A >> 8) & 3] = V;
|
reg[(A >> 8) & 3] = V;
|
||||||
WSync();
|
WSync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ static SFORMAT StateRegs[] =
|
|||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
#if 0
|
||||||
|
|
||||||
cmd[0] = response on/off
|
cmd[0] = response on/off
|
||||||
0x00 - on
|
0x00 - on
|
||||||
@@ -82,7 +82,8 @@ _MANAGE_CHANNEL: .BYTE 0,$70, 0, 0, 8
|
|||||||
byte_8CE5: .BYTE 0,$74, 0, 0,$12
|
byte_8CE5: .BYTE 0,$74, 0, 0,$12
|
||||||
byte_8C29: .BYTE 0,$76, 0, 0, 8
|
byte_8C29: .BYTE 0,$76, 0, 0, 8
|
||||||
byte_8CC6: .BYTE 0,$78, 0, 0,$12
|
byte_8CC6: .BYTE 0,$78, 0, 0,$12
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
static uint8 sim0reset[0x1F] = {
|
static uint8 sim0reset[0x1F] = {
|
||||||
0x3B, 0xE9, 0x00, 0xFF, 0xC1, 0x10, 0x31, 0xFE,
|
0x3B, 0xE9, 0x00, 0xFF, 0xC1, 0x10, 0x31, 0xFE,
|
||||||
@@ -91,6 +92,8 @@ static uint8 sim0reset[0x1F] = {
|
|||||||
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10
|
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static void Sync(void) {
|
static void Sync(void) {
|
||||||
setprg32(0x8000, prg_reg);
|
setprg32(0x8000, prg_reg);
|
||||||
setchr8(chr_reg);
|
setchr8(chr_reg);
|
||||||
@@ -107,11 +110,11 @@ static DECLFW(M216WriteHi) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static DECLFW(M216Write5000) {
|
static DECLFW(M216Write5000) {
|
||||||
// FCEU_printf("WRITE: %04x:%04x (PC=%02x cnt=%02x)\n",A,V,X.PC,sim0bcnt);
|
/* FCEU_printf("WRITE: %04x:%04x (PC=%02x cnt=%02x)\n",A,V,X.PC,sim0bcnt); */
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLFR(M216Read5000) {
|
static DECLFR(M216Read5000) {
|
||||||
// FCEU_printf("READ: %04x PC=%04x out=%02x byte=%02x cnt=%02x bit=%02x\n",A,X.PC,sim0out,sim0byte,sim0bcnt,sim0bit);
|
/* FCEU_printf("READ: %04x PC=%04x out=%02x byte=%02x cnt=%02x bit=%02x\n",A,X.PC,sim0out,sim0byte,sim0bcnt,sim0bit); */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ static const unsigned char default_inst[15][8] = {
|
|||||||
|
|
||||||
/* AM speed(Hz) and depth(dB) */
|
/* AM speed(Hz) and depth(dB) */
|
||||||
#define AM_SPEED 3.7
|
#define AM_SPEED 3.7
|
||||||
//#define AM_DEPTH 4.8
|
/* #define AM_DEPTH 4.8 */
|
||||||
#define AM_DEPTH 2.4
|
#define AM_DEPTH 2.4
|
||||||
|
|
||||||
/* Cut the lower b bit(s) off. */
|
/* Cut the lower b bit(s) off. */
|
||||||
@@ -545,7 +545,7 @@ static void maketables(uint32 c, uint32 r) {
|
|||||||
makeTllTable();
|
makeTllTable();
|
||||||
makeRksTable();
|
makeRksTable();
|
||||||
makeSinTable();
|
makeSinTable();
|
||||||
//makeDefaultPatch ();
|
/* makeDefaultPatch (); */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r != rate) {
|
if (r != rate) {
|
||||||
@@ -595,7 +595,7 @@ void OPLL_reset(OPLL * opll) {
|
|||||||
|
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
opll->key_status[i] = 0;
|
opll->key_status[i] = 0;
|
||||||
//setPatch (opll, i, 0);
|
/* setPatch (opll, i, 0); */
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 0x40; i++)
|
for (i = 0; i < 0x40; i++)
|
||||||
|
|||||||
@@ -46,55 +46,58 @@ static void BMCFK23CCW(uint32 A, uint8 V) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//some games are wired differently, and this will need to be changed.
|
/* some games are wired differently, and this will need to be changed.
|
||||||
//all the WXN games require prg_bonus = 1, and cah4e3's multicarts require prg_bonus = 0
|
* all the WXN games require prg_bonus = 1, and cah4e3's multicarts require prg_bonus = 0
|
||||||
//we'll populate this from a game database
|
* we'll populate this from a game database
|
||||||
|
*/
|
||||||
static int prg_mask;
|
static int prg_mask;
|
||||||
static int prg_bonus = 1;
|
static int prg_bonus = 1;
|
||||||
|
|
||||||
//prg_bonus = 0
|
/*
|
||||||
//4-in-1 (FK23C8021)[p1][!].nes
|
* prg_bonus = 0
|
||||||
//4-in-1 (FK23C8033)[p1][!].nes
|
* 4-in-1 (FK23C8021)[p1][!].nes
|
||||||
//4-in-1 (FK23C8043)[p1][!].nes
|
* 4-in-1 (FK23C8033)[p1][!].nes
|
||||||
//4-in-1 (FK23Cxxxx, S-0210A PCB)[p1][!].nes
|
* 4-in-1 (FK23C8043)[p1][!].nes
|
||||||
|
* 4-in-1 (FK23Cxxxx, S-0210A PCB)[p1][!].nes
|
||||||
|
|
||||||
//prg_bonus = 1
|
* prg_bonus = 1
|
||||||
//[m176]大富翁2-上海大亨.wxn.nes
|
* [m176]大富翁2-上海大亨.wxn.nes
|
||||||
//[m176]宠物翡翠.fix.nes
|
* [m176]宠物翡翠.fix.nes
|
||||||
//[m176]格兰帝亚.wxn.nes
|
* [m176]格兰帝亚.wxn.nes
|
||||||
//[m176]梦幻之星.wxn.nes
|
* [m176]梦幻之星.wxn.nes
|
||||||
//[m176]水浒神兽.fix.nes
|
* [m176]水浒神兽.fix.nes
|
||||||
//[m176]西楚霸王.fix.nes
|
* [m176]西楚霸王.fix.nes
|
||||||
//[m176]超级大富翁.wxn.nes
|
* [m176]超级大富翁.wxn.nes
|
||||||
//[m176]雄霸天下.wxn.nes
|
* [m176]雄霸天下.wxn.nes
|
||||||
|
|
||||||
//works as-is under virtuanes m176
|
* works as-is under virtuanes m176
|
||||||
//[m176]三侠五义.wxn.nes
|
* [m176]三侠五义.wxn.nes
|
||||||
//[m176]口袋金.fix.nes
|
* [m176]口袋金.fix.nes
|
||||||
//[m176]爆笑三国.fix.nes
|
* [m176]爆笑三国.fix.nes
|
||||||
|
|
||||||
//needs other tweaks
|
* needs other tweaks
|
||||||
//[m176]三国忠烈传.wxn.nes
|
* [m176]三国忠烈传.wxn.nes
|
||||||
//[m176]破釜沉舟.fix.nes
|
* [m176]破釜沉舟.fix.nes
|
||||||
|
*/
|
||||||
|
|
||||||
static uint64 CartList[] =
|
static uint64 CartList[] =
|
||||||
{
|
{
|
||||||
0x1606b8c2aff8d942LL, // 4-in-1 (BS-8088) [p1][!].nes
|
0x1606b8c2aff8d942LL, /* 4-in-1 (BS-8088) [p1][!].nes */
|
||||||
0x62b51b108a01d2beLL, // 4-in-1 (FK23C8021) [p1][!].nes
|
0x62b51b108a01d2beLL, /* 4-in-1 (FK23C8021) [p1][!].nes */
|
||||||
0xa37eb9163e001a46LL, // 4-in-1 (FK23C8026) [p1][!].nes
|
0xa37eb9163e001a46LL, /* 4-in-1 (FK23C8026) [p1][!].nes */
|
||||||
0x8bb48490d8d22711LL, // 4-in-1 (FK23C8033) [p1][!].nes
|
0x8bb48490d8d22711LL, /* 4-in-1 (FK23C8033) [p1][!].nes */
|
||||||
0xc75888d7b48cd378LL, // 4-in-1 (FK23C8043) [p1][!].nes
|
0xc75888d7b48cd378LL, /* 4-in-1 (FK23C8043) [p1][!].nes */
|
||||||
0xde5ce25860233f7eLL, // 4-in-1 (FK23C8045) [p1][!].nes
|
0xde5ce25860233f7eLL, /* 4-in-1 (FK23C8045) [p1][!].nes */
|
||||||
0x8b6c9fc7769a5500LL, // 4-in-1 (FK23C8052) [p1][!].nes
|
0x8b6c9fc7769a5500LL, /* 4-in-1 (FK23C8052) [p1][!].nes */
|
||||||
0x5b3aa4cdc484a088LL, // 4-in-1 (FK23C8056) [p1][!].nes
|
0x5b3aa4cdc484a088LL, /* 4-in-1 (FK23C8056) [p1][!].nes */
|
||||||
0x497344d14c308a1aLL, // 4-in-1 (FK23C8078) (Ch) [p1].nes
|
0x497344d14c308a1aLL, /* 4-in-1 (FK23C8078) (Ch) [p1].nes */
|
||||||
0x9342bf9bae1c798aLL, // 4-in-1 (FK23C8079) [p1][!].nes
|
0x9342bf9bae1c798aLL, /* 4-in-1 (FK23C8079) [p1][!].nes */
|
||||||
0xf81a376fa54fdd69LL, // 4-in-1 (FK23Cxxxx, S-0210A PCB)[p1][!].nes
|
0xf81a376fa54fdd69LL, /* 4-in-1 (FK23Cxxxx, S-0210A PCB)[p1][!].nes */
|
||||||
0x8fd9c235957a6df0LL, // 5-in-1 (K5003) [p1][!]-1125) (Ch).nes
|
0x8fd9c235957a6df0LL, /* 5-in-1 (K5003) [p1][!]-1125) (Ch).nes */
|
||||||
0x0315924d00dd7807LL, // Mortal Kombat 30 Peoples (DH1043) (Ch).nes
|
0x0315924d00dd7807LL, /* Mortal Kombat 30 Peoples (DH1043) (Ch).nes */
|
||||||
0x4b99c39fdb66128aLL, // 4-in-1 (FK23C8078) (Ch) [p1][U][!].unf
|
0x4b99c39fdb66128aLL, /* 4-in-1 (FK23C8078) (Ch) [p1][U][!].unf */
|
||||||
0x22a0ba5743191778LL, // Rockman 4 MI (Hack)
|
0x22a0ba5743191778LL, /* Rockman 4 MI (Hack) */
|
||||||
0 /* Abandon all hope if the game has 0 in the lower 64-bits of its MD5 hash */
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
int DetectPRGbonus(CartInfo *tmp) {
|
int DetectPRGbonus(CartInfo *tmp) {
|
||||||
@@ -115,8 +118,8 @@ int DetectPRGbonus(CartInfo *tmp) {
|
|||||||
static void BMCFK23CPW(uint32 A, uint8 V) {
|
static void BMCFK23CPW(uint32 A, uint8 V) {
|
||||||
/* Modified (c)May 2017 - Backport older implementations from FCEUmm
|
/* Modified (c)May 2017 - Backport older implementations from FCEUmm
|
||||||
* to support big sized FK23CA carts which broke in latest commits.
|
* to support big sized FK23CA carts which broke in latest commits.
|
||||||
*/
|
*/
|
||||||
uint32 bank = (EXPREGS[1] & 0x1F);
|
/* uint32 bank = (EXPREGS[1] & 0x1F); */
|
||||||
uint32 hiblock = ((EXPREGS[0] & 8) << 4) | ((EXPREGS[0] & 0x80) << 1) | (UNIFchrrama ? ((EXPREGS[2] & 0x40) << 3) : 0);
|
uint32 hiblock = ((EXPREGS[0] & 8) << 4) | ((EXPREGS[0] & 0x80) << 1) | (UNIFchrrama ? ((EXPREGS[2] & 0x40) << 3) : 0);
|
||||||
uint32 block = (EXPREGS[1] & 0x60) | hiblock;
|
uint32 block = (EXPREGS[1] & 0x60) | hiblock;
|
||||||
uint32 extra = (EXPREGS[3] & 2);
|
uint32 extra = (EXPREGS[3] & 2);
|
||||||
@@ -134,7 +137,7 @@ static void BMCFK23CPW(uint32 A, uint8 V) {
|
|||||||
uint32 blocksize = (6) - (EXPREGS[0] & 3);
|
uint32 blocksize = (6) - (EXPREGS[0] & 3);
|
||||||
uint32 mask = (1 << blocksize) - 1;
|
uint32 mask = (1 << blocksize) - 1;
|
||||||
V &= mask;
|
V &= mask;
|
||||||
//V &= 63; //? is this a good idea?
|
/* V &= 63; */ /* ??? is this a good idea? */
|
||||||
V |= EXPREGS[1] << 1;
|
V |= EXPREGS[1] << 1;
|
||||||
setprg8(A, (V | (hiblock << 1)));
|
setprg8(A, (V | (hiblock << 1)));
|
||||||
} else
|
} else
|
||||||
@@ -163,8 +166,9 @@ static DECLFW(BMCFK23CHiWrite) {
|
|||||||
FixMMC3CHR(MMC3_cmd);
|
FixMMC3CHR(MMC3_cmd);
|
||||||
} else
|
} else
|
||||||
if (A < 0xC000) {
|
if (A < 0xC000) {
|
||||||
if (UNIFchrrama) { // hacky... strange behaviour, must be bit scramble due to pcb layot restrictions
|
if (UNIFchrrama) { /* hacky... strange behaviour, must be bit scramble due to pcb layot restrictions
|
||||||
// check if it not interfer with other dumps
|
* check if it not interfer with other dumps
|
||||||
|
*/
|
||||||
if ((A == 0x8000) && (V == 0x46))
|
if ((A == 0x8000) && (V == 0x46))
|
||||||
V = 0x47;
|
V = 0x47;
|
||||||
else if ((A==0x8000) && (V == 0x47))
|
else if ((A==0x8000) && (V == 0x47))
|
||||||
@@ -182,14 +186,18 @@ static DECLFW(BMCFK23CWrite) {
|
|||||||
int remap = 0;
|
int remap = 0;
|
||||||
EXPREGS[A & 3] = V;
|
EXPREGS[A & 3] = V;
|
||||||
|
|
||||||
//sometimes writing to reg0 causes remappings to occur. we think the 2 signifies this.
|
/* sometimes writing to reg0 causes remappings to occur. we think the 2 signifies this.
|
||||||
//if not, 0x24 is a value that is known to work
|
* if not, 0x24 is a value that is known to work
|
||||||
//however, the low 4 bits are known to control the mapping mode, so 0x20 is more likely to be the immediate remap flag
|
* however, the low 4 bits are known to control the mapping mode,
|
||||||
|
* so 0x20 is more likely to be the immediate remap flag
|
||||||
|
*/
|
||||||
remap |= ((EXPREGS[0] & 0xF0) == 0x20);
|
remap |= ((EXPREGS[0] & 0xF0) == 0x20);
|
||||||
|
|
||||||
//this is an actual mapping reg. i think reg0 controls what happens when reg1 is written. anyway, we have to immediately remap these
|
/* this is an actual mapping reg. i think reg0 controls what happens
|
||||||
|
* when reg1 is written. anyway, we have to immediately remap these
|
||||||
|
*/
|
||||||
remap |= (A & 3) == 1;
|
remap |= (A & 3) == 1;
|
||||||
//this too.
|
/* this too. */
|
||||||
remap |= (A & 3) == 2;
|
remap |= (A & 3) == 2;
|
||||||
|
|
||||||
if (remap) {
|
if (remap) {
|
||||||
@@ -200,15 +208,20 @@ static DECLFW(BMCFK23CWrite) {
|
|||||||
|
|
||||||
if (is_BMCFK23CA)
|
if (is_BMCFK23CA)
|
||||||
if(EXPREGS[3] & 2)
|
if(EXPREGS[3] & 2)
|
||||||
EXPREGS[0] &= ~7; // hacky hacky! if someone wants extra banking, then for sure doesn't want mode 4 for it! (allow to run A version boards on normal mapper)
|
EXPREGS[0] &= ~7; /* hacky hacky! if someone wants extra banking,
|
||||||
|
* then for sure doesn't want mode 4 for it!
|
||||||
|
* (allow to run A version boards on normal mapper)
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BMCFK23CReset(void) {
|
static void BMCFK23CReset(void) {
|
||||||
//NOT NECESSARY ANYMORE
|
/* !NOT NECESSARY ANYMORE!
|
||||||
//this little hack makes sure that we try all the dip switch settings eventually, if we reset enough
|
*
|
||||||
// dipswitch++;
|
* this little hack makes sure that we try all the dip switch settings eventually, if we reset enough
|
||||||
// dipswitch&=7;
|
* dipswitch++;
|
||||||
//printf("BMCFK23C dipswitch set to %d\n",dipswitch);
|
* dipswitch&=7;
|
||||||
|
* printf("BMCFK23C dipswitch set to %d\n",dipswitch);
|
||||||
|
*/
|
||||||
|
|
||||||
EXPREGS[0] = EXPREGS[1] = EXPREGS[2] = EXPREGS[3] = 0;
|
EXPREGS[0] = EXPREGS[1] = EXPREGS[2] = EXPREGS[3] = 0;
|
||||||
EXPREGS[4] = EXPREGS[5] = EXPREGS[6] = EXPREGS[7] = 0xFF;
|
EXPREGS[4] = EXPREGS[5] = EXPREGS[6] = EXPREGS[7] = 0xFF;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ static uint8 cmd, mirr, regs[11];
|
|||||||
static uint8 rmode, IRQmode, IRQCount, IRQa, IRQLatch;
|
static uint8 rmode, IRQmode, IRQCount, IRQa, IRQLatch;
|
||||||
|
|
||||||
static void (*cwrap)(uint32 A, uint8 V);
|
static void (*cwrap)(uint32 A, uint8 V);
|
||||||
static void (*mwrap)(uint8 V);
|
|
||||||
static int _isM158;
|
static int _isM158;
|
||||||
|
|
||||||
static SFORMAT StateRegs[] = {
|
static SFORMAT StateRegs[] = {
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ static uint16 latcha;
|
|||||||
static uint8 *flashdata;
|
static uint8 *flashdata;
|
||||||
static uint32 *flash_write_count;
|
static uint32 *flash_write_count;
|
||||||
static uint8 *FlashPage[32];
|
static uint8 *FlashPage[32];
|
||||||
static uint32 *FlashWriteCountPage[32];
|
/* static uint32 *FlashWriteCountPage[32]; */
|
||||||
static uint8 flashloaded = 0;
|
/* static uint8 flashloaded = 0; */
|
||||||
|
|
||||||
static uint8 flash_save=0, flash_state=0, flash_mode=0, flash_bank;
|
static uint8 flash_save=0, flash_state=0, flash_mode=0, flash_bank;
|
||||||
static void (*WLSync)(void);
|
static void (*WLSync)(void);
|
||||||
@@ -184,7 +184,7 @@ static void UNROM512LSync() {
|
|||||||
flash_state=0;
|
flash_state=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(flash_mode==1) //Chip Erase or Sector Erase
|
else if(flash_mode==1) /* Chip Erase or Sector Erase */
|
||||||
{
|
{
|
||||||
if(latche==0x30)
|
if(latche==0x30)
|
||||||
{
|
{
|
||||||
@@ -196,12 +196,12 @@ static void UNROM512LSync() {
|
|||||||
uint32 i;
|
uint32 i;
|
||||||
for(i=0;i<(ROM_size*4);i++)
|
for(i=0;i<(ROM_size*4);i++)
|
||||||
inc_flash_write_count(i>>2,i<<12);
|
inc_flash_write_count(i>>2,i<<12);
|
||||||
memset(flashdata,0xFF,ROM_size*0x4000); //Erasing the rom chip as instructed. Crash rate calulated to be 99.9% :)
|
memset(flashdata,0xFF,ROM_size*0x4000); /* Erasing the rom chip as instructed. Crash rate calulated to be 99.9% :) */
|
||||||
}
|
}
|
||||||
flash_state=0;
|
flash_state=0;
|
||||||
flash_mode=0;
|
flash_mode=0;
|
||||||
}
|
}
|
||||||
else if(flash_mode==2) //Byte Program
|
else if(flash_mode==2) /* Byte Program */
|
||||||
{
|
{
|
||||||
if(!GetFlashWriteCount(flash_bank,latcha))
|
if(!GetFlashWriteCount(flash_bank,latcha))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,13 +87,13 @@ static DECLFW(VRC24Write) {
|
|||||||
A &= 0xF003;
|
A &= 0xF003;
|
||||||
if ((A >= 0xB000) && (A <= 0xE003)) {
|
if ((A >= 0xB000) && (A <= 0xE003)) {
|
||||||
if (UNIFchrrama)
|
if (UNIFchrrama)
|
||||||
big_bank = (V & 8) << 2; // my personally many-in-one feature ;) just for support pirate cart 2-in-1
|
big_bank = (V & 8) << 2; /* my personally many-in-one feature ;) just for support pirate cart 2-in-1 */
|
||||||
else {
|
else {
|
||||||
uint16 i = ((A >> 1) & 1) | ((A - 0xB000) >> 11);
|
uint16 i = ((A >> 1) & 1) | ((A - 0xB000) >> 11);
|
||||||
uint16 nibble = ((A & 1) << 2);
|
uint16 nibble = ((A & 1) << 2);
|
||||||
chrreg[i] = (chrreg[i] & (0xF0 >> nibble)) | ((V & 0xF) << nibble);
|
chrreg[i] = (chrreg[i] & (0xF0 >> nibble)) | ((V & 0xF) << nibble);
|
||||||
if (nibble)
|
if (nibble)
|
||||||
chrhi[i] = (V & 0x10) << 4; // another one many in one feature from pirate carts
|
chrhi[i] = (V & 0x10) << 4; /* another one many in one feature from pirate carts */
|
||||||
}
|
}
|
||||||
Sync();
|
Sync();
|
||||||
} else
|
} else
|
||||||
@@ -131,29 +131,39 @@ static DECLFW(VRC24Write) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static DECLFW(M21Write) {
|
static DECLFW(M21Write) {
|
||||||
A = (A & 0xF000) | ((A >> 1) & 0x3); // Ganbare Goemon Gaiden 2 - Tenka no Zaihou (J) [!] isn't mapper 21 actually,
|
A = (A & 0xF000) | ((A >> 1) & 0x3) | ((A >> 6) & 0x3); /* Ganbare Goemon Gaiden 2 - Tenka no Zaihou (J) [!] is Mapper 21*/
|
||||||
// it's mapper 23 by wirings
|
|
||||||
VRC24Write(A, V);
|
VRC24Write(A, V);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLFW(M22Write) {
|
static DECLFW(M22Write) {
|
||||||
if ((A >= 0xC004) && (A <= 0xC007)) { // Ganbare Goemon Gaiden does strange things!!! at the end credits
|
#if 0
|
||||||
weirdo = 1; // quick dirty hack, seems there is no other games with such PCB, so
|
/* Removed this hack, which was a bug in actual game cart.
|
||||||
// we never know if it will not work for something else lol
|
* http://forums.nesdev.com/viewtopic.php?f=3&t=6584
|
||||||
|
*/
|
||||||
|
if ((A >= 0xC004) && (A <= 0xC007)) { /* Ganbare Goemon Gaiden does strange things!!! at the end credits
|
||||||
|
weirdo = 1; * quick dirty hack, seems there is no other games with such PCB, so
|
||||||
|
* we never know if it will not work for something else lol
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
A |= ((A >> 2) & 0x3); // It's just swapped lines from 21 mapper
|
#endif
|
||||||
//
|
A |= ((A >> 2) & 0x3); /* It's just swapped lines from 21 mapper
|
||||||
|
*/
|
||||||
VRC24Write((A & 0xF000) | ((A >> 1) & 1) | ((A << 1) & 2), V);
|
VRC24Write((A & 0xF000) | ((A >> 1) & 1) | ((A << 1) & 2), V);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLFW(M23Write) {
|
static DECLFW(M23Write) {
|
||||||
A |= ((A >> 2) & 0x3) | ((A >> 4) & 0x3) | ((A >> 6) & 0x3);// actually there is many-in-one mapper source, some pirate or
|
A |= ((A >> 2) & 0x3) | ((A >> 4) & 0x3); /* actually there is many-in-one mapper source, some pirate or
|
||||||
// licensed games use various address bits for registers
|
* licensed games use various address bits for registers
|
||||||
|
*/
|
||||||
VRC24Write(A, V);
|
VRC24Write(A, V);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M21Power(void) {
|
static void M21Power(void) {
|
||||||
Sync();
|
Sync();
|
||||||
|
setprg8r(0x10, 0x6000, 0);
|
||||||
|
SetReadHandler(0x6000, 0x7FFF, CartBR);
|
||||||
|
SetWriteHandler(0x6000, 0x7FFF, CartBW);
|
||||||
|
FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM);
|
||||||
SetReadHandler(0x8000, 0xFFFF, CartBR);
|
SetReadHandler(0x8000, 0xFFFF, CartBR);
|
||||||
SetWriteHandler(0x8000, 0xFFFF, M21Write);
|
SetWriteHandler(0x8000, 0xFFFF, M21Write);
|
||||||
}
|
}
|
||||||
@@ -167,8 +177,9 @@ static void M22Power(void) {
|
|||||||
static void M23Power(void) {
|
static void M23Power(void) {
|
||||||
big_bank = 0x20;
|
big_bank = 0x20;
|
||||||
Sync();
|
Sync();
|
||||||
setprg8r(0x10, 0x6000, 0); // Only two Goemon games are have battery backed RAM, three more shooters
|
setprg8r(0x10, 0x6000, 0); /* Only two Goemon games are have battery backed RAM, three more shooters
|
||||||
// (Parodius Da!, Gradius 2 and Crisis Force uses 2k or SRAM at 6000-67FF only
|
* (Parodius Da!, Gradius 2 and Crisis Force uses 2k or SRAM at 6000-67FF only
|
||||||
|
*/
|
||||||
SetReadHandler(0x6000, 0x7FFF, CartBR);
|
SetReadHandler(0x6000, 0x7FFF, CartBR);
|
||||||
SetWriteHandler(0x6000, 0x7FFF, CartBW);
|
SetWriteHandler(0x6000, 0x7FFF, CartBW);
|
||||||
SetReadHandler(0x8000, 0xFFFF, CartBR);
|
SetReadHandler(0x8000, 0xFFFF, CartBR);
|
||||||
@@ -214,16 +225,6 @@ static void VRC24Close(void) {
|
|||||||
WRAM = NULL;
|
WRAM = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mapper21_Init(CartInfo *info) {
|
|
||||||
isPirate = 0;
|
|
||||||
is22 = 0;
|
|
||||||
info->Power = M21Power;
|
|
||||||
MapIRQHook = VRC24IRQHook;
|
|
||||||
GameStateRestore = StateRestore;
|
|
||||||
|
|
||||||
AddExState(&StateRegs, ~0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mapper22_Init(CartInfo *info) {
|
void Mapper22_Init(CartInfo *info) {
|
||||||
isPirate = 0;
|
isPirate = 0;
|
||||||
is22 = 1;
|
is22 = 1;
|
||||||
@@ -251,6 +252,13 @@ void VRC24_Init(CartInfo *info) {
|
|||||||
AddExState(&StateRegs, ~0, 0, 0);
|
AddExState(&StateRegs, ~0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Mapper21_Init(CartInfo *info) {
|
||||||
|
isPirate = 0;
|
||||||
|
is22 = 0;
|
||||||
|
info->Power = M21Power;
|
||||||
|
VRC24_Init(info);
|
||||||
|
}
|
||||||
|
|
||||||
void Mapper23_Init(CartInfo *info) {
|
void Mapper23_Init(CartInfo *info) {
|
||||||
isPirate = 0;
|
isPirate = 0;
|
||||||
is22 = 0;
|
is22 = 0;
|
||||||
|
|||||||
@@ -1,203 +0,0 @@
|
|||||||
/* FCE Ultra - NES/Famicom Emulator
|
|
||||||
*
|
|
||||||
* Copyright notice for this file:
|
|
||||||
* Copyright (C) 2005 CaH4e3
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* VRC-5 (CAI Shogakko no Sansu)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "mapinc.h"
|
|
||||||
|
|
||||||
static uint8 QTAINTRAM[2048];
|
|
||||||
static writefunc old2007wrap;
|
|
||||||
|
|
||||||
static uint16 CHRSIZE = 8192;
|
|
||||||
static uint16 WRAMSIZE = 8192 + 4096;
|
|
||||||
static uint8 *CHRRAM = NULL;
|
|
||||||
static uint8 *WRAM = NULL;
|
|
||||||
|
|
||||||
static uint8 IRQa, K4IRQ;
|
|
||||||
static uint32 IRQLatch, IRQCount;
|
|
||||||
|
|
||||||
static uint8 regs[16];
|
|
||||||
//static uint8 test[8];
|
|
||||||
static SFORMAT StateRegs[] =
|
|
||||||
{
|
|
||||||
{ &IRQCount, 1, "IRQC" },
|
|
||||||
{ &IRQLatch, 1, "IRQL" },
|
|
||||||
{ &IRQa, 1, "IRQA" },
|
|
||||||
{ &K4IRQ, 1, "KIRQ" },
|
|
||||||
{ regs, 16, "REGS" },
|
|
||||||
{ 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static void chrSync(void) {
|
|
||||||
setchr4r(0x10, 0x0000, regs[5] & 1);
|
|
||||||
setchr4r(0x10, 0x1000, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Sync(void) {
|
|
||||||
chrSync();
|
|
||||||
// if(regs[0xA]&0x10)
|
|
||||||
// {
|
|
||||||
/* setchr1r(0x10,0x0000,(((regs[5]&1))<<2)+0);
|
|
||||||
setchr1r(0x10,0x0400,(((regs[5]&1))<<2)+1);
|
|
||||||
setchr1r(0x10,0x0800,(((regs[5]&1))<<2)+2);
|
|
||||||
setchr1r(0x10,0x0c00,(((regs[5]&1))<<2)+3);
|
|
||||||
setchr1r(0x10,0x1000,0);
|
|
||||||
setchr1r(0x10,0x1400,1);
|
|
||||||
setchr1r(0x10,0x1800,2);
|
|
||||||
setchr1r(0x10,0x1c00,3);*/
|
|
||||||
/* setchr1r(0x10,0x0000,(((regs[5]&1))<<2)+0);
|
|
||||||
setchr1r(0x10,0x0400,(((regs[5]&1))<<2)+1);
|
|
||||||
setchr1r(0x10,0x0800,(((regs[5]&1))<<2)+2);
|
|
||||||
setchr1r(0x10,0x0c00,(((regs[5]&1))<<2)+3);
|
|
||||||
setchr1r(0x10,0x1000,(((regs[5]&1)^1)<<2)+4);
|
|
||||||
setchr1r(0x10,0x1400,(((regs[5]&1)^1)<<2)+5);
|
|
||||||
setchr1r(0x10,0x1800,(((regs[5]&1)^1)<<2)+6);
|
|
||||||
setchr1r(0x10,0x1c00,(((regs[5]&1)^1)<<2)+7);
|
|
||||||
*/
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
/*
|
|
||||||
setchr1r(0x10,0x0000,(((regs[5]&1)^1)<<2)+0);
|
|
||||||
setchr1r(0x10,0x0400,(((regs[5]&1)^1)<<2)+1);
|
|
||||||
setchr1r(0x10,0x0800,(((regs[5]&1)^1)<<2)+2);
|
|
||||||
setchr1r(0x10,0x0c00,(((regs[5]&1)^1)<<2)+3);
|
|
||||||
setchr1r(0x10,0x1000,(((regs[5]&1))<<2)+4);
|
|
||||||
setchr1r(0x10,0x1400,(((regs[5]&1))<<2)+5);
|
|
||||||
setchr1r(0x10,0x1800,(((regs[5]&1))<<2)+6);
|
|
||||||
setchr1r(0x10,0x1c00,(((regs[5]&1))<<2)+7);
|
|
||||||
// }
|
|
||||||
//*/
|
|
||||||
/* setchr1r(1,0x0000,test[0]);
|
|
||||||
setchr1r(1,0x0400,test[1]);
|
|
||||||
setchr1r(1,0x0800,test[2]);
|
|
||||||
setchr1r(1,0x0c00,test[3]);
|
|
||||||
setchr1r(1,0x1000,test[4]);
|
|
||||||
setchr1r(1,0x1400,test[5]);
|
|
||||||
setchr1r(1,0x1800,test[6]);
|
|
||||||
setchr1r(1,0x1c00,test[7]);
|
|
||||||
*/
|
|
||||||
setprg4r(0x10, 0x6000, regs[0] & 1);
|
|
||||||
if (regs[2] >= 0x40)
|
|
||||||
setprg8r(1, 0x8000, (regs[2] - 0x40));
|
|
||||||
else
|
|
||||||
setprg8r(0, 0x8000, (regs[2] & 0x3F));
|
|
||||||
if (regs[3] >= 0x40)
|
|
||||||
setprg8r(1, 0xA000, (regs[3] - 0x40));
|
|
||||||
else
|
|
||||||
setprg8r(0, 0xA000, (regs[3] & 0x3F));
|
|
||||||
if (regs[4] >= 0x40)
|
|
||||||
setprg8r(1, 0xC000, (regs[4] - 0x40));
|
|
||||||
else
|
|
||||||
setprg8r(0, 0xC000, (regs[4] & 0x3F));
|
|
||||||
|
|
||||||
setprg8r(1, 0xE000, ~0);
|
|
||||||
setmirror(MI_V);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*static DECLFW(TestWrite)
|
|
||||||
{
|
|
||||||
test[A&7] = V;
|
|
||||||
Sync();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
static DECLFW(M190Write) {
|
|
||||||
// FCEU_printf("write %04x:%04x %d, %d\n",A,V,scanline,timestamp);
|
|
||||||
regs[(A & 0x0F00) >> 8] = V;
|
|
||||||
switch (A) {
|
|
||||||
case 0xd600: IRQLatch &= 0xFF00; IRQLatch |= V; break;
|
|
||||||
case 0xd700: IRQLatch &= 0x00FF; IRQLatch |= V << 8; break;
|
|
||||||
case 0xd900: IRQCount = IRQLatch; IRQa = V & 2; K4IRQ = V & 1; X6502_IRQEnd(FCEU_IQEXT); break;
|
|
||||||
case 0xd800: IRQa = K4IRQ; X6502_IRQEnd(FCEU_IQEXT); break;
|
|
||||||
}
|
|
||||||
Sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
static DECLFR(M190Read) {
|
|
||||||
// FCEU_printf("read %04x:%04x %d, %d\n",A,regs[(A&0x0F00)>>8],scanline,timestamp);
|
|
||||||
return regs[(A & 0x0F00) >> 8] + regs[0x0B];
|
|
||||||
}
|
|
||||||
static void FP_FASTAPASS(1) VRC5IRQ(int a) {
|
|
||||||
if (IRQa) {
|
|
||||||
IRQCount += a;
|
|
||||||
if (IRQCount & 0x10000) {
|
|
||||||
X6502_IRQBegin(FCEU_IQEXT);
|
|
||||||
IRQCount = IRQLatch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//static void FP_FASTAPASS(1) Mapper190_PPU(uint32 A)
|
|
||||||
//{
|
|
||||||
// if(A<0x2000)
|
|
||||||
// setchr4r(0x10,0x1000,QTAINTRAM[A&0x1FFF]&1);
|
|
||||||
// else
|
|
||||||
// chrSync();
|
|
||||||
//}
|
|
||||||
|
|
||||||
static DECLFW(M1902007Wrap) {
|
|
||||||
if (A >= 0x2000) {
|
|
||||||
if (regs[0xA] & 1)
|
|
||||||
QTAINTRAM[A & 0x1FFF] = V;
|
|
||||||
else
|
|
||||||
old2007wrap(A, V);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void M190Power(void) {
|
|
||||||
/* test[0]=0;
|
|
||||||
test[1]=1;
|
|
||||||
test[2]=2;
|
|
||||||
test[3]=3;
|
|
||||||
test[4]=4;
|
|
||||||
test[5]=5;
|
|
||||||
test[6]=6;
|
|
||||||
test[7]=7;
|
|
||||||
*/
|
|
||||||
setprg4r(0x10, 0x7000, 2);
|
|
||||||
|
|
||||||
old2007wrap = GetWriteHandler(0x2007);
|
|
||||||
SetWriteHandler(0x2007, 0x2007, M1902007Wrap);
|
|
||||||
|
|
||||||
SetReadHandler(0x6000, 0xFFFF, CartBR);
|
|
||||||
// SetWriteHandler(0x5000,0x5007,TestWrite);
|
|
||||||
SetWriteHandler(0x6000, 0x7FFF, CartBW);
|
|
||||||
SetWriteHandler(0x8000, 0xFFFF, M190Write);
|
|
||||||
SetReadHandler(0xDC00, 0xDC00, M190Read);
|
|
||||||
SetReadHandler(0xDD00, 0xDD00, M190Read);
|
|
||||||
FCEU_CheatAddRAM(WRAMSIZE >> 10, 0x6000, WRAM);
|
|
||||||
Sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void M190Close(void) {
|
|
||||||
if (CHRRAM)
|
|
||||||
FCEU_gfree(CHRRAM);
|
|
||||||
CHRRAM = NULL;
|
|
||||||
if (WRAM)
|
|
||||||
FCEU_gfree(WRAM);
|
|
||||||
WRAM = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void StateRestore(int version) {
|
|
||||||
Sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -39,7 +39,6 @@ void *FCEU_gmalloc(uint32 size)
|
|||||||
|
|
||||||
void *FCEU_malloc(uint32 size)
|
void *FCEU_malloc(uint32 size)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
|
||||||
void *ret;
|
void *ret;
|
||||||
ret = (void*)malloc(size);
|
ret = (void*)malloc(size);
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ void FCEUI_SetDirOverride(int which, char *n)
|
|||||||
|
|
||||||
char *FCEU_MakeFName(int type, int id1, char *cd1)
|
char *FCEU_MakeFName(int type, int id1, char *cd1)
|
||||||
{
|
{
|
||||||
struct stat tmpstat;
|
|
||||||
char tmp[2048] = {0};
|
char tmp[2048] = {0};
|
||||||
char *ret = 0;
|
char *ret = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@
|
|||||||
{0x6e68e31a, 16, 8}, /* Dragon Ball 3*/
|
{0x6e68e31a, 16, 8}, /* Dragon Ball 3*/
|
||||||
{0x33b899c9, 16, -1}, /* Dragon Ball - Dai Maou Fukkatsu (J) [!] */
|
{0x33b899c9, 16, -1}, /* Dragon Ball - Dai Maou Fukkatsu (J) [!] */
|
||||||
{0xa262a81f, 16, -1}, /* Rokudenashi Blues (J) */
|
{0xa262a81f, 16, -1}, /* Rokudenashi Blues (J) */
|
||||||
{0x286fcd20, 23, -1}, /* Ganbare Goemon Gaiden 2 - Tenka no Zaihou (J) [!] */
|
{0x286fcd20, 21, -1}, /* Ganbare Goemon Gaiden 2 - Tenka no Zaihou (J) [!] */
|
||||||
{0xe4a291ce, 23, -1}, /* World Hero (Unl) [!] */
|
{0xe4a291ce, 23, -1}, /* World Hero (Unl) [!] */
|
||||||
{0x51e9cd33, 23, -1}, /* World Hero (Unl) [b1] */
|
{0x51e9cd33, 23, -1}, /* World Hero (Unl) [b1] */
|
||||||
{0x105dd586, 27, -1}, /* Mi Hun Che variations... */
|
{0x105dd586, 27, -1}, /* Mi Hun Che variations... */
|
||||||
|
|||||||
Reference in New Issue
Block a user