[Scummvm-cvs-logs] CVS: scummvm/PocketSCUMM PocketSCUMM.vco,NONE,1.1 PocketSCUMM.vcp,NONE,1.1 pocketpc.cpp,NONE,1.1 screen.cpp,NONE,1.1 screen.h,NONE,1.1 sdl.h,NONE,1.1

Claudio Matsuoka cmatsuoka at users.sourceforge.net
Tue Nov 6 11:13:34 CET 2001


Update of /cvsroot/scummvm/scummvm/PocketSCUMM
In directory usw-pr-cvs1:/tmp/cvs-serv11796

Added Files:
	PocketSCUMM.vco PocketSCUMM.vcp pocketpc.cpp screen.cpp 
	screen.h sdl.h 
Log Message:
Merged Vasyl Tsvirkunov's PocketPC port.


--- NEW FILE: PocketSCUMM.vco ---
ÐÏࡱá

























































object.cpp
script.cpp
stdafx.cpp
string.cpp
scummsys.h
screen.cpp












object.cpp
script.cpp
stdafx.cpp
string.cpp
scummsys.h
screen.cpp





































--- NEW FILE: PocketSCUMM.vcp ---
# Microsoft eMbedded Visual Tools Project File - Name="PocketSCUMM" - Package Owner=<4>
# Microsoft eMbedded Visual Tools Generated Build File, Format Version 6.02
# ** DO NOT EDIT **

# TARGTYPE "Win32 (WCE ARM) Application" 0x8501
# TARGTYPE "Win32 (WCE x86em) Application" 0x7f01
# TARGTYPE "Win32 (WCE SH3) Application" 0x8101
# TARGTYPE "Win32 (WCE SH4) Application" 0x8601
# TARGTYPE "Win32 (WCE MIPS) Application" 0x8201

CFG=PocketSCUMM - Win32 (WCE MIPS) Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE 
!MESSAGE NMAKE /f "PocketSCUMM.vcn".
!MESSAGE 
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE 
[...2658 lines suppressed...]
# End Source File
# Begin Source File

SOURCE=.\missing\sys\time.h
# End Source File
# Begin Source File

SOURCE=.\missing\time.h
# End Source File
# Begin Source File

SOURCE=.\missing\sys\types.h
# End Source File
# Begin Source File

SOURCE=.\missing\unistd.h
# End Source File
# End Group
# End Target
# End Project

--- NEW FILE: pocketpc.cpp ---
// ScummVM - Scumm Interpreter
// PocketSCUMM - PocketPC port of ScummVM. Based on the original Win32
// implementation by Ludvig Strigeus.
// Ported by Vasyl Tsvirkunov (vasyl at pacbell.net).
// Note: this is the very first version, implementing only basic functionality.
//       Keyboard is not implemented, there is no way to access save/load game
//       and the interpreter is hardcoded to one game (MI1 in this case). Later
//       versions will get these limitations removed. Right now you should
//       consider this port a proof of concept.
// To run PocketSCUMM, put PocketSCUMM.exe and game resources (MONKEY.000, MONKEY.001)
// in one folder (can be on storage card) and run the executable. Unused part of
// the screen below the image is split to two halves - tap on the left to press
// Escape (skip intro, etc.), tap on the right to change screen rotation.

#include "stdafx.h"
#include <assert.h>

#include "scumm.h"
#include "screen.h"

class WndMan
{
	HMODULE hInst;
	HWND hWnd;

	bool terminated;	

public:
	byte *_vgabuf;
	Scumm *_scumm;

public:
	void init();

	bool handleMessage();
	void run();
	void setPalette(byte *ctab, int first, int num);
	void writeToScreen();
};

void Error(LPCTSTR msg)
{
	MessageBox(0, msg, TEXT("Error"), MB_ICONSTOP);
	exit(1);
}

Scumm scumm;
ScummDebugger debugger;
WndMan wm[1];
byte veryFastMode;

