Massive update of the wince port. Works almost correctly on smartphones, pocket pcs need some testing.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@842 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
knakos 2005-10-16 18:36:13 +00:00
parent 330c27224c
commit 00b702cdc0
16 changed files with 16793 additions and 15972 deletions

View File

@ -1,331 +1,331 @@
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <windows.h> #include <windows.h>
#include <tchar.h> #include <tchar.h>
//#include <direct.h> //#include <direct.h>
#include "FSNode.hxx" #include "FSNode.hxx"
/* /*
* Implementation of the Stella file system API based on Windows API. * Implementation of the Stella file system API based on Windows API.
*/ */
class WindowsFilesystemNode : public AbstractFilesystemNode class WindowsFilesystemNode : public AbstractFilesystemNode
{
public:
WindowsFilesystemNode();
WindowsFilesystemNode(const string &path);
WindowsFilesystemNode(const WindowsFilesystemNode* node);
virtual string displayName() const { return _displayName; }
virtual bool isValid() const { return _isValid; }
virtual bool isDirectory() const { return _isDirectory; }
virtual string path() const { return _path; }
virtual FSList listDir(ListMode) const;
virtual AbstractFilesystemNode* parent() const;
protected:
string _displayName;
bool _isDirectory;
bool _isValid;
bool _isPseudoRoot;
string _path;
private:
static char* toAscii(TCHAR* x);
static TCHAR* toUnicode(char* x);
static void addFile (FSList& list, ListMode mode,
const char* base, WIN32_FIND_DATA* find_data);
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static const char* lastPathComponent(const string& str)
{
const char* start = str.c_str();
const char* cur = start + str.size() - 2;
while (cur > start && *cur != '\\')
--cur;
return cur + 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static string validatePath(const string& p)
{ {
public:
WindowsFilesystemNode();
WindowsFilesystemNode(const string &path);
WindowsFilesystemNode(const WindowsFilesystemNode* node);
virtual string displayName() const { return _displayName; }
virtual bool isValid() const { return _isValid; }
virtual bool isDirectory() const { return _isDirectory; }
virtual string path() const { return _path; }
virtual FSList listDir(ListMode) const;
virtual AbstractFilesystemNode* parent() const;
protected:
string _displayName;
bool _isDirectory;
bool _isValid;
bool _isPseudoRoot;
string _path;
private:
static char* toAscii(TCHAR* x);
static TCHAR* toUnicode(char* x);
static void addFile (FSList& list, ListMode mode,
const char* base, WIN32_FIND_DATA* find_data);
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static const char* lastPathComponent(const string& str)
{
const char* start = str.c_str();
const char* cur = start + str.size() - 2;
while (cur > start && *cur != '\\')
--cur;
return cur + 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static string validatePath(const string& p)
{
string path = p; string path = p;
/* if(p.size() < 2 || p[1] != ':') /* if(p.size() < 2 || p[1] != ':')
path = "c:"; path = "c:";
*/ */
return path; return path;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
char* WindowsFilesystemNode::toAscii(TCHAR* x)
{
#ifndef UNICODE
return (char*)x;
#else
static char asciiString[MAX_PATH];
WideCharToMultiByte(CP_ACP, 0, x, _tcslen(x) + 1, asciiString, sizeof(asciiString), NULL, NULL);
return asciiString;
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TCHAR* WindowsFilesystemNode::toUnicode(char* x)
{
#ifndef UNICODE
return (TCHAR*)x;
#else
static TCHAR unicodeString[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, x, strlen(x) + 1, unicodeString, sizeof(unicodeString));
return unicodeString;
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void WindowsFilesystemNode::addFile(FSList& list, ListMode mode,
const char* base, WIN32_FIND_DATA* find_data)
{
WindowsFilesystemNode entry;
char* asciiName = toAscii(find_data->cFileName);
bool isDirectory;
// Skip local directory (.) and parent (..)
if (!strcmp(asciiName, ".") || !strcmp(asciiName, ".."))
return;
isDirectory = (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? true : false);
if ((!isDirectory && mode == kListDirectoriesOnly) ||
(isDirectory && mode == kListFilesOnly))
return;
entry._isDirectory = isDirectory;
entry._displayName = asciiName;
entry._path = base;
entry._path += asciiName;
if (entry._isDirectory)
entry._path += "\\";
entry._isValid = true;
entry._isPseudoRoot = false;
list.push_back(wrap(new WindowsFilesystemNode(&entry)));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AbstractFilesystemNode* FilesystemNode::getRoot()
{
return new WindowsFilesystemNode();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AbstractFilesystemNode* FilesystemNode::getNodeForPath(const string& path)
{
return new WindowsFilesystemNode(path);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
WindowsFilesystemNode::WindowsFilesystemNode()
{
_isDirectory = true;
// Create a virtual root directory for standard Windows system
_isValid = false;
_path = "";
_isPseudoRoot = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
WindowsFilesystemNode::WindowsFilesystemNode(const string& path)
{
_path = validatePath(path);
_displayName = lastPathComponent(_path);
_isValid = true;
_isDirectory = true;
_isPseudoRoot = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
WindowsFilesystemNode::WindowsFilesystemNode(const WindowsFilesystemNode* node)
{
_displayName = node->_displayName;
_isDirectory = node->_isDirectory;
_isValid = node->_isValid;
_isPseudoRoot = node->_isPseudoRoot;
_path = node->_path;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FSList WindowsFilesystemNode::listDir(ListMode mode) const
{
assert(_isDirectory);
FSList myList;
if (_isPseudoRoot)
{
addFile(myList, mode, "\\", NULL);
// Drives enumeration
/* TCHAR drive_buffer[100];
GetLogicalDriveStrings(sizeof(drive_buffer) / sizeof(TCHAR), drive_buffer);
for (TCHAR *current_drive = drive_buffer; *current_drive;
current_drive += _tcslen(current_drive) + 1)
{
WindowsFilesystemNode entry;
char drive_name[2];
drive_name[0] = toAscii(current_drive)[0];
drive_name[1] = '\0';
entry._displayName = drive_name;
entry._isDirectory = true;
entry._isValid = true;
entry._isPseudoRoot = false;
entry._path = toAscii(current_drive);
myList.push_back(wrap(new WindowsFilesystemNode(&entry)));
}*/
}
else
{
// Files enumeration
WIN32_FIND_DATA desc;
HANDLE handle;
char searchPath[MAX_PATH + 10];
sprintf(searchPath, "%s*", _path.c_str());
handle = FindFirstFile(toUnicode(searchPath), &desc);
if (handle == INVALID_HANDLE_VALUE)
return myList;
addFile(myList, mode, _path.c_str(), &desc);
while (FindNextFile(handle, &desc))
addFile(myList, mode, _path.c_str(), &desc);
FindClose(handle);
}
return myList;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AbstractFilesystemNode* WindowsFilesystemNode::parent() const
{
assert(_isValid || _isPseudoRoot);
if (_isPseudoRoot)
return 0;
WindowsFilesystemNode* p = new WindowsFilesystemNode();
if (_path.size() > 3)
{
const char *start = _path.c_str();
const char *end = lastPathComponent(_path);
p = new WindowsFilesystemNode();
p->_path = string(start, end - start);
p->_isValid = true;
p->_isDirectory = true;
p->_displayName = lastPathComponent(p->_path);
p->_isPseudoRoot = false;
}
return p;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
char* WindowsFilesystemNode::toAscii(TCHAR* x)
{
#ifndef UNICODE
return (char*)x;
#else
static char asciiString[MAX_PATH];
WideCharToMultiByte(CP_ACP, 0, x, _tcslen(x) + 1, asciiString, sizeof(asciiString), NULL, NULL);
return asciiString;
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TCHAR* WindowsFilesystemNode::toUnicode(char* x)
{
#ifndef UNICODE
return (TCHAR*)x;
#else
static TCHAR unicodeString[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, x, strlen(x) + 1, unicodeString, sizeof(unicodeString));
return unicodeString;
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void WindowsFilesystemNode::addFile(FSList& list, ListMode mode,
const char* base, WIN32_FIND_DATA* find_data)
{
WindowsFilesystemNode entry;
char* asciiName = toAscii(find_data->cFileName);
bool isDirectory;
// Skip local directory (.) and parent (..)
if (!strcmp(asciiName, ".") || !strcmp(asciiName, ".."))
return;
isDirectory = (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? true : false);
if ((!isDirectory && mode == kListDirectoriesOnly) ||
(isDirectory && mode == kListFilesOnly))
return;
entry._isDirectory = isDirectory;
entry._displayName = asciiName;
entry._path = base;
entry._path += asciiName;
if (entry._isDirectory)
entry._path += "\\";
entry._isValid = true;
entry._isPseudoRoot = false;
list.push_back(wrap(new WindowsFilesystemNode(&entry)));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AbstractFilesystemNode* FilesystemNode::getRoot()
{
return new WindowsFilesystemNode();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AbstractFilesystemNode* FilesystemNode::getNodeForPath(const string& path)
{
return new WindowsFilesystemNode(path);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
WindowsFilesystemNode::WindowsFilesystemNode()
{
_isDirectory = true;
// Create a virtual root directory for standard Windows system
_isValid = false;
_path = "";
_isPseudoRoot = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
WindowsFilesystemNode::WindowsFilesystemNode(const string& path)
{
_path = validatePath(path);
_displayName = lastPathComponent(_path);
_isValid = true;
_isDirectory = true;
_isPseudoRoot = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
WindowsFilesystemNode::WindowsFilesystemNode(const WindowsFilesystemNode* node)
{
_displayName = node->_displayName;
_isDirectory = node->_isDirectory;
_isValid = node->_isValid;
_isPseudoRoot = node->_isPseudoRoot;
_path = node->_path;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FSList WindowsFilesystemNode::listDir(ListMode mode) const
{
assert(_isDirectory);
FSList myList;
if (_isPseudoRoot)
{
addFile(myList, mode, "\\", NULL);
// Drives enumeration
/* TCHAR drive_buffer[100];
GetLogicalDriveStrings(sizeof(drive_buffer) / sizeof(TCHAR), drive_buffer);
for (TCHAR *current_drive = drive_buffer; *current_drive;
current_drive += _tcslen(current_drive) + 1)
{
WindowsFilesystemNode entry;
char drive_name[2];
drive_name[0] = toAscii(current_drive)[0];
drive_name[1] = '\0';
entry._displayName = drive_name;
entry._isDirectory = true;
entry._isValid = true;
entry._isPseudoRoot = false;
entry._path = toAscii(current_drive);
myList.push_back(wrap(new WindowsFilesystemNode(&entry)));
}*/
}
else
{
// Files enumeration
WIN32_FIND_DATA desc;
HANDLE handle;
char searchPath[MAX_PATH + 10];
sprintf(searchPath, "%s*", _path.c_str());
handle = FindFirstFile(toUnicode(searchPath), &desc);
if (handle == INVALID_HANDLE_VALUE)
return myList;
addFile(myList, mode, _path.c_str(), &desc);
while (FindNextFile(handle, &desc))
addFile(myList, mode, _path.c_str(), &desc);
FindClose(handle);
}
return myList;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AbstractFilesystemNode* WindowsFilesystemNode::parent() const
{
assert(_isValid || _isPseudoRoot);
if (_isPseudoRoot)
return 0;
WindowsFilesystemNode* p = new WindowsFilesystemNode();
if (_path.size() > 3)
{
const char *start = _path.c_str();
const char *end = lastPathComponent(_path);
p = new WindowsFilesystemNode();
p->_path = string(start, end - start);
p->_isValid = true;
p->_isDirectory = true;
p->_displayName = lastPathComponent(p->_path);
p->_isPseudoRoot = false;
}
return p;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AbstractFilesystemNode::fileExists(const string& path) bool AbstractFilesystemNode::fileExists(const string& path)
{ {
WIN32_FILE_ATTRIBUTE_DATA attr;
static TCHAR unicodeString[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, path.c_str(), strlen(path.c_str()) + 1, unicodeString, sizeof(unicodeString));
BOOL b = GetFileAttributesEx(unicodeString, GetFileExInfoStandard, &attr);
return ((b != 0) && !(attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AbstractFilesystemNode::dirExists(const string& path)
{
WIN32_FILE_ATTRIBUTE_DATA attr;
TCHAR unicodeString[MAX_PATH];
string tmp(path);
if (tmp.at(path.size()-1) == '\\')
tmp.resize(path.size()-1);
MultiByteToWideChar(CP_ACP, 0, tmp.c_str(), strlen(path.c_str()) + 1, unicodeString, sizeof(unicodeString));
BOOL b = GetFileAttributesEx(unicodeString, GetFileExInfoStandard, &attr);
return ((b != 0) && (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AbstractFilesystemNode::makeDir(const string& path)
{
TCHAR unicodeString[MAX_PATH];
string tmp(path);
if (tmp.at(path.size()-1) == '\\')
tmp.resize(path.size()-1);
MultiByteToWideChar(CP_ACP, 0, tmp.c_str(), strlen(path.c_str()) + 1, unicodeString, sizeof(unicodeString));
return CreateDirectory(unicodeString, NULL) != 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string AbstractFilesystemNode::modTime(const string& path)
{
WIN32_FILE_ATTRIBUTE_DATA attr; WIN32_FILE_ATTRIBUTE_DATA attr;
static TCHAR unicodeString[MAX_PATH]; static TCHAR unicodeString[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, path.c_str(), strlen(path.c_str()) + 1, unicodeString, sizeof(unicodeString)); MultiByteToWideChar(CP_ACP, 0, path.c_str(), strlen(path.c_str()) + 1, unicodeString, sizeof(unicodeString));
BOOL b = GetFileAttributesEx(unicodeString, GetFileExInfoStandard, &attr); BOOL b = GetFileAttributesEx(unicodeString, GetFileExInfoStandard, &attr);
if(b == 0)
return ""; return ((b != 0) && !(attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
ostringstream buf;
buf << attr.ftLastWriteTime.dwHighDateTime << attr.ftLastWriteTime.dwLowDateTime;
return buf.str();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AbstractFilesystemNode::dirExists(const string& path)
{
WIN32_FILE_ATTRIBUTE_DATA attr;
TCHAR unicodeString[MAX_PATH];
string tmp(path);
if (tmp.at(path.size()-1) == '\\')
tmp.resize(path.size()-1);
MultiByteToWideChar(CP_ACP, 0, tmp.c_str(), strlen(path.c_str()) + 1, unicodeString, sizeof(unicodeString));
BOOL b = GetFileAttributesEx(unicodeString, GetFileExInfoStandard, &attr);
return ((b != 0) && (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AbstractFilesystemNode::makeDir(const string& path)
{
TCHAR unicodeString[MAX_PATH];
string tmp(path);
if (tmp.at(path.size()-1) == '\\')
tmp.resize(path.size()-1);
MultiByteToWideChar(CP_ACP, 0, tmp.c_str(), strlen(path.c_str()) + 1, unicodeString, sizeof(unicodeString));
return CreateDirectory(unicodeString, NULL) != 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string AbstractFilesystemNode::modTime(const string& path)
{
WIN32_FILE_ATTRIBUTE_DATA attr;
static TCHAR unicodeString[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, path.c_str(), strlen(path.c_str()) + 1, unicodeString, sizeof(unicodeString));
BOOL b = GetFileAttributesEx(unicodeString, GetFileExInfoStandard, &attr);
if(b == 0)
return "";
ostringstream buf;
buf << attr.ftLastWriteTime.dwHighDateTime << attr.ftLastWriteTime.dwLowDateTime;
return buf.str();
}

View File

@ -1,253 +1,504 @@
#include <windows.h> #include <windows.h>
#include <gx.h> #include "FrameBufferWinCE.hxx"
#include "FrameBufferWinCE.hxx" #include "Console.hxx"
#include "Console.hxx" #include "OSystem.hxx"
#include "OSystem.hxx" #include "Font.hxx"
#include "Font.hxx"
#define OPTPIXAVERAGE(pix1,pix2) ( ((((pix1 & optgreenmaskN) + (pix2 & optgreenmaskN)) >> 1) & optgreenmaskN) | ((((pix1 & optgreenmask) + (pix2 & optgreenmask)) >> 1) & optgreenmask) )
FrameBufferWinCE::FrameBufferWinCE(OSystem *osystem)
: FrameBuffer(osystem), myDstScreen(NULL), SubsystemInited(false), displacement(0) FrameBufferWinCE::FrameBufferWinCE(OSystem *osystem)
{ : FrameBuffer(osystem), myDstScreen(NULL), SubsystemInited(false), displacement(0),
} issmartphone(true), islandscape(false), displaymode(0)
{
FrameBufferWinCE::~FrameBufferWinCE() }
{
} FrameBufferWinCE::~FrameBufferWinCE()
{
void FrameBufferWinCE::setPalette(const uInt32* palette) }
{
//setup palette void FrameBufferWinCE::setPalette(const uInt32* palette)
GXDisplayProperties gxdp = GXGetDisplayProperties(); {
for (uInt16 i=0; i<256; i++) //setup palette
{ gxdp = GXGetDisplayProperties();
uInt8 r = (uInt8) ((palette[i] & 0xFF0000) >> 16); for (uInt16 i=0; i<256; i++)
uInt8 g = (uInt8) ((palette[i] & 0x00FF00) >> 8); {
uInt8 b = (uInt8) (palette[i] & 0x0000FF); uInt8 r = (uInt8) ((palette[i] & 0xFF0000) >> 16);
if(gxdp.ffFormat & kfDirect565) uInt8 g = (uInt8) ((palette[i] & 0x00FF00) >> 8);
pal[i] = (uInt16) ( ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3) ); uInt8 b = (uInt8) (palette[i] & 0x0000FF);
else if(gxdp.ffFormat & kfDirect555) if(gxdp.ffFormat & kfDirect565)
pal[i] = (uInt16) ( ((r & 0xF8) << 7) | ((g & 0xF8) << 3) | ((b & 0xF8) >> 3) ); pal[i] = (uInt16) ( ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3) );
else else if(gxdp.ffFormat & kfDirect555)
return; pal[i] = (uInt16) ( ((r & 0xF8) << 7) | ((g & 0xF8) << 3) | ((b & 0xF8) >> 3) );
} else
SubsystemInited = false; return;
} }
SubsystemInited = false;
bool FrameBufferWinCE::initSubsystem() }
{
GXDisplayProperties gxdp = GXGetDisplayProperties(); bool FrameBufferWinCE::initSubsystem()
for (int i=0; i<kNumColors - 256; i++) {
{ gxdp = GXGetDisplayProperties();
uInt8 r = (ourGUIColors[i][0] & 0xFF); for (int i=0; i<kNumColors - 256; i++)
uInt8 g = (ourGUIColors[i][1] & 0xFF); {
uInt8 b = (ourGUIColors[i][2] & 0xFF); uInt8 r = (ourGUIColors[i][0] & 0xFF);
if(gxdp.ffFormat & kfDirect565) uInt8 g = (ourGUIColors[i][1] & 0xFF);
guipal[i] = (uInt16) ( ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3) ); uInt8 b = (ourGUIColors[i][2] & 0xFF);
else if(gxdp.ffFormat & kfDirect555) if(gxdp.ffFormat & kfDirect565)
guipal[i] = (uInt16) ( ((r & 0xF8) << 7) | ((g & 0xF8) << 3) | ((b & 0xF8) >> 3) ); guipal[i] = (uInt16) ( ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3) );
else else if(gxdp.ffFormat & kfDirect555)
return false; guipal[i] = (uInt16) ( ((r & 0xF8) << 7) | ((g & 0xF8) << 3) | ((b & 0xF8) >> 3) );
} else
// screen extents return false;
//GXDisplayProperties gxdp = GXGetDisplayProperties(); }
pixelstep = gxdp.cbxPitch; // screen extents
linestep = gxdp.cbyPitch; if(gxdp.ffFormat & kfDirect565)
scrwidth = gxdp.cxWidth; {
scrheight = gxdp.cyHeight; optgreenmask = 0x7E0;
optgreenmaskN = 0xF81F;
SubsystemInited = false; }
return true; else
} {
optgreenmask = 0x3E0;
void FrameBufferWinCE::lateinit(void) optgreenmaskN = 0x7C1F;
{ }
myWidth = myOSystem->console().mediaSource().width();
myHeight = myOSystem->console().mediaSource().height(); scrwidth = gxdp.cxWidth;
if (scrwidth > myWidth) scrheight = gxdp.cyHeight;
displacement = (scrwidth - myWidth) / 2 * pixelstep; if (scrwidth == 176 && scrheight == 220)
else issmartphone = true;
displacement = 0; else
if (scrheight > myHeight) issmartphone = false;
displacement += (scrheight - myHeight) / 2 * linestep; islandscape = false;
setmode(0);
SubsystemInited = true;
} SubsystemInited = false;
return true;
void FrameBufferWinCE::preFrameUpdate() }
{
myDstScreen = (uInt8 *) GXBeginDraw(); void FrameBufferWinCE::setmode(uInt8 mode)
} {
displaymode = mode % 3;
void FrameBufferWinCE::drawMediaSource() switch (displaymode)
{ {
uInt8 *sc, *sp; // portrait
uInt8 *d, *pl; case 0:
pixelstep = gxdp.cbxPitch;
if (!SubsystemInited) linestep = gxdp.cbyPitch;
{ islandscape = false;
lateinit(); break;
return;
} // landscape
case 1:
if ( (d = myDstScreen) == NULL ) pixelstep = - gxdp.cbyPitch;
return; linestep = gxdp.cbxPitch;
islandscape = true;
d += displacement; break;
pl = d;
sc = myOSystem->console().mediaSource().currentFrameBuffer(); // inverted landscape
sp = myOSystem->console().mediaSource().previousFrameBuffer(); case 2:
for (uInt16 y=0; y<myHeight; y++) pixelstep = gxdp.cbyPitch;
{ linestep = - gxdp.cbxPitch;
for (uInt16 x=0; x<(myWidth>>2); x++) islandscape = true;
{ break;
if ( *((uInt32 *) sc) != *((uInt32 *) sp) ) }
{
*((uInt16 *)d) = pal[*sc++]; d += pixelstep; pixelsteptimes5 = pixelstep * 5;
*((uInt16 *)d) = pal[*sc++]; d += pixelstep; pixelsteptimes6 = pixelstep * 6;
*((uInt16 *)d) = pal[*sc++]; d += pixelstep; SubsystemInited = false;
*((uInt16 *)d) = pal[*sc++]; d += pixelstep; }
}
else int FrameBufferWinCE::rotatedisplay(void)
{ {
sc += 4; displaymode = (displaymode + 1) % 3;
d += (pixelstep << 2); setmode(displaymode);
} wipescreen();
sp += 4; return displaymode;
} }
d = pl + linestep;
pl = d; void FrameBufferWinCE::lateinit(void)
} {
} int w;
myWidth = myOSystem->console().mediaSource().width();
void FrameBufferWinCE::postFrameUpdate() myHeight = myOSystem->console().mediaSource().height();
{
GXEndDraw(); if (issmartphone)
} if (!islandscape)
w = myWidth;
void FrameBufferWinCE::drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, OverlayColor color) else
{ w = (int) ((float) myWidth * 11.0 / 8.0 + 0.5);
GUI::Font* myfont = (GUI::Font*)font; else
const FontDesc& desc = myfont->desc(); if (!islandscape)
w = (int) ((float) myWidth * 3.0 / 2.0 + 0.5);
if (!myDstScreen) return; else
//if (!SubsystemInited) {lateinit(false); return;} w = myWidth * 2;
if(c < desc.firstchar || c >= desc.firstchar + desc.size) switch (displaymode)
{ {
if (c == ' ') case 0:
return; if (scrwidth > w)
c = desc.defaultchar; displacement = (scrwidth - w) / 2 * gxdp.cbxPitch;
} else
displacement = 0;
const Int32 w = myfont->getCharWidth(c); if (scrheight > myHeight)
const Int32 h = myfont->getFontHeight(); {
c -= desc.firstchar; displacement += (scrheight - myHeight) / 2 * gxdp.cbyPitch;
const uInt16* tmp = desc.bits + (desc.offset ? desc.offset[c] : (c * h)); minydim = myHeight;
}
uInt8 *d = myDstScreen + (y/* >> 1*/) * linestep + (x >> 1) * pixelstep; else
uInt32 stride = (scrwidth - w) * pixelstep; minydim = scrheight;
uInt16 col = guipal[((int) color) - 256]; break;
for(int y2 = 0; y2 < h; y2++) case 1:
{ displacement = gxdp.cbyPitch*(gxdp.cyHeight-1);
const uInt16 buffer = *tmp++; if (scrwidth > myHeight)
uInt16 mask = 0x8000; {
minydim = myHeight;
for(int x2 = 0; x2 < w; x2++, mask >>= 1) displacement += (scrwidth - myHeight) / 2 * gxdp.cbxPitch;
{ }
if ((buffer & mask) != 0) else
{ minydim = scrwidth;
*((uInt16 *)d) = col; if (scrheight > w)
} displacement -= (scrheight - w) / 2 * gxdp.cbyPitch;
d += pixelstep; break;
}
d += stride; case 2:
} displacement = gxdp.cbxPitch*(gxdp.cxWidth-1);
} if (scrwidth > myHeight)
{
void FrameBufferWinCE::scanline(uInt32 row, uInt8* data) minydim = myHeight;
{ displacement -= (scrwidth - myHeight) / 2 * gxdp.cbxPitch;
return; }
} else
minydim = scrwidth;
void FrameBufferWinCE::setAspectRatio() if (scrheight > w)
{ displacement += (scrheight - w) / 2 * gxdp.cbyPitch;
return; break;
}
}
bool FrameBufferWinCE::createScreen()
{ SubsystemInited = true;
return true; }
}
void FrameBufferWinCE::preFrameUpdate()
void FrameBufferWinCE::toggleFilter() {
{ myDstScreen = (uInt8 *) GXBeginDraw();
return; }
}
void FrameBufferWinCE::drawMediaSource()
uInt32 FrameBufferWinCE::mapRGB(Uint8 r, Uint8 g, Uint8 b) {
{ // TODO: define these static, also x & y
return 0xFFFFFFFF; uInt8 *sc, *sp;
} uInt8 *d, *pl;
uInt16 pix1, pix2;
void FrameBufferWinCE::hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color)
{ if (!SubsystemInited)
if (!myDstScreen) return; lateinit();
//if (!SubsystemInited) {lateinit(false); return;}
int kx = x >> 1; int ky = y/* >> 1*/; int kx2 = x2>> 1; if ( (d = myDstScreen) == NULL )
uInt8 *d = myDstScreen + ky * linestep + kx * pixelstep; return;
uInt16 col = guipal[((int) color) - 256];
for (;kx < kx2; kx++) d += displacement;
{ pl = d;
*((uInt16 *)d) = col; sc = myOSystem->console().mediaSource().currentFrameBuffer();
d += pixelstep; sp = myOSystem->console().mediaSource().previousFrameBuffer();
}
} if (issmartphone && islandscape == 0)
{
void FrameBufferWinCE::vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color) // straight
{ for (uInt16 y=0; y<myHeight; y++)
if (!myDstScreen) return; {
//if (!SubsystemInited) {lateinit(false); return;} for (uInt16 x=0; x<(myWidth>>2); x++)
int kx = x >> 1; int ky = y/* >> 1*/; int ky2 = y2>> 1; {
uInt8 *d = myDstScreen + ky * linestep + kx * pixelstep; if ( *((uInt32 *) sc) != *((uInt32 *) sp) )
uInt16 col = guipal[((int) color) - 256]; {
for (;ky < ky2; ky++) *((uInt16 *)d) = pal[*sc++]; d += pixelstep;
{ *((uInt16 *)d) = pal[*sc++]; d += pixelstep;
*((uInt16 *)d) = col; *((uInt16 *)d) = pal[*sc++]; d += pixelstep;
d += linestep; *((uInt16 *)d) = pal[*sc++]; d += pixelstep;
} }
} else
{
void FrameBufferWinCE::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor color) sc += 4;
{ d += (pixelstep << 2);
if (!myDstScreen) return; }
//if (!SubsystemInited) {lateinit(false); return;} sp += 4;
int kx = x >> 1; int ky = y/* >> 1*/; int kw = (w >> 1) - 1; int kh = h /*>> 1*/; }
uInt8 *d = myDstScreen + ky * linestep + kx * pixelstep; d = pl + linestep;
uInt16 col = guipal[((int) color) - 256]; pl = d;
uInt32 stride = (scrwidth - kw - 1) * pixelstep; }
for (int h2 = kh; h2 >= 0; h2--) }
{ else if (issmartphone && islandscape)
for (int w2 = kw; w2>=0; w2--) {
{ for (uInt16 y=0; y<minydim; y++)
*((uInt16 *)d) = col; {
d += pixelstep; for (uInt16 x=0; x<(myWidth>>2); x++)
} {
d += stride; // 11/8
} // **X**
} if ( *((uInt32 *) sc) != *((uInt32 *) sp) )
{
void FrameBufferWinCE::drawBitmap(uInt32* bitmap, Int32 x, Int32 y, OverlayColor color, Int32 h) *((uInt16 *)d) = pal[*sc++]; d += pixelstep;
{ pix1 = pal[*sc++]; pix2 = pal[*sc++];
return; *((uInt16 *)d) = pix1; d += pixelstep;
} *((uInt16 *)d) = OPTPIXAVERAGE(pix1,pix2); d += pixelstep;
*((uInt16 *)d) = pix2; d += pixelstep;
void FrameBufferWinCE::translateCoords(Int32* x, Int32* y) *((uInt16 *)d) = pal[*sc++]; d += pixelstep;
{ }
return; else
} {
sc += 4;
void FrameBufferWinCE::addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h) d += pixelsteptimes5;
{ }
return; sp += 4;
} if (++x>=(myWidth>>2)) break;
// *X**X*
if ( *((uInt32 *) sc) != *((uInt32 *) sp) )
{
pix1 = pal[*sc++]; pix2 = pal[*sc++];
*((uInt16 *)d) = pix1; d += pixelstep;
*((uInt16 *)d) = OPTPIXAVERAGE(pix1,pix2); d += pixelstep;
*((uInt16 *)d) = pix2; d += pixelstep;
pix1 = pal[*sc++]; pix2 = pal[*sc++];
*((uInt16 *)d) = pix1; d += pixelstep;
*((uInt16 *)d) = OPTPIXAVERAGE(pix1,pix2); d += pixelstep;
*((uInt16 *)d) = pix2; d += pixelstep;
}
else
{
sc += 4;
d += pixelsteptimes6;
}
sp += 4;
}
d = pl + linestep;
pl = d;
}
}
else if (issmartphone == 0 && islandscape == 0)
{
// 3/2
for (uInt16 y=0; y<myHeight; y++)
{
for (uInt16 x=0; x<(myWidth>>2); x++)
{
if ( *((uInt32 *) sc) != *((uInt32 *) sp) )
{
pix1 = pal[*sc++]; pix2 = pal[*sc++];
*((uInt16 *)d) = pix1; d += pixelstep;
*((uInt16 *)d) = OPTPIXAVERAGE(pix1,pix2); d += pixelstep;
*((uInt16 *)d) = pix2; d += pixelstep;
pix1 = pal[*sc++]; pix2 = pal[*sc++];
*((uInt16 *)d) = pix1; d += pixelstep;
*((uInt16 *)d) = OPTPIXAVERAGE(pix1,pix2); d += pixelstep;
*((uInt16 *)d) = pix2; d += pixelstep;
}
else
{
sc += 4;
d += pixelsteptimes6;
}
sp += 4;
}
d = pl + linestep;
pl = d;
}
}
else if (issmartphone == 0 && islandscape)
{
// 2/1
for (uInt16 y=0; y<myHeight; y++)
{
for (uInt16 x=0; x<(myWidth>>2); x++)
{
if ( *((uInt32 *) sc) != *((uInt32 *) sp) )
{
pix1 = pal[*sc++]; pix2 = pal[*sc++];
*((uInt16 *)d) = pix1; d += pixelstep;
*((uInt16 *)d) = OPTPIXAVERAGE(pix1,pix2); d += pixelstep;
pix1 = pal[*sc++];
*((uInt16 *)d) = pix2; d += pixelstep;
*((uInt16 *)d) = OPTPIXAVERAGE(pix1,pix2); d += pixelstep;
pix2 = pal[*sc++];
*((uInt16 *)d) = pix1; d += pixelstep;
*((uInt16 *)d) = OPTPIXAVERAGE(pix1,pix2); d += pixelstep;
pix1 = pal[*sc++];
*((uInt16 *)d) = pix2; d += pixelstep;
*((uInt16 *)d) = OPTPIXAVERAGE(pix1,pix2); d += pixelstep;
}
else
{
sc += 4;
d += (pixelstep << 3);
}
sp += 4;
}
d = pl + linestep;
pl = d;
}
}
}
void FrameBufferWinCE::wipescreen(void)
{
uInt8 *d;
if (!SubsystemInited)
lateinit();
if (&(myOSystem->console().mediaSource()) != NULL)
{
uInt8 *s = myOSystem->console().mediaSource().currentFrameBuffer();
memset(s, 0, myWidth*myHeight-1);
}
if ( (d = (uInt8 *) GXBeginDraw()) == NULL )
return;
for (int i=0; i < scrwidth*scrheight; i++, *((uInt16 *)d) = 0, d += 2);
GXEndDraw();
}
void FrameBufferWinCE::postFrameUpdate()
{
GXEndDraw();
}
void FrameBufferWinCE::drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, OverlayColor color)
{
GUI::Font* myfont = (GUI::Font*)font;
const FontDesc& desc = myfont->desc();
if (!myDstScreen) return;
if(c < desc.firstchar || c >= desc.firstchar + desc.size)
{
if (c == ' ')
return;
c = desc.defaultchar;
}
const Int32 w = myfont->getCharWidth(c) >> 1;
const Int32 h = myfont->getFontHeight();
c -= desc.firstchar;
const uInt16* tmp = desc.bits + (desc.offset ? desc.offset[c] : (c * h));
if (x<0 || y<0 || (x>>1)+w>scrwidth || y+h>scrheight) return;
uInt8 *d = myDstScreen + (y/* >> 1*/) * linestep + (x >> 1) * pixelstep;
uInt32 stride = (scrwidth - w) * pixelstep;
uInt16 col = guipal[((int) color) - 256];
uInt16 col2 = (col >> 1) & 0xFFE0;
for(int y2 = 0; y2 < h; y2++)
{
const uInt16 buffer = *tmp++;
uInt16 mask = 0x8000;
for(int x2 = 0; x2 < w; x2++, mask >>= 2)
{
if (((buffer & mask) != 0) ^ ((buffer & mask>>1) != 0))
*((uInt16 *)d) = col2;
else if (((buffer & mask) != 0) && ((buffer & mask>>1) != 0))
*((uInt16 *)d) = col;
d += pixelstep;
}
d += stride;
}
}
void FrameBufferWinCE::scanline(uInt32 row, uInt8* data)
{
return;
}
void FrameBufferWinCE::setAspectRatio()
{
return;
}
bool FrameBufferWinCE::createScreen()
{
return true;
}
void FrameBufferWinCE::toggleFilter()
{
return;
}
uInt32 FrameBufferWinCE::mapRGB(Uint8 r, Uint8 g, Uint8 b)
{
return 0xFFFFFFFF;
}
void FrameBufferWinCE::hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color)
{
if (!myDstScreen) return;
int kx = x >> 1; int ky = y/* >> 1*/; int kx2 = x2>> 1;
//if (kx<0 || ky<0 || kx2<0 || kx+kx2>scrwidth || ky>scrheight) return;
if (kx<0) kx=0; if (ky<0) ky=0; if (ky>scrheight-1) return; if (kx2>scrwidth-1) kx2=scrwidth-1;
uInt8 *d = myDstScreen + ky * linestep + kx * pixelstep;
uInt16 col = guipal[((int) color) - 256];
for (;kx < kx2; kx++, *((uInt16 *)d) = col, d += pixelstep);
}
void FrameBufferWinCE::vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color)
{
if (!myDstScreen) return;
int kx = x >> 1; int ky = y/* >> 1*/; int ky2 = y2 /*>> 1*/;
//if (kx<0 || ky<0 || ky2<0 || ky+ky2>scrheight || kx>scrwidth) return;
if (kx<0) kx=0; if (ky<0) ky=0; if (kx>scrwidth-1) return; if (ky2>scrheight-1) ky2=scrheight-1;
uInt8 *d = myDstScreen + ky * linestep + kx * pixelstep;
uInt16 col = guipal[((int) color) - 256];
for (;ky < ky2; ky++, *((uInt16 *)d) = col, d += linestep);
}
void FrameBufferWinCE::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor color)
{
if (!myDstScreen) return;
int kx = x >> 1; int ky = y/* >> 1*/; int kw = (w >> 1) - 1; int kh = h /*>> 1*/;
//if (kx<0 || ky<0 || kw<0 || kh<0 || kx+kw>scrwidth || ky+kh>scrheight) return;
if (kx<0) kx=0; if (ky<0) ky=0;if (kw<0) kw=0; if (kh<0) kh=0;
if (kx+kw>scrwidth-1) kw=scrwidth-kx-1; if (ky+kh>scrheight-1) kh=scrheight-ky-1;
uInt8 *d = myDstScreen + ky * linestep + kx * pixelstep;
uInt16 col = guipal[((int) color) - 256];
uInt32 stride = (scrwidth - kw - 1) * pixelstep;
for (int h2 = kh; h2 >= 0; h2--)
{
for (int w2 = kw; w2>=0; w2--)
{
*((uInt16 *)d) = col;
d += pixelstep;
}
d += stride;
}
}
void FrameBufferWinCE::drawBitmap(uInt32* bitmap, Int32 x, Int32 y, OverlayColor color, Int32 h)
{
return;
}
void FrameBufferWinCE::translateCoords(Int32* x, Int32* y)
{
return;
}
void FrameBufferWinCE::addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h)
{
return;
}
uInt32 FrameBufferWinCE::lineDim()
{
return 1;
}

View File

@ -1,44 +1,56 @@
#ifndef FRAMEBUFFER_WINCE_HXX #ifndef FRAMEBUFFER_WINCE_HXX
#define FRAMEBUFFER_WINCE_HXX #define FRAMEBUFFER_WINCE_HXX
#include "bspf.hxx" #include <gx.h>
#include "FrameBuffer.hxx" #include "bspf.hxx"
#include "OSystem.hxx" #include "FrameBuffer.hxx"
#include "OSystem.hxx"
class FrameBufferWinCE : public FrameBuffer
{ class FrameBufferWinCE : public FrameBuffer
public: {
public:
FrameBufferWinCE(OSystem *osystem);
~FrameBufferWinCE(); FrameBufferWinCE(OSystem *osystem);
virtual void setPalette(const uInt32* palette); ~FrameBufferWinCE();
virtual bool initSubsystem(); virtual void setPalette(const uInt32* palette);
virtual void setAspectRatio() ; virtual bool initSubsystem();
virtual bool createScreen(); virtual void setAspectRatio() ;
virtual void toggleFilter(); virtual bool createScreen();
virtual void drawMediaSource(); virtual void toggleFilter();
virtual void preFrameUpdate(); virtual void drawMediaSource();
virtual void postFrameUpdate(); virtual void preFrameUpdate();
virtual void scanline(uInt32 row, uInt8* data); virtual void postFrameUpdate();
virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b); virtual void scanline(uInt32 row, uInt8* data);
virtual void hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color); virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b);
virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color); virtual void hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color);
virtual void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor color); virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color);
virtual void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, OverlayColor color); virtual void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor color);
virtual void drawBitmap(uInt32* bitmap, Int32 x, Int32 y, OverlayColor color, Int32 h = 8); virtual void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, OverlayColor color);
virtual void translateCoords(Int32* x, Int32* y); virtual void drawBitmap(uInt32* bitmap, Int32 x, Int32 y, OverlayColor color, Int32 h = 8);
virtual void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h); virtual void translateCoords(Int32* x, Int32* y);
virtual void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h);
private: virtual uInt32 lineDim();
void wipescreen(void);
void FrameBufferWinCE::lateinit(void); void setmode(uInt8 mode);
int rotatedisplay(void);
// uInt32 myXstart, myYstart;
// uInt8 *currentFrame, *previousFrame; private:
uInt16 pal[256], myWidth, myHeight, guipal[kNumColors-256], scrwidth, scrheight;
uInt32 pixelstep, linestep, displacement; void FrameBufferWinCE::lateinit(void);
bool SubsystemInited;
uInt8 *myDstScreen; // uInt32 myXstart, myYstart;
}; // uInt8 *currentFrame, *previousFrame;
uInt16 pal[256], myWidth, myHeight, guipal[kNumColors-256], scrwidth, scrheight;
#endif Int32 pixelstep, linestep;
uInt32 displacement;
bool SubsystemInited;
uInt8 *myDstScreen;
bool issmartphone, islandscape;
uInt16 minydim, optgreenmaskN, optgreenmask;
Int32 pixelsteptimes5, pixelsteptimes6;
GXDisplayProperties gxdp;
uInt8 displaymode;
};
#endif

View File

@ -1,111 +1,114 @@
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
#include "bspf.hxx" #include "bspf.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
#include "OSystemWinCE.hxx" #include "OSystemWinCE.hxx"
#include "SoundWinCE.hxx" #include "SoundWinCE.hxx"
//#include <sstream> #include "FrameBufferWinCE.hxx"
extern void KeyCheck(void); //#include <sstream>
int EventHandlerState; extern void KeyCheck(void);
extern int EventHandlerState;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystemWinCE::OSystemWinCE() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{ OSystemWinCE::OSystemWinCE()
string basedir = ((string) getcwd()) + '\\'; {
setBaseDir(basedir); string basedir = ((string) getcwd()) + '\\';
setBaseDir(basedir);
string stateDir = basedir + "state\\";
setStateDir(stateDir); string stateDir = basedir;// + "state\\";
setStateDir(stateDir);
setPropertiesDir(basedir, basedir);
setPropertiesDir(basedir, basedir);
string configFile = basedir + "stella.ini";
setConfigFiles(configFile, configFile); // Input and output are the same string configFile = basedir + "stella.ini";
setConfigFiles(configFile, configFile); // Input and output are the same
string cacheFile = basedir + "stella.cache";
setCacheFile(cacheFile); string cacheFile = basedir + "stella.cache";
} setCacheFile(cacheFile);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystemWinCE::~OSystemWinCE() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{ OSystemWinCE::~OSystemWinCE()
} {
}
void OSystemWinCE::setFramerate(uInt32 framerate)
{ void OSystemWinCE::setFramerate(uInt32 framerate)
myDisplayFrameRate = framerate; {
myTimePerFrame = (uInt32)(1000.0 / (double)myDisplayFrameRate); myDisplayFrameRate = framerate;
} myTimePerFrame = (uInt32)(1000.0 / (double)myDisplayFrameRate);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystemWinCE::mainLoop() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{ void OSystemWinCE::mainLoop()
{
// These variables are common to both timing options
// and are needed to calculate the overall frames per second. uInt32 frameTime = 0, numberOfFrames = 0;
uInt32 frameTime = 0, numberOfFrames = 0; uInt32 startTime, virtualTime, currentTime;
// Set up less accurate timing stuff virtualTime = GetTickCount();
uInt32 startTime, virtualTime, currentTime; frameTime = 0;
// Set the base for the timers // Main game loop
virtualTime = GetTickCount(); MSG msg;
frameTime = 0; int laststate = -1;
for(;;)
// Main game loop {
MSG msg; while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
for(;;) {
{ if (msg.message == WM_QUIT)
while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) break;
{ TranslateMessage(&msg);
if (msg.message == WM_QUIT) DispatchMessage(&msg);
break; }
TranslateMessage(&msg); if (msg.message == WM_QUIT)
DispatchMessage(&msg); break;
}
if (msg.message == WM_QUIT) if(myEventHandler->doQuit())
break; break;
if(myEventHandler->doQuit()) KeyCheck();
break;
startTime = GetTickCount();
KeyCheck();
EventHandlerState = (int) myEventHandler->state();
startTime = GetTickCount(); if ((laststate != -1) && (laststate != EventHandlerState) && (EventHandlerState != 2))
((FrameBufferWinCE *)myFrameBuffer)->wipescreen();
EventHandlerState = (int) myEventHandler->state(); laststate = EventHandlerState;
myEventHandler->poll(startTime);
myFrameBuffer->update(); myEventHandler->poll(startTime);
((SoundWinCE *)mySound)->update(); myFrameBuffer->update();
((SoundWinCE *)mySound)->update();
currentTime = GetTickCount();
virtualTime += myTimePerFrame; currentTime = GetTickCount();
if(currentTime < virtualTime) virtualTime += myTimePerFrame;
Sleep(virtualTime - currentTime); if(currentTime < virtualTime)
Sleep(virtualTime - currentTime);
currentTime = GetTickCount() - startTime; else
frameTime += currentTime; virtualTime = currentTime;
++numberOfFrames;
} currentTime = GetTickCount() - startTime;
frameTime += currentTime;
/* { ++numberOfFrames;
double executionTime = (double) frameTime / 1000000.0; }
double framesPerSecond = (double) numberOfFrames / executionTime;
ostringstream a; /* {
a << endl; double executionTime = (double) frameTime / 1000000.0;
a << numberOfFrames << " total frames drawn\n"; double framesPerSecond = (double) numberOfFrames / executionTime;
a << framesPerSecond << " frames/second\n"; ostringstream a;
a << endl; a << endl;
TCHAR unicodeString[MAX_PATH]; a << numberOfFrames << " total frames drawn\n";
MultiByteToWideChar(CP_ACP, 0, a.str().c_str(), strlen(a.str().c_str()) + 1, unicodeString, sizeof(unicodeString)); a << framesPerSecond << " frames/second\n";
MessageBox(GetDesktopWindow(),unicodeString, _T("..."),0); a << endl;
} TCHAR unicodeString[MAX_PATH];
*/ MultiByteToWideChar(CP_ACP, 0, a.str().c_str(), strlen(a.str().c_str()) + 1, unicodeString, sizeof(unicodeString));
} MessageBox(GetDesktopWindow(),unicodeString, _T("..."),0);
}
uInt32 OSystemWinCE::getTicks(void) */
{ }
return GetTickCount();
} uInt32 OSystemWinCE::getTicks(void)
{
return GetTickCount();
}

View File

@ -1,19 +1,19 @@
#ifndef OSYSTEM_WINCE_HXX #ifndef OSYSTEM_WINCE_HXX
#define OSYSTEM_WINCE_HXX #define OSYSTEM_WINCE_HXX
#include "bspf.hxx" #include "bspf.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
class OSystemWinCE : public OSystem class OSystemWinCE : public OSystem
{ {
public: public:
OSystemWinCE(); OSystemWinCE();
virtual ~OSystemWinCE(); virtual ~OSystemWinCE();
public: public:
virtual void mainLoop(); virtual void mainLoop();
virtual uInt32 getTicks(void); virtual uInt32 getTicks(void);
virtual void setFramerate(uInt32 framerate); virtual void setFramerate(uInt32 framerate);
}; };
#endif #endif

View File

@ -1,161 +1,171 @@
#include <windows.h> #include <windows.h>
#include <gx.h> #include "EventHandler.hxx"
#include "EventHandler.hxx" #include "OSystemWinCE.hxx"
#include "OSystemWinCE.hxx" #include "SettingsWinCE.hxx"
#include "SettingsWinCE.hxx" #include "PropsSet.hxx"
#include "PropsSet.hxx" #include "FSNode.hxx"
#include "FSNode.hxx" #include "FrameBufferWinCE.hxx"
#define KEYSCHECK_ASYNC #define KEYSCHECK_ASYNC
struct key2event struct key2event
{ {
UINT keycode; UINT keycode;
SDLKey sdlkey; SDLKey sdlkey;
uInt8 state; uInt8 state;
SDLKey launcherkey; SDLKey launcherkey;
}; };
extern key2event keycodes[2][MAX_KEYS]; extern key2event keycodes[2][MAX_KEYS];
extern void KeySetup(void); extern void KeySetup(void);
extern void KeySetMode(int);
OSystemWinCE* theOSystem = (OSystemWinCE*) NULL;
HWND hWnd; OSystemWinCE* theOSystem = (OSystemWinCE*) NULL;
HWND hWnd;
void KeyCheck(void) uInt16 rotkeystate = 0;
{
#ifdef KEYSCHECK_ASYNC
if (GetAsyncKeyState(keycodes[0][K_QUIT].keycode) & 0x8000) void KeyCheck(void)
{ {
PostQuitMessage(0); #ifdef KEYSCHECK_ASYNC
return; if (GetAsyncKeyState(VK_F3))
} {
for (int i=0; i<MAX_KEYS-1; i++) if (rotkeystate == 0)
keycodes[0][i].state = ((uInt16) GetAsyncKeyState(keycodes[0][i].keycode)) >> 15; KeySetMode( ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->rotatedisplay() );
#endif rotkeystate = 1;
} }
else
rotkeystate = 0;
void CleanUp(void)
{ for (int i=0; i<MAX_KEYS; i++)
if(theOSystem) delete theOSystem; if (GetAsyncKeyState(keycodes[0][i].keycode))
GXCloseDisplay(); keycodes[0][i].state = 1;
GXCloseInput(); else
} keycodes[0][i].state = 0;
#endif
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) }
{
static PAINTSTRUCT ps;
void CleanUp(void)
switch (uMsg) {
{ if(theOSystem) delete theOSystem;
case WM_KEYDOWN: GXCloseDisplay();
#ifndef KEYSCHECK_ASYNC GXCloseInput();
uInt8 i; }
if (wParam == keycodes[K_QUIT].keycode)
PostQuitMessage(0); LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
else {
for (i=0; i<MAX_KEYS-1; i++) switch (uMsg)
if (wParam == keycodes[i].keycode) {
{ case WM_KEYDOWN:
theConsole->eventHandler().event()->set(keycodes[i].event,1); if (wParam == VK_F3)
break; {
} if (rotkeystate == 0)
#endif KeySetMode( ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->rotatedisplay() );
return 0; rotkeystate = 1;
}
case WM_KEYUP: else
#ifndef KEYSCHECK_ASYNC rotkeystate = 0;
for (i=0; i<MAX_KEYS-1; i++) #ifndef KEYSCHECK_ASYNC
if (wParam == keycodes[i].keycode) uInt8 i;
{ for (i=0; i<MAX_KEYS; i++)
theConsole->eventHandler().event()->set(keycodes[i].event,0); if (wParam == keycodes[0][i].keycode)
break; keycodes[0][i].state = 1;
} #endif
#endif return 0;
return 0;
case WM_KEYUP:
case WM_DESTROY: #ifndef KEYSCHECK_ASYNC
PostQuitMessage(0); for (i=0; i<MAX_KEYS; i++)
return 0; if (wParam == keycodes[0][i].keycode)
keycodes[0][i].state = 0;
case WM_CLOSE: #endif
PostQuitMessage(0); return 0;
return 0;
case WM_DESTROY:
case WM_SETFOCUS: PostQuitMessage(0);
case WM_ACTIVATE: return 0;
GXSuspend();
return 0; case WM_CLOSE:
PostQuitMessage(0);
case WM_KILLFOCUS: return 0;
case WM_HIBERNATE:
GXResume(); case WM_SETFOCUS:
return 0; case WM_ACTIVATE:
GXSuspend();
case WM_PAINT: return 0;
BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps); case WM_KILLFOCUS:
return 0; case WM_HIBERNATE:
GXResume();
} return 0;
return DefWindowProc(hwnd, uMsg, wParam, lParam); }
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd ) }
{
LPTSTR wndname = _T("PocketStella"); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd )
WNDCLASS wc = { CS_HREDRAW | CS_VREDRAW, WindowProc, 0, 0, hInstance, NULL, NULL, {
(HBRUSH)GetStockObject(BLACK_BRUSH), NULL, wndname}; LPTSTR wndname = _T("PocketStella");
RegisterClass(&wc); WNDCLASS wc = { CS_HREDRAW | CS_VREDRAW, WindowProc, 0, 0, hInstance, NULL, NULL,
hWnd = CreateWindow(wndname, wndname, WS_VISIBLE, 0, 0, GetSystemMetrics(SM_CXSCREEN), (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, wndname};
GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL); RegisterClass(&wc);
if (!hWnd) return 1; hWnd = CreateWindow(wndname, wndname, WS_VISIBLE, 0, 0, GetSystemMetrics(SM_CXSCREEN),
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL);
if (!hWnd) return 1;
MSG msg; SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{ MSG msg;
TranslateMessage(&msg); while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
DispatchMessage(&msg); {
} TranslateMessage(&msg);
DispatchMessage(&msg);
theOSystem = new OSystemWinCE(); }
SettingsWinCE theSettings(theOSystem);
theOSystem->settings().loadConfig(); LOGFONT f = {11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
theOSystem->settings().validate(); OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T("")};
EventHandler theEventHandler(theOSystem); HFONT hFnt = CreateFontIndirect(&f);
PropertiesSet propertiesSet; HDC hDC = GetDC(hWnd);
propertiesSet.load(theOSystem->systemProperties(), false); SelectObject(hDC, hFnt);
theOSystem->attach(&propertiesSet); RECT RWnd;
GetClipBox(hDC, &RWnd);
if ( !GXOpenDisplay(hWnd, GX_FULLSCREEN) || !GXOpenInput() ) SetTextColor(hDC, 0xA0A0A0);
{ SetBkColor(hDC, 0);
CleanUp(); DrawText(hDC, _T("PocketStella Initializing..."), -1, &RWnd, DT_CENTER | DT_VCENTER);
return 1; ReleaseDC(hWnd, hDC);
} DeleteObject(hFnt);
KeySetup();
theOSystem = new OSystemWinCE();
if(!theOSystem->createFrameBuffer()) SettingsWinCE theSettings(theOSystem);
{ theOSystem->settings().loadConfig();
CleanUp(); theOSystem->settings().validate();
return 1; EventHandler theEventHandler(theOSystem);
} PropertiesSet propertiesSet;
theOSystem->createSound(); propertiesSet.load(theOSystem->systemProperties(), false);
theOSystem->attach(&propertiesSet);
string romfile = ((string) getcwd()) + ((string) "\\") + theSettings.getString("GameFilename");
if (!FilesystemNode::fileExists(romfile)) if ( !GXOpenDisplay(hWnd, GX_FULLSCREEN) || !GXOpenInput() )
theOSystem->createLauncher(); {
else CleanUp();
{ return 1;
/*TCHAR tmp[200]; }
MultiByteToWideChar(CP_ACP, 0, romfile.c_str(), strlen(romfile.c_str()) + 1, tmp, 200); KeySetup();
MessageBox(hWnd, tmp, _T("..."),0);*/
theOSystem->createConsole(romfile); if(!theOSystem->createFrameBuffer())
} {
CleanUp();
theOSystem->mainLoop(); return 1;
}
CleanUp(); theOSystem->createSound();
return 0; string romfile = ((string) getcwd()) + ((string) "\\") + theSettings.getString("GameFilename");
} if (!FilesystemNode::fileExists(romfile))
theOSystem->createLauncher();
else
theOSystem->createConsole(romfile);
theOSystem->mainLoop();
CleanUp();
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
#include "bspf.hxx" #include "bspf.hxx"
#include "Settings.hxx" #include "Settings.hxx"
#include "SettingsWinCE.hxx" #include "SettingsWinCE.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SettingsWinCE::SettingsWinCE(OSystem* osystem) : Settings(osystem) SettingsWinCE::SettingsWinCE(OSystem* osystem) : Settings(osystem)
{ {
//set("GameFilename", "Mega Force (1982) (20th Century Fox).bin"); //set("GameFilename", "Mega Force (1982) (20th Century Fox).bin");
//set("GameFilename", "Enduro (1983) (Activision).bin"); //set("GameFilename", "Enduro (1983) (Activision).bin");
//set("GameFilename", "Night Driver (1978) (Atari).bin"); //set("GameFilename", "Night Driver (1978) (Atari).bin");
set("romdir", (string) getcwd() + '\\'); set("romdir", (string) getcwd() + '\\');
} }
SettingsWinCE::~SettingsWinCE() SettingsWinCE::~SettingsWinCE()
{ {
} }

View File

@ -1,14 +1,14 @@
#ifndef SETTINGS_WINCE_HXX #ifndef SETTINGS_WINCE_HXX
#define SETTINGS_WINCE_HXX #define SETTINGS_WINCE_HXX
#include "bspf.hxx" #include "bspf.hxx"
#include "Settings.hxx" #include "Settings.hxx"
class SettingsWinCE : public Settings class SettingsWinCE : public Settings
{ {
public: public:
SettingsWinCE(OSystem* osystem); SettingsWinCE(OSystem* osystem);
virtual ~SettingsWinCE(); virtual ~SettingsWinCE();
}; };
#endif #endif

View File

@ -1,378 +1,392 @@
#ifdef SOUND_SUPPORT #ifdef SOUND_SUPPORT
#include "TIASnd.hxx" #include "TIASnd.hxx"
#include "FrameBuffer.hxx" #include "FrameBuffer.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#include "Settings.hxx" #include "Settings.hxx"
#include "System.hxx" #include "System.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
#include "TIASnd.hxx" #include "TIASnd.hxx"
#include "SoundWinCE.hxx" #include "SoundWinCE.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SoundWinCE::SoundWinCE(OSystem* osystem) SoundWinCE::SoundWinCE(OSystem* osystem)
: Sound(osystem), : Sound(osystem),
myIsEnabled(osystem->settings().getBool("sound")), myIsEnabled(osystem->settings().getBool("sound")),
myIsInitializedFlag(false), myIsInitializedFlag(false),
myLastRegisterSetCycle(0), myLastRegisterSetCycle(0),
myDisplayFrameRate(60), myDisplayFrameRate(60),
myNumChannels(1), myNumChannels(1),
myFragmentSizeLogBase2(0), myFragmentSizeLogBase2(0),
myIsMuted(false), myIsMuted(false),
myVolume(100), myVolume(100),
myLatency(100), myMixRate(22050), myBuffnum(0) myLatency(100), myMixRate(22050), myBuffnum(0)
{ {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SoundWinCE::~SoundWinCE() SoundWinCE::~SoundWinCE()
{ {
close(); close();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::setEnabled(bool state) void SoundWinCE::setEnabled(bool state)
{ {
myIsEnabled = state; myIsEnabled = state;
myOSystem->settings().setBool("sound", state); myOSystem->settings().setBool("sound", state);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::initialize() void SoundWinCE::initialize()
{ {
if(!myIsEnabled) if(!myIsEnabled)
{ {
close(); close();
return; return;
} }
myRegWriteQueue.clear(); myRegWriteQueue.clear();
myTIASound.reset(); myTIASound.reset();
// init wave out // init wave out
WAVEFORMATEX wf; WAVEFORMATEX wf;
MMRESULT err; MMRESULT err;
memset(&wf, 0, sizeof(wf)); memset(&wf, 0, sizeof(wf));
wf.wFormatTag = WAVE_FORMAT_PCM; wf.wFormatTag = WAVE_FORMAT_PCM;
wf.nChannels = 1; wf.nChannels = 1;
wf.nSamplesPerSec = myMixRate; wf.nSamplesPerSec = myMixRate;
wf.nAvgBytesPerSec = myMixRate; wf.nAvgBytesPerSec = myMixRate;
wf.nBlockAlign = 2; wf.nBlockAlign = 2;
wf.wBitsPerSample = 8; wf.wBitsPerSample = 8;
wf.cbSize = 0; wf.cbSize = 0;
err = waveOutOpen(&myWout, WAVE_MAPPER, &wf, NULL, NULL, CALLBACK_NULL); err = waveOutOpen(&myWout, WAVE_MAPPER, &wf, NULL, NULL, CALLBACK_NULL);
if (err != MMSYSERR_NOERROR) if (err != MMSYSERR_NOERROR)
return; return;
myBuffnum = ((wf.nAvgBytesPerSec * myLatency / 1000) >> 9) + 1; myBuffnum = ((wf.nAvgBytesPerSec * myLatency / 1000) >> 9) + 1;
myBuffers = (WAVEHDR *) malloc(myBuffnum * sizeof(*myBuffers)); myBuffers = (WAVEHDR *) malloc(myBuffnum * sizeof(*myBuffers));
for (int i = 0; i < myBuffnum; i++) for (int i = 0; i < myBuffnum; i++)
{ {
memset(&myBuffers[i], 0, sizeof (myBuffers[i])); memset(&myBuffers[i], 0, sizeof (myBuffers[i]));
if (!(myBuffers[i].lpData = (LPSTR) malloc(512))) if (!(myBuffers[i].lpData = (LPSTR) malloc(512)))
return; return;
memset(myBuffers[i].lpData, 128, 512); memset(myBuffers[i].lpData, 128, 512);
myBuffers[i].dwBufferLength = 512; myBuffers[i].dwBufferLength = 512;
err = waveOutPrepareHeader(myWout, &myBuffers[i], sizeof(myBuffers[i])); err = waveOutPrepareHeader(myWout, &myBuffers[i], sizeof(myBuffers[i]));
if (err != MMSYSERR_NOERROR) if (err != MMSYSERR_NOERROR)
return; return;
myBuffers[i].dwFlags |= WHDR_DONE; myBuffers[i].dwFlags |= WHDR_DONE;
} }
myIsInitializedFlag = true; myIsInitializedFlag = true;
myIsMuted = false; myIsMuted = false;
myTIASound.outputFrequency(myMixRate); myTIASound.outputFrequency(myMixRate);
myTIASound.channels(1); myTIASound.channels(1);
for (i=0; i<myBuffnum; i++) for (i=0; i<myBuffnum; i++)
waveOutWrite(myWout, &myBuffers[i], sizeof(WAVEHDR)); waveOutWrite(myWout, &myBuffers[i], sizeof(WAVEHDR));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::close() void SoundWinCE::close()
{ {
if(myIsInitializedFlag) if(myIsInitializedFlag)
{ {
int flag; int flag;
do do
{ {
flag = true; flag = true;
for (int i=0; i<myBuffnum; i++) for (int i=0; i<myBuffnum; i++)
{ {
if (!(myBuffers[i].dwFlags & WHDR_DONE)) if (!(myBuffers[i].dwFlags & WHDR_DONE))
{ {
flag = false; flag = false;
Sleep(myLatency); Sleep(myLatency);
} }
} }
} while (flag = false); } while (flag = false);
waveOutReset(myWout); waveOutReset(myWout);
for (int i=0; i<myBuffnum; i++) for (int i=0; i<myBuffnum; i++)
{ {
if (waveOutUnprepareHeader(myWout, &myBuffers[i], sizeof(WAVEHDR)) != MMSYSERR_NOERROR) if (waveOutUnprepareHeader(myWout, &myBuffers[i], sizeof(WAVEHDR)) != MMSYSERR_NOERROR)
return; return;
free(myBuffers[i].lpData); free(myBuffers[i].lpData);
} }
free(myBuffers); free(myBuffers);
waveOutClose(myWout); waveOutClose(myWout);
myIsInitializedFlag = false; myIsInitializedFlag = false;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SoundWinCE::isSuccessfullyInitialized() const bool SoundWinCE::isSuccessfullyInitialized() const
{ {
return myIsInitializedFlag; return myIsInitializedFlag;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::mute(bool state) void SoundWinCE::mute(bool state)
{ {
if(myIsInitializedFlag) if(myIsInitializedFlag)
{ {
if(myIsMuted == state) if(myIsMuted == state)
return; return;
myIsMuted = state; myIsMuted = state;
myRegWriteQueue.clear(); myRegWriteQueue.clear();
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::reset() void SoundWinCE::reset()
{ {
if(myIsInitializedFlag) if(myIsInitializedFlag)
{ {
myIsMuted = false; myIsMuted = false;
myLastRegisterSetCycle = 0; myLastRegisterSetCycle = 0;
myRegWriteQueue.clear(); myRegWriteQueue.clear();
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::setVolume(Int32 percent) void SoundWinCE::setVolume(Int32 percent)
{ {
if(myIsInitializedFlag) if(myIsInitializedFlag)
{ {
if((percent >= 0) && (percent <= 100)) if((percent >= 0) && (percent <= 100))
{ {
myOSystem->settings().setInt("volume", percent); myOSystem->settings().setInt("volume", percent);
myVolume = percent; myVolume = percent;
myTIASound.volume(percent); myTIASound.volume(percent);
} }
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::adjustVolume(Int8 direction) void SoundWinCE::adjustVolume(Int8 direction)
{ {
Int32 percent = myVolume; Int32 percent = myVolume;
if(direction == -1) if(direction == -1)
percent -= 2; percent -= 2;
else if(direction == 1) else if(direction == 1)
percent += 2; percent += 2;
if((percent < 0) || (percent > 100)) if((percent < 0) || (percent > 100))
return; return;
setVolume(percent); setVolume(percent);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::adjustCycleCounter(Int32 amount) void SoundWinCE::adjustCycleCounter(Int32 amount)
{ {
myLastRegisterSetCycle += amount; myLastRegisterSetCycle += amount;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::setChannels(uInt32 channels) void SoundWinCE::setChannels(uInt32 channels)
{ {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::setFrameRate(uInt32 framerate) void SoundWinCE::setFrameRate(uInt32 framerate)
{ {
myDisplayFrameRate = framerate; myDisplayFrameRate = framerate;
myLastRegisterSetCycle = 0; myLastRegisterSetCycle = 0;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::set(uInt16 addr, uInt8 value, Int32 cycle) void SoundWinCE::set(uInt16 addr, uInt8 value, Int32 cycle)
{ {
float delta = (((double)(cycle - myLastRegisterSetCycle)) / (1193191.66666667)); float delta = (((double)(cycle - myLastRegisterSetCycle)) / (1193191.66666667));
delta = delta * (myDisplayFrameRate / (double)myOSystem->frameRate()); delta = delta * (myDisplayFrameRate / (double)myOSystem->frameRate());
RegWrite info; RegWrite info;
info.addr = addr; info.addr = addr;
info.value = value; info.value = value;
info.delta = delta; info.delta = delta;
myRegWriteQueue.enqueue(info); myRegWriteQueue.enqueue(info);
myLastRegisterSetCycle = cycle; myLastRegisterSetCycle = cycle;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::processFragment(uInt8* stream, Int32 length) void SoundWinCE::processFragment(uInt8* stream, Int32 length)
{ {
if(!myIsInitializedFlag) if(!myIsInitializedFlag)
return; return;
float position = 0.0; float position = 0.0;
float remaining = length; float remaining = length;
while(remaining > 0.0) if(myRegWriteQueue.duration() >
{ (9.0 / myDisplayFrameRate))
if(myRegWriteQueue.size() == 0) {
{ float removed = 0.0;
myTIASound.process(stream + ((uInt32)position),length - (uInt32)position); while(removed < ((9.0 - 1) / myDisplayFrameRate))
myLastRegisterSetCycle = 0; {
break; RegWrite& info = myRegWriteQueue.front();
} removed += info.delta;
else myTIASound.set(info.addr, info.value);
{ myRegWriteQueue.dequeue();
RegWrite& info = myRegWriteQueue.front(); }
float duration = remaining / (float) myMixRate; // cout << "Removed Items from RegWriteQueue!" << endl;
if(info.delta <= duration) }
{
if(info.delta > 0.0) while(remaining > 0.0)
{ {
float samples = (myMixRate * info.delta); if(myRegWriteQueue.size() == 0)
myTIASound.process(stream + ((uInt32)position), {
(uInt32)samples + (uInt32)(position + samples) - myTIASound.process(stream + ((uInt32)position),length - (uInt32)position);
((uInt32)position + (uInt32)samples)); myLastRegisterSetCycle = 0;
position += samples; break;
remaining -= samples; }
} else
myTIASound.set(info.addr, info.value); {
myRegWriteQueue.dequeue(); RegWrite& info = myRegWriteQueue.front();
} float duration = remaining / (float) myMixRate;
else if(info.delta <= duration)
{ {
myTIASound.process(stream + ((uInt32)position), length - (uInt32)position); if(info.delta > 0.0)
info.delta -= duration; {
break; float samples = (myMixRate * info.delta);
} myTIASound.process(stream + ((uInt32)position),
} (uInt32)samples + (uInt32)(position + samples) -
} ((uInt32)position + (uInt32)samples));
} position += samples;
remaining -= samples;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
/*void CALLBACK SoundWinCE::waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance, myTIASound.set(info.addr, info.value);
DWORD dwParam1, DWORD dwParam2) myRegWriteQueue.dequeue();
{ }
if (uMsg == WOM_DONE) else
{ {
SoundWinCE *sound = (SoundWinCE *) dwInstance; myTIASound.process(stream + ((uInt32)position), length - (uInt32)position);
sound->processFragment( (uInt8 *) ((WAVEHDR *) dwParam2)->lpData, 512); info.delta -= duration;
waveOutWrite(sound->myWout, (WAVEHDR *) dwParam2, sizeof(WAVEHDR)); break;
} }
} }
*/ }
void SoundWinCE::update(void) }
{
for (int i=0; i<myBuffnum; i++) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (myBuffers[i].dwFlags & WHDR_DONE) /*void CALLBACK SoundWinCE::waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance,
{ DWORD dwParam1, DWORD dwParam2)
processFragment((uInt8 *) myBuffers[i].lpData, 512); {
waveOutWrite(myWout, &myBuffers[i], sizeof(WAVEHDR)); if (uMsg == WOM_DONE)
} {
} SoundWinCE *sound = (SoundWinCE *) dwInstance;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sound->processFragment( (uInt8 *) ((WAVEHDR *) dwParam2)->lpData, 512);
bool SoundWinCE::load(Deserializer& in) waveOutWrite(sound->myWout, (WAVEHDR *) dwParam2, sizeof(WAVEHDR));
{ }
return true; }
} */
void SoundWinCE::update(void)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {
bool SoundWinCE::save(Serializer& out) for (int i=0; i<myBuffnum; i++)
{ if (myBuffers[i].dwFlags & WHDR_DONE)
return true; {
} processFragment((uInt8 *) myBuffers[i].lpData, 512);
waveOutWrite(myWout, &myBuffers[i], sizeof(WAVEHDR));
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
SoundWinCE::RegWriteQueue::RegWriteQueue(uInt32 capacity) }
: myCapacity(capacity), // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
myBuffer(0), bool SoundWinCE::load(Deserializer& in)
mySize(0), {
myHead(0), return true;
myTail(0) }
{
myBuffer = new RegWrite[myCapacity]; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
} bool SoundWinCE::save(Serializer& out)
{
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - return true;
SoundWinCE::RegWriteQueue::~RegWriteQueue() }
{
delete[] myBuffer; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
} SoundWinCE::RegWriteQueue::RegWriteQueue(uInt32 capacity)
: myCapacity(capacity),
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - myBuffer(0),
void SoundWinCE::RegWriteQueue::clear() mySize(0),
{ myHead(0),
myHead = myTail = mySize = 0; myTail(0)
} {
myBuffer = new RegWrite[myCapacity];
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
void SoundWinCE::RegWriteQueue::dequeue()
{ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(mySize > 0) SoundWinCE::RegWriteQueue::~RegWriteQueue()
{ {
myHead = (myHead + 1) % myCapacity; delete[] myBuffer;
--mySize; }
}
} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::RegWriteQueue::clear()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {
float SoundWinCE::RegWriteQueue::duration() myHead = myTail = mySize = 0;
{ }
float duration = 0.0;
for(uInt32 i = 0; i < mySize; ++i) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{ void SoundWinCE::RegWriteQueue::dequeue()
duration += myBuffer[(myHead + i) % myCapacity].delta; {
} if(mySize > 0)
return duration; {
} myHead = (myHead + 1) % myCapacity;
--mySize;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
void SoundWinCE::RegWriteQueue::enqueue(const RegWrite& info) }
{
if(mySize == myCapacity) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
grow(); float SoundWinCE::RegWriteQueue::duration()
myBuffer[myTail] = info; {
myTail = (myTail + 1) % myCapacity; float duration = 0.0;
++mySize; for(uInt32 i = 0; i < mySize; ++i)
} {
duration += myBuffer[(myHead + i) % myCapacity].delta;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
RegWrite& SoundWinCE::RegWriteQueue::front() return duration;
{ }
assert(mySize != 0);
return myBuffer[myHead]; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
} void SoundWinCE::RegWriteQueue::enqueue(const RegWrite& info)
{
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if(mySize == myCapacity)
uInt32 SoundWinCE::RegWriteQueue::size() const grow();
{ myBuffer[myTail] = info;
return mySize; myTail = (myTail + 1) % myCapacity;
} ++mySize;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundWinCE::RegWriteQueue::grow() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{ RegWrite& SoundWinCE::RegWriteQueue::front()
RegWrite* buffer = new RegWrite[myCapacity * 2]; {
for(uInt32 i = 0; i < mySize; ++i) assert(mySize != 0);
{ return myBuffer[myHead];
buffer[i] = myBuffer[(myHead + i) % myCapacity]; }
}
myHead = 0; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
myTail = mySize; uInt32 SoundWinCE::RegWriteQueue::size() const
myCapacity = myCapacity * 2; {
delete[] myBuffer; return mySize;
myBuffer = buffer; }
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#endif void SoundWinCE::RegWriteQueue::grow()
{
RegWrite* buffer = new RegWrite[myCapacity * 2];
for(uInt32 i = 0; i < mySize; ++i)
{
buffer[i] = myBuffer[(myHead + i) % myCapacity];
}
myHead = 0;
myTail = mySize;
myCapacity = myCapacity * 2;
delete[] myBuffer;
myBuffer = buffer;
}
#endif

View File

@ -1,86 +1,86 @@
#ifndef SOUNDWINCE_HXX #ifndef SOUNDWINCE_HXX
#define SOUNDWINCE_HXX #define SOUNDWINCE_HXX
#ifdef SOUND_SUPPORT #ifdef SOUND_SUPPORT
class OSystem; class OSystem;
#include "Sound.hxx" #include "Sound.hxx"
#include "bspf.hxx" #include "bspf.hxx"
#include "MediaSrc.hxx" #include "MediaSrc.hxx"
#include "TIASnd.hxx" #include "TIASnd.hxx"
struct RegWrite struct RegWrite
{ {
uInt16 addr; uInt16 addr;
uInt8 value; uInt8 value;
double delta; double delta;
}; };
class SoundWinCE : public Sound class SoundWinCE : public Sound
{ {
public: public:
SoundWinCE(OSystem* osystem); SoundWinCE(OSystem* osystem);
virtual ~SoundWinCE(); virtual ~SoundWinCE();
void setEnabled(bool state); void setEnabled(bool state);
void adjustCycleCounter(Int32 amount); void adjustCycleCounter(Int32 amount);
void setChannels(uInt32 channels); void setChannels(uInt32 channels);
void setFrameRate(uInt32 framerate); void setFrameRate(uInt32 framerate);
void initialize(); void initialize();
void close(); void close();
bool isSuccessfullyInitialized() const; bool isSuccessfullyInitialized() const;
void mute(bool state); void mute(bool state);
void reset(); void reset();
void set(uInt16 addr, uInt8 value, Int32 cycle); void set(uInt16 addr, uInt8 value, Int32 cycle);
void setVolume(Int32 percent); void setVolume(Int32 percent);
void adjustVolume(Int8 direction); void adjustVolume(Int8 direction);
bool load(Deserializer& in); bool load(Deserializer& in);
bool save(Serializer& out); bool save(Serializer& out);
void update(void); void update(void);
protected: protected:
void processFragment(uInt8* stream, Int32 length); void processFragment(uInt8* stream, Int32 length);
// Struct to hold information regarding a TIA sound register write // Struct to hold information regarding a TIA sound register write
class RegWriteQueue class RegWriteQueue
{ {
public: public:
RegWriteQueue(uInt32 capacity = 512); RegWriteQueue(uInt32 capacity = 512);
virtual ~RegWriteQueue(); virtual ~RegWriteQueue();
void clear(); void clear();
void dequeue(); void dequeue();
float duration(); float duration();
void enqueue(const RegWrite& info); void enqueue(const RegWrite& info);
RegWrite& front(); RegWrite& front();
uInt32 size() const; uInt32 size() const;
private: private:
void grow(); void grow();
private: private:
uInt32 myCapacity; uInt32 myCapacity;
RegWrite* myBuffer; RegWrite* myBuffer;
uInt32 mySize; uInt32 mySize;
uInt32 myHead; uInt32 myHead;
uInt32 myTail; uInt32 myTail;
}; };
private: private:
TIASound myTIASound; TIASound myTIASound;
bool myIsEnabled; bool myIsEnabled;
bool myIsInitializedFlag; bool myIsInitializedFlag;
Int32 myLastRegisterSetCycle; Int32 myLastRegisterSetCycle;
uInt32 myDisplayFrameRate; uInt32 myDisplayFrameRate;
uInt32 myNumChannels; uInt32 myNumChannels;
double myFragmentSizeLogBase2; double myFragmentSizeLogBase2;
bool myIsMuted; bool myIsMuted;
uInt32 myVolume; uInt32 myVolume;
RegWriteQueue myRegWriteQueue; RegWriteQueue myRegWriteQueue;
//static void CALLBACK SoundWinCE::waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2); //static void CALLBACK SoundWinCE::waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2);
int myLatency, myMixRate, myBuffnum; int myLatency, myMixRate, myBuffnum;
WAVEHDR *myBuffers; WAVEHDR *myBuffers;
HWAVEOUT myWout; HWAVEOUT myWout;
}; };
#endif // SOUND_SUPPORT #endif // SOUND_SUPPORT
#endif #endif

View File

@ -1,113 +1,146 @@
#include "bspf.hxx" #include "bspf.hxx"
#include "SDL.h" #include "SDL.h"
#include "gx.h" #include "gx.h"
char *msg = NULL; char *msg = NULL;
extern int EventHandlerState; int EventHandlerState;
int time(int dummy) int time(int dummy)
{ {
return GetTickCount(); return GetTickCount();
} }
char *getcwd(void) char *getcwd(void)
{ {
TCHAR fileUnc[MAX_PATH+1]; TCHAR fileUnc[MAX_PATH+1];
static char cwd[MAX_PATH+1] = ""; static char cwd[MAX_PATH+1] = "";
char *plast; char *plast;
// if(cwd[0] == 0) GetModuleFileName(NULL, fileUnc, MAX_PATH);
// { WideCharToMultiByte(CP_ACP, 0, fileUnc, -1, cwd, MAX_PATH, NULL, NULL);
GetModuleFileName(NULL, fileUnc, MAX_PATH); plast = strrchr(cwd, '\\');
WideCharToMultiByte(CP_ACP, 0, fileUnc, -1, cwd, MAX_PATH, NULL, NULL); if(plast)
plast = strrchr(cwd, '\\'); *plast = 0;
if(plast)
*plast = 0; return cwd;
}
// }
return cwd; struct key2event
} {
UINT keycode;
SDLKey sdlkey;
struct key2event uInt8 state;
{ SDLKey launcherkey;
UINT keycode; };
SDLKey sdlkey; key2event keycodes[2][MAX_KEYS];
uInt8 state;
SDLKey launcherkey; void KeySetup(void)
}; {
key2event keycodes[2][MAX_KEYS]; GXKeyList klist = GXGetDefaultKeys(GX_NORMALKEYS);
void KeySetup(void) for (int i=0; i<2; i++)
{ {
GXKeyList klist = GXGetDefaultKeys(GX_NORMALKEYS); for (int j=0; j<MAX_KEYS; j++, keycodes[i][j].state = 0,
keycodes[i][j].launcherkey = SDLK_UNKNOWN);
for (int i=0; i<2; i++)
{ keycodes[i][K_UP].keycode = klist.vkUp;
for (int j=0; j<MAX_KEYS; j++, keycodes[i][j].state = 0, keycodes[i][K_DOWN].keycode = klist.vkDown;
keycodes[i][j].launcherkey = SDLK_UNKNOWN); keycodes[i][K_LEFT].keycode = klist.vkLeft;
keycodes[i][K_RIGHT].keycode = klist.vkRight;
keycodes[i][K_UP].keycode = klist.vkUp; keycodes[i][K_FIRE].keycode = klist.vkA;
keycodes[i][K_DOWN].keycode = klist.vkDown; keycodes[i][K_RESET].keycode = klist.vkStart;
keycodes[i][K_LEFT].keycode = klist.vkLeft; keycodes[i][K_SELECT].keycode = klist.vkB;
keycodes[i][K_RIGHT].keycode = klist.vkRight; keycodes[i][K_QUIT].keycode = klist.vkC;
keycodes[i][K_FIRE].keycode = klist.vkA;
keycodes[i][K_RESET].keycode = klist.vkStart; keycodes[i][K_UP].sdlkey = SDLK_UP;
keycodes[i][K_SELECT].keycode = klist.vkB; keycodes[i][K_DOWN].sdlkey = SDLK_DOWN;
keycodes[i][K_QUIT].keycode = klist.vkC; keycodes[i][K_LEFT].sdlkey = SDLK_LEFT;
keycodes[i][K_RIGHT].sdlkey = SDLK_RIGHT;
keycodes[i][K_UP].sdlkey = SDLK_UP; keycodes[i][K_FIRE].sdlkey = SDLK_SPACE;
keycodes[i][K_DOWN].sdlkey = SDLK_DOWN; keycodes[i][K_RESET].sdlkey = SDLK_F2;
keycodes[i][K_LEFT].sdlkey = SDLK_LEFT; keycodes[i][K_SELECT].sdlkey = SDLK_F1;
keycodes[i][K_RIGHT].sdlkey = SDLK_RIGHT; keycodes[i][K_QUIT].sdlkey = SDLK_ESCAPE;
keycodes[i][K_FIRE].sdlkey = SDLK_SPACE;
keycodes[i][K_RESET].sdlkey = SDLK_F2; keycodes[i][K_UP].launcherkey = SDLK_UP;
keycodes[i][K_SELECT].sdlkey = SDLK_F1; keycodes[i][K_DOWN].launcherkey = SDLK_DOWN;
keycodes[i][K_QUIT].sdlkey = SDLK_q; keycodes[i][K_LEFT].launcherkey = SDLK_PAGEUP;
keycodes[i][K_RIGHT].launcherkey = SDLK_PAGEDOWN;
keycodes[i][K_UP].launcherkey = SDLK_UP; keycodes[i][K_RESET].launcherkey = SDLK_RETURN;
keycodes[i][K_DOWN].launcherkey = SDLK_DOWN; keycodes[i][K_QUIT].launcherkey = SDLK_ESCAPE;
keycodes[i][K_LEFT].launcherkey = SDLK_LEFT; }
keycodes[i][K_RIGHT].launcherkey = SDLK_RIGHT; }
keycodes[i][K_RESET].launcherkey = SDLK_RETURN;
} void KeySetMode(int mode)
} {
GXKeyList klist = GXGetDefaultKeys(GX_NORMALKEYS);
for (int i=0; i<2; i++)
// SDL {
DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags) { return 0xFFFFFFFF; } switch (mode)
DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable) { return 1; } {
DECLSPEC int SDLCALL SDL_Init(Uint32 flags) { return 1; } case 0:
DECLSPEC int SDLCALL SDL_ShowCursor(int toggle) { return 1; } keycodes[i][K_UP].keycode = klist.vkUp;
DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode) { return SDL_GRAB_ON; } keycodes[i][K_DOWN].keycode = klist.vkDown;
DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon) { return; } keycodes[i][K_LEFT].keycode = klist.vkLeft;
DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface) { return; } keycodes[i][K_RIGHT].keycode = klist.vkRight;
DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask) { return; } break;
DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { return NULL; }
DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y) { return; } case 2:
keycodes[i][K_UP].keycode = klist.vkRight;
DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event) keycodes[i][K_DOWN].keycode = klist.vkLeft;
{ keycodes[i][K_LEFT].keycode = klist.vkUp;
for (int i=0; i<MAX_KEYS; i++) keycodes[i][K_RIGHT].keycode = klist.vkDown;
{ break;
if (keycodes[0][i].state != keycodes[1][i].state)
{ case 1:
keycodes[1][i].state = keycodes[0][i].state; keycodes[i][K_UP].keycode = klist.vkLeft;
if (keycodes[1][i].state == 1) keycodes[i][K_DOWN].keycode = klist.vkRight;
event->type = event->key.type = SDL_KEYDOWN; keycodes[i][K_LEFT].keycode = klist.vkDown;
else keycodes[i][K_RIGHT].keycode = klist.vkUp;
event->type = event->key.type = SDL_KEYUP; break;
if (EventHandlerState == 0)
event->key.keysym.sym = keycodes[0][i].sdlkey; }
else }
event->key.keysym.sym = keycodes[0][i].launcherkey; }
event->key.keysym.mod = (SDLMod) 0;
event->key.keysym.unicode = 0; // SDL
return 1; DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags) { return 0xFFFFFFFF; }
} DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable) { return 1; }
} DECLSPEC int SDLCALL SDL_Init(Uint32 flags) { return 1; }
event->type = SDL_NOEVENT; DECLSPEC int SDLCALL SDL_ShowCursor(int toggle) { return 1; }
return 0; DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode) { return SDL_GRAB_ON; }
DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon) { return; }
DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface) { return; }
DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask) { return; }
DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { return NULL; }
DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y) { return; }
DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event)
{
for (int i=0; i<MAX_KEYS; i++)
{
if (keycodes[0][i].state != keycodes[1][i].state)
{
keycodes[1][i].state = keycodes[0][i].state;
if (i!=K_QUIT || EventHandlerState!=2)
{
if (keycodes[1][i].state == 1)
event->type = event->key.type = SDL_KEYDOWN;
else
event->type = event->key.type = SDL_KEYUP;
}
else if (keycodes[1][i].state == 1)
event->type = SDL_QUIT;
if (EventHandlerState != 2)
event->key.keysym.sym = keycodes[0][i].sdlkey;
else
event->key.keysym.sym = keycodes[0][i].launcherkey;
event->key.keysym.mod = (SDLMod) 0;
event->key.keysym.unicode = '\n'; // hack
return 1;
}
}
event->type = SDL_NOEVENT;
return 0;
} }

View File

@ -1,25 +1,25 @@
#ifndef _WCE_MISSING_H_ #ifndef _WCE_MISSING_H_
#define _WCE_MISSING_H_ #define _WCE_MISSING_H_
#include <windows.h> #include <windows.h>
/* WCE 300 does not support exception handling well */ /* WCE 300 does not support exception handling well */
#define try if (1) #define try if (1)
#define catch(a) else if (0) #define catch(a) else if (0)
extern char *msg; extern char *msg;
#define throw // #define throw //
#pragma warning(disable: 4800) #pragma warning(disable: 4800)
#pragma warning(disable: 4244) #pragma warning(disable: 4244)
#pragma warning(disable: 4786) #pragma warning(disable: 4786)
typedef unsigned int uintptr_t; typedef unsigned int uintptr_t;
int time(int dummy); int time(int dummy);
char *getcwd(void); char *getcwd(void);
#define MAX_KEYS 8 #define MAX_KEYS 8
enum key {K_UP = 0, K_DOWN, K_LEFT, K_RIGHT, K_FIRE, K_RESET, K_SELECT, K_QUIT}; enum key {K_UP = 0, K_DOWN, K_LEFT, K_RIGHT, K_FIRE, K_RESET, K_SELECT, K_QUIT};
#endif #endif

View File

@ -0,0 +1,72 @@
//Microsoft Developer Studio generated resource script.
//
#include "resrc1.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
/*
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
*/
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resrc1.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""resource.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_STELLA ICON DISCARDABLE "stella.ico"
//#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

16
stella/src/wince/resrc1.h Normal file
View File

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by resource.rc
//
#define IDI_ICON1 102
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

BIN
stella/src/wince/stella.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB