Outrun with frame counter

All about ST/STE games

Moderators: simonsunnyboy, Mug UK, Doctor Bob Gordon, ICS, Moderator Team

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Fri Apr 26, 2019 9:10 pm

swapd0 wrote:I print the fps at the end of the rendering loop.


thanks :)
so it like a endless list when it reach 50, it just start over, and every time you print the fps, you just do it as the list look now?
but you don't reset the list every sec?
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

swapd0
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 102
Joined: Thu Dec 13, 2007 8:56 pm

Re: Outrun with frame counter

Postby swapd0 » Fri Apr 26, 2019 9:35 pm

Yes, it's a circular buffer of 50 elements, the fps it's a count of how many items in the list are set to one, I never reset the list but on each vbl I reset the current frame.

It's something like this, in crap pseudocode

Code: Select all

char fps[50];
int vbl_frame;

void vbl()
{
    ....
   fps[vbl_frame++] = 0;
   if (vbl_frame == 50)
       vbl_frame = 0;
}

void print_fps()
{
    int cnt = 0;
    for ( value : fps )
       cnt += value;

   print("fps = %d", cnt);
}

main()
{
   while (1)
   {
   // render loop
   ...
       fps[vbl_frame] = 1;
   print_fps();
   }
}
   

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Fri Apr 26, 2019 9:39 pm

thanks
i think that i got it.
if i use bytes i can just add them all together :)
i have to try this tomorrow :D

thx again
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Sat Apr 27, 2019 9:15 am

ok just a quick update
the waiting for vsync was stupid made, like in enduro racer
it always waited for vsync more when it had to to be sure that they did not get any flickering.
i have been looking a little on that routine, and I have replaces it, with a new one (only in the game loop for now)

and it did help with the game its now hitting 25fps (very seldom) in some parts of the game, and i still have a long way to go with the optimizations,
probably the biggest is still replace the old print object with a blitter routine :D

Outrun 25fps.png
You do not have the required permissions to view the files attached to this post.
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

mikro
Hardware Guru
Hardware Guru
Posts: 2034
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: Outrun with frame counter

Postby mikro » Sat Apr 27, 2019 9:41 am

swapd0 wrote:I did a frame counter many years ago like this way:
- you have an array of "booleans" with 50 elements all set to false
- on each vbl you increment the index into the array and clear his value
- each time you finish a frame mark the array[index] as true
- count how many true values you have into the array and that's the fps.

What advantage does it offer against simply printing the index value and not using any array at all?

User avatar
dma
Atari Super Hero
Atari Super Hero
Posts: 996
Joined: Wed Nov 20, 2002 11:22 pm
Location: France
Contact:

Re: Outrun with frame counter

Postby dma » Sat Apr 27, 2019 10:21 am

Really interesting work on this Peter. :)

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Sat Apr 27, 2019 11:08 am

Many thanks dma :D
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Sat Apr 27, 2019 11:17 am

swapd0 wrote:I did a frame counter many years ago like this way:
- you have an array of "booleans" with 50 elements all set to false
- on each vbl you increment the index into the array and clear his value
- each time you finish a frame mark the array[index] as true
- count how many true values you have into the array and that's the fps.


ok now i have done it, and i got a much smoother FPS counter, but also much lower :D
it have removed all the dips and heights, don't know if that is better :)

many thanks for the help :D
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Sat Apr 27, 2019 11:23 am

mikro wrote:
swapd0 wrote:I did a frame counter many years ago like this way:
- you have an array of "booleans" with 50 elements all set to false
- on each vbl you increment the index into the array and clear his value
- each time you finish a frame mark the array[index] as true
- count how many true values you have into the array and that's the fps.

What advantage does it offer against simply printing the index value and not using any array at all?


it gives you and average fps over a sec, so it remove the high peek and low dips.
The disadvantage is, it's impossible to see the lowest and highest frame at a given frame..
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Sat Apr 27, 2019 1:07 pm

