From 622df200dede8636585edf2c59c0a509139bfc73 Mon Sep 17 00:00:00 2001 From: "therealmogminer@gmail.com" Date: Mon, 15 Feb 2016 20:22:04 +0100 Subject: [PATCH] Fix errors with -rol and -ror, nw --- src/emu/render.cpp | 12 ++--- src/emu/render.h | 2 +- src/osd/modules/render/drawbgfx.cpp | 75 ++++++++++++++++++++--------- 3 files changed, 56 insertions(+), 33 deletions(-) diff --git a/src/emu/render.cpp b/src/emu/render.cpp index cbcfd6b16b3..8cb58de116f 100644 --- a/src/emu/render.cpp +++ b/src/emu/render.cpp @@ -442,7 +442,7 @@ void render_texture::hq_scale(bitmap_argb32 &dest, bitmap_argb32 &source, const // get_scaled - get a scaled bitmap (if we can) //------------------------------------------------- -void render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &texinfo, render_primitive_list &primlist, bool packable) +void render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &texinfo, render_primitive_list &primlist, UINT32 flags) { texinfo.hash = 0; @@ -524,11 +524,7 @@ void render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &t } UINT32 hash = 0; - if (packable) - { - //printf("Packable, %d, %d\n", texinfo.width, texinfo.height); - } - if (packable && texinfo.width <= 128 && texinfo.height <= 128) + if ((flags & PRIMFLAG_PACKABLE) && texinfo.width <= 128 && texinfo.height <= 128) { hash = reinterpret_cast(texinfo.base) & 0xffffffff; } @@ -1764,7 +1760,7 @@ void render_target::add_container_primitives(render_primitive_list &list, const width = MIN(width, m_maxtexwidth); height = MIN(height, m_maxtexheight); - curitem->texture()->get_scaled(width, height, prim->texture, list, (curitem->flags() & PRIMFLAG_PACKABLE) ? true : false); + curitem->texture()->get_scaled(width, height, prim->texture, list, curitem->flags()); // set the palette prim->texture.palette = curitem->texture()->get_adjusted_palette(container); @@ -1867,7 +1863,7 @@ void render_target::add_element_primitives(render_primitive_list &list, const ob // get the scaled texture and append it - texture->get_scaled(width, height, prim->texture, list, (prim->flags & PRIMFLAG_PACKABLE) ? true : false); + texture->get_scaled(width, height, prim->texture, list, prim->flags); // compute the clip rect render_bounds cliprect; diff --git a/src/emu/render.h b/src/emu/render.h index ab464879ec7..1761deb2f20 100644 --- a/src/emu/render.h +++ b/src/emu/render.h @@ -436,7 +436,7 @@ public: private: // internal helpers - void get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &texinfo, render_primitive_list &primlist, bool packable = false); + void get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &texinfo, render_primitive_list &primlist, UINT32 flags = 0); const rgb_t *get_adjusted_palette(render_container &container); static const int MAX_TEXTURE_SCALES = 16; diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp index 707360053aa..4e7c7f15e43 100644 --- a/src/osd/modules/render/drawbgfx.cpp +++ b/src/osd/modules/render/drawbgfx.cpp @@ -283,47 +283,74 @@ void renderer_bgfx::put_packed_quad(render_primitive *prim, UINT32 hash, PosColo float v1 = v0 + float(rect.height()) / float(CACHE_SIZE); UINT32 rgba = u32Color(prim->color.r * 255, prim->color.g * 255, prim->color.b * 255, prim->color.a * 255); - vertex[0].m_x = prim->bounds.x0; - vertex[0].m_y = prim->bounds.y0; + float x[4] = { prim->bounds.x0, prim->bounds.x1, prim->bounds.x0, prim->bounds.x1 }; + float y[4] = { prim->bounds.y0, prim->bounds.y0, prim->bounds.y1, prim->bounds.y1 }; + float u[4] = { u0, u1, u0, u1 }; + float v[4] = { v0, v0, v1, v1 }; + + if (PRIMFLAG_GET_TEXORIENT(prim->flags) & ORIENTATION_SWAP_XY) + { + std::swap(u[1], u[2]); + std::swap(v[1], v[2]); + } + + if (PRIMFLAG_GET_TEXORIENT(prim->flags) & ORIENTATION_FLIP_X) + { + std::swap(u[0], u[1]); + std::swap(v[0], v[1]); + std::swap(u[2], u[3]); + std::swap(v[2], v[3]); + } + + if (PRIMFLAG_GET_TEXORIENT(prim->flags) & ORIENTATION_FLIP_Y) + { + std::swap(u[0], u[2]); + std::swap(v[0], v[2]); + std::swap(u[1], u[3]); + std::swap(v[1], v[3]); + } + + vertex[0].m_x = x[0]; // 0 + vertex[0].m_y = y[0]; vertex[0].m_z = 0; vertex[0].m_rgba = rgba; - vertex[0].m_u = u0; - vertex[0].m_v = v0; + vertex[0].m_u = u[0]; + vertex[0].m_v = v[0]; - vertex[1].m_x = prim->bounds.x1; - vertex[1].m_y = prim->bounds.y0; + vertex[1].m_x = x[1]; // 1 + vertex[1].m_y = y[1]; vertex[1].m_z = 0; vertex[1].m_rgba = rgba; - vertex[1].m_u = u1; - vertex[1].m_v = v0; + vertex[1].m_u = u[1]; + vertex[1].m_v = v[1]; - vertex[2].m_x = prim->bounds.x1; - vertex[2].m_y = prim->bounds.y1; + vertex[2].m_x = x[3]; // 3 + vertex[2].m_y = y[3]; vertex[2].m_z = 0; vertex[2].m_rgba = rgba; - vertex[2].m_u = u1; - vertex[2].m_v = v1; + vertex[2].m_u = u[3]; + vertex[2].m_v = v[3]; - vertex[3].m_x = prim->bounds.x1; - vertex[3].m_y = prim->bounds.y1; + vertex[3].m_x = x[3]; // 3 + vertex[3].m_y = y[3]; vertex[3].m_z = 0; vertex[3].m_rgba = rgba; - vertex[3].m_u = u1; - vertex[3].m_v = v1; + vertex[3].m_u = u[3]; + vertex[3].m_v = v[3]; - vertex[4].m_x = prim->bounds.x0; - vertex[4].m_y = prim->bounds.y1; + vertex[4].m_x = x[2]; // 2 + vertex[4].m_y = y[2]; vertex[4].m_z = 0; vertex[4].m_rgba = rgba; - vertex[4].m_u = u0; - vertex[4].m_v = v1; + vertex[4].m_u = u[2]; + vertex[4].m_v = v[2]; - vertex[5].m_x = prim->bounds.x0; - vertex[5].m_y = prim->bounds.y0; + vertex[5].m_x = x[0]; // 0 + vertex[5].m_y = y[0]; vertex[5].m_z = 0; vertex[5].m_rgba = rgba; - vertex[5].m_u = u0; - vertex[5].m_v = v0; + vertex[5].m_u = u[0]; + vertex[5].m_v = v[0]; } void renderer_bgfx::render_textured_quad(int view, render_primitive* prim)