From ab2451cb8d2b24746d5e71a149608d4dab32ade2 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Thu, 4 Jul 2024 06:50:55 +1000 Subject: -machine/genpc.h: Connect iochrdy properly. Also don't forward the same thing more than once - it could be std::move'd out the first time. -Miscellaneous cleanup: * emu/rendersw.hxx: Made cosine table constexpr, got rid of lambda and loop. * igs/spoker.cpp: DIP switches are a switch matrix. * merit/merit.cpp: Made the video control bits a bit clearer. * Some other trivial tidying. --- src/devices/machine/am9513.cpp | 2 +- src/devices/machine/genpc.h | 5 +++-- src/emu/rendersw.hxx | 17 ++++++----------- src/mame/igs/spoker.cpp | 24 +++++++++++++----------- src/mame/merit/merit.cpp | 13 ++++++------- src/mame/rockwell/aim65.cpp | 4 ++-- src/mame/unico/goori.cpp | 4 ++-- 7 files changed, 33 insertions(+), 36 deletions(-) diff --git a/src/devices/machine/am9513.cpp b/src/devices/machine/am9513.cpp index bcf768f87c7..4f168c7f231 100644 --- a/src/devices/machine/am9513.cpp +++ b/src/devices/machine/am9513.cpp @@ -442,7 +442,7 @@ void am9513_device::set_counter_mode(int c, u16 data) else if (source >= 6 && source <= 10) LOGMASKED(LOG_MODE, "Counter %d: Count on %s edge of GATE %d\n", c + 1, BIT(data, 12) ? "falling" : "rising", source - 5); else if (source == 0) - LOGMASKED(LOG_MODE, "Counter %d: Count on %s edge of TC%d\n", c + 1, BIT(data, 12) ? "falling" : "rising", c ); + LOGMASKED(LOG_MODE, "Counter %d: Count on %s edge of TC%d\n", c + 1, BIT(data, 12) ? "falling" : "rising", c); else LOGMASKED(LOG_MODE, "Counter %d: Count on %s edge of SRC %d\n", c + 1, BIT(data, 12) ? "falling" : "rising", source); } diff --git a/src/devices/machine/genpc.h b/src/devices/machine/genpc.h index 1fa96086c1f..4f0cdbfe3a0 100644 --- a/src/devices/machine/genpc.h +++ b/src/devices/machine/genpc.h @@ -33,8 +33,9 @@ public: template void set_cputag(T &&tag) { m_maincpu.set_tag(std::forward(tag)); - m_isabus.lookup()->set_memspace(std::forward(tag), AS_PROGRAM); - m_isabus.lookup()->set_iospace(std::forward(tag), AS_IO); + m_isabus.lookup()->set_memspace(m_maincpu, AS_PROGRAM); + m_isabus.lookup()->set_iospace(m_maincpu, AS_IO); + m_isabus.lookup()->iochrdy_callback().set_inputline(m_maincpu, INPUT_LINE_HALT); } auto int_callback() { return m_int_callback.bind(); } diff --git a/src/emu/rendersw.hxx b/src/emu/rendersw.hxx index 7173711e018..ccd30912034 100644 --- a/src/emu/rendersw.hxx +++ b/src/emu/rendersw.hxx @@ -30,10 +30,12 @@ private: }; // internal helpers + template + static constexpr auto make_cosine_table(std::integer_sequence) { return std::array{ u32((1.0 / cos(atan(double(Values) / double(sizeof...(Values) - 1)))) * 0x10000000 + 0.5)... }; } static constexpr bool is_opaque(float alpha) { return (alpha >= (NoDestRead ? 0.5f : 1.0f)); } static constexpr bool is_transparent(float alpha) { return (alpha < (NoDestRead ? 0.5f : 0.0001f)); } - static inline rgb_t apply_intensity(int intensity, rgb_t color) { return color.scale8(intensity); } - static inline float round_nearest(float f) { return floor(f + 0.5f); } + static rgb_t apply_intensity(int intensity, rgb_t color) { return color.scale8(intensity); } + static float round_nearest(float f) { return floor(f + 0.5f); } // destination pixels are written based on the values of the template parameters static constexpr PixelType dest_assemble_rgb(u32 r, u32 g, u32 b) { return (r << DstShiftR) | (g << DstShiftG) | (b << DstShiftB); } @@ -427,15 +429,8 @@ private: static void draw_line(render_primitive const &prim, PixelType *dstdata, s32 width, s32 height, u32 pitch) { - // internal cosine table generated at compile-time - static const auto s_cosine_table = []() { - std::array result{}; - - for (int entry = 0; entry <= 2048; entry++) - result[entry] = int(double(1.0 / cos(atan(double(entry) / 2048.0))) * 0x10000000 + 0.5); - - return static_cast>(result); - }(); + // internal cosine table generated at compile time + static constexpr auto s_cosine_table = make_cosine_table(std::make_integer_sequence()); // compute the start/end coordinates int x1 = int(prim.bounds.x0 * 65536.0f); diff --git a/src/mame/igs/spoker.cpp b/src/mame/igs/spoker.cpp index c24c50e1e0d..ad3e25f6361 100644 --- a/src/mame/igs/spoker.cpp +++ b/src/mame/igs/spoker.cpp @@ -225,10 +225,10 @@ void spoker_state::nmi_and_coins_w(uint8_t data) // popmessage("%02x", data); } - machine().bookkeeping().coin_counter_w(0, data & 0x01); // coin_a - machine().bookkeeping().coin_counter_w(1, data & 0x04); // coin_c - machine().bookkeeping().coin_counter_w(2, data & 0x08); // key in - machine().bookkeeping().coin_counter_w(3, data & 0x10); // coin out mech + machine().bookkeeping().coin_counter_w(0, BIT(data, 0)); // coin_a + machine().bookkeeping().coin_counter_w(1, BIT(data, 2)); // coin_c + machine().bookkeeping().coin_counter_w(2, BIT(data, 3)); // key in + machine().bookkeeping().coin_counter_w(3, BIT(data, 4)); // coin out mech m_leds[6] = BIT(data, 6); // led for coin out / hopper active @@ -318,13 +318,15 @@ uint8_t spoker_state::magic_r() switch (m_igs_magic[0]) { case 0x00: - if (!(m_igs_magic[1] & 0x01)) return m_dsw[0]->read(); - if (!(m_igs_magic[1] & 0x02)) return m_dsw[1]->read(); - if (!(m_igs_magic[1] & 0x04)) return m_dsw[2]->read(); - if (!(m_igs_magic[1] & 0x08)) return m_dsw[3]->read(); - if (!(m_igs_magic[1] & 0x10)) return m_dsw[4]->read(); - logerror("%06x: warning, reading dsw with igs_magic[1] = %02x\n", m_maincpu->pc(), m_igs_magic[1]); - break; + { + uint8_t result = 0xff; + if (BIT(~m_igs_magic[1], 0)) result &= m_dsw[0]->read(); + if (BIT(~m_igs_magic[1], 1)) result &= m_dsw[1]->read(); + if (BIT(~m_igs_magic[1], 2)) result &= m_dsw[2]->read(); + if (BIT(~m_igs_magic[1], 3)) result &= m_dsw[3]->read(); + if (BIT(~m_igs_magic[1], 4)) result &= m_dsw[4]->read(); + return result; + } default: logerror("%06x: warning, reading with igs_magic = %02x\n", m_maincpu->pc(), m_igs_magic[0]); diff --git a/src/mame/merit/merit.cpp b/src/mame/merit/merit.cpp index 82b519afe50..e1b972941d6 100644 --- a/src/mame/merit/merit.cpp +++ b/src/mame/merit/merit.cpp @@ -164,7 +164,7 @@ private: pen_t m_pens[NUM_PENS]; uint8_t m_lscnblk = 0; - uint16_t m_extra_video_bank_bit[2]{}; + uint16_t m_extra_video_bank_bit = 0; void hsync_changed(int state); void led1_w(uint8_t data); @@ -383,8 +383,8 @@ MC6845_UPDATE_ROW(merit_state::crtc_update_row) for (uint8_t cx = 0; cx < x_count; cx++) { int const attr = m_ram_attr[ma & 0x7ff]; - int const region = (attr & 0x40) >> 6; - int addr = ((m_ram_video[ma & 0x7ff] | ((attr & 0x80) << 1) | (m_extra_video_bank_bit[0] | m_extra_video_bank_bit[1])) << 4) | (ra & 0x0f); + int const region = BIT(attr, 6); + int addr = ((m_ram_video[ma & 0x7ff] | ((attr & 0x80) << 1) | m_extra_video_bank_bit) << 4) | (ra & 0x0f); int const colour = (attr & 0x7f) << 3; addr &= (rlen - 1); @@ -474,10 +474,9 @@ void merit_state::led2_w(uint8_t data) void merit_state::misc_w(uint8_t data) { - flip_screen_set(~data & 0x10); - m_extra_video_bank_bit[0] = (data & 2) << 8; - m_extra_video_bank_bit[1] = (data & 1) << 10; - m_lscnblk = (data >> 3) & 1; + flip_screen_set(BIT(~data, 4)); + m_extra_video_bank_bit = bitswap<2>(data, 0, 1) << 9; + m_lscnblk = BIT(data, 3); // other bits unknown } diff --git a/src/mame/rockwell/aim65.cpp b/src/mame/rockwell/aim65.cpp index b0d840318f1..e15fb3c3b62 100644 --- a/src/mame/rockwell/aim65.cpp +++ b/src/mame/rockwell/aim65.cpp @@ -48,11 +48,11 @@ void aim65_state::mem_map(address_map &map) map(0x1000, 0x3fff).noprw(); // User available expansions map(0x4000, 0x7fff).rom(); // 4 ROM sockets in 16K PROM/ROM module map(0x8000, 0x9fff).noprw(); // User available expansions - map(0xa000, 0xa00f).mirror(0x3f0).m(m_via1, FUNC(via6522_device::map)); // user via + map(0xa000, 0xa00f).mirror(0x3f0).m(m_via1, FUNC(via6522_device::map)); // user VIA map(0xa400, 0xa47f).m(m_riot, FUNC(mos6532_device::ram_map)); map(0xa480, 0xa497).m(m_riot, FUNC(mos6532_device::io_map)); map(0xa498, 0xa7ff).noprw(); // Not available - map(0xa800, 0xa80f).mirror(0x3f0).m(m_via0, FUNC(via6522_device::map)); // system via + map(0xa800, 0xa80f).mirror(0x3f0).m(m_via0, FUNC(via6522_device::map)); // system VIA map(0xac00, 0xac03).rw(m_pia, FUNC(pia6821_device::read), FUNC(pia6821_device::write)); map(0xac04, 0xac43).ram(); // PIA RAM map(0xac44, 0xafff).noprw(); // Not available diff --git a/src/mame/unico/goori.cpp b/src/mame/unico/goori.cpp index f051803b2c4..aa308d9a9f2 100644 --- a/src/mame/unico/goori.cpp +++ b/src/mame/unico/goori.cpp @@ -142,7 +142,7 @@ uint32_t goori_state::screen_update(screen_device& screen, bitmap_ind16& bitmap, m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - gfx_element *gfx = m_gfxdecode->gfx(0); + gfx_element &gfx = *m_gfxdecode->gfx(0); // is this sprite format a clone of anything? (looks VERY similar to snowbros but this hardware also has a higer resolution, a tile layer and 8bpp) for (int i = 0; i < 0x2000 / 2; i += 8) { @@ -169,7 +169,7 @@ uint32_t goori_state::screen_update(screen_device& screen, bitmap_ind16& bitmap, if (realx >= 0x3e0) realx -= 0x400; - gfx->transpen(bitmap, cliprect, tile, colour, flipx, 0, realx, y, 0xff); + gfx.transpen(bitmap, cliprect, tile, colour, flipx, 0, realx, y, 0xff); } return 0; -- cgit v1.2.3