rasterize: add clear image emulation
This commit is contained in:
parent
c64e50151e
commit
959207cbeb
|
@ -4,25 +4,34 @@
|
|||
#include "types.h"
|
||||
|
||||
struct ALIGN(16) ARM9_struct {
|
||||
//ARM9 mem
|
||||
u8 ARM9_ITCM[0x8000];
|
||||
u8 ARM9_DTCM[0x4000];
|
||||
u8 MAIN_MEM[0x800000]; //this has been expanded to 8MB to support debug consoles
|
||||
u8 ARM9_REG[0x1000000];
|
||||
u8 ARM9_BIOS[0x8000];
|
||||
u8 ARM9_VMEM[0x800];
|
||||
u8 ARM9_LCD[0xA4000+0x4000]; //an extra 16KB for blank memory
|
||||
u8 ARM9_OAM[0x800];
|
||||
|
||||
u8* ExtPal[2][4];
|
||||
u8* ObjExtPal[2][2];
|
||||
|
||||
struct TextureInfo {
|
||||
u8* texPalSlot[6];
|
||||
u8* textureSlotAddr[4];
|
||||
} texInfo;
|
||||
//ARM9 mem
|
||||
u8 ARM9_ITCM[0x8000];
|
||||
u8 ARM9_DTCM[0x4000];
|
||||
u8 MAIN_MEM[0x800000]; //this has been expanded to 8MB to support debug consoles
|
||||
u8 ARM9_REG[0x1000000];
|
||||
u8 ARM9_BIOS[0x8000];
|
||||
u8 ARM9_VMEM[0x800];
|
||||
|
||||
#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* ExtPal[2][4];
|
||||
u8* ObjExtPal[2][2];
|
||||
|
||||
struct TextureInfo {
|
||||
u8* texPalSlot[6];
|
||||
u8* textureSlotAddr[4];
|
||||
} texInfo;
|
||||
|
||||
};
|
||||
|
||||
extern ARM9_struct ARM9Mem;
|
||||
|
|
|
@ -2215,23 +2215,15 @@ static void gfx3d_Control_cache()
|
|||
{
|
||||
u32 v = control;
|
||||
|
||||
if(v&1) gfx3d.enableTexturing = TRUE;
|
||||
else gfx3d.enableTexturing = FALSE;
|
||||
|
||||
if((v>>1)&1) gfx3d.shading = GFX3D::HIGHLIGHT;
|
||||
if(BIT1(v)) gfx3d.shading = GFX3D::HIGHLIGHT;
|
||||
else gfx3d.shading = GFX3D::TOON;
|
||||
|
||||
if((v>>2)&1) gfx3d.enableAlphaTest = TRUE;
|
||||
else gfx3d.enableAlphaTest = FALSE;
|
||||
|
||||
if((v>>3)&1) gfx3d.enableAlphaBlending = TRUE;
|
||||
else gfx3d.enableAlphaBlending = FALSE;
|
||||
|
||||
if((v>>4)&1) gfx3d.enableAntialiasing = TRUE;
|
||||
else gfx3d.enableAntialiasing = FALSE;
|
||||
|
||||
if((v>>5)&1) gfx3d.enableEdgeMarking = TRUE;
|
||||
else gfx3d.enableEdgeMarking = FALSE;
|
||||
gfx3d.enableTexturing = BIT0(v);
|
||||
gfx3d.enableAlphaTest = BIT2(v);
|
||||
gfx3d.enableAlphaBlending = BIT3(v);
|
||||
gfx3d.enableAntialiasing = BIT4(v);
|
||||
gfx3d.enableEdgeMarking = BIT5(v);
|
||||
gfx3d.enableClearImage = BIT14(v);
|
||||
|
||||
//other junk
|
||||
if (v&(1<<14))
|
||||
|
|
|
@ -175,6 +175,7 @@ struct GFX3D
|
|||
, enableAlphaBlending(true)
|
||||
, enableAntialiasing(false)
|
||||
, enableEdgeMarking(false)
|
||||
, enableClearImage(false)
|
||||
, shading(TOON)
|
||||
, polylist(0)
|
||||
, vertlist(0)
|
||||
|
@ -187,7 +188,8 @@ struct GFX3D
|
|||
fogColor[0] = fogColor[1] = fogColor[2] = fogColor[3] = 0;
|
||||
fogOffset = 0;
|
||||
}
|
||||
BOOL enableTexturing, enableAlphaTest, enableAlphaBlending, enableAntialiasing, enableEdgeMarking;
|
||||
BOOL enableTexturing, enableAlphaTest, enableAlphaBlending,
|
||||
enableAntialiasing, enableEdgeMarking, enableClearImage;
|
||||
|
||||
static const u32 TOON = 0;
|
||||
static const u32 HIGHLIGHT = 1;
|
||||
|
|
|
@ -364,17 +364,17 @@ struct Shader
|
|||
dst.b = modulate_table[texColor.b][materialColor.b];
|
||||
dst.a = modulate_table[texColor.a][materialColor.a];
|
||||
//dst.color.components.a = 31;
|
||||
//#ifdef _MSC_VER
|
||||
//if(GetAsyncKeyState(VK_SHIFT)) {
|
||||
// //debugging tricks
|
||||
// dst = materialColor;
|
||||
// if(GetAsyncKeyState(VK_TAB)) {
|
||||
// u8 alpha = dst.a;
|
||||
// dst.color = polynum*8+8;
|
||||
// dst.a = alpha;
|
||||
// }
|
||||
//}
|
||||
//#endif
|
||||
#ifdef _MSC_VER
|
||||
if(GetAsyncKeyState(VK_SHIFT)) {
|
||||
//debugging tricks
|
||||
dst = materialColor;
|
||||
if(GetAsyncKeyState(VK_TAB)) {
|
||||
u8 alpha = dst.a;
|
||||
dst.color = polynum*8+8;
|
||||
dst.a = alpha;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 1: //decal
|
||||
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;
|
||||
u32 test2 = u32floor(test);
|
||||
//depth = fastFloor(z*0x7FFF)>>8;
|
||||
//depth = (u32)(z*0x7FFF);
|
||||
depth = u32floor(z*0x7FFF);
|
||||
//depth = z*0xFFFFFF;
|
||||
//depth = u32floor(z*0x7FFF); //the traditional value
|
||||
depth = u32floor(z*0xFFFFFF); //sonic chronicles uses depth clear and this makes it work
|
||||
}
|
||||
if(polyAttr.decalMode)
|
||||
{
|
||||
|
@ -1173,8 +1171,48 @@ static void SoftRastRender()
|
|||
clearFragment.stencil = 0;
|
||||
for(int i=0;i<256*192;i++)
|
||||
screen[i] = clearFragment;
|
||||
for(int i=0;i<256*192;i++)
|
||||
screenColor[i] = clearFragmentColor;
|
||||
|
||||
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++)
|
||||
screenColor[i] = clearFragmentColor;
|
||||
|
||||
//convert colors to float to get more precision in case we need it
|
||||
for(int i=0;i<gfx3d.vertlist->count;i++)
|
||||
|
|
Loading…
Reference in New Issue