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
|
||||
===========================================================================
|
||||
|
||||
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)
|
||||
|
||||
* 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
|
||||
some window managers.
|
||||
|
||||
-Have fun!
|
||||
|
||||
|
||||
4.1 to 4.1.1: (September 14, 2014)
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -51,7 +51,7 @@ else
|
|||
endif
|
||||
CXXFLAGS+= -Wall
|
||||
ifdef HAVE_GCC
|
||||
CXXFLAGS+= -Wno-multichar -Wunused -fno-rtti -Woverloaded-virtual
|
||||
CXXFLAGS+= -Wno-multichar -Wunused -fno-rtti -Woverloaded-virtual -std=c++11
|
||||
endif
|
||||
|
||||
ifdef PROFILE
|
||||
|
|
|
@ -281,11 +281,8 @@ void CheatManager::saveCheatDatabase()
|
|||
if(!out)
|
||||
return;
|
||||
|
||||
CheatCodeMap::iterator iter;
|
||||
for(iter = myCheatMap.begin(); iter != myCheatMap.end(); ++iter)
|
||||
out << "\"" << iter->first << "\" "
|
||||
<< "\"" << iter->second << "\""
|
||||
<< endl;
|
||||
for(const auto& iter: myCheatMap)
|
||||
out << "\"" << iter.first << "\" " << "\"" << iter.second << "\"" << endl;
|
||||
|
||||
out.close();
|
||||
}
|
||||
|
@ -302,7 +299,7 @@ void CheatManager::loadCheats(const string& md5sum)
|
|||
if(cheats != "")
|
||||
myOSystem.settings().setValue("cheat", "");
|
||||
|
||||
CheatCodeMap::iterator iter = myCheatMap.find(md5sum);
|
||||
const auto& iter = myCheatMap.find(md5sum);
|
||||
if(iter == myCheatMap.end() && cheats == "")
|
||||
return;
|
||||
|
||||
|
|
|
@ -99,8 +99,6 @@ SoundSDL2::~SoundSDL2()
|
|||
SDL_CloseAudio();
|
||||
myIsEnabled = myIsInitializedFlag = false;
|
||||
}
|
||||
|
||||
myOSystem.logMessage("SoundSDL2 destroyed", 2);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <cstring>
|
||||
|
@ -110,18 +111,22 @@ static const string EmptyString("");
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
// 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 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_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; }
|
||||
|
||||
// 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
|
||||
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
|
||||
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(),
|
||||
s2.begin(), s2.end(), BSPF_equalsIgnoreCaseChar);
|
||||
auto pos = std::search(s1.begin()+startpos, s1.end(),
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
// $Id$
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
@ -42,7 +41,7 @@
|
|||
#endif
|
||||
|
||||
// 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)
|
||||
|
@ -51,12 +50,6 @@ int Cleanup()
|
|||
theOSystem->logMessage("Cleanup from mainSDL", 2);
|
||||
theOSystem->saveConfig();
|
||||
|
||||
if(theOSystem)
|
||||
delete theOSystem;
|
||||
|
||||
if(SDL_WasInit(SDL_INIT_VIDEO) & SDL_INIT_VIDEO)
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -164,13 +157,6 @@ int main(int argc, char* argv[])
|
|||
#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
|
||||
theOSystem->logMessage("Starting main loop ...", 2);
|
||||
theOSystem->mainLoop();
|
||||
|
|
|
@ -260,15 +260,15 @@ bool CartDebug::disassemble(bool force)
|
|||
// $bxxx, it must be changed
|
||||
uInt16 offset = (PC - (PC % 0x1000));
|
||||
AddressList& addresses = info.addressList;
|
||||
for(list<uInt16>::iterator i = addresses.begin(); i != addresses.end(); ++i)
|
||||
*i = (*i & 0xFFF) + offset;
|
||||
for(auto& i: addresses)
|
||||
i = (i & 0xFFF) + offset;
|
||||
|
||||
// Only add addresses when absolutely necessary, to cut down on the
|
||||
// work that Distella has to do
|
||||
// Distella expects the addresses to be unique and in sorted order
|
||||
if(bankChanged || !pcfound)
|
||||
{
|
||||
AddressList::iterator i;
|
||||
AddressList::const_iterator i;
|
||||
for(i = addresses.begin(); i != addresses.end(); ++i)
|
||||
{
|
||||
if(PC < *i)
|
||||
|
@ -339,7 +339,7 @@ int CartDebug::addressToLine(uInt16 address) const
|
|||
if(!myAddrToLineIsROM != !(address & 0x1000))
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -390,16 +390,6 @@ string CartDebug::disassemble(uInt16 start, uInt16 lines) const
|
|||
bool CartDebug::addDirective(CartDebug::DisasmType type,
|
||||
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)
|
||||
return false;
|
||||
|
||||
|
@ -525,24 +515,6 @@ bool CartDebug::addDirective(CartDebug::DisasmType type,
|
|||
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)
|
||||
{
|
||||
|
@ -814,7 +786,7 @@ string CartDebug::loadSymbolFile()
|
|||
{
|
||||
// Make sure the value doesn't represent a constant
|
||||
// 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))
|
||||
{
|
||||
// Check for period, and strip leading number
|
||||
|
@ -865,11 +837,8 @@ string CartDebug::loadConfigFile()
|
|||
return "Unable to load directives from " + node.getPath();
|
||||
|
||||
// Erase all previous directives
|
||||
for(Common::Array<BankInfo>::iterator bi = myBankInfo.begin();
|
||||
bi != myBankInfo.end(); ++bi)
|
||||
{
|
||||
bi->directiveList.clear();
|
||||
}
|
||||
for(auto& bi: myBankInfo)
|
||||
bi.directiveList.clear();
|
||||
|
||||
int currentbank = 0;
|
||||
while(!in.eof())
|
||||
|
@ -1167,14 +1136,13 @@ string CartDebug::saveDisassembly()
|
|||
}
|
||||
}
|
||||
|
||||
AddrToLabel::const_iterator iter;
|
||||
if(myReserved.Label.size() > 0)
|
||||
{
|
||||
out << "\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
|
||||
<< "; NON LOCATABLE\n"
|
||||
<< ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n";
|
||||
for(iter = myReserved.Label.begin(); iter != myReserved.Label.end(); ++iter)
|
||||
out << ALIGN(10) << iter->second << " = $" << iter->first << "\n";
|
||||
for(const auto& iter: myReserved.Label)
|
||||
out << ALIGN(10) << iter.second << " = $" << iter.first << "\n";
|
||||
}
|
||||
|
||||
if(myUserLabels.size() > 0)
|
||||
|
@ -1183,10 +1151,10 @@ string CartDebug::saveDisassembly()
|
|||
<< "; USER DEFINED\n"
|
||||
<< ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n";
|
||||
int max_len = 0;
|
||||
for(iter = myUserLabels.begin(); iter != myUserLabels.end(); ++iter)
|
||||
max_len = BSPF_max(max_len, (int)iter->second.size());
|
||||
for(iter = myUserLabels.begin(); iter != myUserLabels.end(); ++iter)
|
||||
out << ALIGN(max_len) << iter->second << " = $" << iter->first << "\n";
|
||||
for(const auto& iter: myUserLabels)
|
||||
max_len = BSPF_max(max_len, (int)iter.second.size());
|
||||
for(const auto& iter: myUserLabels)
|
||||
out << ALIGN(max_len) << iter.second << " = $" << iter.first << "\n";
|
||||
}
|
||||
|
||||
// And finally, output the disassembly
|
||||
|
@ -1230,14 +1198,13 @@ string CartDebug::listConfig(int bank)
|
|||
{
|
||||
BankInfo& info = myBankInfo[b];
|
||||
buf << "[" << b << "]" << endl;
|
||||
for(DirectiveList::const_iterator i = info.directiveList.begin();
|
||||
i != info.directiveList.end(); ++i)
|
||||
for(const auto& i: info.directiveList)
|
||||
{
|
||||
if(i->type != CartDebug::NONE)
|
||||
if(i.type != CartDebug::NONE)
|
||||
{
|
||||
buf << "(*) ";
|
||||
disasmTypeAsString(buf, i->type);
|
||||
buf << " " << Base::HEX4 << i->start << " " << Base::HEX4 << i->end << endl;
|
||||
disasmTypeAsString(buf, i.type);
|
||||
buf << " " << Base::HEX4 << i.start << " " << Base::HEX4 << i.end << endl;
|
||||
}
|
||||
}
|
||||
getBankDirectives(buf, info);
|
||||
|
@ -1291,9 +1258,9 @@ void CartDebug::getCompletions(const char* in, StringList& completions) const
|
|||
|
||||
// Now scan user-defined labels
|
||||
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))
|
||||
completions.push_back(l);
|
||||
}
|
||||
|
|
|
@ -182,19 +182,20 @@ class CartDebug : public DebuggerSystem
|
|||
// The following are convenience methods that query the cartridge object
|
||||
// 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.
|
||||
*/
|
||||
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.
|
||||
|
@ -303,8 +304,8 @@ class CartDebug : public DebuggerSystem
|
|||
<< endl
|
||||
<< "addrlist: ";
|
||||
AddressList::const_iterator i;
|
||||
for(i = b.addressList.begin(); i != b.addressList.end(); ++i)
|
||||
os << HEX4 << *i << " ";
|
||||
for(const auto& i: addressList)
|
||||
os << HEX4 << i << " ";
|
||||
return os;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -557,14 +557,14 @@ bool Debugger::addFunction(const string& name, const string& definition,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::delFunction(const string& name)
|
||||
{
|
||||
FunctionMap::iterator iter = functions.find(name);
|
||||
const auto& iter = functions.find(name);
|
||||
if(iter == functions.end())
|
||||
return false;
|
||||
|
||||
functions.erase(name);
|
||||
delete iter->second;
|
||||
|
||||
FunctionDefMap::iterator def_iter = functionDefs.find(name);
|
||||
const auto& def_iter = functionDefs.find(name);
|
||||
if(def_iter == functionDefs.end())
|
||||
return false;
|
||||
|
||||
|
@ -575,21 +575,15 @@ bool Debugger::delFunction(const string& name)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const Expression* Debugger::getFunction(const string& name) const
|
||||
{
|
||||
FunctionMap::const_iterator iter = functions.find(name);
|
||||
if(iter == functions.end())
|
||||
return 0;
|
||||
else
|
||||
return iter->second;
|
||||
const auto& iter = functions.find(name);
|
||||
return iter != functions.end() ? iter->second : nullptr;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string& Debugger::getFunctionDef(const string& name) const
|
||||
{
|
||||
FunctionDefMap::const_iterator iter = functionDefs.find(name);
|
||||
if(iter == functionDefs.end())
|
||||
return EmptyString;
|
||||
else
|
||||
return iter->second;
|
||||
const auto& iter = functionDefs.find(name);
|
||||
return iter != functionDefs.end() ? iter->second : EmptyString;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -647,10 +641,9 @@ string Debugger::builtinHelp() const
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::getCompletions(const char* in, StringList& list) const
|
||||
{
|
||||
FunctionMap::const_iterator iter;
|
||||
for(iter = functions.begin(); iter != functions.end(); ++iter)
|
||||
for(const auto& iter: functions)
|
||||
{
|
||||
const char* l = iter->first.c_str();
|
||||
const char* l = iter.first.c_str();
|
||||
if(BSPF_equalsIgnoreCase(l, in))
|
||||
list.push_back(l);
|
||||
}
|
||||
|
|
|
@ -602,17 +602,18 @@ bool DebuggerParser::saveScriptFile(string file)
|
|||
ofstream out(file.c_str());
|
||||
|
||||
FunctionDefMap funcs = debugger.getFunctionDefMap();
|
||||
for(FunctionDefMap::const_iterator i = funcs.begin(); i != funcs.end(); ++i)
|
||||
out << "function " << i->first << " { " << i->second << " }" << endl;
|
||||
for(const auto& i: funcs)
|
||||
out << "function " << i.first << " { " << i.second << " }" << endl;
|
||||
|
||||
for(unsigned int i=0; i<watches.size(); i++)
|
||||
out << "watch " << watches[i] << endl;
|
||||
for(const auto& i: watches)
|
||||
out << "watch " << i << endl;
|
||||
|
||||
for(unsigned int i=0; i<0x10000; i++)
|
||||
for(uInt32 i = 0; i < 0x10000; ++i)
|
||||
if(debugger.breakPoint(i))
|
||||
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 w = debugger.writeTrap(i);
|
||||
|
||||
|
@ -625,8 +626,8 @@ bool DebuggerParser::saveScriptFile(string file)
|
|||
}
|
||||
|
||||
StringList conds = debugger.cpuDebug().m6502().getCondBreakNames();
|
||||
for(unsigned int i=0; i<conds.size(); i++)
|
||||
out << "breakif {" << conds[i] << "}" << endl;
|
||||
for(const auto& cond: conds)
|
||||
out << "breakif {" << cond << "}" << endl;
|
||||
|
||||
bool ok = out.good();
|
||||
out.close();
|
||||
|
@ -917,11 +918,11 @@ void DebuggerParser::executeDisasm()
|
|||
// "dump"
|
||||
void DebuggerParser::executeDump()
|
||||
{
|
||||
for(int i=0; i<8; i++)
|
||||
for(int i = 0; i < 8; ++i)
|
||||
{
|
||||
int start = args[0] + i*16;
|
||||
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)) << " ";
|
||||
if(j == 7) commandResult << "- ";
|
||||
|
@ -1046,7 +1047,7 @@ void DebuggerParser::executeListbreaks()
|
|||
ostringstream buf;
|
||||
int count = 0;
|
||||
|
||||
for(unsigned int i = 0; i < 0x10000; i++)
|
||||
for(uInt32 i = 0; i < 0x10000; i++)
|
||||
{
|
||||
if(debugger.breakpoints().isSet(i))
|
||||
{
|
||||
|
@ -1068,7 +1069,7 @@ void DebuggerParser::executeListbreaks()
|
|||
if(conds.size() > 0)
|
||||
{
|
||||
commandResult << "\nbreakifs:\n";
|
||||
for(unsigned int i = 0; i < conds.size(); i++)
|
||||
for(uInt32 i = 0; i < conds.size(); i++)
|
||||
{
|
||||
commandResult << i << ": " << conds[i];
|
||||
if(i != (conds.size() - 1)) commandResult << endl;
|
||||
|
@ -1097,9 +1098,8 @@ void DebuggerParser::executeListfunctions()
|
|||
|
||||
if(functions.size() > 0)
|
||||
{
|
||||
FunctionDefMap::const_iterator iter;
|
||||
for(iter = functions.begin(); iter != functions.end(); ++iter)
|
||||
commandResult << iter->first << " -> " << iter->second << endl;
|
||||
for(const auto& iter: functions)
|
||||
commandResult << iter.first << " -> " << iter.second << endl;
|
||||
}
|
||||
else
|
||||
commandResult << "no user-defined functions";
|
||||
|
@ -1111,7 +1111,7 @@ void DebuggerParser::executeListtraps()
|
|||
{
|
||||
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))
|
||||
{
|
||||
|
@ -1231,7 +1231,7 @@ void DebuggerParser::executeRiot()
|
|||
void DebuggerParser::executeRom()
|
||||
{
|
||||
int addr = args[0];
|
||||
for(int i=1; i<argCount; i++)
|
||||
for(int i = 1; i < argCount; ++i)
|
||||
{
|
||||
if( !(debugger.patchROM(addr++, args[i])) )
|
||||
{
|
||||
|
|
|
@ -1051,10 +1051,8 @@ DONE_WITH_ADD:
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DiStella::processDirectives(const CartDebug::DirectiveList& directives)
|
||||
{
|
||||
for(CartDebug::DirectiveList::const_iterator i = directives.begin();
|
||||
i != directives.end(); ++i)
|
||||
for(const auto& tag: directives)
|
||||
{
|
||||
const CartDebug::DirectiveTag& tag = *i;
|
||||
if(check_range(tag.start, tag.end))
|
||||
for(uInt32 k = tag.start; k <= tag.end; ++k)
|
||||
mark(k, tag.type, true);
|
||||
|
|
|
@ -72,8 +72,6 @@ Console::Console(OSystem& osystem, Cartridge& cart, const Properties& props)
|
|||
myEvent(osystem.eventHandler().event()),
|
||||
myProperties(props),
|
||||
myTIA(0),
|
||||
mySwitches(0),
|
||||
mySystem(0),
|
||||
myCMHandler(0),
|
||||
myDisplayFormat(""), // Unknown TV format @ start
|
||||
myFramerate(0.0), // Unknown framerate @ start
|
||||
|
@ -84,10 +82,10 @@ Console::Console(OSystem& osystem, Cartridge& cart, const Properties& props)
|
|||
loadUserPalette();
|
||||
|
||||
// Create switches for the console
|
||||
mySwitches = new Switches(myEvent, myProperties);
|
||||
mySwitches = make_ptr<Switches>(myEvent, myProperties);
|
||||
|
||||
// Construct the system and components
|
||||
mySystem = new System(osystem);
|
||||
mySystem = make_ptr<System>(osystem);
|
||||
|
||||
// The real controllers for this console will be added later
|
||||
// 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()
|
||||
{
|
||||
delete mySystem;
|
||||
delete mySwitches;
|
||||
delete myCMHandler;
|
||||
delete myControllers[0];
|
||||
delete myControllers[1];
|
||||
|
|
|
@ -346,10 +346,10 @@ class Console : public Serializable
|
|||
TIA* myTIA;
|
||||
|
||||
// Pointer to the switches on the front of the console
|
||||
Switches* mySwitches;
|
||||
unique_ptr<Switches> mySwitches;
|
||||
|
||||
// Pointer to the 6502 based system being emulated
|
||||
System* mySystem;
|
||||
unique_ptr<System> mySystem;
|
||||
|
||||
// Pointer to the 6532 (aka RIOT) (the debugger needs it)
|
||||
// A RIOT of my own! (...with apologies to The Clash...)
|
||||
|
|
|
@ -58,13 +58,11 @@
|
|||
EventHandler::EventHandler(OSystem& osystem)
|
||||
: myOSystem(osystem),
|
||||
myOverlay(NULL),
|
||||
myMouseControl(NULL),
|
||||
myState(S_NONE),
|
||||
myAllowAllDirectionsFlag(false),
|
||||
myFryingFlag(false),
|
||||
myUseCtrlKeyFlag(true),
|
||||
mySkipMouseMotion(true),
|
||||
myJoyHandler(NULL)
|
||||
mySkipMouseMotion(true)
|
||||
{
|
||||
// Erase the key mapping array
|
||||
for(int i = 0; i < KBDK_LAST; ++i)
|
||||
|
@ -77,7 +75,7 @@ EventHandler::EventHandler(OSystem& osystem)
|
|||
myComboTable[i][j] = Event::NoType;
|
||||
|
||||
// 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)
|
||||
if(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)
|
||||
{
|
||||
// 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 i = 0; i < KBDK_LAST; ++i)
|
||||
myKeyTable[i][mode] = (Event::Type) *event++;
|
||||
|
@ -1781,8 +1776,6 @@ void EventHandler::setMouseControllerMode(const string& enable)
|
|||
{
|
||||
if(myOSystem.hasConsole())
|
||||
{
|
||||
delete myMouseControl; myMouseControl = NULL;
|
||||
|
||||
bool usemouse = false;
|
||||
if(BSPF_equalsIgnoreCase(enable, "always"))
|
||||
usemouse = true;
|
||||
|
@ -1821,7 +1814,7 @@ void EventHandler::setMouseControllerMode(const string& enable)
|
|||
const string& control = usemouse ?
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -540,7 +540,7 @@ class EventHandler
|
|||
|
||||
// MouseControl object, which takes care of switching the mouse between
|
||||
// all possible controller modes
|
||||
MouseControl* myMouseControl;
|
||||
unique_ptr<MouseControl> myMouseControl;
|
||||
|
||||
// Array of key events, indexed by StellaKey
|
||||
Event::Type myKeyTable[KBDK_LAST][kNumModes];
|
||||
|
@ -581,7 +581,7 @@ class EventHandler
|
|||
static const Event::Type SA_Key[2][12];
|
||||
|
||||
// Handler for all joystick addition/removal/mapping
|
||||
JoystickHandler* myJoyHandler;
|
||||
unique_ptr<JoystickHandler> myJoyHandler;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -139,7 +139,7 @@ bool EventHandler::StellaJoystick::setMap(const string& m)
|
|||
if((int)map.size() == numAxes * 2 * kNumModes)
|
||||
{
|
||||
// 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 a = 0; a < numAxes; ++a)
|
||||
for(int k = 0; k < 2; ++k)
|
||||
|
@ -148,7 +148,7 @@ bool EventHandler::StellaJoystick::setMap(const string& m)
|
|||
getValues(items[2], map);
|
||||
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 b = 0; b < numButtons; ++b)
|
||||
btnTable[b][m] = (Event::Type) *event++;
|
||||
|
@ -156,7 +156,7 @@ bool EventHandler::StellaJoystick::setMap(const string& m)
|
|||
getValues(items[3], map);
|
||||
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 h = 0; h < numHats; ++h)
|
||||
for(int k = 0; k < 4; ++k)
|
||||
|
@ -260,9 +260,8 @@ EventHandler::JoystickHandler::JoystickHandler(OSystem& system)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
EventHandler::JoystickHandler::~JoystickHandler()
|
||||
{
|
||||
map<string,StickInfo>::const_iterator it;
|
||||
for(it = myDatabase.begin(); it != myDatabase.end(); ++it)
|
||||
delete it->second.joy;
|
||||
for(const auto& i: myDatabase)
|
||||
delete i.second.joy;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -270,14 +269,13 @@ void EventHandler::JoystickHandler::printDatabase() const
|
|||
{
|
||||
cerr << "---------------------------------------------------------" << endl
|
||||
<< "joy database:" << endl;
|
||||
map<string,StickInfo>::const_iterator it;
|
||||
for(it = myDatabase.begin(); it != myDatabase.end(); ++it)
|
||||
cerr << it->first << endl << it->second << endl << endl;
|
||||
for(const auto& i: myDatabase)
|
||||
cerr << i.first << endl << i.second << endl << endl;
|
||||
|
||||
cerr << "---------------------------------------------------------" << endl
|
||||
<< "joy active:" << endl;
|
||||
for(uInt32 i = 0; i < mySticks.size(); ++i)
|
||||
cerr << *mySticks[i] << endl;
|
||||
for(const auto& i: mySticks)
|
||||
cerr << i << endl;
|
||||
cerr << endl;
|
||||
}
|
||||
|
||||
|
@ -291,7 +289,7 @@ int EventHandler::JoystickHandler::add(StellaJoystick* stick)
|
|||
// Figure out what type of joystick this is
|
||||
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
|
||||
// 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;
|
||||
}
|
||||
else if(stick->name.find("Stelladaptor", 0) != string::npos)
|
||||
else if(BSPF_containsIgnoreCase(stick->name, "Stelladaptor"))
|
||||
{
|
||||
stick->name = "Stelladaptor";
|
||||
specialAdaptor = true;
|
||||
|
@ -315,9 +313,8 @@ int EventHandler::JoystickHandler::add(StellaJoystick* stick)
|
|||
{
|
||||
// We need unique names for mappable devices
|
||||
int count = 0;
|
||||
map<string,StickInfo>::const_iterator c_it;
|
||||
for(c_it = myDatabase.begin(); c_it != myDatabase.end(); ++c_it)
|
||||
if(BSPF_startsWithIgnoreCase(c_it->first, stick->name))
|
||||
for(const auto& i: myDatabase)
|
||||
if(BSPF_startsWithIgnoreCase(i.first, stick->name))
|
||||
++count;
|
||||
|
||||
if(count > 1)
|
||||
|
@ -335,7 +332,7 @@ int EventHandler::JoystickHandler::add(StellaJoystick* stick)
|
|||
mapStelladaptors(myOSystem.settings().getString("saport"));
|
||||
|
||||
// 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
|
||||
{
|
||||
it->second.joy = stick;
|
||||
|
@ -364,7 +361,7 @@ int EventHandler::JoystickHandler::remove(int 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)
|
||||
{
|
||||
ostringstream buf;
|
||||
|
@ -398,33 +395,33 @@ void EventHandler::JoystickHandler::mapStelladaptors(const string& saport)
|
|||
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)
|
||||
{
|
||||
mySticks[i]->name += " (emulates left joystick port)";
|
||||
mySticks[i]->type = StellaJoystick::JT_STELLADAPTOR_LEFT;
|
||||
stick->name += " (emulates left joystick port)";
|
||||
stick->type = StellaJoystick::JT_STELLADAPTOR_LEFT;
|
||||
}
|
||||
else if(saOrder[saCount] == 2)
|
||||
{
|
||||
mySticks[i]->name += " (emulates right joystick port)";
|
||||
mySticks[i]->type = StellaJoystick::JT_STELLADAPTOR_RIGHT;
|
||||
stick->name += " (emulates right joystick port)";
|
||||
stick->type = StellaJoystick::JT_STELLADAPTOR_RIGHT;
|
||||
}
|
||||
saCount++;
|
||||
}
|
||||
else if(BSPF_startsWithIgnoreCase(mySticks[i]->name, "2600-daptor"))
|
||||
else if(BSPF_startsWithIgnoreCase(stick->name, "2600-daptor"))
|
||||
{
|
||||
if(saOrder[saCount] == 1)
|
||||
{
|
||||
mySticks[i]->name += " (emulates left joystick port)";
|
||||
mySticks[i]->type = StellaJoystick::JT_2600DAPTOR_LEFT;
|
||||
stick->name += " (emulates left joystick port)";
|
||||
stick->type = StellaJoystick::JT_2600DAPTOR_LEFT;
|
||||
}
|
||||
else if(saOrder[saCount] == 2)
|
||||
{
|
||||
mySticks[i]->name += " (emulates right joystick port)";
|
||||
mySticks[i]->type = StellaJoystick::JT_2600DAPTOR_RIGHT;
|
||||
stick->name += " (emulates right joystick port)";
|
||||
stick->type = StellaJoystick::JT_2600DAPTOR_RIGHT;
|
||||
}
|
||||
saCount++;
|
||||
}
|
||||
|
@ -531,13 +528,13 @@ void EventHandler::JoystickHandler::eraseMapping(Event::Type event, EventMode mo
|
|||
// Otherwise, only reset the given event
|
||||
if(event == Event::NoType)
|
||||
{
|
||||
for(uInt32 i = 0; i < mySticks.size(); ++i)
|
||||
mySticks[i]->eraseMap(mode); // erase all events
|
||||
for(auto stick: mySticks)
|
||||
stick->eraseMap(mode); // erase all events
|
||||
}
|
||||
else
|
||||
{
|
||||
for(uInt32 i = 0; i < mySticks.size(); ++i)
|
||||
mySticks[i]->eraseEvent(event, mode); // only reset the specific event
|
||||
for(auto stick: mySticks)
|
||||
stick->eraseEvent(event, mode); // only reset the specific event
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -549,12 +546,9 @@ void EventHandler::JoystickHandler::saveMapping()
|
|||
ostringstream joybuf;
|
||||
joybuf << Event::LastType;
|
||||
|
||||
map<string,StickInfo>::const_iterator it;
|
||||
for(it = myDatabase.begin(); it != myDatabase.end(); ++it)
|
||||
for(const auto& i: myDatabase)
|
||||
{
|
||||
const string& map = it->second.joy ?
|
||||
it->second.joy->getMap() : it->second.mapping;
|
||||
|
||||
const string& map = i.second.joy ? i.second.joy->getMap() : i.second.mapping;
|
||||
if(map != "")
|
||||
joybuf << "^" << map;
|
||||
}
|
||||
|
|
|
@ -70,8 +70,8 @@ bool FilesystemNode::getChildren(FSList& fslist, ListMode mode, bool hidden) con
|
|||
if (!_realNode->getChildren(tmp, mode, hidden))
|
||||
return false;
|
||||
|
||||
for (AbstractFSList::iterator i = tmp.begin(); i != tmp.end(); ++i)
|
||||
fslist.push_back(FilesystemNode(*i));
|
||||
for (const auto& i: tmp)
|
||||
fslist.push_back(FilesystemNode(i));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -49,22 +49,15 @@
|
|||
FrameBuffer::FrameBuffer(OSystem& osystem)
|
||||
: myOSystem(osystem),
|
||||
myInitializedCount(0),
|
||||
myPausedCount(0),
|
||||
myTIASurface(NULL)
|
||||
myPausedCount(0)
|
||||
{
|
||||
myMsg.surface = myStatsMsg.surface = NULL;
|
||||
myMsg.surface = myStatsMsg.surface = nullptr;
|
||||
myMsg.enabled = myStatsMsg.enabled = false;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FrameBuffer::~FrameBuffer(void)
|
||||
FrameBuffer::~FrameBuffer()
|
||||
{
|
||||
delete myFont;
|
||||
delete myInfoFont;
|
||||
delete mySmallFont;
|
||||
delete myLauncherFont;
|
||||
delete myTIASurface;
|
||||
|
||||
// Free all allocated surfaces
|
||||
while(!mySurfaceList.empty())
|
||||
{
|
||||
|
@ -107,15 +100,15 @@ bool FrameBuffer::initialize()
|
|||
// 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
|
||||
// use it
|
||||
mySmallFont = new GUI::Font(GUI::stellaDesc);
|
||||
mySmallFont = make_ptr<GUI::Font>(GUI::stellaDesc);
|
||||
|
||||
// The general font used in all UI elements
|
||||
// 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
|
||||
// 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
|
||||
// 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");
|
||||
if(lf == "small")
|
||||
myLauncherFont = new GUI::Font(GUI::consoleDesc);
|
||||
myLauncherFont = make_ptr<GUI::Font>(GUI::consoleDesc);
|
||||
else if(lf == "medium")
|
||||
myLauncherFont = new GUI::Font(GUI::stellaMediumDesc);
|
||||
myLauncherFont = make_ptr<GUI::Font>(GUI::stellaMediumDesc);
|
||||
else
|
||||
myLauncherFont = new GUI::Font(GUI::stellaLargeDesc);
|
||||
myLauncherFont = make_ptr<GUI::Font>(GUI::stellaLargeDesc);
|
||||
}
|
||||
else
|
||||
myLauncherFont = new GUI::Font(GUI::stellaDesc);
|
||||
myLauncherFont = make_ptr<GUI::Font>(GUI::stellaDesc);
|
||||
|
||||
// Determine possible TIA windowed zoom levels
|
||||
uInt32 maxZoom = maxWindowSizeForScreen((uInt32)kTIAMinW, (uInt32)kTIAMinH,
|
||||
|
@ -160,7 +153,7 @@ bool FrameBuffer::initialize()
|
|||
FBSurface::setPalette(myPalette);
|
||||
|
||||
// Create a TIA surface; we need it for rendering TIA images
|
||||
myTIASurface = new TIASurface(myOSystem);
|
||||
myTIASurface = make_ptr<TIASurface>(myOSystem);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -241,12 +234,12 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
|
|||
myStatsMsg.w = infoFont().getMaxCharWidth() * 24 + 2;
|
||||
myStatsMsg.h = (infoFont().getFontHeight() + 2) * 2;
|
||||
|
||||
if(myStatsMsg.surface == NULL)
|
||||
if(myStatsMsg.surface == nullptr)
|
||||
{
|
||||
uInt32 surfaceID = allocateSurface(myStatsMsg.w, myStatsMsg.h);
|
||||
myStatsMsg.surface = surface(surfaceID);
|
||||
}
|
||||
if(myMsg.surface == NULL)
|
||||
if(myMsg.surface == nullptr)
|
||||
{
|
||||
uInt32 surfaceID = allocateSurface((uInt32)kFBMinW, font().getFontHeight()+10);
|
||||
myMsg.surface = surface(surfaceID);
|
||||
|
@ -589,8 +582,8 @@ uInt32 FrameBuffer::allocateSurface(int w, int h, const uInt32* data)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FBSurface* FrameBuffer::surface(uInt32 id) const
|
||||
{
|
||||
map<uInt32,FBSurface*>::const_iterator iter = mySurfaceList.find(id);
|
||||
return iter != mySurfaceList.end() ? iter->second : NULL;
|
||||
const auto& iter = mySurfaceList.find(id);
|
||||
return iter != mySurfaceList.end() ? iter->second : nullptr;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -602,11 +595,10 @@ void FrameBuffer::resetSurfaces()
|
|||
// Any derived FrameBuffer classes that call this method should be
|
||||
// aware of these restrictions, and act accordingly
|
||||
|
||||
map<uInt32,FBSurface*>::iterator iter;
|
||||
for(iter = mySurfaceList.begin(); iter != mySurfaceList.end(); ++iter)
|
||||
iter->second->free();
|
||||
for(iter = mySurfaceList.begin(); iter != mySurfaceList.end(); ++iter)
|
||||
iter->second->reload();
|
||||
for(auto& s: mySurfaceList)
|
||||
s.second->free();
|
||||
for(auto& s: mySurfaceList)
|
||||
s.second->reload();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -743,8 +735,8 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
|
|||
{
|
||||
myWindowedModeList.clear();
|
||||
|
||||
for(uInt32 i = 0; i < myFullscreenModeLists.size(); ++i)
|
||||
myFullscreenModeLists[i].clear();
|
||||
for(auto& mode: myFullscreenModeLists)
|
||||
mode.clear();
|
||||
for(uInt32 i = myFullscreenModeLists.size(); i < myDisplays.size(); ++i)
|
||||
myFullscreenModeLists.push_back(VideoModeList());
|
||||
|
||||
|
|
|
@ -534,19 +534,19 @@ class FrameBuffer
|
|||
VariantList myRenderers;
|
||||
|
||||
// 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
|
||||
GUI::Font* myInfoFont;
|
||||
unique_ptr<GUI::Font> myInfoFont;
|
||||
|
||||
// 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
|
||||
GUI::Font* myLauncherFont;
|
||||
unique_ptr<GUI::Font> myLauncherFont;
|
||||
|
||||
// The TIASurface class takes responsibility for TIA rendering
|
||||
TIASurface* myTIASurface;
|
||||
unique_ptr<TIASurface> myTIASurface;
|
||||
|
||||
// Used for onscreen messages and frame statistics
|
||||
// (scanline count and framerate)
|
||||
|
|
|
@ -20,15 +20,21 @@
|
|||
#ifndef MEDIA_FACTORY_HXX
|
||||
#define MEDIA_FACTORY_HXX
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
||||
#include "OSystem.hxx"
|
||||
#include "Settings.hxx"
|
||||
#include "SerialPort.hxx"
|
||||
#if defined(BSPF_UNIX)
|
||||
#include "SerialPortUNIX.hxx"
|
||||
#include "SettingsUNIX.hxx"
|
||||
#include "OSystemUNIX.hxx"
|
||||
#elif defined(BSPF_WINDOWS)
|
||||
#include "SerialPortWINDOWS.hxx"
|
||||
#include "SettingsWINDOWS.hxx"
|
||||
#include "OSystemWINDOWS.hxx"
|
||||
#elif defined(BSPF_MAC_OSX)
|
||||
#include "SerialPortMACOSX.hxx"
|
||||
#include "SettingsMACOSX.hxx"
|
||||
#include "OSystemMACOSX.hxx"
|
||||
extern "C" {
|
||||
|
@ -61,49 +67,62 @@
|
|||
class MediaFactory
|
||||
{
|
||||
public:
|
||||
static OSystem* createOSystem()
|
||||
static unique_ptr<OSystem> createOSystem()
|
||||
{
|
||||
#if defined(BSPF_UNIX)
|
||||
return new OSystemUNIX();
|
||||
return make_ptr<OSystemUNIX>();
|
||||
#elif defined(BSPF_WINDOWS)
|
||||
return new OSystemWINDOWS();
|
||||
return make_ptr<OSystemWINDOWS>();
|
||||
#elif defined(BSPF_MAC_OSX)
|
||||
return new OSystemMACOSX();
|
||||
return make_ptr<OSystemMACOSX>();
|
||||
#else
|
||||
#error Unsupported platform for OSystem!
|
||||
#endif
|
||||
}
|
||||
|
||||
static Settings* createSettings(OSystem& osystem)
|
||||
static unique_ptr<Settings> createSettings(OSystem& osystem)
|
||||
{
|
||||
#if defined(BSPF_UNIX)
|
||||
return new SettingsUNIX(osystem);
|
||||
return make_ptr<SettingsUNIX>(osystem);
|
||||
#elif defined(BSPF_WINDOWS)
|
||||
return new SettingsWINDOWS(osystem);
|
||||
return make_ptr<SettingsWINDOWS>(osystem);
|
||||
#elif defined(BSPF_MAC_OSX)
|
||||
return new SettingsMACOSX(osystem);
|
||||
return make_ptr<SettingsMACOSX>(osystem);
|
||||
#else
|
||||
#error Unsupported platform for Settings!
|
||||
#endif
|
||||
}
|
||||
|
||||
static FrameBuffer* createVideo(OSystem& osystem)
|
||||
static unique_ptr<SerialPort> createSerialPort()
|
||||
{
|
||||
return new FrameBufferSDL2(osystem);
|
||||
}
|
||||
|
||||
static Sound* createAudio(OSystem& osystem)
|
||||
{
|
||||
#ifdef SOUND_SUPPORT
|
||||
return new SoundSDL2(osystem);
|
||||
#if defined(BSPF_UNIX)
|
||||
return make_ptr<SerialPortUNIX>();
|
||||
#elif defined(BSPF_WINDOWS)
|
||||
return make_ptr<SerialPortWINDOWS>();
|
||||
#elif defined(BSPF_MAC_OSX)
|
||||
return make_ptr<SerialPortMACOSX>();
|
||||
#else
|
||||
return new SoundNull(osystem);
|
||||
return make_ptr<SerialPort>();
|
||||
#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"
|
||||
#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 "MD5.hxx"
|
||||
#include "Cart.hxx"
|
||||
|
@ -60,6 +51,7 @@
|
|||
#include "Widget.hxx"
|
||||
#include "Console.hxx"
|
||||
#include "Random.hxx"
|
||||
#include "SerialPort.hxx"
|
||||
#include "StateManager.hxx"
|
||||
#include "Version.hxx"
|
||||
|
||||
|
@ -67,21 +59,9 @@
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
OSystem::OSystem()
|
||||
: myEventHandler(NULL),
|
||||
myFrameBuffer(NULL),
|
||||
mySound(NULL),
|
||||
mySettings(NULL),
|
||||
myPropSet(NULL),
|
||||
myConsole(NULL),
|
||||
mySerialPort(NULL),
|
||||
myMenu(NULL),
|
||||
myCommandMenu(NULL),
|
||||
myLauncher(NULL),
|
||||
: myConsole(nullptr),
|
||||
myLauncherUsed(false),
|
||||
myDebugger(NULL),
|
||||
myCheatManager(NULL),
|
||||
myStateManager(NULL),
|
||||
myPNGLib(NULL),
|
||||
myDebugger(nullptr),
|
||||
myQuitLoop(false),
|
||||
myRomFile(""),
|
||||
myRomMD5(""),
|
||||
|
@ -116,43 +96,17 @@ OSystem::OSystem()
|
|||
myBuildInfo = info.str();
|
||||
|
||||
mySettings = MediaFactory::createSettings(*this);
|
||||
myRandom = new Random(*this);
|
||||
myRandom = make_ptr<Random>(*this);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
OSystem::~OSystem()
|
||||
{
|
||||
delete myMenu;
|
||||
delete myCommandMenu;
|
||||
delete myLauncher;
|
||||
|
||||
// Remove any game console that is currently attached
|
||||
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
|
||||
delete myDebugger;
|
||||
#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();
|
||||
|
||||
// Create a properties set for us to use and set it up
|
||||
myPropSet = new PropertiesSet(propertiesFile());
|
||||
myPropSet = make_ptr<PropertiesSet>(propertiesFile());
|
||||
|
||||
#ifdef CHEATCODE_SUPPORT
|
||||
myCheatManager = new CheatManager(*this);
|
||||
myCheatManager = make_ptr<CheatManager>(*this);
|
||||
myCheatManager->loadCheatDatabase();
|
||||
#endif
|
||||
|
||||
// Create menu and launcher GUI objects
|
||||
myMenu = new Menu(*this);
|
||||
myCommandMenu = new CommandMenu(*this);
|
||||
myLauncher = new Launcher(*this);
|
||||
myStateManager = new StateManager(*this);
|
||||
myMenu = make_ptr<Menu>(*this);
|
||||
myCommandMenu = make_ptr<CommandMenu>(*this);
|
||||
myLauncher = make_ptr<Launcher>(*this);
|
||||
myStateManager = make_ptr<StateManager>(*this);
|
||||
|
||||
// Create the sound object; the sound subsystem isn't actually
|
||||
// opened until needed, so this is non-blocking (on those systems
|
||||
|
@ -206,25 +160,16 @@ bool OSystem::create()
|
|||
// Create the serial port object
|
||||
// This is used by any controller that wants to directly access
|
||||
// a real serial port on the system
|
||||
#if defined(BSPF_UNIX)
|
||||
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
|
||||
mySerialPort = MediaFactory::createSerialPort();
|
||||
|
||||
// Re-initialize random seed
|
||||
myRandom->initSeed();
|
||||
|
||||
// Create PNG handler
|
||||
myPNGLib = new PNGLibrary(*myFrameBuffer);
|
||||
myPNGLib = make_ptr<PNGLibrary>(*myFrameBuffer);
|
||||
|
||||
// Create ZIP handler
|
||||
myZipHandler = new ZipHandler();
|
||||
myZipHandler = make_ptr<ZipHandler>();
|
||||
|
||||
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:
|
||||
// Pointer to the EventHandler object
|
||||
EventHandler* myEventHandler;
|
||||
unique_ptr<EventHandler> myEventHandler;
|
||||
|
||||
// Pointer to the FrameBuffer object
|
||||
FrameBuffer* myFrameBuffer;
|
||||
unique_ptr<FrameBuffer> myFrameBuffer;
|
||||
|
||||
// Pointer to the Sound object
|
||||
Sound* mySound;
|
||||
unique_ptr<Sound> mySound;
|
||||
|
||||
// Pointer to the Settings object
|
||||
Settings* mySettings;
|
||||
unique_ptr<Settings> mySettings;
|
||||
|
||||
// Pointer to the Random object
|
||||
Random* myRandom;
|
||||
unique_ptr<Random> myRandom;
|
||||
|
||||
// Pointer to the PropertiesSet object
|
||||
PropertiesSet* myPropSet;
|
||||
unique_ptr<PropertiesSet> myPropSet;
|
||||
|
||||
// Pointer to the (currently defined) Console object
|
||||
Console* myConsole;
|
||||
|
||||
// Pointer to the serial port object
|
||||
SerialPort* mySerialPort;
|
||||
unique_ptr<SerialPort> mySerialPort;
|
||||
|
||||
// Pointer to the Menu object
|
||||
Menu* myMenu;
|
||||
unique_ptr<Menu> myMenu;
|
||||
|
||||
// Pointer to the CommandMenu object
|
||||
CommandMenu* myCommandMenu;
|
||||
unique_ptr<CommandMenu> myCommandMenu;
|
||||
|
||||
// Pointer to the Launcher object
|
||||
Launcher* myLauncher;
|
||||
unique_ptr<Launcher> myLauncher;
|
||||
bool myLauncherUsed;
|
||||
|
||||
// Pointer to the Debugger object
|
||||
Debugger* myDebugger;
|
||||
|
||||
// Pointer to the CheatManager object
|
||||
CheatManager* myCheatManager;
|
||||
unique_ptr<CheatManager> myCheatManager;
|
||||
|
||||
// Pointer to the StateManager object
|
||||
StateManager* myStateManager;
|
||||
unique_ptr<StateManager> myStateManager;
|
||||
|
||||
// PNG object responsible for loading/saving PNG images
|
||||
PNGLibrary* myPNGLib;
|
||||
unique_ptr<PNGLibrary> myPNGLib;
|
||||
|
||||
// The list of log messages
|
||||
string myLogMessages;
|
||||
|
@ -519,7 +519,7 @@ class OSystem
|
|||
bool myQuitLoop;
|
||||
|
||||
// ZIP static reference variable responsible for accessing ZIP files
|
||||
static ZipHandler* myZipHandler;
|
||||
static unique_ptr<ZipHandler> myZipHandler;
|
||||
|
||||
private:
|
||||
string myBaseDir;
|
||||
|
|
|
@ -73,9 +73,8 @@ bool PropertiesSet::save(const string& filename) const
|
|||
return false;
|
||||
|
||||
// Only save those entries in the external list
|
||||
for(PropsList::const_iterator i = myExternalProps.begin();
|
||||
i != myExternalProps.end(); ++i)
|
||||
i->second.save(out);
|
||||
for(const auto& i: myExternalProps)
|
||||
i.second.save(out);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -99,18 +98,18 @@ bool PropertiesSet::getMD5(const string& md5, Properties& properties,
|
|||
if(!useDefaults)
|
||||
{
|
||||
// Check external list
|
||||
PropsList::const_iterator iter = myExternalProps.find(md5);
|
||||
if(iter != myExternalProps.end())
|
||||
const auto ext = myExternalProps.find(md5);
|
||||
if(ext != myExternalProps.end())
|
||||
{
|
||||
properties = iter->second;
|
||||
properties = ext->second;
|
||||
found = true;
|
||||
}
|
||||
else // Search temp list
|
||||
{
|
||||
iter = myTempProps.find(md5);
|
||||
if(iter != myTempProps.end())
|
||||
const auto tmp = myTempProps.find(md5);
|
||||
if(tmp != myTempProps.end())
|
||||
{
|
||||
properties = iter->second;
|
||||
properties = tmp->second;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
@ -178,8 +177,7 @@ void PropertiesSet::insert(const Properties& properties, bool save)
|
|||
// The status of 'save' determines which list to save to
|
||||
PropsList& list = save ? myExternalProps : myTempProps;
|
||||
|
||||
pair<PropsList::iterator,bool> ret;
|
||||
ret = list.insert(make_pair(md5, properties));
|
||||
auto ret = list.insert(make_pair(md5, properties));
|
||||
if(ret.second == false)
|
||||
{
|
||||
// Remove old item and insert again
|
||||
|
@ -227,6 +225,6 @@ void PropertiesSet::print() const
|
|||
|
||||
// Now, print the resulting list
|
||||
Properties::printHeader();
|
||||
for(PropsList::const_iterator i = list.begin(); i != list.end(); ++i)
|
||||
i->second.print();
|
||||
for(const auto& i: list)
|
||||
i.second.print();
|
||||
}
|
||||
|
|
|
@ -40,37 +40,35 @@ GameList::~GameList()
|
|||
void GameList::appendGame(const string& name, const string& path,
|
||||
const string& md5, bool isDir)
|
||||
{
|
||||
myArray.push_back(Entry(name, path, md5, isDir));
|
||||
myArray.emplace_back(name, path, md5, isDir);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void GameList::sortByName()
|
||||
{
|
||||
if(myArray.size() <= 1)
|
||||
if(myArray.size() < 2)
|
||||
return;
|
||||
|
||||
sort(myArray.begin(), myArray.end());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool GameList::Entry::operator< (const Entry& g) const
|
||||
{
|
||||
string::const_iterator it1 = _name.begin();
|
||||
string::const_iterator it2 = g._name.begin();
|
||||
|
||||
// Account for ending ']' character in directory entries
|
||||
string::const_iterator end1 = _isdir ? _name.end() - 1 : _name.end();
|
||||
string::const_iterator end2 = g._isdir ? g._name.end() - 1 : g._name.end();
|
||||
|
||||
// Stop when either string's end has been reached
|
||||
while((it1 != end1) && (it2 != end2))
|
||||
{
|
||||
if(toupper(*it1) != toupper(*it2)) // letters differ?
|
||||
return toupper(*it1) < toupper(*it2);
|
||||
|
||||
// proceed to the next character in each string
|
||||
++it1;
|
||||
++it2;
|
||||
}
|
||||
return _name.size() < g._name.size();
|
||||
auto cmp = [](const Entry& a, const Entry& b)
|
||||
{
|
||||
auto it1 = a._name.begin(), it2 = b._name.begin();
|
||||
|
||||
// Account for ending ']' character in directory entries
|
||||
auto end1 = a._isdir ? a._name.end() - 1 : a._name.end();
|
||||
auto end2 = b._isdir ? b._name.end() - 1 : b._name.end();
|
||||
|
||||
// Stop when either string's end has been reached
|
||||
while((it1 != end1) && (it2 != end2))
|
||||
{
|
||||
if(toupper(*it1) != toupper(*it2)) // letters differ?
|
||||
return toupper(*it1) < toupper(*it2);
|
||||
|
||||
// proceed to the next character in each string
|
||||
++it1;
|
||||
++it2;
|
||||
}
|
||||
return a._name.size() < b._name.size();
|
||||
};
|
||||
|
||||
sort(myArray.begin(), myArray.end(), cmp);
|
||||
}
|
||||
|
|
|
@ -65,8 +65,6 @@ class GameList
|
|||
{
|
||||
_name = name; _path = path; _md5 = md5; _isdir = isdir;
|
||||
}
|
||||
|
||||
bool operator < (const Entry& a) const;
|
||||
};
|
||||
vector<Entry> myArray;
|
||||
};
|
||||
|
|
|
@ -95,14 +95,14 @@ void ListWidget::setSelected(const string& item)
|
|||
else
|
||||
{
|
||||
uInt32 itemToSelect = 0;
|
||||
StringList::const_iterator iter;
|
||||
for(iter = _list.begin(); iter != _list.end(); ++iter, ++itemToSelect)
|
||||
for(const auto& iter: _list)
|
||||
{
|
||||
if(item == *iter)
|
||||
if(item == iter)
|
||||
{
|
||||
selected = itemToSelect;
|
||||
break;
|
||||
}
|
||||
++itemToSelect;
|
||||
}
|
||||
if(itemToSelect > _list.size() || selected == -1)
|
||||
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
|
||||
// implementation :-)
|
||||
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;
|
||||
break;
|
||||
|
|
|
@ -76,8 +76,8 @@ int main(int ac, char* av[])
|
|||
if(result > 0)
|
||||
{
|
||||
cout << setw(3) << result << " hits: \'" << av[2] << "\' - \"" << av[1] << "\" @";
|
||||
for(list<int>::iterator it = locations.begin(); it != locations.end(); ++it)
|
||||
cout << ' ' << hex << ((int)*it + offset);
|
||||
for(const auto& it: locations)
|
||||
cout << ' ' << hex << (it + offset);
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue