c:\Python-2.5.2\PCbuild8\win32release\python TestPyNES.py Let's persuade NESTopia to run quests. First, we compile NESTopia. I can't get a debug build to go, due to an avalanche of errors of this form: cannot update program database 'c:\necro\pynes\projects\debug\win32\vc90.pdb' However, the release build goes right through after I update my environemnt to include DirectX directories (currently stored at c:\dxtemp\include, c:\dxtemp\libraries). Workaround for the program database errors: I had this very same problem. You could try to disable "Enable Minimal Rebuild" (/Gm) that is found under "C/C++"->"Code Generation" tab in project properties. The workaround I found also needed the "Debug Information Format" to be changed to C7 Compatible (/Z7) under "C/C++"->"General". A paper-thin PyNES Python wrapper was easily added. Now we need to work out how to launch a game from Python. NesTopia uses a huge number of classes and namespaces, most of which have no comments. This is marginally preferable to the uncommented global variables and C-flavored hacks of FCEU, but still not easy to work with. NstMain.cpp defines WinMain: - Instantiates Nestopia.Application.Main(cmdShow) - Calls Application.Main.Run() - This calls window.Run() then emulator.Unload() NstApplicationMain.cpp defines Application::Main, the GOD CLASS with references to many other things including Managers::Emulator and Window::Main and Managers::Machine and so forth. Triggering Manger::Files::Open from NSTManagerFiles is what we need to do. It takes a wcstring (const wchar_t*) and a uint (unisgned int), a set of flags. It's usually invoked via OnMsgLaunch. Note that the constructor looks like "Files::Files". ---------------------------------------------------------------------------------- 5/3/8 We can launch games and savegames. Now we need to apply quest conditions. Cheats::BeginFrame looks like it does what we want. NES_PEEK defines a reader cpu.GetRam()[address] How do we get at the cpu? We have ApplicationMain. It has pointers to many other things...including machine. Annoyance: Rightclicking Managers::Machine puts VS2008 into an infinite loop! The workaround: Use code-grep to navigate to object definitions, not right-click->Goto. Aha! NstMachine.cpp, Machine::Execute calls BeginFrame Displaying success/falure: direct2d.DrawMsg(text); Quest timer: Borrow from the FPS display code. OnScreenText() Direct2D::RenderScreen -> Direct2D::Device::RenderScreen -> Device::Fonts::Render NstDirect2D.cpp IDirect3D9& com; Create the fps and msg objects: void Direct2D::Device::Fonts::Create(const Device& device) { nfo.Create(device); if (1) //if (!device.presentation.Windowed) { fps.Create(device); msg.Create(device); } width = nfo.Width(); } Fixing font size: Call fonts.Create() when resizing NstWindowMain() is where menu can be disabled. Restarting quest: Put a new item in NstApiMachine.hpp just after EVENT_MODE_PAL Time limit display: typedef String::Generic GenericString; Poking: - Set a breakpoint at NstMachine.cpp line 456, in Machine::Execute - Set a watch on NESCPU->ram.mem[0x35] - Edit the value! ------------------------------------------- Crash when using PyNES with standard Python. - Building through Visual Studio 2008: Error happens between AppMain() and Menu() in this logging: AppMain() ::Menu() ::Preferences() ::Menu() - Crash when using PyNES built with DistUtils version of Python (PyNES.DistUtils): Dialog "An application has made an attempt to load the C runtime library incorrectly" ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed. When we run the manifest generation tool, the error becomes the same as the one generated by building through Visual Studio. --> Error was (a) side-by-side configuration from manifest, fixed by mt command, and (b) missing english.nlg ------------------------------------------ DirectX dll issue: dinput8.dll 181760bytes ok for vista ok for XP dinput8.dll 159232bytes ok for vista NOT OK FOR XP!