Some updates to the last BUS/CDF commit:

- update some code to the '5.0' way of doing things
  - allow compilation in Linux
  - whitespace/tab fixes to match main codebase
  - add some extra comments
  - test compile under gcc 6 and clang 5, and fix some warnings
This commit is contained in:
Stephen Anthony 2017-03-24 18:02:08 -02:30
parent 7c6821dfcb
commit 95c7b30a45
16 changed files with 693 additions and 719 deletions

View File

@ -8,13 +8,11 @@
// SS SS tt ee ll ll aa aa // SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa // SSSS ttt eeeee llll llll aaaaa
// //
// Copyright (c) 1995-2015 by Bradford W. Mott, Stephen Anthony // Copyright (c) 1995-2017 by Bradford W. Mott, Stephen Anthony
// and the Stella Team // and the Stella Team
// //
// See the file "License.txt" for information on usage and redistribution of // See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartBUSWidget.cxx 3131 2015-01-01 03:49:32Z stephena $
//============================================================================ //============================================================================
#include "CartBUS.hxx" #include "CartBUS.hxx"
@ -149,7 +147,6 @@ CartridgeBUSWidget::CartridgeBUSWidget(
myZPSTY = new CheckboxWidget(boss, _font, xpos, ypos, "Zero Page STY"); myZPSTY = new CheckboxWidget(boss, _font, xpos, ypos, "Zero Page STY");
myZPSTY->setTarget(this); myZPSTY->setTarget(this);
myZPSTY->setEditable(false); myZPSTY->setEditable(false);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -226,7 +223,7 @@ void CartridgeBUSWidget::loadConfig()
// I = Increment // I = Increment
// F = Fractional // F = Fractional
uInt32 pointervalue = myCart.getDatastreamPointer(i) >> 12; Int32 pointervalue = myCart.getDatastreamPointer(i) >> 12;
alist.push_back(0); vlist.push_back(pointervalue); alist.push_back(0); vlist.push_back(pointervalue);
changed.push_back(pointervalue != myOldState.datastreampointers[i]); changed.push_back(pointervalue != myOldState.datastreampointers[i]);
} }
@ -235,7 +232,7 @@ void CartridgeBUSWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(int i = 0; i < 16; ++i) for(int i = 0; i < 16; ++i)
{ {
uInt32 incrementvalue = myCart.getDatastreamIncrement(i); Int32 incrementvalue = myCart.getDatastreamIncrement(i);
alist.push_back(0); vlist.push_back(incrementvalue); alist.push_back(0); vlist.push_back(incrementvalue);
changed.push_back(incrementvalue != myOldState.datastreamincrements[i]); changed.push_back(incrementvalue != myOldState.datastreamincrements[i]);
} }
@ -244,7 +241,7 @@ void CartridgeBUSWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(int i = 0; i < 40; ++i) for(int i = 0; i < 40; ++i)
{ {
uInt32 mapvalue = myCart.getAddressMap(i); Int32 mapvalue = myCart.getAddressMap(i);
alist.push_back(0); vlist.push_back(mapvalue); alist.push_back(0); vlist.push_back(mapvalue);
changed.push_back(mapvalue != myOldState.addressmaps[i]); changed.push_back(mapvalue != myOldState.addressmaps[i]);
} }
@ -270,7 +267,7 @@ void CartridgeBUSWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5); alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5);
changed.push_back((myCart.getWaveform(i) >> 5) != myOldState.mwaves[i]); changed.push_back((myCart.getWaveform(i) >> 5) != uInt32(myOldState.mwaves[i]));
} }
myMusicWaveforms->setList(alist, vlist, changed); myMusicWaveforms->setList(alist, vlist, changed);
@ -278,7 +275,7 @@ void CartridgeBUSWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i)); alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i));
changed.push_back((myCart.getWaveformSize(i)) != myOldState.mwavesizes[i]); changed.push_back((myCart.getWaveformSize(i)) != uInt32(myOldState.mwavesizes[i]));
} }
myMusicWaveformSizes->setList(alist, vlist, changed); myMusicWaveformSizes->setList(alist, vlist, changed);
@ -290,7 +287,7 @@ void CartridgeBUSWidget::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeBUSWidget::handleCommand(CommandSender* sender, void CartridgeBUSWidget::handleCommand(CommandSender* sender,
int cmd, int data, int id) int cmd, int data, int id)
{ {
if(cmd == kBankChanged) if(cmd == kBankChanged)
{ {

View File

@ -8,13 +8,11 @@
// SS SS tt ee ll ll aa aa // SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa // SSSS ttt eeeee llll llll aaaaa
// //
// Copyright (c) 1995-2015 by Bradford W. Mott, Stephen Anthony // Copyright (c) 1995-2017 by Bradford W. Mott, Stephen Anthony
// and the Stella Team // and the Stella Team
// //
// See the file "License.txt" for information on usage and redistribution of // See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartBUSWidget.hxx 3131 2015-01-01 03:49:32Z stephena $
//============================================================================ //============================================================================
#ifndef CARTRIDGEBUS_WIDGET_HXX #ifndef CARTRIDGEBUS_WIDGET_HXX
@ -31,10 +29,10 @@ class CartridgeBUSWidget : public CartDebugWidget
{ {
public: public:
CartridgeBUSWidget(GuiObject* boss, const GUI::Font& lfont, CartridgeBUSWidget(GuiObject* boss, const GUI::Font& lfont,
const GUI::Font& nfont, const GUI::Font& nfont,
int x, int y, int w, int h, int x, int y, int w, int h,
CartridgeBUS& cart); CartridgeBUS& cart);
virtual ~CartridgeBUSWidget() { } virtual ~CartridgeBUSWidget() = default;
private: private:
struct CartState { struct CartState {
@ -67,7 +65,7 @@ class CartridgeBUSWidget : public CartDebugWidget
enum { kBankChanged = 'bkCH' }; enum { kBankChanged = 'bkCH' };
private: private:
void saveOldState() override; void saveOldState() override;
void loadConfig() override; void loadConfig() override;

24
src/debugger/gui/CartCDFWidget.cxx Executable file → Normal file
View File

@ -8,13 +8,11 @@
// SS SS tt ee ll ll aa aa // SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa // SSSS ttt eeeee llll llll aaaaa
// //
// Copyright (c) 1995-2015 by Bradford W. Mott, Stephen Anthony // Copyright (c) 1995-2017 by Bradford W. Mott, Stephen Anthony
// and the Stella Team // and the Stella Team
// //
// See the file "License.txt" for information on usage and redistribution of // See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartCDFWidget.cxx 3131 2015-01-01 03:49:32Z stephena $
//============================================================================ //============================================================================
#include "CartCDF.hxx" #include "CartCDF.hxx"
@ -24,10 +22,10 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeCDFWidget::CartridgeCDFWidget( CartridgeCDFWidget::CartridgeCDFWidget(
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
int x, int y, int w, int h, CartridgeCDF& cart) int x, int y, int w, int h, CartridgeCDF& cart)
: CartDebugWidget(boss, lfont, nfont, x, y, w, h), : CartDebugWidget(boss, lfont, nfont, x, y, w, h),
myCart(cart) myCart(cart)
{ {
uInt16 size = 8 * 4096; uInt16 size = 8 * 4096;
@ -211,7 +209,7 @@ void CartridgeCDFWidget::loadConfig()
// I = Increment // I = Increment
// F = Fractional // F = Fractional
uInt32 pointervalue = myCart.getDatastreamPointer(i) >> 12; Int32 pointervalue = myCart.getDatastreamPointer(i) >> 12;
alist.push_back(0); vlist.push_back(pointervalue); alist.push_back(0); vlist.push_back(pointervalue);
changed.push_back(pointervalue != myOldState.datastreampointers[i]); changed.push_back(pointervalue != myOldState.datastreampointers[i]);
} }
@ -220,7 +218,7 @@ void CartridgeCDFWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(int i = 0; i < 32; ++i) for(int i = 0; i < 32; ++i)
{ {
uInt32 incrementvalue = myCart.getDatastreamIncrement(i); Int32 incrementvalue = myCart.getDatastreamIncrement(i);
alist.push_back(0); vlist.push_back(incrementvalue); alist.push_back(0); vlist.push_back(incrementvalue);
changed.push_back(incrementvalue != myOldState.datastreamincrements[i]); changed.push_back(incrementvalue != myOldState.datastreamincrements[i]);
} }
@ -230,7 +228,7 @@ void CartridgeCDFWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.myMusicCounters[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); myMusicCounters->setList(alist, vlist, changed);
@ -238,7 +236,7 @@ void CartridgeCDFWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[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); myMusicFrequencies->setList(alist, vlist, changed);
@ -246,7 +244,7 @@ void CartridgeCDFWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5); alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5);
changed.push_back((myCart.getWaveform(i) >> 5) != myOldState.mwaves[i]); changed.push_back((myCart.getWaveform(i) >> 5) != uInt32(myOldState.mwaves[i]));
} }
myMusicWaveforms->setList(alist, vlist, changed); myMusicWaveforms->setList(alist, vlist, changed);
@ -254,7 +252,7 @@ void CartridgeCDFWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i)); alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i));
changed.push_back((myCart.getWaveformSize(i)) != myOldState.mwavesizes[i]); changed.push_back((myCart.getWaveformSize(i)) != uInt32(myOldState.mwavesizes[i]));
} }
myMusicWaveformSizes->setList(alist, vlist, changed); myMusicWaveformSizes->setList(alist, vlist, changed);

