From f5b0dee53eb39ae910730c7d68c39c5e4d90ee31 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 17 Aug 2017 08:18:19 +1000 Subject: [PATCH] [Video] Move vertex definition into Renderer/types.h --- Source/Project64-video/3dmath.cpp | 6 +- Source/Project64-video/3dmath.h | 6 +- Source/Project64-video/Debugger.cpp | 2 +- Source/Project64-video/FBtoScreen.cpp | 12 ++-- .../Renderer/OGLESgeometry.cpp | 8 +-- .../Project64-video/Renderer/OGLgeometry.cpp | 18 +++--- Source/Project64-video/Renderer/Renderer.h | 4 +- Source/Project64-video/Renderer/types.h | 32 ++++++++++ Source/Project64-video/TexBuffer.cpp | 8 +-- Source/Project64-video/Util.cpp | 60 +++++++++---------- Source/Project64-video/Util.h | 6 +- Source/Project64-video/rdp.cpp | 32 +++++----- Source/Project64-video/rdp.h | 55 ++++------------- Source/Project64-video/turbo3D.cpp | 4 +- Source/Project64-video/ucode00.cpp | 16 ++--- Source/Project64-video/ucode00.h | 4 +- Source/Project64-video/ucode01.cpp | 8 +-- Source/Project64-video/ucode02.cpp | 12 ++-- Source/Project64-video/ucode03.cpp | 6 +- Source/Project64-video/ucode04.cpp | 4 +- Source/Project64-video/ucode05.cpp | 4 +- Source/Project64-video/ucode06.cpp | 40 ++++++------- Source/Project64-video/ucode07.cpp | 2 +- Source/Project64-video/ucode08.cpp | 4 +- Source/Project64-video/ucode09.cpp | 8 +-- 25 files changed, 180 insertions(+), 181 deletions(-) diff --git a/Source/Project64-video/3dmath.cpp b/Source/Project64-video/3dmath.cpp index a38799a78..c771b4106 100644 --- a/Source/Project64-video/3dmath.cpp +++ b/Source/Project64-video/3dmath.cpp @@ -22,7 +22,7 @@ extern "C" { #include "3dmath.h" #include "trace.h" -void calc_light(VERTEX &v) +void calc_light(gfxVERTEX &v) { float light_intensity = 0.0f; register float color[3] = { rdp.light[rdp.num_lights].r, rdp.light[rdp.num_lights].g, rdp.light[rdp.num_lights].b }; @@ -47,7 +47,7 @@ void calc_light(VERTEX &v) v.b = (uint8_t)(color[2] * 255.0f); } -void calc_linear(VERTEX &v) +void calc_linear(gfxVERTEX &v) { if (g_settings->force_calc_sphere()) { @@ -90,7 +90,7 @@ void calc_linear(VERTEX &v) WriteTrace(TraceRDP, TraceVerbose, "calc linear u: %f, v: %f", v.ou, v.ov); } -void calc_sphere(VERTEX &v) +void calc_sphere(gfxVERTEX &v) { WriteTrace(TraceRDP, TraceDebug, "calc_sphere"); DECLAREALIGN16VAR(vec[3]); diff --git a/Source/Project64-video/3dmath.h b/Source/Project64-video/3dmath.h index 7d3d10aaa..a1909949c 100644 --- a/Source/Project64-video/3dmath.h +++ b/Source/Project64-video/3dmath.h @@ -11,9 +11,9 @@ * version 2 of the License, or (at your option) any later version. * * * ****************************************************************************/ -void calc_light(VERTEX &v); -void calc_linear(VERTEX &v); -void calc_sphere(VERTEX &v); +void calc_light(gfxVERTEX &v); +void calc_linear(gfxVERTEX &v); +void calc_sphere(gfxVERTEX &v); void math_init(); diff --git a/Source/Project64-video/Debugger.cpp b/Source/Project64-video/Debugger.cpp index 87b842ae2..8fa6188cf 100644 --- a/Source/Project64-video/Debugger.cpp +++ b/Source/Project64-video/Debugger.cpp @@ -37,7 +37,7 @@ void output(float x, float y, int scale, const char *fmt, ...) { c = ((out_buf[i] - 32) & 0x1F) * 8;//<< 3; r = (((out_buf[i] - 32) & 0xE0) >> 5) * 16;//<< 4; - VERTEX v[4] = { { x * scale_1024, (768 - y) * scale_768, 1, 1, (float)c, r + 16.0f, 0, 0,{ 0, 0, 0, 0 } }, + gfxVERTEX v[4] = { { x * scale_1024, (768 - y) * scale_768, 1, 1, (float)c, r + 16.0f, 0, 0,{ 0, 0, 0, 0 } }, { (x + 8) * scale_1024, (768 - y) * scale_768, 1, 1, c + 8.0f, r + 16.0f, 0, 0,{ 0, 0, 0, 0 } }, { x * scale_1024, (768 - y - 16) * scale_768, 1, 1, (float)c, (float)r, 0, 0,{ 0, 0, 0, 0 } }, { (x + 8) * scale_1024, (768 - y - 16) * scale_768, 1, 1, c + 8.0f, (float)r, 0, 0,{ 0, 0, 0, 0 } } diff --git a/Source/Project64-video/FBtoScreen.cpp b/Source/Project64-video/FBtoScreen.cpp index 717c014fa..b483a46d8 100644 --- a/Source/Project64-video/FBtoScreen.cpp +++ b/Source/Project64-video/FBtoScreen.cpp @@ -95,7 +95,7 @@ static void DrawRE2Video(FB_TO_SCREEN_INFO & fb_info, float scale) float lr_x = g_scr_res_x - 1.0f; float lr_u = (fb_info.width - 1)*scale; float lr_v = (fb_info.height - 1)*scale; - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, { 0.5f, 0.5f, 0.5f, 0.5f } }, { lr_x, ul_y, 1, 1, lr_u, 0.5f, lr_u, 0.5f, { lr_u, 0.5f, lr_u, 0.5f } }, { ul_x, lr_y, 1, 1, 0.5f, lr_v, 0.5f, lr_v, { 0.5f, lr_v, 0.5f, lr_v } }, @@ -248,7 +248,7 @@ static void DrawFrameBufferToScreen256(FB_TO_SCREEN_INFO & fb_info) float lr_u = (float)(cur_width - 1); float lr_v = (float)(cur_height - 1); // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, { 0.5f, 0.5f, 0.5f, 0.5f } }, { lr_x, ul_y, 1, 1, lr_u, 0.5f, lr_u, 0.5f, { lr_u, 0.5f, lr_u, 0.5f } }, { ul_x, lr_y, 1, 1, 0.5f, lr_v, 0.5f, lr_v, { 0.5f, lr_v, 0.5f, lr_v } }, @@ -368,7 +368,7 @@ bool DrawFrameBufferToScreen(FB_TO_SCREEN_INFO & fb_info) float lr_u = (width - 1)*scale; float lr_v = (height - 1)*scale; // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, { 0.5f, 0.5f, 0.5f, 0.5f } }, { lr_x, ul_y, 1, 1, lr_u, 0.5f, lr_u, 0.5f, { lr_u, 0.5f, lr_u, 0.5f } }, { ul_x, lr_y, 1, 1, 0.5f, lr_v, 0.5f, lr_v, { 0.5f, lr_v, 0.5f, lr_v } }, @@ -440,7 +440,7 @@ static void DrawDepthBufferToScreen256(FB_TO_SCREEN_INFO & fb_info) float lr_u = (float)(cur_width - 1); float lr_v = (float)(cur_height - 1); // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, { 0.5f, 0.5f, 0.5f, 0.5f } }, { lr_x, ul_y, 1, 1, lr_u, 0.5f, lr_u, 0.5f, { lr_u, 0.5f, lr_u, 0.5f } }, { ul_x, lr_y, 1, 1, 0.5f, lr_v, 0.5f, lr_v, { 0.5f, lr_v, 0.5f, lr_v } }, @@ -509,7 +509,7 @@ static void DrawHiresDepthBufferToScreen(FB_TO_SCREEN_INFO & fb_info) float lr_u = (float)rdp.scissor.lr_x * scale; float lr_v = (float)rdp.scissor.lr_y * scale; // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, 1, 1, ul_u, ul_v, ul_u, ul_v, { ul_u, ul_v, ul_u, ul_v } }, { lr_x, ul_y, 1, 1, lr_u, ul_v, lr_u, ul_v, { lr_u, ul_v, lr_u, ul_v } }, { ul_x, lr_y, 1, 1, ul_u, lr_v, ul_u, lr_v, { ul_u, lr_v, ul_u, lr_v } }, @@ -594,7 +594,7 @@ void DrawDepthBufferToScreen(FB_TO_SCREEN_INFO & fb_info) float lr_v = (height - 1)*scale; float zero = scale*0.5f; // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, 1, 1, zero, zero, zero, zero, { zero, zero, zero, zero } }, { lr_x, ul_y, 1, 1, lr_u, zero, lr_u, zero, { lr_u, zero, lr_u, zero } }, { ul_x, lr_y, 1, 1, zero, lr_v, zero, lr_v, { zero, lr_v, zero, lr_v } }, diff --git a/Source/Project64-video/Renderer/OGLESgeometry.cpp b/Source/Project64-video/Renderer/OGLESgeometry.cpp index 2e33a6fb8..b81488044 100644 --- a/Source/Project64-video/Renderer/OGLESgeometry.cpp +++ b/Source/Project64-video/Renderer/OGLESgeometry.cpp @@ -22,14 +22,14 @@ #include #define Z_MAX (65536.0f) -#define VERTEX_SIZE sizeof(VERTEX) //Size of vertex struct +#define VERTEX_SIZE sizeof(gfxVERTEX) //Size of vertex struct int w_buffer_mode; int inverted_culling; gfxCullMode_t culling_mode; #define VERTEX_BUFFER_SIZE 1500 //Max amount of vertices to buffer, this seems large enough. -static VERTEX vertex_buffer[VERTEX_BUFFER_SIZE]; +static gfxVERTEX vertex_buffer[VERTEX_BUFFER_SIZE]; static int vertex_buffer_count = 0; static GLenum vertex_draw_mode; static bool vertex_buffer_enabled = false; @@ -262,7 +262,7 @@ void gfxDepthBiasLevel(int32_t level) } // draw -void gfxDrawTriangle(const void *a, const void *b, const void *c) +void gfxDrawTriangle(const gfxVERTEX *a, const gfxVERTEX *b, const gfxVERTEX *c) { WriteTrace(TraceGlitch, TraceDebug, "start"); vbo_enable(); @@ -289,7 +289,7 @@ void gfxDrawTriangle(const void *a, const void *b, const void *c) WriteTrace(TraceGlitch, TraceDebug, "Done"); } -void gfxDrawLine(const void *a, const void *b) +void gfxDrawLine(const gfxVERTEX *a, const gfxVERTEX *b) { } diff --git a/Source/Project64-video/Renderer/OGLgeometry.cpp b/Source/Project64-video/Renderer/OGLgeometry.cpp index 38ed6bb85..ee0dc7592 100644 --- a/Source/Project64-video/Renderer/OGLgeometry.cpp +++ b/Source/Project64-video/Renderer/OGLgeometry.cpp @@ -23,13 +23,13 @@ #define Z_MAX (65536.0f) -static int xy_off = offsetof(VERTEX, x); -static int z_off = offsetof(VERTEX, z); -static int q_off = offsetof(VERTEX, q); -static int pargb_off = offsetof(VERTEX, b); -static int st0_off = offsetof(VERTEX, coord[0]); -static int st1_off = offsetof(VERTEX, coord[2]); -static int fog_ext_off = offsetof(VERTEX, f); +static int xy_off = offsetof(gfxVERTEX, x); +static int z_off = offsetof(gfxVERTEX, z); +static int q_off = offsetof(gfxVERTEX, q); +static int pargb_off = offsetof(gfxVERTEX, b); +static int st0_off = offsetof(gfxVERTEX, coord[0]); +static int st1_off = offsetof(gfxVERTEX, coord[2]); +static int fog_ext_off = offsetof(gfxVERTEX, f); int w_buffer_mode; int inverted_culling; @@ -261,7 +261,7 @@ void gfxDepthBiasLevel(int32_t level) } // draw -void gfxDrawTriangle(const void *a, const void *b, const void *c) +void gfxDrawTriangle(const gfxVERTEX *a, const gfxVERTEX *b, const gfxVERTEX *c) { float *a_x = (float*)a + xy_off / sizeof(float); float *a_y = (float*)a + xy_off / sizeof(float) + 1; @@ -376,7 +376,7 @@ void gfxDrawTriangle(const void *a, const void *b, const void *c) grDisplayGLError("gfxDrawTriangle"); } -void gfxDrawLine(const void *a, const void *b) +void gfxDrawLine(const gfxVERTEX *a, const gfxVERTEX *b) { float *a_x = (float*)a + xy_off / sizeof(float); float *a_y = (float*)a + xy_off / sizeof(float) + 1; diff --git a/Source/Project64-video/Renderer/Renderer.h b/Source/Project64-video/Renderer/Renderer.h index 804834117..a4e465eee 100644 --- a/Source/Project64-video/Renderer/Renderer.h +++ b/Source/Project64-video/Renderer/Renderer.h @@ -43,9 +43,9 @@ void gfxCullMode(gfxCullMode_t mode); void gfxDepthBufferMode(gfxDepthBufferMode_t mode); void gfxDepthBufferFunction(gfxCmpFnc_t function); void gfxDepthMask(bool mask); -void gfxDrawTriangle(const void *a, const void *b, const void *c); +void gfxDrawTriangle(const gfxVERTEX *a, const gfxVERTEX *b, const gfxVERTEX *c); void gfxDepthBiasLevel(int32_t level); -void gfxDrawLine(const void *a, const void *b); +void gfxDrawLine(const gfxVERTEX *a, const gfxVERTEX *b); void gfxDrawVertexArray(gfxDrawMode_t mode, uint32_t Count, void *pointers2); void gfxDrawVertexArrayContiguous(gfxDrawMode_t mode, uint32_t Count, void *pointers, uint32_t stride); diff --git a/Source/Project64-video/Renderer/types.h b/Source/Project64-video/Renderer/types.h index 8ede28df4..c68232f3b 100644 --- a/Source/Project64-video/Renderer/types.h +++ b/Source/Project64-video/Renderer/types.h @@ -374,3 +374,35 @@ typedef struct { gfxLfbWriteMode_t writeMode; gfxOriginLocation_t origin; } gfxLfbInfo_t; + +typedef struct +{ + float x, y, z, q; + float u0, v0, u1, v1; + float coord[4]; + float w; + uint16_t flags; + + uint8_t b; // These values are arranged like this so that *(uint32_t*)(gfxVERTEX+?) is + uint8_t g; // ARGB format that glide can use. + uint8_t r; + uint8_t a; + + float f; //fog + + float vec[3]; // normal vector + + float sx, sy, sz; + float x_w, y_w, z_w, u0_w, v0_w, u1_w, v1_w, oow; + uint8_t not_zclipped; + uint8_t screen_translated; + uint8_t uv_scaled; + uint32_t uv_calculated; // like crc + uint32_t shade_mod; + uint32_t color_backup; + + float ou, ov; + + int number; // way to identify it + int scr_off, z_off; // off the screen? +} gfxVERTEX; \ No newline at end of file diff --git a/Source/Project64-video/TexBuffer.cpp b/Source/Project64-video/TexBuffer.cpp index 08c66975a..ec80ff35d 100644 --- a/Source/Project64-video/TexBuffer.cpp +++ b/Source/Project64-video/TexBuffer.cpp @@ -419,7 +419,7 @@ int CloseTextureBuffer(int draw) WriteTrace(TraceRDP, TraceDebug, "lr_x: %f, lr_y: %f, lr_u: %f, lr_v: %f", lr_x, lr_y, lr_u, lr_v); // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, 1, 1, zero, zero, zero, zero, { zero, zero, zero, zero } }, { lr_x, ul_y, 1, 1, lr_u, zero, lr_u, zero, { lr_u, zero, lr_u, zero } }, { ul_x, lr_y, 1, 1, zero, lr_v, zero, lr_v, { zero, lr_v, zero, lr_v } }, @@ -474,7 +474,7 @@ int CopyTextureBuffer(COLOR_IMAGE & fb_from, COLOR_IMAGE & fb_to) WriteTrace(TraceRDP, TraceDebug, "lr_x: %f, lr_y: %f", lr_x, lr_y); // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, 1, 1, zero, zero, zero, zero, { zero, zero, zero, zero } }, { lr_x, ul_y, 1, 1, lr_u, zero, lr_u, zero, { lr_u, zero, lr_u, zero } }, { ul_x, lr_y, 1, 1, zero, lr_v, zero, lr_v, { zero, lr_v, zero, lr_v } }, @@ -530,7 +530,7 @@ int CopyDepthBuffer() WriteTrace(TraceRDP, TraceDebug, "lr_x: %f, lr_y: %f", lr_x, lr_y); // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, 1, 1, zero, zero, zero, zero, { zero, zero, zero, zero } }, { lr_x, ul_y, 1, 1, lr_u, zero, lr_u, zero, { lr_u, zero, lr_u, zero } }, { ul_x, lr_y, 1, 1, zero, lr_v, zero, lr_v, { zero, lr_v, zero, lr_v } }, @@ -585,7 +585,7 @@ int SwapTextureBuffer() float lr_v = rdp.tbuff_tex->lr_v; // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, 1, 1, zero, zero, zero, zero, { zero, zero, zero, zero } }, { lr_x, ul_y, 1, 1, lr_u, zero, lr_u, zero, { lr_u, zero, lr_u, zero } }, { ul_x, lr_y, 1, 1, zero, lr_v, zero, lr_v, { zero, lr_v, zero, lr_v } }, diff --git a/Source/Project64-video/Util.cpp b/Source/Project64-video/Util.cpp index 99b80e14f..21c840ab8 100644 --- a/Source/Project64-video/Util.cpp +++ b/Source/Project64-video/Util.cpp @@ -27,8 +27,8 @@ #define Vj rdp.vtxbuf2[j] #define Vi rdp.vtxbuf2[i] -VERTEX *vtx_list1[32]; // vertex indexing -VERTEX *vtx_list2[32]; +gfxVERTEX *vtx_list1[32]; // vertex indexing +gfxVERTEX *vtx_list2[32]; // // util_init - initialize data for the functions in this file @@ -47,7 +47,7 @@ static uint32_t u_cull_mode = 0; //software backface culling. Gonetz // mega modifications by Dave2001 -int cull_tri(VERTEX **v) // type changed to VERTEX** [Dave2001] +int cull_tri(gfxVERTEX **v) // type changed to gfxVERTEX** [Dave2001] { int i; @@ -138,7 +138,7 @@ int cull_tri(VERTEX **v) // type changed to VERTEX** [Dave2001] return FALSE; } -void apply_shade_mods(VERTEX *v) +void apply_shade_mods(gfxVERTEX *v) { float col[4]; uint32_t mod; @@ -259,9 +259,9 @@ void apply_shade_mods(VERTEX *v) static int dzdx = 0; static int deltaZ = 0; -VERTEX **org_vtx; +gfxVERTEX **org_vtx; -void draw_tri(VERTEX **vtx, uint16_t linew) +void draw_tri(gfxVERTEX **vtx, uint16_t linew) { deltaZ = dzdx = 0; if (linew == 0 && (g_settings->fb_depth_render_enabled() || (rdp.rm & 0xC00) == 0xC00)) @@ -302,11 +302,11 @@ void draw_tri(VERTEX **vtx, uint16_t linew) for (int i = 0; i < 3; i++) { - VERTEX *v = vtx[i]; + gfxVERTEX *v = vtx[i]; if (v->uv_calculated != rdp.tex_ctr) { - WriteTrace(TraceRDP, TraceVerbose, " * CALCULATING VERTEX U/V: %d", v->number); + WriteTrace(TraceRDP, TraceVerbose, " * CALCULATING gfxVERTEX U/V: %d", v->number); v->uv_calculated = rdp.tex_ctr; if (!(rdp.geom_mode & 0x00020000)) @@ -434,7 +434,7 @@ void draw_tri(VERTEX **vtx, uint16_t linew) v->u1_w = v->u1 / v->w; v->v1_w = v->v1 / v->w; } - // WriteTrace(TraceRDP, TraceDebug, " * CALCULATING VERTEX U/V: %d u0: %f, v0: %f, u1: %f, v1: %f", v->number, v->u0, v->v0, v->u1, v->v1); + // WriteTrace(TraceRDP, TraceDebug, " * CALCULATING gfxVERTEX U/V: %d u0: %f, v0: %f, u1: %f, v1: %f", v->number, v->u0, v->v0, v->u1, v->v1); } WriteTrace(TraceRDP, TraceVerbose, "draw_tri. v[%d] ou=%f, ov = %f", i, v->ou, v->ov); if (v->shade_mod != cmb.shade_mod_hash) @@ -479,8 +479,8 @@ void draw_tri(VERTEX **vtx, uint16_t linew) j = i + 1; if (j == 3) j = 0; - VERTEX *v1 = vtx[i]; - VERTEX *v2 = vtx[j]; + gfxVERTEX *v1 = vtx[i]; + gfxVERTEX *v2 = vtx[j]; if (v1->u0 >= left_256) { @@ -549,8 +549,8 @@ void draw_tri(VERTEX **vtx, uint16_t linew) j = i + 1; if (j == rdp.n_global) j = 0; - VERTEX *v1 = &rdp.vtxbuf2[i]; - VERTEX *v2 = &rdp.vtxbuf2[j]; + gfxVERTEX *v1 = &rdp.vtxbuf2[i]; + gfxVERTEX *v2 = &rdp.vtxbuf2[j]; // ** Right plane ** if (v1->u0 <= right_256) @@ -633,7 +633,7 @@ void draw_tri(VERTEX **vtx, uint16_t linew) #define interp2p(a, b, r) (a + (b - a) * r) //* -static void InterpolateColors(VERTEX & va, VERTEX & vb, VERTEX & res, float percent) +static void InterpolateColors(gfxVERTEX & va, gfxVERTEX & vb, gfxVERTEX & res, float percent) { res.b = (uint8_t)interp2p(va.b, vb.b, percent); res.g = (uint8_t)interp2p(va.g, vb.g, percent);; @@ -650,7 +650,7 @@ static void clip_w(int interpolate_colors) int i, j, index, n = rdp.n_global; float percent; // Swap vertex buffers - VERTEX *tmp = rdp.vtxbuf2; + gfxVERTEX *tmp = rdp.vtxbuf2; rdp.vtxbuf2 = rdp.vtxbuf; rdp.vtxbuf = tmp; rdp.vtx_buffer ^= 1; @@ -811,7 +811,7 @@ __inline uint8_t real_to_char(double x) } //* -static void InterpolateColors2(VERTEX & va, VERTEX & vb, VERTEX & res, float percent) +static void InterpolateColors2(gfxVERTEX & va, gfxVERTEX & vb, gfxVERTEX & res, float percent) { float w = 1.0f / (va.oow + (vb.oow - va.oow) * percent); // res.oow = va.oow + (vb.oow-va.oow) * percent; @@ -859,7 +859,7 @@ static double EvaLine(LineEuqationType &li, double x, double y) return li.x*x + li.y*y + li.d; } -static void Create1LineEq(LineEuqationType &l, VERTEX &v1, VERTEX &v2, VERTEX &v3) +static void Create1LineEq(LineEuqationType &l, gfxVERTEX &v1, gfxVERTEX &v2, gfxVERTEX &v3) { // Line between (x1,y1) to (x2,y2) l.x = v2.sy - v1.sy; @@ -882,7 +882,7 @@ __inline double interp3p(float a, float b, float c, double r1, double r2) (a+(((b)+((c)-(b))*(r2))-(a))*(r1)) */ -static void InterpolateColors3(VERTEX &v1, VERTEX &v2, VERTEX &v3, VERTEX &out) +static void InterpolateColors3(gfxVERTEX &v1, gfxVERTEX &v2, gfxVERTEX &v3, gfxVERTEX &out) { LineEuqationType line; Create1LineEq(line, v2, v3, v1); @@ -923,7 +923,7 @@ static void InterpolateColors3(VERTEX &v1, VERTEX &v2, VERTEX &v3, VERTEX &out) */ } -static void CalculateLOD(VERTEX *v, int n) +static void CalculateLOD(gfxVERTEX *v, int n) { float deltaS, deltaT; float deltaX, deltaY; @@ -998,7 +998,7 @@ float ScaleZ(float z) return z; } -static void DepthBuffer(VERTEX * vtx, int n) +static void DepthBuffer(gfxVERTEX * vtx, int n) { if (g_settings->fb_depth_render_enabled() && !g_settings->hacks(CSettings::hack_RE2) && dzdx && (rdp.flags & ZBUF_UPDATE)) { @@ -1036,7 +1036,7 @@ void clip_tri(int interpolate_colors) if (rdp.clip & CLIP_XMAX) // right of the screen { // Swap vertex buffers - VERTEX *tmp = rdp.vtxbuf2; + gfxVERTEX *tmp = rdp.vtxbuf2; rdp.vtxbuf2 = rdp.vtxbuf; rdp.vtxbuf = tmp; rdp.vtx_buffer ^= 1; @@ -1100,7 +1100,7 @@ void clip_tri(int interpolate_colors) if (rdp.clip & CLIP_XMIN) // left of the screen { // Swap vertex buffers - VERTEX *tmp = rdp.vtxbuf2; + gfxVERTEX *tmp = rdp.vtxbuf2; rdp.vtxbuf2 = rdp.vtxbuf; rdp.vtxbuf = tmp; rdp.vtx_buffer ^= 1; @@ -1164,7 +1164,7 @@ void clip_tri(int interpolate_colors) if (rdp.clip & CLIP_YMAX) // top of the screen { // Swap vertex buffers - VERTEX *tmp = rdp.vtxbuf2; + gfxVERTEX *tmp = rdp.vtxbuf2; rdp.vtxbuf2 = rdp.vtxbuf; rdp.vtxbuf = tmp; rdp.vtx_buffer ^= 1; @@ -1228,7 +1228,7 @@ void clip_tri(int interpolate_colors) if (rdp.clip & CLIP_YMIN) // bottom of the screen { // Swap vertex buffers - VERTEX *tmp = rdp.vtxbuf2; + gfxVERTEX *tmp = rdp.vtxbuf2; rdp.vtxbuf2 = rdp.vtxbuf; rdp.vtxbuf = tmp; rdp.vtx_buffer ^= 1; @@ -1292,7 +1292,7 @@ void clip_tri(int interpolate_colors) if (rdp.clip & CLIP_ZMAX) // far plane { // Swap vertex buffers - VERTEX *tmp = rdp.vtxbuf2; + gfxVERTEX *tmp = rdp.vtxbuf2; rdp.vtxbuf2 = rdp.vtxbuf; rdp.vtxbuf = tmp; rdp.vtx_buffer ^= 1; @@ -1358,7 +1358,7 @@ void clip_tri(int interpolate_colors) if (rdp.clip & CLIP_ZMIN) // near Z { // Swap vertex buffers - VERTEX *tmp = rdp.vtxbuf2; + gfxVERTEX *tmp = rdp.vtxbuf2; rdp.vtxbuf2 = rdp.vtxbuf; rdp.vtxbuf = tmp; rdp.vtx_buffer ^= 1; @@ -1458,7 +1458,7 @@ static void render_tri(uint16_t linew, int old_interpolate) for (i = 0; i < n; i++) { float percent = 101.0f; - VERTEX * v1 = 0, *v2 = 0; + gfxVERTEX * v1 = 0, *v2 = 0; switch (rdp.vtxbuf[i].number & 7) { case 1: @@ -1550,13 +1550,13 @@ static void render_tri(uint16_t linew, int old_interpolate) { if (linew > 0) { - VERTEX *V0 = &rdp.vtxbuf[0]; - VERTEX *V1 = &rdp.vtxbuf[1]; + gfxVERTEX *V0 = &rdp.vtxbuf[0]; + gfxVERTEX *V1 = &rdp.vtxbuf[1]; if (fabs(V0->x - V1->x) < 0.01 && fabs(V0->y - V1->y) < 0.01) V1 = &rdp.vtxbuf[2]; V0->z = ScaleZ(V0->z); V1->z = ScaleZ(V1->z); - VERTEX v[4]; + gfxVERTEX v[4]; v[0] = *V0; v[1] = *V0; v[2] = *V1; diff --git a/Source/Project64-video/Util.h b/Source/Project64-video/Util.h index 27abd49f1..88c22ced0 100644 --- a/Source/Project64-video/Util.h +++ b/Source/Project64-video/Util.h @@ -19,11 +19,11 @@ void util_init(); -int cull_tri(VERTEX **v); -void draw_tri(VERTEX **v, uint16_t linew = 0); +int cull_tri(gfxVERTEX **v); +void draw_tri(gfxVERTEX **v, uint16_t linew = 0); void do_triangle_stuff(uint16_t linew = 0, int old_interpolate = TRUE); void do_triangle_stuff_2(uint16_t linew = 0); -void apply_shade_mods(VERTEX *v); +void apply_shade_mods(gfxVERTEX *v); void update(); void update_scissor(); diff --git a/Source/Project64-video/rdp.cpp b/Source/Project64-video/rdp.cpp index 052fd28e8..3d849cc95 100644 --- a/Source/Project64-video/rdp.cpp +++ b/Source/Project64-video/rdp.cpp @@ -167,20 +167,20 @@ bool CRDP::init() return true; } - vtx1 = new VERTEX[256]; + vtx1 = new gfxVERTEX[256]; if (vtx1 == NULL) { free(); return false; } - memset(vtx1, 0, sizeof(VERTEX) * 256); - vtx2 = new VERTEX[256]; + memset(vtx1, 0, sizeof(gfxVERTEX) * 256); + vtx2 = new gfxVERTEX[256]; if (vtx2 == NULL) { free(); return false; } - memset(vtx2, 0, sizeof(VERTEX) * 256); + memset(vtx2, 0, sizeof(gfxVERTEX) * 256); for (int i = 0; i < MAX_TMU; i++) { @@ -191,13 +191,13 @@ bool CRDP::init() return false; } }; - m_vtx = new VERTEX[MAX_VTX]; + m_vtx = new gfxVERTEX[MAX_VTX]; if (m_vtx == NULL) { free(); return false; } - memset(m_vtx, 0, sizeof(VERTEX)*MAX_VTX); + memset(m_vtx, 0, sizeof(gfxVERTEX)*MAX_VTX); // set all vertex numbers for (int i = 0; i < MAX_VTX; i++) { @@ -1422,7 +1422,7 @@ void rdp_texrect() WriteTrace(TraceRDP, TraceDebug, " draw at: (%f, %f) -> (%f, %f)", s_ul_x, s_ul_y, s_lr_x, s_lr_y); - VERTEX vstd[4] = { + gfxVERTEX vstd[4] = { { s_ul_x, s_ul_y, Z, 1.0f, texUV[0].ul_u, texUV[0].ul_v, texUV[1].ul_u, texUV[1].ul_v, { 0, 0, 0, 0 }, 255 }, { s_lr_x, s_ul_y, Z, 1.0f, texUV[0].lr_u, texUV[0].ul_v, texUV[1].lr_u, texUV[1].ul_v, { 0, 0, 0, 0 }, 255 }, { s_ul_x, s_lr_y, Z, 1.0f, texUV[0].ul_u, texUV[0].lr_v, texUV[1].ul_u, texUV[1].lr_v, { 0, 0, 0, 0 }, 255 }, @@ -1441,10 +1441,10 @@ void rdp_texrect() vstd[2].v1 = texUV[1].ul_v; } - VERTEX *vptr = vstd; + gfxVERTEX *vptr = vstd; int n_vertices = 4; - VERTEX *vnew = 0; + gfxVERTEX *vnew = 0; // for (int j =0; j < 4; j++) // WriteTrace(TraceRDP, TraceDebug, "v[%d] u0: %f, v0: %f, u1: %f, v1: %f", j, vstd[j].u0, vstd[j].v0, vstd[j].u1, vstd[j].v1); @@ -1477,7 +1477,7 @@ void rdp_texrect() int num_verts_line = 2 + ((end_u_256 - start_u_256) << 1); n_vertices = num_verts_line << 1; - vnew = new VERTEX[n_vertices]; + vnew = new gfxVERTEX[n_vertices]; vptr = vnew; vnew[0] = vstd[0]; @@ -1586,7 +1586,7 @@ void rdp_texrect() } else { - gfxDrawVertexArrayContiguous(GFX_TRIANGLE_STRIP, n_vertices, vptr, sizeof(VERTEX)); + gfxDrawVertexArrayContiguous(GFX_TRIANGLE_STRIP, n_vertices, vptr, sizeof(gfxVERTEX)); } rdp.tri_n += 2; @@ -2476,7 +2476,7 @@ void rdp_fillrect() const float Z = (rdp.cycle_mode == 3) ? 0.0f : set_sprite_combine_mode(); // Draw the rectangle - VERTEX v[4] = { + gfxVERTEX v[4] = { { (float)s_ul_x, (float)s_ul_y, Z, 1.0f, 0, 0, 0, 0, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0 }, { (float)s_lr_x, (float)s_ul_y, Z, 1.0f, 0, 0, 0, 0, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0 }, { (float)s_ul_x, (float)s_lr_y, Z, 1.0f, 0, 0, 0, 0, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0 }, @@ -3707,8 +3707,8 @@ void lle_triangle(uint32_t w1, uint32_t w2, int shade, int texture, int zbuffer, #define TSCALE(s, w) (rdp.Persp_en? float(PERSP(s, w))/(1 << 10) : float(s)/(1<<21)) int nbVtxs = 0; - VERTEX vtxbuf[12]; - VERTEX * vtx = &vtxbuf[nbVtxs++]; + gfxVERTEX vtxbuf[12]; + gfxVERTEX * vtx = &vtxbuf[nbVtxs++]; xleft = xm; xright = xh; @@ -3889,7 +3889,7 @@ void lle_triangle(uint32_t w1, uint32_t w2, int shade, int texture, int zbuffer, update(); for (int k = 0; k < nbVtxs - 1; k++) { - VERTEX * v = &vtxbuf[k]; + gfxVERTEX * v = &vtxbuf[k]; v->x = v->x * rdp.scale_x + rdp.offset_x; v->y = v->y * rdp.scale_y + rdp.offset_y; // v->z = 1.0f;///v->w; @@ -3949,7 +3949,7 @@ void lle_triangle(uint32_t w1, uint32_t w2, int shade, int texture, int zbuffer, } ConvertCoordsConvert(vtxbuf, nbVtxs); gfxCullMode(GFX_CULL_DISABLE); - gfxDrawVertexArrayContiguous(GFX_TRIANGLE_STRIP, nbVtxs - 1, vtxbuf, sizeof(VERTEX)); + gfxDrawVertexArrayContiguous(GFX_TRIANGLE_STRIP, nbVtxs - 1, vtxbuf, sizeof(gfxVERTEX)); } void rdp_triangle(int shade, int texture, int zbuffer) diff --git a/Source/Project64-video/rdp.h b/Source/Project64-video/rdp.h index d3a3b4088..a8fa1ff7f 100644 --- a/Source/Project64-video/rdp.h +++ b/Source/Project64-video/rdp.h @@ -99,39 +99,6 @@ const unsigned int maxCMDMask = MAXCMD - 1; #define DECLAREALIGN16VAR(var) float (var) __attribute__ ((aligned(16))) #endif -// Vertex structure -typedef struct -{ - float x, y, z, q; - float u0, v0, u1, v1; - float coord[4]; - float w; - uint16_t flags; - - uint8_t b; // These values are arranged like this so that *(uint32_t*)(VERTEX+?) is - uint8_t g; // ARGB format that glide can use. - uint8_t r; - uint8_t a; - - float f; //fog - - float vec[3]; // normal vector - - float sx, sy, sz; - float x_w, y_w, z_w, u0_w, v0_w, u1_w, v1_w, oow; - uint8_t not_zclipped; - uint8_t screen_translated; - uint8_t uv_scaled; - uint32_t uv_calculated; // like crc - uint32_t shade_mod; - uint32_t color_backup; - - float ou, ov; - - int number; // way to identify it - int scr_off, z_off; // off the screen? -} VERTEX; - // Clipping (scissors) typedef struct { @@ -358,14 +325,14 @@ public: bool init(); void free(); - inline VERTEX & vtx(int index) const { return m_vtx[index]; } + inline gfxVERTEX & vtx(int index) const { return m_vtx[index]; } inline TILE & tiles(int index) { return m_tiles[index]; } // Clipping int clip; // clipping flags - VERTEX *vtx1; //[256] copy vertex buffer #1 (used for clipping) - VERTEX *vtx2; //[256] copy vertex buffer #2 - VERTEX *vtxbuf; // current vertex buffer (reset to vtx, used to determine current vertex buffer) - VERTEX *vtxbuf2; + gfxVERTEX *vtx1; //[256] copy vertex buffer #1 (used for clipping) + gfxVERTEX *vtx2; //[256] copy vertex buffer #2 + gfxVERTEX *vtxbuf; // current vertex buffer (reset to vtx, used to determine current vertex buffer) + gfxVERTEX *vtxbuf2; int n_global; // Used to pass the number of vertices from clip_z to clip_tri int vtx_buffer; @@ -376,7 +343,7 @@ public: // Vertices private: - VERTEX * m_vtx; //[MAX_VTX] + gfxVERTEX * m_vtx; //[MAX_VTX] public: int v0, vn; @@ -645,7 +612,7 @@ extern const char *CIStatus[]; #endif // Convert from u0/v0/u1/v1 to the real coordinates without regard to tmu -__inline void ConvertCoordsKeep(VERTEX *v, int n) +__inline void ConvertCoordsKeep(gfxVERTEX *v, int n) { for (int i = 0; i < n; i++) { @@ -657,7 +624,7 @@ __inline void ConvertCoordsKeep(VERTEX *v, int n) } // Convert from u0/v0/u1/v1 to the real coordinates based on the tmu they are on -__inline void ConvertCoordsConvert(VERTEX *v, int n) +__inline void ConvertCoordsConvert(gfxVERTEX *v, int n) { for (int i = 0; i < n; i++) { @@ -668,7 +635,7 @@ __inline void ConvertCoordsConvert(VERTEX *v, int n) } } -__inline void AllowShadeMods(VERTEX *v, int n) +__inline void AllowShadeMods(gfxVERTEX *v, int n) { for (int i = 0; i < n; i++) { @@ -676,7 +643,7 @@ __inline void AllowShadeMods(VERTEX *v, int n) } } -__inline void AddOffset(VERTEX *v, int n) +__inline void AddOffset(gfxVERTEX *v, int n) { for (int i = 0; i < n; i++) { @@ -685,7 +652,7 @@ __inline void AddOffset(VERTEX *v, int n) } } -__inline void CalculateFog(VERTEX &v) +__inline void CalculateFog(gfxVERTEX &v) { if (rdp.flags & FOG_ENABLED) { diff --git a/Source/Project64-video/turbo3D.cpp b/Source/Project64-video/turbo3D.cpp index a6226cd99..4db613453 100644 --- a/Source/Project64-video/turbo3D.cpp +++ b/Source/Project64-video/turbo3D.cpp @@ -121,7 +121,7 @@ static void t3d_vertex(uint32_t addr, uint32_t v0, uint32_t n) for (uint32_t i = 0; i < n; i += 16) { - VERTEX &v = rdp.vtx(v0 + (i >> 4)); + gfxVERTEX &v = rdp.vtx(v0 + (i >> 4)); x = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 0) ^ 1]; y = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 1) ^ 1]; z = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 2) ^ 1]; @@ -206,7 +206,7 @@ static void t3dLoadObject(uint32_t pstate, uint32_t pvtx, uint32_t ptri) t3dTriN * tri = (t3dTriN*)&gfx.RDRAM[a]; a += 4; WriteTrace(TraceRDP, TraceDebug, "tri #%d - %d, %d, %d", t, tri->v0, tri->v1, tri->v2); - VERTEX *vtx[3] = { &rdp.vtx(tri->v0), &rdp.vtx(tri->v1), &rdp.vtx(tri->v2) }; + gfxVERTEX *vtx[3] = { &rdp.vtx(tri->v0), &rdp.vtx(tri->v1), &rdp.vtx(tri->v2) }; if (cull_tri(vtx)) rdp.tri_n++; else diff --git a/Source/Project64-video/ucode00.cpp b/Source/Project64-video/ucode00.cpp index b1632690a..c9e9c4d8f 100644 --- a/Source/Project64-video/ucode00.cpp +++ b/Source/Project64-video/ucode00.cpp @@ -54,7 +54,7 @@ void rsp_vertex(int v0, int n) for (i = 0; i < (n << 4); i += 16) { - VERTEX &v = rdp.vtx(v0 + (i >> 4)); + gfxVERTEX &v = rdp.vtx(v0 + (i >> 4)); x = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 0) ^ 1]; y = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 1) ^ 1]; z = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 2) ^ 1]; @@ -114,7 +114,7 @@ void rsp_vertex(int v0, int n) } } -void rsp_tri1(VERTEX **v, uint16_t linew = 0) +void rsp_tri1(gfxVERTEX **v, uint16_t linew = 0) { if (cull_tri(v)) rdp.tri_n++; @@ -126,7 +126,7 @@ void rsp_tri1(VERTEX **v, uint16_t linew = 0) } } -void rsp_tri2(VERTEX **v) +void rsp_tri2(gfxVERTEX **v) { int updated = 0; @@ -500,7 +500,7 @@ void uc0_tri1() ((rdp.cmd1 >> 8) & 0xFF) / 10, (rdp.cmd1 & 0xFF) / 10); - VERTEX *vtx[3] = { + gfxVERTEX *vtx[3] = { &rdp.vtx(((rdp.cmd1 >> 16) & 0xFF) / 10), &rdp.vtx(((rdp.cmd1 >> 8) & 0xFF) / 10), &rdp.vtx((rdp.cmd1 & 0xFF) / 10) @@ -549,7 +549,7 @@ void uc0_culldl() if (vEnd < vStart) return; for (uint16_t i = vStart; i <= vEnd; i++) { - VERTEX &v = rdp.vtx(i); + gfxVERTEX &v = rdp.vtx(i); // Check if completely off the screen (quick frustrum clipping for 90 FOV) if (v.x >= -v.w) cond |= 0x01; @@ -594,7 +594,7 @@ void uc6_obj_sprite(); void uc0_modifyvtx(uint8_t where, uint16_t vtx, uint32_t val) { - VERTEX &v = rdp.vtx(vtx); + gfxVERTEX &v = rdp.vtx(vtx); switch (where) { @@ -1001,7 +1001,7 @@ void uc0_line3d() uint32_t v1 = ((rdp.cmd1 >> 8) & 0xff) / 10; uint16_t width = (uint16_t)(rdp.cmd1 & 0xFF) + 3; - VERTEX *vtx[3] = { + gfxVERTEX *vtx[3] = { &rdp.vtx(v1), &rdp.vtx(v0), &rdp.vtx(v0) @@ -1037,7 +1037,7 @@ void uc0_tri4() (rdp.cmd0 >> 0) & 0xF, (rdp.cmd1 >> 0) & 0xF); - VERTEX *vtx[12] = { + gfxVERTEX *vtx[12] = { &rdp.vtx((rdp.cmd1 >> 28) & 0xF), &rdp.vtx((rdp.cmd0 >> 12) & 0xF), &rdp.vtx((rdp.cmd1 >> 24) & 0xF), diff --git a/Source/Project64-video/ucode00.h b/Source/Project64-video/ucode00.h index f0cc46e27..ac25f7da2 100644 --- a/Source/Project64-video/ucode00.h +++ b/Source/Project64-video/ucode00.h @@ -40,8 +40,8 @@ void modelview_load_push(float m[4][4]); void projection_load(float m[4][4]); void projection_mul(float m[4][4]); -void rsp_tri1(VERTEX **v, uint16_t linew = 0); -void rsp_tri2(VERTEX **v); +void rsp_tri1(gfxVERTEX **v, uint16_t linew = 0); +void rsp_tri2(gfxVERTEX **v); void rsp_vertex(int v0, int n); void load_matrix(float m[4][4], uint32_t addr); \ No newline at end of file diff --git a/Source/Project64-video/ucode01.cpp b/Source/Project64-video/ucode01.cpp index 7175bb529..bd406ece8 100644 --- a/Source/Project64-video/ucode01.cpp +++ b/Source/Project64-video/ucode01.cpp @@ -45,7 +45,7 @@ void uc1_tri1() ((rdp.cmd1 >> 9) & 0x7F), ((rdp.cmd1 >> 1) & 0x7F), rdp.cmd0, rdp.cmd1); - VERTEX *vtx[3] = { + gfxVERTEX *vtx[3] = { &rdp.vtx((rdp.cmd1 >> 17) & 0x7F), &rdp.vtx((rdp.cmd1 >> 9) & 0x7F), &rdp.vtx((rdp.cmd1 >> 1) & 0x7F) @@ -71,7 +71,7 @@ void uc1_tri2() ((rdp.cmd1 >> 9) & 0x7F), ((rdp.cmd1 >> 1) & 0x7F)); - VERTEX *vtx[6] = { + gfxVERTEX *vtx[6] = { &rdp.vtx((rdp.cmd0 >> 17) & 0x7F), &rdp.vtx((rdp.cmd0 >> 9) & 0x7F), &rdp.vtx((rdp.cmd0 >> 1) & 0x7F), @@ -93,7 +93,7 @@ void uc1_line3d() (rdp.cmd1 >> 17) & 0x7F, (rdp.cmd1 >> 9) & 0x7F); - VERTEX *vtx[3] = { + gfxVERTEX *vtx[3] = { &rdp.vtx((rdp.cmd1 >> 17) & 0x7F), &rdp.vtx((rdp.cmd1 >> 9) & 0x7F), &rdp.vtx((rdp.cmd1 >> 9) & 0x7F) @@ -110,7 +110,7 @@ void uc1_line3d() { WriteTrace(TraceRDP, TraceDebug, "uc1:quad3d #%d, #%d", rdp.tri_n, rdp.tri_n + 1); - VERTEX *vtx[6] = { + gfxVERTEX *vtx[6] = { &rdp.vtx((rdp.cmd1 >> 25) & 0x7F), &rdp.vtx((rdp.cmd1 >> 17) & 0x7F), &rdp.vtx((rdp.cmd1 >> 9) & 0x7F), diff --git a/Source/Project64-video/ucode02.cpp b/Source/Project64-video/ucode02.cpp index ae8c93df8..9b7872a4f 100644 --- a/Source/Project64-video/ucode02.cpp +++ b/Source/Project64-video/ucode02.cpp @@ -19,7 +19,7 @@ #include "3dmath.h" #include "ucode00.h" -static void calc_point_light(VERTEX & v, float * vpos) +static void calc_point_light(gfxVERTEX & v, float * vpos) { float light_intensity = 0.0f; register float color[3] = { rdp.light[rdp.num_lights].r, rdp.light[rdp.num_lights].g, rdp.light[rdp.num_lights].b }; @@ -112,7 +112,7 @@ void uc2_vertex() } for (i = 0; i < (n << 4); i += 16) { - VERTEX & v = rdp.vtx(v0 + (i >> 4)); + gfxVERTEX & v = rdp.vtx(v0 + (i >> 4)); x = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 0) ^ 1]; y = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 1) ^ 1]; z = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 2) ^ 1]; @@ -209,7 +209,7 @@ void uc2_culldl() if (vEnd < vStart) return; for (uint16_t i = vStart; i <= vEnd; i++) { - VERTEX & v = rdp.vtx(i); + gfxVERTEX & v = rdp.vtx(i); /* // Check if completely off the screen (quick frustrum clipping for 90 FOV) if (v.x >= -v.w) @@ -260,7 +260,7 @@ void uc2_tri1() ((rdp.cmd0 >> 9) & 0x7F), ((rdp.cmd0 >> 1) & 0x7F)); - VERTEX *vtx[3] = { + gfxVERTEX *vtx[3] = { &rdp.vtx((rdp.cmd0 >> 17) & 0x7F), &rdp.vtx((rdp.cmd0 >> 9) & 0x7F), &rdp.vtx((rdp.cmd0 >> 1) & 0x7F) @@ -305,7 +305,7 @@ void uc2_quad() ((rdp.cmd1 >> 9) & 0x7F), ((rdp.cmd1 >> 1) & 0x7F)); - VERTEX *vtx[6] = + gfxVERTEX *vtx[6] = { &rdp.vtx((rdp.cmd0 >> 17) & 0x7F), &rdp.vtx((rdp.cmd0 >> 9) & 0x7F), @@ -330,7 +330,7 @@ void uc2_line3d() (rdp.cmd0 >> 17) & 0x7F, (rdp.cmd0 >> 9) & 0x7F); - VERTEX *vtx[3] = + gfxVERTEX *vtx[3] = { &rdp.vtx((rdp.cmd0 >> 17) & 0x7F), &rdp.vtx((rdp.cmd0 >> 9) & 0x7F), diff --git a/Source/Project64-video/ucode03.cpp b/Source/Project64-video/ucode03.cpp index 5af0f1af0..0a8f71184 100644 --- a/Source/Project64-video/ucode03.cpp +++ b/Source/Project64-video/ucode03.cpp @@ -46,7 +46,7 @@ void uc3_tri1() ((rdp.cmd1 >> 8) & 0xFF) / 5, ((rdp.cmd1) & 0xFF) / 5, rdp.cmd0, rdp.cmd1); - VERTEX *vtx[3] = { + gfxVERTEX *vtx[3] = { &rdp.vtx(((rdp.cmd1 >> 16) & 0xFF) / 5), &rdp.vtx(((rdp.cmd1 >> 8) & 0xFF) / 5), &rdp.vtx((rdp.cmd1 & 0xFF) / 5) @@ -65,7 +65,7 @@ void uc3_tri2() ((rdp.cmd1 >> 8) & 0xFF) / 5, ((rdp.cmd1) & 0xFF) / 5); - VERTEX *vtx[6] = { + gfxVERTEX *vtx[6] = { &rdp.vtx(((rdp.cmd0 >> 16) & 0xFF) / 5), &rdp.vtx(((rdp.cmd0 >> 8) & 0xFF) / 5), &rdp.vtx((rdp.cmd0 & 0xFF) / 5), @@ -81,7 +81,7 @@ void uc3_quad3d() { WriteTrace(TraceRDP, TraceDebug, "uc3:quad3d #%d, #%d", rdp.tri_n, rdp.tri_n + 1); - VERTEX *vtx[6] = { + gfxVERTEX *vtx[6] = { &rdp.vtx(((rdp.cmd1 >> 24) & 0xFF) / 5), &rdp.vtx(((rdp.cmd1 >> 16) & 0xFF) / 5), &rdp.vtx(((rdp.cmd1 >> 8) & 0xFF) / 5), diff --git a/Source/Project64-video/ucode04.cpp b/Source/Project64-video/ucode04.cpp index 095ba861a..8d4a2ab9f 100644 --- a/Source/Project64-video/ucode04.cpp +++ b/Source/Project64-video/ucode04.cpp @@ -36,7 +36,7 @@ void uc4_tri1() WriteTrace(TraceRDP, TraceDebug, "uc4:tri1 #%d - %d, %d, %d", rdp.tri_n, v1, v2, v3); - VERTEX *vtx[3] = { + gfxVERTEX *vtx[3] = { &rdp.vtx(v1), &rdp.vtx(v2), &rdp.vtx(v3) @@ -49,7 +49,7 @@ void uc4_quad3d() { WriteTrace(TraceRDP, TraceDebug, "uc4:quad3d #%d, #%d", rdp.tri_n, rdp.tri_n + 1); - VERTEX *vtx[6] = { + gfxVERTEX *vtx[6] = { &rdp.vtx(((rdp.cmd1 >> 24) & 0xFF) / 5), &rdp.vtx(((rdp.cmd1 >> 16) & 0xFF) / 5), &rdp.vtx(((rdp.cmd1 >> 8) & 0xFF) / 5), diff --git a/Source/Project64-video/ucode05.cpp b/Source/Project64-video/ucode05.cpp index bc05f70b7..af379a7e0 100644 --- a/Source/Project64-video/ucode05.cpp +++ b/Source/Project64-video/ucode05.cpp @@ -119,7 +119,7 @@ void uc5_vertex() for (int i = first; i < first + n; i++) { start = (i - first) * 10; - VERTEX &v = rdp.vtx(i); + gfxVERTEX &v = rdp.vtx(i); x = (float)((short*)gfx.RDRAM)[(((addr + start) >> 1) + 0) ^ 1]; y = (float)((short*)gfx.RDRAM)[(((addr + start) >> 1) + 1) ^ 1]; z = (float)((short*)gfx.RDRAM)[(((addr + start) >> 1) + 2) ^ 1]; @@ -194,7 +194,7 @@ void uc5_tridma() WriteTrace(TraceRDP, TraceDebug, "tri #%d - %d, %d, %d", rdp.tri_n, v0, v1, v2); - VERTEX *vtx[3] = { + gfxVERTEX *vtx[3] = { &rdp.vtx(v0), &rdp.vtx(v1), &rdp.vtx(v2) diff --git a/Source/Project64-video/ucode06.cpp b/Source/Project64-video/ucode06.cpp index ead773519..368c84dae 100644 --- a/Source/Project64-video/ucode06.cpp +++ b/Source/Project64-video/ucode06.cpp @@ -152,7 +152,7 @@ void DrawHiresDepthImage(const DRAWIMAGE & d) float lr_y = (float)d.imageH * rdp.scale_y; float lr_u = (float)d.imageW * 0.5f;// - 0.5f; float lr_v = (float)d.imageH * 0.5f;// - 0.5f; - VERTEX v[4] = { + gfxVERTEX v[4] = { { 0, 0, 1.0f, 1.0f, 0, 0, 0, 0 }, { lr_x, 0, 1.0f, 1.0f, lr_u, 0, lr_u, 0 }, { 0, lr_y, 1.0f, 1.0f, 0, lr_v, 0, lr_v }, @@ -464,7 +464,7 @@ void DrawImage(DRAWIMAGE & d) if ((flr_x <= rdp.scissor.lr_x) || (ful_x < rdp.scissor.lr_x)) { - VERTEX v[4] = { + gfxVERTEX v[4] = { { ful_x, ful_y, Z, 1.0f, ful_u, ful_v }, { flr_x, ful_y, Z, 1.0f, flr_u, ful_v }, { ful_x, flr_y, Z, 1.0f, ful_u, flr_v }, @@ -474,7 +474,7 @@ void DrawImage(DRAWIMAGE & d) apply_shade_mods(&(v[s])); ConvertCoordsConvert(v, 4); - gfxDrawVertexArrayContiguous(GFX_TRIANGLE_STRIP, 4, v, sizeof(VERTEX)); + gfxDrawVertexArrayContiguous(GFX_TRIANGLE_STRIP, 4, v, sizeof(gfxVERTEX)); rdp.tri_n += 2; } else @@ -576,7 +576,7 @@ void DrawHiresImage(DRAWIMAGE & d, int screensize) if (lr_y > rdp.scissor.lr_y) lr_y = (float)rdp.scissor.lr_y; } // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, Z, 1.0f, ul_u, ul_v, ul_u, ul_v }, { lr_x, ul_y, Z, 1.0f, lr_u, ul_v, lr_u, ul_v }, { ul_x, lr_y, Z, 1.0f, ul_u, lr_v, ul_u, lr_v }, @@ -687,7 +687,7 @@ void uc6_bg_copy() uc6_bg(false); } -static void draw_split_triangle(VERTEX **vtx) +static void draw_split_triangle(gfxVERTEX **vtx) { vtx[0]->not_zclipped = vtx[1]->not_zclipped = vtx[2]->not_zclipped = 1; @@ -718,8 +718,8 @@ static void draw_split_triangle(VERTEX **vtx) j = i + 1; if (j == 3) j = 0; - VERTEX *v1 = vtx[i]; - VERTEX *v2 = vtx[j]; + gfxVERTEX *v1 = vtx[i]; + gfxVERTEX *v2 = vtx[j]; if (v1->u0 >= left_256) { @@ -782,8 +782,8 @@ static void draw_split_triangle(VERTEX **vtx) j = i + 1; if (j == rdp.n_global) j = 0; - VERTEX *v1 = &rdp.vtxbuf2[i]; - VERTEX *v2 = &rdp.vtxbuf2[j]; + gfxVERTEX *v1 = &rdp.vtxbuf2[i]; + gfxVERTEX *v2 = &rdp.vtxbuf2[j]; // ** Right plane ** if (v1->u0 <= 256.0f) @@ -835,7 +835,7 @@ static void draw_split_triangle(VERTEX **vtx) } } -static void uc6_draw_polygons(VERTEX v[4]) +static void uc6_draw_polygons(gfxVERTEX v[4]) { AllowShadeMods(v, 4); for (int s = 0; s < 4; s++) @@ -845,7 +845,7 @@ static void uc6_draw_polygons(VERTEX v[4]) // Set vertex buffers if (rdp.cur_cache[0] && rdp.cur_cache[0]->splits > 1) { - VERTEX *vptr[3]; + gfxVERTEX *vptr[3]; int i; for (i = 0; i < 3; i++) vptr[i] = &v[i]; @@ -863,7 +863,7 @@ static void uc6_draw_polygons(VERTEX v[4]) rdp.vtxbuf2 = rdp.vtx2; rdp.vtx_buffer = 0; rdp.n_global = 3; - memcpy(rdp.vtxbuf, v, sizeof(VERTEX) * 3); + memcpy(rdp.vtxbuf, v, sizeof(gfxVERTEX) * 3); do_triangle_stuff_2(); rdp.tri_n++; @@ -871,7 +871,7 @@ static void uc6_draw_polygons(VERTEX v[4]) rdp.vtxbuf2 = rdp.vtx2; rdp.vtx_buffer = 0; rdp.n_global = 3; - memcpy(rdp.vtxbuf, v + 1, sizeof(VERTEX) * 3); + memcpy(rdp.vtxbuf, v + 1, sizeof(gfxVERTEX) * 3); do_triangle_stuff_2(); rdp.tri_n++; } @@ -991,7 +991,7 @@ void uc6_obj_rectangle() ul_v = 0.5f; // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, Z, 1, ul_u, ul_v }, { lr_x, ul_y, Z, 1, lr_u, ul_v }, { ul_x, lr_y, Z, 1, ul_u, lr_v }, @@ -1050,7 +1050,7 @@ void uc6_obj_sprite() // Make the vertices // WriteTrace(TraceRDP, TraceDebug, "scale_x: %f, scale_y: %f", rdp.cur_cache[0]->scale_x, rdp.cur_cache[0]->scale_y); - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, Z, 1, ul_u, ul_v }, { lr_x, ul_y, Z, 1, lr_u, ul_v }, { ul_x, lr_y, Z, 1, ul_u, lr_v }, @@ -1221,7 +1221,7 @@ void uc6_obj_rectangle_r() ul_v = 0.5f; // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, Z, 1, ul_u, ul_v }, { lr_x, ul_y, Z, 1, lr_u, ul_v }, { ul_x, lr_y, Z, 1, ul_u, lr_v }, @@ -1533,7 +1533,7 @@ void uc6_sprite2d() } // Make the vertices - VERTEX v[4] = { + gfxVERTEX v[4] = { { ul_x, ul_y, Z, 1, 0.5f, 0.5f }, { lr_x, ul_y, Z, 1, lr_u, 0.5f }, { ul_x, lr_y, Z, 1, 0.5f, lr_v }, @@ -1554,7 +1554,7 @@ void uc6_sprite2d() // Set vertex buffers if (rdp.cur_cache[0]->splits > 1) { - VERTEX *vptr[3]; + gfxVERTEX *vptr[3]; int i; for (i = 0; i < 3; i++) vptr[i] = &v[i]; @@ -1572,7 +1572,7 @@ void uc6_sprite2d() rdp.vtxbuf2 = rdp.vtx2; rdp.vtx_buffer = 0; rdp.n_global = 3; - memcpy(rdp.vtxbuf, v, sizeof(VERTEX) * 3); + memcpy(rdp.vtxbuf, v, sizeof(gfxVERTEX) * 3); do_triangle_stuff_2(); rdp.tri_n++; @@ -1580,7 +1580,7 @@ void uc6_sprite2d() rdp.vtxbuf2 = rdp.vtx2; rdp.vtx_buffer = 0; rdp.n_global = 3; - memcpy(rdp.vtxbuf, v + 1, sizeof(VERTEX) * 3); + memcpy(rdp.vtxbuf, v + 1, sizeof(gfxVERTEX) * 3); do_triangle_stuff_2(); rdp.tri_n++; } diff --git a/Source/Project64-video/ucode07.cpp b/Source/Project64-video/ucode07.cpp index 223314c9f..99be60722 100644 --- a/Source/Project64-video/ucode07.cpp +++ b/Source/Project64-video/ucode07.cpp @@ -72,7 +72,7 @@ void uc7_vertex() for (i = 0; i < n; i++) { - VERTEX &v = rdp.vtx(v0 + i); + gfxVERTEX &v = rdp.vtx(v0 + i); x = (float)vertex->x; y = (float)vertex->y; z = (float)vertex->z; diff --git a/Source/Project64-video/ucode08.cpp b/Source/Project64-video/ucode08.cpp index dddee2ffb..9ff6b4bfb 100644 --- a/Source/Project64-video/ucode08.cpp +++ b/Source/Project64-video/ucode08.cpp @@ -61,7 +61,7 @@ void uc8_vertex() //*/ for (i = 0; i < (n << 4); i += 16) { - VERTEX & v = rdp.vtx(v0 + (i >> 4)); + gfxVERTEX & v = rdp.vtx(v0 + (i >> 4)); x = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 0) ^ 1]; y = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 1) ^ 1]; z = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 2) ^ 1]; @@ -424,7 +424,7 @@ void uc8_tri4() //by Gugaman Apr 19 2002 ((rdp.cmd1 >> 5) & 0x1F), ((rdp.cmd1 >> 0) & 0x1F)); - VERTEX *v[12] = { + gfxVERTEX *v[12] = { &rdp.vtx((rdp.cmd0 >> 23) & 0x1F), &rdp.vtx((rdp.cmd0 >> 18) & 0x1F), &rdp.vtx(((((rdp.cmd0 >> 15) & 0x7) << 2) | ((rdp.cmd1 >> 30) & 0x3))), diff --git a/Source/Project64-video/ucode09.cpp b/Source/Project64-video/ucode09.cpp index acd1e53ec..7244927da 100644 --- a/Source/Project64-video/ucode09.cpp +++ b/Source/Project64-video/ucode09.cpp @@ -109,10 +109,10 @@ static void uc9_draw_object(uint8_t * addr, uint32_t type) textured = vnum = vsize = 0; break; } - VERTEX vtx[4]; + gfxVERTEX vtx[4]; for (uint32_t i = 0; i < vnum; i++) { - VERTEX &v = vtx[i]; + gfxVERTEX &v = vtx[i]; v.sx = zSortRdp.scale_x * ((short*)addr)[0 ^ 1]; v.sy = zSortRdp.scale_y * ((short*)addr)[1 ^ 1]; v.sz = 1.0f; @@ -142,7 +142,7 @@ static void uc9_draw_object(uint8_t * addr, uint32_t type) addr += vsize; } //* - VERTEX *pV[4] = { + gfxVERTEX *pV[4] = { &vtx[0], &vtx[1], &vtx[2], @@ -310,7 +310,7 @@ void uc9_light() int use_material = (csrs != 0x0ff0); tdest >>= 1; WriteTrace(TraceRDP, TraceDebug, "uc9:light n: %d, colsrs: %04lx, normales: %04lx, coldst: %04lx, texdst: %04lx", num, csrs, nsrs, cdest, tdest); - VERTEX v; + gfxVERTEX v; for (uint32_t i = 0; i < num; i++) { v.vec[0] = ((char*)gfx.DMEM)[(nsrs++) ^ 3];