diff --git a/makefile.burn_rules b/makefile.burn_rules index 33cf92da2..235d740b5 100644 --- a/makefile.burn_rules +++ b/makefile.burn_rules @@ -134,7 +134,7 @@ depobj = burn.o burn_bitmap.o burn_gun.o burn_led.o burn_shift.o burn_memory.o \ irem_cpu.o irem_sound.o \ \ - k007121.o k007342_k007420.o k051316.o k051733.o k051960.o k052109.o k053245.o k053247.o k053250.o k053251.o k053936.o k054000.o k054338.o \ + k007121.o k007342_k007420.o k007452.o k051316.o k051733.o k051960.o k052109.o k053245.o k053247.o k053250.o k053251.o k053936.o k054000.o k054338.o \ k055555.o k056832.o konamigx.o konamiic.o timeplt_snd.o \ \ dcs2k.o ide.o midwayic.o midtunit.o midwunit.o narc_sound.o williams_adpcm.o williams_cvsd.o yawdim_sound.o \ diff --git a/src/burn/drv/konami/d_combatsc.cpp b/src/burn/drv/konami/d_combatsc.cpp index 388e25029..b2f2fd78d 100644 --- a/src/burn/drv/konami/d_combatsc.cpp +++ b/src/burn/drv/konami/d_combatsc.cpp @@ -8,6 +8,7 @@ #include "upd7759.h" #include "konamiic.h" #include "k007121.h" +#include "k007452.h" #include "watchdog.h" static UINT8 *AllMem; @@ -31,7 +32,6 @@ static UINT8 *color_table; static UINT32 *DrvPalette; //static UINT8 DrvRecalc; -static UINT8 multiply_data[2]; static UINT8 soundlatch; static UINT8 video_reg; static UINT8 bank_data; @@ -202,11 +202,13 @@ static void combatsc_main_write(UINT16 address, UINT8 data) { case 0x0200: case 0x0201: - multiply_data[address & 1] = data; - return; - + case 0x0202: + case 0x0203: + case 0x0204: + case 0x0205: case 0x0206: - // protection clock (unemulated) + case 0x0207: + K007452Write(address & 7, data); return; case 0x0408: @@ -248,10 +250,14 @@ static UINT8 combatsc_main_read(UINT16 address) return 0; // unk?? case 0x0200: - return (multiply_data[0] * multiply_data[1]); - case 0x0201: - return (multiply_data[0] * multiply_data[1]) >> 8; + case 0x0202: + case 0x0203: + case 0x0204: + case 0x0205: + case 0x0206: + case 0x0207: + return K007452Read(address & 7); case 0x0400: return DrvInputs[0]; @@ -379,9 +385,9 @@ static INT32 DrvDoReset(INT32 clear_mem) k007121_reset(); + K007452Reset(); + soundlatch = 0; - multiply_data[0] = 0; - multiply_data[1] = 0; video_reg = 0; nExtraCycles = 0; @@ -776,10 +782,11 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin) k007121_scan(nAction); + K007452Scan(nAction); + BurnYM2203Scan(nAction, pnMin); UPD7759Scan(nAction, pnMin); - SCAN_VAR(multiply_data); SCAN_VAR(soundlatch); SCAN_VAR(video_reg); SCAN_VAR(bank_data); diff --git a/src/burn/drv/konami/d_contra.cpp b/src/burn/drv/konami/d_contra.cpp index 61d2644b1..1ec7af302 100644 --- a/src/burn/drv/konami/d_contra.cpp +++ b/src/burn/drv/konami/d_contra.cpp @@ -6,6 +6,7 @@ #include "m6809_intf.h" #include "hd6309_intf.h" #include "k007121.h" +#include "k007452.h" static UINT8 *AllMem; static UINT8 *MemEnd; @@ -44,11 +45,6 @@ static UINT8 DrvReset; static UINT8 soundlatch; static UINT8 nBankData; -static UINT32 math_reg[6]; -static UINT16 multiply_result; -static UINT16 divide_quotient; -static UINT16 divide_remainder; - static struct BurnInputInfo DrvInputList[] = { {"P1 Coin" , BIT_DIGITAL , DrvJoy1 + 0, "p1 coin" }, @@ -208,55 +204,6 @@ void contra_bankswitch_w(INT32 data) } } -static UINT8 contra_K007452_r(UINT16 address) -{ - switch (address) - { - case 0: - return multiply_result & 0xFF; - break; - case 1: - return (multiply_result >> 8) & 0xFF; - break; - case 2: - return divide_remainder & 0xFF; - break; - case 3: - return (divide_remainder >> 8) & 0xFF; - break; - case 4: - return divide_quotient & 0xFF; - break; - case 5: - return (divide_quotient >> 8) & 0xFF; - break; - default: - return 0; - } -} - -static void contra_K007452_w(UINT16 address, UINT8 data) -{ - math_reg[address] = data; - - if (address == 1) - { - // Starts multiplication process - multiply_result = math_reg[0] * math_reg[1]; - } - else if (address == 5) - { - // Starts division process - UINT16 divisor = (math_reg[2]<<8) + math_reg[3]; - if (divisor != 0) - { - UINT16 dividend = (math_reg[4]<<8) + math_reg[5]; - divide_quotient = dividend / divisor; - divide_remainder = dividend % divisor; - } - } -} - UINT8 DrvContraHD6309ReadByte(UINT16 address) { switch (address) @@ -267,7 +214,10 @@ UINT8 DrvContraHD6309ReadByte(UINT16 address) case 0x000B: case 0x000C: case 0x000D: - return contra_K007452_r(address & 7); + case 0x000E: + case 0x000F: + return K007452Read(address & 7); + case 0x0010: case 0x0011: case 0x0012: @@ -322,13 +272,16 @@ void DrvContraHD6309WriteByte(UINT16 address, UINT8 data) case 0x0007: contra_K007121_ctrl_0_w(address & 7, data); return; + case 0x0008: case 0x0009: case 0x000A: case 0x000B: case 0x000C: case 0x000D: - contra_K007452_w(address & 7, data); + case 0x000E: + case 0x000F: + K007452Write(address & 7, data); return; case 0x0018: @@ -475,6 +428,8 @@ static INT32 DrvDoReset() k007121_reset(); + K007452Reset(); + soundlatch = 0; nBankData = 0; @@ -899,14 +854,12 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin) M6809Scan(nAction); k007121_scan(nAction); + K007452Scan(nAction); BurnYM2151Scan(nAction, pnMin); SCAN_VAR(soundlatch); SCAN_VAR(nBankData); - SCAN_VAR(multiply_result); - SCAN_VAR(divide_quotient); - SCAN_VAR(divide_remainder); if (nAction & ACB_WRITE) { HD6309Open(0); diff --git a/src/burn/drv/konami/d_flkatck.cpp b/src/burn/drv/konami/d_flkatck.cpp index b8b988d5f..34cb1ffbd 100644 --- a/src/burn/drv/konami/d_flkatck.cpp +++ b/src/burn/drv/konami/d_flkatck.cpp @@ -8,6 +8,7 @@ #include "burn_ym2151.h" #include "k007232.h" #include "watchdog.h" +#include "k007452.h" static UINT8 *AllMem; static UINT8 *MemEnd; @@ -27,7 +28,6 @@ static UINT8 *DrvSprRAM; static UINT32 *DrvPalette; static UINT8 DrvRecalc; -static INT32 multiply_register[2]; static UINT8 main_bank; static UINT8 soundlatch; static UINT8 flipscreen; @@ -226,10 +226,13 @@ static void __fastcall flkatck_sound_write(UINT16 address, UINT8 data) { case 0x9000: case 0x9001: - multiply_register[address & 1] = data; - return; - + case 0x9002: + case 0x9003: + case 0x9004: + case 0x9005: case 0x9006: + case 0x9007: + K007452Write(address & 7, data); return; case 0xb000: @@ -261,11 +264,14 @@ static UINT8 __fastcall flkatck_sound_read(UINT16 address) switch (address) { case 0x9000: - return (multiply_register[0] * multiply_register[1]) & 0xff; - case 0x9001: + case 0x9002: + case 0x9003: case 0x9004: - return 0; + case 0x9005: + case 0x9006: + case 0x9007: + return K007452Read(address & 7); case 0xa000: return soundlatch; @@ -353,11 +359,10 @@ static INT32 DrvDoReset(INT32 clear_mem) k007232_set_bank(0, 0, 1); k007121_reset(); + K007452Reset(); BurnWatchdogReset(); - multiply_register[0] = 0; - multiply_register[1] = 0; flipscreen = 0; soundlatch = 0; @@ -632,10 +637,10 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin) BurnYM2151Scan(nAction, pnMin); K007232Scan(nAction, pnMin); + K007452Scan(nAction); SCAN_VAR(soundlatch); SCAN_VAR(flipscreen); - SCAN_VAR(multiply_register); SCAN_VAR(main_bank); SCAN_VAR(nExtraCycles); } diff --git a/src/burn/drv/konami/d_wecleman.cpp b/src/burn/drv/konami/d_wecleman.cpp index 1bef64613..926366ba6 100644 --- a/src/burn/drv/konami/d_wecleman.cpp +++ b/src/burn/drv/konami/d_wecleman.cpp @@ -7,6 +7,7 @@ #include "m6809_intf.h" #include "burn_ym2151.h" #include "k007232.h" +#include "k007452.h" #include "bitswap.h" #include "konamiic.h" #include "burn_pal.h" @@ -40,7 +41,6 @@ static UINT16 irq_control; static UINT16 protection_state; static UINT16 protection_ram[3]; static UINT16 blitter_regs[16]; -static UINT8 multiply_reg[2]; static UINT8 soundbank; static UINT8 soundlatch; static UINT8 sound_status; @@ -558,11 +558,14 @@ static void __fastcall wecleman_sound_write(UINT16 address, UINT8 data) case 0x9000: case 0x9001: - multiply_reg[address & 1] = data; - return; - + case 0x9002: + case 0x9003: + case 0x9004: + case 0x9005: case 0x9006: - return; // nop + case 0x9007: + K007452Write(address & 7, data); + return; case 0xc000: case 0xc001: @@ -584,7 +587,14 @@ static UINT8 __fastcall wecleman_sound_read(UINT16 address) switch (address) { case 0x9000: - return multiply_reg[0] * multiply_reg[1]; + case 0x9001: + case 0x9002: + case 0x9003: + case 0x9004: + case 0x9005: + case 0x9006: + case 0x9007: + return K007452Read(address & 7); case 0xa000: if (soundlatch == 0) { @@ -723,12 +733,13 @@ static INT32 DrvDoReset() K007232Reset(0); } + K007452Reset(); + BurnLEDReset(); BurnShiftReset(); memset (protection_ram, 0, sizeof(protection_ram)); memset (blitter_regs, 0, sizeof(blitter_regs)); - memset (multiply_reg, 0, sizeof(multiply_reg)); soundbank = 0; selected_ip = 0; @@ -1859,7 +1870,9 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin) ZetScan(nAction); BurnYM2151Scan(nAction, pnMin); } + K007232Scan(nAction, pnMin); + K007452Scan(nAction); KonamiICScan(nAction); @@ -1868,7 +1881,6 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin) SCAN_VAR(protection_ram); SCAN_VAR(blitter_regs); - SCAN_VAR(multiply_reg); SCAN_VAR(soundbank); SCAN_VAR(selected_ip); diff --git a/src/burn/drv/konami/k007452.cpp b/src/burn/drv/konami/k007452.cpp new file mode 100644 index 000000000..555e6e957 --- /dev/null +++ b/src/burn/drv/konami/k007452.cpp @@ -0,0 +1,78 @@ +// K007452 multiplier/divider, silicon-RE, code & (c) by furrtek (Sean Gonsalves) April 2021 + +#include "burnint.h" + +static UINT32 math_reg[6]; +static UINT16 multiply_result; +static UINT16 divide_quotient; +static UINT16 divide_remainder; + +void K007452Reset() +{ + memset(math_reg, 0, sizeof(math_reg)); + + multiply_result = 0; + divide_quotient = 0; + divide_remainder = 0; +} + +void K007452Init() +{ + K007452Reset(); +} + +void K007452Exit() +{ + K007452Reset(); +} + +void K007452Scan(INT32 nAction) +{ + if (nAction & ACB_VOLATILE) { + SCAN_VAR(math_reg); + SCAN_VAR(multiply_result); + SCAN_VAR(divide_quotient); + SCAN_VAR(divide_remainder); + } +} + +UINT8 K007452Read(UINT16 address) +{ + switch (address & 7) + { + case 0: return multiply_result & 0xff; + case 1: return (multiply_result >> 8) & 0xff; + case 2: return divide_remainder & 0xff; + case 3: return (divide_remainder >> 8) & 0xff; + case 4: return divide_quotient & 0xff; + case 5: return (divide_quotient >> 8) & 0xff; + } + + return 0; +} + +void K007452Write(UINT16 address, UINT8 data) +{ + address &= 7; + + if (address < 6) math_reg[address] = data; + + if (address == 1) + { + // Starts multiplication process + multiply_result = math_reg[0] * math_reg[1]; + } + else if (address == 5) + { + // Starts division process + UINT16 dividend = (math_reg[4]<<8) + math_reg[5]; + UINT16 divisor = (math_reg[2]<<8) + math_reg[3]; + if (!divisor) { + divide_quotient = 0xffff; + divide_remainder = 0x0000; + } else { + divide_quotient = dividend / divisor; + divide_remainder = dividend % divisor; + } + } +} diff --git a/src/burn/drv/konami/k007452.h b/src/burn/drv/konami/k007452.h new file mode 100644 index 000000000..406cdd1fc --- /dev/null +++ b/src/burn/drv/konami/k007452.h @@ -0,0 +1,7 @@ +void K007452Init(); +void K007452Exit(); +void K007452Scan(INT32 nAction); +void K007452Reset(); + +UINT8 K007452Read(UINT16 address); +void K007452Write(UINT16 address, UINT8 data);