diff options
Diffstat (limited to 'src/devices/sound/mos6560.cpp')
-rw-r--r-- | src/devices/sound/mos6560.cpp | 127 |
1 files changed, 57 insertions, 70 deletions
diff --git a/src/devices/sound/mos6560.cpp b/src/devices/sound/mos6560.cpp index 05ab0bcd08e..fadef01dd20 100644 --- a/src/devices/sound/mos6560.cpp +++ b/src/devices/sound/mos6560.cpp @@ -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]; } @@ -620,20 +615,17 @@ void mos6560_device::soundport_w( int offset, int data ) void mos6560_device::sound_start() { - int i; - - m_channel = stream_alloc_legacy(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 +653,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; - } } @@ -888,15 +876,15 @@ void mos6560_device::device_timer(emu_timer &timer, device_timer_id id, int para } //------------------------------------------------- -// sound_stream_update_legacy - handle a stream update +// sound_stream_update - handle a stream update //------------------------------------------------- -void mos6560_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void mos6560_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { int i, v; - stream_sample_t *buffer = outputs[0]; + auto &buffer = outputs[0]; - for (i = 0; i < samples; i++) + for (i = 0; i < buffer.samples(); i++) { v = 0; if (TONE1_ON /*||(m_tone1pos != 0) */ ) @@ -909,7 +897,7 @@ void mos6560_device::sound_stream_update_legacy(sound_stream &stream, stream_sam if (m_tone1pos >= m_tone1samples) { m_tone1pos = 0; - m_tone1samples = machine().sample_rate() / TONE1_FREQUENCY; + m_tone1samples = buffer.sample_rate() / TONE1_FREQUENCY; if (m_tone1samples == 0) m_tone1samples = 1; } @@ -925,7 +913,7 @@ void mos6560_device::sound_stream_update_legacy(sound_stream &stream, stream_sam if (m_tone2pos >= m_tone2samples) { m_tone2pos = 0; - m_tone2samples = machine().sample_rate() / TONE2_FREQUENCY; + m_tone2samples = buffer.sample_rate() / TONE2_FREQUENCY; if (m_tone2samples == 0) m_tone2samples = 1; } @@ -941,7 +929,7 @@ void mos6560_device::sound_stream_update_legacy(sound_stream &stream, stream_sam if (m_tone3pos >= m_tone3samples) { m_tone3pos = 0; - m_tone3samples = machine().sample_rate() / TONE3_FREQUENCY; + m_tone3samples = buffer.sample_rate() / TONE3_FREQUENCY; if (m_tone3samples == 0) m_tone3samples = 1; } @@ -956,12 +944,11 @@ void mos6560_device::sound_stream_update_legacy(sound_stream &stream, stream_sam 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; + buffer.put_int(i, v, 8192); } } |