Miscellaneous cleanup.

apple/maciivx.cpp, apple/maclc3.cpp: Fixed unnecessary absolute tags.

video/fixfreq.cpp: Make the code look more like the other MAME code:
* Indent initialiser lists by one level.
* Indent parameters by two levels when they need to be wrapped.
* Don't use const on parameters passed by value (not part of signature).
* Changed C-style casts to function-syntax casts (reduces parentheses).

Ran srcclean on capcom/lwings.cpp and video/fixfreq.cpp.
This commit is contained in:
Vas Crabb 2022-07-19 14:17:42 +10:00
parent 115d90e370
commit 30ae5dea73
5 changed files with 122 additions and 127 deletions

View File

@ -24,9 +24,9 @@
#include <iostream> #include <iostream>
// for quick and dirty debugging // for quick and dirty debugging
#define VERBOSE 0
#define LOG_GENERAL (1U << 0) #define LOG_GENERAL (1U << 0)
#define VERBOSE 0
#define LOG_OUTPUT_STREAM std::cerr #define LOG_OUTPUT_STREAM std::cerr
#include "logmacro.h" #include "logmacro.h"
@ -73,8 +73,7 @@ enum fixedfreq_tag_id_e
SCANLINE_HEIGHT SCANLINE_HEIGHT
}; };
void fixedfreq_monitor_state::update_sync_channel(const time_type &time, void fixedfreq_monitor_state::update_sync_channel(const time_type &time, double newval)
const double newval)
{ {
const time_type delta_time = time - m_last_sync_time; const time_type delta_time = time - m_last_sync_time;
@ -168,14 +167,13 @@ void fixedfreq_monitor_state::update_bm(const time_type &time)
m_last_x = pixels; m_last_x = pixels;
} }
void fixedfreq_monitor_state::update_composite_monochrome(const time_type &time, void fixedfreq_monitor_state::update_composite_monochrome(const time_type &time, double data)
const double data)
{ {
update_bm(time); update_bm(time);
update_sync_channel(time, data); update_sync_channel(time, data);
//#int colv = (int) ((data - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0); //#int colv = int((data - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0);
int colv = (int)((data - 1.5) * m_desc.m_gain * 255.0); int colv = int((data - 1.5) * m_desc.m_gain * 255.0);
if (colv > 255) if (colv > 255)
colv = 255; colv = 255;
if (colv < 0) if (colv < 0)
@ -185,12 +183,11 @@ void fixedfreq_monitor_state::update_composite_monochrome(const time_type &time,
m_col = 0xff000000 | (colv << 16) | (colv << 8) | colv; m_col = 0xff000000 | (colv << 16) | (colv << 8) | colv;
} }
void fixedfreq_monitor_state::update_red(const time_type &time, void fixedfreq_monitor_state::update_red(const time_type &time, double data)
const double data)
{ {
update_bm(time); update_bm(time);
int colv = (int)((data - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0); int colv = int((data - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0);
if (colv > 255) if (colv > 255)
colv = 255; colv = 255;
if (colv < 0) if (colv < 0)
@ -198,13 +195,12 @@ void fixedfreq_monitor_state::update_red(const time_type &time,
m_col = (m_col & 0xff00ffff) | (colv << 16); m_col = (m_col & 0xff00ffff) | (colv << 16);
} }
void fixedfreq_monitor_state::update_green(const time_type &time, void fixedfreq_monitor_state::update_green(const time_type &time, double data)
const double data)
{ {
update_bm(time); update_bm(time);
// update_sync_channel(ctime, data); // update_sync_channel(ctime, data);
int colv = (int)((data - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0); int colv = int((data - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0);
if (colv > 255) if (colv > 255)
colv = 255; colv = 255;
if (colv < 0) if (colv < 0)
@ -212,13 +208,12 @@ void fixedfreq_monitor_state::update_green(const time_type &time,
m_col = (m_col & 0xffff00ff) | (colv << 8); m_col = (m_col & 0xffff00ff) | (colv << 8);
} }
void fixedfreq_monitor_state::update_blue(const time_type &time, void fixedfreq_monitor_state::update_blue(const time_type &time, double data)
const double data)
{ {
update_bm(time); update_bm(time);
// update_sync_channel(ctime, data); // update_sync_channel(ctime, data);
int colv = (int)((data - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0); int colv = int((data - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0);
if (colv > 255) if (colv > 255)
colv = 255; colv = 255;
if (colv < 0) if (colv < 0)
@ -226,31 +221,35 @@ void fixedfreq_monitor_state::update_blue(const time_type &time,
m_col = (m_col & 0xffffff00) | colv; m_col = (m_col & 0xffffff00) | colv;
} }
void fixedfreq_monitor_state::update_sync(const time_type &time, void fixedfreq_monitor_state::update_sync(const time_type &time, double data)
const double data)
{ {
update_bm(time); update_bm(time);
update_sync_channel(time, data); update_sync_channel(time, data);
} }
fixedfreq_device::fixedfreq_device(const machine_config &mconfig, fixedfreq_device::fixedfreq_device(
device_type type, const char *tag, const machine_config &mconfig,
device_t *owner, uint32_t clock) device_type type,
: device_t(mconfig, type, tag, owner, clock) const char *tag,
, device_video_interface(mconfig, *this, false) device_t *owner,
, m_enable(*this, "ENABLE") uint32_t clock)
, m_vector(*this, "VECTOR") : device_t(mconfig, type, tag, owner, clock)
, m_scanline_height(1.0) , device_video_interface(mconfig, *this, false)
, m_last_rt(0.0) , m_enable(*this, "ENABLE")
, m_monitor() , m_vector(*this, "VECTOR")
, m_state(m_monitor, *this) , m_scanline_height(1.0)
, m_last_rt(0.0)
, m_monitor()
, m_state(m_monitor, *this)
{ {
} }
fixedfreq_device::fixedfreq_device(const machine_config &mconfig, fixedfreq_device::fixedfreq_device(
const char *tag, device_t *owner, const machine_config &mconfig,
const char *tag,
device_t *owner,
uint32_t clock) uint32_t clock)
: fixedfreq_device(mconfig, FIXFREQ, tag, owner, clock) : fixedfreq_device(mconfig, FIXFREQ, tag, owner, clock)
{ {
} }
@ -272,12 +271,14 @@ void fixedfreq_device::device_config_complete()
// It is therefore recommended to use `set_raw` in the mame driver // It is therefore recommended to use `set_raw` in the mame driver
// to specify the window size. // to specify the window size.
if (!screen().refresh_attoseconds()) if (!screen().refresh_attoseconds())
screen().set_raw(m_monitor.m_monitor_clock, m_monitor.htotal(), 0, {
screen().set_raw(
m_monitor.m_monitor_clock, m_monitor.htotal(), 0,
m_monitor.htotal(), m_monitor.vtotal(), 0, m_monitor.htotal(), m_monitor.vtotal(), 0,
m_monitor.vtotal()); m_monitor.vtotal());
}
if (!screen().has_screen_update()) if (!screen().has_screen_update())
screen().set_screen_update(*this, screen().set_screen_update(*this, FUNC(fixedfreq_device::screen_update));
FUNC(fixedfreq_device::screen_update));
LOG("config complete\n"); LOG("config complete\n");
} }
@ -336,20 +337,21 @@ void fixedfreq_device::device_post_load()
static uint32_t nom_col(uint32_t col) static uint32_t nom_col(uint32_t col)
{ {
float r = ((col >> 16) & 0xff); float const r = ((col >> 16) & 0xff);
float g = ((col >> 8) & 0xff); float const g = ((col >> 8) & 0xff);
float b = ((col >> 0) & 0xff); float const b = ((col >> 0) & 0xff);
float m = std::max(r, std::max(g, b)); float const m = std::max(r, std::max(g, b));
if (m == 0.0f) if (m == 0.0f)
return 0; return 0;
return (((uint32_t)m) << 24) | (((uint32_t)(r / m * 255.0f)) << 16) return
| (((uint32_t)(g / m * 255.0f)) << 8) (uint32_t(m) << 24) |
| (((uint32_t)(b / m * 255.0f)) << 0); (uint32_t(r / m * 255.0f) << 16) |
(uint32_t(g / m * 255.0f) << 8) |
(uint32_t(b / m * 255.0f) << 0);
} }
static void draw_testpat(screen_device &screen, bitmap_rgb32 &bitmap, static void draw_testpat(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
const rectangle &cliprect)
{ {
// Test pattern Grey scale // Test pattern Grey scale
const int stripes = 255; const int stripes = 255;
@ -361,8 +363,7 @@ static void draw_testpat(screen_device &screen, bitmap_rgb32 &bitmap,
int l = va.left() + (i * va.width() / stripes); int l = va.left() + (i * va.width() / stripes);
int w = (va.left() + (i + 1) * va.width() / stripes) - l; int w = (va.left() + (i + 1) * va.width() / stripes) - l;
int v = (255 * i) / stripes; int v = (255 * i) / stripes;
bitmap.plot_box(l, va.top() + 20, w, va.height() / 2 - 20, bitmap.plot_box(l, va.top() + 20, w, va.height() / 2 - 20, rgb_t(0xff, v, v, v));
rgb_t(0xff, v, v, v));
} }
int l(va.left() + va.width() / 4); int l(va.left() + va.width() / 4);
@ -379,9 +380,7 @@ static void draw_testpat(screen_device &screen, bitmap_rgb32 &bitmap,
bitmap.plot_box(l, t, w, h, rgb_t(0xff, 0xc3, 0xc3, 0xc3)); // 195 bitmap.plot_box(l, t, w, h, rgb_t(0xff, 0xc3, 0xc3, 0xc3)); // 195
} }
uint32_t uint32_t fixedfreq_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
fixedfreq_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap,
const rectangle &cliprect)
{ {
// printf("%f\n", machine().time().as_double()); // printf("%f\n", machine().time().as_double());
// printf("%d %lu %f %f\n", m_state.m_sig_vsync, m_state.m_fragments.size(), // printf("%d %lu %f %f\n", m_state.m_sig_vsync, m_state.m_fragments.size(),
@ -492,10 +491,10 @@ void fixedfreq_device::vsync_end_cb(double refresh_time, uint32_t field)
// reset_origin must be called first. // reset_origin must be called first.
screen().reset_origin( screen().reset_origin(
m_state.m_last_y m_state.m_last_y - (m_monitor.vsync_width() + m_monitor.vbackporch_width()),
- (m_monitor.vsync_width() + m_monitor.vbackporch_width()),
0); 0);
screen().configure(m_monitor.htotal_scaled(), m_monitor.vtotal(), visarea, screen().configure(
m_monitor.htotal_scaled(), m_monitor.vtotal(), visarea,
DOUBLE_TO_ATTOSECONDS(refresh_limited)); DOUBLE_TO_ATTOSECONDS(refresh_limited));
} }

View File

@ -27,8 +27,8 @@ struct fixedfreq_monitor_desc
, m_gain(1.0 / 3.7) , m_gain(1.0 / 3.7)
, m_hscale(1) , m_hscale(1)
, m_vsync_threshold(0.600) , m_vsync_threshold(0.600)
, // trigger at 91% of vsync length 1-exp(-0.6) // trigger at 91% of vsync length 1-exp(-0.6)
m_hvisible(704) , m_hvisible(704)
, m_hfrontporch(728) , m_hfrontporch(728)
, m_hsync(791) , m_hsync(791)
, m_hbackporch(858) , m_hbackporch(858)
@ -94,13 +94,13 @@ struct fixedfreq_monitor_desc
double vsync_filter_timeconst() const noexcept double vsync_filter_timeconst() const noexcept
{ {
return (double)(m_monitor_clock) return double(m_monitor_clock)
/ ((double)m_hbackporch * vsync_width()); / (double(m_hbackporch) * vsync_width());
} }
double hsync_filter_timeconst() const noexcept double hsync_filter_timeconst() const noexcept
{ {
return (double)m_monitor_clock / (double)hsync_width(); return double(m_monitor_clock) / double(hsync_width());
} }
uint32_t m_monitor_clock; uint32_t m_monitor_clock;
@ -139,8 +139,7 @@ struct fixedfreq_monitor_state
{ {
using time_type = double; using time_type = double;
fixedfreq_monitor_state(fixedfreq_monitor_desc &desc, fixedfreq_monitor_state(fixedfreq_monitor_desc &desc, fixedfreq_monitor_intf &intf)
fixedfreq_monitor_intf &intf)
: m_desc(desc) : m_desc(desc)
, m_intf(intf) , m_intf(intf)
, m_last_sync_val(0) , m_last_sync_val(0)
@ -213,14 +212,13 @@ struct fixedfreq_monitor_state
m_fragments.clear(); m_fragments.clear();
} }
void update_sync_channel(const time_type &time, const double newval); void update_sync_channel(const time_type &time, double newval);
void update_bm(const time_type &time); void update_bm(const time_type &time);
void void update_composite_monochrome(const time_type &time, double newval);
update_composite_monochrome(const time_type &time, const double newval); void update_red(const time_type &time, double data);
void update_red(const time_type &time, const double data); void update_green(const time_type &time, double data);
void update_green(const time_type &time, const double data); void update_blue(const time_type &time, double data);
void update_blue(const time_type &time, const double data); void update_sync(const time_type &time, double data);
void update_sync(const time_type &time, const double data);
const fixedfreq_monitor_desc &m_desc; const fixedfreq_monitor_desc &m_desc;
fixedfreq_monitor_intf &m_intf; fixedfreq_monitor_intf &m_intf;
@ -257,8 +255,7 @@ public:
using time_type = fixedfreq_monitor_state::time_type; using time_type = fixedfreq_monitor_state::time_type;
// construction/destruction // construction/destruction
fixedfreq_device(const machine_config &mconfig, const char *tag, fixedfreq_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
device_t *owner, uint32_t clock = 0);
// inline configuration helpers // inline configuration helpers
fixedfreq_device &set_monitor_clock(uint32_t clock) fixedfreq_device &set_monitor_clock(uint32_t clock)
@ -286,18 +283,14 @@ public:
m_monitor.m_gain = gain; m_monitor.m_gain = gain;
return *this; return *this;
} }
fixedfreq_device & fixedfreq_device &set_horz_params(int visible, int frontporch, int sync, int backporch)
set_horz_params(int visible, int frontporch, int sync, int backporch)
{ {
m_monitor.set_h_rel(visible, frontporch - visible, sync - frontporch, m_monitor.set_h_rel(visible, frontporch - visible, sync - frontporch, backporch - sync);
backporch - sync);
return *this; return *this;
} }
fixedfreq_device & fixedfreq_device &set_vert_params(int visible, int frontporch, int sync, int backporch)
set_vert_params(int visible, int frontporch, int sync, int backporch)
{ {
m_monitor.set_v_rel(visible, frontporch - visible, sync - frontporch, m_monitor.set_v_rel(visible, frontporch - visible, sync - frontporch, backporch - sync);
backporch - sync);
return *this; return *this;
} }
fixedfreq_device &set_horz_scale(int hscale) fixedfreq_device &set_horz_scale(int hscale)
@ -329,8 +322,7 @@ public:
return *this; return *this;
} }
virtual uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, virtual uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
const rectangle &cliprect);
NETDEV_ANALOG_CALLBACK_MEMBER(update_composite_monochrome); NETDEV_ANALOG_CALLBACK_MEMBER(update_composite_monochrome);
NETDEV_ANALOG_CALLBACK_MEMBER(update_red); NETDEV_ANALOG_CALLBACK_MEMBER(update_red);
@ -343,8 +335,12 @@ public:
unsigned monitor_val(unsigned param) const; unsigned monitor_val(unsigned param) const;
protected: protected:
fixedfreq_device(const machine_config &mconfig, device_type type, fixedfreq_device(
const char *tag, device_t *owner, uint32_t clock); const machine_config &mconfig,
device_type type,
const char *tag,
device_t *owner,
uint32_t clock);
// device-level overrides // device-level overrides
virtual void device_config_complete() override; virtual void device_config_complete() override;

View File

@ -332,7 +332,7 @@ void maciivx_state::maciiv_base(machine_config &config)
VASP(config, m_vasp, C15M); VASP(config, m_vasp, C15M);
m_vasp->set_maincpu_tag("maincpu"); m_vasp->set_maincpu_tag("maincpu");
m_vasp->set_rom_tag(":bootrom"); m_vasp->set_rom_tag("bootrom");
m_vasp->hdsel_callback().set(FUNC(maciivx_state::hdsel_w)); m_vasp->hdsel_callback().set(FUNC(maciivx_state::hdsel_w));
MACADB(config, m_macadb, C15M); MACADB(config, m_macadb, C15M);

View File

@ -261,7 +261,7 @@ void macvail_state::maclc3_base(machine_config &config)
SONORA(config, m_sonora, C15M); SONORA(config, m_sonora, C15M);
m_sonora->set_maincpu_tag("maincpu"); m_sonora->set_maincpu_tag("maincpu");
m_sonora->set_rom_tag(":bootrom"); m_sonora->set_rom_tag("bootrom");
MACADB(config, m_macadb, C15M); MACADB(config, m_macadb, C15M);
m_macadb->set_mcu_mode(true); m_macadb->set_mcu_mode(true);