added PlusROM info to debugger (resolves #844)

added PlusROM user info to System log
This commit is contained in:
Thomas Jentzsch 2022-02-04 20:12:59 +01:00
parent 2ff5fffe37
commit 645c2fc5bb
9 changed files with 159 additions and 24 deletions

View File

@ -31,6 +31,8 @@
* Added another oddball TIA glitch option for score mode color.
* Debugger: added PlusROM information.
-Have fun!

View File

@ -2856,7 +2856,7 @@
</tr>
<tr>
<td><pre>-autopause &lt;1|0&gt;</pre></td>
<td>Enable or disable automatic pause/continue of emulation, when
<td>Enable or disable automatic pause/continue of emulation when
Stella loses/gains focus.</td>
</tr>
<tr>
@ -3972,7 +3972,7 @@
<tr><td>Fast SuperCharger load</td><td>Skip progress loading bars for SuperCharger ROMs</td><td>-fastscbios</td></tr>
<tr><td>Show UI messages</td><td>Overlay UI messages onscreen</td><td>-uimessages</td></tr>
<tr><td>
Automatic pause</td><td>Enable or disable automatic pause/continue of emulation,
Automatic pause</td><td>Enable or disable automatic pause/continue of emulation
when Stella loses/gains focus.</td><td>-autopause
</td></tr>
<tr><td>Confirm exiting...</td><td>Display a popup when emulation is exited</td><td>-confirmexit</td></tr>

View File

@ -1315,7 +1315,7 @@ string TIADebug::toString()
<< "AUDF0: "
<< hexWithLabel("", int(audF0()),
state.aud[0] != oldState.aud[0]) << "/"
<< std::setw(11) << std::right << stringOnly(audFreq0(),
<< std::setw(9) << std::right << stringOnly(audFreq0(),
state.aud[0] != oldState.aud[0]) << " "
<< "AUDC0: "
<< hexWithLabel("", int(audC0()),
@ -1327,7 +1327,7 @@ string TIADebug::toString()
<< "AUDF1: "
<< hexWithLabel("", int(audF1()),
state.aud[1] != oldState.aud[1]) << "/"
<< std::setw(11) << std::right << stringOnly(audFreq1(),
<< std::setw(9) << std::right << stringOnly(audFreq1(),
state.aud[1] != oldState.aud[1]) << " "
<< "AUDC1: "
<< hexWithLabel("", int(audC1()),

View File

@ -15,6 +15,7 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "EditTextWidget.hxx"
#include "PopUpWidget.hxx"
#include "OSystem.hxx"
#include "Debugger.hxx"
@ -35,8 +36,10 @@ CartridgeEnhancedWidget::CartridgeEnhancedWidget(GuiObject* boss, const GUI::Fon
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartridgeEnhancedWidget::initialize()
{
int ypos = addBaseInformation(size(), manufacturer(), description(), descriptionLines())
+ myLineHeight;
int ypos = addBaseInformation(size(), manufacturer(), description(), descriptionLines());
plusROMInfo(ypos);
ypos += myLineHeight;
bankSelect(ypos);
@ -137,6 +140,41 @@ string CartridgeEnhancedWidget::romDescription()
return info.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeEnhancedWidget::plusROMInfo(int& ypos)
{
if(myCart.isPlusROM())
{
const int xpos = 2,
lwidth = _font.getStringWidth("Manufacturer "),
fwidth = _w - lwidth - 12;
new StaticTextWidget(_boss, _font, xpos, ypos + 1, "PlusROM:");
ypos += myLineHeight + 4;
new StaticTextWidget(_boss, _font, xpos + _fontWidth * 2, ypos + 1, "Host");
myPlusROMHostWidget = new EditTextWidget(_boss, _font, xpos + lwidth, ypos - 1, fwidth, myLineHeight);
myPlusROMHostWidget->setEditable(false);
ypos += myLineHeight + 4;
new StaticTextWidget(_boss, _font, xpos + _fontWidth * 2, ypos + 1, "Path");
myPlusROMPathWidget = new EditTextWidget(_boss, _font, xpos + lwidth, ypos - 1, fwidth, myLineHeight);
myPlusROMPathWidget->setEditable(false);
ypos += myLineHeight + 4;
new StaticTextWidget(_boss, _font, xpos + _fontWidth * 2, ypos + 1, "Send");
myPlusROMSendWidget = new EditTextWidget(_boss, _nfont, xpos + lwidth, ypos - 1, fwidth, myLineHeight);
myPlusROMSendWidget->setEditable(false);
ypos += myLineHeight + 4;
new StaticTextWidget(_boss, _font, xpos + _fontWidth * 2, ypos + 1, "Receive");
myPlusROMReceiveWidget = new EditTextWidget(_boss, _nfont, xpos + lwidth, ypos - 1, fwidth, myLineHeight);
myPlusROMReceiveWidget->setEditable(false);
ypos += myLineHeight + 4;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeEnhancedWidget::bankList(uInt16 bankCount, int seg, VariantList& items, int& width)
{
@ -278,9 +316,28 @@ void CartridgeEnhancedWidget::saveOldState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeEnhancedWidget::loadConfig()
{
if(myCart.isPlusROM())
{
myPlusROMHostWidget->setText(myCart.myPlusROM->getHost());
myPlusROMPathWidget->setText(myCart.myPlusROM->getPath());
ostringstream buf;
ByteArray arr = myCart.myPlusROM->getSend();
for(int i = 0; i < arr.size(); ++i)
buf << Common::Base::HEX2 << int(arr[i]) << " ";
myPlusROMSendWidget->setText(buf.str());
buf.str("");
arr = myCart.myPlusROM->getReceive();
for(int i = 0; i < arr.size(); ++i)
buf << Common::Base::HEX2 << int(arr[i]) << " ";
myPlusROMReceiveWidget->setText(buf.str());
}
if(myBankWidgets != nullptr)
{
if (bankSegs() > 1)
if(bankSegs() > 1)
for(int seg = 0; seg < bankSegs(); ++seg)
myBankWidgets[seg]->setSelectedIndex(myCart.getSegmentBank(seg),
myCart.getSegmentBank(seg) != myOldState.banks[seg]);

View File

@ -19,6 +19,8 @@
#define CART_ENHANCED_WIDGET_HXX
class CartridgeEnhanced;
class EditTextWidget;
class StringListWidget;
class PopUpWidget;
namespace GUI {
@ -52,6 +54,8 @@ class CartridgeEnhancedWidget : public CartDebugWidget
virtual string romDescription();
virtual void plusROMInfo(int& ypos);
virtual void bankList(uInt16 bankCount, int seg, VariantList& items, int& width);
virtual void bankSelect(int& ypos);
@ -92,6 +96,11 @@ class CartridgeEnhancedWidget : public CartDebugWidget
// Distance between two hotspots
int myHotspotDelta{1};
EditTextWidget* myPlusROMHostWidget{nullptr};
EditTextWidget* myPlusROMPathWidget{nullptr};
EditTextWidget* myPlusROMSendWidget{nullptr};
EditTextWidget* myPlusROMReceiveWidget{nullptr};
std::unique_ptr<PopUpWidget* []> myBankWidgets{nullptr};

View File

@ -18,7 +18,6 @@
#ifndef CARTRIDGE_HXX
#define CARTRIDGE_HXX
class Cartridge;
class Properties;
class FilesystemNode;
class CartDebugWidget;

View File

@ -517,21 +517,30 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum,
myFrameBuffer->showTextMessage(msg.str());
}
// Check for first PlusROM start
if(myConsole->cartridge().isPlusROM() &&
settings().getString("plusroms.fixedid") == EmptyString)
if(myConsole->cartridge().isPlusROM())
{
// Make sure there always is an id
constexpr int ID_LEN = 32;
const char* HEX_DIGITS = "0123456789ABCDEF";
char id_chr[ID_LEN] = {0};
Random rnd;
if(settings().getString("plusroms.fixedid") == EmptyString)
{
// Make sure there always is an id
constexpr int ID_LEN = 32;
const char* HEX_DIGITS = "0123456789ABCDEF";
char id_chr[ID_LEN] = { 0 };
Random rnd;
for(char& c: id_chr)
c = HEX_DIGITS[rnd.next() % 16];
for(char& c : id_chr)
c = HEX_DIGITS[rnd.next() % 16];
settings().setValue("plusroms.fixedid", string(id_chr, ID_LEN));
settings().setValue("plusroms.fixedid", string(id_chr, ID_LEN));
myEventHandler->changeStateByEvent(Event::PlusRomsSetupMode);
myEventHandler->changeStateByEvent(Event::PlusRomsSetupMode);
}
string id = settings().getString("plusroms.id");
if(id == EmptyString)
id = settings().getString("plusroms.fixedid");
Logger::info("PlusROM Nick: " + settings().getString("plusroms.nick") + ", ID: " + id);
}
}

View File

@ -156,6 +156,16 @@ class PlusROMRequest {
return myState;
}
const Destination& getDestination() const
{
return myDestination;
}
const PlusStoreId& getPlusStoreId() const
{
return myId;
}
std::pair<size_t, const uInt8*> getResponse() {
if (myState != State::done) throw runtime_error("invalid access to response");
@ -221,7 +231,7 @@ bool PlusROM::initialize(const ByteBuffer& image, size_t size)
return myIsPlusROM = false; // Invalid host
myHost = host;
myPath = "/" + path;
myPath = path;
reset();
@ -398,7 +408,7 @@ void PlusROM::send()
{
const string nick = mySettings.getString("plusroms.nick");
auto request = make_shared<PlusROMRequest>(
PlusROMRequest::Destination(myHost, myPath),
PlusROMRequest::Destination(myHost, "/" + myPath),
PlusROMRequest::PlusStoreId(nick, id),
myTxBuffer.data(),
myTxPos
@ -440,8 +450,8 @@ void PlusROM::receive()
#if defined(HTTP_LIB_SUPPORT)
auto iter = myPendingRequests.begin();
while (iter != myPendingRequests.end()) {
switch ((*iter)->getState()) {
while(iter != myPendingRequests.end()) {
switch((*iter)->getState()) {
case PlusROMRequest::State::failed:
myMsgCallback("PlusROM data receiving failed!");
// Request has failed? -> remove it and start over
@ -456,7 +466,7 @@ void PlusROM::receive()
// and start over
auto [responseSize, response] = (*iter)->getResponse();
for (uInt8 i = 0; i < responseSize; i++)
for(uInt8 i = 0; i < responseSize; i++)
myRxBuffer[myRxWritePos++] = response[i];
myPendingRequests.erase(iter);
@ -470,3 +480,25 @@ void PlusROM::receive()
}
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ByteArray PlusROM::getSend() const
{
ByteArray arr;
for(int i = 0; i < myTxPos; ++i)
arr.push_back(myTxBuffer[i]);
return arr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ByteArray PlusROM::getReceive() const
{
ByteArray arr;
for(uInt8 i = myRxReadPos; i != myRxWritePos; ++i)
arr.push_back(myRxBuffer[i]);
return arr;
}

View File

@ -121,6 +121,33 @@ class PlusROM : public Serializable
*/
void reset();
/**
Retrieve host.
@return The host string
*/
const string& getHost() const { return myHost; }
/**
Retrieve path.
@return The path string
*/
const string& getPath() const { return myPath; }
/**
Retrieve send data.
@return The send data
*/
ByteArray getSend() const;
/**
Retrieve receive data.
@return The receive data
*/
ByteArray getReceive() const;
/**
Set the callback for displaying messages
*/