Use u32 for gfxGetFramebuffer() width/height. Added gfxGetFramebufferDisplayOffset().

This commit is contained in:
yellows8 2017-11-20 19:15:54 -05:00
parent 24adf197af
commit 8f459cf958
2 changed files with 21 additions and 2 deletions

View File

@ -4,5 +4,7 @@ void gfxExit(void);
void gfxWaitForVsync(); void gfxWaitForVsync();
void gfxSwapBuffers(); void gfxSwapBuffers();
u8* gfxGetFramebuffer(u16* width, u16* height); u8* gfxGetFramebuffer(u32* width, u32* height);
void gfxFlushBuffers(void); void gfxFlushBuffers(void);
u32 gfxGetFramebufferDisplayOffset(u32 x, u32 y);

View File

@ -231,7 +231,7 @@ void gfxSwapBuffers() {
if (R_FAILED(rc)) fatalSimple(rc); if (R_FAILED(rc)) fatalSimple(rc);
} }
u8* gfxGetFramebuffer(u16* width, u16* height) { u8* gfxGetFramebuffer(u32* width, u32* height) {
if(width) *width = 1280; if(width) *width = 1280;
if(height) *height = 720; if(height) *height = 720;
@ -242,3 +242,20 @@ void gfxFlushBuffers(void) {
armDCacheFlush(&g_gfxFramebuf[g_gfxCurrentBuffer*g_nvgfx_singleframebuf_size], g_nvgfx_singleframebuf_size); armDCacheFlush(&g_gfxFramebuf[g_gfxCurrentBuffer*g_nvgfx_singleframebuf_size], g_nvgfx_singleframebuf_size);
} }
//This implements tegra blocklinear, with hard-coded constants etc.
u32 gfxGetFramebufferDisplayOffset(u32 x, u32 y) {
u32 width=0, height=0;
u32 tilepos, tmp_pos;
gfxGetFramebuffer(&width, &height);
y = height-1-y;
tilepos = ((y & 127) / 16) + (x/16*8) + ((y/16/8)*(width/16*8));
tilepos = tilepos*16*16 * 4;
tmp_pos = ((y%16)/8)*512 + ((x%16)/8)*256 + ((y%8)/2)*64 + ((x%8)/4)*32 + (y%2)*16 + (x%4)*4;//This line is a modified version of code from the Tegra X1 datasheet.
return tilepos + tmp_pos;
}