summaryrefslogtreecommitdiffstats
path: root/src/mame/drivers/gameking.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/gameking.cpp')
-rw-r--r--src/mame/drivers/gameking.cpp102
1 files changed, 95 insertions, 7 deletions
diff --git a/src/mame/drivers/gameking.cpp b/src/mame/drivers/gameking.cpp
index f9e3f77bb44..8dd9969ee0f 100644
--- a/src/mame/drivers/gameking.cpp
+++ b/src/mame/drivers/gameking.cpp
@@ -1,5 +1,5 @@
// license:GPL-2.0+
-// copyright-holders:Peter Trauner
+// copyright-holders:Peter Trauner, AJR
/* TimeTop - GameKing */
/*
PeT mess@utanet.at 2015
@@ -57,6 +57,7 @@ private:
TIMER_CALLBACK_MEMBER(gameking_timer2);
uint32_t screen_update_gameking(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
+ uint32_t screen_update_gameking3(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart_load);
void gameking_mem(address_map &map);
@@ -65,7 +66,7 @@ private:
required_device<cpu_device> m_maincpu;
required_device<generic_slot_device> m_cart;
required_ioport m_io_joy;
- required_device<palette_device> m_palette;
+ optional_device<palette_device> m_palette;
emu_timer *timer1;
emu_timer *timer2;
@@ -100,8 +101,7 @@ void gameking_state::gameking_mem(address_map &map)
void gameking_state::gameking3_mem(address_map &map)
{
map(0x000000, 0x07ffff).rom().region("maincpu", 0);
- map(0x800000, 0x802fff).ram();
- map(0x804800, 0x8048ff).ram();
+ map(0x800000, 0x807fff).ram();
}
@@ -117,6 +117,13 @@ static INPUT_PORTS_START( gameking )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP)
INPUT_PORTS_END
+static INPUT_PORTS_START( gameking3 )
+ PORT_INCLUDE( gameking )
+ PORT_MODIFY("JOY")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START) PORT_NAME("Start")
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SELECT) PORT_NAME("Select") //?
+INPUT_PORTS_END
+
static constexpr rgb_t gameking_pens[] =
{
{ 255, 255, 255 },
@@ -153,6 +160,76 @@ uint32_t gameking_state::screen_update_gameking(screen_device &screen, bitmap_in
}
+static constexpr uint8_t gameking3_intensities[] =
+{
+ 0,
+ 127,
+ 191,
+ 255
+};
+
+uint32_t gameking_state::screen_update_gameking3(screen_device& screen, bitmap_rgb32 &bitmap, const rectangle& cliprect)
+{
+ address_space* maincpu_ram = &m_maincpu->space(AS_PROGRAM);
+ offs_t lssa = m_maincpu->state_int(st2xxx_device::ST_LSSA);
+ if (lssa < 0x0080)
+ return 0;
+
+ for (int y = 0, i = 0; i < 80; y += 2, i++)
+ {
+ for (int x = 0, j = 0; j < 40; x += 4, j++)
+ {
+ uint8_t data=maincpu_ram->read_byte(lssa+j+i*40);
+
+ // apply SPRD-C color filter
+ switch (i % 3)
+ {
+ case 0:
+ bitmap.pix32(y, x + 3) = rgb_t(0, gameking3_intensities[data&3], 0);
+ bitmap.pix32(y + 1, x + 2) = rgb_t(gameking3_intensities[(data>>2)&3], 0, 0);
+ bitmap.pix32(y, x + 1) = rgb_t(0, gameking3_intensities[(data>>4)&3], 0);
+ bitmap.pix32(y + 1, x) = rgb_t(gameking3_intensities[(data>>6)&3], 0, 0);
+ break;
+
+ case 1:
+ bitmap.pix32(y, x + 3) = rgb_t(0, 0, gameking3_intensities[data&3]);
+ bitmap.pix32(y + 1, x+2) = rgb_t(0, gameking3_intensities[(data>>2)&3], 0);
+ bitmap.pix32(y, x + 1) = rgb_t(0, 0, gameking3_intensities[(data>>4)&3]);
+ bitmap.pix32(y + 1, x) = rgb_t(0, gameking3_intensities[(data>>6)&3], 0);
+ break;
+
+ case 2:
+ bitmap.pix32(y, x + 3) = rgb_t(gameking3_intensities[data&3], 0, 0);
+ bitmap.pix32(y + 1, x+2) = rgb_t(0, 0, gameking3_intensities[(data>>2)&3]);
+ bitmap.pix32(y, x + 1) = rgb_t(gameking3_intensities[(data>>4)&3], 0, 0);
+ bitmap.pix32(y + 1, x) = rgb_t(0, 0, gameking3_intensities[(data>>6)&3]);
+ break;
+ }
+ }
+ }
+
+ // interpolate values for dots in between
+ for (int y = 0; y < 160; y++)
+ {
+ for (int x = y & 1; x < 160; x += 2)
+ {
+ rgb_t l = rgb_t(x == 0 ? 0 : bitmap.pix32(y, x - 1));
+ rgb_t r = rgb_t(x == 159 ? 0 : bitmap.pix32(y, x + 1));
+ rgb_t u = rgb_t(y == 0 ? 0 : bitmap.pix32(y - 1, x));
+ rgb_t d = rgb_t(y == 159 ? 0 : bitmap.pix32(y + 1, x));
+
+ bitmap.pix32(y, x) = rgb_t(
+ ((u.r() + d.r()) * 2 + l.r() + r.r()) / 3,
+ ((u.g() + d.g()) * 2 + l.g() + r.g()) / 3,
+ ((u.b() + d.b()) * 2 + l.b() + r.b()) / 3
+ );
+ }
+ }
+
+ return 0;
+}
+
+
void gameking_state::init_gameking()
{
timer1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gameking_state::gameking_timer), this));
@@ -162,7 +239,7 @@ void gameking_state::init_gameking()
TIMER_CALLBACK_MEMBER(gameking_state::gameking_timer)
{
m_maincpu->set_state_int(st2xxx_device::ST_IREQ,
- m_maincpu->state_int(st2xxx_device::ST_IREQ) | (0x016 & m_maincpu->state_int(st2xxx_device::ST_IENA)));
+ m_maincpu->state_int(st2xxx_device::ST_IREQ) | (0x012 & m_maincpu->state_int(st2xxx_device::ST_IENA)));
timer1->enable(false);
timer2->enable(true);
timer2->reset(m_maincpu->cycles_to_attotime(10/*?*/));
@@ -180,7 +257,7 @@ DEVICE_IMAGE_LOAD_MEMBER(gameking_state::cart_load)
{
uint32_t size = m_cart->common_get_size("rom");
- if (size > 0x80000)
+ if (size > 0x100000)
{
image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
return image_init_result::FAIL;
@@ -234,7 +311,18 @@ void gameking_state::gameking1(machine_config &config)
void gameking_state::gameking3(machine_config &config)
{
gameking(config);
+ m_maincpu->set_clock(8000000);
m_maincpu->set_addrmap(AS_DATA, &gameking_state::gameking3_mem);
+
+ screen_device &screen(*subdevice<screen_device>("screen"));
+ screen.set_size(160, 160);
+ screen.set_visarea_full();
+ screen.set_physical_aspect(3, 2);
+ screen.set_refresh_hz(39.308176); // ?
+ screen.set_screen_update(FUNC(gameking_state::screen_update_gameking3));
+ screen.set_palette(finder_base::DUMMY_TAG);
+ config.device_remove("palette");
+
SOFTWARE_LIST(config, "cart_list").set_original("gameking");
SOFTWARE_LIST(config, "cart_list_3").set_original("gameking3");
}
@@ -253,6 +341,6 @@ ROM_END
CONS( 2003, gameking, 0, 0, gameking1, gameking, gameking_state, init_gameking, "TimeTop", "GameKing GM-218", MACHINE_NOT_WORKING | MACHINE_NO_SOUND )
// the GameKing 2 (GM-219) is probably identical HW
-CONS( 2003, gamekin3, 0, 0, gameking3, gameking, gameking_state, init_gameking, "TimeTop", "GameKing 3", MACHINE_NOT_WORKING | MACHINE_NO_SOUND )
+CONS( 2003, gamekin3, 0, 0, gameking3, gameking3, gameking_state, init_gameking, "TimeTop", "GameKing 3", MACHINE_NOT_WORKING | MACHINE_NO_SOUND )
// gameking 3: similiar cartridges, accepts gameking cartridges, gameking3 cartridges not working on gameking (illegal cartridge scroller)
// my gameking bios backup solution might work on it