Added read_status() and write_command() methods to the okim6295_device

for the common case where these are done outside the context of a read
or write handler (it was annoying to pass in the fake address space
for these cases).

Added DEVCB_DEVICE_MEMBER() macros which allow you to specify a
READ8_MEMBER or WRITE8_MEMBER in a device callback (via dynamically
generated trampolines).

Replaced all remaining calls to okim6295_r/okim6295_w with calls to
the new methods, and removed the static functions.
This commit is contained in:
Aaron Giles 2010-09-05 17:07:31 +00:00
parent e4de6b7bd9
commit 8826428120
31 changed files with 271 additions and 266 deletions

View File

@ -61,6 +61,22 @@
MACROS
***************************************************************************/
// static template for a read8 stub function that calls through a given READ8_MEMBER
template<class _Class, UINT8 (_Class::*_Function)(address_space &, offs_t, UINT8)>
UINT8 devcb_stub(device_t *device, offs_t offset)
{
_Class *target = downcast<_Class *>(device);
return (target->*_Function)(*device->machine->m_nonspecific_space, offset, 0xff);
}
// static template for a write8 stub function that calls through a given WRITE8_MEMBER
template<class _Class, void (_Class::*_Function)(address_space &, offs_t, UINT8, UINT8)>
void devcb_stub(device_t *device, offs_t offset, UINT8 data)
{
_Class *target = downcast<_Class *>(device);
(target->*_Function)(*device->machine->m_nonspecific_space, offset, data, 0xff);
}
#define DEVCB_NULL { DEVCB_TYPE_NULL }
/* standard line or read/write handlers with the calling device passed */
@ -72,6 +88,7 @@
/* line or read/write handlers for another device */
#define DEVCB_DEVICE_LINE(tag,func) { DEVCB_TYPE_DEVICE, tag, (func), NULL, NULL }
#define DEVCB_DEVICE_HANDLER(tag,func) { DEVCB_TYPE_DEVICE, tag, NULL, (func), NULL }
#define DEVCB_DEVICE_MEMBER(tag,cls,memb) { DEVCB_TYPE_DEVICE, tag, NULL, &devcb_stub<cls, &cls::memb>, NULL }
/* read/write handlers for a given CPU's address space */
#define DEVCB_MEMORY_HANDLER(cpu,space,func) { DEVCB_TYPE_MEMORY(ADDRESS_SPACE_##space), (cpu), NULL, NULL, (func) }
@ -102,6 +119,8 @@
#define MDRV_DEVICE_CONFIG_READ_HANDLER(_struct, _entry, _tag, _func) MDRV_DEVICE_CONFIG_DEVCB_GENERIC(read, _struct, _entry, _tag, DEVCB_TYPE_DEVICE, NULL, _func, NULL)
#define MDRV_DEVICE_CONFIG_WRITE_HANDLER(_struct, _entry, _tag, _func) MDRV_DEVICE_CONFIG_DEVCB_GENERIC(write, _struct, _entry, _tag, DEVCB_TYPE_DEVICE, NULL, _func, NULL)
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
@ -110,11 +129,6 @@
class device_config;
/* read/write types for I/O lines (similar to read/write handlers but no offset) */
typedef int (*read_line_device_func)(device_t *device);
typedef void (*write_line_device_func)(device_t *device, int state);
/* static structure used for device configuration when the desired callback type is a read_line_device_func */
typedef struct _devcb_read_line devcb_read_line;
struct _devcb_read_line

View File

