midezeus modernized and lot moved to _state, also made midzeus2_state separated, legacy_poly should be removed in future (nw)

This commit is contained in:
Miodrag Milanovic 2014-04-17 11:55:10 +00:00
parent d75265256e
commit cb62b01e3b
4 changed files with 251 additions and 305 deletions

View File

@ -571,12 +571,12 @@ static ADDRESS_MAP_START( zeus_map, AS_PROGRAM, 32, midzeus_state )
ADDRESS_MAP_END ADDRESS_MAP_END
static ADDRESS_MAP_START( zeus2_map, AS_PROGRAM, 32, midzeus_state ) static ADDRESS_MAP_START( zeus2_map, AS_PROGRAM, 32, midzeus2_state )
ADDRESS_MAP_UNMAP_HIGH ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x000000, 0x03ffff) AM_RAM AM_SHARE("ram_base") AM_RANGE(0x000000, 0x03ffff) AM_RAM AM_SHARE("ram_base")
AM_RANGE(0x400000, 0x43ffff) AM_RAM AM_RANGE(0x400000, 0x43ffff) AM_RAM
AM_RANGE(0x808000, 0x80807f) AM_READWRITE(tms32031_control_r, tms32031_control_w) AM_SHARE("tms32031_ctl") AM_RANGE(0x808000, 0x80807f) AM_READWRITE(tms32031_control_r, tms32031_control_w) AM_SHARE("tms32031_ctl")
AM_RANGE(0x880000, 0x88007f) AM_READWRITE_LEGACY(zeus2_r, zeus2_w) AM_SHARE("zeusbase") AM_RANGE(0x880000, 0x88007f) AM_READWRITE(zeus2_r, zeus2_w) AM_SHARE("zeusbase")
AM_RANGE(0x8a0000, 0x8a003f) AM_READWRITE(linkram_r, linkram_w) AM_SHARE("linkram") AM_RANGE(0x8a0000, 0x8a003f) AM_READWRITE(linkram_r, linkram_w) AM_SHARE("linkram")
AM_RANGE(0x8d0000, 0x8d000a) AM_READWRITE(bitlatches_r, bitlatches_w) AM_RANGE(0x8d0000, 0x8d000a) AM_READWRITE(bitlatches_r, bitlatches_w)
AM_RANGE(0x900000, 0x91ffff) AM_READWRITE(zpram_r, zpram_w) AM_SHARE("nvram") AM_MIRROR(0x020000) AM_RANGE(0x900000, 0x91ffff) AM_READWRITE(zpram_r, zpram_w) AM_SHARE("nvram") AM_MIRROR(0x020000)
@ -1122,24 +1122,24 @@ static MACHINE_CONFIG_DERIVED( invasn, midzeus )
MCFG_CPU_IO_MAP(pic_io_map) MCFG_CPU_IO_MAP(pic_io_map)
MACHINE_CONFIG_END MACHINE_CONFIG_END
static MACHINE_CONFIG_START( midzeus2, midzeus_state ) static MACHINE_CONFIG_START( midzeus2, midzeus2_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", TMS32032, CPU_CLOCK) MCFG_CPU_ADD("maincpu", TMS32032, CPU_CLOCK)
MCFG_CPU_PROGRAM_MAP(zeus2_map) MCFG_CPU_PROGRAM_MAP(zeus2_map)
MCFG_CPU_VBLANK_INT_DRIVER("screen", midzeus_state, display_irq) MCFG_CPU_VBLANK_INT_DRIVER("screen", midzeus2_state, display_irq)
MCFG_MACHINE_START_OVERRIDE(midzeus_state,midzeus) MCFG_MACHINE_START_OVERRIDE(midzeus2_state,midzeus)
MCFG_MACHINE_RESET_OVERRIDE(midzeus_state,midzeus) MCFG_MACHINE_RESET_OVERRIDE(midzeus2_state,midzeus)
MCFG_NVRAM_ADD_1FILL("nvram") MCFG_NVRAM_ADD_1FILL("nvram")
/* video hardware */ /* video hardware */
MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_RAW_PARAMS(MIDZEUS_VIDEO_CLOCK/4, 666, 0, 512, 438, 0, 400) MCFG_SCREEN_RAW_PARAMS(MIDZEUS_VIDEO_CLOCK/4, 666, 0, 512, 438, 0, 400)
MCFG_SCREEN_UPDATE_DRIVER(midzeus_state, screen_update_midzeus2) MCFG_SCREEN_UPDATE_DRIVER(midzeus2_state, screen_update_midzeus2)
MCFG_SCREEN_PALETTE("palette") MCFG_SCREEN_PALETTE("palette")
MCFG_VIDEO_START_OVERRIDE(midzeus_state,midzeus2) MCFG_VIDEO_START_OVERRIDE(midzeus2_state,midzeus2)
/* sound hardware */ /* sound hardware */
MCFG_FRAGMENT_ADD(dcs2_audio_2104) MCFG_FRAGMENT_ADD(dcs2_audio_2104)

View File

@ -67,16 +67,42 @@ public:
DECLARE_MACHINE_START(midzeus); DECLARE_MACHINE_START(midzeus);
DECLARE_MACHINE_RESET(midzeus); DECLARE_MACHINE_RESET(midzeus);
DECLARE_VIDEO_START(midzeus); DECLARE_VIDEO_START(midzeus);
DECLARE_VIDEO_START(midzeus2);
UINT32 screen_update_midzeus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); UINT32 screen_update_midzeus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
UINT32 screen_update_midzeus2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(display_irq); INTERRUPT_GEN_MEMBER(display_irq);
TIMER_CALLBACK_MEMBER(display_irq_off); TIMER_CALLBACK_MEMBER(display_irq_off);
TIMER_CALLBACK_MEMBER(invasn_gun_callback); TIMER_CALLBACK_MEMBER(invasn_gun_callback);
private:
void exit_handler(); void exit_handler();
void exit_handler2(); void zeus_pointer_w(UINT32 which, UINT32 data, int logit);
void zeus_register16_w(offs_t offset, UINT16 data, int logit);
void zeus_register32_w(offs_t offset, UINT32 data, int logit);
void zeus_register_update(offs_t offset);
int zeus_fifo_process(const UINT32 *data, int numwords);
void zeus_draw_model(UINT32 texdata, int logit);
void zeus_draw_quad(int long_fmt, const UINT32 *databuffer, UINT32 texdata, int logit);
void log_fifo_command(const UINT32 *data, int numwords, const char *suffix);
void log_waveram(UINT32 length_and_base);
}; };
/*----------- defined in video/midzeus2.c -----------*/
DECLARE_READ32_HANDLER( zeus2_r ); class midzeus2_state : public midzeus_state
DECLARE_WRITE32_HANDLER( zeus2_w ); {
public:
midzeus2_state(const machine_config &mconfig, device_type type, const char *tag)
: midzeus_state(mconfig, type, tag) { }
DECLARE_VIDEO_START(midzeus2);
UINT32 screen_update_midzeus2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
DECLARE_READ32_MEMBER( zeus2_r );
DECLARE_WRITE32_MEMBER( zeus2_w );
private:
void exit_handler2();
void zeus2_register32_w(offs_t offset, UINT32 data, int logit);
void zeus2_register_update(offs_t offset, UINT32 oldval, int logit);
int zeus2_fifo_process(const UINT32 *data, int numwords);
void zeus2_pointer_write(UINT8 which, UINT32 value);
void zeus2_draw_model(UINT32 baseaddr, UINT16 count, int logit);
void zeus2_draw_quad(const UINT32 *databuffer, UINT32 texoffs, int logit);
void log_fifo_command(const UINT32 *data, int numwords, const char *suffix);
};

View File

