diff options
Diffstat (limited to 'src/devices/machine/s2636.cpp')
-rw-r--r-- | src/devices/machine/s2636.cpp | 72 |
1 files changed, 31 insertions, 41 deletions
diff --git a/src/devices/machine/s2636.cpp b/src/devices/machine/s2636.cpp index 3d29e76b099..d2576b07f1f 100644 --- a/src/devices/machine/s2636.cpp +++ b/src/devices/machine/s2636.cpp @@ -119,7 +119,7 @@ *************************************************************/ #include "emu.h" -#include "machine/s2636.h" +#include "s2636.h" #include "screen.h" @@ -180,6 +180,10 @@ s2636_device::s2636_device(const machine_config &mconfig, const char *tag, devic for (auto &elem : m_obj_dup) elem = false; } +s2636_device::~s2636_device() +{ +} + //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -203,11 +207,9 @@ void s2636_device::device_start() save_item(NAME(m_intreq)); save_item(NAME(m_intack)); - m_stream = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate()); + m_stream = stream_alloc(0, 1, machine().sample_rate()); save_item(NAME(m_sample_cnt)); save_item(NAME(m_sound_lvl)); - - m_intreq_cb.resolve_safe(); } @@ -227,17 +229,6 @@ bitmap_ind16 const &s2636_device::update(const rectangle &cliprect) //------------------------------------------------- -// render the first line into the bitmap -//------------------------------------------------- - -void s2636_device::render_first_line() -{ - m_screen_line = 0; - render_next_line(); -} - - -//------------------------------------------------- // render next line into the bitmap //------------------------------------------------- @@ -247,7 +238,7 @@ void s2636_device::render_next_line() // pre-clear the line for convenience rectangle const &vis_area = screen().visible_area(); - uint16_t *const row = &m_bitmap.pix16(m_screen_line); + uint16_t *const row = &m_bitmap.pix(m_screen_line); m_bitmap.plot_box(0, m_screen_line, m_bitmap.width(), 1, 0); if ((vis_area.min_y > m_screen_line) || (vis_area.max_y < m_screen_line)) @@ -298,8 +289,8 @@ void s2636_device::render_next_line() m_obj_cnt[i] -= obj_inc; // fetch appropriate line from object - uint8_t const obj_bits = m_registers[OFFS_OBJ[i] + OBJ_HEIGHT - 1 - (m_obj_cnt[i] >> 3)]; - uint16_t const obj_clr = object_color(i) | 0x08 | (0x10 << i); + uint8_t const obj_bits = m_registers[OFFS_OBJ[i] + OBJ_HEIGHT - 1 - (m_obj_cnt[i] >> 3)]; + uint16_t const obj_clr = object_color(i) | 0x08 | (0x10 << i); // blit it to the line ignoring intermediate pixels int const obj_h_cnt = m_registers[OFFS_OBJ[i] + (m_obj_dup[i] ? OFFS_HCB : OFFS_HC)] + m_x_offset; @@ -329,15 +320,15 @@ void s2636_device::render_next_line() } // let's take a look at the score display - uint16_t const bg_clr = m_registers[REG_BG_ENB_CLR] & 0x07; - int const score_row = m_vis_line - m_y_offset - SCORE_START_Y[m_registers[REG_SCORE_FMT] & 0x01]; + uint16_t const bg_clr = m_registers[REG_BG_ENB_CLR] & 0x07; + int const score_row = m_vis_line - m_y_offset - SCORE_START_Y[m_registers[REG_SCORE_FMT] & 0x01]; if ((0 <= score_row) && (SCORE_HEIGHT > score_row)) { int const (&score_start_x)[SCORE_DIGITS] = SCORE_START_X[(m_registers[REG_SCORE_FMT] >> 1) & 0x01]; for (int i = 0; i < SCORE_DIGITS; i++) { - uint16_t score_bits = SCORE_FONT[score_digit(i)][score_row >> 2]; - int screen_col = vis_area.min_x + ((score_start_x[i] + m_x_offset) * m_divider); + uint16_t score_bits = SCORE_FONT[score_digit(i)][score_row >> 2]; + int screen_col = vis_area.min_x + ((score_start_x[i] + m_x_offset) * m_divider); while (score_bits && (vis_area.max_x >= screen_col)) { if (score_bits & 0x0001) row[screen_col] |= bg_clr | 0x08; @@ -348,16 +339,16 @@ void s2636_device::render_next_line() } // work out how the background pattern will be drawn - bool const bg_enable = bool(m_registers[REG_BG_ENB_CLR] & 0x08); - int const bg_row = m_vis_line - m_y_offset - BG_START_Y; - bool const bg_draw = bg_enable && (0 <= bg_row) && (BG_HEIGHT > bg_row); - int const bg_vbar_offs = OFFS_VBAR_DEF + ((bg_row / 20) << 2) + (((bg_row % 20) >= 2) ? 2 : 0); - int const bg_hbar_offs = OFFS_HBAR_DEF + (bg_row / 40); - uint16_t const bg_vbar_bits = (uint16_t(m_registers[bg_vbar_offs]) << 8) | uint16_t(m_registers[bg_vbar_offs + 1]); - uint8_t const bg_hbar_bits = m_registers[bg_hbar_offs]; - bool const bg_hbar_stretch = bool(bg_hbar_bits & (1 << ((((bg_row % 40) >= 20) ? 3 : 0) + (((bg_row % 20) >= 11) ? 2 : ((bg_row % 20) >= 2) ? 1 : 0)))); - int const bg_hbar_width = bg_hbar_stretch ? 8 : (0xc0 == (bg_hbar_bits & 0xc0)) ? 4 : (0x40 == (bg_hbar_bits & 0xc0)) ? 2 : 1; - uint16_t const scrn_clr = bg_enable ? ((m_registers[REG_BG_ENB_CLR] >> 4) & 0x07) : 0x00; + bool const bg_enable = bool(m_registers[REG_BG_ENB_CLR] & 0x08); + int const bg_row = m_vis_line - m_y_offset - BG_START_Y; + bool const bg_draw = bg_enable && (0 <= bg_row) && (BG_HEIGHT > bg_row); + int const bg_vbar_offs = OFFS_VBAR_DEF + ((bg_row / 20) << 2) + (((bg_row % 20) >= 2) ? 2 : 0); + int const bg_hbar_offs = OFFS_HBAR_DEF + (bg_row / 40); + uint16_t const bg_vbar_bits = (uint16_t(m_registers[bg_vbar_offs]) << 8) | uint16_t(m_registers[bg_vbar_offs + 1]); + uint8_t const bg_hbar_bits = m_registers[bg_hbar_offs]; + bool const bg_hbar_stretch = bool(bg_hbar_bits & (1 << ((((bg_row % 40) >= 20) ? 3 : 0) + (((bg_row % 20) >= 11) ? 2 : ((bg_row % 20) >= 2) ? 1 : 0)))); + int const bg_hbar_width = bg_hbar_stretch ? 8 : (0xc0 == (bg_hbar_bits & 0xc0)) ? 4 : (0x40 == (bg_hbar_bits & 0xc0)) ? 2 : 1; + uint16_t const scrn_clr = bg_enable ? ((m_registers[REG_BG_ENB_CLR] >> 4) & 0x07) : 0x00; for (int screen_col = vis_area.min_x, x = 0; vis_area.max_x >= screen_col; x++) { @@ -370,8 +361,8 @@ void s2636_device::render_next_line() if ((row[screen_col] & 0x40) && (row[screen_col] & 0x80)) m_registers[REG_VBL_COL_OBJ] |= 0x01; // work out if the background hits this pixel - int const bg_col = x - m_x_offset - BG_START_X; - bool const bg = bool(bg_vbar_bits & (1U << (15 - (bg_col >> 3)))); + int const bg_col = x - m_x_offset - BG_START_X; + bool const bg = bool(bg_vbar_bits & (1U << (15 - (bg_col >> 3)))); if (bg_draw && (0 <= bg_col) && (BG_WIDTH > bg_col) && bg && (bg_hbar_width > (bg_col & 0x07))) { // do object-background collisions @@ -405,7 +396,7 @@ void s2636_device::render_next_line() // bus access handlers //------------------------------------------------- -READ8_MEMBER( s2636_device::read_data ) +uint8_t s2636_device::read_data(offs_t offset) { mask_offset(offset); uint8_t data = m_registers[offset]; @@ -424,7 +415,7 @@ READ8_MEMBER( s2636_device::read_data ) return data; } -WRITE8_MEMBER( s2636_device::write_data ) +void s2636_device::write_data(offs_t offset, uint8_t data) { mask_offset(offset); @@ -434,7 +425,7 @@ WRITE8_MEMBER( s2636_device::write_data ) m_registers[offset] = data; } -WRITE_LINE_MEMBER( s2636_device::write_intack ) +void s2636_device::write_intack(int state) { assert((ASSERT_LINE == state) || (HOLD_LINE == state) || (CLEAR_LINE == state)); @@ -450,10 +441,9 @@ WRITE_LINE_MEMBER( s2636_device::write_intack ) // sound_stream_update - generate audio output //------------------------------------------------- -void s2636_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) +void s2636_device::sound_stream_update(sound_stream &stream) { - stream_sample_t *buffer = outputs[0]; - while (samples--) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { if (!m_sample_cnt) { @@ -469,7 +459,7 @@ void s2636_device::sound_stream_update(sound_stream &stream, stream_sample_t **i } } - *buffer++ = m_sound_lvl ? 0x7fff : 0x0000; + stream.put(0, sampindex, m_sound_lvl ? 1.0 : 0.0); m_sample_cnt--; } } |