/*** Disable the console. @function disableConsole */ static int gfx_disableConsole(lua_State *L) { gfxSetScreenFormat(consoleScreen, GSP_BGR8_OES); gfxSetDoubleBuffering(consoleScreen, true); gfxSwapBuffersGpu(); gspWaitForVBlank(); return 0; }
STATIC mp_obj_t mod_citrus_gfx_set_screen_format(mp_obj_t which, mp_obj_t format) { int screen = _mod_citrus_gfx_get_gfx_screen(which); int fmt = _mod_citrus_gsp_get_framebuffer_format(format); gfxSetScreenFormat(screen, fmt); return mp_const_none; }
/// A very bad implementation for consoleExit, only for debug. PrintConsole* consoleExit(gfxScreen_t screen, PrintConsole* console) { // TODO Future implementation! *currentConsole = *consoleGetDefault(); gfxSetScreenFormat(screen, GSP_BGR8_OES); gfxSetDoubleBuffering(screen, true); gspWaitForVBlank(); return console; }
int main() { gfxInitDefault(); gfxSet3D(true); // uncomment if using stereoscopic 3D gfxFlushBuffers(); transparent = BLACK; gfxSetScreenFormat(GFX_TOP, GSP_BGR8_OES); gfxSetScreenFormat(GFX_BOTTOM, GSP_BGR8_OES); InitParx(BLACK); /* ParxLeft = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL); ParxRight = gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL); ParxBot = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL); ClrParx(ParxLeft, BLACK); ClrParx(ParxRight, BLACK); ClrParx(ParxBot, BLACK); */ char* str[256]; int l, k, j, i=20, posx = 100, posy = 100; TBGR rgbsam; TBGR rgb; u64 time; // Main loop while (aptMainLoop()) { // gspWaitForVBlank(); // ParxLeft = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL); // ParxRight = gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL); // ParxBot = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL); hidScanInput(); u32 kDown = hidKeysHeld(); if (kDown & KEY_START) break; // break in order to return to hbmenu if (kDown & KEY_A) { CanvasString(ParxBot, CopyRight(), 10,10, LIGHT_GREEN); } if (kDown & KEY_B) { time= osGetTime(); rgb.r= 0xCC; rgb.g= 0x33; rgb.b= 0xCC; for (k=0;k<400;k++) for (l=0;l<240;l++) { SetPixL(k,l,rgb); //TopLCD SetPixR(k,l,rgb); if (k<320) SetPixB(k,l,rgb); //BotLCD } time = osGetTime() - time; sprintf(str, "%i:ms ParxPro SetPix L/R/B,kdl", time); CanvasString(ParxBot, str, 10,10, GREEN); } if (kDown & KEY_X) { TestPattern(); } if (kDown & KEY_Y) { InitParx(BLACK); // PasBotfill(ParxBot); rgb.r= 0xFF; rgb.g= 0x00; rgb.b= 0x8F; PasClrSrc(ParxBot, rgb); CanvasString(ParxBot, "InitParx", 10,10, GREEN); } if(kDown & KEY_CPAD_DOWN) { rgb.r= 0x00; rgb.g= 0x00; rgb.b= 0XFF; PasTopfill(ParxLeft, rgb); PasTopfill(ParxRight, rgb); } if(kDown & KEY_CPAD_UP) { rgb.r= 0xFF; rgb.g= 0x00; rgb.b= 0x00; PasTopfill(ParxLeft, rgb); PasTopfill(ParxRight, rgb); } if(kDown & KEY_CPAD_RIGHT) { rgb.r= 0x00; rgb.g= 0xFF; rgb.b= 0x00; time= osGetTime(); PasTopfill(ParxLeft, rgb); PasTopfill(ParxRight, rgb); time = osGetTime() - time; sprintf(str, "%i:ms L&R BGRTop,kdl", time); CanvasString(ParxBot, str, 10,10, GREEN); } if(kDown & KEY_CPAD_LEFT) { rgb.r= 0x00; rgb.g= 0x11; rgb.b= 0x00; time= osGetTime(); HexTopfill(ParxLeft); HexTopfill(ParxRight); time = osGetTime() - time; sprintf(str, "%i:ms L&R TopMapLED,kdl", time); CanvasString(ParxBot, str, 10,10, GREEN); } if(kDown & KEY_R) { InitBufSingle(BLACK); Topfill2; // ClrParx(ParxBot, BLACK); // sprintf(str, "Dergibal Rad:%i X:%i Y:%i", i, posx, posy); // CanvasString(ParxBot, str, 0, 0, RED); } if(kDown & KEY_L) { InitBufDub(BLACK); Topfill1; // ClrParx(ParxBot, BLACK); // sprintf(str, "Dergibal Rad:%i X:%i Y:%i", i, posx, posy); // CanvasString(ParxBot, str, 0, 0, RED); } if(kDown & KEY_DUP) { for (k=0;k<400;k++) for (l=0;l<240;l++) { if (k<320) PSetPixT(ParxRight,k,l, GetPixB(k,l)); } } if(kDown & KEY_DDOWN) { time= osGetTime(); rgb.r= 0xCC; rgb.g= 0x11; rgb.b= 0xCC; for (k=0;k<400;k++) for (l=0;l<240;l++) { PSetPixT(ParxRight,k,l, rgb); //TopLCD PSetPixT(ParxLeft,k,l, rgb); if (k<320) PSetPixB(ParxBot,k,l, rgb); //BotLCD } time = osGetTime() - time; sprintf(str, "%i:ms ParxPro,kdl", time); CanvasString(ParxBot, str, 10,10, GREEN); } if(kDown & KEY_DRIGHT) { ClrParx(ParxBot, BLACK); rgb.r= 0xEE; rgb.g= 0x00; rgb.b= 0xCC; time= osGetTime(); for (k=0;k<400;k++) for (l=0;l<240;l++) SetPixL(k,l,rgb); //TopLCD time = osGetTime() - time; sprintf(str, "Left %i:ms ParxPro,kdl", time); CanvasString(ParxBot, str, 10,10, LIGHT_GREEN); time= osGetTime(); for (k=0;k<400;k++) for (l=0;l<240;l++) SetPixR(k,l,rgb); time = osGetTime() - time; sprintf(str, "Right %i:ms ParxPro,kdl", time); CanvasString(ParxBot, str, 10,20, LIGHT_GREEN); } if(kDown & KEY_DLEFT) { // SetTopFramebuffers(0); time= osGetTime(); for (k=0;k<400;k++) for (l=0;l<240;l++) { SetPix(ParxRight,k,l,BLACK); SetPix(ParxLeft,k,l,BLACK); if (k<320) SetPix(ParxBot,k,l,BLACK); } time = osGetTime() - time; sprintf(str, "%i:ms Parx-GDI,kdl", time); CanvasString(ParxBot, str, 10,10, GREEN); } //gfxString(ParxRight, str, 30,30, 3, rgb); //gfxString(ParxLeft, str, 30,30, 3, rgb); //for (l=1;l<16;l++) print3d(rgb,10*l,10*l,l-1,3,str); //render rainbow // renderEffect(); //copy buffer to lower screen (don't have to do it every frame) // memcpy(gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL), buffer, size); //wait & swap // gfxSwapBuffersGpu(); // gspWaitForEvent(GSPGPU_EVENT_VBlank0, false); // Flush and swap framebuffers // gfxFlushBuffers(); // gfxSwapBuffers(); RefreshBuffer(); //Wait for VBlank gspWaitForVBlank(); } gfxExit(); return 0; }
CtrUi::CtrUi(int width, int height) : BaseUi() { frame = 0; fullscreen = false; trigger_state = false; sf2d_init(); current_display_mode.width = width; current_display_mode.height = height; current_display_mode.bpp = 32; const DynamicFormat format( 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000, PF::NoAlpha); Bitmap::SetFormat(Bitmap::ChooseFormat(format)); main_surface = Bitmap::Create(width, height, true, 32); main_texture = sf2d_create_texture_mem_RGBA8(main_surface->pixels(), main_surface->GetWidth(), main_surface->GetHeight(), TEXFMT_RGBA8, SF2D_PLACE_VRAM); #ifdef SUPPORT_AUDIO audio_.reset(new CtrAudio()); #endif #ifdef NO_DEBUG // Loading bottom screen keyboard u8* key_buffer = (u8*)&keyboard_bmp[0x36]; u32 key_buffer_size = keyboard_bmp_size - 0x36; u8* key_buffer_rgba = (u8*)malloc((key_buffer_size/3)<<2); int z = 0; for(int i=0;i<key_buffer_size;i=i+3){ key_buffer_rgba[z+2] = key_buffer[i]; key_buffer_rgba[z+1] = key_buffer[i+1]; key_buffer_rgba[z] = key_buffer[i+2]; key_buffer_rgba[z+3] = 0xFF; z = z + 4; } keyboard_texture = sf2d_create_texture_mem_RGBA8(key_buffer_rgba, 320, 240, TEXFMT_RGBA8, SF2D_PLACE_RAM); free(key_buffer_rgba); // Disabling debug console devoptab_list[STD_OUT] = &dotab_null; devoptab_list[STD_ERR] = &dotab_null; consoleGetDefault()->frameBuffer = NULL; gfxSetScreenFormat(GFX_BOTTOM,GSP_BGR8_OES); gfxSetDoubleBuffering(GFX_BOTTOM,true); // Drawing keyboard once then unloading it for (int i=0;i<5;i++){ // If we don't print this a couple of time, image is corrupted sf2d_start_frame(GFX_BOTTOM, GFX_LEFT); sf2d_draw_texture(keyboard_texture, 0, 0); sf2d_end_frame(); sf2d_swapbuffers(); } sf2d_free_texture(keyboard_texture); #endif }
void gfxInit(GSPGPU_FramebufferFormats topFormat, GSPGPU_FramebufferFormats bottomFormat, bool vrambuffers) { void *(*screenAlloc)(size_t); if (vrambuffers) { screenAlloc=vramAlloc; screenFree=vramFree; } else { screenAlloc=linearAlloc; screenFree=linearFree; } gspInit(); gfxSharedMemory=(u8*)mappableAlloc(0x1000); GSPGPU_AcquireRight(0x0); //setup our gsp shared mem section svcCreateEvent(&gspEvent, 0x0); GSPGPU_RegisterInterruptRelayQueue(gspEvent, 0x1, &gspSharedMemHandle, &gfxThreadID); svcMapMemoryBlock(gspSharedMemHandle, (u32)gfxSharedMemory, 0x3, 0x10000000); // default gspHeap configuration : // topleft1 0x00000000-0x00046500 // topleft2 0x00046500-0x0008CA00 // bottom1 0x0008CA00-0x000C4E00 // bottom2 0x000C4E00-0x000FD200 // if 3d enabled : // topright1 0x000FD200-0x00143700 // topright2 0x00143700-0x00189C00 u32 topSize = 400 * 240 * __get_bytes_per_pixel(topFormat); u32 bottomSize = 320 * 240 * __get_bytes_per_pixel(bottomFormat); gfxTopLeftFramebuffers[0]=screenAlloc(topSize); gfxTopLeftFramebuffers[1]=screenAlloc(topSize); gfxBottomFramebuffers[0]=screenAlloc(bottomSize); gfxBottomFramebuffers[1]=screenAlloc(bottomSize); gfxTopRightFramebuffers[0]=screenAlloc(topSize); gfxTopRightFramebuffers[1]=screenAlloc(topSize); enable3d=false; //set requested modes gfxSetScreenFormat(GFX_TOP,topFormat); gfxSetScreenFormat(GFX_BOTTOM,bottomFormat); //initialize framebuffer info structures gfxSetFramebufferInfo(GFX_TOP, 0); gfxSetFramebufferInfo(GFX_BOTTOM, 0); //GSP shared mem : 0x2779F000 gxCmdBuf=(u32*)(gfxSharedMemory+0x800+gfxThreadID*0x200); currentBuffer[0]=0; currentBuffer[1]=0; // Initialize event handler and wait for VBlank gspInitEventHandler(gspEvent, (vu8*) gfxSharedMemory, gfxThreadID); gspWaitForVBlank(); GSPGPU_SetLcdForceBlack(0x0); }
int main() { gfxInitDefault(); gfxSet3D(true); // uncomment if using stereoscopic 3D gfxFlushBuffers(); transparent = BLACK; gfxSetScreenFormat(GFX_TOP, GSP_BGR8_OES); gfxSetScreenFormat(GFX_BOTTOM, GSP_BGR8_OES); InitParx(BLACK); /* ParxLeft = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL); ParxRight = gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL); ParxBot = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL); ClrParx(ParxLeft, BLACK); ClrParx(ParxRight, BLACK); ClrParx(ParxBot, BLACK); */ char* str[256]; int l, k, j, i=20, posx = 100, posy = 100; TBGR rgbsam; TBGR rgb; u64 time; u8* tempScr; bool Dbuf; circlePosition pos; touchPosition touch; // Main loop while (aptMainLoop()) { // gspWaitForVBlank(); // ParxLeft = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL); // ParxRight = gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL); // ParxBot = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL); hidScanInput(); u32 kDown = hidKeysHeld(); //Read the CirclePad position hidCircleRead(&pos); //Print the CirclePad position //- printf("\x1b[2;0H%04d; %04d", pos.dx, pos.dy); //Read the touch screen coordinates hidTouchRead(&touch); //Print the touch screen coordinates // printf("\x1b[2;0H%03d; %03d", touch.px, touch.py); if (kDown & KEY_START) break; // break in order to return to hbmenu if (kDown & KEY_A) { CanvasString(ParxBot, CopyRight(), 10,10, LIGHT_GREEN); } if (kDown & KEY_B) { time= osGetTime(); rgb.r= 0xCC; rgb.g= 0x33; rgb.b= 0xCC; for (k=0;k<400;k++) for (l=0;l<240;l++) { SetPixL(k,l,rgb); //TopLCD SetPixR(k,l,rgb); if (k<320) SetPixB(k,l,rgb); //BotLCD } time = osGetTime() - time; sprintf(str, "%i:ms ParxPro SetPix L/R/B,kdl", time); CanvasString(ParxBot, str, 10,10, GREEN); } if (kDown & KEY_X) { TestPattern(); } if (kDown & KEY_Y) { InitParx(BLACK); // PasBotfill(ParxBot); rgb.r= 0xFF; rgb.g= 0x00; rgb.b= 0x8F; PasClrSrc(ParxBot, rgb); CanvasString(ParxBot, "InitParx", 10,10, GREEN); } if(kDown & KEY_CPAD_DOWN) { rgb.r= 0x00; rgb.g= 0x00; rgb.b= 0XFF; PasTopfill(ParxLeft, rgb); PasTopfill(ParxRight, rgb); } if(kDown & KEY_CPAD_UP) { rgb.r= 0xFF; rgb.g= 0x00; rgb.b= 0x00; PasTopfill(ParxLeft, rgb); PasTopfill(ParxRight, rgb); } if(kDown & KEY_CPAD_RIGHT) { rgb.r= 0x00; rgb.g= 0xFF; rgb.b= 0x00; time= osGetTime(); PasTopfill(ParxLeft, rgb); PasTopfill(ParxRight, rgb); time = osGetTime() - time; sprintf(str, "%i:ms L&R BGRTop,kdl", time); CanvasString(ParxBot, str, 10,10, GREEN); } if(kDown & KEY_CPAD_LEFT) { rgb.r= 0x00; rgb.g= 0x11; rgb.b= 0x00; time= osGetTime(); HexTopfill(ParxLeft); HexTopfill(ParxRight); time = osGetTime() - time; sprintf(str, "%i:ms L&R TopMapLED,kdl", time); CanvasString(ParxBot, str, 10,10, GREEN); } if(kDown & KEY_R) { //InitBufSingle(BLACK); ClrParx(ParxBot, BLACK); //i of linearSpaceFree(); //no effect //i of vramSpaceFree(); //reads as Zero //i of mappableSpaceFree(); //no change in alloc & free sprintf(str, "v:%i m:%i l:%i", vramSpaceFree, mappableSpaceFree, linearSpaceFree); CanvasString(ParxBot, str, 0, 10, RED); Topfill2; sprintf(str, "v:%i m:%i l:%i", vramSpaceFree, mappableSpaceFree, linearSpaceFree); CanvasString(ParxBot, str, 0, 20, RED); // Topfill3; // sprintf(str, "Topfill3 Free :%i", vramSpaceFree); //CanvasString(ParxBot, str, 0, 40, RED); //sprintf(str, "Topfill3 Free :%i", ); //CanvasString(ParxBot, str, 0, 40, RED); } if(kDown & KEY_L) { if (Dbuf) InitBufDub(BLACK); else InitBufSingle(BLACK); Topfill1; ClrParx(ParxBot, BLACK); // sprintf(str, "Dergibal Rad:%i X:%i Y:%i", i, posx, posy); if (Dbuf) CanvasString(ParxBot, "InitBufDub", 0, 40, RED); else CanvasString(ParxBot, "InitBufSingle", 0, 40, RED); (BLACK); Dbuf = !Dbuf; } if(kDown & KEY_DUP) { for (k=0;k<400;k++) for (l=0;l<240;l++) { if (k<320) PSetPixT(ParxRight,k,l, GetPixB(k,l)); } } if(kDown & KEY_DDOWN) { time= osGetTime(); rgb.r= 0xCC; rgb.g= 0x11; rgb.b= 0xCC; for (k=0;k<400;k++) for (l=0;l<240;l++) { PSetPixT(ParxRight,k,l, rgb); //TopLCD PSetPixT(ParxLeft,k,l, rgb); if (k<320) PSetPixB(ParxBot,k,l, rgb); //BotLCD } time = osGetTime() - time; sprintf(str, "%i:ms ParxPro,kdl", time); CanvasString(ParxBot, str, 10,10, GREEN); } if(kDown & KEY_DRIGHT) { ClrParx(ParxBot, BLACK); rgb.r= 0xEE; rgb.g= 0x00; rgb.b= 0xCC; time= osGetTime(); for (k=0;k<400;k++) for (l=0;l<240;l++) SetPixL(k,l,rgb); //TopLCD time = osGetTime() - time; sprintf(str, "Left %i:ms ParxPro,kdl", time); CanvasString(ParxBot, str, 10,10, LIGHT_GREEN); time= osGetTime(); //ParxLeft = GetSrcL(-1); // good!! //tempScr = GetSrcL(0); // good!! //tempScr = GetSrcL(1); // good!! // for (k=0;k<400;k++) // { // ParxLeft = GetSrcL(-1); // good!! // for (l=0;l<80;l++) PSetPixT(ParxRight,k,l, GetPixL(k,l)); // // ParxLeft = GetSrcL(0); // good!! // for (l=80;l<160;l++) PSetPixT(ParxRight,k,l, GetPixL(k,l)); // ParxLeft = GetSrcL(1); // good!! // for (l=160;l<240;l++) PSetPixT(ParxRight,k,l, GetPixL(k,l)); // //assignment to eg PSetPixT(GetSrcR(-1),k,l, GetPixL(k,l)) poops out // } time = osGetTime() - time; sprintf(str, "ParxLeft = GetSrcL(-1&0&1); %i:ms ,kdl", time); CanvasString(ParxBot, str, 10,20, LIGHT_GREEN); time= osGetTime(); //SetSrcR(0,tempScr); // No Good //SetSrcL(-1,ParxLeft); // //sprintf(str, "SetSrcL(-1,ParxLeft); %i:ms ,kdl", time); //CanvasString(ParxBot, str, 10,40, LIGHT_GREEN); //BufSub(-1); //BufSub(-2); //BufSub(-3); //SetSrcL(-1,ParxLeft); // sprintf(str, "SetSrcL(1,ParxLeft); %i:ms ,kdl", time); CanvasString(ParxBot, str, 10,50, LIGHT_GREEN); //SetSrcR(0,ParxRight); // //sprintf(str, "SetSrcR(0,ParxRight) %i:ms ,kdl", time); //CanvasString(ParxBot, str, 10,60, LIGHT_GREEN); // for (k=0;k<400;k++) // for (l=0;l<240;l++) PSetPixT(GetSrcR(0),k,l,rgb); //GetSrcR(0) works time = osGetTime() - time; sprintf(str, "SetSrc L&R(-1,(ParxLeft & ParxRight); %i:ms ,kdl", time); CanvasString(ParxBot, str, 10,30, LIGHT_GREEN); } if(kDown & KEY_DLEFT) { // SetTopFramebuffers(0); time= osGetTime(); for (k=0;k<400;k++) for (l=0;l<240;l++) { SetPix(ParxRight,k,l,BLACK); SetPix(ParxLeft,k,l,BLACK); if (k<320) SetPix(ParxBot,k,l,BLACK); } time = osGetTime() - time; sprintf(str, "%i:ms Parx-GDI,kdl", time); CanvasString(ParxBot, str, 10,10, GREEN); } //gfxString(ParxRight, str, 30,30, 3, rgb); //gfxString(ParxLeft, str, 30,30, 3, rgb); //for (l=1;l<16;l++) print3d(rgb,10*l,10*l,l-1,3,str); //render rainbow // renderEffect(); //copy buffer to lower screen (don't have to do it every frame) // memcpy(gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL), buffer, size); //wait & swap // gfxSwapBuffersGpu(); // gspWaitForEvent(GSPGPU_EVENT_VBlank0, false); // Flush and swap framebuffers // gfxFlushBuffers(); // gfxSwapBuffers(); RefreshBuffer(); //Wait for VBlank gspWaitForVBlank(); } gfxExit(); return 0; }