SECONDBASIC - How to implement delta time?

Started by poundlander, January 20, 2020, 20:56:59 PM

Previous topic - Next topic

poundlander

Hey!  I make games that need to run consistently on original, clone and emulation based systems.

Is there a way to calculate an appropriate player speed that looks about the same regardless of genesis variant?

I've tried fumbling with counters during the main loop and vblank but never got results.
Please check out my party favors at https://theloon.itch.io/
Downloadable Atari 2600 games such as Upp Plus Plus, Nitebear on Sleepystreet, Stranglehand and more!

dra600n

So the thing with keeping the exact same time across all machines, and regions, and being 100% the exact same speed just isn't possible (I don't think anyway) on the console without ancillary hardware inside of the cartridge (such as a clock). This is because you'd have to rely on everything to utilize the same code/hardware/standard, which there's no standard to keep things uniform.

That being said, you can get close by keeping a counter ticking during vblank. Here's some skeleton code of how to set that up:



Dim ClockSpeed As Integer
Dim Timer As Integer
Dim hours As Integer, minutes As Integer, seconds As Integer




If TvType() = 0 Then
ClockSpeed = 60
Else
ClockSpeed = 50
End If

On VBlank GoSub vblank_routine
Enable InterruptVBlank

While 1 'infinite loop
Locate 0,1: Print "Clockspeed: "; ClockSpeed
Locate 1,1: Print "Timer: "; timer; "                "
Locate 2,1: Print "Seconds: "; seconds; "    "
Locate 3,1: Print "Minutes: "; minutes; "    "
Locate 4,1: Print "Hours: "; hours


Wend




vblank_routine:
Timer++
If Timer = ClockSpeed Then
Timer = 0
seconds++
If seconds = 60 Then
seconds = 0
minutes++
If minutes = 60 Then
hours++
minutes = 0
End If
End If
End If
Return


Hope this helps