mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-04-02 10:42:14 -04:00
A thank you to everyone who helped test the RC to ensure stability. I've uploaded the official v064 release to Google Code. The most important change in this release is the cycle-based PPU renderer; but due to performance reasons the scanline-based renderer remains the default in the Windows binary. If you want to try out the cycle-based renderer, you will need to compile from source for now. Another major change is the introduction of libsnes, which allows one to build bsnes as a shared library that can be used from other programming languages. It is intended both to create a regression testing framework, and to provide API stability for the various projects that use the bsnes core. While I can't guarantee the API to libsnes won't change, I will properly revision it and do everything I can to avoid changing it if possible.
56 lines
2.2 KiB
C++
56 lines
2.2 KiB
C++
/***************************************************************************
|
|
* Copyright (C) 2008 by Sindre Aamås *
|
|
* aamas@stud.ntnu.no *
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License version 2 as *
|
|
* published by the Free Software Foundation. *
|
|
* *
|
|
* This program is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
* GNU General Public License version 2 for more details. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* version 2 along with this program; if not, write to the *
|
|
* Free Software Foundation, Inc., *
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
***************************************************************************/
|
|
#include "adaptivesleep.h"
|
|
|
|
usec_t AdaptiveSleep::sleepUntil(usec_t base, usec_t inc) {
|
|
usec_t now = getusecs();
|
|
usec_t diff = now - base;
|
|
|
|
if (diff >= inc)
|
|
return diff - inc;
|
|
|
|
diff = inc - diff;
|
|
|
|
if (diff > oversleep + oversleepVar) {
|
|
diff -= oversleep + oversleepVar;
|
|
usecsleep(diff);
|
|
const usec_t ideal = now + diff;
|
|
now = getusecs();
|
|
|
|
{
|
|
usec_t curOversleep = now - ideal;
|
|
|
|
if (negate(curOversleep) < curOversleep)
|
|
curOversleep = 0;
|
|
|
|
oversleepVar = (oversleepVar * 15 + (curOversleep < oversleep ? oversleep - curOversleep : curOversleep - oversleep)) >> 4;
|
|
oversleep = (oversleep * 15 + curOversleep) >> 4;
|
|
}
|
|
|
|
noSleep = 60;
|
|
} else if (--noSleep == 0) {
|
|
noSleep = 60;
|
|
oversleep = oversleepVar = 0;
|
|
}
|
|
|
|
while (now - base < inc)
|
|
now = getusecs();
|
|
|
|
return 0;
|
|
}
|