mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Use u32 for gfxGetFramebuffer() width/height. Added gfxGetFramebufferDisplayOffset().
This commit is contained in:
parent
24adf197af
commit
8f459cf958
@ -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);
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user