diff --git a/src/mame/drivers/megaplay.c b/src/mame/drivers/megaplay.c index 39e85d80c78..471d50f0d54 100644 --- a/src/mame/drivers/megaplay.c +++ b/src/mame/drivers/megaplay.c @@ -569,13 +569,13 @@ MACHINE_RESET_MEMBER(mplay_state,megaplay) m_mp_bios_bank_addr = 0; m_readpos = 1; MACHINE_RESET_CALL_MEMBER(megadriv); - MACHINE_RESET_CALL_MEMBER(megatech_bios); + MACHINE_RESET_CALL_MEMBER(megaplay_bios); } void mplay_state::screen_eof_megaplay(screen_device &screen, bool state) { screen_eof_megadriv(screen,state); - screen_eof_megatech_bios(screen,state); + screen_eof_megaplay_bios(screen,state); } static MACHINE_CONFIG_START( megaplay, mplay_state ) diff --git a/src/mame/drivers/megatech.c b/src/mame/drivers/megatech.c index d2414af5924..dd5cc8be70f 100644 --- a/src/mame/drivers/megatech.c +++ b/src/mame/drivers/megatech.c @@ -202,7 +202,6 @@ static INPUT_PORTS_START( megatech ) /* Genesis Input Ports */ PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - INPUT_PORTS_END /* MEGATECH specific */ @@ -211,7 +210,6 @@ READ8_MEMBER(mtech_state::megatech_cart_select_r ) return m_mt_cart_select_reg; } - void mtech_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { switch (id) @@ -227,6 +225,118 @@ void mtech_state::device_timer(emu_timer &timer, device_timer_id id, int param, } } +READ8_MEMBER(mtech_state::sms_count_r) +{ + address_space &prg = machine().device("genesis_snd_z80")->memory().space(AS_PROGRAM); + if (offset & 0x01) + return m_vdp->hcount_read(prg, offset); + else + return m_vdp->vcount_read(prg, offset); +} + + +/* the SMS inputs should be more complex, like the megadrive ones */ +READ8_MEMBER (mtech_state::sms_ioport_dc_r) +{ + /* 2009-05 FP: would it be worth to give separate inputs to SMS? SMS has only 2 keys A,B (which are B,C on megadrive) */ + /* bit 4: TL-A; bit 5: TR-A */ + return (machine().root_device().ioport("PAD1")->read() & 0x3f) | ((machine().root_device().ioport("PAD2")->read() & 0x03) << 6); +} + +READ8_MEMBER (mtech_state::sms_ioport_dd_r) +{ + /* 2009-05 FP: would it be worth to give separate inputs to SMS? SMS has only 2 keys A,B (which are B,C on megadrive) */ + /* bit 2: TL-B; bit 3: TR-B; bit 4: RESET; bit 5: unused; bit 6: TH-A; bit 7: TH-B*/ + return ((machine().root_device().ioport("PAD2")->read() & 0x3c) >> 2) | 0x10; +} + + +WRITE8_MEMBER( mtech_state::mt_sms_standard_rom_bank_w ) +{ + int bank = data&0x1f; + //logerror("bank w %02x %02x\n", offset, data); + + sms_mainram[0x1ffc+offset] = data; + switch (offset) + { + case 0: + logerror("bank w %02x %02x\n", offset, data); + space.install_rom(0x0000, 0xbfff, sms_rom); + space.unmap_write(0x0000, 0xbfff); + //printf("bank ram??\n"); + break; + case 1: + memcpy(sms_rom+0x0000, space.machine().root_device().memregion("maincpu")->base()+bank*0x4000, 0x4000); + break; + case 2: + memcpy(sms_rom+0x4000, space.machine().root_device().memregion("maincpu")->base()+bank*0x4000, 0x4000); + break; + case 3: + memcpy(sms_rom+0x8000, space.machine().root_device().memregion("maincpu")->base()+bank*0x4000, 0x4000); + break; + + } +} + +void mtech_state::megatech_set_genz80_as_sms(const char* tag) +{ + address_space &prg = machine().device(tag)->memory().space(AS_PROGRAM); + address_space &io = machine().device(tag)->memory().space(AS_IO); + sn76496_base_device *sn = machine().device("snsnd"); + + // main ram area + sms_mainram = (UINT8 *)prg.install_ram(0xc000, 0xdfff, 0, 0x2000); + memset(sms_mainram,0x00,0x2000); + + // fixed rom bank area + sms_rom = (UINT8 *)prg.install_rom(0x0000, 0xbfff, NULL); + + memcpy(sms_rom, machine().root_device().memregion("maincpu")->base(), 0xc000); + + prg.install_write_handler(0xfffc, 0xffff, write8_delegate(FUNC(mtech_state::mt_sms_standard_rom_bank_w),this)); + + // ports + io.install_read_handler (0x40, 0x41, 0xff, 0x3e, read8_delegate(FUNC(mtech_state::sms_count_r),this)); + io.install_write_handler (0x40, 0x41, 0xff, 0x3e, write8_delegate(FUNC(sn76496_device::write),sn)); + io.install_readwrite_handler (0x80, 0x80, 0xff, 0x3e, read8_delegate(FUNC(sega315_5124_device::vram_read),(sega315_5124_device *)m_vdp), write8_delegate(FUNC(sega315_5124_device::vram_write),(sega315_5124_device *)m_vdp)); + io.install_readwrite_handler (0x81, 0x81, 0xff, 0x3e, read8_delegate(FUNC(sega315_5124_device::register_read),(sega315_5124_device *)m_vdp), write8_delegate(FUNC(sega315_5124_device::register_write),(sega315_5124_device *)m_vdp)); + + io.install_read_handler (0x10, 0x10, read8_delegate(FUNC(mtech_state::sms_ioport_dd_r),this)); // super tetris + + io.install_read_handler (0xdc, 0xdc, read8_delegate(FUNC(mtech_state::sms_ioport_dc_r),this)); + io.install_read_handler (0xdd, 0xdd, read8_delegate(FUNC(mtech_state::sms_ioport_dd_r),this)); + io.install_read_handler (0xde, 0xde, read8_delegate(FUNC(mtech_state::sms_ioport_dd_r),this)); + io.install_read_handler (0xdf, 0xdf, read8_delegate(FUNC(mtech_state::sms_ioport_dd_r),this)); // adams family +} + + +/* sets the megadrive z80 to it's normal ports / map */ +void mtech_state::megatech_set_genz80_as_md(const char* tag) +{ + address_space &prg = machine().device(tag)->memory().space(AS_PROGRAM); + address_space &io = machine().device(tag)->memory().space(AS_IO); + ym2612_device *ym2612 = machine().device("ymsnd"); + + io.install_readwrite_handler(0x0000, 0xffff, read8_delegate(FUNC(mtech_state::z80_unmapped_port_r),this), write8_delegate(FUNC(mtech_state::z80_unmapped_port_w),this)); + + /* catch any addresses that don't get mapped */ + prg.install_readwrite_handler(0x0000, 0xffff, read8_delegate(FUNC(mtech_state::z80_unmapped_r),this), write8_delegate(FUNC(mtech_state::z80_unmapped_w),this)); + + + prg.install_readwrite_bank(0x0000, 0x1fff, "bank1"); + machine().root_device().membank("bank1")->set_base(m_genz80.z80_prgram); + + prg.install_ram(0x0000, 0x1fff, m_genz80.z80_prgram); + + prg.install_readwrite_handler(0x4000, 0x4003, read8_delegate(FUNC(ym2612_device::read),ym2612), write8_delegate(FUNC(ym2612_device::write),ym2612)); + prg.install_write_handler (0x6000, 0x6000, write8_delegate(FUNC(mtech_state::megadriv_z80_z80_bank_w),this)); + prg.install_write_handler (0x6001, 0x6001, write8_delegate(FUNC(mtech_state::megadriv_z80_z80_bank_w),this)); + prg.install_read_handler (0x6100, 0x7eff, read8_delegate(FUNC(mtech_state::megadriv_z80_unmapped_read),this)); + prg.install_readwrite_handler(0x7f00, 0x7fff, read8_delegate(FUNC(mtech_state::megadriv_z80_vdp_read),this), write8_delegate(FUNC(mtech_state::megadriv_z80_vdp_write),this)); + prg.install_readwrite_handler(0x8000, 0xffff, read8_delegate(FUNC(mtech_state::z80_read_68k_banked_data),this), write8_delegate(FUNC(mtech_state::z80_write_68k_banked_data),this)); +} + + TIMER_CALLBACK_MEMBER(mtech_state::megatech_z80_run_state ) { @@ -242,7 +352,7 @@ TIMER_CALLBACK_MEMBER(mtech_state::megatech_z80_run_state ) { printf("enabling SMS Z80\n"); m_current_game_is_sms = 1; - megatech_set_genz80_as_sms_standard_map("genesis_snd_z80"); + megatech_set_genz80_as_sms("genesis_snd_z80"); //m_z80snd->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); m_z80snd->set_input_line(INPUT_LINE_RESET, CLEAR_LINE); } @@ -250,7 +360,7 @@ TIMER_CALLBACK_MEMBER(mtech_state::megatech_z80_run_state ) { printf("disabling SMS Z80\n"); m_current_game_is_sms = 0; - megatech_set_megadrive_z80_as_megadrive_z80("genesis_snd_z80"); + megatech_set_genz80_as_md("genesis_snd_z80"); m_maincpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE); //m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); } @@ -273,8 +383,7 @@ TIMER_CALLBACK_MEMBER(mtech_state::megatech_z80_stop_state ) machine().device("ymsnd")->reset(); megadriv_stop_scanline_timer();// stop the scanline timer for the genesis vdp... it can be restarted in video eof when needed - megatech_sms_stop_scanline_timer();// stop the scanline timer for the sms vdp - + m_vdp->reset(); /* if the regions exist we're fine */ if (game_region) @@ -430,20 +539,14 @@ DRIVER_INIT_MEMBER(mtech_state,mt_crt) m_cart_is_genesis[0] = !pin[0] ? 1 : 0;; } -VIDEO_START_MEMBER(mtech_state,mtnew) -{ - init_for_megadrive(); // create an sms vdp too, for compatibility mode - VIDEO_START_CALL_MEMBER(megadriv); -} -//attotime::never UINT32 mtech_state::screen_update_mtnew(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { /* if we're running an sms game then use the SMS update.. maybe this should be moved to the megadrive emulation core as compatibility mode is a feature of the chip */ if (!m_current_game_is_sms) screen_update_megadriv(screen, bitmap, cliprect); else - screen_update_megatech_sms(screen, bitmap, cliprect); + m_vdp->screen_update(screen, bitmap, cliprect); return 0; } @@ -451,16 +554,12 @@ void mtech_state::screen_eof_mtnew(screen_device &screen, bool state) { if (!m_current_game_is_sms) screen_eof_megadriv(screen, state); - else - screen_eof_megatech_md_sms(screen, state); } MACHINE_RESET_MEMBER(mtech_state,mtnew) { m_mt_bank_addr = 0; - MACHINE_RESET_CALL_MEMBER(megadriv); - MACHINE_RESET_CALL_MEMBER(megatech_md_sms); megatech_select_game(0); } @@ -472,16 +571,28 @@ UINT32 mtech_state::screen_update_megatech_menu(screen_device &screen, bitmap_rg -WRITE_LINE_MEMBER( mtech_state::int_callback ) +WRITE_LINE_MEMBER( mtech_state::bios_int_callback ) { m_bioscpu->set_input_line(0, state); } - -static const sega315_5124_interface _vdp_intf = +static const sega315_5124_interface bios_vdp_intf = { false, - DEVCB_DRIVER_LINE_MEMBER(mtech_state, int_callback), + DEVCB_DRIVER_LINE_MEMBER(mtech_state, bios_int_callback), + DEVCB_NULL, +}; + + +WRITE_LINE_MEMBER( mtech_state::snd_int_callback ) +{ + m_z80snd->set_input_line(0, state); +} + +static const sega315_5124_interface main_vdp_intf = +{ + false, + DEVCB_DRIVER_LINE_MEMBER(mtech_state, snd_int_callback), DEVCB_NULL, }; @@ -497,10 +608,23 @@ static MACHINE_CONFIG_START( megatech, mtech_state ) MCFG_MACHINE_RESET_OVERRIDE(mtech_state,mtnew) - MCFG_VIDEO_START_OVERRIDE(mtech_state,mtnew) - MCFG_DEFAULT_LAYOUT(layout_dualhovu) + MCFG_SCREEN_MODIFY("megadriv") + MCFG_SCREEN_RAW_PARAMS(XTAL_10_738635MHz/2, \ + SEGA315_5124_WIDTH , SEGA315_5124_LBORDER_START + SEGA315_5124_LBORDER_WIDTH, SEGA315_5124_LBORDER_START + SEGA315_5124_LBORDER_WIDTH + 256, \ + SEGA315_5124_HEIGHT_NTSC, SEGA315_5124_TBORDER_START + SEGA315_5124_NTSC_224_TBORDER_HEIGHT, SEGA315_5124_TBORDER_START + SEGA315_5124_NTSC_224_TBORDER_HEIGHT + 224) + MCFG_SCREEN_UPDATE_DRIVER(mtech_state, screen_update_mtnew) + MCFG_SCREEN_VBLANK_DRIVER(mtech_state, screen_eof_mtnew) + + MCFG_DEVICE_REMOVE("gen_vdp") + MCFG_DEVICE_ADD("gen_vdp", SEGA_GEN_VDP, 0) + MCFG_DEVICE_CONFIG( main_vdp_intf ) + MCFG_VIDEO_SET_SCREEN("megadriv") + sega_genesis_vdp_device::set_genesis_vdp_sndirqline_callback(*device, DEVCB2_WRITELINE(md_base_state, genesis_vdp_sndirqline_callback_genesis_z80)); + sega_genesis_vdp_device::set_genesis_vdp_lv6irqline_callback(*device, DEVCB2_WRITELINE(md_base_state, genesis_vdp_lv6irqline_callback_genesis_68k)); + sega_genesis_vdp_device::set_genesis_vdp_lv4irqline_callback(*device, DEVCB2_WRITELINE(md_base_state, genesis_vdp_lv4irqline_callback_genesis_68k)); + MCFG_SCREEN_ADD("menu", RASTER) // check frq MCFG_SCREEN_RAW_PARAMS(XTAL_10_738635MHz/2, \ @@ -508,14 +632,9 @@ static MACHINE_CONFIG_START( megatech, mtech_state ) SEGA315_5124_HEIGHT_NTSC, SEGA315_5124_TBORDER_START + SEGA315_5124_NTSC_224_TBORDER_HEIGHT, SEGA315_5124_TBORDER_START + SEGA315_5124_NTSC_224_TBORDER_HEIGHT + 224) MCFG_SCREEN_UPDATE_DRIVER(mtech_state, screen_update_megatech_menu) - MCFG_SEGA315_5246_ADD("vdp1", _vdp_intf) + MCFG_SEGA315_5246_ADD("vdp1", bios_vdp_intf) MCFG_SEGA315_5246_SET_SCREEN("menu") - - MCFG_SCREEN_MODIFY("megadriv") - MCFG_SCREEN_UPDATE_DRIVER(mtech_state, screen_update_mtnew) - MCFG_SCREEN_VBLANK_DRIVER(mtech_state, screen_eof_mtnew) - /* sound hardware */ MCFG_SOUND_ADD("sn2", SN76496, MASTER_CLOCK/15) MCFG_SOUND_ROUTE(0, "lspeaker", 0.50) diff --git a/src/mame/includes/megadriv.h b/src/mame/includes/megadriv.h index 8bc6554f1de..5cde4e9448e 100644 --- a/src/mame/includes/megadriv.h +++ b/src/mame/includes/megadriv.h @@ -338,10 +338,8 @@ public: UINT32 screen_update_megaplay_bios(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); UINT32 screen_update_megatech_sms(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); void init_megaplay_legacy_overlay(); - DECLARE_MACHINE_RESET(megatech_bios); - DECLARE_MACHINE_RESET(megatech_md_sms); - void screen_eof_megatech_bios(screen_device &screen, bool state); - void screen_eof_megatech_md_sms(screen_device &screen, bool state); + DECLARE_MACHINE_RESET(megaplay_bios); + void screen_eof_megaplay_bios(screen_device &screen, bool state); DECLARE_READ8_MEMBER( sms_vcounter_r ); DECLARE_READ8_MEMBER( sms_vdp_data_r ); @@ -349,17 +347,12 @@ public: DECLARE_READ8_MEMBER( sms_vdp_ctrl_r ); DECLARE_WRITE8_MEMBER( sms_vdp_ctrl_w ); - void init_for_megadrive(); - void megatech_sms_stop_scanline_timer(); - void megatech_set_genz80_as_sms_standard_map(const char* tag); private: UINT8* vdp1_vram_bank0; UINT8* vdp1_vram_bank1; - UINT8* sms_mainram; struct sms_vdp *vdp1; struct sms_vdp *md_sms_vdp; - UINT8* sms_rom; static int sms_vdp_null_irq_callback(running_machine &machine, int status); static int sms_vdp_cpu1_irq_callback(running_machine &machine, int status); @@ -380,20 +373,10 @@ private: TIMER_CALLBACK_MEMBER( sms_scanline_timer_callback ); void end_of_frame(screen_device &screen, struct sms_vdp *chip); - READ8_MEMBER(md_sms_vdp_vcounter_r ); - READ8_MEMBER(md_sms_vdp_data_r ); - WRITE8_MEMBER(md_sms_vdp_data_w ); - READ8_MEMBER(md_sms_vdp_ctrl_r ); - WRITE8_MEMBER(md_sms_vdp_ctrl_w ); READ8_MEMBER( sms_z80_unmapped_port_r ); WRITE8_MEMBER( sms_z80_unmapped_port_w ); READ8_MEMBER(sms_z80_unmapped_r ); WRITE8_MEMBER( sms_z80_unmapped_w ); - READ8_MEMBER (megatech_sms_ioport_dc_r); - READ8_MEMBER (megatech_sms_ioport_dd_r); - WRITE8_MEMBER( mt_sms_standard_rom_bank_w ); - void megatech_set_genz80_as_sms_standard_ports(const char* tag); - }; @@ -405,8 +388,6 @@ public: m_ic3_ram(*this, "ic3_ram"), m_vdp1(*this, "vdp1"), m_bioscpu(*this, "mtbios") - - { } UINT32 m_bios_mode; // determines whether ROM banks or Game data @@ -479,8 +460,8 @@ public: required_device m_bioscpu; - DECLARE_WRITE_LINE_MEMBER( int_callback ); - + DECLARE_WRITE_LINE_MEMBER( snd_int_callback ); + DECLARE_WRITE_LINE_MEMBER( bios_int_callback ); UINT8 m_mt_cart_select_reg; UINT32 m_bios_port_ctrl; @@ -504,7 +485,9 @@ public: void screen_eof_mtnew(screen_device &screen, bool state); UINT32 screen_update_megatech_menu(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - void megatech_set_megadrive_z80_as_megadrive_z80(const char* tag); + void megatech_set_genz80_as_md(const char* tag); + void megatech_set_genz80_as_sms(const char* tag); + UINT32 screen_update_megatech_sms2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); DECLARE_READ8_MEMBER( megatech_cart_select_r ); TIMER_CALLBACK_MEMBER( megatech_z80_run_state ); @@ -521,8 +504,16 @@ public: DECLARE_WRITE8_MEMBER( megatech_bios_port_ctrl_w ); DECLARE_READ8_MEMBER( megatech_bios_joypad_r ); DECLARE_WRITE8_MEMBER (megatech_bios_port_7f_w); + READ8_MEMBER(sms_count_r); + READ8_MEMBER(sms_ioport_dc_r); + READ8_MEMBER(sms_ioport_dd_r); + WRITE8_MEMBER(mt_sms_standard_rom_bank_w); + protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + + UINT8* sms_mainram; + UINT8* sms_rom; }; class _32x_state : public md_base_state diff --git a/src/mame/machine/megadriv.c b/src/mame/machine/megadriv.c index 25586851dab..aa7fac5f87c 100644 --- a/src/mame/machine/megadriv.c +++ b/src/mame/machine/megadriv.c @@ -1059,8 +1059,6 @@ MACHINE_CONFIG_FRAGMENT( md_pal ) MCFG_SCREEN_UPDATE_DRIVER(md_base_state,screen_update_megadriv) /* Copies a bitmap */ MCFG_SCREEN_VBLANK_DRIVER(md_base_state,screen_eof_megadriv) /* Used to Sync the timing */ - MCFG_PALETTE_ADD("palette", 0x200) - MCFG_VIDEO_START_OVERRIDE(md_base_state,megadriv) /* sound hardware */ @@ -1246,34 +1244,6 @@ WRITE8_MEMBER(md_base_state::z80_unmapped_w ) } -/* sets the megadrive z80 to it's normal ports / map */ -void mtech_state::megatech_set_megadrive_z80_as_megadrive_z80(const char* tag) -{ - ym2612_device *ym2612 = machine().device("ymsnd"); - - /* INIT THE PORTS *********************************************************************************************/ - machine().device(tag)->memory().space(AS_IO).install_readwrite_handler(0x0000, 0xffff, read8_delegate(FUNC(mtech_state::z80_unmapped_port_r),this), write8_delegate(FUNC(mtech_state::z80_unmapped_port_w),this)); - - /* catch any addresses that don't get mapped */ - machine().device(tag)->memory().space(AS_PROGRAM).install_readwrite_handler(0x0000, 0xffff, read8_delegate(FUNC(mtech_state::z80_unmapped_r),this), write8_delegate(FUNC(mtech_state::z80_unmapped_w),this)); - - - machine().device(tag)->memory().space(AS_PROGRAM).install_readwrite_bank(0x0000, 0x1fff, "bank1"); - machine().root_device().membank("bank1")->set_base(m_genz80.z80_prgram); - - machine().device(tag)->memory().space(AS_PROGRAM).install_ram(0x0000, 0x1fff, m_genz80.z80_prgram); - - - machine().device(tag)->memory().space(AS_PROGRAM).install_readwrite_handler(0x4000, 0x4003, read8_delegate(FUNC(ym2612_device::read),ym2612), write8_delegate(FUNC(ym2612_device::write),ym2612)); - machine().device(tag)->memory().space(AS_PROGRAM).install_write_handler (0x6000, 0x6000, write8_delegate(FUNC(mtech_state::megadriv_z80_z80_bank_w),this)); - machine().device(tag)->memory().space(AS_PROGRAM).install_write_handler (0x6001, 0x6001, write8_delegate(FUNC(mtech_state::megadriv_z80_z80_bank_w),this)); - machine().device(tag)->memory().space(AS_PROGRAM).install_read_handler (0x6100, 0x7eff, read8_delegate(FUNC(mtech_state::megadriv_z80_unmapped_read),this)); - machine().device(tag)->memory().space(AS_PROGRAM).install_readwrite_handler(0x7f00, 0x7fff, read8_delegate(FUNC(mtech_state::megadriv_z80_vdp_read),this), write8_delegate(FUNC(mtech_state::megadriv_z80_vdp_write),this)); - machine().device(tag)->memory().space(AS_PROGRAM).install_readwrite_handler(0x8000, 0xffff, read8_delegate(FUNC(mtech_state::z80_read_68k_banked_data),this), write8_delegate(FUNC(mtech_state::z80_write_68k_banked_data),this)); -} - - - void md_base_state::screen_eof_megadriv(screen_device &screen, bool state) { diff --git a/src/mame/machine/megavdp.c b/src/mame/machine/megavdp.c index 09de447f32b..a5bb7e6d2db 100644 --- a/src/mame/machine/megavdp.c +++ b/src/mame/machine/megavdp.c @@ -27,7 +27,7 @@ sega_genesis_vdp_device::sega_genesis_vdp_device(const machine_config &mconfig, { m_use_alt_timing = 0; m_palwrite_base = -1; -} +} //------------------------------------------------- // static_set_palette_tag: Set the tag of the @@ -42,6 +42,7 @@ void sega_genesis_vdp_device::static_set_palette_tag(device_t &device, const cha static MACHINE_CONFIG_FRAGMENT( sega_genesis_vdp ) MCFG_PALETTE_ADD("palette", 0x200) + MCFG_PALETTE_INIT_OWNER(sega315_5124_device, sega315_5124) MACHINE_CONFIG_END //------------------------------------------------- @@ -188,6 +189,8 @@ void sega_genesis_vdp_device::device_start() m_space68k = &machine().device(":maincpu")->space(); m_cpu68k = machine().device(":maincpu"); + + sega315_5124_device::device_start(); } void sega_genesis_vdp_device::device_reset() @@ -206,6 +209,8 @@ void sega_genesis_vdp_device::device_reset() megadrive_irq6_pending = 0; megadrive_irq4_pending = 0; m_scanline_counter = 0; + + sega315_5124_device::device_reset(); } void sega_genesis_vdp_device::device_reset_old() @@ -220,8 +225,6 @@ void sega_genesis_vdp_device::device_reset_old() - - void sega_genesis_vdp_device::vdp_vram_write(UINT16 data) { UINT16 sprite_base_address = MEGADRIVE_REG0C_RS1?((MEGADRIVE_REG05_SPRITE_ADDR&0x7e)<<9):((MEGADRIVE_REG05_SPRITE_ADDR&0x7f)<<9); diff --git a/src/mame/machine/megavdp.h b/src/mame/machine/megavdp.h index a10bd1f2368..aad36dd2fc5 100644 --- a/src/mame/machine/megavdp.h +++ b/src/mame/machine/megavdp.h @@ -171,7 +171,6 @@ public: int genesis_get_scanline_counter(); - void genesis_render_scanline(); void vdp_handle_scanline_callback(int scanline); void vdp_handle_irq6_on_timer_callback(int param); diff --git a/src/mame/machine/segamsys.c b/src/mame/machine/segamsys.c index f902c80de8c..7a8690eaf32 100644 --- a/src/mame/machine/segamsys.c +++ b/src/mame/machine/segamsys.c @@ -319,13 +319,6 @@ void *segamsys_state::start_vdp(int type) return chip; } -/* stop timer and clear ram.. used on megatech when we switch between genesis and sms mode */ -void segamsys_state::megatech_sms_stop_scanline_timer() -{ - md_sms_vdp->sms_scanline_timer->adjust(attotime::never); - memset(md_sms_vdp->vram,0x00,0x4000); -} - UINT8 segamsys_state::vcounter_r(struct sms_vdp *chip) { // return vc_pal_224[sms_scanline_counter%(sizeof vc_pal_224)]; @@ -482,34 +475,6 @@ void segamsys_state::vdp_ctrl_w(address_space &space, UINT8 data, struct sms_vdp } } -/* for the Genesis */ - -READ8_MEMBER(segamsys_state::md_sms_vdp_vcounter_r ) -{ - return vcounter_r(md_sms_vdp); -} - -READ8_MEMBER(segamsys_state::md_sms_vdp_data_r ) -{ - return vdp_data_r(md_sms_vdp); -} - -WRITE8_MEMBER(segamsys_state::md_sms_vdp_data_w ) -{ - vdp_data_w(space, data, md_sms_vdp); -} - -READ8_MEMBER(segamsys_state::md_sms_vdp_ctrl_r ) -{ - return vdp_ctrl_r(space, md_sms_vdp); -} - -WRITE8_MEMBER(segamsys_state::md_sms_vdp_ctrl_w ) -{ - vdp_ctrl_w(space, data, md_sms_vdp); -} - - /* Read / Write Handlers - call other functions */ READ8_MEMBER(segamsys_state::sms_vcounter_r ) @@ -949,50 +914,19 @@ void segamsys_state::end_of_frame(screen_device &screen, struct sms_vdp *chip) } -MACHINE_RESET_MEMBER(segamsys_state,megatech_md_sms) -{ - md_sms_vdp->sms_scanline_timer->adjust(attotime::zero); -} - -MACHINE_RESET_MEMBER(segamsys_state,megatech_bios) +MACHINE_RESET_MEMBER(segamsys_state, megaplay_bios) { vdp1->sms_scanline_timer->adjust(attotime::zero); } -void segamsys_state::screen_eof_megatech_md_sms(screen_device &screen, bool state) -{ - // rising edge - if (state) - end_of_frame(screen, md_sms_vdp); -} - -void segamsys_state::screen_eof_megatech_bios(screen_device &screen, bool state) +void segamsys_state::screen_eof_megaplay_bios(screen_device &screen, bool state) { // rising edge if (state) end_of_frame(screen, vdp1); } -UINT32 segamsys_state::screen_update_megatech_sms(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - int x,y; - - for (y=0;y<224;y++) - { - UINT32* lineptr = &bitmap.pix32(y); - UINT32* srcptr = &md_sms_vdp->r_bitmap->pix32(y); - - for (x=0;x<256;x++) - { - lineptr[x]=srcptr[x]; - } - } - - return 0; -} - - UINT32 segamsys_state::screen_update_megaplay_bios(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { int x,y; @@ -1014,19 +948,6 @@ UINT32 segamsys_state::screen_update_megaplay_bios(screen_device &screen, bitmap return 0; } - -void segamsys_state::init_for_megadrive() -{ - md_sms_vdp = (struct sms_vdp *)start_vdp(GEN_VDP); - md_sms_vdp->set_irq = segamsys_state::sms_vdp_cpu1_irq_callback; - md_sms_vdp->is_pal = 0; - md_sms_vdp->sms_total_scanlines = 262; - md_sms_vdp->sms_framerate = 60; - md_sms_vdp->chip_id = 3; -} - - - void segamsys_state::init_megaplay_legacy_overlay() { vdp1 = (struct sms_vdp *)start_vdp(SMS2_VDP); @@ -1040,119 +961,3 @@ void segamsys_state::init_megaplay_legacy_overlay() vdp1_vram_bank1 = auto_alloc_array(machine(), UINT8, 0x4000); } -/* Functions to set up the Memory Map - - -- these are needed because on a Genesis the Sound Z80 becomes the SMS Z80 in comptibility mode - so we need to be able to dynamically change the mapping - -*/ - -READ8_MEMBER( segamsys_state::sms_z80_unmapped_port_r ) -{ -// printf("unmapped z80 port read %04x\n",offset); - return 0; -} - -WRITE8_MEMBER( segamsys_state::sms_z80_unmapped_port_w ) -{ -// printf("unmapped z80 port write %04x\n",offset); -} - -READ8_MEMBER( segamsys_state::sms_z80_unmapped_r ) -{ - printf("unmapped z80 read %04x\n",offset); - return 0; -} - -WRITE8_MEMBER( segamsys_state::sms_z80_unmapped_w ) -{ - printf("unmapped z80 write %04x\n",offset); -} - - -/* the SMS inputs should be more complex, like the megadrive ones */ -READ8_MEMBER (segamsys_state::megatech_sms_ioport_dc_r) -{ - /* 2009-05 FP: would it be worth to give separate inputs to SMS? SMS has only 2 keys A,B (which are B,C on megadrive) */ - /* bit 4: TL-A; bit 5: TR-A */ - return (machine().root_device().ioport("PAD1")->read() & 0x3f) | ((machine().root_device().ioport("PAD2")->read() & 0x03) << 6); -} - -READ8_MEMBER (segamsys_state::megatech_sms_ioport_dd_r) -{ - /* 2009-05 FP: would it be worth to give separate inputs to SMS? SMS has only 2 keys A,B (which are B,C on megadrive) */ - /* bit 2: TL-B; bit 3: TR-B; bit 4: RESET; bit 5: unused; bit 6: TH-A; bit 7: TH-B*/ - return ((machine().root_device().ioport("PAD2")->read() & 0x3c) >> 2) | 0x10; -} - - -WRITE8_MEMBER( segamsys_state::mt_sms_standard_rom_bank_w ) -{ - int bank = data&0x1f; - //logerror("bank w %02x %02x\n", offset, data); - - sms_mainram[0x1ffc+offset] = data; - switch (offset) - { - case 0: - logerror("bank w %02x %02x\n", offset, data); - space.install_rom(0x0000, 0xbfff, sms_rom); - space.unmap_write(0x0000, 0xbfff); - //printf("bank ram??\n"); - break; - case 1: - memcpy(sms_rom+0x0000, space.machine().root_device().memregion("maincpu")->base()+bank*0x4000, 0x4000); - break; - case 2: - memcpy(sms_rom+0x4000, space.machine().root_device().memregion("maincpu")->base()+bank*0x4000, 0x4000); - break; - case 3: - memcpy(sms_rom+0x8000, space.machine().root_device().memregion("maincpu")->base()+bank*0x4000, 0x4000); - break; - - } -} - - -void segamsys_state::megatech_set_genz80_as_sms_standard_ports(const char* tag) -{ - /* INIT THE PORTS *********************************************************************************************/ - - address_space &io = machine().device(tag)->memory().space(AS_IO); - sn76496_base_device *sn = machine().device("snsnd"); - - io.install_readwrite_handler(0x0000, 0xffff, read8_delegate(FUNC(segamsys_state::z80_unmapped_port_r),this), write8_delegate(FUNC(segamsys_state::sms_z80_unmapped_port_w),this)); - - io.install_read_handler (0x7e, 0x7e, read8_delegate(FUNC(segamsys_state::md_sms_vdp_vcounter_r),this)); - io.install_write_handler (0x7e, 0x7f, write8_delegate(FUNC(sn76496_device::write),sn)); - io.install_readwrite_handler (0xbe, 0xbe, read8_delegate(FUNC(segamsys_state::md_sms_vdp_data_r),this), write8_delegate(FUNC(segamsys_state::md_sms_vdp_data_w),this)); - io.install_readwrite_handler (0xbf, 0xbf, read8_delegate(FUNC(segamsys_state::md_sms_vdp_ctrl_r),this), write8_delegate(FUNC(segamsys_state::md_sms_vdp_ctrl_w),this)); - - io.install_read_handler (0x10, 0x10, read8_delegate(FUNC(segamsys_state::megatech_sms_ioport_dd_r),this)); // super tetris - - io.install_read_handler (0xdc, 0xdc, read8_delegate(FUNC(segamsys_state::megatech_sms_ioport_dc_r),this)); - io.install_read_handler (0xdd, 0xdd, read8_delegate(FUNC(segamsys_state::megatech_sms_ioport_dd_r),this)); - io.install_read_handler (0xde, 0xde, read8_delegate(FUNC(segamsys_state::megatech_sms_ioport_dd_r),this)); - io.install_read_handler (0xdf, 0xdf, read8_delegate(FUNC(segamsys_state::megatech_sms_ioport_dd_r),this)); // adams family -} - -void segamsys_state::megatech_set_genz80_as_sms_standard_map(const char* tag) -{ - /* INIT THE MEMMAP / BANKING *********************************************************************************/ - - /* catch any addresses that don't get mapped */ - machine().device(tag)->memory().space(AS_PROGRAM).install_readwrite_handler(0x0000, 0xffff, read8_delegate(FUNC(segamsys_state::z80_unmapped_r),this), write8_delegate(FUNC(segamsys_state::z80_unmapped_w),this)); - - /* main ram area */ - sms_mainram = (UINT8 *)machine().device(tag)->memory().space(AS_PROGRAM).install_ram(0xc000, 0xdfff, 0, 0x2000); - memset(sms_mainram,0x00,0x2000); - - megatech_set_genz80_as_sms_standard_ports(tag); - - /* fixed rom bank area */ - sms_rom = (UINT8 *)machine().device(tag)->memory().space(AS_PROGRAM).install_rom(0x0000, 0xbfff, NULL); - - memcpy(sms_rom, machine().root_device().memregion("maincpu")->base(), 0xc000); - - machine().device(tag)->memory().space(AS_PROGRAM).install_write_handler(0xfffc, 0xffff, write8_delegate(FUNC(segamsys_state::mt_sms_standard_rom_bank_w),this)); -}