namcos22: improve window clipping (nw)

This commit is contained in:
hap 2018-10-21 20:08:25 +02:00
parent 3f19591995
commit 0eb5679d24
3 changed files with 46 additions and 30 deletions

View File

@ -33,7 +33,6 @@
* - alpha blended sprite/poly with priority over alpha blended text doesn't work right (see dirtdash countdown when you start at jungle level)
* - cybrcomm arrows(black part) should be below textlayer when a messagebox pops up
* - cybrcycc speed dial needle is missing
* - window clipping is wrong in acedrvrw, victlapw (see rear-view mirrors), and alpinr2b character selection screen
* - global offset is wrong in non-super22 servicemode video test, and above that, it flickers in acedrvrw, victlapw
* - dirtdash polys are broken at the start section of the mountain level, maybe bad rom?
* - ridgerac fogging isn't applied to the upper/side part of the sky (best seen when driving down a hill), it's fine in ridgera2
@ -3786,8 +3785,10 @@ void namcos22_state::machine_start()
save_item(NAME(m_camera_zoom));
save_item(NAME(m_camera_vx));
save_item(NAME(m_camera_vy));
save_item(NAME(m_camera_vw));
save_item(NAME(m_camera_vh));
save_item(NAME(m_camera_vu));
save_item(NAME(m_camera_vd));
save_item(NAME(m_camera_vl));
save_item(NAME(m_camera_vr));
save_item(NAME(m_camera_lx));
save_item(NAME(m_camera_ly));
save_item(NAME(m_camera_lz));

View File

@ -71,7 +71,8 @@ struct namcos22_scenenode
struct
{
float vx, vy, vw, vh;
float vx, vy;
float vu, vd, vl, vr;
int texturebank;
int color;
int cmode;
@ -148,8 +149,8 @@ private:
struct namcos22_scenenode m_scenenode_root;
struct namcos22_scenenode *m_scenenode_cur;
int m_clipx;
int m_clipy;
float m_clipx;
float m_clipy;
rectangle m_cliprect;
inline u8 nthbyte(const u32 *src, int n) { return (src[n / 4] << ((n & 3) * 8)) >> 24; }
@ -555,8 +556,10 @@ private:
float m_camera_zoom;
float m_camera_vx;
float m_camera_vy;
float m_camera_vw;
float m_camera_vh;
float m_camera_vu;
float m_camera_vd;
float m_camera_vl;
float m_camera_vr;
float m_camera_lx; // unit vector for light direction
float m_camera_ly; // "
float m_camera_lz; // "

View File

@ -264,16 +264,12 @@ void namcos22_renderer::poly3d_drawquad(screen_device &screen, bitmap_rgb32 &bit
extra.prioverchar |= m_state.m_is_ss22 ? 2 : 0;
// scene clip
int cx = 320 + node->data.quad.vx;
int cy = 240 + node->data.quad.vy;
float cx = 320.0f + node->data.quad.vx;
float cy = 240.0f + node->data.quad.vy;
m_clipx = cx;
m_clipy = cy;
m_cliprect.set(
std::max<s32>(cx + node->data.quad.vw, 0),
std::min<s32>(cx - node->data.quad.vw, 639),
std::max<s32>(cy + node->data.quad.vh, 0),
std::min<s32>(cy - node->data.quad.vh, 479)
);
m_cliprect.set(cx + node->data.quad.vl, cx - node->data.quad.vr, cy + node->data.quad.vu, cy - node->data.quad.vd);
m_cliprect &= screen.visible_area();
// non-direct case: project and z-clip
if (!direct)
@ -483,12 +479,8 @@ void namcos22_renderer::poly3d_drawsprite(
void namcos22_renderer::render_sprite(screen_device &screen, bitmap_rgb32 &bitmap, struct namcos22_scenenode *node)
{
// scene clip
m_cliprect.set(
std::max<s32>(node->data.sprite.cx_min, 0),
std::min<s32>(node->data.sprite.cx_max, 639),
std::max<s32>(node->data.sprite.cy_min, 0),
std::min<s32>(node->data.sprite.cy_max, 479)
);
m_cliprect.set(node->data.sprite.cx_min, node->data.sprite.cx_max, node->data.sprite.cy_min, node->data.sprite.cy_max);
m_cliprect &= screen.visible_area();
int offset = 0;
@ -849,8 +841,10 @@ void namcos22_state::draw_direct_poly(const u16 *src)
node->data.quad.direct = 1;
node->data.quad.vx = 0;
node->data.quad.vy = 0;
node->data.quad.vw = -320;
node->data.quad.vh = -240;
node->data.quad.vu = -240;
node->data.quad.vd = -240;
node->data.quad.vl = -320;
node->data.quad.vr = -320;
}
/**
@ -1028,8 +1022,10 @@ void namcos22_state::blit_single_quad(u32 color, u32 addr, float m[4][4], int po
node->data.quad.direct = 0;
node->data.quad.vx = m_camera_vx;
node->data.quad.vy = m_camera_vy;
node->data.quad.vw = m_camera_vw;
node->data.quad.vh = m_camera_vh;
node->data.quad.vu = m_camera_vu;
node->data.quad.vd = m_camera_vd;
node->data.quad.vl = m_camera_vl;
node->data.quad.vr = m_camera_vr;
}
@ -1221,14 +1217,30 @@ void namcos22_state::slavesim_handle_bb0003(const s32 *src)
m_camera_ly = dspfixed_to_nativefloat(src[0x3]);
m_camera_lz = dspfixed_to_nativefloat(src[0x4]);
m_reflection = src[0x2] >> 16 & 0x30; // z too?
m_cullflip = (m_reflection == 0x10 || m_reflection == 0x20);
m_absolute_priority = src[0x3] >> 16;
m_camera_vx = (s16)(src[0x5] >> 16);
m_camera_vy = (s16)(src[0x5] & 0xffff);
m_camera_zoom = dspfloat_to_nativefloat(src[0x6]);
m_camera_vw = dspfloat_to_nativefloat(src[0x7]) * m_camera_zoom;
m_camera_vh = dspfloat_to_nativefloat(src[0x9]) * m_camera_zoom;
m_camera_vl = dspfloat_to_nativefloat(src[0x7]) * m_camera_zoom;
m_camera_vr = dspfloat_to_nativefloat(src[0x8]) * m_camera_zoom;
m_camera_vu = dspfloat_to_nativefloat(src[0x9]) * m_camera_zoom;
m_camera_vd = dspfloat_to_nativefloat(src[0xa]) * m_camera_zoom;
m_reflection = src[0x2] >> 16 & 0x30; // z too?
m_cullflip = (m_reflection == 0x10 || m_reflection == 0x20);
if (m_reflection & 0x10)
{
float vl = m_camera_vl;
m_camera_vl = m_camera_vr;
m_camera_vr = vl;
}
if (m_reflection & 0x20)
{
float vu = m_camera_vu;
m_camera_vu = m_camera_vd;
m_camera_vd = vu;
}
m_viewmatrix[0][0] = dspfixed_to_nativefloat(src[0x0c]);
m_viewmatrix[1][0] = dspfixed_to_nativefloat(src[0x0d]);