static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	WndMan *wm = (WndMan*)GetWindowLong(hWnd, GWL_USERDATA);	

	switch (message) 
	{
		case WM_DESTROY:
		case WM_CLOSE:
			GraphicsOff();
			PostQuitMessage(0);
			break;

		case WM_CHAR:
			if(wParam == 'Q' || wParam == 'q')
				wParam = VK_ESCAPE;
			wm->_scumm->_keyPressed = wParam;
			break;

		case WM_KEYDOWN:
			if (wParam>='0' && wParam<='9')
			{
				wm->_scumm->_saveLoadSlot = wParam - '0';
				if (GetAsyncKeyState(VK_SHIFT)<0)
					wm->_scumm->_saveLoadFlag = 1;
				else if (GetAsyncKeyState(VK_CONTROL)<0)
					wm->_scumm->_saveLoadFlag = 2;
				wm->_scumm->_saveLoadCompatible = false;
			}

			if (wParam=='F')
			{
				wm->_scumm->_fastMode ^= 1;
			}

			if (wParam=='G')
			{
				veryFastMode ^= 1;
			}

			if (wParam=='D')
			{
				debugger.attach(wm->_scumm);
			}
			if(wParam == 'R')
				SetScreenMode(GetScreenMode()+1);

			break;

		case WM_MOUSEMOVE:
			{
				int x = ((int16*)&lParam)[0];
				int y = ((int16*)&lParam)[1];
				Translate(&x, &y);
				wm->_scumm->mouse.x = x;
				wm->_scumm->mouse.y = y;
			}
			break;
		case WM_LBUTTONDOWN:
			{
				int x = ((int16*)&lParam)[0];
				int y = ((int16*)&lParam)[1];
				Translate(&x, &y);
				wm->_scumm->mouse.x = x;
				wm->_scumm->mouse.y = y;
				wm->_scumm->_leftBtnPressed |= 1;
				if(y > 200)
				{
					if(x<160)
						wm->_scumm->_keyPressed = VK_ESCAPE;
					else
						SetScreenMode(GetScreenMode()+1);
				}
			}
			break;
		case WM_RBUTTONDOWN:
			wm->_scumm->_rightBtnPressed |= 1;
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}

void WndMan::writeToScreen()
{
	Blt(_vgabuf);
}

void WndMan::setPalette(byte *ctab, int first, int num) {
	int i;

#if 1
	for (i=0; i<256; i++)
		SetPalEntry(i, ctab[i*3+0]<<2, ctab[i*3+1]<<2, ctab[i*3+2]<<2);
#else
	for (i=0; i<256; i++)
		SetPalEntry(i, i, i, i);
#endif
}


void WndMan::init()
{
	/* Retrieve the handle of this module */
	hInst = GetModuleHandle(NULL);

	/* Register the window class */
	WNDCLASS wcex;
	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= (WNDPROC)WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= hInst;
	wcex.hIcon			= 0;
	wcex.hCursor		= ::LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName	= 0;	
	wcex.lpszClassName	= TEXT("ScummVM");
	if (!RegisterClass(&wcex))
		Error(TEXT("Cannot register window class!"));

	hWnd = CreateWindow(TEXT("ScummVM"), TEXT("ScummVM"), WS_POPUP,
      0, 0, 240, 320, NULL, NULL, hInst, NULL);
	SetWindowLong(hWnd, GWL_USERDATA, (long)this);
//	ShowCursor(false);

	ShowWindow(hWnd, SW_SHOW);
	GraphicsOn(hWnd);
}


