(3DS) wrap texture coordinate swizzeling in a function.

This commit is contained in:
aliaspider 2016-10-10 22:22:08 +01:00
parent 1aafa29562
commit c78f697c16
4 changed files with 15 additions and 9 deletions

View File

@ -19,7 +19,7 @@ void dump_result_value(Result val);
#define DEBUG_VAR(X) printf( "%-20s: 0x%08X\n", #X, (u32)(X))
#define DEBUG_INT(X) printf( "%-20s: %10i\n", #X, (s32)(X))
#define DEBUG_VAR64(X) printf( #X"\r\t\t\t\t : 0x%016llX\n", (u64)(X))
#define DEBUG_ERROR(X) do{if(X)dump_result_value(X)}while(0)
#define DEBUG_ERROR(X) do{if(X)dump_result_value(X);}while(0)
#define PRINTFPOS(X,Y) "\x1b["#X";"#Y"H"
#define PRINTFPOS_STR(X,Y) "\x1b["X";"Y"H"
#define PRINTF_LINE(X) "\x1b["X";0H"

View File

@ -137,7 +137,7 @@ extern const char* __system_arglist;
char __argv_hmac[0x20] = {0x1d, 0x78, 0xff, 0xb9, 0xc5, 0xbc, 0x78, 0xb7, 0xac, 0x29, 0x1d, 0x3e, 0x16, 0xd0, 0xcf, 0x53,
0xef, 0x12, 0x58, 0x83, 0xb6, 0x9e, 0x2f, 0x79, 0x47, 0xf9, 0x35, 0x61, 0xeb, 0x50, 0xd7, 0x67};
Result APT_ReceiveDeliverArg(void* param, size_t param_size, void* hmac, size_t hmac_size, u64* source_pid, bool* received)
Result APT_ReceiveDeliverArg_(void* param, size_t param_size, void* hmac, size_t hmac_size, u64* source_pid, bool* received)
{
u32 cmdbuf[16];
cmdbuf[0]=IPC_MakeHeader(0x35,2,0);
@ -187,7 +187,7 @@ void __system_initArgv(void)
bool received;
if(!__service_ptr
&& R_SUCCEEDED(APT_ReceiveDeliverArg(&param, sizeof(param), hmac, sizeof(hmac), NULL, &received))
&& R_SUCCEEDED(APT_ReceiveDeliverArg_(&param, sizeof(param), hmac, sizeof(hmac), NULL, &received))
&& received
&& !memcmp(hmac, __argv_hmac, sizeof(__argv_hmac)))
arg_struct = (void*)param;

View File

@ -237,4 +237,15 @@ static INLINE void ctrGuSetVshGsh(shaderProgram_s* sp, DVLB_s* dvlb, u32 vsh_out
shaderProgramSetGsh(sp, &dvlb->DVLE[1], gsh_input_count);
}
__attribute__((always_inline))
static INLINE int ctrgu_swizzle_coords(int x, int y, int width)
{
int pos = (x & 0x1) << 0 | ((x & 0x2) << 1) | ((x & 0x4) << 2) |
(y & 0x1) << 1 | ((y & 0x2) << 2) | ((y & 0x4) << 3);
return ((x >> 3) << 6) + ((y >> 3) * ((width >> 3) << 6)) + pos;
}
#endif // CTR_GU_H

View File

@ -78,12 +78,7 @@ static void* ctr_font_init_font(void* data, const char* font_path, float font_si
for (j = 0; (j < atlas->height) && (j < font->texture.height); j++)
for (i = 0; (i < atlas->width) && (i < font->texture.width); i++)
{
int pos = (i & 0x1) << 0 | ((i & 0x2) << 1) | ((i & 0x4) << 2) |
(j & 0x1) << 1 | ((j & 0x2) << 2) | ((j & 0x4) << 3);
tmp[((i >> 3) << 6) + ((j >> 3) * ((font->texture.width >> 3) << 6)) + pos ] = src[i + j * atlas->width];
}
tmp[ctrgu_swizzle_coords(i, j, font->texture.width)] = src[i + j * atlas->width];
GSPGPU_FlushDataCache(tmp, font->texture.width * font->texture.height);