summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2011-04-17 18:00:35 +0000
committer Olivier Galibert <galibert@pobox.com>2011-04-17 18:00:35 +0000
commit59a98d5c7cb14c86d95273a3b38bf041cccb0f7a (patch)
treedba35d9e9dc6cd7284f91f24b504381ceb75e702
parent35af804269c41a7e9281d506fb7bab42ce6769c9 (diff)
segas24: Start untangling the Vogon poetry Atari Ace left is his wake.
Apply the new timing implementation per cgfm's analysis. Gain ground is going to be stuck in free play mode. [O. Galibert]
-rw-r--r--.gitattributes1
-rw-r--r--src/mame/drivers/model1.c10
-rw-r--r--src/mame/drivers/model2.c10
-rw-r--r--src/mame/drivers/segas24.c807
-rw-r--r--src/mame/includes/segas24.h133
-rw-r--r--src/mame/machine/segas24.c109
-rw-r--r--src/mame/mame.mak2
-rw-r--r--src/mame/video/model1.c19
-rw-r--r--src/mame/video/model2.c18
-rw-r--r--src/mame/video/segaic24.c360
-rw-r--r--src/mame/video/segaic24.h192
-rw-r--r--src/mame/video/segas24.c57
12 files changed, 949 insertions, 769 deletions
diff --git a/.gitattributes b/.gitattributes
index ce57cf8ce73..d714193530d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -3681,7 +3681,6 @@ src/mame/machine/segag80.h svneol=native#text/plain
src/mame/machine/segaic16.c svneol=native#text/plain
src/mame/machine/segaic16.h svneol=native#text/plain
src/mame/machine/segamsys.c svneol=native#text/plain
-src/mame/machine/segas24.c svneol=native#text/plain
src/mame/machine/segas32.c svneol=native#text/plain
src/mame/machine/seibuspi.c svneol=native#text/plain
src/mame/machine/seibuspi.h svneol=native#text/plain
diff --git a/src/mame/drivers/model1.c b/src/mame/drivers/model1.c
index 25c1bc2488f..32bb121faaa 100644
--- a/src/mame/drivers/model1.c
+++ b/src/mame/drivers/model1.c
@@ -877,12 +877,12 @@ static ADDRESS_MAP_START( model1_mem, AS_PROGRAM, 16 )
AM_RANGE(0x610000, 0x61ffff) AM_RAM_WRITE(md1_w) AM_BASE_MEMBER(model1_state, m_display_list1)
AM_RANGE(0x680000, 0x680003) AM_READWRITE(model1_listctl_r, model1_listctl_w)
- AM_RANGE(0x700000, 0x70ffff) AM_READWRITE(sys24_tile_r, sys24_tile_w)
+ AM_RANGE(0x700000, 0x70ffff) AM_DEVREADWRITE_MODERN("tile", segas24_tile, tile_r, tile_w)
AM_RANGE(0x720000, 0x720001) AM_WRITENOP // Unknown, always 0
AM_RANGE(0x740000, 0x740001) AM_WRITENOP // Horizontal synchronization register
AM_RANGE(0x760000, 0x760001) AM_WRITENOP // Vertical synchronization register
AM_RANGE(0x770000, 0x770001) AM_WRITENOP // Video synchronization switch
- AM_RANGE(0x780000, 0x7fffff) AM_READWRITE(sys24_char_r, sys24_char_w)
+ AM_RANGE(0x780000, 0x7fffff) AM_DEVREADWRITE_MODERN("tile", segas24_tile, char_r, char_w)
AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(p_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x910000, 0x91bfff) AM_RAM AM_BASE_MEMBER(model1_state, m_color_xlat)
@@ -925,12 +925,12 @@ static ADDRESS_MAP_START( model1_vr_mem, AS_PROGRAM, 16 )
AM_RANGE(0x610000, 0x61ffff) AM_RAM_WRITE(md1_w) AM_BASE_MEMBER(model1_state, m_display_list1)
AM_RANGE(0x680000, 0x680003) AM_READWRITE(model1_listctl_r, model1_listctl_w)
- AM_RANGE(0x700000, 0x70ffff) AM_READWRITE(sys24_tile_r, sys24_tile_w)
+ AM_RANGE(0x700000, 0x70ffff) AM_DEVREADWRITE_MODERN("tile", segas24_tile, tile_r, tile_w)
AM_RANGE(0x720000, 0x720001) AM_WRITENOP // Unknown, always 0
AM_RANGE(0x740000, 0x740001) AM_WRITENOP // Horizontal synchronization register
AM_RANGE(0x760000, 0x760001) AM_WRITENOP // Vertical synchronization register
AM_RANGE(0x770000, 0x770001) AM_WRITENOP // Video synchronization switch
- AM_RANGE(0x780000, 0x7fffff) AM_READWRITE(sys24_char_r, sys24_char_w)
+ AM_RANGE(0x780000, 0x7fffff) AM_DEVREADWRITE_MODERN("tile", segas24_tile, char_r, char_w)
AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(p_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x910000, 0x91bfff) AM_RAM AM_BASE_MEMBER(model1_state, m_color_xlat)
@@ -1514,6 +1514,8 @@ static MACHINE_CONFIG_START( model1, model1_state )
MCFG_MACHINE_RESET(model1)
MCFG_NVRAM_ADD_0FILL("nvram")
+ MCFG_S24TILE_DEVICE_ADD("tile", 0x3fff)
+
MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK )
MCFG_SCREEN_ADD("screen", RASTER)
diff --git a/src/mame/drivers/model2.c b/src/mame/drivers/model2.c
index 0088a788601..11923068c6f 100644
--- a/src/mame/drivers/model2.c
+++ b/src/mame/drivers/model2.c
@@ -1373,14 +1373,12 @@ static ADDRESS_MAP_START( model2_base_mem, AS_PROGRAM, 32 )
AM_RANGE(0x00f00000, 0x00f0000f) AM_READWRITE(timers_r, timers_w)
- AM_RANGE(0x01000000, 0x0100ffff) AM_READWRITE(sys24_tile32_r, sys24_tile32_w) AM_MIRROR(0x100000)
+ AM_RANGE(0x01000000, 0x0100ffff) AM_DEVREADWRITE_MODERN("tile", segas24_tile, tile32_r, tile32_w) AM_MIRROR(0x110000)
AM_RANGE(0x01020000, 0x01020003) AM_WRITENOP AM_MIRROR(0x100000) // Unknown, always 0
AM_RANGE(0x01040000, 0x01040003) AM_WRITENOP AM_MIRROR(0x100000) // Horizontal synchronization register
AM_RANGE(0x01060000, 0x01060003) AM_WRITENOP AM_MIRROR(0x100000) // Vertical synchronization register
AM_RANGE(0x01070000, 0x01070003) AM_WRITENOP AM_MIRROR(0x100000) // Video synchronization switch
- AM_RANGE(0x01080000, 0x010fffff) AM_READWRITE(sys24_char32_r, sys24_char32_w) AM_MIRROR(0x100000)
- AM_RANGE(0x01100000, 0x0110ffff) AM_READWRITE(sys24_tile32_r, sys24_tile32_w) AM_MIRROR(0x10000)
- AM_RANGE(0x01180000, 0x011fffff) AM_READWRITE(sys24_char32_r, sys24_char32_w) AM_MIRROR(0x100000)
+ AM_RANGE(0x01080000, 0x010fffff) AM_DEVREADWRITE_MODERN("tile", segas24_tile, char32_r, char32_w) AM_MIRROR(0x100000)
AM_RANGE(0x01800000, 0x01803fff) AM_RAM_WRITE(pal32_w) AM_BASE_MEMBER(model2_state, m_paletteram32)
AM_RANGE(0x01810000, 0x0181bfff) AM_RAM AM_BASE_MEMBER(model2_state, m_colorxlat)
@@ -2028,6 +2026,8 @@ static MACHINE_CONFIG_START( model2o, model2_state )
MCFG_TIMER_ADD("timer3", model2_timer_cb)
MCFG_TIMER_PTR((FPTR)3)
+ MCFG_S24TILE_DEVICE_ADD("tile", 0x3fff)
+
MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK )
MCFG_SCREEN_ADD("screen", RASTER)
@@ -2085,6 +2085,8 @@ static MACHINE_CONFIG_START( model2a, model2_state )
MCFG_TIMER_ADD("timer3", model2_timer_cb)
MCFG_TIMER_PTR((FPTR)3)
+ MCFG_S24TILE_DEVICE_ADD("tile", 0x3fff)
+
MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK )
MCFG_SCREEN_ADD("screen", RASTER)
diff --git a/src/mame/drivers/segas24.c b/src/mame/drivers/segas24.c
index 61b9aa805f1..807e8c8f0cf 100644
--- a/src/mame/drivers/segas24.c
+++ b/src/mame/drivers/segas24.c
@@ -331,6 +331,7 @@ Notes:
just made a copy & renamed them for now to avoid any conflicts
*/
+#define ADDRESS_MAP_MODERN
#include "emu.h"
#include "deprecat.h"
#include "cpu/m68000/m68000.h"
@@ -343,52 +344,50 @@ Notes:
#define MASTER_CLOCK XTAL_20MHz
#define VIDEO_CLOCK XTAL_32MHz
-
+#define TIMER_CLOCK (VIDEO_CLOCK/4)
+#define HSYNC_CLOCK (VIDEO_CLOCK/2/656.0)
// Floppy Fisk Controller
-
-static void fdc_init(running_machine &machine)
+void segas24_state::fdc_init()
{
- segas24_state *state = machine.driver_data<segas24_state>();
- state->m_fdc_status = 0;
- state->m_fdc_track = 0;
- state->m_fdc_sector = 0;
- state->m_fdc_data = 0;
- state->m_fdc_phys_track = 0;
- state->m_fdc_irq = 0;
- state->m_fdc_drq = 0;
- state->m_fdc_index_count = 0;
+ fdc_status = 0;
+ fdc_track = 0;
+ fdc_sector = 0;
+ fdc_data = 0;
+ fdc_phys_track = 0;
+ fdc_irq = 0;
+ fdc_drq = 0;
+ fdc_index_count = 0;
}
-static READ16_HANDLER( fdc_r )
+READ16_MEMBER( segas24_state::fdc_r )
{
- segas24_state *state = space->machine().driver_data<segas24_state>();
- if(!state->m_track_size)
+ if(!track_size)
return 0xffff;
switch(offset) {
case 0:
- state->m_fdc_irq = 0;
- return state->m_fdc_status;
+ fdc_irq = 0;
+ return fdc_status;
case 1:
- return state->m_fdc_track;
+ return fdc_track;
case 2:
- return state->m_fdc_sector;
+ return fdc_sector;
case 3:
default: {
- int res = state->m_fdc_data;
- if(state->m_fdc_drq) {
- state->m_fdc_span--;
- // logerror("Read %02x (%d)\n", res, state->m_fdc_span);
- if(state->m_fdc_span) {
- state->m_fdc_pt++;
- state->m_fdc_data = *state->m_fdc_pt;
+ int res = fdc_data;
+ if(fdc_drq) {
+ fdc_span--;
+ // logerror("Read %02x (%d)\n", res, fdc_span);
+ if(fdc_span) {
+ fdc_pt++;
+ fdc_data = *fdc_pt;
} else {
logerror("FDC: transfert complete\n");
- state->m_fdc_drq = 0;
- state->m_fdc_status = 0;
- state->m_fdc_irq = 1;
+ fdc_drq = 0;
+ fdc_status = 0;
+ fdc_irq = 1;
}
} else
logerror("FDC: data read with drq down\n");
@@ -397,57 +396,56 @@ static READ16_HANDLER( fdc_r )
}
}
-static WRITE16_HANDLER( fdc_w )
+WRITE16_MEMBER( segas24_state::fdc_w )
{
- segas24_state *state = space->machine().driver_data<segas24_state>();
- if(!state->m_track_size)
+ if(!track_size)
return;
if(ACCESSING_BITS_0_7) {
data &= 0xff;
switch(offset) {
case 0:
- state->m_fdc_irq = 0;
+ fdc_irq = 0;
switch(data >> 4) {
case 0x0:
logerror("FDC: Restore\n");
- state->m_fdc_phys_track = state->m_fdc_track = 0;
- state->m_fdc_irq = 1;
- state->m_fdc_status = 4;
+ fdc_phys_track = fdc_track = 0;
+ fdc_irq = 1;
+ fdc_status = 4;
break;
case 0x1:
- logerror("FDC: Seek %d\n", state->m_fdc_data);
- state->m_fdc_phys_track = state->m_fdc_track = state->m_fdc_data;
- state->m_fdc_irq = 1;
- state->m_fdc_status = state->m_fdc_track ? 0 : 4;
+ logerror("FDC: Seek %d\n", fdc_data);
+ fdc_phys_track = fdc_track = fdc_data;
+ fdc_irq = 1;
+ fdc_status = fdc_track ? 0 : 4;
break;
case 0x9:
- logerror("Read multiple [%02x] %d..%d side %d track %d\n", data, state->m_fdc_sector, state->m_fdc_sector+state->m_fdc_data-1, data & 8 ? 1 : 0, state->m_fdc_phys_track);
- state->m_fdc_pt = space->machine().region("floppy")->base() + state->m_track_size*(2*state->m_fdc_phys_track+(data & 8 ? 1 : 0));
- state->m_fdc_span = state->m_track_size;
- state->m_fdc_status = 3;
- state->m_fdc_drq = 1;
- state->m_fdc_data = *state->m_fdc_pt;
+ logerror("Read multiple [%02x] %d..%d side %d track %d\n", data, fdc_sector, fdc_sector+fdc_data-1, data & 8 ? 1 : 0, fdc_phys_track);
+ fdc_pt = machine().region("floppy")->base() + track_size*(2*fdc_phys_track+(data & 8 ? 1 : 0));
+ fdc_span = track_size;
+ fdc_status = 3;
+ fdc_drq = 1;
+ fdc_data = *fdc_pt;
break;
case 0xb:
- logerror("Write multiple [%02x] %d..%d side %d track %d\n", data, state->m_fdc_sector, state->m_fdc_sector+state->m_fdc_data-1, data & 8 ? 1 : 0, state->m_fdc_phys_track);
- state->m_fdc_pt = space->machine().region("floppy")->base() + state->m_track_size*(2*state->m_fdc_phys_track+(data & 8 ? 1 : 0));
- state->m_fdc_span = state->m_track_size;
- state->m_fdc_status = 3;
- state->m_fdc_drq = 1;
+ logerror("Write multiple [%02x] %d..%d side %d track %d\n", data, fdc_sector, fdc_sector+fdc_data-1, data & 8 ? 1 : 0, fdc_phys_track);
+ fdc_pt = machine().region("floppy")->base() + track_size*(2*fdc_phys_track+(data & 8 ? 1 : 0));
+ fdc_span = track_size;
+ fdc_status = 3;
+ fdc_drq = 1;
break;
case 0xd:
logerror("FDC: Forced interrupt\n");
- state->m_fdc_span = 0;
- state->m_fdc_drq = 0;
- state->m_fdc_irq = data & 1;
- state->m_fdc_status = 0;
+ fdc_span = 0;
+ fdc_drq = 0;
+ fdc_irq = data & 1;
+ fdc_status = 0;
break;
case 0xf:
if(data == 0xfe)
- logerror("FDC: Assign mode %02x\n", state->m_fdc_data);
+ logerror("FDC: Assign mode %02x\n", fdc_data);
else if(data == 0xfd)
- logerror("FDC: Assign parameter %02x\n", state->m_fdc_data);
+ logerror("FDC: Assign parameter %02x\n", fdc_data);
else
logerror("FDC: Unknown command %02x\n", data);
break;
@@ -458,41 +456,40 @@ static WRITE16_HANDLER( fdc_w )
break;
case 1:
logerror("FDC: Track register %02x\n", data);
- state->m_fdc_track = data;
+ fdc_track = data;
break;
case 2:
logerror("FDC: Sector register %02x\n", data);
- state->m_fdc_sector = data;
+ fdc_sector = data;
break;
case 3:
- if(state->m_fdc_drq) {
- // logerror("Write %02x (%d)\n", data, state->m_fdc_span);
- *state->m_fdc_pt++ = data;
- state->m_fdc_span--;
- if(!state->m_fdc_span) {
+ if(fdc_drq) {
+ // logerror("Write %02x (%d)\n", data, fdc_span);
+ *fdc_pt++ = data;
+ fdc_span--;
+ if(!fdc_span) {
logerror("FDC: transfert complete\n");
- state->m_fdc_drq = 0;
- state->m_fdc_status = 0;
- state->m_fdc_irq = 1;
+ fdc_drq = 0;
+ fdc_status = 0;
+ fdc_irq = 1;
}
} else
logerror("FDC: Data register %02x\n", data);
- state->m_fdc_data = data;
+ fdc_data = data;
break;
}
}
}
-static READ16_HANDLER( fdc_status_r )
+READ16_MEMBER( segas24_state::fdc_status_r )
{
- segas24_state *state = space->machine().driver_data<segas24_state>();
- if(!state->m_track_size)
+ if(!track_size)
return 0xffff;
- return 0x90 | (state->m_fdc_irq ? 2 : 0) | (state->m_fdc_drq ? 1 : 0) | (state->m_fdc_phys_track ? 0x40 : 0) | (state->m_fdc_index_count ? 0x20 : 0);
+ return 0x90 | (fdc_irq ? 2 : 0) | (fdc_drq ? 1 : 0) | (fdc_phys_track ? 0x40 : 0) | (fdc_index_count ? 0x20 : 0);
}
-static WRITE16_HANDLER( fdc_ctrl_w )
+WRITE16_MEMBER( segas24_state::fdc_ctrl_w )
{
if(ACCESSING_BITS_0_7)
logerror("FDC control %02x\n", data & 0xff);
@@ -501,51 +498,51 @@ static WRITE16_HANDLER( fdc_ctrl_w )
// I/O Mappers
-static UINT8 hotrod_io_r(running_machine &machine, int port)
+UINT8 segas24_state::hotrod_io_r(UINT8 port)
{
switch(port)
{
case 0:
- return input_port_read(machine, "P1");
+ return input_port_read(machine(), "P1");
case 1:
- return input_port_read(machine, "P2");
+ return input_port_read(machine(), "P2");
case 2:
- return input_port_read_safe(machine, "P3", 0xff);
+ return input_port_read_safe(machine(), "P3", 0xff);
case 3:
return 0xff;
case 4:
- return input_port_read(machine, "SERVICE");
+ return input_port_read(machine(), "SERVICE");
case 5: // Dip switches
- return input_port_read(machine, "COINAGE");
+ return input_port_read(machine(), "COINAGE");
case 6:
- return input_port_read(machine, "DSW");
+ return input_port_read(machine(), "DSW");
case 7: // DAC
return 0xff;
}
return 0x00;
}
-static UINT8 dcclub_io_r(running_machine &machine, int port)
+UINT8 segas24_state::dcclub_io_r(UINT8 port)
{
switch(port)
{
case 0:
{
static const UINT8 pos[16] = { 0, 1, 3, 2, 6, 4, 12, 8, 9 };
- return (input_port_read(machine, "P1") & 0xf) | ((~pos[input_port_read(machine, "PADDLE")>>4]<<4) & 0xf0);
+ return (input_port_read(machine(), "P1") & 0xf) | ((~pos[input_port_read(machine(), "PADDLE")>>4]<<4) & 0xf0);
}
case 1:
- return input_port_read(machine, "P2");
+ return input_port_read(machine(), "P2");
case 2:
return 0xff;
case 3:
return 0xff;
case 4:
- return input_port_read(machine, "SERVICE");
+ return input_port_read(machine(), "SERVICE");
case 5: // Dip switches
- return input_port_read(machine, "COINAGE");
+ return input_port_read(machine(), "COINAGE");
case 6:
- return input_port_read(machine, "DSW");
+ return input_port_read(machine(), "DSW");
case 7: // DAC
return 0xff;
}
@@ -553,58 +550,56 @@ static UINT8 dcclub_io_r(running_machine &machine, int port)
}
-static UINT8 mahmajn_io_r(running_machine &machine, int port)
+UINT8 segas24_state::mahmajn_io_r(UINT8 port)
{
- segas24_state *state = machine.driver_data<segas24_state>();
static const char *const keynames[] = { "MJ0", "MJ1", "MJ2", "MJ3", "MJ4", "MJ5", "P1", "P2" };
switch(port)
{
case 0:
- return ~(1 << state->m_cur_input_line);
+ return ~(1 << cur_input_line);
case 1:
return 0xff;
case 2:
- return input_port_read(machine, keynames[state->m_cur_input_line]);
+ return input_port_read(machine(), keynames[cur_input_line]);
case 3:
return 0xff;
case 4:
- return input_port_read(machine, "SERVICE");
+ return input_port_read(machine(), "SERVICE");
case 5: // Dip switches
- return input_port_read(machine, "COINAGE");
+ return input_port_read(machine(), "COINAGE");
case 6:
- return input_port_read(machine, "DSW");
+ return input_port_read(machine(), "DSW");
case 7: // DAC
return 0xff;
}
return 0x00;
}
-static void mahmajn_io_w(running_machine &machine, int port, UINT8 data)
+void segas24_state::mahmajn_io_w(UINT8 port, UINT8 data)
{
- segas24_state *state = machine.driver_data<segas24_state>();
switch(port)
{
case 3:
if(data & 4)
- state->m_cur_input_line = (state->m_cur_input_line + 1) & 7;
+ cur_input_line = (cur_input_line + 1) & 7;
break;
case 7: // DAC
- dac_signed_data_w(machine.device("dac"), data);
+ dac_signed_data_w(machine().device("dac"), data);
break;
default:
fprintf(stderr, "Port %d : %02x\n", port, data & 0xff);
}
}
-static void hotrod_io_w(running_machine &machine, int port, UINT8 data)
+void segas24_state::hotrod_io_w(UINT8 port, UINT8 data)
{
switch(port)
{
case 3: // Lamps
break;
case 7: // DAC
- dac_signed_data_w(machine.device("dac"), data);
+ dac_signed_data_w(machine().device("dac"), data);
break;
default:
fprintf(stderr, "Port %d : %02x\n", port, data & 0xff);
@@ -612,48 +607,46 @@ static void hotrod_io_w(running_machine &machine, int port, UINT8 data)
}
-static WRITE16_HANDLER( hotrod3_ctrl_w )
+WRITE16_MEMBER( segas24_state::hotrod3_ctrl_w )
{
- segas24_state *state = space->machine().driver_data<segas24_state>();
static const char *const portnames[] = { "PEDAL1", "PEDAL2", "PEDAL3", "PEDAL4" };
if(ACCESSING_BITS_0_7)
{
data &= 3;
- state->m_hotrod_ctrl_cur = input_port_read_safe(space->machine(), portnames[data], 0);
+ hotrod_ctrl_cur = input_port_read_safe(machine(), portnames[data], 0);
}
}
-static READ16_HANDLER( hotrod3_ctrl_r )
+READ16_MEMBER( segas24_state::hotrod3_ctrl_r )
{
- segas24_state *state = space->machine().driver_data<segas24_state>();
if(ACCESSING_BITS_0_7)
{
switch(offset)
{
// Steering dials
case 0:
- return input_port_read_safe(space->machine(), "DIAL1", 0) & 0xff;
+ return input_port_read_safe(machine(), "DIAL1", 0) & 0xff;
case 1:
- return input_port_read_safe(space->machine(), "DIAL1", 0) >> 8;
+ return input_port_read_safe(machine(), "DIAL1", 0) >> 8;
case 2:
- return input_port_read_safe(space->machine(), "DIAL2", 0) & 0xff;
+ return input_port_read_safe(machine(), "DIAL2", 0) & 0xff;
case 3:
- return input_port_read_safe(space->machine(), "DIAL2", 0) >> 8;
+ return input_port_read_safe(machine(), "DIAL2", 0) >> 8;
case 4:
- return input_port_read_safe(space->machine(), "DIAL3", 0) & 0xff;
+ return input_port_read_safe(machine(), "DIAL3", 0) & 0xff;
case 5:
- return input_port_read_safe(space->machine(), "DIAL3", 0) >> 8;
+ return input_port_read_safe(machine(), "DIAL3", 0) >> 8;
case 6:
- return input_port_read_safe(space->machine(), "DIAL4", 0) & 0xff;
+ return input_port_read_safe(machine(), "DIAL4", 0) & 0xff;
case 7:
- return input_port_read_safe(space->machine(), "DIAL4", 0) >> 8;
+ return input_port_read_safe(machine(), "DIAL4", 0) >> 8;
case 8:
{
// Serial ADCs for the accel
- int v = state->m_hotrod_ctrl_cur & 0x80;
- state->m_hotrod_ctrl_cur <<= 1;
+ int v = hotrod_ctrl_cur & 0x80;
+ hotrod_ctrl_cur <<= 1;
return v ? 0xff : 0;
}
}
@@ -661,75 +654,69 @@ static READ16_HANDLER( hotrod3_ctrl_r )
return 0;
}
-static READ16_HANDLER( iod_r )
+READ16_MEMBER( segas24_state::iod_r )
{
- logerror("IO daughterboard read %02x (%x)\n", offset, cpu_get_pc(&space->device()));
+ logerror("IO daughterboard read %02x (%x)\n", offset, cpu_get_pc(&space.device()));
return 0xffff;
}
-static WRITE16_HANDLER( iod_w )
+WRITE16_MEMBER( segas24_state::iod_w )
{
- logerror("IO daughterboard write %02x, %04x & %04x (%x)\n", offset, data, mem_mask, cpu_get_pc(&space->device()));
+ logerror("IO daughterboard write %02x, %04x & %04x (%x)\n", offset, data, mem_mask, cpu_get_pc(&space.device()));
}
// Cpu #1 reset control
-static void reset_reset(running_machine &machine)
+void segas24_state::reset_reset()
{
- segas24_state *state = machine.driver_data<segas24_state>();
- int changed = state->m_resetcontrol ^ state->m_prev_resetcontrol;
+ int changed = resetcontrol ^ prev_resetcontrol;
if(changed & 2) {
- if(state->m_resetcontrol & 2) {
- cputag_set_input_line(machine, "sub", INPUT_LINE_HALT, CLEAR_LINE);
- cputag_set_input_line(machine, "sub", INPUT_LINE_RESET, PULSE_LINE);
+ if(resetcontrol & 2) {
+ cputag_set_input_line(machine(), "sub", INPUT_LINE_HALT, CLEAR_LINE);
+ cputag_set_input_line(machine(), "sub", INPUT_LINE_RESET, PULSE_LINE);
// mame_printf_debug("enable 2nd cpu!\n");
// debugger_break(machine);
- s24_fd1094_machine_init(machine);
+ s24_fd1094_machine_init(machine());
} else
- cputag_set_input_line(machine, "sub", INPUT_LINE_HALT, ASSERT_LINE);
+ cputag_set_input_line(machine(), "sub", INPUT_LINE_HALT, ASSERT_LINE);
}
if(changed & 4)
- devtag_reset(machine, "ymsnd");
- state->m_prev_resetcontrol = state->m_resetcontrol;
+ devtag_reset(machine(), "ymsnd");
+ prev_resetcontrol = resetcontrol;
}
-static void resetcontrol_w(address_space *space, UINT8 data)
+void segas24_state::reset_control_w(UINT8 data)
{
- segas24_state *state = space->machine().driver_data<segas24_state>();
- state->m_resetcontrol = data;
- logerror("Reset control %02x ('%s':%x)\n", state->m_resetcontrol, space->device().tag(), cpu_get_pc(&space->device()));
- reset_reset(space->machine());
+ resetcontrol = data;
+ reset_reset();
}
// Rom board bank access
-static void reset_bank(running_machine &machine)
+void segas24_state::reset_bank()
{
- segas24_state *state = machine.driver_data<segas24_state>();
- if (machine.region("romboard")->base())
+ if (machine().region("romboard")->base())
{
- memory_set_bank(machine, "bank1", state->m_curbank & 15);
- memory_set_bank(machine, "bank2", state->m_curbank & 15);
+ memory_set_bank(machine(), "bank1", curbank & 15);
+ memory_set_bank(machine(), "bank2", curbank & 15);
}
}
-static READ16_HANDLER( curbank_r )
+READ16_MEMBER( segas24_state::curbank_r )
{
- segas24_state *state = space->machine().driver_data<segas24_state>();
- return state->m_curbank;
+ return curbank;
}
-static WRITE16_HANDLER( curbank_w )
+WRITE16_MEMBER( segas24_state::curbank_w )
{
- segas24_state *state = space->machine().driver_data<segas24_state>();
if(ACCESSING_BITS_0_7) {
- state->m_curbank = data & 0xff;
- reset_bank(space->machine());
+ curbank = data & 0xff;
+ reset_bank();
}
}
@@ -737,29 +724,27 @@ static WRITE16_HANDLER( curbank_w )
// Protection magic latch
-static const UINT8 mahmajn_mlt[8] = { 5, 1, 6, 2, 3, 7, 4, 0 };
-static const UINT8 mahmajn2_mlt[8] = { 6, 0, 5, 3, 1, 4, 2, 7 };
-static const UINT8 qgh_mlt[8] = { 3, 7, 4, 0, 2, 6, 5, 1 };
-static const UINT8 bnzabros_mlt[8] = { 2, 4, 0, 5, 7, 3, 1, 6 };
-static const UINT8 qrouka_mlt[8] = { 1, 6, 4, 7, 0, 5, 3, 2 };
-static const UINT8 quizmeku_mlt[8] = { 0, 3, 2, 4, 6, 1, 7, 5 };
-static const UINT8 dcclub_mlt[8] = { 4, 7, 3, 0, 2, 6, 5, 1 };
+const UINT8 segas24_state::mahmajn_mlt[8] = { 5, 1, 6, 2, 3, 7, 4, 0 };
+const UINT8 segas24_state::mahmajn2_mlt[8] = { 6, 0, 5, 3, 1, 4, 2, 7 };
+const UINT8 segas24_state::qgh_mlt[8] = { 3, 7, 4, 0, 2, 6, 5, 1 };
+const UINT8 segas24_state::bnzabros_mlt[8] = { 2, 4, 0, 5, 7, 3, 1, 6 };
+const UINT8 segas24_state::qrouka_mlt[8] = { 1, 6, 4, 7, 0, 5, 3, 2 };
+const UINT8 segas24_state::quizmeku_mlt[8] = { 0, 3, 2, 4, 6, 1, 7, 5 };
+const UINT8 segas24_state::dcclub_mlt[8] = { 4, 7, 3, 0, 2, 6, 5, 1 };
-static READ16_HANDLER( mlatch_r )
+READ16_MEMBER( segas24_state::mlatch_r )
{
- segas24_state *state = space->machine().driver_data<segas24_state>();
- return state->m_mlatch;
+ return mlatch;
}
-static WRITE16_HANDLER( mlatch_w )
+WRITE16_MEMBER( segas24_state::mlatch_w )
{
- segas24_state *state = space->machine().driver_data<segas24_state>();
if(ACCESSING_BITS_0_7) {
int i;
UINT8 mxor = 0;
- if(!state->m_mlatch_table) {
- logerror("Protection: magic latch accessed but no table loaded (%s:%x)\n", space->device().tag(), cpu_get_pc(&space->device()));
+ if(!mlatch_table) {
+ logerror("Protection: magic latch accessed but no table loaded (%s:%x)\n", space.device().tag(), cpu_get_pc(&space.device()));
return;
}
@@ -767,13 +752,13 @@ static WRITE16_HANDLER( mlatch_w )
if(data != 0xff) {
for(i=0; i<8; i++)
- if(state->m_mlatch & (1<<i))
- mxor |= 1 << state->m_mlatch_table[i];
- state->m_mlatch = data ^ mxor;
- logerror("Magic latching %02x ^ %02x as %02x (%s:%x)\n", data & 0xff, mxor, state->m_mlatch, space->device().tag(), cpu_get_pc(&space->device()));
+ if(mlatch & (1<<i))
+ mxor |= 1 << mlatch_table[i];
+ mlatch = data ^ mxor;
+ logerror("Magic latching %02x ^ %02x as %02x (%s:%x)\n", data & 0xff, mxor, mlatch, space.device().tag(), cpu_get_pc(&space.device()));
} else {
- logerror("Magic latch reset (%s:%x)\n", space->device().tag(), cpu_get_pc(&space->device()));
- state->m_mlatch = 0x00;
+ logerror("Magic latch reset (%s:%x)\n", space.device().tag(), cpu_get_pc(&space.device()));
+ mlatch = 0x00;
}
}
}
@@ -788,122 +773,171 @@ enum {
IRQ_SPRITE = 4
};
+void segas24_state::irq_timer_sync()
+{
+ attotime ctime = machine().time();
+
+ switch(irq_tmode) {
+ case 0:
+ break;
+ case 1: {
+ // Don't remove the floor(), the value may be slightly negative
+ int ppos = floor((irq_synctime - irq_vsynctime).as_double() * HSYNC_CLOCK);
+ int cpos = floor((ctime - irq_vsynctime).as_double() * HSYNC_CLOCK);
+ irq_tval += cpos-ppos;
+ break;
+ }
+ case 2: {
+ abort();
+ }
+ case 3: {
+ int ppos = floor((irq_synctime - irq_vsynctime).as_double() * TIMER_CLOCK);
+ int cpos = floor((ctime - irq_vsynctime).as_double() * TIMER_CLOCK);
+ irq_tval += cpos-ppos;
+ break;
+ }
+ }
+
+ irq_synctime = ctime;
+}
+
+void segas24_state::irq_timer_start(int old_tmode)
+{
+ switch(irq_tmode) {
+ case 0:
+ if(old_tmode) {
+ irq_tval++;
+ if(irq_tval == 0x1000)
+ irq_timer->adjust(attotime::zero);
+ else
+ irq_timer->enable(false);
+ }
+ break;
+ case 1: {
+ int count = 0x1000 - irq_tval;
+ irq_timer->adjust(attotime::from_hz(HSYNC_CLOCK)*count);
+ break;
+ }
+ case 2:
+ abort();
+ break;
+ case 3: {
+ int count = 0x1000 - irq_tval;
+ irq_timer->adjust(attotime::from_hz(TIMER_CLOCK)*count);
+ break;
+ }
+ }
+}
static TIMER_DEVICE_CALLBACK( irq_timer_cb )
{
segas24_state *state = timer.machine().driver_data<segas24_state>();
- state->m_irq_timer_pend0 = state->m_irq_timer_pend1 = 1;
- if(state->m_irq_allow0 & (1 << IRQ_TIMER))
+ state->irq_timer_sync();
+
+ if(state->irq_tval != 0x1000)
+ fprintf(stderr, "Error: timer desync %x != 1000\n", state->irq_tval);
+
+ state->irq_tval = state->irq_tdata;
+ state->irq_timer_start(state->irq_tmode);
+
+ state->irq_timer_pend0 = state->irq_timer_pend1 = 1;
+ if(state->irq_allow0 & (1 << IRQ_TIMER))
cputag_set_input_line(timer.machine(), "maincpu", IRQ_TIMER+1, ASSERT_LINE);
- if(state->m_irq_allow1 & (1 << IRQ_TIMER))
+ if(state->irq_allow1 & (1 << IRQ_TIMER))
cputag_set_input_line(timer.machine(), "sub", IRQ_TIMER+1, ASSERT_LINE);
+
+ if(state->irq_tmode == 1 || state->irq_tmode == 2)
+ timer.machine().primary_screen->update_now();
}
static TIMER_DEVICE_CALLBACK( irq_timer_clear_cb )
{
segas24_state *state = timer.machine().driver_data<segas24_state>();
- state->m_irq_sprite = state->m_irq_vblank = 0;
+ state->irq_sprite = state->irq_vblank = 0;
cputag_set_input_line(timer.machine(), "maincpu", IRQ_VBLANK+1, CLEAR_LINE);
cputag_set_input_line(timer.machine(), "maincpu", IRQ_SPRITE+1, CLEAR_LINE);
cputag_set_input_line(timer.machine(), "sub", IRQ_VBLANK+1, CLEAR_LINE);
cputag_set_input_line(timer.machine(), "sub", IRQ_SPRITE+1, CLEAR_LINE);
}
-static void irq_init(running_machine &machine)
-{
- segas24_state *state = machine.driver_data<segas24_state>();
- state->m_irq_timera = 0;
- state->m_irq_timerb = 0;
- state->m_irq_allow0 = 0;
- state->m_irq_allow1 = 0;
- state->m_irq_timer_pend0 = 0;
- state->m_irq_timer_pend1 = 0;
- state->m_irq_vblank = 0;
- state->m_irq_sprite = 0;
- state->m_irq_timer = machine.device<timer_device>("irq_timer");
- state->m_irq_timer_clear = machine.device<timer_device>("irq_timer_clear");
-}
-
-static void irq_timer_reset(running_machine &machine)
+void segas24_state::irq_init()
{
- segas24_state *state = machine.driver_data<segas24_state>();
- int freq = (state->m_irq_timerb << 12) | state->m_irq_timera;
- freq &= 0x1fff;
-
- state->m_irq_timer->adjust(attotime::from_hz(freq), 0, attotime::from_hz(freq));
- logerror("New timer frequency: %0d [%02x %04x]\n", freq, state->m_irq_timerb, state->m_irq_timera);
+ irq_tdata = 0;
+ irq_tmode = 0;
+ irq_allow0 = 0;
+ irq_allow1 = 0;
+ irq_timer_pend0 = 0;
+ irq_timer_pend1 = 0;
+ irq_vblank = 0;
+ irq_sprite = 0;
+ irq_timer = machine().device<timer_device>("irq_timer");
+ irq_timer_clear = machine().device<timer_device>("irq_timer_clear");
+ irq_tval = 0;
+ irq_synctime = attotime::zero;
+ irq_vsynctime = attotime::zero;
}
-static WRITE16_HANDLER(irq_w)
+WRITE16_MEMBER(segas24_state::irq_w)
{
- segas24_state *state = space->machine().driver_data<segas24_state>();
switch(offset) {
case 0: {
- UINT16 old_ta = state->m_irq_timera;
- COMBINE_DATA(&state->m_irq_timera);
- if(old_ta != state->m_irq_timera)
- irq_timer_reset(space->machine());
+ irq_timer_sync();
+ COMBINE_DATA(&irq_tdata);
+ irq_tdata &= 0xfff;
+ irq_timer_start(irq_tmode);
break;
}
case 1:
if(ACCESSING_BITS_0_7) {
- UINT8 old_tb = state->m_irq_timerb;
- state->m_irq_timerb = data;
- if(old_tb != state->m_irq_timerb)
- irq_timer_reset(space->machine());
+ UINT8 old_tmode = irq_tmode;
+ irq_timer_sync();
+ irq_tmode = data & 3;
+ irq_timer_start(old_tmode);
}
break;
case 2:
- state->m_irq_allow0 = data;
- state->m_irq_timer_pend0 = 0;
- cputag_set_input_line(space->machine(), "maincpu", IRQ_TIMER+1, CLEAR_LINE);
- cputag_set_input_line(space->machine(), "maincpu", IRQ_YM2151+1, state->m_irq_yms && (state->m_irq_allow0 & (1 << IRQ_YM2151)) ? ASSERT_LINE : CLEAR_LINE);
- cputag_set_input_line(space->machine(), "maincpu", IRQ_VBLANK+1, state->m_irq_vblank && (state->m_irq_allow0 & (1 << IRQ_VBLANK)) ? ASSERT_LINE : CLEAR_LINE);
- cputag_set_input_line(space->machine(), "maincpu", IRQ_SPRITE+1, state->m_irq_sprite && (state->m_irq_allow0 & (1 << IRQ_SPRITE)) ? ASSERT_LINE : CLEAR_LINE);
+ irq_allow0 = data & 0x1f;
+ irq_timer_pend0 = 0;
+ cputag_set_input_line(machine(), "maincpu", IRQ_TIMER+1, CLEAR_LINE);
+ cputag_set_input_line(machine(), "maincpu", IRQ_YM2151+1, irq_yms && (irq_allow0 & (1 << IRQ_YM2151)) ? ASSERT_LINE : CLEAR_LINE);
+ cputag_set_input_line(machine(), "maincpu", IRQ_VBLANK+1, irq_vblank && (irq_allow0 & (1 << IRQ_VBLANK)) ? ASSERT_LINE : CLEAR_LINE);
+ cputag_set_input_line(machine(), "maincpu", IRQ_SPRITE+1, irq_sprite && (irq_allow0 & (1 << IRQ_SPRITE)) ? ASSERT_LINE : CLEAR_LINE);
break;
case 3:
- state->m_irq_allow1 = data;
- state->m_irq_timer_pend1 = 0;
- cputag_set_input_line(space->machine(), "sub", IRQ_TIMER+1, CLEAR_LINE);
- cputag_set_input_line(space->machine(), "sub", IRQ_YM2151+1, state->m_irq_yms && (state->m_irq_allow1 & (1 << IRQ_YM2151)) ? ASSERT_LINE : CLEAR_LINE);
- cputag_set_input_line(space->machine(), "sub", IRQ_VBLANK+1, state->m_irq_vblank && (state->m_irq_allow1 & (1 << IRQ_VBLANK)) ? ASSERT_LINE : CLEAR_LINE);
- cputag_set_input_line(space->machine(), "sub", IRQ_SPRITE+1, state->m_irq_sprite && (state->m_irq_allow1 & (1 << IRQ_SPRITE)) ? ASSERT_LINE : CLEAR_LINE);
+ irq_allow1 = data & 0x1f;
+ irq_timer_pend1 = 0;
+ cputag_set_input_line(machine(), "sub", IRQ_TIMER+1, CLEAR_LINE);
+ cputag_set_input_line(machine(), "sub", IRQ_YM2151+1, irq_yms && (irq_allow1 & (1 << IRQ_YM2151)) ? ASSERT_LINE : CLEAR_LINE);
+ cputag_set_input_line(machine(), "sub", IRQ_VBLANK+1, irq_vblank && (irq_allow1 & (1 << IRQ_VBLANK)) ? ASSERT_LINE : CLEAR_LINE);
+ cputag_set_input_line(machine(), "sub", IRQ_SPRITE+1, irq_sprite && (irq_allow1 & (1 << IRQ_SPRITE)) ? ASSERT_LINE : CLEAR_LINE);
break;
}
}
-static READ16_HANDLER(irq_r)
+// gground bp at 849c (84a4)
+// cmp.w $a00000, d0 | 16
+// dbeq d1, 84b4 | 10
+// 26 cycles/tour
+// 0x200 counts
+// 656 cycles/ligne
+// 656*0x200/26 = 12918 (3276) -> cd89 (got e087, delta = 1f78, 8056)
+// 410 cycles/ligne
+// 410*0x200/26 = 8073
+
+READ16_MEMBER(segas24_state::irq_r)
{
- segas24_state *state = space->machine().driver_data<segas24_state>();
switch(offset) {
- case 0: {
- int pc = cpu_get_pc(&space->device());
- if(pc == 0x84a4 || pc == 0x84a6)
- return 0;
- if(pc == 0x84aa || pc == 0x84ac) {
- // limit = 0x1b5f
- state->m_turns = 0x0100;
- return 1;
- }
- if(pc == 0x84ba || pc == 0x84bc) {
- // 26 cycles/read
- state->m_turns--;
- return state->m_turns ? 1 : 0x200;
- }
- // 84c8
- // -> 85ac / 85bc?
- break;
- }
case 2:
- state->m_irq_timer_pend0 = 0;
- cputag_set_input_line(space->machine(), "maincpu", IRQ_TIMER+1, CLEAR_LINE);
+ irq_timer_pend0 = 0;
+ cputag_set_input_line(machine(), "maincpu", IRQ_TIMER+1, CLEAR_LINE);
break;
case 3:
- state->m_irq_timer_pend1 = 0;
- cputag_set_input_line(space->machine(), "sub", IRQ_TIMER+1, CLEAR_LINE);
+ irq_timer_pend1 = 0;
+ cputag_set_input_line(machine(), "sub", IRQ_TIMER+1, CLEAR_LINE);
break;
}
- return 0xffff;
+ irq_timer_sync();
+ return irq_tval & 0xfff;
}
static INTERRUPT_GEN(irq_vbl)
@@ -913,38 +947,139 @@ static INTERRUPT_GEN(irq_vbl)
if(cpu_getiloops(device)) {
irq = IRQ_SPRITE;
- state->m_irq_sprite = 1;
+ state->irq_sprite = 1;
} else {
irq = IRQ_VBLANK;
- state->m_irq_vblank = 1;
+ state->irq_vblank = 1;
}
- state->m_irq_timer_clear->adjust(attotime::from_hz(VIDEO_CLOCK/2/656.0));
+ state->irq_timer_clear->adjust(attotime::from_hz(HSYNC_CLOCK));
mask = 1 << irq;
- if(state->m_irq_allow0 & mask)
+ if(state->irq_allow0 & mask)
cputag_set_input_line(device->machine(), "maincpu", 1+irq, ASSERT_LINE);
- if(state->m_irq_allow1 & mask)
+ if(state->irq_allow1 & mask)
cputag_set_input_line(device->machine(), "sub", 1+irq, ASSERT_LINE);
if(!cpu_getiloops(device)) {
// Ensure one index pulse every 20 frames
// The is some code in bnzabros at 0x852 that makes it crash
// if the pulse train is too fast
- state->m_fdc_index_count++;
- if(state->m_fdc_index_count >= 20)
- state->m_fdc_index_count = 0;
+ state->fdc_index_count++;
+ if(state->fdc_index_count >= 20)
+ state->fdc_index_count = 0;
}
+
+ state->irq_timer_sync();
+ state->irq_vsynctime = device->machine().time();
}
static void irq_ym(device_t *device, int irq)
{
segas24_state *state = device->machine().driver_data<segas24_state>();
- state->m_irq_yms = irq;
- cputag_set_input_line(device->machine(), "maincpu", IRQ_YM2151+1, state->m_irq_yms && (state->m_irq_allow0 & (1 << IRQ_YM2151)) ? ASSERT_LINE : CLEAR_LINE);
- cputag_set_input_line(device->machine(), "sub", IRQ_YM2151+1, state->m_irq_yms && (state->m_irq_allow1 & (1 << IRQ_YM2151)) ? ASSERT_LINE : CLEAR_LINE);
+ state->irq_yms = irq;
+ cputag_set_input_line(device->machine(), "maincpu", IRQ_YM2151+1, state->irq_yms && (state->irq_allow0 & (1 << IRQ_YM2151)) ? ASSERT_LINE : CLEAR_LINE);
+ cputag_set_input_line(device->machine(), "sub", IRQ_YM2151+1, state->irq_yms && (state->irq_allow1 & (1 << IRQ_YM2151)) ? ASSERT_LINE : CLEAR_LINE);
+}
+
+
+READ16_MEMBER ( segas24_state::sys16_io_r )
+{
+ // logerror("IO read %02x (%s:%x)\n", offset, space->device().tag(), cpu_get_pc(&space->device()));
+ if(offset < 8)
+ return (this->*io_r)(offset);
+ else if (offset < 0x20) {
+ switch(offset) {
+ case 0x8:
+ return 'S';
+ case 0x9:
+ return 'E';
+ case 0xa:
+ return 'G';
+ case 0xb:
+ return 'A';
+ case 0xe:
+ return io_cnt;
+ case 0xf:
+ return io_dir;
+ default:
+ logerror("IO control read %02x (%s:%x)\n", offset, space.device().tag(), cpu_get_pc(&space.device()));
+ return 0xff;
+ }
+ } else
+ return iod_r(space, offset & 0x1f, mem_mask);
+}
+
+WRITE16_MEMBER( segas24_state::sys16_io_w )
+{
+ if(ACCESSING_BITS_0_7) {
+ if(offset < 8) {
+ if(!(io_dir & (1 << offset))) {
+ logerror("IO port write on input-only port (%d, [%02x], %02x, %s:%x)\n", offset, io_dir, data & 0xff, space.device().tag(), cpu_get_pc(&space.device()));
+ return;
+ }
+ (this->*io_w)(offset, data);
+ } else if (offset < 0x20) {
+ switch(offset) {
+ case 0xe:
+ io_cnt = data;
+ reset_control_w(data & 7);
+ break;
+ case 0xf:
+ io_dir = data;
+ break;
+ default:
+ logerror("IO control write %02x, %02x (%s:%x)\n", offset, data & 0xff, space.device().tag(), cpu_get_pc(&space.device()));
+ }
+ }
+ }
+ if(offset >= 0x20)
+ iod_w(space, offset & 0x1f, data, mem_mask);
+}
+
+// 315-5242
+
+READ16_MEMBER( segas24_state::sys16_paletteram_r )
+{
+ return machine().generic.paletteram.u16[offset];
+}
+
+WRITE16_MEMBER( segas24_state::sys16_paletteram_w )
+{
+ int r, g, b;
+ COMBINE_DATA (machine().generic.paletteram.u16 + offset);
+ data = machine().generic.paletteram.u16[offset];
+
+ r = (data & 0x00f) << 4;
+ if(data & 0x1000)
+ r |= 8;
+
+ g = data & 0x0f0;
+ if(data & 0x2000)
+ g |= 8;
+
+ b = (data & 0xf00) >> 4;
+ if(data & 0x4000)
+ b |= 8;
+
+ r |= r >> 5;
+ g |= g >> 5;
+ b |= b >> 5;
+
+ palette_set_color(machine(), offset, MAKE_RGB(r, g, b));
+
+ if(data & 0x8000) {
+ r = 255-0.6*(255-r);
+ g = 255-0.6*(255-g);
+ b = 255-0.6*(255-b);
+ } else {
+ r = 0.6*r;
+ g = 0.6*g;
+ b = 0.6*b;
+ }
+ palette_set_color(machine(), offset+machine().total_colors()/2, MAKE_RGB(r, g, b));
}
@@ -997,21 +1132,21 @@ fc-ff ramhi
*/
-static ADDRESS_MAP_START( system24_cpu1_map, AS_PROGRAM, 16 )
+static ADDRESS_MAP_START( system24_cpu1_map, AS_PROGRAM, 16, segas24_state )
AM_RANGE(0x000000, 0x03ffff) AM_MIRROR(0x040000) AM_ROM AM_REGION("maincpu", 0)
AM_RANGE(0x080000, 0x0bffff) AM_MIRROR(0x040000) AM_RAM AM_SHARE("share1")
AM_RANGE(0x100000, 0x13ffff) AM_MIRROR(0x0c0000) AM_ROM AM_REGION("maincpu", 0)
- AM_RANGE(0x200000, 0x20ffff) AM_MIRROR(0x110000) AM_READWRITE(sys24_tile_r, sys24_tile_w)
+ AM_RANGE(0x200000, 0x20ffff) AM_MIRROR(0x110000) AM_DEVREADWRITE("tile", segas24_tile, tile_r, tile_w)
AM_RANGE(0x220000, 0x220001) AM_MIRROR(0x11fffe) AM_WRITENOP /* Horizontal split position (ABSEL) */
AM_RANGE(0x240000, 0x240001) AM_MIRROR(0x11fffe) AM_WRITENOP /* Scanline trigger position (XHOUT) */
AM_RANGE(0x260000, 0x260001) AM_MIRROR(0x10fffe) AM_WRITENOP /* Frame trigger position (XVOUT) */
AM_RANGE(0x270000, 0x270001) AM_MIRROR(0x10fffe) AM_WRITENOP /* Synchronization mode */
- AM_RANGE(0x280000, 0x29ffff) AM_MIRROR(0x160000) AM_READWRITE(sys24_char_r, sys24_char_w)
- AM_RANGE(0x400000, 0x403fff) AM_MIRROR(0x1f8000) AM_READWRITE(system24temp_sys16_paletteram1_r, system24temp_sys16_paletteram1_w) AM_BASE_GENERIC(paletteram)
- AM_RANGE(0x404000, 0x40401f) AM_MIRROR(0x1fbfe0) AM_READWRITE(sys24_mixer_r, sys24_mixer_w)
- AM_RANGE(0x600000, 0x63ffff) AM_MIRROR(0x180000) AM_READWRITE(sys24_sprite_r, sys24_sprite_w)
- AM_RANGE(0x800000, 0x80007f) AM_MIRROR(0x1ffe00) AM_READWRITE(system24temp_sys16_io_r, system24temp_sys16_io_w)
- AM_RANGE(0x800100, 0x800103) AM_MIRROR(0x1ffe00) AM_DEVREADWRITE8("ymsnd", ym2151_r, ym2151_w, 0x00ff)
+ AM_RANGE(0x280000, 0x29ffff) AM_MIRROR(0x160000) AM_DEVREADWRITE("tile", segas24_tile, char_r, char_w)
+ AM_RANGE(0x400000, 0x403fff) AM_MIRROR(0x1f8000) AM_READWRITE(sys16_paletteram_r, sys16_paletteram_w) AM_BASE_GENERIC(paletteram)
+ AM_RANGE(0x404000, 0x40401f) AM_MIRROR(0x1fbfe0) AM_DEVREADWRITE("mixer", segas24_mixer, read, write)
+ AM_RANGE(0x600000, 0x63ffff) AM_MIRROR(0x180000) AM_DEVREADWRITE("sprite", segas24_sprite, read, write)
+ AM_RANGE(0x800000, 0x80007f) AM_MIRROR(0x1ffe00) AM_READWRITE(sys16_io_r, sys16_io_w)
+ AM_RANGE(0x800100, 0x800103) AM_MIRROR(0x1ffe00) AM_DEVREADWRITE8_LEGACY("ymsnd", ym2151_r, ym2151_w, 0x00ff)
AM_RANGE(0xa00000, 0xa00007) AM_MIRROR(0x0ffff8) AM_READWRITE(irq_r, irq_w)
AM_RANGE(0xb00000, 0xb00007) AM_MIRROR(0x07fff0) AM_READWRITE(fdc_r, fdc_w)
AM_RANGE(0xb00008, 0xb0000f) AM_MIRROR(0x07fff0) AM_READWRITE(fdc_status_r, fdc_ctrl_w)
@@ -1034,21 +1169,21 @@ ADDRESS_MAP_END
*
*************************************/
-static ADDRESS_MAP_START( system24_cpu2_map, AS_PROGRAM, 16 )
+static ADDRESS_MAP_START( system24_cpu2_map, AS_PROGRAM, 16, segas24_state )
AM_RANGE(0x000000, 0x03ffff) AM_MIRROR(0x040000) AM_RAM AM_SHARE("share2")
AM_RANGE(0x080000, 0x0bffff) AM_MIRROR(0x040000) AM_RAM AM_SHARE("share1")
AM_RANGE(0x100000, 0x13ffff) AM_MIRROR(0x0c0000) AM_ROM AM_REGION("maincpu", 0)
- AM_RANGE(0x200000, 0x20ffff) AM_MIRROR(0x110000) AM_READWRITE(sys24_tile_r, sys24_tile_w)
+ AM_RANGE(0x200000, 0x20ffff) AM_MIRROR(0x110000) AM_DEVREADWRITE("tile", segas24_tile, tile_r, tile_w)
AM_RANGE(0x220000, 0x220001) AM_MIRROR(0x11fffe) AM_WRITENOP /* Horizontal split position (ABSEL) */
AM_RANGE(0x240000, 0x240001) AM_MIRROR(0x11fffe) AM_WRITENOP /* Scanline trigger position (XHOUT) */
AM_RANGE(0x260000, 0x260001) AM_MIRROR(0x10fffe) AM_WRITENOP /* Frame trigger position (XVOUT) */
AM_RANGE(0x270000, 0x270001) AM_MIRROR(0x10fffe) AM_WRITENOP /* Synchronization mode */
- AM_RANGE(0x280000, 0x29ffff) AM_MIRROR(0x160000) AM_READWRITE(sys24_char_r, sys24_char_w)
- AM_RANGE(0x400000, 0x403fff) AM_MIRROR(0x1f8000) AM_READWRITE(system24temp_sys16_paletteram1_r, system24temp_sys16_paletteram1_w)
- AM_RANGE(0x404000, 0x40401f) AM_MIRROR(0x1fbfe0) AM_READWRITE(sys24_mixer_r, sys24_mixer_w)
- AM_RANGE(0x600000, 0x63ffff) AM_MIRROR(0x180000) AM_READWRITE(sys24_sprite_r, sys24_sprite_w)
- AM_RANGE(0x800000, 0x80007f) AM_MIRROR(0x1ffe00) AM_READWRITE(system24temp_sys16_io_r, system24temp_sys16_io_w)
- AM_RANGE(0x800100, 0x800103) AM_MIRROR(0x1ffe00) AM_DEVREADWRITE8("ymsnd", ym2151_r, ym2151_w, 0x00ff)
+ AM_RANGE(0x280000, 0x29ffff) AM_MIRROR(0x160000) AM_DEVREADWRITE("tile", segas24_tile, char_r, char_w)
+ AM_RANGE(0x400000, 0x403fff) AM_MIRROR(0x1f8000) AM_READWRITE(sys16_paletteram_r, sys16_paletteram_w) AM_BASE_GENERIC(paletteram)
+ AM_RANGE(0x404000, 0x40401f) AM_MIRROR(0x1fbfe0) AM_DEVREADWRITE("mixer", segas24_mixer, read, write)
+ AM_RANGE(0x600000, 0x63ffff) AM_MIRROR(0x180000) AM_DEVREADWRITE("sprite", segas24_sprite, read, write)
+ AM_RANGE(0x800000, 0x80007f) AM_MIRROR(0x1ffe00) AM_READWRITE(sys16_io_r, sys16_io_w)
+ AM_RANGE(0x800100, 0x800103) AM_MIRROR(0x1ffe00) AM_DEVREADWRITE8_LEGACY("ymsnd", ym2151_r, ym2151_w, 0x00ff)
AM_RANGE(0xa00000, 0xa00007) AM_MIRROR(0x0ffff8) AM_READWRITE(irq_r, irq_w)
AM_RANGE(0xb00000, 0xb00007) AM_MIRROR(0x07fff0) AM_READWRITE(fdc_r, fdc_w)
AM_RANGE(0xb00008, 0xb0000f) AM_MIRROR(0x07fff0) AM_READWRITE(fdc_status_r, fdc_ctrl_w)
@@ -1074,8 +1209,8 @@ ADDRESS_MAP_END
static MACHINE_START( system24 )
{
segas24_state *state = machine.driver_data<segas24_state>();
- if (state->m_track_size)
- machine.device<nvram_device>("floppy_nvram")->set_base(machine.region("floppy")->base(), 2*state->m_track_size);
+ if (state->track_size)
+ machine.device<nvram_device>("floppy_nvram")->set_base(machine.region("floppy")->base(), 2*state->track_size);
UINT8 *usr1 = machine.region("romboard")->base();
if (usr1)
@@ -1083,18 +1218,22 @@ static MACHINE_START( system24 )
memory_configure_bank(machine, "bank1", 0, 16, usr1, 0x40000);
memory_configure_bank(machine, "bank2", 0, 16, usr1, 0x40000);
}
+
+ state->vtile = machine.device<segas24_tile>("tile");
+ state->vsprite = machine.device<segas24_sprite>("sprite");
+ state->vmixer = machine.device<segas24_mixer>("mixer");
}
static MACHINE_RESET( system24 )
{
segas24_state *state = machine.driver_data<segas24_state>();
cputag_set_input_line(machine, "sub", INPUT_LINE_HALT, ASSERT_LINE);
- state->m_prev_resetcontrol = state->m_resetcontrol = 0x06;
- fdc_init(machine);
- state->m_curbank = 0;
- reset_bank(machine);
- irq_init(machine);
- state->m_mlatch = 0x00;
+ state->prev_resetcontrol = state->resetcontrol = 0x06;
+ state->fdc_init();
+ state->curbank = 0;
+ state->reset_bank();
+ state->irq_init();
+ state->mlatch = 0x00;
}
/*************************************
@@ -1791,6 +1930,10 @@ static MACHINE_CONFIG_START( system24, segas24_state )
MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK)
+ MCFG_S24TILE_DEVICE_ADD("tile", 0xfff)
+ MCFG_S24SPRITE_DEVICE_ADD("sprite")
+ MCFG_S24MIXER_DEVICE_ADD("mixer")
+
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_RAW_PARAMS(VIDEO_CLOCK/2, 656, 0/*+69*/, 496/*+69*/, 424, 0/*+25*/, 384/*+25*/)
MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
@@ -1798,8 +1941,6 @@ static MACHINE_CONFIG_START( system24, segas24_state )
MCFG_PALETTE_LENGTH(8192*2)
- MCFG_VIDEO_START(system24)
-
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
MCFG_SOUND_ADD("ymsnd", YM2151, 4000000)
@@ -2162,58 +2303,65 @@ ROM_END
static DRIVER_INIT( qgh )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, hotrod_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = qgh_mlt;
- state->m_track_size = 0;
+ state->io_r = &segas24_state::hotrod_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = segas24_state::qgh_mlt;
+ state->track_size = 0;
}
static DRIVER_INIT( dcclub )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, dcclub_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = dcclub_mlt;
- state->m_track_size = 0;
+ state->io_r = &segas24_state::dcclub_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = segas24_state::dcclub_mlt;
+ state->track_size = 0;
}
static DRIVER_INIT( qrouka )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, hotrod_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = qrouka_mlt;
- state->m_track_size = 0;
+ state->io_r = &segas24_state::hotrod_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = segas24_state::qrouka_mlt;
+ state->track_size = 0;
}
static DRIVER_INIT( quizmeku )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, hotrod_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = quizmeku_mlt;
- state->m_track_size = 0;
+ state->io_r = &segas24_state::hotrod_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = segas24_state::quizmeku_mlt;
+ state->track_size = 0;
}
static DRIVER_INIT( mahmajn )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, mahmajn_io_r, mahmajn_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = mahmajn_mlt;
- state->m_track_size = 0;
- state->m_cur_input_line = 0;
+ state->io_r = &segas24_state::mahmajn_io_r;
+ state->io_w = &segas24_state::mahmajn_io_w;
+ state->mlatch_table = segas24_state::mahmajn_mlt;
+ state->track_size = 0;
+ state->cur_input_line = 0;
}
static DRIVER_INIT( mahmajn2 )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, mahmajn_io_r, mahmajn_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = mahmajn2_mlt;
- state->m_track_size = 0;
- state->m_cur_input_line = 0;
+ state->io_r = &segas24_state::mahmajn_io_r;
+ state->io_w = &segas24_state::mahmajn_io_w;
+ state->mlatch_table = segas24_state::mahmajn2_mlt;
+ state->track_size = 0;
+ state->cur_input_line = 0;
}
static DRIVER_INIT( hotrod )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, hotrod_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = 0;
+ state->io_r = &segas24_state::hotrod_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = 0;
// Sector Size
// 1 8192
@@ -2223,14 +2371,15 @@ static DRIVER_INIT( hotrod )
// 5 512
// 6 256
- state->m_track_size = 0x2f00;
+ state->track_size = 0x2f00;
}
static DRIVER_INIT( bnzabros )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, hotrod_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = bnzabros_mlt;
+ state->io_r = &segas24_state::hotrod_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = segas24_state::bnzabros_mlt;
// Sector Size
// 1 2048
@@ -2241,33 +2390,36 @@ static DRIVER_INIT( bnzabros )
// 6 1024
// 7 256
- state->m_track_size = 0x2d00;
+ state->track_size = 0x2d00;
}
static DRIVER_INIT( sspirits )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, hotrod_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = 0;
- state->m_track_size = 0x2d00;
+ state->io_r = &segas24_state::hotrod_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = 0;
+ state->track_size = 0x2d00;
s24_fd1094_driver_init(machine);
}
static DRIVER_INIT( sspiritj )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, hotrod_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = 0;
- state->m_track_size = 0x2f00;
+ state->io_r = &segas24_state::hotrod_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = 0;
+ state->track_size = 0x2f00;
s24_fd1094_driver_init(machine);
}
static DRIVER_INIT( dcclubfd )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, dcclub_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = dcclub_mlt;
- state->m_track_size = 0x2d00;
+ state->io_r = &segas24_state::dcclub_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = segas24_state::dcclub_mlt;
+ state->track_size = 0x2d00;
s24_fd1094_driver_init(machine);
}
@@ -2275,45 +2427,50 @@ static DRIVER_INIT( dcclubfd )
static DRIVER_INIT( sgmast )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, hotrod_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = 0;
- state->m_track_size = 0x2d00;
+ state->io_r = &segas24_state::hotrod_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = 0;
+ state->track_size = 0x2d00;
s24_fd1094_driver_init(machine);
}
static DRIVER_INIT( qsww )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, hotrod_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = 0;
- state->m_track_size = 0x2d00;
+ state->io_r = &segas24_state::hotrod_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = 0;
+ state->track_size = 0x2d00;
s24_fd1094_driver_init(machine);
}
static DRIVER_INIT( gground )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, hotrod_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = 0;
- state->m_track_size = 0x2d00;
+ state->io_r = &segas24_state::hotrod_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = 0;
+ state->track_size = 0x2d00;
s24_fd1094_driver_init(machine);
}
static DRIVER_INIT( crkdown )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, hotrod_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = 0;
- state->m_track_size = 0x2d00;
+ state->io_r = &segas24_state::hotrod_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = 0;
+ state->track_size = 0x2d00;
s24_fd1094_driver_init(machine);
}
static DRIVER_INIT( roughrac )
{
segas24_state *state = machine.driver_data<segas24_state>();
- system24temp_sys16_io_set_callbacks(machine, hotrod_io_r, hotrod_io_w, resetcontrol_w, iod_r, iod_w);
- state->m_mlatch_table = 0;
- state->m_track_size = 0x2d00;
+ state->io_r = &segas24_state::hotrod_io_r;
+ state->io_w = &segas24_state::hotrod_io_w;
+ state->mlatch_table = 0;
+ state->track_size = 0x2d00;
s24_fd1094_driver_init(machine);
}
diff --git a/src/mame/includes/segas24.h b/src/mame/includes/segas24.h
index b0b58bcd170..bb7ca9db8fe 100644
--- a/src/mame/includes/segas24.h
+++ b/src/mame/includes/segas24.h
@@ -1,73 +1,93 @@
+#include "video/segaic24.h"
+
class segas24_state : public driver_device
{
public:
segas24_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
- int m_fdc_status;
- int m_fdc_track;
- int m_fdc_sector;
- int m_fdc_data;
- int m_fdc_phys_track;
- int m_fdc_irq;
- int m_fdc_drq;
- int m_fdc_span;
- int m_fdc_index_count;
- UINT8 *m_fdc_pt;
- int m_track_size;
- int m_cur_input_line;
- UINT8 m_hotrod_ctrl_cur;
- UINT8 m_resetcontrol;
- UINT8 m_prev_resetcontrol;
- UINT8 m_curbank;
- UINT8 m_mlatch;
- const UINT8 *m_mlatch_table;
- UINT16 m_irq_timera;
- UINT8 m_irq_timerb;
- UINT8 m_irq_allow0;
- UINT8 m_irq_allow1;
- int m_irq_timer_pend0;
- int m_irq_timer_pend1;
- int m_irq_yms;
- int m_irq_vblank;
- int m_irq_sprite;
- timer_device *m_irq_timer;
- timer_device *m_irq_timer_clear;
- int m_turns;
- UINT16 *m_system24temp_sys16_shared_ram;
- UINT8 (*m_system24temp_sys16_io_io_r)(running_machine &machine, int port);
- void (*m_system24temp_sys16_io_io_w)(running_machine &machine, int port, UINT8 data);
- void (*m_system24temp_sys16_io_cnt_w)(address_space *space, UINT8 data);
- read16_space_func m_system24temp_sys16_io_iod_r;
- write16_space_func m_system24temp_sys16_io_iod_w;
- UINT8 m_system24temp_sys16_io_cnt;
- UINT8 m_system24temp_sys16_io_dir;
-};
+ static const UINT8 mahmajn_mlt[8];
+ static const UINT8 mahmajn2_mlt[8];
+ static const UINT8 qgh_mlt[8];
+ static const UINT8 bnzabros_mlt[8];
+ static const UINT8 qrouka_mlt[8];
+ static const UINT8 quizmeku_mlt[8];
+ static const UINT8 dcclub_mlt[8];
-/*----------- defined in machine/segas24.c -----------*/
+ int fdc_status;
+ int fdc_track;
+ int fdc_sector;
+ int fdc_data;
+ int fdc_phys_track;
+ int fdc_irq;
+ int fdc_drq;
+ int fdc_span;
+ int fdc_index_count;
+ UINT8 *fdc_pt;
+ int track_size;
+ int cur_input_line;
+ UINT8 hotrod_ctrl_cur;
+ UINT8 resetcontrol;
+ UINT8 prev_resetcontrol;
+ UINT8 curbank;
+ UINT8 mlatch;
+ const UINT8 *mlatch_table;
-/* system24temp_ functions / variables are from shared rewrite files,
- once the rest of the rewrite is complete they can be removed, I
- just made a copy & renamed them for now to avoid any conflicts
-*/
+ UINT16 irq_tdata, irq_tval;
+ UINT8 irq_tmode, irq_allow0, irq_allow1;
+ int irq_timer_pend0;
+ int irq_timer_pend1;
+ int irq_yms;
+ int irq_vblank;
+ int irq_sprite;
+ attotime irq_synctime, irq_vsynctime;
+ timer_device *irq_timer;
+ timer_device *irq_timer_clear;
-/* New Code */
+ UINT16 *shared_ram;
+ UINT8 (segas24_state::*io_r)(UINT8 port);
+ void (segas24_state::*io_w)(UINT8 port, UINT8 data);
+ UINT8 io_cnt, io_dir;
-void system24temp_sys16_io_set_callbacks(
- running_machine &machine,
- UINT8 (*io_r)(running_machine &machine, int port),
- void (*io_w)(running_machine &machine, int port, UINT8 data),
- void (*cnt_w)(address_space *space, UINT8 data),
- read16_space_func iod_r,
- write16_space_func iod_w);
+ segas24_tile *vtile;
+ segas24_sprite *vsprite;
+ segas24_mixer *vmixer;
-READ16_HANDLER ( system24temp_sys16_io_r );
-WRITE16_HANDLER( system24temp_sys16_io_w );
-READ32_HANDLER ( system24temp_sys16_io_dword_r );
+ DECLARE_READ16_MEMBER( sys16_paletteram_r );
+ DECLARE_WRITE16_MEMBER( sys16_paletteram_w );
+ DECLARE_READ16_MEMBER( irq_r );
+ DECLARE_WRITE16_MEMBER( irq_w );
+ DECLARE_READ16_MEMBER( fdc_r );
+ DECLARE_WRITE16_MEMBER( fdc_w );
+ DECLARE_READ16_MEMBER( fdc_status_r );
+ DECLARE_WRITE16_MEMBER( fdc_ctrl_w );
+ DECLARE_READ16_MEMBER( curbank_r );
+ DECLARE_WRITE16_MEMBER( curbank_w );
+ DECLARE_READ16_MEMBER( mlatch_r );
+ DECLARE_WRITE16_MEMBER( mlatch_w );
+ DECLARE_READ16_MEMBER( hotrod3_ctrl_r );
+ DECLARE_WRITE16_MEMBER( hotrod3_ctrl_w );
+ DECLARE_READ16_MEMBER( iod_r );
+ DECLARE_WRITE16_MEMBER( iod_w );
+ DECLARE_READ16_MEMBER ( sys16_io_r );
+ DECLARE_WRITE16_MEMBER( sys16_io_w );
-/* End New Code */
+ UINT8 hotrod_io_r(UINT8 port);
+ UINT8 dcclub_io_r(UINT8 port);
+ UINT8 mahmajn_io_r(UINT8 port);
+ void hotrod_io_w(UINT8 port, UINT8 data);
+ void mahmajn_io_w(UINT8 port, UINT8 data);
+
+ void fdc_init();
+ void reset_reset();
+ void reset_bank();
+ void irq_init();
+ void irq_timer_sync();
+ void irq_timer_start(int old_tmode);
+ void reset_control_w(UINT8 data);
+};
/*----------- defined in machine/s24fd.c -----------*/
@@ -77,5 +97,4 @@ extern void s24_fd1094_driver_init(running_machine &machine);
/*----------- defined in video/segas24.c -----------*/
-VIDEO_START(system24);
SCREEN_UPDATE(system24);
diff --git a/src/mame/machine/segas24.c b/src/mame/machine/segas24.c
deleted file mode 100644
index 467807c0641..00000000000
--- a/src/mame/machine/segas24.c
+++ /dev/null
@@ -1,109 +0,0 @@
-#include "emu.h"
-#include "includes/segas24.h"
-
-/* system24temp_ functions / variables are from shared rewrite files,
- once the rest of the rewrite is complete they can be removed, I
- just made a copy & renamed them for now to avoid any conflicts
-*/
-
-#ifdef UNUSED_FUNCTION
-READ16_HANDLER( system24temp_sys16_shared_ram_r )
-{
- segas24_state *state = space->machine().driver_data<segas24_state>();
- return state->m_system24temp_sys16_shared_ram[offset];
-}
-
-WRITE16_HANDLER( system24temp_sys16_shared_ram_w )
-{
- segas24_state *state = space->machine().driver_data<segas24_state>();
- COMBINE_DATA(state->m_system24temp_sys16_shared_ram + offset);
-}
-#endif
-
-/* The 315-5296
- 8 8bits I/O ports, 3 output-only pins, some protection, and
- external/daughterboard chip selection on half of the address
- range
-*/
-
-void system24temp_sys16_io_set_callbacks(
- running_machine &machine,
- UINT8 (*io_r)(running_machine &machine, int port),
- void (*io_w)(running_machine &machine, int port, UINT8 data),
- void (*cnt_w)(address_space *space, UINT8 data),
- read16_space_func iod_r,
- write16_space_func iod_w)
-{
- segas24_state *state = machine.driver_data<segas24_state>();
- state->m_system24temp_sys16_io_io_r = io_r;
- state->m_system24temp_sys16_io_io_w = io_w;
- state->m_system24temp_sys16_io_cnt_w = cnt_w;
- state->m_system24temp_sys16_io_iod_r = iod_r;
- state->m_system24temp_sys16_io_iod_w = iod_w;
- state->m_system24temp_sys16_io_cnt = 0x00;
- state->m_system24temp_sys16_io_dir = 0x00;
-}
-
-READ16_HANDLER ( system24temp_sys16_io_r )
-{
- segas24_state *state = space->machine().driver_data<segas24_state>();
- // logerror("IO read %02x (%s:%x)\n", offset, space->device().tag(), cpu_get_pc(&space->device()));
- if(offset < 8)
- return state->m_system24temp_sys16_io_io_r ? state->m_system24temp_sys16_io_io_r(space->machine(),offset) : 0xff;
- else if (offset < 0x20) {
- switch(offset) {
- case 0x8:
- return 'S';
- case 0x9:
- return 'E';
- case 0xa:
- return 'G';
- case 0xb:
- return 'A';
- case 0xe:
- return state->m_system24temp_sys16_io_cnt;
- case 0xf:
- return state->m_system24temp_sys16_io_dir;
- default:
- logerror("IO control read %02x (%s:%x)\n", offset, space->device().tag(), cpu_get_pc(&space->device()));
- return 0xff;
- }
- } else
- return state->m_system24temp_sys16_io_iod_r ? state->m_system24temp_sys16_io_iod_r(space, offset & 0x1f, mem_mask) : 0xff;
-}
-
-READ32_HANDLER(system24temp_sys16_io_dword_r)
-{
- return system24temp_sys16_io_r(space, 2*offset, mem_mask)|(system24temp_sys16_io_r(space,2*offset+1, mem_mask>>16)<<16);
-}
-
-
-WRITE16_HANDLER( system24temp_sys16_io_w )
-{
- segas24_state *state = space->machine().driver_data<segas24_state>();
- if(ACCESSING_BITS_0_7) {
- if(offset < 8) {
- if(!(state->m_system24temp_sys16_io_dir & (1 << offset))) {
- logerror("IO port write on input-only port (%d, [%02x], %02x, %s:%x)\n", offset, state->m_system24temp_sys16_io_dir, data & 0xff, space->device().tag(), cpu_get_pc(&space->device()));
- return;
- }
- if(state->m_system24temp_sys16_io_io_w)
- state->m_system24temp_sys16_io_io_w(space->machine(), offset, data);
- } else if (offset < 0x20) {
- switch(offset) {
- case 0xe:
- state->m_system24temp_sys16_io_cnt = data;
- if(state->m_system24temp_sys16_io_cnt_w)
- state->m_system24temp_sys16_io_cnt_w(space, data & 7);
- break;
- case 0xf:
- state->m_system24temp_sys16_io_dir = data;
- break;
- default:
- logerror("IO control write %02x, %02x (%s:%x)\n", offset, data & 0xff, space->device().tag(), cpu_get_pc(&space->device()));
- }
- }
- }
- if(offset >= 0x20 && state->m_system24temp_sys16_io_iod_w)
- state->m_system24temp_sys16_io_iod_w(space, offset & 0x1f, data, mem_mask);
-}
diff --git a/src/mame/mame.mak b/src/mame/mame.mak
index 30e8ad5977f..4e6c2667661 100644
--- a/src/mame/mame.mak
+++ b/src/mame/mame.mak
@@ -1165,7 +1165,7 @@ $(MAMEOBJ)/sega.a: \
$(DRIVERS)/segas16a.o $(VIDEO)/segas16a.o \
$(DRIVERS)/segas16b.o $(VIDEO)/segas16b.o \
$(DRIVERS)/segas18.o $(VIDEO)/segas18.o \
- $(DRIVERS)/segas24.o $(MACHINE)/segas24.o $(VIDEO)/segas24.o \
+ $(DRIVERS)/segas24.o $(VIDEO)/segas24.o \
$(DRIVERS)/segas32.o $(MACHINE)/segas32.o $(VIDEO)/segas32.o \
$(DRIVERS)/segaxbd.o $(VIDEO)/segaxbd.o \
$(DRIVERS)/segaybd.o $(VIDEO)/segaybd.o \
diff --git a/src/mame/video/model1.c b/src/mame/video/model1.c
index 8bc0fede461..b5feba37a7d 100644
--- a/src/mame/video/model1.c
+++ b/src/mame/video/model1.c
@@ -1452,8 +1452,6 @@ VIDEO_START(model1)
state->m_view = auto_alloc_clear(machine, struct view);
- sys24_tile_vh_start(machine, 0x3fff);
-
state->m_poly_rom = (UINT32 *)machine.region("user1")->base();
state->m_poly_ram = auto_alloc_array_clear(machine, UINT32, 0x400000);
state->m_tgp_ram = auto_alloc_array_clear(machine, UINT16, 0x100000-0x40000);
@@ -1523,17 +1521,18 @@ SCREEN_UPDATE(model1)
bitmap_fill(screen->machine().priority_bitmap, NULL, 0);
bitmap_fill(bitmap, cliprect, screen->machine().pens[0]);
- sys24_tile_draw(screen->machine(), bitmap, cliprect, 6, 0, 0);
- sys24_tile_draw(screen->machine(), bitmap, cliprect, 4, 0, 0);
- sys24_tile_draw(screen->machine(), bitmap, cliprect, 2, 0, 0);
- sys24_tile_draw(screen->machine(), bitmap, cliprect, 0, 0, 0);
+ segas24_tile *tile = screen->machine().device<segas24_tile>("tile");
+ tile->draw(bitmap, cliprect, 6, 0, 0);
+ tile->draw(bitmap, cliprect, 4, 0, 0);
+ tile->draw(bitmap, cliprect, 2, 0, 0);
+ tile->draw(bitmap, cliprect, 0, 0, 0);
tgp_render(screen->machine(), bitmap, cliprect);
- sys24_tile_draw(screen->machine(), bitmap, cliprect, 7, 0, 0);
- sys24_tile_draw(screen->machine(), bitmap, cliprect, 5, 0, 0);
- sys24_tile_draw(screen->machine(), bitmap, cliprect, 3, 0, 0);
- sys24_tile_draw(screen->machine(), bitmap, cliprect, 1, 0, 0);
+ tile->draw(bitmap, cliprect, 7, 0, 0);
+ tile->draw(bitmap, cliprect, 5, 0, 0);
+ tile->draw(bitmap, cliprect, 3, 0, 0);
+ tile->draw(bitmap, cliprect, 1, 0, 0);
return 0;
}
diff --git a/src/mame/video/model2.c b/src/mame/video/model2.c
index ffb5a74d730..f7689932f6b 100644
--- a/src/mame/video/model2.c
+++ b/src/mame/video/model2.c
@@ -2712,7 +2712,6 @@ VIDEO_START(model2)
int width = visarea.max_x - visarea.min_x;
int height = visarea.max_y - visarea.min_y;
- sys24_tile_vh_start(machine, 0x3fff);
state->m_sys24_bitmap = auto_alloc(machine, bitmap_t(width, height+4, BITMAP_FORMAT_INDEXED16));
state->m_poly = poly_alloc(machine, 4000, sizeof(poly_extra_data), 0);
@@ -2750,10 +2749,11 @@ SCREEN_UPDATE(model2)
bitmap_fill(bitmap, cliprect, screen->machine().pens[0]);
bitmap_fill(state->m_sys24_bitmap, cliprect, 0);
- sys24_tile_draw(screen->machine(), state->m_sys24_bitmap, cliprect, 7, 0, 0);
- sys24_tile_draw(screen->machine(), state->m_sys24_bitmap, cliprect, 6, 0, 0);
- sys24_tile_draw(screen->machine(), state->m_sys24_bitmap, cliprect, 5, 0, 0);
- sys24_tile_draw(screen->machine(), state->m_sys24_bitmap, cliprect, 4, 0, 0);
+ segas24_tile *tile = screen->machine().device<segas24_tile>("tile");
+ tile->draw(state->m_sys24_bitmap, cliprect, 7, 0, 0);
+ tile->draw(state->m_sys24_bitmap, cliprect, 6, 0, 0);
+ tile->draw(state->m_sys24_bitmap, cliprect, 5, 0, 0);
+ tile->draw(state->m_sys24_bitmap, cliprect, 4, 0, 0);
convert_bitmap(screen->machine(), bitmap, state->m_sys24_bitmap, cliprect);
@@ -2767,10 +2767,10 @@ SCREEN_UPDATE(model2)
model2_3d_frame_end( state, bitmap, cliprect );
bitmap_fill(state->m_sys24_bitmap, cliprect, 0);
- sys24_tile_draw(screen->machine(), state->m_sys24_bitmap, cliprect, 3, 0, 0);
- sys24_tile_draw(screen->machine(), state->m_sys24_bitmap, cliprect, 2, 0, 0);
- sys24_tile_draw(screen->machine(), state->m_sys24_bitmap, cliprect, 1, 0, 0);
- sys24_tile_draw(screen->machine(), state->m_sys24_bitmap, cliprect, 0, 0, 0);
+ tile->draw(state->m_sys24_bitmap, cliprect, 3, 0, 0);
+ tile->draw(state->m_sys24_bitmap, cliprect, 2, 0, 0);
+ tile->draw(state->m_sys24_bitmap, cliprect, 1, 0, 0);
+ tile->draw(state->m_sys24_bitmap, cliprect, 0, 0, 0);
convert_bitmap(screen->machine(), bitmap, state->m_sys24_bitmap, cliprect);
diff --git a/src/mame/video/segaic24.c b/src/mame/video/segaic24.c
index 68d50dc8b73..26370443091 100644
--- a/src/mame/video/segaic24.c
+++ b/src/mame/video/segaic24.c
@@ -12,81 +12,78 @@ System 24 68000x2 315-5292 315-5293 315-5294 315-5242 ym2151 da
*/
-/*
- * System 16 color palette formats
- */
+#include "emu.h"
+#include "segaic24.h"
-/* system24temp_ functions / variables are from shared rewrite files,
- once the rest of the rewrite is complete they can be removed, I
- just made a copy & renamed them for now to avoid any conflicts
-*/
+const device_type S24TILE = segas24_tile_config::static_alloc_device_config;
+const device_type S24SPRITE = segas24_sprite_config::static_alloc_device_config;
+const device_type S24MIXER = segas24_mixer_config::static_alloc_device_config;
-#include "emu.h"
-#include "segaic24.h"
+segas24_tile_config::segas24_tile_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
+ : device_config(mconfig, static_alloc_device_config, "S24TILE", tag, owner, clock)
+{
+}
+device_config *segas24_tile_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
+{
+ return global_alloc(segas24_tile_config(mconfig, tag, owner, clock));
+}
-static void set_color(running_machine &machine, int color, UINT8 r, UINT8 g, UINT8 b, int highlight)
+void segas24_tile_config::static_set_tile_mask(device_config *device, UINT16 _tile_mask)
{
- palette_set_color (machine, color, MAKE_RGB(r, g, b));
+ segas24_tile_config *dev = downcast<segas24_tile_config *>(device);
+ dev->tile_mask = _tile_mask;
+}
- if(highlight) {
- r = 255-0.6*(255-r);
- g = 255-0.6*(255-g);
- b = 255-0.6*(255-b);
- } else {
- r = 0.6*r;
- g = 0.6*g;
- b = 0.6*b;
- }
- palette_set_color(machine,color+machine.total_colors()/2, MAKE_RGB(r, g, b));
+device_t *segas24_tile_config::alloc_device(running_machine &machine) const
+{
+ return auto_alloc(machine, segas24_tile(machine, *this));
}
-// 315-5242
-// qgh expects to be able to read the palette shared between CPUs
-READ16_HANDLER( system24temp_sys16_paletteram1_r )
+segas24_sprite_config::segas24_sprite_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
+ : device_config(mconfig, static_alloc_device_config, "S24SPRITE", tag, owner, clock)
{
- return space->machine().generic.paletteram.u16[offset];
}
+device_config *segas24_sprite_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
+{
+ return global_alloc(segas24_sprite_config(mconfig, tag, owner, clock));
+}
-WRITE16_HANDLER (system24temp_sys16_paletteram1_w)
+device_t *segas24_sprite_config::alloc_device(running_machine &machine) const
{
- int r, g, b;
- COMBINE_DATA (space->machine().generic.paletteram.u16 + offset);
- data = space->machine().generic.paletteram.u16[offset];
+ return auto_alloc(machine, segas24_sprite(machine, *this));
+}
- r = (data & 0x00f) << 4;
- if(data & 0x1000)
- r |= 8;
- g = data & 0x0f0;
- if(data & 0x2000)
- g |= 8;
+segas24_mixer_config::segas24_mixer_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
+ : device_config(mconfig, static_alloc_device_config, "S24MIXER", tag, owner, clock)
+{
+}
- b = (data & 0xf00) >> 4;
- if(data & 0x4000)
- b |= 8;
+device_config *segas24_mixer_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
+{
+ return global_alloc(segas24_mixer_config(mconfig, tag, owner, clock));
+}
- r |= r >> 5;
- g |= g >> 5;
- b |= b >> 5;
- set_color(space->machine(), offset, r, g, b, data & 0x8000);
+device_t *segas24_mixer_config::alloc_device(running_machine &machine) const
+{
+ return auto_alloc(machine, segas24_mixer(machine, *this));
}
-// - System 24
-enum {SYS24_TILES = 0x4000};
-static UINT16 *sys24_char_ram, *sys24_tile_ram;
-static UINT16 sys24_tile_mask;
-static int sys24_char_gfx_index;
-static tilemap_t *sys24_tile_layer[4];
+segas24_tile::segas24_tile(running_machine &_machine, const segas24_tile_config &_config)
+ : device_t(_machine, _config),
+ config(_config)
+{
+}
#define XOR(a) WORD_XOR_BE(a)
-static const gfx_layout sys24_char_layout = {
+const gfx_layout segas24_tile::char_layout = {
8, 8,
SYS24_TILES,
4,
@@ -96,79 +93,75 @@ static const gfx_layout sys24_char_layout = {
8*32
};
-static TILE_GET_INFO( sys24_tile_info_0s )
+void segas24_tile::tile_info(int offset, tile_data *tileinfo, tilemap_memory_index tile_index)
{
- UINT16 val = sys24_tile_ram[tile_index];
+ UINT16 val = tile_ram[tile_index|offset];
tileinfo->category = (val & 0x8000) != 0;
- SET_TILE_INFO(sys24_char_gfx_index, val & sys24_tile_mask, (val >> 7) & 0xff, 0);
+ tileinfo_set(machine(), tileinfo, char_gfx_index, val & config.tile_mask, (val >> 7) & 0xff, 0);
}
-static TILE_GET_INFO( sys24_tile_info_0w )
+TILE_GET_INFO_DEVICE( segas24_tile::tile_info_0s )
{
- UINT16 val = sys24_tile_ram[tile_index|0x1000];
- tileinfo->category = (val & 0x8000) != 0;
- SET_TILE_INFO(sys24_char_gfx_index, val & sys24_tile_mask, (val >> 7) & 0xff, 0);
+ downcast<segas24_tile *>(device)->tile_info(0x0000, tileinfo, tile_index);
}
-static TILE_GET_INFO( sys24_tile_info_1s )
+TILE_GET_INFO_DEVICE( segas24_tile::tile_info_0w )
{
- UINT16 val = sys24_tile_ram[tile_index|0x2000];
- tileinfo->category = (val & 0x8000) != 0;
- SET_TILE_INFO(sys24_char_gfx_index, val & sys24_tile_mask, (val >> 7) & 0xff, 0);
+ downcast<segas24_tile *>(device)->tile_info(0x1000, tileinfo, tile_index);
}
-static TILE_GET_INFO( sys24_tile_info_1w )
+TILE_GET_INFO_DEVICE( segas24_tile::tile_info_1s )
{
- UINT16 val = sys24_tile_ram[tile_index|0x3000];
- tileinfo->category = (val & 0x8000) != 0;
- SET_TILE_INFO(sys24_char_gfx_index, val & sys24_tile_mask, (val >> 7) & 0xff, 0);
+ downcast<segas24_tile *>(device)->tile_info(0x2000, tileinfo, tile_index);
}
-void sys24_tile_vh_start(running_machine &machine, UINT16 tile_mask)
+TILE_GET_INFO_DEVICE( segas24_tile::tile_info_1w )
{
- sys24_tile_mask = tile_mask;
+ downcast<segas24_tile *>(device)->tile_info(0x3000, tileinfo, tile_index);
+}
- for(sys24_char_gfx_index = 0; sys24_char_gfx_index < MAX_GFX_ELEMENTS; sys24_char_gfx_index++)
- if (machine.gfx[sys24_char_gfx_index] == 0)
+void segas24_tile::device_start()
+{
+ for(char_gfx_index = 0; char_gfx_index < MAX_GFX_ELEMENTS; char_gfx_index++)
+ if (machine().gfx[char_gfx_index] == 0)
break;
- assert(sys24_char_gfx_index != MAX_GFX_ELEMENTS);
-
- sys24_char_ram = auto_alloc_array(machine, UINT16, 0x80000/2);
+ assert(char_gfx_index != MAX_GFX_ELEMENTS);
- sys24_tile_ram = auto_alloc_array(machine, UINT16, 0x10000/2);
+ char_ram = auto_alloc_array(machine(), UINT16, 0x80000/2);
+ tile_ram = auto_alloc_array(machine(), UINT16, 0x10000/2);
- sys24_tile_layer[0] = tilemap_create(machine, sys24_tile_info_0s, tilemap_scan_rows, 8, 8, 64, 64);
- sys24_tile_layer[1] = tilemap_create(machine, sys24_tile_info_0w, tilemap_scan_rows, 8, 8, 64, 64);
- sys24_tile_layer[2] = tilemap_create(machine, sys24_tile_info_1s, tilemap_scan_rows, 8, 8, 64, 64);
- sys24_tile_layer[3] = tilemap_create(machine, sys24_tile_info_1w, tilemap_scan_rows, 8, 8, 64, 64);
+ tile_layer[0] = tilemap_create_device(this, tile_info_0s, tilemap_scan_rows, 8, 8, 64, 64);
+ tile_layer[1] = tilemap_create_device(this, tile_info_0w, tilemap_scan_rows, 8, 8, 64, 64);
+ tile_layer[2] = tilemap_create_device(this, tile_info_1s, tilemap_scan_rows, 8, 8, 64, 64);
+ tile_layer[3] = tilemap_create_device(this, tile_info_1w, tilemap_scan_rows, 8, 8, 64, 64);
- tilemap_set_transparent_pen(sys24_tile_layer[0], 0);
- tilemap_set_transparent_pen(sys24_tile_layer[1], 0);
- tilemap_set_transparent_pen(sys24_tile_layer[2], 0);
- tilemap_set_transparent_pen(sys24_tile_layer[3], 0);
+ tilemap_set_transparent_pen(tile_layer[0], 0);
+ tilemap_set_transparent_pen(tile_layer[1], 0);
+ tilemap_set_transparent_pen(tile_layer[2], 0);
+ tilemap_set_transparent_pen(tile_layer[3], 0);
- memset(sys24_char_ram, 0, 0x80000);
- memset(sys24_tile_ram, 0, 0x10000);
+ memset(char_ram, 0, 0x80000);
+ memset(tile_ram, 0, 0x10000);
- machine.gfx[sys24_char_gfx_index] = gfx_element_alloc(machine, &sys24_char_layout, (UINT8 *)sys24_char_ram, machine.total_colors() / 16, 0);
+ machine().gfx[char_gfx_index] = gfx_element_alloc(machine(), &char_layout, (UINT8 *)char_ram, machine().total_colors() / 16, 0);
- state_save_register_global_pointer(machine, sys24_tile_ram, 0x10000/2);
- state_save_register_global_pointer(machine, sys24_char_ram, 0x80000/2);
+ save_pointer(NAME(tile_ram), 0x10000/2);
+ save_pointer(NAME(char_ram), 0x80000/2);
}
-static void sys24_tile_draw_rect(running_machine &machine, bitmap_t *bm, bitmap_t *tm, bitmap_t *dm, const UINT16 *mask,
- UINT16 tpri, UINT8 lpri, int win, int sx, int sy, int xx1, int yy1, int xx2, int yy2)
+void segas24_tile::draw_rect(bitmap_t *bm, bitmap_t *tm, bitmap_t *dm, const UINT16 *mask,
+ UINT16 tpri, UINT8 lpri, int win, int sx, int sy, int xx1, int yy1, int xx2, int yy2)
{
int y;
const UINT16 *source = ((UINT16 *)bm->base) + sx + sy*bm->rowpixels;
const UINT8 *trans = ((UINT8 *) tm->base) + sx + sy*tm->rowpixels;
- UINT8 *prib = (UINT8 *)machine.priority_bitmap->base;
+ UINT8 *prib = (UINT8 *)machine().priority_bitmap->base;
UINT16 *dest = (UINT16 *)dm->base;
tpri |= TILEMAP_PIXEL_LAYER0;
dest += yy1*dm->rowpixels + xx1;
- prib += yy1*machine.priority_bitmap->rowpixels + xx1;
+ prib += yy1*machine().priority_bitmap->rowpixels + xx1;
mask += yy1*4;
yy2 -= yy1;
@@ -280,7 +273,7 @@ static void sys24_tile_draw_rect(running_machine &machine, bitmap_t *bm, bitmap_
source += bm->rowpixels;
trans += tm->rowpixels;
dest += dm->rowpixels;
- prib += machine.priority_bitmap->rowpixels;
+ prib += machine().priority_bitmap->rowpixels;
mask += 4;
}
}
@@ -288,16 +281,16 @@ static void sys24_tile_draw_rect(running_machine &machine, bitmap_t *bm, bitmap_
// The rgb version is used by model 1 & 2 which do not need to care
// about sprite priority hence the lack of support for the
-// machine.priority_bitmap
+// priority_bitmap
-static void sys24_tile_draw_rect_rgb(running_machine &machine, bitmap_t *bm, bitmap_t *tm, bitmap_t *dm, const UINT16 *mask,
- UINT16 tpri, UINT8 lpri, int win, int sx, int sy, int xx1, int yy1, int xx2, int yy2)
+void segas24_tile::draw_rect_rgb(bitmap_t *bm, bitmap_t *tm, bitmap_t *dm, const UINT16 *mask,
+ UINT16 tpri, UINT8 lpri, int win, int sx, int sy, int xx1, int yy1, int xx2, int yy2)
{
int y;
const UINT16 *source = ((UINT16 *)bm->base) + sx + sy*bm->rowpixels;
const UINT8 *trans = ((UINT8 *) tm->base) + sx + sy*tm->rowpixels;
UINT16 *dest = (UINT16 *)dm->base;
- const pen_t *pens = machine.pens;
+ const pen_t *pens = machine().pens;
tpri |= TILEMAP_PIXEL_LAYER0;
@@ -402,12 +395,12 @@ static void sys24_tile_draw_rect_rgb(running_machine &machine, bitmap_t *bm, bit
}
}
-void sys24_tile_draw(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int lpri, int flags)
+void segas24_tile::draw(bitmap_t *bitmap, const rectangle *cliprect, int layer, int lpri, int flags)
{
- UINT16 hscr = sys24_tile_ram[0x5000+(layer >> 1)];
- UINT16 vscr = sys24_tile_ram[0x5004+(layer >> 1)];
- UINT16 ctrl = sys24_tile_ram[0x5004+((layer >> 1) & 2)];
- UINT16 *mask = sys24_tile_ram + (layer & 4 ? 0x6800 : 0x6000);
+ UINT16 hscr = tile_ram[0x5000+(layer >> 1)];
+ UINT16 vscr = tile_ram[0x5004+(layer >> 1)];
+ UINT16 ctrl = tile_ram[0x5004+((layer >> 1) & 2)];
+ UINT16 *mask = tile_ram + (layer & 4 ? 0x6800 : 0x6000);
UINT16 tpri = layer & 1;
lpri = 1 << lpri;
@@ -422,11 +415,11 @@ void sys24_tile_draw(running_machine &machine, bitmap_t *bitmap, const rectangle
if(layer & 1)
return;
- tilemap_set_scrolly(sys24_tile_layer[layer], 0, vscr & 0x1ff);
- tilemap_set_scrolly(sys24_tile_layer[layer|1], 0, vscr & 0x1ff);
+ tilemap_set_scrolly(tile_layer[layer], 0, vscr & 0x1ff);
+ tilemap_set_scrolly(tile_layer[layer|1], 0, vscr & 0x1ff);
if(hscr & 0x8000) {
- UINT16 *hscrtb = sys24_tile_ram + 0x4000 + 0x200*layer;
+ UINT16 *hscrtb = tile_ram + 0x4000 + 0x200*layer;
switch((ctrl & 0x6000) >> 13) {
case 1: {
@@ -446,8 +439,8 @@ void sys24_tile_draw(running_machine &machine, bitmap_t *bitmap, const rectangle
hscr = hscrtb[y];
h = hscr & 0x1ff;
- tilemap_set_scrollx(sys24_tile_layer[l1], 0, -h);
- tilemap_draw(bitmap, &c, sys24_tile_layer[l1], tpri, lpri);
+ tilemap_set_scrollx(tile_layer[l1], 0, -h);
+ tilemap_draw(bitmap, &c, tile_layer[l1], tpri, lpri);
}
break;
}
@@ -462,8 +455,8 @@ void sys24_tile_draw(running_machine &machine, bitmap_t *bitmap, const rectangle
hscr = hscrtb[y];
h = hscr & 0x1ff;
- tilemap_set_scrollx(sys24_tile_layer[layer], 0, -h);
- tilemap_set_scrollx(sys24_tile_layer[layer|1], 0, -h);
+ tilemap_set_scrollx(tile_layer[layer], 0, -h);
+ tilemap_set_scrollx(tile_layer[layer|1], 0, -h);
if(c1.max_x >= h)
c1.max_x = h-1;
@@ -474,16 +467,16 @@ void sys24_tile_draw(running_machine &machine, bitmap_t *bitmap, const rectangle
c1.min_y = c1.max_y = c2.min_y = c2.max_y = y;
- tilemap_draw(bitmap, &c1, sys24_tile_layer[l1], tpri, lpri);
- tilemap_draw(bitmap, &c2, sys24_tile_layer[l1^1], tpri, lpri);
+ tilemap_draw(bitmap, &c1, tile_layer[l1], tpri, lpri);
+ tilemap_draw(bitmap, &c2, tile_layer[l1^1], tpri, lpri);
}
break;
}
}
} else {
- tilemap_set_scrollx(sys24_tile_layer[layer], 0, -(hscr & 0x1ff));
- tilemap_set_scrollx(sys24_tile_layer[layer|1], 0, -(hscr & 0x1ff));
+ tilemap_set_scrollx(tile_layer[layer], 0, -(hscr & 0x1ff));
+ tilemap_set_scrollx(tile_layer[layer|1], 0, -(hscr & 0x1ff));
switch((ctrl & 0x6000) >> 13) {
case 1: {
@@ -498,8 +491,8 @@ void sys24_tile_draw(running_machine &machine, bitmap_t *bitmap, const rectangle
if(!((-vscr) & 0x200))
layer ^= 1;
- tilemap_draw(bitmap, &c1, sys24_tile_layer[layer], tpri, lpri);
- tilemap_draw(bitmap, &c2, sys24_tile_layer[layer^1], tpri, lpri);
+ tilemap_draw(bitmap, &c1, tile_layer[layer], tpri, lpri);
+ tilemap_draw(bitmap, &c2, tile_layer[layer^1], tpri, lpri);
break;
}
case 2: case 3: {
@@ -514,8 +507,8 @@ void sys24_tile_draw(running_machine &machine, bitmap_t *bitmap, const rectangle
if(!((+hscr) & 0x200))
layer ^= 1;
- tilemap_draw(bitmap, &c1, sys24_tile_layer[layer], tpri, lpri);
- tilemap_draw(bitmap, &c2, sys24_tile_layer[layer^1], tpri, lpri);
+ tilemap_draw(bitmap, &c1, tile_layer[layer], tpri, lpri);
+ tilemap_draw(bitmap, &c2, tile_layer[layer^1], tpri, lpri);
break;
}
}
@@ -523,32 +516,32 @@ void sys24_tile_draw(running_machine &machine, bitmap_t *bitmap, const rectangle
} else {
bitmap_t *bm, *tm;
- void (*draw)(running_machine &machine, bitmap_t *, bitmap_t *, bitmap_t *, const UINT16 *,
+ void (segas24_tile::*draw)(bitmap_t *, bitmap_t *, bitmap_t *, const UINT16 *,
UINT16, UINT8, int, int, int, int, int, int, int);
int win = layer & 1;
if(bitmap->format != BITMAP_FORMAT_INDEXED16)
- draw = sys24_tile_draw_rect_rgb;
+ draw = &segas24_tile::draw_rect_rgb;
else
- draw = sys24_tile_draw_rect;
+ draw = &segas24_tile::draw_rect;
- bm = tilemap_get_pixmap(sys24_tile_layer[layer]);
- tm = tilemap_get_flagsmap(sys24_tile_layer[layer]);
+ bm = tilemap_get_pixmap(tile_layer[layer]);
+ tm = tilemap_get_flagsmap(tile_layer[layer]);
if(hscr & 0x8000) {
int y;
- UINT16 *hscrtb = sys24_tile_ram + 0x4000 + 0x200*layer;
+ UINT16 *hscrtb = tile_ram + 0x4000 + 0x200*layer;
vscr &= 0x1ff;
for(y=0; y<384; y++) {
hscr = (-hscrtb[y]) & 0x1ff;
if(hscr + 496 <= 512) {
// Horizontal split unnecessary
- draw(machine, bm, tm, bitmap, mask, tpri, lpri, win, hscr, vscr, 0, y, 496, y+1);
+ (this->*draw)(bm, tm, bitmap, mask, tpri, lpri, win, hscr, vscr, 0, y, 496, y+1);
} else {
// Horizontal split necessary
- draw(machine, bm, tm, bitmap, mask, tpri, lpri, win, hscr, vscr, 0, y, 512-hscr, y+1);
- draw(machine, bm, tm, bitmap, mask, tpri, lpri, win, 0, vscr, 512-hscr, y, 496, y+1);
+ (this->*draw)(bm, tm, bitmap, mask, tpri, lpri, win, hscr, vscr, 0, y, 512-hscr, y+1);
+ (this->*draw)(bm, tm, bitmap, mask, tpri, lpri, win, 0, vscr, 512-hscr, y, 496, y+1);
}
vscr = (vscr + 1) & 0x1ff;
}
@@ -560,89 +553,90 @@ void sys24_tile_draw(running_machine &machine, bitmap_t *bitmap, const rectangle
// Horizontal split unnecessary
if(vscr + 384 <= 512) {
// Vertical split unnecessary
- draw(machine, bm, tm, bitmap, mask, tpri, lpri, win, hscr, vscr, 0, 0, 496, 384);
+ (this->*draw)(bm, tm, bitmap, mask, tpri, lpri, win, hscr, vscr, 0, 0, 496, 384);
} else {
// Vertical split necessary
- draw(machine, bm, tm, bitmap, mask, tpri, lpri, win, hscr, vscr, 0, 0, 496, 512-vscr);
- draw(machine, bm, tm, bitmap, mask, tpri, lpri, win, hscr, 0, 0, 512-vscr, 496, 384);
+ (this->*draw)(bm, tm, bitmap, mask, tpri, lpri, win, hscr, vscr, 0, 0, 496, 512-vscr);
+ (this->*draw)(bm, tm, bitmap, mask, tpri, lpri, win, hscr, 0, 0, 512-vscr, 496, 384);
}
} else {
// Horizontal split necessary
if(vscr + 384 <= 512) {
// Vertical split unnecessary
- draw(machine, bm, tm, bitmap, mask, tpri, lpri, win, hscr, vscr, 0, 0, 512-hscr, 384);
- draw(machine, bm, tm, bitmap, mask, tpri, lpri, win, 0, vscr, 512-hscr, 0, 496, 384);
+ (this->*draw)(bm, tm, bitmap, mask, tpri, lpri, win, hscr, vscr, 0, 0, 512-hscr, 384);
+ (this->*draw)(bm, tm, bitmap, mask, tpri, lpri, win, 0, vscr, 512-hscr, 0, 496, 384);
} else {
// Vertical split necessary
- draw(machine, bm, tm, bitmap, mask, tpri, lpri, win, hscr, vscr, 0, 0, 512-hscr, 512-vscr);
- draw(machine, bm, tm, bitmap, mask, tpri, lpri, win, 0, vscr, 512-hscr, 0, 496, 512-vscr);
- draw(machine, bm, tm, bitmap, mask, tpri, lpri, win, hscr, 0, 0, 512-vscr, 512-hscr, 384);
- draw(machine, bm, tm, bitmap, mask, tpri, lpri, win, 0, 0, 512-hscr, 512-vscr, 496, 384);
+ (this->*draw)(bm, tm, bitmap, mask, tpri, lpri, win, hscr, vscr, 0, 0, 512-hscr, 512-vscr);
+ (this->*draw)(bm, tm, bitmap, mask, tpri, lpri, win, 0, vscr, 512-hscr, 0, 496, 512-vscr);
+ (this->*draw)(bm, tm, bitmap, mask, tpri, lpri, win, hscr, 0, 0, 512-vscr, 512-hscr, 384);
+ (this->*draw)(bm, tm, bitmap, mask, tpri, lpri, win, 0, 0, 512-hscr, 512-vscr, 496, 384);
}
}
}
}
}
-READ16_HANDLER(sys24_tile_r)
+READ16_MEMBER(segas24_tile::tile_r)
{
- return sys24_tile_ram[offset];
+ return tile_ram[offset];
}
-READ16_HANDLER(sys24_char_r)
+READ16_MEMBER(segas24_tile::char_r)
{
- return sys24_char_ram[offset];
+ return char_ram[offset];
}
-WRITE16_HANDLER(sys24_tile_w)
+WRITE16_MEMBER(segas24_tile::tile_w)
{
- COMBINE_DATA(sys24_tile_ram + offset);
+ COMBINE_DATA(tile_ram + offset);
if(offset < 0x4000)
- tilemap_mark_tile_dirty(sys24_tile_layer[offset >> 12], offset & 0xfff);
+ tilemap_mark_tile_dirty(tile_layer[offset >> 12], offset & 0xfff);
}
-WRITE16_HANDLER(sys24_char_w)
+WRITE16_MEMBER(segas24_tile::char_w)
{
- UINT16 old = sys24_char_ram[offset];
- COMBINE_DATA(sys24_char_ram + offset);
- if(old != sys24_char_ram[offset]) {
- gfx_element_mark_dirty(space->machine().gfx[sys24_char_gfx_index], offset / 16);
- }
+ UINT16 old = char_ram[offset];
+ COMBINE_DATA(char_ram + offset);
+ if(old != char_ram[offset])
+ gfx_element_mark_dirty(machine().gfx[char_gfx_index], offset / 16);
}
-READ32_HANDLER(sys24_tile32_r)
+READ32_MEMBER(segas24_tile::tile32_r)
{
- return sys24_tile_r(space, offset*2, mem_mask&0xffff) | sys24_tile_r(space, (offset*2)+1, mem_mask>>16)<<16;
+ return tile_r(space, offset*2, mem_mask&0xffff) | tile_r(space, (offset*2)+1, mem_mask>>16)<<16;
}
-READ32_HANDLER(sys24_char32_r)
+READ32_MEMBER(segas24_tile::char32_r)
{
- return sys24_char_r(space, offset*2, mem_mask&0xffff) | sys24_char_r(space, (offset*2)+1, mem_mask>>16)<<16;
+ return char_r(space, offset*2, mem_mask&0xffff) | char_r(space, (offset*2)+1, mem_mask>>16)<<16;
}
-WRITE32_HANDLER(sys24_tile32_w)
+WRITE32_MEMBER(segas24_tile::tile32_w)
{
- sys24_tile_w(space, offset*2, data&0xffff, mem_mask&0xffff);
- sys24_tile_w(space, (offset*2)+1, data>>16, mem_mask>>16);
+ tile_w(space, offset*2, data&0xffff, mem_mask&0xffff);
+ tile_w(space, (offset*2)+1, data>>16, mem_mask>>16);
}
-WRITE32_HANDLER(sys24_char32_w)
+WRITE32_MEMBER(segas24_tile::char32_w)
{
- sys24_char_w(space,offset*2, data&0xffff, mem_mask&0xffff);
- sys24_char_w(space,(offset*2)+1, data>>16, mem_mask>>16);
+ char_w(space, offset*2, data&0xffff, mem_mask&0xffff);
+ char_w(space, (offset*2)+1, data>>16, mem_mask>>16);
}
-// - System 24
-static UINT16 *sys24_sprite_ram;
+segas24_sprite::segas24_sprite(running_machine &_machine, const segas24_sprite_config &_config)
+ : device_t(_machine, _config),
+ config(_config)
+{
+}
-void sys24_sprite_vh_start(running_machine &machine)
+void segas24_sprite::device_start()
{
- sys24_sprite_ram = auto_alloc_array(machine, UINT16, 0x40000/2);
+ sprite_ram = auto_alloc_array(machine(), UINT16, 0x40000/2);
- state_save_register_global_pointer(machine, sys24_sprite_ram, 0x40000/2);
- // kc = 0;
+ save_pointer(NAME(sprite_ram), 0x40000/2);
}
/* System24 sprites
@@ -669,7 +663,7 @@ void sys24_sprite_vh_start(running_machine &machine)
0 11------ --------
*/
-void sys24_sprite_draw(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, const int *spri)
+void segas24_sprite::draw(bitmap_t *bitmap, const rectangle *cliprect, const int *spri)
{
UINT16 curspr = 0;
int countspr = 0;
@@ -686,7 +680,7 @@ void sys24_sprite_draw(running_machine &machine, bitmap_t *bitmap, const rectang
UINT16 *source;
UINT16 type;
- source = sys24_sprite_ram + (curspr << 3);
+ source = sprite_ram + (curspr << 3);
if(curspr == 0 && source[0] == 0)
break;
@@ -783,7 +777,7 @@ void sys24_sprite_draw(running_machine &machine, bitmap_t *bitmap, const rectang
flipy = source[4] & 0x8000;
sy = 1 << ((source[4] & 0x7000) >> 12);
- pix = &sys24_sprite_ram[(source[3] & 0x3fff)* 0x8];
+ pix = &sprite_ram[(source[3] & 0x3fff)* 0x8];
for(px=0; px<8; px++) {
int c;
c = pix[px] >> 8;
@@ -830,8 +824,8 @@ void sys24_sprite_draw(running_machine &machine, bitmap_t *bitmap, const rectang
if(xpos2 >= min_x && xpos2 <= max_x) {
int zx1 = flipx ? 7-zx : zx;
UINT32 neweroffset = (newoffset+(zx1>>2))&0x1ffff; // crackdown sometimes attempts to use data past the end of spriteram
- int c = (sys24_sprite_ram[neweroffset] >> (((~zx1) & 3) << 2)) & 0xf;
- UINT8 *pri = BITMAP_ADDR8(machine.priority_bitmap, ypos1, xpos2);
+ int c = (sprite_ram[neweroffset] >> (((~zx1) & 3) << 2)) & 0xf;
+ UINT8 *pri = BITMAP_ADDR8(machine().priority_bitmap, ypos1, xpos2);
if(!(*pri & pm[c])) {
c = colors[c];
if(c) {
@@ -868,39 +862,41 @@ void sys24_sprite_draw(running_machine &machine, bitmap_t *bitmap, const rectang
}
-WRITE16_HANDLER(sys24_sprite_w)
+WRITE16_MEMBER(segas24_sprite::write)
{
- COMBINE_DATA(sys24_sprite_ram + offset);
+ COMBINE_DATA(sprite_ram + offset);
}
-READ16_HANDLER(sys24_sprite_r)
+READ16_MEMBER(segas24_sprite::read)
{
- return sys24_sprite_ram[offset];
+ return sprite_ram[offset];
}
-// Programmable mixers
-// System 24
-static UINT16 sys24_mixer_reg[0x10];
+segas24_mixer::segas24_mixer(running_machine &_machine, const segas24_mixer_config &_config)
+ : device_t(_machine, _config),
+ config(_config)
+{
+}
-void sys24_mixer_vh_start(running_machine &machine)
+void segas24_mixer::device_start()
{
- memset(sys24_mixer_reg, 0, sizeof(sys24_mixer_reg));
- state_save_register_global_array(machine, sys24_mixer_reg);
+ memset(mixer_reg, 0, sizeof(mixer_reg));
+ save_item(NAME(mixer_reg));
}
-WRITE16_HANDLER (sys24_mixer_w)
+WRITE16_MEMBER(segas24_mixer::write)
{
- COMBINE_DATA(sys24_mixer_reg + offset);
+ COMBINE_DATA(mixer_reg + offset);
}
-READ16_HANDLER (sys24_mixer_r)
+READ16_MEMBER(segas24_mixer::read)
{
- return sys24_mixer_reg[offset];
+ return mixer_reg[offset];
}
-int sys24_mixer_get_reg(int reg)
+UINT16 segas24_mixer::get_reg(int reg)
{
- return sys24_mixer_reg[reg];
+ return mixer_reg[reg];
}
diff --git a/src/mame/video/segaic24.h b/src/mame/video/segaic24.h
index 76d556cc68c..3774632d895 100644
--- a/src/mame/video/segaic24.h
+++ b/src/mame/video/segaic24.h
@@ -1,43 +1,153 @@
-#ifndef __SEGAIC_H
-#define __SEGAIC_H
-
-/* system24temp_ functions / variables are from shared rewrite files,
- once the rest of the rewrite is complete they can be removed, I
- just made a copy & renamed them for now to avoid any conflicts
-*/
-
-READ16_HANDLER (system24temp_sys16_paletteram1_r);
-WRITE16_HANDLER (system24temp_sys16_paletteram1_w);
-
-// Tilemaps
-// System24
-void sys24_tile_vh_start(running_machine &machine, UINT16 tile_mask);
-void sys24_tile_draw(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int pri, int flags);
-
-READ16_HANDLER(sys24_tile_r);
-READ16_HANDLER(sys24_char_r);
-WRITE16_HANDLER(sys24_tile_w);
-WRITE16_HANDLER(sys24_char_w);
-
-READ32_HANDLER(sys24_tile32_r);
-READ32_HANDLER(sys24_char32_r);
-WRITE32_HANDLER(sys24_tile32_w);
-WRITE32_HANDLER(sys24_char32_w);
-
-// Sprites
-// System24
-void sys24_sprite_vh_start(running_machine &machine);
-void sys24_sprite_draw(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, const int *spri);
-
-WRITE16_HANDLER (sys24_sprite_w);
-READ16_HANDLER (sys24_sprite_r);
-
-// Programmable mixers
-// System24
-void sys24_mixer_vh_start(running_machine &machine);
-int sys24_mixer_get_reg(int reg);
-
-WRITE16_HANDLER (sys24_mixer_w);
-READ16_HANDLER (sys24_mixer_r);
+#ifndef __SEGAIC24_H
+#define __SEGAIC24_H
+
+#define MCFG_S24TILE_DEVICE_ADD(_tag, tile_mask) \
+ MCFG_DEVICE_ADD(_tag, S24TILE, 0) \
+ segas24_tile_config::static_set_tile_mask(device, tile_mask);
+
+#define MCFG_S24SPRITE_DEVICE_ADD(_tag) \
+ MCFG_DEVICE_ADD(_tag, S24SPRITE, 0)
+
+#define MCFG_S24MIXER_DEVICE_ADD(_tag) \
+ MCFG_DEVICE_ADD(_tag, S24MIXER, 0)
+
+class segas24_tile;
+class segas24_sprite;
+class segas24_mixer;
+
+class segas24_tile_config : public device_config
+{
+ friend class segas24_tile;
+
+protected:
+ segas24_tile_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
+
+public:
+ static void static_set_tile_mask(device_config *device, UINT16 tile_mask);
+
+ static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
+ virtual device_t *alloc_device(running_machine &machine) const;
+
+private:
+ UINT16 tile_mask;
+};
+
+class segas24_sprite_config : public device_config
+{
+ friend class segas24_sprite;
+
+protected:
+ segas24_sprite_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
+
+public:
+ static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
+ virtual device_t *alloc_device(running_machine &machine) const;
+};
+
+class segas24_mixer_config : public device_config
+{
+ friend class segas24_mixer;
+
+protected:
+ segas24_mixer_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
+
+public:
+ static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
+ virtual device_t *alloc_device(running_machine &machine) const;
+};
+
+
+class segas24_tile : public device_t
+{
+ friend class segas24_tile_config;
+
+ segas24_tile(running_machine &_machine, const segas24_tile_config &config);
+
+public:
+ DECLARE_READ16_MEMBER(tile_r);
+ DECLARE_WRITE16_MEMBER(tile_w);
+ DECLARE_READ16_MEMBER(char_r);
+ DECLARE_WRITE16_MEMBER(char_w);
+
+ DECLARE_READ32_MEMBER(tile32_r);
+ DECLARE_WRITE32_MEMBER(tile32_w);
+ DECLARE_READ32_MEMBER(char32_r);
+ DECLARE_WRITE32_MEMBER(char32_w);
+
+ void draw(bitmap_t *bitmap, const rectangle *cliprect, int layer, int pri, int flags);
+
+protected:
+ virtual void device_start();
+
+ const segas24_tile_config &config;
+
+private:
+ enum {
+ SYS24_TILES = 0x4000
+ };
+
+ UINT16 *char_ram, *tile_ram;
+ int char_gfx_index;
+ tilemap_t *tile_layer[4];
+
+ static const gfx_layout char_layout;
+
+ void tile_info(int offset, tile_data *tileinfo, tilemap_memory_index tile_index);
+ static TILE_GET_INFO_DEVICE(tile_info_0s);
+ static TILE_GET_INFO_DEVICE(tile_info_0w);
+ static TILE_GET_INFO_DEVICE(tile_info_1s);
+ static TILE_GET_INFO_DEVICE(tile_info_1w);
+
+ void draw_rect(bitmap_t *bm, bitmap_t *tm, bitmap_t *dm, const UINT16 *mask,
+ UINT16 tpri, UINT8 lpri, int win, int sx, int sy, int xx1, int yy1, int xx2, int yy2);
+ void draw_rect_rgb(bitmap_t *bm, bitmap_t *tm, bitmap_t *dm, const UINT16 *mask,
+ UINT16 tpri, UINT8 lpri, int win, int sx, int sy, int xx1, int yy1, int xx2, int yy2);
+
+};
+
+class segas24_sprite : public device_t
+{
+ friend class segas24_sprite_config;
+
+ segas24_sprite(running_machine &_machine, const segas24_sprite_config &config);
+
+public:
+ DECLARE_READ16_MEMBER(read);
+ DECLARE_WRITE16_MEMBER(write);
+
+ void draw(bitmap_t *bitmap, const rectangle *cliprect, const int *spri);
+
+protected:
+ virtual void device_start();
+
+ const segas24_sprite_config &config;
+
+private:
+ UINT16 *sprite_ram;
+};
+
+
+class segas24_mixer : public device_t
+{
+ friend class segas24_mixer_config;
+
+ segas24_mixer(running_machine &_machine, const segas24_mixer_config &config);
+
+public:
+ DECLARE_READ16_MEMBER(read);
+ DECLARE_WRITE16_MEMBER(write);
+
+ UINT16 get_reg(int reg);
+
+protected:
+ virtual void device_start();
+
+ const segas24_mixer_config &config;
+
+private:
+ UINT16 mixer_reg[16];
+};
+
+extern const device_type S24TILE, S24SPRITE, S24MIXER;
#endif
diff --git a/src/mame/video/segas24.c b/src/mame/video/segas24.c
index 939e5d5f86e..4e1cee5400d 100644
--- a/src/mame/video/segas24.c
+++ b/src/mame/video/segas24.c
@@ -1,32 +1,33 @@
+#include <vector>
+#include <algorithm>
+
#include "emu.h"
#include "video/segaic24.h"
#include "includes/segas24.h"
-VIDEO_START(system24)
-{
- sys24_tile_vh_start(machine, 0xfff);
- sys24_sprite_vh_start(machine);
- sys24_mixer_vh_start(machine);
-}
-static int layer_cmp(const void *pl1, const void *pl2)
-{
- static const int default_pri[12] = { 0, 1, 2, 3, 4, 5, 6, 7, -4, -3, -2, -1 };
- int l1 = *(int *)pl1;
- int l2 = *(int *)pl2;
- int p1 = sys24_mixer_get_reg(l1) & 7;
- int p2 = sys24_mixer_get_reg(l2) & 7;
- if(p1 != p2)
- return p1 - p2;
- return default_pri[l2] - default_pri[l1];
-}
+namespace {
+ struct layer_sort {
+ layer_sort(segas24_mixer *_mixer) { mixer = _mixer; }
+
+ bool operator()(int l1, int l2) {
+ static const int default_pri[12] = { 0, 1, 2, 3, 4, 5, 6, 7, -4, -3, -2, -1 };
+ int p1 = mixer->get_reg(l1) & 7;
+ int p2 = mixer->get_reg(l2) & 7;
+ if(p1 != p2)
+ return p1 - p2 < 0;
+ return default_pri[l2] - default_pri[l1] < 0;
+ }
+
+ segas24_mixer *mixer;
+ };
+};
SCREEN_UPDATE(system24)
{
- int i, level;
- int order[12], spri[4];
+ segas24_state *state = screen->machine().driver_data<segas24_state>();
- if(sys24_mixer_get_reg(13) & 1) {
+ if(state->vmixer->get_reg(13) & 1) {
bitmap_fill(bitmap, 0, get_black_pen(screen->machine()));
return 0;
}
@@ -34,19 +35,23 @@ SCREEN_UPDATE(system24)
bitmap_fill(screen->machine().priority_bitmap, 0, 0);
bitmap_fill(bitmap, cliprect, 0);
- for(i=0; i<12; i++)
+ std::vector<int> order;
+ order.resize(12);
+ for(int i=0; i<12; i++)
order[i] = i;
- qsort(order, 12, sizeof(int), layer_cmp);
- level = 0;
- for(i=0; i<12; i++)
+ std::sort(order.begin(), order.end(), layer_sort(state->vmixer));
+
+ int spri[4];
+ int level = 0;
+ for(int i=0; i<12; i++)
if(order[i] < 8)
- sys24_tile_draw(screen->machine(), bitmap, cliprect, order[i], level, 0);
+ state->vtile->draw(bitmap, cliprect, order[i], level, 0);
else {
spri[order[i]-8] = level;
level++;
}
- sys24_sprite_draw(screen->machine(), bitmap, cliprect, spri);
+ state->vsprite->draw(bitmap, cliprect, spri);
return 0;
}