gameplan: prepare for driver rename,

trvquest: do rom bankswitch the normal way
This commit is contained in:
hap 2023-07-23 22:30:56 +02:00
parent 48fe24f953
commit e6c3c0a7c0
3 changed files with 130 additions and 102 deletions

View File

@ -2,8 +2,7 @@
// copyright-holders:Chris Moore // copyright-holders:Chris Moore
/*************************************************************************** /***************************************************************************
GAME PLAN driver Killer Comet hardware, by Centuri (previously known as Allied Leisure)
driver by Chris Moore driver by Chris Moore
Killer Comet memory map Killer Comet memory map
@ -99,15 +98,15 @@ BTANB:
* *
*************************************/ *************************************/
void gameplan_state::machine_start() void killcom_state::machine_start()
{ {
// register for save states (gameplan specific) // register for save states (killcom specific)
save_item(NAME(m_current_port)); save_item(NAME(m_current_port));
save_item(NAME(m_audio_reset)); save_item(NAME(m_audio_reset));
save_item(NAME(m_audio_trigger)); save_item(NAME(m_audio_trigger));
} }
void gameplan_state::machine_reset() void killcom_state::machine_reset()
{ {
m_video_x = 0; m_video_x = 0;
m_video_y = 0; m_video_y = 0;
@ -115,15 +114,15 @@ void gameplan_state::machine_reset()
} }
void gameplan_state::video_start() void killcom_state::video_start()
{ {
m_videoram = make_unique_clear<uint8_t[]>(0x10000); m_videoram = make_unique_clear<uint8_t[]>(0x10000);
save_pointer(NAME(m_videoram), 0x10000); save_pointer(NAME(m_videoram), 0x10000);
m_hblank_timer[0] = timer_alloc(FUNC(gameplan_state::hblank_callback), this); m_hblank_timer[0] = timer_alloc(FUNC(killcom_state::hblank_callback), this);
m_hblank_timer[0]->adjust(attotime::zero, 0, m_screen->scan_period()); m_hblank_timer[0]->adjust(attotime::zero, 0, m_screen->scan_period());
m_hblank_timer[1] = timer_alloc(FUNC(gameplan_state::hblank_callback), this); m_hblank_timer[1] = timer_alloc(FUNC(killcom_state::hblank_callback), this);
m_hblank_timer[1]->adjust(256 * m_screen->pixel_period(), 1, m_screen->scan_period()); m_hblank_timer[1]->adjust(256 * m_screen->pixel_period(), 1, m_screen->scan_period());
// register for save states // register for save states
@ -143,7 +142,7 @@ void gameplan_state::video_start()
* *
*************************************/ *************************************/
uint32_t gameplan_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) uint32_t killcom_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{ {
for (int y = cliprect.min_y; y <= cliprect.max_y; y++) for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
{ {
@ -164,39 +163,39 @@ uint32_t gameplan_state::screen_update(screen_device &screen, bitmap_ind16 &bitm
* *
*************************************/ *************************************/
TIMER_CALLBACK_MEMBER(gameplan_state::hblank_callback) TIMER_CALLBACK_MEMBER(killcom_state::hblank_callback)
{ {
// screen HBLANK is tied to VIA1 PB6 // screen HBLANK is tied to VIA1 PB6
m_via[0]->write_pb6(param); m_via[0]->write_pb6(param);
} }
void gameplan_state::video_data_w(uint8_t data) void killcom_state::video_data_w(uint8_t data)
{ {
m_video_data = data; m_video_data = data;
} }
void gameplan_state::video_command_w(uint8_t data) void killcom_state::video_command_w(uint8_t data)
{ {
m_video_command = data & 0x07; m_video_command = data & 0x07;
} }
uint8_t gameplan_state::video_status_r() uint8_t killcom_state::video_status_r()
{ {
// video busy flags on the upper bits // video busy flags on the upper bits
return 0xff; return 0xff;
} }
uint8_t gameplan_state::leprechn_videoram_r() uint8_t killcom_state::leprechn_videoram_r()
{ {
return (video_status_r() & 0xf8) | m_video_previous; return (video_status_r() & 0xf8) | m_video_previous;
} }
void gameplan_state::video_command_trigger_w(int state) void killcom_state::video_command_trigger_w(int state)
{ {
if (state && !m_video_command_trigger) if (state && !m_video_command_trigger)
{ {
@ -262,13 +261,13 @@ void gameplan_state::video_command_trigger_w(int state)
* *
*************************************/ *************************************/
void gameplan_state::io_select_w(uint8_t data) void killcom_state::io_select_w(uint8_t data)
{ {
m_current_port = data; m_current_port = data;
} }
uint8_t gameplan_state::io_port_r() uint8_t killcom_state::io_port_r()
{ {
uint8_t data = 0xff; uint8_t data = 0xff;
@ -286,7 +285,7 @@ uint8_t gameplan_state::io_port_r()
} }
void gameplan_state::coin_w(int state) void killcom_state::coin_w(int state)
{ {
machine().bookkeeping().coin_counter_w(0, ~state & 1); machine().bookkeeping().coin_counter_w(0, ~state & 1);
} }
@ -299,7 +298,7 @@ void gameplan_state::coin_w(int state)
* *
*************************************/ *************************************/
void gameplan_state::audio_reset_sync_w(int param) void killcom_state::audio_reset_sync_w(int param)
{ {
if (param && !m_audio_reset) if (param && !m_audio_reset)
{ {
@ -312,22 +311,22 @@ void gameplan_state::audio_reset_sync_w(int param)
} }
void gameplan_state::audio_reset_w(int state) void killcom_state::audio_reset_w(int state)
{ {
machine().scheduler().synchronize(timer_expired_delegate(FUNC(gameplan_state::audio_reset_sync_w), this), state); machine().scheduler().synchronize(timer_expired_delegate(FUNC(killcom_state::audio_reset_sync_w), this), state);
} }
void gameplan_state::audio_trigger_sync_w(int param) void killcom_state::audio_trigger_sync_w(int param)
{ {
m_audio_trigger = param; m_audio_trigger = param;
m_riot->pa_w<7>(param); m_riot->pa_w<7>(param);
} }
void gameplan_state::audio_trigger_w(int state) void killcom_state::audio_trigger_w(int state)
{ {
machine().scheduler().synchronize(timer_expired_delegate(FUNC(gameplan_state::audio_trigger_sync_w), this), state); machine().scheduler().synchronize(timer_expired_delegate(FUNC(killcom_state::audio_trigger_sync_w), this), state);
} }
@ -338,7 +337,7 @@ void gameplan_state::audio_trigger_w(int state)
* *
*************************************/ *************************************/
uint8_t gameplan_state::soundlatch_r() uint8_t killcom_state::soundlatch_r()
{ {
return m_audio_trigger << 7 | (m_soundlatch->read() & 0x7f); return m_audio_trigger << 7 | (m_soundlatch->read() & 0x7f);
} }
@ -351,7 +350,7 @@ uint8_t gameplan_state::soundlatch_r()
* *
*************************************/ *************************************/
void gameplan_state::gameplan_main_map(address_map &map) void killcom_state::killcom_main_map(address_map &map)
{ {
map(0x0000, 0x03ff).mirror(0x0400).ram(); map(0x0000, 0x03ff).mirror(0x0400).ram();
map(0x2000, 0x200f).mirror(0x07f0).m(m_via[0], FUNC(via6522_device::map)); // VIA 1 map(0x2000, 0x200f).mirror(0x07f0).m(m_via[0], FUNC(via6522_device::map)); // VIA 1
@ -360,9 +359,9 @@ void gameplan_state::gameplan_main_map(address_map &map)
map(0x8000, 0xffff).rom(); map(0x8000, 0xffff).rom();
} }
void gameplan_state::piratetr_main_map(address_map &map) void killcom_state::piratetr_main_map(address_map &map)
{ {
gameplan_main_map(map); killcom_main_map(map);
map(0x2010, 0x201f).mirror(0x07e0).unmaprw(); // A4, see TODO map(0x2010, 0x201f).mirror(0x07e0).unmaprw(); // A4, see TODO
} }
@ -374,7 +373,7 @@ void gameplan_state::piratetr_main_map(address_map &map)
* *
*************************************/ *************************************/
void gameplan_state::gameplan_audio_map(address_map &map) void killcom_state::killcom_audio_map(address_map &map)
{ {
map(0x0000, 0x007f).mirror(0x1780).m(m_riot, FUNC(mos6532_new_device::ram_map)); map(0x0000, 0x007f).mirror(0x1780).m(m_riot, FUNC(mos6532_new_device::ram_map));
map(0x0800, 0x081f).mirror(0x17e0).m(m_riot, FUNC(mos6532_new_device::io_map)); map(0x0800, 0x081f).mirror(0x17e0).m(m_riot, FUNC(mos6532_new_device::io_map));
@ -384,9 +383,9 @@ void gameplan_state::gameplan_audio_map(address_map &map)
map(0xe000, 0xe7ff).mirror(0x1800).rom(); map(0xe000, 0xe7ff).mirror(0x1800).rom();
} }
void gameplan_state::leprechn_audio_map(address_map &map) void killcom_state::leprechn_audio_map(address_map &map)
{ {
gameplan_audio_map(map); killcom_audio_map(map);
map(0xe000, 0xefff).mirror(0x1000).rom(); map(0xe000, 0xefff).mirror(0x1000).rom();
} }
@ -1108,58 +1107,58 @@ INPUT_PORTS_END
* *
*************************************/ *************************************/
void gameplan_state::gameplan_video(machine_config &config) void killcom_state::killcom_video(machine_config &config)
{ {
SCREEN(config, m_screen, SCREEN_TYPE_RASTER); SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_raw(11.6688_MHz_XTAL / 2, 352, 0, 256, 280, 0, 256); m_screen->set_raw(11.6688_MHz_XTAL / 2, 352, 0, 256, 280, 0, 256);
m_screen->set_screen_update(FUNC(gameplan_state::screen_update)); m_screen->set_screen_update(FUNC(killcom_state::screen_update));
m_screen->screen_vblank().set(m_via[0], FUNC(via6522_device::write_ca1)); // VBLANK is connected to CA1 m_screen->screen_vblank().set(m_via[0], FUNC(via6522_device::write_ca1)); // VBLANK is connected to CA1
m_screen->set_palette("palette"); m_screen->set_palette("palette");
PALETTE(config, "palette", palette_device::RGB_3BIT); PALETTE(config, "palette", palette_device::RGB_3BIT);
} }
void gameplan_state::gameplan(machine_config &config) void killcom_state::killcom(machine_config &config)
{ {
// basic machine hardware // basic machine hardware
M6502(config, m_maincpu, 3.579545_MHz_XTAL / 4); M6502(config, m_maincpu, 3.579545_MHz_XTAL / 4);
m_maincpu->set_addrmap(AS_PROGRAM, &gameplan_state::gameplan_main_map); m_maincpu->set_addrmap(AS_PROGRAM, &killcom_state::killcom_main_map);
input_merger_device &main_irqs(INPUT_MERGER_ANY_HIGH(config, "main_irqs")); input_merger_device &main_irqs(INPUT_MERGER_ANY_HIGH(config, "main_irqs"));
main_irqs.output_handler().set_inputline(m_maincpu, 0); main_irqs.output_handler().set_inputline(m_maincpu, 0);
M6502(config, m_audiocpu, 3.579545_MHz_XTAL / 4); M6502(config, m_audiocpu, 3.579545_MHz_XTAL / 4);
m_audiocpu->set_addrmap(AS_PROGRAM, &gameplan_state::gameplan_audio_map); m_audiocpu->set_addrmap(AS_PROGRAM, &killcom_state::killcom_audio_map);
GENERIC_LATCH_8(config, m_soundlatch); GENERIC_LATCH_8(config, m_soundlatch);
MOS6532_NEW(config, m_riot, 3.579545_MHz_XTAL / 4); MOS6532_NEW(config, m_riot, 3.579545_MHz_XTAL / 4);
m_riot->pa_rd_callback().set(FUNC(gameplan_state::soundlatch_r)); m_riot->pa_rd_callback().set(FUNC(killcom_state::soundlatch_r));
m_riot->pb_wr_callback().set(m_via[2], FUNC(via6522_device::write_pb)); m_riot->pb_wr_callback().set(m_via[2], FUNC(via6522_device::write_pb));
m_riot->irq_wr_callback().set_inputline(m_audiocpu, 0); m_riot->irq_wr_callback().set_inputline(m_audiocpu, 0);
// via // via
MOS6522(config, m_via[0], 3.579545_MHz_XTAL / 4); MOS6522(config, m_via[0], 3.579545_MHz_XTAL / 4);
m_via[0]->writepa_handler().set(FUNC(gameplan_state::video_data_w)); m_via[0]->writepa_handler().set(FUNC(killcom_state::video_data_w));
m_via[0]->writepb_handler().set(FUNC(gameplan_state::video_command_w)); m_via[0]->writepb_handler().set(FUNC(killcom_state::video_command_w));
m_via[0]->readpb_handler().set(FUNC(gameplan_state::video_status_r)); m_via[0]->readpb_handler().set(FUNC(killcom_state::video_status_r));
m_via[0]->ca2_handler().set(FUNC(gameplan_state::video_command_trigger_w)); m_via[0]->ca2_handler().set(FUNC(killcom_state::video_command_trigger_w));
m_via[0]->irq_handler().set("main_irqs", FUNC(input_merger_device::in_w<0>)); m_via[0]->irq_handler().set("main_irqs", FUNC(input_merger_device::in_w<0>));
MOS6522(config, m_via[1], 3.579545_MHz_XTAL / 4); MOS6522(config, m_via[1], 3.579545_MHz_XTAL / 4);
m_via[1]->readpa_handler().set(FUNC(gameplan_state::io_port_r)); m_via[1]->readpa_handler().set(FUNC(killcom_state::io_port_r));
m_via[1]->writepb_handler().set(FUNC(gameplan_state::io_select_w)); m_via[1]->writepb_handler().set(FUNC(killcom_state::io_select_w));
m_via[1]->cb2_handler().set(FUNC(gameplan_state::coin_w)); m_via[1]->cb2_handler().set(FUNC(killcom_state::coin_w));
m_via[1]->irq_handler().set("main_irqs", FUNC(input_merger_device::in_w<1>)); m_via[1]->irq_handler().set("main_irqs", FUNC(input_merger_device::in_w<1>));
MOS6522(config, m_via[2], 3.579545_MHz_XTAL / 4); MOS6522(config, m_via[2], 3.579545_MHz_XTAL / 4);
m_via[2]->writepa_handler().set(m_soundlatch, FUNC(generic_latch_8_device::write)); m_via[2]->writepa_handler().set(m_soundlatch, FUNC(generic_latch_8_device::write));
m_via[2]->ca2_handler().set(FUNC(gameplan_state::audio_trigger_w)); m_via[2]->ca2_handler().set(FUNC(killcom_state::audio_trigger_w));
m_via[2]->cb2_handler().set(FUNC(gameplan_state::audio_reset_w)); m_via[2]->cb2_handler().set(FUNC(killcom_state::audio_reset_w));
m_via[2]->irq_handler().set("main_irqs", FUNC(input_merger_device::in_w<2>)); m_via[2]->irq_handler().set("main_irqs", FUNC(input_merger_device::in_w<2>));
// video hardware // video hardware
gameplan_video(config); killcom_video(config);
// audio hardware // audio hardware
SPEAKER(config, "mono").front_center(); SPEAKER(config, "mono").front_center();
@ -1170,9 +1169,9 @@ void gameplan_state::gameplan(machine_config &config)
m_ay->add_route(ALL_OUTPUTS, "mono", 0.33); m_ay->add_route(ALL_OUTPUTS, "mono", 0.33);
} }
void gameplan_state::leprechn(machine_config &config) void killcom_state::leprechn(machine_config &config)
{ {
gameplan(config); killcom(config);
// basic machine hardware // basic machine hardware
m_maincpu->set_clock(4_MHz_XTAL / 4); m_maincpu->set_clock(4_MHz_XTAL / 4);
@ -1184,17 +1183,17 @@ void gameplan_state::leprechn(machine_config &config)
m_riot->set_clock(4_MHz_XTAL / 4); m_riot->set_clock(4_MHz_XTAL / 4);
m_ay->set_clock(4_MHz_XTAL / 2); m_ay->set_clock(4_MHz_XTAL / 2);
m_audiocpu->set_addrmap(AS_PROGRAM, &gameplan_state::leprechn_audio_map); m_audiocpu->set_addrmap(AS_PROGRAM, &killcom_state::leprechn_audio_map);
// via // via
m_via[0]->readpb_handler().set(FUNC(gameplan_state::leprechn_videoram_r)); m_via[0]->readpb_handler().set(FUNC(killcom_state::leprechn_videoram_r));
m_via[0]->writepb_handler().set(FUNC(gameplan_state::video_command_w)).rshift(3); m_via[0]->writepb_handler().set(FUNC(killcom_state::video_command_w)).rshift(3);
} }
void gameplan_state::piratetr(machine_config &config) void killcom_state::piratetr(machine_config &config)
{ {
leprechn(config); leprechn(config);
m_maincpu->set_addrmap(AS_PROGRAM, &gameplan_state::piratetr_main_map); m_maincpu->set_addrmap(AS_PROGRAM, &killcom_state::piratetr_main_map);
} }
@ -1350,13 +1349,14 @@ ROM_END
* *
*************************************/ *************************************/
GAME( 1980, killcom, 0, gameplan, killcom, gameplan_state, empty_init, ROT0, "Centuri (Game Plan license)", "Killer Comet", MACHINE_SUPPORTS_SAVE ) // YEAR NAME PARENT MACHINE INPUT CLASS INIT SCREEN COMPANY FULLNAME FLAGS
GAME( 1980, megatack, 0, gameplan, megatack, gameplan_state, empty_init, ROT0, "Centuri (Game Plan license)", "Megatack (set 1)", MACHINE_SUPPORTS_SAVE ) GAME( 1980, killcom, 0, killcom, killcom, killcom_state, empty_init, ROT0, "Centuri (Game Plan license)", "Killer Comet", MACHINE_SUPPORTS_SAVE )
GAME( 1980, megatacka, megatack, gameplan, megatack, gameplan_state, empty_init, ROT0, "Centuri (Game Plan license)", "Megatack (set 2)", MACHINE_SUPPORTS_SAVE ) GAME( 1980, megatack, 0, killcom, megatack, killcom_state, empty_init, ROT0, "Centuri (Game Plan license)", "Megatack (set 1)", MACHINE_SUPPORTS_SAVE )
GAME( 1981, challeng, 0, gameplan, challeng, gameplan_state, empty_init, ROT270, "Centuri", "Challenger", MACHINE_SUPPORTS_SAVE ) // cab is vertical GAME( 1980, megatacka, megatack, killcom, megatack, killcom_state, empty_init, ROT0, "Centuri (Game Plan license)", "Megatack (set 2)", MACHINE_SUPPORTS_SAVE )
GAME( 1981, challeng, 0, killcom, challeng, killcom_state, empty_init, ROT270, "Centuri", "Challenger", MACHINE_SUPPORTS_SAVE ) // cab is vertical
GAME( 1981, kaos, 0, gameplan, kaos, gameplan_state, empty_init, ROT270, "Pacific Polytechnical Corp. (Game Plan license)", "Kaos", MACHINE_SUPPORTS_SAVE ) GAME( 1981, kaos, 0, killcom, kaos, killcom_state, empty_init, ROT270, "Pacific Polytechnical Corp. (Game Plan license)", "Kaos", MACHINE_SUPPORTS_SAVE )
GAME( 1982, leprechn, 0, leprechn, leprechn, gameplan_state, empty_init, ROT0, "Pacific Polytechnical Corp.", "Leprechaun (set 1)", MACHINE_SUPPORTS_SAVE ) GAME( 1982, leprechn, 0, leprechn, leprechn, killcom_state, empty_init, ROT0, "Pacific Polytechnical Corp.", "Leprechaun (set 1)", MACHINE_SUPPORTS_SAVE )
GAME( 1982, leprechna, leprechn, leprechn, leprechna, gameplan_state, empty_init, ROT0, "Pacific Polytechnical Corp. (Tong Electronic license)", "Leprechaun (set 2)", MACHINE_SUPPORTS_SAVE ) GAME( 1982, leprechna, leprechn, leprechn, leprechna, killcom_state, empty_init, ROT0, "Pacific Polytechnical Corp. (Tong Electronic license)", "Leprechaun (set 2)", MACHINE_SUPPORTS_SAVE )
GAME( 1982, potogold, leprechn, leprechn, leprechn, gameplan_state, empty_init, ROT0, "Pacific Polytechnical Corp. (Game Plan license)", "Pot of Gold", MACHINE_SUPPORTS_SAVE ) GAME( 1982, potogold, leprechn, leprechn, leprechn, killcom_state, empty_init, ROT0, "Pacific Polytechnical Corp. (Game Plan license)", "Pot of Gold", MACHINE_SUPPORTS_SAVE )
GAME( 1982, piratetr, 0, piratetr, piratetr, gameplan_state, empty_init, ROT0, "Pacific Polytechnical Corp. (Tong Electronic license)", "Pirate Treasure", MACHINE_SUPPORTS_SAVE ) GAME( 1982, piratetr, 0, piratetr, piratetr, killcom_state, empty_init, ROT0, "Pacific Polytechnical Corp. (Tong Electronic license)", "Pirate Treasure", MACHINE_SUPPORTS_SAVE )

View File

@ -2,7 +2,7 @@
// copyright-holders:Chris Moore // copyright-holders:Chris Moore
/*************************************************************************** /***************************************************************************
GAME PLAN driver Killer Comet driver
***************************************************************************/ ***************************************************************************/
@ -16,10 +16,10 @@ GAME PLAN driver
#include "screen.h" #include "screen.h"
class gameplan_state : public driver_device class killcom_state : public driver_device
{ {
public: public:
gameplan_state(const machine_config &mconfig, device_type type, const char *tag) : killcom_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag), driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"), m_maincpu(*this, "maincpu"),
m_via(*this, "via%u", 1U), m_via(*this, "via%u", 1U),
@ -32,8 +32,8 @@ public:
m_soundlatch(*this, "soundlatch") m_soundlatch(*this, "soundlatch")
{ } { }
void gameplan(machine_config &config); void killcom(machine_config &config);
void gameplan_video(machine_config &config); void killcom_video(machine_config &config);
void leprechn(machine_config &config); void leprechn(machine_config &config);
void piratetr(machine_config &config); void piratetr(machine_config &config);
@ -48,6 +48,7 @@ protected:
optional_ioport_array<4> m_inputs; optional_ioport_array<4> m_inputs;
optional_ioport_array<4> m_dsw; optional_ioport_array<4> m_dsw;
void coin_w(int state);
void video_data_w(uint8_t data); void video_data_w(uint8_t data);
void video_command_w(uint8_t data); void video_command_w(uint8_t data);
uint8_t video_status_r(); uint8_t video_status_r();
@ -78,7 +79,6 @@ private:
void io_select_w(uint8_t data); void io_select_w(uint8_t data);
uint8_t io_port_r(); uint8_t io_port_r();
void coin_w(int state);
void audio_reset_w(int state); void audio_reset_w(int state);
void audio_reset_sync_w(int param); void audio_reset_sync_w(int param);
void audio_trigger_w(int state); void audio_trigger_w(int state);
@ -88,8 +88,8 @@ private:
TIMER_CALLBACK_MEMBER(hblank_callback); TIMER_CALLBACK_MEMBER(hblank_callback);
uint8_t leprechn_videoram_r(); uint8_t leprechn_videoram_r();
void gameplan_main_map(address_map &map); void killcom_main_map(address_map &map);
void gameplan_audio_map(address_map &map); void killcom_audio_map(address_map &map);
void leprechn_audio_map(address_map &map); void leprechn_audio_map(address_map &map);
void piratetr_main_map(address_map &map); void piratetr_main_map(address_map &map);
}; };

View File

@ -32,7 +32,7 @@ as is.
driver by Pierpaolo Prazzoli driver by Pierpaolo Prazzoli
Notes: Notes:
- Hardware is similar to the one in gameplan.cpp - Hardware is similar to the one in killcom.cpp
*/ */
@ -49,64 +49,77 @@ Notes:
namespace { namespace {
class trvquest_state : public gameplan_state class trvquest_state : public killcom_state
{ {
public: public:
trvquest_state(const machine_config &mconfig, device_type type, const char *tag) : trvquest_state(const machine_config &mconfig, device_type type, const char *tag) :
gameplan_state(mconfig, type, tag), killcom_state(mconfig, type, tag),
m_question(*this, "question"), m_bank(*this, "bank")
m_questions_region(*this, "questions")
{ } { }
void trvquest(machine_config &config); void trvquest(machine_config &config);
protected: protected:
virtual void machine_start() override { } virtual void machine_start() override;
private: private:
required_shared_ptr<uint8_t> m_question; required_memory_bank m_bank;
required_region_ptr<uint8_t> m_questions_region;
uint8_t question_r(offs_t offset); void bankswitch_w(uint8_t data);
void coin_w(int state);
void misc_w(int state);
void cpu_map(address_map &map); void main_map(address_map &map);
}; };
uint8_t trvquest_state::question_r(offs_t offset)
/*************************************
*
* Bankswitch
*
*************************************/
void trvquest_state::machine_start()
{ {
return m_questions_region[*m_question * 0x2000 + offset]; m_bank->configure_entries(0, 16, memregion("questions")->base(), 0x2000);
} }
void trvquest_state::coin_w(int state) void trvquest_state::bankswitch_w(uint8_t data)
{ {
machine().bookkeeping().coin_counter_w(0, ~state & 1); m_bank->set_entry(data & 0xf);
} }
void trvquest_state::misc_w(int state)
{
// data & 1 -> led on/off ?
}
void trvquest_state::cpu_map(address_map &map)
/*************************************
*
* Address map
*
*************************************/
void trvquest_state::main_map(address_map &map)
{ {
map(0x0000, 0x1fff).ram().share("nvram"); // cmos ram map(0x0000, 0x1fff).ram().share("nvram"); // cmos ram
map(0x2000, 0x27ff).ram(); // main ram map(0x2000, 0x27ff).ram(); // main ram
map(0x2800, 0x2800).nopr(); // ?
map(0x3800, 0x380f).m(m_via[1], FUNC(via6522_device::map)); map(0x3800, 0x380f).m(m_via[1], FUNC(via6522_device::map));
map(0x3810, 0x381f).m(m_via[2], FUNC(via6522_device::map)); map(0x3810, 0x381f).m(m_via[2], FUNC(via6522_device::map));
map(0x3820, 0x382f).m(m_via[0], FUNC(via6522_device::map)); map(0x3820, 0x382f).m(m_via[0], FUNC(via6522_device::map));
map(0x3830, 0x3831).w("ay1", FUNC(ay8910_device::address_data_w)); map(0x3830, 0x3831).w("ay1", FUNC(ay8910_device::address_data_w));
map(0x3840, 0x3841).w("ay2", FUNC(ay8910_device::address_data_w)); map(0x3840, 0x3841).w("ay2", FUNC(ay8910_device::address_data_w));
map(0x3850, 0x3850).nopr(); //watchdog_reset_r ? map(0x3850, 0x3850).nopr(); // watchdog_reset_r ?
map(0x8000, 0x9fff).r(FUNC(trvquest_state::question_r)); map(0x8000, 0x9fff).bankr(m_bank);
map(0xa000, 0xa000).writeonly().share(m_question); map(0xa000, 0xa000).w(FUNC(trvquest_state::bankswitch_w)).nopr();
map(0xa000, 0xa000).nopr(); // bogus read from the game code when reads question roms
map(0xb000, 0xffff).rom(); map(0xb000, 0xffff).rom();
} }
/*************************************
*
* Input ports
*
*************************************/
static INPUT_PORTS_START( trvquest ) static INPUT_PORTS_START( trvquest )
PORT_START("IN0") PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
@ -182,10 +195,17 @@ static INPUT_PORTS_START( trvquest )
INPUT_PORTS_END INPUT_PORTS_END
/*************************************
*
* Machine config
*
*************************************/
void trvquest_state::trvquest(machine_config &config) void trvquest_state::trvquest(machine_config &config)
{ {
M6809(config, m_maincpu, 6_MHz_XTAL/4); M6809(config, m_maincpu, 6_MHz_XTAL/4);
m_maincpu->set_addrmap(AS_PROGRAM, &trvquest_state::cpu_map); m_maincpu->set_addrmap(AS_PROGRAM, &trvquest_state::main_map);
NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_1); NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_1);
@ -204,11 +224,10 @@ void trvquest_state::trvquest(machine_config &config)
MOS6522(config, m_via[2], 6_MHz_XTAL/4); MOS6522(config, m_via[2], 6_MHz_XTAL/4);
m_via[2]->readpa_handler().set_ioport("UNK"); m_via[2]->readpa_handler().set_ioport("UNK");
m_via[2]->readpb_handler().set_ioport("DSW0"); m_via[2]->readpb_handler().set_ioport("DSW0");
m_via[2]->ca2_handler().set(FUNC(trvquest_state::misc_w));
m_via[2]->irq_handler().set_inputline(m_maincpu, 0); m_via[2]->irq_handler().set_inputline(m_maincpu, 0);
// video hardware // video hardware
gameplan_video(config); killcom_video(config);
m_screen->screen_vblank().set(m_via[2], FUNC(via6522_device::write_ca1)); m_screen->screen_vblank().set(m_via[2], FUNC(via6522_device::write_ca1));
// sound hardware // sound hardware
@ -219,6 +238,13 @@ void trvquest_state::trvquest(machine_config &config)
} }
/*************************************
*
* ROM defintions
*
*************************************/
ROM_START( trvquest ) ROM_START( trvquest )
ROM_REGION( 0x10000, "maincpu", 0 ) ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "rom3", 0xb000, 0x1000, CRC(2ff7f370) SHA1(66f40426ed02ee44235e17a49d9054ede42b83b9) ) ROM_LOAD( "rom3", 0xb000, 0x1000, CRC(2ff7f370) SHA1(66f40426ed02ee44235e17a49d9054ede42b83b9) )
@ -227,8 +253,8 @@ ROM_START( trvquest )
ROM_LOAD( "rom6", 0xe000, 0x1000, CRC(fabf4846) SHA1(862cac32de78f2ff4afef398b864d5533d302a4f) ) ROM_LOAD( "rom6", 0xe000, 0x1000, CRC(fabf4846) SHA1(862cac32de78f2ff4afef398b864d5533d302a4f) )
ROM_LOAD( "rom7", 0xf000, 0x1000, CRC(a9f56551) SHA1(fb6fc3b17a6e66571a5ba837befbfac1ac26cc39) ) ROM_LOAD( "rom7", 0xf000, 0x1000, CRC(a9f56551) SHA1(fb6fc3b17a6e66571a5ba837befbfac1ac26cc39) )
ROM_REGION( 0x18000, "questions", ROMREGION_ERASEFF ) /* Question roms */ ROM_REGION( 0x20000, "questions", ROMREGION_ERASEFF ) // Question roms
/* 0x00000 - 0x07fff empty */ // 0x00000 - 0x05fff empty
ROM_LOAD( "romi", 0x06000, 0x2000, CRC(c8368f69) SHA1(c1dfb701482c5ae922df0a93665a519995a2f4f1) ) ROM_LOAD( "romi", 0x06000, 0x2000, CRC(c8368f69) SHA1(c1dfb701482c5ae922df0a93665a519995a2f4f1) )
ROM_LOAD( "romh", 0x08000, 0x2000, CRC(f3aa8a08) SHA1(2bf8f878cc1df84806a6fb8e7be2656c422d61b9) ) ROM_LOAD( "romh", 0x08000, 0x2000, CRC(f3aa8a08) SHA1(2bf8f878cc1df84806a6fb8e7be2656c422d61b9) )
ROM_LOAD( "romg", 0x0a000, 0x2000, CRC(f85f8e48) SHA1(38c9142181a8ee5c0bc80cf2a06d4137fcb2a8b9) ) ROM_LOAD( "romg", 0x0a000, 0x2000, CRC(f85f8e48) SHA1(38c9142181a8ee5c0bc80cf2a06d4137fcb2a8b9) )
@ -243,4 +269,6 @@ ROM_END
} // anonymous namespace } // anonymous namespace
// YEAR NAME PARENT MACHINE INPUT CLASS INIT SCREEN COMPANY FULLNAME FLAGS
GAME( 1984, trvquest, 0, trvquest, trvquest, trvquest_state, empty_init, ROT90, "Techstar / Sunn", "Trivia Quest", MACHINE_SUPPORTS_SAVE ) GAME( 1984, trvquest, 0, trvquest, trvquest, trvquest_state, empty_init, ROT90, "Techstar / Sunn", "Trivia Quest", MACHINE_SUPPORTS_SAVE )