110
src/debugger/gui/CartCDFWidget.hxx Executable file → Normal file
View File

@ -8,13 +8,11 @@
// SS SS tt ee ll ll aa aa // SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa // SSSS ttt eeeee llll llll aaaaa
// //
// Copyright (c) 1995-2015 by Bradford W. Mott, Stephen Anthony // Copyright (c) 1995-2017 by Bradford W. Mott, Stephen Anthony
// and the Stella Team // and the Stella Team
// //
// See the file "License.txt" for information on usage and redistribution of // See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartCDFWidget.hxx 3131 2015-01-01 03:49:32Z stephena $
//============================================================================ //============================================================================
#ifndef CARTRIDGECDF_WIDGET_HXX #ifndef CARTRIDGECDF_WIDGET_HXX
@ -29,68 +27,68 @@ class DataGridWidget;
class CartridgeCDFWidget : public CartDebugWidget class CartridgeCDFWidget : public CartDebugWidget
{ {
public: public:
CartridgeCDFWidget(GuiObject* boss, const GUI::Font& lfont, CartridgeCDFWidget(GuiObject* boss, const GUI::Font& lfont,
const GUI::Font& nfont, const GUI::Font& nfont,
int x, int y, int w, int h, int x, int y, int w, int h,
CartridgeCDF& cart); CartridgeCDF& cart);
virtual ~CartridgeCDFWidget() { } virtual ~CartridgeCDFWidget() = default;
private: private:
struct CartState { struct CartState {
ByteArray tops; ByteArray tops;
ByteArray bottoms; ByteArray bottoms;
IntArray datastreampointers; IntArray datastreampointers;
IntArray datastreamincrements; IntArray datastreamincrements;
IntArray addressmaps; IntArray addressmaps;
IntArray mcounters; IntArray mcounters;
IntArray mfreqs; IntArray mfreqs;
IntArray mwaves; IntArray mwaves;
IntArray mwavesizes; IntArray mwavesizes;
uInt32 random; uInt32 random;
ByteArray internalram; ByteArray internalram;
}; };
CartridgeCDF& myCart; CartridgeCDF& myCart;
PopUpWidget* myBank; PopUpWidget* myBank;
DataGridWidget* myDatastreamPointers; DataGridWidget* myDatastreamPointers;
DataGridWidget* myDatastreamIncrements; DataGridWidget* myDatastreamIncrements;
DataGridWidget* myMusicCounters; DataGridWidget* myMusicCounters;
DataGridWidget* myMusicFrequencies; DataGridWidget* myMusicFrequencies;
DataGridWidget* myMusicWaveforms; DataGridWidget* myMusicWaveforms;
DataGridWidget* myMusicWaveformSizes; DataGridWidget* myMusicWaveformSizes;
// done differently than in DPC+, need to rethink debugger support // done differently than in DPC+, need to rethink debugger support
// CheckboxWidget* myFastFetch; // CheckboxWidget* myFastFetch;
// CheckboxWidget* myIMLDA; // CheckboxWidget* myIMLDA;
CartState myOldState; CartState myOldState;
enum { kBankChanged = 'bkCH' }; enum { kBankChanged = 'bkCH' };
private: private:
void saveOldState() override; void saveOldState() override;
void loadConfig() override; void loadConfig() override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
string bankState() override; string bankState() override;
// start of functions for Cartridge RAM tab // start of functions for Cartridge RAM tab
uInt32 internalRamSize() override; uInt32 internalRamSize() override;
uInt32 internalRamRPort(int start) override; uInt32 internalRamRPort(int start) override;
string internalRamDescription() override; string internalRamDescription() override;
const ByteArray& internalRamOld(int start, int count) override; const ByteArray& internalRamOld(int start, int count) override;
const ByteArray& internalRamCurrent(int start, int count) override; const ByteArray& internalRamCurrent(int start, int count) override;
void internalRamSetValue(int addr, uInt8 value) override; void internalRamSetValue(int addr, uInt8 value) override;
uInt8 internalRamGetValue(int addr) override; uInt8 internalRamGetValue(int addr) override;
// end of functions for Cartridge RAM tab // end of functions for Cartridge RAM tab
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported
CartridgeCDFWidget() = delete; CartridgeCDFWidget() = delete;
CartridgeCDFWidget(const CartridgeCDFWidget&) = delete; CartridgeCDFWidget(const CartridgeCDFWidget&) = delete;
CartridgeCDFWidget(CartridgeCDFWidget&&) = delete; CartridgeCDFWidget(CartridgeCDFWidget&&) = delete;
CartridgeCDFWidget& operator=(const CartridgeCDFWidget&) = delete; CartridgeCDFWidget& operator=(const CartridgeCDFWidget&) = delete;
CartridgeCDFWidget& operator=(CartridgeCDFWidget&&) = delete; CartridgeCDFWidget& operator=(CartridgeCDFWidget&&) = delete;
}; };
#endif #endif

View File

@ -690,6 +690,7 @@ void DataGridWidget::endEditMode()
editString().insert(0, 1, '#'); editString().insert(0, 1, '#');
break; break;
case Common::Base::F_DEFAULT: case Common::Base::F_DEFAULT:
default:
break; break;
} }
} }

View File

@ -111,6 +111,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont,
return (c >= '0' && c <= '9') || c == ' '; return (c >= '0' && c <= '9') || c == ' ';
case Common::Base::F_DEFAULT: case Common::Base::F_DEFAULT:
default:
return false; return false;
} }
return false; return false;

View File

@ -31,6 +31,8 @@ MODULE_OBJS := \
src/debugger/gui/Cart4KWidget.o \ src/debugger/gui/Cart4KWidget.o \
src/debugger/gui/Cart4KSCWidget.o \ src/debugger/gui/Cart4KSCWidget.o \
src/debugger/gui/CartARWidget.o \ src/debugger/gui/CartARWidget.o \
src/debugger/gui/CartBUSWidget.o \
src/debugger/gui/CartCDFWidget.o \
src/debugger/gui/CartCMWidget.o \ src/debugger/gui/CartCMWidget.o \
src/debugger/gui/CartCTYWidget.o \ src/debugger/gui/CartCTYWidget.o \
src/debugger/gui/CartCVWidget.o \ src/debugger/gui/CartCVWidget.o \

View File

@ -8,13 +8,11 @@
// SS SS tt ee ll ll aa aa // SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa // SSSS ttt eeeee llll llll aaaaa
// //
// Copyright (c) 1995-2015 by Bradford W. Mott, Stephen Anthony // Copyright (c) 1995-2017 by Bradford W. Mott, Stephen Anthony
// and the Stella Team // and the Stella Team
// //
// See the file "License.txt" for information on usage and redistribution of // See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartBUS.cxx 3131 2015-01-01 03:49:32Z stephena $
//============================================================================ //============================================================================
#include <cstring> #include <cstring>
@ -61,11 +59,8 @@ CartridgeBUS::CartridgeBUS(const uInt8* image, uInt32 size,
#ifdef THUMB_SUPPORT #ifdef THUMB_SUPPORT
// Create Thumbulator ARM emulator // Create Thumbulator ARM emulator
myThumbEmulator = make_ptr<Thumbulator> myThumbEmulator = make_ptr<Thumbulator>((uInt16*)myImage, (uInt16*)myBUSRAM,
((uInt16*)myImage, (uInt16*)myBUSRAM, settings.getBool("thumb.trapfatal"), Thumbulator::ConfigureFor::BUS, this);
settings.getBool("thumb.trapfatal"),
Thumbulator::ConfigureFor::BUS,
this);
#endif #endif
setInitialState(); setInitialState();
@ -76,18 +71,12 @@ CartridgeBUS::CartridgeBUS(const uInt8* image, uInt32 size,
myBusStuff = false; myBusStuff = false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeBUS::~CartridgeBUS()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeBUS::reset() void CartridgeBUS::reset()
{ {
// Initialize RAM // Initialize RAM
if(mySettings.getBool("ramrandom")) if(mySettings.getBool("ramrandom"))
for(uInt32 t = 2048; t < 8192; ++t) initializeRAM(myBUSRAM+2048, 8192-2048);
myBUSRAM[t] = mySystem->randGenerator().next();
else else
memset(myBUSRAM+2048, 0, 8192-2048); memset(myBUSRAM+2048, 0, 8192-2048);
@ -328,6 +317,8 @@ uInt8 CartridgeBUS::peek(uInt16 address)
return peekvalue; return peekvalue;
} }
} }
return 0; // make compiler happy
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -343,7 +334,6 @@ bool CartridgeBUS::poke(uInt16 address, uInt8 value)
mySystem->m6532().poke(address, value); mySystem->m6532().poke(address, value);
else if(!(lowAddress & 0x200)) else if(!(lowAddress & 0x200))
mySystem->tia().poke(address, value); mySystem->tia().poke(address, value);
} }
else else
{ {
@ -506,7 +496,6 @@ const uInt8* CartridgeBUS::getImage(int& size) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgeBUS::busOverdrive(uInt16 address) uInt8 CartridgeBUS::busOverdrive(uInt16 address)
{ {
uInt8 overdrive = 0xff; uInt8 overdrive = 0xff;
@ -521,19 +510,19 @@ uInt8 CartridgeBUS::busOverdrive(uInt16 address)
if (address == myBusOverdriveAddress) if (address == myBusOverdriveAddress)
{ {
uInt8 map = address & 0x7f; uInt8 map = address & 0x7f;
if (map <= 0x24) // map TIA registers VSYNC thru HMBL inclusive if (map <= 0x24) // map TIA registers VSYNC thru HMBL inclusive
{ {
uInt32 alldatastreams = getAddressMap(map); uInt32 alldatastreams = getAddressMap(map);
uInt8 datastream = alldatastreams & 0x0f; // lowest nybble has the current datastream to use uInt8 datastream = alldatastreams & 0x0f; // lowest nybble has the current datastream to use
overdrive = readFromDatastream(datastream); overdrive = readFromDatastream(datastream);
// rotate map nybbles for next time // rotate map nybbles for next time
alldatastreams >>= 4; alldatastreams >>= 4;
alldatastreams |= (datastream << 28); alldatastreams |= (datastream << 28);
setAddressMap(map, alldatastreams); setAddressMap(map, alldatastreams);
// overdrive |= 0x7c; // breaks bus stuffing to match hobo's system // overdrive |= 0x7c; // breaks bus stuffing to match hobo's system
} }
} }
myBusOverdriveAddress = 0xff; // turns off overdrive for next poke event myBusOverdriveAddress = 0xff; // turns off overdrive for next poke event
@ -542,10 +531,8 @@ uInt8 CartridgeBUS::busOverdrive(uInt16 address)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeBUS::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2) uInt32 CartridgeBUS::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2)
{ {
switch (function) switch (function)
{ {
case 0: case 0:
@ -573,7 +560,6 @@ uInt32 CartridgeBUS::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2)
return 0; return 0;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeBUS::save(Serializer& out) const bool CartridgeBUS::save(Serializer& out) const
{ {
@ -629,7 +615,8 @@ bool CartridgeBUS::load(Serializer& in)
return true; return true;
} }
uInt32 CartridgeBUS::getDatastreamPointer(uInt8 index) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeBUS::getDatastreamPointer(uInt8 index) const
{ {
// index &= 0x0f; // index &= 0x0f;
@ -639,6 +626,7 @@ uInt32 CartridgeBUS::getDatastreamPointer(uInt8 index)
(myBUSRAM[DSxPTR + index*4 + 3] << 24) ; // high byte (myBUSRAM[DSxPTR + index*4 + 3] << 24) ; // high byte
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeBUS::setDatastreamPointer(uInt8 index, uInt32 value) void CartridgeBUS::setDatastreamPointer(uInt8 index, uInt32 value)
{ {
// index &= 0x0f; // index &= 0x0f;
@ -648,7 +636,8 @@ void CartridgeBUS::setDatastreamPointer(uInt8 index, uInt32 value)
myBUSRAM[DSxPTR + index*4 + 3] = (value >> 24) & 0xff; // high byte myBUSRAM[DSxPTR + index*4 + 3] = (value >> 24) & 0xff; // high byte
} }
uInt32 CartridgeBUS::getDatastreamIncrement(uInt8 index) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeBUS::getDatastreamIncrement(uInt8 index) const
{ {
// index &= 0x0f; // index &= 0x0f;
return myBUSRAM[DSxINC + index*4 + 0] + // low byte return myBUSRAM[DSxINC + index*4 + 0] + // low byte
@ -657,6 +646,7 @@ uInt32 CartridgeBUS::getDatastreamIncrement(uInt8 index)
(myBUSRAM[DSxINC + index*4 + 3] << 24) ; // high byte (myBUSRAM[DSxINC + index*4 + 3] << 24) ; // high byte
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeBUS::setDatastreamIncrement(uInt8 index, uInt32 value) void CartridgeBUS::setDatastreamIncrement(uInt8 index, uInt32 value)
{ {
// index &= 0x0f; // index &= 0x0f;
@ -666,7 +656,8 @@ void CartridgeBUS::setDatastreamIncrement(uInt8 index, uInt32 value)
myBUSRAM[DSxINC + index*4 + 3] = (value >> 24) & 0xff; // high byte myBUSRAM[DSxINC + index*4 + 3] = (value >> 24) & 0xff; // high byte
} }
uInt32 CartridgeBUS::getAddressMap(uInt8 index) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeBUS::getAddressMap(uInt8 index) const
{ {
// index &= 0x0f; // index &= 0x0f;
return myBUSRAM[DSMAPS + index*4 + 0] + // low byte return myBUSRAM[DSMAPS + index*4 + 0] + // low byte
@ -675,7 +666,8 @@ uInt32 CartridgeBUS::getAddressMap(uInt8 index)
(myBUSRAM[DSMAPS + index*4 + 3] << 24) ; // high byte (myBUSRAM[DSMAPS + index*4 + 3] << 24) ; // high byte
} }
uInt32 CartridgeBUS::getWaveform(uInt8 index) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeBUS::getWaveform(uInt8 index) const
{ {
// instead of 0, 1, 2, etc. this returned // instead of 0, 1, 2, etc. this returned
// 0x40000800 for 0 // 0x40000800 for 0
@ -704,11 +696,13 @@ uInt32 CartridgeBUS::getWaveform(uInt8 index)
return result; return result;
} }
uInt32 CartridgeBUS::getWaveformSize(uInt8 index) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeBUS::getWaveformSize(uInt8 index) const
{ {
return myMusicWaveformSize[index]; return myMusicWaveformSize[index];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeBUS::setAddressMap(uInt8 index, uInt32 value) void CartridgeBUS::setAddressMap(uInt8 index, uInt32 value)
{ {
// index &= 0x0f; // index &= 0x0f;
@ -718,16 +712,19 @@ void CartridgeBUS::setAddressMap(uInt8 index, uInt32 value)
myBUSRAM[DSMAPS + index*4 + 3] = (value >> 24) & 0xff; // high byte myBUSRAM[DSMAPS + index*4 + 3] = (value >> 24) & 0xff; // high byte
} }
bool CartridgeBUS::getBusStuffFlag(void) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeBUS::getBusStuffFlag(void) const
{ {
return myBusStuff; return myBusStuff;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeBUS::setBusStuffFlag(bool value) void CartridgeBUS::setBusStuffFlag(bool value)
{ {
myBusStuff = value; myBusStuff = value;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgeBUS::readFromDatastream(uInt8 index) uInt8 CartridgeBUS::readFromDatastream(uInt8 index)
{ {
// Pointers are stored as: // Pointers are stored as:
@ -747,4 +744,3 @@ uInt8 CartridgeBUS::readFromDatastream(uInt8 index)
setDatastreamPointer(index, pointer); setDatastreamPointer(index, pointer);
return value; return value;
} }

View File

@ -8,13 +8,11 @@
// SS SS tt ee ll ll aa aa // SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa // SSSS ttt eeeee llll llll aaaaa
// //
// Copyright (c) 1995-2015 by Bradford W. Mott, Stephen Anthony // Copyright (c) 1995-2017 by Bradford W. Mott, Stephen Anthony
// and the Stella Team // and the Stella Team
// //
// See the file "License.txt" for information on usage and redistribution of // See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartBUS.hxx 3131 2015-01-01 03:49:32Z stephena $
//============================================================================ //============================================================================
#ifndef CARTRIDGE_BUS_HXX #ifndef CARTRIDGE_BUS_HXX
@ -22,7 +20,7 @@
class System; class System;
#ifdef THUMB_SUPPORT #ifdef THUMB_SUPPORT
class Thumbulator; class Thumbulator;
#endif #endif
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
#include "CartBUSWidget.hxx" #include "CartBUSWidget.hxx"
@ -41,13 +39,13 @@ class Thumbulator;
1K C Varaible and Stack, and the BUS chip. 1K C Varaible and Stack, and the BUS chip.
BUS chip access is mapped to $1000 - $103F. BUS chip access is mapped to $1000 - $103F.
@author Darrell Spice Jr, Chris Walton, Fred Quimby, Stephen Anthony, Bradford W. Mott Authors: Darrell Spice Jr, Chris Walton, Fred Quimby,
@version $Id: CartBUS.hxx 3131 2015-01-01 03:49:32Z stephena $ Stephen Anthony, Bradford W. Mott
*/ */
class CartridgeBUS : public Cartridge class CartridgeBUS : public Cartridge
{ {
friend class CartridgeBUSWidget; friend class CartridgeBUSWidget;
friend class CartridgeRamBUSWidget; friend class CartridgeRamBUSWidget;
public: public:
/** /**
@ -58,11 +56,7 @@ class CartridgeBUS : public Cartridge
@param settings A reference to the various settings (read-only) @param settings A reference to the various settings (read-only)
*/ */
CartridgeBUS(const uInt8* image, uInt32 size, const Settings& settings); CartridgeBUS(const uInt8* image, uInt32 size, const Settings& settings);
virtual ~CartridgeBUS() = default;
/**
Destructor
*/
virtual ~CartridgeBUS();
public: public:
/** /**
@ -205,22 +199,22 @@ class CartridgeBUS : public Cartridge
*/ */
void callFunction(uInt8 value); void callFunction(uInt8 value);
uInt32 getDatastreamPointer(uInt8 index); uInt32 getDatastreamPointer(uInt8 index) const;
void setDatastreamPointer(uInt8 index, uInt32 value); void setDatastreamPointer(uInt8 index, uInt32 value);
uInt32 getDatastreamIncrement(uInt8 index); uInt32 getDatastreamIncrement(uInt8 index) const;
void setDatastreamIncrement(uInt8 index, uInt32 value); void setDatastreamIncrement(uInt8 index, uInt32 value);
uInt32 getAddressMap(uInt8 index); uInt32 getAddressMap(uInt8 index) const;
void setAddressMap(uInt8 index, uInt32 value); void setAddressMap(uInt8 index, uInt32 value);
bool getBusStuffFlag(void); bool getBusStuffFlag(void) const;
void setBusStuffFlag(bool value); void setBusStuffFlag(bool value);
uInt8 readFromDatastream(uInt8 index); uInt8 readFromDatastream(uInt8 index);
uInt32 getWaveform(uInt8 index); uInt32 getWaveform(uInt8 index) const;
uInt32 getWaveformSize(uInt8 index); uInt32 getWaveformSize(uInt8 index) const;
private: private:
// The 32K ROM image of the cartridge // The 32K ROM image of the cartridge
@ -275,7 +269,7 @@ class CartridgeBUS : public Cartridge
// Flags that Bus Stuffing is active // Flags that Bus Stuffing is active
bool myBusStuff; bool myBusStuff;
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported
CartridgeBUS() = delete; CartridgeBUS() = delete;
CartridgeBUS(const CartridgeBUS&) = delete; CartridgeBUS(const CartridgeBUS&) = delete;

70
src/emucore/CartCDF.cxx Executable file → Normal file
View File

@ -8,20 +8,19 @@
// SS SS tt ee ll ll aa aa // SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa // SSSS ttt eeeee llll llll aaaaa
// //
// Copyright (c) 1995-2015 by Bradford W. Mott, Stephen Anthony // Copyright (c) 1995-2017 by Bradford W. Mott, Stephen Anthony
// and the Stella Team // and the Stella Team
// //
// See the file "License.txt" for information on usage and redistribution of // See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartCDF.cxx 3131 2015-01-01 03:49:32Z stephena $
//============================================================================ //============================================================================
#include <cstring> #include <cstring>
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
#include "Debugger.hxx" #include "Debugger.hxx"
#endif #endif
#include "System.hxx" #include "System.hxx"
#include "Thumbulator.hxx" #include "Thumbulator.hxx"
#include "CartCDF.hxx" #include "CartCDF.hxx"
@ -35,14 +34,13 @@
#define FAST_FETCH_ON ((myMode & 0x0F) == 0) #define FAST_FETCH_ON ((myMode & 0x0F) == 0)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeCDF::CartridgeCDF(const uInt8* image, uInt32 size, CartridgeCDF::CartridgeCDF(const uInt8* image, uInt32 size,
const Settings& settings) const Settings& settings)
: Cartridge(settings), : Cartridge(settings),
mySystemCycles(0), mySystemCycles(0),
myARMCycles(0), myARMCycles(0),
myFractionalClocks(0.0) myFractionalClocks(0.0)
{ {
// Copy the ROM image into my buffer // Copy the ROM image into my buffer
memcpy(myImage, image, std::min(32768u, size)); memcpy(myImage, image, std::min(32768u, size));
@ -61,11 +59,8 @@ myFractionalClocks(0.0)
myDisplayImage = myCDFRAM + DSRAM; myDisplayImage = myCDFRAM + DSRAM;
#ifdef THUMB_SUPPORT #ifdef THUMB_SUPPORT
// Create Thumbulator ARM emulator // Create Thumbulator ARM emulator
myThumbEmulator = make_ptr<Thumbulator> myThumbEmulator = make_ptr<Thumbulator>((uInt16*)myImage, (uInt16*)myCDFRAM,
((uInt16*)myImage, (uInt16*)myCDFRAM, settings.getBool("thumb.trapfatal"), Thumbulator::ConfigureFor::CDF, this);
settings.getBool("thumb.trapfatal"),
Thumbulator::ConfigureFor::CDF,
this);
#endif #endif
setInitialState(); setInitialState();
@ -77,18 +72,12 @@ myFractionalClocks(0.0)
myMode = 0xFF; myMode = 0xFF;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeCDF::~CartridgeCDF()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCDF::reset() void CartridgeCDF::reset()
{ {
// Initialize RAM // Initialize RAM
if(mySettings.getBool("ramrandom")) if(mySettings.getBool("ramrandom"))
for(uInt32 t = 2048; t < 8192; ++t) initializeRAM(myCDFRAM+2048, 8192-2048);
myCDFRAM[t] = mySystem->randGenerator().next();
else else
memset(myCDFRAM+2048, 0, 8192-2048); memset(myCDFRAM+2048, 0, 8192-2048);
@ -219,7 +208,6 @@ uInt8 CartridgeCDF::peek(uInt16 address)
} }
myLDAimmediateOperandAddress = 0; myLDAimmediateOperandAddress = 0;
if(address <= 0x20) if(address <= 0x20)
{ {
uInt8 result = 0; uInt8 result = 0;
@ -299,7 +287,7 @@ uInt8 CartridgeCDF::peek(uInt16 address)
} }
if(FAST_FETCH_ON && peekvalue == 0xA9) if(FAST_FETCH_ON && peekvalue == 0xA9)
myLDAimmediateOperandAddress = address + 1; myLDAimmediateOperandAddress = address + 1;
return peekvalue; return peekvalue;
} }
@ -478,7 +466,6 @@ const uInt8* CartridgeCDF::getImage(int& size) const
uInt32 CartridgeCDF::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2) uInt32 CartridgeCDF::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2)
{ {
switch (function) switch (function)
{ {
case 0: case 0:
@ -565,16 +552,18 @@ bool CartridgeCDF::load(Serializer& in)
return true; return true;
} }
uInt32 CartridgeCDF::getDatastreamPointer(uInt8 index) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeCDF::getDatastreamPointer(uInt8 index) const
{ {
// index &= 0x0f; // index &= 0x0f;
return myCDFRAM[DSxPTR + index*4 + 0] + // low byte return myCDFRAM[DSxPTR + index*4 + 0] + // low byte
(myCDFRAM[DSxPTR + index*4 + 1] << 8) + (myCDFRAM[DSxPTR + index*4 + 1] << 8) +
(myCDFRAM[DSxPTR + index*4 + 2] << 16) + (myCDFRAM[DSxPTR + index*4 + 2] << 16) +
(myCDFRAM[DSxPTR + index*4 + 3] << 24) ; // high byte (myCDFRAM[DSxPTR + index*4 + 3] << 24) ; // high byte
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCDF::setDatastreamPointer(uInt8 index, uInt32 value) void CartridgeCDF::setDatastreamPointer(uInt8 index, uInt32 value)
{ {
// index &= 0x1f; // index &= 0x1f;
@ -584,15 +573,17 @@ void CartridgeCDF::setDatastreamPointer(uInt8 index, uInt32 value)
myCDFRAM[DSxPTR + index*4 + 3] = (value >> 24) & 0xff; // high byte myCDFRAM[DSxPTR + index*4 + 3] = (value >> 24) & 0xff; // high byte
} }
uInt32 CartridgeCDF::getDatastreamIncrement(uInt8 index) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeCDF::getDatastreamIncrement(uInt8 index) const
{ {
// index &= 0x1f; // index &= 0x1f;
return myCDFRAM[DSxINC + index*4 + 0] + // low byte return myCDFRAM[DSxINC + index*4 + 0] + // low byte
(myCDFRAM[DSxINC + index*4 + 1] << 8) + (myCDFRAM[DSxINC + index*4 + 1] << 8) +
(myCDFRAM[DSxINC + index*4 + 2] << 16) + (myCDFRAM[DSxINC + index*4 + 2] << 16) +
(myCDFRAM[DSxINC + index*4 + 3] << 24) ; // high byte (myCDFRAM[DSxINC + index*4 + 3] << 24) ; // high byte
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCDF::setDatastreamIncrement(uInt8 index, uInt32 value) void CartridgeCDF::setDatastreamIncrement(uInt8 index, uInt32 value)
{ {
// index &= 0x1f; // index &= 0x1f;
@ -602,8 +593,8 @@ void CartridgeCDF::setDatastreamIncrement(uInt8 index, uInt32 value)
myCDFRAM[DSxINC + index*4 + 3] = (value >> 24) & 0xff; // high byte myCDFRAM[DSxINC + index*4 + 3] = (value >> 24) & 0xff; // high byte
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeCDF::getWaveform(uInt8 index) uInt32 CartridgeCDF::getWaveform(uInt8 index) const
{ {
// instead of 0, 1, 2, etc. this returned // instead of 0, 1, 2, etc. this returned
// 0x40000800 for 0 // 0x40000800 for 0
@ -620,9 +611,9 @@ uInt32 CartridgeCDF::getWaveform(uInt8 index)
uInt32 result; uInt32 result;
result = myCDFRAM[WAVEFORM + index*4 + 0] + // low byte result = myCDFRAM[WAVEFORM + index*4 + 0] + // low byte
(myCDFRAM[WAVEFORM + index*4 + 1] << 8) + (myCDFRAM[WAVEFORM + index*4 + 1] << 8) +
(myCDFRAM[WAVEFORM + index*4 + 2] << 16) + (myCDFRAM[WAVEFORM + index*4 + 2] << 16) +
(myCDFRAM[WAVEFORM + index*4 + 3] << 24); (myCDFRAM[WAVEFORM + index*4 + 3] << 24);
result -= 0x40000800; result -= 0x40000800;
@ -632,11 +623,13 @@ uInt32 CartridgeCDF::getWaveform(uInt8 index)
return result; return result;
} }
uInt32 CartridgeCDF::getWaveformSize(uInt8 index) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeCDF::getWaveformSize(uInt8 index) const
{ {
return myMusicWaveformSize[index]; return myMusicWaveformSize[index];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgeCDF::readFromDatastream(uInt8 index) uInt8 CartridgeCDF::readFromDatastream(uInt8 index)
{ {
// Pointers are stored as: // Pointers are stored as:
@ -656,4 +649,3 @@ uInt8 CartridgeCDF::readFromDatastream(uInt8 index)
setDatastreamPointer(index, pointer); setDatastreamPointer(index, pointer);
return value; return value;
} }

374
src/emucore/CartCDF.hxx Executable file → Normal file
View File

@ -8,13 +8,11 @@
// SS SS tt ee ll ll aa aa // SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa // SSSS ttt eeeee llll llll aaaaa
// //
// Copyright (c) 1995-2015 by Bradford W. Mott, Stephen Anthony // Copyright (c) 1995-2017 by Bradford W. Mott, Stephen Anthony
// and the Stella Team // and the Stella Team
// //
// See the file "License.txt" for information on usage and redistribution of // See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CartCDF.hxx 3131 2015-01-01 03:49:32Z stephena $
//============================================================================ //============================================================================
#ifndef CARTRIDGE_CDF_HXX #ifndef CARTRIDGE_CDF_HXX
@ -22,264 +20,260 @@
class System; class System;
#ifdef THUMB_SUPPORT #ifdef THUMB_SUPPORT
class Thumbulator; class Thumbulator;
#endif #endif
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
#include "CartCDFWidget.hxx" #include "CartCDFWidget.hxx"
#endif #endif
#include "bspf.hxx" #include "bspf.hxx"
#include "Cart.hxx" #include "Cart.hxx"
/** /**
Cartridge class used for CDF. Cartridge class used for CDF.
THIS NEEDS TO BE UPDATED THIS NEEDS TO BE UPDATED
There are seven 4K program banks, a 4K Display Data RAM, There are seven 4K program banks, a 4K Display Data RAM,
1K C Varaible and Stack, and the CDF chip. 1K C Varaible and Stack, and the CDF chip.
CDF chip access is mapped to $1000 - $103F. CDF chip access is mapped to $1000 - $103F.
@author Darrell Spice Jr, Chris Walton, Fred Quimby, Stephen Anthony, Bradford W. Mott Authors: Darrell Spice Jr, Chris Walton, Fred Quimby,
@version $Id: CartCDF.hxx 3131 2015-01-01 03:49:32Z stephena $ Stephen Anthony, Bradford W. Mott
*/ */
class CartridgeCDF : public Cartridge class CartridgeCDF : public Cartridge
{ {
friend class CartridgeCDFWidget; friend class CartridgeCDFWidget;
friend class CartridgeRamCDFWidget; friend class CartridgeRamCDFWidget;
public: public:
/** /**
Create a new cartridge using the specified image Create a new cartridge using the specified image
@param image Pointer to the ROM image @param image Pointer to the ROM image
@param size The size of the ROM image @param size The size of the ROM image
@param settings A reference to the various settings (read-only) @param settings A reference to the various settings (read-only)
*/ */
CartridgeCDF(const uInt8* image, uInt32 size, const Settings& settings); CartridgeCDF(const uInt8* image, uInt32 size, const Settings& settings);
virtual ~CartridgeCDF() = default;
/** public:
Destructor /**
*/ Reset device to its power-on state
virtual ~CartridgeCDF(); */
void reset() override;
public: /**
/** Notification method invoked by the system when the console type
Reset device to its power-on state has changed. We need this to inform the Thumbulator that the
*/ timing has changed.
void reset() override;
/** @param timing Enum representing the new console type
Notification method invoked by the system when the console type */
has changed. We need this to inform the Thumbulator that the void consoleChanged(ConsoleTiming timing) override;
timing has changed.
@param timing Enum representing the new console type /**
*/ Notification method invoked by the system right before the
void consoleChanged(ConsoleTiming timing) override; system resets its cycle counter to zero. It may be necessary
to override this method for devices that remember cycle counts.
*/
void systemCyclesReset() override;
/** /**
Notification method invoked by the system right before the Install cartridge in the specified system. Invoked by the system
system resets its cycle counter to zero. It may be necessary when the cartridge is attached to it.
to override this method for devices that remember cycle counts.
*/
void systemCyclesReset() override;
/** @param system The system the device should install itself in
Install cartridge in the specified system. Invoked by the system */
when the cartridge is attached to it. void install(System& system) override;
@param system The system the device should install itself in /**
*/ Install pages for the specified bank in the system.
void install(System& system) override;
/** @param bank The bank that should be installed in the system
Install pages for the specified bank in the system. */
bool bank(uInt16 bank) override;
@param bank The bank that should be installed in the system /**
*/ Get the current bank.
bool bank(uInt16 bank) override; */
uInt16 getBank() const override;
/** /**
Get the current bank. Query the number of banks supported by the cartridge.
*/ */
uInt16 getBank() const override; uInt16 bankCount() const override;
/** /**
Query the number of banks supported by the cartridge. Patch the cartridge ROM.
*/
uInt16 bankCount() const override;
/** @param address The ROM address to patch
Patch the cartridge ROM. @param value The value to place into the address
@return Success or failure of the patch operation
*/
bool patch(uInt16 address, uInt8 value) override;
@param address The ROM address to patch /**
@param value The value to place into the address Access the internal ROM image for this cartridge.
@return Success or failure of the patch operation
*/
bool patch(uInt16 address, uInt8 value) override;
/** @param size Set to the size of the internal ROM image data
Access the internal ROM image for this cartridge. @return A pointer to the internal ROM image data
*/
const uInt8* getImage(int& size) const override;
@param size Set to the size of the internal ROM image data /**
@return A pointer to the internal ROM image data Save the current state of this cart to the given Serializer.
*/
const uInt8* getImage(int& size) const override;
/** @param out The Serializer object to use
Save the current state of this cart to the given Serializer. @return False on any errors, else true
*/
bool save(Serializer& out) const override;
@param out The Serializer object to use /**
@return False on any errors, else true Load the current state of this cart from the given Serializer.
*/
bool save(Serializer& out) const override;
/** @param in The Serializer object to use
Load the current state of this cart from the given Serializer. @return False on any errors, else true
*/
bool load(Serializer& in) override;
@param in The Serializer object to use /**
@return False on any errors, else true Get a descriptor for the device name (used in error checking).
*/
bool load(Serializer& in) override;
/** @return The name of the object
Get a descriptor for the device name (used in error checking). */
string name() const override { return "CartridgeCDF"; }
@return The name of the object // uInt8 busOverdrive(uInt16 address) override;
*/
string name() const override { return "CartridgeCDF"; }
// uInt8 busOverdrive(uInt16 address) override;
/**
Used for Thumbulator to pass values back to the cartridge
*/
uInt32 thumbCallback(uInt8 function, uInt32 value1, uInt32 value2) override;
/**
Used for Thumbulator to pass values back to the cartridge
*/
uInt32 thumbCallback(uInt8 function, uInt32 value1, uInt32 value2) override;
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
/** /**
Get debugger widget responsible for accessing the inner workings Get debugger widget responsible for accessing the inner workings
of the cart. of the cart.
*/ */
CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont, CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont,
const GUI::Font& nfont, int x, int y, int w, int h) override const GUI::Font& nfont, int x, int y, int w, int h) override
{ {
return new CartridgeCDFWidget(boss, lfont, nfont, x, y, w, h, *this); return new CartridgeCDFWidget(boss, lfont, nfont, x, y, w, h, *this);
} }
#endif #endif
public: public:
/** /**
Get the byte at the specified address. Get the byte at the specified address.
@return The byte at the specified address @return The byte at the specified address
*/ */
uInt8 peek(uInt16 address) override; uInt8 peek(uInt16 address) override;
/** /**
Change the byte at the specified address to the given value Change the byte at the specified address to the given value
@param address The address where the value should be stored @param address The address where the value should be stored
@param value The value to be stored at the address @param value The value to be stored at the address
@return True if the poke changed the device address space, else false @return True if the poke changed the device address space, else false
*/ */
bool poke(uInt16 address, uInt8 value) override; bool poke(uInt16 address, uInt8 value) override;
private: private:
/** /**
Sets the initial state of the DPC pointers and RAM Sets the initial state of the DPC pointers and RAM
*/ */
void setInitialState(); void setInitialState();
/** /**
Updates any data fetchers in music mode based on the number of Updates any data fetchers in music mode based on the number of
CPU cycles which have passed since the last update. CPU cycles which have passed since the last update.
*/ */
void updateMusicModeDataFetchers(); void updateMusicModeDataFetchers();
/** /**
Call Special Functions Call Special Functions
*/ */
void callFunction(uInt8 value); void callFunction(uInt8 value);
uInt32 getDatastreamPointer(uInt8 index); uInt32 getDatastreamPointer(uInt8 index) const;
void setDatastreamPointer(uInt8 index, uInt32 value); void setDatastreamPointer(uInt8 index, uInt32 value);
uInt32 getDatastreamIncrement(uInt8 index); uInt32 getDatastreamIncrement(uInt8 index) const;
void setDatastreamIncrement(uInt8 index, uInt32 value); void setDatastreamIncrement(uInt8 index, uInt32 value);
uInt8 readFromDatastream(uInt8 index); uInt8 readFromDatastream(uInt8 index);
uInt32 getWaveform(uInt8 index); uInt32 getWaveform(uInt8 index) const;
uInt32 getWaveformSize(uInt8 index); uInt32 getWaveformSize(uInt8 index) const;
private: private:
// The 32K ROM image of the cartridge // The 32K ROM image of the cartridge
uInt8 myImage[32768]; uInt8 myImage[32768];
// Pointer to the 28K program ROM image of the cartridge // Pointer to the 28K program ROM image of the cartridge
uInt8* myProgramImage; uInt8* myProgramImage;
// Pointer to the 4K display ROM image of the cartridge // Pointer to the 4K display ROM image of the cartridge
uInt8* myDisplayImage; uInt8* myDisplayImage;
// Pointer to the 2K CDF driver image in RAM // Pointer to the 2K CDF driver image in RAM
uInt8* myBusDriverImage; uInt8* myBusDriverImage;
// The CDF 8k RAM image, used as: // The CDF 8k RAM image, used as:
// $0000 - 2K CDF driver // $0000 - 2K CDF driver
// $0800 - 4K Display Data // $0800 - 4K Display Data
// $1800 - 2K C Variable & Stack // $1800 - 2K C Variable & Stack
uInt8 myCDFRAM[8192]; uInt8 myCDFRAM[8192];
#ifdef THUMB_SUPPORT #ifdef THUMB_SUPPORT
// Pointer to the Thumb ARM emulator object // Pointer to the Thumb ARM emulator object
unique_ptr<Thumbulator> myThumbEmulator; unique_ptr<Thumbulator> myThumbEmulator;
#endif #endif
// Indicates which bank is currently active // Indicates which bank is currently active
uInt16 myCurrentBank; uInt16 myCurrentBank;
// System cycle count when the last update to music data fetchers occurred // System cycle count when the last update to music data fetchers occurred
Int32 mySystemCycles; Int32 mySystemCycles;
Int32 myARMCycles; Int32 myARMCycles;
uInt8 mySetAddress; uInt8 mySetAddress;
// The music mode counters // The music mode counters
uInt32 myMusicCounters[3]; uInt32 myMusicCounters[3];
// The music frequency // The music frequency
uInt32 myMusicFrequencies[3]; uInt32 myMusicFrequencies[3];
// The music waveform sizes // The music waveform sizes
uInt8 myMusicWaveformSize[3]; uInt8 myMusicWaveformSize[3];
// Fractional DPC music OSC clocks unused during the last update // Fractional DPC music OSC clocks unused during the last update
double myFractionalClocks; double myFractionalClocks;
// Controls mode, lower nybble sets Fast Fetch, upper nybble sets audio // Controls mode, lower nybble sets Fast Fetch, upper nybble sets audio
// -0 = Fast Fetch ON // -0 = Fast Fetch ON
// -F = Fast Fetch OFF // -F = Fast Fetch OFF
// 0- = Packed Digital Sample // 0- = Packed Digital Sample
// F- = 3 Voice Music // F- = 3 Voice Music
uInt8 myMode; uInt8 myMode;
// set to address of #value if last byte peeked was A9 (LDA #) // set to address of #value if last byte peeked was A9 (LDA #)
uInt16 myLDAimmediateOperandAddress; uInt16 myLDAimmediateOperandAddress;
TIA* myTIA; TIA* myTIA;
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported
CartridgeCDF() = delete; CartridgeCDF() = delete;
CartridgeCDF(const CartridgeCDF&) = delete; CartridgeCDF(const CartridgeCDF&) = delete;
CartridgeCDF(CartridgeCDF&&) = delete; CartridgeCDF(CartridgeCDF&&) = delete;
CartridgeCDF& operator=(const CartridgeCDF&) = delete; CartridgeCDF& operator=(const CartridgeCDF&) = delete;
CartridgeCDF& operator=(CartridgeCDF&&) = delete; CartridgeCDF& operator=(CartridgeCDF&&) = delete;
}; };
#endif #endif

View File

@ -85,6 +85,7 @@ string Thumbulator::run()
return statusMsg.str(); return statusMsg.str();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Thumbulator::setConsoleTiming(ConsoleTiming timing) void Thumbulator::setConsoleTiming(ConsoleTiming timing)
{ {
// this sets how many ticks of the Harmony/Melody clock // this sets how many ticks of the Harmony/Melody clock
@ -104,22 +105,15 @@ void Thumbulator::setConsoleTiming(ConsoleTiming timing)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Thumbulator::updateTimer(uInt32 cycles) void Thumbulator::updateTimer(uInt32 cycles)
{ {
double increment;
increment = cycles * timing_factor;
if (T1TCR & 1) // bit 0 controls timer on/off if (T1TCR & 1) // bit 0 controls timer on/off
{ T1TC += uInt32(cycles * timing_factor);
T1TC += uInt32(increment);
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Thumbulator::run(uInt32 cycles) string Thumbulator::run(uInt32 cycles)
{ {
updateTimer(cycles); updateTimer(cycles);
return this->run(); return run();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -233,20 +227,20 @@ void Thumbulator::write16(uInt32 addr, uInt32 data)
switch(configuration) switch(configuration)
{ {
// this protects 2K Harmony/Melody Drivers // this protects 2K Harmony/Melody Drivers
// Initial section of driver is the bootstrap which copies the driver // Initial section of driver is the bootstrap which copies the driver
// from ROM to RAM, so it can safely be used by the custom ARM code // from ROM to RAM, so it can safely be used by the custom ARM code
// as additional RAM // as additional RAM
case ConfigureFor::BUS: case ConfigureFor::BUS:
case ConfigureFor::CDF: case ConfigureFor::CDF:
if((addr > 0x40000028) && (addr < 0x40000800)) if((addr > 0x40000028) && (addr < 0x40000800))
fatalError("write16", addr, "to bankswitch code area"); fatalError("write16", addr, "to bankswitch code area");
break; break;
// this protects 3K Harmony/Melody Drivers // this protects 3K Harmony/Melody Drivers
// Initial section of driver is the bootstrap which copies the driver // Initial section of driver is the bootstrap which copies the driver
// from ROM to RAM, so it can safely be used by the custom ARM code // from ROM to RAM, so it can safely be used by the custom ARM code
// as additional RAM // as additional RAM
case ConfigureFor::DPCplus: case ConfigureFor::DPCplus:
if((addr > 0x40000028) && (addr < 0x40000c00)) if((addr > 0x40000028) && (addr < 0x40000c00))
fatalError("write16", addr, "to bankswitch code area"); fatalError("write16", addr, "to bankswitch code area");
@ -1099,10 +1093,11 @@ int Thumbulator::execute()
// bx r4 // bx instruction at 0x000006ee // bx r4 // bx instruction at 0x000006ee
// address to test for is + 4 due to pipelining // address to test for is + 4 due to pipelining
#define BUS_SetNote (0x000006e2 + 4)
#define BUS_ResetWave (0x000006e6 + 4) #define BUS_SetNote (0x000006e2 + 4)
#define BUS_GetWavePtr (0x000006ea + 4) #define BUS_ResetWave (0x000006e6 + 4)
#define BUS_SetWaveSize (0x000006ee + 4) #define BUS_GetWavePtr (0x000006ea + 4)
#define BUS_SetWaveSize (0x000006ee + 4)
if (pc == BUS_SetNote) if (pc == BUS_SetNote)
{ {
@ -1130,13 +1125,14 @@ int Thumbulator::execute()
} }
else else
{ {
// just for testing #if 0 // uncomment this for testing
uInt32 r0 = read_register(0); uInt32 r0 = read_register(0);
uInt32 r1 = read_register(1); uInt32 r1 = read_register(1);
uInt32 r2 = read_register(2); uInt32 r2 = read_register(2);
uInt32 r3 = read_register(3); uInt32 r3 = read_register(3);
uInt32 r4 = read_register(4); uInt32 r4 = read_register(4);
myCartridge->thumbCallback(255,0,0); #endif
myCartridge->thumbCallback(255, 0, 0);
} }
break; break;
@ -2206,14 +2202,14 @@ int Thumbulator::reset()
switch(configuration) switch(configuration)
{ {
// future 2K Harmony/Melody drivers will most likely use these settings // future 2K Harmony/Melody drivers will most likely use these settings
case ConfigureFor::BUS: case ConfigureFor::BUS:
case ConfigureFor::CDF: case ConfigureFor::CDF:
reg_norm[14] = 0x00000800; // Link Register reg_norm[14] = 0x00000800; // Link Register
reg_norm[15] = 0x0000080B; // Program Counter reg_norm[15] = 0x0000080B; // Program Counter
break; break;
// future 3K Harmony/Melody drivers will most likely use these settings // future 3K Harmony/Melody drivers will most likely use these settings
case ConfigureFor::DPCplus: case ConfigureFor::DPCplus:
reg_norm[14] = 0x00000C00; // Link Register reg_norm[14] = 0x00000C00; // Link Register
reg_norm[15] = 0x00000C0B; // Program Counter reg_norm[15] = 0x00000C0B; // Program Counter

View File

@ -81,7 +81,12 @@ class Thumbulator
*/ */
static void trapFatalErrors(bool enable) { trapOnFatal = enable; } static void trapFatalErrors(bool enable) { trapOnFatal = enable; }
void setConsoleTiming(ConsoleTiming timing); /**
Inform the Thumbulator class about the console currently in use,
which is used to accurately determine how many 6507 cycles have
passed while ARM code is being executed.
*/
void setConsoleTiming(ConsoleTiming timing);
private: private:
uInt32 read_register(uInt32 reg); uInt32 read_register(uInt32 reg);

View File

@ -13,6 +13,8 @@ MODULE_OBJS := \
src/emucore/Cart4K.o \ src/emucore/Cart4K.o \
src/emucore/Cart4KSC.o \ src/emucore/Cart4KSC.o \
src/emucore/CartAR.o \ src/emucore/CartAR.o \
src/emucore/CartBUS.o \
src/emucore/CartCDF.o \
src/emucore/CartCM.o \ src/emucore/CartCM.o \
src/emucore/CartCTY.o \ src/emucore/CartCTY.o \
src/emucore/CartCV.o \ src/emucore/CartCV.o \