Comments (9)
Sure thing--Discord's krs013#8895 and my email is in the commit logs.
from pyboy.
Frame limiter is only partially fixed. It only works correctly, when the host monitor refreshes at 60hz.
from pyboy.
So it seems to me like this would be the next issue to resolve. I've looked through the code a bit and it seems like PyBoy/MB/Coordinator.py
and PyBoy/__init__.py
are where the relevant code will be; is that right? Do you have a vision for how this could/should be implemented?
The SDL_Renderer
s in GameWindow_SDL2.py
and GameWindow_Scanline.py
do have an optional PRESENTVSYNC flag that I didn't add just yet, but I've tested it before and it doesn't seem to automatically force a 60 Hz refresh rate--I think it just ensures that the present step occurs during the monitor's Vsync period to prevent tearing. If multiple frames are presented faster than 60 Hz, I suppose it would just skip as many as needed. As far as I can tell, we will have to do it manually, at least to within some tolerance.
I did see there was some code that waits on a HALT instruction until an interrupt occurs. Something like that might work, if the VBLANK interrupt is triggered on a timer, perhaps? However, I've also been looking at the documentation for the gameboy's sound, and it will require faster updates than the screen (512 Hz), so something that just pauses the program until it's time to render a frame probably won't do, unless sound is managed in a separate thread or something. If we were in Python3, I'd say this is a job for coroutines and asyncio
, but that functionality is very different or doesn't exist at all in Python2.
Anyway, if you have any thoughts on this, I'd be happy to hear them, or I can start experimenting and see if I find something that works. Once the frame limiter works, perhaps we could take a shot at sound, and then this will be a fully functional emulator!
from pyboy.
Around line 80 of Coordinator.py
, right after rendering the screen, seems like the right place to do it.
The simple solution is to add a type of waiting statement, so we won't progress faster than 60Hz on average. This problem I ran into, was that the timing of time.sleep
is not precise enough, and VSync is unreliable, as framerates are not always 60Hz anymore. A method of VSync could work, if we can drop frames, and duplicate frames — i.e. don't force an update, if we are behind, and repeat a frame, if we are too early.
Regular VSync will not skip frames. It will simply wait until the new frame is out, before continuing. In games, you will often see the GPU utilization drop, with VSync, as it spends more time waiting.
Depending on how the sound library works, we might be forced to run it in a separate thread anyway.
I like you enthusiasm! :D I would say, just go nuts and see what you find. From what I have seen, I trust your judgement. You can push any changes to a pull request, if you want feedback. Just remember, that there are monitors with more than 60Hz, and it's preferable not to spinlock too much, to synchronize. Maybe you'll find, that the sound library could help with synchronization?
from pyboy.
I'm sorry, if you had something in the works. I was working on some Cython stuff, and found the exact SDL functions we needed. I can confirm, that it works on a 144Hz monitor, and it doesn't eat CPU cycles.
from pyboy.
If you have a better implementation, it is still welcome.
from pyboy.
Nope, I hadn’t started anything yet; that’s why I asked! I look forward to seeing what you’ve got.
And briefly, about syncing to sound, I think I did see that an emulator called mGBA could be configured to sync to either the video or the sound. On my friend’s laptop, video syncing was slightly sped up (possibly 75 Hz display) but sound was much more stable.
from pyboy.
Didn’t get to look too much but I did try it out and it looks great! I may poke a bit more to see if there are possible improvements but as far as I can tell it’s already a solid solution to this issue. So that’s awesome! (Also, congrats on the thesis! Mine is killing me so I’m quite envious.)
from pyboy.
Please do, but unless I've made a mistake, I also doubt it can be made much different.
Thanks! Just handed in today. I would like to hear what your's is about. Can I find you on Twitter/Discord/email, so we don't fill up the GitHub issues?
from pyboy.
Related Issues (20)
- Japanese Pokemon Crystal: Doesn't start, locks at blank screen HOT 1
- Pokemon Gold: Upon entering battle, window layer flickers in for one frame HOT 2
- Pokemon Pinball: In CGB, it uses the wrong palette colors on the menu screen HOT 1
- Freestyle Scooter: Doesn't start
- Wrong args description in set_world_level function for Super Mario Land wrapper HOT 1
- Add easy way to add plugins (game wrappers) to Plugin Manager HOT 11
- requirements.txt installs Cython only on CPython, but setup.py tries to use it on anything that is not PyPy HOT 4
- Docs reference deleted files HOT 2
- Savestates not loading with CGB games HOT 3
- Pokemon Red not registering button presses HOT 1
- Error when trying to run with color palette HOT 7
- Pyboy screenshotting function? HOT 2
- Change keybindings HOT 3
- Update build system for Python 3.12
- Street Fighter II screen keeps blinking
- Only show frame-limiting warning when calling set_emulation_speed
- Kirby's Dream Land: Plugin bug HOT 2
- [Enhancement] Expose BG/Obj0/Obj1 Palletes
- Benchmark PyBoy against other emulators
- Create Gameshark plugin [Recommended first issue]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyboy.