mirror of
https://github.com/holub/mame
synced 2025-10-07 17:27:06 +03:00
Modernized s2636 sound device. (nw)
This commit is contained in:
parent
1862219897
commit
29cce1d069
@ -6,89 +6,19 @@
|
|||||||
|
|
||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
#include "sound/s2636.h"
|
#include "sound/s2636.h"
|
||||||
#include "devlegcy.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct s2636_sound
|
|
||||||
{
|
|
||||||
sound_stream *channel;
|
|
||||||
UINT8 reg[1];
|
|
||||||
int size, pos;
|
|
||||||
unsigned level;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static s2636_sound *get_token(device_t *device)
|
|
||||||
{
|
|
||||||
assert(device != NULL);
|
|
||||||
assert(device->type() == S2636_SOUND);
|
|
||||||
return (s2636_sound *) downcast<s2636_sound_device *>(device)->token();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void s2636_soundport_w (device_t *device, int offset, int data)
|
|
||||||
{
|
|
||||||
s2636_sound *token = get_token(device);
|
|
||||||
|
|
||||||
token->channel->update();
|
|
||||||
token->reg[offset] = data;
|
|
||||||
switch (offset)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
token->pos = 0;
|
|
||||||
token->level = TRUE;
|
|
||||||
// frequency 7874/(data+1)
|
|
||||||
token->size = device->machine().sample_rate() * (data + 1) /7874;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************/
|
|
||||||
/* Sound handler update */
|
|
||||||
/************************************/
|
|
||||||
|
|
||||||
static STREAM_UPDATE( s2636_update )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
s2636_sound *token = get_token(device);
|
|
||||||
stream_sample_t *buffer = outputs[0];
|
|
||||||
|
|
||||||
for (i = 0; i < samples; i++, buffer++)
|
|
||||||
{
|
|
||||||
*buffer = 0;
|
|
||||||
if (token->reg[0] && token->pos <= token->size / 2)
|
|
||||||
{
|
|
||||||
*buffer = 0x7fff;
|
|
||||||
}
|
|
||||||
if (token->pos <= token->size)
|
|
||||||
token->pos++;
|
|
||||||
if (token->pos > token->size)
|
|
||||||
token->pos = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************/
|
|
||||||
/* Sound handler start */
|
|
||||||
/************************************/
|
|
||||||
|
|
||||||
static DEVICE_START(s2636_sound)
|
|
||||||
{
|
|
||||||
s2636_sound *token = get_token(device);
|
|
||||||
memset(token, 0, sizeof(*token));
|
|
||||||
token->channel = device->machine().sound().stream_alloc(*device, 0, 1, device->machine().sample_rate(), 0, s2636_update);
|
|
||||||
}
|
|
||||||
|
|
||||||
const device_type S2636_SOUND = &device_creator<s2636_sound_device>;
|
const device_type S2636_SOUND = &device_creator<s2636_sound_device>;
|
||||||
|
|
||||||
s2636_sound_device::s2636_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
s2636_sound_device::s2636_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||||
: device_t(mconfig, S2636_SOUND, "S2636", tag, owner, clock, "s2636", __FILE__),
|
: device_t(mconfig, S2636_SOUND, "S2636", tag, owner, clock, "s2636", __FILE__),
|
||||||
device_sound_interface(mconfig, *this)
|
device_sound_interface(mconfig, *this),
|
||||||
|
m_channel(NULL),
|
||||||
|
m_size(0),
|
||||||
|
m_pos(0),
|
||||||
|
m_level(0)
|
||||||
{
|
{
|
||||||
m_token = global_alloc_clear(s2636_sound);
|
for (int i = 0; i < 1; i++)
|
||||||
|
m_reg[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
@ -107,15 +37,51 @@ void s2636_sound_device::device_config_complete()
|
|||||||
|
|
||||||
void s2636_sound_device::device_start()
|
void s2636_sound_device::device_start()
|
||||||
{
|
{
|
||||||
DEVICE_START_NAME( s2636_sound )(this);
|
m_channel = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate(), this);
|
||||||
|
save_item(NAME(m_size));
|
||||||
|
save_item(NAME(m_pos));
|
||||||
|
save_item(NAME(m_level));
|
||||||
|
|
||||||
|
for (int i = 0; i < 1; i++)
|
||||||
|
save_item(NAME(m_reg[i]), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void s2636_sound_device::soundport_w (int offset, int data)
|
||||||
|
{
|
||||||
|
m_channel->update();
|
||||||
|
m_reg[offset] = data;
|
||||||
|
switch (offset)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
m_pos = 0;
|
||||||
|
m_level = TRUE;
|
||||||
|
// frequency 7874/(data+1)
|
||||||
|
m_size = machine().sample_rate() * (data + 1) /7874;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// sound_stream_update - handle a stream update
|
// sound_stream_update - handle a stream update
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void s2636_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
|
void s2636_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
|
||||||
{
|
{
|
||||||
// should never get here
|
int i;
|
||||||
fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
|
stream_sample_t *buffer = outputs[0];
|
||||||
|
|
||||||
|
for (i = 0; i < samples; i++, buffer++)
|
||||||
|
{
|
||||||
|
*buffer = 0;
|
||||||
|
if (m_reg[0] && m_pos <= m_size / 2)
|
||||||
|
{
|
||||||
|
*buffer = 0x7fff;
|
||||||
|
}
|
||||||
|
if (m_pos <= m_size)
|
||||||
|
m_pos++;
|
||||||
|
if (m_pos > m_size)
|
||||||
|
m_pos = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,10 @@ class s2636_sound_device : public device_t,
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
s2636_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
s2636_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||||
~s2636_sound_device() { global_free(m_token); }
|
~s2636_sound_device() {}
|
||||||
|
|
||||||
// access to legacy token
|
void soundport_w (int mode, int data);
|
||||||
void *token() const { assert(m_token != NULL); return m_token; }
|
|
||||||
protected:
|
protected:
|
||||||
// device-level overrides
|
// device-level overrides
|
||||||
virtual void device_config_complete();
|
virtual void device_config_complete();
|
||||||
@ -25,14 +25,17 @@ protected:
|
|||||||
|
|
||||||
// sound stream update overrides
|
// sound stream update overrides
|
||||||
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
|
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// internal state
|
// internal state
|
||||||
void *m_token;
|
sound_stream *m_channel;
|
||||||
|
UINT8 m_reg[1];
|
||||||
|
int m_size;
|
||||||
|
int m_pos;
|
||||||
|
unsigned m_level;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const device_type S2636_SOUND;
|
extern const device_type S2636_SOUND;
|
||||||
|
|
||||||
void s2636_soundport_w (device_t *device, int mode, int data);
|
|
||||||
|
|
||||||
|
#endif /* S2636_SOUND_H_ */
|
||||||
#endif /* VC4000_H_ */
|
|
||||||
|
@ -319,7 +319,7 @@ WRITE8_DEVICE_HANDLER( s2636_work_ram_w )
|
|||||||
const s2636_interface *intf = get_interface(device);
|
const s2636_interface *intf = get_interface(device);
|
||||||
if ( intf->sound && *intf->sound )
|
if ( intf->sound && *intf->sound )
|
||||||
{
|
{
|
||||||
s2636_soundport_w(device->machine().device(intf->sound), 0, data);
|
device->machine().device<s2636_sound_device>(intf->sound)->soundport_w(0, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
#include "cpu/s2650/s2650.h"
|
#include "cpu/s2650/s2650.h"
|
||||||
#include "sound/s2636.h"
|
|
||||||
|
|
||||||
#include "tinv2650.lh"
|
#include "tinv2650.lh"
|
||||||
#include "includes/zac2650.h"
|
#include "includes/zac2650.h"
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include "sound/s2636.h"
|
||||||
|
|
||||||
class zac2650_state : public driver_device
|
class zac2650_state : public driver_device
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -5,10 +7,15 @@ public:
|
|||||||
: driver_device(mconfig, type, tag),
|
: driver_device(mconfig, type, tag),
|
||||||
m_videoram(*this, "videoram"),
|
m_videoram(*this, "videoram"),
|
||||||
m_s2636_0_ram(*this, "s2636_0_ram"),
|
m_s2636_0_ram(*this, "s2636_0_ram"),
|
||||||
m_maincpu(*this, "maincpu") { }
|
m_maincpu(*this, "maincpu"),
|
||||||
|
m_s2636_sound(*this, "s2636snd") { }
|
||||||
|
|
||||||
required_shared_ptr<UINT8> m_videoram;
|
required_shared_ptr<UINT8> m_videoram;
|
||||||
required_shared_ptr<UINT8> m_s2636_0_ram;
|
required_shared_ptr<UINT8> m_s2636_0_ram;
|
||||||
|
|
||||||
|
required_device<cpu_device> m_maincpu;
|
||||||
|
required_device<s2636_sound_device> m_s2636_sound;
|
||||||
|
|
||||||
bitmap_ind16 m_bitmap;
|
bitmap_ind16 m_bitmap;
|
||||||
bitmap_ind16 m_spritebitmap;
|
bitmap_ind16 m_spritebitmap;
|
||||||
int m_CollisionBackground;
|
int m_CollisionBackground;
|
||||||
@ -25,5 +32,4 @@ public:
|
|||||||
UINT32 screen_update_tinvader(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
UINT32 screen_update_tinvader(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||||
int SpriteCollision(int first,int second);
|
int SpriteCollision(int first,int second);
|
||||||
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
|
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||||
required_device<cpu_device> m_maincpu;
|
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
|
|
||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
#include "sound/s2636.h"
|
|
||||||
#include "includes/zac2650.h"
|
#include "includes/zac2650.h"
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ WRITE8_MEMBER(zac2650_state::zac_s2636_w)
|
|||||||
machine().gfx[2]->mark_dirty(offset/8);
|
machine().gfx[2]->mark_dirty(offset/8);
|
||||||
if (offset == 0xc7)
|
if (offset == 0xc7)
|
||||||
{
|
{
|
||||||
s2636_soundport_w(machine().device("s2636snd"), 0, data);
|
m_s2636_sound->soundport_w(0, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user