Full support for Pocket PCs. Smartphone port is also fully functional.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@863 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
knakos 2005-10-24 18:10:17 +00:00
parent d7272829ea
commit a22beb0451
12 changed files with 527 additions and 169 deletions

View File

@ -1,15 +1,33 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Windows CE Port by Kostas Nakos
//============================================================================
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <tchar.h>
//#include <direct.h>
#include "FSNode.hxx"
/*
* Implementation of the Stella file system API based on Windows API.
* Implementation of the Stella file system API based on Windows CE API.
* Modified from the Win32 version
*/
class WindowsFilesystemNode : public AbstractFilesystemNode
@ -54,21 +72,15 @@ static const char* lastPathComponent(const string& str)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static string validatePath(const string& p)
{
string path = p;
/* if(p.size() < 2 || p[1] != ':')
if (p.size() < 2) path = "\\";
path = "c:";
*/
return path;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
char* WindowsFilesystemNode::toAscii(TCHAR* x)
{
@ -142,7 +154,7 @@ WindowsFilesystemNode::WindowsFilesystemNode()
// Create a virtual root directory for standard Windows system
_isValid = false;
_path = "";
_path = "\\";
_isPseudoRoot = true;
}
@ -173,31 +185,6 @@ FSList WindowsFilesystemNode::listDir(ListMode mode) const
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;
@ -214,7 +201,6 @@ FSList WindowsFilesystemNode::listDir(ListMode mode) const
addFile(myList, mode, _path.c_str(), &desc);
FindClose(handle);
}
return myList;
}
@ -244,33 +230,22 @@ AbstractFilesystemNode* WindowsFilesystemNode::parent() const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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);
@ -280,18 +255,11 @@ bool AbstractFilesystemNode::dirExists(const string& path)
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);
@ -300,17 +268,11 @@ bool AbstractFilesystemNode::makeDir(const string& path)
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];
@ -318,12 +280,9 @@ string AbstractFilesystemNode::modTime(const string& path)
BOOL b = GetFileAttributesEx(unicodeString, GetFileExInfoStandard, &attr);
if(b == 0)
return "";
if(b == 0) return "";
ostringstream buf;
buf << attr.ftLastWriteTime.dwHighDateTime << attr.ftLastWriteTime.dwLowDateTime;
return buf.str();

View File

@ -1,3 +1,21 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Windows CE Port by Kostas Nakos
//============================================================================
#include <windows.h>
#include "FrameBufferWinCE.hxx"
#include "Console.hxx"
@ -64,13 +82,17 @@ bool FrameBufferWinCE::initSubsystem()
scrwidth = gxdp.cxWidth;
scrheight = gxdp.cyHeight;
scrpixelstep = gxdp.cbxPitch;
scrlinestep = gxdp.cbyPitch;
if (scrwidth == 176 && scrheight == 220)
issmartphone = true;
else
issmartphone = false;
islandscape = false;
/*islandscape = false;
setmode(0);
*/
setmode(displaymode);
SubsystemInited = false;
return true;
}
@ -107,7 +129,7 @@ void FrameBufferWinCE::setmode(uInt8 mode)
SubsystemInited = false;
}
int FrameBufferWinCE::rotatedisplay(void)
uInt8 FrameBufferWinCE::rotatedisplay(void)
{
displaymode = (displaymode + 1) % 3;
setmode(displaymode);
@ -186,10 +208,9 @@ void FrameBufferWinCE::preFrameUpdate()
void FrameBufferWinCE::drawMediaSource()
{
// TODO: define these static, also x & y
uInt8 *sc, *sp;
uInt8 *d, *pl;
uInt16 pix1, pix2;
static uInt8 *sc, *sp;
static uInt8 *d, *pl, *p;
static uInt16 pix1, pix2;
if (!SubsystemInited)
lateinit();
@ -202,6 +223,14 @@ void FrameBufferWinCE::drawMediaSource()
sc = myOSystem->console().mediaSource().currentFrameBuffer();
sp = myOSystem->console().mediaSource().previousFrameBuffer();
if (theRedrawTIAIndicator)
{
p = sp;
for (uInt16 y=0; y<myHeight; y++)
for (uInt16 x=0; x<myWidth; x += 4, *p = *p + 1, p += 4);
theRedrawTIAIndicator = false;
}
if (issmartphone && islandscape == 0)
{
// straight
@ -322,9 +351,8 @@ void FrameBufferWinCE::drawMediaSource()
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;
*((uInt16 *)d) = pix2; d += pixelstep;
}
else
{
@ -347,15 +375,14 @@ void FrameBufferWinCE::wipescreen(void)
if (!SubsystemInited)
lateinit();
if (&(myOSystem->console().mediaSource()) != NULL)
{
uInt8 *s = myOSystem->console().mediaSource().currentFrameBuffer();
memset(s, 0, myWidth*myHeight-1);
}
s = myOSystem->console().mediaSource().previousFrameBuffer();
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);
for (int i=0; i < scrwidth*scrheight; i++, *((uInt16 *)d) = 0, d += scrpixelstep);
GXEndDraw();
}
@ -378,33 +405,63 @@ void FrameBufferWinCE::drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32
c = desc.defaultchar;
}
const Int32 w = myfont->getCharWidth(c) >> 1;
Int32 w = myfont->getCharWidth(c);
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;
uInt8 *d;
uInt32 stride;
if (issmartphone)
{
d = myDstScreen + y * scrlinestep + ((x+1) >> 1) * scrpixelstep;
stride = (scrwidth - w) * scrpixelstep;
}
else
{
if (displaymode != 2)
d = myDstScreen + (scrheight-x-1) * scrlinestep + (y-1) * scrpixelstep;
else
d = myDstScreen + x * scrlinestep + (scrwidth-y-1) * scrpixelstep;
}
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;
if (issmartphone)
{
uInt16 mask = 0xC000;
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))
if (buffer & mask)
*((uInt16 *)d) = col;
d += pixelstep;
d += scrpixelstep;
}
d += stride;
}
else
{
uInt16 mask = 0x8000;
uInt8 *tmp = d;
for(int x2 = 0; x2 < w; x2++, mask >>= 1)
{
if (buffer & mask)
*((uInt16 *)d) = col;
if (displaymode != 2)
d -= scrlinestep;
else
d += scrlinestep;
}
if (displaymode != 2)
d = tmp + scrpixelstep;
else
d = tmp - scrpixelstep;
}
}
}
void FrameBufferWinCE::scanline(uInt32 row, uInt8* data)
@ -434,51 +491,83 @@ uInt32 FrameBufferWinCE::mapRGB(Uint8 r, Uint8 g, Uint8 b)
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 (issmartphone)
{
int kx = x >> 1; int ky = y; int kx2 = x2>> 1;
if (kx<0) kx=0; if (ky<0) ky=0; if (ky>scrheight-1) return; if (kx2>scrwidth-1) kx2=scrwidth-1;
PlothLine(kx, ky, kx2, color);
}
else
if (displaymode != 2)
PlotvLine(y, scrheight-x, scrheight-x2-1, color);
else
PlotvLine(scrwidth-y-1, x, x2+1, color);
}
uInt8 *d = myDstScreen + ky * linestep + kx * pixelstep;
void FrameBufferWinCE::PlothLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color)
{
if (!myDstScreen) return;
if (x>x2) { x2 ^= x; x ^= x2; x2 ^= x;} //lazy swap
uInt8 *d = myDstScreen + y * scrlinestep + x * scrpixelstep;
uInt16 col = guipal[((int) color) - 256];
for (;kx < kx2; kx++, *((uInt16 *)d) = col, d += pixelstep);
for (;x < x2; x++, *((uInt16 *)d) = col, d += scrpixelstep);
}
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 (issmartphone)
{
int kx = x >> 1; int ky = y; int ky2 = y2;
if (kx<0) kx=0; if (ky<0) ky=0; if (kx>scrwidth-1) return; if (ky2>scrheight-1) ky2=scrheight-1;
PlotvLine(kx, ky, ky2, color);
}
else
if (displaymode != 2)
PlothLine(y, scrheight-x-1, y2, color);
else
PlothLine(scrwidth-y, x, scrwidth-y2, color);
uInt8 *d = myDstScreen + ky * linestep + kx * pixelstep;
}
void FrameBufferWinCE::PlotvLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color)
{
if (y>y2) { y2 ^= y; y ^= y2; y2 ^= y;} //lazy swap
if (!myDstScreen) return;
uInt8 *d = myDstScreen + y * scrlinestep + x * scrpixelstep;
uInt16 col = guipal[((int) color) - 256];
for (;ky < ky2; ky++, *((uInt16 *)d) = col, d += linestep);
for (;y < y2; y++, *((uInt16 *)d) = col, d += scrlinestep);
}
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 (issmartphone)
{
int kx = x >> 1; int ky = y; int kw = (w >> 1); int kh = h;
if (ky>scrheight-1) return; if (kx>scrwidth-1) 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;
PlotfillRect(kx, ky, kw, kh, color);
}
else
{
if (x>scrheight) return; if (y>scrwidth) return;
if (x+w>scrheight) w=scrheight-x; if (y+h>scrwidth) h=scrwidth-y;
if (displaymode != 2)
PlotfillRect(y, scrheight-x-w, h-1, w-1, color);
else
PlotfillRect(scrwidth-y-h, x, h-1, w-1, color);
}
uInt8 *d = myDstScreen + ky * linestep + kx * pixelstep;
}
void FrameBufferWinCE::PlotfillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor color)
{
if (!myDstScreen) return;
uInt8 *d = myDstScreen + y * scrlinestep + x * scrpixelstep;
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;
}
uInt32 stride = (scrwidth - w - 1) * scrpixelstep;
for (h++; h != 0; h--, d += stride)
for (int w2=w; w2>=0; w2--, *((uInt16 *)d) = col, d += scrpixelstep);
}
void FrameBufferWinCE::drawBitmap(uInt32* bitmap, Int32 x, Int32 y, OverlayColor color, Int32 h)
@ -488,11 +577,37 @@ void FrameBufferWinCE::drawBitmap(uInt32* bitmap, Int32 x, Int32 y, OverlayColor
void FrameBufferWinCE::translateCoords(Int32* x, Int32* y)
{
if (!issmartphone)
{
if ((displaymode == 1) || (displaymode==0 && myOSystem->eventHandler().state() != 1))
{
Int32 x2 = *x;
*x = scrheight - *y;
*y = x2;
}
else if (displaymode == 2)
{
Int32 x2 = *x;
*x = *y;
*y = scrwidth - x2;
}
}
return;
}
void FrameBufferWinCE::addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h)
{
static bool initflag = false;
if (myOSystem->eventHandler().state() == 3)
initflag = true;
if (myOSystem->eventHandler().state()==1 && initflag)
{
// TODO: optimize here
theRedrawTIAIndicator = true;
}
return;
}

