mirror of
https://github.com/holub/mame
synced 2025-05-04 05:23:22 +03:00
(MESS) gmaster.c: Misc cleanups (nw)
This commit is contained in:
parent
086cdd1d4a
commit
fd0f94496b
@ -9,22 +9,6 @@
|
||||
#include "rendlay.h"
|
||||
|
||||
|
||||
struct GMASTER_VIDEO
|
||||
{
|
||||
UINT8 data[8];
|
||||
int index;
|
||||
int x, y;
|
||||
/*bool*/int mode; // true read does not increase address
|
||||
/*bool*/int delayed;
|
||||
UINT8 pixels[8][64/*>=62 sure*/];
|
||||
};
|
||||
|
||||
struct GMASTER_MACHINE
|
||||
{
|
||||
UINT8 ports[5];
|
||||
};
|
||||
|
||||
|
||||
class gmaster_state : public driver_device
|
||||
{
|
||||
public:
|
||||
@ -32,65 +16,86 @@ public:
|
||||
: driver_device(mconfig, type, tag)
|
||||
, m_maincpu(*this, "maincpu")
|
||||
, m_speaker(*this, "speaker")
|
||||
, m_io_joy(*this, "JOY")
|
||||
{ }
|
||||
|
||||
GMASTER_VIDEO m_video;
|
||||
GMASTER_MACHINE m_gmachine;
|
||||
virtual void machine_start();
|
||||
virtual void palette_init();
|
||||
|
||||
DECLARE_READ8_MEMBER(gmaster_io_r);
|
||||
DECLARE_WRITE8_MEMBER(gmaster_io_w);
|
||||
DECLARE_READ8_MEMBER(gmaster_port_r);
|
||||
DECLARE_WRITE8_MEMBER(gmaster_port_w);
|
||||
DECLARE_DRIVER_INIT(gmaster);
|
||||
virtual void palette_init();
|
||||
DECLARE_DRIVER_INIT(gmaster) { memset(&m_video, 0, sizeof(m_video)); memset(m_ram, 0, sizeof(m_ram)); }
|
||||
UINT32 screen_update_gmaster(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
INTERRUPT_GEN_MEMBER(gmaster_interrupt);
|
||||
|
||||
protected:
|
||||
required_device<cpu_device> m_maincpu;
|
||||
required_device<speaker_sound_device> m_speaker;
|
||||
required_ioport m_io_joy;
|
||||
|
||||
struct
|
||||
{
|
||||
UINT8 data[8];
|
||||
int index;
|
||||
int x, y;
|
||||
bool mode; // true read does not increase address
|
||||
bool delayed;
|
||||
UINT8 pixels[8][64];
|
||||
} m_video;
|
||||
UINT8 m_ports[5];
|
||||
UINT8 m_ram[0x4000];
|
||||
};
|
||||
|
||||
|
||||
READ8_MEMBER(gmaster_state::gmaster_io_r)
|
||||
{
|
||||
UINT8 data = 0;
|
||||
if (m_gmachine.ports[2] & 1)
|
||||
|
||||
if (m_ports[2] & 1)
|
||||
{
|
||||
data = memregion("maincpu")->base()[0x4000 + offset];
|
||||
logerror("%.4x external memory %.4x read %.2x\n", (int)space.device().state().state_int(CPUINFO_INT_PC), 0x4000 + offset, data);
|
||||
data = m_ram[offset];
|
||||
logerror("%.4x external memory %.4x read %.2x\n", m_maincpu->pc(), 0x4000 + offset, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (offset)
|
||||
{
|
||||
case 1:
|
||||
data=m_video.pixels[m_video.y][m_video.x];
|
||||
logerror("%.4x lcd x:%.2x y:%.2x %.4x read %.2x\n", (int)space.device().state().state_int(CPUINFO_INT_PC), m_video.x, m_video.y, 0x4000 + offset, data);
|
||||
data = m_video.pixels[m_video.y][m_video.x];
|
||||
logerror("%.4x lcd x:%.2x y:%.2x %.4x read %.2x\n", m_maincpu->pc(), m_video.x, m_video.y, 0x4000 + offset, data);
|
||||
if (!(m_video.mode) && m_video.delayed)
|
||||
{
|
||||
m_video.x++;
|
||||
m_video.delayed = TRUE;
|
||||
}
|
||||
m_video.delayed = true;
|
||||
break;
|
||||
default:
|
||||
logerror("%.4x memory %.4x read %.2x\n", (int)space.device().state().state_int(CPUINFO_INT_PC), 0x4000 + offset, data);
|
||||
logerror("%.4x memory %.4x read %.2x\n", m_maincpu->pc(), 0x4000 + offset, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
#define BLITTER_Y ((m_gmachine.ports[2]&4)|(m_video.data[0]&3))
|
||||
#define BLITTER_Y ((m_ports[2]&4)|(m_video.data[0]&3))
|
||||
|
||||
|
||||
WRITE8_MEMBER(gmaster_state::gmaster_io_w)
|
||||
{
|
||||
if (m_gmachine.ports[2] & 1)
|
||||
if (m_ports[2] & 1)
|
||||
{
|
||||
memregion("maincpu")->base()[0x4000 + offset] = data;
|
||||
logerror("%.4x external memory %.4x written %.2x\n", (int)space.device().state().state_int(CPUINFO_INT_PC), 0x4000 + offset, data);
|
||||
m_ram[offset] = data;
|
||||
logerror("%.4x external memory %.4x written %.2x\n", m_maincpu->pc(), 0x4000 + offset, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (offset)
|
||||
{
|
||||
case 0:
|
||||
m_video.delayed=FALSE;
|
||||
logerror("%.4x lcd %.4x written %.2x\n", (int)space.device().state().state_int(CPUINFO_INT_PC), 0x4000 + offset, data);
|
||||
m_video.delayed = false;
|
||||
logerror("%.4x lcd %.4x written %.2x\n", m_maincpu->pc(), 0x4000 + offset, data);
|
||||
// e2 af a4 a0 a9 falling block init for both halves
|
||||
if ((data & 0xfc) == 0xb8)
|
||||
{
|
||||
@ -104,17 +109,18 @@ WRITE8_MEMBER(gmaster_state::gmaster_io_w)
|
||||
}
|
||||
else if ((data & 0xf0) == 0xe0)
|
||||
{
|
||||
m_video.mode = (data & 0xe) ? FALSE : TRUE;
|
||||
m_video.mode = (data & 0xe) ? false : true;
|
||||
}
|
||||
m_video.data[m_video.index] = data;
|
||||
m_video.index = (m_video.index + 1) & 7;
|
||||
break;
|
||||
case 1:
|
||||
m_video.delayed = FALSE;
|
||||
m_video.delayed = false;
|
||||
if (m_video.x < ARRAY_LENGTH(m_video.pixels[0])) // continental galaxy flutlicht
|
||||
{
|
||||
m_video.pixels[m_video.y][m_video.x] = data;
|
||||
logerror("%.4x lcd x:%.2x y:%.2x %.4x written %.2x\n",
|
||||
(int)space.device().state().state_int(CPUINFO_INT_PC), m_video.x, m_video.y, 0x4000 + offset, data);
|
||||
}
|
||||
logerror("%.4x lcd x:%.2x y:%.2x %.4x written %.2x\n", m_maincpu->pc(), m_video.x, m_video.y, 0x4000 + offset, data);
|
||||
m_video.x++;
|
||||
/* 02 b8 1a
|
||||
02 bb 1a
|
||||
@ -132,30 +138,34 @@ WRITE8_MEMBER(gmaster_state::gmaster_io_w)
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
logerror("%.4x memory %.4x written %.2x\n", (int)space.device().state().state_int(CPUINFO_INT_PC), 0x4000 + offset, data);
|
||||
logerror("%.4x memory %.4x written %.2x\n", m_maincpu->pc(), 0x4000 + offset, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
READ8_MEMBER(gmaster_state::gmaster_port_r)
|
||||
{
|
||||
// UINT8 data = m_gmachine.ports[offset];
|
||||
// UINT8 data = m_ports[offset];
|
||||
UINT8 data = 0xff;
|
||||
switch (offset)
|
||||
{
|
||||
case UPD7810_PORTA:
|
||||
data = ioport("JOY")->read();
|
||||
data = m_io_joy->read();
|
||||
break;
|
||||
default:
|
||||
logerror("%.4x port %d read %.2x\n", (int)space.device().state().state_int(CPUINFO_INT_PC), offset, data);
|
||||
logerror("%.4x port %d read %.2x\n", m_maincpu->pc(), offset, data);
|
||||
break;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
WRITE8_MEMBER(gmaster_state::gmaster_port_w)
|
||||
{
|
||||
m_gmachine.ports[offset] = data;
|
||||
logerror("%.4x port %d written %.2x\n", (int)space.device().state().state_int(CPUINFO_INT_PC), offset, data);
|
||||
m_ports[offset] = data;
|
||||
logerror("%.4x port %d written %.2x\n", m_maincpu->pc(), offset, data);
|
||||
switch (offset)
|
||||
{
|
||||
case UPD7810_PORTC:
|
||||
@ -165,17 +175,20 @@ WRITE8_MEMBER(gmaster_state::gmaster_port_w)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static ADDRESS_MAP_START( gmaster_mem, AS_PROGRAM, 8, gmaster_state )
|
||||
AM_RANGE(0x0000, 0x3fff) AM_ROM
|
||||
AM_RANGE( 0x4000, 0x7fff) AM_READWRITE(gmaster_io_r, gmaster_io_w)
|
||||
AM_RANGE(0x4000, 0x7fff) AM_READWRITE(gmaster_io_r, gmaster_io_w)
|
||||
AM_RANGE(0x8000, 0xfeff) AM_ROM
|
||||
AM_RANGE(0xff00, 0xffff) AM_RAM
|
||||
ADDRESS_MAP_END
|
||||
|
||||
|
||||
static ADDRESS_MAP_START(gmaster_io, AS_IO, 8, gmaster_state )
|
||||
AM_RANGE(UPD7810_PORTA, UPD7810_PORTF) AM_READWRITE(gmaster_port_r, gmaster_port_w )
|
||||
ADDRESS_MAP_END
|
||||
|
||||
|
||||
static INPUT_PORTS_START( gmaster )
|
||||
PORT_START("JOY")
|
||||
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT)
|
||||
@ -188,6 +201,7 @@ static INPUT_PORTS_START( gmaster )
|
||||
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START) PORT_NAME("Start")
|
||||
INPUT_PORTS_END
|
||||
|
||||
|
||||
/* palette in red, green, blue tribles */
|
||||
static const unsigned char gmaster_palette[2][3] =
|
||||
{
|
||||
@ -200,6 +214,7 @@ static const unsigned char gmaster_palette[2][3] =
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void gmaster_state::palette_init()
|
||||
{
|
||||
int i;
|
||||
@ -210,10 +225,10 @@ void gmaster_state::palette_init()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UINT32 gmaster_state::screen_update_gmaster(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
int x,y;
|
||||
// plot_box(bitmap, 0, 0, 64/*bitmap.width*/, bitmap.height, 0); //xmess rounds up to 64 pixel
|
||||
for (y = 0; y < ARRAY_LENGTH(m_video.pixels); y++)
|
||||
{
|
||||
for (x = 0; x < ARRAY_LENGTH(m_video.pixels[0]); x++)
|
||||
@ -243,17 +258,33 @@ UINT32 gmaster_state::screen_update_gmaster(screen_device &screen, bitmap_ind16
|
||||
}
|
||||
|
||||
|
||||
void gmaster_state::machine_start()
|
||||
{
|
||||
save_item(NAME(m_video.data));
|
||||
save_item(NAME(m_video.index));
|
||||
save_item(NAME(m_video.x));
|
||||
save_item(NAME(m_video.y));
|
||||
save_item(NAME(m_video.mode));
|
||||
save_item(NAME(m_video.delayed));
|
||||
save_item(NAME(m_video.pixels));
|
||||
save_item(NAME(m_ports));
|
||||
save_item(NAME(m_ram));
|
||||
}
|
||||
|
||||
|
||||
INTERRUPT_GEN_MEMBER(gmaster_state::gmaster_interrupt)
|
||||
{
|
||||
m_maincpu->set_input_line(UPD7810_INTFE1, ASSERT_LINE);
|
||||
}
|
||||
|
||||
|
||||
static const UPD7810_CONFIG config = {
|
||||
// TYPE_78C10, // 78c11 in handheld
|
||||
TYPE_7810, // temporarily until 7810 core fixes synchronized
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
static MACHINE_CONFIG_START( gmaster, gmaster_state )
|
||||
MCFG_CPU_ADD("maincpu", UPD7810, XTAL_12MHz/2/*?*/) // upd78c11 in the unit
|
||||
MCFG_CPU_PROGRAM_MAP(gmaster_mem)
|
||||
@ -288,10 +319,6 @@ ROM_START(gmaster)
|
||||
ROM_CART_LOAD("cart", 0x8000, 0x8000, 0)
|
||||
ROM_END
|
||||
|
||||
DRIVER_INIT_MEMBER(gmaster_state,gmaster)
|
||||
{
|
||||
memset(&m_video, 0, sizeof(m_video));
|
||||
}
|
||||
|
||||
/* YEAR NAME PARENT MACHINE INPUT INIT COMPANY FULLNAME */
|
||||
CONS( 1990, gmaster, 0, 0, gmaster, gmaster, gmaster_state, gmaster, "Hartung", "Game Master", GAME_IMPERFECT_SOUND)
|
||||
|
Loading…
Reference in New Issue
Block a user