@ -102,6 +102,11 @@ class device_missing_dependencies : public emu_exception { };
typedef device_config *(*device_type)(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
// read/write types for I/O lines (similar to read/write handlers but no offset)
typedef int (*read_line_device_func)(device_t *device);
typedef void (*write_line_device_func)(device_t *device, int state);
// ======================> tagged_device_list

View File

@ -77,7 +77,6 @@ typedef device_config * (*machine_config_constructor)(machine_config &config, de
// devices and callbacks
#include "devintrf.h"
#include "devcb.h"
#include "distate.h"
#include "dimemory.h"
#include "diexec.h"
@ -129,6 +128,7 @@ typedef device_config * (*machine_config_constructor)(machine_config &config, de
#include "sound.h"
// generic helpers
#include "devcb.h"
#include "drivers/xtal.h"
#include "audio/generic.h"
#include "machine/generic.h"

View File

@ -287,15 +287,10 @@ void okim6295_device::set_pin7(int pin7)
//-------------------------------------------------
// status_read - read the status register
// read_status - read the status register
//-------------------------------------------------
READ8_DEVICE_HANDLER( okim6295_r )
{
return downcast<okim6295_device *>(device)->read(*device->machine->m_nonspecific_space, offset);
}
READ8_MEMBER( okim6295_device::read )
UINT8 okim6295_device::read_status()
{
UINT8 result = 0xf0; // naname expects bits 4-7 to be 1
@ -308,23 +303,28 @@ READ8_MEMBER( okim6295_device::read )
return result;
}
//-------------------------------------------------
// data_write - write to the command/data register
// read - memory interface for read
//-------------------------------------------------
WRITE8_DEVICE_HANDLER( okim6295_w )
READ8_MEMBER( okim6295_device::read )
{
downcast<okim6295_device *>(device)->write(*device->machine->m_nonspecific_space, offset, data);
return read_status();
}
WRITE8_MEMBER( okim6295_device::write )
//-------------------------------------------------
// write_command - write to the command register
//-------------------------------------------------
void okim6295_device::write_command(UINT8 command)
{
// if a command is pending, process the second half
if (m_command != -1)
{
// the manual explicitly says that it's not possible to start multiple voices at the same time
int voicemask = data >> 4;
int voicemask = command >> 4;
if (voicemask != 0 && voicemask != 1 && voicemask != 2 && voicemask != 4 && voicemask != 8)
popmessage("OKI6295 start %x contact MAMEDEV", voicemask);
@ -362,7 +362,7 @@ WRITE8_MEMBER( okim6295_device::write )
// also reset the ADPCM parameters
voice.m_adpcm.reset();
voice.m_volume = s_volume_table[data & 0x0f];
voice.m_volume = s_volume_table[command & 0x0f];
}
else
logerror("OKIM6295:'%s' requested to play sample %02x on non-stopped voice\n",tag(),m_command);
@ -381,8 +381,8 @@ WRITE8_MEMBER( okim6295_device::write )
}
// if this is the start of a command, remember the sample number for next time
else if (data & 0x80)
m_command = data & 0x7f;
else if (command & 0x80)
m_command = command & 0x7f;
// otherwise, see if this is a silence command
else
@ -391,7 +391,7 @@ WRITE8_MEMBER( okim6295_device::write )
stream_update(m_stream);
// determine which voice(s) (voice is set by a 1 bit in bits 3-6 of the command
int voicemask = data >> 3;
int voicemask = command >> 3;
for (int voicenum = 0; voicenum < OKIM6295_VOICES; voicenum++, voicemask >>= 1)
if (voicemask & 1)
m_voice[voicenum].m_playing = false;
@ -399,6 +399,16 @@ WRITE8_MEMBER( okim6295_device::write )
}
//-------------------------------------------------
// write - memory interface for write
//-------------------------------------------------
WRITE8_MEMBER( okim6295_device::write )
{
write_command(data);
}
//**************************************************************************
// OKIM VOICE

View File

@ -120,6 +120,9 @@ public:
void set_bank_base(offs_t base);
void set_pin7(int pin7);
UINT8 read_status();
void write_command(UINT8 command);
DECLARE_READ8_MEMBER( read );
DECLARE_WRITE8_MEMBER( write );
@ -170,13 +173,4 @@ protected:
extern const device_type OKIM6295;
//**************************************************************************
// READ/WRITE HANDLERS
//**************************************************************************
READ8_DEVICE_HANDLER( okim6295_r );
WRITE8_DEVICE_HANDLER( okim6295_w );
#endif /* __OKIM6295_H__ */

View File

@ -340,7 +340,7 @@ static READ8_HANDLER( jsa2_io_r )
{
case 0x000: /* /RDV */
if (oki6295 != NULL)
result = okim6295_r(oki6295, offset);
result = oki6295->read(*space, offset);
else
logerror("atarijsa: Unknown read at %04X\n", offset & 0x206);
break;
@ -398,7 +398,7 @@ static WRITE8_HANDLER( jsa2_io_w )
case 0x200: /* /WRV */
if (oki6295 != NULL)
okim6295_w(oki6295, offset, data);
oki6295->write(*space, offset, data);
else
logerror("atarijsa: Unknown write (%02X) at %04X\n", data & 0xff, offset & 0x206);
break;
@ -465,7 +465,7 @@ static READ8_HANDLER( jsa3_io_r )
{
case 0x000: /* /RDV */
if (oki6295 != NULL)
result = okim6295_r(oki6295, offset);
result = oki6295->read(*space, offset);
break;
case 0x002: /* /RDP */
@ -525,7 +525,7 @@ static WRITE8_HANDLER( jsa3_io_w )
case 0x200: /* /WRV */
if (oki6295 != NULL)
okim6295_w(oki6295, offset, data);
oki6295->write(*space, offset, data);
break;
case 0x202: /* /WRP */
@ -599,7 +599,7 @@ static READ8_HANDLER( jsa3s_io_r )
{
case 0x000: /* /RDV */
if (oki6295_l != NULL)
result = okim6295_r((offset & 1) ? oki6295_r : oki6295_l, offset);
result = ((offset & 1) ? oki6295_r : oki6295_l)->read(*space, offset);
break;
case 0x002: /* /RDP */
@ -659,7 +659,7 @@ static WRITE8_HANDLER( jsa3s_io_w )
case 0x200: /* /WRV */
if (oki6295_l != NULL)
okim6295_w((offset & 1) ? oki6295_r : oki6295_l, 0, data);
((offset & 1) ? oki6295_r : oki6295_l)->write(*space, 0, data);
break;
case 0x202: /* /WRP */

View File

@ -71,29 +71,29 @@ static const UINT8 fixeight_cmd_snd[128] =
/*78*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static void play_oki_sound(running_device *device, int game_sound, int data)
static void play_oki_sound(okim6295_device *oki, int game_sound, int data)
{
int status = okim6295_r(device,0);
int status = oki->read_status();
logerror("Playing sample %02x from command %02x\n",game_sound,data);
if (game_sound != 0)
{
if ((status & 0x01) == 0) {
okim6295_w(device,0,(0x80 | game_sound));
okim6295_w(device,0,0x11);
oki->write_command(0x80 | game_sound);
oki->write_command(0x11);
}
else if ((status & 0x02) == 0) {
okim6295_w(device,0,(0x80 | game_sound));
okim6295_w(device,0,0x21);
oki->write_command(0x80 | game_sound);
oki->write_command(0x21);
}
else if ((status & 0x04) == 0) {
okim6295_w(device,0,(0x80 | game_sound));
okim6295_w(device,0,0x41);
oki->write_command(0x80 | game_sound);
oki->write_command(0x41);
}
else if ((status & 0x08) == 0) {
okim6295_w(device,0,(0x80 | game_sound));
okim6295_w(device,0,0x81);
oki->write_command(0x80 | game_sound);
oki->write_command(0x81);
}
}
}
@ -108,13 +108,14 @@ void kbash_okisnd_w(running_device *device, int data)
{
// popmessage("Writing %04x to Sound CPU",data);
okim6295_device *oki = downcast<okim6295_device *>(device);
if (data == 0)
{
okim6295_w(device,0,0x78); /* Stop playing effects */
oki->write_command(0x78); /* Stop playing effects */
}
else if ((data > 0) && (data < 128))
{
play_oki_sound(device, kbash_cmd_snd[data], data);
play_oki_sound(oki, kbash_cmd_snd[data], data);
}
}
@ -122,13 +123,14 @@ void fixeight_okisnd_w(running_device *device, int data)
{
// popmessage("Writing %04x to Sound CPU",data);
okim6295_device *oki = downcast<okim6295_device *>(device);
if (data == 0)
{
okim6295_w(device,0,0x78); /* Stop playing effects */
oki->write_command(0x78); /* Stop playing effects */
}
else if ((data > 0) && (data < 128))
{
play_oki_sound(device, fixeight_cmd_snd[data], data);
play_oki_sound(oki, fixeight_cmd_snd[data], data);
}
}
@ -136,12 +138,13 @@ void batsugun_okisnd_w(running_device *device, int data)
{
// popmessage("Writing %04x to Sound CPU",data);
okim6295_device *oki = downcast<okim6295_device *>(device);
if (data == 0)
{
okim6295_w(device,0,0x78); /* Stop playing effects */
oki->write_command(0x78); /* Stop playing effects */
}
else if ((data > 0) && (data < 64))
{
play_oki_sound(device, batsugun_cmd_snd[data], data);
play_oki_sound(oki, batsugun_cmd_snd[data], data);
}
}

View File

@ -293,10 +293,10 @@ static READ16_HANDLER(ac_devices_r)
return input_port_read(space->machine, "IN0");
case 0x0014/2:
case 0x0016/2:
return okim6295_r(space->machine->device("oki1"),0);
return space->machine->device<okim6295_device>("oki1")->read(*space,0);
case 0x0018/2:
case 0x001a/2:
return okim6295_r(space->machine->device("oki2"),0);
return space->machine->device<okim6295_device>("oki2")->read(*space,0);
case 0x0040/2:
/*
"Upper switch / Under Switch"
@ -385,12 +385,18 @@ static WRITE16_HANDLER(ac_devices_w)
case 0x14/2:
case 0x16/2:
if(ACCESSING_BITS_0_7)
okim6295_w(space->machine->device("oki1"),0,data);
{
okim6295_device *oki1 = space->machine->device<okim6295_device>("oki1");
oki1->write(*space,0,data);
}
break;
case 0x18/2:
case 0x1a/2:
if(ACCESSING_BITS_0_7)
okim6295_w(space->machine->device("oki2"),0,data);
{
okim6295_device *oki2 = space->machine->device<okim6295_device>("oki2");
oki2->write(*space,0,data);
}
break;
case 0x1c/2:
/*IRQ mask?*/

View File

@ -120,15 +120,17 @@ static UINT8 aquarium_snd_bitswap( UINT8 scrambled_data )
return data;
}
static READ8_DEVICE_HANDLER( aquarium_oki_r )
static READ8_HANDLER( aquarium_oki_r )
{
return aquarium_snd_bitswap(okim6295_r(device, 0));
okim6295_device *oki = space->machine->device<okim6295_device>("oki");
return aquarium_snd_bitswap(oki->read(*space, offset));
}
static WRITE8_DEVICE_HANDLER( aquarium_oki_w )
static WRITE8_HANDLER( aquarium_oki_w )
{
logerror("%s:Writing %04x to the OKI M6295\n", cpuexec_describe_context(device->machine), aquarium_snd_bitswap(data));
okim6295_w(device, 0, (aquarium_snd_bitswap(data)));
logerror("%s:Writing %04x to the OKI M6295\n", cpuexec_describe_context(space->machine), aquarium_snd_bitswap(data));
okim6295_device *oki = space->machine->device<okim6295_device>("oki");
oki->write(*space, offset, (aquarium_snd_bitswap(data)));
}
@ -161,7 +163,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( snd_portmap, ADDRESS_SPACE_IO, 8 )
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
AM_RANGE(0x02, 0x02) AM_DEVREADWRITE("oki", aquarium_oki_r, aquarium_oki_w)
AM_RANGE(0x02, 0x02) AM_READWRITE(aquarium_oki_r, aquarium_oki_w)
AM_RANGE(0x04, 0x04) AM_READ(soundlatch_r)
AM_RANGE(0x06, 0x06) AM_WRITE(aquarium_snd_ack_w)
AM_RANGE(0x08, 0x08) AM_WRITE(aquarium_z80_bank_w)

View File

@ -82,8 +82,8 @@ static READ8_HANDLER( drgnmst_snd_command_r )
switch (state->oki_control & 0x1f)
{
case 0x12: data = (okim6295_r(state->oki_2, 0) & 0x0f); break;
case 0x16: data = (okim6295_r(state->oki_1, 0) & 0x0f); break;
case 0x12: data = (state->oki_2->read(*space, 0) & 0x0f); break;
case 0x16: data = (state->oki_1->read(*space, 0) & 0x0f); break;
case 0x0b:
case 0x0f: data = state->snd_command; break;
default: break;
@ -172,12 +172,12 @@ static WRITE8_HANDLER( drgnmst_snd_control_w )
case 0x11:
// logerror("Writing %02x to OKI1", state->oki_command);
// logerror(", PortC=%02x, Code=%02x, Bank0=%01x, Bank1=%01x\n", state->oki_control, state->snd_command, state->oki0_bank, state->oki1_bank);
okim6295_w(state->oki_2, 0, state->oki_command);
state->oki_2->write(*space, 0, state->oki_command);
break;
case 0x15:
// logerror("Writing %02x to OKI0", state->oki_command);
// logerror(", PortC=%02x, Code=%02x, Bank0=%01x, Bank1=%01x\n", state->oki_control, state->snd_command, state->oki0_bank, state->oki1_bank);
okim6295_w(state->oki_1, 0, state->oki_command);
state->oki_1->write(*space, 0, state->oki_command);
break;
default: break;
}

View File

@ -262,8 +262,8 @@ static ADDRESS_MAP_START( comad_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x900000, 0x900001) AM_WRITE(galpanica_6295_bankswitch_w) /* not sure */
AM_RANGE(0xc00000, 0xc0ffff) AM_RAM /* missw96 */
AM_RANGE(0xc80000, 0xc8ffff) AM_RAM /* fantasia, newfant */
AM_RANGE(0xf00000, 0xf00001) AM_DEVREADWRITE8("oki", comad_okim6295_r, okim6295_w, 0xff00) /* fantasia, missw96 */
AM_RANGE(0xf80000, 0xf80001) AM_DEVREADWRITE8("oki", comad_okim6295_r, okim6295_w, 0xff00) /* newfant */
AM_RANGE(0xf00000, 0xf00001) AM_DEVREAD8("oki", comad_okim6295_r, 0xff00) AM_DEVWRITE8_MODERN("oki", okim6295_device, write, 0xff00) /* fantasia, missw96 */
AM_RANGE(0xf80000, 0xf80001) AM_DEVREAD8("oki", comad_okim6295_r, 0xff00) AM_DEVWRITE8_MODERN("oki", okim6295_device, write, 0xff00) /* newfant */
ADDRESS_MAP_END
static ADDRESS_MAP_START( fantsia2_map, ADDRESS_SPACE_PROGRAM, 16 )
@ -279,7 +279,7 @@ static ADDRESS_MAP_START( fantsia2_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x800008, 0x800009) AM_READ(kludge) /* bits 8-a = timer? palette update code waits for them to be 111 */
AM_RANGE(0x900000, 0x900001) AM_WRITE(galpanica_6295_bankswitch_w) /* not sure */
AM_RANGE(0xa00000, 0xa00001) AM_WRITENOP /* coin counters, + ? */
AM_RANGE(0xc80000, 0xc80001) AM_DEVREADWRITE8("oki", comad_okim6295_r, okim6295_w, 0xff00)
AM_RANGE(0xc80000, 0xc80001) AM_DEVREAD8("oki", comad_okim6295_r, 0xff00) AM_DEVWRITE8_MODERN("oki", okim6295_device, write, 0xff00)
AM_RANGE(0xf80000, 0xf8ffff) AM_RAM
ADDRESS_MAP_END
@ -326,7 +326,7 @@ static ADDRESS_MAP_START( zipzap_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x900000, 0x900001) AM_WRITE(galpanica_6295_bankswitch_w)
AM_RANGE(0xc00000, 0xc00001) AM_DEVREADWRITE8("oki", comad_okim6295_r, okim6295_w, 0xff00)
AM_RANGE(0xc00000, 0xc00001) AM_DEVREAD8("oki", comad_okim6295_r, 0xff00) AM_DEVWRITE8_MODERN("oki", okim6295_device, write, 0xff00) /* fantasia, missw96 */
AM_RANGE(0xc80000, 0xc8ffff) AM_RAM // main ram
ADDRESS_MAP_END
@ -351,7 +351,7 @@ static ADDRESS_MAP_START( supmodel_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0xd80000, 0xd80001) AM_WRITENOP
AM_RANGE(0xe00012, 0xe00013) AM_WRITENOP
AM_RANGE(0xe80000, 0xe80001) AM_WRITENOP
AM_RANGE(0xf80000, 0xf80001) AM_DEVREADWRITE8("oki", comad_okim6295_r, okim6295_w, 0xff00)
AM_RANGE(0xf80000, 0xf80001) AM_DEVREAD8("oki", comad_okim6295_r, 0xff00) AM_DEVWRITE8_MODERN("oki", okim6295_device, write, 0xff00) /* fantasia, missw96 */
ADDRESS_MAP_END
#define COMMON_COIN0\

View File

@ -93,7 +93,7 @@ static READ16_HANDLER( ioc_r )
case 0x50:
case 0x51:
return okim6295_r(state->oki, 0) << 8;
return state->oki->read(*space, 0) << 8;
}
@ -146,7 +146,7 @@ static WRITE16_HANDLER( ioc_w )
// OKIM6295
case 0x50:
case 0x51:
okim6295_w(state->oki, 0, data >> 8);
state->oki->write(*space, 0, data >> 8);
break;
// MSM6585 ADPCM - mini emulation

View File

@ -116,9 +116,9 @@ Hollywood Action
//static int state->melody;
//static int kickgoal_snd_bank;
static void kickgoal_play(running_device *device, int melody, int data)
static void kickgoal_play(okim6295_device *oki, int melody, int data)
{
int status = okim6295_r(device,0);
int status = oki->read(0);
logerror("Playing sample %01x:%02x from command %02x\n",kickgoal_snd_bank,kickgoal_sound,data);
if (kickgoal_sound == 0) popmessage("Unknown sound command %02x",kickgoal_sound);
@ -128,35 +128,36 @@ static void kickgoal_play(running_device *device, int melody, int data)
state->melody = kickgoal_sound;
state->melody_loop = kickgoal_sound;
if (status & 0x08)
okim6295_w(device,0,0x40);
okim6295_w(device,0,(0x80 | state->melody));
okim6295_w(device,0,0x81);
oki->write(0,0x40);
oki->write(0,(0x80 | state->melody));
oki->write(0,0x81);
}
}
else {
if ((status & 0x01) == 0) {
okim6295_w(device,0,(0x80 | kickgoal_sound));
okim6295_w(device,0,0x11);
oki->write(0,(0x80 | kickgoal_sound));
oki->write(0,0x11);
}
else if ((status & 0x02) == 0) {
okim6295_w(device,0,(0x80 | kickgoal_sound));
okim6295_w(device,0,0x21);
oki->write(0,(0x80 | kickgoal_sound));
oki->write(0,0x21);
}
else if ((status & 0x04) == 0) {
okim6295_w(device,0,(0x80 | kickgoal_sound));
okim6295_w(device,0,0x41);
oki->write(0,(0x80 | kickgoal_sound));
oki->write(0,0x41);
}
}
}
WRITE16_DEVICE_HANDLER( kickgoal_snd_w )
{
okim6295_device *oki = downcast<okim6295_device *>(device);
if (ACCESSING_BITS_0_7)
{
logerror("PC:%06x Writing %04x to Sound CPU\n",cpu_get_previouspc(space->cpu),data);
if (data >= 0x40) {
if (data == 0xfe) {
okim6295_w(device,0,0x40); /* Stop playing the melody */
oki->write(0,0x40); /* Stop playing the melody */
state->melody = 0x00;
state->melody_loop = 0x00;
}
@ -165,49 +166,37 @@ WRITE16_DEVICE_HANDLER( kickgoal_snd_w )
}
}
else if (data == 0) {
okim6295_w(device,0,0x38); /* Stop playing effects */
oki->write(0,0x38); /* Stop playing effects */
}
else {
kickgoal_sound = kickgoal_cmd_snd[data];
if (kickgoal_sound >= 0x70) {
if (kickgoal_snd_bank != 1)
{
okim6295_device *oki = downcast<okim6295_device *>(device);
oki->set_bank_base((1 * 0x40000));
}
kickgoal_snd_bank = 1;
kickgoal_play(device, 0, data);
kickgoal_play(oki, 0, data);
}
else if (kickgoal_sound >= 0x69) {
if (kickgoal_snd_bank != 2)
{
okim6295_device *oki = downcast<okim6295_device *>(device);
oki->set_bank_base((2 * 0x40000));
}
kickgoal_snd_bank = 2;
kickgoal_play(device, 4, data);
kickgoal_play(oki, 4, data);
}
else if (kickgoal_sound >= 0x65) {
if (kickgoal_snd_bank != 1)
{
okim6295_device *oki = downcast<okim6295_device *>(device);
oki->set_bank_base((1 * 0x40000));
}
kickgoal_snd_bank = 1;
kickgoal_play(device, 4, data);
kickgoal_play(oki, 4, data);
}
else if (kickgoal_sound >= 0x60) {
kickgoal_snd_bank = 0;
{
okim6295_device *oki = downcast<okim6295_device *>(device);
oki->set_bank_base(device, (0 * 0x40000));
}
kickgoal_snd_bank = 0;
kickgoal_play(device, 4, data);
kickgoal_play(oki, 4, data);
}
else {
kickgoal_play(device, 0, data);
kickgoal_play(oki, 0, data);
}
}
}
@ -230,7 +219,7 @@ static WRITE16_DEVICE_HANDLER( actionhw_snd_w )
case 0xfe: oki->set_bank_base((1 * 0x40000)); break;
case 0xff: oki->set_bank_base((3 * 0x40000)); break;
case 0x78:
okim6295_w(device, 0, data);
oki->write_command(data);
state->snd_sam[0] = 00; state->snd_sam[1]= 00; state->snd_sam[2] = 00; state->snd_sam[3] = 00;
break;
default:
@ -239,44 +228,44 @@ static WRITE16_DEVICE_HANDLER( actionhw_snd_w )
if ((data & 0x80) && (state->snd_sam[3] != state->snd_new))
{
logerror("About to play sample %02x at vol %02x\n", state->snd_new, data);
if ((okim6295_r(device, 0) & 0x08) != 0x08)
if ((oki->read_status() & 0x08) != 0x08)
{
logerror("Playing sample %02x at vol %02x\n", state->snd_new, data);
okim6295_w(device, 0, state->snd_new);
okim6295_w(device, 0, data);
oki->write_command(state->snd_new);
oki->write_command(data);
}
state->snd_new = 00;
}
if ((data & 0x40) && (state->snd_sam[2] != state->snd_new))
{
logerror("About to play sample %02x at vol %02x\n", state->snd_new, data);
if ((okim6295_r(device, 0) & 0x04) != 0x04)
if ((oki->read_status() & 0x04) != 0x04)
{
logerror("Playing sample %02x at vol %02x\n", state->snd_new, data);
okim6295_w(device, 0, state->snd_new);
okim6295_w(device, 0, data);
oki->write_command(state->snd_new);
oki->write_command(data);
}
state->snd_new = 00;
}
if ((data & 0x20) && (state->snd_sam[1] != state->snd_new))
{
logerror("About to play sample %02x at vol %02x\n", state->snd_new, data);
if ((okim6295_r(device, 0) & 0x02) != 0x02)
if ((oki->read_status() & 0x02) != 0x02)
{
logerror("Playing sample %02x at vol %02x\n", state->snd_new, data);
okim6295_w(device, 0, state->snd_new);
okim6295_w(device, 0, data);
oki->write_command(state->snd_new);
oki->write_command(data);
}
state->snd_new = 00;
}
if ((data & 0x10) && (state->snd_sam[0] != state->snd_new))
{
logerror("About to play sample %02x at vol %02x\n", state->snd_new, data);
if ((okim6295_r(device, 0) & 0x01) != 0x01)
if ((oki->read_status() & 0x01) != 0x01)
{
logerror("Playing sample %02x at vol %02x\n", state->snd_new, data);
okim6295_w(device, 0, state->snd_new);
okim6295_w(device, 0, data);
oki->write_command(state->snd_new);
oki->write_command(data);
}
state->snd_new = 00;
}
@ -291,7 +280,7 @@ static WRITE16_DEVICE_HANDLER( actionhw_snd_w )
else /* Turn a channel off */
{
logerror("Turning channel %02x off\n", data);
okim6295_w(device, 0, data);
oki->write_command(data);
if (data & 0x40) state->snd_sam[3] = 00;
if (data & 0x20) state->snd_sam[2] = 00;
if (data & 0x10) state->snd_sam[1] = 00;
@ -307,7 +296,7 @@ static INTERRUPT_GEN( kickgoal_interrupt )
{
kickgoal_state *state = device->machine->driver_data<kickgoal_state>();
if ((okim6295_r(state->adpcm, 0) & 0x08) == 0)
if ((state->adpcm->read_status() & 0x08) == 0)
{
switch(state->melody_loop)
{
@ -336,8 +325,8 @@ static INTERRUPT_GEN( kickgoal_interrupt )
if (state->melody_loop)
{
// logerror("Changing to sample %02x\n", state->melody_loop);
okim6295_w(state->adpcm, 0, ((0x80 | state->melody_loop) & 0xff));
okim6295_w(state->adpcm, 0, 0x81);
state->adpcm->write_command((0x80 | state->melody_loop) & 0xff);
state->adpcm->write_command(0x81);
}
}
if (input_code_pressed_once(device->machine, KEYCODE_PGUP))
@ -424,9 +413,9 @@ static INTERRUPT_GEN( kickgoal_interrupt )
{
if (state->m6295_key_delay >= (0x80 * oki_time_base))
{
okim6295_w(state->adpcm, 0, 0x78);
okim6295_w(state->adpcm, 0, (0x80 | state->m6295_comm));
okim6295_w(state->adpcm, 0, 0x11);
state->adpcm->write_command(0x78);
state->adpcm->write_command(0x80 | state->m6295_comm);
state->adpcm->write_command(0x11);
popmessage("Playing sound %02x on Bank %02x", state->m6295_comm, state->m6295_bank);

View File

@ -902,9 +902,9 @@ static const ym2203_interface cowrace_ym2203_interface =
AY8910_LEGACY_OUTPUT,
AY8910_DEFAULT_LOADS,
DEVCB_HANDLER(sound_cmd_r), // read A
DEVCB_DEVICE_HANDLER("oki", okim6295_r), // read B
DEVCB_DEVICE_MEMBER("oki", okim6295_device, read), // read B
DEVCB_NULL, // write A
DEVCB_DEVICE_HANDLER("oki", okim6295_w) // write B
DEVCB_DEVICE_MEMBER("oki", okim6295_device, write) // write B
},
NULL
};

View File

@ -199,7 +199,7 @@ static READ8_HANDLER( spotty_sound_r )
if(spotty_sound_cmd == 0xf7)
return soundlatch_r(space,0);
else
return okim6295_r(space->machine->device("oki"),0);
return space->machine->device<okim6295_device>("oki")->read(*space,0);
}
static ADDRESS_MAP_START( spotty_sound_io_map, ADDRESS_SPACE_IO, 8 )

View File

@ -382,7 +382,7 @@ static READ8_DEVICE_HANDLER( oki_status_r )
if (megasys1_ignore_oki_status == 1)
return 0;
else
return okim6295_r(device,offset);
return downcast<okim6295_device *>(device)->read_status();
}
/***************************************************************************
@ -3843,8 +3843,9 @@ static DRIVER_INIT( iganinju )
static WRITE16_DEVICE_HANDLER( okim6295_both_w )
{
if (ACCESSING_BITS_0_7) okim6295_w(device, 0, (data >> 0) & 0xff );
else okim6295_w(device, 0, (data >> 8) & 0xff );
okim6295_device *oki = downcast<okim6295_device *>(device);
if (ACCESSING_BITS_0_7) oki->write_command((data >> 0) & 0xff );
else oki->write_command((data >> 8) & 0xff );
}
static DRIVER_INIT( jitsupro )

View File

@ -463,7 +463,7 @@ static WRITE8_HANDLER( metro_portb_w )
{
/* write */
if (!BIT(data, 4))
okim6295_w(state->oki, 0, state->porta);
state->oki->write(*space, 0, state->porta);
}
state->portb = data;
@ -513,14 +513,14 @@ static WRITE8_HANDLER( daitorid_portb_w )
{
/* write */
if (!BIT(data, 4))
okim6295_w(state->oki, 0, state->porta);
state->oki->write(*space, 0, state->porta);
}
if (BIT(state->portb, 3) && !BIT(data, 3)) /* clock 1->0 */
{
/* read */
if (!BIT(data, 4))
state->porta = okim6295_r(state->oki, 0);
state->porta = state->oki->read(*space, 0);
}
state->portb = data;

View File

@ -183,20 +183,6 @@ static WRITE16_HANDLER( bitmap_1_w )
COMBINE_DATA(&state->bitmap1[offset + state->vbuffer * 0x20000 / 2]);
}
static READ16_DEVICE_HANDLER( oki_r )
{
if (offset)
return okim6295_r(device, 0);
else
return 0;
}
static WRITE16_DEVICE_HANDLER( oki_w )
{
if (offset)
okim6295_w(device, 0, data);
}
static WRITE16_DEVICE_HANDLER( oki_bank_w )
{
if (offset)
@ -243,8 +229,8 @@ static ADDRESS_MAP_START( pasha2_io, ADDRESS_SPACE_IO, 16 )
AM_RANGE(0x80, 0x83) AM_READ_PORT("INPUTS")
AM_RANGE(0xa0, 0xa3) AM_WRITENOP //soundlatch?
AM_RANGE(0xc0, 0xc3) AM_WRITE(pasha2_misc_w)
AM_RANGE(0xe0, 0xe3) AM_DEVREADWRITE("oki1", oki_r, oki_w)
AM_RANGE(0xe4, 0xe7) AM_DEVREADWRITE("oki2", oki_r, oki_w)
AM_RANGE(0xe2, 0xe3) AM_DEVREADWRITE8_MODERN("oki1", okim6295_device, read, write, 0x00ff)
AM_RANGE(0xe6, 0xe7) AM_DEVREADWRITE8_MODERN("oki2", okim6295_device, read, write, 0x00ff)
AM_RANGE(0xe8, 0xeb) AM_DEVWRITE("oki1", oki_bank_w)
AM_RANGE(0xec, 0xef) AM_DEVWRITE("oki2", oki_bank_w)
ADDRESS_MAP_END

View File

@ -141,7 +141,7 @@ static READ8_HANDLER( playmark_snd_command_r )
}
else if ((state->oki_control & 0x38) == 0x28)
{
data = (okim6295_r(state->oki, 0) & 0x0f);
data = (state->oki->read(*space, 0) & 0x0f);
// logerror("PC$%03x PortB reading %02x from the OKI status port\n", cpu_get_previouspc(space->cpu), data);
}
@ -183,9 +183,9 @@ static WRITE8_HANDLER( playmark_oki_w )
state->oki_command = data;
}
static WRITE8_DEVICE_HANDLER( playmark_snd_control_w )
static WRITE8_HANDLER( playmark_snd_control_w )
{
playmark_state *state = device->machine->driver_data<playmark_state>();
playmark_state *state = space->machine->driver_data<playmark_state>();
// address_space *space = cputag_get_address_space(device->machine, "audiocpu", ADDRESS_SPACE_PROGRAM);
/* This port controls communications to and from the 68K, and the OKI
@ -206,7 +206,8 @@ static WRITE8_DEVICE_HANDLER( playmark_snd_control_w )
if ((data & 0x38) == 0x18)
{
// logerror("PC$%03x Writing %02x to OKI1, PortC=%02x, Code=%02x\n",cpu_get_previouspc(space->cpu),playmark_oki_command,playmark_oki_control,playmark_snd_command);
okim6295_w(device, 0, state->oki_command);
okim6295_device *oki = space->machine->device<okim6295_device>("oki");
oki->write(*space, 0, state->oki_command);
}
}
@ -333,7 +334,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( playmark_sound_io_map, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x00, 0x00) AM_DEVWRITE("oki", playmark_oki_banking_w)
AM_RANGE(0x01, 0x01) AM_READWRITE(playmark_snd_command_r, playmark_oki_w)
AM_RANGE(0x02, 0x02) AM_READ(playmark_snd_flag_r) AM_DEVWRITE("oki", playmark_snd_control_w)
AM_RANGE(0x02, 0x02) AM_READWRITE(playmark_snd_flag_r, playmark_snd_control_w)
AM_RANGE(PIC16C5x_T0, PIC16C5x_T0) AM_READ(PIC16C5X_T0_clk_r)
ADDRESS_MAP_END
@ -909,7 +910,7 @@ static MACHINE_START( playmark )
{
playmark_state *state = machine->driver_data<playmark_state>();
state->oki = machine->device("oki");
state->oki = machine->device<okim6295_device>("oki");
state->eeprom = machine->device("eeprom");
state_save_register_global(machine, state->bgscrollx);

View File

@ -330,30 +330,33 @@ static ADDRESS_MAP_START( psikyo_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0xfe0000, 0xffffff) AM_RAM // RAM
ADDRESS_MAP_END
static READ32_DEVICE_HANDLER( s1945bl_oki_r )
static READ32_HANDLER( s1945bl_oki_r )
{
UINT8 dat = okim6295_r(device, 0);
UINT8 dat = space->machine->device<okim6295_device>("oki")->read(*space, 0);
return dat << 24;
}
static WRITE32_DEVICE_HANDLER( s1945bl_oki_w )
static WRITE32_HANDLER( s1945bl_oki_w )
{
if (ACCESSING_BITS_24_31)
okim6295_w(device, 0, data >> 24);
{
okim6295_device *oki = space->machine->device<okim6295_device>("oki");
oki->write(*space, 0, data >> 24);
}
if (ACCESSING_BITS_16_23)
{
// not at all sure about this, it seems to write 0 too often
UINT8 bank = (data & 0x00ff0000) >> 16;
if (bank < 4)
memory_set_bank(device->machine, "okibank", bank);
memory_set_bank(space->machine, "okibank", bank);
}
if (ACCESSING_BITS_8_15)
printf("ACCESSING_BITS_8_15 ?? %08x %08x\n", data & 0x00ff0000, mem_mask);
printf("ACCESSING_BITS_8_15 ?? %08x %08x\n", data & 0x0000ff00, mem_mask);
if (ACCESSING_BITS_0_7)
printf("ACCESSING_BITS_0_7 ?? %08x %08x\n", data & 0x00ff0000, mem_mask);
printf("ACCESSING_BITS_0_7 ?? %08x %08x\n", data & 0x000000ff, mem_mask);
}
static ADDRESS_MAP_START( s1945bl_oki_map, 0, 8 )
@ -374,7 +377,7 @@ static ADDRESS_MAP_START( psikyo_bootleg_map, ADDRESS_SPACE_PROGRAM, 32 )
// AM_RANGE(0xc00004, 0xc0000b) AM_WRITE(s1945_mcu_w) // MCU on sh404, see DRIVER_INIT
// AM_RANGE(0xc00010, 0xc00013) AM_WRITE(psikyo_soundlatch_w) // Depends on board, see DRIVER_INIT
AM_RANGE(0xC00018, 0xC0001b) AM_DEVREADWRITE("oki", s1945bl_oki_r, s1945bl_oki_w)
AM_RANGE(0xC00018, 0xC0001b) AM_READWRITE(s1945bl_oki_r, s1945bl_oki_w)
AM_RANGE(0xfe0000, 0xffffff) AM_RAM // RAM

View File

@ -124,8 +124,8 @@ static INTERRUPT_GEN( snowbros_interrupt )
static INTERRUPT_GEN( snowbro3_interrupt )
{
running_device *adpcm = device->machine->device("oki");
int status = okim6295_r(adpcm,0);
okim6295_device *adpcm = device->machine->device<okim6295_device>("oki");
int status = adpcm->read_status();
cpu_set_input_line(device, cpu_getiloops(device) + 2, ASSERT_LINE); /* IRQs 4, 3, and 2 */
@ -133,8 +133,8 @@ static INTERRUPT_GEN( snowbro3_interrupt )
{
if ((status&0x08)==0x00)
{
okim6295_w(adpcm,0,0x80|sb3_music);
okim6295_w(adpcm,0,0x00|0x82);
adpcm->write_command(0x80|sb3_music);
adpcm->write_command(0x00|0x82);
}
}
@ -142,7 +142,7 @@ static INTERRUPT_GEN( snowbro3_interrupt )
{
if ((status&0x08)==0x08)
{
okim6295_w(adpcm,0,0x40); /* Stop playing music */
adpcm->write_command(0x40); /* Stop playing music */
}
}
@ -426,24 +426,24 @@ static void sb3_play_music(running_machine *machine, int data)
}
}
static void sb3_play_sound (running_device *device, int data)
static void sb3_play_sound (okim6295_device *oki, int data)
{
int status = okim6295_r(device,0);
int status = oki->read_status();
if ((status&0x01)==0x00)
{
okim6295_w(device,0,0x80|data);
okim6295_w(device,0,0x00|0x12);
oki->write_command(0x80|data);
oki->write_command(0x00|0x12);
}
else if ((status&0x02)==0x00)
{
okim6295_w(device,0,0x80|data);
okim6295_w(device,0,0x00|0x22);
oki->write_command(0x80|data);
oki->write_command(0x00|0x22);
}
else if ((status&0x04)==0x00)
{
okim6295_w(device,0,0x80|data);
okim6295_w(device,0,0x00|0x42);
oki->write_command(0x80|data);
oki->write_command(0x00|0x42);
}
@ -451,10 +451,11 @@ static void sb3_play_sound (running_device *device, int data)
static WRITE16_DEVICE_HANDLER( sb3_sound_w )
{
okim6295_device *oki = downcast<okim6295_device *>(device);
if (data == 0x00fe)
{
sb3_music_is_playing = 0;
okim6295_w(device,0,0x78); /* Stop sounds */
oki->write_command(0x78); /* Stop sounds */
}
else /* the alternating 0x00-0x2f or 0x30-0x5f might be something to do with the channels */
{
@ -462,7 +463,7 @@ static WRITE16_DEVICE_HANDLER( sb3_sound_w )
if (data <= 0x21)
{
sb3_play_sound(device, data);
sb3_play_sound(oki, data);
}
if (data>=0x22 && data<=0x31)
@ -472,7 +473,7 @@ static WRITE16_DEVICE_HANDLER( sb3_sound_w )
if ((data>=0x30) && (data<=0x51))
{
sb3_play_sound(device, data-0x30);
sb3_play_sound(oki, data-0x30);
}
if (data>=0x52 && data<=0x5f)

View File

@ -176,7 +176,7 @@ static READ8_HANDLER( spool99_io_r )
// case 0xafe5: return 1;
// case 0xafe6: return 1;
case 0xafe7: return eeprom_read_bit(space->machine->device("eeprom"));
case 0xaff8: return okim6295_r(space->machine->device("oki"),0);
case 0xaff8: return space->machine->device<okim6295_device>("oki")->read(*space,0);
}
}
// printf("%04x %d\n",offset+0xaf00,io_switch);
@ -234,7 +234,7 @@ static READ8_HANDLER( vcarn_io_r )
case 0xa725: return input_port_read(space->machine,"HOLD3");
case 0xa726: return input_port_read(space->machine,"HOLD4");
case 0xa727: return input_port_read(space->machine,"HOLD2");
case 0xa780: return okim6295_r(space->machine->device("oki"),0);
case 0xa780: return space->machine->device<okim6295_device>("oki")->read(*space,0);
case 0xa7a0: return input_port_read(space->machine,"HOLD1");
case 0xa7a1: return input_port_read(space->machine,"HOLD5");
case 0xa7a2: return input_port_read(space->machine,"START");

View File

@ -221,7 +221,7 @@ static TIMER_CALLBACK( music_playback )
int pattern = 0;
okim6295_device *device = machine->device<okim6295_device>("oki");
if ((okim6295_r(device,0) & 0x08) == 0)
if ((device->read_status() & 0x08) == 0)
{
if (state->bar != 0) {
state->bar += 1;
@ -242,8 +242,8 @@ static TIMER_CALLBACK( music_playback )
}
if (pattern) {
logerror("Changing bar in music track to pattern %02x\n",pattern);
okim6295_w(device,0,(0x80 | pattern));
okim6295_w(device,0,0x81);
device->write_command(0x80 | pattern);
device->write_command(0x81);
}
}
@ -258,7 +258,8 @@ static TIMER_CALLBACK( music_playback )
static void sslam_play(running_device *device, int track, int data)
{
sslam_state *state = device->machine->driver_data<sslam_state>();
int status = okim6295_r(device,0);
okim6295_device *oki = downcast<okim6295_device *>(device);
int status = oki->read_status();
if (data < 0x80) {
if (state->track) {
@ -266,24 +267,24 @@ static void sslam_play(running_device *device, int track, int data)
state->track = data;
state->bar = 1;
if (status & 0x08)
okim6295_w(device,0,0x40);
okim6295_w(device,0,(0x80 | data));
okim6295_w(device,0,0x81);
oki->write_command(0x40);
oki->write_command((0x80 | data));
oki->write_command(0x81);
timer_adjust_periodic(state->music_timer, ATTOTIME_IN_MSEC(4), 0, ATTOTIME_IN_HZ(250)); /* 250Hz for smooth sequencing */
}
}
else {
if ((status & 0x01) == 0) {
okim6295_w(device,0,(0x80 | data));
okim6295_w(device,0,0x11);
oki->write_command((0x80 | data));
oki->write_command(0x11);
}
else if ((status & 0x02) == 0) {
okim6295_w(device,0,(0x80 | data));
okim6295_w(device,0,0x21);
oki->write_command((0x80 | data));
oki->write_command(0x21);
}
else if ((status & 0x04) == 0) {
okim6295_w(device,0,(0x80 | data));
okim6295_w(device,0,0x41);
oki->write_command((0x80 | data));
oki->write_command(0x41);
}
}
}
@ -295,7 +296,7 @@ static void sslam_play(running_device *device, int track, int data)
state->bar = 0;
}
data &= 0x7f;
okim6295_w(device,0,data);
oki->write_command(data);
}
}
@ -441,7 +442,7 @@ static READ8_HANDLER( playmark_snd_command_r )
data = soundlatch_r(space,0);
}
else if ((state->oki_control & 0x38) == 0x28) {
data = (okim6295_r(space->machine->device("oki"),0) & 0x0f);
data = (space->machine->device<okim6295_device>("oki")->read(*space,0) & 0x0f);
}
return data;
@ -471,7 +472,7 @@ static WRITE8_HANDLER( playmark_snd_control_w )
if ((data & 0x38) == 0x18)
{
okim6295_w(space->machine->device("oki"), 0, state->oki_command);
space->machine->device<okim6295_device>("oki")->write(*space, 0, state->oki_command);
}
// !(data & 0x80) -> sound enable

View File

@ -3643,18 +3643,18 @@ static DRIVER_INIT( bubsymph )
}
static READ32_DEVICE_HANDLER( bubsympb_oki_r )
static READ32_HANDLER( bubsympb_oki_r )
{
return okim6295_r(device,0);
return space->machine->device<okim6295_device>("oki")->read(*space,0);
}
static WRITE32_DEVICE_HANDLER( bubsympb_oki_w )
static WRITE32_HANDLER( bubsympb_oki_w )
{
//printf("write %08x %08x\n",data,mem_mask);
if (ACCESSING_BITS_0_7) okim6295_w(device,0,data&0xff);
//if (mem_mask==0x000000ff) okim6295_w(device,0,data&0xff);
if (ACCESSING_BITS_0_7) space->machine->device<okim6295_device>("oki")->write(*space, 0,data&0xff);
//if (mem_mask==0x000000ff) downcast<okim6295_device *>(device)->write(0,data&0xff);
if (ACCESSING_BITS_16_23)
{
UINT8 *snd = memory_region(device->machine, "oki");
UINT8 *snd = memory_region(space->machine, "oki");
int bank = (data & 0x000f0000) >> 16;
// almost certainly wrong
memcpy(snd+0x30000, snd+0x80000+0x30000+bank*0x10000, 0x10000);
@ -3668,7 +3668,6 @@ static WRITE32_DEVICE_HANDLER( bubsympb_oki_w )
static DRIVER_INIT( bubsympb )
{
running_device *oki = machine->device("oki");
f3_game=BUBSYMPH;
//tile_decode(machine);
@ -3691,8 +3690,8 @@ static DRIVER_INIT( bubsympb )
}
}
memory_install_read32_device_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), oki, 0x4a001c, 0x4a001f, 0, 0, bubsympb_oki_r );
memory_install_write32_device_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), oki, 0x4a001c, 0x4a001f, 0, 0, bubsympb_oki_w );
memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x4a001c, 0x4a001f, 0, 0, bubsympb_oki_r );
memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x4a001c, 0x4a001f, 0, 0, bubsympb_oki_w );
}

