Skip to content

Improve timing of main loop#1

Merged
nico-abram merged 1 commit into
nico-abram:masterfrom
ZehMatt:tickrate
Oct 13, 2019
Merged

Improve timing of main loop#1
nico-abram merged 1 commit into
nico-abram:masterfrom
ZehMatt:tickrate

Conversation

@ZehMatt

@ZehMatt ZehMatt commented Jun 21, 2019

Copy link
Copy Markdown
Contributor

It was pretty inconsistent before because the remainder was dropped and if the game can't keep up to due rendering performance it would also slow down the game. This ensures that the logic always runs at a fixed 59.94 hz which its supposed to be. Also I turned vsync off to show the actual FPS its capable of rendering.

2019-06-21_18-36-02

@nico-abram

Copy link
Copy Markdown
Owner

Hey!

First of all, thanks for the pull request. I've got to apologize for not seeing it until now (I've barely touched this project for a few months and I either missed it or didn't get an email about this PR).

I'm a bit confused by the purpose of rendering more than the NES tick rate. Would that be useful for anything? I can only think of properly redrawing in case of resizing/moving the window (And I'm not necessariy sure if that fixes it on all OSs or if it's actually a problem).

To be entirely honest, I wasn't really too worried with the FPS originally since I was mostly just curious how fast it could go :P

Turning off vsync seems like a good idea. (iirc on my system love2d's vsync doesnt work at all so I didn't even notice it!).

I've actually got some local changes for a few things I haven't pushed yet, and one of the things I touched was timing after reading https://web.archive.org/web/20190506122531/http://gafferongames.com/game-physics/fix-your-timestep/

I'll merge this anyways, mosty for credit and the vsync change. I'd be interested if you have any comments on the "rendering more often than the screen has changes" thing

@nico-abram
nico-abram merged commit e394d26 into nico-abram:master Oct 13, 2019
@ZehMatt

ZehMatt commented Oct 13, 2019

Copy link
Copy Markdown
Contributor Author

Oh hey no worries. The main goal behind the PR was to fix a bug when its unable to render at 59.9 hz the game would also slow down because the accumulated time was dropped, being able to render more than that is just a little gimmick.

I've been using the code to implement it into Garry's Mod and implemented lockstep for multiplayer. https://share.epic-domain.com/2019-06-29_18-23-19975b9f0bca56cbe9c.webm

@ZehMatt
ZehMatt deleted the tickrate branch October 13, 2019 11:05
@nico-abram

nico-abram commented Oct 13, 2019

Copy link
Copy Markdown
Owner

Woah!

That's amazing! Is your code available anywhere? If you feel like it, I'd totally accept a PR with a folder containing the necessary stuff to run that (I'm not familiar with gmod's APIs at all)

Also, if you run into issues or have things you'd like to see implemented feel free to open issues. I might not actually be able to fix them or find the time to work on this any time soon, but at least stuff would be there as a todo list, and maybe someone could actually give it a shot. Though I'm honestly mostly thinking about "X game doesnt run" scenarios related to missing mappers (Which might not be that hard/time consuming to do)

EDIT: Someone I know just pointed me to https://wiki.garrysmod.com/page/sound/Generate which might help with outputting sound. Not sure how it'd fare performance wise

@ZehMatt

ZehMatt commented Oct 18, 2019

Copy link
Copy Markdown
Contributor Author

Hey thanks, the code is not available atm, rendering the output on Garry's Mod turned out to be somewhat difficult, doing this pixel by pixel is pretty bad so I had to come up with a clever way of batching them into rectangles of the same color. I also still have issues trying to serialize the state so I could just send that across the network, my implementation is currently naive and requires the players to be already around so they can all load up the ROM at the same time. I will try to commit the Garry's Mod changes the next couple days onto a new branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants