summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/mos6560.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/mos6560.cpp')
-rw-r--r--src/devices/sound/mos6560.cpp180
1 files changed, 76 insertions, 104 deletions
diff --git a/src/devices/sound/mos6560.cpp b/src/devices/sound/mos6560.cpp
index d332791ec7c..5f77f5e0781 100644
--- a/src/devices/sound/mos6560.cpp
+++ b/src/devices/sound/mos6560.cpp
@@ -59,7 +59,7 @@
#include "emu.h"
-#include "sound/mos6560.h"
+#include "mos6560.h"
/*****************************************************************************
@@ -173,20 +173,18 @@ inline uint8_t mos6560_device::read_colorram(offs_t offset)
void mos6560_device::draw_character( int ybegin, int yend, int ch, int yoff, int xoff, uint16_t *color )
{
- int y, code;
-
- for (y = ybegin; y <= yend; y++)
+ for (int y = ybegin; y <= yend; y++)
{
- code = read_videoram((m_chargenaddr + ch * m_charheight + y) & 0x3fff);
-
- m_bitmap.pix32(y + yoff, xoff + 0) = PALETTE_MOS[color[code >> 7]];
- m_bitmap.pix32(y + yoff, xoff + 1) = PALETTE_MOS[color[(code >> 6) & 1]];
- m_bitmap.pix32(y + yoff, xoff + 2) = PALETTE_MOS[color[(code >> 5) & 1]];
- m_bitmap.pix32(y + yoff, xoff + 3) = PALETTE_MOS[color[(code >> 4) & 1]];
- m_bitmap.pix32(y + yoff, xoff + 4) = PALETTE_MOS[color[(code >> 3) & 1]];
- m_bitmap.pix32(y + yoff, xoff + 5) = PALETTE_MOS[color[(code >> 2) & 1]];
- m_bitmap.pix32(y + yoff, xoff + 6) = PALETTE_MOS[color[(code >> 1) & 1]];
- m_bitmap.pix32(y + yoff, xoff + 7) = PALETTE_MOS[color[code & 1]];
+ int code = read_videoram((m_chargenaddr + ch * m_charheight + y) & 0x3fff);
+
+ m_bitmap.pix(y + yoff, xoff + 0) = PALETTE_MOS[color[BIT(code, 7)]];
+ m_bitmap.pix(y + yoff, xoff + 1) = PALETTE_MOS[color[BIT(code, 6)]];
+ m_bitmap.pix(y + yoff, xoff + 2) = PALETTE_MOS[color[BIT(code, 5)]];
+ m_bitmap.pix(y + yoff, xoff + 3) = PALETTE_MOS[color[BIT(code, 4)]];
+ m_bitmap.pix(y + yoff, xoff + 4) = PALETTE_MOS[color[BIT(code, 3)]];
+ m_bitmap.pix(y + yoff, xoff + 5) = PALETTE_MOS[color[BIT(code, 2)]];
+ m_bitmap.pix(y + yoff, xoff + 6) = PALETTE_MOS[color[BIT(code, 1)]];
+ m_bitmap.pix(y + yoff, xoff + 7) = PALETTE_MOS[color[BIT(code, 0)]];
}
}
@@ -197,20 +195,18 @@ void mos6560_device::draw_character( int ybegin, int yend, int ch, int yoff, int
void mos6560_device::draw_character_multi( int ybegin, int yend, int ch, int yoff, int xoff, uint16_t *color )
{
- int y, code;
-
- for (y = ybegin; y <= yend; y++)
+ for (int y = ybegin; y <= yend; y++)
{
- code = read_videoram((m_chargenaddr + ch * m_charheight + y) & 0x3fff);
-
- m_bitmap.pix32(y + yoff, xoff + 0) =
- m_bitmap.pix32(y + yoff, xoff + 1) = PALETTE_MOS[color[code >> 6]];
- m_bitmap.pix32(y + yoff, xoff + 2) =
- m_bitmap.pix32(y + yoff, xoff + 3) = PALETTE_MOS[color[(code >> 4) & 3]];
- m_bitmap.pix32(y + yoff, xoff + 4) =
- m_bitmap.pix32(y + yoff, xoff + 5) = PALETTE_MOS[color[(code >> 2) & 3]];
- m_bitmap.pix32(y + yoff, xoff + 6) =
- m_bitmap.pix32(y + yoff, xoff + 7) = PALETTE_MOS[color[code & 3]];
+ int code = read_videoram((m_chargenaddr + ch * m_charheight + y) & 0x3fff);
+
+ m_bitmap.pix(y + yoff, xoff + 0) = m_bitmap.pix(y + yoff, xoff + 1) =
+ PALETTE_MOS[color[code >> 6]];
+ m_bitmap.pix(y + yoff, xoff + 2) = m_bitmap.pix(y + yoff, xoff + 3) =
+ PALETTE_MOS[color[(code >> 4) & 3]];
+ m_bitmap.pix(y + yoff, xoff + 4) = m_bitmap.pix(y + yoff, xoff + 5) =
+ PALETTE_MOS[color[(code >> 2) & 3]];
+ m_bitmap.pix(y + yoff, xoff + 6) = m_bitmap.pix(y + yoff, xoff + 7) =
+ PALETTE_MOS[color[code & 3]];
}
}
@@ -221,9 +217,7 @@ void mos6560_device::draw_character_multi( int ybegin, int yend, int ch, int yof
void mos6560_device::drawlines( int first, int last )
{
- int line, vline;
- int offs, yoff, xoff, ybegin, yend, i, j;
- int attr, ch;
+ int line;
m_lastline = last;
if (first >= last)
@@ -231,12 +225,13 @@ void mos6560_device::drawlines( int first, int last )
for (line = first; (line < m_ypos) && (line < last); line++)
{
- for (j = 0; j < m_total_xsize; j++)
- m_bitmap.pix32(line, j) = PALETTE_MOS[m_framecolor];
+ for (int j = 0; j < m_total_xsize; j++)
+ m_bitmap.pix(line, j) = PALETTE_MOS[m_framecolor];
}
- for (vline = line - m_ypos; (line < last) && (line < m_ypos + m_ysize);)
+ for (int vline = line - m_ypos; (line < last) && (line < m_ypos + m_ysize);)
{
+ int offs, yoff, xoff, ybegin, yend;
if (m_matrix8x16)
{
offs = (vline >> 4) * m_chars_x;
@@ -254,16 +249,16 @@ void mos6560_device::drawlines( int first, int last )
if (m_xpos > 0)
{
- for (i = ybegin; i <= yend; i++)
- for (j = 0; j < m_xpos; j++)
- m_bitmap.pix32(yoff + i, j) = PALETTE_MOS[m_framecolor];
+ for (int i = ybegin; i <= yend; i++)
+ for (int j = 0; j < m_xpos; j++)
+ m_bitmap.pix(yoff + i, j) = PALETTE_MOS[m_framecolor];
}
for (xoff = m_xpos; (xoff < m_xpos + m_xsize) && (xoff < m_total_xsize); xoff += 8, offs++)
{
- ch = read_videoram((m_videoaddr + offs) & 0x3fff);
+ int ch = read_videoram((m_videoaddr + offs) & 0x3fff);
- attr = (read_colorram((m_videoaddr + offs) & 0x3fff)) & 0xf;
+ int attr = (read_colorram((m_videoaddr + offs) & 0x3fff)) & 0xf;
if (m_variant == TYPE_ATTACK_UFO)
{
@@ -301,9 +296,9 @@ void mos6560_device::drawlines( int first, int last )
if (xoff < m_total_xsize)
{
- for (i = ybegin; i <= yend; i++)
- for (j = xoff; j < m_total_xsize; j++)
- m_bitmap.pix32(yoff + i, j) = PALETTE_MOS[m_framecolor];
+ for (int i = ybegin; i <= yend; i++)
+ for (int j = xoff; j < m_total_xsize; j++)
+ m_bitmap.pix(yoff + i, j) = PALETTE_MOS[m_framecolor];
}
if (m_matrix8x16)
@@ -319,8 +314,8 @@ void mos6560_device::drawlines( int first, int last )
}
for (; line < last; line++)
- for (j = 0; j < m_total_xsize; j++)
- m_bitmap.pix32(line, j) = PALETTE_MOS[m_framecolor];
+ for (int j = 0; j < m_total_xsize; j++)
+ m_bitmap.pix(line, j) = PALETTE_MOS[m_framecolor];
}
@@ -328,8 +323,10 @@ void mos6560_device::drawlines( int first, int last )
mos6560_port_w - write to regs
-------------------------------------------------*/
-WRITE8_MEMBER( mos6560_device::write )
+void mos6560_device::write(offs_t offset, uint8_t data)
{
+ offset &= 0xf;
+
DBG_LOG(1, "mos6560_port_w", ("%.4x:%.2x\n", offset, data));
switch (offset)
@@ -406,8 +403,10 @@ WRITE8_MEMBER( mos6560_device::write )
mos6560_port_r - read from regs
-------------------------------------------------*/
-READ8_MEMBER( mos6560_device::read )
+uint8_t mos6560_device::read(offs_t offset)
{
+ offset &= 0xf;
+
int val;
switch (offset)
@@ -421,7 +420,7 @@ READ8_MEMBER( mos6560_device::read )
break;
case 6: /*lightpen horizontal */
case 7: /*lightpen vertical */
-#ifdef UNUSED_FUNCTION
+#if 0
if (LIGHTPEN_BUTTON && ((machine().time().as_double() - m_lightpenreadtime) * MOS656X_VRETRACERATE >= 1))
{
/* only 1 update each frame */
@@ -450,7 +449,7 @@ READ8_MEMBER( mos6560_device::read )
return val;
}
-WRITE_LINE_MEMBER( mos6560_device::lp_w )
+void mos6560_device::lp_w(int state)
{
// TODO
}
@@ -464,7 +463,7 @@ uint8_t mos6560_device::bus_r()
mos6560_raster_interrupt_gen
-------------------------------------------------*/
-void mos6560_device::raster_interrupt_gen()
+TIMER_CALLBACK_MEMBER(mos6560_device::raster_interrupt_gen)
{
m_rasterline++;
if (m_rasterline >= m_total_lines)
@@ -620,20 +619,17 @@ void mos6560_device::soundport_w( int offset, int data )
void mos6560_device::sound_start()
{
- int i;
-
- m_channel = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate());
+ m_channel = stream_alloc(0, 1, machine().sample_rate());
/* buffer for fastest played sample for 5 second so we have enough data for min 5 second */
m_noisesize = NOISE_FREQUENCY_MAX * NOISE_BUFFER_SIZE_SEC;
- m_noise = std::make_unique<int8_t[]>(m_noisesize);
+ m_noise = std::make_unique<int8_t []>(m_noisesize);
{
int noiseshift = 0x7ffff8;
- char data;
- for (i = 0; i < m_noisesize; i++)
+ for (int i = 0; i < m_noisesize; i++)
{
- data = 0;
+ char data = 0;
if (noiseshift & 0x400000)
data |= 0x80;
if (noiseshift & 0x100000)
@@ -661,17 +657,13 @@ void mos6560_device::sound_start()
if (m_tonesize > 0)
{
- m_tone = std::make_unique<int16_t[]>(m_tonesize);
+ m_tone = std::make_unique<int16_t []>(m_tonesize);
- for (i = 0; i < m_tonesize; i++)
+ for (int i = 0; i < m_tonesize; i++)
{
- m_tone[i] = (int16_t)(sin (2 * M_PI * i / m_tonesize) * 127 + 0.5);
+ m_tone[i] = int16_t(sin (2 * M_PI * i / m_tonesize) * 127 + 0.5);
}
}
- else
- {
- m_tone = nullptr;
- }
}
@@ -692,16 +684,16 @@ void mos6560_device::mos6560_colorram_map(address_map &map)
map(0x000, 0x3ff).ram();
}
-mos6560_device::mos6560_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint32_t variant)
- : device_t(mconfig, type, tag, owner, clock),
- device_memory_interface(mconfig, *this),
- device_sound_interface(mconfig, *this),
- device_video_interface(mconfig, *this),
- m_variant(variant),
- m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, address_map_constructor(FUNC(mos6560_device::mos6560_videoram_map), this)),
- m_colorram_space_config("colorram", ENDIANNESS_LITTLE, 8, 10, 0, address_map_constructor(FUNC(mos6560_device::mos6560_colorram_map), this)),
- m_read_potx(*this),
- m_read_poty(*this)
+mos6560_device::mos6560_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint32_t variant) :
+ device_t(mconfig, type, tag, owner, clock),
+ device_memory_interface(mconfig, *this),
+ device_sound_interface(mconfig, *this),
+ device_video_interface(mconfig, *this),
+ m_variant(variant),
+ m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, address_map_constructor(FUNC(mos6560_device::mos6560_videoram_map), this)),
+ m_colorram_space_config("colorram", ENDIANNESS_LITTLE, 8, 10, 0, address_map_constructor(FUNC(mos6560_device::mos6560_colorram_map), this)),
+ m_read_potx(*this, 0xff),
+ m_read_poty(*this, 0xff)
{
}
@@ -743,10 +735,6 @@ void mos6560_device::device_start()
{
screen().register_screen_bitmap(m_bitmap);
- // resolve callbacks
- m_read_potx.resolve_safe(0xff);
- m_read_poty.resolve_safe(0xff);
-
switch (m_variant)
{
case TYPE_6560:
@@ -772,7 +760,7 @@ void mos6560_device::device_start()
}
// allocate timers
- m_line_timer = timer_alloc(TIMER_LINE);
+ m_line_timer = timer_alloc(FUNC(mos6560_device::raster_interrupt_gen), this);
m_line_timer->adjust(screen().scan_period(), 0, screen().scan_period());
// initialize sound
@@ -874,29 +862,14 @@ void mos6560_device::device_reset()
//-------------------------------------------------
-// device_timer - handler timer events
-//-------------------------------------------------
-
-void mos6560_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_LINE:
- raster_interrupt_gen();
- break;
- }
-}
-
-//-------------------------------------------------
// sound_stream_update - handle a stream update
//-------------------------------------------------
-void mos6560_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
+void mos6560_device::sound_stream_update(sound_stream &stream)
{
int i, v;
- stream_sample_t *buffer = outputs[0];
- for (i = 0; i < samples; i++)
+ for (i = 0; i < stream.samples(); i++)
{
v = 0;
if (TONE1_ON /*||(m_tone1pos != 0) */ )
@@ -909,7 +882,7 @@ void mos6560_device::sound_stream_update(sound_stream &stream, stream_sample_t *
if (m_tone1pos >= m_tone1samples)
{
m_tone1pos = 0;
- m_tone1samples = machine().sample_rate() / TONE1_FREQUENCY;
+ m_tone1samples = stream.sample_rate() / TONE1_FREQUENCY;
if (m_tone1samples == 0)
m_tone1samples = 1;
}
@@ -925,7 +898,7 @@ void mos6560_device::sound_stream_update(sound_stream &stream, stream_sample_t *
if (m_tone2pos >= m_tone2samples)
{
m_tone2pos = 0;
- m_tone2samples = machine().sample_rate() / TONE2_FREQUENCY;
+ m_tone2samples = stream.sample_rate() / TONE2_FREQUENCY;
if (m_tone2samples == 0)
m_tone2samples = 1;
}
@@ -941,7 +914,7 @@ void mos6560_device::sound_stream_update(sound_stream &stream, stream_sample_t *
if (m_tone3pos >= m_tone3samples)
{
m_tone3pos = 0;
- m_tone3samples = machine().sample_rate() / TONE3_FREQUENCY;
+ m_tone3samples = stream.sample_rate() / TONE3_FREQUENCY;
if (m_tone3samples == 0)
m_tone3samples = 1;
}
@@ -956,12 +929,11 @@ void mos6560_device::sound_stream_update(sound_stream &stream, stream_sample_t *
m_noisepos = 0;
}
}
- v = (v * VOLUME) << 2;
- if (v > 32767)
- buffer[i] = 32767;
- else if (v < -32767)
- buffer[i] = -32767;
- else
- buffer[i] = v;
+ v *= VOLUME;
+ if (v > 8191)
+ v = 8191;
+ else if (v < -8191)
+ v = -8191;
+ stream.put_int(0, i, v, 8192);
}
}