summaryrefslogtreecommitdiffstats
path: root/src/emu/screen.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2016-11-19 05:35:54 +1100
committer Vas Crabb <vas@vastheman.com>2016-11-19 05:38:48 +1100
commit8179a84458204a5e767446fcf7d10f032a40fd0c (patch)
tree16105e1667f811dcb24dbf0fc255166cb06df5c2 /src/emu/screen.cpp
parent1b489fe83034072149fb0637b20c7ba57dc72a7a (diff)
Introduce u8/u16/u32/u64/s8/s16/s32/s64
* New abbreviated types are in osd and util namespaces, and also in global namespace for things that #include "emu.h" * Get rid of import of cstdint types to global namespace (C99 does this anyway) * Remove the cstdint types from everything in emu * Get rid of U64/S64 macros * Fix a bug in dps16 caused by incorrect use of macro * Fix debugcon not checking for "do " prefix case-insensitively * Fix a lot of messed up tabulation * More constexpr * Fix up many __names
Diffstat (limited to 'src/emu/screen.cpp')
-rw-r--r--src/emu/screen.cpp118
1 files changed, 59 insertions, 59 deletions
diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp
index 4742963d9d3..f204b9c034e 100644
--- a/src/emu/screen.cpp
+++ b/src/emu/screen.cpp
@@ -35,7 +35,7 @@ const device_type SCREEN = &device_creator<screen_device>;
const attotime screen_device::DEFAULT_FRAME_PERIOD(attotime::from_hz(DEFAULT_FRAME_RATE));
-uint32_t screen_device::m_id_counter = 0;
+u32 screen_device::m_id_counter = 0;
class screen_device_svg_renderer {
public:
@@ -47,7 +47,7 @@ public:
int render(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
- static void output_notifier(const char *outname, int32_t value, void *param);
+ static void output_notifier(const char *outname, s32 value, void *param);
private:
struct paired_entry {
@@ -58,7 +58,7 @@ private:
struct cached_bitmap {
int x, y, sx, sy;
- std::vector<uint32_t> image;
+ std::vector<u32> image;
std::vector<paired_entry> pairs;
};
@@ -75,16 +75,16 @@ private:
int m_sx, m_sy;
double m_scale;
- std::vector<uint32_t> m_background;
+ std::vector<u32> m_background;
std::vector<cached_bitmap> m_cache;
- void output_change(const char *outname, int32_t value);
- void render_state(std::vector<uint32_t> &dest, const std::vector<bool> &state);
+ void output_change(const char *outname, s32 value);
+ void render_state(std::vector<u32> &dest, const std::vector<bool> &state);
void compute_initial_bboxes(std::vector<bbox> &bboxes);
bool compute_mask_intersection_bbox(int key1, int key2, bbox &bb) const;
- void compute_diff_image(const std::vector<uint32_t> &rend, const bbox &bb, cached_bitmap &dest) const;
- void compute_dual_diff_image(const std::vector<uint32_t> &rend, const bbox &bb, const cached_bitmap &src1, const cached_bitmap &src2, cached_bitmap &dest) const;
+ void compute_diff_image(const std::vector<u32> &rend, const bbox &bb, cached_bitmap &dest) const;
+ void compute_dual_diff_image(const std::vector<u32> &rend, const bbox &bb, const cached_bitmap &src1, const cached_bitmap &src2, cached_bitmap &dest) const;
void rebuild_cache();
void blit(bitmap_rgb32 &bitmap, const cached_bitmap &src) const;
};
@@ -153,7 +153,7 @@ int screen_device_svg_renderer::height() const
return int(m_image->height + 0.5);
}
-void screen_device_svg_renderer::render_state(std::vector<uint32_t> &dest, const std::vector<bool> &state)
+void screen_device_svg_renderer::render_state(std::vector<u32> &dest, const std::vector<bool> &state)
{
for(int key = 0; key != m_key_count; key++) {
if (state[key])
@@ -170,30 +170,30 @@ void screen_device_svg_renderer::render_state(std::vector<uint32_t> &dest, const
// alpha to "blend" against a black background. Plus align the
// channel order to what we do.
- uint8_t *image = (uint8_t *)&dest[0];
+ u8 *image = (u8 *)&dest[0];
for(unsigned int pixel=0; pixel != m_sy*m_sx; pixel++) {
- uint8_t r = image[0];
- uint8_t g = image[1];
- uint8_t b = image[2];
- uint8_t a = image[3];
+ u8 r = image[0];
+ u8 g = image[1];
+ u8 b = image[2];
+ u8 a = image[3];
if(a != 0xff) {
r = r*a/255;
g = g*a/255;
b = b*a/255;
}
- uint32_t color = 0xff000000 | (r << 16) | (g << 8) | (b << 0);
- *(uint32_t *)image = color;
+ u32 color = 0xff000000 | (r << 16) | (g << 8) | (b << 0);
+ *(u32 *)image = color;
image += 4;
}
}
void screen_device_svg_renderer::blit(bitmap_rgb32 &bitmap, const cached_bitmap &src) const
{
- const uint32_t *s = &src.image[0];
+ const u32 *s = &src.image[0];
for(int y=0; y<src.sy; y++) {
- uint32_t *d = &bitmap.pix(y + src.y, src.x);
+ u32 *d = &bitmap.pix(y + src.y, src.x);
for(int x=0; x<src.sx; x++) {
- uint32_t c = *s++;
+ u32 c = *s++;
if(c)
*d = c;
d++;
@@ -236,12 +236,12 @@ int screen_device_svg_renderer::render(screen_device &screen, bitmap_rgb32 &bitm
return 0;
}
-void screen_device_svg_renderer::output_notifier(const char *outname, int32_t value, void *param)
+void screen_device_svg_renderer::output_notifier(const char *outname, s32 value, void *param)
{
static_cast<screen_device_svg_renderer *>(param)->output_change(outname, value);
}
-void screen_device_svg_renderer::output_change(const char *outname, int32_t value)
+void screen_device_svg_renderer::output_change(const char *outname, s32 value)
{
auto l = m_key_ids.find(outname);
if (l == m_key_ids.end())
@@ -300,13 +300,13 @@ void screen_device_svg_renderer::compute_initial_bboxes(std::vector<bbox> &bboxe
}
}
-void screen_device_svg_renderer::compute_diff_image(const std::vector<uint32_t> &rend, const bbox &bb, cached_bitmap &dest) const
+void screen_device_svg_renderer::compute_diff_image(const std::vector<u32> &rend, const bbox &bb, cached_bitmap &dest) const
{
int x0, y0, x1, y1;
x0 = y0 = x1 = y1 = -1;
for(int y = bb.y0; y != bb.y1; y++) {
- const uint32_t *src1 = &m_background[bb.x0 + y * m_sx];
- const uint32_t *src2 = &rend[bb.x0 + y * m_sx];
+ const u32 *src1 = &m_background[bb.x0 + y * m_sx];
+ const u32 *src2 = &rend[bb.x0 + y * m_sx];
for(int x = bb.x0; x != bb.x1; x++) {
if(*src1 != *src2) {
if(x0 == -1) {
@@ -337,10 +337,10 @@ void screen_device_svg_renderer::compute_diff_image(const std::vector<uint32_t>
dest.sx = x1+1-x0;
dest.sy = y1+1-y0;
dest.image.resize(dest.sx * dest.sy);
- uint32_t *dst = &dest.image[0];
+ u32 *dst = &dest.image[0];
for(int y = 0; y != dest.sy; y++) {
- const uint32_t *src1 = &m_background[dest.x + (y + dest.y) * m_sx];
- const uint32_t *src2 = &rend[dest.x + (y + dest.y) * m_sx];
+ const u32 *src1 = &m_background[dest.x + (y + dest.y) * m_sx];
+ const u32 *src2 = &rend[dest.x + (y + dest.y) * m_sx];
for(int x = 0; x != dest.sx; x++) {
if(*src1 != *src2)
*dst = *src2;
@@ -372,8 +372,8 @@ bool screen_device_svg_renderer::compute_mask_intersection_bbox(int key1, int ke
x0 = y0 = x1 = y1 = -1;
for(int y = cy0; y < cy1; y++) {
- const uint32_t *src1 = &c1.image[(cx0 - c1.x) + c1.sx * (y - c1.y)];
- const uint32_t *src2 = &c2.image[(cx0 - c2.x) + c2.sx * (y - c2.y)];
+ const u32 *src1 = &c1.image[(cx0 - c1.x) + c1.sx * (y - c1.y)];
+ const u32 *src2 = &c2.image[(cx0 - c2.x) + c2.sx * (y - c2.y)];
for(int x = cx0; x < cx1; x++) {
if(*src1 && *src2 && *src1 != *src2) {
if(x0 == -1) {
@@ -403,7 +403,7 @@ bool screen_device_svg_renderer::compute_mask_intersection_bbox(int key1, int ke
return true;
}
-void screen_device_svg_renderer::compute_dual_diff_image(const std::vector<uint32_t> &rend, const bbox &bb, const cached_bitmap &src1, const cached_bitmap &src2, cached_bitmap &dest) const
+void screen_device_svg_renderer::compute_dual_diff_image(const std::vector<u32> &rend, const bbox &bb, const cached_bitmap &src1, const cached_bitmap &src2, cached_bitmap &dest) const
{
dest.x = bb.x0;
dest.y = bb.y0;
@@ -411,10 +411,10 @@ void screen_device_svg_renderer::compute_dual_diff_image(const std::vector<uint3
dest.sy = bb.y1 - bb.y0 + 1;
dest.image.resize(dest.sx*dest.sy);
for(int y = 0; y != dest.sy; y++) {
- const uint32_t *psrc1 = &src1.image[(dest.x - src1.x) + src1.sx * (y + dest.y - src1.y)];
- const uint32_t *psrc2 = &src2.image[(dest.x - src2.x) + src2.sx * (y + dest.y - src2.y)];
- const uint32_t *psrcr = &rend [ dest.x + m_sx * (y + dest.y )];
- uint32_t *pdest = &dest.image[ dest.sx * y ];
+ const u32 *psrc1 = &src1.image[(dest.x - src1.x) + src1.sx * (y + dest.y - src1.y)];
+ const u32 *psrc2 = &src2.image[(dest.x - src2.x) + src2.sx * (y + dest.y - src2.y)];
+ const u32 *psrcr = &rend [ dest.x + m_sx * (y + dest.y )];
+ u32 *pdest = &dest.image[ dest.sx * y ];
for(int x = 0; x != dest.sx; x++) {
if(*psrc1 && *psrc2 && *psrc1 != *psrc2)
*pdest = *psrcr;
@@ -429,7 +429,7 @@ void screen_device_svg_renderer::compute_dual_diff_image(const std::vector<uint3
void screen_device_svg_renderer::rebuild_cache()
{
m_cache.clear();
- std::vector<uint32_t> rend(m_sx*m_sy);
+ std::vector<u32> rend(m_sx*m_sy);
// Render the background, e.g. with everything off
std::vector<bool> state(m_key_count);
@@ -544,7 +544,7 @@ void screen_device_svg_renderer::rebuild_cache()
// screen_device - constructor
//-------------------------------------------------
-screen_device::screen_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+screen_device::screen_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, SCREEN, "Video Screen", tag, owner, clock, "screen", __FILE__),
m_type(SCREEN_TYPE_RASTER),
m_oldstyle_vblank_supplied(false),
@@ -619,7 +619,7 @@ void screen_device::static_set_svg_region(device_t &device, const char *region)
// to set the raw screen parameters
//-------------------------------------------------
-void screen_device::static_set_raw(device_t &device, uint32_t pixclock, uint16_t htotal, uint16_t hbend, uint16_t hbstart, uint16_t vtotal, uint16_t vbend, uint16_t vbstart)
+void screen_device::static_set_raw(device_t &device, u32 pixclock, u16 htotal, u16 hbend, u16 hbstart, u16 vtotal, u16 vbend, u16 vbstart)
{
screen_device &screen = downcast<screen_device &>(device);
screen.m_clock = pixclock;
@@ -660,7 +660,7 @@ void screen_device::static_set_vblank_time(device_t &device, attoseconds_t time)
// the width/height of the screen
//-------------------------------------------------
-void screen_device::static_set_size(device_t &device, uint16_t width, uint16_t height)
+void screen_device::static_set_size(device_t &device, u16 width, u16 height)
{
screen_device &screen = downcast<screen_device &>(device);
screen.m_width = width;
@@ -673,7 +673,7 @@ void screen_device::static_set_size(device_t &device, uint16_t width, uint16_t h
// set the visible area of the screen
//-------------------------------------------------
-void screen_device::static_set_visarea(device_t &device, int16_t minx, int16_t maxx, int16_t miny, int16_t maxy)
+void screen_device::static_set_visarea(device_t &device, s16 minx, s16 maxx, s16 miny, s16 maxy)
{
downcast<screen_device &>(device).m_visarea.set(minx, maxx, miny, maxy);
}
@@ -743,7 +743,7 @@ void screen_device::static_set_palette(device_t &device, const char *tag)
// video attributes
//-------------------------------------------------
-void screen_device::static_set_video_attributes(device_t &device, uint32_t flags)
+void screen_device::static_set_video_attributes(device_t &device, u32 flags)
{
screen_device &screen = downcast<screen_device &>(device);
screen.m_video_attributes = flags;
@@ -844,9 +844,9 @@ void screen_device::device_start()
// allocate raw textures
m_texture[0] = machine().render().texture_alloc();
- m_texture[0]->set_osd_data((uint64_t)((m_unique_id << 1) | 0));
+ m_texture[0]->set_osd_data(u64((m_unique_id << 1) | 0));
m_texture[1] = machine().render().texture_alloc();
- m_texture[1]->set_osd_data((uint64_t)((m_unique_id << 1) | 1));
+ m_texture[1]->set_osd_data(u64((m_unique_id << 1) | 1));
// configure the default cliparea
render_container::user_settings settings;
@@ -1091,8 +1091,8 @@ void screen_device::realloc_screen_bitmaps()
return;
// determine effective size to allocate
- int32_t effwidth = std::max(m_width, m_visarea.max_x + 1);
- int32_t effheight = std::max(m_height, m_visarea.max_y + 1);
+ s32 effwidth = std::max(m_width, m_visarea.max_x + 1);
+ s32 effheight = std::max(m_height, m_visarea.max_y + 1);
// reize all registered screen bitmaps
for (auto &item : m_auto_bitmap_list)
@@ -1177,7 +1177,7 @@ bool screen_device::update_partial(int scanline)
LOG_PARTIAL_UPDATES(("updating %d-%d\n", clip.min_y, clip.max_y));
g_profiler.start(PROFILER_VIDEO);
- uint32_t flags;
+ u32 flags;
if (m_type != SCREEN_TYPE_SVG)
{
screen_bitmap &curbitmap = m_bitmap[m_curbitmap];
@@ -1242,7 +1242,7 @@ void screen_device::update_now()
// if the line before us was incomplete, we must do it in two pieces
if (m_partial_scan_hpos > 0)
{
- int32_t save_scan = m_partial_scan_hpos;
+ s32 save_scan = m_partial_scan_hpos;
update_partial(current_vpos - 2);
m_partial_scan_hpos = save_scan;
@@ -1301,7 +1301,7 @@ void screen_device::update_now()
LOG_PARTIAL_UPDATES(("doing scanline partial draw: Y %d X %d-%d\n", clip.max_y, clip.min_x, clip.max_x));
- uint32_t flags;
+ u32 flags;
screen_bitmap &curbitmap = m_bitmap[m_curbitmap];
switch (curbitmap.format())
{
@@ -1585,8 +1585,8 @@ void screen_device::update_burnin()
int dstheight = m_burnin.height();
int xstep = (srcwidth << 16) / dstwidth;
int ystep = (srcheight << 16) / dstheight;
- int xstart = ((uint32_t)rand() % 32767) * xstep / 32767;
- int ystart = ((uint32_t)rand() % 32767) * ystep / 32767;
+ int xstart = (u32(rand()) % 32767) * xstep / 32767;
+ int ystart = (u32(rand()) % 32767) * ystep / 32767;
int srcx, srcy;
int x, y;
@@ -1599,8 +1599,8 @@ void screen_device::update_burnin()
bitmap_ind16 &srcbitmap = curbitmap.as_ind16();
for (y = 0, srcy = ystart; y < dstheight; y++, srcy += ystep)
{
- uint64_t *dst = &m_burnin.pix64(y);
- const uint16_t *src = &srcbitmap.pix16(srcy >> 16);
+ u64 *dst = &m_burnin.pix64(y);
+ const u16 *src = &srcbitmap.pix16(srcy >> 16);
const rgb_t *palette = m_palette->palette()->entry_list_adjusted();
for (x = 0, srcx = xstart; x < dstwidth; x++, srcx += xstep)
{
@@ -1617,8 +1617,8 @@ void screen_device::update_burnin()
bitmap_rgb32 &srcbitmap = curbitmap.as_rgb32();
for (y = 0, srcy = ystart; y < dstheight; y++, srcy += ystep)
{
- uint64_t *dst = &m_burnin.pix64(y);
- const uint32_t *src = &srcbitmap.pix32(srcy >> 16);
+ u64 *dst = &m_burnin.pix64(y);
+ const u32 *src = &srcbitmap.pix32(srcy >> 16);
for (x = 0, srcx = xstart; x < dstwidth; x++, srcx += xstep)
{
rgb_t pixel = src[srcx >> 16];
@@ -1657,11 +1657,11 @@ void screen_device::finalize_burnin()
int ystep = (srcheight << 16) / dstheight;
// find the maximum value
- uint64_t minval = ~(uint64_t)0;
- uint64_t maxval = 0;
+ u64 minval = ~u64(0);
+ u64 maxval = 0;
for (int y = 0; y < srcheight; y++)
{
- uint64_t *src = &m_burnin.pix64(y);
+ u64 *src = &m_burnin.pix64(y);
for (int x = 0; x < srcwidth; x++)
{
minval = std::min(minval, src[x]);
@@ -1675,11 +1675,11 @@ void screen_device::finalize_burnin()
// now normalize and convert to RGB
for (int y = 0, srcy = 0; y < dstheight; y++, srcy += ystep)
{
- uint64_t *src = &m_burnin.pix64(srcy >> 16);
- uint32_t *dst = &finalmap.pix32(y);
+ u64 *src = &m_burnin.pix64(srcy >> 16);
+ u32 *dst = &finalmap.pix32(y);
for (int x = 0, srcx = 0; x < dstwidth; x++, srcx += xstep)
{
- int brightness = (uint64_t)(maxval - src[srcx >> 16]) * 255 / (maxval - minval);
+ int brightness = u64(maxval - src[srcx >> 16]) * 255 / (maxval - minval);
dst[x] = rgb_t(0xff, brightness, brightness, brightness);
}
}