mirror of https://github.com/stella-emu/stella.git
Added ability to change XStart. YStart, Width, Height, and Format
both from the commandline (by passing in a user-defined properties object to the Console constructor) and at runtime (by calling various methods in the Console class). Methods are defined as follows: Console::changeXStart() & Console::changeYStart() - Changes the "Display.XStart" and "Display.YStart" variables. Console::changeWidth() & Console::changeHeight() - Changes the "Display.Width" and "Display.Height" variables. Console::toggleFormat() - Changes the "Display.Format" variable, switching between NTSC and PAL modes. Console::saveProperties() - Saves the current properties (including changes made in the current session) to the given filename. Some notes on the new methods: - The GUI's will need to be adapted to see the updated information and act accordingly. - This new code is only activated by '#define DEVELOPER_SUPPORT'. You are encouraged to wrap calls to these new methods (in the GUI) in an appropriate #ifdef. Publicly released binaries probably SHOULD NOT have this stuff activated. - All change methods (except for NTSC/PAL switching) currently do a full system reset after making a change, so that the whole system will see the changes. This means that if you are playing a game and call one of these methods, the game will be reset. In the future, the core may be enhanced so that changes are detected without a full reset. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@121 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
f2f97105f6
commit
c3f834561a
|
@ -13,10 +13,14 @@
|
|||
// 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.4 2002-10-09 04:38:11 bwmott Exp $
|
||||
// $Id: Console.cxx,v 1.5 2002-11-09 23:29:51 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
#include "Booster.hxx"
|
||||
#include "Cart.hxx"
|
||||
#include "Console.hxx"
|
||||
|
@ -37,11 +41,10 @@
|
|||
#include "System.hxx"
|
||||
#include "TIA.hxx"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Console::Console(const uInt8* image, uInt32 size, const char* filename,
|
||||
const Event& event, PropertiesSet& propertiesSet, uInt32 sampleRate)
|
||||
const Event& event, PropertiesSet& propertiesSet, uInt32 sampleRate,
|
||||
const Properties* userDefinedProperties)
|
||||
: myEvent(event)
|
||||
{
|
||||
myControllers[0] = 0;
|
||||
|
@ -56,9 +59,11 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename,
|
|||
// Search for the properties based on MD5
|
||||
propertiesSet.getMD5(md5, myProperties);
|
||||
|
||||
// TODO: At some point I belive we'll need to set the properties'
|
||||
// MD5 value so the user will be able to edit it.
|
||||
// myProperties.save(cout);
|
||||
// Merge any user-defined properties
|
||||
if(userDefinedProperties != 0)
|
||||
{
|
||||
myProperties.merge(*userDefinedProperties);
|
||||
}
|
||||
|
||||
// Setup the controllers based on properties
|
||||
string left = myProperties.get("Controller.Left");
|
||||
|
@ -207,3 +212,208 @@ const Properties& Console::defaultProperties()
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Properties Console::ourDefaultProperties;
|
||||
|
||||
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::toggleFormat()
|
||||
{
|
||||
string format = myProperties.get("Display.Format");
|
||||
string message;
|
||||
|
||||
if(format == "NTSC")
|
||||
{
|
||||
message = "PAL Mode";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myProperties.set("Display.Format", "PAL");
|
||||
}
|
||||
else if(format == "PAL")
|
||||
{
|
||||
message = "NTSC Mode";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myProperties.set("Display.Format", "NTSC");
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::changeXStart(const uInt32 direction)
|
||||
{
|
||||
Int32 xstart = atoi(myProperties.get("Display.XStart").c_str());
|
||||
uInt32 width = atoi(myProperties.get("Display.Width").c_str());
|
||||
ostringstream strval;
|
||||
string message;
|
||||
|
||||
if(direction == 1) // increase XStart
|
||||
{
|
||||
xstart += 4;
|
||||
if(xstart > 80)
|
||||
{
|
||||
message = "XStart at maximum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
return;
|
||||
}
|
||||
else if((width + xstart) > 160)
|
||||
{
|
||||
message = "XStart no effect";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(direction == 0) // decrease XStart
|
||||
{
|
||||
xstart -= 4;
|
||||
if(xstart < 0)
|
||||
{
|
||||
message = "XStart at minimum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
strval << xstart;
|
||||
myProperties.set("Display.XStart", strval.str());
|
||||
mySystem->reset();
|
||||
|
||||
message = "XStart ";
|
||||
message += strval.str();
|
||||
myMediaSource->showMessage(message, 120);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::changeYStart(const uInt32 direction)
|
||||
{
|
||||
Int32 ystart = atoi(myProperties.get("Display.YStart").c_str());
|
||||
ostringstream strval;
|
||||
string message;
|
||||
|
||||
if(direction == 1) // increase YStart
|
||||
{
|
||||
ystart++;
|
||||
if(ystart > 64)
|
||||
{
|
||||
message = "YStart at maximum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(direction == 0) // decrease YStart
|
||||
{
|
||||
ystart--;
|
||||
if(ystart < 0)
|
||||
{
|
||||
message = "YStart at minimum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
strval << ystart;
|
||||
myProperties.set("Display.YStart", strval.str());
|
||||
mySystem->reset();
|
||||
|
||||
message = "YStart ";
|
||||
message += strval.str();
|
||||
myMediaSource->showMessage(message, 120);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::changeWidth(const uInt32 direction)
|
||||
{
|
||||
uInt32 xstart = atoi(myProperties.get("Display.XStart").c_str());
|
||||
Int32 width = atoi(myProperties.get("Display.Width").c_str());
|
||||
ostringstream strval;
|
||||
string message;
|
||||
|
||||
if(direction == 1) // increase Width
|
||||
{
|
||||
width += 4;
|
||||
if((width > 160) || ((width % 4) != 0))
|
||||
{
|
||||
message = "Width at maximum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
return;
|
||||
}
|
||||
else if((width + xstart) > 160)
|
||||
{
|
||||
message = "Width no effect";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(direction == 0) // decrease Width
|
||||
{
|
||||
width -= 4;
|
||||
if(width < 80)
|
||||
{
|
||||
message = "Width at minimum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
strval << width;
|
||||
myProperties.set("Display.Width", strval.str());
|
||||
mySystem->reset();
|
||||
|
||||
message = "Width ";
|
||||
message += strval.str();
|
||||
myMediaSource->showMessage(message, 120);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::changeHeight(const uInt32 direction)
|
||||
{
|
||||
Int32 height = atoi(myProperties.get("Display.Height").c_str());
|
||||
ostringstream strval;
|
||||
string message;
|
||||
|
||||
if(direction == 1) // increase Height
|
||||
{
|
||||
height++;
|
||||
if(height > 256)
|
||||
{
|
||||
message = "Height at maximum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(direction == 0) // decrease Height
|
||||
{
|
||||
height--;
|
||||
if(height < 100)
|
||||
{
|
||||
message = "Height at minimum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
strval << height;
|
||||
myProperties.set("Display.Height", strval.str());
|
||||
mySystem->reset();
|
||||
|
||||
message = "Height ";
|
||||
message += strval.str();
|
||||
myMediaSource->showMessage(message, 120);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::saveProperties(const string& filename)
|
||||
{
|
||||
string message;
|
||||
ofstream out(filename.c_str(), ios::out);
|
||||
|
||||
if(out && out.is_open())
|
||||
{
|
||||
myProperties.save(out);
|
||||
out.close();
|
||||
message = "Properties saved";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "Properties not saved";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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.3 2002-10-09 04:38:11 bwmott Exp $
|
||||
// $Id: Console.hxx,v 1.4 2002-11-09 23:29:51 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef CONSOLE_HXX
|
||||
|
@ -36,7 +36,7 @@ class System;
|
|||
This class represents the entire game console.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: Console.hxx,v 1.3 2002-10-09 04:38:11 bwmott Exp $
|
||||
@version $Id: Console.hxx,v 1.4 2002-11-09 23:29:51 stephena Exp $
|
||||
*/
|
||||
class Console
|
||||
{
|
||||
|
@ -51,9 +51,11 @@ class Console
|
|||
@param event The event object to use
|
||||
@param profiles The game profiles object to use
|
||||
@param sampleRate The rate to create audio samples at
|
||||
@param userDefinedProperties User properties that should override the defaults
|
||||
*/
|
||||
Console(const uInt8* image, uInt32 size, const char* filename,
|
||||
const Event& event, PropertiesSet& propertiesSet, uInt32 sampleRate);
|
||||
const Event& event, PropertiesSet& propertiesSet, uInt32 sampleRate,
|
||||
const Properties* userDefinedProperties = 0);
|
||||
|
||||
/**
|
||||
Create a new console object by copying another one
|
||||
|
@ -132,6 +134,54 @@ class Console
|
|||
*/
|
||||
static const Properties& defaultProperties();
|
||||
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
public:
|
||||
/**
|
||||
Toggle between NTSC and PAL mode. The GUI's may need to reload their palette.
|
||||
*/
|
||||
void toggleFormat();
|
||||
|
||||
/**
|
||||
Change the "Display.XStart" variable. Currently, a system reset is issued
|
||||
after the change. GUI's may need to resize their viewports.
|
||||
|
||||
@param direction A 1 indicates increase, 0 indicates decrease.
|
||||
*/
|
||||
void changeXStart(const uInt32 direction);
|
||||
|
||||
/**
|
||||
Change the "Display.XStart" variable. Currently, a system reset is issued
|
||||
after the change. GUI's may need to resize their viewports.
|
||||
|
||||
@param direction A 1 indicates increase, 0 indicates decrease.
|
||||
*/
|
||||
void changeYStart(const uInt32 direction);
|
||||
|
||||
/**
|
||||
Change the "Display.XStart" variable. Currently, a system reset is issued
|
||||
after the change. GUI's may need to resize their viewports.
|
||||
|
||||
@param direction A 1 indicates increase, 0 indicates decrease.
|
||||
*/
|
||||
void changeWidth(const uInt32 direction);
|
||||
|
||||
/**
|
||||
Change the "Display.XStart" variable. Currently, a system reset is issued
|
||||
after the change. GUI's may need to resize their viewports.
|
||||
|
||||
@param direction A 1 indicates increase, 0 indicates decrease.
|
||||
*/
|
||||
void changeHeight(const uInt32 direction);
|
||||
|
||||
/**
|
||||
Save a copy of the current properties.
|
||||
after the change.
|
||||
|
||||
@param filename Filename to save the properties into.
|
||||
*/
|
||||
void saveProperties(const string& filename);
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Pointers to the left and right controllers
|
||||
Controller* myControllers[2];
|
||||
|
|
|
@ -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.2 2002-01-08 17:11:32 stephena Exp $
|
||||
// $Id: Props.cxx,v 1.3 2002-11-09 23:29:51 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "Props.hxx"
|
||||
|
@ -260,3 +260,20 @@ void Properties::copy(const Properties& properties)
|
|||
myProperties[i] = properties.myProperties[i];
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Properties::merge(const Properties& properties)
|
||||
{
|
||||
// Merge each property from properties if it isn't -1
|
||||
for(uInt32 i = 0; i < properties.mySize; ++i)
|
||||
{
|
||||
if(properties.myProperties[i].value != "-1")
|
||||
{
|
||||
cerr << "Properties::merge ==> changing " << properties.myProperties[i].key
|
||||
<< " from value " << get(properties.myProperties[i].key) << " to "
|
||||
<< properties.myProperties[i].value << endl;
|
||||
|
||||
set(properties.myProperties[i].key, properties.myProperties[i].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.hxx,v 1.2 2002-01-08 17:11:32 stephena Exp $
|
||||
// $Id: Props.hxx,v 1.3 2002-11-09 23:29:51 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef PROPERTIES_HXX
|
||||
|
@ -30,7 +30,7 @@
|
|||
if the property key is not found in the original property list.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: Props.hxx,v 1.2 2002-01-08 17:11:32 stephena Exp $
|
||||
@version $Id: Props.hxx,v 1.3 2002-11-09 23:29:51 stephena Exp $
|
||||
*/
|
||||
class Properties
|
||||
{
|
||||
|
@ -88,6 +88,13 @@ class Properties
|
|||
*/
|
||||
void save(ostream& out);
|
||||
|
||||
/**
|
||||
Merge the given properties into this properties object
|
||||
|
||||
@param properties The properties object to merge
|
||||
*/
|
||||
void merge(const Properties& properties);
|
||||
|
||||
public:
|
||||
/**
|
||||
Read the next quoted string from the specified input stream
|
||||
|
|
Loading…
Reference in New Issue