summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/chihiro.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/video/chihiro.cpp')
-rw-r--r--src/mame/video/chihiro.cpp63
1 files changed, 51 insertions, 12 deletions
diff --git a/src/mame/video/chihiro.cpp b/src/mame/video/chihiro.cpp
index b3ef942a1cb..21fe7d30ba1 100644
--- a/src/mame/video/chihiro.cpp
+++ b/src/mame/video/chihiro.cpp
@@ -2366,7 +2366,6 @@ void nv2a_renderer::convert_vertices_poly(vertex_nv *source, nv2avertex_t *desti
// should use either the vertex program or transformation matrices
if (vertex_pipeline == 4) {
// transformation matrices
- // it is not implemented, so we pretend its always using screen coordinates
for (m = 0; m < count; m++) {
for (int i = 0; i < 4; i++) {
t[i] = 0;
@@ -2378,11 +2377,12 @@ void nv2a_renderer::convert_vertices_poly(vertex_nv *source, nv2avertex_t *desti
for (int j = 0; j < 4; j++)
v[i] += matrix.projection[i][j] * t[j];
};
- /*for (int i = 0; i < 3; i++) {
+ /* it seems these are not needed ?
+ for (int i = 0; i < 3; i++) {
v[i] *= matrix.scale[i];
}
for (int i = 0; i < 3; i++) {
- v[i] += matrix.translate[i];
+ v[i] += matrix.traslate[i];
}*/
destination[m].w = v[3];
destination[m].x = (v[0] / v[3])*supersample_factor_x; // source[m].attribute[0].fv[0];
@@ -2400,6 +2400,7 @@ void nv2a_renderer::convert_vertices_poly(vertex_nv *source, nv2avertex_t *desti
// vertex program
// run vertex program
vertexprogram.exec.process(vertexprogram.start_instruction, source, vert, count);
+ // the output of the vertex program has the perspective divide, viewport scale and offset already applied
// copy data for poly.c
for (m = 0; m < count; m++) {
destination[m].w = vert[m].attribute[0].fv[3];
@@ -2680,6 +2681,15 @@ UINT32 nv2a_renderer::render_triangle_clipping(const rectangle &cliprect, render
vi[2] = &_v3;
for (int n=0;n < 3;n++)
{
+ // remove traslate
+ vi[n]->x = vi[n]->x - translatex;
+ vi[n]->y = vi[n]->y - translatey;
+ vi[n]->p[(int)VERTEX_PARAMETER::PARAM_Z] = vi[n]->p[(int)VERTEX_PARAMETER::PARAM_Z] - translatez;
+ // remove scale
+ vi[n]->x = vi[n]->x / scalex;
+ vi[n]->y = vi[n]->y / scaley;
+ vi[n]->p[(int)VERTEX_PARAMETER::PARAM_Z] = vi[n]->p[(int)VERTEX_PARAMETER::PARAM_Z] / scalez;
+ // remove perspective divide
vi[n]->x = vi[n]->x * vi[n]->w;
vi[n]->y = vi[n]->y * vi[n]->w;
vi[n]->p[(int)VERTEX_PARAMETER::PARAM_Z] = vi[n]->p[(int)VERTEX_PARAMETER::PARAM_Z] * vi[n]->w;
@@ -2715,16 +2725,26 @@ UINT32 nv2a_renderer::render_triangle_clipping(const rectangle &cliprect, render
}
for (int n = 0; n < idx; n++)
{
+ // apply perspective divide
vo[n].x = vo[n].x / vo[n].w;
vo[n].y = vo[n].y / vo[n].w;
vo[n].p[(int)VERTEX_PARAMETER::PARAM_Z] = vo[n].p[(int)VERTEX_PARAMETER::PARAM_Z] / vo[n].w;
+ // apply scale
+ vo[n].x = vo[n].x * scalex;
+ vo[n].y = vo[n].y * scaley;
+ vo[n].p[(int)VERTEX_PARAMETER::PARAM_Z] = vo[n].p[(int)VERTEX_PARAMETER::PARAM_Z] * scalez;
+ // apply traslate
+ vo[n].x = vo[n].x + translatex;
+ vo[n].y = vo[n].y + translatey;
+ vo[n].p[(int)VERTEX_PARAMETER::PARAM_Z] = vo[n].p[(int)VERTEX_PARAMETER::PARAM_Z] + translatez;
+ }
+ for (int n = 0; n < (idx-2); n++)
+ {
+ if ((n & 1) == 0)
+ render_triangle_culling(cliprect, callback, paramcount, vo[n], vo[n + 1], vo[n + 2]);
+ else
+ render_triangle_culling(cliprect, callback, paramcount, vo[n], vo[n + 2], vo[n + 1]);
}
- if (idx > 2)
- render_triangle_culling(cliprect, callback, paramcount, vo[0], vo[1], vo[2]);
- if (idx > 3)
- render_triangle_culling(cliprect, callback, paramcount, vo[0], vo[2], vo[3]);
- if (idx > 4)
- exit(0);
#endif
return 0;
}
@@ -2869,7 +2889,7 @@ int nv2a_renderer::geforce_exec_method(address_space & space, UINT32 chanel, UIN
data = space.read_dword(address);
channel[chanel][subchannel].object.method[method] = data;
#ifdef LOG_NV2A
- printf("A:%08X MTHD:%08X D:%08X\n\r",address,maddress,data);
+ //printf("A:%08X MTHD:%08X D:%08X\n\r",address,maddress,data);
#endif
if (maddress == 0x17fc) {
#if 0 // useful while debugging to see what coordinates have been used
@@ -3483,12 +3503,16 @@ int nv2a_renderer::geforce_exec_method(address_space & space, UINT32 chanel, UIN
*(UINT32 *)(&matrix.projection[maddress >> 2][maddress & 3]) = data;
countlen--;
}
- // viewport translate
+ // viewport traslate
if ((maddress >= 0x0a20) && (maddress < 0x0a30)) {
maddress = (maddress - 0x0a20) / 4;
- *(UINT32 *)(&matrix.translate[maddress]) = data;
+ *(UINT32 *)(&matrix.traslate[maddress]) = data;
// set corresponding vertex shader constant too
vertexprogram.exec.c_constant[59].iv[maddress] = data; // constant -37
+#ifdef LOG_NV2A
+ if (maddress == 3)
+ machine().logerror("viewport traslate = {%f %f %f %f}\n", matrix.traslate[0], matrix.traslate[1], matrix.traslate[2], matrix.traslate[3]);
+#endif
countlen--;
}
// viewport scale
@@ -3497,6 +3521,10 @@ int nv2a_renderer::geforce_exec_method(address_space & space, UINT32 chanel, UIN
*(UINT32 *)(&matrix.scale[maddress]) = data;
// set corresponding vertex shader constant too
vertexprogram.exec.c_constant[58].iv[maddress] = data; // constant -38
+#ifdef LOG_NV2A
+ if (maddress == 3)
+ machine().logerror("viewport scale = {%f %f %f %f}\n", matrix.scale[0], matrix.scale[1], matrix.scale[2], matrix.scale[3]);
+#endif
countlen--;
}
// Vertex program (shader)
@@ -3557,6 +3585,15 @@ int nv2a_renderer::geforce_exec_method(address_space & space, UINT32 chanel, UIN
machine().logerror("Need to increase size of vertexprogram.parameter to %d\n\r", vertexprogram.upload_parameter_index);
vertexprogram.upload_parameter_component++;
if (vertexprogram.upload_parameter_component >= 4) {
+#ifdef LOG_NV2A
+ if ((vertexprogram.upload_parameter_index == 58) || (vertexprogram.upload_parameter_index == 59))
+ machine().logerror("vp constant %d (%s) = {%f %f %f %f}\n", vertexprogram.upload_parameter_index,
+ vertexprogram.upload_parameter_index == 58 ? "viewport scale" : "viewport traslate",
+ vertexprogram.exec.c_constant[vertexprogram.upload_parameter_index].fv[0],
+ vertexprogram.exec.c_constant[vertexprogram.upload_parameter_index].fv[1],
+ vertexprogram.exec.c_constant[vertexprogram.upload_parameter_index].fv[2],
+ vertexprogram.exec.c_constant[vertexprogram.upload_parameter_index].fv[3]);
+#endif
vertexprogram.upload_parameter_component = 0;
vertexprogram.upload_parameter_index++;
}
@@ -4616,6 +4653,8 @@ WRITE32_MEMBER(nv2a_renderer::geforce_w)
dmaget = &channel[chanel][0].regs[0x44 / 4];
//printf("dmaget %08X dmaput %08X\n\r",*dmaget,*dmaput);
if (((*dmaput == 0x048cf000) && (*dmaget == 0x07f4d000)) || // only for outr2
+ ((*dmaput == 0x045cd000) && (*dmaget == 0x07f4d000)) || // only for scg06nt
+ ((*dmaput == 0x0494c000) && (*dmaget == 0x07f4d000)) || // only for wangmid
((*dmaput == 0x07dca000) && (*dmaget == 0x07f4d000))) // only for crtaxihr
{
*dmaget = *dmaput;