svn-id: r7366
This commit is contained in:
Chris Apers 2003-05-06 08:24:21 +00:00
parent c8eb0a9878
commit ba7e13262c
10 changed files with 206 additions and 749 deletions

View file

@ -24,6 +24,8 @@
#include "extend.h" #include "extend.h"
#include "string.h" #include "string.h"
#include "palm.h" #include "palm.h"
const Char *SCUMMVM_SAVEPATH = "/PALM/Programs/ScummVM/Saved/";
/* /*
//Sony clie PalmOS<5 //Sony clie PalmOS<5
void BmpDrawDDBitmap(const FormType *formP, DmResID bitmapID) void BmpDrawDDBitmap(const FormType *formP, DmResID bitmapID)

View file

@ -23,12 +23,14 @@
#ifndef EXTEND_H #ifndef EXTEND_H
#define EXTEND_H #define EXTEND_H
extern const Char *SCUMMVM_SAVEPATH; // extras.cpp extern const Char *SCUMMVM_SAVEPATH;
#define DISABLE_SKY #define DISABLE_SKY
#define DISABLE_SIMON #define DISABLE_SIMON
#define OutputDebugString PalmFatalError #define appFileCreator 'ScVM'
int main(int argc, char **argv);
void WinDrawWarpChars(const Char *chars, Int16 len, Coord x, Coord y, Coord maxWidth); void WinDrawWarpChars(const Char *chars, Int16 len, Coord x, Coord y, Coord maxWidth);
UInt16 StrReplace(Char *ioStr, UInt16 inMaxLen, const Char *inParamStr, const Char *fndParamStr); UInt16 StrReplace(Char *ioStr, UInt16 inMaxLen, const Char *inParamStr, const Char *fndParamStr);

View file

@ -1,239 +0,0 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001 Ludvig Strigeus
* Copyright (C) 2001-2003 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*
*/
//##############################################################################
#include "extras.h"
#include "StarterRsc.h"
#include "mathlib.h"
#include "globals.h"
//#include "palm.h"
//##############################################################################
//UInt16 gVolRefNum = 0;
//UInt16 HRrefNum,SndRefNum;
//FileRef logfile;
//Boolean _flipping = false;
//Boolean _vibrator = false;
//extern Boolean gFlipping;
//extern FileRef gLogFile;
//##############################################################################
//##############################################################################
void *memchr(const void *s, int c, UInt32 n)
{
UInt32 chr;
for(chr = 0; chr < n;chr++,((UInt8 *)s)++)
if ( *((UInt8 *)s) == c)
return (void *)s;
return NULL;
}
/*
UInt32 time(UInt32 *cur)
{
UInt32 secs = TimGetTicks();
if (cur != NULL)
*cur = secs;
return secs;
}
*/
///////////////////////////////////////////////////////////////////////////////
const Char *SCUMMVM_SAVEPATH = "/PALM/Programs/ScummVM/Saved/";
///////////////////////////////////////////////////////////////////////////////
Err SonySoundLib(UInt16 *refNumP)
{
SonySysFtrSysInfoP sonySysFtrSysInfoP;
Err error = errNone;
if ((error = FtrGet(sonySysFtrCreator, sonySysFtrNumSysInfoP, (UInt32*)&sonySysFtrSysInfoP))) {
/* Not CLIE: maybe not available */
} else {
if (sonySysFtrSysInfoP->libr & sonySysFtrSysInfoLibrFm) {
/* Sound-Lib available */
if ((error = SysLibFind(sonySysLibNameSound, refNumP))) {
if (error == sysErrLibNotFound) {
/* couldn't find lib */
error = SysLibLoad( 'libr', sonySysFileCSoundLib, refNumP );
}
}
if ( error ) {
/* Now we can use Sound-Lib */
FrmCustomAlert(FrmWarnAlert,"Sound Lib not found.",0,0);
}
}
}
if (!error)
FrmCustomAlert(FrmWarnAlert,"Sound Lib ok",0,0);
return error;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//UInt8 _indicatorColorOn = 255;
//UInt8 _indicatorColorOff = 0;
/*
int getc(FILE *stream)
{
UInt8 c;
DrawStatus(true);
Err error = VFSFileRead(*stream, 1, &c, NULL);
DrawStatus(false);
if (error == errNone || error == vfsErrFileEOF)
return c;
#ifdef DEBUG
switch (error)
{
case expErrNotOpen:
FrmCustomAlert(FrmWarn,"expErrNotOpen",0,0);
break;
case vfsErrFileBadRef:
FrmCustomAlert(FrmWarn,"vfsErrFileBadRef",0,0);
break;
case vfsErrFileEOF:
FrmCustomAlert(FrmWarn,"vfsErrFileEOF",0,0);
break;
case vfsErrFilePermissionDenied:
FrmCustomAlert(FrmWarn,"vfsErrFilePermissionDenied",0,0);
break;
case vfsErrIsADirectory:
FrmCustomAlert(FrmWarn,"vfsErrIsADirectory",0,0);
break;
case vfsErrNoFileSystem:
FrmCustomAlert(FrmWarn,"vfsErrNoFileSystem",0,0);
break;
}
#endif
return 0;
}
*/
/*
static Char *enumSaveLoad = NULL;
void doEnumSaveLoad(const Char* path, const Char* game)
{
if (enumSaveLoad)
return;
FileRef fileRef;
Err e = VFSFileOpen(gVars->volRefNum, path, vfsModeRead, &fileRef);
if (e != errNone)
return;
UInt32 dirEntryIterator = vfsIteratorStart;
Char file[32];
FileInfoType info = {0, file, 32};
UInt16 lenght;
UInt32 oldSize = 0;
UInt32 count = 0;
while (dirEntryIterator != vfsIteratorStop)
{
e = VFSDirEntryEnumerate (fileRef, &dirEntryIterator, &info);
if (e != expErrEnumerationEmpty)
{
if (StrNCaselessCompare(game, info.nameP, StrLen(game)) == 0)
{
lenght = StrLen(info.nameP);
if (!enumSaveLoad)
enumSaveLoad = (Char *)MemPtrNew(lenght+1);
else
{
oldSize = MemPtrSize(enumSaveLoad);
enumSaveLoad = (Char *)realloc(enumSaveLoad, oldSize + StrLen(info.nameP)+1);
}
TxtGlueLowerStr(info.nameP,StrLen(info.nameP));
StrCopy(enumSaveLoad+oldSize, info.nameP);
count++;
}
}
}
if (count == 0) { // if no files, create an empty list item to prevent ALL FILES EXIST
enumSaveLoad = (Char *)MemPtrNew(1);
enumSaveLoad[0] = 0;
}
// if (count > 20)
// endEnumSaveLoad(); // too manu files
}
void endEnumSaveLoad()
{
if (!enumSaveLoad)
return;
MemPtrFree(enumSaveLoad);
enumSaveLoad = NULL;
}
Boolean fexists(const Char* filename)
{
if (!enumSaveLoad)
return true;
Char *found;
UInt32 search = 0;
UInt32 size = MemPtrSize(enumSaveLoad);
UInt32 length = StrLen(filename);
// Char find[256];
// StrCopy(find,filename);
TxtGlueLowerStr((Char *)filename,length);
while (search < size)
{
found = StrStr(filename, enumSaveLoad+search);
if ( found && found == (filename+length-StrLen(enumSaveLoad+search)) )
return true;
search += StrLen(enumSaveLoad+search)+1;
}
return false;
}*/
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

View file

@ -1,156 +0,0 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001 Ludvig Strigeus
* Copyright (C) 2001-2003 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*
*/
//##############################################################################
#include <PalmOS.h>
#include <PalmOSGlue.h>
#include "SonyClie.h"
#include "VFSMgr.h"
#include "mathlib.h"
#include "vibrate.h"
#include <stdarg.h>
//##############################################################################
//##############################################################################
int main(int argc, char **argv);
MemPtr realloc(MemPtr, UInt32);
MemPtr calloc(UInt32, UInt32);
void exit(int);
//UInt16 parseCards(Boolean forceDisplay);
Err CheckMathLib();
//Err CheckHRmode(void);
Err SonySoundLib(UInt16 *refNumP);
UInt16 StrReplace(Char *ioStr, UInt16 inMaxLen, const Char *inParamStr, const Char *fndParamStr);
Int16 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam);
Int16 sprintf(Char* s, const Char* formatStr, ...);
Int16 printf(const Char* formatStr, ...);
//void xsprintf(const Char* formatStr, ...);
void PalmFatalError(const Char *err);
typedef FileRef FILE;
UInt16 FindFileSlot();
FILE *fopen(const char *filename, const char *type);
UInt16 fprintf(FILE *stream, const Char *format, ...);
int feof(FILE *stream);
void clearerr(FILE *stream);
UInt32 fread(void *ptr, UInt32 size, UInt32 nitems, FILE *stream);
int fseek(FILE *stream, long offset, int whence);
int fclose(FILE *stream);
char *fgets(char *s, UInt32 n, FILE *stream);
int free(MemPtr ptr);
UInt32 fwrite(void *ptr, UInt32 size, UInt32 nitems, FILE *stream);
int ftell(FILE *stream);
//int getc(FILE *stream);
void *memchr(const void *s, int c, UInt32 n);
Char *StrTok(Char *str, const Char *sep);
void WinDrawWarpChars(const Char *chars, Int16 len, Coord x, Coord y, Coord maxWidth);
Err HwrDisplayPalette(UInt8 operation, Int16 startIndex,
UInt16 paletteEntries, RGBColorType *tableP)
SYS_TRAP(sysTrapHwrDisplayPalette);
//#define memNewChunkFlagNonMovable 0x0200
#define memNewChunkFlagAllowLarge 0x1000 // this is not in the sdk *g*
SysAppInfoPtr SysGetAppInfo(SysAppInfoPtr *uiAppPP, SysAppInfoPtr *actionCodeAppPP)
SYS_TRAP(sysTrapSysGetAppInfo);
//##############################################################################
//#define DEBUG
#define MAXPATHLEN 255
#define NONSTANDARD_SAVE // scumm.h
////////////////////////////////////////////////////////////////////////////////
/*
extern UInt16 firstCard;
extern UInt16 HRrefNum;
extern UInt16 SndRefNum;
extern FileRef logfile;
extern Boolean _flipping;
extern Boolean _vibrator;
*/
//extern UInt8 *screen_1;
//extern UInt8 *screen_2;
//extern Char **argvP;
//#define assert(a)
//#define fflush(a)
//#define OutputDebugString PalmFatalError
//#define SEEK_SET vfsOriginBeginning
//#define SEEK_CUR vfsOriginCurrent
//#define SEEK_END vfsOriginEnd
//#define strtol(a,b,c) StrAToI(a)
//#define abs fabs
/*
//#define malloc MemPtrNew
//#define calloc(a,b) MemPtrNew(((UInt32)a)*((UInt32)b))
#define memcpy MemMove
#define memmove MemMove
//#define free MemPtrFree
#define strcmp StrCompare
#define strncmp StrNCompare
#define stricmp StrCaselessCompare
#define atoi StrAToI
#define tolower TxtGlueLowerChar
#define strchr StrChr
#define strcat StrCat
//#define vsprintf StrVPrintF
//#define sprintf StrPrintF
#define strtok StrTok
#define rand() SysRandom(0)
#define strncpy MemMove
#define stdin 0
#define stdout &logfile
#define stderr &logfile
#define memset(ptr,value,numBytes) MemSet(ptr,numBytes,value)
*/
//typedef UInt32 time_t;
//UInt32 time(UInt32 *cur);
#define bool Boolean
typedef unsigned int uint;
typedef unsigned long uint32;
// scumm protos
///////////////
struct AkosRenderer;
// akos.cpp
void akos_c1_0y_decode(AkosRenderer * ar);
void akos_generic_decode(AkosRenderer * ar);
void akos_c1_spec1(AkosRenderer * ar);
// sound.cpp
int CompDecode(unsigned char *src, unsigned char *dst);
// simon.cpp
void palette_fadeout(uint32 *pal_values,uint num);
uint fileReadItemID(FILE *in);