View File

@ -1,3 +1,21 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Windows CE Port by Kostas Nakos
//============================================================================
#ifndef FRAMEBUFFER_WINCE_HXX
#define FRAMEBUFFER_WINCE_HXX
@ -32,16 +50,17 @@ class FrameBufferWinCE : public FrameBuffer
virtual uInt32 lineDim();
void wipescreen(void);
void setmode(uInt8 mode);
int rotatedisplay(void);
uInt8 rotatedisplay(void);
private:
void FrameBufferWinCE::lateinit(void);
void lateinit(void);
void PlothLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color);
void PlotvLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color);
void PlotfillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor color);
// uInt32 myXstart, myYstart;
// uInt8 *currentFrame, *previousFrame;
uInt16 pal[256], myWidth, myHeight, guipal[kNumColors-256], scrwidth, scrheight;
Int32 pixelstep, linestep;
Int32 pixelstep, linestep, scrpixelstep, scrlinestep;
uInt32 displacement;
bool SubsystemInited;
uInt8 *myDstScreen;
@ -51,6 +70,10 @@ class FrameBufferWinCE : public FrameBuffer
Int32 pixelsteptimes5, pixelsteptimes6;
GXDisplayProperties gxdp;
uInt8 displaymode;
public:
bool IsSmartphone(void) { return issmartphone; }
uInt8 getmode(void) { return displaymode; }
};
#endif

View File

