From 113f32b7e114037c073ef636e86958458e66590e Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 29 Jun 2005 13:11:03 +0000 Subject: [PATCH] Moved initialization of TIADebug from Console to Debugger, since the Console doesn't really need to know about it, and it belongs to the debugger anyway. Fixed some makefile issues: Pure C programs were being compiled with 'cc', when 'g++' (or equivalent) should have been used. Only pre-define the compiler flags to include '-O2' if the user doesn't have a CXXFLAGS env variable set. Sometimes I want to use '-g', and in that case I want to override the internal '-O2'. Fixed TIASound code to not use its own type definitions, and instead use the ones from bspf.hxx. Eliminates requirement of specifying -DWIN32, even when the host system wasn't Win32. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@583 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/Makefile | 46 +++++++++++--- stella/src/debugger/Debugger.cxx | 11 +++- stella/src/debugger/PackedBitArray.cxx | 17 +++++ stella/src/debugger/PackedBitArray.hxx | 17 +++++ stella/src/debugger/TIADebug.cxx | 17 +++++ stella/src/debugger/TIADebug.hxx | 17 +++++ stella/src/emucore/Console.cxx | 5 +- stella/src/emucore/Console.hxx | 15 +++-- stella/src/emucore/MediaSrc.hxx | 6 +- stella/src/emucore/TIASound.c | 87 +++++++++++--------------- 10 files changed, 163 insertions(+), 75 deletions(-) diff --git a/stella/Makefile b/stella/Makefile index 54f5300c1..4ae559706 100644 --- a/stella/Makefile +++ b/stella/Makefile @@ -1,4 +1,23 @@ -# $Header: /home/stephena/STELLA_CVS-to-SVN/stella/Makefile,v 1.3 2005-06-29 00:31:48 urchlay Exp $ +##============================================================================ +## +## SSSS tt lll lll +## SS SS tt ll ll +## SS tttttt eeee ll ll aaaa +## SSSS tt ee ee ll ll aa +## SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +## SS SS tt ee ll ll aa aa +## SSSS ttt eeeee llll llll aaaaa +## +## Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +## +## See the file "license" for information on usage and redistribution of +## this file, and for a DISCLAIMER OF ALL WARRANTIES. +## +## $Id: Makefile,v 1.4 2005-06-29 13:11:03 stephena Exp $ +## +## Based on code from ScummVM - Scumm Interpreter +## Copyright (C) 2002-2004 The ScummVM project +##============================================================================ ####################################################################### # Default compilation parameters. Normally don't edit these # @@ -21,8 +40,12 @@ include config.mak # Uncomment this for stricter compile time code verification # CXXFLAGS+= -Werror -CXXFLAGS:= $(CXXFLAGS) -CXXFLAGS+= -O2 -Wall -Wuninitialized -Wno-multichar -Wunused +ifdef CXXFLAGS + CXXFLAGS:= $(CXXFLAGS) +else + CXXFLAGS:= -O2 +endif +CXXFLAGS+= -Wall -Wno-multichar -Wunused # Even more warnings... #CXXFLAGS+= -pedantic -Wpointer-arith -Wcast-qual -Wconversion #CXXFLAGS+= -Wshadow -Wimplicit -Wundef -Wnon-virtual-dtor @@ -97,12 +120,6 @@ clean: .PHONY: all clean dist distclean plugins -# Old (dumb) compile & dependcy rules -#INCS = scumm/scumm.h common/scummsys.h common/stdafx.h -#.cpp.o: -# $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o -#$(OBJS): $(INCS) - .SUFFIXES: .cxx ifndef HAVE_GCC3 # If you use GCC, disable the above and enable this for intelligent @@ -113,6 +130,13 @@ ifndef HAVE_GCC3 $(ECHO) "$(*D)/" > $(*D)/$(DEPDIR)/$(*F).d $(CAT) "$(*D)/$(DEPDIR)/$(*F).d2" >> "$(*D)/$(DEPDIR)/$(*F).d" $(RM) "$(*D)/$(DEPDIR)/$(*F).d2" + +.c.o: + $(MKDIR) $(*D)/$(DEPDIR) + $(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d2" $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o + $(ECHO) "$(*D)/" > $(*D)/$(DEPDIR)/$(*F).d + $(CAT) "$(*D)/$(DEPDIR)/$(*F).d2" >> "$(*D)/$(DEPDIR)/$(*F).d" + $(RM) "$(*D)/$(DEPDIR)/$(*F).d2" else # If you even have GCC 3.x, you can use this build rule, which is safer; the above # rule can get you into a bad state if you Ctrl-C at the wrong moment. @@ -121,6 +145,10 @@ else .cxx.o: $(MKDIR) $(*D)/$(DEPDIR) $(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o + +.c.o: + $(MKDIR) $(*D)/$(DEPDIR) + $(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o endif ifdef HAVE_NASM diff --git a/stella/src/debugger/Debugger.cxx b/stella/src/debugger/Debugger.cxx index f1007fe2a..098d2fb77 100644 --- a/stella/src/debugger/Debugger.cxx +++ b/stella/src/debugger/Debugger.cxx @@ -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: Debugger.cxx,v 1.41 2005-06-29 04:23:41 urchlay Exp $ +// $Id: Debugger.cxx,v 1.42 2005-06-29 13:11:03 stephena Exp $ //============================================================================ #include "bspf.hxx" @@ -61,6 +61,7 @@ Debugger::~Debugger() { delete myParser; delete myDebugger; + delete myTIAdebug; delete equateList; delete breakPoints; delete readTraps; @@ -113,7 +114,13 @@ void Debugger::setConsole(Console* console) // Keep pointers to these items for efficiency myConsole = console; mySystem = &(myConsole->system()); - myTIAdebug = myConsole->tiaDebugger(); + + // Create a new TIA debugger for this console + // This code is somewhat ugly, since we derive a TIA from the MediaSource + // for no particular reason. Maybe it's better to make the TIA be the + // base class and entirely eliminate MediaSource class?? + delete myTIAdebug; + myTIAdebug = new TIADebug((TIA*)&myConsole->mediaSource()); // Create a new 6502 debugger for this console delete myDebugger; diff --git a/stella/src/debugger/PackedBitArray.cxx b/stella/src/debugger/PackedBitArray.cxx index 0c9355b30..2f2a23fae 100644 --- a/stella/src/debugger/PackedBitArray.cxx +++ b/stella/src/debugger/PackedBitArray.cxx @@ -1,3 +1,20 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: PackedBitArray.cxx,v 1.4 2005-06-29 13:11:03 stephena Exp $ +//============================================================================ #include "bspf.hxx" #include "PackedBitArray.hxx" diff --git a/stella/src/debugger/PackedBitArray.hxx b/stella/src/debugger/PackedBitArray.hxx index 77158de25..e9f9074db 100644 --- a/stella/src/debugger/PackedBitArray.hxx +++ b/stella/src/debugger/PackedBitArray.hxx @@ -1,3 +1,20 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: PackedBitArray.hxx,v 1.2 2005-06-29 13:11:03 stephena Exp $ +//============================================================================ #ifndef PACKEDBITARRAY_HXX #define PACKEDBITARRAY_HXX diff --git a/stella/src/debugger/TIADebug.cxx b/stella/src/debugger/TIADebug.cxx index 3ed1bea05..bf6e30aa6 100644 --- a/stella/src/debugger/TIADebug.cxx +++ b/stella/src/debugger/TIADebug.cxx @@ -1,3 +1,20 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: TIADebug.cxx,v 1.4 2005-06-29 13:11:03 stephena Exp $ +//============================================================================ #include "TIADebug.hxx" #include "System.hxx" diff --git a/stella/src/debugger/TIADebug.hxx b/stella/src/debugger/TIADebug.hxx index 2f88054c6..475e990c3 100644 --- a/stella/src/debugger/TIADebug.hxx +++ b/stella/src/debugger/TIADebug.hxx @@ -1,3 +1,20 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: TIADebug.hxx,v 1.4 2005-06-29 13:11:03 stephena Exp $ +//============================================================================ #ifndef TIADEBUG_HXX #define TIADEBUG_HXX diff --git a/stella/src/emucore/Console.cxx b/stella/src/emucore/Console.cxx index 331185a61..3ba66362e 100644 --- a/stella/src/emucore/Console.cxx +++ b/stella/src/emucore/Console.cxx @@ -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.62 2005-06-29 00:31:49 urchlay Exp $ +// $Id: Console.cxx,v 1.63 2005-06-29 13:11:03 stephena Exp $ //============================================================================ #include @@ -46,7 +46,6 @@ #include "OSystem.hxx" #include "Menu.hxx" #include "Debugger.hxx" -#include "TIADebug.hxx" #include "Version.hxx" #ifdef SNAPSHOT_SUPPORT @@ -152,7 +151,6 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem) // Remember what my media source is myMediaSource = tia; - myTIAdebugger = new TIADebug(tia); myCart = cartridge; // Reset, the system to its power-on state @@ -206,7 +204,6 @@ Console::~Console() delete mySwitches; delete myControllers[0]; delete myControllers[1]; - delete myTIAdebugger; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/emucore/Console.hxx b/stella/src/emucore/Console.hxx index 9e170be3e..370c9f411 100644 --- a/stella/src/emucore/Console.hxx +++ b/stella/src/emucore/Console.hxx @@ -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.35 2005-06-29 00:31:49 urchlay Exp $ +// $Id: Console.hxx,v 1.36 2005-06-29 13:11:03 stephena Exp $ //============================================================================ #ifndef CONSOLE_HXX @@ -30,14 +30,13 @@ class System; #include "Control.hxx" #include "Props.hxx" #include "TIA.hxx" -#include "TIADebug.hxx" #include "Cart.hxx" /** This class represents the entire game console. @author Bradford W. Mott - @version $Id: Console.hxx,v 1.35 2005-06-29 00:31:49 urchlay Exp $ + @version $Id: Console.hxx,v 1.36 2005-06-29 13:11:03 stephena Exp $ */ class Console { @@ -103,6 +102,11 @@ class Console */ System& system() const { return *mySystem; } + /** + Get the cartridge used by the console which contains the ROM code + + @return The cartridge for this console + */ Cartridge& cartridge() const { return *myCart; } public: @@ -160,8 +164,6 @@ class Console */ void fry(); - TIADebug *tiaDebugger() { return myTIAdebugger; } - #ifdef DEVELOPER_SUPPORT public: /** @@ -234,9 +236,6 @@ class Console // Pointer to the 6502 based system being emulated System* mySystem; - // Pointer to TIADebug - TIADebug *myTIAdebugger; - // Pointer to the Cartridge (the debugger needs it) Cartridge *myCart; }; diff --git a/stella/src/emucore/MediaSrc.hxx b/stella/src/emucore/MediaSrc.hxx index 134a0303f..8737881a5 100644 --- a/stella/src/emucore/MediaSrc.hxx +++ b/stella/src/emucore/MediaSrc.hxx @@ -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.10 2005-06-16 00:55:58 stephena Exp $ +// $Id: MediaSrc.hxx,v 1.11 2005-06-29 13:11:03 stephena Exp $ //============================================================================ #ifndef MEDIASOURCE_HXX @@ -30,7 +30,7 @@ class Sound; This class provides an interface for accessing graphics and audio data. @author Bradford W. Mott - @version $Id: MediaSrc.hxx,v 1.10 2005-06-16 00:55:58 stephena Exp $ + @version $Id: MediaSrc.hxx,v 1.11 2005-06-29 13:11:03 stephena Exp $ */ class MediaSource { @@ -111,5 +111,5 @@ class MediaSource // Assignment operator isn't supported by this class so make it private MediaSource& operator = (const MediaSource&); }; -#endif +#endif diff --git a/stella/src/emucore/TIASound.c b/stella/src/emucore/TIASound.c index 70d288b37..178b62d7b 100644 --- a/stella/src/emucore/TIASound.c +++ b/stella/src/emucore/TIASound.c @@ -32,6 +32,10 @@ /* */ /*****************************************************************************/ +#ifdef SOUND_SUPPORT + +#include "bspf.hxx" + #ifdef __cplusplus extern "C" { #endif @@ -40,23 +44,6 @@ extern "C" { #include #include - -/* define some data types to keep it platform independent */ -#ifdef WIN32 -#define int8 char -#define int16 short -#define int32 int -#else -#define int8 char -#define int16 int -#define int32 long -#endif - -#define uint8 unsigned int8 -#define uint16 unsigned int16 -#define uint32 unsigned int32 - - /* CONSTANT DEFINITIONS */ /* definitions for AUDCx (15, 16) */ @@ -102,13 +89,13 @@ extern "C" { /* LOCAL GLOBAL VARIABLE DEFINITIONS */ /* structures to hold the 6 tia sound control bytes */ -static uint8 AUDC[2]; /* AUDCx (15, 16) */ -static uint8 AUDF[2]; /* AUDFx (17, 18) */ -static uint8 AUDV[2]; /* AUDVx (19, 1A) */ +static uInt8 AUDC[2]; /* AUDCx (15, 16) */ +static uInt8 AUDF[2]; /* AUDFx (17, 18) */ +static uInt8 AUDV[2]; /* AUDVx (19, 1A) */ -static uint8 Outvol[2]; /* last output volume for each channel */ +static uInt8 Outvol[2]; /* last output volume for each channel */ -static uint32 volume; /* output sample volume percentage */ +static uInt32 volume; /* output sample volume percentage */ /* Initialze the bit patterns for the polynomials. */ @@ -117,10 +104,10 @@ static uint32 volume; /* output sample volume percentage */ /* single bit per byte keeps the math simple, which is important for */ /* efficient processing. */ -static uint8 Bit4[POLY4_SIZE] = +static uInt8 Bit4[POLY4_SIZE] = { 1,1,0,1,1,1,0,0,0,0,1,0,1,0,0 }; -static uint8 Bit5[POLY5_SIZE] = +static uInt8 Bit5[POLY5_SIZE] = { 0,0,1,0,1,1,0,0,1,1,1,1,1,0,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,0,1 }; /* I've treated the 'Div by 31' counter as another polynomial because of */ @@ -128,28 +115,28 @@ static uint8 Bit5[POLY5_SIZE] = /* has a 13:18 ratio (of course, 13+18 = 31). This could also be */ /* implemented by using counters. */ -static uint8 Div31[POLY5_SIZE] = +static uInt8 Div31[POLY5_SIZE] = { 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0 }; /* Rather than have a table with 511 entries, I use a random number */ /* generator. */ -static uint8 Bit9[POLY9_SIZE]; +static uInt8 Bit9[POLY9_SIZE]; -static uint8 P4[2]; /* Position pointer for the 4-bit POLY array */ -static uint8 P5[2]; /* Position pointer for the 5-bit POLY array */ -static uint16 P9[2]; /* Position pointer for the 9-bit POLY array */ +static uInt8 P4[2]; /* Position pointer for the 4-bit POLY array */ +static uInt8 P5[2]; /* Position pointer for the 5-bit POLY array */ +static uInt16 P9[2]; /* Position pointer for the 9-bit POLY array */ -static uint8 Div_n_cnt[2]; /* Divide by n counter. one for each channel */ -static uint8 Div_n_max[2]; /* Divide by n maximum, one for each channel */ +static uInt8 Div_n_cnt[2]; /* Divide by n counter. one for each channel */ +static uInt8 Div_n_max[2]; /* Divide by n maximum, one for each channel */ /* In my routines, I treat the sample output as another divide by N counter. */ /* For better accuracy, the Samp_n_cnt has a fixed binary decimal point */ /* which has 8 binary digits to the right of the decimal point. */ -static uint16 Samp_n_max; /* Sample max, multiplied by 256 */ -static uint16 Samp_n_cnt; /* Sample cnt. */ +static uInt16 Samp_n_max; /* Sample max, multiplied by 256 */ +static uInt16 Samp_n_cnt; /* Sample cnt. */ @@ -168,10 +155,10 @@ static uint16 Samp_n_cnt; /* Sample cnt. */ /* */ /*****************************************************************************/ -void Tia_sound_init (uint16 sample_freq, uint16 playback_freq) +void Tia_sound_init (uInt16 sample_freq, uInt16 playback_freq) { - uint8 chan; - int16 n; + uInt8 chan; + Int16 n; /* fill the 9bit polynomial with random bits */ for (n=0; n