View File

@ -224,7 +224,7 @@ static ADDRESS_MAP_START( apache3_v20_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x04000, 0x04003) AM_NOP // piu select .. ?
AM_RANGE(0x06000, 0x06001) AM_READ_PORT("IN0") // esw
AM_RANGE(0x08000, 0x08001) AM_DEVREADWRITE("ymsnd", tatsumi_hack_ym2151_r, ym2151_w)
AM_RANGE(0x0a000, 0x0a000) AM_DEVREADWRITE("oki", tatsumi_hack_oki_r, okim6295_w)
AM_RANGE(0x0a000, 0x0a000) AM_DEVREAD("oki", tatsumi_hack_oki_r) AM_DEVWRITE_MODERN("oki", okim6295_device, write)
AM_RANGE(0x0e000, 0x0e007) AM_READWRITE(apache3_adc_r, apache3_adc_w) //adc select
AM_RANGE(0xf0000, 0xfffff) AM_ROM
ADDRESS_MAP_END
@ -268,7 +268,7 @@ static ADDRESS_MAP_START( roundup5_z80_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xdfff) AM_ROM
AM_RANGE(0xe000, 0xffef) AM_RAM
AM_RANGE(0xfff0, 0xfff1) AM_DEVREADWRITE("ymsnd", tatsumi_hack_ym2151_r, ym2151_w)
AM_RANGE(0xfff4, 0xfff4) AM_DEVREADWRITE("oki", tatsumi_hack_oki_r, okim6295_w)
AM_RANGE(0xfff4, 0xfff4) AM_DEVREAD("oki", tatsumi_hack_oki_r) AM_DEVWRITE_MODERN("oki", okim6295_device, write)
AM_RANGE(0xfff8, 0xfff8) AM_READ_PORT("IN0")
AM_RANGE(0xfff9, 0xfff9) AM_READ_PORT("IN1")
AM_RANGE(0xfffc, 0xfffc) AM_READ_PORT("STICKX")
@ -325,7 +325,7 @@ static ADDRESS_MAP_START( cyclwarr_z80_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xdfff) AM_ROM
AM_RANGE(0xe000, 0xffef) AM_RAM
AM_RANGE(0xfff0, 0xfff1) AM_DEVREADWRITE("ymsnd", tatsumi_hack_ym2151_r, ym2151_w)
AM_RANGE(0xfff4, 0xfff4) AM_DEVREADWRITE("oki", tatsumi_hack_oki_r, okim6295_w)
AM_RANGE(0xfff4, 0xfff4) AM_DEVREAD("oki", tatsumi_hack_oki_r) AM_DEVWRITE_MODERN("oki", okim6295_device, write)
AM_RANGE(0xfffc, 0xfffc) AM_READ(soundlatch_r)
AM_RANGE(0xfffe, 0xfffe) AM_WRITENOP
ADDRESS_MAP_END