View file

@ -21,11 +21,18 @@
*/ */
#include "string.h" #include "string.h"
Char *StrTokNext;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
Char *strtok(Char *str, const Char *sep) void *memchr(const void *s, int c, UInt32 n) {
{ UInt32 chr;
for(chr = 0; chr < n;chr++,((UInt8 *)s)++)
if ( *((UInt8 *)s) == c)
return (void *)s;
return NULL;
}
///////////////////////////////////////////////////////////////////////////////
Char *StrTokNext;
Char *strtok(Char *str, const Char *sep) {
Char *position = NULL, Char *position = NULL,
*found, *found,
*end; *end;
@ -67,8 +74,7 @@ Char *strtok(Char *str, const Char *sep)
return str; return str;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
Char *strpbrk(const Char *s1, const Char *s2) Char *strpbrk(const Char *s1, const Char *s2) {
{
Char *found; Char *found;
UInt32 n; UInt32 n;
@ -81,8 +87,7 @@ Char *strpbrk(const Char *s1, const Char *s2)
return NULL; return NULL;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
Char *strrchr(const Char *s, int c) Char *strrchr(const Char *s, int c) {
{
UInt32 chr; UInt32 chr;
UInt32 n = StrLen(s); UInt32 n = StrLen(s);
@ -93,8 +98,7 @@ Char *strrchr(const Char *s, int c)
return NULL; return NULL;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
Char *strdup(const Char *s1) Char *strdup(const Char *s1) {
{
Char* buf = (Char *)MemPtrNew(StrLen(s1)+1); Char* buf = (Char *)MemPtrNew(StrLen(s1)+1);
if(buf) if(buf)

View file

@ -36,6 +36,7 @@
#define strncmp StrNCompare #define strncmp StrNCompare
#define strstr StrStr #define strstr StrStr
void *memchr(const void *s, int c, UInt32 n);
Char *strtok(Char *str, const Char *sep); Char *strtok(Char *str, const Char *sep);
Char *strrchr(const Char *s, int c); Char *strrchr(const Char *s, int c);
Char *strdup(const Char *strSource); Char *strdup(const Char *strSource);

View file

@ -20,53 +20,20 @@
* *
*/ */
#include "stdafx.h"
#include "scumm.h" #include "scumm.h"
#include "mididrv.h"
#include "gameDetector.h"
#include "common/scaler.h" #include "common/scaler.h"
#include "palm.h" #include "palm.h"
#include "starterrsc.h" #include "vibrate.h"
#include "pa1lib.h"
#include "sonychars.h"
#define SAVEDELAY (5 * 60 * 1000) // five minutes #define EXITDELAY (500) // delay to exit : calc button : double tap 1/500 sec
#define EXITDELAY (100) // delay to exit : calc button : double tap 1/500 sec #define ftrOverlayPtr (1000)
#define SCREEN_OVERLAY 0
static DmOpenRef gStgMemory = NULL;
static void MemStgInit() {
if (!gStgMemory)
{
LocalID localID = DmFindDatabase(0, "Scumm-Memory");
if (localID) DmDeleteDatabase(0, localID);
if (DmCreateDatabase (0, "Scumm-Memory", 'ScVM', 'DATA', false) != errNone)
return;
localID = DmFindDatabase(0, "Scumm-Memory");
gStgMemory = DmOpenDatabase(0, localID, dmModeReadWrite|dmModeExclusive);
}
}
static void MemStgCleanup() {
if (gStgMemory) {
DmCloseDatabase(gStgMemory);
LocalID localID = DmFindDatabase(0, "Scumm-Memory");
if (localID)
DmDeleteDatabase(0, localID);
}
}
OSystem *OSystem_PALMOS::create(UInt16 gfx_mode) { OSystem *OSystem_PALMOS::create(UInt16 gfx_mode) {
OSystem_PALMOS *syst = new OSystem_PALMOS(); OSystem_PALMOS *syst = new OSystem_PALMOS();
syst->_mode = gfx_mode; syst->_mode = gfx_mode;
syst->_vibrate = gVars->vibrator; syst->_vibrate = gVars->vibrator;
return syst; return syst;
} }
@ -112,40 +79,38 @@ void OSystem_PALMOS::load_gfx_mode() {
255 ,255,87 ,0, 255 ,255,87 ,0,
255 ,255,255,0 255 ,255,255,0
}; };
// palette for preload dialog // palette for preload dialog
set_palette(startupPalette,0,16); set_palette(startupPalette,0,16);
MemStgInit();
switch(_mode) switch(_mode)
{ {
case GFX_FLIPPING: case GFX_FLIPPING:
palm_offscreen = WinScreenLock(winLockErase) + _screeny; _offScreenP = WinScreenLock(winLockErase) + _screeny;
palm_screen = palm_offscreen; _screenP = _offScreenP;
gVars->screenLocked = true; gVars->screenLocked = true;
_renderer_proc = &update_screen__flipping; _renderer_proc = &update_screen__flipping;
break; break;
case GFX_DOUBLEBUFFER: case GFX_DOUBLEBUFFER:
h_palm_screen = WinGetDisplayWindow(); _screenH = WinGetDisplayWindow();
palm_screen = (byte *)(BmpGetBits(WinGetBitmap(h_palm_screen))) + _screeny; _screenP = (byte *)(BmpGetBits(WinGetBitmap(_screenH))) + _screeny;
h_palm_offscreen= WinCreateOffscreenWindow(SCREEN_WIDTH, SCREEN_HEIGHT, screenFormat, &e); _offScreenH = WinCreateOffscreenWindow(_screenWidth, _screenHeight, screenFormat, &e);
palm_offscreen = (byte *)(BmpGetBits(WinGetBitmap(h_palm_offscreen))); _offScreenP = (byte *)(BmpGetBits(WinGetBitmap(_offScreenH)));
_renderer_proc = &update_screen__dbuffer; _renderer_proc = &update_screen__dbuffer;
break; break;
case GFX_NORMAL: case GFX_NORMAL:
default: default:
h_palm_offscreen= WinGetDisplayWindow(); _offScreenH = WinGetDisplayWindow();
palm_offscreen = (byte *)(BmpGetBits(WinGetBitmap(h_palm_offscreen))) + _screeny; _offScreenP = (byte *)(BmpGetBits(WinGetBitmap(_offScreenH))) + _screeny;
palm_screen = palm_offscreen; _screenP = _offScreenP;
_renderer_proc = &update_screen__direct; _renderer_proc = &update_screen__direct;
break; break;
} }
// h_palm_tmpscreen = WinCreateOffscreenWindow(SCREEN_WIDTH, SCREEN_HEIGHT, screenFormat, &e); // try to allocate on storage heap
// palm_tmpscreen = (byte *)(BmpGetBits(WinGetBitmap(h_palm_tmpscreen))); FtrPtrNew(appFileCreator, ftrOverlayPtr, _screenWidth * _screenHeight, (void **)&_tmpScreenP);
UInt16 index = SCREEN_OVERLAY; // failed ? dynamic heap
tmpScreenHandle = DmNewRecord(gStgMemory, &index, SCREEN_WIDTH * SCREEN_HEIGHT); if (!_tmpScreenP)
tmpScreen = (byte *)MemHandleLock(tmpScreenHandle); _tmpScreenP = (byte *)malloc(_screenWidth * _screenHeight);
_overlaySaved = false; _overlaySaved = false;
} }
@ -157,20 +122,21 @@ void OSystem_PALMOS::unload_gfx_mode() {
WinScreenUnlock(); WinScreenUnlock();
break; break;
case GFX_DOUBLEBUFFER: case GFX_DOUBLEBUFFER:
WinDeleteWindow(h_palm_offscreen,false); WinDeleteWindow(_offScreenH,false);
break; break;
} }
// WinDeleteWindow(h_palm_tmpscreen,false); if (_tmpScreenP)
if (tmpScreenHandle) if (MemPtrDataStorage(_tmpScreenP))
MemPtrUnlock(tmpScreen); FtrPtrFree(appFileCreator, ftrOverlayPtr);
MemStgCleanup(); else
free(_tmpScreenP);
} }
void OSystem_PALMOS::init_size(uint w, uint h) { void OSystem_PALMOS::init_size(uint w, uint h) {
SCREEN_WIDTH = w; _screenWidth = w;
SCREEN_HEIGHT = h; _screenHeight = h;
_overlay_visible = false; _overlay_visible = false;
_quit = false; _quit = false;
@ -181,24 +147,21 @@ void OSystem_PALMOS::init_size(uint w, uint h) {
set_mouse_pos(200,150); set_mouse_pos(200,150);
_currentPalette = (RGBColorType*)calloc(sizeof(RGBColorType), 256); _currentPalette = (RGBColorType*)calloc(sizeof(RGBColorType), 256);
_mouse_backup = (byte*)malloc(MAX_MOUSE_W * MAX_MOUSE_H); _mouseBackupP = (byte*)malloc(MAX_MOUSE_W * MAX_MOUSE_H);
load_gfx_mode(); load_gfx_mode();
} }
void OSystem_PALMOS::copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) { void OSystem_PALMOS::copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) {
byte *dst;
/* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */ /* FIXME: undraw mouse only if the draw rect intersects with the mouse rect */
if (_mouse_drawn) if (_mouseDrawn)
undraw_mouse(); undraw_mouse();
dst = palm_offscreen + y * SCREEN_WIDTH + x; byte *dst = _offScreenP + y * _screenWidth + x;
do { do {
memcpy(dst, buf, w); memcpy(dst, buf, w);
dst += SCREEN_WIDTH; dst += _screenWidth;
buf += pitch; buf += pitch;
} while (--h); } while (--h);
} }
@ -207,18 +170,18 @@ void OSystem_PALMOS::update_screen__flipping()
{ {
RectangleType r; RectangleType r;
UInt8 *screen; UInt8 *screen;
UInt32 size = SCREEN_WIDTH*SCREEN_HEIGHT + 6400; // 10 pix top and bottom border UInt32 size = _screenWidth * _screenHeight + 6400; // 10 pix top and bottom border
Boolean shaked = false; Boolean shaked = false;
UInt32 move = 0; UInt32 move = 0;
// shake screen // shake screen
if (_current_shake_pos != _new_shake_pos) { if (_current_shake_pos != _new_shake_pos) {
if (gVars->HRrefNum) { if (gVars->HRrefNum) {
RctSetRectangle(&r, 0, _decaly - _new_shake_pos, SCREEN_WIDTH, SCREEN_HEIGHT + (_new_shake_pos << 2)); RctSetRectangle(&r, 0, _decaly - _new_shake_pos, _screenWidth, _screenHeight + (_new_shake_pos << 2));
HRWinScrollRectangle(gVars->HRrefNum, &r, winDown, _new_shake_pos, NULL); HRWinScrollRectangle(gVars->HRrefNum, &r, winDown, _new_shake_pos, NULL);
} else { } else {
move = (_new_shake_pos * SCREEN_WIDTH); move = (_new_shake_pos * _screenWidth);
screen = palm_offscreen - 3200; screen = _offScreenP - 3200;
MemMove(screen + move, screen, size); MemMove(screen + move, screen, size);
} }
@ -233,13 +196,13 @@ void OSystem_PALMOS::update_screen__flipping()
// update screen // update screen
WinScreenUnlock(); WinScreenUnlock();
palm_offscreen = WinScreenLock(winLockCopy) + _screeny; _offScreenP = WinScreenLock(winLockCopy) + _screeny;
palm_screen = palm_offscreen; _screenP = _offScreenP;
if (shaked) { if (shaked) {
if (gVars->HRrefNum) { if (gVars->HRrefNum) {
HRWinScrollRectangle(gVars->HRrefNum, &r, winUp, _new_shake_pos, NULL); HRWinScrollRectangle(gVars->HRrefNum, &r, winUp, _new_shake_pos, NULL);
} else { } else {
screen = palm_offscreen - 3200; screen = _offScreenP - 3200;
MemMove(screen, screen + move, size); MemMove(screen, screen + move, size);
} }
} }
@ -249,13 +212,13 @@ void OSystem_PALMOS::update_screen__flipping()
void OSystem_PALMOS::update_screen__dbuffer() void OSystem_PALMOS::update_screen__dbuffer()
{ {
UInt32 move = 0; UInt32 move = 0;
UInt32 size = SCREEN_WIDTH*SCREEN_HEIGHT; UInt32 size = _screenWidth * _screenHeight;
// shake screen // shake screen
if (_current_shake_pos != _new_shake_pos) { if (_current_shake_pos != _new_shake_pos) {
move = (_new_shake_pos * SCREEN_WIDTH); move = (_new_shake_pos * _screenWidth);
// copy clear bottom of the screen to top to cover shaking image // copy clear bottom of the screen to top to cover shaking image
MemMove(palm_screen, palm_screen + size , move); MemMove(_screenP, _screenP + size , move);
if (_vibrate) { if (_vibrate) {
Boolean active = (_new_shake_pos >= 3); Boolean active = (_new_shake_pos >= 3);
@ -265,7 +228,7 @@ void OSystem_PALMOS::update_screen__dbuffer()
_current_shake_pos = _new_shake_pos; _current_shake_pos = _new_shake_pos;
} }
// update screen // update screen
MemMove(palm_screen + move, palm_offscreen, size - move); MemMove(_screenP + move, _offScreenP, size - move);
} }
void OSystem_PALMOS::update_screen__direct() void OSystem_PALMOS::update_screen__direct()
@ -309,11 +272,11 @@ void OSystem_PALMOS::update_screen() {
} }
bool OSystem_PALMOS::show_mouse(bool visible) { bool OSystem_PALMOS::show_mouse(bool visible) {
if (_mouse_visible == visible) if (_mouseVisible == visible)
return visible; return visible;
bool last = _mouse_visible; bool last = _mouseVisible;
_mouse_visible = visible; _mouseVisible = visible;
if (visible) if (visible)
draw_mouse(); draw_mouse();
@ -327,21 +290,21 @@ void OSystem_PALMOS::warp_mouse(int x, int y) {
} }
void OSystem_PALMOS::set_mouse_pos(int x, int y) { void OSystem_PALMOS::set_mouse_pos(int x, int y) {
if (x != _mouse_cur_state.x || y != _mouse_cur_state.y) { if (x != _mouseCurState.x || y != _mouseCurState.y) {
_mouse_cur_state.x = x; _mouseCurState.x = x;
_mouse_cur_state.y = y; _mouseCurState.y = y;
undraw_mouse(); undraw_mouse();
} }
} }
void OSystem_PALMOS::set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) { void OSystem_PALMOS::set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) {
_mouse_cur_state.w = w; _mouseCurState.w = w;
_mouse_cur_state.h = h; _mouseCurState.h = h;
_mouse_hotspot_x = hotspot_x; _mouseHotspotX = hotspot_x;
_mouse_hotspot_y = hotspot_y; _mouseHotspotY = hotspot_y;
_mouse_data = (byte*)buf; _mouseDataP = (byte*)buf;
undraw_mouse(); undraw_mouse();
} }
@ -406,8 +369,8 @@ void OSystem_PALMOS::delete_mutex(void *mutex)
} }
void OSystem_PALMOS::SimulateArrowKeys(Event *event, Int8 iHoriz, Int8 iVert, Boolean repeat) { void OSystem_PALMOS::SimulateArrowKeys(Event *event, Int8 iHoriz, Int8 iVert, Boolean repeat) {
Int16 x = _mouse_cur_state.x; Int16 x = _mouseCurState.x;
Int16 y = _mouse_cur_state.y; Int16 y = _mouseCurState.y;
if (repeat) { if (repeat) {
lastKeyRepeat += 100; lastKeyRepeat += 100;
@ -422,9 +385,9 @@ void OSystem_PALMOS::SimulateArrowKeys(Event *event, Int8 iHoriz, Int8 iVert, Bo
y = y + iVert * (lastKeyRepeat/100); y = y + iVert * (lastKeyRepeat/100);
x = (x < 0 ) ? 0 : x; x = (x < 0 ) ? 0 : x;
x = (x >= SCREEN_WIDTH ) ? SCREEN_WIDTH-1 : x; x = (x >= _screenWidth ) ? _screenWidth-1 : x;
y = (y < 0 ) ? 0 : y; y = (y < 0 ) ? 0 : y;
y = (y >= SCREEN_HEIGHT ) ? SCREEN_HEIGHT-1 : y; y = (y >= _screenHeight ) ? _screenHeight-1 : y;
event->event_code = EVENT_MOUSEMOVE; event->event_code = EVENT_MOUSEMOVE;
@ -443,7 +406,7 @@ void OSystem_PALMOS::drawKeyState() {
MemHandle hTemp; MemHandle hTemp;
BitmapType *bmTemp; BitmapType *bmTemp;
UInt32 *bmData; UInt32 *bmData;
UInt8 *scr = palm_screen + SCREEN_WIDTH * (SCREEN_HEIGHT + 2) + 2; UInt8 *scr = _screenP + _screenWidth * (_screenHeight + 2) + 2;
hTemp = DmGetResource(bitmapRsc,bmpID); hTemp = DmGetResource(bitmapRsc,bmpID);
@ -458,7 +421,7 @@ void OSystem_PALMOS::drawKeyState() {
else else
*scr++ = gVars->indicator.off; *scr++ = gVars->indicator.off;
} }
scr += SCREEN_WIDTH - 32; scr += _screenWidth - 32;
bmData++; bmData++;
} }
@ -469,7 +432,7 @@ void OSystem_PALMOS::drawKeyState() {
for (j = 0; j < 32; j++) { for (j = 0; j < 32; j++) {
*scr++ = gVars->indicator.off; *scr++ = gVars->indicator.off;
} }
scr += SCREEN_WIDTH - 32; scr += _screenWidth - 32;
} }
} }
} }
@ -477,7 +440,6 @@ void OSystem_PALMOS::drawKeyState() {
bool OSystem_PALMOS::poll_event(Event *event) { bool OSystem_PALMOS::poll_event(Event *event) {
EventType ev; EventType ev;
Boolean handled; Boolean handled;
// UInt32 button = 0;
uint32 current_msecs; uint32 current_msecs;
UInt32 keyCurrentState = 0; UInt32 keyCurrentState = 0;
Boolean funcButton = false; Boolean funcButton = false;
@ -497,9 +459,6 @@ bool OSystem_PALMOS::poll_event(Event *event) {
if(_sound.active) if(_sound.active)
check_sound(); check_sound();
// if (_msg.state != 0)
// drawMessage();
// timer handler // timer handler
if (_timer.active && (current_msecs >= _timer.next_expiry)) { if (_timer.active && (current_msecs >= _timer.next_expiry)) {
_timer.duration = _timer.callback(_timer.duration); _timer.duration = _timer.callback(_timer.duration);
@ -545,8 +504,8 @@ bool OSystem_PALMOS::poll_event(Event *event) {
// mouse emulation // mouse emulation
case vchrHard1: // left button case vchrHard1: // left button
event->event_code = EVENT_LBUTTONDOWN; event->event_code = EVENT_LBUTTONDOWN;
event->mouse.x = _mouse_cur_state.x; event->mouse.x = _mouseCurState.x;
event->mouse.y = _mouse_cur_state.y; event->mouse.y = _mouseCurState.y;
lastKeyPressed = -1; lastKeyPressed = -1;
return true; return true;
@ -572,8 +531,8 @@ bool OSystem_PALMOS::poll_event(Event *event) {
case vchrHard4: // right button case vchrHard4: // right button
event->event_code = EVENT_RBUTTONDOWN; event->event_code = EVENT_RBUTTONDOWN;
event->mouse.x = _mouse_cur_state.x; event->mouse.x = _mouseCurState.x;
event->mouse.y = _mouse_cur_state.y; event->mouse.y = _mouseCurState.y;
lastKeyPressed = -1; lastKeyPressed = -1;
return true; return true;
@ -639,7 +598,7 @@ bool OSystem_PALMOS::poll_event(Event *event) {
} }
case penMoveEvent: case penMoveEvent:
if (ev.screenY*2-_decaly > SCREEN_HEIGHT || ev.screenY*2-_decaly < 0) if (ev.screenY*2-_decaly > _screenHeight || ev.screenY*2-_decaly < 0)
return true; return true;
if (lastEvent != penMoveEvent && (abs(ev.screenY*2-event->mouse.y) <= 2 || abs(ev.screenX*2-event->mouse.x) <= 2)) // move only if if (lastEvent != penMoveEvent && (abs(ev.screenY*2-event->mouse.y) <= 2 || abs(ev.screenX*2-event->mouse.x) <= 2)) // move only if
@ -654,7 +613,7 @@ bool OSystem_PALMOS::poll_event(Event *event) {
case penDownEvent: case penDownEvent:
lastEvent = penDownEvent; lastEvent = penDownEvent;
if (ev.screenY*2-_decaly > SCREEN_HEIGHT || ev.screenY*2-_decaly < 0) if (ev.screenY*2-_decaly > _screenHeight || ev.screenY*2-_decaly < 0)
return true; return true;
event->event_code = EVENT_LBUTTONDOWN; event->event_code = EVENT_LBUTTONDOWN;
@ -666,7 +625,7 @@ bool OSystem_PALMOS::poll_event(Event *event) {
case penUpEvent: case penUpEvent:
event->event_code = EVENT_LBUTTONUP; event->event_code = EVENT_LBUTTONUP;
if (ev.screenY*2-_decaly > SCREEN_HEIGHT || ev.screenY*2-_decaly < 0) if (ev.screenY*2-_decaly > _screenHeight || ev.screenY*2-_decaly < 0)
return true; return true;
event->mouse.x = ev.screenX*2; event->mouse.x = ev.screenX*2;
@ -688,28 +647,29 @@ uint32 OSystem_PALMOS::property(int param, Property *value) {
if (StrCaselessCompare(value->caption,"ScummVM") == 0) if (StrCaselessCompare(value->caption,"ScummVM") == 0)
return 1; return 1;
UInt16 w1 = FntCharsWidth(value->caption,StrLen(value->caption));
if (gVars->HRrefNum != sysInvalidRefNum) {
Char *caption = "Loading...\0"; Char *caption = "Loading...\0";
Char *build = "Build on " __DATE__ ", " __TIME__ " GMT+1\0";
UInt16 h0 = FntLineHeight() + 2; UInt16 h0 = FntLineHeight() + 2;
UInt16 w1; UInt16 w1;
WinSetTextColor(255); WinSetTextColor(255);
WinSetForeColor(255);
if (gVars->HRrefNum != sysInvalidRefNum) {
HRFntSetFont(gVars->HRrefNum,hrTinyBoldFont); HRFntSetFont(gVars->HRrefNum,hrTinyBoldFont);
w1 = FntCharsWidth(caption,StrLen(caption)) * 1; w1 = FntCharsWidth(caption,StrLen(caption));
w1 = (320 - w1) / 2; w1 = (320 - w1) / 2;
HRWinDrawChars(gVars->HRrefNum,caption,StrLen(caption),w1,80); HRWinDrawChars(gVars->HRrefNum,caption,StrLen(caption),w1,80);
HRFntSetFont(gVars->HRrefNum,hrTinyFont); HRFntSetFont(gVars->HRrefNum,hrTinyFont);
w1 = FntCharsWidth(value->caption,StrLen(value->caption)) * 1; w1 = FntCharsWidth(value->caption,StrLen(value->caption));
w1 = (320 - w1) / 2; w1 = (320 - w1) / 2;
HRWinDrawChars(gVars->HRrefNum,value->caption,StrLen(value->caption),w1,80 + h0); HRWinDrawChars(gVars->HRrefNum,value->caption,StrLen(value->caption),w1,80 + h0);
HRWinDrawLine(gVars->HRrefNum, 40, 85 + h0 * 2, 280, 85 + h0 * 2);
w1 = FntCharsWidth(build,StrLen(build));
w1 = (320 - w1) / 2;
HRWinDrawChars(gVars->HRrefNum,build,StrLen(build),w1,90 + h0 * 2);
} else { } else {
Char *caption = "Loading...\0";
UInt16 w1;
WinSetTextColor(255);
FntSetFont(boldFont); FntSetFont(boldFont);
w1 = FntCharsWidth(caption,StrLen(caption)); w1 = FntCharsWidth(caption,StrLen(caption));
w1 = (160 - w1) / 2; w1 = (160 - w1) / 2;
@ -732,35 +692,36 @@ void OSystem_PALMOS::quit() {
if (_quit) if (_quit)
return; return;
if (g_scumm) if (g_scumm)
g_scumm->_quit = true; g_scumm->_quit = true;
if (_currentPalette) if (_currentPalette)
free(_currentPalette); free(_currentPalette);
if (_mouse_backup) if (_mouseBackupP)
free(_mouse_backup); free(_mouseBackupP);
if (_sndData)
MemPtrFree(_sndData); if (_sndTempP)
MemPtrFree(_sndTempP);
if (_sndDataP)
MemPtrFree(_sndDataP);
unload_gfx_mode(); unload_gfx_mode();
_quit = true; _quit = true;
_currentPalette = NULL;
_mouse_backup = NULL;
} }
void OSystem_PALMOS::draw_mouse() { void OSystem_PALMOS::draw_mouse() {
if (_mouse_drawn || !_mouse_visible || _quit) if (_mouseDrawn || !_mouseVisible || _quit)
return; return;
_mouse_cur_state.y = _mouse_cur_state.y>=SCREEN_HEIGHT ? SCREEN_HEIGHT-1 : _mouse_cur_state.y; _mouseCurState.y = _mouseCurState.y >= _screenHeight ? _screenHeight - 1 : _mouseCurState.y;
int x = _mouse_cur_state.x - _mouse_hotspot_x; int x = _mouseCurState.x - _mouseHotspotX;
int y = _mouse_cur_state.y - _mouse_hotspot_y; int y = _mouseCurState.y - _mouseHotspotY;
int w = _mouse_cur_state.w; int w = _mouseCurState.w;
int h = _mouse_cur_state.h; int h = _mouseCurState.h;
byte color; byte color;
byte *src = _mouse_data; // Image representing the mouse byte *src = _mouseDataP; // Image representing the mouse
byte *bak = _mouse_backup; // Surface used to backup the area obscured by the mouse byte *bak = _mouseBackupP; // Surface used to backup the area obscured by the mouse
byte *dst; // Surface we are drawing into byte *dst; // Surface we are drawing into
@ -772,27 +733,27 @@ void OSystem_PALMOS::draw_mouse() {
} }
if (y < 0) { if (y < 0) {
h += y; h += y;
src -= y * _mouse_cur_state.w; src -= y * _mouseCurState.w;
y = 0; y = 0;
} }
if (w > SCREEN_WIDTH - x) if (w > _screenWidth - x)
w = SCREEN_WIDTH - x; w = _screenWidth - x;
if (h > SCREEN_HEIGHT - y) if (h > _screenHeight - y)
h = SCREEN_HEIGHT - y; h = _screenHeight - y;
// Store the bounding box so that undraw mouse can restore the area the
// mouse currently covers to its original content.
_mouse_old_state.x = x;
_mouse_old_state.y = y;
_mouse_old_state.w = w;
_mouse_old_state.h = h;
// Quick check to see if anything has to be drawn at all // Quick check to see if anything has to be drawn at all
if (w <= 0 || h <= 0) if (w <= 0 || h <= 0)
return; return;
// Store the bounding box so that undraw mouse can restore the area the
// mouse currently covers to its original content.
_mouseOldState.x = x;
_mouseOldState.y = y;
_mouseOldState.w = w;
_mouseOldState.h = h;
// Draw the mouse cursor; backup the covered area in "bak" // Draw the mouse cursor; backup the covered area in "bak"
dst = palm_offscreen + y * SCREEN_WIDTH + x; dst = _offScreenP + y * _screenWidth + x;
while (h > 0) { while (h > 0) {
int width = w; int width = w;
while (width > 0) { while (width > 0) {
@ -803,33 +764,33 @@ void OSystem_PALMOS::draw_mouse() {
dst++; dst++;
width--; width--;
} }
src += _mouse_cur_state.w - w; src += _mouseCurState.w - w;
bak += MAX_MOUSE_W - w; bak += MAX_MOUSE_W - w;
dst += SCREEN_WIDTH - w; dst += _screenWidth - w;
h--; h--;
} }
// Finally, set the flag to indicate the mouse has been drawn // Finally, set the flag to indicate the mouse has been drawn
_mouse_drawn = true; _mouseDrawn = true;
} }
void OSystem_PALMOS::undraw_mouse() { void OSystem_PALMOS::undraw_mouse() {
if (!_mouse_drawn || _quit) if (!_mouseDrawn || _quit)
return; return;
_mouse_drawn = false; _mouseDrawn = false;
byte *dst, *bak = _mouse_backup; byte *dst, *bak = _mouseBackupP;
const int old_mouse_x = _mouse_old_state.x; const int old_mouse_x = _mouseOldState.x;
const int old_mouse_y = _mouse_old_state.y; const int old_mouse_y = _mouseOldState.y;
const int old_mouse_w = _mouse_old_state.w; const int old_mouse_w = _mouseOldState.w;
const int old_mouse_h = _mouse_old_state.h; const int old_mouse_h = _mouseOldState.h;
int x,y; int x,y;
// No need to do clipping here, since draw_mouse() did that already // No need to do clipping here, since draw_mouse() did that already
dst = palm_offscreen + old_mouse_y * SCREEN_WIDTH + old_mouse_x; dst = _offScreenP + old_mouse_y * _screenWidth + old_mouse_x;
for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += SCREEN_WIDTH) { for (y = 0; y < old_mouse_h; ++y, bak += MAX_MOUSE_W, dst += _screenWidth) {
for (x = 0; x < old_mouse_w; ++x) { for (x = 0; x < old_mouse_w; ++x) {
dst[x] = bak[x]; dst[x] = bak[x];
} }
@ -857,10 +818,8 @@ OSystem_PALMOS::OSystem_PALMOS() {
_current_shake_pos = 0; _current_shake_pos = 0;
_new_shake_pos = 0; _new_shake_pos = 0;
memset(&_mouse_old_state,0,sizeof(MousePos)); memset(&_mouseOldState,0,sizeof(MousePos));
memset(&_mouse_cur_state,0,sizeof(MousePos)); memset(&_mouseCurState,0,sizeof(MousePos));
_msg.state = 0;
_paletteDirtyStart = 0; _paletteDirtyStart = 0;
_paletteDirtyEnd = 0; _paletteDirtyEnd = 0;
@ -870,15 +829,16 @@ OSystem_PALMOS::OSystem_PALMOS() {
_sound.active = false; _sound.active = false;
_currentPalette = NULL; _currentPalette = NULL;
_mouse_backup = NULL; _mouseBackupP = NULL;
lastKeyPressed = -1; lastKeyPressed = -1;
lastKeyRepeat = 100; lastKeyRepeat = 100;
lastKeyModifier = MD_NONE; lastKeyModifier = MD_NONE;
_isPlaying = false; // sound
_isSndPlaying = false;
_sndData = (UInt8 *)MemPtrNew(512); _sndTempP = (UInt8 *)MemPtrNew(4096);
_sndDataP = (UInt8 *)MemPtrNew(1024);
} }
void OSystem_PALMOS::move_screen(int dx, int dy, int height) { void OSystem_PALMOS::move_screen(int dx, int dy, int height) {
@ -892,25 +852,25 @@ void OSystem_PALMOS::move_screen(int dx, int dy, int height) {
// move down // move down
// copy from bottom to top // copy from bottom to top
for (int y = height - 1; y >= dy; y--) for (int y = height - 1; y >= dy; y--)
copy_rect((byte *)palm_offscreen + SCREEN_WIDTH * (y - dy), SCREEN_WIDTH, 0, y, SCREEN_WIDTH, 1); copy_rect((byte *)_offScreenP + _screenWidth * (y - dy), _screenWidth, 0, y, _screenWidth, 1);
} else { } else {
// move up // move up
// copy from top to bottom // copy from top to bottom
for (int y = 0; y < height + dx; y++) for (int y = 0; y < height + dx; y++)
copy_rect((byte *)palm_offscreen + SCREEN_WIDTH * (y - dy), SCREEN_WIDTH, 0, y, SCREEN_WIDTH, 1); copy_rect((byte *)_offScreenP + _screenWidth * (y - dy), _screenWidth, 0, y, _screenWidth, 1);
} }
} else if (dy == 0) { } else if (dy == 0) {
// horizontal movement // horizontal movement
if (dx > 0) { if (dx > 0) {
// move right // move right
// copy from right to left // copy from right to left
for (int x = SCREEN_WIDTH - 1; x >= dx; x--) for (int x = _screenWidth - 1; x >= dx; x--)
copy_rect((byte *)palm_offscreen + x - dx, SCREEN_WIDTH, x, 0, 1, height); copy_rect((byte *)_offScreenP + x - dx, _screenWidth, x, 0, 1, height);
} else { } else {
// move left // move left
// copy from left to right // copy from left to right
for (int x = 0; x < SCREEN_WIDTH; x++) for (int x = 0; x < _screenWidth; x++)
copy_rect((byte *)palm_offscreen + x - dx, SCREEN_WIDTH, x, 0, 1, height); copy_rect((byte *)_offScreenP + x - dx, _screenWidth, x, 0, 1, height);
} }
} else { } else {
// free movement // free movement
@ -918,55 +878,6 @@ void OSystem_PALMOS::move_screen(int dx, int dy, int height) {
} }
} }
void OSystem_PALMOS::drawMessage() {
UInt32 msecs = get_msecs();
if ((msecs - _msg.time) >= _msg.wait) {
Int16 y = _msg.position * _msg.state + (_msg.state == -1 ? 320 : 308);
_msg.time = msecs;
WinSetDrawMode(winPaint);
WinSetBackColor(0);
WinSetTextColor(_msg.color);
HRFntSetFont(gVars->HRrefNum,hrTinyFont);
HRWinDrawChars(gVars->HRrefNum, _msg.text, StrLen(_msg.text), 2, y);
_msg.position += 2;
if (_msg.position > 12) {
_msg.position = 0;
_msg.state *= -1;
_msg.wait = 5000;
_msg.state = (_msg.state == -1 ? 0 : _msg.state);
} else {
_msg.wait = 100;
}
}
}
void OSystem_PALMOS::deleteMessage() {
if (_msg.state != 0) {
Int16 y = _msg.position * _msg.state + (_msg.state == -1 ? 320 : 308);
WinSetDrawMode(winPaint);
WinSetBackColor(0);
WinSetTextColor(0);
HRFntSetFont(gVars->HRrefNum,hrTinyFont);
HRWinDrawChars(gVars->HRrefNum, _msg.text, StrLen(_msg.text), 2, y);
}
}
void OSystem_PALMOS::addMessage(const Char *msg) {
if (_msg.state != 0)
deleteMessage();
_msg.state = -1;
_msg.position = 0;
StrCopy(_msg.text,msg);
_msg.time = get_msecs();
_msg.wait = 100;
_msg.color = RGBToColor(255,255,255);
}
bool OSystem_PALMOS::set_sound_proc(void *param, SoundProc *proc, byte format) { bool OSystem_PALMOS::set_sound_proc(void *param, SoundProc *proc, byte format) {
_sound.active = true; _sound.active = true;
@ -978,11 +889,10 @@ bool OSystem_PALMOS::set_sound_proc(void *param, SoundProc *proc, byte format) {
void OSystem_PALMOS::check_sound() { void OSystem_PALMOS::check_sound() {
// currently not supported // currently not supported
_sound.proc(_sound.param, _sndData, 512); _sound.proc(_sound.param, _sndTempP, 256);
} }
void OSystem_PALMOS::show_overlay() void OSystem_PALMOS::show_overlay() {
{
// hide the mouse // hide the mouse
undraw_mouse(); undraw_mouse();
@ -990,75 +900,72 @@ void OSystem_PALMOS::show_overlay()
clear_overlay(); clear_overlay();
} }
void OSystem_PALMOS::hide_overlay() void OSystem_PALMOS::hide_overlay() {
{
// hide the mouse // hide the mouse
undraw_mouse(); undraw_mouse();
_overlay_visible = false; _overlay_visible = false;
_overlaySaved = false; _overlaySaved = false;
memmove(palm_offscreen, tmpScreen, SCREEN_WIDTH*SCREEN_HEIGHT); memmove(_offScreenP, _tmpScreenP, _screenWidth * _screenHeight);
} }
void OSystem_PALMOS::clear_overlay() void OSystem_PALMOS::clear_overlay() {
{
if (!_overlay_visible) if (!_overlay_visible)
return; return;
// hide the mouse // hide the mouse
undraw_mouse(); undraw_mouse();
if (!_overlaySaved) if (!_overlaySaved) {
{ //memmove(palm_tmpscreen, palm_offscreen, SCREEN_WIDTH*SCREEN_HEIGHT); if (MemPtrDataStorage(_tmpScreenP))
DmWrite(tmpScreen, 0, palm_offscreen, SCREEN_WIDTH*SCREEN_HEIGHT); DmWrite(_tmpScreenP, 0, _offScreenP, _screenWidth * _screenHeight);
else
MemMove(_tmpScreenP, _offScreenP, _screenWidth * _screenHeight);
_overlaySaved = true; _overlaySaved = true;
} }
} }
void OSystem_PALMOS::grab_overlay(byte *buf, int pitch) void OSystem_PALMOS::grab_overlay(byte *buf, int pitch) {
{
if (!_overlay_visible) if (!_overlay_visible)
return; return;
// hide the mouse // hide the mouse
undraw_mouse(); undraw_mouse();
byte *src = tmpScreen; byte *src = _tmpScreenP;
int h = SCREEN_HEIGHT; int h = _screenHeight;
do { do {
memcpy(buf, src, SCREEN_WIDTH); memcpy(buf, src, _screenWidth);
src += SCREEN_WIDTH; src += _screenWidth;
buf += pitch; buf += pitch;
} while (--h); } while (--h);
} }
void OSystem_PALMOS::copy_rect_overlay(const byte *buf, int pitch, int x, int y, int w, int h) void OSystem_PALMOS::copy_rect_overlay(const byte *buf, int pitch, int x, int y, int w, int h) {
{
if (!_overlay_visible) if (!_overlay_visible)
return; return;
undraw_mouse(); undraw_mouse();
byte *dst = palm_offscreen + y * SCREEN_WIDTH + x; byte *dst = _offScreenP + y * _screenWidth + x;
do { do {
memcpy(dst, buf, w); memcpy(dst, buf, w);
dst += SCREEN_WIDTH; dst += _screenWidth;
buf += pitch; buf += pitch;
} while (--h); } while (--h);
} }
int16 OSystem_PALMOS::get_height() { int16 OSystem_PALMOS::get_height() {
return SCREEN_HEIGHT; return _screenHeight;
} }
int16 OSystem_PALMOS::get_width() { int16 OSystem_PALMOS::get_width() {
return SCREEN_WIDTH; return _screenWidth;
} }
byte OSystem_PALMOS::RGBToColor(uint8 r, uint8 g, uint8 b) byte OSystem_PALMOS::RGBToColor(uint8 r, uint8 g, uint8 b) {
{
NewGuiColor color = 255; NewGuiColor color = 255;
byte nearest = 255; byte nearest = 255;
byte check; byte check;
@ -1074,8 +981,7 @@ byte OSystem_PALMOS::RGBToColor(uint8 r, uint8 g, uint8 b)
if (check == 0) // perfect match if (check == 0) // perfect match
return i; return i;
else if (check<nearest) // else save and continue else if (check < nearest) { // else save and continue
{
color = i; color = i;
nearest = check; nearest = check;
} }
@ -1084,8 +990,7 @@ byte OSystem_PALMOS::RGBToColor(uint8 r, uint8 g, uint8 b)
return color; return color;
} }
void OSystem_PALMOS::ColorToRGB(byte color, uint8 &r, uint8 &g, uint8 &b) void OSystem_PALMOS::ColorToRGB(byte color, uint8 &r, uint8 &g, uint8 &b) {
{
r = _currentPalette[color].r; r = _currentPalette[color].r;
g = _currentPalette[color].g; g = _currentPalette[color].g;
b = _currentPalette[color].b; b = _currentPalette[color].b;

View file

@ -24,30 +24,7 @@
#define PALM_H #define PALM_H
#include <SonyClie.h> #include <SonyClie.h>
#include "SonySndLib.h"
#include "vibrate.h"
#include "globals.h"
#include "system.h" #include "system.h"
/*
typedef struct {
UInt16 HRrefNum;
UInt16 volRefNum;
FileRef logFile;
Boolean screenLocked;
Boolean vibrator;
} GlobalsDataType;
*/
//extern UInt16 gHRrefNum;
//extern Boolean gVibrator;
//extern Boolean gFlipping;
//extern Boolean gScreenLocked;
//extern GlobalsDataType *gVars;
//Err CheckHRmode();
Err HwrDisplayPalette(UInt8 operation, Int16 startIndex, Err HwrDisplayPalette(UInt8 operation, Int16 startIndex,
UInt16 paletteEntries, RGBColorType *tableP) UInt16 paletteEntries, RGBColorType *tableP)
@ -157,53 +134,37 @@ public:
static OSystem *create(UInt16 gfx_mode); static OSystem *create(UInt16 gfx_mode);
UInt8 _sndHandle; UInt8 _sndHandle;
Boolean _isPlaying; Boolean _isSndPlaying;
protected: protected:
bool _overlay_visible; bool _overlay_visible;
private: private:
struct {
Int16 state;
Int16 position;
UInt32 time;
UInt32 wait;
UInt8 color;
Char text[100];
} _msg;
void addMessage(const Char *msg);
void drawMessage();
void deleteMessage();
typedef void (OSystem_PALMOS::*RendererProc)(void); typedef void (OSystem_PALMOS::*RendererProc)(void);
RendererProc _renderer_proc; RendererProc _renderer_proc;
UInt8 *_sndData; UInt8 *_sndDataP, *_sndTempP;
void update_screen__flipping(); void update_screen__flipping();
void update_screen__dbuffer(); void update_screen__dbuffer();
void update_screen__direct(); void update_screen__direct();
WinHandle h_palm_screen; WinHandle _screenH;
WinHandle h_palm_offscreen; WinHandle _offScreenH;
// WinHandle h_palm_tmpscreen;
MemHandle tmpScreenHandle;
byte *palm_screen; byte *_screenP;
byte *palm_offscreen; byte *_offScreenP;
// byte *palm_tmpscreen; byte *_tmpScreenP;
byte *tmpScreen;
bool _mouse_visible; bool _mouseVisible;
bool _mouse_drawn; bool _mouseDrawn;
enum { enum {
MAX_MOUSE_W = 40, MAX_MOUSE_W = 40, // must be 80x80 with 640x480 games
MAX_MOUSE_H = 40 MAX_MOUSE_H = 40
}; };
int SCREEN_WIDTH, SCREEN_HEIGHT; int _screenWidth, _screenHeight;
bool _overlaySaved; bool _overlaySaved;
struct MousePos { struct MousePos {
@ -211,12 +172,12 @@ private:
}; };
UInt16 _mode; UInt16 _mode;
byte *_mouse_data; byte *_mouseDataP;
byte *_mouse_backup; byte *_mouseBackupP;
MousePos _mouse_cur_state; MousePos _mouseCurState;
MousePos _mouse_old_state; MousePos _mouseOldState;
int16 _mouse_hotspot_x; int16 _mouseHotspotX;
int16 _mouse_hotspot_y; int16 _mouseHotspotY;
int _current_shake_pos; int _current_shake_pos;
int _new_shake_pos; int _new_shake_pos;
@ -271,11 +232,6 @@ private:
eventsEnum lastEvent; eventsEnum lastEvent;
// sound support
SndPcmFormatType _snd_format;
SndPcmOptionsType _snd_options;
OSystem_PALMOS(); OSystem_PALMOS();
}; };

View file

@ -22,14 +22,11 @@
#include <ctype.h> #include <ctype.h>
#include "common/scummsys.h" #include "common/scummsys.h"
//#include "common/stdafx.h"
#include "common/engine.h" #include "common/engine.h"
#include "scumm/saveload.h" #include "scumm/saveload.h"
#include "palm.h" #include "palm.h"
//#include "gui/newgui.h"
//#include "gui/message.h"
#define MAX_BLOCK 64000 #define MAX_BLOCK 64000 // store in memory, before dump to file
// SaveFile class // SaveFile class
@ -103,24 +100,6 @@ int PalmSaveFile::fwrite(void *buf, int size, int cnt) {
class PalmSaveFileManager : public SaveFileManager { class PalmSaveFileManager : public SaveFileManager {
public: public:
/* SaveFile *open_savefile(const char *filename,
bool saveOrLoad)
{
PalmSaveFile *sf = new PalmSaveFile(filename,
(saveOrLoad? "wb":"rb"));
if(!sf->is_open()) {
delete sf;
sf = NULL;
}
return sf;
}
void list_savefiles(const char *prefix,
bool *marks, int num)
{
memset(marks, true, num*sizeof(bool));
}
*/
SaveFile *open_savefile(const char *filename, bool saveOrLoad); SaveFile *open_savefile(const char *filename, bool saveOrLoad);
void list_savefiles(const char *prefix, bool *marks, int num); void list_savefiles(const char *prefix, bool *marks, int num);
}; };

View file

@ -21,15 +21,19 @@
*/ */
#include <PalmOS.h> #include <PalmOS.h>
#include <PalmOSGlue.h>
#include <SonyClie.h> #include <SonyClie.h>
#include "StarterRsc.h" #include "StarterRsc.h"
#include "extras.h"
#include "skin.h" #include "skin.h"
#include "globals.h" #include "globals.h"
#include "pa1lib.h" #include "pa1lib.h"
#include "scumm_globals.h" #include "scumm_globals.h"
#include "extend.h" // for disable state #include "extend.h" // for disable state
#include "mathlib.h"
#include "vibrate.h"
void MemExtInit(); void MemExtInit();
void MemExtCleanup(); void MemExtCleanup();
/*********************************************************************** /***********************************************************************
@ -136,7 +140,6 @@ GlobalsDataType *gVars;
* Internal Constants * Internal Constants
* *
***********************************************************************/ ***********************************************************************/
#define appFileCreator 'ScVM' // register your own at http://www.palmos.com/dev/creatorid/
#define appVersionNum 0x01 #define appVersionNum 0x01
#define appPrefID 0x00 #define appPrefID 0x00
#define appPrefVersionNum 0x01 #define appPrefVersionNum 0x01