mirror of https://github.com/stella-emu/stella.git
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:
parent
330c27224c
commit
00b702cdc0
|
@ -1,12 +1,14 @@
|
|||
#include <windows.h>
|
||||
#include <gx.h>
|
||||
#include "FrameBufferWinCE.hxx"
|
||||
#include "Console.hxx"
|
||||
#include "OSystem.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)
|
||||
: FrameBuffer(osystem), myDstScreen(NULL), SubsystemInited(false), displacement(0),
|
||||
issmartphone(true), islandscape(false), displaymode(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -17,7 +19,7 @@ FrameBufferWinCE::~FrameBufferWinCE()
|
|||
void FrameBufferWinCE::setPalette(const uInt32* palette)
|
||||
{
|
||||
//setup palette
|
||||
GXDisplayProperties gxdp = GXGetDisplayProperties();
|
||||
gxdp = GXGetDisplayProperties();
|
||||
for (uInt16 i=0; i<256; i++)
|
||||
{
|
||||
uInt8 r = (uInt8) ((palette[i] & 0xFF0000) >> 16);
|
||||
|
@ -35,7 +37,7 @@ void FrameBufferWinCE::setPalette(const uInt32* palette)
|
|||
|
||||
bool FrameBufferWinCE::initSubsystem()
|
||||
{
|
||||
GXDisplayProperties gxdp = GXGetDisplayProperties();
|
||||
gxdp = GXGetDisplayProperties();
|
||||
for (int i=0; i<kNumColors - 256; i++)
|
||||
{
|
||||
uInt8 r = (ourGUIColors[i][0] & 0xFF);
|
||||
|
@ -49,26 +51,130 @@ bool FrameBufferWinCE::initSubsystem()
|
|||
return false;
|
||||
}
|
||||
// screen extents
|
||||
//GXDisplayProperties gxdp = GXGetDisplayProperties();
|
||||
pixelstep = gxdp.cbxPitch;
|
||||
linestep = gxdp.cbyPitch;
|
||||
if(gxdp.ffFormat & kfDirect565)
|
||||
{
|
||||
optgreenmask = 0x7E0;
|
||||
optgreenmaskN = 0xF81F;
|
||||
}
|
||||
else
|
||||
{
|
||||
optgreenmask = 0x3E0;
|
||||
optgreenmaskN = 0x7C1F;
|
||||
}
|
||||
|
||||
scrwidth = gxdp.cxWidth;
|
||||
scrheight = gxdp.cyHeight;
|
||||
if (scrwidth == 176 && scrheight == 220)
|
||||
issmartphone = true;
|
||||
else
|
||||
issmartphone = false;
|
||||
islandscape = false;
|
||||
setmode(0);
|
||||
|
||||
SubsystemInited = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrameBufferWinCE::setmode(uInt8 mode)
|
||||
{
|
||||
displaymode = mode % 3;
|
||||
switch (displaymode)
|
||||
{
|
||||
// portrait
|
||||
case 0:
|
||||
pixelstep = gxdp.cbxPitch;
|
||||
linestep = gxdp.cbyPitch;
|
||||
islandscape = false;
|
||||
break;
|
||||
|
||||
// landscape
|
||||
case 1:
|
||||
pixelstep = - gxdp.cbyPitch;
|
||||
linestep = gxdp.cbxPitch;
|
||||
islandscape = true;
|
||||
break;
|
||||
|
||||
// inverted landscape
|
||||
case 2:
|
||||
pixelstep = gxdp.cbyPitch;
|
||||
linestep = - gxdp.cbxPitch;
|
||||
islandscape = true;
|
||||
break;
|
||||
}
|
||||
|
||||
pixelsteptimes5 = pixelstep * 5;
|
||||
pixelsteptimes6 = pixelstep * 6;
|
||||
SubsystemInited = false;
|
||||
}
|
||||
|
||||
int FrameBufferWinCE::rotatedisplay(void)
|
||||
{
|
||||
displaymode = (displaymode + 1) % 3;
|
||||
setmode(displaymode);
|
||||
wipescreen();
|
||||
return displaymode;
|
||||
}
|
||||
|
||||
void FrameBufferWinCE::lateinit(void)
|
||||
{
|
||||
int w;
|
||||
myWidth = myOSystem->console().mediaSource().width();
|
||||
myHeight = myOSystem->console().mediaSource().height();
|
||||
if (scrwidth > myWidth)
|
||||
displacement = (scrwidth - myWidth) / 2 * pixelstep;
|
||||
|
||||
if (issmartphone)
|
||||
if (!islandscape)
|
||||
w = myWidth;
|
||||
else
|
||||
w = (int) ((float) myWidth * 11.0 / 8.0 + 0.5);
|
||||
else
|
||||
displacement = 0;
|
||||
if (scrheight > myHeight)
|
||||
displacement += (scrheight - myHeight) / 2 * linestep;
|
||||
if (!islandscape)
|
||||
w = (int) ((float) myWidth * 3.0 / 2.0 + 0.5);
|
||||
else
|
||||
w = myWidth * 2;
|
||||
|
||||
switch (displaymode)
|
||||
{
|
||||
case 0:
|
||||
if (scrwidth > w)
|
||||
displacement = (scrwidth - w) / 2 * gxdp.cbxPitch;
|
||||
else
|
||||
displacement = 0;
|
||||
if (scrheight > myHeight)
|
||||
{
|
||||
displacement += (scrheight - myHeight) / 2 * gxdp.cbyPitch;
|
||||
minydim = myHeight;
|
||||
}
|
||||
else
|
||||
minydim = scrheight;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
displacement = gxdp.cbyPitch*(gxdp.cyHeight-1);
|
||||
if (scrwidth > myHeight)
|
||||
{
|
||||
minydim = myHeight;
|
||||
displacement += (scrwidth - myHeight) / 2 * gxdp.cbxPitch;
|
||||
}
|
||||
else
|
||||
minydim = scrwidth;
|
||||
if (scrheight > w)
|
||||
displacement -= (scrheight - w) / 2 * gxdp.cbyPitch;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
displacement = gxdp.cbxPitch*(gxdp.cxWidth-1);
|
||||
if (scrwidth > myHeight)
|
||||
{
|
||||
minydim = myHeight;
|
||||
displacement -= (scrwidth - myHeight) / 2 * gxdp.cbxPitch;
|
||||
}
|
||||
else
|
||||
minydim = scrwidth;
|
||||
if (scrheight > w)
|
||||
displacement += (scrheight - w) / 2 * gxdp.cbyPitch;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
SubsystemInited = true;
|
||||
}
|
||||
|
@ -80,14 +186,13 @@ void FrameBufferWinCE::preFrameUpdate()
|
|||
|
||||
void FrameBufferWinCE::drawMediaSource()
|
||||
{
|
||||
// TODO: define these static, also x & y
|
||||
uInt8 *sc, *sp;
|
||||
uInt8 *d, *pl;
|
||||
uInt16 pix1, pix2;
|
||||
|
||||
if (!SubsystemInited)
|
||||
{
|
||||
lateinit();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (d = myDstScreen) == NULL )
|
||||
return;
|
||||
|
@ -96,27 +201,162 @@ void FrameBufferWinCE::drawMediaSource()
|
|||
pl = d;
|
||||
sc = myOSystem->console().mediaSource().currentFrameBuffer();
|
||||
sp = myOSystem->console().mediaSource().previousFrameBuffer();
|
||||
for (uInt16 y=0; y<myHeight; y++)
|
||||
|
||||
if (issmartphone && islandscape == 0)
|
||||
{
|
||||
for (uInt16 x=0; x<(myWidth>>2); x++)
|
||||
// straight
|
||||
for (uInt16 y=0; y<myHeight; y++)
|
||||
{
|
||||
if ( *((uInt32 *) sc) != *((uInt32 *) sp) )
|
||||
for (uInt16 x=0; x<(myWidth>>2); x++)
|
||||
{
|
||||
*((uInt16 *)d) = pal[*sc++]; d += pixelstep;
|
||||
*((uInt16 *)d) = pal[*sc++]; d += pixelstep;
|
||||
*((uInt16 *)d) = pal[*sc++]; d += pixelstep;
|
||||
*((uInt16 *)d) = pal[*sc++]; d += pixelstep;
|
||||
if ( *((uInt32 *) sc) != *((uInt32 *) sp) )
|
||||
{
|
||||
*((uInt16 *)d) = pal[*sc++]; d += pixelstep;
|
||||
*((uInt16 *)d) = pal[*sc++]; d += pixelstep;
|
||||
*((uInt16 *)d) = pal[*sc++]; d += pixelstep;
|
||||
*((uInt16 *)d) = pal[*sc++]; d += pixelstep;
|
||||
}
|
||||
else
|
||||
{
|
||||
sc += 4;
|
||||
d += (pixelstep << 2);
|
||||
}
|
||||
sp += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
sc += 4;
|
||||
d += (pixelstep << 2);
|
||||
}
|
||||
sp += 4;
|
||||
d = pl + linestep;
|
||||
pl = d;
|
||||
}
|
||||
d = pl + linestep;
|
||||
pl = d;
|
||||
}
|
||||
else if (issmartphone && islandscape)
|
||||
{
|
||||
for (uInt16 y=0; y<minydim; y++)
|
||||
{
|
||||
for (uInt16 x=0; x<(myWidth>>2); x++)
|
||||
{
|
||||
// 11/8
|
||||
// **X**
|
||||
if ( *((uInt32 *) sc) != *((uInt32 *) sp) )
|
||||
{
|
||||
*((uInt16 *)d) = pal[*sc++]; 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;
|
||||
*((uInt16 *)d) = pal[*sc++]; d += pixelstep;
|
||||
}
|
||||
else
|
||||
{
|
||||
sc += 4;
|
||||
d += pixelsteptimes5;
|
||||
}
|
||||
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()
|
||||
|
@ -130,7 +370,6 @@ void FrameBufferWinCE::drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32
|
|||
const FontDesc& desc = myfont->desc();
|
||||
|
||||
if (!myDstScreen) return;
|
||||
//if (!SubsystemInited) {lateinit(false); return;}
|
||||
|
||||
if(c < desc.firstchar || c >= desc.firstchar + desc.size)
|
||||
{
|
||||
|
@ -139,26 +378,29 @@ void FrameBufferWinCE::drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32
|
|||
c = desc.defaultchar;
|
||||
}
|
||||
|
||||
const Int32 w = myfont->getCharWidth(c);
|
||||
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 >>= 1)
|
||||
for(int x2 = 0; x2 < w; x2++, mask >>= 2)
|
||||
{
|
||||
if ((buffer & mask) != 0)
|
||||
{
|
||||
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;
|
||||
|
@ -193,36 +435,38 @@ uInt32 FrameBufferWinCE::mapRGB(Uint8 r, Uint8 g, Uint8 b)
|
|||
void FrameBufferWinCE::hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color)
|
||||
{
|
||||
if (!myDstScreen) return;
|
||||
//if (!SubsystemInited) {lateinit(false); 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;
|
||||
}
|
||||
for (;kx < kx2; kx++, *((uInt16 *)d) = col, d += pixelstep);
|
||||
}
|
||||
|
||||
void FrameBufferWinCE::vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color)
|
||||
{
|
||||
if (!myDstScreen) return;
|
||||
//if (!SubsystemInited) {lateinit(false); return;}
|
||||
int kx = x >> 1; int ky = y/* >> 1*/; int ky2 = y2>> 1;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
//if (!SubsystemInited) {lateinit(false); 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;
|
||||
|
@ -251,3 +495,10 @@ void FrameBufferWinCE::addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h)
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uInt32 FrameBufferWinCE::lineDim()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef FRAMEBUFFER_WINCE_HXX
|
||||
#define FRAMEBUFFER_WINCE_HXX
|
||||
|
||||
#include <gx.h>
|
||||
#include "bspf.hxx"
|
||||
#include "FrameBuffer.hxx"
|
||||
#include "OSystem.hxx"
|
||||
|
@ -28,6 +29,10 @@ class FrameBufferWinCE : public FrameBuffer
|
|||
virtual void drawBitmap(uInt32* bitmap, Int32 x, Int32 y, OverlayColor color, Int32 h = 8);
|
||||
virtual void translateCoords(Int32* x, Int32* y);
|
||||
virtual void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h);
|
||||
virtual uInt32 lineDim();
|
||||
void wipescreen(void);
|
||||
void setmode(uInt8 mode);
|
||||
int rotatedisplay(void);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -36,9 +41,16 @@ class FrameBufferWinCE : public FrameBuffer
|
|||
// uInt32 myXstart, myYstart;
|
||||
// uInt8 *currentFrame, *previousFrame;
|
||||
uInt16 pal[256], myWidth, myHeight, guipal[kNumColors-256], scrwidth, scrheight;
|
||||
uInt32 pixelstep, linestep, displacement;
|
||||
Int32 pixelstep, linestep;
|
||||
uInt32 displacement;
|
||||
bool SubsystemInited;
|
||||
uInt8 *myDstScreen;
|
||||
|
||||
bool issmartphone, islandscape;
|
||||
uInt16 minydim, optgreenmaskN, optgreenmask;
|
||||
Int32 pixelsteptimes5, pixelsteptimes6;
|
||||
GXDisplayProperties gxdp;
|
||||
uInt8 displaymode;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -5,9 +5,10 @@
|
|||
#include "OSystem.hxx"
|
||||
#include "OSystemWinCE.hxx"
|
||||
#include "SoundWinCE.hxx"
|
||||
#include "FrameBufferWinCE.hxx"
|
||||
//#include <sstream>
|
||||
extern void KeyCheck(void);
|
||||
int EventHandlerState;
|
||||
extern int EventHandlerState;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
OSystemWinCE::OSystemWinCE()
|
||||
|
@ -15,7 +16,7 @@ OSystemWinCE::OSystemWinCE()
|
|||
string basedir = ((string) getcwd()) + '\\';
|
||||
setBaseDir(basedir);
|
||||
|
||||
string stateDir = basedir + "state\\";
|
||||
string stateDir = basedir;// + "state\\";
|
||||
setStateDir(stateDir);
|
||||
|
||||
setPropertiesDir(basedir, basedir);
|
||||
|
@ -43,19 +44,15 @@ void OSystemWinCE::setFramerate(uInt32 framerate)
|
|||
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;
|
||||
|
||||
// Set up less accurate timing stuff
|
||||
uInt32 startTime, virtualTime, currentTime;
|
||||
|
||||
// Set the base for the timers
|
||||
virtualTime = GetTickCount();
|
||||
frameTime = 0;
|
||||
|
||||
// Main game loop
|
||||
MSG msg;
|
||||
int laststate = -1;
|
||||
for(;;)
|
||||
{
|
||||
while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
||||
|
@ -76,6 +73,10 @@ void OSystemWinCE::mainLoop()
|
|||
startTime = GetTickCount();
|
||||
|
||||
EventHandlerState = (int) myEventHandler->state();
|
||||
if ((laststate != -1) && (laststate != EventHandlerState) && (EventHandlerState != 2))
|
||||
((FrameBufferWinCE *)myFrameBuffer)->wipescreen();
|
||||
laststate = EventHandlerState;
|
||||
|
||||
myEventHandler->poll(startTime);
|
||||
myFrameBuffer->update();
|
||||
((SoundWinCE *)mySound)->update();
|
||||
|
@ -84,6 +85,8 @@ void OSystemWinCE::mainLoop()
|
|||
virtualTime += myTimePerFrame;
|
||||
if(currentTime < virtualTime)
|
||||
Sleep(virtualTime - currentTime);
|
||||
else
|
||||
virtualTime = currentTime;
|
||||
|
||||
currentTime = GetTickCount() - startTime;
|
||||
frameTime += currentTime;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <windows.h>
|
||||
#include <gx.h>
|
||||
#include "EventHandler.hxx"
|
||||
#include "OSystemWinCE.hxx"
|
||||
#include "SettingsWinCE.hxx"
|
||||
#include "PropsSet.hxx"
|
||||
#include "FSNode.hxx"
|
||||
#include "FrameBufferWinCE.hxx"
|
||||
|
||||
#define KEYSCHECK_ASYNC
|
||||
|
||||
|
@ -17,20 +17,30 @@ struct key2event
|
|||
};
|
||||
extern key2event keycodes[2][MAX_KEYS];
|
||||
extern void KeySetup(void);
|
||||
extern void KeySetMode(int);
|
||||
|
||||
OSystemWinCE* theOSystem = (OSystemWinCE*) NULL;
|
||||
HWND hWnd;
|
||||
uInt16 rotkeystate = 0;
|
||||
|
||||
|
||||
void KeyCheck(void)
|
||||
{
|
||||
#ifdef KEYSCHECK_ASYNC
|
||||
if (GetAsyncKeyState(keycodes[0][K_QUIT].keycode) & 0x8000)
|
||||
if (GetAsyncKeyState(VK_F3))
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
return;
|
||||
if (rotkeystate == 0)
|
||||
KeySetMode( ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->rotatedisplay() );
|
||||
rotkeystate = 1;
|
||||
}
|
||||
for (int i=0; i<MAX_KEYS-1; i++)
|
||||
keycodes[0][i].state = ((uInt16) GetAsyncKeyState(keycodes[0][i].keycode)) >> 15;
|
||||
else
|
||||
rotkeystate = 0;
|
||||
|
||||
for (int i=0; i<MAX_KEYS; i++)
|
||||
if (GetAsyncKeyState(keycodes[0][i].keycode))
|
||||
keycodes[0][i].state = 1;
|
||||
else
|
||||
keycodes[0][i].state = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -44,33 +54,30 @@ void CleanUp(void)
|
|||
|
||||
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
static PAINTSTRUCT ps;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_KEYDOWN:
|
||||
if (wParam == VK_F3)
|
||||
{
|
||||
if (rotkeystate == 0)
|
||||
KeySetMode( ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->rotatedisplay() );
|
||||
rotkeystate = 1;
|
||||
}
|
||||
else
|
||||
rotkeystate = 0;
|
||||
#ifndef KEYSCHECK_ASYNC
|
||||
uInt8 i;
|
||||
if (wParam == keycodes[K_QUIT].keycode)
|
||||
PostQuitMessage(0);
|
||||
else
|
||||
for (i=0; i<MAX_KEYS-1; i++)
|
||||
if (wParam == keycodes[i].keycode)
|
||||
{
|
||||
theConsole->eventHandler().event()->set(keycodes[i].event,1);
|
||||
break;
|
||||
}
|
||||
for (i=0; i<MAX_KEYS; i++)
|
||||
if (wParam == keycodes[0][i].keycode)
|
||||
keycodes[0][i].state = 1;
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
case WM_KEYUP:
|
||||
#ifndef KEYSCHECK_ASYNC
|
||||
for (i=0; i<MAX_KEYS-1; i++)
|
||||
if (wParam == keycodes[i].keycode)
|
||||
{
|
||||
theConsole->eventHandler().event()->set(keycodes[i].event,0);
|
||||
break;
|
||||
}
|
||||
for (i=0; i<MAX_KEYS; i++)
|
||||
if (wParam == keycodes[0][i].keycode)
|
||||
keycodes[0][i].state = 0;
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
|
@ -91,13 +98,8 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|||
case WM_HIBERNATE:
|
||||
GXResume();
|
||||
return 0;
|
||||
|
||||
case WM_PAINT:
|
||||
BeginPaint(hWnd, &ps);
|
||||
EndPaint(hWnd, &ps);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
@ -110,7 +112,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLin
|
|||
hWnd = CreateWindow(wndname, wndname, WS_VISIBLE, 0, 0, GetSystemMetrics(SM_CXSCREEN),
|
||||
GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL);
|
||||
if (!hWnd) return 1;
|
||||
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
|
||||
SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
|
||||
|
||||
MSG msg;
|
||||
while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
||||
|
@ -119,6 +121,19 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLin
|
|||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
LOGFONT f = {11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
|
||||
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T("")};
|
||||
HFONT hFnt = CreateFontIndirect(&f);
|
||||
HDC hDC = GetDC(hWnd);
|
||||
SelectObject(hDC, hFnt);
|
||||
RECT RWnd;
|
||||
GetClipBox(hDC, &RWnd);
|
||||
SetTextColor(hDC, 0xA0A0A0);
|
||||
SetBkColor(hDC, 0);
|
||||
DrawText(hDC, _T("PocketStella Initializing..."), -1, &RWnd, DT_CENTER | DT_VCENTER);
|
||||
ReleaseDC(hWnd, hDC);
|
||||
DeleteObject(hFnt);
|
||||
|
||||
theOSystem = new OSystemWinCE();
|
||||
SettingsWinCE theSettings(theOSystem);
|
||||
theOSystem->settings().loadConfig();
|
||||
|
@ -146,12 +161,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLin
|
|||
if (!FilesystemNode::fileExists(romfile))
|
||||
theOSystem->createLauncher();
|
||||
else
|
||||
{
|
||||
/*TCHAR tmp[200];
|
||||
MultiByteToWideChar(CP_ACP, 0, romfile.c_str(), strlen(romfile.c_str()) + 1, tmp, 200);
|
||||
MessageBox(hWnd, tmp, _T("..."),0);*/
|
||||
theOSystem->createConsole(romfile);
|
||||
}
|
||||
|
||||
theOSystem->mainLoop();
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -224,6 +224,20 @@ void SoundWinCE::processFragment(uInt8* stream, Int32 length)
|
|||
float position = 0.0;
|
||||
float remaining = length;
|
||||
|
||||
if(myRegWriteQueue.duration() >
|
||||
(9.0 / myDisplayFrameRate))
|
||||
{
|
||||
float removed = 0.0;
|
||||
while(removed < ((9.0 - 1) / myDisplayFrameRate))
|
||||
{
|
||||
RegWrite& info = myRegWriteQueue.front();
|
||||
removed += info.delta;
|
||||
myTIASound.set(info.addr, info.value);
|
||||
myRegWriteQueue.dequeue();
|
||||
}
|
||||
// cout << "Removed Items from RegWriteQueue!" << endl;
|
||||
}
|
||||
|
||||
while(remaining > 0.0)
|
||||
{
|
||||
if(myRegWriteQueue.size() == 0)
|
||||
|
|
|
@ -76,7 +76,7 @@ class SoundWinCE : public Sound
|
|||
bool myIsMuted;
|
||||
uInt32 myVolume;
|
||||
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;
|
||||
WAVEHDR *myBuffers;
|
||||
HWAVEOUT myWout;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "gx.h"
|
||||
|
||||
char *msg = NULL;
|
||||
extern int EventHandlerState;
|
||||
int EventHandlerState;
|
||||
|
||||
int time(int dummy)
|
||||
{
|
||||
|
@ -16,15 +16,11 @@ char *getcwd(void)
|
|||
static char cwd[MAX_PATH+1] = "";
|
||||
char *plast;
|
||||
|
||||
// if(cwd[0] == 0)
|
||||
// {
|
||||
GetModuleFileName(NULL, fileUnc, MAX_PATH);
|
||||
WideCharToMultiByte(CP_ACP, 0, fileUnc, -1, cwd, MAX_PATH, NULL, NULL);
|
||||
plast = strrchr(cwd, '\\');
|
||||
if(plast)
|
||||
*plast = 0;
|
||||
|
||||
// }
|
||||
GetModuleFileName(NULL, fileUnc, MAX_PATH);
|
||||
WideCharToMultiByte(CP_ACP, 0, fileUnc, -1, cwd, MAX_PATH, NULL, NULL);
|
||||
plast = strrchr(cwd, '\\');
|
||||
if(plast)
|
||||
*plast = 0;
|
||||
|
||||
return cwd;
|
||||
}
|
||||
|
@ -64,17 +60,49 @@ void KeySetup(void)
|
|||
keycodes[i][K_FIRE].sdlkey = SDLK_SPACE;
|
||||
keycodes[i][K_RESET].sdlkey = SDLK_F2;
|
||||
keycodes[i][K_SELECT].sdlkey = SDLK_F1;
|
||||
keycodes[i][K_QUIT].sdlkey = SDLK_q;
|
||||
keycodes[i][K_QUIT].sdlkey = SDLK_ESCAPE;
|
||||
|
||||
keycodes[i][K_UP].launcherkey = SDLK_UP;
|
||||
keycodes[i][K_DOWN].launcherkey = SDLK_DOWN;
|
||||
keycodes[i][K_LEFT].launcherkey = SDLK_LEFT;
|
||||
keycodes[i][K_RIGHT].launcherkey = SDLK_RIGHT;
|
||||
keycodes[i][K_LEFT].launcherkey = SDLK_PAGEUP;
|
||||
keycodes[i][K_RIGHT].launcherkey = SDLK_PAGEDOWN;
|
||||
keycodes[i][K_RESET].launcherkey = SDLK_RETURN;
|
||||
keycodes[i][K_QUIT].launcherkey = SDLK_ESCAPE;
|
||||
}
|
||||
}
|
||||
|
||||
void KeySetMode(int mode)
|
||||
{
|
||||
GXKeyList klist = GXGetDefaultKeys(GX_NORMALKEYS);
|
||||
|
||||
for (int i=0; i<2; i++)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
keycodes[i][K_UP].keycode = klist.vkUp;
|
||||
keycodes[i][K_DOWN].keycode = klist.vkDown;
|
||||
keycodes[i][K_LEFT].keycode = klist.vkLeft;
|
||||
keycodes[i][K_RIGHT].keycode = klist.vkRight;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
keycodes[i][K_UP].keycode = klist.vkRight;
|
||||
keycodes[i][K_DOWN].keycode = klist.vkLeft;
|
||||
keycodes[i][K_LEFT].keycode = klist.vkUp;
|
||||
keycodes[i][K_RIGHT].keycode = klist.vkDown;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
keycodes[i][K_UP].keycode = klist.vkLeft;
|
||||
keycodes[i][K_DOWN].keycode = klist.vkRight;
|
||||
keycodes[i][K_LEFT].keycode = klist.vkDown;
|
||||
keycodes[i][K_RIGHT].keycode = klist.vkUp;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SDL
|
||||
DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags) { return 0xFFFFFFFF; }
|
||||
|
@ -95,16 +123,21 @@ DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event)
|
|||
if (keycodes[0][i].state != keycodes[1][i].state)
|
||||
{
|
||||
keycodes[1][i].state = keycodes[0][i].state;
|
||||
if (keycodes[1][i].state == 1)
|
||||
event->type = event->key.type = SDL_KEYDOWN;
|
||||
else
|
||||
event->type = event->key.type = SDL_KEYUP;
|
||||
if (EventHandlerState == 0)
|
||||
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 = 0;
|
||||
event->key.keysym.unicode = '\n'; // hack
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
@ -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
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue