Merge branch 'release/6.0' of https://github.com/stella-emu/stella into release/6.0

This commit is contained in:
thrust26 2018-12-06 14:25:41 +01:00
commit 251449cacf
24 changed files with 411 additions and 62 deletions

View File

@ -63,6 +63,10 @@
* Fixed bug in autodetecting Genesis controllers.
* Fixed bug with 'thumb.trapfatal' commandline argument; sometimes Stella
would lock up when encountering a fatal error instead of entering the
debugger and displaying a message.
* Fixed bug in reading from settings file with entries that were empty;
the parsing was failing. This affected the 'cpurandom' argument; when
all options in it were turned off, they were all turned on again during

View File

@ -18,10 +18,14 @@
#include "OSystem.hxx"
#include "EventHandlerSDL2.hxx"
#include "ThreadDebugging.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventHandlerSDL2::EventHandlerSDL2(OSystem& osystem)
: EventHandler(osystem)
{
ASSERT_MAIN_THREAD;
#ifdef JOYSTICK_SUPPORT
if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0)
{
@ -36,6 +40,8 @@ EventHandlerSDL2::EventHandlerSDL2(OSystem& osystem)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventHandlerSDL2::~EventHandlerSDL2()
{
ASSERT_MAIN_THREAD;
if(SDL_WasInit(SDL_INIT_JOYSTICK))
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
}
@ -43,6 +49,8 @@ EventHandlerSDL2::~EventHandlerSDL2()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandlerSDL2::enableTextEvents(bool enable)
{
ASSERT_MAIN_THREAD;
if(enable)
SDL_StartTextInput();
else
@ -52,6 +60,8 @@ void EventHandlerSDL2::enableTextEvents(bool enable)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandlerSDL2::pollEvent()
{
ASSERT_MAIN_THREAD;
while(SDL_PollEvent(&myEvent))
{
switch(myEvent.type)
@ -210,6 +220,8 @@ void EventHandlerSDL2::pollEvent()
EventHandlerSDL2::JoystickSDL2::JoystickSDL2(int idx)
: myStick(nullptr)
{
ASSERT_MAIN_THREAD;
myStick = SDL_JoystickOpen(idx);
if(myStick)
{
@ -231,6 +243,8 @@ EventHandlerSDL2::JoystickSDL2::JoystickSDL2(int idx)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventHandlerSDL2::JoystickSDL2::~JoystickSDL2()
{
ASSERT_MAIN_THREAD;
if(SDL_WasInit(SDL_INIT_JOYSTICK) && myStick)
SDL_JoystickClose(myStick);
}

View File

@ -17,6 +17,8 @@
#include "FBSurfaceSDL2.hxx"
#include "ThreadDebugging.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FBSurfaceSDL2::FBSurfaceSDL2(FrameBufferSDL2& buffer,
uInt32 width, uInt32 height, const uInt32* data)
@ -36,6 +38,8 @@ FBSurfaceSDL2::FBSurfaceSDL2(FrameBufferSDL2& buffer,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FBSurfaceSDL2::~FBSurfaceSDL2()
{
ASSERT_MAIN_THREAD;
if(mySurface)
{
SDL_FreeSurface(mySurface);
@ -48,6 +52,8 @@ FBSurfaceSDL2::~FBSurfaceSDL2()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSDL2::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, ColorId color)
{
ASSERT_MAIN_THREAD;
// Fill the rectangle
SDL_Rect tmp;
tmp.x = x;
@ -125,6 +131,8 @@ void FBSurfaceSDL2::translateCoords(Int32& x, Int32& y) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FBSurfaceSDL2::render()
{
ASSERT_MAIN_THREAD;
if(myIsVisible)
{
if(myTexAccess == SDL_TEXTUREACCESS_STREAMING)
@ -139,12 +147,16 @@ bool FBSurfaceSDL2::render()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSDL2::invalidate()
{
ASSERT_MAIN_THREAD;
SDL_FillRect(mySurface, nullptr, 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSDL2::free()
{
ASSERT_MAIN_THREAD;
if(myTexture)
{
SDL_DestroyTexture(myTexture);
@ -155,6 +167,8 @@ void FBSurfaceSDL2::free()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSDL2::reload()
{
ASSERT_MAIN_THREAD;
// Re-create texture; the underlying SDL_Surface is fine as-is
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, myInterpolate ? "1" : "0");
myTexture = SDL_CreateTexture(myFB.myRenderer, myFB.myPixelFormat->format,
@ -175,6 +189,8 @@ void FBSurfaceSDL2::reload()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSDL2::resize(uInt32 width, uInt32 height)
{
ASSERT_MAIN_THREAD;
// We will only resize when necessary, and not using static textures
if((myTexAccess == SDL_TEXTUREACCESS_STATIC) || (mySurface &&
int(width) <= mySurface->w && int(height) <= mySurface->h))
@ -191,6 +207,8 @@ void FBSurfaceSDL2::resize(uInt32 width, uInt32 height)
void FBSurfaceSDL2::createSurface(uInt32 width, uInt32 height,
const uInt32* data)
{
ASSERT_MAIN_THREAD;
// Create a surface in the same format as the parent GL class
const SDL_PixelFormat* pf = myFB.myPixelFormat;

View File

@ -26,12 +26,16 @@
#include "FBSurfaceSDL2.hxx"
#include "FrameBufferSDL2.hxx"
#include "ThreadDebugging.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBufferSDL2::FrameBufferSDL2(OSystem& osystem)
: FrameBuffer(osystem),
myWindow(nullptr),
myRenderer(nullptr)
{
ASSERT_MAIN_THREAD;
// Initialize SDL2 context
if(SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
{
@ -52,6 +56,8 @@ FrameBufferSDL2::FrameBufferSDL2(OSystem& osystem)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBufferSDL2::~FrameBufferSDL2()
{
ASSERT_MAIN_THREAD;
SDL_FreeFormat(myPixelFormat);
if(myRenderer)
@ -79,6 +85,8 @@ FrameBufferSDL2::~FrameBufferSDL2()
void FrameBufferSDL2::queryHardware(vector<GUI::Size>& displays,
VariantList& renderers)
{
ASSERT_MAIN_THREAD;
// First get the maximum windowed desktop resolution
SDL_DisplayMode display;
int maxDisplays = SDL_GetNumVideoDisplays();
@ -129,12 +137,16 @@ void FrameBufferSDL2::queryHardware(vector<GUI::Size>& displays,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 FrameBufferSDL2::getCurrentDisplayIndex()
{
ASSERT_MAIN_THREAD;
return SDL_GetWindowDisplayIndex(myWindow);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameBufferSDL2::setVideoMode(const string& title, const VideoMode& mode)
{
ASSERT_MAIN_THREAD;
// If not initialized by this point, then immediately fail
if(SDL_WasInit(SDL_INIT_VIDEO) == 0)
return false;
@ -244,6 +256,8 @@ bool FrameBufferSDL2::setVideoMode(const string& title, const VideoMode& mode)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSDL2::setTitle(const string& title)
{
ASSERT_MAIN_THREAD;
myScreenTitle = title;
if(myWindow)
@ -253,6 +267,8 @@ void FrameBufferSDL2::setTitle(const string& title)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string FrameBufferSDL2::about() const
{
ASSERT_MAIN_THREAD;
ostringstream out;
out << "Video system: " << SDL_GetCurrentVideoDriver() << endl;
SDL_RendererInfo info;
@ -273,24 +289,32 @@ string FrameBufferSDL2::about() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSDL2::invalidate()
{
ASSERT_MAIN_THREAD;
SDL_RenderClear(myRenderer);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSDL2::showCursor(bool show)
{
ASSERT_MAIN_THREAD;
SDL_ShowCursor(show ? SDL_ENABLE : SDL_DISABLE);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSDL2::grabMouse(bool grab)
{
ASSERT_MAIN_THREAD;
SDL_SetRelativeMouseMode(grab ? SDL_TRUE : SDL_FALSE);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameBufferSDL2::fullScreen() const
{
ASSERT_MAIN_THREAD;
#ifdef WINDOWED_SUPPORT
return SDL_GetWindowFlags(myWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP;
#else
@ -301,6 +325,8 @@ bool FrameBufferSDL2::fullScreen() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSDL2::renderToScreen()
{
ASSERT_MAIN_THREAD;
// Show all changes made to the renderer
SDL_RenderPresent(myRenderer);
}
@ -308,6 +334,8 @@ void FrameBufferSDL2::renderToScreen()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSDL2::setWindowIcon()
{
ASSERT_MAIN_THREAD;
#ifndef BSPF_MAC_OSX // Currently not needed for OSX
#include "stella_icon.hxx" // The Stella icon
@ -329,6 +357,8 @@ unique_ptr<FBSurface>
void FrameBufferSDL2::readPixels(uInt8* pixels, uInt32 pitch,
const GUI::Rect& rect) const
{
ASSERT_MAIN_THREAD;
SDL_Rect r;
r.x = rect.x(); r.y = rect.y();
r.w = rect.width(); r.h = rect.height();

View File

@ -34,6 +34,8 @@
#include "audio/SimpleResampler.hxx"
#include "audio/LanczosResampler.hxx"
#include "ThreadDebugging.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SoundSDL2::SoundSDL2(OSystem& osystem, AudioSettings& audioSettings)
: Sound(osystem),
@ -46,6 +48,8 @@ SoundSDL2::SoundSDL2(OSystem& osystem, AudioSettings& audioSettings)
myUnderrun(false),
myAudioSettings(audioSettings)
{
ASSERT_MAIN_THREAD;
myOSystem.logMessage("SoundSDL2::SoundSDL2 started ...", 2);
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
@ -69,6 +73,8 @@ SoundSDL2::SoundSDL2(OSystem& osystem, AudioSettings& audioSettings)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SoundSDL2::~SoundSDL2()
{
ASSERT_MAIN_THREAD;
if (!myIsInitializedFlag) return;
SDL_CloseAudioDevice(myDevice);
@ -78,6 +84,8 @@ SoundSDL2::~SoundSDL2()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SoundSDL2::openDevice()
{
ASSERT_MAIN_THREAD;
SDL_AudioSpec desired;
desired.freq = myAudioSettings.sampleRate();
desired.format = AUDIO_F32SYS;

View File

@ -0,0 +1,57 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2018 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "ThreadDebugging.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ThreadDebuggingHelper::ThreadDebuggingHelper()
: myMainThreadIdConfigured(false)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ThreadDebuggingHelper& ThreadDebuggingHelper::instance()
{
static ThreadDebuggingHelper instance;
return instance;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ThreadDebuggingHelper::fail(const string& message)
{
cerr << message << endl;
throw runtime_error(message);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ThreadDebuggingHelper::setMainThread()
{
if (myMainThreadIdConfigured) fail("main thread already configured");
myMainThreadIdConfigured = true;
myMainThreadId = std::this_thread::get_id();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ThreadDebuggingHelper::assertMainThread()
{
if (!myMainThreadIdConfigured) fail("main thread not configured");
if (std::this_thread::get_id() != myMainThreadId) fail("must be called from main thread");
}

View File

@ -0,0 +1,65 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2018 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef THREADING_DEBUGGER_HXX
#define THREADING_DEBUGGER_HXX
#include <thread>
#include "bspf.hxx"
#ifdef DEBUG_BUILD
#define SET_MAIN_THREAD ThreadDebuggingHelper::instance().setMainThread();
#define ASSERT_MAIN_THREAD ThreadDebuggingHelper::instance().assertMainThread();
#else
#define SET_MAIN_THREAD
#define ASSERT_MAIN_THREAD
#endif
class ThreadDebuggingHelper {
public:
void setMainThread();
void assertMainThread();
static ThreadDebuggingHelper& instance();
private:
[[noreturn]] void fail(const string& message);
ThreadDebuggingHelper();
std::thread::id myMainThreadId;
bool myMainThreadIdConfigured;
private:
ThreadDebuggingHelper(const ThreadDebuggingHelper&) = delete;
ThreadDebuggingHelper(ThreadDebuggingHelper&&) = delete;
ThreadDebuggingHelper& operator=(const ThreadDebuggingHelper&) = delete;
ThreadDebuggingHelper& operator=(ThreadDebuggingHelper&&) = delete;
};
#endif // THREADING_DEBUGGER_HXX

View File

@ -31,6 +31,8 @@
#include "PNGLibrary.hxx"
#include "System.hxx"
#include "ThreadDebugging.hxx"
#ifdef DEBUGGER_SUPPORT
#include "Debugger.hxx"
#endif
@ -47,6 +49,8 @@ int stellaMain(int argc, char* argv[])
int main(int argc, char* argv[])
#endif
{
SET_MAIN_THREAD;
std::ios_base::sync_with_stdio(false);
// Create the parent OSystem object

View File

@ -19,7 +19,8 @@ MODULE_OBJS := \
src/common/ZipHandler.o \
src/common/AudioQueue.o \
src/common/AudioSettings.o \
src/common/FpsMeter.o
src/common/FpsMeter.o \
src/common/ThreadDebugging.o
MODULE_DIRS += \
src/common

View File

@ -25,6 +25,7 @@
#include "TIA.hxx"
#include "Thumbulator.hxx"
#include "CartBUS.hxx"
#include "exception/FatalEmulationError.hxx"
// Location of data within the RAM copy of the BUS Driver.
#define DSxPTR 0x06D8
@ -171,11 +172,7 @@ inline void CartridgeBUS::callFunction(uInt8 value)
catch(const runtime_error& e) {
if(!mySystem->autodetectMode())
{
#ifdef DEBUGGER_SUPPORT
Debugger::debugger().startWithFatalError(e.what());
#else
cout << e.what() << endl;
#endif
FatalEmulationError::raise(e.what());
}
}
break;

View File

@ -25,6 +25,7 @@
#include "Thumbulator.hxx"
#include "CartCDF.hxx"
#include "TIA.hxx"
#include "exception/FatalEmulationError.hxx"
// Location of data within the RAM copy of the CDF Driver.
// Version 0 1
@ -166,11 +167,7 @@ inline void CartridgeCDF::callFunction(uInt8 value)
catch(const runtime_error& e) {
if(!mySystem->autodetectMode())
{
#ifdef DEBUGGER_SUPPORT
Debugger::debugger().startWithFatalError(e.what());
#else
cout << e.what() << endl;
#endif
FatalEmulationError::raise(e.what());
}
}
break;

View File

@ -312,7 +312,6 @@ bool CartridgeCTY::save(Serializer& out) const
out.putIntArray(myMusicCounters, 3);
out.putIntArray(myMusicFrequencies, 3);
out.putLong(myFrequencyImage - myTuneData);
}
catch(...)
{

View File

@ -22,6 +22,7 @@
#include "Thumbulator.hxx"
#include "CartDPCPlus.hxx"
#include "TIA.hxx"
#include "exception/FatalEmulationError.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeDPCPlus::CartridgeDPCPlus(const BytePtr& image, uInt32 size,
@ -191,11 +192,7 @@ inline void CartridgeDPCPlus::callFunction(uInt8 value)
catch(const runtime_error& e) {
if(!mySystem->autodetectMode())
{
#ifdef DEBUGGER_SUPPORT
Debugger::debugger().startWithFatalError(e.what());
#else
cout << e.what() << endl;
#endif
FatalEmulationError::raise(e.what());
}
}
break;

View File

@ -17,12 +17,6 @@
#include "DispatchResult.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DispatchResult::assertStatus(Status status) const
{
if (myStatus != status) throw runtime_error("invalid status for operation");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool DispatchResult::isSuccess() const
{
@ -53,3 +47,9 @@ void DispatchResult::setFatal(uInt64 cycles)
myStatus = Status::fatal;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DispatchResult::setMessage(const string& message)
{
myMessage = message;
}

View File

@ -34,7 +34,7 @@ class DispatchResult
uInt64 getCycles() const { return myCycles; }
const string& getMessage() const { assertStatus(Status::debugger); return myMessage; }
const string& getMessage() const { assertStatus(Status::debugger, Status::fatal); return myMessage; }
int getAddress() const { assertStatus(Status::debugger); return myAddress; }
@ -48,9 +48,21 @@ class DispatchResult
void setFatal(uInt64 cycles);
void setMessage(const string& message);
private:
void assertStatus(Status status) const;
void assertStatus(Status status) const
{
if (myStatus != status) throw runtime_error("invalid status for operation");
}
template<class ...Ts> void assertStatus(Status status, Ts... more) const
{
if (myStatus == status) return;
assertStatus(more...);
}
private:

View File

@ -1227,7 +1227,8 @@ void EventHandler::setState(EventHandlerState state)
// after a state change, which should be supressed
mySkipMouseMotion = true;
// Erase and pending events
// Erase any previously set events, since a state change implies
// that old events are now invalid
myEvent.clear();
}

View File

@ -48,6 +48,7 @@
#include "System.hxx"
#include "M6502.hxx"
#include "DispatchResult.hxx"
#include "exception/FatalEmulationError.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
M6502::M6502(const Settings& settings)
@ -244,8 +245,7 @@ bool M6502::execute(uInt64 number)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline void M6502::_execute(uInt64 cycles, DispatchResult& result)
{
// Clear all of the execution status bits except for the fatal error bit
myExecutionStatus &= FatalErrorBit;
myExecutionStatus = 0;
#ifdef DEBUGGER_SUPPORT
TIA& tia = mySystem->tia();
@ -306,19 +306,24 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result)
// Reset the peek/poke address pointers
myLastPeekAddress = myLastPokeAddress = myDataAddressForPoke = 0;
icycles = 0;
// Fetch instruction at the program counter
IR = peek(PC++, DISASM_CODE); // This address represents a code section
try {
icycles = 0;
// Call code to execute the instruction
switch(IR)
{
// 6502 instruction emulation is generated by an M4 macro file
#include "M6502.ins"
// Fetch instruction at the program counter
IR = peek(PC++, DISASM_CODE); // This address represents a code section
default:
// Oops, illegal instruction executed so set fatal error flag
myExecutionStatus |= FatalErrorBit;
// Call code to execute the instruction
switch(IR)
{
// 6502 instruction emulation is generated by an M4 macro file
#include "M6502.ins"
default:
FatalEmulationError::raise("invalid instruction");
}
} catch (FatalEmulationError& e) {
myExecutionStatus |= FatalErrorBit;
result.setMessage(e.what());
}
currentCycles = (mySystem->cycles() - previousCycles);
@ -343,6 +348,15 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result)
interruptHandler();
}
// See if a fatal error has occured
if(myExecutionStatus & FatalErrorBit)
{
// Yes, so answer that something when wrong. The message has already been set when
// the exception was handled.
result.setFatal(currentCycles);
return;
}
// See if execution has been stopped
if(myExecutionStatus & StopExecutionBit)
{
@ -351,18 +365,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result)
return;
}
// See if a fatal error has occured
if(myExecutionStatus & FatalErrorBit)
{
// Yes, so answer that something when wrong
result.setFatal(currentCycles + icycles);
return;
}
// See if we've executed the specified number of instructions
if (currentCycles >= cycles * SYSTEM_CYCLES_PER_CPU)
{
// Yes, so answer that everything finished fine
if (currentCycles >= cycles * SYSTEM_CYCLES_PER_CPU) {
result.setOk(currentCycles);
return;
}

View File

@ -626,14 +626,34 @@ double OSystem::dispatchEmulation(EmulationWorker& emulationWorker)
// Stop the worker and wait until it has finished
uInt64 totalCycles = emulationWorker.stop();
#ifdef DEBUGGER_SUPPORT
// Break or trap? -> start debugger
if (dispatchResult.getStatus() == DispatchResult::Status::debugger) myDebugger->start(
dispatchResult.getMessage(),
dispatchResult.getAddress(),
dispatchResult.wasReadTrap()
);
#endif
// Handle the dispatch result
switch (dispatchResult.getStatus()) {
case DispatchResult::Status::ok:
break;
case DispatchResult::Status::debugger:
#ifdef DEBUGGER_SUPPORT
myDebugger->start(
dispatchResult.getMessage(),
dispatchResult.getAddress(),
dispatchResult.wasReadTrap()
);
#endif
break;
case DispatchResult::Status::fatal:
#ifdef DEBUGGER_SUPPORT
myDebugger->startWithFatalError(dispatchResult.getMessage());
#else
throw runtime_error(dispatchResult.getMessage());
#endif
break;
default:
throw runtime_error("invalid emulation dispatch result");
}
// Handle frying
if (dispatchResult.getStatus() == DispatchResult::Status::ok && myEventHandler->frying())

View File

@ -0,0 +1,36 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2018 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "FatalEmulationError.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FatalEmulationError::FatalEmulationError(const string& message)
: myMessage(message)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* FatalEmulationError::what() const noexcept
{
return myMessage.c_str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FatalEmulationError::raise(const string& message)
{
throw FatalEmulationError(message);
}

View File

@ -0,0 +1,39 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2018 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef FATAL_EMULATION_ERROR_HXX
#define FATAL_EMULATION_ERROR_HXX
#include "bspf.hxx"
class FatalEmulationError: public std::exception {
public:
FatalEmulationError(const string& message);
virtual const char* what() const noexcept;
[[noreturn]] static void raise(const string& message);
private:
const string myMessage;
};
#endif // FATAL_EMULATION_ERROR_HXX

View File

@ -80,7 +80,8 @@ MODULE_OBJS := \
src/emucore/Switches.o \
src/emucore/System.o \
src/emucore/TIASurface.o \
src/emucore/Thumbulator.o
src/emucore/Thumbulator.o \
src/emucore/exception/FatalEmulationError.o
MODULE_DIRS += \
src/emucore

View File

@ -378,6 +378,10 @@
DC6DC91F205DB879004A5FC3 /* PhysicalJoystick.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC6DC91B205DB879004A5FC3 /* PhysicalJoystick.hxx */; };
DC6DC920205DB879004A5FC3 /* PJoystickHandler.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DC6DC91C205DB879004A5FC3 /* PJoystickHandler.cxx */; };
DC6DC921205DB879004A5FC3 /* PJoystickHandler.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC6DC91D205DB879004A5FC3 /* PJoystickHandler.hxx */; };
DC6F394921B897C700897AD8 /* FatalEmulationError.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DC6F394721B897C700897AD8 /* FatalEmulationError.cxx */; };
DC6F394A21B897C700897AD8 /* FatalEmulationError.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC6F394821B897C700897AD8 /* FatalEmulationError.hxx */; };
DC6F394D21B897F300897AD8 /* ThreadDebugging.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DC6F394B21B897F300897AD8 /* ThreadDebugging.cxx */; };
DC6F394E21B897F300897AD8 /* ThreadDebugging.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC6F394C21B897F300897AD8 /* ThreadDebugging.hxx */; };
DC71EA9D1FDA06D2008827CB /* CartE78K.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DC71EA991FDA06D2008827CB /* CartE78K.cxx */; };
DC71EA9E1FDA06D2008827CB /* CartE78K.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DC71EA9A1FDA06D2008827CB /* CartE78K.hxx */; };
DC71EA9F1FDA06D2008827CB /* CartMNetwork.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DC71EA9B1FDA06D2008827CB /* CartMNetwork.cxx */; };
@ -1075,6 +1079,10 @@
DC6DC91B205DB879004A5FC3 /* PhysicalJoystick.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PhysicalJoystick.hxx; sourceTree = "<group>"; };
DC6DC91C205DB879004A5FC3 /* PJoystickHandler.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PJoystickHandler.cxx; sourceTree = "<group>"; };
DC6DC91D205DB879004A5FC3 /* PJoystickHandler.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PJoystickHandler.hxx; sourceTree = "<group>"; };
DC6F394721B897C700897AD8 /* FatalEmulationError.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FatalEmulationError.cxx; path = exception/FatalEmulationError.cxx; sourceTree = "<group>"; };
DC6F394821B897C700897AD8 /* FatalEmulationError.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = FatalEmulationError.hxx; path = exception/FatalEmulationError.hxx; sourceTree = "<group>"; };
DC6F394B21B897F300897AD8 /* ThreadDebugging.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadDebugging.cxx; sourceTree = "<group>"; };
DC6F394C21B897F300897AD8 /* ThreadDebugging.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ThreadDebugging.hxx; sourceTree = "<group>"; };
DC71EA991FDA06D2008827CB /* CartE78K.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CartE78K.cxx; sourceTree = "<group>"; };
DC71EA9A1FDA06D2008827CB /* CartE78K.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CartE78K.hxx; sourceTree = "<group>"; };
DC71EA9B1FDA06D2008827CB /* CartMNetwork.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CartMNetwork.cxx; sourceTree = "<group>"; };
@ -1668,6 +1676,8 @@
DCDDEAC31F5DBF0400C67366 /* StateManager.hxx */,
DC5C768E14C26F7C0031EBC7 /* StellaKeys.hxx */,
DC74D6A0138D4D7E00F05C5C /* StringParser.hxx */,
DC6F394B21B897F300897AD8 /* ThreadDebugging.cxx */,
DC6F394C21B897F300897AD8 /* ThreadDebugging.hxx */,
DC30924A212F74930020DAD0 /* TimerManager.cxx */,
DC30924B212F74930020DAD0 /* TimerManager.hxx */,
DCC467EA14FBEC9600E15508 /* tv_filters */,
@ -1824,6 +1834,7 @@
2D733D6E062895B2006265D9 /* EventHandler.cxx */,
2D733D6F062895B2006265D9 /* EventHandler.hxx */,
DC5AAC261FCB24AB00C420A6 /* EventHandlerConstants.hxx */,
DC6F394621B897AD00897AD8 /* exception */,
DC73BD871915E5E3003FAFAD /* FBSurface.cxx */,
DC73BD881915E5E3003FAFAD /* FBSurface.hxx */,
2D733D70062895B2006265D9 /* FrameBuffer.cxx */,
@ -2066,6 +2077,15 @@
path = zlib;
sourceTree = "<group>";
};
DC6F394621B897AD00897AD8 /* exception */ = {
isa = PBXGroup;
children = (
DC6F394721B897C700897AD8 /* FatalEmulationError.cxx */,
DC6F394821B897C700897AD8 /* FatalEmulationError.hxx */,
);
name = exception;
sourceTree = "<group>";
};
DCC467EA14FBEC9600E15508 /* tv_filters */ = {
isa = PBXGroup;
children = (
@ -2373,6 +2393,7 @@
DC6DC91F205DB879004A5FC3 /* PhysicalJoystick.hxx in Headers */,
DC0984860D3985160073C852 /* CartSB.hxx in Headers */,
DCEC585E1E945175002F0246 /* DelayQueueIterator.hxx in Headers */,
DC6F394A21B897C700897AD8 /* FatalEmulationError.hxx in Headers */,
DCA23AEA0D75B22500F77B33 /* CartX07.hxx in Headers */,
DC4613680D92C03600D8DAB9 /* RomAuditDialog.hxx in Headers */,
DC487FB70DA5350900E12499 /* AtariVox.hxx in Headers */,
@ -2407,6 +2428,7 @@
DCF7B0DE10A762FC007A2870 /* CartF0.hxx in Headers */,
DCF7B0E010A762FC007A2870 /* CartFA.hxx in Headers */,
DCC527D110B9DA19005E1287 /* Device.hxx in Headers */,
DC6F394E21B897F300897AD8 /* ThreadDebugging.hxx in Headers */,
DCC527D310B9DA19005E1287 /* M6502.hxx in Headers */,
DC3EE8661E2C0E6D00905161 /* inflate.h in Headers */,
DCC527D510B9DA19005E1287 /* NullDev.hxx in Headers */,
@ -2697,6 +2719,7 @@
2D9174B609BA90380026E9FF /* Menu.cxx in Sources */,
CFE3F60D1E84A9A200A8204E /* CartCDFWidget.cxx in Sources */,
2D9174B709BA90380026E9FF /* OptionsDialog.cxx in Sources */,
DC6F394921B897C700897AD8 /* FatalEmulationError.cxx in Sources */,
2D9174B809BA90380026E9FF /* PopUpWidget.cxx in Sources */,
DCBDDE9A1D6A5F0E009DF1E9 /* Cart3EPlusWidget.cxx in Sources */,
DCE9158B201543B900960CC0 /* TimeLineWidget.cxx in Sources */,
@ -2835,6 +2858,7 @@
E0306E0F1F93E916003DDD52 /* JitterEmulation.cxx in Sources */,
DCD6FC7C11C281ED005DA767 /* pngset.c in Sources */,
DCD6FC7E11C281ED005DA767 /* pngtrans.c in Sources */,
DC6F394D21B897F300897AD8 /* ThreadDebugging.cxx in Sources */,
DCD6FC7F11C281ED005DA767 /* pngwio.c in Sources */,
DCD6FC8011C281ED005DA767 /* pngwrite.c in Sources */,
DC3EE8621E2C0E6D00905161 /* inffast.c in Sources */,

View File

@ -110,7 +110,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BSPF_WINDOWS;WIN32;NDEBUG;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>BSPF_WINDOWS;WIN32;DEBUG_BUILD;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@ -145,7 +145,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BSPF_WINDOWS;WIN32;NDEBUG;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>BSPF_WINDOWS;WIN32;DEBUG_BUILD;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@ -261,6 +261,7 @@
<ClCompile Include="..\common\PKeyboardHandler.cxx" />
<ClCompile Include="..\common\RewindManager.cxx" />
<ClCompile Include="..\common\StateManager.cxx" />
<ClCompile Include="..\common\ThreadDebugging.cxx" />
<ClCompile Include="..\common\TimerManager.cxx" />
<ClCompile Include="..\common\tv_filters\AtariNTSC.cxx" />
<ClCompile Include="..\common\tv_filters\NTSCFilter.cxx" />
@ -349,6 +350,7 @@
<ClCompile Include="..\emucore\DispatchResult.cxx" />
<ClCompile Include="..\emucore\EmulationTiming.cxx" />
<ClCompile Include="..\emucore\EmulationWorker.cxx" />
<ClCompile Include="..\emucore\exception\FatalEmulationError.cxx" />
<ClCompile Include="..\emucore\FBSurface.cxx" />
<ClCompile Include="..\emucore\MindLink.cxx" />
<ClCompile Include="..\emucore\PointingDevice.cxx" />
@ -832,6 +834,7 @@
<ClInclude Include="..\common\StateManager.hxx" />
<ClInclude Include="..\common\StellaKeys.hxx" />
<ClInclude Include="..\common\StringParser.hxx" />
<ClInclude Include="..\common\ThreadDebugging.hxx" />
<ClInclude Include="..\common\TimerManager.hxx" />
<ClInclude Include="..\common\tv_filters\AtariNTSC.hxx" />
<ClInclude Include="..\common\tv_filters\NTSCFilter.hxx" />
@ -929,6 +932,7 @@
<ClInclude Include="..\emucore\EmulationTiming.hxx" />
<ClInclude Include="..\emucore\EmulationWorker.hxx" />
<ClInclude Include="..\emucore\EventHandlerConstants.hxx" />
<ClInclude Include="..\emucore\exception\FatalEmulationError.hxx" />
<ClInclude Include="..\emucore\FBSurface.hxx" />
<ClInclude Include="..\emucore\FrameBufferConstants.hxx" />
<ClInclude Include="..\emucore\MindLink.hxx" />

View File

@ -61,6 +61,12 @@
<Filter Include="Source Files\audio">
<UniqueIdentifier>{000e4a6b-8cd6-43db-8253-8255c7efa706}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\emucore\exception">
<UniqueIdentifier>{fb5429b5-4ffb-4574-a98d-54ba865e4199}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\emucore\exception">
<UniqueIdentifier>{e4a56aea-89f9-4680-a6b4-b26ec4799e1c}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\common\FrameBufferSDL2.cxx">
@ -942,6 +948,12 @@
<ClCompile Include="..\emucore\Bankswitch.cxx">
<Filter>Source Files\emucore</Filter>
</ClCompile>
<ClCompile Include="..\emucore\exception\FatalEmulationError.cxx">
<Filter>Source Files\emucore\exception</Filter>
</ClCompile>
<ClCompile Include="..\common\ThreadDebugging.cxx">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\bspf.hxx">
@ -1922,6 +1934,12 @@
<ClInclude Include="..\emucore\Bankswitch.hxx">
<Filter>Header Files\emucore</Filter>
</ClInclude>
<ClInclude Include="..\emucore\exception\FatalEmulationError.hxx">
<Filter>Header Files\emucore\exception</Filter>
</ClInclude>
<ClInclude Include="..\common\ThreadDebugging.hxx">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="stella.ico">