void InitVideo () { VIDEO_Init(); vmode = VIDEO_GetPreferredMode(NULL); // get default video mode //Widescreen loading image fix... vmode->viWidth = 678; vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - 678) / 2; VIDEO_Configure (vmode); // Allocate the video buffers xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); // A console is always useful while debugging console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2); // Clear framebuffers etc. VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK); VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK); VIDEO_SetNextFramebuffer (xfb[0]); VIDEO_SetBlack (FALSE); VIDEO_Flush (); VIDEO_WaitVSync (); if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync (); StartGX(); ResetVideo_Menu(); // Finally, the video is up and ready for use :) }
void InitVideo() { VIDEO_Init(); // If WiiU - Force 16:9 aspect ratio based on WiiU settings if(isWiiU() && Settings.widescreen) { write32(0xd8006a0, 0x30000004), mask32(0xd8006a8, 0, 2); } vmode = VIDEO_GetPreferredMode(NULL); // get default video mode vmode->viWidth = Settings.widescreen ? 708 : 694; if (Settings.PAL50) { vmode->viXOrigin = (VI_MAX_WIDTH_PAL - vmode->viWidth) / 2; } else { vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - vmode->viWidth) / 2; } VIDEO_Configure(vmode); screenheight = 480; screenwidth = vmode->fbWidth; // Allocate the video buffers xfb[0] = (u32 *) MEM_K0_TO_K1 ( SYS_AllocateFramebuffer ( vmode ) ); xfb[1] = (u32 *) MEM_K0_TO_K1 ( SYS_AllocateFramebuffer ( vmode ) ); // Clear framebuffers etc. VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK); VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK); VIDEO_SetNextFramebuffer(xfb[0]); VIDEO_Flush(); VIDEO_WaitVSync(); if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); // Initialize GX GXColor background = { 0, 0, 0, 0xff }; gp_fifo = (u8 *) memalign(32, GP_FIFO_SIZE); memset (gp_fifo, 0, GP_FIFO_SIZE); GX_Init (gp_fifo, GP_FIFO_SIZE); GX_SetCopyClear (background, 0x00ffffff); GX_SetDispCopyGamma (GX_GM_1_0); GX_SetCullMode (GX_CULL_NONE); ResetVideo_Menu(); VIDEO_SetBlack(FALSE); // Finally, the video is up and ready for use :) }
static void SetGCVideoMode (void) { syssram *sram; sram = __SYS_LockSram(); if(VIDEO_HaveComponentCable()) sram->flags |= 0x80; //set progressive flag else sram->flags &= 0x7F; //clear progressive flag if (config.dmlvideomode == DMLVIDEOMODE_NTSC) { rmode = &TVNtsc480IntDf; sram->flags &= 0xFE; // Clear bit 0 to set the video mode to NTSC sram->ntd &= 0xBF; //clear pal60 flag } else { rmode = &TVPal528IntDf; sram->flags |= 0x01; // Set bit 0 to set the video mode to PAL sram->ntd |= 0x40; //set pal60 flag } __SYS_UnlockSram(1); // 1 -> write changes while(!__SYS_SyncSram()); // TVPal528IntDf u32 *sfb; static GXRModeObj *rmode; //config.dmlvideomode = DMLVIDEOMODE_PAL; if (config.dmlvideomode == DMLVIDEOMODE_PAL) { rmode = &TVPal528IntDf; *(u32*)0x800000CC = VI_PAL; } else { rmode = &TVNtsc480IntDf; *(u32*)0x800000CC = VI_NTSC; } VIDEO_SetBlack(TRUE); VIDEO_Configure(rmode); sfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); VIDEO_ClearFrameBuffer(rmode, sfb, COLOR_BLACK); VIDEO_SetNextFramebuffer(sfb); VIDEO_Flush(); VIDEO_WaitVSync(); if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); VIDEO_SetBlack(FALSE); VIDEO_WaitVSync(); if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); }
void InitVideo (void) { // Initialise the video system VIDEO_Init(); // Obtain the preferred video mode from the system // This will correspond to the settings in the Wii menu rmode = VIDEO_GetPreferredMode(NULL); // Allocate memory for the display in the uncached region xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(xfb); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); int x, y, w, h; x = 20; y = 32; w = rmode->fbWidth - (32); h = rmode->xfbHeight - (48); CON_InitEx(rmode, x, y, w, h); VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK); CON_InitEx(rmode, x, y, w, h); // Set console text color printf("\x1b[%u;%um", 37, false); printf("\x1b[%u;%um", 40, false); }
int main(int argc, char **argv) { //DEBUG_Init(GDBSTUB_DEVICE_USB, 1); s8 ios_patched = 0; s32 ret = 0; CheckForGecko(); VIDEO_Init(); vmode = VIDEO_GetPreferredMode(NULL); xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode)); VIDEO_Configure(vmode); VIDEO_SetNextFramebuffer(xfb); VIDEO_SetBlack(false); VIDEO_Flush(); VIDEO_WaitVSync(); if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); int x = 20, y = 20, w, h; w = vmode->fbWidth - (x * 2); h = vmode->xfbHeight - (y + 20); // Initialize the console //Con_InitEX works better but for some odd reason doesn't show right when clearing screen... //CON_InitEx(vmode, x, y, w, h); CON_Init(xfb,x,y,w,h, vmode->fbWidth*VI_DISPLAY_PIX_SZ ); printf("\n\n\n"); VIDEO_ClearFrameBuffer(vmode, xfb, COLOR_BLACK); gprintf("resolution is %dx%d\n",vmode->viWidth,vmode->viHeight); //printf("\x1b[2J"); /*sleep(3); gprintf("crashing...\n"); free((void*)0x1);*/ /*free((void*)0x1); free((void*)0x1); free((void*)0x1); memcpy((void*)0x0,(void*)0x1,5);*/ //return 0; //reload ios so that IF the user started this with AHBPROT we lose everything from HBC. also, IOS36 is the most patched ios :') IOS_ReloadIOS(36); WPAD_Init(); PAD_Init(); printf("\nIOS %d rev %d\n\n",IOS_GetVersion(),IOS_GetRevision()); if( (VERSION&0xFF) % 10 == 0 ) { #if BETAVERSION > 0 printf("Priiloader v%d.%db%d(r0x%08x) Installation/Removal Tool\n\n\n\n\t",VERSION>>8, (VERSION&0xFF) / 10,BETAVERSION,GIT_REV); #else printf("\t\tPriiloader v%d.%d(r0x%08x) Installation / Removal Tool\n\n\n\n\t",VERSION>>8, (VERSION&0xFF) / 10,GIT_REV); #endif }
void initConsole(const void *imgBgData,enum CONSOLE_COLORS CONSOLE_COLOR,const char *strSplashScreenMessage,double dbLeft,double dbTop,double dbWidth,double dbHeight) { PNGUPROP imgProperties; IMGCTX imgContext; void *pFramebuffer=NULL; GXRModeObj *pRmode=NULL; double dbConsoleFrameX[2]={dbLeft,dbLeft},dbConsoleFrameY[2]={dbTop,dbTop},dbBgImgXScaleFactor=1,dbBgImgYScaleFactor=1,dbReferenceWidth,dbReferenceHeight; int intConsoleColumnsCount,intConsoleRowsCount; struct stConsoleCursorLocation stTexteLocation; VIDEO_Init(); pRmode=VIDEO_GetPreferredMode(NULL); pFramebuffer=MEM_K0_TO_K1(SYS_AllocateFramebuffer(pRmode)); VIDEO_ClearFrameBuffer(pRmode,pFramebuffer,CONSOLE_COLOR); VIDEO_Configure(pRmode); VIDEO_SetNextFramebuffer(pFramebuffer); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(pRmode->viTVMode&VI_NON_INTERLACE) { VIDEO_WaitVSync(); } dbWidth=fabs(dbWidth); dbHeight=fabs(dbHeight); if ((imgContext=getPngImageRessources(imgBgData,&imgProperties))) { dbReferenceWidth=imgProperties.imgWidth; dbReferenceHeight=imgProperties.imgHeight; dbBgImgXScaleFactor=pRmode->fbWidth/imgProperties.imgWidth; dbBgImgYScaleFactor=pRmode->xfbHeight/imgProperties.imgHeight; } else { dbReferenceWidth=pRmode->fbWidth; dbReferenceHeight=pRmode->xfbHeight; } if (dbWidth<=1) { dbWidth=dbReferenceWidth*dbWidth; dbConsoleFrameX[0]=0; dbConsoleFrameX[1]=dbWidth; } if (dbHeight<=1) { dbHeight=dbReferenceHeight*dbHeight; dbConsoleFrameY[0]=0; dbConsoleFrameY[1]=dbHeight; } CON_InitEx(pRmode,(s32) getRoundNumber(getPolyContainerPosition(&dbConsoleFrameX[0],2,0,dbReferenceWidth,dbLeft)*dbBgImgXScaleFactor),(s32) getRoundNumber(getPolyContainerPosition(&dbConsoleFrameY[0],2,0,dbReferenceHeight,dbTop)*dbBgImgYScaleFactor),(s32) getRoundNumber(dbWidth*dbBgImgXScaleFactor),(s32) getRoundNumber(dbHeight*dbBgImgYScaleFactor)); if (imgContext) { PNGU_DECODE_TO_COORDS_YCbYCr(imgContext,0,0,imgProperties.imgWidth,imgProperties.imgHeight,pRmode->fbWidth,pRmode->xfbHeight,pFramebuffer); PNGU_ReleaseImageContext(imgContext); } resetDefaultFontSyle(); if (*strSplashScreenMessage) { CON_GetMetrics(&intConsoleColumnsCount,&intConsoleRowsCount); printAlignedText(ALIGN_CENTER,ALIGN_MIDDLE,0,0,intConsoleRowsCount-1,intConsoleColumnsCount-1,true,true,&stTexteLocation,"%s",strSplashScreenMessage); } }
void initialise_video(GXRModeObj *m) { VIDEO_Configure (m); if(xfb[0]) free(MEM_K1_TO_K0(xfb[0])); if(xfb[1]) free(MEM_K1_TO_K0(xfb[1])); xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (m)); xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (m)); VIDEO_ClearFrameBuffer (m, xfb[0], COLOR_BLACK); VIDEO_ClearFrameBuffer (m, xfb[1], COLOR_BLACK); VIDEO_SetNextFramebuffer (xfb[0]); VIDEO_SetPostRetraceCallback (ProperScanPADS); VIDEO_SetBlack (0); VIDEO_Flush (); VIDEO_WaitVSync (); if (m->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); else while (VIDEO_GetNextField()) VIDEO_WaitVSync(); // setup the fifo and then init GX if(gp_fifo == NULL) { gp_fifo = MEM_K0_TO_K1 (memalign (32, DEFAULT_FIFO_SIZE)); memset (gp_fifo, 0, DEFAULT_FIFO_SIZE); GX_Init (gp_fifo, DEFAULT_FIFO_SIZE); } // clears the bg to color and clears the z buffer GX_SetCopyClear ((GXColor) {0, 0, 0, 0xFF}, GX_MAX_Z24); // init viewport GX_SetViewport (0, 0, m->fbWidth, m->efbHeight, 0, 1); // Set the correct y scaling for efb->xfb copy operation GX_SetDispCopyYScale ((f32) m->xfbHeight / (f32) m->efbHeight); GX_SetDispCopySrc (0, 0, m->fbWidth, m->efbHeight); GX_SetDispCopyDst (m->fbWidth, m->xfbHeight); GX_SetCopyFilter (m->aa, m->sample_pattern, GX_TRUE, m->vfilter); GX_SetFieldMode (m->field_rendering, ((m->viHeight == 2 * m->xfbHeight) ? GX_ENABLE : GX_DISABLE)); if (m->aa) GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); else GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_SetCullMode (GX_CULL_NONE); // default in rsp init GX_CopyDisp (xfb[0], GX_TRUE); // This clears the efb GX_CopyDisp (xfb[0], GX_TRUE); // This clears the xfb }
void InitVideo () { VIDEO_Init(); vmode = VIDEO_GetPreferredMode(NULL); // get default video mode // widescreen fix if(CONF_GetAspectRatio() == CONF_ASPECT_16_9) { vmode->viWidth = VI_MAX_WIDTH_PAL-12; vmode->viXOrigin = ((VI_MAX_WIDTH_PAL - vmode->viWidth) / 2) + 2; } VIDEO_Configure (vmode); screenheight = vmode->xfbHeight; screenwidth = vmode->fbWidth; // Allocate the video buffers xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); // Clear framebuffers etc. VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK); VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK); VIDEO_SetNextFramebuffer (xfb[0]); // video callback VIDEO_SetPostRetraceCallback ((VIRetraceCallback)UpdatePadsCB); VIDEO_SetBlack (FALSE); VIDEO_Flush (); VIDEO_WaitVSync (); if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync (); StartGX(); ResetVideo_Menu(); // Finally, the video is up and ready for use :) }
void init_video_and_wpad() { // Video and WPAD initialized? if(video_and_wpad_initialized) { return; } // Initialise the video system VIDEO_Init(); // Obtain the preferred video mode from the system // This will correspond to the settings in the Wii menu rmode = VIDEO_GetPreferredMode(NULL); // Allocate memory for the display in the uncached region xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); // Set up the video registers with the chosen mode VIDEO_Configure(rmode); // Tell the video hardware where our display memory is VIDEO_SetNextFramebuffer(xfb); // Make the display visible VIDEO_SetBlack(FALSE); // Flush the video register changes to the hardware VIDEO_Flush(); // Wait for Video setup to complete VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); // Set console parameters int x = 24, y = 32, w, h; w = rmode->fbWidth - (32); h = rmode->xfbHeight - (48); // Initialize the console - CON_InitEx works after VIDEO_ calls CON_InitEx(rmode, x, y, w, h); // Clear the garbage around the edges of the console VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK); // This function initialises the attached controllers WPAD_Init(); WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); video_and_wpad_initialized = TRUE; }
int main() { Initialise(); while(1) { s32 Size; s32 SSize; u32 ID; s32 getIDerr; s32 CARDerr; s32 EXIerr; VIDEO_ClearFrameBuffer(rmode, xfb, 0); // Can't use printf since Dolphin overrides it std::cout<<"\x1b[0;0H"; // Position the cursor (at 0, 0) for (int channel = 0; channel < EXI_CHANNEL_MAX; ++channel) for (int device = 0; device < EXI_DEVICE_MAX; ++device) { if (getIDerr = EXI_GetID(channel, device, &ID) == 1) { std::cout<<"Channel "<<channel<<" Device "<<device<<"\tID = 0x"<<std::setbase(16)<<ID<<std::endl; if ((channel == 0 && device == 0)||(channel == 1 && device == 0)) { // It's a memcard slot if (CARDerr = CARD_ProbeEx(channel, &Size, &SSize) >= 0) { std::cout<<"\tMemcard has a size of "<<std::setbase(10)<<Size<<" and a Sector Size of "<<std::setbase(10)<<SSize<<std::endl; } else if (CARDerr == -2) std::cout<<"\tNot a Memcard!"<<std::endl; else std::cout<<"\tCARD Error "<<CARDerr<<std::endl; } else { // It's not a memcard, what to do? - Just probe for now if (EXIerr = EXI_ProbeEx(channel)){} else std::cout<<"\tEXI Error "<<EXIerr<<std::endl; } } else std::cout<<"Channel "<<channel<<" Device "<<device<<std::endl<<"\tEXI_GetID Error "<<getIDerr<<std::endl; } VIDEO_WaitVSync(); } return 0; }
static void setup_video_mode(GXRModeObj *mode) { VIDEO_Configure(mode); for (unsigned i = 0; i < 3; i++) { g_framebuf[i] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(mode)); VIDEO_ClearFrameBuffer(mode, g_framebuf[i], COLOR_BLACK); } g_vi_framebuf = 0; g_render_framebuf = 1; VIDEO_SetNextFramebuffer(g_framebuf[0]); VIDEO_SetPreRetraceCallback(retrace_callback); VIDEO_SetBlack(false); VIDEO_Flush(); VIDEO_WaitVSync(); if (mode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); }
void InitTextVideo () { gprintf("\nInitTextVideo ()"); if (textVideoInit) { gprintf("...0"); return; } dbvideo=1; VIDEO_Init(); // get default video mode GXRModeObj *vmode = VIDEO_GetPreferredMode(NULL); // widescreen fix VIDEO_Configure (vmode); // Allocate the video buffers xfb = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); // A console is always useful while debugging console_init (xfb, 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2); // Clear framebuffers etc. VIDEO_ClearFrameBuffer (vmode, xfb, COLOR_BLACK); VIDEO_SetNextFramebuffer (xfb); VIDEO_SetBlack (FALSE); VIDEO_Flush (); VIDEO_WaitVSync (); if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync (); //send console output to the gecko if (geckoinit)CON_EnableGecko(1, true); textVideoInit = true; gprintf("...1"); }
void video_setmode(void) { /* Select preferred video mode */ vmode = VIDEO_GetPreferredMode(NULL); /* Allocate memory for the framebuffer */ framebuffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode)); /* Configure the video subsystem */ VIDEO_Configure(vmode); /* Setup video */ VIDEO_SetNextFramebuffer(framebuffer); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); /* Clear the screen */ VIDEO_ClearFrameBuffer(vmode, framebuffer, COLOR_BLACK); }
void InitVideo () { VIDEO_Init(); vmode = VIDEO_GetPreferredMode(NULL); // get default video mode bool pal = false; if (vmode == &TVPal528IntDf) pal = true; if (CONF_GetAspectRatio() == CONF_ASPECT_16_9) { vmode->fbWidth = 640; vmode->efbHeight = 456; vmode->viWidth = 686; if (pal) { vmode->xfbHeight = 542; vmode->viHeight = 542; } else { vmode->xfbHeight = 456; vmode->viHeight = 456; } } else { if (pal) vmode = &TVPal574IntDfScale; vmode->viWidth = 672; } if (pal) { vmode->viXOrigin = (VI_MAX_WIDTH_PAL - vmode->viWidth) / 2; vmode->viYOrigin = (VI_MAX_HEIGHT_PAL - vmode->viHeight) / 2; } else { vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - vmode->viWidth) / 2; vmode->viYOrigin = (VI_MAX_HEIGHT_NTSC - vmode->viHeight) / 2; } VIDEO_Configure (vmode); // Allocate the video buffers xfb[0] = (u32 *) SYS_AllocateFramebuffer (vmode); xfb[1] = (u32 *) SYS_AllocateFramebuffer (vmode); DCInvalidateRange(xfb[0], VIDEO_GetFrameBufferSize(vmode)); DCInvalidateRange(xfb[1], VIDEO_GetFrameBufferSize(vmode)); xfb[0] = (u32 *) MEM_K0_TO_K1 (xfb[0]); xfb[1] = (u32 *) MEM_K0_TO_K1 (xfb[1]); // Clear framebuffers etc. VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK); VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK); VIDEO_SetNextFramebuffer (xfb[0]); VIDEO_SetBlack (FALSE); VIDEO_Flush (); VIDEO_WaitVSync (); if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync (); StartGX(); ResetVideo_Menu(); // Finally, the video is up and ready for use :) }
void MainMenu () { s8 ret; u8 quit = 0; menu = 0; #ifdef HW_RVL u8 count = 6; char items[6][20] = #else u8 count = 5; char items[5][20] = #endif { {"Play Game"}, {"Hard Reset"}, {"Load New Game"}, {"Emulator Options"}, #ifdef HW_RVL {"Return to Loader"}, #endif {"System Reboot"} }; /* 50 hz TV mode */ if (gc_pal) { VIDEO_Configure (vmode); VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); VIDEO_WaitVSync(); } /* autosave (SRAM only) */ int temp = config.freeze_auto; config.freeze_auto = -1; memfile_autosave(); config.freeze_auto = temp; while (quit == 0) { strcpy (menutitle, "Version 1.04.2"); ret = DoMenu (&items[0], count); switch (ret) { case -1: /*** Button B ***/ case 0: /*** Play Game ***/ quit = 1; break; case 1: emu_reset(); quit = 1; break; case 2: /*** Load ROM Menu ***/ quit = loadmenu(); break; case 3: /*** Emulator Options */ Emu_options(); break; case 4: /*** SD/PSO/TP Reload ***/ memfile_autosave(); VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); #ifdef HW_RVL DI_Close(); exit(0); break; case 5: /*** Return to Wii System Menu ***/ memfile_autosave(); VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); DI_Close(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); #else SYS_ResetSystem(SYS_HOTRESET,0,0); #endif break; } } /*** Remove any still held buttons ***/ while (PAD_ButtonsHeld(0)) PAD_ScanPads(); #ifdef HW_RVL while (WPAD_ButtonsHeld(0)) WPAD_ScanPads(); #endif /*** Restore fullscreen 50hz ***/ if (gc_pal) { extern GXRModeObj TV50hz_576i; GXRModeObj *rmode = &TV50hz_576i; Mtx p; rmode->xfbHeight = 574; rmode->viYOrigin = 0; rmode->viHeight = 574; VIDEO_Configure (rmode); VIDEO_ClearFrameBuffer(rmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); VIDEO_WaitVSync(); /* reset rendering mode */ GX_SetViewport (0.0F, 0.0F, rmode->fbWidth, rmode->efbHeight, 0.0F, 1.0F); GX_SetScissor (0, 0, rmode->fbWidth, rmode->efbHeight); f32 yScale = GX_GetYScaleFactor(rmode->efbHeight, rmode->xfbHeight); u16 xfbHeight = GX_SetDispCopyYScale (yScale); GX_SetDispCopySrc (0, 0, rmode->fbWidth, rmode->efbHeight); GX_SetDispCopyDst (rmode->fbWidth, xfbHeight); GX_SetCopyFilter (rmode->aa, rmode->sample_pattern, GX_TRUE, rmode->vfilter); GX_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR); guOrtho(p, rmode->efbHeight/2, -(rmode->efbHeight/2), -(rmode->fbWidth/2), rmode->fbWidth/2, 100, 1000); GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC); } #ifndef HW_RVL /*** Stop the DVD from causing clicks while playing ***/ uselessinquiry (); #endif }
static int drawgx_window_create(sdl_window_info *window, int width, int height) { sdl_info *sdl = window->dxdata; u32 xfbHeight; f32 yscale; Mtx44 perspective; Mtx GXmodelView2D; GXColor background = {0, 0, 0, 0xff}; currfb = 0; // allocate memory for our structures sdl = malloc(sizeof(*sdl)); memset(sdl, 0, sizeof(*sdl)); window->dxdata = sdl; sdl->scale_mode = &scale_modes[window->scale_mode]; sdl->extra_flags = (window->fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE); sdl->extra_flags |= sdl->scale_mode->extra_flags; /*sdl->sdlsurf = SDL_SetVideoMode(width, height, 0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags);*/ //sdl->sdlsurf = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF); //if (!sdl->sdlsurf) // return 1; window->width = gx_screenWidth();//sdl->sdlsurf->w; window->height = 480;//sdl->sdlsurf->h; sdl->safe_hofs = (window->width - window->width * options_get_float(mame_options(), SDLOPTVAL_SAFEAREA)) / 2; sdl->safe_vofs = (window->height - window->height * options_get_float(mame_options(), SDLOPTVAL_SAFEAREA)) / 2; /*if (sdl->scale_mode->is_yuv) yuv_overlay_init(window);*/ sdl->yuv_lookup = NULL; sdl->blittimer = 0; //if (is_inited) return 0; //is_inited = 1; //drawgx_yuv_init(sdl); //SDL_QuitSubSystem(SDL_INIT_VIDEO); if (is_inited) return 0; is_inited = 1; VIDEO_Init(); VIDEO_SetBlack(true); vmode = VIDEO_GetPreferredMode(NULL); switch (vmode->viTVMode >> 2) { case VI_PAL: vmode = &TVPal574IntDfScale; vmode->xfbHeight = 480; vmode->viYOrigin = (VI_MAX_HEIGHT_PAL - 480)/2; vmode->viHeight = 480; break; case VI_NTSC: break; default: break; } VIDEO_Configure(vmode); xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode)); xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode)); VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK); VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK); VIDEO_SetNextFramebuffer(xfb[currfb]); VIDEO_Flush(); VIDEO_WaitVSync(); if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); else while (VIDEO_GetNextField()) VIDEO_WaitVSync(); gp_fifo = memalign(32, DEFAULT_FIFO_SIZE); memset(gp_fifo, 0, DEFAULT_FIFO_SIZE); GX_Init(gp_fifo, DEFAULT_FIFO_SIZE); atexit(drawgx_shutdown); GX_SetCopyClear(background, 0x00ffffff); // other gx setup GX_SetViewport(0,0,vmode->fbWidth,vmode->efbHeight,0,1); yscale = GX_GetYScaleFactor(vmode->efbHeight,vmode->xfbHeight); xfbHeight = GX_SetDispCopyYScale(yscale); GX_SetScissor(0,0,vmode->fbWidth,vmode->efbHeight); GX_SetDispCopySrc(0,0,vmode->fbWidth,vmode->efbHeight); GX_SetDispCopyDst(vmode->fbWidth,xfbHeight); GX_SetCopyFilter(vmode->aa,vmode->sample_pattern,GX_TRUE,vmode->vfilter); GX_SetFieldMode(vmode->field_rendering,((vmode->viHeight==2*vmode->xfbHeight)?GX_ENABLE:GX_DISABLE)); if (vmode->aa) GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); else GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_SetCullMode(GX_CULL_NONE); GX_CopyDisp(xfb[currfb],GX_TRUE); GX_SetDispCopyGamma(GX_GM_1_0); GX_SetNumChans(1); GX_SetNumTexGens(1); GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); GX_SetAlphaUpdate(GX_TRUE); GX_SetColorUpdate(GX_TRUE); guOrtho(perspective,0,479,0,gx_screenWidth()-1,0,300); GX_LoadProjectionMtx(perspective, GX_ORTHOGRAPHIC); guMtxIdentity(GXmodelView2D); guMtxTransApply (GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -5.0F); GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0); GX_SetViewport(0,0,vmode->fbWidth,vmode->efbHeight,0,1); GX_InvVtxCache(); GX_ClearVtxDesc(); GX_InvalidateTexAll(); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); VIDEO_SetBlack(false); GX_InitTexObj(&blankTex, blanktex, 1, 1, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE); return 0; }
// path is the full path to iso image bool DEVO_Boot (char *path, u8 memcardId, bool widescreen, bool activity_led, bool wifi) { //Read in loader.bin char loader_path[256]; Debug ("DEVO_Boot: %s", path); snprintf(loader_path, sizeof (loader_path), "%s://ploader/plugins/loader.bin", vars.defMount); loader_bin = fsop_ReadFile (loader_path, 0, NULL); if (!loader_bin) return false; Debug ("DEVO_Boot: loader in memory"); //start writing cfg to mem struct stat st; char full_path[256]; int data_fd; char gameID[7]; FILE *f = fopen(path, "rb"); if (!f) { free (loader_bin); return false; } fread ((u8*)0x80000000, 1, 32, f); fclose (f); memcpy (&gameID, (u8*)0x80000000, 6); stat (path, &st); // fill out the Devolution config struct memset(DEVO_CONFIG, 0, sizeof(*DEVO_CONFIG)); DEVO_CONFIG->signature = DEVO_CONFIG_SIG; DEVO_CONFIG->version = DEVO_CONFIG_VERSION; DEVO_CONFIG->device_signature = st.st_dev; DEVO_CONFIG->disc1_cluster = st.st_ino; // Pergame options if(wifi) DEVO_CONFIG->options |= DEVO_CONFIG_WIFILOG; if(widescreen) DEVO_CONFIG->options |= DEVO_CONFIG_WIDE; if(!activity_led) DEVO_CONFIG->options |= DEVO_CONFIG_NOLED; // make sure these directories exist, they are required for Devolution to function correctly snprintf(full_path, sizeof(full_path), "%s:/apps", fsop_GetDev (path)); fsop_MakeFolder(full_path); snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo", fsop_GetDev (path)); fsop_MakeFolder(full_path); if (!IsGCCardAvailable ()) { char cardname[64]; if (memcardId == 0) { if(gameID[3] == 'J') //Japanese Memory Card sprintf (cardname, "memcard_jap.bin"); else sprintf (cardname, "memcard.bin"); } else { if(gameID[3] == 'J') //Japanese Memory Card sprintf (cardname, "memcard%u_jap.bin", memcardId); else sprintf (cardname, "memcard%u.bin", memcardId); } Debug ("DEVO_Boot: using emulated card"); // find or create a memcard file for emulation(as of devolution r115 it doesn't need to be 16MB) // this file can be located anywhere since it's passed by cluster, not name if(gameID[3] == 'J') //Japanese Memory Card snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo/%s", fsop_GetDev (path), cardname); else snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo/%s", fsop_GetDev (path), cardname); // check if file doesn't exist if (stat(full_path, &st) == -1) { // need to create it data_fd = open(full_path, O_WRONLY|O_CREAT); if (data_fd >= 0) { // make it 16MB, if we're creating a new memory card image //gprintf("Resizing memcard file...\n"); ftruncate(data_fd, 16<<20); if (fstat(data_fd, &st) == -1) { // it still isn't created. Give up. st.st_ino = 0; } close(data_fd); } else { // couldn't open or create the memory card file st.st_ino = 0; } } } else { Debug ("DEVO_Boot: using real card"); st.st_ino = 0; } // set FAT cluster for start of memory card file // if this is zero memory card emulation will not be used DEVO_CONFIG->memcard_cluster = st.st_ino; // flush disc ID and Devolution config out to memory DCFlushRange((void*)0x80000000, 64); Shutdown (); // Configure video mode as "suggested" to devolution GXRModeObj *vidmode; if (gameID[3] == 'E' || gameID[3] == 'J') vidmode = &TVNtsc480IntDf; else vidmode = &TVPal528IntDf; static u8 *sfb = NULL; sfb = SYS_AllocateFramebuffer(vidmode); VIDEO_ClearFrameBuffer(vidmode, sfb, COLOR_BLACK); sfb = MEM_K0_TO_K1(sfb); VIDEO_Configure(vidmode); VIDEO_SetNextFramebuffer(sfb); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); VIDEO_WaitVSync(); // the Devolution blob has an ID string at offset 4 gprintf((const char*)loader_bin + 4); // devolution seems to like hbc stub. So we can force it. ((void(*)(void))loader_bin)(); return true; }
void video_clear(s32 color) { VIDEO_ClearFrameBuffer(vmode, framebuffer, color); }
//--------------------------------------------------------------------------------- int main() { //--------------------------------------------------------------------------------- VIDEO_Init(); rmode = VIDEO_GetPreferredMode(NULL); PAD_Init(); xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(xfb); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); console_init(xfb,20,64,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*2); VIDEO_SetNextFramebuffer(xfb); int slot = CARD_SLOTA; u32 i; int tomenu = 0; u16 buttonsDown; u8 pressed = 0; int filesize; int bytesdone = 0; while(1){ VIDEO_ClearFrameBuffer (rmode, xfb, COLOR_BLACK); listpos=0; tomenu=0; pressed = 0; printf("\x1b[2;0H"); printf("Memory Card Loader 0.2 by Suloku\n"); printf("********************************\n\n"); printf("Press A or B button to select a slot.\n"); while (1){ PAD_ScanPads(); buttonsDown=PAD_ButtonsDown(0); if (buttonsDown & PAD_BUTTON_A){ slot = CARD_SLOTA; pressed = 1;} if (buttonsDown & PAD_BUTTON_B){ slot = CARD_SLOTB; pressed = 1;} if (buttonsDown & PAD_BUTTON_START){ PSOreload();} VIDEO_WaitVSync(); if (pressed) break; } printf("Mounting card in slot %s...", (slot==0?"A":"B")); int Slot_error = MountCard(slot); printf("code %d. ",Slot_error); int CardError; if (Slot_error >= 0) { printf("Sector size is %d bytes.\n",sectsize); printf("Reading memory card files..."); card_dir CardDir; card_file CardFile; CardError = CARD_FindFirst(slot, &CardDir, true); cardcount = 0; while ( CARD_ERROR_NOFILE != CardError ) { if (strncmp ("DOLX", (char *)CardDir.gamecode, 4) == 0){ memcpy (&CardList[cardcount], &CardDir, sizeof (card_dir)); cardcount++; } CardError = CARD_FindNext(&CardDir); } printf("finished.\n\n"); if (cardcount == 0){ printf("No dol files in memory card in slot %s\n\n", (slot==0?"A":"B")); waitA(); }else{ while (1){ pressed = 0; VIDEO_ClearFrameBuffer (rmode, xfb, COLOR_BLACK); printf("\x1b[2;0H"); printf("Memory Card Loader 0.1 by Suloku\n"); printf("********************************\n\n"); printf("Dol files in memory card %s: %d\n\n", (slot==0?"A":"B"), cardcount); if (listpos!=0) printf ("/\\/\\\n"); else printf(" \n"); for (i=listpos; i<listpos+10; i++){ printf (" "); if (i==listpos) printf ("-->"); printf("%s \n",CardList[i].filename); if (i>= cardcount )break; } printf("\x1b[18;0H"); if (cardcount >=10 && listpos != cardcount-1) printf ("\\/\\/\n"); else{ printf(" \n"); } printf("\n\t\tPress B button to go back to slot select.\n\n"); while (1){ PAD_ScanPads(); buttonsDown=PAD_ButtonsDown(0); if (buttonsDown & PAD_BUTTON_UP){ listpos--; if (listpos <0) listpos = 0; pressed = 1; } if (buttonsDown & PAD_BUTTON_DOWN){ listpos++; if (listpos >= cardcount-1) listpos = cardcount-1; pressed = 1; } if (buttonsDown & PAD_BUTTON_LEFT){ listpos-=10; if (listpos <0) listpos = 0; pressed = 1; } if (buttonsDown & PAD_BUTTON_RIGHT){ listpos+=10; if (listpos >= cardcount-1) listpos = cardcount-1; pressed = 1; } if (buttonsDown & PAD_BUTTON_A){ printf("Loading %s...\n", CardList[listpos].filename); /*** Initialise for this company & gamecode ***/ //add null char company[2] = gamecode[4] = 0; memcpy (company, &CardList[listpos].company, 2); memcpy (gamecode, &CardList[listpos].gamecode, 4); CARD_SetCompany(company); CARD_SetGamecode(gamecode); CardError = CARD_Open(slot ,(char*)&CardList[listpos].filename,&CardFile); if (CardError < 0) { CARD_Unmount (slot); printf("Error %d while opening file.\n", CardError); waitA(); }else{ /*** Copy the file contents to the buffer ***/ filesize = CardFile.len; u8 *dolbuffer = (u8*) memalign(32, filesize); while (bytesdone < filesize) { CardError= CARD_Read(&CardFile, dolbuffer+bytesdone, sectsize, bytesdone); bytesdone += sectsize; } CARD_Close(&CardFile); CARD_Unmount(slot); //boot dol //This will load cli_buffer and cli_size getclifrombuffer(dolbuffer, filesize); if (cli_buffer!=NULL){ // Build a command line to pass to the DOL int argc2 = 0; char *argv2[1024]; //add a terminating null character for last argument if needed if (cli_buffer[cli_size-1] != '\0'){ cli_buffer[cli_size] = '\0'; cli_size += 1; } // CLI parse char bootpath[CARD_FILENAMELEN+10]; sprintf(bootpath, "mc%d:/%s", slot, (char*)&CardList[listpos].filename); argv2[argc2] = bootpath; argc2++; // First argument is at the beginning of the file if(cli_buffer[0] != '\r' && cli_buffer[0] != '\n') { argv2[argc2] = cli_buffer; argc2++; } // Search for the others after each newline int i; for(i = 0; i < cli_size; i++) { if(cli_buffer[i] == '\r' || cli_buffer[i] == '\n') { cli_buffer[i] = '\0'; } else if(cli_buffer[i - 1] == '\0') { argv2[argc2] = cli_buffer + i; argc2++; if(argc2 >= 1024) break; } } DOLtoARAM(dolbuffer, argc2, argc2 == 0 ? NULL : argv2); }else{ DOLtoARAM(dolbuffer, 0, NULL); } //If we get here dol was invalid if(dolbuffer != NULL) free(dolbuffer); printf("Not a valid dol file.\n"); waitA(); tomenu = 1; } pressed = 1; } if (buttonsDown & PAD_BUTTON_B){ pressed = 1;tomenu=1;} if (buttonsDown & PAD_BUTTON_START){ PSOreload();} VIDEO_WaitVSync(); if (pressed) break; } if (tomenu) break; } } CARD_Unmount(slot); }else{ printf("\n\nCan't mount card in slot %s!\n", (slot==0?"A":"B")); waitA(); } } return 0; }
/**************************************************************************** * Initialise Video * * Before doing anything in libogc, it's recommended to configure a video * output. ****************************************************************************/ static void Initialise (void) { VIDEO_Init (); /*** ALWAYS CALL FIRST IN ANY LIBOGC PROJECT! Not only does it initialise the video subsystem, but also sets up the ogc os ***/ PAD_Init (); /*** Initialise pads for input ***/ #ifdef HW_RVL WPAD_Init (); #endif // get default video mode vmode = VIDEO_GetPreferredMode(NULL); switch (vmode->viTVMode >> 2) { case VI_PAL: // 576 lines (PAL 50Hz) // display should be centered vertically (borders) //Make all video modes the same size so menus doesn't screw up vmode = &TVPal576IntDfScale; vmode->xfbHeight = 480; vmode->viYOrigin = (VI_MAX_HEIGHT_PAL - 480)/2; vmode->viHeight = 480; vmode_60hz = 0; break; case VI_NTSC: // 480 lines (NTSC 60hz) vmode_60hz = 1; break; default: // 480 lines (PAL 60Hz) vmode_60hz = 1; break; } #ifdef HW_DOL /* we have component cables, but the preferred mode is interlaced * why don't we switch into progressive? * (user may not have progressive compatible display but component input) * on the Wii, the user can do this themselves on their Wii Settings */ if(VIDEO_HaveComponentCable()) vmode = &TVNtsc480Prog; #endif /* // check for progressive scan // bool progressive = FALSE; if (vmode->viTVMode == VI_TVMODE_NTSC_PROG) progressive = true; */ #ifdef HW_RVL // widescreen fix if(CONF_GetAspectRatio()) { vmode->viWidth = 678; vmode->viXOrigin = (VI_MAX_WIDTH_PAL - 678) / 2; } #endif // configure VI VIDEO_Configure (vmode); // always 480 lines /*** Update screen height for font engine ***/ screenheight = vmode->xfbHeight; /*** Now configure the framebuffer. Really a framebuffer is just a chunk of memory to hold the display line by line. ***/ // Allocate the video buffers xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); /*** I prefer also to have a second buffer for double-buffering. This is not needed for the console demo. ***/ xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); /*** Define a console ***/ console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2); /*** Clear framebuffer to black ***/ VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK); VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK); /*** Set the framebuffer to be displayed at next VBlank ***/ VIDEO_SetNextFramebuffer (xfb[0]); /*** Get the PAD status updated by libogc ***/ VIDEO_SetPostRetraceCallback (updatePAD); VIDEO_SetBlack (0); /*** Update the video for next vblank ***/ VIDEO_Flush (); VIDEO_WaitVSync (); /*** Wait for VBL ***/ if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync (); }