@ -84,14 +84,6 @@ static int is_mk4b;
* *
*************************************/ *************************************/
static void zeus_pointer_w(UINT32 which, UINT32 data, int logit);
static void zeus_register16_w(running_machine &machine, offs_t offset, UINT16 data, int logit);
static void zeus_register32_w(running_machine &machine, offs_t offset, UINT32 data, int logit);
static void zeus_register_update(running_machine &machine, offs_t offset);
static int zeus_fifo_process(running_machine &machine, const UINT32 *data, int numwords);
static void zeus_draw_model(running_machine &machine, UINT32 texdata, int logit);
static void zeus_draw_quad(running_machine &machine, int long_fmt, const UINT32 *databuffer, UINT32 texdata, int logit);
INLINE UINT8 get_texel_4bit(const void *base, int y, int x, int width); INLINE UINT8 get_texel_4bit(const void *base, int y, int x, int width);
INLINE UINT8 get_texel_alt_4bit(const void *base, int y, int x, int width); INLINE UINT8 get_texel_alt_4bit(const void *base, int y, int x, int width);
INLINE UINT8 get_texel_8bit(const void *base, int y, int x, int width); INLINE UINT8 get_texel_8bit(const void *base, int y, int x, int width);
@ -102,10 +94,6 @@ static void render_poly_shade(void *dest, INT32 scanline, const poly_extent *ext
static void render_poly_solid(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid); static void render_poly_solid(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid);
static void render_poly_solid_fixedz(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid); static void render_poly_solid_fixedz(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid);
static void log_fifo_command(const UINT32 *data, int numwords, const char *suffix);
static void log_waveram(UINT32 length_and_base);
/************************************* /*************************************
* *
@ -463,11 +451,11 @@ WRITE32_MEMBER(midzeus_state::zeus_w)
/* 32-bit mode */ /* 32-bit mode */
if (m_zeusbase[0x80] & 0x00020000) if (m_zeusbase[0x80] & 0x00020000)
zeus_register32_w(machine(), offset, data, logit); zeus_register32_w(offset, data, logit);
/* 16-bit mode */ /* 16-bit mode */
else else
zeus_register16_w(machine(), offset, data, logit); zeus_register16_w(offset, data, logit);
} }
@ -479,7 +467,7 @@ WRITE32_MEMBER(midzeus_state::zeus_w)
* *
*************************************/ *************************************/
static void zeus_pointer_w(UINT32 which, UINT32 data, int logit) void midzeus_state::zeus_pointer_w(UINT32 which, UINT32 data, int logit)
{ {
switch (which & 0xffffff) switch (which & 0xffffff)
{ {
@ -541,42 +529,38 @@ static void zeus_pointer_w(UINT32 which, UINT32 data, int logit)
* *
*************************************/ *************************************/
static void zeus_register16_w(running_machine &machine, offs_t offset, UINT16 data, int logit) void midzeus_state::zeus_register16_w(offs_t offset, UINT16 data, int logit)
{ {
midzeus_state *state = machine.driver_data<midzeus_state>();
/* writes to register $CC need to force a partial update */ /* writes to register $CC need to force a partial update */
if ((offset & ~1) == 0xcc) if ((offset & ~1) == 0xcc)
machine.first_screen()->update_partial(machine.first_screen()->vpos()); m_screen->update_partial(m_screen->vpos());
/* write to high part on odd addresses */ /* write to high part on odd addresses */
if (offset & 1) if (offset & 1)
state->m_zeusbase[offset & ~1] = (state->m_zeusbase[offset & ~1] & 0x0000ffff) | (data << 16); m_zeusbase[offset & ~1] = (m_zeusbase[offset & ~1] & 0x0000ffff) | (data << 16);
/* write to low part on event addresses */ /* write to low part on event addresses */
else else
state->m_zeusbase[offset & ~1] = (state->m_zeusbase[offset & ~1] & 0xffff0000) | (data & 0xffff); m_zeusbase[offset & ~1] = (m_zeusbase[offset & ~1] & 0xffff0000) | (data & 0xffff);
/* log appropriately */ /* log appropriately */
if (logit) if (logit)
logerror("(%02X) = %04X [%08X]\n", offset, data & 0xffff, state->m_zeusbase[offset & ~1]); logerror("(%02X) = %04X [%08X]\n", offset, data & 0xffff, m_zeusbase[offset & ~1]);
/* handle the update */ /* handle the update */
if ((offset & 1) == 0) if ((offset & 1) == 0)
zeus_register_update(machine, offset); zeus_register_update(offset);
} }
static void zeus_register32_w(running_machine &machine, offs_t offset, UINT32 data, int logit) void midzeus_state::zeus_register32_w(offs_t offset, UINT32 data, int logit)
{ {
midzeus_state *state = machine.driver_data<midzeus_state>();
/* writes to register $CC need to force a partial update */ /* writes to register $CC need to force a partial update */
if ((offset & ~1) == 0xcc) if ((offset & ~1) == 0xcc)
machine.first_screen()->update_partial(machine.first_screen()->vpos()); m_screen->update_partial(m_screen->vpos());
/* always write to low word? */ /* always write to low word? */
state->m_zeusbase[offset & ~1] = data; m_zeusbase[offset & ~1] = data;
/* log appropriately */ /* log appropriately */
if (logit) if (logit)
@ -591,7 +575,7 @@ static void zeus_register32_w(running_machine &machine, offs_t offset, UINT32 da
/* handle the update */ /* handle the update */
if ((offset & 1) == 0) if ((offset & 1) == 0)
zeus_register_update(machine, offset); zeus_register_update(offset);
} }
@ -602,58 +586,56 @@ static void zeus_register32_w(running_machine &machine, offs_t offset, UINT32 da
* *
*************************************/ *************************************/
static void zeus_register_update(running_machine &machine, offs_t offset) void midzeus_state::zeus_register_update(offs_t offset)
{ {
midzeus_state *state = machine.driver_data<midzeus_state>();
/* handle the writes; only trigger on low accesses */ /* handle the writes; only trigger on low accesses */
switch (offset) switch (offset)
{ {
case 0x52: case 0x52:
state->m_zeusbase[0xb2] = state->m_zeusbase[0x52]; m_zeusbase[0xb2] = m_zeusbase[0x52];
break; break;
case 0x60: case 0x60:
/* invasn writes here to execute a command (?) */ /* invasn writes here to execute a command (?) */
if (state->m_zeusbase[0x60] & 1) if (m_zeusbase[0x60] & 1)
{ {
if ((state->m_zeusbase[0x80] & 0xffffff) == 0x22FCFF) if ((m_zeusbase[0x80] & 0xffffff) == 0x22FCFF)
{ {
// state->m_zeusbase[0x00] = color // m_zeusbase[0x00] = color
// state->m_zeusbase[0x02] = ??? = 0x000C0000 // m_zeusbase[0x02] = ??? = 0x000C0000
// state->m_zeusbase[0x04] = ??? = 0x00000E01 // m_zeusbase[0x04] = ??? = 0x00000E01
// state->m_zeusbase[0x06] = ??? = 0xFFFF0030 // m_zeusbase[0x06] = ??? = 0xFFFF0030
// state->m_zeusbase[0x08] = vert[0] = (y0 << 16) | x0 // m_zeusbase[0x08] = vert[0] = (y0 << 16) | x0
// state->m_zeusbase[0x0a] = vert[1] = (y1 << 16) | x1 // m_zeusbase[0x0a] = vert[1] = (y1 << 16) | x1
// state->m_zeusbase[0x0c] = vert[2] = (y2 << 16) | x2 // m_zeusbase[0x0c] = vert[2] = (y2 << 16) | x2
// state->m_zeusbase[0x0e] = vert[3] = (y3 << 16) | x3 // m_zeusbase[0x0e] = vert[3] = (y3 << 16) | x3
// state->m_zeusbase[0x18] = ??? = 0xFFFFFFFF // m_zeusbase[0x18] = ??? = 0xFFFFFFFF
// state->m_zeusbase[0x1a] = ??? = 0xFFFFFFFF // m_zeusbase[0x1a] = ??? = 0xFFFFFFFF
// state->m_zeusbase[0x1c] = ??? = 0xFFFFFFFF // m_zeusbase[0x1c] = ??? = 0xFFFFFFFF
// state->m_zeusbase[0x1e] = ??? = 0xFFFFFFFF // m_zeusbase[0x1e] = ??? = 0xFFFFFFFF
// state->m_zeusbase[0x20] = ??? = 0x00000000 // m_zeusbase[0x20] = ??? = 0x00000000
// state->m_zeusbase[0x22] = ??? = 0x00000000 // m_zeusbase[0x22] = ??? = 0x00000000
// state->m_zeusbase[0x24] = ??? = 0x00000000 // m_zeusbase[0x24] = ??? = 0x00000000
// state->m_zeusbase[0x26] = ??? = 0x00000000 // m_zeusbase[0x26] = ??? = 0x00000000
// state->m_zeusbase[0x40] = ??? = 0x00000000 // m_zeusbase[0x40] = ??? = 0x00000000
// state->m_zeusbase[0x42] = ??? = 0x00000000 // m_zeusbase[0x42] = ??? = 0x00000000
// state->m_zeusbase[0x44] = ??? = 0x00000000 // m_zeusbase[0x44] = ??? = 0x00000000
// state->m_zeusbase[0x46] = ??? = 0x00000000 // m_zeusbase[0x46] = ??? = 0x00000000
// state->m_zeusbase[0x4c] = ??? = 0x00808080 (brightness?) // m_zeusbase[0x4c] = ??? = 0x00808080 (brightness?)
// state->m_zeusbase[0x4e] = ??? = 0x00808080 (brightness?) // m_zeusbase[0x4e] = ??? = 0x00808080 (brightness?)
poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(poly); poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(poly);
poly_vertex vert[4]; poly_vertex vert[4];
vert[0].x = (INT16)state->m_zeusbase[0x08]; vert[0].x = (INT16)m_zeusbase[0x08];
vert[0].y = (INT16)(state->m_zeusbase[0x08] >> 16); vert[0].y = (INT16)(m_zeusbase[0x08] >> 16);
vert[1].x = (INT16)state->m_zeusbase[0x0a]; vert[1].x = (INT16)m_zeusbase[0x0a];
vert[1].y = (INT16)(state->m_zeusbase[0x0a] >> 16); vert[1].y = (INT16)(m_zeusbase[0x0a] >> 16);
vert[2].x = (INT16)state->m_zeusbase[0x0c]; vert[2].x = (INT16)m_zeusbase[0x0c];
vert[2].y = (INT16)(state->m_zeusbase[0x0c] >> 16); vert[2].y = (INT16)(m_zeusbase[0x0c] >> 16);
vert[3].x = (INT16)state->m_zeusbase[0x0e]; vert[3].x = (INT16)m_zeusbase[0x0e];
vert[3].y = (INT16)(state->m_zeusbase[0x0e] >> 16); vert[3].y = (INT16)(m_zeusbase[0x0e] >> 16);
extra->solidcolor = state->m_zeusbase[0x00]; extra->solidcolor = m_zeusbase[0x00];
extra->zoffset = 0x7fff; extra->zoffset = 0x7fff;
poly_render_quad(poly, NULL, zeus_cliprect, render_poly_solid_fixedz, 0, &vert[0], &vert[1], &vert[2], &vert[3]); poly_render_quad(poly, NULL, zeus_cliprect, render_poly_solid_fixedz, 0, &vert[0], &vert[1], &vert[2], &vert[3]);
@ -665,74 +647,74 @@ static void zeus_register_update(running_machine &machine, offs_t offset)
break; break;
case 0x70: case 0x70:
zeus_point[0] = state->m_zeusbase[0x70] << 16; zeus_point[0] = m_zeusbase[0x70] << 16;
break; break;
case 0x72: case 0x72:
zeus_point[1] = state->m_zeusbase[0x72] << 16; zeus_point[1] = m_zeusbase[0x72] << 16;
break; break;
case 0x74: case 0x74:
zeus_point[2] = state->m_zeusbase[0x74] << 16; zeus_point[2] = m_zeusbase[0x74] << 16;
break; break;
case 0x80: case 0x80:
/* this bit enables the "FIFO empty" IRQ; since our virtual FIFO is always empty, /* this bit enables the "FIFO empty" IRQ; since our virtual FIFO is always empty,
we simply assert immediately if this is enabled. invasn needs this for proper we simply assert immediately if this is enabled. invasn needs this for proper
operations */ operations */
if (state->m_zeusbase[0x80] & 0x02000000) if (m_zeusbase[0x80] & 0x02000000)
state->m_maincpu->set_input_line(2, ASSERT_LINE); m_maincpu->set_input_line(2, ASSERT_LINE);
else else
state->m_maincpu->set_input_line(2, CLEAR_LINE); m_maincpu->set_input_line(2, CLEAR_LINE);
break; break;
case 0x84: case 0x84:
/* MK4: Written in tandem with 0xcc */ /* MK4: Written in tandem with 0xcc */
/* MK4: Writes either 0x80 (and 0x000000 to 0xcc) or 0x00 (and 0x800000 to 0xcc) */ /* MK4: Writes either 0x80 (and 0x000000 to 0xcc) or 0x00 (and 0x800000 to 0xcc) */
zeus_renderbase = waveram1_ptr_from_expanded_addr(state->m_zeusbase[0x84] << 16); zeus_renderbase = waveram1_ptr_from_expanded_addr(m_zeusbase[0x84] << 16);
break; break;
case 0xb0: case 0xb0:
case 0xb2: case 0xb2:
if ((state->m_zeusbase[0xb6] >> 16) != 0) if ((m_zeusbase[0xb6] >> 16) != 0)
{ {
if ((offset == 0xb0 && (state->m_zeusbase[0xb6] & 0x02000000) == 0) || if ((offset == 0xb0 && (m_zeusbase[0xb6] & 0x02000000) == 0) ||
(offset == 0xb2 && (state->m_zeusbase[0xb6] & 0x02000000) != 0)) (offset == 0xb2 && (m_zeusbase[0xb6] & 0x02000000) != 0))
{ {
void *dest; void *dest;
if (state->m_zeusbase[0xb6] & 0x80000000) if (m_zeusbase[0xb6] & 0x80000000)
dest = waveram1_ptr_from_expanded_addr(state->m_zeusbase[0xb4]); dest = waveram1_ptr_from_expanded_addr(m_zeusbase[0xb4]);
else else
dest = waveram0_ptr_from_expanded_addr(state->m_zeusbase[0xb4]); dest = waveram0_ptr_from_expanded_addr(m_zeusbase[0xb4]);
if (state->m_zeusbase[0xb6] & 0x00100000) if (m_zeusbase[0xb6] & 0x00100000)
WAVERAM_WRITE16(dest, 0, state->m_zeusbase[0xb0]); WAVERAM_WRITE16(dest, 0, m_zeusbase[0xb0]);
if (state->m_zeusbase[0xb6] & 0x00200000) if (m_zeusbase[0xb6] & 0x00200000)
WAVERAM_WRITE16(dest, 1, state->m_zeusbase[0xb0] >> 16); WAVERAM_WRITE16(dest, 1, m_zeusbase[0xb0] >> 16);
if (state->m_zeusbase[0xb6] & 0x00400000) if (m_zeusbase[0xb6] & 0x00400000)
WAVERAM_WRITE16(dest, 2, state->m_zeusbase[0xb2]); WAVERAM_WRITE16(dest, 2, m_zeusbase[0xb2]);
if (state->m_zeusbase[0xb6] & 0x00800000) if (m_zeusbase[0xb6] & 0x00800000)
WAVERAM_WRITE16(dest, 3, state->m_zeusbase[0xb2] >> 16); WAVERAM_WRITE16(dest, 3, m_zeusbase[0xb2] >> 16);
if (state->m_zeusbase[0xb6] & 0x00020000) if (m_zeusbase[0xb6] & 0x00020000)
state->m_zeusbase[0xb4]++; m_zeusbase[0xb4]++;
} }
} }
break; break;
case 0xb4: case 0xb4:
if (state->m_zeusbase[0xb6] & 0x00010000) if (m_zeusbase[0xb6] & 0x00010000)
{ {
const UINT32 *src; const UINT32 *src;
if (state->m_zeusbase[0xb6] & 0x80000000) if (m_zeusbase[0xb6] & 0x80000000)
src = (const UINT32 *)waveram1_ptr_from_expanded_addr(state->m_zeusbase[0xb4]); src = (const UINT32 *)waveram1_ptr_from_expanded_addr(m_zeusbase[0xb4]);
else else
src = (const UINT32 *)waveram0_ptr_from_expanded_addr(state->m_zeusbase[0xb4]); src = (const UINT32 *)waveram0_ptr_from_expanded_addr(m_zeusbase[0xb4]);
poly_wait(poly, "vram_read"); poly_wait(poly, "vram_read");
state->m_zeusbase[0xb0] = WAVERAM_READ32(src, 0); m_zeusbase[0xb0] = WAVERAM_READ32(src, 0);
state->m_zeusbase[0xb2] = WAVERAM_READ32(src, 1); m_zeusbase[0xb2] = WAVERAM_READ32(src, 1);
} }
break; break;
@ -742,15 +724,15 @@ static void zeus_register_update(running_machine &machine, offs_t offset)
case 0xc6: case 0xc6:
case 0xc8: case 0xc8:
case 0xca: case 0xca:
machine.first_screen()->update_partial(machine.first_screen()->vpos()); m_screen->update_partial(m_screen->vpos());
{ {
int vtotal = state->m_zeusbase[0xca] >> 16; int vtotal = m_zeusbase[0xca] >> 16;
int htotal = state->m_zeusbase[0xc6] >> 16; int htotal = m_zeusbase[0xc6] >> 16;
rectangle visarea(state->m_zeusbase[0xc6] & 0xffff, htotal - 3, 0, state->m_zeusbase[0xc8] & 0xffff); rectangle visarea(m_zeusbase[0xc6] & 0xffff, htotal - 3, 0, m_zeusbase[0xc8] & 0xffff);
if (htotal > 0 && vtotal > 0 && visarea.min_x < visarea.max_x && visarea.max_y < vtotal) if (htotal > 0 && vtotal > 0 && visarea.min_x < visarea.max_x && visarea.max_y < vtotal)
{ {
machine.first_screen()->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 8.0 / (htotal * vtotal))); m_screen->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 8.0 / (htotal * vtotal)));
zeus_cliprect = visarea; zeus_cliprect = visarea;
zeus_cliprect.max_x -= zeus_cliprect.min_x; zeus_cliprect.max_x -= zeus_cliprect.min_x;
zeus_cliprect.min_x = 0; zeus_cliprect.min_x = 0;
@ -759,13 +741,13 @@ static void zeus_register_update(running_machine &machine, offs_t offset)
break; break;
case 0xcc: case 0xcc:
machine.first_screen()->update_partial(machine.first_screen()->vpos()); m_screen->update_partial(m_screen->vpos());
log_fifo = machine.input().code_pressed(KEYCODE_L); log_fifo = machine().input().code_pressed(KEYCODE_L);
break; break;
case 0xe0: case 0xe0:
zeus_fifo[zeus_fifo_words++] = state->m_zeusbase[0xe0]; zeus_fifo[zeus_fifo_words++] = m_zeusbase[0xe0];
if (zeus_fifo_process(machine, zeus_fifo, zeus_fifo_words)) if (zeus_fifo_process(zeus_fifo, zeus_fifo_words))
zeus_fifo_words = 0; zeus_fifo_words = 0;
break; break;
} }
@ -779,10 +761,8 @@ static void zeus_register_update(running_machine &machine, offs_t offset)
* *
*************************************/ *************************************/
static int zeus_fifo_process(running_machine &machine, const UINT32 *data, int numwords) int midzeus_state::zeus_fifo_process(const UINT32 *data, int numwords)
{ {
midzeus_state *state = machine.driver_data<midzeus_state>();
/* handle logging */ /* handle logging */
switch (data[0] >> 24) switch (data[0] >> 24)
{ {
@ -801,14 +781,14 @@ static int zeus_fifo_process(running_machine &machine, const UINT32 *data, int n
case 0x13: /* invasn */ case 0x13: /* invasn */
if (log_fifo) if (log_fifo)
log_fifo_command(data, numwords, ""); log_fifo_command(data, numwords, "");
zeus_draw_model(machine, (state->m_zeusbase[0x06] << 16), log_fifo); zeus_draw_model((m_zeusbase[0x06] << 16), log_fifo);
break; break;
/* 0x17: write 16-bit value to low registers */ /* 0x17: write 16-bit value to low registers */
case 0x17: case 0x17:
if (log_fifo) if (log_fifo)
log_fifo_command(data, numwords, " -- reg16"); log_fifo_command(data, numwords, " -- reg16");
zeus_register16_w(machine, (data[0] >> 16) & 0x7f, data[0], log_fifo); zeus_register16_w((data[0] >> 16) & 0x7f, data[0], log_fifo);
break; break;
/* 0x18: write 32-bit value to low registers */ /* 0x18: write 32-bit value to low registers */
@ -818,7 +798,7 @@ static int zeus_fifo_process(running_machine &machine, const UINT32 *data, int n
return FALSE; return FALSE;
if (log_fifo) if (log_fifo)
log_fifo_command(data, numwords, " -- reg32"); log_fifo_command(data, numwords, " -- reg32");
zeus_register32_w(machine, (data[0] >> 16) & 0x7f, data[1], log_fifo); zeus_register32_w((data[0] >> 16) & 0x7f, data[1], log_fifo);
break; break;
/* 0x1A/0x1B: sync pipeline(?) */ /* 0x1A/0x1B: sync pipeline(?) */
@ -962,8 +942,8 @@ static int zeus_fifo_process(running_machine &machine, const UINT32 *data, int n
} }
else else
{ {
UINT32 texdata = (state->m_zeusbase[0x06] << 16) | (state->m_zeusbase[0x00] >> 16); UINT32 texdata = (m_zeusbase[0x06] << 16) | (m_zeusbase[0x00] >> 16);
zeus_draw_quad(machine, FALSE, data, texdata, log_fifo); zeus_draw_quad(FALSE, data, texdata, log_fifo);
} }
break; break;
@ -982,7 +962,7 @@ static int zeus_fifo_process(running_machine &machine, const UINT32 *data, int n
if (log_fifo) if (log_fifo)
log_fifo_command(data, numwords, ""); log_fifo_command(data, numwords, "");
zeus_objdata = data[1]; zeus_objdata = data[1];
zeus_draw_model(machine, data[2], log_fifo); zeus_draw_model(data[2], log_fifo);
break; break;
default: default:
@ -1002,9 +982,8 @@ static int zeus_fifo_process(running_machine &machine, const UINT32 *data, int n
* *
*************************************/ *************************************/
static void zeus_draw_model(running_machine &machine, UINT32 texdata, int logit) void midzeus_state::zeus_draw_model(UINT32 texdata, int logit)
{ {
midzeus_state *state = machine.driver_data<midzeus_state>();
UINT32 databuffer[32]; UINT32 databuffer[32];
int databufcount = 0; int databufcount = 0;
int model_done = FALSE; int model_done = FALSE;
@ -1062,23 +1041,23 @@ static void zeus_draw_model(running_machine &machine, UINT32 texdata, int logit)
case 0x17: /* mk4 */ case 0x17: /* mk4 */
if (logit) if (logit)
logerror("reg16"); logerror("reg16");
zeus_register16_w(machine, (databuffer[0] >> 16) & 0x7f, databuffer[0], logit); zeus_register16_w((databuffer[0] >> 16) & 0x7f, databuffer[0], logit);
if (((databuffer[0] >> 16) & 0x7f) == 0x06) if (((databuffer[0] >> 16) & 0x7f) == 0x06)
texdata = (texdata & 0xffff) | (state->m_zeusbase[0x06] << 16); texdata = (texdata & 0xffff) | (m_zeusbase[0x06] << 16);
break; break;
case 0x19: /* invasn */ case 0x19: /* invasn */
if (logit) if (logit)
logerror("reg32"); logerror("reg32");
zeus_register32_w(machine, (databuffer[0] >> 16) & 0x7f, databuffer[1], logit); zeus_register32_w((databuffer[0] >> 16) & 0x7f, databuffer[1], logit);
if (((databuffer[0] >> 16) & 0x7f) == 0x06) if (((databuffer[0] >> 16) & 0x7f) == 0x06)
texdata = (texdata & 0xffff) | (state->m_zeusbase[0x06] << 16); texdata = (texdata & 0xffff) | (m_zeusbase[0x06] << 16);
break; break;
case 0x25: /* mk4 */ case 0x25: /* mk4 */
case 0x28: /* mk4r1 */ case 0x28: /* mk4r1 */
case 0x30: /* invasn */ case 0x30: /* invasn */
zeus_draw_quad(machine, TRUE, databuffer, texdata, logit); zeus_draw_quad(TRUE, databuffer, texdata, logit);
break; break;
default: default:
@ -1102,9 +1081,8 @@ static void zeus_draw_model(running_machine &machine, UINT32 texdata, int logit)
* *
*************************************/ *************************************/
static void zeus_draw_quad(running_machine &machine, int long_fmt, const UINT32 *databuffer, UINT32 texdata, int logit) void midzeus_state::zeus_draw_quad(int long_fmt, const UINT32 *databuffer, UINT32 texdata, int logit)
{ {
midzeus_state *state = machine.driver_data<midzeus_state>();
poly_draw_scanline_func callback; poly_draw_scanline_func callback;
poly_extra_data *extra; poly_extra_data *extra;
poly_vertex clipvert[8]; poly_vertex clipvert[8];
@ -1147,7 +1125,7 @@ static void zeus_draw_quad(running_machine &machine, int long_fmt, const UINT32
{ {
if (logit) if (logit)
logerror("quad (culled %08X)\n", rotnormal[2]); logerror("quad (culled %08X)\n", rotnormal[2]);
// if (machine.input().code_pressed(KEYCODE_COMMA)) // if (machine().input().code_pressed(KEYCODE_COMMA))
// return; // return;
} }
@ -1155,8 +1133,8 @@ static void zeus_draw_quad(running_machine &machine, int long_fmt, const UINT32
val2 = (texdata >> 16) & 0x3ff; val2 = (texdata >> 16) & 0x3ff;
texwshift = (val2 >> 6) & 7; texwshift = (val2 >> 6) & 7;
uscale = (8 >> ((state->m_zeusbase[0x04] >> 4) & 3)) * 0.125f * 256.0f; uscale = (8 >> ((m_zeusbase[0x04] >> 4) & 3)) * 0.125f * 256.0f;
vscale = (8 >> ((state->m_zeusbase[0x04] >> 6) & 3)) * 0.125f * 256.0f; vscale = (8 >> ((m_zeusbase[0x04] >> 6) & 3)) * 0.125f * 256.0f;
int xy_offset = long_fmt ? 2 : 1; int xy_offset = long_fmt ? 2 : 1;
@ -1272,9 +1250,9 @@ static void zeus_draw_quad(running_machine &machine, int long_fmt, const UINT32
printf("Unknown draw mode: %.8x\n", ctrl_word); printf("Unknown draw mode: %.8x\n", ctrl_word);
return; return;
} }
extra->solidcolor = state->m_zeusbase[0x00] & 0x7fff; extra->solidcolor = m_zeusbase[0x00] & 0x7fff;
extra->zoffset = state->m_zeusbase[0x7e] >> 16; extra->zoffset = m_zeusbase[0x7e] >> 16;
extra->alpha = state->m_zeusbase[0x4e]; extra->alpha = m_zeusbase[0x4e];
extra->transcolor = ((ctrl_word >> 16) & 1) ? 0 : 0x100; extra->transcolor = ((ctrl_word >> 16) & 1) ? 0 : 0x100;
extra->palbase = waveram0_ptr_from_block_addr(zeus_palbase); extra->palbase = waveram0_ptr_from_block_addr(zeus_palbase);
@ -1417,7 +1395,7 @@ static void render_poly_solid_fixedz(void *dest, INT32 scanline, const poly_exte
* *
*************************************/ *************************************/
static void log_fifo_command(const UINT32 *data, int numwords, const char *suffix) void midzeus_state::log_fifo_command(const UINT32 *data, int numwords, const char *suffix)
{ {
int wordnum; int wordnum;
@ -1428,7 +1406,7 @@ static void log_fifo_command(const UINT32 *data, int numwords, const char *suffi
} }
static void log_waveram(UINT32 length_and_base) void midzeus_state::log_waveram(UINT32 length_and_base)
{ {
static struct static struct
{ {

View File

@ -103,19 +103,8 @@ static int subregwrite_count[0x100];
* *
*************************************/ *************************************/
static void zeus_register32_w(running_machine &machine, offs_t offset, UINT32 data, int logit);
static void zeus_register_update(running_machine &machine, offs_t offset, UINT32 oldval, int logit);
static void zeus_pointer_write(UINT8 which, UINT32 value);
static int zeus_fifo_process(running_machine &machine, const UINT32 *data, int numwords);
static void zeus_draw_model(running_machine &machine, UINT32 baseaddr, UINT16 count, int logit);
static void zeus_draw_quad(running_machine &machine, const UINT32 *databuffer, UINT32 texoffs, int logit);
static void render_poly_8bit(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid); static void render_poly_8bit(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid);
static void log_fifo_command(const UINT32 *data, int numwords, const char *suffix);
//static void log_waveram(UINT32 base, UINT16 length);
/************************************* /*************************************
* *
* Macros * Macros
@ -262,7 +251,7 @@ static TIMER_CALLBACK( int_timer_callback )
} }
VIDEO_START_MEMBER(midzeus_state,midzeus2) VIDEO_START_MEMBER(midzeus2_state,midzeus2)
{ {
/* allocate memory for "wave" RAM */ /* allocate memory for "wave" RAM */
waveram[0] = auto_alloc_array(machine(), UINT32, WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 8/4); waveram[0] = auto_alloc_array(machine(), UINT32, WAVERAM0_WIDTH * WAVERAM0_HEIGHT * 8/4);
@ -272,7 +261,7 @@ VIDEO_START_MEMBER(midzeus_state,midzeus2)
poly = poly_alloc(machine(), 10000, sizeof(poly_extra_data), POLYFLAG_ALLOW_QUADS); poly = poly_alloc(machine(), 10000, sizeof(poly_extra_data), POLYFLAG_ALLOW_QUADS);
/* we need to cleanup on exit */ /* we need to cleanup on exit */
machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(midzeus_state::exit_handler2), this)); machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(midzeus2_state::exit_handler2), this));
zbase = 2.0f; zbase = 2.0f;
yoffs = 0; yoffs = 0;
@ -296,7 +285,7 @@ VIDEO_START_MEMBER(midzeus_state,midzeus2)
} }
void midzeus_state::exit_handler2() void midzeus2_state::exit_handler2()
{ {
#if DUMP_WAVE_RAM #if DUMP_WAVE_RAM
FILE *f = fopen("waveram.dmp", "w"); FILE *f = fopen("waveram.dmp", "w");
@ -357,7 +346,7 @@ void midzeus_state::exit_handler2()
* *
*************************************/ *************************************/
UINT32 midzeus_state::screen_update_midzeus2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) UINT32 midzeus2_state::screen_update_midzeus2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{ {
int x, y; int x, y;
@ -415,11 +404,10 @@ if (machine().input().code_pressed(KEYCODE_DOWN)) { zbase -= 1.0f; popmessage("Z
* *
*************************************/ *************************************/
READ32_HANDLER( zeus2_r ) READ32_MEMBER( midzeus2_state::zeus2_r )
{ {
int logit = (offset != 0x00 && offset != 0x01 && offset != 0x54 && offset != 0x48 && offset != 0x49 && offset != 0x58 && offset != 0x59 && offset != 0x5a); int logit = (offset != 0x00 && offset != 0x01 && offset != 0x54 && offset != 0x48 && offset != 0x49 && offset != 0x58 && offset != 0x59 && offset != 0x5a);
midzeus_state *state = space.machine().driver_data<midzeus_state>(); UINT32 result = m_zeusbase[offset];
UINT32 result = state->m_zeusbase[offset];
#if TRACK_REG_USAGE #if TRACK_REG_USAGE
regread_count[offset]++; regread_count[offset]++;
@ -439,7 +427,7 @@ READ32_HANDLER( zeus2_r )
/* bits $00080000 is tested in a loop until 0 */ /* bits $00080000 is tested in a loop until 0 */
/* bit $00000004 is tested for toggling; probably VBLANK */ /* bit $00000004 is tested for toggling; probably VBLANK */
result = 0x00; result = 0x00;
if (state->m_screen->vblank()) if (m_screen->vblank())
result |= 0x04; result |= 0x04;
break; break;
@ -450,7 +438,7 @@ READ32_HANDLER( zeus2_r )
case 0x54: case 0x54:
/* both upper 16 bits and lower 16 bits seem to be used as vertical counters */ /* both upper 16 bits and lower 16 bits seem to be used as vertical counters */
result = (state->m_screen->vpos() << 16) | state->m_screen->vpos(); result = (m_screen->vpos() << 16) | m_screen->vpos();
break; break;
} }
@ -465,7 +453,7 @@ READ32_HANDLER( zeus2_r )
* *
*************************************/ *************************************/
WRITE32_HANDLER( zeus2_w ) WRITE32_MEMBER( midzeus2_state::zeus2_w )
{ {
int logit = (offset != 0x08 && int logit = (offset != 0x08 &&
(offset != 0x20 || data != 0) && (offset != 0x20 || data != 0) &&
@ -473,7 +461,7 @@ WRITE32_HANDLER( zeus2_w )
offset != 0x50 && offset != 0x51 && offset != 0x57 && offset != 0x58 && offset != 0x59 && offset != 0x5a && offset != 0x5e); offset != 0x50 && offset != 0x51 && offset != 0x57 && offset != 0x58 && offset != 0x59 && offset != 0x5a && offset != 0x5e);
if (logit) if (logit)
logerror("%06X:zeus2_w", space.device().safe_pc()); logerror("%06X:zeus2_w", space.device().safe_pc());
zeus_register32_w(space.machine(), offset, data, logit); zeus2_register32_w(offset, data, logit);
} }
@ -484,10 +472,9 @@ WRITE32_HANDLER( zeus2_w )
* *
*************************************/ *************************************/
static void zeus_register32_w(running_machine &machine, offs_t offset, UINT32 data, int logit) void midzeus2_state::zeus2_register32_w(offs_t offset, UINT32 data, int logit)
{ {
midzeus_state *state = machine.driver_data<midzeus_state>(); UINT32 oldval = m_zeusbase[offset];
UINT32 oldval = state->m_zeusbase[offset];
#if TRACK_REG_USAGE #if TRACK_REG_USAGE
regwrite_count[offset]++; regwrite_count[offset]++;
@ -510,17 +497,17 @@ if (regdata_count[offset] < 256)
/* writes to register $CC need to force a partial update */ /* writes to register $CC need to force a partial update */
// if ((offset & ~1) == 0xcc) // if ((offset & ~1) == 0xcc)
// machine.first_screen()->update_partial(machine.first_screen()->vpos()); // m_screen->update_partial(m_screen->vpos());
/* always write to low word? */ /* always write to low word? */
state->m_zeusbase[offset] = data; m_zeusbase[offset] = data;
/* log appropriately */ /* log appropriately */
if (logit) if (logit)
logerror("(%02X) = %08X\n", offset, data); logerror("(%02X) = %08X\n", offset, data);
/* handle the update */ /* handle the update */
zeus_register_update(machine, offset, oldval, logit); zeus2_register_update(offset, oldval, logit);
} }
@ -531,15 +518,14 @@ if (regdata_count[offset] < 256)
* *
*************************************/ *************************************/
static void zeus_register_update(running_machine &machine, offs_t offset, UINT32 oldval, int logit) void midzeus2_state::zeus2_register_update(offs_t offset, UINT32 oldval, int logit)
{ {
/* handle the writes; only trigger on low accesses */ /* handle the writes; only trigger on low accesses */
midzeus_state *state = machine.driver_data<midzeus_state>();
switch (offset) switch (offset)
{ {
case 0x08: case 0x08:
zeus_fifo[zeus_fifo_words++] = state->m_zeusbase[0x08]; zeus_fifo[zeus_fifo_words++] = m_zeusbase[0x08];
if (zeus_fifo_process(machine, zeus_fifo, zeus_fifo_words)) if (zeus2_fifo_process(zeus_fifo, zeus_fifo_words))
zeus_fifo_words = 0; zeus_fifo_words = 0;
/* set the interrupt signal to indicate we can handle more */ /* set the interrupt signal to indicate we can handle more */
@ -549,12 +535,12 @@ static void zeus_register_update(running_machine &machine, offs_t offset, UINT32
case 0x20: case 0x20:
/* toggles between two values based on the page: /* toggles between two values based on the page:
Page # state->m_zeusbase[0x20] state->m_zeusbase[0x38] Page # m_zeusbase[0x20] m_zeusbase[0x38]
------ -------------- -------------- ------ -------------- --------------
0 $04000190 $00000000 0 $04000190 $00000000
1 $04000000 $01900000 1 $04000000 $01900000
*/ */
zeus_pointer_write(state->m_zeusbase[0x20] >> 24, state->m_zeusbase[0x20]); zeus2_pointer_write(m_zeusbase[0x20] >> 24, m_zeusbase[0x20]);
break; break;
case 0x33: case 0x33:
@ -562,15 +548,15 @@ static void zeus_register_update(running_machine &machine, offs_t offset, UINT32
case 0x35: case 0x35:
case 0x36: case 0x36:
case 0x37: case 0x37:
machine.first_screen()->update_partial(machine.first_screen()->vpos()); m_screen->update_partial(m_screen->vpos());
{ {
int vtotal = state->m_zeusbase[0x37] & 0xffff; int vtotal = m_zeusbase[0x37] & 0xffff;
int htotal = state->m_zeusbase[0x34] >> 16; int htotal = m_zeusbase[0x34] >> 16;
rectangle visarea(state->m_zeusbase[0x33] >> 16, (state->m_zeusbase[0x34] & 0xffff) - 1, 0, state->m_zeusbase[0x35] & 0xffff); rectangle visarea(m_zeusbase[0x33] >> 16, (m_zeusbase[0x34] & 0xffff) - 1, 0, m_zeusbase[0x35] & 0xffff);
if (htotal > 0 && vtotal > 0 && visarea.min_x < visarea.max_x && visarea.max_y < vtotal) if (htotal > 0 && vtotal > 0 && visarea.min_x < visarea.max_x && visarea.max_y < vtotal)
{ {
machine.first_screen()->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 4.0 / (htotal * vtotal))); m_screen->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 4.0 / (htotal * vtotal)));
zeus_cliprect = visarea; zeus_cliprect = visarea;
zeus_cliprect.max_x -= zeus_cliprect.min_x; zeus_cliprect.max_x -= zeus_cliprect.min_x;
zeus_cliprect.min_x = 0; zeus_cliprect.min_x = 0;
@ -580,28 +566,28 @@ static void zeus_register_update(running_machine &machine, offs_t offset, UINT32
case 0x38: case 0x38:
{ {
UINT32 temp = state->m_zeusbase[0x38]; UINT32 temp = m_zeusbase[0x38];
state->m_zeusbase[0x38] = oldval; m_zeusbase[0x38] = oldval;
machine.first_screen()->update_partial(machine.first_screen()->vpos()); m_screen->update_partial(m_screen->vpos());
log_fifo = machine.input().code_pressed(KEYCODE_L); log_fifo = machine().input().code_pressed(KEYCODE_L);
state->m_zeusbase[0x38] = temp; m_zeusbase[0x38] = temp;
} }
break; break;
case 0x41: case 0x41:
/* this is the address, except in read mode, where it latches values */ /* this is the address, except in read mode, where it latches values */
if (state->m_zeusbase[0x4e] & 0x10) if (m_zeusbase[0x4e] & 0x10)
{ {
const void *src = waveram0_ptr_from_expanded_addr(oldval); const void *src = waveram0_ptr_from_expanded_addr(oldval);
state->m_zeusbase[0x41] = oldval; m_zeusbase[0x41] = oldval;
state->m_zeusbase[0x48] = WAVERAM_READ32(src, 0); m_zeusbase[0x48] = WAVERAM_READ32(src, 0);
state->m_zeusbase[0x49] = WAVERAM_READ32(src, 1); m_zeusbase[0x49] = WAVERAM_READ32(src, 1);
if (state->m_zeusbase[0x4e] & 0x40) if (m_zeusbase[0x4e] & 0x40)
{ {
state->m_zeusbase[0x41]++; m_zeusbase[0x41]++;
state->m_zeusbase[0x41] += (state->m_zeusbase[0x41] & 0x400) << 6; m_zeusbase[0x41] += (m_zeusbase[0x41] & 0x400) << 6;
state->m_zeusbase[0x41] &= ~0xfc00; m_zeusbase[0x41] &= ~0xfc00;
} }
} }
break; break;
@ -609,113 +595,113 @@ static void zeus_register_update(running_machine &machine, offs_t offset, UINT32
case 0x48: case 0x48:
case 0x49: case 0x49:
/* if we're in write mode, process it */ /* if we're in write mode, process it */
if (state->m_zeusbase[0x40] == 0x00890000) if (m_zeusbase[0x40] == 0x00890000)
{ {
/* /*
state->m_zeusbase[0x4e]: m_zeusbase[0x4e]:
bit 0-1: which register triggers write through bit 0-1: which register triggers write through
bit 3: enable write through via these registers bit 3: enable write through via these registers
bit 4: seems to be set during reads, when 0x41 is used for latching bit 4: seems to be set during reads, when 0x41 is used for latching
bit 6: enable autoincrement on write through bit 6: enable autoincrement on write through
*/ */
if ((state->m_zeusbase[0x4e] & 0x08) && (offset & 3) == (state->m_zeusbase[0x4e] & 3)) if ((m_zeusbase[0x4e] & 0x08) && (offset & 3) == (m_zeusbase[0x4e] & 3))
{ {
void *dest = waveram0_ptr_from_expanded_addr(state->m_zeusbase[0x41]); void *dest = waveram0_ptr_from_expanded_addr(m_zeusbase[0x41]);
WAVERAM_WRITE32(dest, 0, state->m_zeusbase[0x48]); WAVERAM_WRITE32(dest, 0, m_zeusbase[0x48]);
WAVERAM_WRITE32(dest, 1, state->m_zeusbase[0x49]); WAVERAM_WRITE32(dest, 1, m_zeusbase[0x49]);
if (state->m_zeusbase[0x4e] & 0x40) if (m_zeusbase[0x4e] & 0x40)
{ {
state->m_zeusbase[0x41]++; m_zeusbase[0x41]++;
state->m_zeusbase[0x41] += (state->m_zeusbase[0x41] & 0x400) << 6; m_zeusbase[0x41] += (m_zeusbase[0x41] & 0x400) << 6;
state->m_zeusbase[0x41] &= ~0xfc00; m_zeusbase[0x41] &= ~0xfc00;
} }
} }
} }
/* make sure we log anything else */ /* make sure we log anything else */
else if (logit) else if (logit)
logerror("\t[40]=%08X [4E]=%08X\n", state->m_zeusbase[0x40], state->m_zeusbase[0x4e]); logerror("\t[40]=%08X [4E]=%08X\n", m_zeusbase[0x40], m_zeusbase[0x4e]);
break; break;
case 0x51: case 0x51:
/* in this mode, crusnexo expects the reads to immediately latch */ /* in this mode, crusnexo expects the reads to immediately latch */
if (state->m_zeusbase[0x50] == 0x00a20000) if (m_zeusbase[0x50] == 0x00a20000)
oldval = state->m_zeusbase[0x51]; oldval = m_zeusbase[0x51];
/* this is the address, except in read mode, where it latches values */ /* this is the address, except in read mode, where it latches values */
if ((state->m_zeusbase[0x5e] & 0x10) || (state->m_zeusbase[0x50] == 0x00a20000)) if ((m_zeusbase[0x5e] & 0x10) || (m_zeusbase[0x50] == 0x00a20000))
{ {
const void *src = waveram1_ptr_from_expanded_addr(oldval); const void *src = waveram1_ptr_from_expanded_addr(oldval);
state->m_zeusbase[0x51] = oldval; m_zeusbase[0x51] = oldval;
state->m_zeusbase[0x58] = WAVERAM_READ32(src, 0); m_zeusbase[0x58] = WAVERAM_READ32(src, 0);
state->m_zeusbase[0x59] = WAVERAM_READ32(src, 1); m_zeusbase[0x59] = WAVERAM_READ32(src, 1);
state->m_zeusbase[0x5a] = WAVERAM_READ32(src, 2); m_zeusbase[0x5a] = WAVERAM_READ32(src, 2);
if (state->m_zeusbase[0x5e] & 0x40) if (m_zeusbase[0x5e] & 0x40)
{ {
state->m_zeusbase[0x51]++; m_zeusbase[0x51]++;
state->m_zeusbase[0x51] += (state->m_zeusbase[0x51] & 0x200) << 7; m_zeusbase[0x51] += (m_zeusbase[0x51] & 0x200) << 7;
state->m_zeusbase[0x51] &= ~0xfe00; m_zeusbase[0x51] &= ~0xfe00;
} }
} }
break; break;
case 0x57: case 0x57:
/* thegrid uses this to write either left or right halves of pixels */ /* thegrid uses this to write either left or right halves of pixels */
if (state->m_zeusbase[0x50] == 0x00e90000) if (m_zeusbase[0x50] == 0x00e90000)
{ {
void *dest = waveram1_ptr_from_expanded_addr(state->m_zeusbase[0x51]); void *dest = waveram1_ptr_from_expanded_addr(m_zeusbase[0x51]);
if (state->m_zeusbase[0x57] & 1) if (m_zeusbase[0x57] & 1)
WAVERAM_WRITE32(dest, 0, state->m_zeusbase[0x58]); WAVERAM_WRITE32(dest, 0, m_zeusbase[0x58]);
if (state->m_zeusbase[0x57] & 4) if (m_zeusbase[0x57] & 4)
WAVERAM_WRITE32(dest, 1, state->m_zeusbase[0x59]); WAVERAM_WRITE32(dest, 1, m_zeusbase[0x59]);
} }
/* make sure we log anything else */ /* make sure we log anything else */
else if (logit) else if (logit)
logerror("\t[50]=%08X [5E]=%08X\n", state->m_zeusbase[0x50], state->m_zeusbase[0x5e]); logerror("\t[50]=%08X [5E]=%08X\n", m_zeusbase[0x50], m_zeusbase[0x5e]);
break; break;
case 0x58: case 0x58:
case 0x59: case 0x59:
case 0x5a: case 0x5a:
/* if we're in write mode, process it */ /* if we're in write mode, process it */
if (state->m_zeusbase[0x50] == 0x00890000) if (m_zeusbase[0x50] == 0x00890000)
{ {
/* /*
state->m_zeusbase[0x5e]: m_zeusbase[0x5e]:
bit 0-1: which register triggers write through bit 0-1: which register triggers write through
bit 3: enable write through via these registers bit 3: enable write through via these registers
bit 4: seems to be set during reads, when 0x51 is used for latching bit 4: seems to be set during reads, when 0x51 is used for latching
bit 5: unknown, currently used to specify ordering, but this is suspect bit 5: unknown, currently used to specify ordering, but this is suspect
bit 6: enable autoincrement on write through bit 6: enable autoincrement on write through
*/ */
if ((state->m_zeusbase[0x5e] & 0x08) && (offset & 3) == (state->m_zeusbase[0x5e] & 3)) if ((m_zeusbase[0x5e] & 0x08) && (offset & 3) == (m_zeusbase[0x5e] & 3))
{ {
void *dest = waveram1_ptr_from_expanded_addr(state->m_zeusbase[0x51]); void *dest = waveram1_ptr_from_expanded_addr(m_zeusbase[0x51]);
WAVERAM_WRITE32(dest, 0, state->m_zeusbase[0x58]); WAVERAM_WRITE32(dest, 0, m_zeusbase[0x58]);
if (state->m_zeusbase[0x5e] & 0x20) if (m_zeusbase[0x5e] & 0x20)
WAVERAM_WRITE32(dest, 1, state->m_zeusbase[0x5a]); WAVERAM_WRITE32(dest, 1, m_zeusbase[0x5a]);
else else
{ {
WAVERAM_WRITE32(dest, 1, state->m_zeusbase[0x59]); WAVERAM_WRITE32(dest, 1, m_zeusbase[0x59]);
WAVERAM_WRITE32(dest, 2, state->m_zeusbase[0x5a]); WAVERAM_WRITE32(dest, 2, m_zeusbase[0x5a]);
} }
if (state->m_zeusbase[0x5e] & 0x40) if (m_zeusbase[0x5e] & 0x40)
{ {
state->m_zeusbase[0x51]++; m_zeusbase[0x51]++;
state->m_zeusbase[0x51] += (state->m_zeusbase[0x51] & 0x200) << 7; m_zeusbase[0x51] += (m_zeusbase[0x51] & 0x200) << 7;
state->m_zeusbase[0x51] &= ~0xfe00; m_zeusbase[0x51] &= ~0xfe00;
} }
} }
} }
/* make sure we log anything else */ /* make sure we log anything else */
else if (logit) else if (logit)
logerror("\t[50]=%08X [5E]=%08X\n", state->m_zeusbase[0x50], state->m_zeusbase[0x5e]); logerror("\t[50]=%08X [5E]=%08X\n", m_zeusbase[0x50], m_zeusbase[0x5e]);
break; break;
} }
} }
@ -728,7 +714,7 @@ static void zeus_register_update(running_machine &machine, offs_t offset, UINT32
* *
*************************************/ *************************************/
static void zeus_pointer_write(UINT8 which, UINT32 value) void midzeus2_state::zeus2_pointer_write(UINT8 which, UINT32 value)
{ {
#if TRACK_REG_USAGE #if TRACK_REG_USAGE
subregwrite_count[which]++; subregwrite_count[which]++;
@ -774,7 +760,7 @@ if (subregdata_count[which] < 256)
* *
*************************************/ *************************************/
static int zeus_fifo_process(running_machine &machine, const UINT32 *data, int numwords) int midzeus2_state::zeus2_fifo_process(const UINT32 *data, int numwords)
{ {
int dataoffs = 0; int dataoffs = 0;
@ -788,7 +774,7 @@ static int zeus_fifo_process(running_machine &machine, const UINT32 *data, int n
if (log_fifo) if (log_fifo)
log_fifo_command(data, numwords, " -- reg32"); log_fifo_command(data, numwords, " -- reg32");
if (((data[0] >> 16) & 0x7f) != 0x08) if (((data[0] >> 16) & 0x7f) != 0x08)
zeus_register32_w(machine, (data[0] >> 16) & 0x7f, data[1], log_fifo); zeus2_register32_w((data[0] >> 16) & 0x7f, data[1], log_fifo);
break; break;
/* 0x08: set matrix and point (thegrid) */ /* 0x08: set matrix and point (thegrid) */
@ -887,7 +873,7 @@ static int zeus_fifo_process(running_machine &machine, const UINT32 *data, int n
return FALSE; return FALSE;
if (log_fifo) if (log_fifo)
log_fifo_command(data, numwords, ""); log_fifo_command(data, numwords, "");
zeus_draw_model(machine, data[1], data[0] & 0xffff, log_fifo); zeus2_draw_model(data[1], data[0] & 0xffff, log_fifo);
break; break;
/* 0x31: sync pipeline? (thegrid) */ /* 0x31: sync pipeline? (thegrid) */
@ -933,7 +919,7 @@ static int zeus_fifo_process(running_machine &machine, const UINT32 *data, int n
* *
*************************************/ *************************************/
static void zeus_draw_model(running_machine &machine, UINT32 baseaddr, UINT16 count, int logit) void midzeus2_state::zeus2_draw_model(UINT32 baseaddr, UINT16 count, int logit)
{ {
UINT32 databuffer[32]; UINT32 databuffer[32];
int databufcount = 0; int databufcount = 0;
@ -1005,11 +991,11 @@ static void zeus_draw_model(running_machine &machine, UINT32 baseaddr, UINT16 co
case 0x36: /* crusnexo */ case 0x36: /* crusnexo */
if (logit) if (logit)
logerror("reg32"); logerror("reg32");
zeus_register32_w(machine, (databuffer[0] >> 16) & 0x7f, databuffer[1], logit); zeus2_register32_w((databuffer[0] >> 16) & 0x7f, databuffer[1], logit);
break; break;
case 0x38: /* crusnexo/thegrid */ case 0x38: /* crusnexo/thegrid */
zeus_draw_quad(machine, databuffer, texoffs, logit); zeus2_draw_quad(databuffer, texoffs, logit);
break; break;
default: default:
@ -1038,9 +1024,8 @@ static void zeus_draw_model(running_machine &machine, UINT32 baseaddr, UINT16 co
* *
*************************************/ *************************************/
static void zeus_draw_quad(running_machine &machine, const UINT32 *databuffer, UINT32 texoffs, int logit) void midzeus2_state::zeus2_draw_quad(const UINT32 *databuffer, UINT32 texoffs, int logit)
{ {
midzeus_state *state = machine.driver_data<midzeus_state>();
poly_draw_scanline_func callback; poly_draw_scanline_func callback;
poly_extra_data *extra; poly_extra_data *extra;
poly_vertex clipvert[8]; poly_vertex clipvert[8];
@ -1057,15 +1042,15 @@ static void zeus_draw_quad(running_machine &machine, const UINT32 *databuffer, U
if (logit) if (logit)
logerror("quad\n"); logerror("quad\n");
if (machine.input().code_pressed(KEYCODE_Q) && (texoffs & 0xffff) == 0x119) return; if (machine().input().code_pressed(KEYCODE_Q) && (texoffs & 0xffff) == 0x119) return;
if (machine.input().code_pressed(KEYCODE_E) && (texoffs & 0xffff) == 0x01d) return; if (machine().input().code_pressed(KEYCODE_E) && (texoffs & 0xffff) == 0x01d) return;
if (machine.input().code_pressed(KEYCODE_R) && (texoffs & 0xffff) == 0x11d) return; if (machine().input().code_pressed(KEYCODE_R) && (texoffs & 0xffff) == 0x11d) return;
if (machine.input().code_pressed(KEYCODE_T) && (texoffs & 0xffff) == 0x05d) return; if (machine().input().code_pressed(KEYCODE_T) && (texoffs & 0xffff) == 0x05d) return;
if (machine.input().code_pressed(KEYCODE_Y) && (texoffs & 0xffff) == 0x0dd) return; if (machine().input().code_pressed(KEYCODE_Y) && (texoffs & 0xffff) == 0x0dd) return;
//if (machine.input().code_pressed(KEYCODE_U) && (texoffs & 0xffff) == 0x119) return; //if (machine().input().code_pressed(KEYCODE_U) && (texoffs & 0xffff) == 0x119) return;
//if (machine.input().code_pressed(KEYCODE_I) && (texoffs & 0xffff) == 0x119) return; //if (machine().input().code_pressed(KEYCODE_I) && (texoffs & 0xffff) == 0x119) return;
//if (machine.input().code_pressed(KEYCODE_O) && (texoffs & 0xffff) == 0x119) return; //if (machine().input().code_pressed(KEYCODE_O) && (texoffs & 0xffff) == 0x119) return;
//if (machine.input().code_pressed(KEYCODE_L) && (texoffs & 0x100)) return; //if (machine().input().code_pressed(KEYCODE_L) && (texoffs & 0x100)) return;
callback = render_poly_8bit; callback = render_poly_8bit;
@ -1252,12 +1237,12 @@ In memory:
} }
} }
extra->solidcolor = 0;//state->m_zeusbase[0x00] & 0x7fff; extra->solidcolor = 0;//m_zeusbase[0x00] & 0x7fff;
extra->zoffset = 0;//state->m_zeusbase[0x7e] >> 16; extra->zoffset = 0;//m_zeusbase[0x7e] >> 16;
extra->alpha = 0;//state->m_zeusbase[0x4e]; extra->alpha = 0;//m_zeusbase[0x4e];
extra->transcolor = 0x100;//((databuffer[1] >> 16) & 1) ? 0 : 0x100; extra->transcolor = 0x100;//((databuffer[1] >> 16) & 1) ? 0 : 0x100;
extra->texbase = WAVERAM_BLOCK0(zeus_texbase); extra->texbase = WAVERAM_BLOCK0(zeus_texbase);
extra->palbase = waveram0_ptr_from_expanded_addr(state->m_zeusbase[0x41]); extra->palbase = waveram0_ptr_from_expanded_addr(m_zeusbase[0x41]);
poly_render_quad_fan(poly, NULL, zeus_cliprect, callback, 4, numverts, &clipvert[0]); poly_render_quad_fan(poly, NULL, zeus_cliprect, callback, 4, numverts, &clipvert[0]);
} }
@ -1334,7 +1319,7 @@ static void render_poly_8bit(void *dest, INT32 scanline, const poly_extent *exte
* *
*************************************/ *************************************/
static void log_fifo_command(const UINT32 *data, int numwords, const char *suffix) void midzeus2_state::log_fifo_command(const UINT32 *data, int numwords, const char *suffix)
{ {
int wordnum; int wordnum;
@ -1344,46 +1329,3 @@ static void log_fifo_command(const UINT32 *data, int numwords, const char *suffi
logerror("%s", suffix); logerror("%s", suffix);
} }
#if 0
static void log_waveram(UINT32 base, UINT16 length)
{
static struct
{
UINT32 base;
UINT16 length;
UINT32 checksum;
} recent_entries[100];
UINT32 numoctets = length + 1;
const void *ptr = waveram0_ptr_from_expanded_addr(base);
UINT32 checksum = base | ((UINT64)length << 32);
int foundit = FALSE;
int i;
for (i = 0; i < numoctets; i++)
checksum += WAVERAM_READ32(ptr, i*2) + WAVERAM_READ32(ptr, i*2+1);
for (i = 0; i < ARRAY_LENGTH(recent_entries); i++)
if (recent_entries[i].base == base && recent_entries[i].length == length && recent_entries[i].checksum == checksum)
{
foundit = TRUE;
break;
}
if (i == ARRAY_LENGTH(recent_entries))
i--;
if (i != 0)
{
memmove(&recent_entries[1], &recent_entries[0], i * sizeof(recent_entries[0]));
recent_entries[0].base = base;
recent_entries[0].length = length;
recent_entries[0].checksum = checksum;
}
if (foundit)
return;
for (i = 0; i < numoctets; i++)
logerror("\t%02X: %08X %08X\n", i, WAVERAM_READ32(ptr, i*2), WAVERAM_READ32(ptr, i*2+1));
}
#endif