void grlib_Init (void) { memset (&grlibSettings, 0, sizeof (s_grlibSettings)); grlibSettings.wiiswitch_poweroff = false; grlibSettings.wiiswitch_reset = false; // Initialise the Wiimotes & Gamecube PAD_Init(); WPAD_Init(); WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); VIDEO_Init(); VIDEO_SetBlack(true); // Disable video output during initialisation VIDEO_WaitVSync(); VIDEO_WaitVSync(); GRRLIB_Init(1,0); WPAD_SetVRes(0, 640, 480); WPAD_SetPowerButtonCallback( wmpower_cb ); SYS_SetPowerCallback (power_cb); SYS_SetResetCallback (reset_cb); redrawTex = GRRLIB_CreateEmptyTexture (rmode->fbWidth, rmode->efbHeight); popPushTex = GRRLIB_CreateEmptyTexture (rmode->fbWidth, rmode->efbHeight); grlibSettings.RedrawCallback = NULL; grlibSettings.pointer[0] = NULL; grlibSettings.pointer[1] = NULL; grlibSettings.pointer[2] = NULL; grlibSettings.pointer[3] = NULL; }
static bool gx_joypad_init(void *data) { int i; SYS_SetResetCallback(reset_cb); #ifdef HW_RVL SYS_SetPowerCallback(power_callback); #endif (void)data; for (i = 0; i < MAX_PADS; i++) pad_type[i] = WPAD_EXP_NOCONTROLLER; PAD_Init(); #ifdef HW_RVL WPADInit(); #ifdef HAVE_LIBSICKSAXIS ss_init(sixaxis, USB_SLOTS); #endif #endif gx_joypad_poll(); return true; }
void Sys_Init(void) { /* Initialize video subsytem */ //VIDEO_Init(); /* Set RESET/POWER button callback */ SYS_SetResetCallback(__Sys_ResetCallback); SYS_SetPowerCallback(__Sys_PowerCallback); }
void reset_cb(void) { #ifdef DEBUG_WII_GDB printf("attach gdb now\n"); _break(); SYS_SetResetCallback(reset_cb); #else reset_btn_pressed = true; #endif }
int main(){ SYS_SetResetCallback(WiiResetPressed); SYS_SetPowerCallback(WiiPowerPressed); WPAD_SetPowerButtonCallback(WiimotePowerPressed); VIDEO_Init(); if(CONF_GetAspectRatio()) { SCREEN_WIDTH = 720; } else { SCREEN_WIDTH = 640; } initializeinput(); initializeworld(); GRRLIB_InitVideo(); GRRLIB_Start(); startscreen(); while(1){ if(!fadeout) { updateinput(); updateworld(); updatetiles(); updateoverlay(); } drawworld(); drawcursor(); drawoverlay(); //When hitting home do a slow fade to black, //if it is totally black do the actual exit if (wpadheld & WPAD_BUTTON_HOME || HWButton) fadeout = true; if(fadeout) { fadeout_opacity += 5; if(fadeout_opacity >= 270) { if(HWButton) SYS_ResetSystem(HWButton, 0, 0); return 0; } GRRLIB_Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, fadeout_opacity > 255 ? 255 << 24 : fadeout_opacity << 24, true); } GRRLIB_Render(); } return 0; }
void Sys_Init(void) { /* Initialize video subsytem */ VIDEO_Init(); /* Set RESET/POWER button callback */ SYS_SetResetCallback(__Sys_ResetCallback); SYS_SetPowerCallback(__Sys_PowerCallback); /* Prepare random seed */ srand(time(0)); }
void ogc_input__init(void) { PAD_Init (); #ifdef HW_RVL WPAD_Init(); WPAD_SetIdleTimeout(60); WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL,640,480); #endif /* register SOFTRESET */ SYS_SetResetCallback(set_softreset); }
int main(int argc, char **argv) { void *xfb[2]; u32 type; int fbi = 0; VIDEO_Init(); PAD_Init(); WPAD_Init(); rmode = VIDEO_GetPreferredMode(NULL); // double buffering, prevents flickering (is it needed for LCD TV? i don't have one to test) xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); xfb[1] = 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(); SYS_SetResetCallback(reload); SYS_SetPowerCallback(shutdown); WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(0, rmode->fbWidth, rmode->xfbHeight); while(!doreload && !dooff) { CON_Init(xfb[fbi],0,0,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); //VIDEO_ClearFrameBuffer(rmode,xfb[fbi],COLOR_BLACK); std::cout<<"\n\n\n"; WPAD_ReadPending(WPAD_CHAN_ALL, countevs); int wiimote_connection_status = WPAD_Probe(0, &type); print_wiimote_connection_status(wiimote_connection_status); std::cout<<" Event count: "<<evctr<<"\n"; if(wiimote_connection_status == WPAD_ERR_NONE) { print_and_draw_wiimote_data(xfb[fbi]); } VIDEO_SetNextFramebuffer(xfb[fbi]); VIDEO_Flush(); VIDEO_WaitVSync(); fbi ^= 1; } if(doreload) return 0; if(dooff) SYS_ResetSystem(SYS_SHUTDOWN,0,0); return 0; }
void WiiOS::Init() { OS::Init(); HWButton = -1; //input.WiiSetScreenExtents(vid.ScreenWidth(), vid.ScreenHeight()); //TODO: call this function until a successful file read can be done fatInitDefault(); //TEMP sleep(1); wiiInput.WiiInputInit(vid.ScreenWidth(), vid.ScreenHeight()); SYS_SetResetCallback(WiiResetPressed); SYS_SetPowerCallback(WiiPowerPressed); WPAD_SetPowerButtonCallback(WiimotePowerPressed); }
static void *gx_input_init(void) { PAD_Init(); #ifdef HW_RVL WPAD_Init(); #endif SYS_SetResetCallback(reset_callback); #ifdef HW_RVL SYS_SetPowerCallback(power_callback); #endif for(unsigned i = 0; i < MAX_PLAYERS; i++) if (driver.input->set_keybinds) driver.input->set_keybinds(driver.input_data, 0, i, 0, (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS)); for(unsigned i = 0; i < MAX_PADS; i++) { unsigned keybind_action = 0; switch (g_settings.input.dpad_emulation[i]) { case ANALOG_DPAD_LSTICK: keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_LSTICK); break; case ANALOG_DPAD_RSTICK: keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_RSTICK); break; case ANALOG_DPAD_NONE: keybind_action = (1ULL << KEYBINDS_ACTION_SET_ANALOG_DPAD_NONE); break; default: break; } if (keybind_action) if (driver.input->set_keybinds) driver.input->set_keybinds(driver.input_data, 0, i, 0, keybind_action); } return (void*)-1; }
void gen_reset (unsigned int hard_reset) { if (hard_reset) { /* Clear RAM */ memset (work_ram, 0, sizeof (work_ram)); memset (zram, 0, sizeof (zram)); /* Reset ROM mapping */ if (config.bios_enabled == 3) { rom_readmap[0] = &bios_rom[0]; rom_size = 0x800; } else { rom_readmap[0] = &cart_rom[0]; rom_size = genromsize; } uint8 i; for (i=1; i<8; i++) rom_readmap[i] = &cart_rom[i << 19]; } gen_running = 1; zreset = 0; /* Z80 is reset */ zbusreq = 0; /* Z80 has control of the Z bus */ zbusack = 1; /* Z80 is busy using the Z bus */ zbank = 0; /* Assume default bank is 000000-007FFF */ zirq = 0; /* No interrupts occuring */ resetline = -1; /* Reset CPUs */ m68k_pulse_reset (); z80_reset (); _YM2612_Reset(); #ifdef NGC /* register SOFTRESET */ SYS_SetResetCallback(set_softreset); #endif }
static void *gx_input_init(void) { for (unsigned i = 0; i < MAX_PADS; i++) { pad_connect[i] = 0; pad_type[i] = 0; pad_detect_pending[i] = 1; } PAD_Init(); #ifdef HW_RVL WPAD_Init(); #endif SYS_SetResetCallback(reset_callback); #ifdef HW_RVL SYS_SetPowerCallback(power_callback); #endif return (void*)-1; }
static bool gx_joypad_init(void) { SYS_SetResetCallback(reset_cb); #ifdef HW_RVL SYS_SetPowerCallback(power_callback); #endif PAD_Init(); #ifdef HW_RVL WPADInit(); #endif #ifdef HAVE_LIBSICKSAXIS int i; USB_Initialize(); ss_init(); for (i = 0; i < MAX_PADS; i++) ss_initialize(&dev[i]); #endif gx_joypad_poll(); return true; }
int main(int argc, char *argv[]) { #ifdef HW_DOL ipl_set_config(6); // disable Qoob modchip #endif #ifdef WII_DVD DI_Init(); // first #endif int selectedMenu = -1; InitDeviceThread(); InitGCVideo (); ResetVideo_Menu (); // change to menu video mode // Controllers PAD_Init(); #ifdef HW_RVL WPAD_Init(); // read wiimote accelerometer and IR data WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL,640,480); // Wii Power/Reset buttons WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB); SYS_SetPowerCallback(ShutdownCB); SYS_SetResetCallback(ResetCB); #endif // Initialise FreeType if (FT_Init ()) { printf ("Cannot initialise font subsystem!\n"); while (1); } InitialiseAudio(); // Initialize libFAT for SD and USB MountAllFAT(); // Initialize DVD subsystem (GameCube only) #ifdef HW_DOL DVD_Init (); #endif // allocate memory to store rom nesrom = (unsigned char *)malloc(1024*1024*3); // 3 MB should be plenty /*** Minimal Emulation Loop ***/ if ( !FCEUI_Initialize() ) { WaitPrompt("Unable to initialize FCE Ultra\n"); ExitToLoader(); } FCEUI_SetGameGenie(0); // 0 - OFF, 1 - ON memset(FDSBIOS, 0, sizeof(FDSBIOS)); // clear FDS BIOS memory cleanSFMDATA(); // clear state data // Set defaults DefaultSettings(); // store path app was loaded from sprintf(appPath, "fceugx"); if(argc > 0 && argv[0] != NULL) CreateAppPath(argv[0]); // Load preferences if(!LoadPrefs()) { WaitPrompt("Preferences reset - check settings!"); selectedMenu = 1; // change to preferences menu } FCEUI_SetSoundQuality(1); // 0 - low, 1 - high, 2 - high (alt.) FCEUI_SetVidSystem(GCSettings.timing); // causes a small 'pop' in the audio while (1) // main loop { #ifdef HW_RVL if(ShutdownRequested) ShutdownWii(); #endif // go back to checking if devices were inserted/removed // since we're entering the menu LWP_ResumeThread (devicethread); MainMenu(selectedMenu); selectedMenu = 2; // return to game menu from now on // stop checking if devices were removed/inserted // since we're starting emulation again LWP_SuspendThread (devicethread); ResetVideo_Emu(); setFrameTimer(); // set frametimer method before emulation SetPalette(); static int fskipc=0; while(1) // emulation loop { uint8 *gfx; int32 *sound; int32 ssize; #ifdef FRAMESKIP fskipc=(fskipc+1)%(frameskip+1); #endif FCEUI_Emulate(&gfx, &sound, &ssize, fskipc); if(!fskipc) { xbsave = gfx; FCEUD_Update(gfx, sound, ssize); } if(ResetRequested) { PowerNES(); // reset game ResetRequested = 0; } if(ConfigRequested) { ResetVideo_Menu(); if (GCSettings.AutoSave == 1) { SaveRAM(GCSettings.SaveMethod, SILENT); } else if (GCSettings.AutoSave == 2) { SaveState(GCSettings.SaveMethod, SILENT); } else if(GCSettings.AutoSave == 3) { SaveRAM(GCSettings.SaveMethod, SILENT); SaveState(GCSettings.SaveMethod, SILENT); } // save zoom level SavePrefs(SILENT); ConfigRequested = 0; break; // leave emulation loop } } } }
static void wpad_update(void) { int i,use_wpad; u32 exp; u32 p; s8 x,y; struct ir_t ir; /* update WPAD data */ WPAD_ScanPads(); for (i=0; i<2; i++) { /* check WPAD status */ if ((WPAD_Probe(i, &exp) == WPAD_ERR_NONE)) { p = WPAD_ButtonsHeld(i); x = WPAD_StickX(i, 0); y = WPAD_StickY(i, 0); if ((i == 0) && (exp == WPAD_EXP_CLASSIC)) use_wpad = 1; else use_wpad = 0; /* retrieve current key mapping */ u8 index = exp + (3 * i); /* MENU */ if ((p & wpad_keymap[index][KEY_MENU]) || (p & WPAD_BUTTON_HOME)) { ConfigRequested = 1; return; } /* PAUSE & START */ if (p & wpad_keymap[index][KEY_PAUSE]) input.system |= (sms.console == CONSOLE_GG) ? INPUT_START : INPUT_PAUSE; /* RESET */ if (((p & WPAD_CLASSIC_BUTTON_PLUS) && (p & WPAD_CLASSIC_BUTTON_MINUS)) || ((p & WPAD_BUTTON_PLUS) && (p & WPAD_BUTTON_MINUS)) || softreset) { input.system |= INPUT_RESET; softreset = 0; SYS_SetResetCallback(set_softreset); } /* BUTTON 1 */ if (p & wpad_keymap[index][KEY_BUTTON1]) input.pad[i] |= INPUT_BUTTON1; if (use_wpad && (p & wpad_keymap[0][KEY_BUTTON1])) input.pad[1] |= INPUT_BUTTON1; /* BUTTON 2 */ if (p & wpad_keymap[index][KEY_BUTTON2]) input.pad[i] |= INPUT_BUTTON2; if (use_wpad && (p & wpad_keymap[0][KEY_BUTTON2])) input.pad[1] |= INPUT_BUTTON2; /* check emulated device type */ switch (sms.device[i]) { /* digital gamepad */ case DEVICE_PAD2B: /* directional buttons */ if ((p & wpad_dirmap[exp][PAD_UP]) || (y > 70)) input.pad[i] |= INPUT_UP; else if ((p & wpad_dirmap[exp][PAD_DOWN]) || (y < -70)) input.pad[i] |= INPUT_DOWN; if ((p & wpad_dirmap[exp][PAD_LEFT]) || (x < -60)) input.pad[i] |= INPUT_LEFT; else if ((p & wpad_dirmap[exp][PAD_RIGHT]) || (x > 60)) input.pad[i] |= INPUT_RIGHT; if (use_wpad) { if ((p & wpad_dirmap[0][PAD_UP]) || (y > 70)) input.pad[1] |= INPUT_UP; else if ((p & wpad_dirmap[0][PAD_DOWN]) || (y < -70)) input.pad[1] |= INPUT_DOWN; if ((p & wpad_dirmap[0][PAD_LEFT]) || (x < -60)) input.pad[1] |= INPUT_LEFT; else if ((p & wpad_dirmap[0][PAD_RIGHT]) || (x > 60)) input.pad[1] |= INPUT_RIGHT; } break; /* analog devices */ case DEVICE_LIGHTGUN: case DEVICE_SPORTSPAD: case DEVICE_PADDLE: /* X position */ if (p & wpad_dirmap[exp][PAD_LEFT]) input.analog[i][0] --; else if (p & wpad_dirmap[exp][PAD_RIGHT]) input.analog[i][0] ++; else if (x) input.analog[i][0] = (u8)(x + 128); /* Y position */ if (p & wpad_dirmap[exp][PAD_UP]) input.analog[i][1] --; else if (p & wpad_dirmap[exp][PAD_DOWN]) input.analog[i][1] ++; else if (y) input.analog[i][1] = (u8)(128 - y); /* by default, use IR pointing */ WPAD_IR(i, &ir); if (ir.valid) { input.analog[i][0] = (ir.x * 4) / 10; input.analog[i][1] = ir.y / 2; if (p & WPAD_BUTTON_A) input.pad[i] |= INPUT_BUTTON1; } /* limiter */ if (input.analog[i][0] < 0) input.analog[i][0] = 0; else if (input.analog[i][0] > 0xFF) input.analog[i][0] = 0xFF; if (input.analog[i][1] < 0) input.analog[i][1] = 0; else if (input.analog[i][1] > 0xFF) input.analog[i][1] = 0xFF; break; /* none */ default: break; } /* Colecovision keypad support */ if (sms.console == CONSOLE_COLECO) { u32 pad; u32 d = WPAD_ButtonsDown(i); input.system = 0; if (d & WPAD_CLASSIC_BUTTON_PLUS) { pad = (coleco.keypad[i] & 0x0f) + 1; if (pad > 11) pad = 0; if (pad == 11) sprintf(osd.msg,"KeyPad(%d) #",i+1); else if (pad == 10) sprintf(osd.msg,"KeyPad(%d) *",i+1); else sprintf(osd.msg,"KeyPad(%d) %d",i+1,pad); osd.frames = 60; coleco.keypad[i] = (coleco.keypad[i] & 0xf0) | pad; } if (p & WPAD_CLASSIC_BUTTON_MINUS) coleco.keypad[i] &= 0x0f; if (use_wpad) { if (d & WPAD_BUTTON_PLUS) { pad = (coleco.keypad[1] & 0x0f) + 1; if (pad > 11) pad = 0; if (pad == 11) sprintf(osd.msg,"KeyPad(2) #"); else if (pad == 10) sprintf(osd.msg,"KeyPad(2) *"); else sprintf(osd.msg,"KeyPad(2) %d",pad); osd.frames = 60; coleco.keypad[1] = (coleco.keypad[1] & 0xf0) | pad; } if (p & WPAD_BUTTON_MINUS) coleco.keypad[1] &= 0x0f; } else { if (d & WPAD_BUTTON_PLUS) { pad = (coleco.keypad[i] & 0x0f) + 1; if (pad > 11) pad = 0; if (pad == 11) sprintf(osd.msg,"KeyPad(%d) #",i+1); else if (pad == 10) sprintf(osd.msg,"KeyPad(%d) *",i+1); else sprintf(osd.msg,"KeyPad(%d) %d",i+1,pad); osd.frames = 30; coleco.keypad[i] = (coleco.keypad[i] & 0xf0) | pad; } if (p & WPAD_BUTTON_MINUS) coleco.keypad[i] &= 0x0f; } } } } }
void Sys_Init(void) { /* Set RESET/POWER button callback */ SYS_SetResetCallback(__Sys_ResetCallback); SYS_SetPowerCallback(__Sys_PowerCallback); }
//--------------------------------------------------------------------------------- int main(int argc, char **argv) { //--------------------------------------------------------------------------------- s32 ret; u8 gamestatus = 0x03; u8 versionnumber = 0x80; u32 geckoidcheck; u8 oldconfigbytes[2]; ret = sd_init(); if(!ret){ sd_found = 0; } else { sd_found = 1; } if (*((u32 *) 0x80001804) == 0x53545542 && *((u32 *) 0x80001808) == 0x48415858) loaderhbc = 1; *(u32*)0xCD00643C = 0x00000000; // 32Mhz on Bus gecko_attached = usb_isgeckoalive(EXI_CHANNEL_1); if(gecko_attached){ gecko_channel = 1; if (EXI_GetID(gecko_channel, 0x80, &geckoidcheck) == 1) { if (geckoidcheck != 0) { gecko_attached = FALSE; goto slota; } } else { gecko_attached = FALSE; goto slota; } usb_flushnew(gecko_channel); goto slotb; } slota: gecko_attached = usb_isgeckoalive(EXI_CHANNEL_0); if(gecko_attached){ gecko_channel = 0; if (EXI_GetID(gecko_channel, 0x80, &geckoidcheck) == 1) { if (geckoidcheck != 0) { gecko_attached = FALSE; goto slotb; } } else { gecko_attached = FALSE; goto slotb; } usb_flushnew(gecko_channel); } slotb: sd_load_config(); tempgameconf = (char *) sdbuffer; autobootcheck = 1; memset(gameidbuffer, 0, 8); app_loadgameconfig(gameidbuffer); autobootcheck = 0; loadStartupIOS(); iosversion = IOS_GetVersion(); if(config_not_loaded == 0){ menu_load_config(); config_not_loaded = 1; } if (autoboothbc || !loaderhbc) { if (autoboot == 1) { rebooter_thread(); menu_number = 12; rebooter_thread_state = 0; } } else autoboot = 0; WPAD_Init(); PAD_Init(); VIDEO_Init(); AUDIO_Init (NULL); SYS_SetPowerCallback (power_cb); SYS_SetResetCallback (reset_cb); if (CONF_GetProgressiveScan() > 0 && VIDEO_HaveComponentCable()) { progmode = 1; } if (CONF_GetAspectRatio()) { widescreen = 1; } gfx_init(); gfx_load_gfx(); gfx_load_gfx1(); if (autoboot == 0 || autobootwait > 1) gfx_fade_logo(); VIDEO_WaitVSync(); if(!gecko_attached){ gecko_channel = 2; } gfx_int_stars(); while(1) { if(gecko_attached){ usb_recvbuffer(gecko_channel,&gecko_command,1); switch(gecko_command) { //case 0x04: // gecko_readmem(); //break; case 0x14: // Load DOL load_geckoexe(0); break; case 0x24: // Load DOL load_geckoexe(1); break; case 0x42: // Debugger on, pause start off config_bytes[7] = 0x01; config_bytes[5] = 0x00; usb_recvbuffer_safe(gecko_channel,&oldconfigbytes,2); // Get config config_bytes[0] = oldconfigbytes[0]; switch (oldconfigbytes[1]) { case 0x00: config_bytes[1] = 0x00; break; case 0x01: config_bytes[1] = 0x01; break; case 0x02: config_bytes[1] = 0x00; break; case 0x03: config_bytes[1] = 0x01; break; case 0x04: config_bytes[1] = 0x03; break; case 0x05: config_bytes[1] = 0x03; break; case 0x06: config_bytes[1] = 0x02; break; case 0x07: config_bytes[1] = 0x02; break; } menu_number = 8; apploader_thread(); gecko_command = 0; break; case 0x43: // Debugger on, pause start on config_bytes[7] = 0x01; config_bytes[5] = 0x01; usb_recvbuffer_safe(gecko_channel,&oldconfigbytes,2); // Get config config_bytes[0] = oldconfigbytes[0]; switch (oldconfigbytes[1]) { case 0x00: config_bytes[1] = 0x00; break; case 0x01: config_bytes[1] = 0x01; break; case 0x02: config_bytes[1] = 0x00; break; case 0x03: config_bytes[1] = 0x01; break; case 0x04: config_bytes[1] = 0x03; break; case 0x05: config_bytes[1] = 0x03; break; case 0x06: config_bytes[1] = 0x02; break; case 0x07: config_bytes[1] = 0x02; break; } menu_number = 8; apploader_thread(); gecko_command = 0; break; case 0x50: usb_sendbuffer_safe(gecko_channel,&gamestatus,1); break; case 0x99: usb_sendbuffer_safe(gecko_channel,&versionnumber,1); break; } } if(error_sd || confirm_sd || error_video){ sleep(1); error_sd = 0; confirm_sd = 0; error_video = 0; } if(loadedpng && !alphapng){ // if custom backdrop draw bubbles after image gfx_draw_image(0, 0, 640, 480, tex_logo1, 0, 1, 1,0xff); gfx_draw_stars(); } else{ gfx_draw_stars(); // else if own back drop do in this order due to border clip gfx_draw_image(0, 0, 640, 480, tex_logo1, 0, 1, 1,0xff); }; menu_draw(); gfx_render_direct(); } return 0; }
SdlUi::SdlUi(long width, long height, bool fs_flag) : BaseUi(), zoom_available(true), toggle_fs_available(false), mode_changing(false) { #ifdef GEKKO WPAD_Init(); SYS_SetResetCallback(GekkoResetCallback); #endif uint32_t flags = SDL_INIT_VIDEO; #ifndef EMSCRIPTEN flags |= SDL_INIT_TIMER; #endif #if (!defined(NDEBUG) || defined(_WIN32)) flags |= SDL_INIT_NOPARACHUTE; #endif // Set some SDL environment variables before starting. These are platform // dependent, so every port needs to set them manually #ifndef GEKKO // Set window position to the middle of the screen putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=center")); #endif #ifdef __LINUX__ // Set the application class name setenv("SDL_VIDEO_X11_WMCLASS", GAME_TITLE, 0); #elif defined(PSP) putenv(const_cast<char *>("SDL_ASPECT_RATIO=4:3")); #endif if (SDL_Init(flags) < 0) { Output::Error("Couldn't initialize SDL.\n%s\n", SDL_GetError()); } #if SDL_MAJOR_VERSION==1 sdl_surface = NULL; #else sdl_window = NULL; #endif BeginDisplayModeChange(); if (!RequestVideoMode(width, height, fs_flag)) { Output::Error("No suitable video resolution found. Aborting."); } EndDisplayModeChange(); #ifdef GEKKO // Eliminate debug spew in on-screen console Output::WiiSetConsole(); // Eliminate overscan / add 5% borders WII_ChangeSquare(304, 228, 0, 0); #endif SetTitle(GAME_TITLE); #if (defined(USE_JOYSTICK) && defined(SUPPORT_JOYSTICK)) || (defined(USE_JOYSTICK_AXIS) && defined(SUPPORT_JOYSTICK_AXIS)) || (defined(USE_JOYSTICK_HAT) && defined(SUPPORT_JOYSTICK_HAT)) if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) { Output::Warning("Couldn't initialize joystick.\n%s", SDL_GetError()); } SDL_JoystickEventState(1); SDL_JoystickOpen(0); #endif #if defined(USE_MOUSE) && defined(SUPPORT_MOUSE) ShowCursor(true); #else ShowCursor(false); #endif #ifdef HAVE_SDL_MIXER audio_.reset(new SdlAudio()); #elif defined(HAVE_OPENAL) audio_.reset(new ALAudio()); #else audio_.reset(new EmptyAudio()); #endif }
static void* main_thread_function(void*) { u32 level, real_heap_size; // hope the parms are all set by now COM_InitArgv(parms_number, parms_array); _CPU_ISR_Disable(level); heap = (char *)align32(SYS_GetArena2Lo()); real_heap_size = heap_size - ((u32)heap - (u32)SYS_GetArena2Lo()); if ((u32)heap + real_heap_size > (u32)SYS_GetArena2Hi()) { _CPU_ISR_Restore(level); Sys_Error("heap + real_heap_size > (u32)SYS_GetArena2Hi()"); } else { SYS_SetArena2Lo(heap + real_heap_size); _CPU_ISR_Restore(level); } VIDEO_SetBlack(TRUE); // Initialise the Host module. quakeparms_t parms; memset(&parms, 0, sizeof(parms)); parms.argc = com_argc; parms.argv = com_argv; parms.basedir = QUAKE_WII_BASEDIR; parms.memsize = real_heap_size; parms.membase = heap; if (parms.membase == 0) { Sys_Error("Heap allocation failed"); } memset(parms.membase, 0, parms.memsize); Host_Init(&parms); #if TIME_DEMO Cbuf_AddText("map start\n"); Cbuf_AddText("wait\n"); Cbuf_AddText("timedemo demo1\n"); #endif #if TEST_CONNECTION Cbuf_AddText("connect 192.168.0.2"); #endif SYS_SetResetCallback(reset_system); SYS_SetPowerCallback(shutdown_system); VIDEO_SetBlack(FALSE); // Run the main loop. u64 last_time = gettime(); for (;;) { if (want_to_reset) Sys_Reset(); if (want_to_shutdown) Sys_Shutdown(); // Get the frame time in ticks. const u64 current_time = gettime(); const u64 time_delta = current_time - last_time; const double seconds = time_delta * (0.001f / TB_TIMER_CLOCK); last_time = current_time; // Run the frame. Host_Frame(seconds); }; // Quit (this code is never reached). Sys_Quit(); return 0; }
int main(int argc, char *argv[]) { s32 res; #if defined(USE_WII_DI) && !defined(GAMECUBE) DI_Init(); #endif VIDEO_Init(); PAD_Init(); DSP_Init(); AUDIO_Init(NULL); gfx_video_init(NULL); gfx_init(); gfx_con_init(NULL); #ifdef DEBUG_WII_GDB DEBUG_Init(GDBSTUB_DEVICE_USB, 1); #endif printf("startup as "); if (argc > 0) printf("'%s'\n", argv[0]); else printf("<unknown>\n"); SYS_RegisterResetFunc(&resetinfo); SYS_SetResetCallback(reset_cb); #ifndef GAMECUBE SYS_SetPowerCallback(power_cb); #endif if (!fatInitDefault()) { printf("fatInitDefault failed\n"); } else { // set the default path if libfat couldnt set it // this allows loading over tcp/usbgecko char cwd[MAXPATHLEN]; if (getcwd(cwd, MAXPATHLEN)) { size_t len = strlen(cwd); if (len > 2 && (cwd[len - 1] == ':' || cwd[len - 2] == ':')) { printf("chdir to default\n"); chdir("/apps/scummvm"); } } } g_system = new OSystem_Wii(); assert(g_system); #ifdef DYNAMIC_MODULES PluginManager::instance().addPluginProvider(new WiiPluginProvider()); #endif res = scummvm_main(argc, argv); g_system->quit(); printf("shutdown\n"); SYS_UnregisterResetFunc(&resetinfo); fatUnmountDefault(); if (res) show_console(res); if (power_btn_pressed) { printf("shutting down\n"); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } printf("reloading\n"); gfx_con_deinit(); gfx_deinit(); gfx_video_deinit(); return res; }
SdlUi::SdlUi(long width, long height, const std::string& title, bool fs_flag) : BaseUi(), zoom_available(true), toggle_fs_available(false), mode_changing(false) { #ifdef GEKKO WPAD_Init(); SYS_SetResetCallback(GekkoResetCallback); #endif uint32_t flags = SDL_INIT_VIDEO; #ifndef EMSCRIPTEN flags |= SDL_INIT_TIMER; #endif #if (!defined(NDEBUG) || defined(_WIN32)) flags |= SDL_INIT_NOPARACHUTE; #endif // Set some SDL env. variables before starting // These are platform dependent, so every port // needs to set them manually // Set window position to the middle of the // screen #ifndef GEKKO putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=center")); #endif #if defined(PSP) putenv(const_cast<char *>("SDL_ASPECT_RATIO=4:3")); #endif if (SDL_Init(flags) < 0) { Output::Error("Couldn't initialize SDL.\n%s\n", SDL_GetError()); } #if SDL_MAJOR_VERSION==1 sdl_surface = NULL; SetAppIcon(); #else sdl_window = NULL; #endif BeginDisplayModeChange(); if (!RequestVideoMode(width, height, fs_flag)) { Output::Error("No suitable video resolution found. Aborting."); } EndDisplayModeChange(); SetTitle(title); #if (defined(USE_JOYSTICK) && defined(SUPPORT_JOYSTICK)) || (defined(USE_JOYSTICK_AXIS) && defined(SUPPORT_JOYSTICK_AXIS)) || (defined(USE_JOYSTICK_HAT) && defined(SUPPORT_JOYSTICK_HAT)) if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) { Output::Warning("Couldn't initialize joystick.\n%s", SDL_GetError()); } SDL_JoystickEventState(1); SDL_JoystickOpen(0); #endif #if defined(USE_MOUSE) && defined(SUPPORT_MOUSE) ShowCursor(true); #else ShowCursor(false); #endif #if defined(HAVE_SDL_MIXER) audio_.reset(new SdlAudio()); #elif defined(HAVE_OPENAL) audio_.reset(new ALAudio()); #else audio_.reset(new EmptyAudio()); #endif }
int main(int argc, char **argv) { int ret; VIDEO_Init(); //Inicialización del Vídeo. rmode = VIDEO_GetPreferredMode(NULL); //mediante esta función rmode recibe el valor de tu modo de vídeo. xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); //inicialización del buffer. console_init(xfb,20,20,rmode->fbWidth,rmode-> //inicialización de la consola. xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); VIDEO_Configure(rmode); //configuración del vídeo. VIDEO_SetNextFramebuffer(xfb); //Configura donde guardar el siguiente buffer . VIDEO_SetBlack(FALSE); //Hace visible el display . VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); SYS_SetResetCallback(reset_call); IOS_ReloadIOS(222); sleep(1); /* secuencias de escape \33[2J -> borra pantalla y posiciona en 1,1 \33[1;1H -> posiciona en 1,1 \33[42m -> color de fondo verde (0->negro, 1->rojo, 2->verde, 3-> amarillo, 4->azul, 5->magenta 6->cyan 7->blanco ) \33[32m -> color de letras verde */ printf("\33[2J\n\n\n \33[42m dev/mload Test \33[40m \n\n\n\n"); ret=mload_init(); if(ret<0) { printf("fail to get dev/mload\n"); goto out; } else { u32 addr; int len; printf("Hello!: my name is dev/mload and my thread id is %i\n", mload_get_thread_id()); mload_get_load_base(&addr, &len); printf("You have from 0x%x to 0x%x to work\n\n", addr, addr+len-1); } /* mload_elf((void *) ehcmodule_elf, &my_data_elf); my_thread_id=mload_run_thread(my_data_elf.start, my_data_elf.stack, my_data_elf.size_stack, my_data_elf.prio); */ printf("Loading example1.elf (Starlet)\n"); if(((u32) example1_elf) & 3) {printf("Unaligned elf!\n"); goto out;} mload_elf((void *) example1_elf, &my_data_elf); printf("Running... at 0x%x\n", (u32) my_data_elf.start); my_thread_id=mload_run_thread(my_data_elf.start, my_data_elf.stack, my_data_elf.size_stack, my_data_elf.prio); if(my_thread_id<0) {printf("fail to init the starlet thread: %i\n", my_thread_id); goto out;} printf("Module thread id: %i Priority in elf: 0x%x\n", my_thread_id, my_data_elf.prio); printf("The example Module counts seconds and report the thread id and the priority\n"); { #if 0 int n,m; sleep(1); #define UMS_BASE (('U'<<24)|('M'<<16)|('S'<<8)) #define USB_IOCTL_UMS_INIT (UMS_BASE+0x1) s32 hid2 = -1; hid2 = iosCreateHeap(1024); n=IOS_Open(ehc_fs, 0); if(n<0) printf("Error: device not found\n"); else { printf("OK\n"); /* Initialize USB storage */ m=IOS_IoctlvFormat(hid2, n, USB_IOCTL_UMS_INIT, ":"); } #endif } while(1) { static u32 data[8] ATTRIBUTE_ALIGN(32); if(exit_by_reset) break; mload_seek(0x13740000, SEEK_SET); mload_read(&data,32); printf("\33[16;16H Starlet activity: %i Thid: %i Prio: 0x%x \n",data[0],data[1],data[2]); VIDEO_WaitVSync(); } // you can stops the Starlet thread using this function: mload_stop_thread(my_thread_id); out: mload_close(); VIDEO_WaitVSync(); sleep(4); return 0; }
int main(int argc, char *argv[]) { s32 res; #ifdef USE_WII_DI DI_Init(); #endif VIDEO_Init(); PAD_Init(); AUDIO_Init(NULL); #ifdef DEBUG_WII_USBGECKO CON_EnableGecko(1, false); #endif #ifdef DEBUG_WII_GDB DEBUG_Init(GDBSTUB_DEVICE_USB, 1); #endif printf("startup as "); if (argc > 0) printf("'%s'\n", argv[0]); else printf("<unknown>\n"); SYS_SetResetCallback(reset_cb); #ifndef GAMECUBE SYS_SetPowerCallback(power_cb); #endif #ifdef USE_WII_DI // initial async mount for the browser, see wii-fs.cpp DI_Mount(); #endif if (!fatInitDefault()) { printf("fatInitDefault failed\n"); } else { // set the default path if libfat couldnt set it // this allows loading over tcp/usbgecko char cwd[MAXPATHLEN]; if (getcwd(cwd, MAXPATHLEN)) { size_t len = strlen(cwd); if (len > 2 && (cwd[len - 1] == ':' || cwd[len - 2] == ':')) { printf("chdir to default\n"); chdir("/apps/scummvm"); } } } g_system = new OSystem_Wii(); assert(g_system); res = scummvm_main(argc, argv); g_system->quit(); printf("shutdown\n"); fatUnmountDefault(); #ifdef USE_WII_DI DI_Close(); #endif if (power_btn_pressed) { printf("shutting down\n"); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } printf("reloading\n"); return res; }
int main(int argc, char **argv) { SYS_SetResetCallback(WiiResetPressed); SYS_SetPowerCallback(WiiPowerPressed); usleep(250*1000); GRRLIB_Init(); GRRLIB_ttfFont *font = GRRLIB_LoadTTF(verdana_ttf, verdana_ttf_size); WPAD_Init(); USB_Initialize(); USB_DeviceChangeNotifyAsync(USB_CLASS_HID, change_notify_cb, NULL); int dev_id = get_device_id(); int fd = open_device(dev_id); struct ds4_input data; memset(&data, 0, sizeof(data)); fetch_data(fd, &data); random_leds(fd); int screenW = rmode->fbWidth, screenH = rmode->efbHeight; float pos_x = screenW/2, pos_y = screenH/2; while (run) { WPAD_ScanPads(); u32 pressed = WPAD_ButtonsDown(0); if (pressed & WPAD_BUTTON_B) { dev_id = get_device_id(); fd = open_device(dev_id); } if (pressed & WPAD_BUTTON_A) { random_leds(fd); } GRRLIB_FillScreen(0x0); GRRLIB_PrintfTTF(15, 15, font, "ds4wii by xerpi | L1: center | R1: random color", 15, 0xFFFFFFFF); u32 color = (r<<24)|(g<<16)|(b<<8)|0xFF; GRRLIB_Circle(pos_x, pos_y, 15, color, 0); GRRLIB_Circle(pos_x, pos_y, 14, color, 0); memset(&data, 0, sizeof(data)); fetch_data(fd, &data); if (data.L1) {pos_x = screenW/2, pos_y = screenH/2;} if (data.R1) {random_leds(fd);} //1920x940 if (data.finger1active) { GRRLIB_Circle((screenW/1920.0f)*data.finger1X, (screenH/940.0f)*data.finger1Y, 10, 0x00FF00FF, 1); } if (data.finger2active) { GRRLIB_Circle((screenW/1920.0f)*data.finger2X, (screenH/940.0f)*data.finger2Y, 10, 0x0000FFFF, 1); } /*char buf1[256]; sprintf(buf1, "aX: %8hi aY: %8hi aZ: %8hi", data.accelX, data.accelY, data.accelZ); char buf2[256]; sprintf(buf2, "gyroX: %8hi gyroY: %8hi gyroZ: %8hi", data.gyroX, data.gyroY, data.gyroZ); GRRLIB_PrintfTTF(15, 30, font, buf1, 14, 0xFFFFFFFF); GRRLIB_PrintfTTF(15, 45, font, buf2, 14, 0xFFFFFFFF); */ #define THRESHOLD 50.0f if (fabs(data.accelX) > THRESHOLD) pos_y -= data.accelX/55.0f; if (fabs(data.accelY) > THRESHOLD) pos_x -= data.accelY/55.0f; if (pressed & WPAD_BUTTON_HOME) run = 0; GRRLIB_Render(); } USB_CloseDevice(&fd); USB_Deinitialize(); GRRLIB_FreeTTF (font); GRRLIB_Exit(); exit(0); return 0; }
static void pad_update() { int i; u16 p; s8 x,y; /* update PAD status */ PAD_ScanPads(); for (i=0; i<MAX_INPUTS; i++) { x = PAD_StickX (i); y = PAD_StickY (i); p = PAD_ButtonsHeld(i); /* MENU */ if (p & pad_keymap[i][KEY_MENU]) { ConfigRequested = 1; return; } /* PAUSE & START button */ if (p & pad_keymap[i][KEY_PAUSE]) input.system |= (sms.console == CONSOLE_GG) ? INPUT_START : INPUT_PAUSE; /* SOFT RESET */ if (((p & PAD_TRIGGER_R) && (p & PAD_TRIGGER_L)) || softreset) { input.system |= INPUT_RESET; softreset = 0; SYS_SetResetCallback(set_softreset); } /* BUTTONS 1&2 */ if (p & pad_keymap[i][KEY_BUTTON1]) input.pad[i] |= INPUT_BUTTON1; if (p & pad_keymap[i][KEY_BUTTON2]) input.pad[i] |= INPUT_BUTTON2; /* check emulated device type */ switch (sms.device[i]) { /* digital gamepad */ case DEVICE_PAD2B: /* directional buttons */ if ((p & PAD_BUTTON_UP) || (y > 70)) input.pad[i] |= INPUT_UP; else if ((p & PAD_BUTTON_DOWN) || (y < -70)) input.pad[i] |= INPUT_DOWN; if ((p & PAD_BUTTON_LEFT) || (x < -60)) input.pad[i] |= INPUT_LEFT; else if ((p & PAD_BUTTON_RIGHT) || (x > 60)) input.pad[i] |= INPUT_RIGHT; break; /* analog devices */ case DEVICE_LIGHTGUN: case DEVICE_SPORTSPAD: case DEVICE_PADDLE: /* X position */ if (p & PAD_BUTTON_LEFT) input.analog[i][0] --; else if (p & PAD_BUTTON_RIGHT) input.analog[i][0] ++; else if (x) input.analog[i][0] = (u8)(x + 128); /* Y position */ if (p & PAD_BUTTON_UP) input.analog[i][1] --; else if (p & PAD_BUTTON_DOWN) input.analog[i][1] ++; else if (y) input.analog[i][1] = (u8)(128 - y); /* Limiters */ if (input.analog[i][0] < 0) input.analog[i][0] = 0; else if (input.analog[i][0] > 0xFF) input.analog[i][0] = 0xFF; if (input.analog[i][1] < 0) input.analog[i][1] = 0; else if (input.analog[i][1] > 0xFF) input.analog[i][1] = 0xFF; break; /* none */ default: break; } /* Colecovision support */ if (sms.console == CONSOLE_COLECO) { u16 pad; u16 d = PAD_ButtonsDown(i); input.system = 0; if (d & PAD_TRIGGER_R) { pad = (coleco.keypad[i] & 0x0f) + 1; if (pad > 11) pad = 0; if (pad == 11) sprintf(osd.msg,"KeyPad(%d) #",i+1); else if (pad == 10) sprintf(osd.msg,"KeyPad(%d) *",i+1); else sprintf(osd.msg,"KeyPad(%d) %d",i+1,pad); osd.frames = 30; coleco.keypad[i] = (coleco.keypad[i] & 0xf0) | pad; } if (p & PAD_TRIGGER_L) coleco.keypad[i] &= 0x0f; } } }
int main(int argc, char* argv[]) { u8 *tex_ptrone=GRRLIB_LoadTexture(handpointerred_png); u8 *tex_ptrtwo=GRRLIB_LoadTexture(handpointergreen_png); u8 *tex_back=GRRLIB_LoadJPG(bigmenuback_jpg, bigmenuback_jpg_size); u8 *tex_fore=GRRLIB_LoadTexture(credits_png); fatInitDefault(); GRRLIB_InitVideo(); WPAD_Init(); SYS_SetResetCallback(WiiResetPressed); SYS_SetPowerCallback(WiiPowerPressed); WPAD_SetPowerButtonCallback(WiimotePowerPressed); rmode = VIDEO_GetPreferredMode(NULL); AESND_Init(NULL); MODPlay_Init(&mod_track); Init_Voice(); AESND_Pause(0); // the sound loop is running now // set the MOD song if (MODPlay_SetMOD (&mod_track, dojo_dan_oriental_mod) < 0 ) { MODPlay_Unload (&mod_track); } else { // set the music volume to the minimum so we don't hear the music before saved volume is known MODPlay_SetVolume( &mod_track, 0,0); MODPlay_Start (&mod_track);// Play the MOD } WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL, rmode->fbWidth, rmode->xfbHeight); initMain(); MODPlay_SetVolume( &mod_track, opt_music, opt_music); while( HWButton == 0) { WPAD_ScanPads(); u32 wpad_one_down = WPAD_ButtonsDown(0); u32 wpad_two_down = WPAD_ButtonsDown(1); u32 type; WPADData *wd_one, *wd_two; WPAD_ReadPending(WPAD_CHAN_ALL, countevs); WPAD_Probe(WPAD_CHAN_ALL, &type); wd_one = WPAD_Data(0); wd_two = WPAD_Data(1); switch(main_mode) { case STARTUP : GRRLIB_FillScreen(0xFF000000); GRRLIB_DrawImg(0, 0, 640, 480, tex_back, 0, 1, 1, alpha>255?255:alpha); GRRLIB_DrawImg(68,308, 256, 80, tex_fore, 0, 1, 1, alpha>255?255:alpha); if(alpha++>394 || wpad_one_down > 0) { main_mode=MENU; if(tex_back) free(tex_back); if(tex_fore) free(tex_fore); initMenu(); } break; case MENU : GRRLIB_FillScreen(0xFF000000); int menuopt = menuWiimote(wd_one,wpad_one_down); if(menuopt==EXIT) { if(tex_ptrone) free(tex_ptrone); if(tex_ptrtwo) free(tex_ptrtwo); } if(menuopt>NOTHING) { processMenuOption(menuopt); if(main_mode==GAME) { MODPlay_Unload (&mod_track); if(opt_tileset==SPOOKY) MODPlay_SetMOD (&mod_track, graveyard_mod); else if(opt_tileset==EGYPTIAN) MODPlay_SetMOD (&mod_track, egypt_crap_mod); else if(opt_tileset==SIMPLE) MODPlay_SetMOD (&mod_track, childhood_mod); else if(opt_tileset==SPACE) MODPlay_SetMOD (&mod_track, nebulos_mod); else MODPlay_SetMOD (&mod_track, sushi_mod); MODPlay_SetVolume( &mod_track, opt_music, opt_music); MODPlay_Start (&mod_track); } else drawMenu(wd_one); } else drawMenu(wd_one); break; case GAME : if(gameWiimote(wd_one,wpad_one_down,wd_two,wpad_two_down)) { // we are exiting the game back to the menu main_mode=MENU; MODPlay_Unload (&mod_track); MODPlay_SetMOD (&mod_track, dojo_dan_oriental_mod); MODPlay_SetVolume( &mod_track, opt_music, opt_music); MODPlay_Start (&mod_track); killGame(); initMenu(); } else { drawGame(); } break; } // alternate which pointer is on top every frame to not give the advantage to player one in two player mode static int ticktock=0; ticktock++; if(wd_two->ir.valid && ticktock%2==0) { if(main_mode==GAME && whatGameMode()==ONE_PLAYER_GAME) { // don't display second pointer in one player mode } else GRRLIB_DrawColImg(wd_two->ir.x - 9,wd_two->ir.y - 7,68,80,tex_ptrtwo,0,1,1,0xEEFFFFFF); } if(wd_one->ir.valid) { GRRLIB_DrawColImg(wd_one->ir.x - 9,wd_one->ir.y - 7,68,80,tex_ptrone,0,1,1,0xEEFFFFFF); } if(wd_two->ir.valid && ticktock%2!=0) { if(main_mode==GAME && whatGameMode()==ONE_PLAYER_GAME) { // don't display second pointer in one player mode } else GRRLIB_DrawColImg(wd_two->ir.x - 9,wd_two->ir.y - 7,68,80,tex_ptrtwo,0,1,1,0xEEFFFFFF); } if(wd_one->btns_h & WPAD_BUTTON_1) { GRRLIB_ScrShot("MahjonggWii_Screen_%y%m%d_%H%M%S.png",time(NULL)); } GRRLIB_Render(); } // we are exiting, free the mallocs switch( main_mode) { case GAME: killGame(); } if(tex_ptrone) free(tex_ptrone); if(tex_ptrtwo) free(tex_ptrtwo); killMenuLanguages(); MODPlay_Unload (&mod_track); Free_Voice(); WPAD_Shutdown(); GRRLIB_Stop(); saveConfig(FILE_CFG); SYS_ResetSystem(HWButton, 0, 0); return 0; }
/*************************************************************************** * M A I N * ***************************************************************************/ int main (int argc, char *argv[]) { #ifdef HW_RVL /* enable 64-byte fetch mode for L2 cache */ L2Enhance(); /* initialize DI interface */ DI_UseCache(0); DI_Init(); sprintf(osd_version, "%s (IOS %d)", VERSION, IOS_GetVersion()); #else sprintf(osd_version, "%s (GCN)", VERSION); #endif /* initialize video engine */ gx_video_Init(); #ifndef HW_RVL /* initialize DVD interface */ DVD_Init(); #endif /* initialize input engine */ gx_input_Init(); /* initialize FAT devices */ int retry = 0; int fatMounted = 0; /* try to mount FAT devices during 3 seconds */ while (!fatMounted && (retry < 12)) { fatMounted = fatInitDefault(); usleep(250000); retry++; } if (fatMounted) { /* base directory */ char pathname[MAXPATHLEN]; sprintf (pathname, DEFAULT_PATH); DIR *dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); /* default SRAM & Savestate files directories */ sprintf (pathname, "%s/saves",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/saves/md",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/saves/ms",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/saves/gg",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/saves/sg",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/saves/cd",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); /* default Snapshot files directories */ sprintf (pathname, "%s/snaps",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/snaps/md",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/snaps/ms",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/snaps/gg",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/snaps/sg",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/snaps/cd",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); /* default Cheat files directories */ sprintf (pathname, "%s/cheats",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/cheats/md",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/cheats/ms",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/cheats/gg",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/cheats/sg",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); sprintf (pathname, "%s/cheats/cd",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); /* default BIOS ROM files directories */ sprintf (pathname, "%s/bios",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); /* default LOCK-ON ROM files directories */ sprintf (pathname, "%s/lock-on",DEFAULT_PATH); dir = opendir(pathname); if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); } /* initialize sound engine */ gx_audio_Init(); /* initialize genesis plus core */ history_default(); config_default(); init_machine(); /* auto-load last ROM file */ if (config.autoload) { SILENT = 1; if (OpenDirectory(TYPE_RECENT, -1)) { if (LoadFile(0)) { reloadrom(); gx_video_Start(); gx_audio_Start(); ConfigRequested = 0; } } SILENT = 0; } /* show disclaimer */ if (ConfigRequested) { legal(); } #ifdef HW_RVL /* power button callback */ SYS_SetPowerCallback(PowerOff_cb); #endif /* reset button callback */ SYS_SetResetCallback(Reset_cb); /* main emulation loop */ run_emulation(); /* we should never return anyway */ return 0; }
// TODO this is just my console test app, clean up this mess! int main(int argc, char *argv[]) { (void) argc; (void) argv; VIDEO_Init(); PAD_Init(); SYS_SetResetCallback(stmcb); SYS_SetPowerCallback(stmcb); gfx_video_init(NULL); gfx_init(); gfx_con_init(NULL); printf("startup\n"); gfx_tex_t tex; memset(&tex, 0, sizeof(gfx_tex_t)); if (!gfx_tex_init(&tex, GFX_TF_RGB565, 0, 16, 16)) { printf("failed to init tex!\n"); return 1; } memset(tex.pixels, 0xe070, 16 * 16 * 2); gfx_tex_flush_texture(&tex); gfx_screen_coords_t coords_bg; gfx_coords(&coords_bg, &tex, GFX_COORD_FULLSCREEN); srand(gettime()); u64 frame = 0; u16 b; bool pf = false; u32 retries; u8 fg = 7, bg = 0; u32 i; char buf[32]; while (!quit) { b = 0; if (PAD_ScanPads() & 1) { b = PAD_ButtonsDown(0); gfx_con_set_alpha(0xff - PAD_TriggerR(0), 0xff - PAD_TriggerL(0)); } if (b & PAD_BUTTON_A) quit = true; if (b & PAD_BUTTON_B) pf = !pf; if (b & PAD_BUTTON_X) printf(S_RED("Hello") " " S_BLUE("world") "!\n"); if (pf) { for (i = 0; i < gfx_con_get_columns() * gfx_con_get_rows(); ++i) { printf(CON_ESC "%u;1m" CON_ESC "%um%c", 30 + IRAND(8), 40 + IRAND(8), 0x20 + IRAND(16 * 9)); } } if (b & PAD_TRIGGER_Z) { gfx_con_reset(); fg = 7; bg = 0; } if (b & 15) { if (b & PAD_BUTTON_LEFT) { fg = (fg + 8 - 1) % 8; gfx_con_set_foreground_color(fg, true); } if (b & PAD_BUTTON_RIGHT) { fg = (fg + 1) % 8; gfx_con_set_foreground_color(fg, true); } if (b & PAD_BUTTON_UP) { bg = (bg + 8 - 1) % 8; gfx_con_set_background_color(bg, false); } if (b & PAD_BUTTON_DOWN) { bg = (bg + 1) % 8; gfx_con_set_background_color(bg, false); } printf("new color selected: %u %u\n", fg, bg); } sprintf(buf, "frame: %llu", frame); gfx_con_save_attr(); gfx_con_set_pos(1, gfx_con_get_columns() - strlen(buf) + 1); printf(CON_COLRESET "%s", buf); gfx_con_restore_attr(); retries = 0; while (!gfx_frame_start()) { retries++; if (retries > 1000) { printf("gx hates you\n"); gfx_frame_abort(); return -1; } usleep(50); } gfx_draw_tex(&tex, &coords_bg); gfx_con_draw(); gfx_frame_end(); frame++; } printf("shutdown\n"); gfx_tex_deinit(&tex); gfx_con_deinit(); gfx_deinit(); gfx_video_deinit(); return 0; }
int main(int argc, char* argv[]) { // Setup video VIDEO_Init(); GXRModeObj* pref_vid_mode = VIDEO_GetPreferredMode(NULL); #if USING_AA pref_vid_mode = &TVNtsc480ProgAa; u32 half_height = pref_vid_mode->xfbHeight / 2; u32 bottom_offset = VIDEO_PadFramebufferWidth(pref_vid_mode->fbWidth) * (pref_vid_mode->efbHeight-3) * VI_DISPLAY_PIX_SZ; #endif VIDEO_Configure(pref_vid_mode); xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(pref_vid_mode)); xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(pref_vid_mode)); fbi = 0; VIDEO_SetNextFramebuffer(xfb[0]); // Console console_init(xfb[0],20,20,pref_vid_mode->fbWidth,pref_vid_mode->xfbHeight,pref_vid_mode->fbWidth*VI_DISPLAY_PIX_SZ); // Make display visible VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(pref_vid_mode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); printf("Console active\n"); // Setup GX void *gp_fifo = NULL; gp_fifo = memalign(32,DEFAULT_FIFO_SIZE); memset(gp_fifo,0,DEFAULT_FIFO_SIZE); GX_Init(gp_fifo, DEFAULT_FIFO_SIZE); GXColor background = {0x0,0x0,0x0,0xff}; GX_SetCopyClear(background, 0x00ffffff); f32 yscale; u32 xfbHeight; yscale = GX_GetYScaleFactor(pref_vid_mode->efbHeight,pref_vid_mode->xfbHeight); xfbHeight = GX_SetDispCopyYScale(yscale); GX_SetScissor(0,0,pref_vid_mode->fbWidth,pref_vid_mode->efbHeight); GX_SetDispCopySrc(0,0,pref_vid_mode->fbWidth,pref_vid_mode->efbHeight); GX_SetDispCopyDst(pref_vid_mode->fbWidth,xfbHeight); GX_SetCopyFilter(pref_vid_mode->aa,pref_vid_mode->sample_pattern,GX_TRUE,pref_vid_mode->vfilter); GX_SetFieldMode(pref_vid_mode->field_rendering,((pref_vid_mode->viHeight==2*pref_vid_mode->xfbHeight)?GX_ENABLE:GX_DISABLE)); if (pref_vid_mode->aa) { GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); GX_SetDispCopyYScale(1); GX_SetDither(GX_ENABLE); } else GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_SetDispCopyGamma(GX_GM_1_0); // Setup PSPL const pspl_platform_t* plat; pspl_runtime_init(&plat); const pspl_runtime_package_t* package = NULL; printf("PACKAGE OFF: %p SIZE: %u\n", (void*)&monkey_psplp, monkey_psplp_size); pspl_runtime_load_package_membuf((void*)&monkey_psplp, monkey_psplp_size, &package); pspl_runtime_enumerate_psplcs(package, enumerate_psplc_hook); printf("PSPL package read\n"); // Setup monkey rendering context monkey_ctx = pmdl_new_draw_context(); monkey_ctx->texcoord_mtx[1].m[0][0] = 0.5; monkey_ctx->texcoord_mtx[1].m[1][1] = -0.5; monkey_ctx->texcoord_mtx[1].m[0][3] = 0.5; monkey_ctx->texcoord_mtx[1].m[1][3] = 0.5; monkey_ctx->camera_view.pos.f[0] = 0; monkey_ctx->camera_view.pos.f[1] = 3; monkey_ctx->camera_view.pos.f[2] = 0; monkey_ctx->camera_view.look.f[0] = 0; monkey_ctx->camera_view.look.f[1] = 0; monkey_ctx->camera_view.look.f[2] = 0; monkey_ctx->camera_view.up.f[0] = 0; monkey_ctx->camera_view.up.f[1] = 0; monkey_ctx->camera_view.up.f[2] = 1; monkey_ctx->projection_type = PMDL_PERSPECTIVE; monkey_ctx->projection.perspective.fov = 55; monkey_ctx->projection.perspective.far = 5; monkey_ctx->projection.perspective.near = 1; monkey_ctx->projection.perspective.aspect = 1.777; monkey_ctx->projection.perspective.post_translate_x = 0; monkey_ctx->projection.perspective.post_translate_y = 0; pmdl_update_context(monkey_ctx, PMDL_INVALIDATE_ALL); // Load monkey const pspl_runtime_psplc_t* monkey_obj = pspl_runtime_get_psplc_from_key(package, "Monkey", 1); monkey_ctx->default_shader = monkey_obj; monkey_model = pmdl_lookup(monkey_obj, "monkey"); printf("Monkey loaded\n"); // Setup animation context haha_action_ctx = pmdl_action_init(pmdl_action_lookup(monkey_model, "haha")); haha_action_ctx->loop_flag = 1; rotate_action_ctx = pmdl_action_init(pmdl_action_lookup(monkey_model, "rotate")); rotate_action_ctx->loop_flag = 1; anim_ctx = pmdl_animation_initv(rotate_action_ctx, haha_action_ctx, NULL); printf("Animation Context Setup\n"); //init_time_profile(&profile); // Loop until reset button pressed SYS_SetResetCallback(reset_press_cb); double tex_off = 0; while (!reset_pressed) { //start_time_profile(&profile); // Update action contexts pmdl_action_advance(rotate_action_ctx, 0.1/60.0); pmdl_action_advance(haha_action_ctx, 1/60.0); pmdl_animation_evaluate(anim_ctx); tex_off += 0.005; //stop_time_profile(&profile); //report_time_profile(&profile); #if USING_AA GX_SetViewport(0, 0, pref_vid_mode->fbWidth, pref_vid_mode->xfbHeight, 0, 1); GX_SetScissor(0, 0, pref_vid_mode->fbWidth, half_height); GX_SetScissorBoxOffset(0, 0); #endif // Render top renderfunc(); // Copy to XFB GX_CopyDisp(xfb[fbi], GX_TRUE); #if USING_AA GX_SetViewport(0, 1, pref_vid_mode->fbWidth, pref_vid_mode->xfbHeight, 0, 1); GX_SetScissor(0, half_height, pref_vid_mode->fbWidth, half_height); GX_SetScissorBoxOffset(0, half_height); // Render bottom renderfunc(); // Copy to XFB GX_CopyDisp(xfb[fbi] + bottom_offset, GX_TRUE); #endif GX_DrawDone(); // Swap buffers VIDEO_SetNextFramebuffer(xfb[fbi]); fbi ^= 1; VIDEO_Flush(); ++cur_frame; VIDEO_WaitVSync(); } return 0; }