- RDP optimizations and memory system shunting in N64 driver; relative speedup of 1.4x to 1.5x [MooglyGuy]

This commit is contained in:
Ryan Holtz 2012-02-03 21:06:10 +00:00
parent f2778a6a5a
commit ae70f4d52b
14 changed files with 1448 additions and 1269 deletions

View File

@ -3123,19 +3123,19 @@ CPU_GET_INFO( rsp )
} }
} }
void rspdrc_flush_drc_cache(device_t *device)
{
}
void rspdrc_set_options(device_t *device, UINT32 options) void rspdrc_set_options(device_t *device, UINT32 options)
{ {
} }
void rspdrc_add_imem(device_t *device, void *base) void rspdrc_add_imem(device_t *device, UINT32 *base)
{ {
} }
void rspdrc_add_dmem(device_t *device, void *base) void rspdrc_add_dmem(device_t *device, UINT32 *base)
{
}
void rspdrc_flush_drc_cache(device_t *device)
{ {
} }

View File

@ -88,8 +88,8 @@ struct _rsp_config
void rspdrc_flush_drc_cache(device_t *device); void rspdrc_flush_drc_cache(device_t *device);
void rspdrc_set_options(device_t *device, UINT32 options); void rspdrc_set_options(device_t *device, UINT32 options);
void rspdrc_add_imem(device_t *device, void *base); void rspdrc_add_dmem(device_t *device, UINT32 *base);
void rspdrc_add_dmem(device_t *device, void *base); void rspdrc_add_imem(device_t *device, UINT32 *base);
/*************************************************************************** /***************************************************************************
HELPER MACROS HELPER MACROS
@ -184,6 +184,14 @@ struct _rsp_state
direct_read_data *direct; direct_read_data *direct;
int icount; int icount;
UINT32 *dmem32;
UINT16 *dmem16;
UINT8 *dmem8;
UINT32 *imem32;
UINT16 *imem16;
UINT8 *imem8;
rspimp_state* impstate; rspimp_state* impstate;
}; };

View File

@ -303,13 +303,25 @@ INLINE void save_fast_iregs(rsp_state *rsp, drcuml_block *block)
CORE CALLBACKS CORE CALLBACKS
***************************************************************************/ ***************************************************************************/
void rspdrc_add_imem(device_t *device, UINT32 *base)
{
rsp_state *rsp = get_safe_token(device);
rsp->imem32 = base;
rsp->imem16 = (UINT16*)base;
rsp->imem8 = (UINT8*)base;
}
void rspdrc_add_dmem(device_t *device, UINT32 *base)
{
rsp_state *rsp = get_safe_token(device);
rsp->dmem32 = base;
rsp->dmem16 = (UINT16*)base;
rsp->dmem8 = (UINT8*)base;
}
INLINE UINT8 READ8(rsp_state *rsp, UINT32 address) INLINE UINT8 READ8(rsp_state *rsp, UINT32 address)
{ {
UINT8 ret; return rsp->dmem8[BYTE4_XOR_BE(address & 0xfff)];
address = 0x04000000 | (address & 0xfff);
ret = rsp->program->read_byte(address);
//printf("%04xr%02x\n",address & 0x1fff, ret);
return ret;
} }
static void cfunc_read8(void *param) static void cfunc_read8(void *param)
@ -321,10 +333,10 @@ static void cfunc_read8(void *param)
INLINE UINT16 READ16(rsp_state *rsp, UINT32 address) INLINE UINT16 READ16(rsp_state *rsp, UINT32 address)
{ {
UINT16 ret; UINT16 ret;
address = 0x04000000 | (address & 0xfff); address &= 0xfff;
ret = rsp->program->read_byte(address+0) << 8; ret = rsp->dmem8[BYTE4_XOR_BE(address)] << 8;
ret |= rsp->program->read_byte(address+1) << 0; ret |= rsp->dmem8[BYTE4_XOR_BE(address + 1)];
//printf("%04xr%04x\n",address & 0x1fff, ret); //printf("%04xr%04x\n",address, ret);
return ret; return ret;
} }
@ -337,12 +349,12 @@ static void cfunc_read16(void *param)
INLINE UINT32 READ32(rsp_state *rsp, UINT32 address) INLINE UINT32 READ32(rsp_state *rsp, UINT32 address)
{ {
UINT32 ret; UINT32 ret;
address = 0x04000000 | (address & 0xfff); address &= 0xfff;
ret = rsp->program->read_byte(address+0) << 24; ret = rsp->dmem8[BYTE4_XOR_BE(address)] << 24;
ret |= rsp->program->read_byte(address+1) << 16; ret |= rsp->dmem8[BYTE4_XOR_BE(address + 1)] << 16;
ret |= rsp->program->read_byte(address+2) << 8; ret |= rsp->dmem8[BYTE4_XOR_BE(address + 2)] << 8;
ret |= rsp->program->read_byte(address+3) << 0; ret |= rsp->dmem8[BYTE4_XOR_BE(address + 3)];
//printf("%04xr%08x\n",address & 0x1fff, ret); //printf("%04xr%08x\n",address, ret);
return ret; return ret;
} }
@ -354,9 +366,9 @@ static void cfunc_read32(void *param)
INLINE void WRITE8(rsp_state *rsp, UINT32 address, UINT8 data) INLINE void WRITE8(rsp_state *rsp, UINT32 address, UINT8 data)
{ {
address = 0x04000000 | (address & 0xfff); address &= 0xfff;
//printf("%04x:%02x\n",address & 0x1fff, data); rsp->dmem8[BYTE4_XOR_BE(address)] = data;
rsp->program->write_byte(address, data); //printf("%04xw%02x\n",address, data);
} }
static void cfunc_write8(void *param) static void cfunc_write8(void *param)
@ -367,11 +379,10 @@ static void cfunc_write8(void *param)
INLINE void WRITE16(rsp_state *rsp, UINT32 address, UINT16 data) INLINE void WRITE16(rsp_state *rsp, UINT32 address, UINT16 data)
{ {
address = 0x04000000 | (address & 0xfff); address &= 0xfff;
rsp->dmem8[BYTE4_XOR_BE(address)] = data >> 8;
//printf("%04x:%04x\n",address & 0x1fff, data); rsp->dmem8[BYTE4_XOR_BE(address + 1)] = data & 0xff;
rsp->program->write_byte(address + 0, (data >> 8) & 0xff); //printf("%04xw%04x\n",address, data);
rsp->program->write_byte(address + 1, (data >> 0) & 0xff);
} }
static void cfunc_write16(void *param) static void cfunc_write16(void *param)
@ -382,13 +393,12 @@ static void cfunc_write16(void *param)
INLINE void WRITE32(rsp_state *rsp, UINT32 address, UINT32 data) INLINE void WRITE32(rsp_state *rsp, UINT32 address, UINT32 data)
{ {
address = 0x04000000 | (address & 0xfff); address &= 0xfff;
rsp->dmem8[BYTE4_XOR_BE(address)] = data >> 24;
//printf("%04x:%08x\n",address & 0x1fff, data); rsp->dmem8[BYTE4_XOR_BE(address + 1)] = (data >> 16) & 0xff;
rsp->program->write_byte(address + 0, (data >> 24) & 0xff); rsp->dmem8[BYTE4_XOR_BE(address + 2)] = (data >> 8) & 0xff;
rsp->program->write_byte(address + 1, (data >> 16) & 0xff); rsp->dmem8[BYTE4_XOR_BE(address + 3)] = data & 0xff;
rsp->program->write_byte(address + 2, (data >> 8) & 0xff); //printf("%04xw%08x\n",address, data);
rsp->program->write_byte(address + 3, (data >> 0) & 0xff);
} }
static void cfunc_write32(void *param) static void cfunc_write32(void *param)

View File

