2 * Glide64 - Glide video plugin for Nintendo 64 emulators.
3 * Copyright (c) 2002 Dave2001
4 * Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //****************************************************************
23 // Glide64 - Glide Plugin for Nintendo 64 emulators
24 // Project started on December 29th, 2001
27 // Dave2001, original author, founded the project in 2001, left it in 2002
28 // Gugaman, joined the project in 2002, left it in 2002
29 // Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
30 // Hiroshi 'KoolSmoky' Morii, joined the project in 2007
32 //****************************************************************
35 // * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
36 // * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
38 //****************************************************************
41 // vertex - loads vertices
44 static void uc1_vertex()
48 int v0 = (rdp.cmd0 >> 17) & 0x7F; // Current vertex
49 int n = (rdp.cmd0 >> 10) & 0x3F; // Number to copy
54 // tri1 - renders a triangle
57 static void uc1_tri1()
63 LRDP("uc1:tri1. skipped\n");
66 FRDP("uc1:tri1 #%d - %d, %d, %d - %08lx - %08lx\n", rdp.tri_n,
67 ((rdp.cmd1 >> 17) & 0x7F),
68 ((rdp.cmd1 >> 9) & 0x7F),
69 ((rdp.cmd1 >> 1) & 0x7F), rdp.cmd0, rdp.cmd1);
72 &rdp.vtx[(rdp.cmd1 >> 17) & 0x7F],
73 &rdp.vtx[(rdp.cmd1 >> 9) & 0x7F],
74 &rdp.vtx[(rdp.cmd1 >> 1) & 0x7F]
80 static void uc1_tri2 ()
86 LRDP("uc1:tri2. skipped\n");
91 FRDP(" #%d, #%d - %d, %d, %d - %d, %d, %d\n", rdp.tri_n, rdp.tri_n+1,
92 ((rdp.cmd0 >> 17) & 0x7F),
93 ((rdp.cmd0 >> 9) & 0x7F),
94 ((rdp.cmd0 >> 1) & 0x7F),
95 ((rdp.cmd1 >> 17) & 0x7F),
96 ((rdp.cmd1 >> 9) & 0x7F),
97 ((rdp.cmd1 >> 1) & 0x7F));
100 &rdp.vtx[(rdp.cmd0 >> 17) & 0x7F],
101 &rdp.vtx[(rdp.cmd0 >> 9) & 0x7F],
102 &rdp.vtx[(rdp.cmd0 >> 1) & 0x7F],
103 &rdp.vtx[(rdp.cmd1 >> 17) & 0x7F],
104 &rdp.vtx[(rdp.cmd1 >> 9) & 0x7F],
105 &rdp.vtx[(rdp.cmd1 >> 1) & 0x7F]
111 static void uc1_line3d()
115 if (!settings.force_quad3d && ((rdp.cmd1&0xFF000000) == 0) && ((rdp.cmd0&0x00FFFFFF) == 0))
117 wxUint16 width = (wxUint16)(rdp.cmd1&0xFF) + 3;
119 FRDP("uc1:line3d width: %d #%d, #%d - %d, %d\n", width, rdp.tri_n, rdp.tri_n+1,
120 (rdp.cmd1 >> 17) & 0x7F,
121 (rdp.cmd1 >> 9) & 0x7F);
124 &rdp.vtx[(rdp.cmd1 >> 17) & 0x7F],
125 &rdp.vtx[(rdp.cmd1 >> 9) & 0x7F],
126 &rdp.vtx[(rdp.cmd1 >> 9) & 0x7F]
128 wxUint32 cull_mode = (rdp.flags & CULLMASK) >> CULLSHIFT;
129 rdp.flags |= CULLMASK;
130 rdp.update |= UPDATE_CULL_MODE;
132 rdp.flags ^= CULLMASK;
133 rdp.flags |= cull_mode << CULLSHIFT;
134 rdp.update |= UPDATE_CULL_MODE;
138 FRDP("uc1:quad3d #%d, #%d\n", rdp.tri_n, rdp.tri_n+1);
141 &rdp.vtx[(rdp.cmd1 >> 25) & 0x7F],
142 &rdp.vtx[(rdp.cmd1 >> 17) & 0x7F],
143 &rdp.vtx[(rdp.cmd1 >> 9) & 0x7F],
144 &rdp.vtx[(rdp.cmd1 >> 1) & 0x7F],
145 &rdp.vtx[(rdp.cmd1 >> 25) & 0x7F],
146 &rdp.vtx[(rdp.cmd1 >> 9) & 0x7F]
153 wxUint32 branch_dl = 0;
155 static void uc1_rdphalf_1()
157 LRDP("uc1:rdphalf_1\n");
158 branch_dl = rdp.cmd1;
162 static void uc1_branch_z()
164 wxUint32 addr = segoffset(branch_dl);
165 FRDP ("uc1:branch_less_z, addr: %08lx\n", addr);
166 wxUint32 vtx = (rdp.cmd0 & 0xFFF) >> 1;
167 if( fabs(rdp.vtx[vtx].z) <= (rdp.cmd1/*&0xFFFF*/) )
169 rdp.pc[rdp.pc_i] = addr;