I made a small proof of concept routine that lets you make an HP Prime program run at the same speed on both the emulator and real calculator. It is not perfect and could use major code improvements, but it was more to show that it's possible and it somewhat gets the job done, even if not 100% accurate:
EXPORT spdThrt()
BEGIN
DIMGROB_P(G1,80,60);
WHILE 1 DO
T:=TICKS();
RECT_P(G1,#FFFFFF);
FOR A FROM 0 TO 3 DO
FOR B FROM 0 TO 3 DO
PIXON_P(G1,A,B,RGB(RANDOM*255,RANDOM*255,RANDOM*255));
END;
END;
U:=TICKS();
WAIT(.01666-(U-T)/1000);
V:=TICKS();
TEXTOUT_P(U-T,G1,12,30);
TEXTOUT_P(V-T,G1,12,40);
BLIT_P(G0,0,0,320,240,G1,0,0,80,60);
END;
END;
(http://img.codewalr.us/hpprimesamespeed.jpg)
While the speed is still slightly different, at least it would allow games to be playable on the emulator. I might just not have gotten the numbers right. The other alternative is to use WAIT(.016) or something that matches the on-calc frame rate, but then the game will lose speed on the calc)
@alexgt might find this handy for his games.
Oh,thats good. But wouldn't it just be simple to make to versions?
It depends. If the slowdown code is used as subroutine then you can simply replace the routine I guess. But ideally it's best to not have 2 versions to update each time people reports bugs.
Oh, yeah. Or you could ask what the player was running on, and then change a variable in wait( according to the answer.
That can be an idea too actually. I could simply detect which platform the game runs on on launch by running some code then check how long it took to run, then if it took longer then it means you are either using the calculator or a very old computer. Then the delay in-game is set accordingly at the same value everywhere.
Cool, In MinePrime the only thing that makes it not playable on PC is movement since the delay on calc for displaying GROBS is much greater (It displays the same GROB 16 times to achive the smooth scrolling)
But this is helpful in games like Nagoji 4x3. But what would really be nice it to have a command that will tell you if you are on calc or on emu
I would probably suggest using delta values. It's practically what DJ_ O is doing except instead of a wait() function you have the player move less/more depending on performance. That's how all new games are made to run at the same speeds across platforms. Basicly you have to measure how long one game loop takes, and store it. If the measurement of how long one game loop takes is in nano seconds, It is recommended that you divide that number by a million, or if you are measuring in milliseconds, a thousand ect. Bassicly you don't want your delta value to be big. From now on, you pass that value to all your movement functions. If a player is supposed to move x+playerSpeed->x, then have him move x+playerSpeed*delta->x. You will have to adjust the playerSpeed a bit though.this way if the loop takes longer, delta is bigger and the player/entity moves a bit further then usual. Or vice versa, if this game is running on an op computer, delta will be very small and the player movement will be smother.
That would definitively be an idea. Another idea for HP Prime slowdowns could be frame skipping, although right now the issue is more about games running too fast in the emulator. I'll have to read documentation about how delta values work.
Hmmm that sounds like it could work to. Alex, you could implement a command like this into your lib that you are making.
That would be a nice idea actually. It would be nice to have the perfect speed throttling command as standalone as well, though, for people who don't want to make their games dependent on another lib.
It would have to be very customizeable which is not a big problem.
What kind of customizing ideas did you havein mind? The main goal is to have games run at identical speeds on both hardware and emulator, without requiring the user to change any setting, file or outright download a different file. Basically, no config required (although having the ability to change settings would definitively be a plus)
the one I was thinking was have a base setting that the user would specify that would run the loop at the same time again and again.
Do you mean have him set it to run every 2 frame, every 3 frame, etc? Or just change the speed?
change the speed as it would depend on the games coding of when it would display frames
Ah right, so it would wait at frame display? I guess that works.
But the question is what is the exact math formula and variable setup to use to generate the perfect delay?
Quote from: DJ Omnimaga on September 02, 2015, 05:17:42 AM
But the question is what is the exact math formula and variable setup to use to generate the perfect delay?
That is a good question :P