@ -1,6 +1,7 @@
/* machine/n64.c - contains N64 hardware emulation shared between MAME and MESS */ /* machine/n64.c - contains N64 hardware emulation shared between MAME and MESS */
#include "emu.h" #include "emu.h"
#include "debugger.h"
#include "cpu/mips/mips3.h" #include "cpu/mips/mips3.h"
#include "cpu/mips/mips3com.h" #include "cpu/mips/mips3com.h"
#include "includes/n64.h" #include "includes/n64.h"
@ -437,20 +438,19 @@ void n64_periphs::sp_dma(int direction)
sp_dma_length = 0x1000 - (sp_mem_addr & 0xfff); sp_dma_length = 0x1000 - (sp_mem_addr & 0xfff);
} }
UINT32 *sp_mem[2] = { rsp_dmem, rsp_imem };
if(direction == 0)// RDRAM -> I/DMEM if(direction == 0)// RDRAM -> I/DMEM
{ {
for(int c = 0; c <= sp_dma_count; c++) for(int c = 0; c <= sp_dma_count; c++)
{ {
UINT32 src = sp_dram_addr; UINT32 src = (sp_dram_addr & 0x007fffff) >> 2;
UINT32 dst = 0x04000000 | (sp_mem_addr & 0x1fff); UINT32 dst = (sp_mem_addr & 0x1fff) >> 2;
//printf("CPU %08x -> RSP %08x\n", sp_dram_addr, 0x04000000 | sp_mem_addr); for(int i = 0; i < sp_dma_length / 4; i++)
for(int i = 0; i < sp_dma_length; i++)
{ {
//printf("%02x ", mem_map->read_byte((src + i)^3)); sp_mem[(dst + i) >> 10][(dst + i) & 0x3ff] = rdram[src + i];
mem_map->write_byte(dst + i, mem_map->read_byte(src + i));
} }
//printf("\n");
sp_mem_addr += sp_dma_length; sp_mem_addr += sp_dma_length;
sp_dram_addr += sp_dma_length; sp_dram_addr += sp_dma_length;
@ -462,16 +462,13 @@ void n64_periphs::sp_dma(int direction)
{ {
for(int c = 0; c <= sp_dma_count; c++) for(int c = 0; c <= sp_dma_count; c++)
{ {
UINT32 src = 0x04000000 | (sp_mem_addr & 0x1fff); UINT32 src = (sp_mem_addr & 0x1fff) >> 2;
UINT32 dst = sp_dram_addr; UINT32 dst = (sp_dram_addr & 0x007fffff) >> 2;
//printf("RSP %08x -> CPU %08x\n", 0x04000000 | sp_mem_addr, sp_dram_addr); for(int i = 0; i < sp_dma_length / 4; i++)
for(int i = 0; i < sp_dma_length; i++)
{ {
//printf("%02x ", mem_map->read_byte((src + i)^3)); rdram[dst + i] = sp_mem[(src + i) >> 10][(src + i) & 0x3ff];
mem_map->write_byte(dst + i, mem_map->read_byte(src + i));
} }
//printf("\n");
sp_mem_addr += sp_dma_length; sp_mem_addr += sp_dma_length;
sp_dram_addr += sp_dma_length; sp_dram_addr += sp_dma_length;
@ -870,7 +867,7 @@ void n64_periphs::vi_recalculate_resolution()
if (height > 480) if (height > 480)
height = 480; height = 480;
state->m_rdp.GetMiscState()->m_fb_height = height; state->m_rdp.MiscState.FBHeight = height;
visarea.max_x = width - 1; visarea.max_x = width - 1;
visarea.max_y = height - 1; visarea.max_y = height - 1;
@ -953,7 +950,7 @@ WRITE32_MEMBER( n64_periphs::vi_reg_w )
vi_recalculate_resolution(); vi_recalculate_resolution();
} }
vi_width = data; vi_width = data;
state->m_rdp.GetMiscState()->m_fb_width = data; state->m_rdp.MiscState.FBWidth = data;
break; break;
case 0x0c/4: // VI_INTR_REG case 0x0c/4: // VI_INTR_REG
@ -1212,7 +1209,12 @@ static TIMER_CALLBACK(pi_dma_callback)
void n64_periphs::pi_dma_tick() void n64_periphs::pi_dma_tick()
{ {
//printf("pi_dma_tick\n"); UINT16 *cart16 = (UINT16*)machine().region("user2")->base();
UINT16 *dram16 = (UINT16*)rdram;
UINT32 cart_addr = (pi_cart_addr & 0x0fffffff) >> 1;
UINT32 dram_addr = (pi_dram_addr & 0x007fffff) >> 1;
if(pi_dma_dir == 1) if(pi_dma_dir == 1)
{ {
UINT32 dma_length = pi_wr_len + 1; UINT32 dma_length = pi_wr_len + 1;
@ -1223,13 +1225,13 @@ void n64_periphs::pi_dma_tick()
if (pi_dram_addr != 0xffffffff) if (pi_dram_addr != 0xffffffff)
{ {
for(int i = 0; i < dma_length; i++) for(int i = 0; i < dma_length / 2; i++)
{ {
UINT8 b = mem_map->read_byte(pi_cart_addr); dram16[BYTE_XOR_BE(dram_addr + i)] = cart16[BYTE_XOR_BE(cart_addr + i)];
mem_map->write_byte(pi_dram_addr & 0x1fffffff, b);
pi_cart_addr += 1;
pi_dram_addr += 1;
} }
pi_cart_addr += dma_length;
pi_dram_addr += dma_length;
} }
if (pi_first_dma) if (pi_first_dma)
@ -1250,13 +1252,13 @@ void n64_periphs::pi_dma_tick()
if (pi_dram_addr != 0xffffffff) if (pi_dram_addr != 0xffffffff)
{ {
for(int i = 0; i < dma_length; i++) for(int i = 0; i < dma_length / 2; i++)
{ {
UINT8 b = mem_map->read_byte(pi_dram_addr); cart16[BYTE_XOR_BE(cart_addr + i)] = dram16[BYTE_XOR_BE(dram_addr + i)];
mem_map->write_byte(pi_cart_addr & 0x1fffffff, b);
pi_cart_addr += 1;
pi_dram_addr += 1;
} }
pi_cart_addr += dma_length;
pi_dram_addr += dma_length;
} }
} }
@ -1861,6 +1863,8 @@ MACHINE_START( n64 )
rspdrc_set_options(machine.device("rsp"), RSPDRC_STRICT_VERIFY); rspdrc_set_options(machine.device("rsp"), RSPDRC_STRICT_VERIFY);
rspdrc_flush_drc_cache(machine.device("rsp")); rspdrc_flush_drc_cache(machine.device("rsp"));
rspdrc_add_dmem(machine.device("rsp"), rsp_dmem);
rspdrc_add_imem(machine.device("rsp"), rsp_imem);
} }
MACHINE_RESET( n64 ) MACHINE_RESET( n64 )

File diff suppressed because it is too large Load Diff

View File

@ -49,9 +49,9 @@
#endif #endif
#define DWORD_XOR_DWORD_SWAP 1 #define DWORD_XOR_DWORD_SWAP 1
#define GET_LOW_RGBA16_TMEM(x) (m_rdp->ReplicatedRGBA()[((x) >> 1) & 0x1f]) #define GET_LOW_RGBA16_TMEM(x) (m_rdp->ReplicatedRGBA[((x) >> 1) & 0x1f])
#define GET_MED_RGBA16_TMEM(x) (m_rdp->ReplicatedRGBA()[((x) >> 6) & 0x1f]) #define GET_MED_RGBA16_TMEM(x) (m_rdp->ReplicatedRGBA[((x) >> 6) & 0x1f])
#define GET_HI_RGBA16_TMEM(x) (m_rdp->ReplicatedRGBA()[((x) >> 11) & 0x1f]) #define GET_HI_RGBA16_TMEM(x) (m_rdp->ReplicatedRGBA[((x) >> 11) & 0x1f])
#define MEM8_LIMIT 0x7fffff #define MEM8_LIMIT 0x7fffff
#define MEM16_LIMIT 0x3fffff #define MEM16_LIMIT 0x3fffff
@ -69,8 +69,8 @@
#define GETMEDCOL(x) (((x) & 0x7c0) >> 3) #define GETMEDCOL(x) (((x) & 0x7c0) >> 3)
#define GETHICOL(x) (((x) & 0xf800) >> 8) #define GETHICOL(x) (((x) & 0xf800) >> 8)
#define HREADADDR8(in) (((in) <= MEM8_LIMIT) ? (m_rdp->GetHiddenBits()[(in) ^ BYTE_ADDR_XOR]) : 0) #define HREADADDR8(in) (((in) <= MEM8_LIMIT) ? (m_rdp->HiddenBits[(in) ^ BYTE_ADDR_XOR]) : 0)
#define HWRITEADDR8(in, val) {if ((in) <= MEM8_LIMIT) m_rdp->GetHiddenBits()[(in) ^ BYTE_ADDR_XOR] = val;} #define HWRITEADDR8(in, val) {if ((in) <= MEM8_LIMIT) m_rdp->HiddenBits[(in) ^ BYTE_ADDR_XOR] = val;}
//sign-extension macros //sign-extension macros
#define SIGN22(x) (((x) & 0x200000) ? ((x) | ~0x3fffff) : ((x) & 0x3fffff)) #define SIGN22(x) (((x) & 0x200000) ? ((x) | ~0x3fffff) : ((x) & 0x3fffff))
@ -94,8 +94,8 @@ namespace RDP
{ {
class Processor; class Processor;
class MiscState; class MiscStateT;
class OtherModes; class OtherModesT;
class Color class Color
{ {
@ -138,48 +138,48 @@ class Tile
int num; int num;
}; };
class MiscState class MiscStateT
{ {
public: public:
MiscState() MiscStateT()
{ {
m_curpixel_cvg = 0; CurrentPixCvg = 0;
m_curpixel_memcvg = 0; CurrentMemCvg = 0;
m_curpixel_cvbit = 0; CurrentCvgBit = 0;
m_curpixel_overlap = 0; CurrentPixOverlap = 0;
m_max_level = 0; MaxLevel = 0;
m_min_level = 0; MinLevel = 0;
} }
int m_fb_format; int FBFormat; // Framebuffer pixel format index (0 - I, 1 - IA, 2 - CI, 3 - RGBA)
int m_fb_size; int FBSize; // Framebuffer pixel size index (0 - 4bpp, 1 - 8bpp, 2 - 16bpp, 3 - 32bpp)
int m_fb_width; int FBWidth; // Framebuffer width, in pixels
int m_fb_height; int FBHeight; // Framebuffer height, in scanlines
UINT32 m_fb_address; UINT32 FBAddress; // Framebuffer source address offset (in bytes) from start of RDRAM
UINT32 m_zb_address; UINT32 ZBAddress; // Z-buffer source address offset (in bytes) from start of RDRAM
int m_ti_format; int TIFormat; // Format for Texture Interface (TI) transfers
int m_ti_size; int TISize; // Size (in bytes) of TI transfers
int m_ti_width; int TIWidth; // Width (in pixels) of TI transfers
UINT32 m_ti_address; UINT32 TIAddress; // Destination address for TI transfers
UINT32 m_curpixel_cvg; UINT32 CurrentPixCvg; // Coverage for the current pixel
UINT32 m_curpixel_memcvg; UINT32 CurrentMemCvg; // Incoming coverage, in memory, for the current pixel
UINT32 m_curpixel_cvbit; UINT32 CurrentCvgBit; // Bitfield representation of current coverage value
UINT32 m_curpixel_overlap; UINT32 CurrentPixOverlap; // Current overlap value, in coverage indices, for the current pixel
UINT8 m_random_seed; UINT8 RandomSeed; // %HACK%, adds 19 each time it's read and is more or less random
int m_special_bsel0; int SpecialBlendSelect0; // Special blend-mode select for cycle 0
int m_special_bsel1; int SpecialBlendSelect1; // Special blend-mode select for cycle 1
UINT32 m_max_level; UINT32 MaxLevel; // Maximum LOD level for texture filtering
UINT32 m_min_level; UINT32 MinLevel; // Minimum LOD level for texture filtering
UINT16 m_primitive_z; UINT16 PrimitiveZ; // Forced Z value for current primitive, if applicable
UINT16 m_primitive_delta_z; UINT16 PrimitiveDZ; // Forced Delta-Z value for current primitive, if applicable
}; };
class CombineModes class CombineModes
@ -204,7 +204,7 @@ class CombineModes
int add_a1; int add_a1;
}; };
class OtherModes class OtherModesT
{ {
public: public:
int cycle_type; int cycle_type;
@ -246,7 +246,7 @@ class OtherModes
bool alpha_compare_en; bool alpha_compare_en;
}; };
class ColorInputs class ColorInputsT
{ {
public: public:
// combiner inputs // combiner inputs
@ -305,35 +305,35 @@ class Processor
m_tiles[i].num = i; m_tiles[i].num = i;
} }
m_one_color.c = 0xffffffff; OneColor.c = 0xffffffff;
m_zero_color.c = 0x00000000; ZeroColor.c = 0x00000000;
m_color_inputs.combiner_rgbsub_a_r[0] = m_color_inputs.combiner_rgbsub_a_r[1] = &m_one_color.i.r; ColorInputs.combiner_rgbsub_a_r[0] = ColorInputs.combiner_rgbsub_a_r[1] = &OneColor.i.r;
m_color_inputs.combiner_rgbsub_a_g[0] = m_color_inputs.combiner_rgbsub_a_g[1] = &m_one_color.i.g; ColorInputs.combiner_rgbsub_a_g[0] = ColorInputs.combiner_rgbsub_a_g[1] = &OneColor.i.g;
m_color_inputs.combiner_rgbsub_a_b[0] = m_color_inputs.combiner_rgbsub_a_b[1] = &m_one_color.i.b; ColorInputs.combiner_rgbsub_a_b[0] = ColorInputs.combiner_rgbsub_a_b[1] = &OneColor.i.b;
m_color_inputs.combiner_rgbsub_b_r[0] = m_color_inputs.combiner_rgbsub_b_r[1] = &m_one_color.i.r; ColorInputs.combiner_rgbsub_b_r[0] = ColorInputs.combiner_rgbsub_b_r[1] = &OneColor.i.r;
m_color_inputs.combiner_rgbsub_b_g[0] = m_color_inputs.combiner_rgbsub_b_g[1] = &m_one_color.i.g; ColorInputs.combiner_rgbsub_b_g[0] = ColorInputs.combiner_rgbsub_b_g[1] = &OneColor.i.g;
m_color_inputs.combiner_rgbsub_b_b[0] = m_color_inputs.combiner_rgbsub_b_b[1] = &m_one_color.i.b; ColorInputs.combiner_rgbsub_b_b[0] = ColorInputs.combiner_rgbsub_b_b[1] = &OneColor.i.b;
m_color_inputs.combiner_rgbmul_r[0] = m_color_inputs.combiner_rgbmul_r[1] = &m_one_color.i.r; ColorInputs.combiner_rgbmul_r[0] = ColorInputs.combiner_rgbmul_r[1] = &OneColor.i.r;
m_color_inputs.combiner_rgbmul_g[0] = m_color_inputs.combiner_rgbmul_g[1] = &m_one_color.i.g; ColorInputs.combiner_rgbmul_g[0] = ColorInputs.combiner_rgbmul_g[1] = &OneColor.i.g;
m_color_inputs.combiner_rgbmul_b[0] = m_color_inputs.combiner_rgbmul_b[1] = &m_one_color.i.b; ColorInputs.combiner_rgbmul_b[0] = ColorInputs.combiner_rgbmul_b[1] = &OneColor.i.b;
m_color_inputs.combiner_rgbadd_r[0] = m_color_inputs.combiner_rgbadd_r[1] = &m_one_color.i.r; ColorInputs.combiner_rgbadd_r[0] = ColorInputs.combiner_rgbadd_r[1] = &OneColor.i.r;
m_color_inputs.combiner_rgbadd_g[0] = m_color_inputs.combiner_rgbadd_g[1] = &m_one_color.i.g; ColorInputs.combiner_rgbadd_g[0] = ColorInputs.combiner_rgbadd_g[1] = &OneColor.i.g;
m_color_inputs.combiner_rgbadd_b[0] = m_color_inputs.combiner_rgbadd_b[1] = &m_one_color.i.b; ColorInputs.combiner_rgbadd_b[0] = ColorInputs.combiner_rgbadd_b[1] = &OneColor.i.b;
m_color_inputs.combiner_alphasub_a[0] = m_color_inputs.combiner_alphasub_a[1] = &m_one_color.i.a; ColorInputs.combiner_alphasub_a[0] = ColorInputs.combiner_alphasub_a[1] = &OneColor.i.a;
m_color_inputs.combiner_alphasub_b[0] = m_color_inputs.combiner_alphasub_b[1] = &m_one_color.i.a; ColorInputs.combiner_alphasub_b[0] = ColorInputs.combiner_alphasub_b[1] = &OneColor.i.a;
m_color_inputs.combiner_alphamul[0] = m_color_inputs.combiner_alphamul[1] = &m_one_color.i.a; ColorInputs.combiner_alphamul[0] = ColorInputs.combiner_alphamul[1] = &OneColor.i.a;
m_color_inputs.combiner_alphaadd[0] = m_color_inputs.combiner_alphaadd[1] = &m_one_color.i.a; ColorInputs.combiner_alphaadd[0] = ColorInputs.combiner_alphaadd[1] = &OneColor.i.a;
m_color_inputs.blender1a_r[0] = m_color_inputs.blender1a_r[1] = &m_pixel_color.i.r; ColorInputs.blender1a_r[0] = ColorInputs.blender1a_r[1] = &PixelColor.i.r;
m_color_inputs.blender1a_g[0] = m_color_inputs.blender1a_g[1] = &m_pixel_color.i.r; ColorInputs.blender1a_g[0] = ColorInputs.blender1a_g[1] = &PixelColor.i.r;
m_color_inputs.blender1a_b[0] = m_color_inputs.blender1a_b[1] = &m_pixel_color.i.r; ColorInputs.blender1a_b[0] = ColorInputs.blender1a_b[1] = &PixelColor.i.r;
m_color_inputs.blender1b_a[0] = m_color_inputs.blender1b_a[1] = &m_pixel_color.i.r; ColorInputs.blender1b_a[0] = ColorInputs.blender1b_a[1] = &PixelColor.i.r;
m_color_inputs.blender2a_r[0] = m_color_inputs.blender2a_r[1] = &m_pixel_color.i.r; ColorInputs.blender2a_r[0] = ColorInputs.blender2a_r[1] = &PixelColor.i.r;
m_color_inputs.blender2a_g[0] = m_color_inputs.blender2a_g[1] = &m_pixel_color.i.r; ColorInputs.blender2a_g[0] = ColorInputs.blender2a_g[1] = &PixelColor.i.r;
m_color_inputs.blender2a_b[0] = m_color_inputs.blender2a_b[1] = &m_pixel_color.i.r; ColorInputs.blender2a_b[0] = ColorInputs.blender2a_b[1] = &PixelColor.i.r;
m_color_inputs.blender2b_a[0] = m_color_inputs.blender2b_a[1] = &m_pixel_color.i.r; ColorInputs.blender2b_a[0] = ColorInputs.blender2b_a[1] = &PixelColor.i.r;
m_tmem = NULL; m_tmem = NULL;
@ -341,8 +341,8 @@ class Processor
//memset(m_hidden_bits, 3, 8388608); //memset(m_hidden_bits, 3, 8388608);
m_prim_lod_frac = 0; PrimLODFraction = 0;
m_lod_frac = 0; LODFraction = 0;
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
@ -386,14 +386,12 @@ class Processor
for(int i = 0; i < 32; i++) for(int i = 0; i < 32; i++)
{ {
m_replicated_rgba[i] = (i << 3) | ((i >> 2) & 7); ReplicatedRGBA[i] = (i << 3) | ((i >> 2) & 7);
} }
} }
~Processor() { } ~Processor() { }
UINT8* ReplicatedRGBA() { return m_replicated_rgba; }
void Dasm(char *buffer); void Dasm(char *buffer);
void ProcessList(); void ProcessList();
@ -454,71 +452,8 @@ class Processor
void SetStatusReg(UINT32 val) { m_status = val; } void SetStatusReg(UINT32 val) { m_status = val; }
UINT32 GetStatusReg() const { return m_status; } UINT32 GetStatusReg() const { return m_status; }
// Functional blocks
Blender* GetBlender() { return &m_blender; }
Framebuffer* GetFramebuffer() { return &m_framebuffer; }
TexturePipe* GetTexPipe() { return &m_tex_pipe; }
// Internal state // Internal state
OtherModes* GetOtherModes() { return &m_other_modes; }
ColorInputs* GetColorInputs() { return &m_color_inputs; }
CombineModes* GetCombine() { return &m_combine; } CombineModes* GetCombine() { return &m_combine; }
MiscState* GetMiscState() { return &m_misc_state; }
// Color constants
Color* GetBlendColor() { return &m_blend_color; }
void SetBlendColor(UINT32 color) { m_blend_color.c = color; }
Color* GetPixelColor() { return &m_pixel_color; }
void SetPixelColor(UINT32 color) { m_pixel_color.c = color; }
Color* GetInvPixelColor() { return &m_inv_pixel_color; }
void SetInvPixelColor(UINT32 color) { m_inv_pixel_color.c = color; }
Color* GetBlendedColor() { return &m_blended_pixel_color; }
void SetBlendedColor(UINT32 color) { m_blended_pixel_color.c = color; }
Color* GetMemoryColor() { return &m_memory_color; }
void SetMemoryColor(UINT32 color) { m_memory_color.c = color; }
Color* GetPrimColor() { return &m_prim_color; }
void SetPrimColor(UINT32 color) { m_prim_color.c = color; }
Color* GetEnvColor() { return &m_env_color; }
void SetEnvColor(UINT32 color) { m_env_color.c = color; }
Color* GetFogColor() { return &m_fog_color; }
void SetFogColor(UINT32 color) { m_fog_color.c = color; }
Color* GetCombinedColor() { return &m_combined_color; }
void SetCombinedColor(UINT32 color) { m_combined_color.c = color; }
Color* GetTexel0Color() { return &m_texel0_color; }
void SetTexel0Color(UINT32 color) { m_texel0_color.c = color; }
Color* GetTexel1Color() { return &m_texel1_color; }
void SetTexel1Color(UINT32 color) { m_texel1_color.c = color; }
Color* GetNextTexelColor() { return &m_next_texel_color; }
void SetNextTexelColor(UINT32 color) { m_next_texel_color.c = color; }
Color* GetShadeColor() { return &m_shade_color; }
void SetShadeColor(UINT32 color) { m_shade_color.c = color; }
Color* GetKeyScale() { return &m_key_scale; }
void SetKeyScale(UINT32 scale) { m_key_scale.c = scale; }
Color* GetNoiseColor() { return &m_noise_color; }
void SetNoiseColor(UINT32 color) { m_noise_color.c = color; }
Color* GetOne() { return &m_one_color; }
Color* GetZero() { return &m_zero_color; }
UINT8 GetLODFrac() { return m_lod_frac; }
void SetLODFrac(UINT8 lod_frac) { m_lod_frac = lod_frac; }
UINT8 GetPrimLODFrac() { return m_prim_lod_frac; }
void SetPrimLODFrac(UINT8 prim_lod_frac) { m_prim_lod_frac = prim_lod_frac; }
// Color Combiner // Color Combiner
INT32 ColorCombinerEquation(INT32 a, INT32 b, INT32 c, INT32 d); INT32 ColorCombinerEquation(INT32 a, INT32 b, INT32 c, INT32 d);
@ -540,7 +475,7 @@ class Processor
Tile* GetTiles(){ return m_tiles; } Tile* GetTiles(){ return m_tiles; }
// Emulation Accelerators // Emulation Accelerators
UINT8 GetRandom() { return m_misc_state.m_random_seed += 0x13; } UINT8 GetRandom() { return MiscState.RandomSeed += 0x13; }
// YUV Factors // YUV Factors
void SetYUVFactors(INT32 k0, INT32 k1, INT32 k2, INT32 k3, INT32 k4, INT32 k5) { m_k0 = k0; m_k1 = k1; m_k2 = k2; m_k3 = k3; m_k4 = k4; m_k5 = k5; } void SetYUVFactors(INT32 k0, INT32 k1, INT32 k2, INT32 k3, INT32 k4, INT32 k5) { m_k0 = k0; m_k1 = k1; m_k2 = k2; m_k3 = k3; m_k4 = k4; m_k5 = k5; }
@ -560,13 +495,10 @@ class Processor
void TCDivNoPersp(INT32 ss, INT32 st, INT32 sw, INT32* sss, INT32* sst); void TCDivNoPersp(INT32 ss, INT32 st, INT32 sw, INT32* sss, INT32* sst);
UINT32 GetLog2(UINT32 lod_clamp); UINT32 GetLog2(UINT32 lod_clamp);
void RenderSpans(int start, int end, int tilenum, bool flip); void RenderSpans(int start, int end, int tilenum, bool flip);
UINT8* GetHiddenBits() { return m_hidden_bits; }
void GetAlphaCvg(UINT8 *comb_alpha); void GetAlphaCvg(UINT8 *comb_alpha);
const UINT8* GetBayerMatrix() const { return s_bayer_matrix; } const UINT8* GetBayerMatrix() const { return s_bayer_matrix; }
const UINT8* GetMagicMatrix() const { return s_magic_matrix; } const UINT8* GetMagicMatrix() const { return s_magic_matrix; }
Span* GetSpans() { return m_span; }
int GetCurrFIFOIndex() const { return m_cmd_cur; } int GetCurrFIFOIndex() const { return m_cmd_cur; }
UINT32 GetFillColor32() const { return m_fill_color; }
void ZStore(UINT32 zcurpixel, UINT32 dzcurpixel, UINT32 z); void ZStore(UINT32 zcurpixel, UINT32 dzcurpixel, UINT32 z);
UINT32 ZDecompress(UINT32 zcurpixel); UINT32 ZDecompress(UINT32 zcurpixel);
@ -648,40 +580,51 @@ class Processor
UINT16 decompress_cvmask_frombyte(UINT8 x); UINT16 decompress_cvmask_frombyte(UINT8 x);
void lookup_cvmask_derivatives(UINT32 mask, UINT8* offx, UINT8* offy); void lookup_cvmask_derivatives(UINT32 mask, UINT8* offx, UINT8* offy);
MiscStateT MiscState;
// Color constants
Color MemoryColor;
Color PixelColor;
Color InvPixelColor;
Color BlendedPixelColor;
Color BlendColor;
Color PrimColor;
Color EnvColor;
Color FogColor;
Color CombinedColor;
Color Texel0Color;
Color Texel1Color;
Color NextTexelColor;
Color ShadeColor;
Color KeyScale;
Color NoiseColor;
Color OneColor;
Color ZeroColor;
UINT8 LODFraction;
UINT8 PrimLODFraction;
UINT32 FillColor;
OtherModesT OtherModes;
ColorInputsT ColorInputs;
BlenderT Blender;
Span Spans[4096];
FramebufferT Framebuffer;
TexturePipeT TexPipe;
UINT8 HiddenBits[0x800000];
UINT8 ReplicatedRGBA[32];
protected: protected:
Blender m_blender;
Framebuffer m_framebuffer;
TexturePipe m_tex_pipe;
OtherModes m_other_modes;
MiscState m_misc_state;
ColorInputs m_color_inputs;
CombineModes m_combine; CombineModes m_combine;
Color m_pixel_color;
Color m_inv_pixel_color;
Color m_blended_pixel_color;
Color m_memory_color;
Color m_blend_color;
Color m_prim_color;
Color m_env_color;
Color m_fog_color;
Color m_combined_color;
Color m_texel0_color;
Color m_texel1_color;
Color m_next_texel_color;
Color m_shade_color;
Color m_key_scale;
Color m_noise_color;
UINT8 m_lod_frac;
UINT8 m_prim_lod_frac;
Color m_one_color;
Color m_zero_color;
UINT32 m_fill_color;
typedef struct typedef struct
{ {
UINT8 cvg; UINT8 cvg;
@ -727,10 +670,6 @@ class Processor
INT32 m_norm_point_rom[64]; INT32 m_norm_point_rom[64];
INT32 m_norm_slope_rom[64]; INT32 m_norm_slope_rom[64];
UINT8 m_hidden_bits[0x800000];
Span m_span[4096];
static const UINT8 s_bayer_matrix[16]; static const UINT8 s_bayer_matrix[16];
static const UINT8 s_magic_matrix[16]; static const UINT8 s_magic_matrix[16];
@ -739,8 +678,6 @@ class Processor
UINT32 m_special_9bit_clamptable[512]; UINT32 m_special_9bit_clamptable[512];
UINT8 m_replicated_rgba[32];
INT32 m_dzpix_enc; INT32 m_dzpix_enc;
INT32 m_dz_enc; INT32 m_dz_enc;

View File

@ -8,95 +8,94 @@ namespace N64
namespace RDP namespace RDP
{ {
bool Blender::Blend1Cycle(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel) bool BlenderT::Blend1Cycle(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel)
{ {
ColorInputs* ci = m_rdp->GetColorInputs();
INT32 r, g, b; INT32 r, g, b;
if (!m_other_modes->alpha_cvg_select) if (!m_rdp->OtherModes.alpha_cvg_select)
{ {
DitherA(&m_rdp->GetPixelColor()->i.a, adseed); DitherA(&m_rdp->PixelColor.i.a, adseed);
} }
DitherA(&m_rdp->GetShadeColor()->i.a, adseed); DitherA(&m_rdp->ShadeColor.i.a, adseed);
if (!AlphaCompare(m_rdp->GetPixelColor()->i.a)) if (!AlphaCompare(m_rdp->PixelColor.i.a))
{ {
return false; return false;
} }
if (m_other_modes->antialias_en ? (!m_misc_state->m_curpixel_cvg) : (!m_misc_state->m_curpixel_cvbit)) if (m_rdp->OtherModes.antialias_en ? (!m_rdp->MiscState.CurrentPixCvg) : (!m_rdp->MiscState.CurrentCvgBit))
{ {
return false; return false;
} }
bool dontblend = (partialreject && m_rdp->GetPixelColor()->i.a >= 0xff); bool dontblend = (partialreject && m_rdp->PixelColor.i.a >= 0xff);
if (!m_blend_enable || dontblend) if (!BlendEnable || dontblend)
{ {
r = *ci->blender1a_r[0]; r = *m_rdp->ColorInputs.blender1a_r[0];
g = *ci->blender1a_g[0]; g = *m_rdp->ColorInputs.blender1a_g[0];
b = *ci->blender1a_b[0]; b = *m_rdp->ColorInputs.blender1a_b[0];
} }
else else
{ {
m_rdp->GetInvPixelColor()->i.a = 0xff - *ci->blender1b_a[0]; m_rdp->InvPixelColor.i.a = 0xff - *m_rdp->ColorInputs.blender1b_a[0];
BlendEquationCycle0(&r, &g, &b, special_bsel); BlendEquationCycle0(&r, &g, &b, special_bsel);
} }
if (m_other_modes->rgb_dither_sel < 3) if (m_rdp->OtherModes.rgb_dither_sel < 3)
{ {
DitherRGB(&r, &g, &b, dith); DitherRGB(&r, &g, &b, dith);
} }
*fr = r; *fr = r;
*fg = g; *fg = g;
*fb = b; *fb = b;
return true; return true;
} }
bool Blender::Blend2Cycle(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, int special_bsel1) bool BlenderT::Blend2Cycle(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, int special_bsel1)
{ {
ColorInputs* ci = m_rdp->GetColorInputs(); if (!m_rdp->OtherModes.alpha_cvg_select)
if (!m_other_modes->alpha_cvg_select)
{ {
DitherA(&m_rdp->GetPixelColor()->i.a, adseed); DitherA(&m_rdp->PixelColor.i.a, adseed);
} }
DitherA(&m_rdp->GetShadeColor()->i.a, adseed); DitherA(&m_rdp->ShadeColor.i.a, adseed);
if (!AlphaCompare(m_rdp->GetPixelColor()->i.a)) if (!AlphaCompare(m_rdp->PixelColor.i.a))
{ {
return false; return false;
} }
if (m_other_modes->antialias_en ? (!m_misc_state->m_curpixel_cvg) : (!m_misc_state->m_curpixel_cvbit)) if (m_rdp->OtherModes.antialias_en ? (!m_rdp->MiscState.CurrentPixCvg) : (!m_rdp->MiscState.CurrentCvgBit))
{ {
return false; return false;
} }
m_rdp->GetInvPixelColor()->i.a = 0xff - *ci->blender1b_a[0]; m_rdp->InvPixelColor.i.a = 0xff - *m_rdp->ColorInputs.blender1b_a[0];
INT32 r, g, b; INT32 r, g, b;
BlendEquationCycle0(&r, &g, &b, special_bsel0); BlendEquationCycle0(&r, &g, &b, special_bsel0);
m_rdp->GetBlendedColor()->i.r = r; m_rdp->BlendedPixelColor.i.r = r;
m_rdp->GetBlendedColor()->i.g = g; m_rdp->BlendedPixelColor.i.g = g;
m_rdp->GetBlendedColor()->i.b = b; m_rdp->BlendedPixelColor.i.b = b;
m_rdp->GetBlendedColor()->i.a = m_rdp->GetPixelColor()->i.a; m_rdp->BlendedPixelColor.i.a = m_rdp->PixelColor.i.a;
bool dontblend = (partialreject && m_rdp->GetPixelColor()->i.a >= 0xff); bool dontblend = (partialreject && m_rdp->PixelColor.i.a >= 0xff);
if (!m_blend_enable || dontblend) if (!BlendEnable || dontblend)
{ {
r = *ci->blender1a_r[1]; r = *m_rdp->ColorInputs.blender1a_r[1];
g = *ci->blender1a_g[1]; g = *m_rdp->ColorInputs.blender1a_g[1];
b = *ci->blender1a_b[1]; b = *m_rdp->ColorInputs.blender1a_b[1];
} }
else else
{ {
m_rdp->GetInvPixelColor()->i.a = 0xff - *ci->blender1b_a[1]; m_rdp->InvPixelColor.i.a = 0xff - *m_rdp->ColorInputs.blender1b_a[1];
BlendEquationCycle1(&r, &g, &b, special_bsel1); BlendEquationCycle1(&r, &g, &b, special_bsel1);
} }
if (m_other_modes->rgb_dither_sel < 3) if (m_rdp->OtherModes.rgb_dither_sel < 3)
{ {
DitherRGB(&r, &g, &b, dith); DitherRGB(&r, &g, &b, dith);
} }
@ -108,47 +107,46 @@ bool Blender::Blend2Cycle(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adse
return true; return true;
} }
void Blender::BlendEquationCycle0(int* r, int* g, int* b, int bsel_special) void BlenderT::BlendEquationCycle0(int* r, int* g, int* b, int bsel_special)
{ {
ColorInputs* ci = m_rdp->GetColorInputs(); UINT8 blend1a = *m_rdp->ColorInputs.blender1b_a[0] >> 3;
UINT8 blend1a = *ci->blender1b_a[0] >> 3; UINT8 blend2a = *m_rdp->ColorInputs.blender2b_a[0] >> 3;
UINT8 blend2a = *ci->blender2b_a[0] >> 3;
if (bsel_special) if (bsel_special)
{ {
blend1a = (blend1a >> m_shift_a) & 0x1C; blend1a = (blend1a >> ShiftA) & 0x1C;
blend2a = (blend2a >> m_shift_b) & 0x1C; blend2a = (blend2a >> ShiftB) & 0x1C;
} }
UINT32 sum = ((blend1a >> 2) + (blend2a >> 2) + 1) & 0xf; UINT32 sum = ((blend1a >> 2) + (blend2a >> 2) + 1) & 0xf;
*r = (((int)(*ci->blender1a_r[0]) * (int)(blend1a))) + *r = (((int)(*m_rdp->ColorInputs.blender1a_r[0]) * (int)(blend1a))) +
(((int)(*ci->blender2a_r[0]) * (int)(blend2a))); (((int)(*m_rdp->ColorInputs.blender2a_r[0]) * (int)(blend2a)));
*g = (((int)(*ci->blender1a_g[0]) * (int)(blend1a))) + *g = (((int)(*m_rdp->ColorInputs.blender1a_g[0]) * (int)(blend1a))) +
(((int)(*ci->blender2a_g[0]) * (int)(blend2a))); (((int)(*m_rdp->ColorInputs.blender2a_g[0]) * (int)(blend2a)));
*b = (((int)(*ci->blender1a_b[0]) * (int)(blend1a))) + *b = (((int)(*m_rdp->ColorInputs.blender1a_b[0]) * (int)(blend1a))) +
(((int)(*ci->blender2a_b[0]) * (int)(blend2a))); (((int)(*m_rdp->ColorInputs.blender2a_b[0]) * (int)(blend2a)));
if (bsel_special) if (bsel_special)
{ {
*r += (((int)*ci->blender2a_r[0]) << 2); *r += (((int)*m_rdp->ColorInputs.blender2a_r[0]) << 2);
*g += (((int)*ci->blender2a_g[0]) << 2); *g += (((int)*m_rdp->ColorInputs.blender2a_g[0]) << 2);
*b += (((int)*ci->blender2a_b[0]) << 2); *b += (((int)*m_rdp->ColorInputs.blender2a_b[0]) << 2);
} }
else else
{ {
*r += (int)*ci->blender2a_r[0]; *r += (int)*m_rdp->ColorInputs.blender2a_r[0];
*g += (int)*ci->blender2a_g[0]; *g += (int)*m_rdp->ColorInputs.blender2a_g[0];
*b += (int)*ci->blender2a_b[0]; *b += (int)*m_rdp->ColorInputs.blender2a_b[0];
} }
*r >>= 2; *r >>= 2;
*g >>= 2; *g >>= 2;
*b >>= 2; *b >>= 2;
if (m_other_modes->force_blend) if (m_rdp->OtherModes.force_blend)
{ {
*r >>= 3; *r >>= 3;
*g >>= 3; *g >>= 3;
@ -173,47 +171,46 @@ void Blender::BlendEquationCycle0(int* r, int* g, int* b, int bsel_special)
if (*b > 255) *b = 255; if (*b > 255) *b = 255;
} }
void Blender::BlendEquationCycle1(INT32* r, INT32* g, INT32* b, int bsel_special) void BlenderT::BlendEquationCycle1(INT32* r, INT32* g, INT32* b, int bsel_special)
{ {
ColorInputs* ci = m_rdp->GetColorInputs(); UINT8 blend1a = *m_rdp->ColorInputs.blender1b_a[1] >> 3;
UINT8 blend1a = *ci->blender1b_a[1] >> 3; UINT8 blend2a = *m_rdp->ColorInputs.blender2b_a[1] >> 3;
UINT8 blend2a = *ci->blender2b_a[1] >> 3;
if (bsel_special) if (bsel_special)
{ {
blend1a = (blend1a >> m_shift_a) & 0x1C; blend1a = (blend1a >> ShiftA) & 0x1C;
blend2a = (blend2a >> m_shift_b) & 0x1C; blend2a = (blend2a >> ShiftB) & 0x1C;
} }
UINT32 sum = ((blend1a >> 2) + (blend2a >> 2) + 1) & 0xf; UINT32 sum = ((blend1a >> 2) + (blend2a >> 2) + 1) & 0xf;
*r = (((int)(*ci->blender1a_r[1]) * (int)(blend1a))) + *r = (((int)(*m_rdp->ColorInputs.blender1a_r[1]) * (int)(blend1a))) +
(((int)(*ci->blender2a_r[1]) * (int)(blend2a))); (((int)(*m_rdp->ColorInputs.blender2a_r[1]) * (int)(blend2a)));
*g = (((int)(*ci->blender1a_g[1]) * (int)(blend1a))) + *g = (((int)(*m_rdp->ColorInputs.blender1a_g[1]) * (int)(blend1a))) +
(((int)(*ci->blender2a_g[1]) * (int)(blend2a))); (((int)(*m_rdp->ColorInputs.blender2a_g[1]) * (int)(blend2a)));
*b = (((int)(*ci->blender1a_b[1]) * (int)(blend1a))) + *b = (((int)(*m_rdp->ColorInputs.blender1a_b[1]) * (int)(blend1a))) +
(((int)(*ci->blender2a_b[1]) * (int)(blend2a))); (((int)(*m_rdp->ColorInputs.blender2a_b[1]) * (int)(blend2a)));
if (bsel_special) if (bsel_special)
{ {
*r += (((int)*ci->blender2a_r[1]) << 2); *r += (((int)*m_rdp->ColorInputs.blender2a_r[1]) << 2);
*g += (((int)*ci->blender2a_g[1]) << 2); *g += (((int)*m_rdp->ColorInputs.blender2a_g[1]) << 2);
*b += (((int)*ci->blender2a_b[1]) << 2); *b += (((int)*m_rdp->ColorInputs.blender2a_b[1]) << 2);
} }
else else
{ {
*r += (int)*ci->blender2a_r[1]; *r += (int)*m_rdp->ColorInputs.blender2a_r[1];
*g += (int)*ci->blender2a_g[1]; *g += (int)*m_rdp->ColorInputs.blender2a_g[1];
*b += (int)*ci->blender2a_b[1]; *b += (int)*m_rdp->ColorInputs.blender2a_b[1];
} }
*r >>= 2; *r >>= 2;
*g >>= 2; *g >>= 2;
*b >>= 2; *b >>= 2;
if (m_other_modes->force_blend) if (m_rdp->OtherModes.force_blend)
{ {
*r >>= 3; *r >>= 3;
*g >>= 3; *g >>= 3;
@ -238,12 +235,12 @@ void Blender::BlendEquationCycle1(INT32* r, INT32* g, INT32* b, int bsel_special
if (*b > 255) *b = 255; if (*b > 255) *b = 255;
} }
bool Blender::AlphaCompare(UINT8 alpha) bool BlenderT::AlphaCompare(UINT8 alpha)
{ {
INT32 threshold; INT32 threshold;
if (m_other_modes->alpha_compare_en) if (m_rdp->OtherModes.alpha_compare_en)
{ {
threshold = (m_other_modes->dither_alpha_en) ? (machine().rand() & 0xff) : m_rdp->GetBlendColor()->i.a; threshold = (m_rdp->OtherModes.dither_alpha_en) ? m_rdp->GetRandom() : m_rdp->BlendColor.i.a;
if (alpha < threshold) if (alpha < threshold)
{ {
return false; return false;
@ -253,7 +250,7 @@ bool Blender::AlphaCompare(UINT8 alpha)
return true; return true;
} }
void Blender::DitherA(UINT8 *a, int dith) void BlenderT::DitherA(UINT8 *a, int dith)
{ {
INT32 new_a = *a + dith; INT32 new_a = *a + dith;
if(new_a & 0x100) if(new_a & 0x100)
@ -263,7 +260,7 @@ void Blender::DitherA(UINT8 *a, int dith)
*a = (UINT8)new_a; *a = (UINT8)new_a;
} }
void Blender::DitherRGB(INT32 *r, INT32 *g, INT32 *b, int dith) void BlenderT::DitherRGB(INT32 *r, INT32 *g, INT32 *b, int dith)
{ {
if ((*r & 7) > dith) if ((*r & 7) > dith)
{ {

View File

@ -9,45 +9,35 @@ namespace N64
namespace RDP namespace RDP
{ {
class OtherModes; class OtherModesT;
class MiscState; class MiscStateT;
class Processor; class Processor;
class Color; class Color;
class Blender class BlenderT
{ {
public: public:
Blender() BlenderT()
{ {
m_blend_enable = false; BlendEnable = false;
} }
bool Blend2Cycle(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int bsel0, int bsel1); bool Blend2Cycle(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int bsel0, int bsel1);
bool Blend1Cycle(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel); bool Blend1Cycle(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel);
void SetOtherModes(OtherModes* other_modes) { m_other_modes = other_modes; }
void SetMiscState(MiscState* misc_state) { m_misc_state = misc_state; }
void SetMachine(running_machine& machine) { m_machine = &machine; } void SetMachine(running_machine& machine) { m_machine = &machine; }
void SetProcessor(Processor* rdp) { m_rdp = rdp; } void SetProcessor(Processor* rdp) { m_rdp = rdp; }
void SetBlendEnable(bool enable) { m_blend_enable = enable; }
bool GetBlendEnable() { return m_blend_enable; }
void SetShiftA(INT32 shift) { m_shift_a = shift; }
void SetShiftB(INT32 shift) { m_shift_b = shift; }
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
bool BlendEnable;
INT32 ShiftA;
INT32 ShiftB;
private: private:
running_machine* m_machine; running_machine* m_machine;
OtherModes* m_other_modes;
MiscState* m_misc_state;
Processor* m_rdp; Processor* m_rdp;
bool m_blend_enable;
INT32 m_shift_a;
INT32 m_shift_b;
void BlendEquationCycle0(INT32* r, INT32* g, INT32* b, int bsel_special); void BlendEquationCycle0(INT32* r, INT32* g, INT32* b, int bsel_special);
void BlendEquationCycle1(INT32* r, INT32* g, INT32* b, int bsel_special); void BlendEquationCycle1(INT32* r, INT32* g, INT32* b, int bsel_special);

View File

@ -8,9 +8,9 @@ namespace N64
namespace RDP namespace RDP
{ {
void Framebuffer::Write(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b) void FramebufferT::Write(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b)
{ {
switch(m_misc_state->m_fb_size) switch(m_rdp->MiscState.FBSize)
{ {
case PIXEL_SIZE_16BIT: case PIXEL_SIZE_16BIT:
Write16Bit(curpixel, r, g, b); Write16Bit(curpixel, r, g, b);
@ -21,51 +21,51 @@ void Framebuffer::Write(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b)
break; break;
default: default:
fatalerror("Unsupported bit depth: %d\n", m_misc_state->m_fb_size); fatalerror("Unsupported bit depth: %d\n", m_rdp->MiscState.FBSize);
break; break;
} }
} }
void Framebuffer::Write16Bit(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b) void FramebufferT::Write16Bit(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b)
{ {
#undef CVG_DRAW #undef CVG_DRAW
#ifdef CVG_DRAW #ifdef CVG_DRAW
int covdraw = (curpixel_cvg - 1) << 5; int covdraw = (CurrentPixCvg - 1) << 5;
r = covdraw; r = covdraw;
g = covdraw; g = covdraw;
b = covdraw; b = covdraw;
#endif #endif
UINT32 fb = (m_misc_state->m_fb_address >> 1) + curpixel; UINT32 fb = (m_rdp->MiscState.FBAddress >> 1) + curpixel;
UINT32 hb = fb; UINT32 hb = fb;
#if 0 #if 0
if (m_misc_state->m_curpixel_cvg > 8 && m_other_modes->z_mode != 1) if (m_rdp->MiscState.CurrentPixCvg > 8 && m_rdp->OtherModes.z_mode != 1)
{ {
stricterror("FBWRITE_16: curpixel_cvg %d", m_misc_state->m_curpixel_cvg); stricterror("FBWRITE_16: CurrentPixCvg %d", m_rdp->MiscState.CurrentPixCvg);
} }
#endif #endif
UINT16 finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1); UINT16 finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
UINT32 finalcvg = 0; UINT32 finalcvg = 0;
if (m_other_modes->color_on_cvg && !m_pre_wrap) if (m_rdp->OtherModes.color_on_cvg && !m_pre_wrap)
{ {
finalcolor = RREADIDX16(fb) & 0xfffe; finalcolor = RREADIDX16(fb) & 0xfffe;
} }
switch(m_other_modes->cvg_dest) switch(m_rdp->OtherModes.cvg_dest)
{ {
case 0: case 0:
if (!m_rdp->GetBlender()->GetBlendEnable()) if (!m_rdp->Blender.BlendEnable)
{ {
finalcvg = (m_misc_state->m_curpixel_cvg - 1) & 7; finalcvg = (m_rdp->MiscState.CurrentPixCvg - 1) & 7;
RWRITEIDX16(fb, finalcolor | ((finalcvg >> 2) & 1)); RWRITEIDX16(fb, finalcolor | ((finalcvg >> 2) & 1));
HWRITEADDR8(hb, finalcvg & 3); HWRITEADDR8(hb, finalcvg & 3);
} }
else else
{ {
finalcvg = m_misc_state->m_curpixel_cvg + m_misc_state->m_curpixel_memcvg; finalcvg = m_rdp->MiscState.CurrentPixCvg + m_rdp->MiscState.CurrentMemCvg;
if (finalcvg & 8) if (finalcvg & 8)
{ {
finalcvg = 7; finalcvg = 7;
@ -75,7 +75,7 @@ void Framebuffer::Write16Bit(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b)
} }
break; break;
case 1: case 1:
finalcvg = (m_misc_state->m_curpixel_cvg + m_misc_state->m_curpixel_memcvg) & 7; finalcvg = (m_rdp->MiscState.CurrentPixCvg + m_rdp->MiscState.CurrentMemCvg) & 7;
RWRITEIDX16(fb, finalcolor | ((finalcvg >> 2) & 1)); RWRITEIDX16(fb, finalcolor | ((finalcvg >> 2) & 1));
HWRITEADDR8(hb, finalcvg & 3); HWRITEADDR8(hb, finalcvg & 3);
break; break;
@ -84,42 +84,42 @@ void Framebuffer::Write16Bit(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b)
HWRITEADDR8(hb, 3); HWRITEADDR8(hb, 3);
break; break;
case 3: case 3:
RWRITEIDX16(fb, finalcolor | ((m_misc_state->m_curpixel_memcvg >> 2) & 1)); RWRITEIDX16(fb, finalcolor | ((m_rdp->MiscState.CurrentMemCvg >> 2) & 1));
HWRITEADDR8(hb, m_misc_state->m_curpixel_memcvg & 3); HWRITEADDR8(hb, m_rdp->MiscState.CurrentMemCvg & 3);
break; break;
} }
} }
void Framebuffer::Write32Bit(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b) void FramebufferT::Write32Bit(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b)
{ {
UINT32 fb = (m_misc_state->m_fb_address >> 2) + curpixel; UINT32 fb = (m_rdp->MiscState.FBAddress >> 2) + curpixel;
UINT32 finalcolor = (r << 24) | (g << 16) | (b << 8);//cvg as 3 MSBs of alpha channel; UINT32 finalcolor = (r << 24) | (g << 16) | (b << 8);//cvg as 3 MSBs of alpha channel;
UINT32 finalcvg = 0; UINT32 finalcvg = 0;
#if 0 #if 0
if (curpixel_cvg > 8 && m_other_modes->z_mode != 1) if (CurrentPixCvg > 8 && m_rdp->OtherModes.z_mode != 1)
{ {
stricterror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg); stricterror("FBWRITE_16: CurrentPixCvg %d", CurrentPixCvg);
} }
#endif #endif
if (m_other_modes->color_on_cvg && !m_pre_wrap) if (m_rdp->OtherModes.color_on_cvg && !m_pre_wrap)
{ {
finalcolor = RREADIDX32(fb) & 0xffffff00; finalcolor = RREADIDX32(fb) & 0xffffff00;
} }
switch(m_other_modes->cvg_dest) switch(m_rdp->OtherModes.cvg_dest)
{ {
case 0: //normal case 0: //normal
if (!m_rdp->GetBlender()->GetBlendEnable()) if (!m_rdp->Blender.BlendEnable)
{ {
finalcvg = (m_misc_state->m_curpixel_cvg - 1) & 7; finalcvg = (m_rdp->MiscState.CurrentPixCvg - 1) & 7;
finalcolor |= (finalcvg << 5); finalcolor |= (finalcvg << 5);
RWRITEIDX32(fb, finalcolor); RWRITEIDX32(fb, finalcolor);
} }
else else
{ {
finalcvg = m_misc_state->m_curpixel_cvg + m_misc_state->m_curpixel_memcvg; finalcvg = m_rdp->MiscState.CurrentPixCvg + m_rdp->MiscState.CurrentMemCvg;
if (finalcvg & 8) if (finalcvg & 8)
{ {
finalcvg = 7; finalcvg = 7;
@ -129,7 +129,7 @@ void Framebuffer::Write32Bit(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b)
} }
break; break;
case 1: case 1:
finalcvg = (m_misc_state->m_curpixel_cvg + m_misc_state->m_curpixel_memcvg) & 7; finalcvg = (m_rdp->MiscState.CurrentPixCvg + m_rdp->MiscState.CurrentMemCvg) & 7;
finalcolor |= (finalcvg << 5); finalcolor |= (finalcvg << 5);
RWRITEIDX32(fb, finalcolor); RWRITEIDX32(fb, finalcolor);
break; break;
@ -137,15 +137,15 @@ void Framebuffer::Write32Bit(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b)
RWRITEIDX32(fb, finalcolor | 0xE0); RWRITEIDX32(fb, finalcolor | 0xE0);
break; break;
case 3: case 3:
finalcolor |= (m_misc_state->m_curpixel_memcvg << 5); finalcolor |= (m_rdp->MiscState.CurrentMemCvg << 5);
RWRITEIDX32(fb, finalcolor); RWRITEIDX32(fb, finalcolor);
break; break;
} }
} }
void Framebuffer::Read(UINT32 curpixel) void FramebufferT::Read(UINT32 curpixel)
{ {
switch(m_misc_state->m_fb_size) switch(m_rdp->MiscState.FBSize)
{ {
case PIXEL_SIZE_16BIT: case PIXEL_SIZE_16BIT:
Read16Bit(curpixel); Read16Bit(curpixel);
@ -156,51 +156,51 @@ void Framebuffer::Read(UINT32 curpixel)
break; break;
default: default:
fatalerror("Unsupported bit depth: %d\n", m_misc_state->m_fb_size); fatalerror("Unsupported bit depth: %d\n", m_rdp->MiscState.FBSize);
break; break;
} }
} }
void Framebuffer::Read16Bit(UINT32 curpixel) void FramebufferT::Read16Bit(UINT32 curpixel)
{ {
UINT16 fword = RREADIDX16((m_misc_state->m_fb_address >> 1) + curpixel); UINT16 fword = RREADIDX16((m_rdp->MiscState.FBAddress >> 1) + curpixel);
UINT8 hbyte = HREADADDR8((m_misc_state->m_fb_address >> 1) + curpixel); UINT8 hbyte = HREADADDR8((m_rdp->MiscState.FBAddress >> 1) + curpixel);
m_rdp->GetMemoryColor()->i.r = GETHICOL(fword); m_rdp->MemoryColor.i.r = GETHICOL(fword);
m_rdp->GetMemoryColor()->i.g = GETMEDCOL(fword); m_rdp->MemoryColor.i.g = GETMEDCOL(fword);
m_rdp->GetMemoryColor()->i.b = GETLOWCOL(fword); m_rdp->MemoryColor.i.b = GETLOWCOL(fword);
if (m_other_modes->image_read_en) if (m_rdp->OtherModes.image_read_en)
{ {
m_misc_state->m_curpixel_memcvg = ((fword & 1) << 2) | (hbyte & 3); m_rdp->MiscState.CurrentMemCvg = ((fword & 1) << 2) | (hbyte & 3);
m_rdp->GetMemoryColor()->i.a = m_misc_state->m_curpixel_memcvg << 5; m_rdp->MemoryColor.i.a = m_rdp->MiscState.CurrentMemCvg << 5;
} }
else else
{ {
m_misc_state->m_curpixel_memcvg = 7; m_rdp->MiscState.CurrentMemCvg = 7;
m_rdp->GetMemoryColor()->i.a = 0xff; m_rdp->MemoryColor.i.a = 0xff;
} }
} }
void Framebuffer::Read32Bit(UINT32 curpixel) void FramebufferT::Read32Bit(UINT32 curpixel)
{ {
UINT32 mem = RREADIDX32((m_misc_state->m_fb_address >> 2) + curpixel); UINT32 mem = RREADIDX32((m_rdp->MiscState.FBAddress >> 2) + curpixel);
m_rdp->GetMemoryColor()->i.r = (mem >> 24) & 0xff; m_rdp->MemoryColor.i.r = (mem >> 24) & 0xff;
m_rdp->GetMemoryColor()->i.g = (mem >> 16) & 0xff; m_rdp->MemoryColor.i.g = (mem >> 16) & 0xff;
m_rdp->GetMemoryColor()->i.b = (mem >> 8) & 0xff; m_rdp->MemoryColor.i.b = (mem >> 8) & 0xff;
if (m_other_modes->image_read_en) if (m_rdp->OtherModes.image_read_en)
{ {
m_misc_state->m_curpixel_memcvg = (mem >> 5) & 7; m_rdp->MiscState.CurrentMemCvg = (mem >> 5) & 7;
m_rdp->GetMemoryColor()->i.a = (mem) & 0xff; m_rdp->MemoryColor.i.a = (mem) & 0xff;
} }
else else
{ {
m_misc_state->m_curpixel_memcvg = 7; m_rdp->MiscState.CurrentMemCvg = 7;
m_rdp->GetMemoryColor()->i.a = 0xff; m_rdp->MemoryColor.i.a = 0xff;
} }
} }
void Framebuffer::Copy(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b) void FramebufferT::Copy(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b)
{ {
switch(m_misc_state->m_fb_size) switch(m_rdp->MiscState.FBSize)
{ {
case PIXEL_SIZE_16BIT: case PIXEL_SIZE_16BIT:
Copy16Bit(curpixel, r, g, b); Copy16Bit(curpixel, r, g, b);
@ -211,27 +211,27 @@ void Framebuffer::Copy(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b)
break; break;
default: default:
fatalerror("Unsupported bit depth: %d\n", m_misc_state->m_fb_size); fatalerror("Unsupported bit depth: %d\n", m_rdp->MiscState.FBSize);
break; break;
} }
} }
void Framebuffer::Copy16Bit(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b) void FramebufferT::Copy16Bit(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b)
{ {
UINT16 val = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1) | ((m_misc_state->m_curpixel_cvg >> 2) & 1); UINT16 val = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1) | ((m_rdp->MiscState.CurrentPixCvg >> 2) & 1);
RWRITEIDX16((m_misc_state->m_fb_address >> 1) + curpixel, val); RWRITEIDX16((m_rdp->MiscState.FBAddress >> 1) + curpixel, val);
HWRITEADDR8((m_misc_state->m_fb_address >> 1) + curpixel, m_misc_state->m_curpixel_cvg & 3); HWRITEADDR8((m_rdp->MiscState.FBAddress >> 1) + curpixel, m_rdp->MiscState.CurrentPixCvg & 3);
} }
void Framebuffer::Copy32Bit(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b) void FramebufferT::Copy32Bit(UINT32 curpixel, UINT32 r, UINT32 g, UINT32 b)
{ {
UINT32 val = (r << 24) | (g << 16) | (b << 8) | (m_misc_state->m_curpixel_cvg << 5); UINT32 val = (r << 24) | (g << 16) | (b << 8) | (m_rdp->MiscState.CurrentPixCvg << 5);
RWRITEIDX32((m_misc_state->m_fb_address >> 2) + curpixel, val); RWRITEIDX32((m_rdp->MiscState.FBAddress >> 2) + curpixel, val);
} }
void Framebuffer::Fill(UINT32 curpixel) void FramebufferT::Fill(UINT32 curpixel)
{ {
switch(m_misc_state->m_fb_size) switch(m_rdp->MiscState.FBSize)
{ {
case PIXEL_SIZE_16BIT: case PIXEL_SIZE_16BIT:
Fill16Bit(curpixel); Fill16Bit(curpixel);
@ -242,32 +242,32 @@ void Framebuffer::Fill(UINT32 curpixel)
break; break;
default: default:
fatalerror("Unsupported bit depth: %d\n", m_misc_state->m_fb_size); fatalerror("Unsupported bit depth: %d\n", m_rdp->MiscState.FBSize);
break; break;
} }
} }
void Framebuffer::Fill16Bit(UINT32 curpixel) void FramebufferT::Fill16Bit(UINT32 curpixel)
{ {
UINT16 val; UINT16 val;
if (curpixel & 1) if (curpixel & 1)
{ {
val = m_rdp->GetFillColor32() & 0xffff; val = m_rdp->FillColor & 0xffff;
} }
else else
{ {
val = (m_rdp->GetFillColor32() >> 16) & 0xffff; val = (m_rdp->FillColor >> 16) & 0xffff;
} }
RWRITEIDX16((m_misc_state->m_fb_address >> 1) + curpixel, val); RWRITEIDX16((m_rdp->MiscState.FBAddress >> 1) + curpixel, val);
HWRITEADDR8((m_misc_state->m_fb_address >> 1) + curpixel, ((val & 1) << 1) | (val & 1)); HWRITEADDR8((m_rdp->MiscState.FBAddress >> 1) + curpixel, ((val & 1) << 1) | (val & 1));
} }
void Framebuffer::Fill32Bit(UINT32 curpixel) void FramebufferT::Fill32Bit(UINT32 curpixel)
{ {
UINT32 fill_color = m_rdp->GetFillColor32(); UINT32 FillColor = m_rdp->FillColor;
RWRITEIDX32((m_misc_state->m_fb_address >> 2) + curpixel, fill_color); RWRITEIDX32((m_rdp->MiscState.FBAddress >> 2) + curpixel, FillColor);
HWRITEADDR8((m_misc_state->m_fb_address >> 1) + (curpixel << 1), (fill_color & 0x10000) ? 3 : 0); HWRITEADDR8((m_rdp->MiscState.FBAddress >> 1) + (curpixel << 1), (FillColor & 0x10000) ? 3 : 0);
HWRITEADDR8((m_misc_state->m_fb_address >> 1) + (curpixel << 1) + 1, (fill_color & 0x1) ? 3 : 0); HWRITEADDR8((m_rdp->MiscState.FBAddress >> 1) + (curpixel << 1) + 1, (FillColor & 0x1) ? 3 : 0);
} }
} // namespace RDP } // namespace RDP

View File

@ -12,10 +12,10 @@ namespace RDP
class OtherModes; class OtherModes;
class MiscState; class MiscState;
class Framebuffer class FramebufferT
{ {
public: public:
Framebuffer() FramebufferT()
{ {
m_pre_wrap = false; m_pre_wrap = false;
} }

View File

@ -34,13 +34,12 @@ void Processor::RenderSpans(int start, int end, int tilenum, bool flip)
for(int i = start; i <= end; i++) for(int i = start; i <= end; i++)
{ {
m_span[i].SetMachine(machine()); switch(OtherModes.cycle_type)
switch(m_other_modes.cycle_type)
{ {
case CYCLE_TYPE_1: m_span[i].Draw1Cycle(i, tilenum, flip); break; case CYCLE_TYPE_1: Spans[i].Draw1Cycle(i, tilenum, flip); break;
case CYCLE_TYPE_2: m_span[i].Draw2Cycle(i, tilenum, flip); break; case CYCLE_TYPE_2: Spans[i].Draw2Cycle(i, tilenum, flip); break;
case CYCLE_TYPE_COPY: m_span[i].DrawCopy(i, tilenum, flip); break; case CYCLE_TYPE_COPY: Spans[i].DrawCopy(i, tilenum, flip); break;
case CYCLE_TYPE_FILL: m_span[i].DrawFill(i, tilenum, flip); break; case CYCLE_TYPE_FILL: Spans[i].DrawFill(i, tilenum, flip); break;
} }
} }
@ -73,16 +72,14 @@ void Span::SetMachine(running_machine &machine)
m_machine = &machine; m_machine = &machine;
m_rdp = &state->m_rdp; m_rdp = &state->m_rdp;
m_other_modes = m_rdp->GetOtherModes();
m_misc_state = m_rdp->GetMiscState();
} }
void Span::RGBAZClip(int sr, int sg, int sb, int sa, int *sz) void Span::RGBAZClip(int sr, int sg, int sb, int sa, int *sz)
{ {
m_rdp->GetShadeColor()->i.r = m_rdp->GetSpecial9BitClampTable()[sr & 0x1ff]; m_rdp->ShadeColor.i.r = m_rdp->GetSpecial9BitClampTable()[sr & 0x1ff];
m_rdp->GetShadeColor()->i.g = m_rdp->GetSpecial9BitClampTable()[sg & 0x1ff]; m_rdp->ShadeColor.i.g = m_rdp->GetSpecial9BitClampTable()[sg & 0x1ff];
m_rdp->GetShadeColor()->i.b = m_rdp->GetSpecial9BitClampTable()[sb & 0x1ff]; m_rdp->ShadeColor.i.b = m_rdp->GetSpecial9BitClampTable()[sb & 0x1ff];
m_rdp->GetShadeColor()->i.a = m_rdp->GetSpecial9BitClampTable()[sa & 0x1ff]; m_rdp->ShadeColor.i.a = m_rdp->GetSpecial9BitClampTable()[sa & 0x1ff];
INT32 zanded = (*sz) & 0x60000; INT32 zanded = (*sz) & 0x60000;
@ -98,7 +95,7 @@ void Span::RGBAZClip(int sr, int sg, int sb, int sa, int *sz)
void Span::RGBAZCorrectTriangle(INT32 offx, INT32 offy, INT32* r, INT32* g, INT32* b, INT32* a, INT32* z) void Span::RGBAZCorrectTriangle(INT32 offx, INT32 offy, INT32* r, INT32* g, INT32* b, INT32* a, INT32* z)
{ {
if (m_rdp->GetMiscState()->m_curpixel_cvg == 8) if (m_rdp->MiscState.CurrentPixCvg == 8)
{ {
*r >>= 2; *r >>= 2;
*g >>= 2; *g >>= 2;
@ -142,17 +139,17 @@ void Span::Draw1Cycle(int index, int tilenum, bool flip)
SpanParam t = m_t; SpanParam t = m_t;
SpanParam w = m_w; SpanParam w = m_w;
UINT32 zb = m_misc_state->m_zb_address >> 1; UINT32 zb = m_rdp->MiscState.ZBAddress >> 1;
UINT32 zhb = zb; UINT32 zhb = zb;
UINT8 offx = 0, offy = 0; UINT8 offx = 0, offy = 0;
INT32 tile1 = tilenum; INT32 tile1 = tilenum;
m_rdp->GetTexPipe()->CalculateClampDiffs(tile1); m_rdp->TexPipe.CalculateClampDiffs(tile1);
bool noisecompute = m_rdp->GetColorInputs()->combiner_rgbsub_a_r[1] == &m_rdp->GetNoiseColor()->i.r; bool noisecompute = m_rdp->ColorInputs.combiner_rgbsub_a_r[1] == &m_rdp->NoiseColor.i.r;
bool partialreject = (m_rdp->GetColorInputs()->blender2b_a[0] == &m_rdp->GetInvPixelColor()->i.a && m_rdp->GetColorInputs()->blender1b_a[0] == &m_rdp->GetPixelColor()->i.a); bool partialreject = (m_rdp->ColorInputs.blender2b_a[0] == &m_rdp->InvPixelColor.i.a && m_rdp->ColorInputs.blender1b_a[0] == &m_rdp->PixelColor.i.a);
bool bsel0 = (m_rdp->GetColorInputs()->blender2b_a[0] == &m_rdp->GetMemoryColor()->i.a); bool bsel0 = (m_rdp->ColorInputs.blender2b_a[0] == &m_rdp->MemoryColor.i.a);
int drinc = flip ? (m_rdp->m_span_dr) : -m_rdp->m_span_dr; int drinc = flip ? (m_rdp->m_span_dr) : -m_rdp->m_span_dr;
int dginc = flip ? (m_rdp->m_span_dg) : -m_rdp->m_span_dg; int dginc = flip ? (m_rdp->m_span_dg) : -m_rdp->m_span_dg;
@ -165,7 +162,7 @@ void Span::Draw1Cycle(int index, int tilenum, bool flip)
int dzpix = m_rdp->m_span_dzpix; int dzpix = m_rdp->m_span_dzpix;
int xinc = flip ? 1 : -1; int xinc = flip ? 1 : -1;
int fb_index = m_misc_state->m_fb_width * index; int fb_index = m_rdp->MiscState.FBWidth * index;
int cdith = 0; int cdith = 0;
int adith = 0; int adith = 0;
@ -177,7 +174,7 @@ void Span::Draw1Cycle(int index, int tilenum, bool flip)
int x = xend; int x = xend;
int length = flip ? (xstart - xend) : (xend - xstart); int length = flip ? (xstart - xend) : (xend - xstart);
m_rdp->GetTexPipe()->m_start_span = true; m_rdp->TexPipe.m_start_span = true;
UINT32 fir, fig, fib; UINT32 fir, fig, fib;
for (int j = 0; j <= length; j++) for (int j = 0; j <= length; j++)
@ -193,10 +190,10 @@ void Span::Draw1Cycle(int index, int tilenum, bool flip)
INT32 sss = 0; INT32 sss = 0;
INT32 sst = 0; INT32 sst = 0;
if (m_other_modes->z_source_sel) if (m_rdp->OtherModes.z_source_sel)
{ {
sz = (((UINT32)m_misc_state->m_primitive_z) << 6) & 0x3fffff; sz = (((UINT32)m_rdp->MiscState.PrimitiveZ) << 6) & 0x3fffff;
dzpix = m_misc_state->m_primitive_delta_z; dzpix = m_rdp->MiscState.PrimitiveDZ;
dzinc = m_rdp->m_span_dz = m_rdp->m_span_dzdy = 0; dzinc = m_rdp->m_span_dz = m_rdp->m_span_dzdy = 0;
} }
@ -206,9 +203,9 @@ void Span::Draw1Cycle(int index, int tilenum, bool flip)
{ {
m_rdp->lookup_cvmask_derivatives(m_cvg[x], &offx, &offy); m_rdp->lookup_cvmask_derivatives(m_cvg[x], &offx, &offy);
if (m_rdp->GetTexPipe()->m_start_span) if (m_rdp->TexPipe.m_start_span)
{ {
if (m_other_modes->persp_tex_en) if (m_rdp->OtherModes.persp_tex_en)
{ {
m_rdp->TCDiv(ss, st, sw, &sss, &sst); m_rdp->TCDiv(ss, st, sw, &sss, &sst);
} }
@ -219,16 +216,16 @@ void Span::Draw1Cycle(int index, int tilenum, bool flip)
} }
else else
{ {
sss = m_rdp->GetTexPipe()->m_precomp_s; sss = m_rdp->TexPipe.m_precomp_s;
sst = m_rdp->GetTexPipe()->m_precomp_t; sst = m_rdp->TexPipe.m_precomp_t;
} }
m_rdp->GetTexPipe()->LOD1Cycle(&sss, &sst, s.w, t.w, w.w, dsinc, dtinc, dwinc); m_rdp->TexPipe.LOD1Cycle(&sss, &sst, s.w, t.w, w.w, dsinc, dtinc, dwinc);
RGBAZCorrectTriangle(offx, offy, &sr, &sg, &sb, &sa, &sz); RGBAZCorrectTriangle(offx, offy, &sr, &sg, &sb, &sa, &sz);
RGBAZClip(sr, sg, sb, sa, &sz); RGBAZClip(sr, sg, sb, sa, &sz);
m_rdp->GetTexPipe()->Cycle(m_rdp->GetTexel0Color(), m_rdp->GetTexel0Color(), sss, sst, tilenum, 0); m_rdp->TexPipe.Cycle(&m_rdp->Texel0Color, &m_rdp->Texel0Color, sss, sst, tilenum, 0);
m_rdp->ColorCombiner1Cycle(noisecompute); m_rdp->ColorCombiner1Cycle(noisecompute);
@ -236,18 +233,18 @@ void Span::Draw1Cycle(int index, int tilenum, bool flip)
UINT32 zbcur = zb + curpixel; UINT32 zbcur = zb + curpixel;
UINT32 zhbcur = zhb + curpixel; UINT32 zhbcur = zhb + curpixel;
m_rdp->GetFramebuffer()->Read(curpixel); m_rdp->Framebuffer.Read(curpixel);
if(m_rdp->ZCompare(zbcur, zhbcur, sz, dzpix)) if(m_rdp->ZCompare(zbcur, zhbcur, sz, dzpix))
{ {
m_rdp->GetDitherValues(index, j, &cdith, &adith); m_rdp->GetDitherValues(index, j, &cdith, &adith);
bool rendered = m_rdp->GetBlender()->Blend1Cycle(&fir, &fig, &fib, cdith, adith, partialreject, bsel0); bool rendered = m_rdp->Blender.Blend1Cycle(&fir, &fig, &fib, cdith, adith, partialreject, bsel0);
if (rendered) if (rendered)
{ {
m_rdp->GetFramebuffer()->Write(curpixel, fir, fig, fib); m_rdp->Framebuffer.Write(curpixel, fir, fig, fib);
if (m_other_modes->z_update_en) if (m_rdp->OtherModes.z_update_en)
{ {
m_rdp->ZStore(zbcur, zhbcur, sz); m_rdp->ZStore(zbcur, zhbcur, sz);
} }
@ -282,7 +279,7 @@ void Span::Draw2Cycle(int index, int tilenum, bool flip)
SpanParam t = m_t; SpanParam t = m_t;
SpanParam w = m_w; SpanParam w = m_w;
UINT32 zb = m_misc_state->m_zb_address >> 1; UINT32 zb = m_rdp->MiscState.ZBAddress >> 1;
UINT32 zhb = zb; UINT32 zhb = zb;
UINT8 offx = 0, offy = 0; UINT8 offx = 0, offy = 0;
@ -294,12 +291,12 @@ void Span::Draw2Cycle(int index, int tilenum, bool flip)
INT32 news = 0; INT32 news = 0;
INT32 newt = 0; INT32 newt = 0;
m_rdp->GetTexPipe()->CalculateClampDiffs(tile1); m_rdp->TexPipe.CalculateClampDiffs(tile1);
bool noisecompute = (m_rdp->GetColorInputs()->combiner_rgbsub_a_r[0] == &m_rdp->GetNoiseColor()->i.r || m_rdp->GetColorInputs()->combiner_rgbsub_a_r[1] == &m_rdp->GetPixelColor()->i.r); bool noisecompute = (m_rdp->ColorInputs.combiner_rgbsub_a_r[0] == &m_rdp->NoiseColor.i.r || m_rdp->ColorInputs.combiner_rgbsub_a_r[1] == &m_rdp->PixelColor.i.r);
bool partialreject = (m_rdp->GetColorInputs()->blender2b_a[1] == &m_rdp->GetInvPixelColor()->i.a && m_rdp->GetColorInputs()->blender1b_a[1] == &m_rdp->GetPixelColor()->i.a); bool partialreject = (m_rdp->ColorInputs.blender2b_a[1] == &m_rdp->InvPixelColor.i.a && m_rdp->ColorInputs.blender1b_a[1] == &m_rdp->PixelColor.i.a);
bool bsel0 = (m_rdp->GetColorInputs()->blender2b_a[0] == &m_rdp->GetMemoryColor()->i.a); bool bsel0 = (m_rdp->ColorInputs.blender2b_a[0] == &m_rdp->MemoryColor.i.a);
bool bsel1 = (m_rdp->GetColorInputs()->blender2b_a[1] == &m_rdp->GetMemoryColor()->i.a); bool bsel1 = (m_rdp->ColorInputs.blender2b_a[1] == &m_rdp->MemoryColor.i.a);
int dzpix = m_rdp->m_span_dzpix; int dzpix = m_rdp->m_span_dzpix;
int drinc = flip ? (m_rdp->m_span_dr) : -m_rdp->m_span_dr; int drinc = flip ? (m_rdp->m_span_dr) : -m_rdp->m_span_dr;
@ -312,7 +309,7 @@ void Span::Draw2Cycle(int index, int tilenum, bool flip)
int dwinc = flip ? (m_rdp->m_span_dw) : -m_rdp->m_span_dw; int dwinc = flip ? (m_rdp->m_span_dw) : -m_rdp->m_span_dw;
int xinc = flip ? 1 : -1; int xinc = flip ? 1 : -1;
int fb_index = m_misc_state->m_fb_width * index; int fb_index = m_rdp->MiscState.FBWidth * index;
int cdith = 0; int cdith = 0;
int adith = 0; int adith = 0;
@ -324,7 +321,7 @@ void Span::Draw2Cycle(int index, int tilenum, bool flip)
int x = xend; int x = xend;
int length = flip ? (xstart - xend) : (xend - xstart); int length = flip ? (xstart - xend) : (xend - xstart);
m_rdp->GetTexPipe()->m_start_span = true; m_rdp->TexPipe.m_start_span = true;
UINT32 fir, fig, fib; UINT32 fir, fig, fib;
//printf( "Span length: %d\n", length); //printf( "Span length: %d\n", length);
@ -344,10 +341,10 @@ void Span::Draw2Cycle(int index, int tilenum, bool flip)
Color c1; Color c1;
Color c2; Color c2;
if (m_other_modes->z_source_sel) if (m_rdp->OtherModes.z_source_sel)
{ {
sz = (((UINT32)m_misc_state->m_primitive_z) << 6) & 0x3fffff; sz = (((UINT32)m_rdp->MiscState.PrimitiveZ) << 6) & 0x3fffff;
dzpix = m_misc_state->m_primitive_delta_z; dzpix = m_rdp->MiscState.PrimitiveDZ;
dzinc = m_rdp->m_span_dz = m_rdp->m_span_dzdy = 0; dzinc = m_rdp->m_span_dz = m_rdp->m_span_dzdy = 0;
} }
@ -357,9 +354,9 @@ void Span::Draw2Cycle(int index, int tilenum, bool flip)
{ {
m_rdp->lookup_cvmask_derivatives(m_cvg[x], &offx, &offy); m_rdp->lookup_cvmask_derivatives(m_cvg[x], &offx, &offy);
if (m_rdp->GetTexPipe()->m_start_span) if (m_rdp->TexPipe.m_start_span)
{ {
if (m_other_modes->persp_tex_en) if (m_rdp->OtherModes.persp_tex_en)
{ {
m_rdp->TCDiv(ss, st, sw, &sss, &sst); m_rdp->TCDiv(ss, st, sw, &sss, &sst);
} }
@ -370,23 +367,23 @@ void Span::Draw2Cycle(int index, int tilenum, bool flip)
} }
else else
{ {
sss = m_rdp->GetTexPipe()->m_precomp_s; sss = m_rdp->TexPipe.m_precomp_s;
sst = m_rdp->GetTexPipe()->m_precomp_t; sst = m_rdp->TexPipe.m_precomp_t;
} }
m_rdp->GetTexPipe()->LOD2Cycle(&sss, &sst, s.w, t.w, w.w, dsinc, dtinc, dwinc, prim_tile, &tile1, &tile2); m_rdp->TexPipe.LOD2Cycle(&sss, &sst, s.w, t.w, w.w, dsinc, dtinc, dwinc, prim_tile, &tile1, &tile2);
news = m_rdp->GetTexPipe()->m_precomp_s; news = m_rdp->TexPipe.m_precomp_s;
newt = m_rdp->GetTexPipe()->m_precomp_t; newt = m_rdp->TexPipe.m_precomp_t;
m_rdp->GetTexPipe()->LOD2CycleLimited(&news, &newt, s.w + dsinc, t.w + dtinc, w.w + dwinc, dsinc, dtinc, dwinc, prim_tile, &newtile1); m_rdp->TexPipe.LOD2CycleLimited(&news, &newt, s.w + dsinc, t.w + dtinc, w.w + dwinc, dsinc, dtinc, dwinc, prim_tile, &newtile1);
RGBAZCorrectTriangle(offx, offy, &sr, &sg, &sb, &sa, &sz); RGBAZCorrectTriangle(offx, offy, &sr, &sg, &sb, &sa, &sz);
RGBAZClip(sr, sg, sb, sa, &sz); RGBAZClip(sr, sg, sb, sa, &sz);
m_rdp->GetTexPipe()->Cycle(m_rdp->GetTexel0Color(), m_rdp->GetTexel0Color(), sss, sst, tile1, 0); m_rdp->TexPipe.Cycle(&m_rdp->Texel0Color, &m_rdp->Texel0Color, sss, sst, tile1, 0);
m_rdp->GetTexPipe()->Cycle(m_rdp->GetTexel1Color(), m_rdp->GetTexel0Color(), sss, sst, tile2, 1); m_rdp->TexPipe.Cycle(&m_rdp->Texel1Color, &m_rdp->Texel0Color, sss, sst, tile2, 1);
m_rdp->GetTexPipe()->Cycle(m_rdp->GetNextTexelColor(), m_rdp->GetNextTexelColor(), sss, sst, tile2, 1); m_rdp->TexPipe.Cycle(&m_rdp->NextTexelColor, &m_rdp->NextTexelColor, sss, sst, tile2, 1);
m_rdp->ColorCombiner2Cycle(noisecompute); m_rdp->ColorCombiner2Cycle(noisecompute);
@ -394,18 +391,18 @@ void Span::Draw2Cycle(int index, int tilenum, bool flip)
UINT32 zbcur = zb + curpixel; UINT32 zbcur = zb + curpixel;
UINT32 zhbcur = zhb + curpixel; UINT32 zhbcur = zhb + curpixel;
m_rdp->GetFramebuffer()->Read(curpixel); m_rdp->Framebuffer.Read(curpixel);
if(m_rdp->ZCompare(zbcur, zhbcur, sz, dzpix)) if(m_rdp->ZCompare(zbcur, zhbcur, sz, dzpix))
{ {
m_rdp->GetDitherValues(index, j, &cdith, &adith); m_rdp->GetDitherValues(index, j, &cdith, &adith);
bool rendered = m_rdp->GetBlender()->Blend2Cycle(&fir, &fig, &fib, cdith, adith, partialreject, bsel0, bsel1); bool rendered = m_rdp->Blender.Blend2Cycle(&fir, &fig, &fib, cdith, adith, partialreject, bsel0, bsel1);
if (rendered) if (rendered)
{ {
m_rdp->GetFramebuffer()->Write(curpixel, fir, fig, fib); m_rdp->Framebuffer.Write(curpixel, fir, fig, fib);
if (m_other_modes->z_update_en) if (m_rdp->OtherModes.z_update_en)
{ {
m_rdp->ZStore(zbcur, zhbcur, sz); m_rdp->ZStore(zbcur, zhbcur, sz);
} }
@ -440,7 +437,7 @@ void Span::DrawCopy(int index, int tilenum, bool flip)
int dtinc = flip ? (dt) : -dt; int dtinc = flip ? (dt) : -dt;
int xinc = flip ? 1 : -1; int xinc = flip ? 1 : -1;
int fb_index = m_misc_state->m_fb_width * index; int fb_index = m_rdp->MiscState.FBWidth * index;
int xstart = m_lx; int xstart = m_lx;
int xend = m_unscissored_rx; int xend = m_unscissored_rx;
@ -458,13 +455,13 @@ void Span::DrawCopy(int index, int tilenum, bool flip)
{ {
INT32 sss = s.h.h; INT32 sss = s.h.h;
INT32 sst = t.h.h; INT32 sst = t.h.h;
m_rdp->GetTexPipe()->Copy(m_rdp->GetTexel0Color(), sss, sst, tilenum); m_rdp->TexPipe.Copy(&m_rdp->Texel0Color, sss, sst, tilenum);
UINT32 curpixel = fb_index + x; UINT32 curpixel = fb_index + x;
m_misc_state->m_curpixel_cvg = m_rdp->GetTexel0Color()->i.a ? 7 : 0; m_rdp->MiscState.CurrentPixCvg = m_rdp->Texel0Color.i.a ? 7 : 0;
if ((m_rdp->GetTexel0Color()->i.a != 0) || (!m_other_modes->alpha_compare_en)) if ((m_rdp->Texel0Color.i.a != 0) || (!m_rdp->OtherModes.alpha_compare_en))
{ {
m_rdp->GetFramebuffer()->Copy(curpixel, m_rdp->GetTexel0Color()->i.r, m_rdp->GetTexel0Color()->i.g, m_rdp->GetTexel0Color()->i.b); m_rdp->Framebuffer.Copy(curpixel, m_rdp->Texel0Color.i.r, m_rdp->Texel0Color.i.g, m_rdp->Texel0Color.i.b);
} }
} }
@ -481,7 +478,7 @@ void Span::DrawFill(int index, int tilenum, bool flip)
int xinc = flip ? 1 : -1; int xinc = flip ? 1 : -1;
int fb_index = m_misc_state->m_fb_width * index; int fb_index = m_rdp->MiscState.FBWidth * index;
int xstart = m_lx; int xstart = m_lx;
int xend_scissored = m_rx; int xend_scissored = m_rx;
@ -495,7 +492,7 @@ void Span::DrawFill(int index, int tilenum, bool flip)
if (x >= clipx1 && x < clipx2) if (x >= clipx1 && x < clipx2)
{ {
UINT32 curpixel = fb_index + x; UINT32 curpixel = fb_index + x;
m_rdp->GetFramebuffer()->Fill(curpixel); m_rdp->Framebuffer.Fill(curpixel);
} }
x += xinc; x += xinc;

File diff suppressed because it is too large Load Diff

View File

@ -14,10 +14,12 @@ class MiscState;
class Processor; class Processor;
class Color; class Color;
class TexturePipe class TexturePipeT
{ {
public: public:
TexturePipe() typedef UINT32 (N64::RDP::TexturePipeT::*TexelFetcher) (INT32 s, INT32 t, INT32 tbase, INT32 tpal);
TexturePipeT()
{ {
m_maskbits_table[0] = 0x3ff; m_maskbits_table[0] = 0x3ff;
for(int i = 1; i < 16; i++) for(int i = 1; i < 16; i++)
@ -27,6 +29,56 @@ class TexturePipe
m_start_span = false; m_start_span = false;
m_precomp_s = 0; m_precomp_s = 0;
m_precomp_t = 0; m_precomp_t = 0;
for (int idx = 0; idx < 80; idx++)
{
TexelFetch[idx] = &N64::RDP::TexturePipeT::_FetchNOP;
}
TexelFetch[ 8] = &N64::RDP::TexturePipeT::_FetchRGBA_16_RAW;
TexelFetch[ 9] = &N64::RDP::TexturePipeT::_FetchRGBA_16_RAW;
TexelFetch[10] = &N64::RDP::TexturePipeT::_FetchRGBA_16_TLUT0;
TexelFetch[11] = &N64::RDP::TexturePipeT::_FetchRGBA_16_TLUT1;
TexelFetch[12] = &N64::RDP::TexturePipeT::_FetchRGBA_32_RAW;
TexelFetch[13] = &N64::RDP::TexturePipeT::_FetchRGBA_32_RAW;
TexelFetch[14] = &N64::RDP::TexturePipeT::_FetchRGBA_32_TLUT0;
TexelFetch[15] = &N64::RDP::TexturePipeT::_FetchRGBA_32_TLUT1;
TexelFetch[24] = &N64::RDP::TexturePipeT::_FetchYUV;
TexelFetch[25] = &N64::RDP::TexturePipeT::_FetchYUV;
TexelFetch[26] = &N64::RDP::TexturePipeT::_FetchYUV;
TexelFetch[27] = &N64::RDP::TexturePipeT::_FetchYUV;
TexelFetch[32] = &N64::RDP::TexturePipeT::_FetchCI_4_RAW;
TexelFetch[33] = &N64::RDP::TexturePipeT::_FetchCI_4_RAW;
TexelFetch[34] = &N64::RDP::TexturePipeT::_FetchCI_4_TLUT0;
TexelFetch[35] = &N64::RDP::TexturePipeT::_FetchCI_4_TLUT1;
TexelFetch[36] = &N64::RDP::TexturePipeT::_FetchCI_8_RAW;
TexelFetch[37] = &N64::RDP::TexturePipeT::_FetchCI_8_RAW;
TexelFetch[38] = &N64::RDP::TexturePipeT::_FetchCI_8_TLUT0;
TexelFetch[39] = &N64::RDP::TexturePipeT::_FetchCI_8_TLUT1;
TexelFetch[48] = &N64::RDP::TexturePipeT::_FetchIA_4_RAW;
TexelFetch[49] = &N64::RDP::TexturePipeT::_FetchIA_4_RAW;
TexelFetch[50] = &N64::RDP::TexturePipeT::_FetchIA_4_TLUT0;
TexelFetch[51] = &N64::RDP::TexturePipeT::_FetchIA_4_TLUT1;
TexelFetch[52] = &N64::RDP::TexturePipeT::_FetchIA_8_RAW;
TexelFetch[53] = &N64::RDP::TexturePipeT::_FetchIA_8_RAW;
TexelFetch[54] = &N64::RDP::TexturePipeT::_FetchIA_8_TLUT0;
TexelFetch[55] = &N64::RDP::TexturePipeT::_FetchIA_8_TLUT1;
TexelFetch[56] = &N64::RDP::TexturePipeT::_FetchIA_16_RAW;
TexelFetch[57] = &N64::RDP::TexturePipeT::_FetchIA_16_RAW;
TexelFetch[58] = &N64::RDP::TexturePipeT::_FetchIA_16_TLUT0;
TexelFetch[59] = &N64::RDP::TexturePipeT::_FetchIA_16_TLUT1;
TexelFetch[64] = &N64::RDP::TexturePipeT::_FetchI_4_RAW;
TexelFetch[65] = &N64::RDP::TexturePipeT::_FetchI_4_RAW;
TexelFetch[66] = &N64::RDP::TexturePipeT::_FetchI_4_TLUT0;
TexelFetch[67] = &N64::RDP::TexturePipeT::_FetchI_4_TLUT1;
TexelFetch[68] = &N64::RDP::TexturePipeT::_FetchI_8_RAW;
TexelFetch[69] = &N64::RDP::TexturePipeT::_FetchI_8_RAW;
TexelFetch[70] = &N64::RDP::TexturePipeT::_FetchI_8_TLUT0;
TexelFetch[71] = &N64::RDP::TexturePipeT::_FetchI_8_TLUT1;
} }
void Cycle(Color* TEX, Color* prev, INT32 SSS, INT32 SST, UINT32 tilenum, UINT32 cycle); void Cycle(Color* TEX, Color* prev, INT32 SSS, INT32 SST, UINT32 tilenum, UINT32 cycle);
@ -44,6 +96,8 @@ class TexturePipe
INT32 m_precomp_t; INT32 m_precomp_t;
private: private:
UINT32 Expand16To32Table[0x10000];
void Mask(INT32* S, INT32* T, INT32 num); void Mask(INT32* S, INT32* T, INT32 num);
void MaskCoupled(INT32* S, INT32* S1, INT32* T, INT32* T1, INT32 num); void MaskCoupled(INT32* S, INT32* S1, INT32* T, INT32* T1, INT32 num);
@ -53,6 +107,43 @@ class TexturePipe
void ClampCycle(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, INT32 num); void ClampCycle(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, INT32 num);
void ClampCycleLight(INT32* S, INT32* T, bool maxs, bool maxt, INT32 num); void ClampCycleLight(INT32* S, INT32* T, bool maxs, bool maxt, INT32 num);
UINT32 _FetchNOP(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchRGBA_16_TLUT0(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchRGBA_16_TLUT1(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchRGBA_16_RAW(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchRGBA_32_TLUT0(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchRGBA_32_TLUT1(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchRGBA_32_RAW(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchYUV(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchCI_4_TLUT0(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchCI_4_TLUT1(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchCI_4_RAW(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchCI_8_TLUT0(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchCI_8_TLUT1(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchCI_8_RAW(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchIA_4_TLUT0(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchIA_4_TLUT1(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchIA_4_RAW(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchIA_8_TLUT0(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchIA_8_TLUT1(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchIA_8_RAW(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchIA_16_TLUT0(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchIA_16_TLUT1(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchIA_16_RAW(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchI_4_TLUT0(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchI_4_TLUT1(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchI_4_RAW(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchI_8_TLUT0(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchI_8_TLUT1(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
UINT32 _FetchI_8_RAW(INT32 s, INT32 t, INT32 tbase, INT32 tpal);
TexelFetcher TexelFetch[16*5];
running_machine* m_machine; running_machine* m_machine;
OtherModes* m_other_modes; OtherModes* m_other_modes;
MiscState* m_misc_state; MiscState* m_misc_state;

View File

@ -27,7 +27,6 @@ class Triangle
running_machine* m_machine; running_machine* m_machine;
UINT32* m_cmd_data; UINT32* m_cmd_data;
MiscState* m_misc_state;
Processor* m_rdp; Processor* m_rdp;
bool m_shade; bool m_shade;
bool m_texture; bool m_texture;