mirror of https://github.com/stella-emu/stella.git
Added autodetection of NTSC or PAL display format, based on the number
of scanlines in a 20-frame run of the Console. This should finally quiet those idiots that say 'Stella sucks' because it's too slow (when in fact it just didn't know a ROM was PAL). This will only detect NTSC and PAL; PAL60 will be autodetected as NTSC. AFAIK, there's no way to detect this, so it will still need to be defined in the properties. Added autodetection logic for E0 and E7 bankswitching types. Added '-rominfo' commandline argument, which gives a semi-detailed description of the given ROM, including cart type and display format. Yes, I'm a geek; this is what I spend Christmas day doing :) git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1238 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
deacea8437
commit
5593970b56
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: mainSDL.cxx,v 1.70 2006-12-15 16:42:53 stephena Exp $
|
||||
// $Id: mainSDL.cxx,v 1.71 2006-12-26 00:39:43 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -131,14 +131,26 @@ int main(int argc, char* argv[])
|
|||
// probably needed for defaults
|
||||
theOSystem->create();
|
||||
|
||||
// Check to see if the 'listroms' argument was given
|
||||
// If so, list the roms and immediately exit
|
||||
// Check to see if the user requested info about a specific ROM,
|
||||
// or the list of internal ROMs
|
||||
// If so, show the information and immediately exit
|
||||
if(theOSystem->settings().getBool("listrominfo"))
|
||||
{
|
||||
theOSystem->propSet().print();
|
||||
Cleanup();
|
||||
return 0;
|
||||
}
|
||||
else if(theOSystem->settings().getBool("rominfo"))
|
||||
{
|
||||
string romfile = argv[argc - 1];
|
||||
if(argc > 1 && FilesystemNode::fileExists(romfile))
|
||||
cout << theOSystem->getROMInfo(romfile);
|
||||
else
|
||||
cout << "Error: Can't find " << romfile << endl;
|
||||
|
||||
Cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Request that the SDL window be centered, if possible
|
||||
// At some point, this should be properly integrated into the UI
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Cart.cxx,v 1.23 2006-12-24 17:13:10 stephena Exp $
|
||||
// $Id: Cart.cxx,v 1.24 2006-12-26 00:39:43 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -48,7 +48,7 @@
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Cartridge* Cartridge::create(const uInt8* image, uInt32 size,
|
||||
const Properties& properties, const Settings& settings)
|
||||
const Properties& properties, const Settings& settings, string& about)
|
||||
{
|
||||
Cartridge* cartridge = 0;
|
||||
|
||||
|
@ -57,17 +57,21 @@ Cartridge* Cartridge::create(const uInt8* image, uInt32 size,
|
|||
|
||||
// Collect some info about the ROM
|
||||
ostringstream buf;
|
||||
buf << "Size of ROM: " << size << endl
|
||||
<< "Specified type: " << type << endl;
|
||||
buf << " Size of ROM: " << size << endl
|
||||
<< " Specified bankswitch type: " << type << endl;
|
||||
|
||||
// See if we should try to auto-detect the cartridge type
|
||||
if(type == "AUTO-DETECT")
|
||||
// If we ask for extended info, always do an autodetect
|
||||
if(type == "AUTO-DETECT" || settings.getBool("rominfo"))
|
||||
{
|
||||
type = autodetectType(image, size);
|
||||
buf << "Auto-detected type: " << type << endl;
|
||||
}
|
||||
string detected = autodetectType(image, size);
|
||||
buf << " Auto-detected bankswitch type: " << detected << endl;
|
||||
if(type != "AUTO-DETECT" && type != detected)
|
||||
buf << " ==> Bankswitch auto-detection not consistent" << endl;
|
||||
|
||||
// cerr << buf.str() << endl;
|
||||
type = detected;
|
||||
}
|
||||
about = buf.str();
|
||||
|
||||
// We should know the cart's type by now so let's create it
|
||||
if(type == "2K")
|
||||
|
@ -139,26 +143,25 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size)
|
|||
{
|
||||
type = "AR";
|
||||
}
|
||||
else if(size == 2048)
|
||||
else if((size == 2048) ||
|
||||
(size == 4096 && memcmp(image, image + 2048, 2048) == 0))
|
||||
{
|
||||
// TODO - autodetect CV
|
||||
type = "2K";
|
||||
}
|
||||
else if(size == 4096)
|
||||
{
|
||||
// 2K image in consecutive banks
|
||||
if(memcmp(image, image + 2048, 2048) == 0)
|
||||
type = "2K";
|
||||
else
|
||||
type = "4K";
|
||||
type = "4K";
|
||||
}
|
||||
else if(size == 8192) // 8K
|
||||
{
|
||||
// TODO - autodetect E0, FE, UA
|
||||
// TODO - autodetect FE and UA, probably not possible
|
||||
if(isProbablySC(image, size))
|
||||
type = "F8SC";
|
||||
else if(memcmp(image, image + 4096, 4096) == 0)
|
||||
type = "4K";
|
||||
else if(isProbablyE0(image, size))
|
||||
type = "E0";
|
||||
else if(isProbably3E(image, size))
|
||||
type = "3E";
|
||||
else if(isProbably3F(image, size))
|
||||
|
@ -180,9 +183,10 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size)
|
|||
}
|
||||
else if(size == 16384) // 16K
|
||||
{
|
||||
// TODO - autodetect E7
|
||||
if(isProbablySC(image, size))
|
||||
type = "F6SC";
|
||||
else if(isProbablyE7(image, size))
|
||||
type = "E7";
|
||||
else if(isProbably3E(image, size))
|
||||
type = "3E";
|
||||
else if(isProbably3F(image, size))
|
||||
|
@ -280,6 +284,66 @@ bool Cartridge::isProbably3E(const uInt8* image, uInt32 size)
|
|||
return (searchForBytes(image, size, 0x85, 0x3E) > 2);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Cartridge::isProbablyE0(const uInt8* image, uInt32 size)
|
||||
{
|
||||
// E0 cart bankswitching is triggered by accessing addresses
|
||||
// $FE0 to $FF7 using absolute non-indexed addressing
|
||||
// So we search for the pattern 'LDA Fxxx' or 'STA Fxxx' in hex
|
||||
// using the regex (AD|8D, E0-F7, xF)
|
||||
// This must be present at least three times, since there are
|
||||
// three segments to be initialized (and a few more so that more
|
||||
// of the ROM is used)
|
||||
// Thanks to "stella@casperkitty.com" for this advice
|
||||
uInt32 count = 0;
|
||||
for(uInt32 i = 0; i < size - 2; ++i)
|
||||
{
|
||||
uInt8 b1 = image[i], b2 = image[i+1], b3 = image[i+2];
|
||||
if((b1 == 0xAD || b1 == 0x8D) &&
|
||||
(b2 >= 0xE0 && b2 <= 0xF7) &&
|
||||
(b3 & 0xF == 0xF))
|
||||
{
|
||||
if(++count > 4) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Cartridge::isProbablyE7(const uInt8* image, uInt32 size)
|
||||
{
|
||||
// E7 carts map their second 1K block of RAM at addresses
|
||||
// $800 to $8FF. However, since this occurs in the upper 2K address
|
||||
// space, and the last 2K in the cart always points to the last 2K of the
|
||||
// ROM image, the RAM area should fall in addresses $3800 to $38FF
|
||||
// Similar to the Superchip cart, we assume this RAM block contains
|
||||
// the same bytes for its entire area
|
||||
// Also, we want to distinguish between ROMs that have large blocks
|
||||
// of the same amount of (probably unused) data by making sure that
|
||||
// something differs in the previous 32 or next 32 bytes
|
||||
uInt8 first = image[0x3800];
|
||||
for(uInt32 i = 0x3800; i < 0x3A00; ++i)
|
||||
{
|
||||
if(first != image[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
// OK, now scan the surrounding 32 byte blocks
|
||||
uInt32 count1 = 0, count2 = 0;
|
||||
for(uInt32 i = 0x3800 - 32; i < 0x3800; ++i)
|
||||
{
|
||||
if(first != image[i])
|
||||
++count1;
|
||||
}
|
||||
for(uInt32 i = 0x3A00; i < 0x3A00 + 32; ++i)
|
||||
{
|
||||
if(first != image[i])
|
||||
++count2;
|
||||
}
|
||||
|
||||
return (count1 > 0 || count2 > 0);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// default implementations of bankswitching-related methods.
|
||||
// These are suitable to be inherited by a cart type that
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Cart.hxx,v 1.12 2006-12-24 17:13:10 stephena Exp $
|
||||
// $Id: Cart.hxx,v 1.13 2006-12-26 00:39:43 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef CARTRIDGE_HXX
|
||||
|
@ -33,7 +33,7 @@ class Settings;
|
|||
game and handles any bankswitching performed by the cartridge.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: Cart.hxx,v 1.12 2006-12-24 17:13:10 stephena Exp $
|
||||
@version $Id: Cart.hxx,v 1.13 2006-12-26 00:39:43 stephena Exp $
|
||||
*/
|
||||
class Cartridge : public Device
|
||||
{
|
||||
|
@ -46,10 +46,11 @@ class Cartridge : public Device
|
|||
@param size The size of the ROM image
|
||||
@param props The properties associated with the game
|
||||
@param settings The settings associated with the system
|
||||
@param about Some info about this Cartridge
|
||||
@return Pointer to the new cartridge object allocated on the heap
|
||||
*/
|
||||
static Cartridge* create(const uInt8* image, uInt32 size,
|
||||
const Properties& props, const Settings& settings);
|
||||
const Properties& props, const Settings& settings, string& about);
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -93,7 +94,7 @@ class Cartridge : public Device
|
|||
static int searchForBytes(const uInt8* image, uInt32 size, uInt8 byte1, uInt8 byte2);
|
||||
|
||||
/**
|
||||
Returns true if the image contains a extra RAM (aka SuperChip)
|
||||
Returns true if the image is probably a SuperChip (256 bytes RAM)
|
||||
*/
|
||||
static bool isProbablySC(const uInt8* image, uInt32 size);
|
||||
|
||||
|
@ -107,6 +108,16 @@ class Cartridge : public Device
|
|||
*/
|
||||
static bool isProbably3E(const uInt8* image, uInt32 size);
|
||||
|
||||
/**
|
||||
Returns true if the image is probably a E0 bankswitching cartridge
|
||||
*/
|
||||
static bool isProbablyE0(const uInt8* image, uInt32 size);
|
||||
|
||||
/**
|
||||
Returns true if the image is probably a E7 bankswitching cartridge
|
||||
*/
|
||||
static bool isProbablyE7(const uInt8* image, uInt32 size);
|
||||
|
||||
private:
|
||||
// Copy constructor isn't supported by cartridges so make it private
|
||||
Cartridge(const Cartridge&);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: CartCV.cxx,v 1.11 2006-12-08 16:49:21 stephena Exp $
|
||||
// $Id: CartCV.cxx,v 1.12 2006-12-26 00:39:43 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -196,7 +196,8 @@ bool CartridgeCV::load(Deserializer& in)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt8* CartridgeCV::getImage(int& size) {
|
||||
uInt8* CartridgeCV::getImage(int& size)
|
||||
{
|
||||
size = 2048;
|
||||
return &myImage[0];
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Console.cxx,v 1.110 2006-12-22 23:14:39 stephena Exp $
|
||||
// $Id: Console.cxx,v 1.111 2006-12-26 00:39:43 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -66,6 +66,8 @@ Console::Console(const uInt8* image, uInt32 size, const string& md5,
|
|||
ourUserNTSCPalette(NULL),
|
||||
ourUserPALPalette(NULL)
|
||||
{
|
||||
Cartridge* cartridge = (Cartridge*) NULL;
|
||||
ostringstream buf;
|
||||
myControllers[0] = 0;
|
||||
myControllers[1] = 0;
|
||||
myMediaSource = 0;
|
||||
|
@ -85,22 +87,9 @@ Console::Console(const uInt8* image, uInt32 size, const string& md5,
|
|||
// Load user-defined palette for this ROM
|
||||
loadUserPalette();
|
||||
|
||||
// Make sure height is set properly for PAL ROM
|
||||
if(myProperties.get(Display_Format).compare(0, 3, "PAL") == 0)
|
||||
if(myProperties.get(Display_Height) == "210")
|
||||
myProperties.set(Display_Height, "250");
|
||||
|
||||
// Make sure this ROM can fit in the screen dimensions
|
||||
int sWidth, sHeight, iWidth, iHeight;
|
||||
myOSystem->getScreenDimensions(sWidth, sHeight);
|
||||
iWidth = atoi(myProperties.get(Display_Width).c_str()) << 1;
|
||||
iHeight = atoi(myProperties.get(Display_Height).c_str());
|
||||
if(iWidth > sWidth || iHeight > sHeight)
|
||||
{
|
||||
myOSystem->frameBuffer().showMessage("PAL ROMS not supported, screen too small",
|
||||
kMiddleCenter, kTextColorEm);
|
||||
return;
|
||||
}
|
||||
// Query some info about this console
|
||||
buf << " Cart Name: " << myProperties.get(Cartridge_Name) << endl
|
||||
<< " Cart MD5: " << md5 << endl;
|
||||
|
||||
// Setup the controllers based on properties
|
||||
string left = myProperties.get(Controller_Left);
|
||||
|
@ -199,8 +188,10 @@ Console::Console(const uInt8* image, uInt32 size, const string& md5,
|
|||
M6532* m6532 = new M6532(*this);
|
||||
TIA *tia = new TIA(*this, myOSystem->settings());
|
||||
tia->setSound(myOSystem->sound());
|
||||
Cartridge* cartridge = Cartridge::create(image, size, myProperties,
|
||||
myOSystem->settings());
|
||||
cartridge = Cartridge::create(image, size, myProperties,
|
||||
myOSystem->settings(), myAboutString);
|
||||
buf << myAboutString;
|
||||
|
||||
if(!cartridge)
|
||||
return;
|
||||
|
||||
|
@ -217,6 +208,46 @@ Console::Console(const uInt8* image, uInt32 size, const string& md5,
|
|||
// Reset, the system to its power-on state
|
||||
mySystem->reset();
|
||||
|
||||
// Auto-detect NTSC/PAL mode if it's requested
|
||||
myDisplayFormat = myProperties.get(Display_Format);
|
||||
buf << " Specified display format: " << myDisplayFormat << endl;
|
||||
if(myDisplayFormat == "AUTO-DETECT" ||
|
||||
myOSystem->settings().getBool("rominfo"))
|
||||
{
|
||||
// Run the system for 20 frames, looking for PAL frames
|
||||
int palCount = 0;
|
||||
for(int i = 0; i < 20; ++i)
|
||||
{
|
||||
myMediaSource->update();
|
||||
if(myMediaSource->scanlines() > 290)
|
||||
++palCount;
|
||||
}
|
||||
|
||||
myDisplayFormat = (palCount >= 10) ? "PAL" : "NTSC";
|
||||
if(myProperties.get(Display_Format) == "AUTO-DETECT")
|
||||
buf << " Auto-detected display format: " << myDisplayFormat << endl;
|
||||
}
|
||||
|
||||
// Make sure height is set properly for PAL ROM
|
||||
if(myDisplayFormat.compare(0, 3, "PAL") == 0)
|
||||
if(myProperties.get(Display_Height) == "210")
|
||||
myProperties.set(Display_Height, "250");
|
||||
|
||||
// Make sure this ROM can fit in the screen dimensions
|
||||
int sWidth, sHeight, iWidth, iHeight;
|
||||
myOSystem->getScreenDimensions(sWidth, sHeight);
|
||||
iWidth = atoi(myProperties.get(Display_Width).c_str()) << 1;
|
||||
iHeight = atoi(myProperties.get(Display_Height).c_str());
|
||||
if(iWidth > sWidth || iHeight > sHeight)
|
||||
{
|
||||
myOSystem->frameBuffer().showMessage("PAL ROMS not supported, screen too small",
|
||||
kMiddleCenter, kTextColorEm);
|
||||
return;
|
||||
}
|
||||
|
||||
mySystem->reset(); // Restart ROM again
|
||||
|
||||
myAboutString = buf.str();
|
||||
myIsValidFlag = true;
|
||||
}
|
||||
|
||||
|
@ -245,31 +276,30 @@ const Properties& Console::properties() const
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::toggleFormat()
|
||||
{
|
||||
const string& format = myProperties.get(Display_Format);
|
||||
uInt32 framerate = 60;
|
||||
|
||||
if(format == "NTSC")
|
||||
if(myDisplayFormat == "NTSC")
|
||||
{
|
||||
myProperties.set(Display_Format, "PAL");
|
||||
mySystem->reset();
|
||||
myOSystem->frameBuffer().showMessage("PAL Mode");
|
||||
framerate = 50;
|
||||
}
|
||||
else if(format == "PAL")
|
||||
else if(myDisplayFormat == "PAL")
|
||||
{
|
||||
myProperties.set(Display_Format, "PAL60");
|
||||
mySystem->reset();
|
||||
myOSystem->frameBuffer().showMessage("PAL60 Mode");
|
||||
framerate = 60;
|
||||
}
|
||||
else if(format == "PAL60")
|
||||
else if(myDisplayFormat == "PAL60")
|
||||
{
|
||||
myProperties.set(Display_Format, "NTSC");
|
||||
mySystem->reset();
|
||||
myOSystem->frameBuffer().showMessage("NTSC Mode");
|
||||
framerate = 60;
|
||||
}
|
||||
|
||||
myDisplayFormat = myProperties.get(Display_Format);
|
||||
setPalette(myOSystem->settings().getString("palette"));
|
||||
myOSystem->setFramerate(framerate);
|
||||
myOSystem->sound().setFrameRate(framerate);
|
||||
|
@ -327,19 +357,17 @@ void Console::togglePalette()
|
|||
void Console::setPalette(const string& type)
|
||||
{
|
||||
// See which format we should be using
|
||||
const string& format = myProperties.get(Display_Format);
|
||||
|
||||
const uInt32* palette = NULL;
|
||||
if(type == "standard")
|
||||
palette = (format.compare(0, 3, "PAL") == 0) ? ourPALPalette : ourNTSCPalette;
|
||||
palette = (myDisplayFormat.compare(0, 3, "PAL") == 0) ? ourPALPalette : ourNTSCPalette;
|
||||
else if(type == "original")
|
||||
palette = (format.compare(0, 3, "PAL") == 0) ? ourPALPalette11 : ourNTSCPalette11;
|
||||
palette = (myDisplayFormat.compare(0, 3, "PAL") == 0) ? ourPALPalette11 : ourNTSCPalette11;
|
||||
else if(type == "z26")
|
||||
palette = (format.compare(0, 3, "PAL") == 0) ? ourPALPaletteZ26 : ourNTSCPaletteZ26;
|
||||
palette = (myDisplayFormat.compare(0, 3, "PAL") == 0) ? ourPALPaletteZ26 : ourNTSCPaletteZ26;
|
||||
else if(type == "user" && myUserPaletteDefined)
|
||||
palette = (format.compare(0, 3, "PAL") == 0) ? ourUserPALPalette : ourUserNTSCPalette;
|
||||
palette = (myDisplayFormat.compare(0, 3, "PAL") == 0) ? ourUserPALPalette : ourUserNTSCPalette;
|
||||
else // return normal palette by default
|
||||
palette = (format.compare(0, 3, "PAL") == 0) ? ourPALPalette : ourNTSCPalette;
|
||||
palette = (myDisplayFormat.compare(0, 3, "PAL") == 0) ? ourPALPalette : ourNTSCPalette;
|
||||
|
||||
myOSystem->frameBuffer().setPalette(palette);
|
||||
|
||||
|
@ -381,13 +409,12 @@ void Console::initialize()
|
|||
// This can be overridden by changing the framerate in the
|
||||
// VideoDialog box or on the commandline, but it can't be saved
|
||||
// (ie, framerate is now solely determined based on ROM format).
|
||||
const string& format = myProperties.get(Display_Format);
|
||||
int framerate = myOSystem->settings().getInt("framerate");
|
||||
if(framerate == -1)
|
||||
{
|
||||
if(format == "NTSC" || format == "PAL60")
|
||||
if(myDisplayFormat == "NTSC" || myDisplayFormat == "PAL60")
|
||||
framerate = 60;
|
||||
else if(format == "PAL")
|
||||
else if(myDisplayFormat == "PAL")
|
||||
framerate = 50;
|
||||
else
|
||||
framerate = 60;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Console.hxx,v 1.52 2006-12-22 23:14:39 stephena Exp $
|
||||
// $Id: Console.hxx,v 1.53 2006-12-26 00:39:43 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef CONSOLE_HXX
|
||||
|
@ -38,7 +38,7 @@ class System;
|
|||
This class represents the entire game console.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: Console.hxx,v 1.52 2006-12-22 23:14:39 stephena Exp $
|
||||
@version $Id: Console.hxx,v 1.53 2006-12-26 00:39:43 stephena Exp $
|
||||
*/
|
||||
class Console
|
||||
{
|
||||
|
@ -127,6 +127,11 @@ class Console
|
|||
*/
|
||||
void setProperties(const Properties& props);
|
||||
|
||||
/**
|
||||
Query some information about this console.
|
||||
*/
|
||||
string about() { return myAboutString; }
|
||||
|
||||
public:
|
||||
/**
|
||||
Overloaded assignment operator
|
||||
|
@ -138,10 +143,15 @@ class Console
|
|||
|
||||
public:
|
||||
/**
|
||||
Toggle between NTSC and PAL mode.
|
||||
Toggle between NTSC/PAL/PAL60 display format.
|
||||
*/
|
||||
void toggleFormat();
|
||||
|
||||
/**
|
||||
Query the currently selected display format (NTSC/PAL/PAL60).
|
||||
*/
|
||||
string getFormat() const { return myDisplayFormat; }
|
||||
|
||||
/**
|
||||
Toggle between the available palettes.
|
||||
*/
|
||||
|
@ -171,7 +181,7 @@ class Console
|
|||
Determine whether the console object is valid (no errors occurred
|
||||
when it was created)
|
||||
*/
|
||||
bool isValid() { return myIsValidFlag; }
|
||||
bool isValid() const { return myIsValidFlag; }
|
||||
|
||||
/**
|
||||
Initialize the video subsystem wrt this class.
|
||||
|
@ -286,6 +296,12 @@ class Console
|
|||
uInt32* ourUserNTSCPalette;
|
||||
uInt32* ourUserPALPalette;
|
||||
|
||||
// Contains info about this console in string format
|
||||
string myAboutString;
|
||||
|
||||
// The currently defined display format (NTSC/PAL/PAL60)
|
||||
string myDisplayFormat;
|
||||
|
||||
// Table of RGB values for NTSC
|
||||
static const uInt32 ourNTSCPalette[256];
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: OSystem.cxx,v 1.83 2006-12-22 23:14:39 stephena Exp $
|
||||
// $Id: OSystem.cxx,v 1.84 2006-12-26 00:39:44 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -385,7 +385,9 @@ bool OSystem::createConsole(const string& romfile)
|
|||
if(showmessage)
|
||||
myFrameBuffer->showMessage("New console created");
|
||||
if(mySettings->getBool("showinfo"))
|
||||
cout << "Game console created: " << myRomFile << endl;
|
||||
cout << "Game console created:" << endl
|
||||
<< " ROM file: " << myRomFile << endl
|
||||
<< myConsole->about() << endl;
|
||||
|
||||
retval = true;
|
||||
}
|
||||
|
@ -522,6 +524,36 @@ bool OSystem::openROM(const string& rom, string& md5, uInt8** image, int* size)
|
|||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string OSystem::getROMInfo(const string& romfile)
|
||||
{
|
||||
ostringstream buf;
|
||||
Console* console = (Console*) NULL;
|
||||
|
||||
// Open the cartridge image and read it in
|
||||
uInt8* image;
|
||||
int size = -1;
|
||||
string md5;
|
||||
if(openROM(romfile, md5, &image, &size))
|
||||
{
|
||||
// Create a temporary instance of the 2600 game console
|
||||
console = new Console(image, size, md5, this);
|
||||
if(console && console->isValid())
|
||||
buf << console->about();
|
||||
else
|
||||
buf << "ERROR: Couldn't get ROM info for " << romfile << " ..." << endl;
|
||||
}
|
||||
else
|
||||
buf << "ERROR: Couldn't open " << romfile << " ..." << endl;
|
||||
|
||||
// Free the image and console since we don't need it any longer
|
||||
delete console;
|
||||
if(size != -1)
|
||||
delete[] image;
|
||||
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystem::setDefaultJoymap()
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: OSystem.hxx,v 1.47 2006-12-18 14:01:58 stephena Exp $
|
||||
// $Id: OSystem.hxx,v 1.48 2006-12-26 00:39:44 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef OSYSTEM_HXX
|
||||
|
@ -45,7 +45,7 @@ class VideoDialog;
|
|||
other objects belong.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: OSystem.hxx,v 1.47 2006-12-18 14:01:58 stephena Exp $
|
||||
@version $Id: OSystem.hxx,v 1.48 2006-12-26 00:39:44 stephena Exp $
|
||||
*/
|
||||
class OSystem
|
||||
{
|
||||
|
@ -252,6 +252,15 @@ class OSystem
|
|||
*/
|
||||
void createLauncher();
|
||||
|
||||
/**
|
||||
Gets all possible info about the ROM by creating a temporary
|
||||
Console object and querying it.
|
||||
|
||||
@param romfile The full pathname of the ROM to use
|
||||
@return Some information about this ROM
|
||||
*/
|
||||
string getROMInfo(const string& romfile);
|
||||
|
||||
/**
|
||||
The features which are conditionally compiled into Stella.
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Props.cxx,v 1.17 2006-12-09 00:25:20 stephena Exp $
|
||||
// $Id: Props.cxx,v 1.18 2006-12-26 00:39:44 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cctype>
|
||||
|
@ -294,7 +294,7 @@ const char* Properties::ourDefaultProperties[LastPropType] = {
|
|||
"JOYSTICK", // Controller.Left
|
||||
"JOYSTICK", // Controller.Right
|
||||
"NO", // Controller.SwapPaddles
|
||||
"NTSC", // Display.Format
|
||||
"AUTO-DETECT", // Display.Format
|
||||
"0", // Display.XStart
|
||||
"160", // Display.Width
|
||||
"34", // Display.YStart
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Settings.cxx,v 1.106 2006-12-22 22:32:49 stephena Exp $
|
||||
// $Id: Settings.cxx,v 1.107 2006-12-26 00:39:44 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -176,6 +176,11 @@ bool Settings::loadCommandLine(int argc, char** argv)
|
|||
setExternal(key, "true");
|
||||
return true;
|
||||
}
|
||||
else if(key == "rominfo")
|
||||
{
|
||||
setExternal(key, "true");
|
||||
return true;
|
||||
}
|
||||
else if(key == "debug") // this doesn't make Stella exit
|
||||
{
|
||||
setExternal(key, "true");
|
||||
|
@ -348,6 +353,7 @@ void Settings::usage()
|
|||
<< " -sssingle <1|0> Generate single snapshot instead of many\n"
|
||||
<< endl
|
||||
<< " -listrominfo Display contents of stella.pro, one line per ROM entry\n"
|
||||
<< " -rominfo <rom> Display detailed information for the given ROM\n"
|
||||
<< " -help Show the text you're now reading\n"
|
||||
#ifdef DEBUGGER_SUPPORT
|
||||
<< endl
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: TIA.cxx,v 1.74 2006-12-15 16:43:02 stephena Exp $
|
||||
// $Id: TIA.cxx,v 1.75 2006-12-26 00:39:44 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -237,7 +237,7 @@ void TIA::reset()
|
|||
myFrameWidth = 160;
|
||||
}
|
||||
|
||||
if(myConsole.properties().get(Display_Format).compare(0, 3, "PAL") == 0)
|
||||
if(myConsole.getFormat().compare(0, 3, "PAL") == 0)
|
||||
{
|
||||
myColorLossEnabled = true;
|
||||
myMaximumNumberOfScanlines = 342;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: GameInfoDialog.cxx,v 1.32 2006-12-09 00:25:20 stephena Exp $
|
||||
// $Id: GameInfoDialog.cxx,v 1.33 2006-12-26 00:39:44 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -214,14 +214,15 @@ GameInfoDialog::GameInfoDialog(
|
|||
|
||||
xpos = 10; ypos = vBorder;
|
||||
lwidth = font.getStringWidth("Use Phosphor: ");
|
||||
pwidth = font.getStringWidth("PAL60");
|
||||
pwidth = font.getStringWidth("Auto-detect");
|
||||
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
|
||||
"Format:", kTextAlignLeft);
|
||||
myFormat = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
|
||||
pwidth, lineHeight, "", 0, 0);
|
||||
myFormat->appendEntry("NTSC", 1);
|
||||
myFormat->appendEntry("PAL", 2);
|
||||
myFormat->appendEntry("PAL60", 3);
|
||||
myFormat->appendEntry("Auto-detect", 1);
|
||||
myFormat->appendEntry("NTSC", 2);
|
||||
myFormat->appendEntry("PAL", 3);
|
||||
myFormat->appendEntry("PAL60", 4);
|
||||
wid.push_back(myFormat);
|
||||
|
||||
ypos += lineHeight + 3;
|
||||
|
@ -439,12 +440,14 @@ void GameInfoDialog::loadView()
|
|||
|
||||
// Display properties
|
||||
s = myGameProperties.get(Display_Format);
|
||||
if(s == "NTSC")
|
||||
if(s == "AUTO-DETECT")
|
||||
myFormat->setSelectedTag(1);
|
||||
else if(s == "PAL")
|
||||
else if(s == "NTSC")
|
||||
myFormat->setSelectedTag(2);
|
||||
else if(s == "PAL60")
|
||||
else if(s == "PAL")
|
||||
myFormat->setSelectedTag(3);
|
||||
else if(s == "PAL60")
|
||||
myFormat->setSelectedTag(4);
|
||||
else
|
||||
myFormat->setSelectedTag(0);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ my @prop_defaults = (
|
|||
"JOYSTICK",
|
||||
"JOYSTICK",
|
||||
"NO",
|
||||
"NTSC",
|
||||
"AUTO-DETECT",
|
||||
"0",
|
||||
"160",
|
||||
"34",
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: OSystemUNIX.cxx,v 1.22 2006-12-08 16:49:39 stephena Exp $
|
||||
// $Id: OSystemUNIX.cxx,v 1.23 2006-12-26 00:39:44 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -142,7 +142,7 @@ void OSystemUNIX::mainLoop()
|
|||
}
|
||||
|
||||
// Only print console information if a console was actually created
|
||||
if(mySettings->getBool("showinfo") && myConsole)
|
||||
if(mySettings->getBool("showinfo"))
|
||||
{
|
||||
double executionTime = (double) frameTime / 1000000.0;
|
||||
double framesPerSecond = (double) numberOfFrames / executionTime;
|
||||
|
@ -150,11 +150,6 @@ void OSystemUNIX::mainLoop()
|
|||
cout << endl;
|
||||
cout << numberOfFrames << " total frames drawn\n";
|
||||
cout << framesPerSecond << " frames/second\n";
|
||||
cout << endl;
|
||||
cout << "Cartridge Name: " << myConsole->properties().get(Cartridge_Name);
|
||||
cout << endl;
|
||||
cout << "Cartridge MD5: " << myConsole->properties().get(Cartridge_MD5);
|
||||
cout << endl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: OSystemWin32.cxx,v 1.14 2006-12-08 16:49:41 stephena Exp $
|
||||
// $Id: OSystemWin32.cxx,v 1.15 2006-12-26 00:39:44 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <sstream>
|
||||
|
@ -99,8 +99,7 @@ void OSystemWin32::mainLoop()
|
|||
++numberOfFrames;
|
||||
}
|
||||
|
||||
// Only print console information if a console was actually created
|
||||
if(mySettings->getBool("showinfo") && myConsole)
|
||||
if(mySettings->getBool("showinfo"))
|
||||
{
|
||||
double executionTime = (double) frameTime / 1000000.0;
|
||||
double framesPerSecond = (double) numberOfFrames / executionTime;
|
||||
|
@ -108,11 +107,6 @@ void OSystemWin32::mainLoop()
|
|||
cout << endl;
|
||||
cout << numberOfFrames << " total frames drawn\n";
|
||||
cout << framesPerSecond << " frames/second\n";
|
||||
cout << endl;
|
||||
cout << "Cartridge Name: " << myConsole->properties().get(Cartridge_Name);
|
||||
cout << endl;
|
||||
cout << "Cartridge MD5: " << myConsole->properties().get(Cartridge_MD5);
|
||||
cout << endl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue