Jump to content



1

Consistent use of RTCLOK across NTSC and PAL.. how?


4 replies to this topic

#1 tschak909 OFFLINE  

tschak909

    Chopper Commander

  • 161 posts
  • Location:USA

Posted Sun Jun 25, 2006 10:14 PM

I am currently writing small snippets of code to test the vertical scrolling techniques of the game I am working on, but I have a question for all you guys with both NTSC and PAL machines.... RTCLOK works well as a consistent way of timing everything, however, it is tied to the VBLANK routines in the operating system, so my carefully timed delays will be different (my game will play slower on PAL machines versus NTSC machnes..) how can I compensate for this, so that my game will run consistently on both types of machines?

#2 Heaven/TQA OFFLINE  

Heaven/TQA

    Quadrunner

  • 8,111 posts
  • Location:Baden-Württemberg, Germany

Posted Sun Jun 25, 2006 11:34 PM

different delay sonstants based on machine. you can detect the machine or chipset which your game is running on...

#3 Rybags ONLINE  

Rybags

    Quadrunner

  • 10,323 posts
  • Location:Australia

Posted Mon Jun 26, 2006 11:23 AM

The problem with different constants is that you will get some degree of jerkiness in the motion.

But, to implement smooth transition in velocity, here's a technique I like to use.

Have a velocity byte for movement (scrolling, player left-right speed, whatever):

bit 7 = direction

bits 6-3 = fractional value. Maintain a seperate counter value which this number gets added to each frame. In the event that the counter goes negative (ie - bit 7 set), then add one to the velocity value for that frame only.

bits 2-0 = velocity value - value from 0 to 7 which gets added/subtracted from positional value each frame.

Having such a layout allows simple operations.
Firstly, AND out direction and velocity, then add to the counter.
Bit 7 of the counter will goto 1 if the counter overflows... so just PHP to save the overflow state. AND the new counter value with #$78 and store back in.
Next, get your velocity byte, branch to the relevant add or subtract code dependant on the N flag (bit 7)... then AND #7 to get the velocity value only, then PLP to get the overflow status from the counter.
Now if the N flag is set, you have to set (for add) or clear (for subtract) the carry. Then do your add/subtract from XPos, Scroll value, whatever.

#4 tschak909 OFFLINE  

tschak909

    Chopper Commander

  • 161 posts
  • Location:USA

Posted Mon Jun 26, 2006 11:56 AM

most interesting.. will have to chew on this one for a bit. :-)

-Thom

View PostRybags, on Mon Jun 26, 2006 12:23 PM, said:

The problem with different constants is that you will get some degree of jerkiness in the motion.

But, to implement smooth transition in velocity, here's a technique I like to use.

Have a velocity byte for movement (scrolling, player left-right speed, whatever):

bit 7 = direction

bits 6-3 = fractional value. Maintain a seperate counter value which this number gets added to each frame. In the event that the counter goes negative (ie - bit 7 set), then add one to the velocity value for that frame only.

bits 2-0 = velocity value - value from 0 to 7 which gets added/subtracted from positional value each frame.

Having such a layout allows simple operations.
Firstly, AND out direction and velocity, then add to the counter.
Bit 7 of the counter will goto 1 if the counter overflows... so just PHP to save the overflow state. AND the new counter value with #$78 and store back in.
Next, get your velocity byte, branch to the relevant add or subtract code dependant on the N flag (bit 7)... then AND #7 to get the velocity value only, then PLP to get the overflow status from the counter.
Now if the N flag is set, you have to set (for add) or clear (for subtract) the carry. Then do your add/subtract from XPos, Scroll value, whatever.


#5 Rybags ONLINE  

Rybags

    Quadrunner

  • 10,323 posts
  • Location:Australia

Posted Mon Jun 26, 2006 7:22 PM

Actually, you might be better off having the velocity in bits 6-4 and the fractional from 3-0.

That way, can you just increment/decrement the value for slight variations in speed.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users