summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Ville Linde <villelin@mamedev.org>2012-07-28 18:43:19 +0000
committer Ville Linde <villelin@mamedev.org>2012-07-28 18:43:19 +0000
commit6780d718caef925ea178e673d1cb97327c93845f (patch)
tree5d73f6507cd1b6cc1f00c51e513fa87942ca5ea9 /src
parent3ae8987c2ce6a538dfcbf5ea73982794f2c8149f (diff)
cobra.c: Moved FIFOs into a class.
Diffstat (limited to 'src')
-rw-r--r--src/mame/drivers/cobra.c534
1 files changed, 251 insertions, 283 deletions
diff --git a/src/mame/drivers/cobra.c b/src/mame/drivers/cobra.c
index 487c0a01a61..e40cfe2257f 100644
--- a/src/mame/drivers/cobra.c
+++ b/src/mame/drivers/cobra.c
@@ -9,9 +9,10 @@
#include "video/polynew.h"
#include "sound/rf5c400.h"
-#define ENABLE_MAIN_CPU 1
-#define ENABLE_SUB_CPU 1
-#define ENABLE_GFX_CPU 1
+#define GFXFIFO_IN_VERBOSE 0
+#define GFXFIFO_OUT_VERBOSE 0
+#define M2SFIFO_VERBOSE 0
+#define S2MFIFO_VERBOSE 0
struct cobra_polydata
{
@@ -45,6 +46,42 @@ private:
int m_texture_height;
};
+class cobra_fifo
+{
+public:
+ cobra_fifo(running_machine &machine, int capacity, const char *name, bool verbose)
+ {
+ m_data = auto_alloc_array(machine, UINT64, capacity);
+
+ m_name = name;
+ m_size = capacity;
+ m_wpos = 0;
+ m_rpos = 0;
+ m_num = 0;
+
+ m_verbose = verbose;
+ }
+
+ void push(const device_t *cpu, UINT64 data);
+ bool pop(const device_t *cpu, UINT64 *result);
+ bool pop_float(const device_t *cpu, float *result);
+ int current_num();
+ int space_left();
+ bool is_empty();
+ bool is_half_full();
+ bool is_full();
+ void flush();
+
+private:
+ int m_size;
+ int m_wpos;
+ int m_rpos;
+ int m_num;
+ bool m_verbose;
+ const char *m_name;
+ UINT64 *m_data;
+};
+
class cobra_state : public driver_device
{
public:
@@ -97,6 +134,11 @@ public:
cobra_renderer *m_renderer;
+ cobra_fifo *m_gfxfifo_in;
+ cobra_fifo *m_gfxfifo_out;
+ cobra_fifo *m_m2sfifo;
+ cobra_fifo *m_s2mfifo;
+
int m2sfifo_unk_flag;
int s2mfifo_unk_flag;
@@ -268,45 +310,9 @@ static int decode_debug_state_value(int v)
}
-#define MAX_FIFOS 32
-
-static void fifo_init(running_machine &machine, int id, int size, const char *name, int debug);
-static void fifo_push(const device_t *cpu, int id, UINT64 data);
-static int fifo_pop(const device_t *cpu, int id, UINT64 *result);
-static int fifo_pop_float(const device_t *cpu, int id, float *result);
-//static UINT64 fifo_peek_top(int id);
-//static UINT64 fifo_peek_next(int id);
-static int fifo_current_num(int id);
-static int fifo_space_left(int id);
-
-typedef struct
-{
- UINT64 *data;
- int fifo_size;
- int fifo_wpos;
- int fifo_rpos;
- int fifo_num;
- int verbose;
- char *name;
-} FIFO;
-
-static FIFO fifo[MAX_FIFOS];
-
-static void fifo_init(running_machine &machine, int id, int size, const char *name, int verbose)
+void cobra_fifo::push(const device_t *cpu, UINT64 data)
{
- fifo[id].data = auto_alloc_array(machine, UINT64, size);
- fifo[id].fifo_wpos = 0;
- fifo[id].fifo_rpos = 0;
- fifo[id].fifo_num = 0;
- fifo[id].fifo_size = size;
-
- fifo[id].verbose = verbose;
- fifo[id].name = (char*)name;
-}
-
-static void fifo_push(const device_t *cpu, int id, UINT64 data)
-{
- if (fifo[id].verbose)
+ if (m_verbose)
{
char accessor_location[50];
if (cpu != NULL)
@@ -320,80 +326,86 @@ static void fifo_push(const device_t *cpu, int id, UINT64 data)
sprintf(accessor_location, "(non-cpu)");
}
- printf("%s: push %08X%08X (%d) at %s\n", fifo[id].name, (UINT32)(data >> 32), (UINT32)(data), fifo[id].fifo_num, accessor_location);
+ printf("%s: push %08X%08X (%d) at %s\n", m_name, (UINT32)(data >> 32), (UINT32)(data), m_num, accessor_location);
}
- if (fifo[id].fifo_num == fifo[id].fifo_size)
+ if (m_num == m_size)
{
- int i, j;
- char accessor_location[50];
- if (cpu != NULL)
- {
- // cpu has a name and a PC
- sprintf(accessor_location, "(%s) %08X", cpu->tag(), cpu_get_pc((device_t *)cpu));
- }
- else
+ if (m_verbose)
{
- // non-cpu
- sprintf(accessor_location, "(non-cpu)");
- }
+ int i, j;
+ char accessor_location[50];
+ if (cpu != NULL)
+ {
+ // cpu has a name and a PC
+ sprintf(accessor_location, "(%s) %08X", cpu->tag(), cpu_get_pc((device_t *)cpu));
+ }
+ else
+ {
+ // non-cpu
+ sprintf(accessor_location, "(non-cpu)");
+ }
- printf("%s overflow at %s\n", fifo[id].name, accessor_location);
- printf("%s dump:\n", fifo[id].name);
+ printf("%s overflow at %s\n", m_name, accessor_location);
+ printf("%s dump:\n", m_name);
- for (j=0; j < 128; j+=4)
- {
- printf(" ");
- for (i=0; i < 4; i++)
+ for (j=0; j < 128; j+=4)
{
- UINT64 val = 0;
- fifo_pop(cpu, id, &val);
- printf("%08X ", (UINT32)(val));
+ printf(" ");
+ for (i=0; i < 4; i++)
+ {
+ UINT64 val = 0;
+ pop(cpu, &val);
+ printf("%08X ", (UINT32)(val));
+ }
+ printf("\n");
}
printf("\n");
}
- logerror("\n");
return;
}
- fifo[id].data[fifo[id].fifo_wpos] = data;
+ m_data[m_wpos] = data;
- fifo[id].fifo_wpos++;
+ m_wpos++;
- if (fifo[id].fifo_wpos == fifo[id].fifo_size)
+ if (m_wpos == m_size)
{
- fifo[id].fifo_wpos = 0;
+ m_wpos = 0;
}
- fifo[id].fifo_num++;
+ m_num++;
}
-static int fifo_pop(const device_t *cpu, int id, UINT64 *result)
+bool cobra_fifo::pop(const device_t *cpu, UINT64 *result)
{
UINT64 r;
- if (fifo[id].fifo_num == 0)
+ if (m_num == 0)
{
- char accessor_location[50];
- if (cpu != NULL)
+ if (m_verbose)
{
- // cpu has a name and a PC
- sprintf(accessor_location, "(%s) %08X", cpu->tag(), cpu_get_pc((device_t *)cpu));
- }
- else
- {
- // non-cpu
- sprintf(accessor_location, "(non-cpu)");
- }
+ char accessor_location[50];
+ if (cpu != NULL)
+ {
+ // cpu has a name and a PC
+ sprintf(accessor_location, "(%s) %08X", cpu->tag(), cpu_get_pc((device_t *)cpu));
+ }
+ else
+ {
+ // non-cpu
+ sprintf(accessor_location, "(non-cpu)");
+ }
- logerror("%s underflow at %s\n", fifo[id].name, accessor_location);
- return 0;
+ printf("%s underflow at %s\n", m_name, accessor_location);
+ }
+ return false;
}
- r = fifo[id].data[fifo[id].fifo_rpos];
+ r = m_data[m_rpos];
- if (fifo[id].verbose)
+ if (m_verbose)
{
char accessor_location[50];
if (cpu != NULL)
@@ -407,94 +419,64 @@ static int fifo_pop(const device_t *cpu, int id, UINT64 *result)
sprintf(accessor_location, "(non-cpu)");
}
- printf("%s: pop %08X%08X (%d) at %s\n", fifo[id].name, (UINT32)(r >> 32), (UINT32)(r), fifo[id].fifo_num-1, accessor_location);
+ printf("%s: pop %08X%08X (%d) at %s\n", m_name, (UINT32)(r >> 32), (UINT32)(r), m_num-1, accessor_location);
}
- fifo[id].fifo_rpos++;
+ m_rpos++;
- if (fifo[id].fifo_rpos == fifo[id].fifo_size)
+ if (m_rpos == m_size)
{
- fifo[id].fifo_rpos = 0;
+ m_rpos = 0;
}
- fifo[id].fifo_num--;
+ m_num--;
*result = r;
- return 1;
+ return true;
}
-static int fifo_pop_float(const device_t *cpu, int id, float *result)
+bool cobra_fifo::pop_float(const device_t *cpu, float *result)
{
UINT64 value = 0;
- int status = fifo_pop(cpu, id, &value);
+ bool status = pop(cpu, &value);
*result = u2f((UINT32)(value));
return status;
}
-/*static UINT64 fifo_peek_top(int id)
-{
- return fifo[id].data[fifo[id].fifo_rpos];
-}
-
-static UINT64 fifo_peek_next(int id)
-{
- int pos = fifo[id].fifo_rpos + 1;
-
- if (pos == fifo[id].fifo_size)
- {
- pos = 0;
- }
-
- return fifo[id].data[pos];
-}*/
-
-static int fifo_current_num(int id)
+int cobra_fifo::current_num()
{
- return fifo[id].fifo_num;
+ return m_num;
}
-static int fifo_space_left(int id)
+int cobra_fifo::space_left()
{
- return fifo[id].fifo_size - fifo[id].fifo_num;
+ return m_size - m_num;
}
-static int fifo_is_empty(int id)
+bool cobra_fifo::is_empty()
{
- return (fifo[id].fifo_num == 0) ? 1 : 0;
+ return (m_num == 0);
}
-static int fifo_is_half_full(int id)
+bool cobra_fifo::is_half_full()
{
- return (fifo[id].fifo_num > (fifo[id].fifo_size / 2)) ? 1 : 0;
+ return (m_num > (m_size / 2));
}
-static int fifo_is_full(int id)
+bool cobra_fifo::is_full()
{
- return (fifo[id].fifo_num >= fifo[id].fifo_size) ? 1 : 0;
+ return (m_num >= m_size);
}
-static void fifo_flush(int id)
+void cobra_fifo::flush()
{
- fifo[id].fifo_num = 0;
- fifo[id].fifo_rpos = 0;
- fifo[id].fifo_wpos = 0;
+ m_num = 0;
+ m_rpos = 0;
+ m_wpos = 0;
}
-// FIFO id's
-
-#define GFXFIFO_IN 0
-#define GFXFIFO_OUT 1
-#define M2SFIFO 2 // main to sub FIFO
-#define S2MFIFO 3 // sub to main FIFO
-
-#define GFXFIFO_IN_VERBOSE 0
-#define GFXFIFO_OUT_VERBOSE 0
-#define M2SFIFO_VERBOSE 0
-#define S2MFIFO_VERBOSE 0
-
-
/*****************************************************************************/
/*****************************************************************************/
@@ -521,8 +503,6 @@ static void fifo_flush(int id)
// RPA: 0x8010C000
-#if ENABLE_MAIN_CPU
-
static UINT32 mpc106_regs[256/4];
static UINT32 mpc106_pci_r(device_t *busdevice, device_t *device, int function, int reg, UINT32 mem_mask)
{
@@ -575,13 +555,13 @@ READ64_MEMBER(cobra_state::main_fifo_r)
// x S2M FIFO half-full flag
int value = 0x00;
- value |= fifo_is_full(M2SFIFO) ? 0x00 : 0x01;
- value |= fifo_is_empty(M2SFIFO) ? 0x00 : 0x02;
- value |= fifo_is_half_full(M2SFIFO) ? 0x00 : 0x04;
+ value |= m_m2sfifo->is_full() ? 0x00 : 0x01;
+ value |= m_m2sfifo->is_empty() ? 0x00 : 0x02;
+ value |= m_m2sfifo->is_half_full() ? 0x00 : 0x04;
- value |= fifo_is_full(S2MFIFO) ? 0x00 : 0x10;
- value |= fifo_is_empty(S2MFIFO) ? 0x00 : 0x20;
- value |= fifo_is_half_full(S2MFIFO) ? 0x00 : 0x40;
+ value |= m_s2mfifo->is_full() ? 0x00 : 0x10;
+ value |= m_s2mfifo->is_empty() ? 0x00 : 0x20;
+ value |= m_s2mfifo->is_half_full() ? 0x00 : 0x40;
value |= m_comram_page ? 0x80 : 0x00;
@@ -598,13 +578,13 @@ READ64_MEMBER(cobra_state::main_fifo_r)
// Sub-to-Main FIFO read data
UINT64 value;
- fifo_pop(&space.device(), S2MFIFO, &value);
+ m_s2mfifo->pop(&space.device(), &value);
- if (fifo_is_empty(S2MFIFO))
+ if (m_s2mfifo->is_empty())
{
s2mfifo_unk_flag = 1;
}
- else if (fifo_is_full(S2MFIFO))
+ else if (m_s2mfifo->is_full())
{
s2mfifo_unk_flag = 0;
}
@@ -632,11 +612,11 @@ READ64_MEMBER(cobra_state::main_fifo_r)
int value = 0x01;
//value |= s2mfifo_unk_flag ? 0x2 : 0x0;
- if (fifo_is_empty(S2MFIFO))
+ if (m_s2mfifo->is_empty())
{
value |= 0x2;
}
- else if (!fifo_is_full(S2MFIFO) && !fifo_is_half_full(S2MFIFO))
+ else if (!m_s2mfifo->is_full() && !m_s2mfifo->is_half_full())
{
//value |= s2mfifo_unk_flag ? 0x2 : 0x0;
}
@@ -660,7 +640,7 @@ WRITE64_MEMBER(cobra_state::main_fifo_w)
//printf("MAIN: M2S FIFO data write %02X\n", (UINT8)(data >> 40) & 0xff);
- fifo_push(&space.device(), M2SFIFO, (UINT8)(data >> 40));
+ m_m2sfifo->push(&space.device(), (UINT8)(data >> 40));
cputag_set_input_line(space.machine(), "subcpu", INPUT_LINE_IRQ0, ASSERT_LINE);
@@ -674,9 +654,9 @@ WRITE64_MEMBER(cobra_state::main_fifo_w)
// Register 0xffff0003:
// Main-to-Sub FIFO unknown
- if (!fifo_is_empty(M2SFIFO))
+ if (!m_m2sfifo->is_empty())
{
- if (fifo_is_half_full(M2SFIFO))
+ if (m_m2sfifo->is_half_full())
{
m2sfifo_unk_flag = 0x8;
}
@@ -762,13 +742,10 @@ static ADDRESS_MAP_START( cobra_main_map, AS_PROGRAM, 64, cobra_state )
AM_RANGE(0xffff0000, 0xffff0007) AM_READWRITE(main_fifo_r, main_fifo_w)
ADDRESS_MAP_END
-#endif // ENABLE_MAIN_CPU
/*****************************************************************************/
// Sub board (PPC403)
-#if ENABLE_SUB_CPU
-
//static int ucount = 0;
READ32_MEMBER(cobra_state::sub_unk1_r)
@@ -810,9 +787,9 @@ READ32_MEMBER(cobra_state::sub_mainbd_r)
// M2S FIFO read
UINT64 value;
- fifo_pop(&space.device(), M2SFIFO, &value);
+ m_m2sfifo->pop(&space.device(), &value);
- if (fifo_is_empty(M2SFIFO))
+ if (m_m2sfifo->is_empty())
{
// cputag_set_input_line(space.machine(), "subcpu", INPUT_LINE_IRQ0, CLEAR_LINE);
@@ -847,13 +824,13 @@ READ32_MEMBER(cobra_state::sub_mainbd_r)
// x M2S FIFO half-full flag
UINT32 value = 0x00;
- value |= fifo_is_full(S2MFIFO) ? 0x00 : 0x01;
- value |= fifo_is_empty(S2MFIFO) ? 0x00 : 0x02;
- value |= fifo_is_half_full(S2MFIFO) ? 0x00 : 0x04;
+ value |= m_s2mfifo->is_full() ? 0x00 : 0x01;
+ value |= m_s2mfifo->is_empty() ? 0x00 : 0x02;
+ value |= m_s2mfifo->is_half_full() ? 0x00 : 0x04;
- value |= fifo_is_full(M2SFIFO) ? 0x00 : 0x10;
- value |= fifo_is_empty(M2SFIFO) ? 0x00 : 0x20;
- value |= fifo_is_half_full(M2SFIFO) ? 0x00 : 0x40;
+ value |= m_m2sfifo->is_full() ? 0x00 : 0x10;
+ value |= m_m2sfifo->is_empty() ? 0x00 : 0x20;
+ value |= m_m2sfifo->is_half_full() ? 0x00 : 0x40;
value |= m_comram_page ? 0x80 : 0x00;
@@ -870,15 +847,15 @@ WRITE32_MEMBER(cobra_state::sub_mainbd_w)
// Register 0x7E380000
// Sub-to-Main FIFO data
- fifo_push(&space.device(), S2MFIFO, (UINT8)(data >> 24));
+ m_s2mfifo->push(&space.device(), (UINT8)(data >> 24));
}
if (ACCESSING_BITS_16_23)
{
// Register 0x7E380001
- if (!fifo_is_empty(S2MFIFO))
+ if (!m_s2mfifo->is_empty())
{
- if (fifo_is_half_full(S2MFIFO))
+ if (m_s2mfifo->is_half_full())
{
s2mfifo_unk_flag = 1;
}
@@ -1110,7 +1087,6 @@ static ADDRESS_MAP_START( cobra_sub_map, AS_PROGRAM, 32, cobra_state )
AM_RANGE(0x7ff80000, 0x7fffffff) AM_MIRROR(0x80000000) AM_ROM AM_REGION("user2", 0) /* Boot ROM */
ADDRESS_MAP_END
-#endif // ENABLE_SUB_CPU
/*****************************************************************************/
// Graphics board (PPC604)
@@ -1141,7 +1117,6 @@ ADDRESS_MAP_END
// SR8: 0x00000008 SR9: 0x00000009 SR10: 0x0000000a SR11: 0x0000000b
// SR12: 0x0000000c SR13: 0x0000000d SR14: 0x0000000e SR15: 0x0000000f
-#if ENABLE_GFX_CPU
#define RE_STATUS_IDLE 0
#define RE_STATUS_COMMAND 1
@@ -1166,15 +1141,18 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
const rectangle visarea = machine.primary_screen->visible_area();
- while (fifo_current_num(GFXFIFO_IN) >= 2)
+ cobra_fifo *fifo_in = cobra->m_gfxfifo_in;
+ cobra_fifo *fifo_out = cobra->m_gfxfifo_out;
+
+ while (fifo_in->current_num() >= 2)
{
UINT64 in1, in2 = 0;
UINT32 w1, w2;
if (cobra->m_gfx_re_status == RE_STATUS_IDLE)
{
- fifo_pop(NULL, GFXFIFO_IN, &in1);
- fifo_pop(NULL, GFXFIFO_IN, &in2);
+ fifo_in->pop(NULL, &in1);
+ fifo_in->pop(NULL, &in2);
w1 = (UINT32)(in1);
w2 = (UINT32)(in2);
@@ -1206,7 +1184,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
UINT64 param[6];
UINT32 w[6];
- if (fifo_current_num(GFXFIFO_IN) < 6)
+ if (fifo_in->current_num() < 6)
{
// wait until there's enough data in FIFO
memset(param, 0, sizeof(param));
@@ -1214,12 +1192,12 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
return;
}
- fifo_pop(NULL, GFXFIFO_IN, &param[0]);
- fifo_pop(NULL, GFXFIFO_IN, &param[1]);
- fifo_pop(NULL, GFXFIFO_IN, &param[2]);
- fifo_pop(NULL, GFXFIFO_IN, &param[3]);
- fifo_pop(NULL, GFXFIFO_IN, &param[4]);
- fifo_pop(NULL, GFXFIFO_IN, &param[5]);
+ fifo_in->pop(NULL, &param[0]);
+ fifo_in->pop(NULL, &param[1]);
+ fifo_in->pop(NULL, &param[2]);
+ fifo_in->pop(NULL, &param[3]);
+ fifo_in->pop(NULL, &param[4]);
+ fifo_in->pop(NULL, &param[5]);
w[0] = (UINT32)param[0]; w[1] = (UINT32)param[1]; w[2] = (UINT32)param[2];
w[3] = (UINT32)param[3]; w[4] = (UINT32)param[4]; w[5] = (UINT32)param[5];
@@ -1262,7 +1240,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
// check_mergebus_self(): 0x0F600000 0x10520C00
- if (fifo_current_num(GFXFIFO_IN) < 6)
+ if (fifo_in->current_num() < 6)
{
// wait until there's enough data in FIFO
return;
@@ -1275,19 +1253,19 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
printf("gfxfifo_exec: unhandled %08X %08X\n", w1, w2);
- fifo_pop(NULL, GFXFIFO_IN, &in3);
- fifo_pop(NULL, GFXFIFO_IN, &in4);
- fifo_pop(NULL, GFXFIFO_IN, &ignore);
- fifo_pop(NULL, GFXFIFO_IN, &ignore);
- fifo_pop(NULL, GFXFIFO_IN, &ignore);
- fifo_pop(NULL, GFXFIFO_IN, &ignore);
+ fifo_in->pop(NULL, &in3);
+ fifo_in->pop(NULL, &in4);
+ fifo_in->pop(NULL, &ignore);
+ fifo_in->pop(NULL, &ignore);
+ fifo_in->pop(NULL, &ignore);
+ fifo_in->pop(NULL, &ignore);
if (w1 == 0x0f600000 && w2 == 0x10520c00)
{
- fifo_push(NULL, GFXFIFO_OUT, w1);
- fifo_push(NULL, GFXFIFO_OUT, w2);
- fifo_push(NULL, GFXFIFO_OUT, in3);
- fifo_push(NULL, GFXFIFO_OUT, in4);
+ fifo_out->push(NULL, w1);
+ fifo_out->push(NULL, w2);
+ fifo_out->push(NULL, in3);
+ fifo_out->push(NULL, in4);
}
cobra->m_gfx_re_status = RE_STATUS_IDLE;
@@ -1417,10 +1395,10 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
{
int c = 0;
printf("gfxfifo_exec: E0 unhandled %08X %08X\n", w1, w2);
- while (fifo_current_num(GFXFIFO_IN) > 0)
+ while (fifo_in->current_num() > 0)
{
UINT64 param;
- fifo_pop(NULL, GFXFIFO_IN, &param);
+ fifo_in->pop(NULL, &param);
if (c == 0)
printf(" ");
@@ -1437,7 +1415,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
logerror("\n");
}
- if (fifo_current_num(GFXFIFO_IN) < num)
+ if (fifo_in->current_num() < num)
{
// wait until there's enough data in FIFO
return;
@@ -1446,7 +1424,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
// make sure the FIFO has fresh data at top...
- fifo_flush(GFXFIFO_OUT);
+ fifo_out->flush();
if (w1 == 0xe0c00004 && w2 == 0x18f803c1)
{
@@ -1456,21 +1434,21 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
for (i=0; i < 4; i++)
{
UINT64 in;
- fifo_pop_float(NULL, GFXFIFO_IN, &vert[i].x); // X coord
- fifo_pop_float(NULL, GFXFIFO_IN, &vert[i].y); // Y coord
+ fifo_in->pop_float(NULL, &vert[i].x); // X coord
+ fifo_in->pop_float(NULL, &vert[i].y); // Y coord
- fifo_pop(NULL, GFXFIFO_IN, &in);
- fifo_pop(NULL, GFXFIFO_IN, &in);
- fifo_pop(NULL, GFXFIFO_IN, &in);
+ fifo_in->pop(NULL, &in);
+ fifo_in->pop(NULL, &in);
+ fifo_in->pop(NULL, &in);
- fifo_pop_float(NULL, GFXFIFO_IN, &vert[i].p[0]); // texture U coord
- fifo_pop_float(NULL, GFXFIFO_IN, &vert[i].p[1]); // texture V coord
+ fifo_in->pop_float(NULL, &vert[i].p[0]); // texture U coord
+ fifo_in->pop_float(NULL, &vert[i].p[1]); // texture V coord
- fifo_pop(NULL, GFXFIFO_IN, &in);
- fifo_pop(NULL, GFXFIFO_IN, &in);
- fifo_pop(NULL, GFXFIFO_IN, &in);
- fifo_pop(NULL, GFXFIFO_IN, &in);
- fifo_pop(NULL, GFXFIFO_IN, &in);
+ fifo_in->pop(NULL, &in);
+ fifo_in->pop(NULL, &in);
+ fifo_in->pop(NULL, &in);
+ fifo_in->pop(NULL, &in);
+ fifo_in->pop(NULL, &in);
}
render_delegate rd = render_delegate(FUNC(cobra_renderer::render_texture_scan), this);
@@ -1488,17 +1466,17 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
{
UINT64 in;
- fifo_pop(NULL, GFXFIFO_IN, &in); // ? seen values 0x10 and 0x100 (start and end markers?)
- fifo_pop_float(NULL, GFXFIFO_IN, &vert[j].x); // X coord
- fifo_pop_float(NULL, GFXFIFO_IN, &vert[j].y); // Y coord
- fifo_pop(NULL, GFXFIFO_IN, &in); // ? only 0 so far (Z coord?)
-
- fifo_pop(NULL, GFXFIFO_IN, &in); // ? only 1.0f so far
- fifo_pop(NULL, GFXFIFO_IN, &in); // ? only 1.0f so far
- fifo_pop(NULL, GFXFIFO_IN, &in); // ? only 1.0f so far
- fifo_pop(NULL, GFXFIFO_IN, &in); // ? only 1.0f so far
- fifo_pop(NULL, GFXFIFO_IN, &in); // ? only 1.0f so far
- fifo_pop(NULL, GFXFIFO_IN, &in); // ? only 0 so far
+ fifo_in->pop(NULL, &in); // ? seen values 0x10 and 0x100 (start and end markers?)
+ fifo_in->pop_float(NULL, &vert[j].x); // X coord
+ fifo_in->pop_float(NULL, &vert[j].y); // Y coord
+ fifo_in->pop(NULL, &in); // ? only 0 so far (Z coord?)
+
+ fifo_in->pop(NULL, &in); // ? only 1.0f so far
+ fifo_in->pop(NULL, &in); // ? only 1.0f so far
+ fifo_in->pop(NULL, &in); // ? only 1.0f so far
+ fifo_in->pop(NULL, &in); // ? only 1.0f so far
+ fifo_in->pop(NULL, &in); // ? only 1.0f so far
+ fifo_in->pop(NULL, &in); // ? only 0 so far
}
draw_line(visarea, vert[0], vert[1]);
@@ -1512,22 +1490,22 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
for (i=0; i < 3; i++)
{
UINT64 in = 0;
- fifo_pop(NULL, GFXFIFO_IN, &in);
+ fifo_in->pop(NULL, &in);
- fifo_pop(NULL, GFXFIFO_IN, &in);
+ fifo_in->pop(NULL, &in);
vert[i].x = (u2f((UINT32)(in)) / 8.0f) + 256.0f;
- fifo_pop(NULL, GFXFIFO_IN, &in);
+ fifo_in->pop(NULL, &in);
vert[i].y = (u2f((UINT32)(in)) / 8.0f) + 192.0f;
- fifo_pop(NULL, GFXFIFO_IN, &in);
+ fifo_in->pop(NULL, &in);
- fifo_pop(NULL, GFXFIFO_IN, &in);
- fifo_pop(NULL, GFXFIFO_IN, &in);
- fifo_pop(NULL, GFXFIFO_IN, &in);
- fifo_pop(NULL, GFXFIFO_IN, &in);
+ fifo_in->pop(NULL, &in);
+ fifo_in->pop(NULL, &in);
+ fifo_in->pop(NULL, &in);
+ fifo_in->pop(NULL, &in);
}
render_delegate rd = render_delegate(FUNC(cobra_renderer::render_texture_scan), this);
@@ -1540,12 +1518,12 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
for (i=0; i < num; i+=2)
{
UINT64 in3 = 0, in4 = 0;
- fifo_pop(NULL, GFXFIFO_IN, &in3);
- fifo_pop(NULL, GFXFIFO_IN, &in4);
+ fifo_in->pop(NULL, &in3);
+ fifo_in->pop(NULL, &in4);
printf(" %08X %08X (%f, %f)\n", (UINT32)(in3), (UINT32)(in4), u2f((UINT32)(in3)), u2f((UINT32)(in4)));
- fifo_push(NULL, GFXFIFO_OUT, (UINT32)(in3));
- fifo_push(NULL, GFXFIFO_OUT, (UINT32)(in4));
+ fifo_out->push(NULL, (UINT32)(in3));
+ fifo_out->push(NULL, (UINT32)(in4));
}
}
@@ -1559,7 +1537,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
int i;
// int c=0;
- if (fifo_current_num(GFXFIFO_IN) < num)
+ if (fifo_in->current_num() < num)
{
// wait until there's enough data in FIFO
return;
@@ -1580,7 +1558,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
for (i=0; i < num; i++)
{
UINT64 param;
- fifo_pop(NULL, GFXFIFO_IN, &param);
+ fifo_in->pop(NULL, &param);
/*if (c == 0)
printf(" ");
@@ -1610,10 +1588,10 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
printf("GFX: E9 on X: %d, Y: %d\n", x, y);
}*/
- fifo_push(NULL, GFXFIFO_OUT, 0);
- fifo_push(NULL, GFXFIFO_OUT, 0);
- fifo_push(NULL, GFXFIFO_OUT, 0);
- fifo_push(NULL, GFXFIFO_OUT, 0);
+ fifo_out->push(NULL, 0);
+ fifo_out->push(NULL, 0);
+ fifo_out->push(NULL, 0);
+ fifo_out->push(NULL, 0);
cobra->m_gfx_re_status = RE_STATUS_IDLE;
break;
@@ -1639,7 +1617,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
int num = w2;
int i;
- if (fifo_current_num(GFXFIFO_IN) < num)
+ if (fifo_in->current_num() < num)
{
return;
}
@@ -1667,7 +1645,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
for (i = 0; i < num; i++)
{
UINT64 value = 0;
- fifo_pop(NULL, GFXFIFO_IN, &value);
+ fifo_in->pop(NULL, &value);
cobra->m_gfx_gram[reg + (i*4) + 0] = (value >> 24) & 0xff;
cobra->m_gfx_gram[reg + (i*4) + 1] = (value >> 16) & 0xff;
@@ -1713,7 +1691,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
ret |= cobra->m_gfx_gram[reg + 2] << 8;
ret |= cobra->m_gfx_gram[reg + 3] << 0;
- fifo_push(NULL, GFXFIFO_OUT, ret);
+ fifo_out->push(NULL, ret);
cobra->m_gfx_re_status = RE_STATUS_IDLE;
break;
@@ -1728,7 +1706,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
int num = w2;
int i;
- if (fifo_space_left(GFXFIFO_OUT) < num)
+ if (fifo_out->space_left() < num)
{
return;
}
@@ -1757,7 +1735,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
value |= cobra->m_gfx_gram[reg + (i*4) + 2] << 8;
value |= cobra->m_gfx_gram[reg + (i*4) + 3] << 0;
- fifo_push(NULL, GFXFIFO_OUT, value);
+ fifo_out->push(NULL, value);
}
cobra->m_gfx_re_status = RE_STATUS_IDLE;
@@ -1776,9 +1754,9 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
int num_left = num - cobra->m_gfx_re_word_count;
int start = cobra->m_gfx_re_word_count;
- if (fifo_current_num(GFXFIFO_IN) < num_left)
+ if (fifo_in->current_num() < num_left)
{
- num_left = fifo_current_num(GFXFIFO_IN);
+ num_left = fifo_in->current_num();
}
@@ -1788,7 +1766,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
for (i=0; i < num_left; i++)
{
UINT64 param;
- fifo_pop(NULL, GFXFIFO_IN, &param);
+ fifo_in->pop(NULL, &param);
cobra->m_gfx_re_word_count++;
}
}
@@ -1799,7 +1777,7 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
for (i=0; i < num_left; i++)
{
UINT64 param = 0;
- fifo_pop(NULL, GFXFIFO_IN, &param);
+ fifo_in->pop(NULL, &param);
cobra->m_gfx_re_word_count++;
m_gfx_texture[start+i] = (UINT32)(param);
@@ -1831,15 +1809,15 @@ void cobra_renderer::gfx_fifo_exec(running_machine &machine)
int c = 0;
printf("gfxfifo_exec: unknown command %08X %08X\n", w1, w2);
- if (fifo_current_num(GFXFIFO_IN) < 0)
+ if (fifo_in->current_num() < 0)
{
return;
}
- while (fifo_current_num(GFXFIFO_IN) > 0)
+ while (fifo_in->current_num() > 0)
{
UINT64 param;
- fifo_pop(NULL, GFXFIFO_IN, &param);
+ fifo_in->pop(NULL, &param);
if (c == 0)
printf(" ");
@@ -1873,7 +1851,7 @@ READ64_MEMBER(cobra_state::gfx_fifo_r)
if (ACCESSING_BITS_32_63)
{
UINT64 data;
- fifo_pop(&space.device(), GFXFIFO_OUT, &data);
+ m_gfxfifo_out->pop(&space.device(), &data);
data &= 0xffffffff;
@@ -1882,7 +1860,7 @@ READ64_MEMBER(cobra_state::gfx_fifo_r)
if (ACCESSING_BITS_0_31)
{
UINT64 data;
- fifo_pop(&space.device(), GFXFIFO_OUT, &data);
+ m_gfxfifo_out->pop(&space.device(), &data);
data &= 0xffffffff;
@@ -1964,12 +1942,12 @@ WRITE64_MEMBER(cobra_state::gfx_unk1_w)
if (value == 0xc0)
{
- fifo_pop(&space.device(), GFXFIFO_IN, &in1);
- fifo_pop(&space.device(), GFXFIFO_IN, &in2);
+ m_gfxfifo_in->pop(&space.device(), &in1);
+ m_gfxfifo_in->pop(&space.device(), &in2);
m_gfx_unknown_v1 = (UINT32)(in1 >> 32); // FIFO number is read back from this same register
- fifo_push(&space.device(), GFXFIFO_OUT, in1 & 0xffffffff);
- fifo_push(&space.device(), GFXFIFO_OUT, in2 & 0xffffffff);
+ m_gfxfifo_out->push(&space.device(), in1 & 0xffffffff);
+ m_gfxfifo_out->push(&space.device(), in2 & 0xffffffff);
}
else if (value == 0x80)
{
@@ -1998,12 +1976,12 @@ WRITE64_MEMBER(cobra_state::gfx_buf_w)
if (data == U64(0x00a0000110500018))
{
- fifo_flush(GFXFIFO_OUT);
+ m_gfxfifo_out->flush();
// reads back the register selected by gfx register select
- fifo_push(&space.device(), GFXFIFO_OUT, (UINT32)((m_gfx_register[m_gfx_register_select] >> 32)));
- fifo_push(&space.device(), GFXFIFO_OUT, (UINT32)(m_gfx_register[m_gfx_register_select]));
+ m_gfxfifo_out->push(&space.device(), (UINT32)((m_gfx_register[m_gfx_register_select] >> 32)));
+ m_gfxfifo_out->push(&space.device(), (UINT32)(m_gfx_register[m_gfx_register_select]));
}
else if (data == U64(0x00a0000110520800))
{
@@ -2012,13 +1990,13 @@ WRITE64_MEMBER(cobra_state::gfx_buf_w)
// the code waits for bit 0x400 to be set
- fifo_push(&space.device(), GFXFIFO_OUT, 0x400);
+ m_gfxfifo_out->push(&space.device(), 0x400);
}
else if (data != U64(0x00a0000110520200))
{
// prc_read always expects a value...
- fifo_push(&space.device(), GFXFIFO_OUT, 0);
+ m_gfxfifo_out->push(&space.device(), 0);
}
}
@@ -2029,15 +2007,16 @@ static void gfx_cpu_dc_store(device_t *device, UINT32 address)
if (address == 0x10000000 || address == 0x18000000 || address == 0x1e000000)
{
UINT64 i = (UINT64)(cobra->m_gfx_fifo_cache_addr) << 32;
+ cobra_fifo *fifo_in = cobra->m_gfxfifo_in;
- fifo_push(device, GFXFIFO_IN, (UINT32)(cobra->m_gfx_fifo_mem[0] >> 32) | i);
- fifo_push(device, GFXFIFO_IN, (UINT32)(cobra->m_gfx_fifo_mem[0] >> 0) | i);
- fifo_push(device, GFXFIFO_IN, (UINT32)(cobra->m_gfx_fifo_mem[1] >> 32) | i);
- fifo_push(device, GFXFIFO_IN, (UINT32)(cobra->m_gfx_fifo_mem[1] >> 0) | i);
- fifo_push(device, GFXFIFO_IN, (UINT32)(cobra->m_gfx_fifo_mem[2] >> 32) | i);
- fifo_push(device, GFXFIFO_IN, (UINT32)(cobra->m_gfx_fifo_mem[2] >> 0) | i);
- fifo_push(device, GFXFIFO_IN, (UINT32)(cobra->m_gfx_fifo_mem[3] >> 32) | i);
- fifo_push(device, GFXFIFO_IN, (UINT32)(cobra->m_gfx_fifo_mem[3] >> 0) | i);
+ fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[0] >> 32) | i);
+ fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[0] >> 0) | i);
+ fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[1] >> 32) | i);
+ fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[1] >> 0) | i);
+ fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[2] >> 32) | i);
+ fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[2] >> 0) | i);
+ fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[3] >> 32) | i);
+ fifo_in->push(device, (UINT32)(cobra->m_gfx_fifo_mem[3] >> 0) | i);
cobra->m_renderer->gfx_fifo_exec(device->machine());
}
@@ -2091,7 +2070,6 @@ static ADDRESS_MAP_START( cobra_gfx_map, AS_PROGRAM, 64, cobra_state )
AM_RANGE(0xffff0010, 0xffff001f) AM_READ(gfx_fifo_r)
ADDRESS_MAP_END
-#endif
/*****************************************************************************/
@@ -2114,23 +2092,19 @@ INPUT_PORTS_END
//};
-#if ENABLE_MAIN_CPU
static powerpc_config main_ppc_cfg =
{
XTAL_66_6667MHz, /* Multiplier 1.5, Bus = 66MHz, Core = 100MHz */
NULL,
NULL
};
-#endif
-#if ENABLE_GFX_CPU
static powerpc_config gfx_ppc_cfg =
{
XTAL_66_6667MHz, /* Multiplier 1.5, Bus = 66MHz, Core = 100MHz */
NULL,
NULL
};
-#endif
static void ide_interrupt(device_t *device, int state)
@@ -2174,23 +2148,17 @@ static MACHINE_RESET( cobra )
static MACHINE_CONFIG_START( cobra, cobra_state )
/* basic machine hardware */
-#if ENABLE_MAIN_CPU
MCFG_CPU_ADD("maincpu", PPC603, 100000000) /* 603EV, 100? MHz */
MCFG_CPU_CONFIG(main_ppc_cfg)
MCFG_CPU_PROGRAM_MAP(cobra_main_map)
MCFG_CPU_VBLANK_INT("screen", cobra_vblank)
-#endif
-#if ENABLE_SUB_CPU
MCFG_CPU_ADD("subcpu", PPC403GA, 33000000) /* 403GA, 33? MHz */
MCFG_CPU_PROGRAM_MAP(cobra_sub_map)
-#endif
-#if ENABLE_GFX_CPU
MCFG_CPU_ADD("gfxcpu", PPC604, 100000000) /* 604, 100? MHz */
MCFG_CPU_CONFIG(gfx_ppc_cfg)
MCFG_CPU_PROGRAM_MAP(cobra_gfx_map)
-#endif
MCFG_QUANTUM_TIME(attotime::from_hz(10000))
@@ -2228,16 +2196,16 @@ static DRIVER_INIT(cobra)
{
cobra_state *cobra = machine.driver_data<cobra_state>();
- fifo_init(machine, GFXFIFO_IN, 8192, "GFXFIFO_IN", GFXFIFO_IN_VERBOSE);
- fifo_init(machine, GFXFIFO_OUT, 8192, "GFXFIFO_OUT", GFXFIFO_OUT_VERBOSE);
- fifo_init(machine, M2SFIFO, 2048, "M2SFIFO", M2SFIFO_VERBOSE);
- fifo_init(machine, S2MFIFO, 2048, "S2MFIFO", S2MFIFO_VERBOSE);
+ cobra->m_gfxfifo_in = auto_alloc(machine, cobra_fifo(machine, 8192, "GFXFIFO_IN", GFXFIFO_IN_VERBOSE != 0));
+ cobra->m_gfxfifo_out = auto_alloc(machine, cobra_fifo(machine, 8192, "GFXFIFO_IN", GFXFIFO_OUT_VERBOSE != 0));
+ cobra->m_m2sfifo = auto_alloc(machine, cobra_fifo(machine, 2048, "M2SFIFO", M2SFIFO_VERBOSE != 0));
+ cobra->m_s2mfifo = auto_alloc(machine, cobra_fifo(machine, 2048, "S2MFIFO", S2MFIFO_VERBOSE != 0));
+
-#if ENABLE_GFX_CPU
ppc_set_dcstore_callback(cobra->m_gfxcpu, gfx_cpu_dc_store);
+
cobra_gfx_init(cobra);
-#endif
cobra->m_comram[0] = auto_alloc_array(machine, UINT32, 0x40000/4);
cobra->m_comram[1] = auto_alloc_array(machine, UINT32, 0x40000/4);