mirror of https://github.com/stella-emu/stella.git
The long march to converting Stella to C++11 has finally started. Already,
I've found and fixed a few memory leaks. You will need an up-to-date compiler. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3031 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
bd1a391eb3
commit
79ada8685c
12
Changes.txt
12
Changes.txt
|
@ -12,6 +12,16 @@
|
||||||
Release History
|
Release History
|
||||||
===========================================================================
|
===========================================================================
|
||||||
|
|
||||||
|
4.2 to 4.3: (December xx, 2014)
|
||||||
|
|
||||||
|
* The conversion to C++11 has begun :) From this point on, to build
|
||||||
|
Stella you will need a C++11 compatible compiler (Visual Studio 2013,
|
||||||
|
Clang 3.5, gcc 4.9, etc). Eventually, this will bring more bug-free
|
||||||
|
and (hopefully) faster code.
|
||||||
|
|
||||||
|
-Have fun!
|
||||||
|
|
||||||
|
|
||||||
4.1.1 to 4.2: (October 28, 2014)
|
4.1.1 to 4.2: (October 28, 2014)
|
||||||
|
|
||||||
* Text input from non-US keyboard layouts is now supported. Note that
|
* Text input from non-US keyboard layouts is now supported. Note that
|
||||||
|
@ -42,8 +52,6 @@
|
||||||
* The Linux port now uses an app-icon; this seems to be needed for
|
* The Linux port now uses an app-icon; this seems to be needed for
|
||||||
some window managers.
|
some window managers.
|
||||||
|
|
||||||
-Have fun!
|
|
||||||
|
|
||||||
|
|
||||||
4.1 to 4.1.1: (September 14, 2014)
|
4.1 to 4.1.1: (September 14, 2014)
|
||||||
|
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -51,7 +51,7 @@ else
|
||||||
endif
|
endif
|
||||||
CXXFLAGS+= -Wall
|
CXXFLAGS+= -Wall
|
||||||
ifdef HAVE_GCC
|
ifdef HAVE_GCC
|
||||||
CXXFLAGS+= -Wno-multichar -Wunused -fno-rtti -Woverloaded-virtual
|
CXXFLAGS+= -Wno-multichar -Wunused -fno-rtti -Woverloaded-virtual -std=c++11
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef PROFILE
|
ifdef PROFILE
|
||||||
|
|
|
@ -281,11 +281,8 @@ void CheatManager::saveCheatDatabase()
|
||||||
if(!out)
|
if(!out)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CheatCodeMap::iterator iter;
|
for(const auto& iter: myCheatMap)
|
||||||
for(iter = myCheatMap.begin(); iter != myCheatMap.end(); ++iter)
|
out << "\"" << iter.first << "\" " << "\"" << iter.second << "\"" << endl;
|
||||||
out << "\"" << iter->first << "\" "
|
|
||||||
<< "\"" << iter->second << "\""
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
@ -302,7 +299,7 @@ void CheatManager::loadCheats(const string& md5sum)
|
||||||
if(cheats != "")
|
if(cheats != "")
|
||||||
myOSystem.settings().setValue("cheat", "");
|
myOSystem.settings().setValue("cheat", "");
|
||||||
|
|
||||||
CheatCodeMap::iterator iter = myCheatMap.find(md5sum);
|
const auto& iter = myCheatMap.find(md5sum);
|
||||||
if(iter == myCheatMap.end() && cheats == "")
|
if(iter == myCheatMap.end() && cheats == "")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -99,8 +99,6 @@ SoundSDL2::~SoundSDL2()
|
||||||
SDL_CloseAudio();
|
SDL_CloseAudio();
|
||||||
myIsEnabled = myIsInitializedFlag = false;
|
myIsEnabled = myIsInitializedFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
myOSystem.logMessage("SoundSDL2 destroyed", 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -110,18 +111,22 @@ static const string EmptyString("");
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Some convenience functions
|
// Some convenience functions
|
||||||
|
|
||||||
|
// Initialize C++11 unique_ptr, at least until std::make_unique()
|
||||||
|
// becomes part of the standard (C++14)
|
||||||
|
template <typename Value, typename ... Arguments>
|
||||||
|
std::unique_ptr<Value> make_ptr(Arguments && ... arguments_for_constructor)
|
||||||
|
{
|
||||||
|
return std::unique_ptr<Value>(
|
||||||
|
new Value(std::forward<Arguments>(arguments_for_constructor)...)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T> inline void BSPF_swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
|
template<typename T> inline void BSPF_swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
|
||||||
template<typename T> inline T BSPF_abs (T x) { return (x>=0) ? x : -x; }
|
template<typename T> inline T BSPF_abs (T x) { return (x>=0) ? x : -x; }
|
||||||
template<typename T> inline T BSPF_min (T a, T b) { return (a<b) ? a : b; }
|
template<typename T> inline T BSPF_min (T a, T b) { return (a<b) ? a : b; }
|
||||||
template<typename T> inline T BSPF_max (T a, T b) { return (a>b) ? a : b; }
|
template<typename T> inline T BSPF_max (T a, T b) { return (a>b) ? a : b; }
|
||||||
template<typename T> inline T BSPF_clamp (T a, T l, T u) { return (a<l) ? l : (a>u) ? u : a; }
|
template<typename T> inline T BSPF_clamp (T a, T l, T u) { return (a<l) ? l : (a>u) ? u : a; }
|
||||||
|
|
||||||
// Test whether two characters are equal (case insensitive)
|
|
||||||
static bool BSPF_equalsIgnoreCaseChar(char ch1, char ch2)
|
|
||||||
{
|
|
||||||
return toupper((unsigned char)ch1) == toupper((unsigned char)ch2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare two strings, ignoring case
|
// Compare two strings, ignoring case
|
||||||
inline int BSPF_compareIgnoreCase(const string& s1, const string& s2)
|
inline int BSPF_compareIgnoreCase(const string& s1, const string& s2)
|
||||||
{
|
{
|
||||||
|
@ -168,8 +173,10 @@ inline bool BSPF_equalsIgnoreCase(const string& s1, const string& s2)
|
||||||
// starting from 'startpos' in the first string
|
// starting from 'startpos' in the first string
|
||||||
inline size_t BSPF_findIgnoreCase(const string& s1, const string& s2, int startpos = 0)
|
inline size_t BSPF_findIgnoreCase(const string& s1, const string& s2, int startpos = 0)
|
||||||
{
|
{
|
||||||
string::const_iterator pos = std::search(s1.begin()+startpos, s1.end(),
|
auto pos = std::search(s1.begin()+startpos, s1.end(),
|
||||||
s2.begin(), s2.end(), BSPF_equalsIgnoreCaseChar);
|
s2.begin(), s2.end(), [](char ch1, char ch2) {
|
||||||
|
return toupper((unsigned char)ch1) == toupper((unsigned char)ch2);
|
||||||
|
});
|
||||||
return pos == s1.end() ? string::npos : pos - (s1.begin()+startpos);
|
return pos == s1.end() ? string::npos : pos - (s1.begin()+startpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <SDL.h>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
@ -42,7 +41,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Pointer to the main parent osystem object or the null pointer
|
// Pointer to the main parent osystem object or the null pointer
|
||||||
OSystem* theOSystem = (OSystem*) NULL;
|
unique_ptr<OSystem> theOSystem;
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// Does general Cleanup in case any operation failed (or at end of program)
|
// Does general Cleanup in case any operation failed (or at end of program)
|
||||||
|
@ -51,12 +50,6 @@ int Cleanup()
|
||||||
theOSystem->logMessage("Cleanup from mainSDL", 2);
|
theOSystem->logMessage("Cleanup from mainSDL", 2);
|
||||||
theOSystem->saveConfig();
|
theOSystem->saveConfig();
|
||||||
|
|
||||||
if(theOSystem)
|
|
||||||
delete theOSystem;
|
|
||||||
|
|
||||||
if(SDL_WasInit(SDL_INIT_VIDEO) & SDL_INIT_VIDEO)
|
|
||||||
SDL_Quit();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,13 +157,6 @@ int main(int argc, char* argv[])
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Swallow any spurious events in the queue
|
|
||||||
// These are normally caused by joystick/mouse jitter
|
|
||||||
SDL_Event event;
|
|
||||||
while(SDL_PollEvent(&event)) /* swallow event */ ;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Start the main loop, and don't exit until the user issues a QUIT command
|
// Start the main loop, and don't exit until the user issues a QUIT command
|
||||||
theOSystem->logMessage("Starting main loop ...", 2);
|
theOSystem->logMessage("Starting main loop ...", 2);
|
||||||
theOSystem->mainLoop();
|
theOSystem->mainLoop();
|
||||||
|
|
|
@ -260,15 +260,15 @@ bool CartDebug::disassemble(bool force)
|
||||||
// $bxxx, it must be changed
|
// $bxxx, it must be changed
|
||||||
uInt16 offset = (PC - (PC % 0x1000));
|
uInt16 offset = (PC - (PC % 0x1000));
|
||||||
AddressList& addresses = info.addressList;
|
AddressList& addresses = info.addressList;
|
||||||
for(list<uInt16>::iterator i = addresses.begin(); i != addresses.end(); ++i)
|
for(auto& i: addresses)
|
||||||
*i = (*i & 0xFFF) + offset;
|
i = (i & 0xFFF) + offset;
|
||||||
|
|
||||||
// Only add addresses when absolutely necessary, to cut down on the
|
// Only add addresses when absolutely necessary, to cut down on the
|
||||||
// work that Distella has to do
|
// work that Distella has to do
|
||||||
// Distella expects the addresses to be unique and in sorted order
|
// Distella expects the addresses to be unique and in sorted order
|
||||||
if(bankChanged || !pcfound)
|
if(bankChanged || !pcfound)
|
||||||
{
|
{
|
||||||
AddressList::iterator i;
|
AddressList::const_iterator i;
|
||||||
for(i = addresses.begin(); i != addresses.end(); ++i)
|
for(i = addresses.begin(); i != addresses.end(); ++i)
|
||||||
{
|
{
|
||||||
if(PC < *i)
|
if(PC < *i)
|
||||||
|
@ -339,7 +339,7 @@ int CartDebug::addressToLine(uInt16 address) const
|
||||||
if(!myAddrToLineIsROM != !(address & 0x1000))
|
if(!myAddrToLineIsROM != !(address & 0x1000))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
map<uInt16, int>::const_iterator iter = myAddrToLineList.find(address & 0xFFF);
|
const auto& iter = myAddrToLineList.find(address & 0xFFF);
|
||||||
return iter != myAddrToLineList.end() ? iter->second : -1;
|
return iter != myAddrToLineList.end() ? iter->second : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,16 +390,6 @@ string CartDebug::disassemble(uInt16 start, uInt16 lines) const
|
||||||
bool CartDebug::addDirective(CartDebug::DisasmType type,
|
bool CartDebug::addDirective(CartDebug::DisasmType type,
|
||||||
uInt16 start, uInt16 end, int bank)
|
uInt16 start, uInt16 end, int bank)
|
||||||
{
|
{
|
||||||
#define PRINT_TAG(tag) \
|
|
||||||
disasmTypeAsString(cerr, tag.type); \
|
|
||||||
cerr << ": start = " << tag.start << ", end = " << tag.end << endl;
|
|
||||||
|
|
||||||
#define PRINT_LIST(header) \
|
|
||||||
cerr << header << endl; \
|
|
||||||
for(DirectiveList::const_iterator d = list.begin(); d != list.end(); ++d) { \
|
|
||||||
PRINT_TAG((*d)); } \
|
|
||||||
cerr << endl;
|
|
||||||
|
|
||||||
if(end < start || start == 0 || end == 0)
|
if(end < start || start == 0 || end == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -525,24 +515,6 @@ bool CartDebug::addDirective(CartDebug::DisasmType type,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
int CartDebug::getBank()
|
|
||||||
{
|
|
||||||
return myConsole.cartridge().getBank();
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
int CartDebug::bankCount() const
|
|
||||||
{
|
|
||||||
return myConsole.cartridge().bankCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
string CartDebug::getCartType() const
|
|
||||||
{
|
|
||||||
return myConsole.cartridge().name();
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool CartDebug::addLabel(const string& label, uInt16 address)
|
bool CartDebug::addLabel(const string& label, uInt16 address)
|
||||||
{
|
{
|
||||||
|
@ -814,7 +786,7 @@ string CartDebug::loadSymbolFile()
|
||||||
{
|
{
|
||||||
// Make sure the value doesn't represent a constant
|
// Make sure the value doesn't represent a constant
|
||||||
// For now, we simply ignore constants completely
|
// For now, we simply ignore constants completely
|
||||||
AddrToLabel::const_iterator iter = myUserCLabels.find(value);
|
const auto& iter = myUserCLabels.find(value);
|
||||||
if(iter == myUserCLabels.end() || !BSPF_equalsIgnoreCase(label, iter->second))
|
if(iter == myUserCLabels.end() || !BSPF_equalsIgnoreCase(label, iter->second))
|
||||||
{
|
{
|
||||||
// Check for period, and strip leading number
|
// Check for period, and strip leading number
|
||||||
|
@ -865,11 +837,8 @@ string CartDebug::loadConfigFile()
|
||||||
return "Unable to load directives from " + node.getPath();
|
return "Unable to load directives from " + node.getPath();
|
||||||
|
|
||||||
// Erase all previous directives
|
// Erase all previous directives
|
||||||
for(Common::Array<BankInfo>::iterator bi = myBankInfo.begin();
|
for(auto& bi: myBankInfo)
|
||||||
bi != myBankInfo.end(); ++bi)
|
bi.directiveList.clear();
|
||||||
{
|
|
||||||
bi->directiveList.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentbank = 0;
|
int currentbank = 0;
|
||||||
while(!in.eof())
|
while(!in.eof())
|
||||||
|
@ -1167,14 +1136,13 @@ string CartDebug::saveDisassembly()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddrToLabel::const_iterator iter;
|
|
||||||
if(myReserved.Label.size() > 0)
|
if(myReserved.Label.size() > 0)
|
||||||
{
|
{
|
||||||
out << "\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
|
out << "\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
|
||||||
<< "; NON LOCATABLE\n"
|
<< "; NON LOCATABLE\n"
|
||||||
<< ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n";
|
<< ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n";
|
||||||
for(iter = myReserved.Label.begin(); iter != myReserved.Label.end(); ++iter)
|
for(const auto& iter: myReserved.Label)
|
||||||
out << ALIGN(10) << iter->second << " = $" << iter->first << "\n";
|
out << ALIGN(10) << iter.second << " = $" << iter.first << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(myUserLabels.size() > 0)
|
if(myUserLabels.size() > 0)
|
||||||
|
@ -1183,10 +1151,10 @@ string CartDebug::saveDisassembly()
|
||||||
<< "; USER DEFINED\n"
|
<< "; USER DEFINED\n"
|
||||||
<< ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n";
|
<< ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n";
|
||||||
int max_len = 0;
|
int max_len = 0;
|
||||||
for(iter = myUserLabels.begin(); iter != myUserLabels.end(); ++iter)
|
for(const auto& iter: myUserLabels)
|
||||||
max_len = BSPF_max(max_len, (int)iter->second.size());
|
max_len = BSPF_max(max_len, (int)iter.second.size());
|
||||||
for(iter = myUserLabels.begin(); iter != myUserLabels.end(); ++iter)
|
for(const auto& iter: myUserLabels)
|
||||||
out << ALIGN(max_len) << iter->second << " = $" << iter->first << "\n";
|
out << ALIGN(max_len) << iter.second << " = $" << iter.first << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// And finally, output the disassembly
|
// And finally, output the disassembly
|
||||||
|
@ -1230,14 +1198,13 @@ string CartDebug::listConfig(int bank)
|
||||||
{
|
{
|
||||||
BankInfo& info = myBankInfo[b];
|
BankInfo& info = myBankInfo[b];
|
||||||
buf << "[" << b << "]" << endl;
|
buf << "[" << b << "]" << endl;
|
||||||
for(DirectiveList::const_iterator i = info.directiveList.begin();
|
for(const auto& i: info.directiveList)
|
||||||
i != info.directiveList.end(); ++i)
|
|
||||||
{
|
{
|
||||||
if(i->type != CartDebug::NONE)
|
if(i.type != CartDebug::NONE)
|
||||||
{
|
{
|
||||||
buf << "(*) ";
|
buf << "(*) ";
|
||||||
disasmTypeAsString(buf, i->type);
|
disasmTypeAsString(buf, i.type);
|
||||||
buf << " " << Base::HEX4 << i->start << " " << Base::HEX4 << i->end << endl;
|
buf << " " << Base::HEX4 << i.start << " " << Base::HEX4 << i.end << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getBankDirectives(buf, info);
|
getBankDirectives(buf, info);
|
||||||
|
@ -1291,9 +1258,9 @@ void CartDebug::getCompletions(const char* in, StringList& completions) const
|
||||||
|
|
||||||
// Now scan user-defined labels
|
// Now scan user-defined labels
|
||||||
LabelToAddr::const_iterator iter;
|
LabelToAddr::const_iterator iter;
|
||||||
for(iter = myUserAddresses.begin(); iter != myUserAddresses.end(); ++iter)
|
for(const auto& iter: myUserAddresses)
|
||||||
{
|
{
|
||||||
const char* l = iter->first.c_str();
|
const char* l = iter.first.c_str();
|
||||||
if(BSPF_startsWithIgnoreCase(l, in))
|
if(BSPF_startsWithIgnoreCase(l, in))
|
||||||
completions.push_back(l);
|
completions.push_back(l);
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,19 +182,20 @@ class CartDebug : public DebuggerSystem
|
||||||
// The following are convenience methods that query the cartridge object
|
// The following are convenience methods that query the cartridge object
|
||||||
// for the desired information.
|
// for the desired information.
|
||||||
/**
|
/**
|
||||||
Get the current bank in use by the cartridge.
|
Get the current bank in use by the cartridge
|
||||||
|
(non-const because of use in YaccParser)
|
||||||
*/
|
*/
|
||||||
int getBank(); // non-const because of use in YaccParser
|
int getBank() { return myConsole.cartridge().getBank(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the total number of banks supported by the cartridge.
|
Get the total number of banks supported by the cartridge.
|
||||||
*/
|
*/
|
||||||
int bankCount() const;
|
int bankCount() const { return myConsole.cartridge().bankCount(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the name/type of the cartridge.
|
Get the name/type of the cartridge. // FIXME - dead code
|
||||||
*/
|
*/
|
||||||
string getCartType() const; // FIXME - dead code
|
string getCartType() const { return myConsole.cartridge().name(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Add a label and associated address.
|
Add a label and associated address.
|
||||||
|
@ -303,8 +304,8 @@ class CartDebug : public DebuggerSystem
|
||||||
<< endl
|
<< endl
|
||||||
<< "addrlist: ";
|
<< "addrlist: ";
|
||||||
AddressList::const_iterator i;
|
AddressList::const_iterator i;
|
||||||
for(i = b.addressList.begin(); i != b.addressList.end(); ++i)
|
for(const auto& i: addressList)
|
||||||
os << HEX4 << *i << " ";
|
os << HEX4 << i << " ";
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -557,14 +557,14 @@ bool Debugger::addFunction(const string& name, const string& definition,
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool Debugger::delFunction(const string& name)
|
bool Debugger::delFunction(const string& name)
|
||||||
{
|
{
|
||||||
FunctionMap::iterator iter = functions.find(name);
|
const auto& iter = functions.find(name);
|
||||||
if(iter == functions.end())
|
if(iter == functions.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
functions.erase(name);
|
functions.erase(name);
|
||||||
delete iter->second;
|
delete iter->second;
|
||||||
|
|
||||||
FunctionDefMap::iterator def_iter = functionDefs.find(name);
|
const auto& def_iter = functionDefs.find(name);
|
||||||
if(def_iter == functionDefs.end())
|
if(def_iter == functionDefs.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -575,21 +575,15 @@ bool Debugger::delFunction(const string& name)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const Expression* Debugger::getFunction(const string& name) const
|
const Expression* Debugger::getFunction(const string& name) const
|
||||||
{
|
{
|
||||||
FunctionMap::const_iterator iter = functions.find(name);
|
const auto& iter = functions.find(name);
|
||||||
if(iter == functions.end())
|
return iter != functions.end() ? iter->second : nullptr;
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return iter->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const string& Debugger::getFunctionDef(const string& name) const
|
const string& Debugger::getFunctionDef(const string& name) const
|
||||||
{
|
{
|
||||||
FunctionDefMap::const_iterator iter = functionDefs.find(name);
|
const auto& iter = functionDefs.find(name);
|
||||||
if(iter == functionDefs.end())
|
return iter != functionDefs.end() ? iter->second : EmptyString;
|
||||||
return EmptyString;
|
|
||||||
else
|
|
||||||
return iter->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -647,10 +641,9 @@ string Debugger::builtinHelp() const
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Debugger::getCompletions(const char* in, StringList& list) const
|
void Debugger::getCompletions(const char* in, StringList& list) const
|
||||||
{
|
{
|
||||||
FunctionMap::const_iterator iter;
|
for(const auto& iter: functions)
|
||||||
for(iter = functions.begin(); iter != functions.end(); ++iter)
|
|
||||||
{
|
{
|
||||||
const char* l = iter->first.c_str();
|
const char* l = iter.first.c_str();
|
||||||
if(BSPF_equalsIgnoreCase(l, in))
|
if(BSPF_equalsIgnoreCase(l, in))
|
||||||
list.push_back(l);
|
list.push_back(l);
|
||||||
}
|
}
|
||||||
|
|
|
@ -602,17 +602,18 @@ bool DebuggerParser::saveScriptFile(string file)
|
||||||
ofstream out(file.c_str());
|
ofstream out(file.c_str());
|
||||||
|
|
||||||
FunctionDefMap funcs = debugger.getFunctionDefMap();
|
FunctionDefMap funcs = debugger.getFunctionDefMap();
|
||||||
for(FunctionDefMap::const_iterator i = funcs.begin(); i != funcs.end(); ++i)
|
for(const auto& i: funcs)
|
||||||
out << "function " << i->first << " { " << i->second << " }" << endl;
|
out << "function " << i.first << " { " << i.second << " }" << endl;
|
||||||
|
|
||||||
for(unsigned int i=0; i<watches.size(); i++)
|
for(const auto& i: watches)
|
||||||
out << "watch " << watches[i] << endl;
|
out << "watch " << i << endl;
|
||||||
|
|
||||||
for(unsigned int i=0; i<0x10000; i++)
|
for(uInt32 i = 0; i < 0x10000; ++i)
|
||||||
if(debugger.breakPoint(i))
|
if(debugger.breakPoint(i))
|
||||||
out << "break #" << i << endl;
|
out << "break #" << i << endl;
|
||||||
|
|
||||||
for(unsigned int i=0; i<0x10000; i++) {
|
for(uInt32 i = 0; i < 0x10000; ++i)
|
||||||
|
{
|
||||||
bool r = debugger.readTrap(i);
|
bool r = debugger.readTrap(i);
|
||||||
bool w = debugger.writeTrap(i);
|
bool w = debugger.writeTrap(i);
|
||||||
|
|
||||||
|
@ -625,8 +626,8 @@ bool DebuggerParser::saveScriptFile(string file)
|
||||||
}
|
}
|
||||||
|
|
||||||
StringList conds = debugger.cpuDebug().m6502().getCondBreakNames();
|
StringList conds = debugger.cpuDebug().m6502().getCondBreakNames();
|
||||||
for(unsigned int i=0; i<conds.size(); i++)
|
for(const auto& cond: conds)
|
||||||
out << "breakif {" << conds[i] << "}" << endl;
|
out << "breakif {" << cond << "}" << endl;
|
||||||
|
|
||||||
bool ok = out.good();
|
bool ok = out.good();
|
||||||
out.close();
|
out.close();
|
||||||
|
@ -917,11 +918,11 @@ void DebuggerParser::executeDisasm()
|
||||||
// "dump"
|
// "dump"
|
||||||
void DebuggerParser::executeDump()
|
void DebuggerParser::executeDump()
|
||||||
{
|
{
|
||||||
for(int i=0; i<8; i++)
|
for(int i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
int start = args[0] + i*16;
|
int start = args[0] + i*16;
|
||||||
commandResult << Base::toString(start) << ": ";
|
commandResult << Base::toString(start) << ": ";
|
||||||
for(int j = 0; j < 16; j++)
|
for(int j = 0; j < 16; ++j)
|
||||||
{
|
{
|
||||||
commandResult << Base::toString(debugger.peek(start+j)) << " ";
|
commandResult << Base::toString(debugger.peek(start+j)) << " ";
|
||||||
if(j == 7) commandResult << "- ";
|
if(j == 7) commandResult << "- ";
|
||||||
|
@ -1046,7 +1047,7 @@ void DebuggerParser::executeListbreaks()
|
||||||
ostringstream buf;
|
ostringstream buf;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < 0x10000; i++)
|
for(uInt32 i = 0; i < 0x10000; i++)
|
||||||
{
|
{
|
||||||
if(debugger.breakpoints().isSet(i))
|
if(debugger.breakpoints().isSet(i))
|
||||||
{
|
{
|
||||||
|
@ -1068,7 +1069,7 @@ void DebuggerParser::executeListbreaks()
|
||||||
if(conds.size() > 0)
|
if(conds.size() > 0)
|
||||||
{
|
{
|
||||||
commandResult << "\nbreakifs:\n";
|
commandResult << "\nbreakifs:\n";
|
||||||
for(unsigned int i = 0; i < conds.size(); i++)
|
for(uInt32 i = 0; i < conds.size(); i++)
|
||||||
{
|
{
|
||||||
commandResult << i << ": " << conds[i];
|
commandResult << i << ": " << conds[i];
|
||||||
if(i != (conds.size() - 1)) commandResult << endl;
|
if(i != (conds.size() - 1)) commandResult << endl;
|
||||||
|
@ -1097,9 +1098,8 @@ void DebuggerParser::executeListfunctions()
|
||||||
|
|
||||||
if(functions.size() > 0)
|
if(functions.size() > 0)
|
||||||
{
|
{
|
||||||
FunctionDefMap::const_iterator iter;
|
for(const auto& iter: functions)
|
||||||
for(iter = functions.begin(); iter != functions.end(); ++iter)
|
commandResult << iter.first << " -> " << iter.second << endl;
|
||||||
commandResult << iter->first << " -> " << iter->second << endl;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
commandResult << "no user-defined functions";
|
commandResult << "no user-defined functions";
|
||||||
|
@ -1111,7 +1111,7 @@ void DebuggerParser::executeListtraps()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for(unsigned int i=0; i<0x10000; i++)
|
for(uInt32 i = 0; i < 0x10000; ++i)
|
||||||
{
|
{
|
||||||
if(debugger.readTrap(i) || debugger.writeTrap(i))
|
if(debugger.readTrap(i) || debugger.writeTrap(i))
|
||||||
{
|
{
|
||||||
|
@ -1231,7 +1231,7 @@ void DebuggerParser::executeRiot()
|
||||||
void DebuggerParser::executeRom()
|
void DebuggerParser::executeRom()
|
||||||
{
|
{
|
||||||
int addr = args[0];
|
int addr = args[0];
|
||||||
for(int i=1; i<argCount; i++)
|
for(int i = 1; i < argCount; ++i)
|
||||||
{
|
{
|
||||||
if( !(debugger.patchROM(addr++, args[i])) )
|
if( !(debugger.patchROM(addr++, args[i])) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1051,10 +1051,8 @@ DONE_WITH_ADD:
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void DiStella::processDirectives(const CartDebug::DirectiveList& directives)
|
void DiStella::processDirectives(const CartDebug::DirectiveList& directives)
|
||||||
{
|
{
|
||||||
for(CartDebug::DirectiveList::const_iterator i = directives.begin();
|
for(const auto& tag: directives)
|
||||||
i != directives.end(); ++i)
|
|
||||||
{
|
{
|
||||||
const CartDebug::DirectiveTag& tag = *i;
|
|
||||||
if(check_range(tag.start, tag.end))
|
if(check_range(tag.start, tag.end))
|
||||||
for(uInt32 k = tag.start; k <= tag.end; ++k)
|
for(uInt32 k = tag.start; k <= tag.end; ++k)
|
||||||
mark(k, tag.type, true);
|
mark(k, tag.type, true);
|
||||||
|
|
|
@ -72,8 +72,6 @@ Console::Console(OSystem& osystem, Cartridge& cart, const Properties& props)
|
||||||
myEvent(osystem.eventHandler().event()),
|
myEvent(osystem.eventHandler().event()),
|
||||||
myProperties(props),
|
myProperties(props),
|
||||||
myTIA(0),
|
myTIA(0),
|
||||||
mySwitches(0),
|
|
||||||
mySystem(0),
|
|
||||||
myCMHandler(0),
|
myCMHandler(0),
|
||||||
myDisplayFormat(""), // Unknown TV format @ start
|
myDisplayFormat(""), // Unknown TV format @ start
|
||||||
myFramerate(0.0), // Unknown framerate @ start
|
myFramerate(0.0), // Unknown framerate @ start
|
||||||
|
@ -84,10 +82,10 @@ Console::Console(OSystem& osystem, Cartridge& cart, const Properties& props)
|
||||||
loadUserPalette();
|
loadUserPalette();
|
||||||
|
|
||||||
// Create switches for the console
|
// Create switches for the console
|
||||||
mySwitches = new Switches(myEvent, myProperties);
|
mySwitches = make_ptr<Switches>(myEvent, myProperties);
|
||||||
|
|
||||||
// Construct the system and components
|
// Construct the system and components
|
||||||
mySystem = new System(osystem);
|
mySystem = make_ptr<System>(osystem);
|
||||||
|
|
||||||
// The real controllers for this console will be added later
|
// The real controllers for this console will be added later
|
||||||
// For now, we just add dummy joystick controllers, since autodetection
|
// For now, we just add dummy joystick controllers, since autodetection
|
||||||
|
@ -176,8 +174,6 @@ Console::Console(OSystem& osystem, Cartridge& cart, const Properties& props)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Console::~Console()
|
Console::~Console()
|
||||||
{
|
{
|
||||||
delete mySystem;
|
|
||||||
delete mySwitches;
|
|
||||||
delete myCMHandler;
|
delete myCMHandler;
|
||||||
delete myControllers[0];
|
delete myControllers[0];
|
||||||
delete myControllers[1];
|
delete myControllers[1];
|
||||||
|
|
|
@ -346,10 +346,10 @@ class Console : public Serializable
|
||||||
TIA* myTIA;
|
TIA* myTIA;
|
||||||
|
|
||||||
// Pointer to the switches on the front of the console
|
// Pointer to the switches on the front of the console
|
||||||
Switches* mySwitches;
|
unique_ptr<Switches> mySwitches;
|
||||||
|
|
||||||
// Pointer to the 6502 based system being emulated
|
// Pointer to the 6502 based system being emulated
|
||||||
System* mySystem;
|
unique_ptr<System> mySystem;
|
||||||
|
|
||||||
// Pointer to the 6532 (aka RIOT) (the debugger needs it)
|
// Pointer to the 6532 (aka RIOT) (the debugger needs it)
|
||||||
// A RIOT of my own! (...with apologies to The Clash...)
|
// A RIOT of my own! (...with apologies to The Clash...)
|
||||||
|
|
|
@ -58,13 +58,11 @@
|
||||||
EventHandler::EventHandler(OSystem& osystem)
|
EventHandler::EventHandler(OSystem& osystem)
|
||||||
: myOSystem(osystem),
|
: myOSystem(osystem),
|
||||||
myOverlay(NULL),
|
myOverlay(NULL),
|
||||||
myMouseControl(NULL),
|
|
||||||
myState(S_NONE),
|
myState(S_NONE),
|
||||||
myAllowAllDirectionsFlag(false),
|
myAllowAllDirectionsFlag(false),
|
||||||
myFryingFlag(false),
|
myFryingFlag(false),
|
||||||
myUseCtrlKeyFlag(true),
|
myUseCtrlKeyFlag(true),
|
||||||
mySkipMouseMotion(true),
|
mySkipMouseMotion(true)
|
||||||
myJoyHandler(NULL)
|
|
||||||
{
|
{
|
||||||
// Erase the key mapping array
|
// Erase the key mapping array
|
||||||
for(int i = 0; i < KBDK_LAST; ++i)
|
for(int i = 0; i < KBDK_LAST; ++i)
|
||||||
|
@ -77,7 +75,7 @@ EventHandler::EventHandler(OSystem& osystem)
|
||||||
myComboTable[i][j] = Event::NoType;
|
myComboTable[i][j] = Event::NoType;
|
||||||
|
|
||||||
// Create joystick handler (to handle all joystick functionality)
|
// Create joystick handler (to handle all joystick functionality)
|
||||||
myJoyHandler = new JoystickHandler(osystem);
|
myJoyHandler = make_ptr<JoystickHandler>(osystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -90,9 +88,6 @@ EventHandler::~EventHandler()
|
||||||
for(uInt32 i = 0; i < kMenuActionListSize; ++i)
|
for(uInt32 i = 0; i < kMenuActionListSize; ++i)
|
||||||
if(ourMenuActionList[i].key)
|
if(ourMenuActionList[i].key)
|
||||||
free(ourMenuActionList[i].key);
|
free(ourMenuActionList[i].key);
|
||||||
|
|
||||||
delete myMouseControl; myMouseControl = NULL;
|
|
||||||
delete myJoyHandler; myJoyHandler = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -1196,7 +1191,7 @@ void EventHandler::setKeymap()
|
||||||
if(event == Event::LastType && map.size() == KBDK_LAST * kNumModes)
|
if(event == Event::LastType && map.size() == KBDK_LAST * kNumModes)
|
||||||
{
|
{
|
||||||
// Fill the keymap table with events
|
// Fill the keymap table with events
|
||||||
IntArray::const_iterator event = map.begin();
|
auto event = map.begin();
|
||||||
for(int mode = 0; mode < kNumModes; ++mode)
|
for(int mode = 0; mode < kNumModes; ++mode)
|
||||||
for(int i = 0; i < KBDK_LAST; ++i)
|
for(int i = 0; i < KBDK_LAST; ++i)
|
||||||
myKeyTable[i][mode] = (Event::Type) *event++;
|
myKeyTable[i][mode] = (Event::Type) *event++;
|
||||||
|
@ -1781,8 +1776,6 @@ void EventHandler::setMouseControllerMode(const string& enable)
|
||||||
{
|
{
|
||||||
if(myOSystem.hasConsole())
|
if(myOSystem.hasConsole())
|
||||||
{
|
{
|
||||||
delete myMouseControl; myMouseControl = NULL;
|
|
||||||
|
|
||||||
bool usemouse = false;
|
bool usemouse = false;
|
||||||
if(BSPF_equalsIgnoreCase(enable, "always"))
|
if(BSPF_equalsIgnoreCase(enable, "always"))
|
||||||
usemouse = true;
|
usemouse = true;
|
||||||
|
@ -1821,7 +1814,7 @@ void EventHandler::setMouseControllerMode(const string& enable)
|
||||||
const string& control = usemouse ?
|
const string& control = usemouse ?
|
||||||
myOSystem.console().properties().get(Controller_MouseAxis) : "none";
|
myOSystem.console().properties().get(Controller_MouseAxis) : "none";
|
||||||
|
|
||||||
myMouseControl = new MouseControl(myOSystem.console(), control);
|
myMouseControl = make_ptr<MouseControl>(myOSystem.console(), control);
|
||||||
myMouseControl->next(); // set first available mode
|
myMouseControl->next(); // set first available mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -540,7 +540,7 @@ class EventHandler
|
||||||
|
|
||||||
// MouseControl object, which takes care of switching the mouse between
|
// MouseControl object, which takes care of switching the mouse between
|
||||||
// all possible controller modes
|
// all possible controller modes
|
||||||
MouseControl* myMouseControl;
|
unique_ptr<MouseControl> myMouseControl;
|
||||||
|
|
||||||
// Array of key events, indexed by StellaKey
|
// Array of key events, indexed by StellaKey
|
||||||
Event::Type myKeyTable[KBDK_LAST][kNumModes];
|
Event::Type myKeyTable[KBDK_LAST][kNumModes];
|
||||||
|
@ -581,7 +581,7 @@ class EventHandler
|
||||||
static const Event::Type SA_Key[2][12];
|
static const Event::Type SA_Key[2][12];
|
||||||
|
|
||||||
// Handler for all joystick addition/removal/mapping
|
// Handler for all joystick addition/removal/mapping
|
||||||
JoystickHandler* myJoyHandler;
|
unique_ptr<JoystickHandler> myJoyHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -139,7 +139,7 @@ bool EventHandler::StellaJoystick::setMap(const string& m)
|
||||||
if((int)map.size() == numAxes * 2 * kNumModes)
|
if((int)map.size() == numAxes * 2 * kNumModes)
|
||||||
{
|
{
|
||||||
// Fill the axes table with events
|
// Fill the axes table with events
|
||||||
IntArray::const_iterator event = map.begin();
|
auto event = map.begin();
|
||||||
for(int m = 0; m < kNumModes; ++m)
|
for(int m = 0; m < kNumModes; ++m)
|
||||||
for(int a = 0; a < numAxes; ++a)
|
for(int a = 0; a < numAxes; ++a)
|
||||||
for(int k = 0; k < 2; ++k)
|
for(int k = 0; k < 2; ++k)
|
||||||
|
@ -148,7 +148,7 @@ bool EventHandler::StellaJoystick::setMap(const string& m)
|
||||||
getValues(items[2], map);
|
getValues(items[2], map);
|
||||||
if((int)map.size() == numButtons * kNumModes)
|
if((int)map.size() == numButtons * kNumModes)
|
||||||
{
|
{
|
||||||
IntArray::const_iterator event = map.begin();
|
auto event = map.begin();
|
||||||
for(int m = 0; m < kNumModes; ++m)
|
for(int m = 0; m < kNumModes; ++m)
|
||||||
for(int b = 0; b < numButtons; ++b)
|
for(int b = 0; b < numButtons; ++b)
|
||||||
btnTable[b][m] = (Event::Type) *event++;
|
btnTable[b][m] = (Event::Type) *event++;
|
||||||
|
@ -156,7 +156,7 @@ bool EventHandler::StellaJoystick::setMap(const string& m)
|
||||||
getValues(items[3], map);
|
getValues(items[3], map);
|
||||||
if((int)map.size() == numHats * 4 * kNumModes)
|
if((int)map.size() == numHats * 4 * kNumModes)
|
||||||
{
|
{
|
||||||
IntArray::const_iterator event = map.begin();
|
auto event = map.begin();
|
||||||
for(int m = 0; m < kNumModes; ++m)
|
for(int m = 0; m < kNumModes; ++m)
|
||||||
for(int h = 0; h < numHats; ++h)
|
for(int h = 0; h < numHats; ++h)
|
||||||
for(int k = 0; k < 4; ++k)
|
for(int k = 0; k < 4; ++k)
|
||||||
|
@ -260,9 +260,8 @@ EventHandler::JoystickHandler::JoystickHandler(OSystem& system)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
EventHandler::JoystickHandler::~JoystickHandler()
|
EventHandler::JoystickHandler::~JoystickHandler()
|
||||||
{
|
{
|
||||||
map<string,StickInfo>::const_iterator it;
|
for(const auto& i: myDatabase)
|
||||||
for(it = myDatabase.begin(); it != myDatabase.end(); ++it)
|
delete i.second.joy;
|
||||||
delete it->second.joy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -270,14 +269,13 @@ void EventHandler::JoystickHandler::printDatabase() const
|
||||||
{
|
{
|
||||||
cerr << "---------------------------------------------------------" << endl
|
cerr << "---------------------------------------------------------" << endl
|
||||||
<< "joy database:" << endl;
|
<< "joy database:" << endl;
|
||||||
map<string,StickInfo>::const_iterator it;
|
for(const auto& i: myDatabase)
|
||||||
for(it = myDatabase.begin(); it != myDatabase.end(); ++it)
|
cerr << i.first << endl << i.second << endl << endl;
|
||||||
cerr << it->first << endl << it->second << endl << endl;
|
|
||||||
|
|
||||||
cerr << "---------------------------------------------------------" << endl
|
cerr << "---------------------------------------------------------" << endl
|
||||||
<< "joy active:" << endl;
|
<< "joy active:" << endl;
|
||||||
for(uInt32 i = 0; i < mySticks.size(); ++i)
|
for(const auto& i: mySticks)
|
||||||
cerr << *mySticks[i] << endl;
|
cerr << i << endl;
|
||||||
cerr << endl;
|
cerr << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +289,7 @@ int EventHandler::JoystickHandler::add(StellaJoystick* stick)
|
||||||
// Figure out what type of joystick this is
|
// Figure out what type of joystick this is
|
||||||
bool specialAdaptor = false;
|
bool specialAdaptor = false;
|
||||||
|
|
||||||
if(stick->name.find("2600-daptor", 0) != string::npos)
|
if(BSPF_containsIgnoreCase(stick->name, "2600-daptor"))
|
||||||
{
|
{
|
||||||
// 2600-daptorII devices have 3 axes and 12 buttons, and the value of the z-axis
|
// 2600-daptorII devices have 3 axes and 12 buttons, and the value of the z-axis
|
||||||
// determines how those 12 buttons are used (not all buttons are used in all modes)
|
// determines how those 12 buttons are used (not all buttons are used in all modes)
|
||||||
|
@ -306,7 +304,7 @@ int EventHandler::JoystickHandler::add(StellaJoystick* stick)
|
||||||
|
|
||||||
specialAdaptor = true;
|
specialAdaptor = true;
|
||||||
}
|
}
|
||||||
else if(stick->name.find("Stelladaptor", 0) != string::npos)
|
else if(BSPF_containsIgnoreCase(stick->name, "Stelladaptor"))
|
||||||
{
|
{
|
||||||
stick->name = "Stelladaptor";
|
stick->name = "Stelladaptor";
|
||||||
specialAdaptor = true;
|
specialAdaptor = true;
|
||||||
|
@ -315,9 +313,8 @@ int EventHandler::JoystickHandler::add(StellaJoystick* stick)
|
||||||
{
|
{
|
||||||
// We need unique names for mappable devices
|
// We need unique names for mappable devices
|
||||||
int count = 0;
|
int count = 0;
|
||||||
map<string,StickInfo>::const_iterator c_it;
|
for(const auto& i: myDatabase)
|
||||||
for(c_it = myDatabase.begin(); c_it != myDatabase.end(); ++c_it)
|
if(BSPF_startsWithIgnoreCase(i.first, stick->name))
|
||||||
if(BSPF_startsWithIgnoreCase(c_it->first, stick->name))
|
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
if(count > 1)
|
if(count > 1)
|
||||||
|
@ -335,7 +332,7 @@ int EventHandler::JoystickHandler::add(StellaJoystick* stick)
|
||||||
mapStelladaptors(myOSystem.settings().getString("saport"));
|
mapStelladaptors(myOSystem.settings().getString("saport"));
|
||||||
|
|
||||||
// Add stick to database
|
// Add stick to database
|
||||||
map<string,StickInfo>::iterator it = myDatabase.find(stick->name);
|
auto it = myDatabase.find(stick->name);
|
||||||
if(it != myDatabase.end()) // already present
|
if(it != myDatabase.end()) // already present
|
||||||
{
|
{
|
||||||
it->second.joy = stick;
|
it->second.joy = stick;
|
||||||
|
@ -364,7 +361,7 @@ int EventHandler::JoystickHandler::remove(int index)
|
||||||
{
|
{
|
||||||
StellaJoystick* stick = mySticks[index];
|
StellaJoystick* stick = mySticks[index];
|
||||||
|
|
||||||
map<string,StickInfo>::iterator it = myDatabase.find(stick->name);
|
auto it = myDatabase.find(stick->name);
|
||||||
if(it != myDatabase.end() && it->second.joy == stick)
|
if(it != myDatabase.end() && it->second.joy == stick)
|
||||||
{
|
{
|
||||||
ostringstream buf;
|
ostringstream buf;
|
||||||
|
@ -398,33 +395,33 @@ void EventHandler::JoystickHandler::mapStelladaptors(const string& saport)
|
||||||
saOrder[0] = 2; saOrder[1] = 1;
|
saOrder[0] = 2; saOrder[1] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uInt32 i = 0; i < mySticks.size(); ++i)
|
for(auto stick: mySticks)
|
||||||
{
|
{
|
||||||
if(BSPF_startsWithIgnoreCase(mySticks[i]->name, "Stelladaptor"))
|
if(BSPF_startsWithIgnoreCase(stick->name, "Stelladaptor"))
|
||||||
{
|
{
|
||||||
if(saOrder[saCount] == 1)
|
if(saOrder[saCount] == 1)
|
||||||
{
|
{
|
||||||
mySticks[i]->name += " (emulates left joystick port)";
|
stick->name += " (emulates left joystick port)";
|
||||||
mySticks[i]->type = StellaJoystick::JT_STELLADAPTOR_LEFT;
|
stick->type = StellaJoystick::JT_STELLADAPTOR_LEFT;
|
||||||
}
|
}
|
||||||
else if(saOrder[saCount] == 2)
|
else if(saOrder[saCount] == 2)
|
||||||
{
|
{
|
||||||
mySticks[i]->name += " (emulates right joystick port)";
|
stick->name += " (emulates right joystick port)";
|
||||||
mySticks[i]->type = StellaJoystick::JT_STELLADAPTOR_RIGHT;
|
stick->type = StellaJoystick::JT_STELLADAPTOR_RIGHT;
|
||||||
}
|
}
|
||||||
saCount++;
|
saCount++;
|
||||||
}
|
}
|
||||||
else if(BSPF_startsWithIgnoreCase(mySticks[i]->name, "2600-daptor"))
|
else if(BSPF_startsWithIgnoreCase(stick->name, "2600-daptor"))
|
||||||
{
|
{
|
||||||
if(saOrder[saCount] == 1)
|
if(saOrder[saCount] == 1)
|
||||||
{
|
{
|
||||||
mySticks[i]->name += " (emulates left joystick port)";
|
stick->name += " (emulates left joystick port)";
|
||||||
mySticks[i]->type = StellaJoystick::JT_2600DAPTOR_LEFT;
|
stick->type = StellaJoystick::JT_2600DAPTOR_LEFT;
|
||||||
}
|
}
|
||||||
else if(saOrder[saCount] == 2)
|
else if(saOrder[saCount] == 2)
|
||||||
{
|
{
|
||||||
mySticks[i]->name += " (emulates right joystick port)";
|
stick->name += " (emulates right joystick port)";
|
||||||
mySticks[i]->type = StellaJoystick::JT_2600DAPTOR_RIGHT;
|
stick->type = StellaJoystick::JT_2600DAPTOR_RIGHT;
|
||||||
}
|
}
|
||||||
saCount++;
|
saCount++;
|
||||||
}
|
}
|
||||||
|
@ -531,13 +528,13 @@ void EventHandler::JoystickHandler::eraseMapping(Event::Type event, EventMode mo
|
||||||
// Otherwise, only reset the given event
|
// Otherwise, only reset the given event
|
||||||
if(event == Event::NoType)
|
if(event == Event::NoType)
|
||||||
{
|
{
|
||||||
for(uInt32 i = 0; i < mySticks.size(); ++i)
|
for(auto stick: mySticks)
|
||||||
mySticks[i]->eraseMap(mode); // erase all events
|
stick->eraseMap(mode); // erase all events
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(uInt32 i = 0; i < mySticks.size(); ++i)
|
for(auto stick: mySticks)
|
||||||
mySticks[i]->eraseEvent(event, mode); // only reset the specific event
|
stick->eraseEvent(event, mode); // only reset the specific event
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,12 +546,9 @@ void EventHandler::JoystickHandler::saveMapping()
|
||||||
ostringstream joybuf;
|
ostringstream joybuf;
|
||||||
joybuf << Event::LastType;
|
joybuf << Event::LastType;
|
||||||
|
|
||||||
map<string,StickInfo>::const_iterator it;
|
for(const auto& i: myDatabase)
|
||||||
for(it = myDatabase.begin(); it != myDatabase.end(); ++it)
|
|
||||||
{
|
{
|
||||||
const string& map = it->second.joy ?
|
const string& map = i.second.joy ? i.second.joy->getMap() : i.second.mapping;
|
||||||
it->second.joy->getMap() : it->second.mapping;
|
|
||||||
|
|
||||||
if(map != "")
|
if(map != "")
|
||||||
joybuf << "^" << map;
|
joybuf << "^" << map;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,8 @@ bool FilesystemNode::getChildren(FSList& fslist, ListMode mode, bool hidden) con
|
||||||
if (!_realNode->getChildren(tmp, mode, hidden))
|
if (!_realNode->getChildren(tmp, mode, hidden))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (AbstractFSList::iterator i = tmp.begin(); i != tmp.end(); ++i)
|
for (const auto& i: tmp)
|
||||||
fslist.push_back(FilesystemNode(*i));
|
fslist.push_back(FilesystemNode(i));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,22 +49,15 @@
|
||||||
FrameBuffer::FrameBuffer(OSystem& osystem)
|
FrameBuffer::FrameBuffer(OSystem& osystem)
|
||||||
: myOSystem(osystem),
|
: myOSystem(osystem),
|
||||||
myInitializedCount(0),
|
myInitializedCount(0),
|
||||||
myPausedCount(0),
|
myPausedCount(0)
|
||||||
myTIASurface(NULL)
|
|
||||||
{
|
{
|
||||||
myMsg.surface = myStatsMsg.surface = NULL;
|
myMsg.surface = myStatsMsg.surface = nullptr;
|
||||||
myMsg.enabled = myStatsMsg.enabled = false;
|
myMsg.enabled = myStatsMsg.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
FrameBuffer::~FrameBuffer(void)
|
FrameBuffer::~FrameBuffer()
|
||||||
{
|
{
|
||||||
delete myFont;
|
|
||||||
delete myInfoFont;
|
|
||||||
delete mySmallFont;
|
|
||||||
delete myLauncherFont;
|
|
||||||
delete myTIASurface;
|
|
||||||
|
|
||||||
// Free all allocated surfaces
|
// Free all allocated surfaces
|
||||||
while(!mySurfaceList.empty())
|
while(!mySurfaceList.empty())
|
||||||
{
|
{
|
||||||
|
@ -107,15 +100,15 @@ bool FrameBuffer::initialize()
|
||||||
// This font is used in a variety of situations when a really small
|
// This font is used in a variety of situations when a really small
|
||||||
// font is needed; we let the specific widget/dialog decide when to
|
// font is needed; we let the specific widget/dialog decide when to
|
||||||
// use it
|
// use it
|
||||||
mySmallFont = new GUI::Font(GUI::stellaDesc);
|
mySmallFont = make_ptr<GUI::Font>(GUI::stellaDesc);
|
||||||
|
|
||||||
// The general font used in all UI elements
|
// The general font used in all UI elements
|
||||||
// This is determined by the size of the framebuffer
|
// This is determined by the size of the framebuffer
|
||||||
myFont = new GUI::Font(smallScreen ? GUI::stellaDesc : GUI::stellaMediumDesc);
|
myFont = make_ptr<GUI::Font>(smallScreen ? GUI::stellaDesc : GUI::stellaMediumDesc);
|
||||||
|
|
||||||
// The info font used in all UI elements
|
// The info font used in all UI elements
|
||||||
// This is determined by the size of the framebuffer
|
// This is determined by the size of the framebuffer
|
||||||
myInfoFont = new GUI::Font(smallScreen ? GUI::stellaDesc : GUI::consoleDesc);
|
myInfoFont = make_ptr<GUI::Font>(smallScreen ? GUI::stellaDesc : GUI::consoleDesc);
|
||||||
|
|
||||||
// The font used by the ROM launcher
|
// The font used by the ROM launcher
|
||||||
// Normally, this is configurable by the user, except in the case of
|
// Normally, this is configurable by the user, except in the case of
|
||||||
|
@ -124,14 +117,14 @@ bool FrameBuffer::initialize()
|
||||||
{
|
{
|
||||||
const string& lf = myOSystem.settings().getString("launcherfont");
|
const string& lf = myOSystem.settings().getString("launcherfont");
|
||||||
if(lf == "small")
|
if(lf == "small")
|
||||||
myLauncherFont = new GUI::Font(GUI::consoleDesc);
|
myLauncherFont = make_ptr<GUI::Font>(GUI::consoleDesc);
|
||||||
else if(lf == "medium")
|
else if(lf == "medium")
|
||||||
myLauncherFont = new GUI::Font(GUI::stellaMediumDesc);
|
myLauncherFont = make_ptr<GUI::Font>(GUI::stellaMediumDesc);
|
||||||
else
|
else
|
||||||
myLauncherFont = new GUI::Font(GUI::stellaLargeDesc);
|
myLauncherFont = make_ptr<GUI::Font>(GUI::stellaLargeDesc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
myLauncherFont = new GUI::Font(GUI::stellaDesc);
|
myLauncherFont = make_ptr<GUI::Font>(GUI::stellaDesc);
|
||||||
|
|
||||||
// Determine possible TIA windowed zoom levels
|
// Determine possible TIA windowed zoom levels
|
||||||
uInt32 maxZoom = maxWindowSizeForScreen((uInt32)kTIAMinW, (uInt32)kTIAMinH,
|
uInt32 maxZoom = maxWindowSizeForScreen((uInt32)kTIAMinW, (uInt32)kTIAMinH,
|
||||||
|
@ -160,7 +153,7 @@ bool FrameBuffer::initialize()
|
||||||
FBSurface::setPalette(myPalette);
|
FBSurface::setPalette(myPalette);
|
||||||
|
|
||||||
// Create a TIA surface; we need it for rendering TIA images
|
// Create a TIA surface; we need it for rendering TIA images
|
||||||
myTIASurface = new TIASurface(myOSystem);
|
myTIASurface = make_ptr<TIASurface>(myOSystem);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -241,12 +234,12 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
|
||||||
myStatsMsg.w = infoFont().getMaxCharWidth() * 24 + 2;
|
myStatsMsg.w = infoFont().getMaxCharWidth() * 24 + 2;
|
||||||
myStatsMsg.h = (infoFont().getFontHeight() + 2) * 2;
|
myStatsMsg.h = (infoFont().getFontHeight() + 2) * 2;
|
||||||
|
|
||||||
if(myStatsMsg.surface == NULL)
|
if(myStatsMsg.surface == nullptr)
|
||||||
{
|
{
|
||||||
uInt32 surfaceID = allocateSurface(myStatsMsg.w, myStatsMsg.h);
|
uInt32 surfaceID = allocateSurface(myStatsMsg.w, myStatsMsg.h);
|
||||||
myStatsMsg.surface = surface(surfaceID);
|
myStatsMsg.surface = surface(surfaceID);
|
||||||
}
|
}
|
||||||
if(myMsg.surface == NULL)
|
if(myMsg.surface == nullptr)
|
||||||
{
|
{
|
||||||
uInt32 surfaceID = allocateSurface((uInt32)kFBMinW, font().getFontHeight()+10);
|
uInt32 surfaceID = allocateSurface((uInt32)kFBMinW, font().getFontHeight()+10);
|
||||||
myMsg.surface = surface(surfaceID);
|
myMsg.surface = surface(surfaceID);
|
||||||
|
@ -589,8 +582,8 @@ uInt32 FrameBuffer::allocateSurface(int w, int h, const uInt32* data)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
FBSurface* FrameBuffer::surface(uInt32 id) const
|
FBSurface* FrameBuffer::surface(uInt32 id) const
|
||||||
{
|
{
|
||||||
map<uInt32,FBSurface*>::const_iterator iter = mySurfaceList.find(id);
|
const auto& iter = mySurfaceList.find(id);
|
||||||
return iter != mySurfaceList.end() ? iter->second : NULL;
|
return iter != mySurfaceList.end() ? iter->second : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -602,11 +595,10 @@ void FrameBuffer::resetSurfaces()
|
||||||
// Any derived FrameBuffer classes that call this method should be
|
// Any derived FrameBuffer classes that call this method should be
|
||||||
// aware of these restrictions, and act accordingly
|
// aware of these restrictions, and act accordingly
|
||||||
|
|
||||||
map<uInt32,FBSurface*>::iterator iter;
|
for(auto& s: mySurfaceList)
|
||||||
for(iter = mySurfaceList.begin(); iter != mySurfaceList.end(); ++iter)
|
s.second->free();
|
||||||
iter->second->free();
|
for(auto& s: mySurfaceList)
|
||||||
for(iter = mySurfaceList.begin(); iter != mySurfaceList.end(); ++iter)
|
s.second->reload();
|
||||||
iter->second->reload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -743,8 +735,8 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
|
||||||
{
|
{
|
||||||
myWindowedModeList.clear();
|
myWindowedModeList.clear();
|
||||||
|
|
||||||
for(uInt32 i = 0; i < myFullscreenModeLists.size(); ++i)
|
for(auto& mode: myFullscreenModeLists)
|
||||||
myFullscreenModeLists[i].clear();
|
mode.clear();
|
||||||
for(uInt32 i = myFullscreenModeLists.size(); i < myDisplays.size(); ++i)
|
for(uInt32 i = myFullscreenModeLists.size(); i < myDisplays.size(); ++i)
|
||||||
myFullscreenModeLists.push_back(VideoModeList());
|
myFullscreenModeLists.push_back(VideoModeList());
|
||||||
|
|
||||||
|
|
|
@ -534,19 +534,19 @@ class FrameBuffer
|
||||||
VariantList myRenderers;
|
VariantList myRenderers;
|
||||||
|
|
||||||
// The font object to use for the normal in-game GUI
|
// The font object to use for the normal in-game GUI
|
||||||
GUI::Font* myFont;
|
unique_ptr<GUI::Font> myFont;
|
||||||
|
|
||||||
// The info font object to use for the normal in-game GUI
|
// The info font object to use for the normal in-game GUI
|
||||||
GUI::Font* myInfoFont;
|
unique_ptr<GUI::Font> myInfoFont;
|
||||||
|
|
||||||
// The font object to use when space is very limited
|
// The font object to use when space is very limited
|
||||||
GUI::Font* mySmallFont;
|
unique_ptr<GUI::Font> mySmallFont;
|
||||||
|
|
||||||
// The font object to use for the ROM launcher
|
// The font object to use for the ROM launcher
|
||||||
GUI::Font* myLauncherFont;
|
unique_ptr<GUI::Font> myLauncherFont;
|
||||||
|
|
||||||
// The TIASurface class takes responsibility for TIA rendering
|
// The TIASurface class takes responsibility for TIA rendering
|
||||||
TIASurface* myTIASurface;
|
unique_ptr<TIASurface> myTIASurface;
|
||||||
|
|
||||||
// Used for onscreen messages and frame statistics
|
// Used for onscreen messages and frame statistics
|
||||||
// (scanline count and framerate)
|
// (scanline count and framerate)
|
||||||
|
|
|
@ -20,15 +20,21 @@
|
||||||
#ifndef MEDIA_FACTORY_HXX
|
#ifndef MEDIA_FACTORY_HXX
|
||||||
#define MEDIA_FACTORY_HXX
|
#define MEDIA_FACTORY_HXX
|
||||||
|
|
||||||
|
#include "bspf.hxx"
|
||||||
|
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
#include "Settings.hxx"
|
#include "Settings.hxx"
|
||||||
|
#include "SerialPort.hxx"
|
||||||
#if defined(BSPF_UNIX)
|
#if defined(BSPF_UNIX)
|
||||||
|
#include "SerialPortUNIX.hxx"
|
||||||
#include "SettingsUNIX.hxx"
|
#include "SettingsUNIX.hxx"
|
||||||
#include "OSystemUNIX.hxx"
|
#include "OSystemUNIX.hxx"
|
||||||
#elif defined(BSPF_WINDOWS)
|
#elif defined(BSPF_WINDOWS)
|
||||||
|
#include "SerialPortWINDOWS.hxx"
|
||||||
#include "SettingsWINDOWS.hxx"
|
#include "SettingsWINDOWS.hxx"
|
||||||
#include "OSystemWINDOWS.hxx"
|
#include "OSystemWINDOWS.hxx"
|
||||||
#elif defined(BSPF_MAC_OSX)
|
#elif defined(BSPF_MAC_OSX)
|
||||||
|
#include "SerialPortMACOSX.hxx"
|
||||||
#include "SettingsMACOSX.hxx"
|
#include "SettingsMACOSX.hxx"
|
||||||
#include "OSystemMACOSX.hxx"
|
#include "OSystemMACOSX.hxx"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -61,49 +67,62 @@
|
||||||
class MediaFactory
|
class MediaFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static OSystem* createOSystem()
|
static unique_ptr<OSystem> createOSystem()
|
||||||
{
|
{
|
||||||
#if defined(BSPF_UNIX)
|
#if defined(BSPF_UNIX)
|
||||||
return new OSystemUNIX();
|
return make_ptr<OSystemUNIX>();
|
||||||
#elif defined(BSPF_WINDOWS)
|
#elif defined(BSPF_WINDOWS)
|
||||||
return new OSystemWINDOWS();
|
return make_ptr<OSystemWINDOWS>();
|
||||||
#elif defined(BSPF_MAC_OSX)
|
#elif defined(BSPF_MAC_OSX)
|
||||||
return new OSystemMACOSX();
|
return make_ptr<OSystemMACOSX>();
|
||||||
#else
|
#else
|
||||||
#error Unsupported platform for OSystem!
|
#error Unsupported platform for OSystem!
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static Settings* createSettings(OSystem& osystem)
|
static unique_ptr<Settings> createSettings(OSystem& osystem)
|
||||||
{
|
{
|
||||||
#if defined(BSPF_UNIX)
|
#if defined(BSPF_UNIX)
|
||||||
return new SettingsUNIX(osystem);
|
return make_ptr<SettingsUNIX>(osystem);
|
||||||
#elif defined(BSPF_WINDOWS)
|
#elif defined(BSPF_WINDOWS)
|
||||||
return new SettingsWINDOWS(osystem);
|
return make_ptr<SettingsWINDOWS>(osystem);
|
||||||
#elif defined(BSPF_MAC_OSX)
|
#elif defined(BSPF_MAC_OSX)
|
||||||
return new SettingsMACOSX(osystem);
|
return make_ptr<SettingsMACOSX>(osystem);
|
||||||
#else
|
#else
|
||||||
#error Unsupported platform for Settings!
|
#error Unsupported platform for Settings!
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static FrameBuffer* createVideo(OSystem& osystem)
|
static unique_ptr<SerialPort> createSerialPort()
|
||||||
{
|
{
|
||||||
return new FrameBufferSDL2(osystem);
|
#if defined(BSPF_UNIX)
|
||||||
}
|
return make_ptr<SerialPortUNIX>();
|
||||||
|
#elif defined(BSPF_WINDOWS)
|
||||||
static Sound* createAudio(OSystem& osystem)
|
return make_ptr<SerialPortWINDOWS>();
|
||||||
{
|
#elif defined(BSPF_MAC_OSX)
|
||||||
#ifdef SOUND_SUPPORT
|
return make_ptr<SerialPortMACOSX>();
|
||||||
return new SoundSDL2(osystem);
|
|
||||||
#else
|
#else
|
||||||
return new SoundNull(osystem);
|
return make_ptr<SerialPort>();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static EventHandler* createEventHandler(OSystem& osystem)
|
static unique_ptr<FrameBuffer> createVideo(OSystem& osystem)
|
||||||
{
|
{
|
||||||
return new EventHandlerSDL2(osystem);
|
return make_ptr<FrameBufferSDL2>(osystem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static unique_ptr<Sound> createAudio(OSystem& osystem)
|
||||||
|
{
|
||||||
|
#ifdef SOUND_SUPPORT
|
||||||
|
return make_ptr<SoundSDL2>(osystem);
|
||||||
|
#else
|
||||||
|
return make_ptr<SoundNull>(osystem);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static unique_ptr<EventHandler> createEventHandler(OSystem& osystem)
|
||||||
|
{
|
||||||
|
return make_ptr<EventHandlerSDL2>(osystem);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,15 +39,6 @@
|
||||||
#include "CheatManager.hxx"
|
#include "CheatManager.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "SerialPort.hxx"
|
|
||||||
#if defined(BSPF_UNIX)
|
|
||||||
#include "SerialPortUNIX.hxx"
|
|
||||||
#elif defined(BSPF_WINDOWS)
|
|
||||||
#include "SerialPortWINDOWS.hxx"
|
|
||||||
#elif defined(BSPF_MAC_OSX)
|
|
||||||
#include "SerialPortMACOSX.hxx"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "FSNode.hxx"
|
#include "FSNode.hxx"
|
||||||
#include "MD5.hxx"
|
#include "MD5.hxx"
|
||||||
#include "Cart.hxx"
|
#include "Cart.hxx"
|
||||||
|
@ -60,6 +51,7 @@
|
||||||
#include "Widget.hxx"
|
#include "Widget.hxx"
|
||||||
#include "Console.hxx"
|
#include "Console.hxx"
|
||||||
#include "Random.hxx"
|
#include "Random.hxx"
|
||||||
|
#include "SerialPort.hxx"
|
||||||
#include "StateManager.hxx"
|
#include "StateManager.hxx"
|
||||||
#include "Version.hxx"
|
#include "Version.hxx"
|
||||||
|
|
||||||
|
@ -67,21 +59,9 @@
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
OSystem::OSystem()
|
OSystem::OSystem()
|
||||||
: myEventHandler(NULL),
|
: myConsole(nullptr),
|
||||||
myFrameBuffer(NULL),
|
|
||||||
mySound(NULL),
|
|
||||||
mySettings(NULL),
|
|
||||||
myPropSet(NULL),
|
|
||||||
myConsole(NULL),
|
|
||||||
mySerialPort(NULL),
|
|
||||||
myMenu(NULL),
|
|
||||||
myCommandMenu(NULL),
|
|
||||||
myLauncher(NULL),
|
|
||||||
myLauncherUsed(false),
|
myLauncherUsed(false),
|
||||||
myDebugger(NULL),
|
myDebugger(nullptr),
|
||||||
myCheatManager(NULL),
|
|
||||||
myStateManager(NULL),
|
|
||||||
myPNGLib(NULL),
|
|
||||||
myQuitLoop(false),
|
myQuitLoop(false),
|
||||||
myRomFile(""),
|
myRomFile(""),
|
||||||
myRomMD5(""),
|
myRomMD5(""),
|
||||||
|
@ -116,43 +96,17 @@ OSystem::OSystem()
|
||||||
myBuildInfo = info.str();
|
myBuildInfo = info.str();
|
||||||
|
|
||||||
mySettings = MediaFactory::createSettings(*this);
|
mySettings = MediaFactory::createSettings(*this);
|
||||||
myRandom = new Random(*this);
|
myRandom = make_ptr<Random>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
OSystem::~OSystem()
|
OSystem::~OSystem()
|
||||||
{
|
{
|
||||||
delete myMenu;
|
|
||||||
delete myCommandMenu;
|
|
||||||
delete myLauncher;
|
|
||||||
|
|
||||||
// Remove any game console that is currently attached
|
// Remove any game console that is currently attached
|
||||||
deleteConsole();
|
deleteConsole();
|
||||||
|
|
||||||
// These must be deleted after all the others
|
|
||||||
// This is a bit hacky, since it depends on ordering
|
|
||||||
// of d'tor calls
|
|
||||||
#ifdef DEBUGGER_SUPPORT
|
#ifdef DEBUGGER_SUPPORT
|
||||||
delete myDebugger;
|
delete myDebugger;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CHEATCODE_SUPPORT
|
|
||||||
delete myCheatManager;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
delete myStateManager;
|
|
||||||
delete myPropSet;
|
|
||||||
|
|
||||||
delete mySerialPort;
|
|
||||||
delete myPNGLib;
|
|
||||||
delete myZipHandler;
|
|
||||||
|
|
||||||
// OSystem takes responsibility for these, since it called MediaFactory
|
|
||||||
// to create them
|
|
||||||
delete myFrameBuffer;
|
|
||||||
delete mySound;
|
|
||||||
delete myEventHandler;
|
|
||||||
delete myRandom;
|
|
||||||
delete mySettings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -185,18 +139,18 @@ bool OSystem::create()
|
||||||
myEventHandler->initialize();
|
myEventHandler->initialize();
|
||||||
|
|
||||||
// Create a properties set for us to use and set it up
|
// Create a properties set for us to use and set it up
|
||||||
myPropSet = new PropertiesSet(propertiesFile());
|
myPropSet = make_ptr<PropertiesSet>(propertiesFile());
|
||||||
|
|
||||||
#ifdef CHEATCODE_SUPPORT
|
#ifdef CHEATCODE_SUPPORT
|
||||||
myCheatManager = new CheatManager(*this);
|
myCheatManager = make_ptr<CheatManager>(*this);
|
||||||
myCheatManager->loadCheatDatabase();
|
myCheatManager->loadCheatDatabase();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create menu and launcher GUI objects
|
// Create menu and launcher GUI objects
|
||||||
myMenu = new Menu(*this);
|
myMenu = make_ptr<Menu>(*this);
|
||||||
myCommandMenu = new CommandMenu(*this);
|
myCommandMenu = make_ptr<CommandMenu>(*this);
|
||||||
myLauncher = new Launcher(*this);
|
myLauncher = make_ptr<Launcher>(*this);
|
||||||
myStateManager = new StateManager(*this);
|
myStateManager = make_ptr<StateManager>(*this);
|
||||||
|
|
||||||
// Create the sound object; the sound subsystem isn't actually
|
// Create the sound object; the sound subsystem isn't actually
|
||||||
// opened until needed, so this is non-blocking (on those systems
|
// opened until needed, so this is non-blocking (on those systems
|
||||||
|
@ -206,25 +160,16 @@ bool OSystem::create()
|
||||||
// Create the serial port object
|
// Create the serial port object
|
||||||
// This is used by any controller that wants to directly access
|
// This is used by any controller that wants to directly access
|
||||||
// a real serial port on the system
|
// a real serial port on the system
|
||||||
#if defined(BSPF_UNIX)
|
mySerialPort = MediaFactory::createSerialPort();
|
||||||
mySerialPort = new SerialPortUNIX();
|
|
||||||
#elif defined(BSPF_WINDOWS)
|
|
||||||
mySerialPort = new SerialPortWINDOWS();
|
|
||||||
#elif defined(BSPF_MAC_OSX)
|
|
||||||
mySerialPort = new SerialPortMACOSX();
|
|
||||||
#else
|
|
||||||
// Create an 'empty' serial port
|
|
||||||
mySerialPort = new SerialPort();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Re-initialize random seed
|
// Re-initialize random seed
|
||||||
myRandom->initSeed();
|
myRandom->initSeed();
|
||||||
|
|
||||||
// Create PNG handler
|
// Create PNG handler
|
||||||
myPNGLib = new PNGLibrary(*myFrameBuffer);
|
myPNGLib = make_ptr<PNGLibrary>(*myFrameBuffer);
|
||||||
|
|
||||||
// Create ZIP handler
|
// Create ZIP handler
|
||||||
myZipHandler = new ZipHandler();
|
myZipHandler = make_ptr<ZipHandler>();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -777,4 +722,4 @@ void OSystem::mainLoop()
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
ZipHandler* OSystem::myZipHandler = 0;
|
unique_ptr<ZipHandler> OSystem::myZipHandler = unique_ptr<ZipHandler>();
|
||||||
|
|
|
@ -458,50 +458,50 @@ class OSystem
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Pointer to the EventHandler object
|
// Pointer to the EventHandler object
|
||||||
EventHandler* myEventHandler;
|
unique_ptr<EventHandler> myEventHandler;
|
||||||
|
|
||||||
// Pointer to the FrameBuffer object
|
// Pointer to the FrameBuffer object
|
||||||
FrameBuffer* myFrameBuffer;
|
unique_ptr<FrameBuffer> myFrameBuffer;
|
||||||
|
|
||||||
// Pointer to the Sound object
|
// Pointer to the Sound object
|
||||||
Sound* mySound;
|
unique_ptr<Sound> mySound;
|
||||||
|
|
||||||
// Pointer to the Settings object
|
// Pointer to the Settings object
|
||||||
Settings* mySettings;
|
unique_ptr<Settings> mySettings;
|
||||||
|
|
||||||
// Pointer to the Random object
|
// Pointer to the Random object
|
||||||
Random* myRandom;
|
unique_ptr<Random> myRandom;
|
||||||
|
|
||||||
// Pointer to the PropertiesSet object
|
// Pointer to the PropertiesSet object
|
||||||
PropertiesSet* myPropSet;
|
unique_ptr<PropertiesSet> myPropSet;
|
||||||
|
|
||||||
// Pointer to the (currently defined) Console object
|
// Pointer to the (currently defined) Console object
|
||||||
Console* myConsole;
|
Console* myConsole;
|
||||||
|
|
||||||
// Pointer to the serial port object
|
// Pointer to the serial port object
|
||||||
SerialPort* mySerialPort;
|
unique_ptr<SerialPort> mySerialPort;
|
||||||
|
|
||||||
// Pointer to the Menu object
|
// Pointer to the Menu object
|
||||||
Menu* myMenu;
|
unique_ptr<Menu> myMenu;
|
||||||
|
|
||||||
// Pointer to the CommandMenu object
|
// Pointer to the CommandMenu object
|
||||||
CommandMenu* myCommandMenu;
|
unique_ptr<CommandMenu> myCommandMenu;
|
||||||
|
|
||||||
// Pointer to the Launcher object
|
// Pointer to the Launcher object
|
||||||
Launcher* myLauncher;
|
unique_ptr<Launcher> myLauncher;
|
||||||
bool myLauncherUsed;
|
bool myLauncherUsed;
|
||||||
|
|
||||||
// Pointer to the Debugger object
|
// Pointer to the Debugger object
|
||||||
Debugger* myDebugger;
|
Debugger* myDebugger;
|
||||||
|
|
||||||
// Pointer to the CheatManager object
|
// Pointer to the CheatManager object
|
||||||
CheatManager* myCheatManager;
|
unique_ptr<CheatManager> myCheatManager;
|
||||||
|
|
||||||
// Pointer to the StateManager object
|
// Pointer to the StateManager object
|
||||||
StateManager* myStateManager;
|
unique_ptr<StateManager> myStateManager;
|
||||||
|
|
||||||
// PNG object responsible for loading/saving PNG images
|
// PNG object responsible for loading/saving PNG images
|
||||||
PNGLibrary* myPNGLib;
|
unique_ptr<PNGLibrary> myPNGLib;
|
||||||
|
|
||||||
// The list of log messages
|
// The list of log messages
|
||||||
string myLogMessages;
|
string myLogMessages;
|
||||||
|
@ -519,7 +519,7 @@ class OSystem
|
||||||
bool myQuitLoop;
|
bool myQuitLoop;
|
||||||
|
|
||||||
// ZIP static reference variable responsible for accessing ZIP files
|
// ZIP static reference variable responsible for accessing ZIP files
|
||||||
static ZipHandler* myZipHandler;
|
static unique_ptr<ZipHandler> myZipHandler;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string myBaseDir;
|
string myBaseDir;
|
||||||
|
|
|
@ -73,9 +73,8 @@ bool PropertiesSet::save(const string& filename) const
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Only save those entries in the external list
|
// Only save those entries in the external list
|
||||||
for(PropsList::const_iterator i = myExternalProps.begin();
|
for(const auto& i: myExternalProps)
|
||||||
i != myExternalProps.end(); ++i)
|
i.second.save(out);
|
||||||
i->second.save(out);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -99,18 +98,18 @@ bool PropertiesSet::getMD5(const string& md5, Properties& properties,
|
||||||
if(!useDefaults)
|
if(!useDefaults)
|
||||||
{
|
{
|
||||||
// Check external list
|
// Check external list
|
||||||
PropsList::const_iterator iter = myExternalProps.find(md5);
|
const auto ext = myExternalProps.find(md5);
|
||||||
if(iter != myExternalProps.end())
|
if(ext != myExternalProps.end())
|
||||||
{
|
{
|
||||||
properties = iter->second;
|
properties = ext->second;
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
else // Search temp list
|
else // Search temp list
|
||||||
{
|
{
|
||||||
iter = myTempProps.find(md5);
|
const auto tmp = myTempProps.find(md5);
|
||||||
if(iter != myTempProps.end())
|
if(tmp != myTempProps.end())
|
||||||
{
|
{
|
||||||
properties = iter->second;
|
properties = tmp->second;
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,8 +177,7 @@ void PropertiesSet::insert(const Properties& properties, bool save)
|
||||||
// The status of 'save' determines which list to save to
|
// The status of 'save' determines which list to save to
|
||||||
PropsList& list = save ? myExternalProps : myTempProps;
|
PropsList& list = save ? myExternalProps : myTempProps;
|
||||||
|
|
||||||
pair<PropsList::iterator,bool> ret;
|
auto ret = list.insert(make_pair(md5, properties));
|
||||||
ret = list.insert(make_pair(md5, properties));
|
|
||||||
if(ret.second == false)
|
if(ret.second == false)
|
||||||
{
|
{
|
||||||
// Remove old item and insert again
|
// Remove old item and insert again
|
||||||
|
@ -227,6 +225,6 @@ void PropertiesSet::print() const
|
||||||
|
|
||||||
// Now, print the resulting list
|
// Now, print the resulting list
|
||||||
Properties::printHeader();
|
Properties::printHeader();
|
||||||
for(PropsList::const_iterator i = list.begin(); i != list.end(); ++i)
|
for(const auto& i: list)
|
||||||
i->second.print();
|
i.second.print();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,37 +40,35 @@ GameList::~GameList()
|
||||||
void GameList::appendGame(const string& name, const string& path,
|
void GameList::appendGame(const string& name, const string& path,
|
||||||
const string& md5, bool isDir)
|
const string& md5, bool isDir)
|
||||||
{
|
{
|
||||||
myArray.push_back(Entry(name, path, md5, isDir));
|
myArray.emplace_back(name, path, md5, isDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void GameList::sortByName()
|
void GameList::sortByName()
|
||||||
{
|
{
|
||||||
if(myArray.size() <= 1)
|
if(myArray.size() < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sort(myArray.begin(), myArray.end());
|
auto cmp = [](const Entry& a, const Entry& b)
|
||||||
}
|
{
|
||||||
|
auto it1 = a._name.begin(), it2 = b._name.begin();
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
bool GameList::Entry::operator< (const Entry& g) const
|
// Account for ending ']' character in directory entries
|
||||||
{
|
auto end1 = a._isdir ? a._name.end() - 1 : a._name.end();
|
||||||
string::const_iterator it1 = _name.begin();
|
auto end2 = b._isdir ? b._name.end() - 1 : b._name.end();
|
||||||
string::const_iterator it2 = g._name.begin();
|
|
||||||
|
// Stop when either string's end has been reached
|
||||||
// Account for ending ']' character in directory entries
|
while((it1 != end1) && (it2 != end2))
|
||||||
string::const_iterator end1 = _isdir ? _name.end() - 1 : _name.end();
|
{
|
||||||
string::const_iterator end2 = g._isdir ? g._name.end() - 1 : g._name.end();
|
if(toupper(*it1) != toupper(*it2)) // letters differ?
|
||||||
|
return toupper(*it1) < toupper(*it2);
|
||||||
// Stop when either string's end has been reached
|
|
||||||
while((it1 != end1) && (it2 != end2))
|
// proceed to the next character in each string
|
||||||
{
|
++it1;
|
||||||
if(toupper(*it1) != toupper(*it2)) // letters differ?
|
++it2;
|
||||||
return toupper(*it1) < toupper(*it2);
|
}
|
||||||
|
return a._name.size() < b._name.size();
|
||||||
// proceed to the next character in each string
|
};
|
||||||
++it1;
|
|
||||||
++it2;
|
sort(myArray.begin(), myArray.end(), cmp);
|
||||||
}
|
|
||||||
return _name.size() < g._name.size();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,6 @@ class GameList
|
||||||
{
|
{
|
||||||
_name = name; _path = path; _md5 = md5; _isdir = isdir;
|
_name = name; _path = path; _md5 = md5; _isdir = isdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator < (const Entry& a) const;
|
|
||||||
};
|
};
|
||||||
vector<Entry> myArray;
|
vector<Entry> myArray;
|
||||||
};
|
};
|
||||||
|
|
|
@ -95,14 +95,14 @@ void ListWidget::setSelected(const string& item)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uInt32 itemToSelect = 0;
|
uInt32 itemToSelect = 0;
|
||||||
StringList::const_iterator iter;
|
for(const auto& iter: _list)
|
||||||
for(iter = _list.begin(); iter != _list.end(); ++iter, ++itemToSelect)
|
|
||||||
{
|
{
|
||||||
if(item == *iter)
|
if(item == iter)
|
||||||
{
|
{
|
||||||
selected = itemToSelect;
|
selected = itemToSelect;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
++itemToSelect;
|
||||||
}
|
}
|
||||||
if(itemToSelect > _list.size() || selected == -1)
|
if(itemToSelect > _list.size() || selected == -1)
|
||||||
selected = 0;
|
selected = 0;
|
||||||
|
@ -264,9 +264,9 @@ bool ListWidget::handleText(char text)
|
||||||
// quite big lists to deal with -- so for now we can live with this lazy
|
// quite big lists to deal with -- so for now we can live with this lazy
|
||||||
// implementation :-)
|
// implementation :-)
|
||||||
int newSelectedItem = 0;
|
int newSelectedItem = 0;
|
||||||
for (StringList::const_iterator i = _list.begin(); i != _list.end(); ++i)
|
for(const auto& i: _list)
|
||||||
{
|
{
|
||||||
if(BSPF_startsWithIgnoreCase(*i, _quickSelectStr))
|
if(BSPF_startsWithIgnoreCase(i, _quickSelectStr))
|
||||||
{
|
{
|
||||||
_selectedItem = newSelectedItem;
|
_selectedItem = newSelectedItem;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -76,8 +76,8 @@ int main(int ac, char* av[])
|
||||||
if(result > 0)
|
if(result > 0)
|
||||||
{
|
{
|
||||||
cout << setw(3) << result << " hits: \'" << av[2] << "\' - \"" << av[1] << "\" @";
|
cout << setw(3) << result << " hits: \'" << av[2] << "\' - \"" << av[1] << "\" @";
|
||||||
for(list<int>::iterator it = locations.begin(); it != locations.end(); ++it)
|
for(const auto& it: locations)
|
||||||
cout << ' ' << hex << ((int)*it + offset);
|
cout << ' ' << hex << (it + offset);
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue