rasterize: add clear image emulation
This commit is contained in:
parent
c64e50151e
commit
959207cbeb
|
@ -11,7 +11,17 @@ struct ALIGN(16) ARM9_struct {
|
||||||
u8 ARM9_REG[0x1000000];
|
u8 ARM9_REG[0x1000000];
|
||||||
u8 ARM9_BIOS[0x8000];
|
u8 ARM9_BIOS[0x8000];
|
||||||
u8 ARM9_VMEM[0x800];
|
u8 ARM9_VMEM[0x800];
|
||||||
u8 ARM9_LCD[0xA4000+0x4000]; //an extra 16KB for blank memory
|
|
||||||
|
#include "PACKED.h"
|
||||||
|
struct {
|
||||||
|
u8 ARM9_LCD[0xA4000];
|
||||||
|
//an extra 128KB for blank memory, directly after arm9_lcd, so that
|
||||||
|
//we can easily map things to the end of arm9_lcd to represent
|
||||||
|
//an unmapped state
|
||||||
|
u8 blank_memory[0x20000];
|
||||||
|
};
|
||||||
|
#include "PACKED_END.h"
|
||||||
|
|
||||||
u8 ARM9_OAM[0x800];
|
u8 ARM9_OAM[0x800];
|
||||||
|
|
||||||
u8* ExtPal[2][4];
|
u8* ExtPal[2][4];
|
||||||
|
@ -22,7 +32,6 @@ struct ALIGN(16) ARM9_struct {
|
||||||
u8* textureSlotAddr[4];
|
u8* textureSlotAddr[4];
|
||||||
} texInfo;
|
} texInfo;
|
||||||
|
|
||||||
u8 blank_memory[0x20000];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ARM9_struct ARM9Mem;
|
extern ARM9_struct ARM9Mem;
|
||||||
|
|
|
@ -2215,23 +2215,15 @@ static void gfx3d_Control_cache()
|
||||||
{
|
{
|
||||||
u32 v = control;
|
u32 v = control;
|
||||||
|
|
||||||
if(v&1) gfx3d.enableTexturing = TRUE;
|
if(BIT1(v)) gfx3d.shading = GFX3D::HIGHLIGHT;
|
||||||
else gfx3d.enableTexturing = FALSE;
|
|
||||||
|
|
||||||
if((v>>1)&1) gfx3d.shading = GFX3D::HIGHLIGHT;
|
|
||||||
else gfx3d.shading = GFX3D::TOON;
|
else gfx3d.shading = GFX3D::TOON;
|
||||||
|
|
||||||
if((v>>2)&1) gfx3d.enableAlphaTest = TRUE;
|
gfx3d.enableTexturing = BIT0(v);
|
||||||
else gfx3d.enableAlphaTest = FALSE;
|
gfx3d.enableAlphaTest = BIT2(v);
|
||||||
|
gfx3d.enableAlphaBlending = BIT3(v);
|
||||||
if((v>>3)&1) gfx3d.enableAlphaBlending = TRUE;
|
gfx3d.enableAntialiasing = BIT4(v);
|
||||||
else gfx3d.enableAlphaBlending = FALSE;
|
gfx3d.enableEdgeMarking = BIT5(v);
|
||||||
|
gfx3d.enableClearImage = BIT14(v);
|
||||||
if((v>>4)&1) gfx3d.enableAntialiasing = TRUE;
|
|
||||||
else gfx3d.enableAntialiasing = FALSE;
|
|
||||||
|
|
||||||
if((v>>5)&1) gfx3d.enableEdgeMarking = TRUE;
|
|
||||||
else gfx3d.enableEdgeMarking = FALSE;
|
|
||||||
|
|
||||||
//other junk
|
//other junk
|
||||||
if (v&(1<<14))
|
if (v&(1<<14))
|
||||||
|
|
|
@ -175,6 +175,7 @@ struct GFX3D
|
||||||
, enableAlphaBlending(true)
|
, enableAlphaBlending(true)
|
||||||
, enableAntialiasing(false)
|
, enableAntialiasing(false)
|
||||||
, enableEdgeMarking(false)
|
, enableEdgeMarking(false)
|
||||||
|
, enableClearImage(false)
|
||||||
, shading(TOON)
|
, shading(TOON)
|
||||||
, polylist(0)
|
, polylist(0)
|
||||||
, vertlist(0)
|
, vertlist(0)
|
||||||
|
@ -187,7 +188,8 @@ struct GFX3D
|
||||||
fogColor[0] = fogColor[1] = fogColor[2] = fogColor[3] = 0;
|
fogColor[0] = fogColor[1] = fogColor[2] = fogColor[3] = 0;
|
||||||
fogOffset = 0;
|
fogOffset = 0;
|
||||||
}
|
}
|
||||||
BOOL enableTexturing, enableAlphaTest, enableAlphaBlending, enableAntialiasing, enableEdgeMarking;
|
BOOL enableTexturing, enableAlphaTest, enableAlphaBlending,
|
||||||
|
enableAntialiasing, enableEdgeMarking, enableClearImage;
|
||||||
|
|
||||||
static const u32 TOON = 0;
|
static const u32 TOON = 0;
|
||||||
static const u32 HIGHLIGHT = 1;
|
static const u32 HIGHLIGHT = 1;
|
||||||
|
|
|
@ -364,17 +364,17 @@ struct Shader
|
||||||
dst.b = modulate_table[texColor.b][materialColor.b];
|
dst.b = modulate_table[texColor.b][materialColor.b];
|
||||||
dst.a = modulate_table[texColor.a][materialColor.a];
|
dst.a = modulate_table[texColor.a][materialColor.a];
|
||||||
//dst.color.components.a = 31;
|
//dst.color.components.a = 31;
|
||||||
//#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
//if(GetAsyncKeyState(VK_SHIFT)) {
|
if(GetAsyncKeyState(VK_SHIFT)) {
|
||||||
// //debugging tricks
|
//debugging tricks
|
||||||
// dst = materialColor;
|
dst = materialColor;
|
||||||
// if(GetAsyncKeyState(VK_TAB)) {
|
if(GetAsyncKeyState(VK_TAB)) {
|
||||||
// u8 alpha = dst.a;
|
u8 alpha = dst.a;
|
||||||
// dst.color = polynum*8+8;
|
dst.color = polynum*8+8;
|
||||||
// dst.a = alpha;
|
dst.a = alpha;
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
//#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 1: //decal
|
case 1: //decal
|
||||||
u = invu*w;
|
u = invu*w;
|
||||||
|
@ -469,10 +469,8 @@ static FORCEINLINE void pixel(int adr,float r, float g, float b, float invu, flo
|
||||||
{
|
{
|
||||||
float test = -1.2f;
|
float test = -1.2f;
|
||||||
u32 test2 = u32floor(test);
|
u32 test2 = u32floor(test);
|
||||||
//depth = fastFloor(z*0x7FFF)>>8;
|
//depth = u32floor(z*0x7FFF); //the traditional value
|
||||||
//depth = (u32)(z*0x7FFF);
|
depth = u32floor(z*0xFFFFFF); //sonic chronicles uses depth clear and this makes it work
|
||||||
depth = u32floor(z*0x7FFF);
|
|
||||||
//depth = z*0xFFFFFF;
|
|
||||||
}
|
}
|
||||||
if(polyAttr.decalMode)
|
if(polyAttr.decalMode)
|
||||||
{
|
{
|
||||||
|
@ -1173,6 +1171,46 @@ static void SoftRastRender()
|
||||||
clearFragment.stencil = 0;
|
clearFragment.stencil = 0;
|
||||||
for(int i=0;i<256*192;i++)
|
for(int i=0;i<256*192;i++)
|
||||||
screen[i] = clearFragment;
|
screen[i] = clearFragment;
|
||||||
|
|
||||||
|
if(gfx3d.enableClearImage)
|
||||||
|
{
|
||||||
|
u16* clearImage = (u16*)ARM9Mem.texInfo.textureSlotAddr[2];
|
||||||
|
u16* clearDepth = (u16*)ARM9Mem.texInfo.textureSlotAddr[3];
|
||||||
|
|
||||||
|
//not emulated until we actually have a test case
|
||||||
|
//(since in the meantime it would just slow us down)
|
||||||
|
//(and when we find a case, it will be obvious that it isnt scrolling, instead of possibly obscured by a bug)
|
||||||
|
u16 scroll = T1ReadWord(ARM9Mem.ARM9_REG,0x356); //CLRIMAGE_OFFSET
|
||||||
|
u16 xscroll = scroll&0xFF;
|
||||||
|
u16 yscroll = (scroll>>8)&0xFF;
|
||||||
|
|
||||||
|
FragmentColor *dstColor = screenColor;
|
||||||
|
Fragment *dst = screen;
|
||||||
|
|
||||||
|
for(int y=0;y<192;y++)
|
||||||
|
for(int x=0;x<256;x++) {
|
||||||
|
|
||||||
|
//this hasnt been tested
|
||||||
|
//TODO - dont do this if we are mapped to blank memory (such as in sonic chronicles)
|
||||||
|
//(or use a special zero fill in the bulk clearing above)
|
||||||
|
u16 col = *clearImage;
|
||||||
|
dstColor->color = RGB15TO32(255*(col>>15),col);
|
||||||
|
|
||||||
|
//this is tested quite well in the sonic chronicles main map mode
|
||||||
|
//where depth values are used for trees etc you can walk behind
|
||||||
|
u32 depth = *clearDepth;
|
||||||
|
//masking off fog for now
|
||||||
|
depth &= 0x7FFF;
|
||||||
|
//TODO - might consider a lookup table for this
|
||||||
|
dst->depth = (depth*0x200)+((depth+1)>>15)*0x01FF;
|
||||||
|
|
||||||
|
clearDepth++;
|
||||||
|
clearImage++;
|
||||||
|
dstColor++;
|
||||||
|
dst++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
for(int i=0;i<256*192;i++)
|
for(int i=0;i<256*192;i++)
|
||||||
screenColor[i] = clearFragmentColor;
|
screenColor[i] = clearFragmentColor;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue