Second pass at cleaning up warnings generated by -Weverything in clang.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3204 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2015-09-14 18:14:00 +00:00
parent f539cef173
commit 687b638437
70 changed files with 291 additions and 261 deletions

View File

@ -74,7 +74,7 @@ bool CheatManager::add(const string& name, const string& code,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheatManager::remove(int idx)
{
if((uInt32)idx < myCheatList.size())
if(uInt32(idx) < myCheatList.size())
{
// This will also remove it from the per-frame list (if applicable)
myCheatList[idx]->disable();
@ -343,6 +343,6 @@ bool CheatManager::isValidCode(const string& code) const
if(!isxdigit(c))
return false;
uInt32 length = (uInt32)code.length();
uInt32 length = uInt32(code.length());
return (length == 4 || length == 6 || length == 8);
}

View File

@ -28,8 +28,8 @@
RamCheat::RamCheat(OSystem& os, const string& name, const string& code)
: Cheat(os, name, code)
{
address = (uInt16) unhex(myCode.substr(0, 2));
value = (uInt8) unhex(myCode.substr(2, 2));
address = uInt16(unhex(myCode.substr(0, 2)));
value = uInt8(unhex(myCode.substr(2, 2)));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -44,6 +44,7 @@ string Base::toString(int value, Common::Base::Format outputBase)
if(outputBase == Base::F_DEFAULT)
outputBase = myDefaultBase;
// Note: generates warnings about 'nonliteral' format
switch(outputBase)
{
case Base::F_2: // base 2: 8 or 16 bits (depending on value)

View File

@ -90,7 +90,6 @@ MouseControl::MouseControl(Console& console, const string& mode)
xid = 1;
msg << "MindLink 1";
break;
default: break;
}
msg << ", Y-axis is ";
switch(yaxis)
@ -138,7 +137,6 @@ MouseControl::MouseControl(Console& console, const string& mode)
yid = 1;
msg << "MindLink 1";
break;
default: break;
}
myModeList.push_back(MouseMode(xtype, xid, ytype, yid, msg.str()));
}

View File

@ -146,8 +146,8 @@ class PNGLibrary
static void png_read_data(png_structp ctx, png_bytep area, png_size_t size);
static void png_write_data(png_structp ctx, png_bytep area, png_size_t size);
static void png_io_flush(png_structp ctx);
static void png_user_warn(png_structp ctx, png_const_charp str);
static void png_user_error(png_structp ctx, png_const_charp str);
static void png_user_warn[[noreturn]] (png_structp ctx, png_const_charp str);
static void png_user_error[[noreturn]] (png_structp ctx, png_const_charp str);
private:
// Following constructors and assignment operators not supported

View File

@ -21,7 +21,6 @@
/* Common implementation of NTSC filters */
#include <assert.h>
#include <math.h>
/* Copyright (C) 2006-2009 Shay Green. This module is free software; you
@ -140,7 +139,6 @@ static void init_filters( init_t* impl, atari_ntsc_setup_t const* setup )
{
int x = kernel_size * 3 / 2 - kernel_half + i;
kernels [x] *= sum;
assert( kernels [x] == kernels [x] ); /* catch numerical instability */
}
}
@ -175,7 +173,6 @@ static void init_filters( init_t* impl, atari_ntsc_setup_t const* setup )
for ( x = i; x < kernel_size; x += 2 )
{
kernels [x] *= sum;
assert( kernels [x] == kernels [x] ); /* catch numerical instability */
}
}
}

View File

@ -189,8 +189,8 @@ string CartDebug::toString()
return DebuggerParser::red("invalid base, this is a BUG");
}
const CartState& state = (CartState&) getState();
const CartState& oldstate = (CartState&) getOldState();
const CartState& state = static_cast<const CartState&>(getState());
const CartState& oldstate = static_cast<const CartState&>(getOldState());
uInt32 curraddr = 0, bytesSoFar = 0;
for(uInt32 i = 0; i < state.ram.size(); i += bytesPerLine, bytesSoFar += bytesPerLine)

View File

@ -148,10 +148,10 @@ void Debugger::initialize()
// The debugger dialog is resizable, within certain bounds
// We check those bounds now
myWidth = BSPF_max(myWidth, (uInt32)DebuggerDialog::kSmallFontMinW);
myHeight = BSPF_max(myHeight, (uInt32)DebuggerDialog::kSmallFontMinH);
myWidth = BSPF_min(myWidth, (uInt32)d.w);
myHeight = BSPF_min(myHeight, (uInt32)d.h);
myWidth = BSPF_max(myWidth, uInt32(DebuggerDialog::kSmallFontMinW));
myHeight = BSPF_max(myHeight, uInt32(DebuggerDialog::kSmallFontMinH));
myWidth = BSPF_min(myWidth, uInt32(d.w));
myHeight = BSPF_min(myHeight, uInt32(d.h));
myOSystem.settings().setValue("dbg.res", GUI::Size(myWidth, myHeight));
@ -271,7 +271,7 @@ string Debugger::setRAM(IntArray& args)
{
ostringstream buf;
int count = (int)args.size();
int count = int(args.size());
int address = args[0];
for(int i = 1; i < count; ++i)
mySystem.poke(address++, args[i]);

View File

@ -196,7 +196,7 @@ class Debugger : public DialogContainer
bits.push_back(false);
}
}
static uInt8 get_bits(BoolArray& bits)
static uInt8 get_bits(const BoolArray& bits)
{
uInt8 result = 0x0;
for(int i = 0; i < 8; ++i)

View File

@ -222,7 +222,7 @@ int DebuggerParser::decipher_arg(const string& str)
if(bin && dec) return -1;
// Special cases (registers):
CpuState& state = (CpuState&) debugger.cpuDebug().getState();
const CpuState& state = static_cast<const CpuState&>(debugger.cpuDebug().getState());
if(arg == "a") result = state.A;
else if(arg == "x") result = state.X;
else if(arg == "y") result = state.Y;
@ -318,7 +318,7 @@ string DebuggerParser::showWatches()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool DebuggerParser::getArgs(const string& command, string& verb)
{
int state = kIN_COMMAND, i = 0, length = (int)command.length();
int state = kIN_COMMAND, i = 0, length = int(command.length());
string curArg = "";
verb = "";
@ -375,7 +375,7 @@ bool DebuggerParser::getArgs(const string& command, string& verb)
if(curArg != "")
argStrings.push_back(curArg);
argCount = (int)argStrings.size();
argCount = int(argStrings.size());
/*
cerr << "verb = " << verb << endl;
cerr << "arguments (" << argCount << "):\n";
@ -630,7 +630,7 @@ bool DebuggerParser::saveScriptFile(string file)
// "a"
void DebuggerParser::executeA()
{
debugger.cpuDebug().setA((uInt8)args[0]);
debugger.cpuDebug().setA(uInt8(args[0]));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -871,7 +871,7 @@ void DebuggerParser::executeDelfunction()
void DebuggerParser::executeDelwatch()
{
int which = args[0] - 1;
if(which >= 0 && which < (int)watches.size())
if(which >= 0 && which < int(watches.size()))
{
Vec::removeAt(watches, which);
commandResult << "removed watch";
@ -1275,7 +1275,7 @@ void DebuggerParser::executeRunTo()
const CartDebug& cartdbg = debugger.cartDebug();
const CartDebug::DisassemblyList& list = cartdbg.disassembly().list;
uInt32 count = 0, max_iterations = (uInt32)list.size();
uInt32 count = 0, max_iterations = list.size();
// Create a progress dialog box to show the progress searching through the
// disassembly, since this may be a time-consuming operation
@ -1343,7 +1343,7 @@ void DebuggerParser::executeRunToPc()
// "s"
void DebuggerParser::executeS()
{
debugger.cpuDebug().setSP((uInt8)args[0]);
debugger.cpuDebug().setSP(uInt8(args[0]));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1546,14 +1546,14 @@ void DebuggerParser::executeWatch()
// "x"
void DebuggerParser::executeX()
{
debugger.cpuDebug().setX((uInt8)args[0]);
debugger.cpuDebug().setX(uInt8(args[0]));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "y"
void DebuggerParser::executeY()
{
debugger.cpuDebug().setY((uInt8)args[0]);
debugger.cpuDebug().setY(uInt8(args[0]));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -34,6 +34,11 @@ class DebuggerState
public:
DebuggerState() { }
~DebuggerState() { }
DebuggerState(const DebuggerState&) = default;
DebuggerState(DebuggerState&&) = delete;
DebuggerState& operator=(const DebuggerState&) = default;
DebuggerState& operator=(DebuggerState&&) = delete;
};
/**

View File

@ -733,7 +733,7 @@ void DiStella::disasm(uInt32 distart, int pass)
// where wraparound occurred on a 32-bit int, and subsequent
// indexing into the labels array caused a crash
d1 = Debugger::debugger().peek(myPC+myOffset); myPC++;
ad = ((myPC + (Int8)d1) & 0xfff) + myOffset;
ad = ((myPC + Int8(d1)) & 0xfff) + myOffset;
labfound = mark(ad, CartDebug::REFERENCED);
if (pass == 1)

View File

@ -310,8 +310,8 @@ string RiotDebug::switchesString()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string RiotDebug::toString()
{
const RiotState& state = (RiotState&) getState();
const RiotState& oldstate = (RiotState&) getOldState();
const RiotState& state = static_cast<const RiotState&>(getState());
const RiotState& oldstate = static_cast<const RiotState&>(getOldState());
ostringstream buf;
buf << "280/SWCHA(R)=" << myDebugger.invIfChanged(state.SWCHA_R, oldstate.SWCHA_R)

View File

@ -749,8 +749,7 @@ string TIADebug::toString()
// TODO: inverse video for changed regs. Core needs to track this.
// TODO: strobes? WSYNC RSYNC RESP0/1 RESM0/1 RESBL HMOVE HMCLR CXCLR
const TiaState& state = (TiaState&) getState();
// const TiaState& oldstate = (TiaState&) getOldState();
const TiaState& state = static_cast<const TiaState&>(getState());
// build up output, then return it.
buf << "scanline " << dec << myTIA.scanlines() << " "

View File

@ -66,7 +66,7 @@ void AtariVoxWidget::handleCommand(CommandSender*, int cmd, int, int)
{
if(cmd == kEEPROMErase)
{
AtariVox& avox = (AtariVox&)myController;
AtariVox& avox = static_cast<AtariVox&>(myController);
avox.myEEPROM->erase();
}
}

View File

@ -103,8 +103,8 @@ void AudioWidget::loadConfig()
Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug();
TiaState state = (TiaState&) tia.getState();
TiaState oldstate = (TiaState&) tia.getOldState();
const TiaState& state = static_cast<const TiaState&>(tia.getState());
const TiaState& oldstate = static_cast<const TiaState&>(tia.getOldState());
// AUDF0/1
alist.clear(); vlist.clear(); changed.clear();

View File

@ -123,7 +123,7 @@ void Cartridge3EWidget::handleCommand(CommandSender* sender,
if(cmd == kROMBankChanged)
{
if(myROMBank->getSelected() < (int)myNumRomBanks)
if(myROMBank->getSelected() < int(myNumRomBanks))
{
bank = myROMBank->getSelected();
myRAMBank->setSelectedMax();
@ -136,7 +136,7 @@ void Cartridge3EWidget::handleCommand(CommandSender* sender,
}
else if(cmd == kRAMBankChanged)
{
if(myRAMBank->getSelected() < (int)myNumRamBanks)
if(myRAMBank->getSelected() < int(myNumRamBanks))
{
myROMBank->setSelectedMax();
bank = myRAMBank->getSelected() + 256;

View File

@ -166,7 +166,7 @@ void CartridgeCMWidget::loadConfig()
myBank->setSelectedIndex(myCart.myCurrentBank);
RiotDebug& riot = Debugger::debugger().riotDebug();
const RiotState& state = (RiotState&) riot.getState();
const RiotState& state = static_cast<const RiotState&>(riot.getState());
uInt8 swcha = myCart.mySWCHA;

View File

@ -255,7 +255,7 @@ void CartridgeDPCPlusWidget::loadConfig()
for(int i = 0; i < 8; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myFractionalCounters[i]);
changed.push_back(myCart.myFractionalCounters[i] != (uInt32)myOldState.fraccounters[i]);
changed.push_back(myCart.myFractionalCounters[i] != uInt32(myOldState.fraccounters[i]));
}
myFracCounters->setList(alist, vlist, changed);
@ -279,7 +279,7 @@ void CartridgeDPCPlusWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]);
changed.push_back(myCart.myMusicCounters[i] != (uInt32)myOldState.mcounters[i]);
changed.push_back(myCart.myMusicCounters[i] != uInt32(myOldState.mcounters[i]));
}
myMusicCounters->setList(alist, vlist, changed);
@ -287,7 +287,7 @@ void CartridgeDPCPlusWidget::loadConfig()
for(int i = 0; i < 3; ++i)
{
alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]);
changed.push_back(myCart.myMusicFrequencies[i] != (uInt32)myOldState.mfreqs[i]);
changed.push_back(myCart.myMusicFrequencies[i] != uInt32(myOldState.mfreqs[i]));
}
myMusicFrequencies->setList(alist, vlist, changed);

View File

@ -63,7 +63,7 @@ CartRamWidget::CartRamWidget(
const uInt16 maxlines = 6;
StringParser bs(desc, (fwidth - kScrollBarWidth) / myFontWidth);
const StringList& sl = bs.stringList();
uInt32 lines = (int)sl.size();
uInt32 lines = sl.size();
if(lines < 3) lines = 3;
if(lines > maxlines) lines = maxlines;

View File

@ -39,15 +39,15 @@ class ControllerWidget : public Widget, public CommandSender
_h = 8 * font.getLineHeight();
}
virtual ~ControllerWidget() { };
virtual ~ControllerWidget() { }
virtual void loadConfig() override { };
virtual void loadConfig() override { }
protected:
Controller& myController;
private:
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) override { };
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) override { }
// Following constructors and assignment operators not supported
ControllerWidget() = delete;

View File

@ -270,8 +270,8 @@ void CpuWidget::loadConfig()
Debugger& dbg = instance().debugger();
CartDebug& cart = dbg.cartDebug();
CpuDebug& cpu = dbg.cpuDebug();
const CpuState& state = (CpuState&) cpu.getState();
const CpuState& oldstate = (CpuState&) cpu.getOldState();
const CpuState& state = static_cast<const CpuState&>(cpu.getState());
const CpuState& oldstate = static_cast<const CpuState&>(cpu.getOldState());
// Add PC to its own DataGridWidget
alist.push_back(kPCRegAddr);

View File

@ -126,7 +126,7 @@ cerr << "alist.size() = " << alist.size()
<< ", changed.size() = " << changed.size()
<< ", _rows*_cols = " << _rows * _cols << endl << endl;
*/
int size = (int)vlist.size(); // assume the alist is the same size
int size = int(vlist.size()); // assume the alist is the same size
assert(size == _rows * _cols);
_addrList.clear();
@ -256,7 +256,7 @@ void DataGridWidget::handleMouseDown(int x, int y, int button, int clickCount)
// First check whether the selection changed
int newSelectedItem;
newSelectedItem = findItem(x, y);
if (newSelectedItem > (int)_valueList.size() - 1)
if (newSelectedItem > int(_valueList.size()) - 1)
newSelectedItem = -1;
if (_selectedItem != newSelectedItem)
@ -370,12 +370,12 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod)
break;
case KBDK_DOWN:
if (_currentRow < (int) _rows - 1)
if (_currentRow < int(_rows) - 1)
{
_currentRow++;
dirty = true;
}
else if(_currentCol < (int) _cols - 1)
else if(_currentCol < int(_cols) - 1)
{
_currentRow = 0;
_currentCol++;
@ -398,12 +398,12 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod)
break;
case KBDK_RIGHT:
if (_currentCol < (int) _cols - 1)
if (_currentCol < int(_cols) - 1)
{
_currentCol++;
dirty = true;
}
else if(_currentRow < (int) _rows - 1)
else if(_currentRow < int(_rows) - 1)
{
_currentCol = 0;
_currentRow++;
@ -424,7 +424,7 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod)
case KBDK_PAGEDOWN:
if(instance().eventHandler().kbdShift(mod) && _scrollBar)
handleMouseWheel(0, 0, +1);
else if (_currentRow < (int) _rows - 1)
else if (_currentRow < int(_rows) - 1)
{
_currentRow = _rows - 1;
dirty = true;
@ -440,7 +440,7 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod)
break;
case KBDK_END:
if (_currentCol < (int) _cols - 1)
if (_currentCol < int(_cols) - 1)
{
_currentCol = _cols - 1;
dirty = true;

View File

@ -453,7 +453,7 @@ void DebuggerDialog::addRomArea()
GUI::Rect DebuggerDialog::getTiaBounds() const
{
// The area showing the TIA image (NTSC and PAL supported, up to 260 lines)
GUI::Rect r(0, 0, 320, BSPF_max(260, (int)(_h * 0.35)));
GUI::Rect r(0, 0, 320, BSPF_max(260, int(_h * 0.35)));
return r;
}
@ -477,7 +477,7 @@ GUI::Rect DebuggerDialog::getStatusBounds() const
int x1 = tia.right + 1;
int y1 = 0;
int x2 = tia.right + 225 + (_w > 1030 ? (int) (0.35 * (_w - 1030)) : 0);
int x2 = tia.right + 225 + (_w > 1030 ? int(0.35 * (_w - 1030)) : 0);
int y2 = tia.bottom;
GUI::Rect r(x1, y1, x2, y2);

View File

@ -48,7 +48,7 @@ class NullControlWidget : public ControllerWidget
kTextAlignCenter);
}
virtual ~NullControlWidget() { };
virtual ~NullControlWidget() { }
private:
// Following constructors and assignment operators not supported

View File

@ -75,8 +75,8 @@ PaddleWidget::~PaddleWidget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PaddleWidget::loadConfig()
{
myP0Resistance->setValue(1400000 - (Int32)myController.read(Controller::Nine));
myP1Resistance->setValue(1400000 - (Int32)myController.read(Controller::Five));
myP0Resistance->setValue(1400000 - Int32(myController.read(Controller::Nine)));
myP1Resistance->setValue(1400000 - Int32(myController.read(Controller::Five)));
myP0Fire->setState(!myController.read(Controller::Four));
myP1Fire->setState(!myController.read(Controller::Three));
}

View File

@ -474,7 +474,7 @@ void PromptWidget::handleCommand(CommandSender* sender, int cmd,
switch (cmd)
{
case kSetPositionCmd:
int newPos = (int)data + _linesPerPage - 1 + _firstLineInBuffer;
int newPos = int(data) + _linesPerPage - 1 + _firstLineInBuffer;
if (newPos != _scrollLine)
{
_scrollLine = newPos;
@ -765,7 +765,7 @@ int PromptWidget::printf(const char* format, ...)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int PromptWidget::vprintf(const char* format, va_list argptr)
{
char buf[2048];
char buf[2048]; // Note: generates warnings about 'nonliteral' format
int count = BSPF_vsnprintf(buf, sizeof(buf), format, argptr);
print(buf);

View File

@ -170,7 +170,7 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
// We simply change the values in the DataGridWidget
// It will then send the 'kDGItemDataChangedCmd' signal to change the actual
// memory location
int addr, value;
int addr = 0, value = 0;
switch(cmd)
{

View File

@ -38,21 +38,21 @@ RiotRamWidget::~RiotRamWidget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 RiotRamWidget::getValue(int addr) const
{
const CartState& state = (CartState&) myDbg.getState();
const CartState& state = static_cast<const CartState&>(myDbg.getState());
return myDbg.peek(state.rport[addr]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RiotRamWidget::setValue(int addr, uInt8 value)
{
const CartState& state = (CartState&) myDbg.getState();
const CartState& state = static_cast<const CartState&>(myDbg.getState());
myDbg.poke(state.wport[addr], value);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string RiotRamWidget::getLabel(int addr) const
{
const CartState& state = (CartState&) myDbg.getState();
const CartState& state = static_cast<const CartState&>(myDbg.getState());
return myDbg.getLabel(state.rport[addr], true);
}
@ -60,8 +60,8 @@ string RiotRamWidget::getLabel(int addr) const
void RiotRamWidget::fillList(uInt32 start, uInt32 size, IntArray& alist,
IntArray& vlist, BoolArray& changed) const
{
const CartState& state = (CartState&) myDbg.getState();
const CartState& oldstate = (CartState&) myDbg.getOldState();
const CartState& state = static_cast<const CartState&>(myDbg.getState());
const CartState& oldstate = static_cast<const CartState&>(myDbg.getOldState());
for(uInt32 i = 0; i < size; i++)
{
@ -74,13 +74,13 @@ void RiotRamWidget::fillList(uInt32 start, uInt32 size, IntArray& alist,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 RiotRamWidget::readPort(uInt32 start) const
{
const CartState& state = (CartState&) myDbg.getState();
const CartState& state = static_cast<const CartState&>(myDbg.getState());
return state.rport[start];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const ByteArray& RiotRamWidget::currentRam(uInt32) const
{
const CartState& state = (CartState&) myDbg.getState();
const CartState& state = static_cast<const CartState&>(myDbg.getState());
return state.ram;
}

View File

@ -266,8 +266,8 @@ void RiotWidget::loadConfig()
// address in the callback (handleCommand)
Debugger& dbg = instance().debugger();
RiotDebug& riot = dbg.riotDebug();
const RiotState& state = (RiotState&) riot.getState();
const RiotState& oldstate = (RiotState&) riot.getOldState();
const RiotState& state = static_cast<const RiotState&>(riot.getState());
const RiotState& oldstate = static_cast<const RiotState&>(riot.getOldState());
// Update the SWCHA register booleans (poke mode)
IO_REGS_UPDATE(mySWCHAWriteBits, swchaWriteBits);
@ -335,9 +335,9 @@ void RiotWidget::loadConfig()
// Console switches (inverted, since 'selected' in the UI
// means 'grounded' in the system)
myP0Diff->setSelectedIndex((int)riot.diffP0());
myP1Diff->setSelectedIndex((int)riot.diffP1());
myTVType->setSelectedIndex((int)riot.tvType());
myP0Diff->setSelectedIndex(riot.diffP0());
myP1Diff->setSelectedIndex(riot.diffP1());
myTVType->setSelectedIndex(riot.tvType());
mySelect->setState(!riot.select());
myReset->setState(!riot.reset());
@ -387,19 +387,19 @@ void RiotWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
switch(id)
{
case kSWCHABitsID:
value = Debugger::get_bits((BoolArray&)mySWCHAWriteBits->getState());
value = Debugger::get_bits(mySWCHAWriteBits->getState());
riot.swcha(value & 0xff);
break;
case kSWACNTBitsID:
value = Debugger::get_bits((BoolArray&)mySWACNTBits->getState());
value = Debugger::get_bits(mySWACNTBits->getState());
riot.swacnt(value & 0xff);
break;
case kSWCHBBitsID:
value = Debugger::get_bits((BoolArray&)mySWCHBWriteBits->getState());
value = Debugger::get_bits(mySWCHBWriteBits->getState());
riot.swchb(value & 0xff);
break;
case kSWBCNTBitsID:
value = Debugger::get_bits((BoolArray&)mySWBCNTBits->getState());
value = Debugger::get_bits(mySWBCNTBits->getState());
riot.swbcnt(value & 0xff);
break;
}
@ -432,7 +432,7 @@ void RiotWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
break;
case kTVTypeChanged:
riot.tvType((bool)myTVType->getSelected());
riot.tvType(myTVType->getSelected());
break;
}
}

View File

@ -134,8 +134,8 @@ void RomListWidget::setList(const CartDebug::Disassembly& disasm,
myCheckList[i]->setFlags(WIDGET_ENABLED);
// Then turn off any extras
if((int)myDisasm->list.size() < _rows)
for(int i = (int)myDisasm->list.size(); i < _rows; ++i)
if(int(myDisasm->list.size()) < _rows)
for(int i = int(myDisasm->list.size()); i < _rows; ++i)
myCheckList[i]->clearFlags(WIDGET_ENABLED);
recalc();
@ -144,7 +144,7 @@ void RomListWidget::setList(const CartDebug::Disassembly& disasm,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomListWidget::setSelected(int item)
{
if(item < -1 || item >= (int)myDisasm->list.size())
if(item < -1 || item >= int(myDisasm->list.size()))
return;
if(isEnabled())
@ -160,7 +160,7 @@ void RomListWidget::setSelected(int item)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomListWidget::setHighlighted(int item)
{
if(item < -1 || item >= (int)myDisasm->list.size())
if(item < -1 || item >= int(myDisasm->list.size()))
return;
if(isEnabled())
@ -189,7 +189,7 @@ int RomListWidget::findItem(int x, int y) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomListWidget::recalc()
{
int size = (int)myDisasm->list.size();
int size = int(myDisasm->list.size());
if (_currentPos >= size)
_currentPos = size - 1;
@ -201,7 +201,7 @@ void RomListWidget::recalc()
_editMode = false;
myScrollBar->_numEntries = (int)myDisasm->list.size();
myScrollBar->_numEntries = int(myDisasm->list.size());
myScrollBar->_entriesPerPage = _rows;
// Reset to normal data entry
@ -225,10 +225,11 @@ void RomListWidget::scrollToCurrent(int item)
_currentPos = item - _rows + 1;
}
if (_currentPos < 0 || _rows > (int)myDisasm->list.size())
int size = myDisasm->list.size();
if (_currentPos < 0 || _rows > size)
_currentPos = 0;
else if (_currentPos + _rows > (int)myDisasm->list.size())
_currentPos = (int)myDisasm->list.size() - _rows;
else if (_currentPos + _rows > size)
_currentPos = size - _rows;
myScrollBar->_currentPos = _currentPos;
myScrollBar->recalc();
@ -255,7 +256,7 @@ void RomListWidget::handleMouseDown(int x, int y, int button, int clickCount)
// First check whether the selection changed
int newSelectedItem;
newSelectedItem = findItem(x, y);
if (newSelectedItem > (int)myDisasm->list.size() - 1)
if (newSelectedItem > int(myDisasm->list.size()) - 1)
newSelectedItem = -1;
if (_selectedItem != newSelectedItem)
@ -374,7 +375,7 @@ bool RomListWidget::handleEvent(Event::Type e)
break;
case Event::UIDown:
if (_selectedItem < (int)myDisasm->list.size() - 1)
if (_selectedItem < int(myDisasm->list.size()) - 1)
_selectedItem++;
break;
@ -386,8 +387,8 @@ bool RomListWidget::handleEvent(Event::Type e)
case Event::UIPgDown:
_selectedItem += _rows - 1;
if (_selectedItem >= (int)myDisasm->list.size())
_selectedItem = (int)myDisasm->list.size() - 1;
if (_selectedItem >= int(myDisasm->list.size()))
_selectedItem = int(myDisasm->list.size()) - 1;
break;
case Event::UIHome:
@ -395,7 +396,7 @@ bool RomListWidget::handleEvent(Event::Type e)
break;
case Event::UIEnd:
_selectedItem = (int)myDisasm->list.size() - 1;
_selectedItem = int(myDisasm->list.size()) - 1;
break;
default:
@ -424,7 +425,7 @@ void RomListWidget::handleCommand(CommandSender* sender, int cmd, int data, int
break;
case kSetPositionCmd:
if (_currentPos != (int)data)
if (_currentPos != data)
{
_currentPos = data;
setDirty();
@ -451,7 +452,7 @@ void RomListWidget::drawWidget(bool hilite)
{
FBSurface& s = _boss->dialog().surface();
const CartDebug::DisassemblyList& dlist = myDisasm->list;
int i, pos, xpos, ypos, len = (int)dlist.size();
int i, pos, xpos, ypos, len = int(dlist.size());
const GUI::Rect& r = getEditRect();
const GUI::Rect& l = getLineRect();

View File

@ -71,8 +71,8 @@ void RomWidget::loadConfig()
{
Debugger& dbg = instance().debugger();
CartDebug& cart = dbg.cartDebug();
const CartState& state = (CartState&) cart.getState();
const CartState& oldstate = (CartState&) cart.getOldState();
const CartState& state = static_cast<const CartState&>(cart.getState());
const CartState& oldstate = static_cast<const CartState&>(cart.getOldState());
// Fill romlist the current bank of source or disassembly
myListIsDirty |= cart.disassemble(myListIsDirty);
@ -109,7 +109,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case RomListWidget::kRomChangedCmd:
// 'data' is the line in the disassemblylist to be accessed
// 'id' is the base to use for the data to be changed
patchROM(data, myRomList->getText(), (Common::Base::Format)id);
patchROM(data, myRomList->getText(), Common::Base::Format(id));
break;
case RomListWidget::kSetPCCmd:
@ -174,7 +174,7 @@ void RomWidget::setBreak(int disasm_line, bool state)
{
const CartDebug::DisassemblyList& list =
instance().debugger().cartDebug().disassembly().list;
if(disasm_line >= (int)list.size()) return;
if(disasm_line >= int(list.size())) return;
if(list[disasm_line].address != 0 && list[disasm_line].bytes != "")
instance().debugger().setBreakPoint(list[disasm_line].address, state);
@ -185,7 +185,7 @@ void RomWidget::setPC(int disasm_line)
{
const CartDebug::DisassemblyList& list =
instance().debugger().cartDebug().disassembly().list;
if(disasm_line >= (int)list.size()) return;
if(disasm_line >= int(list.size())) return;
if(list[disasm_line].address != 0)
{
@ -200,7 +200,7 @@ void RomWidget::runtoPC(int disasm_line)
{
const CartDebug::DisassemblyList& list =
instance().debugger().cartDebug().disassembly().list;
if(disasm_line >= (int)list.size()) return;
if(disasm_line >= int(list.size())) return;
if(list[disasm_line].address != 0)
{
@ -216,7 +216,7 @@ void RomWidget::patchROM(int disasm_line, const string& bytes,
{
const CartDebug::DisassemblyList& list =
instance().debugger().cartDebug().disassembly().list;
if(disasm_line >= (int)list.size()) return;
if(disasm_line >= int(list.size())) return;
if(list[disasm_line].address != 0)
{

View File

@ -66,7 +66,7 @@ void SaveKeyWidget::handleCommand(CommandSender*, int cmd, int, int)
{
if(cmd == kEEPROMErase)
{
SaveKey& skey = (SaveKey&)myController;
SaveKey& skey = static_cast<SaveKey&>(myController);
skey.myEEPROM->erase();
}
}

View File

@ -66,7 +66,7 @@ void TiaOutputWidget::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaOutputWidget::saveSnapshot()
{
int number = (int)(instance().getTicks() / 1000);
int number = int(instance().getTicks() / 1000);
ostringstream sspath;
sspath << instance().snapshotSaveDir()
<< instance().console().properties().get(Cartridge_Name)

View File

@ -809,8 +809,8 @@ void TiaWidget::loadConfig()
Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug();
TiaState& state = (TiaState&) tia.getState();
TiaState& oldstate = (TiaState&) tia.getOldState();
const TiaState& state = static_cast<const TiaState&>(tia.getState());
const TiaState& oldstate = static_cast<const TiaState&>(tia.getOldState());
// Color registers
alist.clear(); vlist.clear(); changed.clear();

View File

@ -60,8 +60,7 @@ void ToggleBitWidget::setList(const StringList& off, const StringList& on)
_onList.clear();
_onList = on;
int size = (int)_offList.size(); // assume _onList is the same size
assert(size == _rows * _cols);
assert(int(_offList.size()) == _rows * _cols);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -39,7 +39,7 @@ TogglePixelWidget::TogglePixelWidget(GuiObject* boss, const GUI::Font& font,
_h = _rowHeight * rows + 1;
// Changed state isn't used, but we still need to fill it
while((int)_changedList.size() < rows * cols)
while(int(_changedList.size()) < rows * cols)
_changedList.push_back(false);
}
@ -92,7 +92,7 @@ void TogglePixelWidget::setIntState(int value, bool swap)
int TogglePixelWidget::getIntState()
{
// Construct int based on current state and swap
uInt32 value = 0, size = (int)_stateList.size();
uInt32 value = 0, size = _stateList.size();
for(uInt32 i = 0; i < size; ++i)
{

View File

@ -53,7 +53,7 @@ void ToggleWidget::handleMouseDown(int x, int y, int button, int clickCount)
// First check whether the selection changed
int newSelectedItem;
newSelectedItem = findItem(x, y);
if (newSelectedItem > (int)_stateList.size() - 1)
if (newSelectedItem > int(_stateList.size()) - 1)
newSelectedItem = -1;
if (_selectedItem != newSelectedItem)
@ -125,7 +125,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod)
break;
case KBDK_DOWN:
if (_currentRow < (int) _rows - 1)
if (_currentRow < int(_rows) - 1)
{
_currentRow++;
dirty = true;
@ -141,7 +141,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod)
break;
case KBDK_RIGHT:
if (_currentCol < (int) _cols - 1)
if (_currentCol < int(_cols) - 1)
{
_currentCol++;
dirty = true;
@ -157,7 +157,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod)
break;
case KBDK_PAGEDOWN:
if (_currentRow < (int) _rows - 1)
if (_currentRow < int(_rows) - 1)
{
_currentRow = _rows - 1;
dirty = true;
@ -173,7 +173,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod)
break;
case KBDK_END:
if (_currentCol < (int) _cols - 1)
if (_currentCol < int(_cols) - 1)
{
_currentCol = _cols - 1;
dirty = true;
@ -208,7 +208,7 @@ void ToggleWidget::handleCommand(CommandSender* sender, int cmd,
switch (cmd)
{
case kSetPositionCmd:
if (_selectedItem != (int)data)
if (_selectedItem != data)
{
_selectedItem = data;
setDirty();

View File

@ -27,7 +27,7 @@ AtariVox::AtariVox(Jack jack, const Event& event, const System& system,
const SerialPort& port, const string& portname,
const string& eepromfile)
: Controller(jack, event, system, Controller::AtariVox),
mySerialPort((SerialPort&)port),
mySerialPort(const_cast<SerialPort&>(port)),
myShiftCount(0),
myShiftRegister(0),
myLastDataWriteCycle(0)

View File

@ -327,7 +327,7 @@ bool Cartridge::saveROM(ofstream& out)
return false;
}
out.write((const char*)image, size);
out.write(reinterpret_cast<const char*>(image), size);
return true;
}

View File

@ -156,7 +156,7 @@ bool Cartridge3E::bank(uInt16 bank)
if(bank < 256)
{
// Make sure the bank they're asking for is reasonable
if(((uInt32)bank << 11) < uInt32(mySize))
if((uInt32(bank) << 11) < mySize)
{
myCurrentBank = bank;
}

View File

@ -122,7 +122,7 @@ bool Cartridge3F::bank(uInt16 bank)
if(bankLocked()) return false;
// Make sure the bank they're asking for is reasonable
if(((uInt32)bank << 11) < mySize)
if((uInt32(bank) << 11) < mySize)
{
myCurrentBank = bank;
}

View File

@ -533,7 +533,7 @@ bool CartridgeAR::load(Serializer& in)
myPower = in.getBool();
// Indicates when the power was last turned on
myPowerRomCycle = (Int32) in.getInt();
myPowerRomCycle = in.getInt();
// Data hold register used for writing
myDataHoldRegister = in.getByte();

View File

@ -309,7 +309,7 @@ bool CartridgeCTY::save(Serializer& out) const
out.putBool(myLDAimmediate);
out.putInt(myRandomNumber);
out.putInt(mySystemCycles);
out.putInt((uInt32)(myFractionalClocks * 100000000.0));
out.putInt(uInt32(myFractionalClocks * 100000000.0));
}
catch(...)
@ -337,8 +337,8 @@ bool CartridgeCTY::load(Serializer& in)
myCounter = in.getShort();
myLDAimmediate = in.getBool();
myRandomNumber = in.getInt();
mySystemCycles = (Int32)in.getInt();
myFractionalClocks = (double)in.getInt() / 100000000.0;
mySystemCycles = in.getInt();
myFractionalClocks = double(in.getInt()) / 100000000.0;
}
catch(...)
{
@ -495,7 +495,7 @@ void CartridgeCTY::saveScore(uInt8 index)
catch(...)
{
// Maybe add logging here that save failed?
cerr << name() << ": ERROR saving score table " << (int)index << endl;
cerr << name() << ": ERROR saving score table " << int(index) << endl;
}
}
}
@ -530,8 +530,8 @@ inline void CartridgeCTY::updateMusicModeDataFetchers()
// Calculate the number of DPC OSC clocks since the last update
double clocks = ((20000.0 * cycles) / 1193191.66666667) + myFractionalClocks;
Int32 wholeClocks = (Int32)clocks;
myFractionalClocks = clocks - (double)wholeClocks;
Int32 wholeClocks = Int32(clocks);
myFractionalClocks = clocks - double(wholeClocks);
if(wholeClocks <= 0)
return;

View File

@ -189,12 +189,12 @@ void CartridgeDASH::bankRAMSlot(uInt16 bank) {
if (upper) { // We're mapping the write port
bankInUse[bankNumber + 4] = (Int16) bank;
bankInUse[bankNumber + 4] = Int16(bank);
access.type = System::PA_WRITE;
} else { // We're mapping the read port
bankInUse[bankNumber] = (Int16) bank;
bankInUse[bankNumber] = Int16(bank);
access.type = System::PA_READ;
}
@ -238,7 +238,7 @@ void CartridgeDASH::bankROMSlot(uInt16 bank) {
uInt16 currentBank = bank & BIT_BANK_MASK; // Wrap around/restrict to valid range
bool upper = bank & BITMASK_LOWERUPPER; // is this the lower or upper 512b
bankInUse[bankNumber * 2 + (upper ? 1 : 0)] = (Int16) bank; // Record which bank switched in (as ROM)
bankInUse[bankNumber * 2 + (upper ? 1 : 0)] = Int16(bank); // Record which bank switched in (as ROM)
uInt32 startCurrentBank = currentBank << ROM_BANK_TO_POWER; // Effectively *1K

View File

@ -118,8 +118,8 @@ inline void CartridgeDPC::updateMusicModeDataFetchers()
// Calculate the number of DPC OSC clocks since the last update
double clocks = ((20000.0 * cycles) / 1193191.66666667) + myFractionalClocks;
Int32 wholeClocks = (Int32)clocks;
myFractionalClocks = clocks - (double)wholeClocks;
Int32 wholeClocks = Int32(clocks);
myFractionalClocks = clocks - double(wholeClocks);
if(wholeClocks <= 0)
{
@ -133,7 +133,7 @@ inline void CartridgeDPC::updateMusicModeDataFetchers()
if(myMusicMode[x - 5])
{
Int32 top = myTops[x] + 1;
Int32 newLow = (Int32)(myCounters[x] & 0x00ff);
Int32 newLow = Int32(myCounters[x] & 0x00ff);
if(myTops[x] != 0)
{
@ -158,7 +158,7 @@ inline void CartridgeDPC::updateMusicModeDataFetchers()
myFlags[x] = 0xff;
}
myCounters[x] = (myCounters[x] & 0x0700) | (uInt16)newLow;
myCounters[x] = (myCounters[x] & 0x0700) | uInt16(newLow);
}
}
}
@ -332,14 +332,14 @@ bool CartridgeDPC::poke(uInt16 address, uInt8 value)
// Data fetcher is in music mode so its low counter value
// should be loaded from the top register not the poked value
myCounters[index] = (myCounters[index] & 0x0700) |
(uInt16)myTops[index];
uInt16(myTops[index]);
}
else
{
// Data fetcher is either not a music mode data fetcher or it
// isn't in music mode so it's low counter value should be loaded
// with the poked value
myCounters[index] = (myCounters[index] & 0x0700) | (uInt16)value;
myCounters[index] = (myCounters[index] & 0x0700) | uInt16(value);
}
break;
}
@ -347,7 +347,7 @@ bool CartridgeDPC::poke(uInt16 address, uInt8 value)
// DFx counter high
case 0x03:
{
myCounters[index] = (((uInt16)value & 0x07) << 8) |
myCounters[index] = ((uInt16(value) & 0x07) << 8) |
(myCounters[index] & 0x00ff);
// Execute special code for music mode data fetchers
@ -491,7 +491,7 @@ bool CartridgeDPC::save(Serializer& out) const
out.putByte(myRandomNumber);
out.putInt(mySystemCycles);
out.putInt((uInt32)(myFractionalClocks * 100000000.0));
out.putInt(uInt32(myFractionalClocks * 100000000.0));
}
catch(...)
{
@ -533,8 +533,8 @@ bool CartridgeDPC::load(Serializer& in)
myRandomNumber = in.getByte();
// Get system cycles and fractional clocks
mySystemCycles = (Int32)in.getInt();
myFractionalClocks = (double)in.getInt() / 100000000.0;
mySystemCycles = Int32(in.getInt());
myFractionalClocks = double(in.getInt()) / 100000000.0;
}
catch(...)
{

View File

@ -61,7 +61,8 @@ CartridgeDPCPlus::CartridgeDPCPlus(const uInt8* image, uInt32 size,
#ifdef THUMB_SUPPORT
// Create Thumbulator ARM emulator
myThumbEmulator = make_ptr<Thumbulator>
((uInt16*)(myProgramImage-0xC00), (uInt16*)myDPCRAM,
(reinterpret_cast<uInt16*>(myProgramImage-0xC00),
reinterpret_cast<uInt16*>(myDPCRAM),
settings.getBool("thumb.trapfatal"));
#endif
setInitialState();
@ -157,8 +158,8 @@ inline void CartridgeDPCPlus::updateMusicModeDataFetchers()
// Calculate the number of DPC OSC clocks since the last update
double clocks = ((20000.0 * cycles) / 1193191.66666667) + myFractionalClocks;
Int32 wholeClocks = (Int32)clocks;
myFractionalClocks = clocks - (double)wholeClocks;
Int32 wholeClocks = Int32(clocks);
myFractionalClocks = clocks - double(wholeClocks);
if(wholeClocks <= 0)
{
@ -287,7 +288,7 @@ uInt8 CartridgeDPCPlus::peek(uInt16 address)
myDisplayImage[(myMusicWaveforms[1] << 5) + (myMusicCounters[1] >> 27)] +
myDisplayImage[(myMusicWaveforms[2] << 5) + (myMusicCounters[2] >> 27)];
result = (uInt8)i;
result = uInt8(i);
break;
}
@ -412,12 +413,12 @@ bool CartridgeDPCPlus::poke(uInt16 address, uInt8 value)
{
//DFxFRACLOW - fractional data pointer low byte
case 0x00:
myFractionalCounters[index] = (myFractionalCounters[index] & 0x0F00FF) | ((uInt16)value << 8);
myFractionalCounters[index] = (myFractionalCounters[index] & 0x0F00FF) | (uInt16(value) << 8);
break;
// DFxFRACHI - fractional data pointer high byte
case 0x01:
myFractionalCounters[index] = (((uInt16)value & 0x0F) << 16) | (myFractionalCounters[index] & 0x00ffff);
myFractionalCounters[index] = ((uInt16(value) & 0x0F) << 16) | (myFractionalCounters[index] & 0x00ffff);
break;
//DFxFRACINC - Fractional Increment amount
@ -481,7 +482,7 @@ bool CartridgeDPCPlus::poke(uInt16 address, uInt8 value)
// DFxHI - data pointer high byte
case 0x08:
{
myCounters[index] = (((uInt16)value & 0x0F) << 8) | (myCounters[index] & 0x00ff);
myCounters[index] = ((uInt16(value) & 0x0F) << 8) | (myCounters[index] & 0x00ff);
break;
}
@ -690,7 +691,7 @@ bool CartridgeDPCPlus::save(Serializer& out) const
out.putInt(myRandomNumber);
out.putInt(mySystemCycles);
out.putInt((uInt32)(myFractionalClocks * 100000000.0));
out.putInt(uInt32(myFractionalClocks * 100000000.0));
}
catch(...)
{
@ -750,8 +751,8 @@ bool CartridgeDPCPlus::load(Serializer& in)
myRandomNumber = in.getInt();
// Get system cycles and fractional clocks
mySystemCycles = (Int32)in.getInt();
myFractionalClocks = (double)in.getInt() / 100000000.0;
mySystemCycles = in.getInt();
myFractionalClocks = double(in.getInt()) / 100000000.0;
}
catch(...)
{

View File

@ -134,7 +134,7 @@ uInt8 CartridgeMC::peek(uInt16 address)
if(block & 0x80)
{
// ROM access
return myImage[(uInt32)((block & 0x7F) << 10) + (address & 0x03FF)];
return myImage[uInt32((block & 0x7F) << 10) + (address & 0x03FF)];
}
else
{
@ -142,7 +142,7 @@ uInt8 CartridgeMC::peek(uInt16 address)
if(address & 0x0200)
{
// Reading from the read port of the RAM block
return myRAM[(uInt32)((block & 0x3F) << 9) + (address & 0x01FF)];
return myRAM[uInt32((block & 0x3F) << 9) + (address & 0x01FF)];
}
else
{
@ -155,7 +155,7 @@ uInt8 CartridgeMC::peek(uInt16 address)
else
{
triggerReadFromWritePort(peekAddress);
return myRAM[(uInt32)((block & 0x3F) << 9) + (address & 0x01FF)] = value;
return myRAM[uInt32((block & 0x3F) << 9) + (address & 0x01FF)] = value;
}
}
}
@ -202,7 +202,7 @@ bool CartridgeMC::poke(uInt16 address, uInt8 value)
if(!(block & 0x80) && !(address & 0x0200))
{
// Handle the write to RAM
myRAM[(uInt32)((block & 0x3F) << 9) + (address & 0x01FF)] = value;
myRAM[uInt32((block & 0x3F) << 9) + (address & 0x01FF)] = value;
return true;
}
}

View File

@ -461,7 +461,7 @@ void Console::initializeAudio()
void Console::fry() const
{
for(int ZPmem = 0; ZPmem < 0x100; ZPmem += rand() % 4)
mySystem->poke(ZPmem, mySystem->peek(ZPmem) & (uInt8)rand() % 256);
mySystem->poke(ZPmem, mySystem->peek(ZPmem) & uInt8(rand()) % 256);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -767,22 +767,22 @@ void Console::loadUserPalette()
for(int i = 0; i < 128; i++) // NTSC palette
{
in.read((char*)pixbuf, 3);
uInt32 pixel = ((int)pixbuf[0] << 16) + ((int)pixbuf[1] << 8) + (int)pixbuf[2];
in.read(reinterpret_cast<char*>(pixbuf), 3);
uInt32 pixel = (int(pixbuf[0]) << 16) + (int(pixbuf[1]) << 8) + int(pixbuf[2]);
ourUserNTSCPalette[(i<<1)] = pixel;
}
for(int i = 0; i < 128; i++) // PAL palette
{
in.read((char*)pixbuf, 3);
uInt32 pixel = ((int)pixbuf[0] << 16) + ((int)pixbuf[1] << 8) + (int)pixbuf[2];
in.read(reinterpret_cast<char*>(pixbuf), 3);
uInt32 pixel = (int(pixbuf[0]) << 16) + (int(pixbuf[1]) << 8) + int(pixbuf[2]);
ourUserPALPalette[(i<<1)] = pixel;
}
uInt32 secam[16]; // All 8 24-bit pixels, plus 8 colorloss pixels
for(int i = 0; i < 8; i++) // SECAM palette
{
in.read((char*)pixbuf, 3);
uInt32 pixel = ((int)pixbuf[0] << 16) + ((int)pixbuf[1] << 8) + (int)pixbuf[2];
in.read(reinterpret_cast<char*>(pixbuf), 3);
uInt32 pixel = (int(pixbuf[0]) << 16) + (int(pixbuf[1]) << 8) + int(pixbuf[2]);
secam[(i<<1)] = pixel;
secam[(i<<1)+1] = 0;
}
@ -827,9 +827,7 @@ void Console::generateColorLossPalette()
uInt8 r = (pixel >> 16) & 0xff;
uInt8 g = (pixel >> 8) & 0xff;
uInt8 b = (pixel >> 0) & 0xff;
uInt8 sum = (uInt8) (((float)r * 0.2989) +
((float)g * 0.5870) +
((float)b * 0.1140));
uInt8 sum = uInt8((r * 0.2989) + (g * 0.5870) + (b * 0.1140));
palette[i][(j<<1)+1] = (sum << 16) + (sum << 8) + sum;
}
}

View File

@ -163,8 +163,8 @@ bool Controller::load(Serializer& in)
myDigitalPinState[Six] = in.getBool();
// Input the analog pins
myAnalogPinValue[Five] = (Int32) in.getInt();
myAnalogPinValue[Nine] = (Int32) in.getInt();
myAnalogPinValue[Five] = in.getInt();
myAnalogPinValue[Nine] = in.getInt();
}
catch(...)
{

View File

@ -227,7 +227,7 @@ void EventHandler::poll(uInt64 time)
// Handle continuous snapshots
if(myContSnapshotInterval > 0 &&
(++myContSnapshotCounter % myContSnapshotInterval == 0))
takeSnapshot((uInt32)time >> 10); // not quite milliseconds, but close enough
takeSnapshot(uInt32(time) >> 10); // not quite milliseconds, but close enough
}
}
else if(myOverlay)
@ -441,7 +441,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
else
{
buf << "Enabling shotshots in " << interval << " second intervals";
interval *= (uInt32) myOSystem.frameRate();
interval *= uInt32(myOSystem.frameRate());
}
myOSystem.frameBuffer().showMessage(buf.str());
setContinuousSnapshots(interval);
@ -691,7 +691,7 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value)
// Check for analog events, which are handled differently
// We'll pass them off as Stelladaptor events, and let the controllers
// handle it
switch((int)eventAxisNeg)
switch(int(eventAxisNeg))
{
case Event::PaddleZeroAnalog:
myEvent.set(Event::SALeftAxis0Value, value);
@ -1157,9 +1157,9 @@ void EventHandler::setActionMappings(EventMode mode)
if(myKeyTable[j][mode] == event)
{
if(key == "")
key = key + nameForKey((StellaKey)j);
key = key + nameForKey(StellaKey(j));
else
key = key + ", " + nameForKey((StellaKey)j);
key = key + ", " + nameForKey(StellaKey(j));
}
}
@ -1279,7 +1279,7 @@ void EventHandler::setKeymap()
// Get event count, which should be the first int in the list
buf >> value;
event = (Event::Type) value;
event = Event::Type(value);
if(event == Event::LastType)
while(buf >> value)
map.push_back(value);
@ -1291,7 +1291,7 @@ void EventHandler::setKeymap()
auto e = map.begin();
for(int mode = 0; mode < kNumModes; ++mode)
for(int i = 0; i < KBDK_LAST; ++i)
myKeyTable[i][mode] = (Event::Type) *e++;
myKeyTable[i][mode] = Event::Type(*e++);
}
else
{
@ -1326,7 +1326,7 @@ void EventHandler::setComboMap()
int eventcount = 0;
while(buf2 >> key && eventcount < kEventsPerCombo)
{
myComboTable[combocount][eventcount] = (Event::Type) atoi(key.c_str());
myComboTable[combocount][eventcount] = Event::Type(atoi(key.c_str()));
++eventcount;
}
++combocount;

View File

@ -137,31 +137,31 @@ bool EventHandler::StellaJoystick::setMap(const string& mapString)
// Parse axis/button/hat values
getValues(items[1], map);
if((int)map.size() == numAxes * 2 * kNumModes)
if(int(map.size()) == numAxes * 2 * kNumModes)
{
// Fill the axes table with events
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)
axisTable[a][k][m] = (Event::Type) *event++;
axisTable[a][k][m] = Event::Type(*event++);
}
getValues(items[2], map);
if((int)map.size() == numButtons * kNumModes)
if(int(map.size()) == numButtons * kNumModes)
{
auto event = map.begin();
for(int m = 0; m < kNumModes; ++m)
for(int b = 0; b < numButtons; ++b)
btnTable[b][m] = (Event::Type) *event++;
btnTable[b][m] = Event::Type(*event++);
}
getValues(items[3], map);
if((int)map.size() == numHats * 4 * kNumModes)
if(int(map.size()) == numHats * 4 * kNumModes)
{
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)
hatTable[h][k][m] = (Event::Type) *event++;
hatTable[h][k][m] = Event::Type(*event++);
}
return true;

View File

@ -37,7 +37,7 @@ FBSurface::FBSurface()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::readPixels(uInt8* buffer, uInt32 pitch, const GUI::Rect& rect) const
{
uInt8* src = (uInt8*) myPixels + rect.y() * myPitch + rect.x();
uInt8* src = reinterpret_cast<uInt8*>(myPixels + rect.y() * myPitch + rect.x());
if(rect.empty())
memcpy(buffer, src, width() * height() * 4);
@ -62,16 +62,16 @@ void FBSurface::hLine(uInt32 x, uInt32 y, uInt32 x2, uInt32 color)
{
uInt32* buffer = myPixels + y * myPitch + x;
while(x++ <= x2)
*buffer++ = (uInt32) myPalette[color];
*buffer++ = uInt32(myPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::vLine(uInt32 x, uInt32 y, uInt32 y2, uInt32 color)
{
uInt32* buffer = (uInt32*) myPixels + y * myPitch + x;
uInt32* buffer = static_cast<uInt32*>(myPixels + y * myPitch + x);
while(y++ <= y2)
{
*buffer = (uInt32) myPalette[color];
*buffer = uInt32(myPalette[color]);
buffer += myPitch;
}
}
@ -124,7 +124,7 @@ void FBSurface::drawChar(const GUI::Font& font, uInt8 chr,
for(int x = 0; x < bbw; x++, mask >>= 1)
if(ptr & mask)
buffer[x] = (uInt32) myPalette[color];
buffer[x] = uInt32(myPalette[color]);
buffer += myPitch;
}
@ -141,7 +141,7 @@ void FBSurface::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty,
uInt32 mask = 0xF0000000;
for(uInt32 x = 0; x < 8; ++x, mask >>= 4)
if(bitmap[y] & mask)
buffer[x] = (uInt32) myPalette[color];
buffer[x] = uInt32(myPalette[color]);
buffer += myPitch;
}
@ -153,7 +153,7 @@ void FBSurface::drawPixels(uInt32* data, uInt32 tx, uInt32 ty, uInt32 numpixels)
uInt32* buffer = myPixels + ty * myPitch + tx;
for(uInt32 i = 0; i < numpixels; ++i)
*buffer++ = (uInt32) data[i];
*buffer++ = data[i];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -95,6 +95,14 @@ class FilesystemNode
virtual ~FilesystemNode() { }
/**
* Assignment operators.
*/
FilesystemNode(const FilesystemNode&) = default;
FilesystemNode(FilesystemNode&&) = default;
FilesystemNode& operator=(const FilesystemNode&) = default;
FilesystemNode& operator=(FilesystemNode&&) = default;
/**
* Compare the name of this node to the name of another. Directories
* go before normal files.
@ -271,6 +279,15 @@ class AbstractFSNode
using ListMode = FilesystemNode::ListMode;
public:
/**
* Assignment operators.
*/
AbstractFSNode() = default;
AbstractFSNode(const AbstractFSNode&) = default;
AbstractFSNode(AbstractFSNode&&) = default;
AbstractFSNode& operator=(const AbstractFSNode&) = default;
AbstractFSNode& operator=(AbstractFSNode&&) = default;
/**
* Destructor.
*/

View File

@ -76,8 +76,8 @@ bool FrameBuffer::initialize()
query_h = s.h;
}
// Various parts of the codebase assume a minimum screen size
myDesktopSize.w = BSPF_max(query_w, (uInt32)kFBMinW);
myDesktopSize.h = BSPF_max(query_h, (uInt32)kFBMinH);
myDesktopSize.w = BSPF_max(query_w, uInt32(kFBMinW));
myDesktopSize.h = BSPF_max(query_h, uInt32(kFBMinH));
////////////////////////////////////////////////////////////////////
// Create fonts to draw text
@ -121,7 +121,7 @@ bool FrameBuffer::initialize()
myLauncherFont = make_ptr<GUI::Font>(GUI::stellaDesc);
// Determine possible TIA windowed zoom levels
uInt32 maxZoom = maxWindowSizeForScreen((uInt32)kTIAMinW, (uInt32)kTIAMinH,
uInt32 maxZoom = maxWindowSizeForScreen(uInt32(kTIAMinW), uInt32(kTIAMinH),
myDesktopSize.w, myDesktopSize.h);
// Figure our the smallest zoom level we can use
@ -194,7 +194,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
// Initialize video subsystem (make sure we get a valid mode)
string pre_about = about();
const VideoMode& mode = getSavedVidMode(useFullscreen);
if(width <= (uInt32)mode.screen.w && height <= (uInt32)mode.screen.h)
if(width <= mode.screen.w && height <= mode.screen.h)
{
if(setVideoMode(myScreenTitle, mode))
{
@ -232,7 +232,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
myStatsMsg.surface = allocateSurface(myStatsMsg.w, myStatsMsg.h);
if(!myMsg.surface)
myMsg.surface = allocateSurface((uInt32)kFBMinW, font().getFontHeight()+10);
myMsg.surface = allocateSurface(kFBMinW, font().getFontHeight()+10);
// Print initial usage message, but only print it later if the status has changed
if(myInitializedCount == 1)
@ -747,8 +747,8 @@ VideoMode::VideoMode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh,
zoom(z),
description(desc)
{
sw = BSPF_max(sw, (uInt32)FrameBuffer::kTIAMinW);
sh = BSPF_max(sh, (uInt32)FrameBuffer::kTIAMinH);
sw = BSPF_max(sw, uInt32(FrameBuffer::kTIAMinW));
sh = BSPF_max(sh, uInt32(FrameBuffer::kTIAMinH));
iw = BSPF_min(iw, sw);
ih = BSPF_min(ih, sh);
int ix = (sw - iw) >> 1;
@ -761,7 +761,7 @@ VideoMode::VideoMode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh,
void VideoMode::applyAspectCorrection(uInt32 aspect, bool stretch)
{
// Width is modified by aspect ratio; other factors may be applied below
uInt32 iw = (uInt32)(float(image.width() * aspect) / 100.0);
uInt32 iw = uInt32(float(image.width() * aspect) / 100.0);
uInt32 ih = image.height();
if(fsIndex != -1)
@ -794,8 +794,8 @@ void VideoMode::applyAspectCorrection(uInt32 aspect, bool stretch)
stretchFactor = float(int(screen.h / bh) * bh) / ih;
}
}
iw = (uInt32) (stretchFactor * iw);
ih = (uInt32) (stretchFactor * ih);
iw = uInt32(stretchFactor * iw);
ih = uInt32(stretchFactor * ih);
}
else
{
@ -805,8 +805,8 @@ void VideoMode::applyAspectCorrection(uInt32 aspect, bool stretch)
}
// Now re-calculate the dimensions
iw = BSPF_min(iw, (uInt32)screen.w);
ih = BSPF_min(ih, (uInt32)screen.h);
iw = BSPF_min(iw, screen.w);
ih = BSPF_min(ih, screen.h);
image.moveTo((screen.w - iw) >> 1, (screen.h - ih) >> 1);
image.setWidth(iw);
@ -850,14 +850,14 @@ bool FrameBuffer::VideoModeList::empty() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 FrameBuffer::VideoModeList::size() const
{
return (uInt32)myModeList.size();
return myModeList.size();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::VideoModeList::previous()
{
--myIdx;
if(myIdx < 0) myIdx = (int)myModeList.size() - 1;
if(myIdx < 0) myIdx = int(myModeList.size()) - 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -449,6 +449,11 @@ class FrameBuffer
VideoModeList();
~VideoModeList();
VideoModeList(const VideoModeList&) = default;
VideoModeList(VideoModeList&&) = default;
VideoModeList& operator=(const VideoModeList&) = default;
VideoModeList& operator=(VideoModeList&&) = default;
void add(const VideoMode& mode);
void clear();

View File

@ -64,7 +64,7 @@ OSystem::OSystem()
myQuitLoop(false)
{
// Calculate startup time
myMillisAtStart = (uInt32)(time(NULL) * 1000);
myMillisAtStart = uInt32(time(NULL) * 1000);
// Get built-in features
#ifdef SOUND_SUPPORT
@ -85,8 +85,8 @@ OSystem::OSystem()
SDL_version ver;
SDL_GetVersion(&ver);
info << "Build " << STELLA_BUILD << ", using SDL " << (int)ver.major
<< "." << (int)ver.minor << "."<< (int)ver.patch
info << "Build " << STELLA_BUILD << ", using SDL " << int(ver.major)
<< "." << int(ver.minor) << "."<< int(ver.patch)
<< " [" << BSPF_ARCH << "]";
myBuildInfo = info.str();
@ -236,7 +236,7 @@ void OSystem::setFramerate(float framerate)
if(framerate > 0.0)
{
myDisplayFrameRate = framerate;
myTimePerFrame = (uInt32)(1000000.0 / myDisplayFrameRate);
myTimePerFrame = uInt32(1000000.0 / myDisplayFrameRate);
}
}
@ -458,7 +458,7 @@ void OSystem::logMessage(const string& message, uInt8 level)
cout << message << endl << flush;
myLogMessages += message + "\n";
}
else if(level <= (uInt8)mySettings->getInt("loglevel"))
else if(level <= uInt8(mySettings->getInt("loglevel")))
{
if(mySettings->getBool("logtoconsole"))
cout << message << endl << flush;

View File

@ -269,14 +269,12 @@ void Paddles::update()
int sa_yaxis = myEvent.get(myP1AxisValue);
if(abs(myLastAxisX - sa_xaxis) > 10)
{
myAnalogPinValue[Nine] = (Int32)(1400000 *
(float)(32767 - (Int16)sa_xaxis) / 65536.0);
myAnalogPinValue[Nine] = Int32(1400000 * (32767 - Int16(sa_xaxis)) / 65536.0);
sa_changed = true;
}
if(abs(myLastAxisY - sa_yaxis) > 10)
{
myAnalogPinValue[Five] = (Int32)(1400000 *
(float)(32767 - (Int16)sa_yaxis) / 65536.0);
myAnalogPinValue[Five] = Int32(1400000 * (32767 - Int16(sa_yaxis)) / 65536.0);
sa_changed = true;
}
myLastAxisX = sa_xaxis;
@ -373,10 +371,10 @@ void Paddles::update()
// Only change state if the charge has actually changed
if(myCharge[1] != myLastCharge[1])
myAnalogPinValue[Five] =
(Int32)(1400000 * (myCharge[1] / float(TRIGRANGE)));
Int32(1400000 * (myCharge[1] / float(TRIGRANGE)));
if(myCharge[0] != myLastCharge[0])
myAnalogPinValue[Nine] =
(Int32)(1400000 * (myCharge[0] / float(TRIGRANGE)));
Int32(1400000 * (myCharge[0] / float(TRIGRANGE)));
myLastCharge[1] = myCharge[1];
myLastCharge[0] = myCharge[0];

View File

@ -119,7 +119,7 @@ bool PropertiesSet::getMD5(const string& md5, Properties& properties,
{
for(int p = 0; p < LastPropType; ++p)
if(DefProps[i][p][0] != 0)
properties.set((PropertyType)p, DefProps[i][p]);
properties.set(PropertyType(p), DefProps[i][p]);
found = true;
break;
@ -207,7 +207,7 @@ void PropertiesSet::print() const
properties.setDefaults();
for(int p = 0; p < LastPropType; ++p)
if(DefProps[i][p][0] != 0)
properties.set((PropertyType)p, DefProps[i][p]);
properties.set(PropertyType(p), DefProps[i][p]);
list.insert(make_pair(DefProps[i][Cartridge_MD5], properties));
}

View File

@ -99,14 +99,14 @@ uInt8 Serializer::getByte() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::getByteArray(uInt8* array, uInt32 size) const
{
myStream->read((char*)array, size);
myStream->read(reinterpret_cast<char*>(array), size);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Serializer::getShort() const
{
uInt16 val = 0;
myStream->read((char*)&val, sizeof(uInt16));
myStream->read(reinterpret_cast<char*>(&val), sizeof(uInt16));
return val;
}
@ -114,14 +114,14 @@ uInt16 Serializer::getShort() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::getShortArray(uInt16* array, uInt32 size) const
{
myStream->read((char*)array, sizeof(uInt16)*size);
myStream->read(reinterpret_cast<char*>(array), sizeof(uInt16)*size);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 Serializer::getInt() const
{
uInt32 val = 0;
myStream->read((char*)&val, sizeof(uInt32));
myStream->read(reinterpret_cast<char*>(&val), sizeof(uInt32));
return val;
}
@ -129,7 +129,7 @@ uInt32 Serializer::getInt() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::getIntArray(uInt32* array, uInt32 size) const
{
myStream->read((char*)array, sizeof(uInt32)*size);
myStream->read(reinterpret_cast<char*>(array), sizeof(uInt32)*size);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -152,43 +152,43 @@ bool Serializer::getBool() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::putByte(uInt8 value)
{
myStream->write((char*)&value, 1);
myStream->write(reinterpret_cast<char*>(&value), 1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::putByteArray(const uInt8* array, uInt32 size)
{
myStream->write((char*)array, size);
myStream->write(reinterpret_cast<const char*>(array), size);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::putShort(uInt16 value)
{
myStream->write((char*)&value, sizeof(uInt16));
myStream->write(reinterpret_cast<char*>(&value), sizeof(uInt16));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::putShortArray(const uInt16* array, uInt32 size)
{
myStream->write((char*)array, sizeof(uInt16)*size);
myStream->write(reinterpret_cast<const char*>(array), sizeof(uInt16)*size);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::putInt(uInt32 value)
{
myStream->write((char*)&value, sizeof(uInt32));
myStream->write(reinterpret_cast<char*>(&value), sizeof(uInt32));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::putIntArray(const uInt32* array, uInt32 size)
{
myStream->write((char*)array, sizeof(uInt32)*size);
myStream->write(reinterpret_cast<const char*>(array), sizeof(uInt32)*size);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::putString(const string& str)
{
int len = (int)str.length();
int len = int(str.length());
putInt(len);
myStream->write(str.data(), len);
}

View File

@ -44,7 +44,7 @@ class Sound : public Serializable
/**
Destructor
*/
virtual ~Sound() { };
virtual ~Sound() { }
public:
/**

View File

@ -114,13 +114,13 @@ void ComboDialog::loadConfig()
{
StringList events = instance().eventHandler().getComboListForEvent(myComboEvent);
int size = BSPF_min((int)events.size(), 8);
for(int i = 0; i < size; ++i)
uInt32 size = BSPF_min(uInt32(events.size()), 8u);
for(uInt32 i = 0; i < size; ++i)
myEvents[i]->setSelected("", events[i]);
// Fill any remaining items to 'None'
if(size < 8)
for(int i = size; i < 8; ++i)
for(uInt32 i = size; i < 8; ++i)
myEvents[i]->setSelected("None", "-1");
}

View File

@ -67,7 +67,7 @@ void ContextMenu::addItems(const VariantList& items)
_h = 1; // recalculate this in ::recalc()
_scrollUpColor = _firstEntry > 0 ? kScrollColor : kColor;
_scrollDnColor = (_firstEntry + _numEntries < (int)_entries.size()) ?
_scrollDnColor = (_firstEntry + _numEntries < int(_entries.size())) ?
kScrollColor : kColor;
}
@ -115,8 +115,8 @@ void ContextMenu::recalc(const GUI::Rect& image)
}
else
{
_numEntries = (int)_entries.size();
_h = (int)_entries.size() * _rowHeight + 4;
_numEntries = int(_entries.size());
_h = int(_entries.size()) * _rowHeight + 4;
_showScroll = false;
}
_isScrolling = false;
@ -125,7 +125,7 @@ void ContextMenu::recalc(const GUI::Rect& image)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::setSelectedIndex(int idx)
{
if(idx >= 0 && idx < (int)_entries.size())
if(idx >= 0 && idx < int(_entries.size()))
_selectedItem = idx;
else
_selectedItem = -1;
@ -160,7 +160,7 @@ void ContextMenu::setSelected(const Variant& tag, const Variant& defaultTag)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::setSelectedMax()
{
setSelectedIndex((int)_entries.size() - 1);
setSelectedIndex(int(_entries.size()) - 1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -201,7 +201,7 @@ bool ContextMenu::sendSelectionUp()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ContextMenu::sendSelectionDown()
{
if(isVisible() || _selectedItem >= (int)_entries.size() - 1)
if(isVisible() || _selectedItem >= int(_entries.size()) - 1)
return false;
_selectedItem++;
@ -226,7 +226,7 @@ bool ContextMenu::sendSelectionLast()
if(isVisible())
return false;
_selectedItem = (int)_entries.size() - 1;
_selectedItem = int(_entries.size()) - 1;
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1);
return true;
}
@ -421,12 +421,12 @@ void ContextMenu::moveDown()
// Otherwise, the offset should increase by 1
if(_selectedOffset == _numEntries)
scrollDown();
else if(_selectedOffset < (int)_entries.size())
else if(_selectedOffset < int(_entries.size()))
drawCurrentSelection(_selectedOffset+1);
}
else
{
if(_selectedOffset < (int)_entries.size() - 1)
if(_selectedOffset < int(_entries.size()) - 1)
drawCurrentSelection(_selectedOffset+1);
}
}
@ -443,7 +443,7 @@ void ContextMenu::movePgUp()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::movePgDown()
{
if(_firstEntry == (int)(_entries.size() - _numEntries))
if(_firstEntry == int(_entries.size() - _numEntries))
moveToLast();
else
scrollDown(_numEntries);
@ -462,7 +462,7 @@ void ContextMenu::moveToFirst()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::moveToLast()
{
_firstEntry = (int)_entries.size() - _numEntries;
_firstEntry = int(_entries.size()) - _numEntries;
_scrollUpColor = kScrollColor;
_scrollDnColor = kColor;
@ -472,7 +472,7 @@ void ContextMenu::moveToLast()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::moveToSelected()
{
if(_selectedItem < 0 || _selectedItem >= (int)_entries.size())
if(_selectedItem < 0 || _selectedItem >= int(_entries.size()))
return;
// First jump immediately to the item
@ -481,7 +481,7 @@ void ContextMenu::moveToSelected()
// Now check if we've gone past the current 'window' size, and scale
// back accordingly
int max_offset = (int)_entries.size() - _numEntries;
int max_offset = int(_entries.size()) - _numEntries;
if(_firstEntry > max_offset)
{
offset = _firstEntry - max_offset;
@ -510,7 +510,7 @@ void ContextMenu::scrollUp(int distance)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::scrollDown(int distance)
{
int max_offset = (int)_entries.size() - _numEntries;
int max_offset = int(_entries.size()) - _numEntries;
if(_firstEntry == max_offset)
return;

View File

@ -153,7 +153,7 @@ void Dialog::addToFocusList(WidgetArray& list)
void Dialog::addToFocusList(WidgetArray& list, TabWidget* w, int tabId)
{
// Only add the list if the tab actually exists
if(!w || w->getID() < 0 || (uInt32)w->getID() >= _myTabList.size())
if(!w || w->getID() < 0 || uInt32(w->getID()) >= _myTabList.size())
return;
assert(w == _myTabList[w->getID()].widget);
@ -221,7 +221,7 @@ void Dialog::buildCurrentFocusList(int tabID)
// Remember which tab item previously had focus, if applicable
// This only applies if this method was called for a tab change
Widget* tabFocusWidget = nullptr;
if(tabID >= 0 && tabID < (int)_myTabList.size())
if(tabID >= 0 && tabID < int(_myTabList.size()))
{
// Save focus in previously selected tab column,
// and get focus for new tab column
@ -611,7 +611,7 @@ void Dialog::getTabIdForWidget(Widget* w)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Dialog::cycleTab(int direction)
{
if(_tabID >= 0 && _tabID < (int)_myTabList.size())
if(_tabID >= 0 && _tabID < int(_myTabList.size()))
{
_myTabList[_tabID].widget->cycleTab(direction);
return true;
@ -708,7 +708,7 @@ void Dialog::TabFocus::appendFocusList(WidgetArray& list)
{
int active = widget->getActiveTab();
if(active >= 0 && active < (int)focus.size())
if(active >= 0 && active < int(focus.size()))
Vec::append(list, focus[active].list);
}

View File

@ -132,6 +132,11 @@ class Dialog : public GuiObject
Focus(Widget* w = nullptr);
virtual ~Focus();
Focus(const Focus&) = default;
Focus(Focus&&) = default;
Focus& operator=(const Focus&) = default;
Focus& operator=(Focus&&) = default;
};
using FocusList = vector<Focus>;
@ -143,6 +148,11 @@ class Dialog : public GuiObject
TabFocus(TabWidget* w = nullptr);
virtual ~TabFocus();
TabFocus(const TabFocus&) = default;
TabFocus(TabFocus&&) = default;
TabFocus& operator=(const TabFocus&) = default;
TabFocus& operator=(TabFocus&&) = default;
void appendFocusList(WidgetArray& list);
void saveCurrentFocus(Widget* w);
Widget* getNewFocus();

View File

@ -59,7 +59,7 @@ void EditableWidget::setText(const string& str, bool)
if(_filter(tolower(c)))
_editString.push_back(c);
_caretPos = (int)_editString.size();
_caretPos = _editString.size();
_editScrollOffset = (_font.getStringWidth(_editString) - (getEditRect().width()));
if (_editScrollOffset < 0)
@ -153,7 +153,7 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod)
case KBDK_RIGHT:
if(instance().eventHandler().kbdControl(mod))
dirty = specialKeys(key);
else if(_caretPos < (int)_editString.size())
else if(_caretPos < int(_editString.size()))
dirty = setCaretPos(_caretPos + 1);
break;
@ -162,7 +162,7 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod)
break;
case KBDK_END:
dirty = setCaretPos((int)_editString.size());
dirty = setCaretPos(int(_editString.size()));
break;
default:
@ -215,7 +215,7 @@ void EditableWidget::drawCaret()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EditableWidget::setCaretPos(int newPos)
{
assert(newPos >= 0 && newPos <= (int)_editString.size());
assert(newPos >= 0 && newPos <= int(_editString.size()));
_caretPos = newPos;
return adjustOffset();
@ -275,7 +275,7 @@ bool EditableWidget::specialKeys(StellaKey key)
break;
case KBDK_E:
setCaretPos((int)_editString.size());
setCaretPos(_editString.size());
break;
case KBDK_D:
@ -359,7 +359,7 @@ bool EditableWidget::killLine(int direction)
}
else if(direction == 1) // erase from current position to end of line
{
int count = (int)_editString.size() - _caretPos;
int count = int(_editString.size()) - _caretPos;
if(count > 0)
{
for (int i = 0; i < count; i++)
@ -429,7 +429,7 @@ bool EditableWidget::moveWord(int direction)
}
else if(direction == +1) // move to first character of next word
{
while (currentPos < (int)_editString.size())
while (currentPos < int(_editString.size()))
{
if (_editString[currentPos - 1] == ' ')
{

View File

@ -78,7 +78,7 @@ void FileListWidget::setLocation(const FilesystemNode& node, string select)
// Now fill the list widget with the contents of the GameList
StringList l;
for(int i = 0; i < (int) _gameList.size(); ++i)
for(uInt32 i = 0; i < _gameList.size(); ++i)
l.push_back(_gameList.name(i));
setList(l);

View File

@ -53,7 +53,7 @@ int Font::getStringWidth(const string& str) const
{
// If no width table is specified, use the maximum width
if(!myFontDesc.width)
return (int)(myFontDesc.maxwidth * str.size());
return myFontDesc.maxwidth * str.size();
else
{
int space = 0;

View File

@ -45,13 +45,13 @@ class GameList
void setMd5(uInt32 i, const string& md5)
{ myArray[i]._md5 = md5; }
uInt32 size() const { return (uInt32)myArray.size(); }
uInt32 size() const { return myArray.size(); }
void clear() { myArray.clear(); }
void appendGame(const string& name, const string& path, const string& md5,
bool isDir = false) {
myArray.emplace_back(name, path, md5, isDir);
};
}
void sortByName();
private:

View File

@ -114,6 +114,7 @@ struct Rect
Rect() : top(0), left(0), bottom(0), right(0) { }
Rect(const Rect& s) : top(s.top), left(s.left), bottom(s.bottom), right(s.right) { }
Rect& operator=(const Rect&) = default;
Rect(uInt32 w, uInt32 h) : top(0), left(0), bottom(h), right(w) { }
Rect(const Point& p, uInt32 w, uInt32 h) : top(p.y), left(p.x), bottom(h), right(w) { }
Rect(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) : top(y1), left(x1), bottom(y2), right(x2)