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
This commit is contained in:
stephena 2005-06-29 13:11:03 +00:00
parent c64d9b5f64
commit 113f32b7e1
10 changed files with 163 additions and 75 deletions

View File

@ -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

View File

@ -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;

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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 <assert.h>
@ -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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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;
};

View File

@ -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

View File

@ -32,6 +32,10 @@
/* */
/*****************************************************************************/
#ifdef SOUND_SUPPORT
#include "bspf.hxx"
#ifdef __cplusplus
extern "C" {
#endif
@ -40,23 +44,6 @@ extern "C" {
#include <stdlib.h>
#include <time.h>
/* 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<POLY9_SIZE; n++)
@ -180,7 +167,7 @@ void Tia_sound_init (uint16 sample_freq, uint16 playback_freq)
}
/* calculate the sample 'divide by N' value based on the playback freq. */
Samp_n_max = (uint16)(((uint32)sample_freq<<8)/playback_freq);
Samp_n_max = (uInt16)(((uInt32)sample_freq<<8)/playback_freq);
Samp_n_cnt = 0; /* initialize all bits of the sample counter */
/* initialize the local globals */
@ -218,10 +205,10 @@ void Tia_sound_init (uint16 sample_freq, uint16 playback_freq)
/* */
/*****************************************************************************/
void Update_tia_sound (uint16 addr, uint8 val)
void Update_tia_sound (uInt16 addr, uInt8 val)
{
uint16 new_val = 0;
uint8 chan;
uInt16 new_val = 0;
uInt8 chan;
/* determine which address was changed */
switch (addr)
@ -318,11 +305,11 @@ void Update_tia_sound (uint16 addr, uint8 val)
/* */
/*****************************************************************************/
void Tia_process (register unsigned char *buffer, register uint16 n)
void Tia_process (register unsigned char *buffer, register uInt16 n)
{
register uint8 audc0,audv0,audc1,audv1;
register uint8 div_n_cnt0,div_n_cnt1;
register uint8 p5_0, p5_1,outvol_0,outvol_1;
register uInt8 audc0,audv0,audc1,audv1;
register uInt8 div_n_cnt0,div_n_cnt1;
register uInt8 p5_0, p5_1,outvol_0,outvol_1;
audc0 = AUDC[0];
audv0 = AUDV[0];
@ -480,8 +467,8 @@ void Tia_process (register unsigned char *buffer, register uint16 n)
/* calculate the latest output value and place in buffer
scale the volume by 128, since this is the default silence value
when using unsigned 8-bit samples in SDL */
*(buffer++) = ((uint8) ((((uint32)outvol_0 + (uint32)outvol_1) * volume) / 100))/2 + 128;
/* *(buffer++) = ((((uint32)outvol_0 + (uint32)outvol_1) * volume) / 100); */
*(buffer++) = ((uInt8) ((((uInt32)outvol_0 + (uInt32)outvol_1) * volume) / 100))/2 + 128;
/* *(buffer++) = ((((uInt32)outvol_0 + (uInt32)outvol_1) * volume) / 100); */
/* and indicate one less byte to process */
n--;
@ -558,7 +545,7 @@ void Tia_set_registers (unsigned char reg1, unsigned char reg2, unsigned char re
void Tia_clear_registers ()
{
uint8 chan;
uInt8 chan;
for (chan = CHAN1; chan <= CHAN2; chan++)
{
Outvol[chan] = 0;
@ -612,9 +599,9 @@ void Tia_volume (unsigned int percent)
/* */
/*****************************************************************************/
void Tia_process_2 (register unsigned char *buffer, register uint16 n)
void Tia_process_2 (register unsigned char *buffer, register uInt16 n)
{
register uint8 chan;
register uInt8 chan;
/* loop until the buffer is filled */
while (n)
@ -715,3 +702,5 @@ void Tia_process_2 (register unsigned char *buffer, register uint16 n)
}
}
#endif
#endif // SOUND_SUPPORT