diff --git a/common/common.h b/common/common.h index 6eb31dd..028dc90 100644 --- a/common/common.h +++ b/common/common.h @@ -59,11 +59,12 @@ static inline color_t MakeColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) #ifdef SWITCH extern uint8_t* g_framebuf; +extern u32 g_framebuf_width; static inline void DrawPixel(uint32_t x, uint32_t y, color_t clr) { if (x >= 1280 || y >= 720) return; - u32 off = 4*gfxGetFramebufferDisplayOffset(x, y); + u32 off = (y * g_framebuf_width + x)*4; g_framebuf[off] = BlendColor(g_framebuf[off], clr.r, clr.a); off++; g_framebuf[off] = BlendColor(g_framebuf[off], clr.g, clr.a); off++; g_framebuf[off] = BlendColor(g_framebuf[off], clr.b, clr.a); off++; @@ -73,7 +74,7 @@ static inline void DrawPixelRaw(uint32_t x, uint32_t y, color_t clr) { if (x >= 1280 || y >= 720) return; - u32 off = 4*gfxGetFramebufferDisplayOffset(x, y); + u32 off = (y * g_framebuf_width + x)*4; g_framebuf[off] = clr.r; off++; g_framebuf[off] = clr.g; off++; g_framebuf[off] = clr.b; off++; diff --git a/nx_main/main.c b/nx_main/main.c index 682b455..eee6fa1 100644 --- a/nx_main/main.c +++ b/nx_main/main.c @@ -5,6 +5,7 @@ #include "../common/common.h" uint8_t* g_framebuf; +u32 g_framebuf_width; int main(int argc, char **argv) { @@ -21,7 +22,7 @@ int main(int argc, char **argv) //Scan all the inputs. This should be done once for each frame hidScanInput(); - g_framebuf = gfxGetFramebuffer(NULL, NULL); + g_framebuf = gfxGetFramebuffer(&g_framebuf_width, NULL); memset(g_framebuf, 237, gfxGetFramebufferSize()); if (!uiUpdate()) break; menuLoop();