diff options
author | Tomasz Slanina <tomaszsl@mamedev.org> | 2009-08-27 08:57:11 +0000 |
---|---|---|
committer | Tomasz Slanina <tomaszsl@mamedev.org> | 2009-08-27 08:57:11 +0000 |
commit | 183b2b082b49e43fac478627304cb4dab9f316d3 (patch) | |
tree | 7e545999ed20dddf8af59b63ba1da2869d9d92d5 | |
parent | 25d5307394a7191991adba0cc4800972a79a563a (diff) |
Added eeprom support to the B Rap Boys protection simulation [David Haywood]
-rw-r--r-- | src/mame/drivers/kaneko16.c | 59 | ||||
-rw-r--r-- | src/mame/machine/kaneko16.c | 69 |
2 files changed, 111 insertions, 17 deletions
diff --git a/src/mame/drivers/kaneko16.c b/src/mame/drivers/kaneko16.c index f8cbaf92ec0..41392f8d88f 100644 --- a/src/mame/drivers/kaneko16.c +++ b/src/mame/drivers/kaneko16.c @@ -2100,6 +2100,63 @@ static INTERRUPT_GEN( shogwarr_interrupt ) } } +/* +unsigned char shogwarr_default_eeprom[128] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F, 0x2F, 0x41, 0x54, 0x4F, 0x50, 0x20, 0x31, 0x39, 0x39, 0x32, + 0x46, 0x55, 0x4A, 0x49, 0xFF, 0xFF, 0x4D, 0x41, 0x20, 0x42, 0x55, 0x53, 0x54, 0x45, 0x52, 0x20, + 0x20, 0x53, 0x48, 0x4F, 0xFF, 0xFF, 0x4E, 0x20, 0x57, 0x41, 0x52, 0x52, 0x49, 0x4F, 0x52, 0x53, + 0xFF, 0xFF, 0x70, 0x79, 0x72, 0x69, 0xFF, 0xFF, 0x74, 0x20, 0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF +}; +*/ +// the above eeprom looks corrupt, some of the text is wrong, the game never writes this text tho.. maybe it should be as below +// leaving both here incase they relate to which tables get 'locked out' by the MCU somehow +UINT8 shogwarr_default_eeprom[128] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F, 0x2F, 0x41, 0x54, 0x4F, 0x50, 0x20, 0x31, 0x39, 0x39, 0x32, + 0x46, 0x55, 0x4A, 0x49, 0x59, 0x41, 0x4D, 0x41, 0x20, 0x42, 0x55, 0x53, 0x54, 0x45, 0x52, 0x20, + 0x20, 0x53, 0x48, 0x4F, 0x47, 0x55, 0x4E, 0x20, 0x57, 0x41, 0x52, 0x52, 0x49, 0x4F, 0x52, 0x53, + 0x63, 0x6F, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF +}; + +UINT8 brapboys_default_eeprom[128] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x20, 0x30, 0x00, 0x03, 0x68, 0x18, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F, 0x20, 0x20, + 0x42, 0x65, 0x20, 0x52, 0x61, 0x70, 0x20, 0x42, 0x6F, 0x79, 0x73, 0x00, 0x30, 0x30, 0x30, 0x2E, + 0x30, 0x38, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x35, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +static NVRAM_HANDLER( shogwarr ) +{ + int isbrap = ( !strcmp(machine->gamedrv->name,"brapboysj") || !strcmp(machine->gamedrv->name,"brapboys")); + + if (read_or_write) + eeprom_save(file); + else + { + eeprom_init(machine, &eeprom_interface_93C46); + + if (file) eeprom_load(file); + else + { + if (isbrap) + eeprom_set_data(brapboys_default_eeprom,128); + else + eeprom_set_data(shogwarr_default_eeprom,128); + } + } +} + static MACHINE_DRIVER_START( shogwarr ) /* basic machine hardware */ @@ -2123,6 +2180,8 @@ static MACHINE_DRIVER_START( shogwarr ) MDRV_VIDEO_START(kaneko16_1xVIEW2) MDRV_VIDEO_UPDATE(kaneko16) + MDRV_NVRAM_HANDLER(shogwarr) + /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mame/machine/kaneko16.c b/src/mame/machine/kaneko16.c index 4187ffcef17..96476215c95 100644 --- a/src/mame/machine/kaneko16.c +++ b/src/mame/machine/kaneko16.c @@ -16,6 +16,7 @@ Currently none of the MCUs' internal roms are dumped so simulation is used #include "includes/kaneko16.h" #include "kanekotb.h" // TOYBOX MCU trojaning results +#include "machine/eeprom.h" #define CALC3_VERBOSE_OUTPUT 0 @@ -954,9 +955,41 @@ int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram, // hack, set it to a known address instead of trying to restore to anywhere specific.. // might break at some point tho, eg if it doesn't write command 06 often enough because it trys to use another one like 07... // need to understand the meaning of this (test hw?) - if (calc3_mode==0x06) calc3_writeaddress_current = 0x202000; - // also calls empty table with Mode? 07 - // maybe they reset to different points? + + // !dstram is used because we don't want to process these during our initial table scan, only when the game asks! + + if (calc3_mode==0x06) + { + calc3_writeaddress_current = 0x202000; + } + else if (calc3_mode==0x07) + { + // also calls empty table with Mode? 07 + // maybe they reset to different points? + } + else if (calc3_mode==0x08 && !dstram) + { + //printf("save to eeprom\n"); + + { + UINT32 length, size; + UINT8 *dat; + + dat = (UINT8 *)eeprom_get_data_pointer(&length, &size); + + for (i=0;i<0x80;i++) + { + dat[i] = memory_read_byte(space, calc3_eeprom_addr+0x200000+i); + } + + } + + } + else if (!dstram) + { + printf("unknown blank table command\n"); + } + return 0; } @@ -1291,19 +1324,6 @@ DRIVER_INIT(calc3_scantables) extern UINT16 calc3_mcu_crc; -// from brap boys, might be polluted with shogun warriors values tho as was running shogun code at the time -static UINT16 kaneko16_eeprom_data[0x40] = -{ - 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0003, 0x0002, 0x1020, 0x0002, 0x6010, 0x0101, 0x0101, - 0x0101, 0x0001, 0x0003, 0x0008, 0x4B41, 0x4E45, 0x4B4F, 0x2020, - 0x4265, 0x2052, 0x6170, 0x2042, 0x6F79, 0x7300, 0x3030, 0x302E, - 0x3038, 0x7FFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, - 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, - 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, - 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x003B, 0xFFFF, 0xFFFF, 0xFFFF -}; - void calc3_mcu_run(running_machine *machine) { UINT16 mcu_command; @@ -1353,15 +1373,30 @@ void calc3_mcu_run(running_machine *machine) printf("Calc 3 Init Command - %04x ROM Checksum Address\n", cakc3_checkumaddress); printf("Calc 3 Init Command - %08x Data Write Address\n", calc3_writeaddress); #endif - memory_write_byte(space, calc3_dsw_addr+0x200000, ( ~input_port_read(machine, "DSW1"))&0xff); // // DSW // dsw actually updates in realtime - mcu reads+writes it every frame + // memory_write_byte(space, calc3_dsw_addr+0x200000, ( ~input_port_read(machine, "DSW1"))&0xff); // // DSW // dsw actually updates in realtime - mcu reads+writes it every frame kaneko16_mcu_ram[cakc3_checkumaddress / 2] = calc3_mcu_crc; // MCU Rom Checksum! + /* for (i=0;i<0x40;i++) { kaneko16_mcu_ram[(calc3_eeprom_addr / 2)+i] = kaneko16_eeprom_data[i];//((eepromData[i]&0xff00)>>8) | ((eepromData[i]&0x00ff)<<8); } + */ + { + UINT32 length, size; + UINT8 *dat; + + dat = (UINT8 *)eeprom_get_data_pointer(&length, &size); + + for (i=0;i<0x80;i++) + { + memory_write_byte(space, calc3_eeprom_addr+0x200000+i, dat[i]); + } + + } + } /* otherwise the command number is the number of transfer operations to perform */ else |