View File

@ -325,16 +325,17 @@ static WRITE16_HANDLER( semicom_soundcmd_w );
/******************************************************************************/
static WRITE16_DEVICE_HANDLER( tumblepb_oki_w )
static WRITE16_HANDLER( tumblepb_oki_w )
{
okim6295_device *oki = space->machine->device<okim6295_device>("oki");
if (mem_mask == 0xffff)
{
okim6295_w(device, 0, data & 0xff);
oki->write(*space, 0, data & 0xff);
//printf("tumbleb_oki_w %04x %04x\n", data, mem_mask);
}
else
{
okim6295_w(device, 0, (data >> 8) & 0xff);
oki->write(*space, 0, (data >> 8) & 0xff);
//printf("tumbleb_oki_w %04x %04x\n", data, mem_mask);
}
/* STUFF IN OTHER BYTE TOO..*/
@ -453,14 +454,15 @@ command 1 - stop?
static void tumbleb2_playmusic( running_device *device )
{
tumbleb_state *state = device->machine->driver_data<tumbleb_state>();
int status = okim6295_r(device, 0);
okim6295_device *oki = downcast<okim6295_device *>(device);
int status = oki->read_status();
if (state->music_is_playing)
{
if (!BIT(status, 3))
{
okim6295_w(device, 0, 0x80 | state->music_command);
okim6295_w(device, 0, 0x00 | 0x82);
oki->write_command(0x80 | state->music_command);
oki->write_command(0x00 | 0x82);
}
}
}
@ -500,24 +502,24 @@ static void tumbleb2_set_music_bank( running_machine *machine, int bank )
memcpy(&oki[0x38000], &oki[0x80000 + 0x38000 + 0x8000 * bank], 0x8000);
}
static void tumbleb2_play_sound( running_device *device, int data )
static void tumbleb2_play_sound( okim6295_device *oki, int data )
{
int status = okim6295_r(device, 0);
int status = oki->read_status();
if (!BIT(status, 0))
{
okim6295_w(device, 0, 0x80 | data);
okim6295_w(device, 0, 0x00 | 0x12);
oki->write_command(0x80 | data);
oki->write_command(0x00 | 0x12);
}
else if (!BIT(status, 1))
{
okim6295_w(device, 0, 0x80 | data);
okim6295_w(device, 0, 0x00 | 0x22);
oki->write_command(0x80 | data);
oki->write_command(0x00 | 0x22);
}
else if (!BIT(status, 2))
{
okim6295_w(device, 0, 0x80 | data);
okim6295_w(device, 0, 0x00 | 0x42);
oki->write_command(0x80 | data);
oki->write_command(0x00 | 0x42);
}
}
@ -533,16 +535,16 @@ static void tumbleb2_play_sound( running_device *device, int data )
// bank 7 = how to play?
// bank 8 = boss???
static void process_tumbleb2_music_command( running_device *device, int data )
static void process_tumbleb2_music_command( okim6295_device *oki, int data )
{
tumbleb_state *state = device->machine->driver_data<tumbleb_state>();
int status = okim6295_r(device, 0);
tumbleb_state *state = oki->machine->driver_data<tumbleb_state>();
int status = oki->read_status();
if (data == 1) // stop?
{
if (BIT(status, 3))
{
okim6295_w(device, 0, 0x40); /* Stop playing music */
oki->write_command(0x40); /* Stop playing music */
state->music_is_playing = 0;
}
}
@ -551,7 +553,7 @@ static void process_tumbleb2_music_command( running_device *device, int data )
if (state->music_is_playing != data)
{
state->music_is_playing = data;
okim6295_w(device, 0, 0x40); // stop the current music
oki->write_command(0x40); // stop the current music
switch (data)
{
case 0x04: // map screen
@ -625,8 +627,8 @@ static void process_tumbleb2_music_command( running_device *device, int data )
break;
}
tumbleb2_set_music_bank(device->machine, state->music_bank);
tumbleb2_playmusic(device);
tumbleb2_set_music_bank(oki->machine, state->music_bank);
tumbleb2_playmusic(oki);
}
}
}
@ -643,11 +645,11 @@ static WRITE16_DEVICE_HANDLER( tumbleb2_soundmcu_w )
}
else if (sound == -2)
{
process_tumbleb2_music_command(device, data);
process_tumbleb2_music_command(downcast<okim6295_device *>(device), data);
}
else
{
tumbleb2_play_sound(device, sound);
tumbleb2_play_sound(downcast<okim6295_device *>(device), sound);
}
}
@ -658,7 +660,7 @@ static ADDRESS_MAP_START( tumblepopb_main_map, ADDRESS_SPACE_PROGRAM, 16 )
#if TUMBLEP_HACK
AM_RANGE(0x000000, 0x07ffff) AM_WRITEONLY /* To write levels modifications */
#endif
AM_RANGE(0x100000, 0x100001) AM_READ(tumblepb_prot_r) AM_DEVWRITE("oki", tumblepb_oki_w)
AM_RANGE(0x100000, 0x100001) AM_READWRITE(tumblepb_prot_r, tumblepb_oki_w)
AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE_MEMBER(tumbleb_state, mainram)
AM_RANGE(0x140000, 0x1407ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_SIZE_MEMBER(tumbleb_state, spriteram, spriteram_size) /* Bootleg sprite buffer */

View File

@ -56,7 +56,8 @@ Stephh's notes (based on the games M68000 code and some tests) :
#ifdef UNUSED_FUNCTION
static WRITE16_DEVICE_HANDLER( tumblep_oki_w )
{
okim6295_w(0, data & 0xff);
okim6295_device *oki = downcast<okim6295_device *>(device);
oki->write(0, data & 0xff);
/* STUFF IN OTHER BYTE TOO..*/
}

View File

@ -67,20 +67,6 @@ static UINT16 semicom_prot_data[2];
static UINT16 finalgdr_backupram_bank;
static UINT8 *finalgdr_backupram;
static READ16_DEVICE_HANDLER( oki_r )
{
if(offset)
return okim6295_r(device, 0);
else
return 0;
}
static WRITE16_DEVICE_HANDLER( oki_w )
{
if(offset)
okim6295_w(device, 0, data);
}
static READ16_DEVICE_HANDLER( eeprom_r )
{
if(offset)
@ -244,7 +230,7 @@ static ADDRESS_MAP_START( common_32bit_map, ADDRESS_SPACE_PROGRAM, 32 )
ADDRESS_MAP_END
static ADDRESS_MAP_START( vamphalf_io, ADDRESS_SPACE_IO, 16 )
AM_RANGE(0x0c0, 0x0c3) AM_DEVREADWRITE("oki", oki_r, oki_w)
AM_RANGE(0x0c2, 0x0c3) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
AM_RANGE(0x140, 0x143) AM_DEVWRITE8("ymsnd", ym2151_register_port_w, 0x00ff)
AM_RANGE(0x146, 0x147) AM_DEVREADWRITE8("ymsnd", ym2151_status_port_r, ym2151_data_port_w, 0x00ff)
AM_RANGE(0x1c0, 0x1c3) AM_DEVREAD("eeprom", eeprom_r)
@ -267,7 +253,7 @@ static ADDRESS_MAP_START( coolmini_io, ADDRESS_SPACE_IO, 16 )
AM_RANGE(0x300, 0x303) AM_READ_PORT("SYSTEM")
AM_RANGE(0x304, 0x307) AM_READ_PORT("P1_P2")
AM_RANGE(0x308, 0x30b) AM_DEVWRITE("eeprom", eeprom_w)
AM_RANGE(0x4c0, 0x4c3) AM_DEVREADWRITE("oki", oki_r, oki_w)
AM_RANGE(0x4c2, 0x4c3) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
AM_RANGE(0x540, 0x543) AM_DEVWRITE8("ymsnd", ym2151_register_port_w, 0x00ff)
AM_RANGE(0x546, 0x547) AM_DEVREADWRITE8("ymsnd", ym2151_status_port_r, ym2151_data_port_w, 0x00ff)
AM_RANGE(0x7c0, 0x7c3) AM_DEVREAD("eeprom", eeprom_r)
@ -277,7 +263,7 @@ static ADDRESS_MAP_START( suplup_io, ADDRESS_SPACE_IO, 16 )
AM_RANGE(0x020, 0x023) AM_DEVWRITE("eeprom", eeprom_w)
AM_RANGE(0x040, 0x043) AM_READ_PORT("P1_P2")
AM_RANGE(0x060, 0x063) AM_READ_PORT("SYSTEM")
AM_RANGE(0x080, 0x083) AM_DEVREADWRITE("oki", oki_r, oki_w)
AM_RANGE(0x082, 0x083) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
AM_RANGE(0x0c0, 0x0c3) AM_DEVWRITE8("ymsnd", ym2151_register_port_w, 0x00ff)
AM_RANGE(0x0c4, 0x0c7) AM_DEVREADWRITE8("ymsnd", ym2151_status_port_r, ym2151_data_port_w, 0x00ff)
AM_RANGE(0x100, 0x103) AM_DEVREAD("eeprom", eeprom_r)
@ -335,7 +321,7 @@ static ADDRESS_MAP_START( jmpbreak_io, ADDRESS_SPACE_IO, 16 )
AM_RANGE(0x240, 0x243) AM_READ_PORT("P1_P2")
AM_RANGE(0x280, 0x283) AM_DEVWRITE("eeprom", eeprom_w)
AM_RANGE(0x2c0, 0x2c3) AM_DEVREAD("eeprom", eeprom_r)
AM_RANGE(0x440, 0x443) AM_DEVREADWRITE("oki", oki_r, oki_w)
AM_RANGE(0x442, 0x443) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
AM_RANGE(0x540, 0x543) AM_READ_PORT("SYSTEM")
AM_RANGE(0x680, 0x683) AM_DEVWRITE8("ymsnd", ym2151_register_port_w, 0x00ff)
AM_RANGE(0x684, 0x687) AM_DEVREADWRITE8("ymsnd", ym2151_status_port_r, ym2151_data_port_w, 0x00ff)
@ -346,7 +332,7 @@ static ADDRESS_MAP_START( mrdig_io, ADDRESS_SPACE_IO, 16 )
AM_RANGE(0x500, 0x503) AM_READ_PORT("P1_P2")
AM_RANGE(0x3c0, 0x3c3) AM_DEVWRITE("eeprom", eeprom_w)
AM_RANGE(0x180, 0x183) AM_DEVREAD("eeprom", eeprom_r)
AM_RANGE(0x080, 0x083) AM_DEVREADWRITE("oki", oki_r, oki_w)
AM_RANGE(0x082, 0x083) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
AM_RANGE(0x280, 0x283) AM_READ_PORT("SYSTEM")
AM_RANGE(0x0c0, 0x0c3) AM_DEVWRITE8("ymsnd", ym2151_register_port_w, 0x00ff)
AM_RANGE(0x0c4, 0x0c7) AM_DEVREADWRITE8("ymsnd", ym2151_status_port_r, ym2151_data_port_w, 0x00ff)

View File

@ -1,3 +1,4 @@
#include "sound/okim6295.h"
class playmark_state : public driver_device
{
@ -38,7 +39,7 @@ public:
int old_oki_bank;
/* devices */
running_device *oki;
okim6295_device *oki;
running_device *eeprom;
};

View File

@ -97,8 +97,8 @@ static struct
running_machine *machine;
running_device *ymdevice;
running_device *oki1device;
running_device *oki2device;
okim6295_device *oki1device;
okim6295_device *oki2device;
/* C001 */ UINT8 last_command; // last command received
/* C016 */ UINT8 oki_playing; // bitmap of active Oki channels
@ -144,12 +144,12 @@ static void oki_play_sample(int sample_no)
UINT8 byte1 = read8(table_start + 2 * (sample_no & 0x7f) + 0);
UINT8 byte2 = read8(table_start + 2 * (sample_no & 0x7f) + 1);
int chip = (byte1 & 0x80) >> 7;
running_device *okidevice = (chip) ? NMK004_state.oki2device : NMK004_state.oki1device;
okim6295_device *okidevice = (chip) ? NMK004_state.oki2device : NMK004_state.oki1device;
if ((byte1 & 0x7f) == 0)
{
// stop all channels
okim6295_w(okidevice, 0, 0x78 );
okidevice->write_command( 0x78 );
}
else
{
@ -163,7 +163,7 @@ static void oki_play_sample(int sample_no)
NMK004_state.oki_playing |= 1 << (ch + 4*chip);
// stop channel
okim6295_w(okidevice, 0, (0x08 << ch) );
okidevice->write_command( 0x08 << ch );
if (sample != 0)
{
@ -174,15 +174,15 @@ static void oki_play_sample(int sample_no)
if (bank != 3)
memcpy(rom + 0x20000,rom + 0x40000 + bank * 0x20000,0x20000);
okim6295_w(okidevice, 0, 0x80 | sample );
okim6295_w(okidevice, 0, (0x10 << ch) | vol );
okidevice->write_command( 0x80 | sample );
okidevice->write_command( (0x10 << ch) | vol );
}
}
}
static void oki_update_state(void)
{
NMK004_state.oki_playing = ((okim6295_r(NMK004_state.oki2device, 0) & 0x0f) << 4) | (okim6295_r(NMK004_state.oki1device, 0) & 0x0f);
NMK004_state.oki_playing = ((NMK004_state.oki2device->read_status() & 0x0f) << 4) | (NMK004_state.oki1device->read_status() & 0x0f);
}
@ -1022,8 +1022,8 @@ static TIMER_CALLBACK( real_nmk004_init )
NMK004_state.machine = machine;
NMK004_state.ymdevice = machine->device("ymsnd");
NMK004_state.oki1device = machine->device("oki1");
NMK004_state.oki2device = machine->device("oki2");
NMK004_state.oki1device = machine->device<okim6295_device>("oki1");
NMK004_state.oki2device = machine->device<okim6295_device>("oki2");
NMK004_state.rom = memory_region(machine, "audiocpu");

View File

@ -360,7 +360,7 @@ READ8_DEVICE_HANDLER(tatsumi_hack_ym2151_r)
READ8_DEVICE_HANDLER(tatsumi_hack_oki_r)
{
address_space *space = cputag_get_address_space(device->machine, "audiocpu", ADDRESS_SPACE_PROGRAM);
int r=okim6295_r(device,0);
int r=downcast<okim6295_device *>(device)->read(*space,0);
if (cpu_get_pc(space->cpu)==0x2b70 || cpu_get_pc(space->cpu)==0x2bb5
|| cpu_get_pc(space->cpu)==0x2acc