//////////////////////////////////////////////////////////////////////////////////////// // // Nestopia - NES/Famicom emulator written in C++ // // Copyright (C) 2003-2008 Martin Freij // // This file is part of Nestopia. // // Nestopia is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // Nestopia is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Nestopia; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // //////////////////////////////////////////////////////////////////////////////////////// #include "NstManagerPaths.hpp" #include "NstResourceString.hpp" #include "NstWindowParam.hpp" #include "NstWindowUser.hpp" #include "NstDialogVideo.hpp" #include "NstManagerVideo.hpp" #include "NstIoScreen.hpp" namespace Nestopia { namespace Managers { #ifdef NST_MSVC_OPTIMIZE #pragma optimize("t", on) #endif struct Video::Callbacks { static bool NST_CALLBACK ScreenLock(Nes::Video::UserData data,Nes::Video::Output& output) { NST_ASSERT( data ); return static_cast(data)->LockScreen( output.pixels, output.pitch ); } static void NST_CALLBACK ScreenUnlock(Nes::Video::UserData data,Nes::Video::Output&) { NST_ASSERT( data ); static_cast(data)->UnlockScreen(); static_cast(data)->RenderScreen( DirectX::Direct2D::RENDER_PICTURE|DirectX::Direct2D::RENDER_FPS|DirectX::Direct2D::RENDER_MSG ); } }; #ifdef NST_MSVC_OPTIMIZE #pragma optimize("", on) #endif inline Video::Fps::Fps() : frame(0) {} inline Video::Nsf::Nsf() : songTextOffset(0) {} void Video::Nsf::Load(const Nes::Nsf emulator) { struct Info { static cstring GoodName(cstring text) { if ( text && *text && std::strcmp( text, "" ) && std::strcmp( text, "< ? >" ) && std::strcmp( text, "?" ) ) return text; return NULL; } static cstring GetMode(Nes::Nsf::TuneMode mode) { return ( mode == Nes::Nsf::TUNE_MODE_PAL ? " (PAL)" : mode == Nes::Nsf::TUNE_MODE_NTSC ? " (NTSC)" : " (NTSC/PAL)" ); } }; text.Clear(); if (cstring name = Info::GoodName( emulator.GetName() )) text.Import( name ); else text = "noname"; text << Info::GetMode( emulator.GetMode() ); cstring const artist = Info::GoodName( emulator.GetArtist() ); cstring const copyright = Info::GoodName( emulator.GetCopyright() ); if (artist) (text << "\r\n").Import( artist ); if (copyright) (text << "\r\n").Import( copyright ); if (const uint chips = emulator.GetChips()) { text << (copyright || artist ? ", " : "\r\n"); if ( chips & Nes::Nsf::CHIP_MMC5 ) text << "MMC5 "; if ( chips & Nes::Nsf::CHIP_FDS ) text << "FDS "; if ( chips & Nes::Nsf::CHIP_VRC6 ) text << "VRC6 "; if ( chips & Nes::Nsf::CHIP_VRC7 ) text << "VRC7 "; if ( chips & Nes::Nsf::CHIP_N163 ) text << "N163 "; if ( chips & Nes::Nsf::CHIP_S5B ) text << "Sunsoft5B "; text << ((chips & (chips-1)) ? "chips" : "chip"); } text << "\r\nSong: "; songTextOffset = text.Length(); Update( emulator ); } void Video::Nsf::Update(const Nes::Nsf emulator) { text.ShrinkTo( songTextOffset ); text << (emulator.GetCurrentSong() + 1) << '/' << emulator.GetNumSongs(); } Video::Video ( Window::Custom& w, Window::Menu& m, Emulator& e, const Paths& p, const Configuration& cfg ) : Manager ( e, m, this, &Video::OnEmuEvent, &Video::OnAppEvent ), window ( w ), statusBar ( w, STATUSBAR_WIDTH ), direct2d ( w ), dialog ( new Window::Video( e, direct2d.GetAdapters(), p, cfg ) ), sizingMoving ( false ), paths ( p ), childWindowSwitchCount ( Application::Instance::NumChildWindows() + 1 ) { static const Window::MsgHandler::Entry