summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-04-06 03:37:22 +1000
committer Vas Crabb <vas@vastheman.com>2020-04-06 03:37:22 +1000
commitebbb2b39cb1f44ab3ff1656ab6ddef9029237687 (patch)
treebb34c8e5e9458efbb840e343b74921455777d56e
parentbce322107551daf8c069957df66689ba2d611aa4 (diff)
(nw) random cleanup:
* xavix2.cpp: better to be exception safe with allocations * williams.cpp: group the numbers in eights so it's easier to visually find a particular index, and restore the styling of the file (two blank lines between functions, three blank lines between sections)
-rw-r--r--src/mame/drivers/xavix2.cpp5
-rw-r--r--src/mame/includes/williams.h9
-rw-r--r--src/mame/video/williams.cpp325
3 files changed, 65 insertions, 274 deletions
diff --git a/src/mame/drivers/xavix2.cpp b/src/mame/drivers/xavix2.cpp
index 7d17e36658f..bb0f3d638df 100644
--- a/src/mame/drivers/xavix2.cpp
+++ b/src/mame/drivers/xavix2.cpp
@@ -313,12 +313,12 @@ void xavix2_state::gpu1_trigger_w(u8 data)
void xavix2_state::gpu_update(u16 count, u16 adr)
{
- int *list = new int[count];
+ std::unique_ptr<int []> list(new int[count]);
for(u32 i=0; i != count; i++) {
u64 command = m_maincpu->space(AS_PROGRAM).read_qword(adr + 8*i);
list[i] = (command & 0x1fe00000) | i;
}
- std::sort(list, list + count, std::greater<int>());
+ std::sort(list.get(), list.get() + count, std::greater<int>());
for(u32 i=0; i != count; i++) {
u64 command = m_maincpu->space(AS_PROGRAM).read_qword(adr + 8*(list[i] & 0xffff));
logerror("gpu %02d: %016x x=%03x y=%03x ?=%02x ?=%x s=%02x w=%02x h=%02x c=%04x %s\n",
@@ -370,7 +370,6 @@ void xavix2_state::gpu_update(u16 count, u16 adr)
}
}
}
- delete[] list;
}
void xavix2_state::gpu_descsize_w(u16 data)
diff --git a/src/mame/includes/williams.h b/src/mame/includes/williams.h
index 22948219698..696d10c55f2 100644
--- a/src/mame/includes/williams.h
+++ b/src/mame/includes/williams.h
@@ -315,17 +315,18 @@ public:
m_bank8000(*this, "bank8000"),
m_gfxdecode(*this, "gfxdecode"),
m_tileram(*this, "williams2_tile"),
- m_gain({0.8f, 0.73f, 0.81f}),
- m_offset({-0.27f, 0.0f, -0.22f})
+ m_gain({ 0.8f, 0.73f, 0.81f }),
+ m_offset({ -0.27f, 0.0f, -0.22f })
{ }
void williams2_base(machine_config &config);
+
INPUT_CHANGED_MEMBER(rgb_gain)
{
if (param < 3)
- m_gain[param] = (float) newval / 100.0f;
+ m_gain[param] = float(newval) / 100.0f;
else
- m_offset[param-3] = (float) newval / 100.0f - 1.0f;
+ m_offset[param - 3] = (float(newval) / 100.0f) - 1.0f;
rebuild_palette();
}
diff --git a/src/mame/video/williams.cpp b/src/mame/video/williams.cpp
index f6658a6391b..c846df713f1 100644
--- a/src/mame/video/williams.cpp
+++ b/src/mame/video/williams.cpp
@@ -273,6 +273,7 @@ uint32_t blaster_state::screen_update(screen_device &screen, bitmap_rgb32 &bitma
return 0;
}
+
uint32_t williams2_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
rgb_t pens[16];
@@ -304,6 +305,7 @@ uint32_t williams2_state::screen_update(screen_device &screen, bitmap_rgb32 &bit
return 0;
}
+
uint32_t mysticm_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
rgb_t pens[16];
@@ -337,6 +339,8 @@ uint32_t mysticm_state::screen_update(screen_device &screen, bitmap_rgb32 &bitma
return 0;
}
+
+
/*************************************
*
* Williams palette I/O
@@ -368,6 +372,7 @@ void williams_state::palette_init(palette_device &palette) const
}
}
+
rgb_t williams2_state::calc_col(uint16_t lo, uint16_t hi)
{
/*
@@ -390,289 +395,69 @@ rgb_t williams2_state::calc_col(uint16_t lo, uint16_t hi)
static const float frgb[256] =
{
- 0.001889f,
- 0.002456f,
- 0.003196f,
- 0.004384f,
- 0.005272f,
- 0.007672f,
- 0.011345f,
- 0.017759f,
- 0.018643f,
- 0.03103f,
- 0.051912f,
- 0.087251f,
- 0.1256f,
- 0.204967f,
- 0.331644f,
- 0.529628f,
- 0.002524f,
- 0.003306f,
- 0.004371f,
- 0.006072f,
- 0.007386f,
- 0.010812f,
- 0.016096f,
- 0.02509f,
- 0.02687f,
- 0.043747f,
- 0.070899f,
- 0.114042f,
- 0.159992f,
- 0.250108f,
- 0.391104f,
- 0.607433f,
- 0.003522f,
- 0.004666f,
- 0.006254f,
- 0.008766f,
- 0.010795f,
- 0.015856f,
- 0.023585f,
- 0.036228f,
- 0.039487f,
- 0.062206f,
- 0.096916f,
- 0.148811f,
- 0.20338f,
- 0.305447f,
- 0.462741f,
- 0.700199f,
- 0.004941f,
- 0.006607f,
- 0.00895f,
- 0.012619f,
- 0.015683f,
- 0.022944f,
- 0.033832f,
- 0.050765f,
- 0.056018f,
- 0.085033f,
- 0.127452f,
- 0.187886f,
- 0.25112f,
- 0.364998f,
- 0.53879f,
- 0.797876f,
- 0.006857f,
- 0.009233f,
- 0.012592f,
- 0.017771f,
- 0.022172f,
- 0.03212f,
- 0.046615f,
- 0.06811f,
- 0.075696f,
- 0.110906f,
- 0.160678f,
- 0.229149f,
- 0.300735f,
- 0.42593f,
- 0.61584f,
- 0.896241f,
- 0.010113f,
- 0.01368f,
- 0.018726f,
- 0.02625f,
- 0.032735f,
- 0.046462f,
- 0.065809f,
- 0.092996f,
- 0.103803f,
- 0.146292f,
- 0.204648f,
- 0.282479f,
- 0.364084f,
- 0.502781f,
- 0.712244f,
- 1.018759f,
- 0.015744f,
- 0.021251f,
- 0.028944f,
- 0.039945f,
- 0.049446f,
- 0.068127f,
- 0.093445f,
- 0.127285f,
- 0.14231f,
- 0.193004f,
- 0.261153f,
- 0.349656f,
- 0.443068f,
- 0.597642f,
- 0.830444f,
- 1.168267f,
- 0.024223f,
- 0.032378f,
- 0.043467f,
- 0.058612f,
- 0.071646f,
- 0.09563f,
- 0.127147f,
- 0.167588f,
- 0.187237f,
- 0.246001f,
- 0.32398f,
- 0.423282f,
- 0.528958f,
- 0.699986f,
- 0.957283f,
- 1.328146f,
- 0.03429f,
- 0.045182f,
- 0.059626f,
- 0.078588f,
- 0.094882f,
- 0.123449f,
- 0.160233f,
- 0.206173f,
- 0.230031f,
- 0.295596f,
- 0.382005f,
- 0.490617f,
- 0.607092f,
- 0.792615f,
- 1.071663f,
- 1.471949f,
- 0.053106f,
- 0.068185f,
- 0.087712f,
- 0.112105f,
- 0.132967f,
- 0.167685f,
- 0.211656f,
- 0.265082f,
- 0.295044f,
- 0.369837f,
- 0.467993f,
- 0.58972f,
- 0.721623f,
- 0.927771f,
- 1.23799f,
- 1.680648f,
- 0.083576f,
- 0.103924f,
- 0.129726f,
- 0.160516f,
- 0.186838f,
- 0.228722f,
- 0.281144f,
- 0.343382f,
- 0.381103f,
- 0.46708f,
- 0.5795f,
- 0.717377f,
- 0.86859f,
- 1.100548f,
- 1.449999f,
- 1.946101f,
- 0.124032f,
- 0.149904f,
- 0.182177f,
- 0.219335f,
- 0.251408f,
- 0.300484f,
- 0.361692f,
- 0.433113f,
- 0.479348f,
- 0.577076f,
- 0.704911f,
- 0.860274f,
- 1.032601f,
- 1.292736f,
- 1.685276f,
- 2.240223f,
- 0.175706f,
- 0.207011f,
- 0.245689f,
- 0.289706f,
- 0.327912f,
- 0.384501f,
- 0.455038f,
- 0.536297f,
- 0.592068f,
- 0.702442f,
- 0.847309f,
- 1.021943f,
- 1.217772f,
- 1.509243f,
- 1.949852f,
- 2.570528f,
- 0.24927f,
- 0.287025f,
- 0.333877f,
- 0.385984f,
- 0.431717f,
- 0.497443f,
- 0.579727f,
- 0.673464f,
- 0.741572f,
- 0.868017f,
- 1.034559f,
- 1.234123f,
- 1.460333f,
- 1.79207f,
- 2.295118f,
- 3.001228f,
- 0.357357f,
- 0.403448f,
- 0.460931f,
- 0.52375f,
- 0.579557f,
- 0.656404f,
- 0.754715f,
- 0.865436f,
- 0.950203f,
- 1.097887f,
- 1.293872f,
- 1.527752f,
- 1.795589f,
- 2.182008f,
- 2.770169f,
- 3.593798f,
- 0.494255f,
- 0.549094f,
- 0.61884f,
- 0.693823f,
- 0.760527f,
- 0.851544f,
- 0.968276f,
- 1.098965f,
- 1.203912f,
- 1.377026f,
- 1.608183f,
- 1.882244f,
- 2.200036f,
- 2.652345f,
- 3.342626f,
- 4.215708f,
+ 0.001889f, 0.002456f, 0.003196f, 0.004384f, 0.005272f, 0.007672f, 0.011345f, 0.017759f,
+ 0.018643f, 0.03103f, 0.051912f, 0.087251f, 0.1256f, 0.204967f, 0.331644f, 0.529628f,
+ 0.002524f, 0.003306f, 0.004371f, 0.006072f, 0.007386f, 0.010812f, 0.016096f, 0.02509f,
+ 0.02687f, 0.043747f, 0.070899f, 0.114042f, 0.159992f, 0.250108f, 0.391104f, 0.607433f,
+ 0.003522f, 0.004666f, 0.006254f, 0.008766f, 0.010795f, 0.015856f, 0.023585f, 0.036228f,
+ 0.039487f, 0.062206f, 0.096916f, 0.148811f, 0.20338f, 0.305447f, 0.462741f, 0.700199f,
+ 0.004941f, 0.006607f, 0.00895f, 0.012619f, 0.015683f, 0.022944f, 0.033832f, 0.050765f,
+ 0.056018f, 0.085033f, 0.127452f, 0.187886f, 0.25112f, 0.364998f, 0.53879f, 0.797876f,
+
+ 0.006857f, 0.009233f, 0.012592f, 0.017771f, 0.022172f, 0.03212f, 0.046615f, 0.06811f,
+ 0.075696f, 0.110906f, 0.160678f, 0.229149f, 0.300735f, 0.42593f, 0.61584f, 0.896241f,
+ 0.010113f, 0.01368f, 0.018726f, 0.02625f, 0.032735f, 0.046462f, 0.065809f, 0.092996f,
+ 0.103803f, 0.146292f, 0.204648f, 0.282479f, 0.364084f, 0.502781f, 0.712244f, 1.018759f,
+ 0.015744f, 0.021251f, 0.028944f, 0.039945f, 0.049446f, 0.068127f, 0.093445f, 0.127285f,
+ 0.14231f, 0.193004f, 0.261153f, 0.349656f, 0.443068f, 0.597642f, 0.830444f, 1.168267f,
+ 0.024223f, 0.032378f, 0.043467f, 0.058612f, 0.071646f, 0.09563f, 0.127147f, 0.167588f,
+ 0.187237f, 0.246001f, 0.32398f, 0.423282f, 0.528958f, 0.699986f, 0.957283f, 1.328146f,
+
+ 0.03429f, 0.045182f, 0.059626f, 0.078588f, 0.094882f, 0.123449f, 0.160233f, 0.206173f,
+ 0.230031f, 0.295596f, 0.382005f, 0.490617f, 0.607092f, 0.792615f, 1.071663f, 1.471949f,
+ 0.053106f, 0.068185f, 0.087712f, 0.112105f, 0.132967f, 0.167685f, 0.211656f, 0.265082f,
+ 0.295044f, 0.369837f, 0.467993f, 0.58972f, 0.721623f, 0.927771f, 1.23799f, 1.680648f,
+ 0.083576f, 0.103924f, 0.129726f, 0.160516f, 0.186838f, 0.228722f, 0.281144f, 0.343382f,
+ 0.381103f, 0.46708f, 0.5795f, 0.717377f, 0.86859f, 1.100548f, 1.449999f, 1.946101f,
+ 0.124032f, 0.149904f, 0.182177f, 0.219335f, 0.251408f, 0.300484f, 0.361692f, 0.433113f,
+ 0.479348f, 0.577076f, 0.704911f, 0.860274f, 1.032601f, 1.292736f, 1.685276f, 2.240223f,
+
+ 0.175706f, 0.207011f, 0.245689f, 0.289706f, 0.327912f, 0.384501f, 0.455038f, 0.536297f,
+ 0.592068f, 0.702442f, 0.847309f, 1.021943f, 1.217772f, 1.509243f, 1.949852f, 2.570528f,
+ 0.24927f, 0.287025f, 0.333877f, 0.385984f, 0.431717f, 0.497443f, 0.579727f, 0.673464f,
+ 0.741572f, 0.868017f, 1.034559f, 1.234123f, 1.460333f, 1.79207f, 2.295118f, 3.001228f,
+ 0.357357f, 0.403448f, 0.460931f, 0.52375f, 0.579557f, 0.656404f, 0.754715f, 0.865436f,
+ 0.950203f, 1.097887f, 1.293872f, 1.527752f, 1.795589f, 2.182008f, 2.770169f, 3.593798f,
+ 0.494255f, 0.549094f, 0.61884f, 0.693823f, 0.760527f, 0.851544f, 0.968276f, 1.098965f,
+ 1.203912f, 1.377026f, 1.608183f, 1.882244f, 2.200036f, 2.652345f, 3.342626f, 4.215708f
};
- uint16_t i, ur, ug, ub;
- float r, g, b;
- /* update the palette entry */
+ // update the palette entry
- i = (hi >> 4) & 15;
- ub = (hi >> 0) & 15;
- ug = (lo >> 4) & 15;
- ur = (lo >> 0) & 15;
+ const uint16_t i = (hi >> 4) & 15;
+ const uint16_t ub = (hi >> 0) & 15;
+ const uint16_t ug = (lo >> 4) & 15;
+ const uint16_t ur = (lo >> 0) & 15;
// normalize
- r = frgb[i * 16 + ur] / 4.22f;
- g = frgb[i * 16 + ug] / 4.22f;
- b = frgb[i * 16 + ub] / 4.22f;
+ float r = frgb[i * 16 + ur] / 4.22f;
+ float g = frgb[i * 16 + ug] / 4.22f;
+ float b = frgb[i * 16 + ub] / 4.22f;
+
// cut off
r = std::max(r + m_offset[0], 0.0f);
g = std::max(g + m_offset[1], 0.0f);
b = std::max(b + m_offset[2], 0.0f);
+
// drive
r = std::min(r * m_gain[0] / 0.25f, 1.0f);
g = std::min(g * m_gain[1] / 0.25f, 1.0f);
b = std::min(b * m_gain[2] / 0.25f, 1.0f);
- return rgb_t((int) (r * 255), (int) (g * 255), (int) (b * 255));
+ return rgb_t(int(r * 255), int(g * 255), int(b * 255));
}
+
void williams2_state::paletteram_w(offs_t offset, u8 data)
{
uint16_t entry_lo, entry_hi;
@@ -689,12 +474,14 @@ void williams2_state::paletteram_w(offs_t offset, u8 data)
m_palette->set_pen_color(offset / 2, calc_col(entry_lo, entry_hi));
}
+
void williams2_state::rebuild_palette()
{
for (offs_t i=0; i<2048; i++)
paletteram_w(i, m_paletteram[i]);
}
+
void williams2_state::fg_select_w(u8 data)
{
m_fg_color = data & 0x3f;
@@ -716,12 +503,14 @@ u8 williams_state::video_counter_r()
return 0xfc;
}
+
u8 williams2_state::video_counter_r()
{
return m_screen->vpos() & 0xff;
}
+
/*************************************
*
* Tilemap handling
@@ -740,6 +529,7 @@ TILE_GET_INFO_MEMBER(williams2_state::get_tile_info)
tileinfo.set(0, data & mask, color, (data & ~mask) ? TILE_FLIPX : 0);
}
+
int mysticm_state::color_decode(uint8_t base_col, int sig_J1, int y)
{
int v = y << 6;
@@ -775,6 +565,7 @@ int mysticm_state::color_decode(uint8_t base_col, int sig_J1, int y)
return (base_col & 0x3e) | color;
}
+
TILE_GET_INFO_MEMBER(mysticm_state::get_tile_info)
{
int color = color_decode(m_bg_color, 0, (tile_index << 4) & 0xff);