mirror of https://github.com/stella-emu/stella.git
Keep book of the number of cycles spent during emulation.
This commit is contained in:
parent
d70b0d8c40
commit
7f83e776b2
|
@ -261,12 +261,14 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBuffer::update()
|
||||
Int64 FrameBuffer::update()
|
||||
{
|
||||
// Determine which mode we are in (from the EventHandler)
|
||||
// Take care of S_EMULATE mode here, otherwise let the GUI
|
||||
// figure out what to draw
|
||||
|
||||
Int64 cycles = -1;
|
||||
|
||||
invalidate();
|
||||
switch(myOSystem.eventHandler().state())
|
||||
{
|
||||
|
@ -275,7 +277,7 @@ void FrameBuffer::update()
|
|||
// Run the console for one frame
|
||||
// Note that the debugger can cause a breakpoint to occur, which changes
|
||||
// the EventHandler state 'behind our back' - we need to check for that
|
||||
myOSystem.console().tia().update();
|
||||
cycles = myOSystem.console().tia().update();
|
||||
#ifdef DEBUGGER_SUPPORT
|
||||
if(myOSystem.eventHandler().state() != EventHandlerState::EMULATION) break;
|
||||
#endif
|
||||
|
@ -344,7 +346,7 @@ void FrameBuffer::update()
|
|||
}
|
||||
|
||||
case EventHandlerState::NONE:
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Draw any pending messages
|
||||
|
@ -353,6 +355,8 @@ void FrameBuffer::update()
|
|||
|
||||
// Do any post-frame stuff
|
||||
postFrameUpdate();
|
||||
|
||||
return cycles;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -113,9 +113,10 @@ class FrameBuffer
|
|||
|
||||
/**
|
||||
Updates the display, which depending on the current mode could mean
|
||||
drawing the TIA, any pending menus, etc.
|
||||
drawing the TIA, any pending menus, etc. Returns the numbers of CPU cycles
|
||||
spent during emulation, or -1 if not applicable.
|
||||
*/
|
||||
void update();
|
||||
Int64 update();
|
||||
|
||||
/**
|
||||
Shows a message onscreen.
|
||||
|
|
|
@ -26,7 +26,7 @@ PaddleReader::PaddleReader()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PaddleReader::reset(double timestamp)
|
||||
void PaddleReader::reset(uInt64 timestamp)
|
||||
{
|
||||
myU = 0;
|
||||
myIsDumped = false;
|
||||
|
@ -38,7 +38,7 @@ void PaddleReader::reset(double timestamp)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PaddleReader::vblank(uInt8 value, double timestamp)
|
||||
void PaddleReader::vblank(uInt8 value, uInt64 timestamp)
|
||||
{
|
||||
bool oldIsDumped = myIsDumped;
|
||||
|
||||
|
@ -53,7 +53,7 @@ void PaddleReader::vblank(uInt8 value, double timestamp)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt8 PaddleReader::inpt(double timestamp)
|
||||
uInt8 PaddleReader::inpt(uInt64 timestamp)
|
||||
{
|
||||
updateCharge(timestamp);
|
||||
|
||||
|
@ -63,7 +63,7 @@ uInt8 PaddleReader::inpt(double timestamp)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PaddleReader::update(double value, double timestamp, ConsoleTiming consoleTiming)
|
||||
void PaddleReader::update(double value, uInt64 timestamp, ConsoleTiming consoleTiming)
|
||||
{
|
||||
if (consoleTiming != myConsoleTiming) {
|
||||
setConsoleTiming(consoleTiming);
|
||||
|
@ -94,13 +94,13 @@ void PaddleReader::setConsoleTiming(ConsoleTiming consoleTiming)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PaddleReader::updateCharge(double timestamp)
|
||||
void PaddleReader::updateCharge(uInt64 timestamp)
|
||||
{
|
||||
if (myIsDumped) return;
|
||||
|
||||
if (myValue >= 0)
|
||||
myU = USUPP * (1 - (1 - myU / USUPP) *
|
||||
exp(-(timestamp - myTimestamp) / (myValue * RPOT + R0) / C / myClockFreq));
|
||||
exp(-static_cast<double>(timestamp - myTimestamp) / (myValue * RPOT + R0) / C / myClockFreq));
|
||||
|
||||
myTimestamp = timestamp;
|
||||
}
|
||||
|
|
|
@ -30,14 +30,14 @@ class PaddleReader : public Serializable
|
|||
|
||||
public:
|
||||
|
||||
void reset(double timestamp);
|
||||
void reset(uInt64 timestamp);
|
||||
|
||||
void vblank(uInt8 value, double timestamp);
|
||||
void vblank(uInt8 value, uInt64 timestamp);
|
||||
bool vblankDumped() const { return myIsDumped; }
|
||||
|
||||
uInt8 inpt(double timestamp);
|
||||
uInt8 inpt(uInt64 timestamp);
|
||||
|
||||
void update(double value, double timestamp, ConsoleTiming consoleTiming);
|
||||
void update(double value, uInt64 timestamp, ConsoleTiming consoleTiming);
|
||||
|
||||
/**
|
||||
Serializable methods (see that class for more information).
|
||||
|
@ -50,7 +50,7 @@ class PaddleReader : public Serializable
|
|||
|
||||
void setConsoleTiming(ConsoleTiming timing);
|
||||
|
||||
void updateCharge(double timestamp);
|
||||
void updateCharge(uInt64 timestamp);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -58,7 +58,7 @@ class PaddleReader : public Serializable
|
|||
double myU;
|
||||
|
||||
double myValue;
|
||||
double myTimestamp;
|
||||
uInt64 myTimestamp;
|
||||
|
||||
ConsoleTiming myConsoleTiming;
|
||||
double myClockFreq;
|
||||
|
|
|
@ -809,9 +809,14 @@ bool TIA::loadDisplay(Serializer& in)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TIA::update()
|
||||
uInt64 TIA::update()
|
||||
{
|
||||
uInt64 timestampOld = myTimestamp;
|
||||
|
||||
mySystem->m6502().execute(25000);
|
||||
|
||||
updateEmulation();
|
||||
return (myTimestamp - timestampOld) / 3;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -199,7 +199,7 @@ class TIA : public Device
|
|||
desired frame rate to update the TIA. Invoking this method will update
|
||||
the graphics buffer and generate the corresponding audio samples.
|
||||
*/
|
||||
void update();
|
||||
uInt64 update();
|
||||
|
||||
/**
|
||||
Returns a pointer to the internal frame buffer.
|
||||
|
@ -748,11 +748,9 @@ class TIA : public Device
|
|||
uInt8 myColorHBlank;
|
||||
|
||||
/**
|
||||
* The total number of color clocks since emulation started. This is a
|
||||
* double a) to avoid overflows and b) as it will enter floating point
|
||||
* expressions in the paddle readout simulation anyway.
|
||||
* The total number of color clocks since emulation started.
|
||||
*/
|
||||
double myTimestamp;
|
||||
uInt64 myTimestamp;
|
||||
|
||||
/**
|
||||
* The "shadow registers" track the last written register value for the
|
||||
|
|
Loading…
Reference in New Issue