diff --git a/misc/ps1/ps1defs.h b/misc/ps1/ps1defs.h index fdca41868..b92c8677e 100644 --- a/misc/ps1/ps1defs.h +++ b/misc/ps1/ps1defs.h @@ -1,3 +1,7 @@ +// Scratchpad memory is essentially data cache of CPU, +// and so takes less cycles to access +#define SCRATCHPAD_MEM ((cc_uint8*)0x1F800000) + enum dma_chrc_flags { CHRC_STATUS_BUSY = (1 << 24), }; diff --git a/misc/wiiu/ps_textured_exp.psh b/misc/wiiu/ps_textured_exp.psh index 6ac5cd167..de9f80f0c 100644 --- a/misc/wiiu/ps_textured_exp.psh +++ b/misc/wiiu/ps_textured_exp.psh @@ -3,6 +3,10 @@ ; $SAMPLER_VARS[0].type= "sampler2D" ; $SAMPLER_VARS[0].location = 0 +; Set position field enabled +; https://github.com/DirectFB/mesa/blob/01e637114914453451becc0dc8afe60faff48d84/src/gallium/drivers/r600/r600_state.c#L2925 +; $SPI_PS_IN_CONTROL_0.POSITION_ENA = true + ; $NUM_SPI_PS_INPUT_CNTL = 2 ; $SPI_PS_INPUT_CNTL[0].semantic = 0 ; $SPI_PS_INPUT_CNTL[0].default_val = 1 diff --git a/misc/wiiu/ps_textured_lin.psh b/misc/wiiu/ps_textured_lin.psh index 7b656ec82..cad2b5db1 100644 --- a/misc/wiiu/ps_textured_lin.psh +++ b/misc/wiiu/ps_textured_lin.psh @@ -3,6 +3,10 @@ ; $SAMPLER_VARS[0].type= "sampler2D" ; $SAMPLER_VARS[0].location = 0 +; Set position field enabled +; https://github.com/DirectFB/mesa/blob/01e637114914453451becc0dc8afe60faff48d84/src/gallium/drivers/r600/r600_state.c#L2925 +; $SPI_PS_IN_CONTROL_0.POSITION_ENA = true + ; $NUM_SPI_PS_INPUT_CNTL = 2 ; $SPI_PS_INPUT_CNTL[0].semantic = 0 ; $SPI_PS_INPUT_CNTL[0].default_val = 1 diff --git a/misc/wiiu/shaders.txt b/misc/wiiu/shaders.txt index c2c9ba7f5..830a83a26 100644 --- a/misc/wiiu/shaders.txt +++ b/misc/wiiu/shaders.txt @@ -8,6 +8,7 @@ https://github.com/rw-r-r-0644/gx2-texture/blob/83d7707e8d4b33ec7ba63d5c7dfe62c3 https://github.com/yawut/ntrview-wiiu/blob/45b1c7f05cfd9917b8b171f3db08dc63293fc5c5/gfx/gx2_shaders/main.psh https://github.com/Hydr8gon/NooDS/blob/b41cb3b9b889481c998e7e83db1ab3ef9d97b838/src/console/shaders/shader_wiiu.vsh https://github.com/luRaichu/recsbr/blob/163fa441712f6b25e780e914617941c2385b330e/src/Backends/Rendering/WiiUShaders/shader%20sources/wtf%20is%20this.txt +https://github.com/comex/quiet_/blob/4b55e8c9585e336ad3e09628d951a4d7321e70f7/qmod/shader2.psh#L4 To generate shader assembly 1) Get AMD ShaderAnalyzer diff --git a/misc/wiiu/textured_exp.gsh b/misc/wiiu/textured_exp.gsh index 6ef52e1e3..37160de1f 100644 Binary files a/misc/wiiu/textured_exp.gsh and b/misc/wiiu/textured_exp.gsh differ diff --git a/misc/wiiu/textured_lin.gsh b/misc/wiiu/textured_lin.gsh index a5d231e65..c31640255 100644 Binary files a/misc/wiiu/textured_lin.gsh and b/misc/wiiu/textured_lin.gsh differ diff --git a/src/Graphics_PS1.c b/src/Graphics_PS1.c index bf2ced4f4..b1294cdd7 100644 --- a/src/Graphics_PS1.c +++ b/src/Graphics_PS1.c @@ -393,28 +393,31 @@ static void CreateFullTexture(BitmapCol* tmp, struct Bitmap* bmp, int rowWidth) } static void CreatePalettedTexture(BitmapCol* tmp, struct Bitmap* bmp, int rowWidth, BitmapCol* palette, int pal_count) { - cc_uint8* buf = (cc_uint8*)tmp; + cc_uint8* dst = (cc_uint8*)tmp; + BitmapCol* src = bmp->scan0; + int stride = (bmp->width * 2) >> 2; for (int y = 0; y < bmp->height; y++) { - BitmapCol* row = bmp->scan0 + y * rowWidth; - for (int x = 0; x < bmp->width; x++) { - int idx = FindInPalette(palette, pal_count, row[x]); + int idx = FindInPalette(palette, pal_count, src[x]); if ((x & 1) == 0) { - buf[x >> 1] = idx; + dst[x >> 1] = idx; } else { - buf[x >> 1] |= idx << 4; + dst[x >> 1] |= idx << 4; } } + + src += rowWidth; + dst += stride; } } static void* AllocTextureAt(int i, struct Bitmap* bmp, int rowWidth) { - BitmapCol palette[16]; - int pal_count = 0;//CalcPalette(palette, bmp, rowWidth); TODO fix + BitmapCol palette[16]; // = (BitmapCol*)SCRATCHPAD_MEM; TODO doesn't work + int pal_count = CalcPalette(palette, bmp, rowWidth); cc_uint16* tmp; int tmp_size; @@ -468,11 +471,11 @@ static void* AllocTextureAt(int i, struct Bitmap* bmp, int rowWidth) { int x = pageX * TPAGE_WIDTH + tex->xOffset; int y = pageY * TPAGE_HEIGHT + tex->yOffset; - int w = pal_count > 0 ? (bmp->width / 4) : bmp->width; + int w = pal_count > 0 ? (bmp->width >> 2) : bmp->width; int h = bmp->height; - Platform_Log2(" LOAD AT: %i, %i", &x, &y); - Gfx_TransferToVRAM(x, y, w, h, tmp); + Platform_Log4(" LOAD AT: %i, %i (%i x %i)", &x, &y, &w, &h); + Gfx_TransferToVRAM(x, y, w, h, tmp); Mem_Free(tmp); return tex; diff --git a/src/Graphics_WiiU.c b/src/Graphics_WiiU.c index ff40e8f54..b8daad6c6 100644 --- a/src/Graphics_WiiU.c +++ b/src/Graphics_WiiU.c @@ -130,7 +130,7 @@ static void UpdatePS(void) { cur_PS = texture_PS[2]; } else if (gfx_fogEnabled && fog_func == FOG_LINEAR) { cur_PS = texture_PS[1]; - } */else { + */} else { cur_PS = texture_PS[0]; } GX2SetPixelShader(cur_PS);