void menu_loop(void) { g_console.menu_enable = true; HRESULT hr; xdk360_video_t *vid = (xdk360_video_t*)g_d3d; if(g_console.emulator_initialized) video_xdk360.set_swap_block_state(NULL, true); do { g_frame_count++; if(g_console.emulator_initialized) { rarch_render_cached_frame(); } else vid->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(255, 32, 32, 64), 1.0f, 0); XINPUT_STATE state; XInputGetState(0, &state); g_console.menu_enable = !((state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) && (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) && (g_console.emulator_initialized) && IS_TIMER_EXPIRED()); g_console.mode_switch = g_console.menu_enable ? MODE_MENU : MODE_EMULATION; app.RunFrame(); /* Update XUI */ hr = app.Render(); /* Render XUI */ hr = XuiTimersRun(); /* Update XUI timers */ if(g_console.mode_switch == MODE_EMULATION && !g_console.frame_advance_enable) { SET_TIMER_EXPIRATION(30); } video_xdk360.swap(NULL); }while(g_console.menu_enable); if(g_console.emulator_initialized) video_xdk360.set_swap_block_state(NULL, false); g_console.ingame_menu_enable = false; }
static bool xdk_d3d_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data; #ifdef HAVE_FBO D3DSurface* pRenderTarget0; #endif bool fps_enable = g_extern.console.rmenu.state.msg_fps.enable; #ifdef _XBOX1 unsigned flicker_filter = g_extern.console.screen.state.flicker_filter.value; bool soft_filter_enable = g_extern.console.screen.state.soft_filter.enable; #endif if (d3d->last_width != width || d3d->last_height != height) { D3DLOCKED_RECT d3dlr; d3d->lpTexture->LockRect(0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK); memset(d3dlr.pBits, 0, d3d->tex_w * d3dlr.Pitch); d3d->lpTexture->UnlockRect(0); #if defined(_XBOX1) float tex_w = width; // / 512.0f; float tex_h = height; // / 512.0f; DrawVerticeFormats verts[] = { { -1.0f, -1.0f, 1.0f, 0.0f, tex_h }, { 1.0f, -1.0f, 1.0f, tex_w, tex_h }, { -1.0f, 1.0f, 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f, 1.0f, tex_w, 0.0f }, }; #elif defined(_XBOX360) float tex_w = width / ((float)d3d->tex_w); float tex_h = height / ((float)d3d->tex_h); DrawVerticeFormats verts[] = { { -1.0f, -1.0f, 0.0f, tex_h }, { 1.0f, -1.0f, tex_w, tex_h }, { -1.0f, 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f, tex_w, 0.0f }, }; #endif // Align texels and vertices (D3D9 quirk). for (unsigned i = 0; i < 4; i++) { verts[i].x -= 0.5f / ((float)d3d->tex_w); verts[i].y += 0.5f / ((float)d3d->tex_h); } #if defined(_XBOX1) BYTE *verts_ptr; #elif defined(_XBOX360) void *verts_ptr; #endif d3d->vertex_buf->Lock(0, 0, &verts_ptr, 0); memcpy(verts_ptr, verts, sizeof(verts)); d3d->vertex_buf->Unlock(); d3d->last_width = width; d3d->last_height = height; } #ifdef HAVE_FBO if (d3d->fbo_inited) { d3d->d3d_render_device->GetRenderTarget(0, &pRenderTarget0); d3d->d3d_render_device->SetRenderTarget(0, d3d->lpSurface); } #endif if (d3d->should_resize) xdk_d3d_set_viewport(false); d3d->d3d_render_device->SetTexture(0, d3d->lpTexture); #ifdef HAVE_HLSL hlsl_use(1); #endif #ifdef HAVE_FBO if(d3d->fbo_inited) { #ifdef HAVE_HLSL hlsl_set_params(width, height, d3d->tex_w, d3d->tex_h, g_settings.video.fbo.scale_x * width, g_settings.video.fbo.scale_y * height, g_extern.frame_count); #endif D3DVIEWPORT vp = {0}; vp.Width = g_settings.video.fbo.scale_x * width; vp.Height = g_settings.video.fbo.scale_y * height; vp.X = 0; vp.Y = 0; vp.MinZ = 0.0f; vp.MaxZ = 1.0f; d3d->d3d_render_device->SetViewport(&vp); } else #endif { #ifdef HAVE_HLSL hlsl_set_params(width, height, d3d->tex_w, d3d->tex_h, d3d->win_width, d3d->win_height, g_extern.frame_count); #endif } if(frame) { D3DLOCKED_RECT d3dlr; d3d->lpTexture->LockRect(0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK); for (unsigned y = 0; y < height; y++) { const uint8_t *in = (const uint8_t*)frame + y * pitch; uint8_t *out = (uint8_t*)d3dlr.pBits + y * d3dlr.Pitch; memcpy(out, in, width * d3d->base_size); } d3d->lpTexture->UnlockRect(0); } d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MINFILTER, g_settings.video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MAGFILTER, g_settings.video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER); #if defined(_XBOX1) d3d->d3d_render_device->SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1); d3d->d3d_render_device->SetStreamSource(0, d3d->vertex_buf, sizeof(DrawVerticeFormats)); d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0); d3d->d3d_render_device->BeginScene(); d3d->d3d_render_device->SetFlickerFilter(flicker_filter); d3d->d3d_render_device->SetSoftDisplayFilter(soft_filter_enable); d3d->d3d_render_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); d3d->d3d_render_device->EndScene(); #elif defined(_XBOX360) d3d->d3d_render_device->SetVertexDeclaration(d3d->v_decl); d3d->d3d_render_device->SetStreamSource(0, d3d->vertex_buf, 0, sizeof(DrawVerticeFormats)); d3d->d3d_render_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); #endif #ifdef HAVE_FBO if(d3d->fbo_inited) { d3d->d3d_render_device->Resolve(D3DRESOLVE_RENDERTARGET0, NULL, d3d->lpTexture_ot, NULL, 0, 0, NULL, 0, 0, NULL); d3d->d3d_render_device->SetRenderTarget(0, pRenderTarget0); pRenderTarget0->Release(); d3d->d3d_render_device->SetTexture(0, &d3d->lpTexture_ot_as16srgb); #ifdef HAVE_HLSL hlsl_use(2); hlsl_set_params(g_settings.video.fbo.scale_x * width, g_settings.video.fbo.scale_y * height, g_settings.video.fbo.scale_x * d3d->tex_w, g_settings.video.fbo.scale_y * d3d->tex_h, d3d->win_width, d3d->win_height, g_extern.frame_count); #endif xdk_d3d_set_viewport(false); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MINFILTER, g_settings.video.second_pass_smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MAGFILTER, g_settings.video.second_pass_smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER); d3d->d3d_render_device->SetVertexDeclaration(d3d->v_decl); d3d->d3d_render_device->SetStreamSource(0, d3d->vertex_buf, 0, sizeof(DrawVerticeFormats)); d3d->d3d_render_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); } #endif #if defined(_XBOX1) float mem_width = font_x + 30; float mem_height = font_y + 50; float msg_width = 60; float msg_height = 365; #elif defined(_XBOX360) float mem_width = g_extern.console.rmenu.state.rmenu_hd.enable ? 160 : 100; float mem_height = 70; float msg_width = mem_width; float msg_height = mem_height + 50; #endif if(fps_enable) { MEMORYSTATUS stat; GlobalMemoryStatus(&stat); char fps_txt[128]; char buf[128]; snprintf(buf, sizeof(buf), "%.2f MB free / %.2f MB total", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f)); if (d3d->font_ctx) d3d->font_ctx->render_msg_place(d3d, mem_width, mem_height, 0, 0, buf); gfx_get_fps(fps_txt, sizeof(fps_txt), true); if (d3d->font_ctx) d3d->font_ctx->render_msg_place(d3d, mem_width, mem_height + 30, 0, 0, fps_txt); } if (msg) d3d->font_ctx->render_msg_place(d3d, msg_width, msg_height, 0.0f, 0, msg); #ifdef _XBOX360 if(g_extern.draw_menu) { app.Render(); XuiTimersRun(); } else #endif gfx_ctx_xdk_swap_buffers(); return true; }
void menu_loop(void) { HRESULT hr; xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; g_extern.console.rmenu.state.rmenu.enable = true; d3d->block_swap = true; g_extern.console.rmenu.input_loop = INPUT_LOOP_MENU; do { if(g_extern.console.emulator_initialized) rarch_render_cached_frame(); else { d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0); d3d->frame_count++; } XINPUT_STATE state; XInputGetState(0, &state); g_extern.console.rmenu.state.rmenu.enable = !((state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) && (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) && (g_extern.console.emulator_initialized) && IS_TIMER_EXPIRED(d3d)); g_extern.console.rmenu.mode = g_extern.console.rmenu.state.rmenu.enable ? MODE_MENU : MODE_EMULATION; switch(g_extern.console.rmenu.input_loop) { case INPUT_LOOP_FILEBROWSER: /* if(((state.Gamepad.wButtons & XINPUT_GAMEPAD_Y) && hCur != app.hMainScene)) { uint64_t action = (1 << RMENU_DEVICE_NAV_A); browser_update(browser, action, rarch_console_get_rom_ext()); SET_TIMER_EXPIRATION(d3d, 15); } */ case INPUT_LOOP_MENU: app.RunFrame(); /* Update XUI */ if((state.Gamepad.wButtons & XINPUT_GAMEPAD_B) && hCur != app.hMainScene) XuiSceneNavigateBack(hCur, app.hMainScene, XUSER_INDEX_ANY); break; case INPUT_LOOP_RESIZE_MODE: ingame_menu_resize(); break; default: break; } hr = app.Render(); /* Render XUI */ hr = XuiTimersRun(); /* Update XUI timers */ if(g_extern.console.rmenu.mode == MODE_EMULATION && !g_extern.console.screen.state.frame_advance.enable) { SET_TIMER_EXPIRATION(d3d, 30); } const char *message = msg_queue_pull(g_extern.msg_queue); if (message) { xdk360_console_format(message); xdk360_console_draw(); } context->swap_buffers(); }while(g_extern.console.rmenu.state.rmenu.enable); d3d->block_swap = false; g_extern.console.rmenu.state.ingame_menu.enable = false; }
void menu_loop(void) { HRESULT hr; xdk360_video_t *d3d9 = (xdk360_video_t*)driver.video_data; g_console.menu_enable = true; d3d9->block_swap = true; g_console.input_loop = INPUT_LOOP_MENU; do { if(g_console.emulator_initialized) { rarch_render_cached_frame(); } else { d3d9->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0); d3d9->frame_count++; } XINPUT_STATE state; XInputGetState(0, &state); g_console.menu_enable = !((state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) && (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) && (g_console.emulator_initialized) && IS_TIMER_EXPIRED(d3d9)); g_console.mode_switch = g_console.menu_enable ? MODE_MENU : MODE_EMULATION; switch(g_console.input_loop) { case INPUT_LOOP_MENU: app.RunFrame(); /* Update XUI */ if(state.Gamepad.wButtons & XINPUT_GAMEPAD_B && hCur != app.hMainScene) XuiSceneNavigateBack(hCur, app.hMainScene, XUSER_INDEX_ANY); break; case INPUT_LOOP_RESIZE_MODE: ingame_menu_resize(); break; default: break; } hr = app.Render(); /* Render XUI */ hr = XuiTimersRun(); /* Update XUI timers */ if(g_console.mode_switch == MODE_EMULATION && !g_console.frame_advance_enable) { SET_TIMER_EXPIRATION(d3d9, 30); } const char *message = msg_queue_pull(g_extern.msg_queue); if (message) { if(IS_TIMER_EXPIRED(d3d9)) { xdk360_console_format(message); SET_TIMER_EXPIRATION(d3d9, 30); } xdk360_console_draw(); } gfx_ctx_swap_buffers(); }while(g_console.menu_enable); d3d9->block_swap = false; g_console.ingame_menu_enable = false; }