I have just uploaded a new video the show the new frame counter.



Edit reloaded the video

Last edited by FedePede04 on Sat Apr 27, 2019 3:54 pm, edited 1 time in total.
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

junosix
Captain Atari
Captain Atari
Posts: 288
Joined: Sun Jul 08, 2007 3:22 pm
Location: Plymouth

Re: Outrun with frame counter

Postby junosix » Sat Apr 27, 2019 1:15 pm

Superb work, keep it going dude.

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Sat Apr 27, 2019 1:16 pm

Many Thanks :cheers:
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

swapd0
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 102
Joined: Thu Dec 13, 2007 8:56 pm

Re: Outrun with frame counter

Postby swapd0 » Sat Apr 27, 2019 2:01 pm

Thanks for the credits :cheers:

By the way it's "swap d0", llike the opcode, but you can't use spaces in the nickname, in the video looks like "swapdo" with an 'o' vowel.

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Sat Apr 27, 2019 3:36 pm

swapd0 wrote:Thanks for the credits :cheers:

By the way it's "swap d0", llike the opcode, but you can't use spaces in the nickname, in the video looks like "swapdo" with an 'o' vowel.


you are welcome, and sorry about that, i did first notice it when i wrote the last description, and i was thinking his name is swap d0,
i can redo the video if you like :D

edit:
i have fixed my mistake, reloaded the video :lol:
Last edited by FedePede04 on Sat Apr 27, 2019 3:55 pm, edited 1 time in total.
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

mlynn1974
Captain Atari
Captain Atari
Posts: 277
Joined: Mon Mar 03, 2008 10:33 pm
Contact:

Re: Outrun with frame counter

Postby mlynn1974 » Sat Apr 27, 2019 3:42 pm

Superb work Peter! I wish I could help with the code optimization.

With Outrun you have to be really careful about using registers they didn't use in the tight loops because they've probably used them for something else outside the loop or in the calling function then you have to consider the cost of preserving them on the stack.
Still got, still working: Atari 4Mb STe, 520STFM, 2.5Mb STF.
Hardware: Cumana CSA 354, Ultimate Ripper, Blitz Turbo, Synchro Express II (US and UK Versions).

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Sat Apr 27, 2019 4:05 pm

mlynn1974 wrote:Superb work Peter! I wish I could help with the code optimization.

With Outrun you have to be really careful about using registers they didn't use in the tight loops because they've probably used them for something else outside the loop or in the calling function then you have to consider the cost of preserving them on the stack.


thanks for you words and the warning :D

yes one really have to be careful i have try a couple of time to do errors that i could not find again, so it ended with i had to paste some of the original code back.
I had same problem in enduro racer. so you have to work slowly and look ahead to see if you destroy any thing and try to map labels and variables.

but the more you work with it your easier it will get, because you are replacing there code with you own..
but i actual like to do stuff like this. you don't have to start from scratch, and you can see if you do any progress :D
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Tue May 07, 2019 7:43 am

here you are Outrun with frame counter

NOTE: this version need a blitter to run :)
please removed this post it if its not ok to uploaded the game here :D
Outrun.zip


can be some visual error in it, i have just compiled it :D
plus due to it run faster it very easy to get through and the bonus time f..k up, need to adjust the time so it fits no matter what frame you are pulling :D

edit :
I forgot it can still be optimized a lot next could be let the blitter print the road :)
also still missing the new route map / and the new speed bar :D
You do not have the required permissions to view the files attached to this post.
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

EvilFranky
Atari Super Hero
Atari Super Hero
Posts: 870
Joined: Thu Sep 11, 2003 10:49 pm
Location: UK
Contact:

Re: Outrun with frame counter

Postby EvilFranky » Tue May 07, 2019 5:10 pm

Great effort so far, well done.

Slightly off topic, what frame rate did the Lotus games run at on the ST? Think the Amiga version is 25fps.

