Forum etiquette

Our mission ...

This forum is part of our mission to promote the preservation of vintage computers through education and outreach. (In real life we also run events and have a museum.) We encourage you to join us, participate, share your knowledge, and enjoy.

This forum has been around in this format for over 15 years. These rules and guidelines help us maintain a healthy and active community, and we moderate the forum to keep things on track. Please familiarize yourself with these rules and guidelines.

Remain civil and respectful

There are several hundred people who actively participate here. People come from all different backgrounds and will have different ways of seeing things. You will not agree with everything you read here. Back-and-forth discussions are fine but do not cross the line into rude or disrespectful behavior.

Conduct yourself as you would at any other place where people come together in person to discuss their hobby. If you wouldn't say something to somebody in person, then you probably should not be writing it here.

This should be obvious but, just in case: profanity, threats, slurs against any group (sexual, racial, gender, etc.) will not be tolerated.

Stay close to the original topic being discussed
  • If you are starting a new thread choose a reasonable sub-forum to start your thread. (If you choose incorrectly don't worry, we can fix that.)
  • If you are responding to a thread, stay on topic - the original poster was trying to achieve something. You can always start a new thread instead of potentially "hijacking" an existing thread.

Contribute something meaningful

To put things in engineering terms, we value a high signal to noise ratio. Coming here should not be a waste of time.
  • This is not a chat room. If you are taking less than 30 seconds to make a post then you are probably doing something wrong. A post should be on topic, clear, and contribute something meaningful to the discussion. If people read your posts and feel that their time as been wasted, they will stop reading your posts. Worse yet, they will stop visiting and we'll lose their experience and contributions.
  • Do not bump threads.
  • Do not "necro-post" unless you are following up to a specific person on a specific thread. And even then, that person may have moved on. Just start a new thread for your related topic.
  • Use the Private Message system for posts that are targeted at a specific person.

"PM Sent!" messages (or, how to use the Private Message system)

This forum has a private message feature that we want people to use for messages that are not of general interest to other members.

In short, if you are going to reply to a thread and that reply is targeted to a specific individual and not of interest to anybody else (either now or in the future) then send a private message instead.

Here are some obvious examples of when you should not reply to a thread and use the PM system instead:
  • "PM Sent!": Do not tell the rest of us that you sent a PM ... the forum software will tell the other person that they have a PM waiting.
  • "How much is shipping to ....": This is a very specific and directed question that is not of interest to anybody else.

Why do we have this policy? Sending a "PM Sent!" type message basically wastes everybody else's time by making them having to scroll past a post in a thread that looks to be updated, when the update is not meaningful. And the person you are sending the PM to will be notified by the forum software that they have a message waiting for them. Look up at the top near the right edge where it says 'Notifications' ... if you have a PM waiting, it will tell you there.

Copyright and other legal issues

We are here to discuss vintage computing, so discussing software, books, and other intellectual property that is on-topic is fine. We don't want people using these forums to discuss or enable copyright violations or other things that are against the law; whether you agree with the law or not is irrelevant. Do not use our resources for something that is legally or morally questionable.

Our discussions here generally fall under "fair use." Telling people how to pirate a software title is an example of something that is not allowable here.

Reporting problematic posts

If you see spam, a wildly off-topic post, or something abusive or illegal please report the thread by clicking on the "Report Post" icon. (It looks like an exclamation point in a triangle and it is available under every post.) This send a notification to all of the moderators, so somebody will see it and deal with it.

If you are unsure you may consider sending a private message to a moderator instead.

New user moderation

New users are directly moderated so that we can weed spammers out early. This means that for your first 10 posts you will have some delay before they are seen. We understand this can be disruptive to the flow of conversation and we try to keep up with our new user moderation duties to avoid undue inconvenience. Please do not make duplicate posts, extra posts to bump your post count, or ask the moderators to expedite this process; 10 moderated posts will go by quickly.

New users also have a smaller personal message inbox limit and are rate limited when sending PMs to other users.

Other suggestions
  • Use Google, books, or other definitive sources. There is a lot of information out there.
  • Don't make people guess at what you are trying to say; we are not mind readers. Be clear and concise.
  • Spelling and grammar are not rated, but they do make a post easier to read.
See more
See less

Automatic frame skip on the x86

  • Filter
  • Time
  • Show
Clear All
new posts

    Automatic frame skip on the x86

    OutRun for PC self adapts the FPS shown depending on the speed of the processor. But, and this really seems stunning to me, it makes it on real time! For example, on DOSBox you can start at a certain speed (let's say, 3000 cycles) and it runs very smooth. But if, during the game play, we gradually reduce the cycles down to 280 (which could be more or less equivalent to an 8088 at 4.77 Mhz), we'll see how the game continues its way, but n frames are being skipped, finally being quite jerky when ~280 is reached. The opposite is also true, starting slow and incrementing the speed makes the game run smoother on real time.

    So I'm wondering what technique could be used to achieve this effect.

    A less elegant solution I figured out would be calculating the approximate speed of the system, by counting cycles, and after that, skip the frames needed for every speed. I post here the code I wrote for counting cycles, in case it's useful for somebody, or if anybody would like to improve something on it:

    #include <stdio.h>
    #include <time.h>
    void count_cpu_cycles (void)
    	clock_t start, stop;
      	unsigned long t;
      	asm mov al, 0x34
      	asm out 0x43, al    /* tell the PIT which channel we're setting */
     	_CX = (int)(1193180L / 1000); /* 1193180L / Frequency in Hz*/
    	outportb(0x40,_CL);			  /* Configuring timer 0 with the freq */
    	start = clock();
    	asm mov cx,8000h  /* Do it 32768 times */
    	asm ror al,1
    	asm sub al,al
    	asm add al,250	/* Just a few random operations to consume cycles */
    	asm loop loopClock
    	stop = clock();
    	outportb(0x40,0);  /* Restoring the timer */
    	t = stop-start;
    	printf ("Result = %lu ... %lu = %lu", stop, start, t);
    I made a table of the values returned by a few systems, emulated via 86Box, so I could use them as a reference. For instance, this code returns 302 for the IBM PC and XT, 291 for the Compaq Portable, 276 for the original Tandy 1000 or 349 for an American XT clone, all of them running at 4.77 (the higher, the slower). I also have values from 8086 to 486 processors, that ranks from 160 to 6. I think this code could not be used for real time speed poling as it takes a time to count the cycles, I would use it once at the beginning to establish the frame skipping.

    Another solution would be just asking the user if s/he is using a slow of fast processor (as Blood Money for PC does) and then accordingly skip 1, 2 or whatever the frames needed.

    I think the autoskip solution would be fantastic but I have not a clue of how could be accomplished.

    Thank you very much!

    Why would you need to know the speed of the system at all? In a racing game the movement of things on the screen would depend on elapsed time and vehicle speed, no? You can calculate that independently of the frame rate.


      Isn't that what most games do anyway? I mean, games don't run in slow-motion on slower systems, they just draw fewer frames per second - keeping the game speed intact.

      Also, I would not even call this "frame skipping", as no frames are skipped. Skipping would mean there's a fixed target frame-rate the game can not uphold. But these games will simply scale with CPU speed.


        Originally posted by carlos12 View Post
        I think the autoskip solution would be fantastic but I have not a clue of how could be accomplished.
        You're overthinking the problem. On systems where speed is not known and single-frame lock (ie. full framerate) is not required (or achievable), it's common for most action games to calculate time-sensitive operations (usually game logic, input, and music) on a background timer, so that their results are guaranteed no matter what speed the system is. Then the part of the game that takes the most time -- rendering -- is done whenever it can. At the start of the render loop, it copies (hopefully atomically) the data it needs from the output of the gameplay calcs to render the screen, then it renders the screen. While it's rendering, several more calcs could have happened, because the game calcs are on a timer. So it's not that intentional frame skipping is occuring, but rather it's a natural effect of the game not being able to render frames fast enough to match the game calcs on a timer.

        As bakemono wrote: "independently of the frame rate."

        Watching dosbox's debugger output running outrun, we can see the game sets PIT 0 to 100Hz (mode 3) and doesn't change until you exit. Since I can hear the sound effects aren't updating at 100Hz, I'm guessing that timer is subdivided by 3 such that each portion of the timer handler has an effective 33 Hz rate. My guess is:
        0: input
        1: game calcs
        2: sound

        ...then loops around (3: input, 4: game calcs, etc.)

        One way to test this theory is by running the game on a ludicrously fast system (such that render time is instant), record video of the screen, and seeing how many unique frames per second we get. I did that, and found the following:

        - If you include everything on the screen, the true framerate is ~58 fps because the score, timer, and your car's tires update every single render
        - If you exclude those elements, looking at only the main track/cars/scenery updating, the framerate is about ~19 fps

        So this proves my theory WRONG: With an effective framerate of only 20, they set the timer to 100 Hz, and every fifth tick (for a framerate of 100 / 5 = 20) is when they calculate the main game mechanics.

        Here's a trdrop export of the main gameplay area so you can see what I'm talking about:

        Edit: Watching this a few times, the fps increases a bit in one section, which might be an actual fps increase or it could be a measurement error on my part. But the overwhelming majority of the footage (not included in that clip) is ~20 fps.
        Offering a bounty for:
        - A working Sanyo MBC-775 or Logabax 1600
        - Music Construction Set, IBM Music Feature edition (has red sticker on front stating IBM Music Feature)


          Thank you so much! That was one my missing pieces. You're right, counting cycles to determine the approximate CPU speed, and then skipping frames accordingly is an overkill. I've been testing moving the game's coordinate calculations from the main loop to a custom interrupt procedure, poling at 60 or 100 Hz (I'm trying several options), and getting the help of a tick counter. It works great.