Author Topic: SECONDBASIC - How to implement delta time?  (Read 722 times)

Offline poundlander

  • Developer
  • Jr. Member
  • *****
  • Posts: 74
  • Country: ca
  • Karma: 4
    • View Profile
SECONDBASIC - How to implement delta time?
« on: January 20, 2020, 20:56:59 PM »
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
Downloadable Atari 2600 games such as Upp Plus Plus, Nitebear on Sleepystreet, Stranglehand and more!

Offline dra600n

  • Moderator
  • Full Member
  • *****
  • Posts: 122
  • Country: 00
  • Karma: 3
    • View Profile
Re: SECONDBASIC - How to implement delta time?
« Reply #1 on: January 21, 2020, 20:29:21 PM »
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:

Code: [Select]

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

If TvType() = 0 Then
ClockSpeed = 60
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


If Timer = ClockSpeed Then
Timer = 0
If seconds = 60 Then
seconds = 0
If minutes = 60 Then
minutes = 0
End If
End If
End If

Hope this helps


SMF spam blocked by CleanTalk
SimplePortal 2.3.7 © 2008-2021, SimplePortal