diff --git a/src/nu/nugfxsetcfb.c b/src/nu/nugfxsetcfb.c index 6c950b5..b176722 100644 --- a/src/nu/nugfxsetcfb.c +++ b/src/nu/nugfxsetcfb.c @@ -1,3 +1,37 @@ #include "common.h" -INCLUDE_ASM(const s32, "nu/nugfxsetcfb", nuGfxSetCfb); +#include "nu/nusys.h" + +void nuGfxSetCfb(u16** framebuf, u32 framebufnum) { + u32 i; + + nuGfxCfb = framebuf; + nuGfxCfbNum = framebufnum; + nuGfxCfbCounter = 0; + nuGfxCfb_ptr = nuGfxCfb[0]; + + nuGfxRetraceWait(1); + nuScSetFrameBufferNum(framebufnum); + + if (framebufnum > 1) { + s32 i; + + for (i = 0; i < framebufnum - 1; i++) { + if (nuGfxCfb[i] != nuGfxCfb[i+1]) { + break; + } + } + + if (i == framebufnum - 1) { + nuScSetFrameBufferNum(1); + } else { + for (i = 0; i < framebufnum; i++) { + if (osViGetNextFramebuffer() != nuGfxCfb[i]) { + nuGfxCfbCounter = i; + nuGfxCfb_ptr = nuGfxCfb[i]; + break; + } + } + } + } +} \ No newline at end of file