mirror of https://github.com/stella-emu/stella.git
Removed all responsibility of creation and deletion for the FrameBuffer
and Sound classes into OSystem. This makes the main function a lot smaller. Re-added developer keys used to change XStart, YStart, Width and Height properties of the ROM. I must have done something better this time, since these keys now work correctly in OpenGL mode as well (they didn't previous to this). Cleaned up some code wrt conditional compilation of sound code. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@402 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
b026a1e247
commit
e768e6f7dd
|
@ -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: SoundNull.cxx,v 1.1 2005-04-28 19:30:26 stephena Exp $
|
||||
// $Id: SoundNull.cxx,v 1.2 2005-05-01 18:57:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "Serializer.hxx"
|
||||
|
@ -29,12 +29,9 @@
|
|||
SoundNull::SoundNull(OSystem* osystem)
|
||||
: Sound(osystem)
|
||||
{
|
||||
// Add the sound object to the system
|
||||
myOSystem->attach(this);
|
||||
|
||||
// Show some info
|
||||
if(myOSystem->settings().getBool("showinfo"))
|
||||
cout << "Sound support not available." << endl << endl;
|
||||
cout << "Sound disabled." << 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: SoundSDL.cxx,v 1.13 2005-04-28 19:28:32 stephena Exp $
|
||||
// $Id: SoundSDL.cxx,v 1.14 2005-05-01 18:57:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <sstream>
|
||||
|
@ -38,7 +38,6 @@ SoundSDL::SoundSDL(OSystem* osystem)
|
|||
myFragmentSizeLogBase2(0),
|
||||
myIsMuted(false)
|
||||
{
|
||||
myOSystem->attach(this);
|
||||
initialize(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.32 2005-04-29 19:05:05 stephena Exp $
|
||||
// $Id: mainSDL.cxx,v 1.33 2005-05-01 18:57:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <fstream>
|
||||
|
@ -35,22 +35,11 @@
|
|||
#include "Event.hxx"
|
||||
#include "EventHandler.hxx"
|
||||
#include "FrameBuffer.hxx"
|
||||
#include "FrameBufferSoft.hxx"
|
||||
#include "PropsSet.hxx"
|
||||
#include "Sound.hxx"
|
||||
#include "Settings.hxx"
|
||||
#include "OSystem.hxx"
|
||||
|
||||
#ifdef SOUND_SUPPORT
|
||||
#include "SoundSDL.hxx"
|
||||
#else
|
||||
#include "SoundNull.hxx"
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_OPENGL
|
||||
#include "FrameBufferGL.hxx"
|
||||
#endif
|
||||
|
||||
#if defined(UNIX)
|
||||
#include "SettingsUNIX.hxx"
|
||||
#include "OSystemUNIX.hxx"
|
||||
|
@ -71,15 +60,6 @@ static void ShowInfo(const string& msg);
|
|||
// Pointer to the main parent osystem object or the null pointer
|
||||
static OSystem* theOSystem = (OSystem*) NULL;
|
||||
|
||||
// Pointer to the display object or the null pointer
|
||||
static EventHandler* theEventHandler = (EventHandler*) NULL;
|
||||
|
||||
// Pointer to the sound object or the null pointer
|
||||
static Sound* theSound = (Sound*) NULL;
|
||||
|
||||
// Pointer to the settings object or the null pointer
|
||||
static Settings* theSettings = (Settings*) NULL;
|
||||
|
||||
// Indicates whether to show information during program execution
|
||||
static bool theShowInfoFlag;
|
||||
|
||||
|
@ -120,7 +100,7 @@ inline uInt32 GetTicks()
|
|||
void SetupProperties(PropertiesSet& set)
|
||||
{
|
||||
bool useMemList = false;
|
||||
string theAltPropertiesFile = theSettings->getString("altpro");
|
||||
string theAltPropertiesFile = theOSystem->settings().getString("altpro");
|
||||
string thePropertiesFile = theOSystem->propertiesInputFilename();
|
||||
|
||||
// When 'listrominfo' or 'mergeprops' is specified, we need to have the
|
||||
|
@ -191,11 +171,11 @@ void mainGameLoop()
|
|||
// and are needed to calculate the overall frames per second.
|
||||
uInt32 frameTime = 0, numberOfFrames = 0;
|
||||
|
||||
if(theSettings->getBool("accurate")) // normal, CPU-intensive timing
|
||||
if(theOSystem->settings().getBool("accurate")) // normal, CPU-intensive timing
|
||||
{
|
||||
// Set up accurate timing stuff
|
||||
uInt32 startTime, delta;
|
||||
uInt32 timePerFrame = (uInt32)(1000000.0 / (double) theSettings->getInt("framerate"));
|
||||
uInt32 timePerFrame = (uInt32)(1000000.0 / (double) theOSystem->settings().getInt("framerate"));
|
||||
|
||||
// Set the base for the timers
|
||||
frameTime = 0;
|
||||
|
@ -229,7 +209,7 @@ void mainGameLoop()
|
|||
{
|
||||
// Set up less accurate timing stuff
|
||||
uInt32 startTime, virtualTime, currentTime;
|
||||
uInt32 timePerFrame = (uInt32)(1000000.0 / (double) theSettings->getInt("framerate"));
|
||||
uInt32 timePerFrame = (uInt32)(1000000.0 / (double) theOSystem->settings().getInt("framerate"));
|
||||
|
||||
// Set the base for the timers
|
||||
virtualTime = GetTicks();
|
||||
|
@ -294,13 +274,6 @@ void Cleanup()
|
|||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
if(theSound)
|
||||
delete theSound;
|
||||
|
||||
if(theEventHandler)
|
||||
delete theEventHandler;
|
||||
|
||||
if(theOSystem)
|
||||
delete theOSystem;
|
||||
|
||||
|
@ -315,22 +288,17 @@ int main(int argc, char* argv[])
|
|||
// Create the parent OSystem object and settings
|
||||
#if defined(UNIX)
|
||||
theOSystem = new OSystemUNIX();
|
||||
theSettings = new SettingsUNIX(theOSystem);
|
||||
SettingsUNIX settings(theOSystem);
|
||||
#elif defined(WIN32)
|
||||
theOSystem = new OSystemWin32();
|
||||
theSettings = new SettingsWin32(theOSystem);
|
||||
SettingsWin32 settings(theOSystem);
|
||||
#else
|
||||
#error Unsupported platform!
|
||||
#endif
|
||||
if(!theSettings)
|
||||
{
|
||||
Cleanup();
|
||||
return 0;
|
||||
}
|
||||
theSettings->loadConfig();
|
||||
theOSystem->settings().loadConfig();
|
||||
|
||||
// Take care of commandline arguments
|
||||
if(!theSettings->loadCommandLine(argc, argv))
|
||||
if(!theOSystem->settings().loadCommandLine(argc, argv))
|
||||
{
|
||||
Cleanup();
|
||||
return 0;
|
||||
|
@ -338,13 +306,13 @@ int main(int argc, char* argv[])
|
|||
|
||||
// Finally, make sure the settings are valid
|
||||
// We do it once here, so the rest of the program can assume valid settings
|
||||
//FIXME theSettings->validate();
|
||||
//FIXME theOSystem->settings().validate();
|
||||
|
||||
// Create the event handler for the system
|
||||
theEventHandler = new EventHandler(theOSystem);
|
||||
EventHandler handler(theOSystem);
|
||||
|
||||
// Cache some settings so they don't have to be repeatedly searched for
|
||||
theShowInfoFlag = theSettings->getBool("showinfo");
|
||||
theShowInfoFlag = theOSystem->settings().getBool("showinfo");
|
||||
bool theRomLauncherFlag = false;//true;//FIXMEtheSettings->getBool("romlauncher");
|
||||
|
||||
// Create a properties set for us to use and set it up
|
||||
|
@ -354,7 +322,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
// Check to see if the 'listroms' argument was given
|
||||
// If so, list the roms and immediately exit
|
||||
if(theSettings->getBool("listrominfo"))
|
||||
if(theOSystem->settings().getBool("listrominfo"))
|
||||
{
|
||||
propertiesSet.print();
|
||||
Cleanup();
|
||||
|
@ -364,7 +332,7 @@ int main(int argc, char* argv[])
|
|||
// Request that the SDL window be centered, if possible
|
||||
putenv("SDL_VIDEO_CENTERED=1");
|
||||
|
||||
// Create the SDL framebuffer
|
||||
// Create the framebuffer(s)
|
||||
if(!theOSystem->createFrameBuffer())
|
||||
{
|
||||
cerr << "ERROR: Couldn't set up display.\n";
|
||||
|
@ -372,12 +340,8 @@ int main(int argc, char* argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Create a sound object for playing audio, even if sound has been disabled
|
||||
#ifdef SOUND_SUPPORT
|
||||
theSound = new SoundSDL(theOSystem);
|
||||
#else
|
||||
theSound = new SoundNull(theOSystem);
|
||||
#endif
|
||||
// Create the sound object
|
||||
theOSystem->createSound();
|
||||
|
||||
// Setup the SDL joysticks (must be done after FrameBuffer is created)
|
||||
/* FIXME - don't exit if joysticks can't be initialized
|
||||
|
@ -391,7 +355,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
// Print message about the framerate
|
||||
ostringstream message;
|
||||
message << "Framerate: " << theSettings->getInt("framerate");
|
||||
message << "Framerate: " << theOSystem->settings().getInt("framerate");
|
||||
ShowInfo(message.str());
|
||||
|
||||
//// Main loop ////
|
||||
|
|
|
@ -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.47 2005-04-29 19:05:05 stephena Exp $
|
||||
// $Id: Console.cxx,v 1.48 2005-05-01 18:57:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -146,7 +146,8 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
|
|||
}
|
||||
|
||||
M6532* m6532 = new M6532(*this);
|
||||
TIA* tia = new TIA(*this, myOSystem->sound(), myOSystem->settings());
|
||||
TIA* tia = new TIA(*this, myOSystem->settings());
|
||||
tia->setSound(myOSystem->sound());
|
||||
Cartridge* cartridge = Cartridge::create(image, size, myProperties);
|
||||
|
||||
mySystem->attach(m6502);
|
||||
|
@ -330,6 +331,12 @@ void Console::initializeVideo()
|
|||
myMediaSource->height());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::initializeAudio()
|
||||
{
|
||||
myMediaSource->setSound(myOSystem->sound());
|
||||
}
|
||||
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::changeXStart(const uInt32 direction)
|
||||
|
@ -366,6 +373,7 @@ void Console::changeXStart(const uInt32 direction)
|
|||
strval << xstart;
|
||||
myProperties.set("Display.XStart", strval.str());
|
||||
mySystem->reset();
|
||||
initializeVideo();
|
||||
|
||||
message = "XStart ";
|
||||
message += strval.str();
|
||||
|
@ -401,6 +409,7 @@ void Console::changeYStart(const uInt32 direction)
|
|||
strval << ystart;
|
||||
myProperties.set("Display.YStart", strval.str());
|
||||
mySystem->reset();
|
||||
initializeVideo();
|
||||
|
||||
message = "YStart ";
|
||||
message += strval.str();
|
||||
|
@ -442,6 +451,7 @@ void Console::changeWidth(const uInt32 direction)
|
|||
strval << width;
|
||||
myProperties.set("Display.Width", strval.str());
|
||||
mySystem->reset();
|
||||
initializeVideo();
|
||||
|
||||
message = "Width ";
|
||||
message += strval.str();
|
||||
|
@ -477,6 +487,7 @@ void Console::changeHeight(const uInt32 direction)
|
|||
strval << height;
|
||||
myProperties.set("Display.Height", strval.str());
|
||||
mySystem->reset();
|
||||
initializeVideo();
|
||||
|
||||
message = "Height ";
|
||||
message += strval.str();
|
||||
|
|
|
@ -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.27 2005-04-29 19:05:05 stephena Exp $
|
||||
// $Id: Console.hxx,v 1.28 2005-05-01 18:57:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef CONSOLE_HXX
|
||||
|
@ -26,8 +26,6 @@ class MediaSource;
|
|||
class Switches;
|
||||
class System;
|
||||
|
||||
class OSystem;
|
||||
|
||||
#include "bspf.hxx"
|
||||
#include "Control.hxx"
|
||||
#include "Props.hxx"
|
||||
|
@ -37,7 +35,7 @@ class OSystem;
|
|||
This class represents the entire game console.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: Console.hxx,v 1.27 2005-04-29 19:05:05 stephena Exp $
|
||||
@version $Id: Console.hxx,v 1.28 2005-05-01 18:57:20 stephena Exp $
|
||||
*/
|
||||
class Console
|
||||
{
|
||||
|
@ -154,10 +152,15 @@ class Console
|
|||
void saveProperties(string filename, bool merge = false);
|
||||
|
||||
/**
|
||||
Initialize this video subsystem wrt this class.
|
||||
Initialize the video subsystem wrt this class.
|
||||
*/
|
||||
void initializeVideo();
|
||||
|
||||
/**
|
||||
Initialize the audio subsystem wrt this class.
|
||||
*/
|
||||
void initializeAudio();
|
||||
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -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: EventHandler.cxx,v 1.45 2005-04-29 19:05:05 stephena Exp $
|
||||
// $Id: EventHandler.cxx,v 1.46 2005-05-01 18:57:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -285,27 +285,48 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
|
|||
case SDLK_RIGHTBRACKET:
|
||||
myOSystem->sound().adjustVolume(1);
|
||||
break;
|
||||
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
case SDLK_END: // Alt-End increases XStart
|
||||
myOSystem->console().changeXStart(1);
|
||||
myOSystem->frameBuffer().resize(0);
|
||||
break;
|
||||
|
||||
case SDLK_HOME: // Alt-Home decreases XStart
|
||||
myOSystem->console().changeXStart(0);
|
||||
myOSystem->frameBuffer().resize(0);
|
||||
break;
|
||||
|
||||
case SDLK_PAGEUP: // Alt-PageUp increases YStart
|
||||
myOSystem->console().changeYStart(1);
|
||||
myOSystem->frameBuffer().resize(0);
|
||||
break;
|
||||
|
||||
case SDLK_PAGEDOWN: // Alt-PageDown decreases YStart
|
||||
myOSystem->console().changeYStart(0);
|
||||
myOSystem->frameBuffer().resize(0);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
// FIXME - alt developer stuff goes here
|
||||
}
|
||||
else if(mod & KMOD_CTRL && state)
|
||||
{
|
||||
switch(int(key))
|
||||
{
|
||||
case SDLK_0: // Ctrl-0 sets the mouse to paddle 0
|
||||
setPaddleMode(0);
|
||||
setPaddleMode(0, true);
|
||||
break;
|
||||
|
||||
case SDLK_1: // Ctrl-1 sets the mouse to paddle 1
|
||||
setPaddleMode(1);
|
||||
setPaddleMode(1, true);
|
||||
break;
|
||||
|
||||
case SDLK_2: // Ctrl-2 sets the mouse to paddle 2
|
||||
setPaddleMode(2);
|
||||
setPaddleMode(2, true);
|
||||
break;
|
||||
|
||||
case SDLK_3: // Ctrl-3 sets the mouse to paddle 3
|
||||
setPaddleMode(3);
|
||||
setPaddleMode(3, true);
|
||||
break;
|
||||
|
||||
case SDLK_f: // Ctrl-f toggles NTSC/PAL mode
|
||||
|
@ -318,8 +339,27 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
|
|||
myOSystem->frameBuffer().setupPalette();
|
||||
break;
|
||||
|
||||
// FIXME - Ctrl developer support goes here
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
case SDLK_END: // Ctrl-End increases Width
|
||||
myOSystem->console().changeWidth(1);
|
||||
myOSystem->frameBuffer().resize(0);
|
||||
break;
|
||||
|
||||
case SDLK_HOME: // Ctrl-Home decreases Width
|
||||
myOSystem->console().changeWidth(0);
|
||||
myOSystem->frameBuffer().resize(0);
|
||||
break;
|
||||
|
||||
case SDLK_PAGEUP: // Ctrl-PageUp increases Height
|
||||
myOSystem->console().changeHeight(1);
|
||||
myOSystem->frameBuffer().resize(0);
|
||||
break;
|
||||
|
||||
case SDLK_PAGEDOWN: // Ctrl-PageDown decreases Height
|
||||
myOSystem->console().changeHeight(0);
|
||||
myOSystem->frameBuffer().resize(0);
|
||||
break;
|
||||
#endif
|
||||
case SDLK_s: // Ctrl-s saves properties to a file
|
||||
// Attempt to merge with propertiesSet
|
||||
if(myOSystem->settings().getBool("mergeprops"))
|
||||
|
@ -368,7 +408,7 @@ void EventHandler::handleMouseMotionEvent(SDL_Event& event)
|
|||
uInt32 zoom = theDisplay->zoomLevel();
|
||||
Int32 width = theDisplay->width() * zoom;
|
||||
|
||||
// Grabmouse and hidecursor introduce some lag into the mouse movement,
|
||||
// Grabmouse introduces some lag into the mouse movement,
|
||||
// so we need to fudge the numbers a bit
|
||||
if(theGrabMouseIndicator && theHideCursorIndicator)
|
||||
mouseX = (int)((float)mouseX + (float)event.motion.xrel
|
||||
|
@ -958,13 +998,16 @@ void EventHandler::takeSnapshot()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::setPaddleMode(uInt32 num)
|
||||
void EventHandler::setPaddleMode(uInt32 num, bool showmessage)
|
||||
{
|
||||
myPaddleMode = num;
|
||||
|
||||
ostringstream buf;
|
||||
buf << "Mouse is paddle " << num;
|
||||
myOSystem->frameBuffer().showMessage(buf.str());
|
||||
if(showmessage)
|
||||
{
|
||||
ostringstream buf;
|
||||
buf << "Mouse is paddle " << num;
|
||||
myOSystem->frameBuffer().showMessage(buf.str());
|
||||
}
|
||||
|
||||
myOSystem->settings().setInt("paddle", myPaddleMode);
|
||||
}
|
||||
|
|
|
@ -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: EventHandler.hxx,v 1.23 2005-04-06 23:47:07 stephena Exp $
|
||||
// $Id: EventHandler.hxx,v 1.24 2005-05-01 18:57:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef EVENTHANDLER_HXX
|
||||
|
@ -57,7 +57,7 @@ struct ActionList {
|
|||
mapping can take place.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: EventHandler.hxx,v 1.23 2005-04-06 23:47:07 stephena Exp $
|
||||
@version $Id: EventHandler.hxx,v 1.24 2005-05-01 18:57:20 stephena Exp $
|
||||
*/
|
||||
class EventHandler
|
||||
{
|
||||
|
@ -186,9 +186,10 @@ class EventHandler
|
|||
/**
|
||||
Sets the mouse to act as paddle 'num'
|
||||
|
||||
@param num The paddle which the mouse should emulate
|
||||
@param num The paddle which the mouse should emulate
|
||||
@param showmessage Print a message to the framebuffer
|
||||
*/
|
||||
void setPaddleMode(uInt32 num);
|
||||
void setPaddleMode(uInt32 num, bool showmessage = false);
|
||||
|
||||
/**
|
||||
The following methods take care of assigning action mappings.
|
||||
|
|
|
@ -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: FrameBuffer.cxx,v 1.28 2005-04-29 19:05:05 stephena Exp $
|
||||
// $Id: FrameBuffer.cxx,v 1.29 2005-05-01 18:57:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <sstream>
|
||||
|
@ -370,8 +370,8 @@ void FrameBuffer::setCursorState()
|
|||
// Keep mouse in game window if grabmouse is selected
|
||||
grabMouse(myOSystem->settings().getBool("grabmouse"));
|
||||
|
||||
// Show or hide the cursor depending on the 'hidecursor' argument
|
||||
showCursor(!myOSystem->settings().getBool("hidecursor"));
|
||||
// Never show cursor in normal emulation mode
|
||||
showCursor(false);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -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: MediaSrc.hxx,v 1.8 2004-07-14 16:15:06 stephena Exp $
|
||||
// $Id: MediaSrc.hxx,v 1.9 2005-05-01 18:57:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef MEDIASOURCE_HXX
|
||||
|
@ -22,6 +22,7 @@
|
|||
#include <string>
|
||||
|
||||
class MediaSource;
|
||||
class Sound;
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
||||
|
@ -29,7 +30,7 @@ class MediaSource;
|
|||
This class provides an interface for accessing graphics and audio data.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: MediaSrc.hxx,v 1.8 2004-07-14 16:15:06 stephena Exp $
|
||||
@version $Id: MediaSrc.hxx,v 1.9 2005-05-01 18:57:20 stephena Exp $
|
||||
*/
|
||||
class MediaSource
|
||||
{
|
||||
|
@ -98,6 +99,11 @@ class MediaSource
|
|||
*/
|
||||
virtual uInt32 scanlines() const = 0;
|
||||
|
||||
/**
|
||||
Sets the sound device for the TIA.
|
||||
*/
|
||||
virtual void setSound(Sound& sound) = 0;
|
||||
|
||||
private:
|
||||
// Copy constructor isn't supported by this class so make it private
|
||||
MediaSource(const MediaSource&);
|
||||
|
|
|
@ -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.7 2005-04-29 19:05:05 stephena Exp $
|
||||
// $Id: OSystem.cxx,v 1.8 2005-05-01 18:57:20 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -27,6 +27,11 @@
|
|||
#endif
|
||||
|
||||
#include "Sound.hxx"
|
||||
#include "SoundNull.hxx"
|
||||
#ifdef SOUND_SUPPORT
|
||||
#include "SoundSDL.hxx"
|
||||
#endif
|
||||
|
||||
#include "Settings.hxx"
|
||||
#include "PropsSet.hxx"
|
||||
#include "EventHandler.hxx"
|
||||
|
@ -60,8 +65,10 @@ OSystem::~OSystem()
|
|||
// Remove any game console that is currently attached
|
||||
detachConsole();
|
||||
|
||||
// OSystem takes responsibility for the framebuffer
|
||||
// OSystem takes responsibility for framebuffer and sound,
|
||||
// since it created them
|
||||
delete myFrameBuffer;
|
||||
delete mySound;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -181,6 +188,39 @@ void OSystem::toggleFrameBuffer()
|
|||
createFrameBuffer(true); // show onscreen message
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystem::createSound()
|
||||
{
|
||||
// Delete the old sound device
|
||||
delete mySound;
|
||||
|
||||
// And recreate a new sound device
|
||||
#ifdef SOUND_SUPPORT
|
||||
mySound = new SoundSDL(this);
|
||||
#else
|
||||
mySettings->setBool("sound", false);
|
||||
mySound = new SoundNull(this);
|
||||
#endif
|
||||
|
||||
// Re-initialize the framebuffer to current settings
|
||||
switch(myEventHandler->state())
|
||||
{
|
||||
case EventHandler::S_EMULATE:
|
||||
case EventHandler::S_MENU:
|
||||
myConsole->initializeAudio();
|
||||
break; // S_EMULATE, S_MENU
|
||||
|
||||
case EventHandler::S_BROWSER:
|
||||
break; // S_BROWSER
|
||||
|
||||
case EventHandler::S_DEBUGGER:
|
||||
break;
|
||||
|
||||
case EventHandler::S_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
OSystem::OSystem(const OSystem& osystem)
|
||||
{
|
||||
|
|
|
@ -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.5 2005-04-29 19:05:05 stephena Exp $
|
||||
// $Id: OSystem.hxx,v 1.6 2005-05-01 18:57:21 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef OSYSTEM_HXX
|
||||
|
@ -37,7 +37,7 @@ class Browser;
|
|||
other objects belong.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: OSystem.hxx,v 1.5 2005-04-29 19:05:05 stephena Exp $
|
||||
@version $Id: OSystem.hxx,v 1.6 2005-05-01 18:57:21 stephena Exp $
|
||||
*/
|
||||
class OSystem
|
||||
{
|
||||
|
@ -245,6 +245,12 @@ class OSystem
|
|||
*/
|
||||
void toggleFrameBuffer();
|
||||
|
||||
/**
|
||||
Creates the various sound devices available in this system
|
||||
(for now, that means either 'SDL' or 'Null').
|
||||
*/
|
||||
void createSound();
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// The following methods are system-specific and must be implemented
|
||||
|
|
|
@ -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.34 2005-03-26 04:19:56 stephena Exp $
|
||||
// $Id: Settings.cxx,v 1.35 2005-05-01 18:57:21 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -47,7 +47,6 @@ Settings::Settings(OSystem* osystem)
|
|||
set("fragsize", "512");
|
||||
set("fullscreen", "false");
|
||||
set("grabmouse", "false");
|
||||
set("hidecursor", "false");
|
||||
set("volume", "-1");
|
||||
set("accurate", "false");
|
||||
set("framerate", "-1");
|
||||
|
@ -187,13 +186,14 @@ void Settings::usage()
|
|||
<< " -gl_fsmax <1|0> Use the largest available screenmode in fullscreen OpenGL\n"
|
||||
<< endl
|
||||
#endif
|
||||
#ifdef SOUND_SUPPORT
|
||||
<< " -sound <1|0> Enable sound generation\n"
|
||||
<< " -fragsize <number> The size of sound fragments (must be a power of two)\n"
|
||||
#endif
|
||||
<< " -framerate <number> Display the given number of frames per second\n"
|
||||
<< " -zoom <size> Makes window be 'size' times normal\n"
|
||||
<< " -fullscreen <1|0> Play the game in fullscreen mode\n"
|
||||
<< " -grabmouse <1|0> Keeps the mouse in the game window\n"
|
||||
<< " -hidecursor <1|0> Hides the mouse cursor in the game window\n"
|
||||
<< " -volume <number> Set the volume (0 - 100)\n"
|
||||
<< " -paddle <0|1|2|3> Indicates which paddle the mouse should emulate\n"
|
||||
<< " -altpro <props file> Use the given properties file instead of stella.pro\n"
|
||||
|
|
|
@ -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: Sound.hxx,v 1.17 2005-04-28 19:28:33 stephena Exp $
|
||||
// $Id: Sound.hxx,v 1.18 2005-05-01 18:57:21 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SOUND_HXX
|
||||
|
@ -30,7 +30,7 @@ class Deserializer;
|
|||
It has no functionality whatsoever.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: Sound.hxx,v 1.17 2005-04-28 19:28:33 stephena Exp $
|
||||
@version $Id: Sound.hxx,v 1.18 2005-05-01 18:57:21 stephena Exp $
|
||||
*/
|
||||
class Sound
|
||||
{
|
||||
|
@ -41,6 +41,11 @@ class Sound
|
|||
*/
|
||||
Sound(OSystem* osystem) { myOSystem = osystem; }
|
||||
|
||||
/**
|
||||
Destructor
|
||||
*/
|
||||
virtual ~Sound() { };
|
||||
|
||||
public:
|
||||
/**
|
||||
Enables/disables the sound subsystem.
|
||||
|
|
|
@ -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.39 2005-04-21 18:55:15 stephena Exp $
|
||||
// $Id: TIA.cxx,v 1.40 2005-05-01 18:57:21 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -34,10 +34,10 @@
|
|||
#define HBLANK 68
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
TIA::TIA(const Console& console, Sound& sound, Settings& settings)
|
||||
TIA::TIA(const Console& console, Settings& settings)
|
||||
: myConsole(console),
|
||||
mySound(sound),
|
||||
mySettings(settings),
|
||||
mySound(NULL),
|
||||
myColorLossEnabled(false),
|
||||
myMaximumNumberOfScanlines(262),
|
||||
myCOLUBK(myColor[0]),
|
||||
|
@ -121,7 +121,7 @@ const char* TIA::name() const
|
|||
void TIA::reset()
|
||||
{
|
||||
// Reset the sound device
|
||||
mySound.reset();
|
||||
mySound->reset();
|
||||
|
||||
// Clear frame buffers
|
||||
for(uInt32 i = 0; i < 160 * 300; ++i)
|
||||
|
@ -245,7 +245,7 @@ void TIA::systemCyclesReset()
|
|||
uInt32 cycles = mySystem->cycles();
|
||||
|
||||
// Adjust the sound cycle indicator
|
||||
mySound.adjustCycleCounter(-cycles);
|
||||
mySound->adjustCycleCounter(-cycles);
|
||||
|
||||
// Adjust the dump cycle
|
||||
myDumpDisabledCycle -= cycles;
|
||||
|
@ -372,7 +372,7 @@ bool TIA::save(Serializer& out)
|
|||
out.putLong(myDumpDisabledCycle);
|
||||
|
||||
// Save the sound sample stuff ...
|
||||
mySound.save(out);
|
||||
mySound->save(out);
|
||||
}
|
||||
catch(char *msg)
|
||||
{
|
||||
|
@ -473,7 +473,7 @@ bool TIA::load(Deserializer& in)
|
|||
myDumpDisabledCycle = (Int32) in.getLong();
|
||||
|
||||
// Load the sound sample stuff ...
|
||||
mySound.load(in);
|
||||
mySound->load(in);
|
||||
}
|
||||
catch(char *msg)
|
||||
{
|
||||
|
@ -580,6 +580,12 @@ uInt32 TIA::scanlines() const
|
|||
return (uInt32)myScanlineCountForLastFrame;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TIA::setSound(Sound& sound)
|
||||
{
|
||||
mySound = &sound;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TIA::computeBallMaskTable()
|
||||
{
|
||||
|
@ -2363,37 +2369,37 @@ void TIA::poke(uInt16 addr, uInt8 value)
|
|||
|
||||
case 0x15: // Audio control 0
|
||||
{
|
||||
mySound.set(addr, value, mySystem->cycles());
|
||||
mySound->set(addr, value, mySystem->cycles());
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x16: // Audio control 1
|
||||
{
|
||||
mySound.set(addr, value, mySystem->cycles());
|
||||
mySound->set(addr, value, mySystem->cycles());
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x17: // Audio frequency 0
|
||||
{
|
||||
mySound.set(addr, value, mySystem->cycles());
|
||||
mySound->set(addr, value, mySystem->cycles());
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x18: // Audio frequency 1
|
||||
{
|
||||
mySound.set(addr, value, mySystem->cycles());
|
||||
mySound->set(addr, value, mySystem->cycles());
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x19: // Audio volume 0
|
||||
{
|
||||
mySound.set(addr, value, mySystem->cycles());
|
||||
mySound->set(addr, value, mySystem->cycles());
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x1A: // Audio volume 1
|
||||
{
|
||||
mySound.set(addr, value, mySystem->cycles());
|
||||
mySound->set(addr, value, mySystem->cycles());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3287,8 +3293,8 @@ const uInt32 TIA::ourPALPaletteZ26[256] = {
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
TIA::TIA(const TIA& c)
|
||||
: myConsole(c.myConsole),
|
||||
mySound(c.mySound),
|
||||
mySettings(c.mySettings),
|
||||
mySound(c.mySound),
|
||||
myCOLUBK(myColor[0]),
|
||||
myCOLUPF(myColor[1]),
|
||||
myCOLUP0(myColor[2]),
|
||||
|
|
|
@ -13,20 +13,20 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: TIA.hxx,v 1.18 2005-04-21 21:18:37 stephena Exp $
|
||||
// $Id: TIA.hxx,v 1.19 2005-05-01 18:57:21 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef TIA_HXX
|
||||
#define TIA_HXX
|
||||
|
||||
class Console;
|
||||
class Sound;
|
||||
class System;
|
||||
class Serializer;
|
||||
class Deserializer;
|
||||
class Settings;
|
||||
|
||||
#include "bspf.hxx"
|
||||
#include "Sound.hxx"
|
||||
#include "Device.hxx"
|
||||
#include "MediaSrc.hxx"
|
||||
|
||||
|
@ -42,7 +42,7 @@ class Settings;
|
|||
be displayed on screen.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: TIA.hxx,v 1.18 2005-04-21 21:18:37 stephena Exp $
|
||||
@version $Id: TIA.hxx,v 1.19 2005-05-01 18:57:21 stephena Exp $
|
||||
*/
|
||||
class TIA : public Device , public MediaSource
|
||||
{
|
||||
|
@ -50,11 +50,10 @@ class TIA : public Device , public MediaSource
|
|||
/**
|
||||
Create a new TIA for the specified console
|
||||
|
||||
@param console The console the TIA is associated with
|
||||
@param sound The sound object the TIA is associated with
|
||||
@param settings The settings object the TIA is associated with
|
||||
@param console The console the TIA is associated with
|
||||
@param settings The settings object for this TIA device
|
||||
*/
|
||||
TIA(const Console& console, Sound& sound, Settings& settings);
|
||||
TIA(const Console& console, Settings& settings);
|
||||
|
||||
/**
|
||||
Destructor
|
||||
|
@ -171,6 +170,11 @@ class TIA : public Device , public MediaSource
|
|||
*/
|
||||
uInt32 scanlines() const;
|
||||
|
||||
/**
|
||||
Sets the sound device for the TIA.
|
||||
*/
|
||||
void setSound(Sound& sound);
|
||||
|
||||
enum TIABit {
|
||||
P0, // Descriptor for Player 0 Bit
|
||||
P1, // Descriptor for Player 1 Bit
|
||||
|
@ -230,11 +234,11 @@ class TIA : public Device , public MediaSource
|
|||
// Console the TIA is associated with
|
||||
const Console& myConsole;
|
||||
|
||||
// Sound object the TIA is associated with
|
||||
Sound& mySound;
|
||||
|
||||
// Settings object the TIA is associated with
|
||||
Settings& mySettings;
|
||||
const Settings& mySettings;
|
||||
|
||||
// Sound object the TIA is associated with
|
||||
Sound* mySound;
|
||||
|
||||
private:
|
||||
// Indicates if color loss should be enabled or disabled. Color loss
|
||||
|
|
|
@ -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: OptionsDialog.cxx,v 1.12 2005-04-29 19:05:06 stephena Exp $
|
||||
// $Id: OptionsDialog.cxx,v 1.13 2005-05-01 18:57:21 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -66,7 +66,12 @@ OptionsDialog::OptionsDialog(OSystem* osystem)
|
|||
const int xoffset = (_w - kBigButtonWidth) / 2;
|
||||
|
||||
addBigButton("Video Settings", kVidCmd, 'V');
|
||||
#ifdef SOUND_SUPPORT
|
||||
addBigButton("Audio Settings", kAudCmd, 'A');
|
||||
#else
|
||||
ButtonWidget* b = addBigButton("Audio Settings", kAudCmd, 'A');
|
||||
b->setEnabled(false);
|
||||
#endif
|
||||
addBigButton("Event Remapping", kEMapCmd, 'E');
|
||||
addBigButton("Miscellaneous", kMiscCmd, 'M');
|
||||
addBigButton("Game Information", kInfoCmd, 'I');
|
||||
|
|
Loading…
Reference in New Issue