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>
// for quick and dirty debugging
#define VERBOSE 0
#define LOG_GENERAL (1U << 0)
#define VERBOSE 0
#define LOG_OUTPUT_STREAM std::cerr
#include "logmacro.h"
@ -73,8 +73,7 @@ enum fixedfreq_tag_id_e
SCANLINE_HEIGHT
};
void fixedfreq_monitor_state::update_sync_channel(const time_type &time,
const double newval)
void fixedfreq_monitor_state::update_sync_channel(const time_type &time, double newval)
{
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;
}
void fixedfreq_monitor_state::update_composite_monochrome(const time_type &time,
const double data)
void fixedfreq_monitor_state::update_composite_monochrome(const time_type &time, double data)
{
update_bm(time);
update_sync_channel(time, data);
//#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 - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0);
int colv = int((data - 1.5) * m_desc.m_gain * 255.0);
if (colv > 255)
colv = 255;
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;
}
void fixedfreq_monitor_state::update_red(const time_type &time,
const double data)
void fixedfreq_monitor_state::update_red(const time_type &time, double data)
{
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)
colv = 255;
if (colv < 0)
@ -198,13 +195,12 @@ void fixedfreq_monitor_state::update_red(const time_type &time,
m_col = (m_col & 0xff00ffff) | (colv << 16);
}
void fixedfreq_monitor_state::update_green(const time_type &time,
const double data)
void fixedfreq_monitor_state::update_green(const time_type &time, double data)
{
update_bm(time);
// 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)
colv = 255;
if (colv < 0)
@ -212,13 +208,12 @@ void fixedfreq_monitor_state::update_green(const time_type &time,
m_col = (m_col & 0xffff00ff) | (colv << 8);
}
void fixedfreq_monitor_state::update_blue(const time_type &time,
const double data)
void fixedfreq_monitor_state::update_blue(const time_type &time, double data)
{
update_bm(time);
// 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)
colv = 255;
if (colv < 0)
@ -226,16 +221,18 @@ void fixedfreq_monitor_state::update_blue(const time_type &time,
m_col = (m_col & 0xffffff00) | colv;
}
void fixedfreq_monitor_state::update_sync(const time_type &time,
const double data)
void fixedfreq_monitor_state::update_sync(const time_type &time, double data)
{
update_bm(time);
update_sync_channel(time, data);
}
fixedfreq_device::fixedfreq_device(const machine_config &mconfig,
device_type type, const char *tag,
device_t *owner, uint32_t clock)
fixedfreq_device::fixedfreq_device(
const machine_config &mconfig,
device_type type,
const char *tag,
device_t *owner,
uint32_t clock)
: device_t(mconfig, type, tag, owner, clock)
, device_video_interface(mconfig, *this, false)
, m_enable(*this, "ENABLE")
@ -247,8 +244,10 @@ fixedfreq_device::fixedfreq_device(const machine_config &mconfig,
{
}
fixedfreq_device::fixedfreq_device(const machine_config &mconfig,
const char *tag, device_t *owner,
fixedfreq_device::fixedfreq_device(
const machine_config &mconfig,
const char *tag,
device_t *owner,
uint32_t 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
// to specify the window size.
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.vtotal());
}
if (!screen().has_screen_update())
screen().set_screen_update(*this,
FUNC(fixedfreq_device::screen_update));
screen().set_screen_update(*this, FUNC(fixedfreq_device::screen_update));
LOG("config complete\n");
}
@ -336,20 +337,21 @@ void fixedfreq_device::device_post_load()
static uint32_t nom_col(uint32_t col)
{
float r = ((col >> 16) & 0xff);
float g = ((col >> 8) & 0xff);
float b = ((col >> 0) & 0xff);
float const r = ((col >> 16) & 0xff);
float const g = ((col >> 8) & 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)
return 0;
return (((uint32_t)m) << 24) | (((uint32_t)(r / m * 255.0f)) << 16)
| (((uint32_t)(g / m * 255.0f)) << 8)
| (((uint32_t)(b / m * 255.0f)) << 0);
return
(uint32_t(m) << 24) |
(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,
const rectangle &cliprect)
static void draw_testpat(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
// Test pattern Grey scale
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 w = (va.left() + (i + 1) * va.width() / stripes) - l;
int v = (255 * i) / stripes;
bitmap.plot_box(l, va.top() + 20, w, va.height() / 2 - 20,
rgb_t(0xff, v, v, v));
bitmap.plot_box(l, va.top() + 20, w, va.height() / 2 - 20, rgb_t(0xff, v, v, v));
}
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
}
uint32_t
fixedfreq_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap,
const rectangle &cliprect)
uint32_t fixedfreq_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
// printf("%f\n", machine().time().as_double());
// 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.
screen().reset_origin(
m_state.m_last_y
- (m_monitor.vsync_width() + m_monitor.vbackporch_width()),
m_state.m_last_y - (m_monitor.vsync_width() + m_monitor.vbackporch_width()),
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));
}

View File

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

View File

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