@ -1,3 +1,21 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Windows CE Port by Kostas Nakos
//============================================================================
#include <sstream>
#include <fstream>
@ -6,9 +24,11 @@
#include "OSystemWinCE.hxx"
#include "SoundWinCE.hxx"
#include "FrameBufferWinCE.hxx"
//#include <sstream>
extern void KeyCheck(void);
extern int EventHandlerState;
extern void KeySetMode(int);
extern bool RequestRefresh;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OSystemWinCE::OSystemWinCE()
@ -16,7 +36,7 @@ OSystemWinCE::OSystemWinCE()
string basedir = ((string) getcwd()) + '\\';
setBaseDir(basedir);
string stateDir = basedir;// + "state\\";
string stateDir = basedir;
setStateDir(stateDir);
setPropertiesDir(basedir, basedir);
@ -46,6 +66,7 @@ void OSystemWinCE::mainLoop()
uInt32 frameTime = 0, numberOfFrames = 0;
uInt32 startTime, virtualTime, currentTime;
uInt8 lastkeyset;
virtualTime = GetTickCount();
frameTime = 0;
@ -53,6 +74,11 @@ void OSystemWinCE::mainLoop()
// Main game loop
MSG msg;
int laststate = -1;
if (!((FrameBufferWinCE *)myFrameBuffer)->IsSmartphone())
{
lastkeyset = 0;
KeySetMode(1);
}
for(;;)
{
while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
@ -70,11 +96,35 @@ void OSystemWinCE::mainLoop()
KeyCheck();
if (RequestRefresh)
{
RequestRefresh = false;
myEventHandler->refreshDisplay();
}
startTime = GetTickCount();
EventHandlerState = (int) myEventHandler->state();
if ((laststate != -1) && (laststate != EventHandlerState) && (EventHandlerState != 2))
if ((laststate != -1) && (laststate != EventHandlerState))
if (EventHandlerState!=2 && EventHandlerState!=3)
{
((FrameBufferWinCE *)myFrameBuffer)->wipescreen();
KeySetMode(lastkeyset);
}
else
{
if ( ((FrameBufferWinCE *)myFrameBuffer)->IsSmartphone() )
{
KeySetMode(0);
((FrameBufferWinCE *)myFrameBuffer)->setmode(0);
}
else
{
lastkeyset = ((FrameBufferWinCE *)myFrameBuffer)->getmode();
if (lastkeyset == 0)
KeySetMode(1);
}
}
laststate = EventHandlerState;
myEventHandler->poll(startTime);

View File

@ -1,3 +1,21 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Windows CE Port by Kostas Nakos
//============================================================================
#ifndef OSYSTEM_WINCE_HXX
#define OSYSTEM_WINCE_HXX

View File

@ -1,3 +1,21 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Windows CE Port by Kostas Nakos
//============================================================================
#include <windows.h>
#include "EventHandler.hxx"
#include "OSystemWinCE.hxx"
@ -12,12 +30,13 @@ struct key2event
{
UINT keycode;
SDLKey sdlkey;
uInt8 state;
uInt32 state;
SDLKey launcherkey;
};
extern key2event keycodes[2][MAX_KEYS];
extern key2event keycodes[2][MAX_KEYS+NUM_MOUSEKEYS];
extern void KeySetup(void);
extern void KeySetMode(int);
bool RequestRefresh = false;
OSystemWinCE* theOSystem = (OSystemWinCE*) NULL;
HWND hWnd;
@ -54,6 +73,8 @@ void CleanUp(void)
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static PAINTSTRUCT ps;
switch (uMsg)
{
case WM_KEYDOWN:
@ -81,6 +102,18 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
#endif
return 0;
case WM_MOUSEMOVE:
keycodes[0][M_POS].state = lParam;
return 0;
case WM_LBUTTONDOWN:
keycodes[0][M_BUT].state = lParam | 0x80000000;
return 0;
case WM_LBUTTONUP:
keycodes[0][M_BUT].state = lParam & 0x7FFFFFFF;
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
@ -91,12 +124,18 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
case WM_SETFOCUS:
case WM_ACTIVATE:
GXSuspend();
GXResume();
return 0;
case WM_KILLFOCUS:
case WM_HIBERNATE:
GXResume();
GXSuspend();
return 0;
case WM_PAINT:
BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
RequestRefresh = true;
return 0;
}
@ -109,11 +148,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLin
WNDCLASS wc = { CS_HREDRAW | CS_VREDRAW, WindowProc, 0, 0, hInstance, NULL, NULL,
(HBRUSH)GetStockObject(BLACK_BRUSH), NULL, wndname};
RegisterClass(&wc);
hWnd = CreateWindow(wndname, wndname, WS_VISIBLE, 0, 0, GetSystemMetrics(SM_CXSCREEN),
hWnd = CreateWindow(wndname, wndname, WS_VISIBLE | WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL);
if (!hWnd) return 1;
SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
// pump the messages to get the window up
MSG msg;
while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{

View File

@ -1,3 +1,21 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Windows CE Port by Kostas Nakos
//============================================================================
#include <sstream>
#include <fstream>

View File

@ -1,3 +1,21 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Windows CE Port by Kostas Nakos
//============================================================================
#ifndef SETTINGS_WINCE_HXX
#define SETTINGS_WINCE_HXX

View File

@ -1,3 +1,21 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Windows CE Port by Kostas Nakos
//============================================================================
#ifdef SOUND_SUPPORT
#include "TIASnd.hxx"
@ -288,6 +306,7 @@ void SoundWinCE::processFragment(uInt8* stream, Int32 length)
*/
void SoundWinCE::update(void)
{
if (myIsMuted) return;
for (int i=0; i<myBuffnum; i++)
if (myBuffers[i].dwFlags & WHDR_DONE)
{

View File

@ -1,3 +1,21 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Windows CE Port by Kostas Nakos
//============================================================================
#ifndef SOUNDWINCE_HXX
#define SOUNDWINCE_HXX

View File

@ -1,9 +1,30 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Windows CE Port by Kostas Nakos
//============================================================================
#include "bspf.hxx"
#include "SDL.h"
#include "gx.h"
//#include "gx.h"
#include "OSystemWinCE.hxx"
#include "FrameBufferWinCE.hxx"
char *msg = NULL;
int EventHandlerState;
extern OSystemWinCE *theOSystem;
int time(int dummy)
{
@ -30,10 +51,10 @@ struct key2event
{
UINT keycode;
SDLKey sdlkey;
uInt8 state;
uInt32 state;
SDLKey launcherkey;
};
key2event keycodes[2][MAX_KEYS];
key2event keycodes[2][MAX_KEYS+NUM_MOUSEKEYS];
void KeySetup(void)
{
@ -41,7 +62,7 @@ void KeySetup(void)
for (int i=0; i<2; i++)
{
for (int j=0; j<MAX_KEYS; j++, keycodes[i][j].state = 0,
for (int j=0; j<MAX_KEYS+NUM_MOUSEKEYS; j++, keycodes[i][j].state = 0,
keycodes[i][j].launcherkey = SDLK_UNKNOWN);
keycodes[i][K_UP].keycode = klist.vkUp;
@ -118,26 +139,65 @@ 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++)
for (int i=0; i<MAX_KEYS+NUM_MOUSEKEYS; 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 (i < MAX_KEYS)
{
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
}
else if (i == M_POS)
{
event->type = SDL_MOUSEMOTION;
event->motion.x = LOWORD(keycodes[0][M_POS].state);
event->motion.y = HIWORD(keycodes[0][M_POS].state);
}
else
{
if (keycodes[0][M_BUT].state & 0x80000000)
event->type = event->button.type = SDL_MOUSEBUTTONDOWN;
else
event->type = SDL_MOUSEBUTTONUP;
event->motion.x = LOWORD(keycodes[0][M_BUT].state);
event->motion.y = HIWORD(keycodes[0][M_BUT].state & 0x7FFFFFFF);
event->button.button = SDL_BUTTON_LEFT;
if (event->type==SDL_MOUSEBUTTONDOWN && event->motion.x>220 && event->motion.y>300 && EventHandlerState!=2)
{
// bottom right corner for rotate
KeySetMode( ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->rotatedisplay() );
event->type = SDL_NOEVENT;
}
else if (event->type==SDL_MOUSEBUTTONDOWN && event->motion.x<20 && event->motion.y>300 && EventHandlerState!=2)
{
// bottom left corner for launcher
keycodes[0][K_QUIT].state = 1;
event->type = SDL_NOEVENT;
}
else if (event->type==SDL_MOUSEBUTTONDOWN && event->motion.x<20 && event->motion.y<20 && EventHandlerState!=2 && EventHandlerState!=3)
{
// top left for menu
theOSystem->eventHandler().enterMenuMode();
}
}
}
else if (keycodes[1][i].state == 1)
event->type = SDL_QUIT;
return 1;
}
}

View File

@ -1,9 +1,28 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// Windows CE Port by Kostas Nakos
//============================================================================
#ifndef _WCE_MISSING_H_
#define _WCE_MISSING_H_
#include <windows.h>
/* WCE 300 does not support exception handling well */
// WCE 300 does not support exception handling well
// so we remove all catch blocks
#define try if (1)
#define catch(a) else if (0)
extern char *msg;
@ -20,6 +39,7 @@ char *getcwd(void);
#define MAX_KEYS 8
enum key {K_UP = 0, K_DOWN, K_LEFT, K_RIGHT, K_FIRE, K_RESET, K_SELECT, K_QUIT};
#define NUM_MOUSEKEYS 2
enum key {K_UP = 0, K_DOWN, K_LEFT, K_RIGHT, K_FIRE, K_RESET, K_SELECT, K_QUIT, M_POS, M_BUT};
#endif