From f431841d7a42f97432bc8d49012408fa3ed091e2 Mon Sep 17 00:00:00 2001 From: angelosa Date: Sun, 28 Jul 2024 12:31:55 +0200 Subject: [PATCH 01/11] commodore/c65.cpp: basic convert DMAgic to device --- src/mame/commodore/c65.cpp | 222 ++++++++++++++++++++++++------------- 1 file changed, 142 insertions(+), 80 deletions(-) diff --git a/src/mame/commodore/c65.cpp b/src/mame/commodore/c65.cpp index 6adcc4509e3..a175e6336c3 100644 --- a/src/mame/commodore/c65.cpp +++ b/src/mame/commodore/c65.cpp @@ -30,6 +30,139 @@ Hardware pics: #define MAIN_CLOCK XTAL(28'375'160)/8 +// TODO: move to own file, subclass with f018a, use device_execute_interface +class dmagic_f018_device : public device_t +{ +public: + // construction/destruction + dmagic_f018_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + template void set_space(T &&tag, int spacenum) { m_space.set_tag(std::forward(tag), spacenum); } + + void map(address_map &map); + +protected: + virtual void device_start() override; + virtual void device_reset() override; + +private: + required_address_space m_space; + + u32 m_dmalist_address = 0; + + void execute(u32 address); +}; + +DEFINE_DEVICE_TYPE(DMAGIC_F018, dmagic_f018_device, "dmagic_f018", "DMAgic F018 Gate Array") + +dmagic_f018_device::dmagic_f018_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, DMAGIC_F018, tag, owner, clock) + , m_space(*this, finder_base::DUMMY_TAG, -1) +{ +} + +void dmagic_f018_device::device_start() +{ + save_item(NAME(m_dmalist_address)); +} + +void dmagic_f018_device::device_reset() +{} + +void dmagic_f018_device::execute(u32 address) +{ + static const char *const dma_cmd_string[] = + { + "COPY", + "MIX", + "SWAP", + "FILL" + }; + u8 cmd = m_space->read_byte(address++); + u16 length = m_space->read_byte(address++); + length |=(m_space->read_byte(address++)<<8); + + u32 src = m_space->read_byte(address++); + src |=(m_space->read_byte(address++)<<8); + src |=(m_space->read_byte(address++)<<16); + + u32 dst = m_space->read_byte(address++); + dst |=(m_space->read_byte(address++)<<8); + dst |=(m_space->read_byte(address++)<<16); + + if(cmd & 0xfc) + logerror("%02x\n",cmd & 0xfc); + switch(cmd & 3) + { + // copy + // TODO: untested, is it even implemented in F018? + case 0: + { + if(length != 1) + logerror("DMAgic %s %02x -> %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src,dst,length,cmd & 4 ? "yes" : "no"); + uint32_t SourceIndex; + uint32_t DestIndex; + uint16_t SizeIndex; + SourceIndex = src & 0xfffff; + DestIndex = dst & 0xfffff; + SizeIndex = length; + do + { + m_space->write_byte(DestIndex++,m_space->read_byte(SourceIndex++)); + SizeIndex--; + }while(SizeIndex != 0); + + return; + } + // fill + case 3: + { + // TODO: upper bits of source + logerror("DMAgic %s %02x -> %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src & 0xff,dst,length,cmd & 4 ? "yes" : "no"); + uint8_t FillValue; + uint32_t DestIndex; + uint16_t SizeIndex; + FillValue = src & 0xff; + DestIndex = dst & 0xfffff; + SizeIndex = length; + do + { + m_space->write_byte(DestIndex++,FillValue); + SizeIndex--; + }while(SizeIndex != 0); + return; + } + } + logerror("DMAgic %s %08x %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src,dst,length,cmd & 4 ? "yes" : "no"); +} + + +void dmagic_f018_device::map(address_map &map) +{ + map(0, 0).lw8( + NAME([this] (offs_t offset, u8 data) { + m_dmalist_address &= 0xffff00; + m_dmalist_address |= data; + execute(m_dmalist_address); + }) + ); + map(1, 1).lw8( + NAME([this] (offs_t offset, u8 data) { + m_dmalist_address &= 0xff00ff; + m_dmalist_address |= data << 8; + }) + ); + map(2, 2).lw8( + NAME([this] (offs_t offset, u8 data) { + m_dmalist_address &= 0x00ffff; + m_dmalist_address |= data << 16; + }) + ); +// 3 read status +} + +namespace { + class c65_state : public driver_device { public: @@ -38,6 +171,7 @@ class c65_state : public driver_device , m_maincpu(*this, "maincpu") , m_cia(*this, "cia_%u", 0U) , m_sid(*this, "sid_%u", 0U) + , m_dma(*this, "dma") , m_cia_view(*this, "cia_view") , m_screen(*this, "screen") , m_palette(*this, "palette") @@ -45,7 +179,6 @@ class c65_state : public driver_device , m_palred(*this, "redpal") , m_palgreen(*this, "greenpal") , m_palblue(*this, "bluepal") - , m_dmalist(*this, "dmalist") , m_cram(*this, "cram") , m_gfxdecode(*this, "gfxdecode") , m_ipl_rom(*this, "ipl") @@ -55,6 +188,7 @@ class c65_state : public driver_device required_device m_maincpu; required_device_array m_cia; required_device_array m_sid; + required_device m_dma; memory_view m_cia_view; required_device m_screen; required_device m_palette; @@ -62,7 +196,6 @@ class c65_state : public driver_device required_shared_ptr m_palred; required_shared_ptr m_palgreen; required_shared_ptr m_palblue; - required_shared_ptr m_dmalist; required_shared_ptr m_cram; required_device m_gfxdecode; required_memory_region m_ipl_rom; @@ -77,7 +210,6 @@ class c65_state : public driver_device void PalBlue_w(offs_t offset, uint8_t data); uint8_t uart_r(offs_t offset); void uart_w(offs_t offset, uint8_t data); - void DMAgic_w(address_space &space, offs_t offset, uint8_t data); uint8_t cia0_porta_r(); void cia0_porta_w(uint8_t data); uint8_t cia0_portb_r(); @@ -110,7 +242,6 @@ class c65_state : public driver_device /* 0x31: video modes */ uint8_t m_VIC3_ControlB = 0U; void PalEntryFlush(uint8_t offset); - void DMAgicExecute(address_space &space,uint32_t address); void IRQCheck(uint8_t irq_cause); }; @@ -273,80 +404,6 @@ void c65_state::PalBlue_w(offs_t offset, uint8_t data) PalEntryFlush(offset); } - -void c65_state::DMAgicExecute(address_space &space,uint32_t address) -{ - uint8_t cmd;// = space.read_byte(address++); - uint16_t length; //= space.read_byte(address++); - uint32_t src, dst; - static const char *const dma_cmd_string[] = - { - "COPY", - "MIX", - "SWAP", - "FILL" - }; - cmd = space.read_byte(address++); - length = space.read_byte(address++); - length|=(space.read_byte(address++)<<8); - src = space.read_byte(address++); - src|=(space.read_byte(address++)<<8); - src|=(space.read_byte(address++)<<16); - dst = space.read_byte(address++); - dst|=(space.read_byte(address++)<<8); - dst|=(space.read_byte(address++)<<16); - - if(cmd & 0xfc) - logerror("%02x\n",cmd & 0xfc); - switch(cmd & 3) - { - case 0: // copy - TODO: untested - { - if(length != 1) - logerror("DMAgic %s %02x -> %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src,dst,length,cmd & 4 ? "yes" : "no"); - uint32_t SourceIndex; - uint32_t DestIndex; - uint16_t SizeIndex; - SourceIndex = src & 0xfffff; - DestIndex = dst & 0xfffff; - SizeIndex = length; - do - { - space.write_byte(DestIndex++,space.read_byte(SourceIndex++)); - SizeIndex--; - }while(SizeIndex != 0); - - return; - } - case 3: // fill - { - /* TODO: upper bits of source */ - logerror("DMAgic %s %02x -> %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src & 0xff,dst,length,cmd & 4 ? "yes" : "no"); - uint8_t FillValue; - uint32_t DestIndex; - uint16_t SizeIndex; - FillValue = src & 0xff; - DestIndex = dst & 0xfffff; - SizeIndex = length; - do - { - space.write_byte(DestIndex++,FillValue); - SizeIndex--; - }while(SizeIndex != 0); - } - return; - } - logerror("DMAgic %s %08x %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src,dst,length,cmd & 4 ? "yes" : "no"); -} - - -void c65_state::DMAgic_w(address_space &space, offs_t offset, uint8_t data) -{ - m_dmalist[offset] = data; - if(offset == 0) - DMAgicExecute(space,(m_dmalist[0])|(m_dmalist[1]<<8)|(m_dmalist[2]<<16)); -} - uint8_t c65_state::uart_r(offs_t offset) { switch (offset) @@ -427,8 +484,8 @@ void c65_state::c65_map(address_map &map) // 0x0d440, 0x0d4*f Left SID map(0x0d440, 0x0d45f).rw(m_sid[0], FUNC(mos6581_device::read), FUNC(mos6581_device::write)); map(0x0d600, 0x0d6ff).rw(FUNC(c65_state::uart_r), FUNC(c65_state::uart_w)); - map(0x0d700, 0x0d702).w(FUNC(c65_state::DMAgic_w)).share("dmalist"); // 0x0d700, 0x0d7** DMAgic - //map(0x0d703, 0x0d703).r(FUNC(c65_state::DMAgic_r)); + // 0x0d700, 0x0d7** DMAgic + map(0x0d700, 0x0d703).m(m_dma, FUNC(dmagic_f018_device::map)); // 0x0d800, 0x0d8** Color matrix map(0x0d800, 0x0dfff).view(m_cia_view); // maps lower 1024 bytes regardless of the setting (essentially touches $dc00 as overlay) @@ -630,6 +687,9 @@ void c65_state::c65(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &c65_state::c65_map); m_maincpu->set_vblank_int("screen", FUNC(c65_state::vic3_vblank_irq)); + DMAGIC_F018(config, m_dma, MAIN_CLOCK); + m_dma->set_space(m_maincpu, AS_PROGRAM); + MOS6526(config, m_cia[0], MAIN_CLOCK); m_cia[0]->set_tod_clock(60); m_cia[0]->irq_wr_callback().set(FUNC(c65_state::cia0_irq)); @@ -718,5 +778,7 @@ void c65_state::init_c65pal() // m_pal = 1; } +} // anonymous namespace + COMP( 1991, c65, 0, 0, c65, c65, c65_state, init_c65, "Commodore Business Machines", "Commodore 65 Development System (Prototype, NTSC)", MACHINE_NOT_WORKING ) COMP( 1991, c64dx, c65, 0, c65, c65, c65_state, init_c65pal, "Commodore Business Machines", "Commodore 64DX Development System (Prototype, PAL, German)", MACHINE_NOT_WORKING ) From e5011b3f0c4f93822ee0c0166ca50d83909ffa4b Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 28 Jul 2024 21:33:36 +0200 Subject: [PATCH 02/11] New working systems ------------------- Kasparov Blitz [hap, Berger] --- src/mame/chess/conic_cchess2.cpp | 2 +- src/mame/excalibur/mirage.cpp | 6 +- src/mame/layout/saitek_blitz.lay | 374 +++++++++++++++++++++++++++++++ src/mame/mame.lst | 3 + src/mame/saitek/blitz.cpp | 356 +++++++++++++++++++++++++++++ src/mame/saitek/mark5.cpp | 20 +- src/mame/saitek/prisma.cpp | 5 +- 7 files changed, 756 insertions(+), 10 deletions(-) create mode 100644 src/mame/layout/saitek_blitz.lay create mode 100644 src/mame/saitek/blitz.cpp diff --git a/src/mame/chess/conic_cchess2.cpp b/src/mame/chess/conic_cchess2.cpp index b94c3a00b7b..c1196a3cc8b 100644 --- a/src/mame/chess/conic_cchess2.cpp +++ b/src/mame/chess/conic_cchess2.cpp @@ -75,7 +75,7 @@ class cchess2_state : public driver_device u8 m_inp_mux = 0; u8 m_led_data = 0; - int m_dac_on = 0; + u8 m_dac_on = 0; // address maps void main_map(address_map &map); diff --git a/src/mame/excalibur/mirage.cpp b/src/mame/excalibur/mirage.cpp index 6c32938a06d..5fe5ab68181 100644 --- a/src/mame/excalibur/mirage.cpp +++ b/src/mame/excalibur/mirage.cpp @@ -15,8 +15,8 @@ of the chessboard. Hardware notes: - PCB label: EXCALIBUR ELECTRONICS, INC. 6/5/96, MIRAGE, 00-55052-000 -- Hitachi H8/3256 MCU (only 32KB out of 48KB internal ROM used), either mask ROM - or OTP ROM, 20MHz XTAL +- Hitachi H8/3256 MCU (only 32KB out of 48KB internal ROM used), either Mask ROM + or PROM, 20MHz XTAL - 2*L293DNE motor drivers, 2 DC motors (like a plotter), electromagnet under the chessboard for automatically moving the pieces - LCD with 5 7segs and custom segments @@ -27,7 +27,7 @@ most likely the same hardware. TODO: - like fphantom, sensorboard undo buffer fills up pretty quickly -- dump/add OTP version, maybe they improved the motor drift issue? +- dump/add PROM version, maybe they improved the motor drift issue? - it does a cold boot at every reset, so nvram won't work properly unless MAME adds some kind of auxillary autosave state feature at power-off diff --git a/src/mame/layout/saitek_blitz.lay b/src/mame/layout/saitek_blitz.lay new file mode 100644 index 00000000000..29fc0f440c0 --- /dev/null +++ b/src/mame/layout/saitek_blitz.lay @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mame/mame.lst b/src/mame/mame.lst index 37b9ae54fc4..a94476f1ef5 100644 --- a/src/mame/mame.lst +++ b/src/mame/mame.lst @@ -38804,6 +38804,9 @@ r9751 // ROLM 9751 phone system @source:sage/sage2.cpp sage2 +@source:saitek/blitz.cpp +kblitz + @source:saitek/chessac.cpp chessac schachak diff --git a/src/mame/saitek/blitz.cpp b/src/mame/saitek/blitz.cpp new file mode 100644 index 00000000000..7b7fca36c11 --- /dev/null +++ b/src/mame/saitek/blitz.cpp @@ -0,0 +1,356 @@ +// license:BSD-3-Clause +// copyright-holders:hap +// thanks-to:Berger +/******************************************************************************* + +Saitek Kasparov Blitz (model 291) + +NOTE: Turn the power switch off before exiting MAME, otherwise NVRAM won't save +properly. + +This is the last Saitek chess computer with Julio Kaplan's involement (Heuristic +Software), although Craig Barnes continued working for Saitek. Julio Kaplan kept +programming his chess engine for a few more years, he stopped altogether after +the release of Kasparov's Gambit (Socrates II) for MS-DOS in 1993. + +At first power-on, the chessboard gets calibrated, this is done automatically +in MAME. Not counting the chessboard, the whole user interface is with 2 vertical +dials at the right edge. There are no pushbuttons. + +Hardware notes: +- PCB label: SA9-PE-020 REV3, P/N 51290-02013 +- Hitachi H8/325 MCU (either Mask ROM or PROM), 20MHz XTAL +- LCD with 10 7segs and custom segments +- piezo, 64 LEDs, metal sensors chessboard*, 2 dials + +*: The chessboard technology is not with magnets (reed switches or hall effect +sensors). There are of copper wires beneath the chessboard, each square resembles +a metal detector. Chess pieces have aluminium washers at the bottom. + +TODO: +- if/when MAME supports an exit callback, hook up power-off switch to that +- dump/add newer Mask ROM version (might be same ROM contents) + +*******************************************************************************/ + +#include "emu.h" + +#include "cpu/h8/h8325.h" +#include "machine/sensorboard.h" +#include "sound/spkrdev.h" +#include "video/pwm.h" + +#include "screen.h" +#include "speaker.h" + +// internal artwork +#include "saitek_blitz.lh" + + +namespace { + +class blitz_state : public driver_device +{ +public: + blitz_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_board(*this, "board"), + m_led_pwm(*this, "led_pwm"), + m_lcd_pwm(*this, "lcd_pwm"), + m_dac(*this, "dac"), + m_inputs(*this, "IN.0"), + m_out_lcd(*this, "s%u.%u", 0U, 0U) + { } + + void blitz(machine_config &config); + + DECLARE_INPUT_CHANGED_MEMBER(power_off) { m_power = false; } + +protected: + virtual void machine_start() override; + virtual void machine_reset() override { m_power = true; } + +private: + // devices/pointers + required_device m_maincpu; + required_device m_board; + required_device m_led_pwm; + required_device m_lcd_pwm; + required_device m_dac; + required_ioport m_inputs; + output_finder<4, 22> m_out_lcd; + + u8 m_inp_mux = 0; + u8 m_sensor_strength = 0; + bool m_sensor_state = false; + u32 m_lcd_segs = 0; + u8 m_lcd_com = 0; + bool m_power = false; + + u8 m_port3 = 0xff; + u8 m_port6 = 0xff; + + attotime m_board_init_time; + + void init_board(u8 data); + bool board_active() { return machine().time() > m_board_init_time; } + + // I/O handlers + void standby(int state); + u8 power_r(); + + void lcd_pwm_w(offs_t offset, u8 data); + void update_lcd(); + template void lcd_segs_w(u8 data); + + void p1_w(u8 data); + void p2_w(u8 data); + u8 p3_r(); + void p3_w(u8 data); + u8 p6_r(); + void p6_w(u8 data); +}; + +void blitz_state::machine_start() +{ + m_out_lcd.resolve(); + + // register for savestates + save_item(NAME(m_inp_mux)); + save_item(NAME(m_sensor_strength)); + save_item(NAME(m_sensor_state)); + save_item(NAME(m_lcd_segs)); + save_item(NAME(m_lcd_com)); + save_item(NAME(m_power)); + save_item(NAME(m_port3)); + save_item(NAME(m_port6)); + save_item(NAME(m_board_init_time)); +} + +void blitz_state::init_board(u8 data) +{ + // briefly deactivate board after a cold boot to give it time to calibrate + if (~data & 1) + m_board_init_time = machine().time() + attotime::from_msec(1750); +} + + + +/******************************************************************************* + I/O +*******************************************************************************/ + +// power + +void blitz_state::standby(int state) +{ + // clear display + if (state) + { + m_lcd_pwm->clear(); + m_led_pwm->clear(); + } +} + +u8 blitz_state::power_r() +{ + // P46: power switch state + return m_power ? 0xbf : 0xff; +} + + +// LCD + +void blitz_state::lcd_pwm_w(offs_t offset, u8 data) +{ + m_out_lcd[offset & 0x3f][offset >> 6] = data; +} + +void blitz_state::update_lcd() +{ + u32 lcd_segs = bitswap<22>(m_lcd_segs,26,27,28,29,30,31,0,1,2,3,4,5,19,7,8,9,10,11,12,13,24,25); + + for (int i = 0; i < 4; i++) + { + // LCD common is analog (voltage level) + const u8 com = population_count_32(m_lcd_com >> (i * 2) & 3); + const u32 data = (com == 0) ? lcd_segs : (com == 2) ? ~lcd_segs : 0; + m_lcd_pwm->write_row(i, data); + } +} + +template +void blitz_state::lcd_segs_w(u8 data) +{ + // P4x, P5x, P63, P7x: LCD segments + const u8 shift = 8 * N; + m_lcd_segs = (m_lcd_segs & ~(0xff << shift)) | (data << shift); + update_lcd(); +} + + +// misc + +void blitz_state::p1_w(u8 data) +{ + // P10-P15: board sensor strength (higher is more sensitive) + m_sensor_strength = bitswap<6>(data,0,1,2,3,4,5); + + // P16: ext power (no need to emulate it) +} + +void blitz_state::p2_w(u8 data) +{ + // P20-P27: LED select + m_led_pwm->write_my(~data); +} + +u8 blitz_state::p3_r() +{ + // P37: board sensor state + return m_sensor_state ? 0x7f : 0xff; +} + +void blitz_state::p3_w(u8 data) +{ + // P36: reset board sensor on falling edge + if (m_port3 & ~data & 0x40) + { + // P30-P32: board x + // P33-P35: board y + const u8 x = data & 7; + const u8 y = data >> 3 & 7; + const u8 s = m_sensor_strength; + + m_sensor_state = (s > 0x38) || (s > 0x30 && board_active() && m_board->read_sensor(x, y)); + } + + m_port3 = data; +} + +u8 blitz_state::p6_r() +{ + // P66: multiplexed inputs + return (m_inp_mux & m_inputs->read()) ? 0xbf : 0xff; +} + +void blitz_state::p6_w(u8 data) +{ + // P62: speaker out + m_dac->level_w(BIT(data, 2)); + + // P60: 74164(1) CP + // P61: 74164(1) DSB, outputs to input mux / LED data + if (~m_port6 & data & 1) + m_inp_mux = m_inp_mux << 1 | BIT(~data, 1); + m_led_pwm->write_mx(m_inp_mux); + + // P64: 74164(2) CP + // P65: 74164(2) DSB, output to LCD commons + if (~m_port6 & data & 0x10) + m_lcd_com = m_lcd_com << 1 | BIT(data, 5); + + m_port6 = data; + update_lcd(); +} + + + +/******************************************************************************* + Input Ports +*******************************************************************************/ + +// mode dial, rotary switch with 12 stops (duplicate halves) +// 1: ready, 2: options, 3: info, 4: game, 5: set up, 6: level +static const ioport_value mode_dial[6] = { 5, 1, 2, 4, 6, 3 }; + +// shuttle dial, free running dial with 6 magnets and 2 reed switches +static const ioport_value shuttle_dial[4] = { 0, 1, 3, 2 }; + +static INPUT_PORTS_START( blitz ) + PORT_START("IN.0") + PORT_BIT(0x07, 0x00, IPT_POSITIONAL_V) PORT_POSITIONS(6) PORT_WRAPS PORT_REMAP_TABLE(mode_dial) PORT_SENSITIVITY(4) PORT_KEYDELTA(1) PORT_CENTERDELTA(0) PORT_NAME("Mode Dial") + PORT_BIT(0x18, 0x00, IPT_POSITIONAL_H) PORT_POSITIONS(4) PORT_WRAPS PORT_REMAP_TABLE(shuttle_dial) PORT_SENSITIVITY(12) PORT_KEYDELTA(1) PORT_CENTERDELTA(0) PORT_NAME("Shuttle Dial") + PORT_BIT(0x60, IP_ACTIVE_HIGH, IPT_CUSTOM) // freq sel + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN) + + PORT_START("POWER") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_OTHER) PORT_CODE(KEYCODE_F1) PORT_CHANGED_MEMBER(DEVICE_SELF, blitz_state, power_off, 0) PORT_NAME("Power Off") +INPUT_PORTS_END + + + +/******************************************************************************* + Machine Configs +*******************************************************************************/ + +void blitz_state::blitz(machine_config &config) +{ + // basic machine hardware + H8325(config, m_maincpu, 20_MHz_XTAL); + m_maincpu->nvram_enable_backup(true); + m_maincpu->nvram_set_default_value(~0); + m_maincpu->standby_cb().set(m_maincpu, FUNC(h8325_device::nvram_set_battery)); + m_maincpu->standby_cb().append(FUNC(blitz_state::standby)); + m_maincpu->write_port1().set(FUNC(blitz_state::p1_w)); + m_maincpu->write_port2().set(FUNC(blitz_state::p2_w)); + m_maincpu->read_port3().set(FUNC(blitz_state::p3_r)); + m_maincpu->write_port3().set(FUNC(blitz_state::p3_w)); + m_maincpu->read_port4().set(FUNC(blitz_state::power_r)); + m_maincpu->write_port4().set(FUNC(blitz_state::lcd_segs_w<0>)); + m_maincpu->write_port5().set(FUNC(blitz_state::lcd_segs_w<1>)); + m_maincpu->read_port6().set(FUNC(blitz_state::p6_r)); + m_maincpu->write_port6().set(FUNC(blitz_state::p6_w)); + m_maincpu->write_port6().append(FUNC(blitz_state::lcd_segs_w<2>)); + m_maincpu->write_port7().set(FUNC(blitz_state::lcd_segs_w<3>)); + + SENSORBOARD(config, m_board).set_type(sensorboard_device::MAGNETS); + m_board->init_cb().set(m_board, FUNC(sensorboard_device::preset_chess)); + m_board->init_cb().append(FUNC(blitz_state::init_board)); + m_board->set_delay(attotime::from_msec(150)); + m_board->set_nvram_enable(true); + + // video hardware + PWM_DISPLAY(config, m_lcd_pwm).set_size(4, 22); + m_lcd_pwm->output_x().set(FUNC(blitz_state::lcd_pwm_w)); + + screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_SVG)); + screen.set_refresh_hz(60); + screen.set_size(1920/5, 406/5); + screen.set_visarea_full(); + + PWM_DISPLAY(config, m_led_pwm).set_size(8, 8); + m_led_pwm->set_bri_levels(0.15); + + config.set_default_layout(layout_saitek_blitz); + + // sound hardware + SPEAKER(config, "speaker").front_center(); + SPEAKER_SOUND(config, m_dac).add_route(ALL_OUTPUTS, "speaker", 0.25); +} + + + +/******************************************************************************* + ROM Definitions +*******************************************************************************/ + +ROM_START( kblitz ) + ROM_REGION16_BE( 0x8000, "maincpu", 0 ) + ROM_LOAD("h8_325_hd6473258p10_sa9_702g.u1", 0x0000, 0x8000, CRC(a5d17819) SHA1(e46c0b70aff31809ae02a5c5973935cf118f2324) ) + + ROM_REGION( 94712, "screen", 0 ) + ROM_LOAD("kblitz.svg", 0, 94712, CRC(b3bda86b) SHA1(9b64d3d6f6a275acd05a0f78899a5aee48d6b86b) ) +ROM_END + +} // anonymous namespace + + + +/******************************************************************************* + Drivers +*******************************************************************************/ + +// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY, FULLNAME, FLAGS +SYST( 1990, kblitz, 0, 0, blitz, blitz, blitz_state, empty_init, "Saitek / Heuristic Software", "Kasparov Blitz", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/saitek/mark5.cpp b/src/mame/saitek/mark5.cpp index a5f1b6d9334..22ea1faac58 100644 --- a/src/mame/saitek/mark5.cpp +++ b/src/mame/saitek/mark5.cpp @@ -13,9 +13,6 @@ by Nick Toop. These credits are in the ROM data. Mark VI/Philidor was released a year later, it was a plug-in module for the Mark V. It's not much stronger than Mark V(retroactively called Mark V/Travemunde). -When using the MAME sensorboard interface with MK VI, reset the board by pressing -CLEAR before RESET, needed when starting a new game. - Hardware notes: - SY6502A @ ~2MHz (19.6608MHz XTAL, bunch of 74113 dividers) - 16KB RAM (8*HM4716AP-4N) @@ -106,7 +103,11 @@ class mark5_state : public driver_device u8 m_lcd_rowsel = 0; u8 m_cb_mux = 0; - emu_timer *m_irqtimer = nullptr; + attotime m_board_init_time; + emu_timer *m_irqtimer; + + void init_board(u8 data); + bool board_active() { return machine().time() > m_board_init_time; } // address maps void mark5_map(address_map &map); @@ -142,6 +143,7 @@ void mark5_state::machine_start() save_item(NAME(m_lcd_lcd)); save_item(NAME(m_lcd_rowsel)); save_item(NAME(m_cb_mux)); + save_item(NAME(m_board_init_time)); } void mark5_state::machine_reset() @@ -149,6 +151,13 @@ void mark5_state::machine_reset() reset_irq_w(0); } +void mark5_state::init_board(u8 data) +{ + // ccmk6 expects an empty chessboard after a cold boot + if (~data & 1) + m_board_init_time = machine().time() + attotime::from_msec(1500); +} + /******************************************************************************* @@ -272,7 +281,7 @@ void mark5_state::cb_w(u8 data) u8 mark5_state::cb_r() { - if (~m_inputs[6]->read() & 0x20) + if (~m_inputs[6]->read() & 0x20 || !board_active()) return 0xff; // read chessboard sensors @@ -454,6 +463,7 @@ void mark5_state::mark6(machine_config &config) SENSORBOARD(config, m_board).set_type(sensorboard_device::MAGNETS); m_board->init_cb().set(m_board, FUNC(sensorboard_device::preset_chess)); + m_board->init_cb().append(FUNC(mark5_state::init_board)); m_board->set_delay(attotime::from_msec(150)); m_board->set_nvram_enable(true); diff --git a/src/mame/saitek/prisma.cpp b/src/mame/saitek/prisma.cpp index 905ee577058..ab208df821e 100644 --- a/src/mame/saitek/prisma.cpp +++ b/src/mame/saitek/prisma.cpp @@ -22,6 +22,9 @@ Hardware notes: In 1992, it was also sold by Tandy as Chess Champion 2150L, still manufactured by Saitek. Overall, the hardware is the same, but with a slower CPU (16MHz XTAL). +TODO: +- are older versions of Prisma on PROM H8/325 just like with Blitz? + *******************************************************************************/ #include "emu.h" @@ -162,7 +165,7 @@ void prisma_state::lcd_output_w(offs_t offset, u64 data) } -// MCU ports +// misc void prisma_state::update_leds() { From b57ea51ab179d9b14e0e79300976feb454db6c9a Mon Sep 17 00:00:00 2001 From: hap Date: Mon, 29 Jul 2024 00:31:53 +0200 Subject: [PATCH 03/11] blitz: add note about calibration --- src/mame/saitek/blitz.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mame/saitek/blitz.cpp b/src/mame/saitek/blitz.cpp index 7b7fca36c11..3098de09c21 100644 --- a/src/mame/saitek/blitz.cpp +++ b/src/mame/saitek/blitz.cpp @@ -8,7 +8,7 @@ Saitek Kasparov Blitz (model 291) NOTE: Turn the power switch off before exiting MAME, otherwise NVRAM won't save properly. -This is the last Saitek chess computer with Julio Kaplan's involement (Heuristic +This is the last Saitek chess computer with Julio Kaplan's involvement (Heuristic Software), although Craig Barnes continued working for Saitek. Julio Kaplan kept programming his chess engine for a few more years, he stopped altogether after the release of Kasparov's Gambit (Socrates II) for MS-DOS in 1993. @@ -17,6 +17,11 @@ At first power-on, the chessboard gets calibrated, this is done automatically in MAME. Not counting the chessboard, the whole user interface is with 2 vertical dials at the right edge. There are no pushbuttons. +If chessboard calibration goes wrong somehow (eg. it wrongly tells you to place +a piece on a square, thinking the square is empty): clear the sensorboard, go to +options and select calibration, wait until the "board clr?" message goes away, +and then reset the sensorboard. + Hardware notes: - PCB label: SA9-PE-020 REV3, P/N 51290-02013 - Hitachi H8/325 MCU (either Mask ROM or PROM), 20MHz XTAL From 505e403f7de8a2ec79985091da224bc596cc273c Mon Sep 17 00:00:00 2001 From: hap Date: Mon, 29 Jul 2024 19:03:55 +0200 Subject: [PATCH 04/11] New working clones ------------------ Kasparov Blitz (set 1) [Berger] --- src/devices/bus/odyssey2/chess.cpp | 3 ++- src/mame/mame.lst | 1 + src/mame/saitek/blitz.cpp | 24 ++++++++++++++++-------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/devices/bus/odyssey2/chess.cpp b/src/devices/bus/odyssey2/chess.cpp index 1e63062af7a..80b807d769e 100644 --- a/src/devices/bus/odyssey2/chess.cpp +++ b/src/devices/bus/odyssey2/chess.cpp @@ -3,7 +3,8 @@ /****************************************************************************** Videopac C7010 Chess Module emulation -The chess engine is "Gambiet", written by Wim Rens + +The chess engine is Wim Rens's Gambiet, evidently based on the 1980 version. Hardware notes: - NSC800 (Z80-compatible) @ 4.43MHz diff --git a/src/mame/mame.lst b/src/mame/mame.lst index a94476f1ef5..618ddbea855 100644 --- a/src/mame/mame.lst +++ b/src/mame/mame.lst @@ -38806,6 +38806,7 @@ sage2 @source:saitek/blitz.cpp kblitz +kblitza @source:saitek/chessac.cpp chessac diff --git a/src/mame/saitek/blitz.cpp b/src/mame/saitek/blitz.cpp index 3098de09c21..ad8f9c45b80 100644 --- a/src/mame/saitek/blitz.cpp +++ b/src/mame/saitek/blitz.cpp @@ -23,7 +23,7 @@ options and select calibration, wait until the "board clr?" message goes away, and then reset the sensorboard. Hardware notes: -- PCB label: SA9-PE-020 REV3, P/N 51290-02013 +- PCB label: SA9-PE-020 REV 3/4 - Hitachi H8/325 MCU (either Mask ROM or PROM), 20MHz XTAL - LCD with 10 7segs and custom segments - piezo, 64 LEDs, metal sensors chessboard*, 2 dials @@ -34,7 +34,6 @@ a metal detector. Chess pieces have aluminium washers at the bottom. TODO: - if/when MAME supports an exit callback, hook up power-off switch to that -- dump/add newer Mask ROM version (might be same ROM contents) *******************************************************************************/ @@ -275,8 +274,8 @@ static const ioport_value shuttle_dial[4] = { 0, 1, 3, 2 }; static INPUT_PORTS_START( blitz ) PORT_START("IN.0") - PORT_BIT(0x07, 0x00, IPT_POSITIONAL_V) PORT_POSITIONS(6) PORT_WRAPS PORT_REMAP_TABLE(mode_dial) PORT_SENSITIVITY(4) PORT_KEYDELTA(1) PORT_CENTERDELTA(0) PORT_NAME("Mode Dial") - PORT_BIT(0x18, 0x00, IPT_POSITIONAL_H) PORT_POSITIONS(4) PORT_WRAPS PORT_REMAP_TABLE(shuttle_dial) PORT_SENSITIVITY(12) PORT_KEYDELTA(1) PORT_CENTERDELTA(0) PORT_NAME("Shuttle Dial") + PORT_BIT(0x07, 0x00, IPT_POSITIONAL_V) PORT_POSITIONS(6) PORT_WRAPS PORT_REMAP_TABLE(mode_dial) PORT_SENSITIVITY(5) PORT_KEYDELTA(1) PORT_CENTERDELTA(0) PORT_NAME("Mode Dial") + PORT_BIT(0x18, 0x00, IPT_POSITIONAL_H) PORT_POSITIONS(4) PORT_WRAPS PORT_REMAP_TABLE(shuttle_dial) PORT_SENSITIVITY(10) PORT_KEYDELTA(1) PORT_CENTERDELTA(0) PORT_NAME("Shuttle Dial") PORT_BIT(0x60, IP_ACTIVE_HIGH, IPT_CUSTOM) // freq sel PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN) @@ -326,7 +325,7 @@ void blitz_state::blitz(machine_config &config) screen.set_visarea_full(); PWM_DISPLAY(config, m_led_pwm).set_size(8, 8); - m_led_pwm->set_bri_levels(0.15); + m_led_pwm->set_bri_levels(0.25); config.set_default_layout(layout_saitek_blitz); @@ -342,7 +341,15 @@ void blitz_state::blitz(machine_config &config) *******************************************************************************/ ROM_START( kblitz ) - ROM_REGION16_BE( 0x8000, "maincpu", 0 ) + ROM_REGION16_BE( 0x8000, "maincpu", 0 ) // serial S004184xx + ROM_LOAD("90_saitek_86058151sa9_3258a03p.u1", 0x0000, 0x8000, CRC(636ccde5) SHA1(c333ea3260892458a9d0c37db849d7d290674f86) ) + + ROM_REGION( 94712, "screen", 0 ) + ROM_LOAD("kblitz.svg", 0, 94712, CRC(b3bda86b) SHA1(9b64d3d6f6a275acd05a0f78899a5aee48d6b86b) ) +ROM_END + +ROM_START( kblitza ) + ROM_REGION16_BE( 0x8000, "maincpu", 0 ) // serial S003078xx ROM_LOAD("h8_325_hd6473258p10_sa9_702g.u1", 0x0000, 0x8000, CRC(a5d17819) SHA1(e46c0b70aff31809ae02a5c5973935cf118f2324) ) ROM_REGION( 94712, "screen", 0 ) @@ -357,5 +364,6 @@ ROM_END Drivers *******************************************************************************/ -// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY, FULLNAME, FLAGS -SYST( 1990, kblitz, 0, 0, blitz, blitz, blitz_state, empty_init, "Saitek / Heuristic Software", "Kasparov Blitz", MACHINE_SUPPORTS_SAVE ) +// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY, FULLNAME, FLAGS +SYST( 1990, kblitz, 0, 0, blitz, blitz, blitz_state, empty_init, "Saitek / Heuristic Software", "Kasparov Blitz (set 1)", MACHINE_SUPPORTS_SAVE ) +SYST( 1990, kblitza, kblitz, 0, blitz, blitz, blitz_state, empty_init, "Saitek / Heuristic Software", "Kasparov Blitz (set 2)", MACHINE_SUPPORTS_SAVE ) From 1aa8abc3e5d97966f6167a083a48eaf704d3b1b1 Mon Sep 17 00:00:00 2001 From: hap Date: Mon, 29 Jul 2024 20:25:16 +0200 Subject: [PATCH 05/11] ioport: offset analog value by half a step because of rounding issue when crossing 0 (crossing 0 now takes 1 step instead of 2, and there's 0.5 step wiggle room at edges) --- src/emu/ioport.cpp | 251 +++++++++++++++++++------------------- src/mame/saitek/mark5.cpp | 4 +- 2 files changed, 128 insertions(+), 127 deletions(-) diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index aed29b6324f..8e8d736f5eb 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -435,22 +435,22 @@ void ioport_list::append(device_t &device, std::string &errorbuf) // input_type_entry - constructors //------------------------------------------------- -input_type_entry::input_type_entry(ioport_type type, ioport_group group, int player, const char *token, const char *name, input_seq standard) noexcept - : m_type(type), - m_group(group), - m_player(player), - m_token(token), - m_name(name) +input_type_entry::input_type_entry(ioport_type type, ioport_group group, int player, const char *token, const char *name, input_seq standard) noexcept : + m_type(type), + m_group(group), + m_player(player), + m_token(token), + m_name(name) { m_defseq[SEQ_TYPE_STANDARD] = m_seq[SEQ_TYPE_STANDARD] = standard; } -input_type_entry::input_type_entry(ioport_type type, ioport_group group, int player, const char *token, const char *name, input_seq standard, input_seq decrement, input_seq increment) noexcept - : m_type(type), - m_group(group), - m_player(player), - m_token(token), - m_name(name) +input_type_entry::input_type_entry(ioport_type type, ioport_group group, int player, const char *token, const char *name, input_seq standard, input_seq decrement, input_seq increment) noexcept : + m_type(type), + m_group(group), + m_player(player), + m_token(token), + m_name(name) { m_defseq[SEQ_TYPE_STANDARD] = m_seq[SEQ_TYPE_STANDARD] = standard; m_defseq[SEQ_TYPE_INCREMENT] = m_seq[SEQ_TYPE_INCREMENT] = increment; @@ -520,12 +520,12 @@ void input_type_entry::restore_default_seq() noexcept // digital_joystick - constructor //------------------------------------------------- -digital_joystick::digital_joystick(int player, int number) - : m_player(player), - m_number(number), - m_current(0), - m_current4way(0), - m_previous(0) +digital_joystick::digital_joystick(int player, int number) : + m_player(player), + m_number(number), + m_current(0), + m_current4way(0), + m_previous(0) { } @@ -662,10 +662,10 @@ void ioport_condition::initialize(device_t &device) // ioport_setting - constructor //------------------------------------------------- -ioport_setting::ioport_setting(ioport_field &field, ioport_value _value, const char *_name) - : m_field(field), - m_value(_value), - m_name(_name) +ioport_setting::ioport_setting(ioport_field &field, ioport_value _value, const char *_name) : + m_field(field), + m_value(_value), + m_name(_name) { } @@ -679,10 +679,10 @@ ioport_setting::ioport_setting(ioport_field &field, ioport_value _value, const c // ioport_diplocation - constructor //------------------------------------------------- -ioport_diplocation::ioport_diplocation(const char *name, u8 swnum, bool invert) - : m_name(name), - m_number(swnum), - m_invert(invert) +ioport_diplocation::ioport_diplocation(const char *name, u8 swnum, bool invert) : + m_name(name), + m_number(swnum), + m_invert(invert) { } @@ -696,34 +696,34 @@ ioport_diplocation::ioport_diplocation(const char *name, u8 swnum, bool invert) // ioport_field - constructor //------------------------------------------------- -ioport_field::ioport_field(ioport_port &port, ioport_type type, ioport_value defvalue, ioport_value maskbits, const char *name) - : m_next(nullptr), - m_port(port), - m_modcount(port.modcount()), - m_mask(maskbits), - m_defvalue(defvalue & maskbits), - m_type(type), - m_player(0), - m_flags(0), - m_impulse(0), - m_name(name), - m_read(port.device()), - m_write(port.device()), - m_write_param(0), - m_digital_value(false), - m_min(0), - m_max(maskbits), - m_sensitivity(0), - m_delta(0), - m_centerdelta(0), - m_crosshair_axis(CROSSHAIR_AXIS_NONE), - m_crosshair_scale(1.0), - m_crosshair_offset(0), - m_crosshair_altaxis(0), - m_crosshair_mapper(port.device()), - m_full_turn_count(0), - m_remap_table(nullptr), - m_way(0) +ioport_field::ioport_field(ioport_port &port, ioport_type type, ioport_value defvalue, ioport_value maskbits, const char *name) : + m_next(nullptr), + m_port(port), + m_modcount(port.modcount()), + m_mask(maskbits), + m_defvalue(defvalue & maskbits), + m_type(type), + m_player(0), + m_flags(0), + m_impulse(0), + m_name(name), + m_read(port.device()), + m_write(port.device()), + m_write_param(0), + m_digital_value(false), + m_min(0), + m_max(maskbits), + m_sensitivity(0), + m_delta(0), + m_centerdelta(0), + m_crosshair_axis(CROSSHAIR_AXIS_NONE), + m_crosshair_scale(1.0), + m_crosshair_offset(0), + m_crosshair_altaxis(0), + m_crosshair_mapper(port.device()), + m_full_turn_count(0), + m_remap_table(nullptr), + m_way(0) { // reset sequences and chars for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype) @@ -1453,15 +1453,15 @@ void ioport_field::init_live_state(analog_field *analog) // ioport_field_live - constructor //------------------------------------------------- -ioport_field_live::ioport_field_live(ioport_field &field, analog_field *analog) - : analog(analog), - joystick(nullptr), - value(field.defvalue()), - impulse(0), - last(0), - toggle(field.toggle()), - joydir(digital_joystick::JOYDIR_COUNT), - lockout(false) +ioport_field_live::ioport_field_live(ioport_field &field, analog_field *analog) : + analog(analog), + joystick(nullptr), + value(field.defvalue()), + impulse(0), + last(0), + toggle(field.toggle()), + joydir(digital_joystick::JOYDIR_COUNT), + lockout(false) { // fill in the basic values for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype) @@ -1509,12 +1509,12 @@ ioport_field_live::ioport_field_live(ioport_field &field, analog_field *analog) // ioport_port - constructor //------------------------------------------------- -ioport_port::ioport_port(device_t &owner, const char *tag) - : m_next(nullptr), - m_device(owner), - m_tag(tag), - m_modcount(0), - m_active(0) +ioport_port::ioport_port(device_t &owner, const char *tag) : + m_next(nullptr), + m_device(owner), + m_tag(tag), + m_modcount(0), + m_active(0) { } @@ -1733,10 +1733,10 @@ void ioport_port::update_defvalue(bool flush_defaults) // ioport_port_live - constructor //------------------------------------------------- -ioport_port_live::ioport_port_live(ioport_port &port) - : defvalue(0), - digital(0), - outputvalue(0) +ioport_port_live::ioport_port_live(ioport_port &port) : + defvalue(0), + digital(0), + outputvalue(0) { // iterate over fields for (ioport_field &field : port.fields()) @@ -1769,15 +1769,15 @@ ioport_port_live::ioport_port_live(ioport_port &port) // ioport_manager - constructor //------------------------------------------------- -ioport_manager::ioport_manager(running_machine &machine) - : m_machine(machine) - , m_safe_to_read(false) - , m_last_frame_time(attotime::zero) - , m_last_delta_nsec(0) - , m_playback_accumulated_speed(0) - , m_playback_accumulated_frames(0) - , m_deselected_card_config() - , m_applied_device_defaults(false) +ioport_manager::ioport_manager(running_machine &machine) : + m_machine(machine), + m_safe_to_read(false), + m_last_frame_time(attotime::zero), + m_last_delta_nsec(0), + m_playback_accumulated_speed(0), + m_playback_accumulated_frames(0), + m_deselected_card_config(), + m_applied_device_defaults(false) { for (auto &entries : m_type_to_entry) std::fill(std::begin(entries), std::end(entries), nullptr); @@ -3262,13 +3262,13 @@ void ioport_manager::record_port(ioport_port &port) // ioport_configurer - constructor //------------------------------------------------- -ioport_configurer::ioport_configurer(device_t &owner, ioport_list &portlist, std::string &errorbuf) - : m_owner(owner), - m_portlist(portlist), - m_errorbuf(errorbuf), - m_curport(nullptr), - m_curfield(nullptr), - m_cursetting(nullptr) +ioport_configurer::ioport_configurer(device_t &owner, ioport_list &portlist, std::string &errorbuf) : + m_owner(owner), + m_portlist(portlist), + m_errorbuf(errorbuf), + m_curport(nullptr), + m_curfield(nullptr), + m_cursetting(nullptr) { } @@ -3465,10 +3465,10 @@ ioport_configurer& ioport_configurer::onoff_alloc(const char *name, ioport_value // dynamic_field - constructor //------------------------------------------------- -dynamic_field::dynamic_field(ioport_field &field) - : m_field(field) - , m_shift(0) - , m_oldval(field.defvalue()) +dynamic_field::dynamic_field(ioport_field &field) : + m_field(field), + m_shift(0), + m_oldval(field.defvalue()) { // fill in the data for (ioport_value mask = field.mask(); !(mask & 1); mask >>= 1) @@ -3522,36 +3522,36 @@ void dynamic_field::write(ioport_value newval) // analog_field - constructor //------------------------------------------------- -analog_field::analog_field(ioport_field &field) - : m_field(field) - , m_shift(compute_shift(field.mask())) - , m_adjdefvalue((field.defvalue() & field.mask()) >> m_shift) - , m_adjmin((field.minval() & field.mask()) >> m_shift) - , m_adjmax((field.maxval() & field.mask()) >> m_shift) - , m_adjoverride((field.defvalue() & field.mask()) >> m_shift) - , m_sensitivity(field.sensitivity()) - , m_reverse(field.analog_reverse()) - , m_delta(field.delta()) - , m_centerdelta(field.centerdelta()) - , m_accum(0) - , m_previous(0) - , m_previousanalog(0) - , m_minimum(osd::input_device::ABSOLUTE_MIN) - , m_maximum(osd::input_device::ABSOLUTE_MAX) - , m_center(0) - , m_reverse_val(0) - , m_scalepos(0) - , m_scaleneg(0) - , m_keyscalepos(0) - , m_keyscaleneg(0) - , m_positionalscale(0) - , m_absolute(false) - , m_wraps(false) - , m_autocenter(false) - , m_single_scale(false) - , m_interpolate(false) - , m_lastdigital(false) - , m_use_adjoverride(false) +analog_field::analog_field(ioport_field &field) : + m_field(field), + m_shift(compute_shift(field.mask())), + m_adjdefvalue((field.defvalue() & field.mask()) >> m_shift), + m_adjmin((field.minval() & field.mask()) >> m_shift), + m_adjmax((field.maxval() & field.mask()) >> m_shift), + m_adjoverride((field.defvalue() & field.mask()) >> m_shift), + m_sensitivity(field.sensitivity()), + m_reverse(field.analog_reverse()), + m_delta(field.delta()), + m_centerdelta(field.centerdelta()), + m_accum(0), + m_previous(0), + m_previousanalog(0), + m_minimum(osd::input_device::ABSOLUTE_MIN), + m_maximum(osd::input_device::ABSOLUTE_MAX), + m_center(0), + m_reverse_val(0), + m_scalepos(0), + m_scaleneg(0), + m_keyscalepos(0), + m_keyscaleneg(0), + m_positionalscale(0), + m_absolute(false), + m_wraps(false), + m_autocenter(false), + m_single_scale(false), + m_interpolate(false), + m_lastdigital(false), + m_use_adjoverride(false) { // set basic parameters based on the configured type switch (field.type()) @@ -3763,10 +3763,11 @@ s32 analog_field::apply_settings(s32 value) const value -= osd::input_device::ABSOLUTE_MIN; // map differently for positive and negative values + const s32 adjust = m_field.analog_reset() ? 0 : (1 << 23); if (value >= 0) - value = apply_scale(value, m_scalepos); + value = ((s64(value) * m_scalepos) + adjust) / (1 << 24); else - value = apply_scale(value, m_scaleneg); + value = ((s64(value) * m_scaleneg) - adjust) / (1 << 24); value += m_adjdefvalue; // for relative devices, wrap around when we go past the edge diff --git a/src/mame/saitek/mark5.cpp b/src/mame/saitek/mark5.cpp index 22ea1faac58..be57b41150a 100644 --- a/src/mame/saitek/mark5.cpp +++ b/src/mame/saitek/mark5.cpp @@ -352,8 +352,8 @@ static INPUT_PORTS_START( mark5 ) PORT_START("IN.3") PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_6) PORT_CODE(KEYCODE_6_PAD) PORT_CODE(KEYCODE_F) PORT_NAME("F / 6 / King") - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_7) PORT_CODE(KEYCODE_7_PAD) PORT_CODE(KEYCODE_G) PORT_NAME("G / 7 / Black") - PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_8) PORT_CODE(KEYCODE_8_PAD) PORT_CODE(KEYCODE_H) PORT_NAME("H / 8 / White") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_7) PORT_CODE(KEYCODE_7_PAD) PORT_CODE(KEYCODE_G) PORT_NAME("G / 7 / White") + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_8) PORT_CODE(KEYCODE_8_PAD) PORT_CODE(KEYCODE_H) PORT_NAME("H / 8 / Black") PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_9) PORT_CODE(KEYCODE_9_PAD) PORT_CODE(KEYCODE_EQUALS) PORT_CODE(KEYCODE_PLUS_PAD) PORT_NAME("Yes / 9 / CB") PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_PGDN) PORT_NAME("Backward") PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_PGUP) PORT_NAME("Forward") From 6435d1b7b51b489894d816cf93bfdd99ce762d90 Mon Sep 17 00:00:00 2001 From: Mark Garlanger Date: Mon, 29 Jul 2024 20:34:38 -0500 Subject: [PATCH 06/11] heathzenith/mms77316_fdc.cpp: Suppress side effects of data reads for debugger accesses. (#12627) --- src/mame/heathzenith/mms77316_fdc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mame/heathzenith/mms77316_fdc.cpp b/src/mame/heathzenith/mms77316_fdc.cpp index c978791e3ee..621ed6bf922 100644 --- a/src/mame/heathzenith/mms77316_fdc.cpp +++ b/src/mame/heathzenith/mms77316_fdc.cpp @@ -151,7 +151,10 @@ u8 mms77316_fdc_device::data_r() { LOGBURST("%s: burst_mode setting wait state\n", FUNCNAME); - m_wait_cb(ASSERT_LINE); + if (!machine().side_effects_disabled()) + { + m_wait_cb(ASSERT_LINE); + } } else { From c92333ab60a311d7a902899f83f1932919a67712 Mon Sep 17 00:00:00 2001 From: lidnariq Date: Tue, 30 Jul 2024 16:23:59 +0100 Subject: [PATCH 07/11] casio/pv1000.cpp: IRQs were broken in a08b1138: now commercial games work again (#12631) --- src/mame/casio/pv1000.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mame/casio/pv1000.cpp b/src/mame/casio/pv1000.cpp index 7892c2706d2..05f9ef99a77 100644 --- a/src/mame/casio/pv1000.cpp +++ b/src/mame/casio/pv1000.cpp @@ -391,7 +391,7 @@ TIMER_CALLBACK_MEMBER(pv1000_state::d65010_irq_on_cb) int vpos = m_screen->vpos(); int next_vpos = vpos + 4; - if(vpos == 195) + if(vpos == 20) m_fd_buffer_flag |= 1; /* TODO: exact timing of this */ /* Set IRQ line and schedule release of IRQ line */ @@ -399,9 +399,13 @@ TIMER_CALLBACK_MEMBER(pv1000_state::d65010_irq_on_cb) m_irq_off_timer->adjust(m_screen->time_until_pos(vpos, 380/2)); /* Schedule next IRQ trigger */ - if (vpos >= 281) + if (vpos >= 258) { - next_vpos = 221; + next_vpos = 0; // 262=0, 4, 8, 12, 16, 20 + } + else if (vpos >= 20 && vpos < 222) + { + next_vpos = 222; // 226, 230, 234, 238, 242, 246, 250, 254, 258 } m_irq_on_timer->adjust(m_screen->time_until_pos(next_vpos, 224)); } From 1f891897b32b2d6ef75a4445e447f0521e9f191b Mon Sep 17 00:00:00 2001 From: Michael Sanborn <95501796+mikehyrus@users.noreply.github.com> Date: Tue, 30 Jul 2024 09:24:48 -0600 Subject: [PATCH 08/11] igs_fear.cpp - Pubilisher licenses and Chinese title addition for superkds. (#12628) * Fearless Pinocchio was licensed by American Alpha * Super Kids was licensed by Golden Dragon Amusement * Added Chinese title to superkds --- src/mame/igs/igs_fear.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mame/igs/igs_fear.cpp b/src/mame/igs/igs_fear.cpp index b5012567715..a90a752b139 100644 --- a/src/mame/igs/igs_fear.cpp +++ b/src/mame/igs/igs_fear.cpp @@ -819,6 +819,6 @@ void igs_fear_state::init_igs_icescape() } // anonymous namespace -GAME( 2005, superkds, 0, igs_fear, superkds, igs_fear_state, init_igs_superkds, ROT0, "IGS", "Super Kids (S019CN)", 0 ) -GAME( 2006, fearless, 0, igs_fear, fear, igs_fear_state, init_igs_fear, ROT0, "IGS", "Fearless Pinocchio (V101US)", 0 ) -GAME( 2006, icescape, 0, igs_fear, fear, igs_fear_state, init_igs_icescape, ROT0, "IGS", "Icescape (V104FA)", MACHINE_IS_SKELETON ) // IGS FOR V104FA 2006-11-02 +GAME( 2005, superkds, 0, igs_fear, superkds, igs_fear_state, init_igs_superkds, ROT0, "IGS (Golden Dragon Amusement license)", "Super Kids / Jiu Nan Xiao Yingxiong (S019CN)", 0 ) +GAME( 2006, fearless, 0, igs_fear, fear, igs_fear_state, init_igs_fear, ROT0, "IGS (American Alpha license)", "Fearless Pinocchio (V101US)", 0 ) +GAME( 2006, icescape, 0, igs_fear, fear, igs_fear_state, init_igs_icescape, ROT0, "IGS", "Icescape (V104FA)", MACHINE_IS_SKELETON ) // IGS FOR V104FA 2006-11-02 From 4f732878ef4ace721a8fc2595744b046bc136211 Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Tue, 30 Jul 2024 18:18:56 +0200 Subject: [PATCH 09/11] - nmk/nmk16.cpp: improved controls and scrolling for tdragonb2. IRQs related problems remain. - sunelectronics/shangha3.cpp: consolidated driver in single file --- src/mame/nmk/nmk16.cpp | 70 ++- src/mame/nmk/nmk16.h | 2 + src/mame/sega/model1.cpp | 3 +- src/mame/shared/segam1audio.cpp | 2 +- src/mame/sunelectronics/shangha3.cpp | 665 +++++++++++++++++++------ src/mame/sunelectronics/shangha3.h | 91 ---- src/mame/sunelectronics/shangha3_v.cpp | 260 ---------- 7 files changed, 569 insertions(+), 524 deletions(-) delete mode 100644 src/mame/sunelectronics/shangha3.h delete mode 100644 src/mame/sunelectronics/shangha3_v.cpp diff --git a/src/mame/nmk/nmk16.cpp b/src/mame/nmk/nmk16.cpp index 171ec04f2ca..08457b5eadb 100644 --- a/src/mame/nmk/nmk16.cpp +++ b/src/mame/nmk/nmk16.cpp @@ -776,15 +776,22 @@ void nmk16_state::tdragonb2_map(address_map &map) { map(0x000000, 0x03ffff).rom(); map(0x0b0000, 0x0bffff).ram().share("mainram"); + map(0x08e294, 0x08e925).portr("IN1"); map(0x0c0000, 0x0c0001).portr("IN0"); - map(0x0c0002, 0x0c0003).portr("IN1"); - map(0x0c0008, 0x0c0009).portr("DSW1"); // .w TODO oki banking? + map(0x0c0002, 0x0c0003).nopr(); // leftover from the original? + map(0x0c0008, 0x0c0009).portr("DSW1"); + map(0x0c0009, 0x0c0009).lw8(NAME([this] (uint8_t data) { m_okibank[0]->set_entry(data & 0x03); })); map(0x0c000a, 0x0c000b).portr("DSW2"); - //map(0x0c000e, 0x0c000f).r; TODO: what's this? - map(0x0c0015, 0x0c0015).w(FUNC(nmk16_state::flipscreen_w)); // Maybe + map(0x0c000e, 0x0c000f).nopr(); // ?? + map(0x0c0015, 0x0c0015).w(FUNC(nmk16_state::flipscreen_w)); + map(0x0c0018, 0x0c0019).nopr(); // ?? map(0x0c0019, 0x0c0019).w(FUNC(nmk16_state::tilebank_w)); // Tile Bank map(0x0c001f, 0x0c001f).w("oki", FUNC(okim6295_device::write)); - map(0x0c4000, 0x0c4007).ram().w(FUNC(nmk16_state::scroll_w<0>)).umask16(0x00ff); + map(0x0c4000, 0x0c4001).lw16(NAME([this] (uint16_t data) { m_bg_tilemap[0]->set_scrollx(0, data); } )); + map(0x0c4002, 0x0c4003).nopw(); // duplicate value of the above + map(0x0c4004, 0x0c4005).lw16(NAME([this] (uint16_t data) { m_bg_tilemap[0]->set_scrolly(0, data); } )); + map(0x0c4006, 0x0c4007).nopw(); // duplicate value of the above + map(0x0c4018, 0x0c4019).nopr(); // ?? map(0x0c8000, 0x0c87ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); map(0x0cc000, 0x0cffff).ram().w(FUNC(nmk16_state::bgvideoram_w<0>)).share("bgvideoram0"); map(0x0d0000, 0x0d07ff).ram().w(FUNC(nmk16_state::txvideoram_w)).share("txvideoram"); @@ -1107,6 +1114,12 @@ void nmk16_state::powerinsa_oki_map(address_map &map) map(0x30000, 0x3ffff).bankr(m_okibank[0]); } +void nmk16_state::tdragonb2_oki_map(address_map &map) +{ + map(0x00000, 0x1ffff).rom().region("oki", 0); + map(0x20000, 0x3ffff).bankr(m_okibank[0]); +} + static INPUT_PORTS_START( vandyke ) PORT_START("IN0") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) @@ -2287,6 +2300,38 @@ static INPUT_PORTS_START( tdragonb ) PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END +static INPUT_PORTS_START( tdragonb2 ) + PORT_INCLUDE(tdragon) + + PORT_MODIFY("IN0") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) + + PORT_MODIFY("IN1") + PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) + PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) + PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) + PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_NAME("P1 Up / P1 Start") + PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 Button 1 / P2 Start") + PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) + PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN ) +INPUT_PORTS_END + static INPUT_PORTS_START( ssmissin ) PORT_START("IN0") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) @@ -4684,7 +4729,7 @@ void nmk16_state::tdragonb3(machine_config &config) void nmk16_state::tdragonb2(machine_config &config) { // basic machine hardware - M68000(config, m_maincpu, 10000000); + M68000(config, m_maincpu, 10'000'000); m_maincpu->set_addrmap(AS_PROGRAM, &nmk16_state::tdragonb2_map); set_hacky_interrupt_timing(config); @@ -4700,7 +4745,9 @@ void nmk16_state::tdragonb2(machine_config &config) // sound hardware SPEAKER(config, "mono").front_center(); - OKIM6295(config, "oki", 1320000, okim6295_device::PIN7_LOW).add_route(ALL_OUTPUTS, "mono", 0.40); + okim6295_device &oki(OKIM6295(config, "oki", 1'320'000, okim6295_device::PIN7_LOW)); + oki.set_addrmap(0, &nmk16_state::tdragonb2_oki_map); + oki.add_route(ALL_OUTPUTS, "mono", 0.40); } void nmk16_state::tdragon(machine_config &config) @@ -5884,6 +5931,11 @@ void nmk16_state::init_tdragonb() decode_tdragonb(); } +void nmk16_state::init_tdragonb2() +{ + m_okibank[0]->configure_entries(0, 4, memregion("oki")->base(), 0x20000); +} + void nmk16_state::init_ssmissin() { decode_ssmissin(); @@ -10356,10 +10408,10 @@ GAME( 1990, mustangb3, mustang, mustangb3, mustang, nmk16_state, empty GAME( 1989, tharrierb, tharrier, tharrier, tharrier, nmk16_state, init_tharrier, ROT270, "bootleg (Lettering)", "Task Force Harrier (Lettering bootleg)", 0 ) // bootleg with no audio CPU and only 1 Oki -GAME( 1991, tdragonb2, tdragon, tdragonb2, tdragon, nmk16_state, empty_init, ROT270, "bootleg", "Thunder Dragon (bootleg with reduced sound system)", MACHINE_NOT_WORKING ) // GFX and input problems. IRQs related? +GAME( 1991, tdragonb2, tdragon, tdragonb2, tdragonb2, nmk16_state, init_tdragonb2, ROT270, "bootleg", "Thunder Dragon (bootleg with reduced sound system)", MACHINE_IMPERFECT_SOUND | MACHINE_NOT_WORKING ) // runs too quickly, Oki sounds terrible (IRQ problems? works better commenting out IRQ1_SCANLINE_2) // bootleg with cloned airbustr sound hardware -GAME( 1992, gunnailb, gunnail, gunnailb, gunnail, nmk16_state, init_gunnailb, ROT270, "bootleg", "GunNail (bootleg)", MACHINE_IMPERFECT_SOUND ) // crappy sound, unknown how much of it is incomplete emulation and how much bootleg quality +GAME( 1992, gunnailb, gunnail, gunnailb, gunnail, nmk16_state, init_gunnailb, ROT270, "bootleg", "GunNail (bootleg)", MACHINE_IMPERFECT_SOUND ) // crappy sound, unknown how much of it is incomplete emulation and how much bootleg quality // these are from Comad, based on the Thunder Dragon code? GAME( 1992, ssmissin, 0, ssmissin, ssmissin, nmk16_state, init_ssmissin, ROT270, "Comad", "S.S. Mission", 0 ) diff --git a/src/mame/nmk/nmk16.h b/src/mame/nmk/nmk16.h index 716635fabda..50d3a535456 100644 --- a/src/mame/nmk/nmk16.h +++ b/src/mame/nmk/nmk16.h @@ -90,6 +90,7 @@ class nmk16_state : public driver_device, public seibu_sound_common void init_tharrier(); void init_vandykeb(); void init_tdragonb(); + void init_tdragonb2(); void init_ssmissin(); void init_twinactn(); void init_banked_audiocpu(); @@ -257,6 +258,7 @@ class nmk16_state : public driver_device, public seibu_sound_common void tdragon_map(address_map &map); void tdragonb_map(address_map &map); void tdragonb2_map(address_map &map); + void tdragonb2_oki_map(address_map &map); void tdragonb3_map(address_map &map); void tharrier_map(address_map &map); void tharrier_sound_io_map(address_map &map); diff --git a/src/mame/sega/model1.cpp b/src/mame/sega/model1.cpp index 581987e4f1a..2b15daf7c8b 100644 --- a/src/mame/sega/model1.cpp +++ b/src/mame/sega/model1.cpp @@ -486,7 +486,8 @@ MODEL-1 SOUND BD 837-8679 (C) SEGA 1992 TMP68000N-10- Toshiba TMP68000N-10 CPU, running at 10.000MHz (SDIP64, clock 20 / 2) 82C51 - Toshiba 82C51AM-10 Programmable 8-bit I/O Serial Interface (SOP28) DSW1 - 4 position Dip Switch - MB8464 - Fujitsu MB8464 8k x8 SRAM (DIP28) + MB8464 - Fujitsu MB8464 8k x8 SRAM (DIP28). Jumpers JP5 and JP6 next to the RAMs are tied to A13 and A14 on the CPU + buffers to allow larger RAMs to be used but both jumpers are set to VCC so only 8kB RAMs are actually used on the sound board. 3771 - Fujitsu MB3771 Master Reset IC (DIP8) TL062 - ST Microelectronics Dual Low Power Operational Amplifier (DIP8) PC910 - Sharp PC910 opto-isolator (DIP8) diff --git a/src/mame/shared/segam1audio.cpp b/src/mame/shared/segam1audio.cpp index d57d6350c7a..a486eb15343 100644 --- a/src/mame/shared/segam1audio.cpp +++ b/src/mame/shared/segam1audio.cpp @@ -25,7 +25,7 @@ void segam1audio_device::segam1audio_map(address_map &map) map(0xc60000, 0xc60007).rw(m_multipcm_2, FUNC(multipcm_device::read), FUNC(multipcm_device::write)).umask16(0x00ff); map(0xc70000, 0xc70001).w(FUNC(segam1audio_device::m1_snd_mpcm_bnk2_w)); map(0xd00000, 0xd00007).rw(m_ym, FUNC(ym3438_device::read), FUNC(ym3438_device::write)).umask16(0x00ff); - map(0xf00000, 0xf0ffff).ram(); + map(0xf00000, 0xf0ffff).ram(); // real PCB actually has 2x 8kBx8-bit SRAMs (16kB total) } void segam1audio_device::mpcm1_map(address_map &map) diff --git a/src/mame/sunelectronics/shangha3.cpp b/src/mame/sunelectronics/shangha3.cpp index 11d1bc6e9a2..93afe21ba8d 100644 --- a/src/mame/sunelectronics/shangha3.cpp +++ b/src/mame/sunelectronics/shangha3.cpp @@ -1,5 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:Nicola Salmoria +// copyright-holders: Nicola Salmoria + /*************************************************************************** Shanghai 3 (c)1993 Sunsoft (68000 YM2149 OKI6295) @@ -42,16 +43,364 @@ all games: ***************************************************************************/ #include "emu.h" -#include "shangha3.h" #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" +#include "machine/gen_latch.h" #include "sound/ay8910.h" +#include "sound/okim6295.h" #include "sound/ymopn.h" + +#include "emupal.h" #include "speaker.h" +#include "screen.h" + + +namespace { + +class shangha3_state : public driver_device +{ +public: + shangha3_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_oki(*this, "oki"), + m_gfxdecode(*this, "gfxdecode"), + m_screen(*this, "screen"), + m_palette(*this, "palette"), + m_ram(*this, "ram") + { } + + void shangha3(machine_config &config); + + void init_shangha3(); + +protected: + virtual void video_start() override; + +protected: + required_device m_maincpu; + required_device m_oki; + required_device m_gfxdecode; + required_device m_screen; + required_device m_palette; + + required_shared_ptr m_ram; + + // driver init configuration + uint8_t m_do_shadows = 0; + + void flipscreen_w(uint8_t data); + void gfxlist_addr_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void blitter_go_w(uint16_t data); + void irq_ack_w(uint16_t data); + void coinctrl_w(uint8_t data); + + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + +private: + uint8_t m_drawmode_table[16]{}; + uint16_t m_gfxlist_addr = 0; + bitmap_ind16 m_rawbitmap; + int m_prot_count = 0; + + uint16_t prot_r(); + void prot_w(uint16_t data); + + void program_map(address_map &map); +}; + +class heberpop_state : public shangha3_state +{ +public: + heberpop_state(const machine_config &mconfig, device_type type, const char *tag) : + shangha3_state(mconfig, type, tag), + m_audiocpu(*this, "audiocpu"), + m_soundlatch(*this, "soundlatch") + { } + + void heberpop(machine_config &config); + + void init_heberpop(); + +protected: + required_device m_audiocpu; + required_device m_soundlatch; + + void sound_program_map(address_map &map); + void sound_io_map(address_map &map); + +private: + void coinctrl_w(uint8_t data); + + void program_map(address_map &map); +}; + +class blocken_state : public heberpop_state +{ +public: + blocken_state(const machine_config &mconfig, device_type type, const char *tag) : + heberpop_state(mconfig, type, tag), + m_okibank(*this, "okibank") + { } + + void blocken(machine_config &config); + + void init_blocken(); + +private: + required_memory_bank m_okibank; + + void coinctrl_w(uint8_t data); + + void program_map(address_map &map); + void oki_map(address_map &map); +}; + + +/*************************************************************************** + +Custom blitter GA9201 KA01-0249 (120pin IC) + + +This is a tile-based blitter that writes to a frame buffer. The buffer is +never cleared, so stuff drawn is left over from frame to frame until it is +overwritten. + +Tiles are stored in ROM and have a fixed 16x16 size. The blitter can draw them +as single sprites (composed of one or more tiles in the horizontal direction), +or as larger sprites whose tile codes are picked from a tilemap in RAM. + +Sprites can be zoomed, distorted and rotated. + +Shadows are supported on pen 14 (shangha3 makes heavy use of them) but it's not +clear how they are turned on and off. heberpop definitely doesn't use them, +pen 14 is supposed to be solid black (outlines). + +The chip addresses 0x100000 bytes of memory, containing both the command list, +tilemap, and spare RAM to be used by the CPU. + +The command list starts at a variable point in memory, set by +gfxlist_addr_w(), and always ends at 0x0fffff. + +Large sprites refer to a single tilemap starting at 0x000000, the command list +contains the coordinates of the place in the tilemap to pick data from. + +The commands list is processed when blitter_go_w() is written to, so +it is not processed automatically every frame. + +The commands have a fixed length of 16 words. The format is as follows: + +Word | Bit(s) | Use +-----+-fedcba9876543210-+---------------- + 0 | ---------------- | unused? + 1 | xxxx------------ | high bits of tile #; for tilemaps, this is applied to all tiles + 1 | ----xxxxxxxxxxxx | low bits of tile #; probably unused for tilemaps + 2 | ---xxxxxxxxx---- | x coordinate of destination top left corner + 3 | ---xxxxxxxxx---- | y coordinate of destination top left corner + 4 | ------------x--- | 0 = use code as-is 1 = fetch codes from tilemap RAM + 4 | -------------x-- | 1 = draw "compressed" tilemap, as if tiles were 8x8 instead of 16x16 + 4 | --------------x- | flip y + 4 | ---------------x | flip x + 5 | --------x------- | unknown (used by blocken) + 5 | ---------xxx---- | high bits of color #; for tilemaps, this is applied to all tiles + 5 | ------------xxxx | low bits of color #; probably unused for tilemaps + 6 | xxxxxxxxxxxxxxxx | width-1 of destination rectangle \ if *both* of these are 0, + 7 | xxxxxxxxxxxxxxxx | height-1 of destination rectangle / disable sprite + 8 | xxxxxxxxxxxxxxxx | x coordinate*0x10 of source top left corner (tilemaps only?) + 9 | xxxxxxxxxxxxxxxx | y coordinate*0x10 of source top left corner (tilemaps only?) + a | xxxxxxxxxxxxxxxx | x zoom + b | xxxxxxxxxxxxxxxx | rotation + c | xxxxxxxxxxxxxxxx | rotation + d | xxxxxxxxxxxxxxxx | y zoom + e | ---------------- | unknown + f | ---------------- | unknown + +***************************************************************************/ + + +void shangha3_state::video_start() +{ + m_screen->register_screen_bitmap(m_rawbitmap); + + for (int i = 0; i < 14; i++) + m_drawmode_table[i] = DRAWMODE_SOURCE; + m_drawmode_table[14] = m_do_shadows ? DRAWMODE_SHADOW : DRAWMODE_SOURCE; + m_drawmode_table[15] = DRAWMODE_NONE; + + if (m_do_shadows) + { + // Prepare the shadow table + for (int i = 0; i < 128; i++) + m_palette->shadow_table()[i] = i + 128; + } + + save_item(NAME(m_gfxlist_addr)); + save_item(NAME(m_rawbitmap)); +} -/* this looks like a simple protection check */ + +void shangha3_state::flipscreen_w(uint8_t data) +{ + // bit 7 flips screen, the rest seems to always be set to 0x7e + flip_screen_set(data & 0x80); + + if ((data & 0x7f) != 0x7e) popmessage("flipscreen_w %02x", data); +} + +void shangha3_state::gfxlist_addr_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + COMBINE_DATA(&m_gfxlist_addr); +} + + +void shangha3_state::blitter_go_w(uint16_t data) +{ + auto profile = g_profiler.start(PROFILER_VIDEO); + + for (int offs = m_gfxlist_addr << 3; offs < m_ram.bytes() / 2; offs += 16) + { + int code = m_ram[offs + 1]; + int const color = m_ram[offs + 5] & 0x7f; + int flipx = m_ram[offs + 4] & 0x01; + int flipy = m_ram[offs + 4] & 0x02; + int sx = (m_ram[offs + 2] & 0x1ff0) >> 4; + if (sx >= 0x180) sx -= 0x200; + int sy = (m_ram[offs + 3] & 0x1ff0) >> 4; + if (sy >= 0x100) sy -= 0x200; + int const sizex = m_ram[offs + 6]; + int const sizey = m_ram[offs + 7]; + int const zoomx = m_ram[offs + 10]; + int const zoomy = m_ram[offs + 13]; + + if (flip_screen()) + { + sx = 383 - sx - sizex; + sy = 255 - sy - sizey; + flipx = !flipx; + flipy = !flipy; + } + + if ((sizex || sizey) + // avoid garbage on startup + && sizex < 512 && sizey < 256 && zoomx < 0x1f0 && zoomy < 0x1f0) + { + rectangle myclip; + +// if (m_ram[offs + 11] || m_ram[offs + 12]) +// logerror("offs %04x: sx %04x sy %04x zoom %04x %04x %04x %04x fx %d fy %d\n", offs, sx, sy, zoomx, m_ram[offs + 11]), m_ram[offs + 12], zoomy, flipx, flipy); + + myclip.set(sx, sx + sizex, sy, sy + sizey); + myclip &= m_rawbitmap.cliprect(); + + if (m_ram[offs + 4] & 0x08) // tilemap + { + int const condensed = m_ram[offs + 4] & 0x04; + + int srcx = m_ram[offs + 8] / 16; + int srcy = m_ram[offs + 9] / 16; + int const dispx = srcx & 0x0f; + int const dispy = srcy & 0x0f; + + int h = (sizey + 15) / 16 + 1; + int w = (sizex + 15) / 16 + 1; + + if (condensed) + { + h *= 2; + w *= 2; + srcx /= 8; + srcy /= 8; + } + else + { + srcx /= 16; + srcy /= 16; + } + + for (int y = 0; y < h; y++) + { + for (int x = 0; x < w; x++) + { + int dx, dy, tile; + + // TODO: zooming algo is definitely wrong for Blocken here + if (condensed) + { + int const addr = ((y + srcy) & 0x1f) | + (((x + srcx) & 0xff) << 5); + tile = m_ram[addr]; + dx = 8 * x * (0x200 - zoomx) / 0x100 - dispx; + dy = 8 * y * (0x200 - zoomy) / 0x100 - dispy; + } + else + { + int const addr = ((y + srcy) & 0x0f) | + (((x + srcx) & 0xff) << 4) | + (((y + srcy) & 0x10) << 8); + tile = m_ram[addr]; + dx = 16 * x * (0x200 - zoomx) / 0x100 - dispx; + dy = 16 * y * (0x200 - zoomy) / 0x100 - dispy; + } + + if (flipx) dx = sx + sizex - 15 - dx; + else dx = sx + dx; + if (flipy) dy = sy + sizey - 15 - dy; + else dy = sy + dy; + + m_gfxdecode->gfx(0)->transpen(m_rawbitmap, myclip, + (tile & 0x0fff) | (code & 0xf000), + (tile >> 12) | (color & 0x70), + flipx, flipy, + dx, dy, 15); + } + } + } + else // sprite + { + if (zoomx <= 1 && zoomy <= 1) + m_gfxdecode->gfx(0)->zoom_transtable(m_rawbitmap, myclip, + code, + color, + flipx, flipy, + sx, sy, + 0x1000000, 0x1000000, + m_drawmode_table); + else + { + int w = (sizex + 15) / 16; + + for (int x = 0; x < w; x++) + { + m_gfxdecode->gfx(0)->zoom_transtable(m_rawbitmap, myclip, + code, + color, + flipx, flipy, + sx + 16 * x,sy, + (0x200 - zoomx) * 0x100, (0x200 - zoomy) * 0x100, + m_drawmode_table); + + if ((code & 0x000f) == 0x0f) + code = (code + 0x100) & 0xfff0; + else + code++; + } + } + } + } + } +} + + +uint32_t shangha3_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + copybitmap(bitmap, m_rawbitmap, 0, 0, 0, 0, cliprect); + return 0; +} + + +// this looks like a simple protection check /* write read 78 78 -> 0 @@ -64,48 +413,42 @@ write read 20 -> 8 40 -> 0 */ -uint16_t shangha3_state::shangha3_prot_r() +uint16_t shangha3_state::prot_r() { - static const int result[] = { 0x0,0x1,0x3,0x7,0xf,0xe,0xc,0x8,0x0}; + static const int result[] = { 0x0, 0x1, 0x3, 0x7, 0xf, 0xe, 0xc, 0x8, 0x0}; - logerror("PC %04x: read 20004e\n",m_maincpu->pc()); + logerror("PC %04x: read 20004e\n", m_maincpu->pc()); return result[m_prot_count++ % 9]; } -void shangha3_state::shangha3_prot_w(uint16_t data) +void shangha3_state::prot_w(uint16_t data) { - logerror("PC %04x: write %02x to 20004e\n",m_maincpu->pc(),data); + logerror("PC %04x: write %02x to 20004e\n", m_maincpu->pc(), data); } -void shangha3_state::shangha3_coinctrl_w(uint8_t data) +void shangha3_state::coinctrl_w(uint8_t data) { - machine().bookkeeping().coin_lockout_w(0,~data & 0x04); - machine().bookkeeping().coin_lockout_w(1,~data & 0x04); - machine().bookkeeping().coin_counter_w(0,data & 0x01); - machine().bookkeeping().coin_counter_w(1,data & 0x02); + machine().bookkeeping().coin_lockout_w(0, BIT(~data, 2)); + machine().bookkeeping().coin_lockout_w(1, BIT(~data, 2)); + machine().bookkeeping().coin_counter_w(0, BIT(data, 0)); + machine().bookkeeping().coin_counter_w(1, BIT(data, 1)); } -void shangha3_state::heberpop_coinctrl_w(uint8_t data) +void heberpop_state::coinctrl_w(uint8_t data) { - /* the sound ROM bank is selected by the main CPU! */ - m_oki->set_rom_bank((data >> 3) & 1); + // the Oki ROM bank is selected by the main CPU! + m_oki->set_rom_bank(BIT(data, 3)); - machine().bookkeeping().coin_lockout_w(0,~data & 0x04); - machine().bookkeeping().coin_lockout_w(1,~data & 0x04); - machine().bookkeeping().coin_counter_w(0,data & 0x01); - machine().bookkeeping().coin_counter_w(1,data & 0x02); + shangha3_state::coinctrl_w(data); } -void shangha3_state::blocken_coinctrl_w(uint8_t data) +void blocken_state::coinctrl_w(uint8_t data) { - /* the sound ROM bank is selected by the main CPU! */ + // the Oki ROM bank is selected by the main CPU! m_okibank->set_entry((data >> 4) & 3); - machine().bookkeeping().coin_lockout_w(0,~data & 0x04); - machine().bookkeeping().coin_lockout_w(1,~data & 0x04); - machine().bookkeeping().coin_counter_w(0,data & 0x01); - machine().bookkeeping().coin_counter_w(1,data & 0x02); + shangha3_state::coinctrl_w(data); } @@ -114,12 +457,7 @@ void shangha3_state::irq_ack_w(uint16_t data) m_maincpu->set_input_line(4, CLEAR_LINE); } -uint8_t shangha3_state::cgrom_r(offs_t offset) -{ - return m_cgrom[offset]; -} - -void shangha3_state::shangha3_map(address_map &map) +void shangha3_state::program_map(address_map &map) { map(0x000000, 0x07ffff).rom(); map(0x100000, 0x100fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); @@ -127,59 +465,59 @@ void shangha3_state::shangha3_map(address_map &map) map(0x200002, 0x200003).portr("SYSTEM"); map(0x200008, 0x200009).w(FUNC(shangha3_state::blitter_go_w)); map(0x20000a, 0x20000b).w(FUNC(shangha3_state::irq_ack_w)); - map(0x20000c, 0x20000c).w(FUNC(shangha3_state::shangha3_coinctrl_w)); + map(0x20000c, 0x20000c).w(FUNC(shangha3_state::coinctrl_w)); map(0x20001f, 0x20001f).r("aysnd", FUNC(ym2149_device::data_r)); map(0x20002f, 0x20002f).w("aysnd", FUNC(ym2149_device::data_w)); map(0x20003f, 0x20003f).w("aysnd", FUNC(ym2149_device::address_w)); - map(0x20004e, 0x20004f).rw(FUNC(shangha3_state::shangha3_prot_r), FUNC(shangha3_state::shangha3_prot_w)); + map(0x20004e, 0x20004f).rw(FUNC(shangha3_state::prot_r), FUNC(shangha3_state::prot_w)); map(0x20006f, 0x20006f).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write)); - map(0x300000, 0x30ffff).ram().share("ram"); /* gfx & work ram */ + map(0x300000, 0x30ffff).ram().share(m_ram); // gfx & work RAM map(0x340001, 0x340001).w(FUNC(shangha3_state::flipscreen_w)); map(0x360000, 0x360001).w(FUNC(shangha3_state::gfxlist_addr_w)); } -void shangha3_state::heberpop_map(address_map &map) +void heberpop_state::program_map(address_map &map) { map(0x000000, 0x0fffff).rom(); map(0x100000, 0x100fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); map(0x200000, 0x200001).portr("INPUTS"); map(0x200002, 0x200003).portr("SYSTEM"); map(0x200004, 0x200005).portr("DSW"); - map(0x200008, 0x200009).w(FUNC(shangha3_state::blitter_go_w)); - map(0x20000a, 0x20000b).w(FUNC(shangha3_state::irq_ack_w)); - map(0x20000d, 0x20000d).w(FUNC(shangha3_state::heberpop_coinctrl_w)); + map(0x200008, 0x200009).w(FUNC(heberpop_state::blitter_go_w)); + map(0x20000a, 0x20000b).w(FUNC(heberpop_state::irq_ack_w)); + map(0x20000d, 0x20000d).w(FUNC(heberpop_state::coinctrl_w)); map(0x20000f, 0x20000f).w(m_soundlatch, FUNC(generic_latch_8_device::write)); - map(0x300000, 0x30ffff).ram().share("ram"); /* gfx & work ram */ - map(0x340001, 0x340001).w(FUNC(shangha3_state::flipscreen_w)); - map(0x360000, 0x360001).w(FUNC(shangha3_state::gfxlist_addr_w)); - map(0x800000, 0xb7ffff).r(FUNC(shangha3_state::cgrom_r)); + map(0x300000, 0x30ffff).ram().share(m_ram); // gfx & work RAM + map(0x340001, 0x340001).w(FUNC(heberpop_state::flipscreen_w)); + map(0x360000, 0x360001).w(FUNC(heberpop_state::gfxlist_addr_w)); + map(0x800000, 0xb7ffff).rom().region("blitter", 0); } -void shangha3_state::blocken_map(address_map &map) +void blocken_state::program_map(address_map &map) { map(0x000000, 0x0fffff).rom(); map(0x100000, 0x100001).portr("INPUTS"); map(0x100002, 0x100003).portr("SYSTEM").nopw(); // w -> unknown purpose map(0x100004, 0x100005).portr("DSW"); - map(0x100008, 0x100009).w(FUNC(shangha3_state::blitter_go_w)); - map(0x10000a, 0x10000b).nopr().w(FUNC(shangha3_state::irq_ack_w)); // r -> unknown purpose (value doesn't matter, left-over?) - map(0x10000d, 0x10000d).w(FUNC(shangha3_state::blocken_coinctrl_w)); + map(0x100008, 0x100009).w(FUNC(blocken_state::blitter_go_w)); + map(0x10000a, 0x10000b).nopr().w(FUNC(blocken_state::irq_ack_w)); // r -> unknown purpose (value doesn't matter, left-over?) + map(0x10000d, 0x10000d).w(FUNC(blocken_state::coinctrl_w)); map(0x10000f, 0x10000f).w(m_soundlatch, FUNC(generic_latch_8_device::write)); map(0x200000, 0x200fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); - map(0x300000, 0x30ffff).ram().share("ram"); /* gfx & work ram */ - map(0x340001, 0x340001).w(FUNC(shangha3_state::flipscreen_w)); - map(0x360000, 0x360001).w(FUNC(shangha3_state::gfxlist_addr_w)); - map(0x800000, 0xb7ffff).r(FUNC(shangha3_state::cgrom_r)); + map(0x300000, 0x30ffff).ram().share(m_ram); // gfx & work RAM + map(0x340001, 0x340001).w(FUNC(blocken_state::flipscreen_w)); + map(0x360000, 0x360001).w(FUNC(blocken_state::gfxlist_addr_w)); + map(0x800000, 0xb7ffff).rom().region("blitter", 0); } -void shangha3_state::heberpop_sound_map(address_map &map) +void heberpop_state::sound_program_map(address_map &map) { map(0x0000, 0xf7ff).rom(); map(0xf800, 0xffff).ram(); } -void shangha3_state::heberpop_sound_io_map(address_map &map) +void heberpop_state::sound_io_map(address_map &map) { map.global_mask(0xff); map(0x00, 0x03).rw("ymsnd", FUNC(ym3438_device::read), FUNC(ym3438_device::write)); @@ -187,12 +525,12 @@ void shangha3_state::heberpop_sound_io_map(address_map &map) map(0xc0, 0xc0).r(m_soundlatch, FUNC(generic_latch_8_device::read)); } -/* $00000-$20000 stays the same in all sound banks, */ -/* the second half of the bank is what gets switched */ -void shangha3_state::blocken_oki_map(address_map &map) +/* $00000-$20000 stays the same in all sound banks, + the second half of the bank is what gets switched */ +void blocken_state::oki_map(address_map &map) { map(0x00000, 0x1ffff).rom(); - map(0x20000, 0x3ffff).bankr("okibank"); + map(0x20000, 0x3ffff).bankr(m_okibank); } static INPUT_PORTS_START( shangha3 ) @@ -224,7 +562,7 @@ static INPUT_PORTS_START( shangha3 ) PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") - PORT_START("DSW1") /* Dipswitch locations assigned as per service mode */ + PORT_START("DSW1") // DIP switch locations assigned as per service mode PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SWA:1,2,3") PORT_DIPSETTING( 0x00, DEF_STR( 5C_1C ) ) PORT_DIPSETTING( 0x04, DEF_STR( 4C_1C ) ) @@ -250,7 +588,7 @@ static INPUT_PORTS_START( shangha3 ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_START("DSW2") /* Dipswitch locations assigned as per service mode */ + PORT_START("DSW2") // DIP switch locations assigned as per service mode PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SWB:1,2") PORT_DIPSETTING( 0x01, DEF_STR( Easy ) ) PORT_DIPSETTING( 0x03, DEF_STR( Normal ) ) @@ -283,7 +621,7 @@ static INPUT_PORTS_START( heberpop ) PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") /* vblank?? has to toggle */ + PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") // vblank?? has to toggle PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) @@ -291,7 +629,7 @@ static INPUT_PORTS_START( heberpop ) PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") /* vblank?? has to toggle */ + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") // vblank?? has to toggle PORT_START("SYSTEM") PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 ) @@ -303,7 +641,7 @@ static INPUT_PORTS_START( heberpop ) PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_START("DSW") /* Dipswitch locations assigned as per service mode */ + PORT_START("DSW") // DIP switch locations assigned as per service mode PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW1:1,2") PORT_DIPSETTING( 0x0002, DEF_STR( Very_Easy) ) PORT_DIPSETTING( 0x0001, DEF_STR( Easy ) ) @@ -362,7 +700,7 @@ static INPUT_PORTS_START( blocken ) PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) - PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") /* vblank?? has to toggle */ + PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") // vblank?? has to toggle PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) @@ -370,7 +708,7 @@ static INPUT_PORTS_START( blocken ) PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) - PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") /* vblank?? has to toggle */ + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") // vblank?? has to toggle PORT_START("SYSTEM") PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 ) @@ -378,11 +716,11 @@ static INPUT_PORTS_START( blocken ) PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START2 ) - PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_SERVICE ) /* keeping this pressed on boot generates "BAD DIPSW" */ + PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_SERVICE ) // keeping this pressed on boot generates "BAD DIPSW" PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_START("DSW") /* Dipswitch locations assigned as per service mode */ + PORT_START("DSW") // DIP switch locations assigned as per service mode PORT_SERVICE_DIPLOC( 0x0001, IP_ACTIVE_LOW, "SW1:1" ) PORT_DIPNAME( 0x0006, 0x0006, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW1:2,3") PORT_DIPSETTING( 0x0004, DEF_STR( Easy ) ) @@ -442,24 +780,24 @@ INPUT_PORTS_END static GFXDECODE_START( gfx_shangha3 ) - GFXDECODE_ENTRY( "gfx1", 0, gfx_16x16x4_packed_lsb, 0, 128 ) + GFXDECODE_ENTRY( "blitter", 0, gfx_16x16x4_packed_lsb, 0, 128 ) GFXDECODE_END void shangha3_state::shangha3(machine_config &config) { - /* basic machine hardware */ - M68000(config, m_maincpu, 48_MHz_XTAL/3); // TMP68HC000N-16 - m_maincpu->set_addrmap(AS_PROGRAM, &shangha3_state::shangha3_map); + // basic machine hardware + M68000(config, m_maincpu, 48_MHz_XTAL / 3); // TMP68HC000N-16 + m_maincpu->set_addrmap(AS_PROGRAM, &shangha3_state::program_map); m_maincpu->set_vblank_int("screen", FUNC(shangha3_state::irq4_line_assert)); - /* video hardware */ + // video hardware SCREEN(config, m_screen, SCREEN_TYPE_RASTER); // m_screen->set_refresh_hz(60); -// m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */ +// m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); // not accurate // m_screen->set_size(24*16, 16*16); // m_screen->set_visarea(0*16, 24*16-1, 1*16, 15*16-1); - m_screen->set_raw(48_MHz_XTAL/6, 512, 0, 24*16, 263, 1*16, 15*16); /* refresh rate is unknown */ + m_screen->set_raw(48_MHz_XTAL / 6, 512, 0, 24 * 16, 263, 1 * 16, 15 * 16); // refresh rate is unknown m_screen->set_screen_update(FUNC(shangha3_state::screen_update)); m_screen->set_palette(m_palette); @@ -467,10 +805,10 @@ void shangha3_state::shangha3(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::RGBx_555, 2048).enable_shadows(); - /* sound hardware */ + // sound hardware SPEAKER(config, "mono").front_center(); - ym2149_device &aysnd(YM2149(config, "aysnd", 48_MHz_XTAL/32)); // 1.5MHz + ym2149_device &aysnd(YM2149(config, "aysnd", 48_MHz_XTAL / 32)); // 1.5MHz aysnd.port_a_read_callback().set_ioport("DSW1"); aysnd.port_b_read_callback().set_ioport("DSW2"); aysnd.add_route(ALL_OUTPUTS, "mono", 0.30); @@ -479,38 +817,38 @@ void shangha3_state::shangha3(machine_config &config) m_oki->add_route(ALL_OUTPUTS, "mono", 1.0); } -void shangha3_state::heberpop(machine_config &config) +void heberpop_state::heberpop(machine_config &config) { - /* basic machine hardware */ - M68000(config, m_maincpu, 48_MHz_XTAL/3); // TMP68HC000N-16 like the others?? - m_maincpu->set_addrmap(AS_PROGRAM, &shangha3_state::heberpop_map); - m_maincpu->set_vblank_int("screen", FUNC(shangha3_state::irq4_line_assert)); + // basic machine hardware + M68000(config, m_maincpu, 48_MHz_XTAL / 3); // TMP68HC000N-16 like the others?? + m_maincpu->set_addrmap(AS_PROGRAM, &heberpop_state::program_map); + m_maincpu->set_vblank_int("screen", FUNC(heberpop_state::irq4_line_assert)); - Z80(config, m_audiocpu, 48_MHz_XTAL/8); /* 6 MHz ??? */ - m_audiocpu->set_addrmap(AS_PROGRAM, &shangha3_state::heberpop_sound_map); - m_audiocpu->set_addrmap(AS_IO, &shangha3_state::heberpop_sound_io_map); /* NMI triggered by YM3438 */ + Z80(config, m_audiocpu, 48_MHz_XTAL / 8); // 6 MHz ??? + m_audiocpu->set_addrmap(AS_PROGRAM, &heberpop_state::sound_program_map); + m_audiocpu->set_addrmap(AS_IO, &heberpop_state::sound_io_map); // NMI triggered by YM3438 - /* video hardware */ + // video hardware SCREEN(config, m_screen, SCREEN_TYPE_RASTER); // m_screen->set_refresh_hz(60); -// m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */ +// m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); // not accurate // m_screen->set_size(24*16, 16*16); // m_screen->set_visarea(0*16, 24*16-1, 1*16, 15*16-1); - m_screen->set_raw(48_MHz_XTAL/6, 512, 0, 24*16, 263, 1*16, 15*16); /* refresh rate is unknown */ - m_screen->set_screen_update(FUNC(shangha3_state::screen_update)); + m_screen->set_raw(48_MHz_XTAL / 6, 512, 0, 24 * 16, 263, 1 * 16, 15 * 16); // refresh rate is unknown + m_screen->set_screen_update(FUNC(heberpop_state::screen_update)); m_screen->set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_shangha3); PALETTE(config, m_palette).set_format(palette_device::RGBx_555, 2048).enable_shadows(); - /* sound hardware */ + // sound hardware SPEAKER(config, "mono").front_center(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, 0); - ym3438_device &ymsnd(YM3438(config, "ymsnd", 48_MHz_XTAL/6)); /* 8 MHz? */ + ym3438_device &ymsnd(YM3438(config, "ymsnd", 48_MHz_XTAL / 6)); // 8 MHz? ymsnd.irq_handler().set_inputline("audiocpu", INPUT_LINE_NMI); ymsnd.add_route(0, "mono", 0.40); ymsnd.add_route(1, "mono", 0.40); @@ -519,44 +857,44 @@ void shangha3_state::heberpop(machine_config &config) m_oki->add_route(ALL_OUTPUTS, "mono", 1.0); } -void shangha3_state::blocken(machine_config &config) +void blocken_state::blocken(machine_config &config) { - /* basic machine hardware */ - M68000(config, m_maincpu, 48_MHz_XTAL/3); // TMP68HC000N-16 - m_maincpu->set_addrmap(AS_PROGRAM, &shangha3_state::blocken_map); - m_maincpu->set_vblank_int("screen", FUNC(shangha3_state::irq4_line_assert)); + // basic machine hardware + M68000(config, m_maincpu, 48_MHz_XTAL / 3); // TMP68HC000N-16 + m_maincpu->set_addrmap(AS_PROGRAM, &blocken_state::program_map); + m_maincpu->set_vblank_int("screen", FUNC(blocken_state::irq4_line_assert)); - Z80(config, m_audiocpu, 48_MHz_XTAL/8); /* 6 MHz? */ - m_audiocpu->set_addrmap(AS_PROGRAM, &shangha3_state::heberpop_sound_map); - m_audiocpu->set_addrmap(AS_IO, &shangha3_state::heberpop_sound_io_map); /* NMI triggered by YM3438 */ + Z80(config, m_audiocpu, 48_MHz_XTAL / 8); // 6 MHz? + m_audiocpu->set_addrmap(AS_PROGRAM, &blocken_state::sound_program_map); + m_audiocpu->set_addrmap(AS_IO, &blocken_state::sound_io_map); // NMI triggered by YM3438 - /* video hardware */ + // video hardware SCREEN(config, m_screen, SCREEN_TYPE_RASTER); // m_screen->set_refresh_hz(60); -// m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */ +// m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); // not accurate // m_screen->set_size(24*16, 16*16); // m_screen->set_visarea(0*16, 24*16-1, 1*16, 15*16-1); - m_screen->set_raw(48_MHz_XTAL/6, 512, 0, 24*16, 263, 1*16, 15*16); /* refresh rate is unknown */ - m_screen->set_screen_update(FUNC(shangha3_state::screen_update)); + m_screen->set_raw(48_MHz_XTAL / 6, 512, 0, 24 * 16, 263, 1 * 16, 15 * 16); // refresh rate is unknown + m_screen->set_screen_update(FUNC(blocken_state::screen_update)); m_screen->set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_shangha3); PALETTE(config, m_palette).set_format(palette_device::RGBx_555, 2048).enable_shadows(); - /* sound hardware */ + // sound hardware SPEAKER(config, "mono").front_center(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, 0); - ym3438_device &ymsnd(YM3438(config, "ymsnd", 48_MHz_XTAL/6)); /* 8 MHz? */ + ym3438_device &ymsnd(YM3438(config, "ymsnd", 48_MHz_XTAL / 6)); // 8 MHz? ymsnd.irq_handler().set_inputline("audiocpu", INPUT_LINE_NMI); ymsnd.add_route(0, "mono", 0.40); ymsnd.add_route(1, "mono", 0.40); OKIM6295(config, m_oki, 1.056_MHz_XTAL, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified - m_oki->set_addrmap(0, &shangha3_state::blocken_oki_map); + m_oki->set_addrmap(0, &blocken_state::oki_map); m_oki->add_route(ALL_OUTPUTS, "mono", 1.0); } @@ -613,68 +951,68 @@ NOTE: For the "World" set, it differs from the US set (besides the US set having */ -ROM_START( shangha3 ) /* PCB labeled SUN04C - Has two additional tiles sets to choose from. */ +ROM_START( shangha3 ) // PCB labeled SUN04C - Has two additional tiles sets to choose from. ROM_REGION( 0x80000, "maincpu", 0 ) - ROM_LOAD16_BYTE( "ic3", 0x0000, 0x40000, CRC(4a9cdcfd) SHA1(c27b767ef2de90b36095b49baae9fa514f461c2c) ) /* ST M27C2001 EPROM with no label */ - ROM_LOAD16_BYTE( "ic2", 0x0001, 0x40000, CRC(714bfdbc) SHA1(0ce611624e8a5e28cba5443b63b8872eed9f68fc) ) /* ST M27C2001 EPROM with no label */ + ROM_LOAD16_BYTE( "ic3", 0x00000, 0x40000, CRC(4a9cdcfd) SHA1(c27b767ef2de90b36095b49baae9fa514f461c2c) ) // ST M27C2001 EPROM with no label + ROM_LOAD16_BYTE( "ic2", 0x00001, 0x40000, CRC(714bfdbc) SHA1(0ce611624e8a5e28cba5443b63b8872eed9f68fc) ) // ST M27C2001 EPROM with no label - ROM_REGION( 0x400000, "gfx1", 0 ) - ROM_LOAD( "s3j_char-a1.ic43", 0x0000, 0x200000, CRC(2dbf9d17) SHA1(dd94ddc4bb02ab544aa3f89b614afc46678cc48d) ) /* 42pin mask ROM */ - ROM_LOAD( "27c4000.ic44", 0x200000, 0x080000, CRC(6344ffb7) SHA1(06bc5bcf94973ec152e7abf9cc658ef319eb4b65) ) // Korean fonts, vs mode how to play etc? (probably for Korean program ROMs we don't have, but was on World board) + ROM_REGION16_BE( 0x400000, "blitter", 0 ) + ROM_LOAD( "s3j_char-a1.ic43", 0x000000, 0x200000, CRC(2dbf9d17) SHA1(dd94ddc4bb02ab544aa3f89b614afc46678cc48d) ) // 42pin mask ROM + ROM_LOAD( "27c4000.ic44", 0x200000, 0x080000, CRC(6344ffb7) SHA1(06bc5bcf94973ec152e7abf9cc658ef319eb4b65) ) // Korean fonts, vs mode how to play etc? (probably for Korean program ROMs we don't have, but was on World board) - ROM_REGION( 0x40000, "oki", 0 ) /* samples for M6295 */ - ROM_LOAD( "s3j_v10.ic75", 0x0000, 0x40000, CRC(f0cdc86a) SHA1(b1017a9841a56e0f5d2714f550f64ed1f4e238e6) ) + ROM_REGION( 0x40000, "oki", 0 ) + ROM_LOAD( "s3j_v10.ic75", 0x00000, 0x40000, CRC(f0cdc86a) SHA1(b1017a9841a56e0f5d2714f550f64ed1f4e238e6) ) ROM_END -ROM_START( shangha3u ) /* PCB labeled SUN04C - Shows FBI "Winners Don't Use Drugs" splash screen (once). Has two additional tiles sets to choose from. */ +ROM_START( shangha3u ) // PCB labeled SUN04C - Shows FBI "Winners Don't Use Drugs" splash screen (once). Has two additional tiles sets to choose from. ROM_REGION( 0x100000, "maincpu", 0 ) - ROM_LOAD16_BYTE( "s3u_ic3_v1.0.ic3", 0x0000, 0x80000, CRC(53ef4988) SHA1(63f098d95865928a553e945fe60dea79aa16c603) ) /* ST M27C4001 EPROM labeled S3U IC3 V1.0 */ - ROM_LOAD16_BYTE( "s3u_ic2_v1.0.ic2", 0x0001, 0x80000, CRC(fdea0232) SHA1(8983a646412df01b6bc66994700796e7b7fcbb61) ) /* ST M27C4001 EPROM labeled S3U IC2 V1.0 */ - /* both program ROMs are double sized with the identical halves */ + ROM_LOAD16_BYTE( "s3u_ic3_v1.0.ic3", 0x00000, 0x80000, CRC(53ef4988) SHA1(63f098d95865928a553e945fe60dea79aa16c603) ) // ST M27C4001 EPROM labeled S3U IC3 V1.0 + ROM_LOAD16_BYTE( "s3u_ic2_v1.0.ic2", 0x00001, 0x80000, CRC(fdea0232) SHA1(8983a646412df01b6bc66994700796e7b7fcbb61) ) // ST M27C4001 EPROM labeled S3U IC2 V1.0 + // both program ROMs are double sized with the identical halves - ROM_REGION( 0x200000, "gfx1", 0 ) - ROM_LOAD( "s3j_char-a1.ic43", 0x0000, 0x200000, CRC(2dbf9d17) SHA1(dd94ddc4bb02ab544aa3f89b614afc46678cc48d) ) /* 42pin mask ROM */ + ROM_REGION16_BE( 0x200000, "blitter", 0 ) + ROM_LOAD( "s3j_char-a1.ic43", 0x000000, 0x200000, CRC(2dbf9d17) SHA1(dd94ddc4bb02ab544aa3f89b614afc46678cc48d) ) // 42pin mask ROM - ROM_REGION( 0x80000, "oki", 0 ) /* samples for M6295 */ - ROM_LOAD( "s3j_ic75v1.0.ic75", 0x0000, 0x80000, CRC(a8136d8c) SHA1(8028bda5642c2546c1ac8da78dbff4084829f03b) ) /* 27C4001 labeled S3J IC75V1.0 with 1st & 2nd halves == s3j_v10.ic75 */ + ROM_REGION( 0x80000, "oki", 0 ) + ROM_LOAD( "s3j_ic75v1.0.ic75", 0x00000, 0x80000, CRC(a8136d8c) SHA1(8028bda5642c2546c1ac8da78dbff4084829f03b) ) // 27C4001 labeled S3J IC75V1.0 with 1st & 2nd halves == s3j_v10.ic75 ROM_END -ROM_START( shangha3up ) /* PCB labeled SUN04 with a sticker labeled PCB 001, a prototyping version of the later SUN04C */ +ROM_START( shangha3up ) // PCB labeled SUN04 with a sticker labeled PCB 001, a prototyping version of the later SUN04C ROM_REGION( 0x100000, "maincpu", 0 ) - ROM_LOAD16_BYTE( "syan3u_evn_10-7.ic3", 0x0000, 0x40000, CRC(a1f5275a) SHA1(71a024205bd5e6385bd9d746c339f0327bd1c1d6) ) /* ST M27C2001 EPROM hand written label: SYAN3U EVN 10/7 */ - ROM_LOAD16_BYTE( "syan3u_odd_10-7.ic2", 0x0001, 0x40000, CRC(fe3960bf) SHA1(545473260d959b8ed8145263d54f5f4523a844c4) ) /* ST M27C2001 EPROM hand written label: SYAN3U ODD 10/7 */ + ROM_LOAD16_BYTE( "syan3u_evn_10-7.ic3", 0x00000, 0x40000, CRC(a1f5275a) SHA1(71a024205bd5e6385bd9d746c339f0327bd1c1d6) ) // ST M27C2001 EPROM hand written label: SYAN3U EVN 10/7 + ROM_LOAD16_BYTE( "syan3u_odd_10-7.ic2", 0x00001, 0x40000, CRC(fe3960bf) SHA1(545473260d959b8ed8145263d54f5f4523a844c4) ) // ST M27C2001 EPROM hand written label: SYAN3U ODD 10/7 - ROM_REGION( 0x200000, "gfx1", 0 ) /* same data as the 42 pin mask S3J CHAR-A1 */ - ROM_LOAD( "s3j_chr-a1_1_sum_53b1_93.9.20.ic80", 0x000000, 0x80000, CRC(fcaf795b) SHA1(312d85f39087564d67f12e0287f508b94b1493af) ) /* HN27C4001 hand written label: S3J-CHR-A1 #1 SUM: 53B1 93.9.20 */ - ROM_LOAD( "s3j_chr-a1_2_sum_0e32_93.9.20.ic81", 0x080000, 0x80000, CRC(5a564f50) SHA1(34ca2ecd7101961e657034082802d89db5b4b7bd) ) /* HN27C4001 hand written label: S3J-CHR-A1 #2 SUM: 0E32 93.9.20 */ - ROM_LOAD( "s3j_chr-a1_3_sum_0d9a_93.9.20.ic82", 0x100000, 0x80000, CRC(2b333c69) SHA1(6e720de5d222be25857ab18902636587e8c6afb8) ) /* HN27C4001 hand written label: S3J-CHR-A1 #3 SUM: 0D9A 93.9.20 */ - ROM_LOAD( "s3j_chr-a1_4_sum_27e7_93.9.20.ic83", 0x180000, 0x80000, CRC(19be7039) SHA1(53839460b53144120cc2f68992c054062efa939b) ) /* HN27C4001 hand written label: S3J-CHR-A1 #4 SUM: 27E7 93.9.20 */ + ROM_REGION16_BE( 0x200000, "blitter", 0 ) // same data as the 42 pin mask S3J CHAR-A1 + ROM_LOAD( "s3j_chr-a1_1_sum_53b1_93.9.20.ic80", 0x000000, 0x80000, CRC(fcaf795b) SHA1(312d85f39087564d67f12e0287f508b94b1493af) ) // HN27C4001 hand written label: S3J-CHR-A1 #1 SUM: 53B1 93.9.20 + ROM_LOAD( "s3j_chr-a1_2_sum_0e32_93.9.20.ic81", 0x080000, 0x80000, CRC(5a564f50) SHA1(34ca2ecd7101961e657034082802d89db5b4b7bd) ) // HN27C4001 hand written label: S3J-CHR-A1 #2 SUM: 0E32 93.9.20 + ROM_LOAD( "s3j_chr-a1_3_sum_0d9a_93.9.20.ic82", 0x100000, 0x80000, CRC(2b333c69) SHA1(6e720de5d222be25857ab18902636587e8c6afb8) ) // HN27C4001 hand written label: S3J-CHR-A1 #3 SUM: 0D9A 93.9.20 + ROM_LOAD( "s3j_chr-a1_4_sum_27e7_93.9.20.ic83", 0x180000, 0x80000, CRC(19be7039) SHA1(53839460b53144120cc2f68992c054062efa939b) ) // HN27C4001 hand written label: S3J-CHR-A1 #4 SUM: 27E7 93.9.20 - ROM_REGION( 0x40000, "oki", 0 ) /* samples for M6295 */ - ROM_LOAD( "pcm_9-16_0166.ic75", 0x0000, 0x40000, CRC(f0cdc86a) SHA1(b1017a9841a56e0f5d2714f550f64ed1f4e238e6) ) /* Hand written label: PCM 9/16 0166 */ + ROM_REGION( 0x40000, "oki", 0 ) + ROM_LOAD( "pcm_9-16_0166.ic75", 0x00000, 0x40000, CRC(f0cdc86a) SHA1(b1017a9841a56e0f5d2714f550f64ed1f4e238e6) ) // Hand written label: PCM 9/16 0166 ROM_END -ROM_START( shangha3j ) /* PCB labeled SUN04C */ +ROM_START( shangha3j ) // PCB labeled SUN04C ROM_REGION( 0x80000, "maincpu", 0 ) - ROM_LOAD16_BYTE( "s3j_v11.ic3", 0x0000, 0x40000, CRC(e98ce9c8) SHA1(359e117aebb644d7b235add7e71ed6891243d451) ) - ROM_LOAD16_BYTE( "s3j_v11.ic2", 0x0001, 0x40000, CRC(09174620) SHA1(1d1639c07895f715facfe153fbdb6ae0f3cdd876) ) + ROM_LOAD16_BYTE( "s3j_v11.ic3", 0x00000, 0x40000, CRC(e98ce9c8) SHA1(359e117aebb644d7b235add7e71ed6891243d451) ) + ROM_LOAD16_BYTE( "s3j_v11.ic2", 0x00001, 0x40000, CRC(09174620) SHA1(1d1639c07895f715facfe153fbdb6ae0f3cdd876) ) - ROM_REGION( 0x200000, "gfx1", 0 ) - ROM_LOAD( "s3j_char-a1.ic43", 0x0000, 0x200000, CRC(2dbf9d17) SHA1(dd94ddc4bb02ab544aa3f89b614afc46678cc48d) ) /* 42pin mask ROM */ + ROM_REGION16_BE( 0x200000, "blitter", 0 ) + ROM_LOAD( "s3j_char-a1.ic43", 0x000000, 0x200000, CRC(2dbf9d17) SHA1(dd94ddc4bb02ab544aa3f89b614afc46678cc48d) ) // 42pin mask ROM - ROM_REGION( 0x40000, "oki", 0 ) /* samples for M6295 */ - ROM_LOAD( "s3j_v10.ic75", 0x0000, 0x40000, CRC(f0cdc86a) SHA1(b1017a9841a56e0f5d2714f550f64ed1f4e238e6) ) + ROM_REGION( 0x40000, "oki", 0 ) + ROM_LOAD( "s3j_v10.ic75", 0x00000, 0x40000, CRC(f0cdc86a) SHA1(b1017a9841a56e0f5d2714f550f64ed1f4e238e6) ) ROM_END -ROM_START( heberpop ) /* PCB labeled SUN-06 */ +ROM_START( heberpop ) // PCB labeled SUN-06 ROM_REGION( 0x100000, "maincpu", 0 ) - ROM_LOAD16_BYTE( "hbp_ic31.ic31", 0x0000, 0x80000, CRC(c430d264) SHA1(4be12b1fa90da09047db3a31171ffda8ab8bd851) ) - ROM_LOAD16_BYTE( "hbp_ic32.ic32", 0x0001, 0x80000, CRC(bfa555a8) SHA1(754f581554022b98ba8e78ee96f846faa2cedc69) ) + ROM_LOAD16_BYTE( "hbp_ic31.ic31", 0x00000, 0x80000, CRC(c430d264) SHA1(4be12b1fa90da09047db3a31171ffda8ab8bd851) ) + ROM_LOAD16_BYTE( "hbp_ic32.ic32", 0x00001, 0x80000, CRC(bfa555a8) SHA1(754f581554022b98ba8e78ee96f846faa2cedc69) ) ROM_REGION( 0x10000, "audiocpu", 0 ) - ROM_LOAD( "hbp_ic34_v1.0.ic34", 0x0000, 0x10000, CRC(0cf056c6) SHA1(9992cd3879d9a57fcb784fc1e11d6b6d87e5a366) ) + ROM_LOAD( "hbp_ic34_v1.0.ic34", 0x00000, 0x10000, CRC(0cf056c6) SHA1(9992cd3879d9a57fcb784fc1e11d6b6d87e5a366) ) - ROM_REGION( 0x380000, "gfx1", ROMREGION_ERASEFF ) + ROM_REGION16_BE( 0x380000, "blitter", ROMREGION_ERASEFF ) ROM_LOAD( "hbp_ic98_v1.0.ic98", 0x000000, 0x80000, CRC(a599100a) SHA1(f2e517256a42b3fa4a047bbe742d714f568cc117) ) ROM_LOAD( "hbp_ic99_v1.0.ic99", 0x080000, 0x80000, CRC(fb8bb12f) SHA1(78c1fec1371d312e113d92803dd59acc36604989) ) ROM_LOAD( "hbp_ic100_v1.0.ic100", 0x100000, 0x80000, CRC(05a0f765) SHA1(4f44cf367c3697eb6c245297c9d05160d7d94e24) ) @@ -683,27 +1021,27 @@ ROM_START( heberpop ) /* PCB labeled SUN-06 */ ROM_LOAD( "hbp_ic103_v1.0.ic103", 0x280000, 0x80000, CRC(efa0e745) SHA1(fc1d52d35b3c902d8b25403b0e13f86a04039bc4) ) ROM_LOAD( "hbp_ic104_v1.0.ic104", 0x300000, 0x80000, CRC(bb896bbb) SHA1(4311876628beb82cbacdab4d055c3738e74241b0) ) - ROM_REGION( 0x80000, "oki", 0 ) /* samples for M6295 */ - ROM_LOAD( "hbp_ic53_v1.0.ic53", 0x0000, 0x80000, CRC(a4483aa0) SHA1(be301d8ac6d69f5c3fdbcb85bd557090e46da1ff) ) + ROM_REGION( 0x80000, "oki", 0 ) + ROM_LOAD( "hbp_ic53_v1.0.ic53", 0x00000, 0x80000, CRC(a4483aa0) SHA1(be301d8ac6d69f5c3fdbcb85bd557090e46da1ff) ) ROM_END -ROM_START( blocken ) /* PCB labeled KID-07 */ +ROM_START( blocken ) // PCB labeled KID-07 ROM_REGION( 0x100000, "maincpu", ROMREGION_ERASEFF ) - ROM_LOAD16_BYTE( "ic31j.bin", 0x0000, 0x20000, CRC(ec8de2a3) SHA1(09a6b8c1b656b17ab3d1fc057902487e4f94cf02) ) - ROM_LOAD16_BYTE( "ic32j.bin", 0x0001, 0x20000, CRC(79b96240) SHA1(c1246bd4b91fa45c581a8fdf90cc6beb85adf8ec) ) + ROM_LOAD16_BYTE( "ic31j.bin", 0x00000, 0x20000, CRC(ec8de2a3) SHA1(09a6b8c1b656b17ab3d1fc057902487e4f94cf02) ) + ROM_LOAD16_BYTE( "ic32j.bin", 0x00001, 0x20000, CRC(79b96240) SHA1(c1246bd4b91fa45c581a8fdf90cc6beb85adf8ec) ) ROM_REGION( 0x10000, "audiocpu", 0 ) - ROM_LOAD( "ic34.bin", 0x0000, 0x10000, CRC(23e446ff) SHA1(82c03b45b337696b0f8293c446544d7ee080d415) ) + ROM_LOAD( "ic34.bin", 0x00000, 0x10000, CRC(23e446ff) SHA1(82c03b45b337696b0f8293c446544d7ee080d415) ) - ROM_REGION( 0x380000, "gfx1", ROMREGION_ERASEFF ) + ROM_REGION16_BE( 0x380000, "blitter", ROMREGION_ERASEFF ) ROM_LOAD( "ic98j.bin", 0x000000, 0x80000, CRC(35dda273) SHA1(95850d12ca1557c14bc471ddf925aaf423313ff0) ) ROM_LOAD( "ic99j.bin", 0x080000, 0x80000, CRC(ce43762b) SHA1(e1c51ea0b54b5febdee127619e15f1cda650cb4c) ) - /* 100000-1fffff empty */ + // 100000-1fffff empty ROM_LOAD( "ic100j.bin", 0x200000, 0x80000, CRC(a34786fd) SHA1(7d4879cbaa055c2ddbe6d20dd946bf0e3e069d4d) ) - /* 280000-37ffff empty */ + // 280000-37ffff empty - ROM_REGION( 0x80000, "oki", 0 ) /* samples for M6295 */ - ROM_LOAD( "ic53.bin", 0x0000, 0x80000, CRC(86108c56) SHA1(aa405fa2eec5cc178ef6226f229a12dac09504f0) ) + ROM_REGION( 0x80000, "oki", 0 ) + ROM_LOAD( "ic53.bin", 0x00000, 0x80000, CRC(86108c56) SHA1(aa405fa2eec5cc178ef6226f229a12dac09504f0) ) ROM_END @@ -715,23 +1053,26 @@ void shangha3_state::init_shangha3() save_item(NAME(m_prot_count)); } -void shangha3_state::init_heberpop() +void heberpop_state::init_heberpop() { m_do_shadows = 0; // sound CPU runs in IM 0 - m_audiocpu->set_input_line_vector(0, 0xff); /* Z80 - RST 38h */ + m_audiocpu->set_input_line_vector(0, 0xff); // Z80 - RST 38h } -void shangha3_state::init_blocken() +void blocken_state::init_blocken() { init_heberpop(); m_okibank->configure_entries(0, 4, memregion("oki")->base(), 0x20000); } -GAME( 1993, shangha3, 0, shangha3, shangha3, shangha3_state, init_shangha3, ROT0, "Sunsoft", "Shanghai III (World)", MACHINE_SUPPORTS_SAVE ) -GAME( 1993, shangha3u, shangha3, shangha3, shangha3, shangha3_state, init_shangha3, ROT0, "Sunsoft", "Shanghai III (US)", MACHINE_SUPPORTS_SAVE ) -GAME( 1993, shangha3up, shangha3, shangha3, shangha3, shangha3_state, init_shangha3, ROT0, "Sunsoft", "Shanghai III (US, prototype)", MACHINE_SUPPORTS_SAVE ) -GAME( 1993, shangha3j, shangha3, shangha3, shangha3, shangha3_state, init_shangha3, ROT0, "Sunsoft", "Shanghai III (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1994, heberpop, 0, heberpop, heberpop, shangha3_state, init_heberpop, ROT0, "Sunsoft / Atlus", "Hebereke no Popoon (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1994, blocken, 0, blocken, blocken, shangha3_state, init_blocken, ROT0, "Visco / KID", "Blocken (Japan)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +} // anonymous namespace + + +GAME( 1993, shangha3, 0, shangha3, shangha3, shangha3_state, init_shangha3, ROT0, "Sunsoft", "Shanghai III (World)", MACHINE_SUPPORTS_SAVE ) +GAME( 1993, shangha3u, shangha3, shangha3, shangha3, shangha3_state, init_shangha3, ROT0, "Sunsoft", "Shanghai III (US)", MACHINE_SUPPORTS_SAVE ) +GAME( 1993, shangha3up, shangha3, shangha3, shangha3, shangha3_state, init_shangha3, ROT0, "Sunsoft", "Shanghai III (US, prototype)", MACHINE_SUPPORTS_SAVE ) +GAME( 1993, shangha3j, shangha3, shangha3, shangha3, shangha3_state, init_shangha3, ROT0, "Sunsoft", "Shanghai III (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1994, heberpop, 0, heberpop, heberpop, heberpop_state, init_heberpop, ROT0, "Sunsoft / Atlus", "Hebereke no Popoon (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1994, blocken, 0, blocken, blocken, blocken_state, init_blocken, ROT0, "Visco / KID", "Blocken (Japan)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/sunelectronics/shangha3.h b/src/mame/sunelectronics/shangha3.h deleted file mode 100644 index 74e4a9eb661..00000000000 --- a/src/mame/sunelectronics/shangha3.h +++ /dev/null @@ -1,91 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria -#ifndef MAME_SUNELECTRONICS_SHANGHA3_H -#define MAME_SUNELECTRONICS_SHANGHA3_H - -#pragma once - -#include "machine/gen_latch.h" -#include "sound/okim6295.h" -#include "emupal.h" -#include "screen.h" - -class shangha3_state : public driver_device -{ -public: - shangha3_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_audiocpu(*this, "audiocpu"), - m_oki(*this, "oki"), - m_gfxdecode(*this, "gfxdecode"), - m_screen(*this, "screen"), - m_palette(*this, "palette"), - m_soundlatch(*this, "soundlatch"), - m_ram(*this, "ram"), - m_cgrom(*this, "gfx1"), - m_okibank(*this, "okibank") - { } - - void shangha3(machine_config &config); - void heberpop(machine_config &config); - void blocken(machine_config &config); - - void init_shangha3(); - void init_heberpop(); - void init_blocken(); - -protected: - virtual void video_start() override; - -private: - required_device m_maincpu; - optional_device m_audiocpu; - required_device m_oki; - required_device m_gfxdecode; - required_device m_screen; - required_device m_palette; - optional_device m_soundlatch; - - required_shared_ptr m_ram; - required_region_ptr m_cgrom; - - optional_memory_bank m_okibank; - - // driver init configuration - int m_do_shadows = 0; - uint8_t m_drawmode_table[16]{}; - - int m_prot_count = 0; - uint16_t m_gfxlist_addr = 0; - bitmap_ind16 m_rawbitmap; - - // common - void flipscreen_w(uint8_t data); - void gfxlist_addr_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void blitter_go_w(uint16_t data); - void irq_ack_w(uint16_t data); - uint8_t cgrom_r(offs_t offset); - - // shangha3 specific - uint16_t shangha3_prot_r(); - void shangha3_prot_w(uint16_t data); - void shangha3_coinctrl_w(uint8_t data); - - // heberpop specific - void heberpop_coinctrl_w(uint8_t data); - - // blocken specific - void blocken_coinctrl_w(uint8_t data); - - uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - - void blocken_map(address_map &map); - void blocken_oki_map(address_map &map); - void heberpop_map(address_map &map); - void heberpop_sound_io_map(address_map &map); - void heberpop_sound_map(address_map &map); - void shangha3_map(address_map &map); -}; - -#endif // MAME_SUNELECTRONICS_SHANGHA3_H diff --git a/src/mame/sunelectronics/shangha3_v.cpp b/src/mame/sunelectronics/shangha3_v.cpp deleted file mode 100644 index ccb820877e8..00000000000 --- a/src/mame/sunelectronics/shangha3_v.cpp +++ /dev/null @@ -1,260 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria -/*************************************************************************** - -Custom blitter GA9201 KA01-0249 (120pin IC) - - -This is a tile-based blitter that writes to a frame buffer. The buffer is -never cleared, so stuff drawn is left over from frame to frame until it is -overwritten. - -Tiles are stored in ROM and have a fixed 16x16 size. The blitter can draw them -as single sprites (composed of one or more tiles in the horizontal direction), -or as larger sprites whose tile codes are picked from a tilemap in RAM. - -Sprites can be zoomed, distorted and rotated. - -Shadows are supported on pen 14 (shangha3 makes heavy use of them) but it's not -clear how they are turned on and off. heberpop definitely doesn't use them, -pen 14 is supposed to be solid black (outlines). - -The chip addresses 0x100000 bytes of memory, containing both the command list, -tilemap, and spare RAM to be used by the CPU. - -The command list starts at a variable point in memory, set by -gfxlist_addr_w(), and always ends at 0x0fffff. - -Large sprites refer to a single tilemap starting at 0x000000, the command list -contains the coordinates of the place in the tilemap to pick data from. - -The commands list is processed when blitter_go_w() is written to, so -it is not processed automatically every frame. - -The commands have a fixed length of 16 words. The format is as follows: - -Word | Bit(s) | Use ------+-fedcba9876543210-+---------------- - 0 | ---------------- | unused? - 1 | xxxx------------ | high bits of tile #; for tilemaps, this is applied to all tiles - 1 | ----xxxxxxxxxxxx | low bits of tile #; probably unused for tilemaps - 2 | ---xxxxxxxxx---- | x coordinate of destination top left corner - 3 | ---xxxxxxxxx---- | y coordinate of destination top left corner - 4 | ------------x--- | 0 = use code as-is 1 = fetch codes from tilemap RAM - 4 | -------------x-- | 1 = draw "compressed" tilemap, as if tiles were 8x8 instead of 16x16 - 4 | --------------x- | flip y - 4 | ---------------x | flip x - 5 | --------x------- | unknown (used by blocken) - 5 | ---------xxx---- | high bits of color #; for tilemaps, this is applied to all tiles - 5 | ------------xxxx | low bits of color #; probably unused for tilemaps - 6 | xxxxxxxxxxxxxxxx | width-1 of destination rectangle \ if *both* of these are 0, - 7 | xxxxxxxxxxxxxxxx | height-1 of destination rectangle / disable sprite - 8 | xxxxxxxxxxxxxxxx | x coordinate*0x10 of source top left corner (tilemaps only?) - 9 | xxxxxxxxxxxxxxxx | y coordinate*0x10 of source top left corner (tilemaps only?) - a | xxxxxxxxxxxxxxxx | x zoom - b | xxxxxxxxxxxxxxxx | rotation - c | xxxxxxxxxxxxxxxx | rotation - d | xxxxxxxxxxxxxxxx | y zoom - e | ---------------- | unknown - f | ---------------- | unknown - -***************************************************************************/ - -#include "emu.h" -#include "shangha3.h" - - - -void shangha3_state::video_start() -{ - int i; - - m_screen->register_screen_bitmap(m_rawbitmap); - - for (i = 0;i < 14;i++) - m_drawmode_table[i] = DRAWMODE_SOURCE; - m_drawmode_table[14] = m_do_shadows ? DRAWMODE_SHADOW : DRAWMODE_SOURCE; - m_drawmode_table[15] = DRAWMODE_NONE; - - if (m_do_shadows) - { - /* Prepare the shadow table */ - for (i = 0;i < 128;i++) - m_palette->shadow_table()[i] = i+128; - } - - save_item(NAME(m_gfxlist_addr)); - save_item(NAME(m_rawbitmap)); -} - - - -void shangha3_state::flipscreen_w(uint8_t data) -{ - /* bit 7 flips screen, the rest seems to always be set to 0x7e */ - flip_screen_set(data & 0x80); - - if ((data & 0x7f) != 0x7e) popmessage("flipscreen_w %02x",data); -} - -void shangha3_state::gfxlist_addr_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - COMBINE_DATA(&m_gfxlist_addr); -} - - -void shangha3_state::blitter_go_w(uint16_t data) -{ - uint16_t *shangha3_ram = m_ram; - bitmap_ind16 &rawbitmap = m_rawbitmap; - uint8_t *drawmode_table = m_drawmode_table; - int offs; - - - auto profile = g_profiler.start(PROFILER_VIDEO); - - for (offs = m_gfxlist_addr << 3; offs < m_ram.bytes()/2; offs += 16) - { - int sx,sy,x,y,code,color,flipx,flipy,sizex,sizey,zoomx,zoomy; - - code = shangha3_ram[offs+1]; - color = shangha3_ram[offs+5] & 0x7f; - flipx = shangha3_ram[offs+4] & 0x01; - flipy = shangha3_ram[offs+4] & 0x02; - sx = (shangha3_ram[offs+2] & 0x1ff0) >> 4; - if (sx >= 0x180) sx -= 0x200; - sy = (shangha3_ram[offs+3] & 0x1ff0) >> 4; - if (sy >= 0x100) sy -= 0x200; - sizex = shangha3_ram[offs+6]; - sizey = shangha3_ram[offs+7]; - zoomx = shangha3_ram[offs+10]; - zoomy = shangha3_ram[offs+13]; - - if (flip_screen()) - { - sx = 383 - sx - sizex; - sy = 255 - sy - sizey; - flipx = !flipx; - flipy = !flipy; - } - - if ((sizex || sizey) - /* avoid garbage on startup */ - && sizex < 512 && sizey < 256 && zoomx < 0x1f0 && zoomy < 0x1f0) - { - rectangle myclip; - -// if (shangha3_ram[offs+11] || shangha3_ram[offs+12]) -// logerror("offs %04x: sx %04x sy %04x zoom %04x %04x %04x %04x fx %d fy %d\n",offs,sx,sy,zoomx,shangha3_ram[offs+11]),shangha3_ram[offs+12],zoomy,flipx,flipy); - - myclip.set(sx, sx + sizex, sy, sy + sizey); - myclip &= rawbitmap.cliprect(); - - if (shangha3_ram[offs+4] & 0x08) /* tilemap */ - { - int srcx,srcy,dispx,dispy,w,h,condensed; - - condensed = shangha3_ram[offs+4] & 0x04; - - srcx = shangha3_ram[offs+8]/16; - srcy = shangha3_ram[offs+9]/16; - dispx = srcx & 0x0f; - dispy = srcy & 0x0f; - - h = (sizey+15)/16+1; - w = (sizex+15)/16+1; - - if (condensed) - { - h *= 2; - w *= 2; - srcx /= 8; - srcy /= 8; - } - else - { - srcx /= 16; - srcy /= 16; - } - - for (y = 0;y < h;y++) - { - for (x = 0;x < w;x++) - { - int dx,dy,tile; - - /* TODO: zooming algo is definitely wrong for Blocken here */ - if (condensed) - { - int addr = ((y+srcy) & 0x1f) | - (((x+srcx) & 0xff) << 5); - tile = shangha3_ram[addr]; - dx = 8*x*(0x200-zoomx)/0x100 - dispx; - dy = 8*y*(0x200-zoomy)/0x100 - dispy; - } - else - { - int addr = ((y+srcy) & 0x0f) | - (((x+srcx) & 0xff) << 4) | - (((y+srcy) & 0x10) << 8); - tile = shangha3_ram[addr]; - dx = 16*x*(0x200-zoomx)/0x100 - dispx; - dy = 16*y*(0x200-zoomy)/0x100 - dispy; - } - - if (flipx) dx = sx + sizex-15 - dx; - else dx = sx + dx; - if (flipy) dy = sy + sizey-15 - dy; - else dy = sy + dy; - - m_gfxdecode->gfx(0)->transpen(rawbitmap,myclip, - (tile & 0x0fff) | (code & 0xf000), - (tile >> 12) | (color & 0x70), - flipx,flipy, - dx,dy,15); - } - } - } - else /* sprite */ - { - int w; - - if (zoomx <= 1 && zoomy <= 1) - m_gfxdecode->gfx(0)->zoom_transtable(rawbitmap,myclip, - code, - color, - flipx,flipy, - sx,sy, - 0x1000000,0x1000000, - drawmode_table); - else - { - w = (sizex+15)/16; - - for (x = 0;x < w;x++) - { - m_gfxdecode->gfx(0)->zoom_transtable(rawbitmap,myclip, - code, - color, - flipx,flipy, - sx + 16*x,sy, - (0x200-zoomx)*0x100,(0x200-zoomy)*0x100, - drawmode_table); - - if ((code & 0x000f) == 0x0f) - code = (code + 0x100) & 0xfff0; - else - code++; - } - } - } - } - } -} - - -uint32_t shangha3_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, m_rawbitmap, 0, 0, 0, 0, cliprect); - return 0; -} From acea8712d6a424374d5f4955a06b4bae77d4af0a Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Wed, 31 Jul 2024 03:16:53 +1000 Subject: [PATCH 10/11] Bumped version to 0.268 --- android-project/app/src/main/AndroidManifest.xml | 4 ++-- docs/source/conf.py | 4 ++-- makefile | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/android-project/app/src/main/AndroidManifest.xml b/android-project/app/src/main/AndroidManifest.xml index 765e2a0788b..37320df98a9 100644 --- a/android-project/app/src/main/AndroidManifest.xml +++ b/android-project/app/src/main/AndroidManifest.xml @@ -4,8 +4,8 @@ --> diff --git a/docs/source/conf.py b/docs/source/conf.py index c498499145f..63dd0bfed6a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -63,9 +63,9 @@ # built documents. # # The short X.Y version. -version = '0.267' +version = '0.268' # The full version, including alpha/beta/rc tags. -release = '0.267' +release = '0.268' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/makefile b/makefile index 599df7935da..7af7a7c8020 100644 --- a/makefile +++ b/makefile @@ -1578,7 +1578,7 @@ endif ifeq (posix,$(SHELLTYPE)) $(GENDIR)/version.cpp: makefile $(GENDIR)/git_desc | $(GEN_FOLDERS) - @echo '#define BARE_BUILD_VERSION "0.267"' > $@ + @echo '#define BARE_BUILD_VERSION "0.268"' > $@ @echo '#define BARE_VCS_REVISION "$(NEW_GIT_VERSION)"' >> $@ @echo 'extern const char bare_build_version[];' >> $@ @echo 'extern const char bare_vcs_revision[];' >> $@ @@ -1588,7 +1588,7 @@ $(GENDIR)/version.cpp: makefile $(GENDIR)/git_desc | $(GEN_FOLDERS) @echo 'const char build_version[] = BARE_BUILD_VERSION " (" BARE_VCS_REVISION ")";' >> $@ else $(GENDIR)/version.cpp: makefile $(GENDIR)/git_desc | $(GEN_FOLDERS) - @echo #define BARE_BUILD_VERSION "0.267" > $@ + @echo #define BARE_BUILD_VERSION "0.268" > $@ @echo #define BARE_VCS_REVISION "$(NEW_GIT_VERSION)" >> $@ @echo extern const char bare_build_version[]; >> $@ @echo extern const char bare_vcs_revision[]; >> $@ From 955ecd040c06a8b23fa7e15ef190ae947782154f Mon Sep 17 00:00:00 2001 From: angelosa Date: Wed, 31 Jul 2024 19:06:24 +0200 Subject: [PATCH 11/11] commodore/c65.cpp: move DMA logic to emu_timer --- src/mame/commodore/c65.cpp | 265 +++++++++++++++++++++++++------------ 1 file changed, 182 insertions(+), 83 deletions(-) diff --git a/src/mame/commodore/c65.cpp b/src/mame/commodore/c65.cpp index a175e6336c3..0b16aed3b13 100644 --- a/src/mame/commodore/c65.cpp +++ b/src/mame/commodore/c65.cpp @@ -4,6 +4,18 @@ C=65 / C=64DX (c) 1991 Commodore +TODO: +- Fails interpreting BASIC commands +\- DMA tries this COPY in ROM space $20200 but should really be in work RAM $206; +\- PC=f27c stz $03d5 have Z=0 but transfers a 0x02? +- Complete memory model; +- Complete interrupts; +- F011 FDC; +- C=64 mode (with "GO64" at BASIC prompt); + +=================================================================================================== +References: + Hardware infos can be found at: http://www.zimmers.net/cbmpics/cbm/c65/c65manual.txt http://www.zimmers.net/cbmpics/cbm/c65/c65faq20.txt @@ -30,7 +42,7 @@ Hardware pics: #define MAIN_CLOCK XTAL(28'375'160)/8 -// TODO: move to own file, subclass with f018a, use device_execute_interface +// TODO: move to own file, subclass with f018a and f018b, use device_execute_interface class dmagic_f018_device : public device_t { public: @@ -50,7 +62,21 @@ class dmagic_f018_device : public device_t u32 m_dmalist_address = 0; - void execute(u32 address); + TIMER_CALLBACK_MEMBER(execute_cb); + typedef enum { + COPY, + MIX, + SWAP, + FILL, + IDLE, + FETCH_PARAMS + } dma_state_t; + + dma_state_t m_state; + u32 m_src, m_dst, m_length, m_command, m_modulo; + bool m_chained_transfer; + emu_timer *m_dma_timer; + void check_state(int next_cycles); }; DEFINE_DEVICE_TYPE(DMAGIC_F018, dmagic_f018_device, "dmagic_f018", "DMAgic F018 Gate Array") @@ -64,76 +90,135 @@ dmagic_f018_device::dmagic_f018_device(const machine_config &mconfig, const char void dmagic_f018_device::device_start() { save_item(NAME(m_dmalist_address)); + //save_item(NAME(m_state)); + + m_dma_timer = timer_alloc(FUNC(dmagic_f018_device::execute_cb), this); } void dmagic_f018_device::device_reset() -{} +{ + m_dma_timer->adjust(attotime::never); + m_state = dma_state_t::IDLE; + m_chained_transfer = false; + m_dmalist_address = 0; +} -void dmagic_f018_device::execute(u32 address) +void dmagic_f018_device::check_state(int next_cycles) { - static const char *const dma_cmd_string[] = - { - "COPY", - "MIX", - "SWAP", - "FILL" - }; - u8 cmd = m_space->read_byte(address++); - u16 length = m_space->read_byte(address++); - length |=(m_space->read_byte(address++)<<8); - - u32 src = m_space->read_byte(address++); - src |=(m_space->read_byte(address++)<<8); - src |=(m_space->read_byte(address++)<<16); - - u32 dst = m_space->read_byte(address++); - dst |=(m_space->read_byte(address++)<<8); - dst |=(m_space->read_byte(address++)<<16); - - if(cmd & 0xfc) - logerror("%02x\n",cmd & 0xfc); - switch(cmd & 3) + if (m_length != 0) + m_dma_timer->adjust(attotime::from_ticks((next_cycles), clock())); + else { - // copy - // TODO: untested, is it even implemented in F018? - case 0: - { - if(length != 1) - logerror("DMAgic %s %02x -> %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src,dst,length,cmd & 4 ? "yes" : "no"); - uint32_t SourceIndex; - uint32_t DestIndex; - uint16_t SizeIndex; - SourceIndex = src & 0xfffff; - DestIndex = dst & 0xfffff; - SizeIndex = length; - do - { - m_space->write_byte(DestIndex++,m_space->read_byte(SourceIndex++)); - SizeIndex--; - }while(SizeIndex != 0); + m_chained_transfer = bool(BIT(m_command, 2)); + if (m_chained_transfer) + popmessage("DMAgic: untested Chain Mode"); + m_state = m_chained_transfer ? FETCH_PARAMS : IDLE; + m_dma_timer->adjust(m_chained_transfer ? attotime::from_ticks(12, clock()) : attotime::never); + } +} +TIMER_CALLBACK_MEMBER(dmagic_f018_device::execute_cb) +{ + switch(m_state) + { + case dma_state_t::IDLE: return; + + case dma_state_t::FETCH_PARAMS: { + static const char *const dma_cmd_string[] = + { + "COPY", + "MIX", + "SWAP", + "FILL" + }; + + u32 address = m_dmalist_address; + logerror("%05x ", address); + m_command = m_space->read_byte(address++); + + m_length = m_space->read_byte(address++); + m_length |=(m_space->read_byte(address++)<<8); + + if (m_length == 0) + m_length = 0x10000; + + m_src = m_space->read_byte(address++); + m_src |=(m_space->read_byte(address++)<<8); + m_src |=(m_space->read_byte(address++)<<16); + + m_dst = m_space->read_byte(address++); + m_dst |=(m_space->read_byte(address++)<<8); + m_dst |=(m_space->read_byte(address++)<<16); + + m_modulo = m_space->read_byte(address++); + m_modulo |=(m_space->read_byte(address++)<<8); + + m_dmalist_address = address; + m_state = (dma_state_t)(m_command & 3); + + logerror("DMAgic %s %06x -> %06x %04x %02x (CHAIN=%s)\n" + , dma_cmd_string[m_command & 3] + , m_src + , m_dst + , m_length + , m_modulo + , m_command & 4 ? "yes" : "no" + ); + + if (m_command & 0xf8) + popmessage("DMAgic unhandled command %02x", m_command); + + // x--- I/O select + // -x-- DIR + // --x- MOD + // ---x HOLD + if ((m_src & 0xf0'0000 || m_dst & 0xf0'0000) && m_length != 1) + { + popmessage("DMAgic unhandled source %06x dst %06x length %05x", m_src, m_dst, m_length); + machine().debug_break(); + } + + m_dma_timer->adjust(attotime::from_ticks((1), clock())); + break; } - // fill - case 3: - { - // TODO: upper bits of source - logerror("DMAgic %s %02x -> %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src & 0xff,dst,length,cmd & 4 ? "yes" : "no"); - uint8_t FillValue; - uint32_t DestIndex; - uint16_t SizeIndex; - FillValue = src & 0xff; - DestIndex = dst & 0xfffff; - SizeIndex = length; - do - { - m_space->write_byte(DestIndex++,FillValue); - SizeIndex--; - }while(SizeIndex != 0); - return; + + // TODO: very limited use by the BIOS, not extensively tested + // generally uses length == 1 (for copying BASIC strings from work RAM) + // or length == 50 (for scrolling vertical text, cfr. c64dx) + case dma_state_t::COPY: { + m_space->write_byte(m_dst & 0xf'ffff, m_space->read_byte(m_src & 0xf'ffff)); + m_src = ((m_src + 1) & 0xffff) | (m_src & 0xf'0000); + m_dst = ((m_dst + 1) & 0xffff) | (m_dst & 0xf'0000); + m_length --; + check_state(2); + break; } + + case dma_state_t::MIX: + popmessage("DMAgic: unimplemented MIX"); + break; + + case dma_state_t::SWAP: { + popmessage("DMAgic: untested SWAP"); + const u8 tmp_src = m_space->read_byte(m_src & 0xf'ffff); + const u8 tmp_dst = m_space->read_byte(m_dst & 0xf'ffff); + m_space->write_byte(m_src & 0xf'ffff, tmp_dst); + m_space->write_byte(m_dst & 0xf'ffff, tmp_src); + m_src = ((m_src + 1) & 0xffff) | (m_src & 0xf'0000); + m_dst = ((m_dst + 1) & 0xffff) | (m_dst & 0xf'0000); + m_length --; + check_state(4); + break; + } + + case dma_state_t::FILL: + m_space->write_byte(m_dst & 0xf'ffff, m_src & 0xff); + m_dst = ((m_dst + 1) & 0xffff) | (m_dst & 0xf'0000); + m_length --; + check_state(1); + break; } - logerror("DMAgic %s %08x %08x %04x (CHAIN=%s)\n",dma_cmd_string[cmd & 3],src,dst,length,cmd & 4 ? "yes" : "no"); } @@ -143,7 +228,8 @@ void dmagic_f018_device::map(address_map &map) NAME([this] (offs_t offset, u8 data) { m_dmalist_address &= 0xffff00; m_dmalist_address |= data; - execute(m_dmalist_address); + m_state = FETCH_PARAMS; + m_dma_timer->adjust(attotime::from_ticks((12), clock())); }) ); map(1, 1).lw8( @@ -158,7 +244,11 @@ void dmagic_f018_device::map(address_map &map) m_dmalist_address |= data << 16; }) ); -// 3 read status + map(3, 3).lr8( + NAME([this] (offs_t offset) { + return (m_state != IDLE) << 7 | (m_chained_transfer << 0); + }) + ); } namespace { @@ -172,7 +262,7 @@ class c65_state : public driver_device , m_cia(*this, "cia_%u", 0U) , m_sid(*this, "sid_%u", 0U) , m_dma(*this, "dma") - , m_cia_view(*this, "cia_view") + , m_cram_view(*this, "cram_view") , m_screen(*this, "screen") , m_palette(*this, "palette") , m_workram(*this, "work_ram") @@ -189,7 +279,7 @@ class c65_state : public driver_device required_device_array m_cia; required_device_array m_sid; required_device m_dma; - memory_view m_cia_view; + memory_view m_cram_view; required_device m_screen; required_device m_palette; required_shared_ptr m_workram; @@ -237,6 +327,7 @@ class c65_state : public driver_device uint8_t m_VIC2_EXTColor = 0U; uint8_t m_VIC2_VS_CB_Base = 0U; uint8_t m_VIC2_BK0_Color = 0U; + uint8_t m_sprite_enable = 0U; /* 0x30: banking + PAL + EXT SYNC */ uint8_t m_VIC3_ControlA = 0U; /* 0x31: video modes */ @@ -262,9 +353,12 @@ void c65_state::vic4567_map(address_map &map) return (m_screen->vpos() & 0xff); }) ); - map(0x15, 0x15).lr8( - NAME([] (offs_t offset) { - return 0xff; // silence log for now + map(0x15, 0x15).lrw8( + NAME([this] (offs_t offset) { + return m_sprite_enable; + }), + NAME([this] (offs_t offset, u8 data) { + m_sprite_enable = data; }) ); map(0x18, 0x18).lrw8( @@ -312,7 +406,7 @@ void c65_state::vic4567_map(address_map &map) /* * KEY register, handles vic-iii and vic-ii modes via two consecutive writes * 0xa5 -> 0x96 vic-iii mode - * any other write vic-ii mode + * any other write vic-ii mode (changes base memory map) */ // map(0x2f, 0x2f) map(0x30, 0x30).lrw8( @@ -323,7 +417,8 @@ void c65_state::vic4567_map(address_map &map) if((data & 0xfe) != 0x64) logerror("CONTROL A %02x\n",data); m_VIC3_ControlA = data; - m_cia_view.select(BIT(data, 0)); + // TODO: all the other bits + m_cram_view.select(BIT(data, 0)); }) ); map(0x31, 0x31).lrw8( @@ -471,8 +566,9 @@ void c65_state::cia0_portb_w(uint8_t data) void c65_state::c65_map(address_map &map) { - map(0x00000, 0x07fff).ram().share("work_ram"); // TODO: bank - map(0x0c800, 0x0cfff).rom().region("ipl", 0xc800); + map(0x00000, 0x07fff).ram().share("work_ram"); + map(0x08000, 0x0bfff).rom().region("ipl", 0x08000); + map(0x0c800, 0x0cfff).rom().region("ipl", 0x0c800); map(0x0d000, 0x0d07f).m(*this, FUNC(c65_state::vic4567_map)); // 0x0d080, 0x0d09f FDC // 0x0d0a0, 0x0d0ff Ram Expansion Control (REC) @@ -480,24 +576,26 @@ void c65_state::c65_map(address_map &map) map(0x0d200, 0x0d2ff).ram().w(FUNC(c65_state::PalGreen_w)).share("greenpal"); // 0x0d200, 0x0d2ff Green Palette map(0x0d300, 0x0d3ff).ram().w(FUNC(c65_state::PalBlue_w)).share("bluepal"); // 0x0d300, 0x0d3ff Blue Palette // 0x0d400, 0x0d4*f Right SID - map(0x0d400, 0x0d41f).rw(m_sid[1], FUNC(mos6581_device::read), FUNC(mos6581_device::write)); + // keyboard hold left shift will read to $d484 (?) + map(0x0d400, 0x0d41f).mirror(0x80).rw(m_sid[1], FUNC(mos6581_device::read), FUNC(mos6581_device::write)); // 0x0d440, 0x0d4*f Left SID - map(0x0d440, 0x0d45f).rw(m_sid[0], FUNC(mos6581_device::read), FUNC(mos6581_device::write)); + map(0x0d440, 0x0d45f).mirror(0x80).rw(m_sid[0], FUNC(mos6581_device::read), FUNC(mos6581_device::write)); map(0x0d600, 0x0d6ff).rw(FUNC(c65_state::uart_r), FUNC(c65_state::uart_w)); // 0x0d700, 0x0d7** DMAgic map(0x0d700, 0x0d703).m(m_dma, FUNC(dmagic_f018_device::map)); // 0x0d800, 0x0d8** Color matrix - map(0x0d800, 0x0dfff).view(m_cia_view); + map(0x0d800, 0x0dfff).view(m_cram_view); // maps lower 1024 bytes regardless of the setting (essentially touches $dc00 as overlay) - m_cia_view[0](0x0d800, 0x0dbff).lrw8( + m_cram_view[0](0x0d800, 0x0dbff).lrw8( NAME([this] (offs_t offset) { return m_cram[offset]; }), NAME([this] (offs_t offset, u8 data) { m_cram[offset] = data; }) ); - m_cia_view[0](0x0dc00, 0x0dc0f).rw(m_cia[0], FUNC(mos6526_device::read), FUNC(mos6526_device::write)); - m_cia_view[0](0x0dd00, 0x0dd0f).rw(m_cia[1], FUNC(mos6526_device::read), FUNC(mos6526_device::write)); + + m_cram_view[0](0x0dc00, 0x0dc0f).rw(m_cia[0], FUNC(mos6526_device::read), FUNC(mos6526_device::write)); + m_cram_view[0](0x0dd00, 0x0dd0f).rw(m_cia[1], FUNC(mos6526_device::read), FUNC(mos6526_device::write)); // 0x0de00, 0x0de** Ext I/O Select 1 // 0x0df00, 0x0df** Ext I/O Select 2 (RAM window?) - m_cia_view[1](0x0d800, 0x0dfff).ram().share("cram"); + m_cram_view[1](0x0d800, 0x0dfff).ram().share("cram"); map(0x0e000, 0x0ffff).rom().region("ipl", 0x0e000); map(0x10000, 0x1f7ff).ram(); map(0x1f800, 0x1ffff).ram().share("cram"); @@ -621,7 +719,8 @@ void c65_state::machine_start() void c65_state::machine_reset() { - m_cia_view.select(0); + m_VIC3_ControlA = 0; + m_cram_view.select(0); } @@ -660,8 +759,6 @@ void c65_state::IRQCheck(uint8_t irq_cause) INTERRUPT_GEN_MEMBER(c65_state::vic3_vblank_irq) { IRQCheck(1); - //if(m_VIC2_IRQMask & 1) - // m_maincpu->set_input_line(M4510_IRQ_LINE,HOLD_LINE); } void c65_state::cia0_irq(int state) @@ -687,7 +784,9 @@ void c65_state::c65(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &c65_state::c65_map); m_maincpu->set_vblank_int("screen", FUNC(c65_state::vic3_vblank_irq)); - DMAGIC_F018(config, m_dma, MAIN_CLOCK); + // TODO: multiply by x8 because with a more canonical x1 no transfer will complete in time. + // is this thing a mixed burst/cycle steal really? + DMAGIC_F018(config, m_dma, MAIN_CLOCK * 8); m_dma->set_space(m_maincpu, AS_PROGRAM); MOS6526(config, m_cia[0], MAIN_CLOCK);