bool WndMan::handleMessage()
{
	MSG msg;

	if (!PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		return false;

	if(msg.message==WM_QUIT)
	{
		terminated=true;
		exit(1);
		return true;
	}

	TranslateMessage(&msg);
	DispatchMessage(&msg);

	return true;
}


void blitToScreen(Scumm *s, byte *src,int x, int y, int w, int h)
{
	byte *dst;
	int i;

	dst = (byte*)wm->_vgabuf + y*320 + x;

	do
	{
		memcpy(dst, src, w);
		dst += 320;
		src += 320;
	}
	while (--h);

}

void updateScreen(Scumm *s)
{
	if(s->_palDirtyMax != -1)
	{
		wm->setPalette(s->_currentPalette, 0, 256);	
		s->_palDirtyMax = -1;
	}

	wm->writeToScreen();
}

void waitForTimer(Scumm *s)
{
	if(!veryFastMode)
	{
		Sleep(5);
	} 
	s->_scummTimer+=2;
	wm->handleMessage();
}

void initGraphics(Scumm *s)
{
}

void drawMouse(Scumm *s, int, int, int, byte*, bool)
{
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
{
	scumm._videoMode = 0x13;

	wm->init();
	wm->_vgabuf = (byte*)calloc(320,200);
	wm->_scumm = &scumm;
	
	char* argv[] = { "", "MONKEY", NULL };
	int argc = 2;

	scumm.scummMain(argc, argv);

	return 0;
}

--- NEW FILE: screen.cpp ---
/* (C) 2001  Vasyl Tsvirkunov */

#include <windows.h>
#include "gx.h"
#include "screen.h"

#define SMOOTH

#define MAX_CLR         0x100
#ifdef SMOOTH
static UBYTE palRed[MAX_CLR];
static UBYTE palGreen[MAX_CLR];
static UBYTE palBlue[MAX_CLR];
#endif
static unsigned short pal[MAX_CLR];


GXDisplayProperties gxdp;
int active;

struct tScreenGeometry
{
	long width;
	long height;
	long startoffset;
	long sourceoffset;
	long linestep;
	long pixelstep;
	long xSkipMask;
	long xLimit;
	long lineLimit;
};

tScreenGeometry geom[3];

int currentScreenMode = 0;
int useMode = 0;
int maxMode = 2;

void SetScreenMode(int mode)
{
	currentScreenMode = mode;
	if(currentScreenMode > maxMode)
		currentScreenMode = 0;
}

int GetScreenMode()
{
	return currentScreenMode;
}

void GraphicsSuspend()
{
	if(active)
	{
		active = 0;
		GXSuspend();
	}
}

void GraphicsResume()
{
	if(!active)
	{
		active = 1;
		GXResume();
	}
}

void GraphicsOff(void)
{
	GXCloseDisplay();
	active = 0;
}

int GraphicsOn(HWND hWndMain)
{
	GXOpenDisplay(hWndMain, GX_FULLSCREEN);
	
	gxdp = GXGetDisplayProperties();
	if((gxdp.ffFormat & (kfDirect555 | kfDirect565)) == 0 || gxdp.cxWidth < 240 || gxdp.cyHeight < 240)
	{
		GraphicsOff();
		return 1;
	}
	
	// portrait
	geom[0].width = gxdp.cxWidth; // 240
	geom[0].height = gxdp.cyHeight; // 320
	geom[0].startoffset = 0;
	geom[0].sourceoffset = 0;
	geom[0].linestep = gxdp.cbyPitch;
	geom[0].pixelstep = gxdp.cbxPitch;
	geom[0].xSkipMask = gxdp.cxWidth < 320 ? 0x00000003 : 0xffffffff;
	geom[0].xLimit = 320; // skip 1/4
	geom[0].lineLimit = 320*200;
	
	// left handed landscape
	geom[1].width = gxdp.cyHeight; // 320
	geom[1].height = gxdp.cxWidth; // 240
	geom[1].startoffset = gxdp.cbyPitch*(gxdp.cyHeight-1);
	geom[1].sourceoffset = 0;
	geom[1].linestep = gxdp.cbxPitch;
	geom[1].pixelstep = -gxdp.cbyPitch;
	geom[1].xSkipMask = 0xffffffff;
	geom[1].xLimit = 320; // no skip
	geom[1].lineLimit = 320*200;
	
	// right handed landscape
	geom[2].width = gxdp.cyHeight; // 320
	geom[2].height = gxdp.cxWidth; // 240
	geom[2].startoffset = gxdp.cbxPitch*(gxdp.cxWidth-1);
	geom[2].sourceoffset = 0;
	geom[2].linestep = -gxdp.cbxPitch;
	geom[2].pixelstep = gxdp.cbyPitch;
	geom[2].xSkipMask = 0xffffffff;
	geom[2].xLimit = 320; // no skip
	geom[2].lineLimit = 320*200;
	
	if(gxdp.cyHeight < 320)
		maxMode = 0; // portrait only!

	active = 1;
	return 0;
}

void SetPalEntry(int ent, UBYTE r, UBYTE g, UBYTE b)
{
	if (ent >= MAX_CLR)
		return;
#ifdef SMOOTH
	palRed[ent] = r;
	palGreen[ent] = g;
	palBlue[ent] = b;
#endif
	if(gxdp.ffFormat & kfDirect565)
		pal[ent] = ((r&0xf8)<<(11-3))|((g&0xfc)<<(5-2))|((b&0xf8)>>3);
	else if(gxdp.ffFormat & kfDirect555)
		pal[ent] = ((r&0xf8)<<(10-3))|((g&0xf8)<<(5-2))|((b&0xf8)>>3);
}

void Cls()
{
	int x, y;
	UBYTE* dst;
	UBYTE *scraddr;
	scraddr = (UBYTE*)GXBeginDraw();
	if(scraddr)
	{
		for(y=0; y<geom[useMode].height; y++)
		{
			dst = scraddr+geom[useMode].startoffset;
			for(x=0; x<geom[useMode].width; x++)
			{
				*(unsigned short*)dst = 0;
				dst += geom[useMode].pixelstep;
			}
			scraddr += geom[useMode].linestep;
		}
		GXEndDraw();
	}
}

int counter = 0;

void Blt(UBYTE * scr_ptr)
{
	static UBYTE *src;
	static UBYTE *dst;
	static UBYTE *scraddr;
	static UBYTE *scr_ptr_limit;
	static UBYTE *src_limit;
	static long pixelstep;
	static long linestep;
	static long skipmask;

#ifdef SMOOTH
	static bool b565 = (gxdp.ffFormat & kfDirect565);
#endif
	
	if(!active)
	{
		Sleep(100);
		return;
	}
	
	/* Update screen mode, also thread protection by doing this */
	if(useMode != currentScreenMode)
	{
		useMode = currentScreenMode;
		Cls();
	}
	
	scraddr = (UBYTE*)GXBeginDraw();
	if(scraddr)
	{
		scraddr += geom[useMode].startoffset;
		scr_ptr += geom[useMode].sourceoffset;
		scr_ptr_limit = scr_ptr + geom[useMode].lineLimit;
		pixelstep = geom[useMode].pixelstep;
		linestep = geom[useMode].linestep;
		src_limit = scr_ptr + geom[useMode].xLimit;
		skipmask = geom[useMode].xSkipMask;
		
		/* Internal pixel loops */
#ifdef SMOOTH
		if(skipmask == 3)
		{
			while(scr_ptr < scr_ptr_limit)
			{
				src = scr_ptr;
				dst = scraddr;
				while(src < src_limit)
				{
					UBYTE r, g, b;
					r = (3*palRed[*(src+0)] + palRed[*(src+1)])>>2;
					g = (3*palGreen[*(src+0)] + palGreen[*(src+1)])>>2;
					b = (3*palBlue[*(src+0)] + palBlue[*(src+1)])>>2;

					if(b565)
						*(unsigned short*)dst = ((r&0xf8)<<(11-3))|((g&0xfc)<<(5-2))|((b&0xf8)>>3);
					else
						*(unsigned short*)dst = ((r&0xf8)<<(10-3))|((g&0xf8)<<(5-2))|((b&0xf8)>>3);
					dst += pixelstep;

					r = (palRed[*(src+1)] + palRed[*(src+2)])>>1;
					g = (palGreen[*(src+1)] + palGreen[*(src+2)])>>1;
					b = (palBlue[*(src+1)] + palBlue[*(src+2)])>>1;

					if(b565)
						*(unsigned short*)dst = ((r&0xf8)<<(11-3))|((g&0xfc)<<(5-2))|((b&0xf8)>>3);
					else
						*(unsigned short*)dst = ((r&0xf8)<<(10-3))|((g&0xf8)<<(5-2))|((b&0xf8)>>3);
					dst += pixelstep;

					r = (palRed[*(src+2)] + 3*palRed[*(src+3)])>>2;
					g = (palGreen[*(src+2)] + 3*palGreen[*(src+3)])>>2;
					b = (palBlue[*(src+2)] + 3*palBlue[*(src+3)])>>2;

					if(b565)
						*(unsigned short*)dst = ((r&0xf8)<<(11-3))|((g&0xfc)<<(5-2))|((b&0xf8)>>3);
					else
						*(unsigned short*)dst = ((r&0xf8)<<(10-3))|((g&0xf8)<<(5-2))|((b&0xf8)>>3);
					dst += pixelstep;

					src += 4;
				}
				scraddr += linestep;
				scr_ptr += 320;
				src_limit += 320;
			}
		}
		else
#endif
		if(skipmask != 0xffffffff)
		{
			while(scr_ptr < scr_ptr_limit)
			{
				src = scr_ptr;
				dst = scraddr;
				while(src < src_limit)
				{
					if((long)src & skipmask)
					{
						*(unsigned short*)dst = pal[*src];
						dst += pixelstep;
					}
					src ++;
				}
				scraddr += linestep;
				scr_ptr += 320;
				src_limit += 320;
			}
		}
		else
		{
			while(scr_ptr < scr_ptr_limit)
			{
				src = scr_ptr;
				dst = scraddr;
				while(src < src_limit)
				{
					*(unsigned short*)dst = pal[*src];
					dst += pixelstep;
					src ++;
				}
				scraddr += linestep;
				scr_ptr += 320;
				src_limit += 320;
			}
		}
		
		GXEndDraw();
	}
}

void Translate(int* px, int* py)
{
	int x, y;
	
	switch(currentScreenMode)
	{
	case 0: /* portrait */
		*px = *px*4/3;
		break;
	case 1: /* landscape left */
		x = 320 - *py;
		y = *px;
		*px = x;
		*py = y;
		break;
	case 2: /* landscape right */
		x = *py;
		y = 240 - *px;
		*px = x;
		*py = y;
		break;
	}
}

--- NEW FILE: screen.h ---
/* (C) 2001  Vasyl Tsvirkunov */

#ifndef SCREEN_H
#define SCREEN_H

#ifndef UBYTE
#define UBYTE unsigned char
#endif

int GraphicsOn(HWND hWndMain);
void GraphicsOff();
void GraphicsSuspend();
void GraphicsResume();

void SetPalEntry(int ent, UBYTE r, UBYTE g, UBYTE b);
void Blt(UBYTE * scr_ptr);

/* meaning: 0 - portrait, 1 - left hand landscape, 2 - right hand landscape */
void SetScreenMode(int mode);
int GetScreenMode();

void Translate(int* x, int* y);

#endif

--- NEW FILE: sdl.h ---
/* dummy header */






More information about the Scummvm-git-logs mailing list