Updated the Cyberstella port wrt the recent Sound class

changes.

Added code to draw menus to FrameBufferWin32.  This will be
changed around soon, when I get to implementing the windowed
modes.  I added it now to make sure that remapping works from
the in-game GUI (it does!).

Most of the core features are now working.  I need to add
windowed mode (as mentioned above), then start cleaning up
the settings and getting rid of the registry crap ...


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@215 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2003-11-19 21:06:27 +00:00
parent b15698ff2e
commit b4388d45c0
8 changed files with 144 additions and 82 deletions

View File

@ -298,8 +298,6 @@ void CCyberstellaView::playRom(LONG gameID)
pszFileName = fileName; pszFileName = fileName;
} }
//::MessageBox(*this, "got here", _T("Error"), MB_OK | MB_ICONEXCLAMATION );
::ShowWindow( *this, SW_HIDE ); ::ShowWindow( *this, SW_HIDE );
// Create a new main instance for this cartridge // Create a new main instance for this cartridge
@ -309,6 +307,7 @@ void CCyberstellaView::playRom(LONG gameID)
mainWin32->run(); mainWin32->run();
::ShowWindow( *this, SW_SHOW ); ::ShowWindow( *this, SW_SHOW );
ShowCursor(TRUE);
delete pImage; delete pImage;
delete mainWin32; delete mainWin32;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBufferWin32.cxx,v 1.4 2003-11-16 19:32:52 stephena Exp $ // $Id: FrameBufferWin32.cxx,v 1.5 2003-11-19 21:06:27 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -103,8 +103,8 @@ bool FrameBufferWin32::init()
HRESULT hrCoInit = ::CoInitialize( NULL ); HRESULT hrCoInit = ::CoInitialize( NULL );
// Get the game's width and height // Get the game's width and height
mySizeGame.cx = myMediaSource->width() << 1; mySizeGame.cx = myWidth = myMediaSource->width() << 1;
mySizeGame.cy = myMediaSource->height(); mySizeGame.cy = myHeight = myMediaSource->height();
// Initialize the pixel data table // Initialize the pixel data table
for(uInt32 i = 0; i < 256; ++i) for(uInt32 i = 0; i < 256; ++i)
@ -347,7 +347,6 @@ void FrameBufferWin32::drawMediaSource()
// BUGBUG: Check for error // BUGBUG: Check for error
BYTE* pbBackBytes = (BYTE*)ddsd.lpSurface; BYTE* pbBackBytes = (BYTE*)ddsd.lpSurface;
register int y; register int y;
for(y = 0; y < mySizeGame.cy; ++y) for(y = 0; y < mySizeGame.cy; ++y)
{ {
@ -359,7 +358,7 @@ void FrameBufferWin32::drawMediaSource()
{ {
const WORD bufofs = bufofsY + x; const WORD bufofs = bufofsY + x;
BYTE v = current[ bufofs ]; BYTE v = current[ bufofs ];
if(v == previous[ bufofs ]) if(v == previous[ bufofs ] && !theRedrawEntireFrameIndicator)
continue; continue;
// x << 1 is times 2 ( doubling width ) WIDTH_FACTOR // x << 1 is times 2 ( doubling width ) WIDTH_FACTOR
@ -367,19 +366,23 @@ void FrameBufferWin32::drawMediaSource()
pbBackBytes[ pos + 0 ] = pbBackBytes[ pos + 1 ] = myPalette[v]; pbBackBytes[ pos + 0 ] = pbBackBytes[ pos + 1 ] = myPalette[v];
} }
} }
(void)m_piDDSBack->Unlock( ddsd.lpSurface ); (void)m_piDDSBack->Unlock( ddsd.lpSurface );
// The frame doesn't need to be completely redrawn anymore
theRedrawEntireFrameIndicator = false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferWin32::preFrameUpdate() void FrameBufferWin32::preFrameUpdate()
{ {
// FIXME - move locking here so its only done once per frame
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferWin32::postFrameUpdate() void FrameBufferWin32::postFrameUpdate()
{ {
// We only send any changes to the screen once per frame // We only send any changes to the screen once per frame
// FIXME - move unlocking here so its only done once per frame
// Blit offscreen to onscreen // Blit offscreen to onscreen
RECT rc = { 0, 0, mySizeGame.cx, mySizeGame.cy }; RECT rc = { 0, 0, mySizeGame.cx, mySizeGame.cy };
@ -404,16 +407,114 @@ void FrameBufferWin32::toggleFullscreen()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferWin32::drawBoundedBox(uInt32 x, uInt32 y, uInt32 w, uInt32 h) void FrameBufferWin32::drawBoundedBox(uInt32 x, uInt32 y, uInt32 w, uInt32 h)
{ {
// acquire pointer to linear video ram
DDSURFACEDESC ddsd;
ZeroMemory( &ddsd, sizeof(ddsd) );
ddsd.dwSize = sizeof(ddsd);
HRESULT hr = m_piDDSBack->Lock( NULL,
&ddsd,
/* DDLOCK_SURFACEMEMORYPTR | */ DDLOCK_WAIT,
NULL );
// BUGBUG: Check for error
BYTE* pbBackBytes = (BYTE*)ddsd.lpSurface;
// First draw the background
for(uInt32 row = 0; row < h; row++)
{
for(uInt32 col = 0; col < w; col++)
{
BYTE* ptr = pbBackBytes + ((row + y) * ddsd.lPitch) + col + x;
*ptr = myPalette[myBGColor];
}
}
// Now draw the surrounding lines
for(uInt32 col = 0; col < w+1; col++) // Top line
{
BYTE* ptr = pbBackBytes + y * ddsd.lPitch + col + x;
*ptr = myPalette[myFGColor];
}
for(uInt32 col = 0; col < w+1; col++) // Bottom line
{
BYTE* ptr = pbBackBytes + (y+h) * ddsd.lPitch + col + x;
*ptr = myPalette[myFGColor];
}
for(uInt32 row = 0; row < h; row++) // Left line
{
BYTE* ptr = pbBackBytes + (row + y) * ddsd.lPitch + x;
*ptr = myPalette[myFGColor];
}
for(uInt32 row = 0; row < h; row++) // Right line
{
BYTE* ptr = pbBackBytes + (row + y) * ddsd.lPitch + x + w;
*ptr = myPalette[myFGColor];
}
(void)m_piDDSBack->Unlock( ddsd.lpSurface );
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferWin32::drawText(uInt32 xorig, uInt32 yorig, const string& message) void FrameBufferWin32::drawText(uInt32 xorig, uInt32 yorig, const string& message)
{ {
// acquire pointer to linear video ram
DDSURFACEDESC ddsd;
ZeroMemory( &ddsd, sizeof(ddsd) );
ddsd.dwSize = sizeof(ddsd);
HRESULT hr = m_piDDSBack->Lock( NULL,
&ddsd,
/* DDLOCK_SURFACEMEMORYPTR | */ DDLOCK_WAIT,
NULL );
BYTE* pbBackBytes = (BYTE*)ddsd.lpSurface;
uInt8 length = message.length();
for(uInt32 x = 0; x < length; x++)
{
for(uInt32 y = 0; y < 8; y++)
{
for(uInt32 z = 0; z < 8; z++)
{
char letter = message[x];
if((ourFontData[(letter << 3) + y] >> z) & 1)
pbBackBytes[((x<<3) + z + xorig) + (y + yorig) * ddsd.lPitch] =
myPalette[myFGColor];
}
}
}
(void)m_piDDSBack->Unlock( ddsd.lpSurface );
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferWin32::drawChar(uInt32 xorig, uInt32 yorig, uInt32 c) void FrameBufferWin32::drawChar(uInt32 xorig, uInt32 yorig, uInt32 c)
{ {
// acquire pointer to linear video ram
DDSURFACEDESC ddsd;
ZeroMemory( &ddsd, sizeof(ddsd) );
ddsd.dwSize = sizeof(ddsd);
HRESULT hr = m_piDDSBack->Lock( NULL,
&ddsd,
/* DDLOCK_SURFACEMEMORYPTR | */ DDLOCK_WAIT,
NULL );
BYTE* pbBackBytes = (BYTE*)ddsd.lpSurface;
for(uInt32 y = 0; y < 8; y++)
{
for(uInt32 x = 0; x < 8; x++)
{
if((ourFontData[(c << 3) + y] >> x) & 1)
pbBackBytes[x + xorig + (y + yorig) * ddsd.lPitch] =
myPalette[myFGColor];
}
}
(void)m_piDDSBack->Unlock( ddsd.lpSurface );
} }
LRESULT CALLBACK FrameBufferWin32::StaticWindowProc( LRESULT CALLBACK FrameBufferWin32::StaticWindowProc(
@ -472,23 +573,6 @@ BOOL FrameBufferWin32::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
::PostQuitMessage(0); ::PostQuitMessage(0);
break; break;
case WM_KEYDOWN:
switch((int)wParam)
{
case VK_ESCAPE:
::PostMessage(myHWND, WM_CLOSE, 0, 0);
// For some braindead reason, the exit event must be handled
// here. Normally, an Escape event would be the same as any
// other and the Console would handle it.
// But since Windows insists on doing it this way, we have
// to make sure that the Escape event is still received by
// the core.
myConsole->eventHandler().sendEvent(Event::Quit, 1);
break;
}
break;
case WM_PAINT: case WM_PAINT:
PAINTSTRUCT ps; PAINTSTRUCT ps;
::BeginPaint( myHWND, &ps ); ::BeginPaint( myHWND, &ps );

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: MainWin32.cxx,v 1.3 2003-11-16 19:32:52 stephena Exp $ // $Id: MainWin32.cxx,v 1.4 2003-11-19 21:06:27 stephena Exp $
//============================================================================ //============================================================================
#define STRICT #define STRICT
@ -92,14 +92,15 @@ MainWin32::MainWin32(const uInt8* image, uInt32 size, const char* filename,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MainWin32::~MainWin32() MainWin32::~MainWin32()
{ {
// Save the settings for this instance of the console
theConsole->settings().saveConfig();
cleanup(); cleanup();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MainWin32::cleanup() void MainWin32::cleanup()
{ {
ShowCursor(TRUE);
if(theDisplay) if(theDisplay)
delete theDisplay; delete theDisplay;
@ -132,7 +133,7 @@ DWORD MainWin32::run()
QueryPerformanceFrequency( (LARGE_INTEGER*)&uiCountsPerSecond ); QueryPerformanceFrequency( (LARGE_INTEGER*)&uiCountsPerSecond );
const unsigned __int64 uiCountsPerFrame = const unsigned __int64 uiCountsPerFrame =
( uiCountsPerSecond / 60);// FIXME m_rGlobalData->desiredFrameRate); ( uiCountsPerSecond / theSettings.getInt("framerate"));
unsigned __int64 uiFrameStart; unsigned __int64 uiFrameStart;
unsigned __int64 uiFrameCurrent; unsigned __int64 uiFrameCurrent;
@ -158,8 +159,7 @@ DWORD MainWin32::run()
::QueryPerformanceCounter( (LARGE_INTEGER*)&uiFrameStart ); ::QueryPerformanceCounter( (LARGE_INTEGER*)&uiFrameStart );
UpdateEvents(); UpdateEvents();
theDisplay->update(); theConsole->update();
theSound->updateSound(*theDisplay->mediaSource());
// waste time to to meet desired frame rate // waste time to to meet desired frame rate
for(;;) for(;;)
@ -167,38 +167,25 @@ DWORD MainWin32::run()
QueryPerformanceCounter( (LARGE_INTEGER*)&uiFrameCurrent ); QueryPerformanceCounter( (LARGE_INTEGER*)&uiFrameCurrent );
if((uiFrameCurrent - uiFrameStart) >= uiCountsPerFrame) if((uiFrameCurrent - uiFrameStart) >= uiCountsPerFrame)
break; break;
//FIXME else
// WaitMessage();
} }
} }
} }
// Main message loop done // Main message loop done
/* if(0)// m_rGlobalData->bShowFPS)
if ( m_rGlobalData->bShowFPS) {
{ // Get the final tick count
// get number of scanlines in last frame unsigned __int64 uiEndRun;
QueryPerformanceCounter( (LARGE_INTEGER*)&uiEndRun );
uInt32 uScanLines = rMediaSource.scanlines(); // Get number of ticks
DWORD secs = (DWORD)((uiEndRun - uiStartRun) / uiCountsPerSecond);
DWORD fps = (secs == 0) ? 0 : (uFrameCount / secs);
// Get the final tick count TCHAR pszBuf[1024];
wsprintf(pszBuf, _T("Frames drawn: %ld\nFPS: %ld\n"), uFrameCount, fps);
unsigned __int64 uiEndRun; MessageBox(NULL, pszBuf, _T("Statistics"), MB_OK);
::QueryPerformanceCounter( (LARGE_INTEGER*)&uiEndRun ); }
// Get number of ticks
DWORD secs = (DWORD)( ( uiEndRun - uiStartRun ) / uiCountsPerSecond );
DWORD fps = (secs == 0) ? 0 : (uFrameCount / secs);
TCHAR pszBuf[1024];
wsprintf( pszBuf, _T("Frames drawn: %ld\nFPS: %ld\nScanlines in last frame: %ld\n"),
uFrameCount,
fps,
uScanLines );
MessageBox( NULL, pszBuf, _T("Statistics"), MB_OK );
}*/
return msg.wParam; return msg.wParam;
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: MainWin32.hxx,v 1.3 2003-11-16 19:32:52 stephena Exp $ // $Id: MainWin32.hxx,v 1.4 2003-11-19 21:06:27 stephena Exp $
//============================================================================ //============================================================================
#ifndef MAIN_WIN32_HXX #ifndef MAIN_WIN32_HXX
@ -41,7 +41,7 @@ class DirectInput;
in the Porting.txt document in the Porting.txt document
@author Stephen Anthony @author Stephen Anthony
@version $Id: MainWin32.hxx,v 1.3 2003-11-16 19:32:52 stephena Exp $ @version $Id: MainWin32.hxx,v 1.4 2003-11-19 21:06:27 stephena Exp $
*/ */
class MainWin32 class MainWin32
{ {
@ -100,8 +100,6 @@ class MainWin32
static StellaEvent::JoyStick joyList[StellaEvent::LastJSTICK]; static StellaEvent::JoyStick joyList[StellaEvent::LastJSTICK];
static StellaEvent::JoyCode joyButtonList[StellaEvent::LastJCODE-4]; static StellaEvent::JoyCode joyButtonList[StellaEvent::LastJCODE-4];
const CGlobalData* m_rGlobalData;
// Indicates the current mouse position in the X direction // Indicates the current mouse position in the X direction
Int32 theMouseX; Int32 theMouseX;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: SettingsWin32.cxx,v 1.2 2003-09-23 19:41:16 stephena Exp $ // $Id: SettingsWin32.cxx,v 1.3 2003-11-19 21:06:27 stephena Exp $
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -29,23 +29,18 @@ SettingsWin32::SettingsWin32()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SettingsWin32::~SettingsWin32() SettingsWin32::~SettingsWin32()
{ {
cerr << "SettingsWin32::~SettingsWin32()\n";
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string SettingsWin32::stateFilename(uInt32 state) string SettingsWin32::stateFilename(uInt32 state)
{ {
cerr << "SettingsWin32::stateFilename()\n"; return "";
return "";
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string SettingsWin32::snapshotFilename() string SettingsWin32::snapshotFilename()
{ {
cerr << "SettingsWin32::snapshotFilename()\n"; return "";
return "";
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: SettingsWin32.hxx,v 1.2 2003-09-23 19:41:16 stephena Exp $ // $Id: SettingsWin32.hxx,v 1.3 2003-11-19 21:06:27 stephena Exp $
//============================================================================ //============================================================================
#ifndef SETTINGS_WIN32_HXX #ifndef SETTINGS_WIN32_HXX
@ -31,7 +31,7 @@ class SettingsWin32 : public Settings
public: public:
virtual string stateFilename(uInt32 state); virtual string stateFilename(uInt32 state);
virtual string snapshotFilename(); virtual string snapshotFilename();
virtual void usage(string& message); virtual void usage(string& message);
}; };
#endif #endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: SoundWin32.cxx,v 1.2 2003-09-21 14:33:34 stephena Exp $ // $Id: SoundWin32.cxx,v 1.3 2003-11-19 21:06:27 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <assert.h>
@ -102,12 +102,12 @@ bool SoundWin32::isSuccessfullyInitialized() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWin32::setSoundVolume(Int32 percent) void SoundWin32::setVolume(Int32 percent)
{ {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWin32::updateSound(MediaSource& mediaSource) void SoundWin32::update()
{ {
if(myIsInitializedFlag) if(myIsInitializedFlag)
{ {
@ -116,9 +116,9 @@ void SoundWin32::updateSound(MediaSource& mediaSource)
uInt8* buffer = new uInt8[myBufferSize]; uInt8* buffer = new uInt8[myBufferSize];
// Dequeue samples as long as full fragments are available // Dequeue samples as long as full fragments are available
while(mediaSource.numberOfAudioSamples() >= myBufferSize) while(myMediaSource->numberOfAudioSamples() >= myBufferSize)
{ {
mediaSource.dequeueAudioSamples(buffer, myBufferSize); myMediaSource->dequeueAudioSamples(buffer, myBufferSize);
LPVOID lpvWrite; LPVOID lpvWrite;
DWORD dwLength; DWORD dwLength;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: SoundWin32.hxx,v 1.2 2003-09-21 14:33:34 stephena Exp $ // $Id: SoundWin32.hxx,v 1.3 2003-11-19 21:06:27 stephena Exp $
//============================================================================ //============================================================================
#ifndef SOUND_WIN32_HXX #ifndef SOUND_WIN32_HXX
@ -30,7 +30,7 @@
Win32 DirectSound API. Win32 DirectSound API.
@author Stephen Anthony @author Stephen Anthony
@version $Id: SoundWin32.hxx,v 1.2 2003-09-21 14:33:34 stephena Exp $ @version $Id: SoundWin32.hxx,v 1.3 2003-11-19 21:06:27 stephena Exp $
*/ */
class SoundWin32 : public Sound class SoundWin32 : public Sound
{ {
@ -72,15 +72,13 @@ class SoundWin32 : public Sound
@param percent The new volume percentage level for the sound device @param percent The new volume percentage level for the sound device
*/ */
void setSoundVolume(Int32 percent); void setVolume(Int32 percent);
/** /**
Update the sound device using the audio sample from the specified Update the sound device using the audio sample from the
media source. media source.
@param mediaSource The media source to get audio samples from.
*/ */
void updateSound(MediaSource& mediaSource); void update();
/** /**
Initialize the DirectSound subsystem/ Initialize the DirectSound subsystem/
@ -114,4 +112,5 @@ class SoundWin32 : public Sound
// DSP sample rate // DSP sample rate
uInt32 mySampleRate; uInt32 mySampleRate;
}; };
#endif #endif