User avatar
Cyprian
10 GOTO 10
10 GOTO 10
Posts: 1737
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Outrun with frame counter

Postby Cyprian » Tue May 07, 2019 5:51 pm

Steem SSE debugger shows 25fps for Lotus Turbo Esprit
Lynx II / Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / Lynx Multi Card / LDW Super 2000 / XCA12 / SkunkBoard / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.appspot.com/

EvilFranky
Atari Super Hero
Atari Super Hero
Posts: 870
Joined: Thu Sep 11, 2003 10:49 pm
Location: UK
Contact:

Re: Outrun with frame counter

Postby EvilFranky » Tue May 07, 2019 5:54 pm

Cyprian wrote:Steem SSE debugger shows 25fps for Lotus Turbo Esprit


Oh really! I'm surprised.

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Tue May 07, 2019 9:57 pm

Many thx.
I will probably shelf the project for some time, also the reason why i uploaded it now.
i need to do some other stuff that have been waiting for me :D

EvilFranky wrote:Great effort so far, well done.

Slightly off topic, what frame rate did the Lotus games run at on the ST? Think the Amiga version is 25fps.
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Fri May 10, 2019 9:15 am

I could use some input, Ok i am looking at some code optimations and i found this

original code

Code: Select all


L02B3:           
            Move.w   SPEED,D0
            Add.w   #$FF,D0
            LSR.W   #8,D0
            Move.w   D0,D1
            LSR.W   #4,D1
            Sub.w   D1,D0
            Add.w   D0,UND_POSN
            ADD.B   D0,ANY_ZED
            Add.w   D0,POSITION
            Sub.w   D0,L049E
            Bpl.s   L02B4
            Clr.w   L049E
            Clr.w   L049C
L02B4:           
         
            Move.w   L049E,D1
            Move.w   L049C,D1
            Mulu   #8,D1
            Lea   L03C3,A0
            Add.w   D1,A0
            Move.w   L049E,D1
            LSR.W   #8,D1
            Move.b   (A0,D1.W),D1
            Move.w   D1,SPEC_GRA
            Clr.w   SPEC_GRA
            Sub.w   D0,LANE_POS
            Bpl.s   L02B5
            Clr.w   LANE_POS
L02B5:           
            Lea   HIT_LIST,A0
            Lea   WILD_DT,A1
            Moveq   #7,D1



optimize code 1

Code: Select all

            
            Lea      L03C3,A0
            Move.w   SPEED,D0
            Add.w   #$FF,D0
            LSR.W   #8,D0
            Move.w   D0,D1
            LSR.W   #4,D1
            Sub.w   D1,D0
            Add.w   D0,UND_POSN
            ADD.B   D0,ANY_ZED
            Add.w   D0,POSITION
            Sub.w   D0,L049E
            Bpl.s   L02B4
            Moveq   #0,D1
            Move.w   D1,L049E
            Move.w   D1,L049C
            Bra.s   VoVFisk
L02B4:           
         
;            Move.w   L049E,D1
            Move.w   L049C,D1
            Lsl.w   #3,D1
;            Mulu   #8,D1
            Add.w   D1,A0
VoVFisk:         
            Moveq   #0,D1
            Move.b   L049E,D1
            Move.b   (A0,D1.W),D1
            Move.w   D1,SPEC_GRA
            Clr.w   SPEC_GRA
            Sub.w   D0,LANE_POS
            Bpl.s   L02B5
            Clr.w   LANE_POS
L02B5:           
            Lea      HIT_LIST,A0
            Lea      WILD_DT,A1
            Moveq   #7,D1
L02B6:           


ok but iam i missing something because it look like it real stupid code in the first places
if one look at d1 it get store in SPEC_GRA and SPEC_GRA the clear right after?
so could the code be something like this, or do i over miss something?

Code: Select all

            Moveq   #0,D0
            Move.b   SPEED,D0
            Addq.w   #1,D0

            Move.w   D0,D1
            LSR.W   #4,D1
            Sub.w   D1,D0
            Add.w   D0,UND_POSN
            ADD.B   D0,ANY_ZED
            Add.w   D0,POSITION
            Moveq   #0,D1
            Sub.w   D0,L049E
            Bpl.s   L02B4
            Move.w   D1,L049E
            Move.w   D1,L049C
L02B4:           
            Move.w   D1,SPEC_GRA
            Sub.w   D0,LANE_POS
            Bpl.s   L02B5
            Move.w   D1,LANE_POS
L02B5:           
            Lea      HIT_LIST,A0
            Lea      WILD_DT,A1
            Moveq   #7,D1
L02B6:           



Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

wietze
Captain Atari
Captain Atari
Posts: 272
Joined: Fri Mar 01, 2013 10:52 pm

Re: Outrun with frame counter

Postby wietze » Fri May 10, 2019 2:22 pm

Your suggested code seems correct; a few explicit remarks; which you most probably noticed yourself; but it never hurts to make it explicit:

- you introduce a small margin of error in the value of d0 that propagates to d1 (in some cases, the margin is 255/256, and propagated by another fraction of 16 later on); I assume this is a way of ALWAYS rounding up, unless the byte value is $00.
- you prevent the setting up of a0 and d1, which I cannot derive from if they are needed or not, if you are sure that these registers values are not used outside the routine; this is good

keep them coming :)

User avatar
FedePede04
Atari God
Atari God
Posts: 1211
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark
Contact:

Re: Outrun with frame counter

Postby FedePede04 » Fri May 10, 2019 2:43 pm

wietze wrote:Your suggested code seems correct; a few explicit remarks; which you most probably noticed yourself; but it never hurts to make it explicit:

- you introduce a small margin of error in the value of d0 that propagates to d1 (in some cases, the margin is 255/256, and propagated by another fraction of 16 later on); I assume this is a way of ALWAYS rounding up, unless the byte value is $00.
- you prevent the setting up of a0 and d1, which I cannot derive from if they are needed or not, if you are sure that these registers values are not used outside the routine; this is good

keep them coming :)


thanks for the reply, i had to removed the addq.w #1,D0 it made the background move always.
but even if the round up is gone it still look to work fine.
if you look at L02B5 the new value is loaded into A0/D1 so it should not have any impact on the code later on, and it do work the same.
but its probably some leftover that he never got to removed.

thanks for looking it over, its always nice with a pair fresh eyes, to confirm that its ok and not me going crazy :D
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)

wietze
Captain Atari
Captain Atari
Posts: 272
Joined: Fri Mar 01, 2013 10:52 pm

Re: Outrun with frame counter

Postby wietze » Fri May 10, 2019 2:51 pm

FedePede04 wrote:
wietze wrote:Your suggested code seems correct; a few explicit remarks; which you most probably noticed yourself; but it never hurts to make it explicit:

- you introduce a small margin of error in the value of d0 that propagates to d1 (in some cases, the margin is 255/256, and propagated by another fraction of 16 later on); I assume this is a way of ALWAYS rounding up, unless the byte value is $00.
- you prevent the setting up of a0 and d1, which I cannot derive from if they are needed or not, if you are sure that these registers values are not used outside the routine; this is good

keep them coming :)


thanks for the reply, i had to removed the addq.w #1,D0 it made the background move always.
but even if the round up is gone it still look to work fine.
if you look at L02B5 the new value is loaded into A0/D1 so it should not have any impact on the code later on, and it do work the same.
but its probably some leftover that he never got to removed.

thanks for looking it over, its always nice with a pair fresh eyes, to confirm that its ok and not me going crazy :D


You're right, I oversaw that. I removed that since it was the same in all versions in my comparison.


Social Media

     

Return to “Games - General”

Who is online

Users browsing this forum: No registered users and 5 guests