mirror of https://github.com/stella-emu/stella.git
Disabled PlusROM for now, until we find more time to work on it.
This commit is contained in:
parent
a891f5cb33
commit
e837e1f94c
|
@ -56,10 +56,12 @@ CartridgeEnhanced::CartridgeEnhanced(const ByteBuffer& image, size_t size,
|
|||
// space will be filled with 0's from above
|
||||
std::copy_n(image.get(), std::min(mySize, size), myImage.get());
|
||||
|
||||
#if 0
|
||||
// Determine whether we have a PlusROM cart
|
||||
// PlusROM needs to call peek() method, so disable direct peeks
|
||||
if(myPlusROM.initialize(myImage, mySize))
|
||||
myDirectPeek = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -147,6 +149,7 @@ uInt8 CartridgeEnhanced::peek(uInt16 address)
|
|||
{
|
||||
const uInt16 peekAddress = address;
|
||||
|
||||
#if 0
|
||||
// Is this a PlusROM?
|
||||
if(myPlusROM.isValid())
|
||||
{
|
||||
|
@ -154,6 +157,7 @@ uInt8 CartridgeEnhanced::peek(uInt16 address)
|
|||
if(myPlusROM.peekHotspot(address, value))
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
// hotspots in TIA range are reacting to pokes only
|
||||
if (hotspot() >= 0x80)
|
||||
|
@ -184,9 +188,11 @@ uInt8 CartridgeEnhanced::peek(uInt16 address)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool CartridgeEnhanced::poke(uInt16 address, uInt8 value)
|
||||
{
|
||||
#if 0
|
||||
// Is this a PlusROM?
|
||||
if(myPlusROM.isValid() && myPlusROM.pokeHotspot(address, value))
|
||||
return true;
|
||||
#endif
|
||||
|
||||
// Switch banks if necessary
|
||||
if (checkSwitchBank(address & ADDR_MASK, value))
|
||||
|
@ -380,8 +386,10 @@ bool CartridgeEnhanced::save(Serializer& out) const
|
|||
out.putIntArray(myCurrentSegOffset.get(), myBankSegs);
|
||||
if(myRamSize > 0)
|
||||
out.putByteArray(myRAM.get(), myRamSize);
|
||||
if(myPlusROM.isValid())
|
||||
if(!myPlusROM.save(out)) return false;
|
||||
#if 0
|
||||
if(myPlusROM.isValid() && !myPlusROM.save(out))
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
@ -400,8 +408,10 @@ bool CartridgeEnhanced::load(Serializer& in)
|
|||
in.getIntArray(myCurrentSegOffset.get(), myBankSegs);
|
||||
if(myRamSize > 0)
|
||||
in.getByteArray(myRAM.get(), myRamSize);
|
||||
if(myPlusROM.isValid())
|
||||
if(!myPlusROM.load(in)) return false;
|
||||
#if 0
|
||||
if(myPlusROM.isValid() && !myPlusROM.load(in))
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//============================================================================
|
||||
|
||||
#include <regex>
|
||||
|
||||
#include "bspf.hxx"
|
||||
#include "PlusROM.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -25,36 +28,28 @@ bool PlusROM::initialize(const ByteBuffer& image, size_t size)
|
|||
if(i >= size)
|
||||
return myIsPlusROM = false; // Invalid NMI
|
||||
|
||||
// Convenience functions to detect valid path and host characters
|
||||
auto isValidPathChar = [](uInt8 c) {
|
||||
return ((c > 44 && c < 58) || (c > 64 && c < 91) || (c > 96 && c < 122));
|
||||
};
|
||||
auto isValidHostChar = [](uInt8 c) {
|
||||
return (c == 45 || c == 46 || (c > 47 && c < 58) ||
|
||||
(c > 64 && c < 91) || (c > 96 && c < 122));
|
||||
};
|
||||
|
||||
// Path stored first, 0-terminated
|
||||
while(i < size && isValidPathChar(image[i]))
|
||||
myPath += static_cast<char>(image[i++]);
|
||||
string path;
|
||||
while(i < size && image[i] != 0)
|
||||
path += static_cast<char>(image[i++]);
|
||||
|
||||
// Did we get a 0-terminated path?
|
||||
if(i >= size || image[i] != 0)
|
||||
return myIsPlusROM = false; // Wrong delimiter
|
||||
// Did we get a valid, 0-terminated path?
|
||||
if(i >= size || image[i] != 0 || !isValidPath(path))
|
||||
return myIsPlusROM = false; // Invalid path
|
||||
|
||||
i++; // advance past 0 terminator
|
||||
|
||||
// Host stored next, 0-terminated
|
||||
while(i < size && isValidHostChar(image[i]))
|
||||
myHost += static_cast<char>(image[i++]);
|
||||
string host;
|
||||
while(i < size && image[i] != 0)
|
||||
host += static_cast<char>(image[i++]);
|
||||
|
||||
// Did we get a valid, 0-terminated host?
|
||||
if(i >= size || image[i] != 0 || myHost.size() < 3 || myHost.find(".") == string::npos)
|
||||
return myIsPlusROM = false; // Wrong delimiter or dotless IP
|
||||
|
||||
cerr << "Path: " << myPath << endl;
|
||||
cerr << "Host: " << myHost << endl;
|
||||
if(i >= size || image[i] != 0 || !isValidHost(host))
|
||||
return myIsPlusROM = false; // Invalid host
|
||||
|
||||
myURL = "http://" + host + "/" + path;
|
||||
cerr << "URL: " << myURL << endl;
|
||||
return myIsPlusROM = true;
|
||||
}
|
||||
|
||||
|
@ -120,3 +115,28 @@ bool PlusROM::load(Serializer& in)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PlusROM::isValidHost(const string& host) const
|
||||
{
|
||||
// TODO: This isn't 100% either, as we're supposed to check for the length
|
||||
// of each part between '.' in the range 1 .. 63
|
||||
// Perhaps a better function will be included with whatever network
|
||||
// library we decide to use
|
||||
static std::regex rgx(R"(^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$)", std::regex_constants::icase);
|
||||
|
||||
return std::regex_match(host, rgx);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PlusROM::isValidPath(const string& path) const
|
||||
{
|
||||
// TODO: This isn't 100%
|
||||
// Perhaps a better function will be included with whatever network
|
||||
// library we decide to use
|
||||
for(auto c: path)
|
||||
if(!((c > 44 && c < 58) || (c > 64 && c < 91) || (c > 96 && c < 122)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -108,9 +108,16 @@ class PlusROM : public Serializable
|
|||
*/
|
||||
bool load(Serializer& in) override;
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////
|
||||
// These probably belong in the networking library
|
||||
bool isValidHost(const string& host) const;
|
||||
bool isValidPath(const string& path) const;
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
private:
|
||||
bool myIsPlusROM{false};
|
||||
string myPath, myHost;
|
||||
string myURL;
|
||||
|
||||
std::array<uInt8, 256> myRxBuffer, myTxBuffer;
|
||||
|
||||
|
|
Loading…
Reference in New Issue