[Scummvm-cvs-logs] CVS: scummvm/backends/PalmOS/Src extend.cpp,NONE,1.1 extend.h,NONE,1.1 extras.cpp,NONE,1.1 extras.h,NONE,1.1 globals.h,NONE,1.1 init.cpp,NONE,1.1 palm.cpp,NONE,1.1 palm.h,NONE,1.1 palmsave.cpp,NONE,1.1 palmstart.cpp,NONE,1.1 saveslot.cpp,NONE,1.1 scumm_globals.h,NONE,1.1 skin.h,NONE,1.1 vibrate.h,NONE,1.1
Max Horn
fingolfin at users.sourceforge.net
Wed Apr 30 04:34:08 CEST 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/backends/PalmOS/Src/missing _stdio.cpp,NONE,1.1 _stdlib.cpp,NONE,1.1 _string.cpp,NONE,1.1 _time.cpp,NONE,1.1 _unistd.cpp,NONE,1.1 assert.h,NONE,1.1 fcntl.h,NONE,1.1 math.h,NONE,1.1 stdio.h,NONE,1.1 stdlib.h,NONE,1.1 string.h,NONE,1.1 time.h,NONE,1.1 unistd.h,NONE,1.1
- Next message: [Scummvm-cvs-logs] CVS: scummvm/backends/PalmOS/Src/missing/sys stat.h,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/backends/PalmOS/Src
In directory sc8-pr-cvs1:/tmp/cvs-serv1788/Src
Added Files:
extend.cpp extend.h extras.cpp extras.h globals.h init.cpp
palm.cpp palm.h palmsave.cpp palmstart.cpp saveslot.cpp
scumm_globals.h skin.h vibrate.h
Log Message:
started to merge in Chrilith's PalmOS port
--- NEW FILE: extend.cpp ---
#include <PalmOS.h>
#include "extend.h"
#include "string.h"
#include "palm.h"
/*
//Sony clie PalmOS<5
void BmpDrawDDBitmap(const FormType *formP, DmResID bitmapID)
{
MemHandle hTemp;
BitmapType* bmTemp;
Coord x,y;
hTemp = DmGetResource(bitmapRsc,bitmapID);
bmTemp = (BitmapType*)MemHandleLock(hTemp);
FrmGetObjectPosition(formP, FrmGetObjectIndex(formP,bitmapID), &x, &y);
HRWinDrawBitmap(gHRrefNum,bmTemp, x*2, y*2);
MemHandleUnlock(hTemp);
DmReleaseResource(hTemp);
// palmos 5 : need to set the object to usable
}
*/
UInt16 StrReplace(Char *ioStr, UInt16 inMaxLen, const Char *inParamStr, const Char *fndParamStr)
{
Char *found;
Boolean quit = false;
UInt16 occurences = 0;
UInt16 newLength;
UInt16 l1 = StrLen(fndParamStr);
UInt16 l2 = 0;
UInt16 l3 = StrLen(ioStr);
UInt16 next = 0;
if (inParamStr)
l2 = StrLen(inParamStr); // can be null to know how many occur.
while (((found = StrStr(ioStr+next, fndParamStr)) != NULL) && (!quit))
{
occurences++;
newLength = (StrLen(ioStr) - l1 + l2);
if ( newLength > inMaxLen )
{
quit = true;
occurences--;
}
else if (inParamStr)
{
MemMove(found + l2, found + l1, inMaxLen-(found-ioStr+l2));
MemMove(found, inParamStr, l2);
next = found - ioStr + l2;
}
else
next = found - ioStr + l1;
}
if (inParamStr)
ioStr[l3 + l2*occurences - l1*occurences] = 0;
return occurences;
}
void WinDrawWarpChars(const Char *chars, Int16 len, Coord x, Coord y, Coord maxWidth)
{
Char *part = (Char *)chars;
Coord x2 = x;
Int16 next;
if (part[StrLen(part)-1] == '\n')
part[StrLen(part)-1] = 0;
part = StrTok(part," ");
while ( part )
{
next = FntLineWidth (part, StrLen(part)) + FntLineWidth (" ",1);
if ((x2 + next - x) > maxWidth)
{
x2 = x;
y += FntLineHeight();
}
//HRWinDrawTruncChars(gHRrefNum, part, StrLen(part), x2, y, maxWidth - (x2-x));
WinDrawTruncChars(part, StrLen(part), x2, y, maxWidth - (x2-x));
x2 += next;
part = StrTok(NULL," ");
}
}
--- NEW FILE: extend.h ---
#ifndef EXTEND_H
#define EXTEND_H
extern const Char *SCUMMVM_SAVEPATH; // extras.cpp
#define DISABLE_SKY
#define DISABLE_SIMON
#define OutputDebugString PalmFatalError
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);
void PalmFatalError(const Char *err);
#endif
--- NEW FILE: extras.cpp ---
//##############################################################################
#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;
}*/
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
--- NEW FILE: extras.h ---
//##############################################################################
#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);
--- NEW FILE: globals.h ---
#ifndef GLOBALS_H
#define GLOBALS_H
typedef struct {
DmOpenRef globals[3];
UInt16 HRrefNum;
UInt16 volRefNum;
FileRef logFile;
Boolean screenLocked;
Boolean vibrator;
Boolean stdPalette;
/*
struct {
UInt16 speaker;
UInt16 headphone;
} volume;
*/
struct {
UInt8 on;
UInt8 off;
} indicator;
struct {
UInt8 *pageAddr1;
UInt8 *pageAddr2;
} flipping;
} GlobalsDataType;
extern GlobalsDataType *gVars;
#endif
--- NEW FILE: init.cpp ---
//#include <PalmOS.h>
//#include "palm.h"
//#include "starterrsc.h"
//UInt16 gHRrefNum = 0;
//Boolean gVibrator = false;
//Boolean gFlipping = false;
//Boolean gScreenLocked = false;
--- NEW FILE: palm.cpp ---
//##############################################################################
//##############################################################################
#include "stdafx.h"
#include "scumm.h"
#include "mididrv.h"
#include "gameDetector.h"
#include "common/scaler.h"
//##############################################################################
#include "palm.h"
#include "starterrsc.h"
#include "pa1lib.h"
#include "sonychars.h"
//extern UInt8 _indicatorColorOn,_indicatorColorOff;
#define SAVEDELAY (5 * 60 * 1000) // five minutes
//#define EXITDELAY (2 * 1000) // delay to exit : calc button
#define EXITDELAY (100) // delay to exit : calc button : double tap 1/500 sec
//OSystem_PALMOS *g_palm = NULL;
[...1286 lines suppressed...]
check = (ABS(r2 - r) + ABS(g2 - g) + ABS(b2 - b))/3;
if (check == 0) // perfect match
return i;
else if (check<nearest) // else save and continue
{
color = i;
nearest = check;
}
}
return color;
}
void OSystem_PALMOS::ColorToRGB(byte color, uint8 &r, uint8 &g, uint8 &b)
{
r = _currentPalette[color].r;
g = _currentPalette[color].g;
b = _currentPalette[color].b;
}
--- NEW FILE: palm.h ---
#ifndef PALM_H
#define PALM_H
#include <SonyClie.h>
#include "SonySndLib.h"
#include "vibrate.h"
#include "globals.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,
UInt16 paletteEntries, RGBColorType *tableP)
SYS_TRAP(sysTrapHwrDisplayPalette);
//-- 02-12-17 --////////////////////////////////////////////////////////////////
class OSystem_PALMOS : public OSystem {
public:
// Set colors of the palette
void set_palette(const byte *colors, uint start, uint num);
// Set the size of the video bitmap.
// Typically, 320x200
void init_size(uint w, uint h);
// Draw a bitmap to screen.
// The screen will not be updated to reflect the new bitmap
void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h);
// Moves the screen content around by the given amount of pixels
// but only the top height pixel rows, the rest stays untouched
void move_screen(int dx, int dy, int height);
// Update the dirty areas of the screen
void update_screen();
// Either show or hide the mouse cursor
bool show_mouse(bool visible);
// Set the position of the mouse cursor
void set_mouse_pos(int x, int y);
// Warp the mouse cursor. Where set_mouse_pos() only informs the
// backend of the mouse cursor's current position, this function
// actually moves the cursor to the specified position.
void warp_mouse(int x, int y);
// Set the bitmap that's used when drawing the cursor.
void set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y);
// Shaking is used in SCUMM. Set current shake position.
void set_shake_pos(int shake_pos);
// Get the number of milliseconds since the program was started.
uint32 get_msecs();
// Delay for a specified amount of milliseconds
void delay_msecs(uint msecs);
// Create a thread
void *create_thread(ThreadProc *proc, void *param);
// Get the next event.
// Returns true if an event was retrieved.
bool poll_event(Event *event);
void SimulateArrowKeys(Event *event, Int8 iHoriz, Int8 iVert, Boolean repeat);
// Set function that generates samples
bool set_sound_proc(void *param, SoundProc *proc, byte sound);
// Poll cdrom status
// Returns true if cd audio is playing
bool poll_cdrom();
// Play cdrom audio track
void play_cdrom(int track, int num_loops, int start_frame, int end_frame);
// Stop cdrom audio track
void stop_cdrom();
// Update cdrom audio status
void update_cdrom();
// Add a callback timer
void set_timer(int timer, int (*callback)(int));
// Mutex handling
void *create_mutex(void);
void lock_mutex(void *mutex);
void unlock_mutex(void *mutex);
void delete_mutex(void *mutex);
// Quit
void quit();
bool _quit;
// Overlay
void show_overlay();
void hide_overlay();
void clear_overlay();
void grab_overlay(byte *buf, int pitch);
void copy_rect_overlay(const byte *buf, int pitch, int x, int y, int w, int h);
int16 get_width();
int16 get_height();
byte RGBToColor(uint8 r, uint8 g, uint8 b);
void ColorToRGB(byte color, uint8 &r, uint8 &g, uint8 &b);
// Set a parameter
uint32 property(int param, Property *value);
// Savefile management
SaveFileManager *get_savefile_manager();
static OSystem *create(UInt16 gfx_mode);
UInt8 _sndHandle;
Boolean _isPlaying;
protected:
bool _overlay_visible;
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);
RendererProc _renderer_proc;
UInt8 *_sndData;
void update_screen__flipping();
void update_screen__dbuffer();
void update_screen__direct();
WinHandle h_palm_screen;
WinHandle h_palm_offscreen;
WinHandle h_palm_tmpscreen;
byte *palm_screen;
byte *palm_offscreen;
byte *palm_tmpscreen;
bool _mouse_visible;
bool _mouse_drawn;
enum {
MAX_MOUSE_W = 40,
MAX_MOUSE_H = 40
};
int SCREEN_WIDTH, SCREEN_HEIGHT;
bool _overlaySaved;
struct MousePos {
int16 x,y,w,h;
};
UInt16 _mode;
byte *_mouse_data;
byte *_mouse_backup;
MousePos _mouse_cur_state;
MousePos _mouse_old_state;
int16 _mouse_hotspot_x;
int16 _mouse_hotspot_y;
int _current_shake_pos;
int _new_shake_pos;
UInt16 _decaly, _screeny;
Boolean _vibrate;
UInt32 _exit_delay;
struct {
uint32 duration, next_expiry;
bool active;
int (*callback) (int);
} _timer;
struct {
bool active;
ThreadProc *proc;
void *param;
struct {
UInt32 value;
UInt32 status;
} sleep;
} _thread;
struct {
bool active;
SoundProc *proc;
void *param;
} _sound;
// Palette data
RGBColorType *_currentPalette;
uint _paletteDirtyStart, _paletteDirtyEnd;
void check_sound();
void draw_mouse();
void undraw_mouse();
void load_gfx_mode();
void unload_gfx_mode();
/*
void hotswap_gfx_mode();
void get_320x200_image(byte *buf);
*/ static void autosave();
// PALM spec
void drawKeyState();
Int32 lastKeyPressed;
UInt32 lastKeyRepeat;
UInt8 lastKeyModifier;
eventsEnum lastEvent;
// sound support
SndPcmFormatType _snd_format;
SndPcmOptionsType _snd_options;
OSystem_PALMOS();
};
#endif
--- NEW FILE: palmsave.cpp ---
#include <ctype.h>
#include "common/scummsys.h"
//#include "common/stdafx.h"
#include "common/engine.h"
#include "scumm/saveload.h"
#include "palm.h"
//#include "gui/newgui.h"
//#include "gui/message.h"
#define MAX_BLOCK 64000
// SaveFile class
class PalmSaveFile : public SaveFile {
public:
PalmSaveFile(const char *filename, const char *mode);
~PalmSaveFile();
bool is_open() { return file != NULL; }
int fread(void *buf, int size, int cnt);
int fwrite(void *buf, int size, int cnt);
// must be removed
int feof() { return ::feof(file); }
private :
FILE *file;
UInt8 * _readWriteData;
UInt32 _readWritePos;
bool _needDump;
};
PalmSaveFile::PalmSaveFile(const char *filename, const char *mode) {
_readWriteData = NULL;
_readWritePos = 0;
_needDump = false;
file = ::fopen(filename, mode);
}
PalmSaveFile::~PalmSaveFile() {
if (file) {
if (_needDump && _readWriteData) {
::fwrite(_readWriteData, _readWritePos, 1, file);
free(_readWriteData);
}
::fclose(file);
}
}
int PalmSaveFile::fread(void *buf, int size, int cnt) {
return ::fread(buf, size, cnt, file);
}
int PalmSaveFile::fwrite(void *buf, int size, int cnt) {
UInt32 fullsize = size*cnt;
if (fullsize<=MAX_BLOCK)
{
if (!_readWriteData)
_readWriteData = (byte *)malloc(MAX_BLOCK);
if ((_readWritePos+fullsize)>MAX_BLOCK) {
::fwrite(_readWriteData, _readWritePos, 1, file);
_readWritePos = 0;
_needDump = false;
}
MemMove(_readWriteData + _readWritePos, buf, fullsize);
_readWritePos += fullsize;
_needDump = true;
return cnt;
}
return ::fwrite(buf, size, cnt, file);
}
// SaveFileManager class
class PalmSaveFileManager : public SaveFileManager {
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);
void list_savefiles(const char *prefix, bool *marks, int num);
};
SaveFile *PalmSaveFileManager::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 PalmSaveFileManager::list_savefiles(const char *prefix, bool *marks, int num) {
FileRef fileRef;
// try to open the dir
Err e = VFSFileOpen(gVars->volRefNum, SCUMMVM_SAVEPATH, vfsModeRead, &fileRef);
memset(marks, false, num*sizeof(bool));
if (e != errNone)
return;
// enumerate all files
Char *nameonly = strrchr(prefix,'/') + 1;
UInt32 dirEntryIterator = vfsIteratorStart;
Char filename[32];
FileInfoType info = {0, filename, 32};
UInt16 length = StrLen(nameonly);
int slot = 0;
while (dirEntryIterator != vfsIteratorStop) {
e = VFSDirEntryEnumerate (fileRef, &dirEntryIterator, &info);
if (e != expErrEnumerationEmpty) { // there is something
if (StrLen(info.nameP) == (length + 2)) { // consider max 99, filename length is ok
if (StrNCaselessCompare(nameonly, info.nameP, length) == 0) { // this seems to be a save file
if (isdigit(info.nameP[length]) && isdigit(info.nameP[length+1])) {
slot = StrAToI(filename + length);
if (slot >= 0 && slot < num)
*(marks+slot) = true;
}
}
}
}
}
VFSFileClose(fileRef);
}
// OSystem
SaveFileManager *OSystem_PALMOS::get_savefile_manager() {
return new PalmSaveFileManager();
}
--- NEW FILE: palmstart.cpp ---
/******************************************************************************
*
* File: palmstart.cpp
*
*****************************************************************************/
#include <PalmOS.h>
#include <SonyClie.h>
#include "StarterRsc.h"
#include "extras.h"
#include "skin.h"
#include "globals.h"
#include "pa1lib.h"
#include "scumm_globals.h"
#include "extend.h" // for disable state
void MemExtInit();
void MemExtCleanup();
/***********************************************************************
[...3141 lines suppressed...]
/***********************************************************************
*
* FUNCTION: PilotMain
*
* DESCRIPTION: This is the main entry point for the application.
*
* PARAMETERS: cmd - word value specifying the launch code.
* cmdPB - pointer to a structure that is associated with the launch code.
* launchFlags - word value providing extra information about the launch.
* RETURNED: Result of launch
*
* REVISION HISTORY:
*
*
***********************************************************************/
UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
return ScummVMPalmMain(cmd, cmdPBP, launchFlags);
}
--- NEW FILE: saveslot.cpp ---
//#include "extras.h"
#include <string.h>
#include "scummsys.h"
#include "saveload.h"
#define MAX_BLOCK 64000
enum SaveLoadState {
STATE_LOAD,
STATE_SAVE,
STATE_NONE
};
class SaveLoadData {
public:
SaveLoadData();
SaveLoadState _currentState;
byte * _readWriteData;
uint32 _readWritePos;
bool _needDump;
};
SaveLoadData current;
SaveLoadData::SaveLoadData()
{
_currentState = STATE_NONE;
_readWritePos = 0;
_needDump = false;
}
bool SerializerStream::fopen(const char *filename, const char *mode)
{
if (current._currentState != STATE_NONE)
fclose();
context = ::fopen(filename, mode);
if (context != NULL) {
current._currentState = ((strcmp(mode,"rb")==0) ? STATE_LOAD : STATE_SAVE);
return true;
}
return false;
}
int SerializerStream::fread(void *buf, int size, int cnt)
{
return ::fread(buf, size, cnt, (FILE *)context);
}
int SerializerStream::fwrite(void *buf, int size, int cnt) {
int fullsize = size*cnt;
if (current._currentState == STATE_SAVE && fullsize<=MAX_BLOCK)
{
if (!current._readWriteData)
current._readWriteData = (byte *)malloc(MAX_BLOCK);
if ((current._readWritePos+fullsize)>MAX_BLOCK) {
::fwrite(current._readWriteData, current._readWritePos, 1, (FILE *)context);
current._readWritePos = 0;
current._needDump = false;
}
memcpy(current._readWriteData + current._readWritePos, buf, fullsize);
current._readWritePos += fullsize;
current._needDump = true;
return cnt;
}
return ::fwrite(buf, size, cnt, (FILE *)context);
}
void SerializerStream::fclose()
{
if (current._needDump && current._readWriteData != NULL) {
if (current._currentState == STATE_SAVE)
::fwrite(current._readWriteData, current._readWritePos, 1, (FILE *)context);
free(current._readWriteData);
current._readWriteData = NULL;
}
current._readWritePos = 0;
current._needDump = false;
current._currentState = STATE_NONE;
::fclose((FILE *)context);
}
--- NEW FILE: scumm_globals.h ---
#define GBVARS_DIGSTATEMUSICMAP_INDEX 0
#define GBVARS_DIGSTATEMUSICTABLE_INDEX 1
#define GBVARS_COMISTATEMUSICTABLE_INDEX 2
#define GBVARS_COMISEQMUSICTABLE_INDEX 3
#define GBVARS_DIGSEQMUSICTABLE_INDEX 4
#define GBVARS_FTSTATEMUSICTABLE_INDEX 5
#define GBVARS_FTSEQMUSICTABLE_INDEX 6
#define GBVARS_GUIFONT_INDEX 7
#define GBVARS_OLD256MIDIHACK_INDEX 8 // fix me : sizeof is used on scummvm
#define GBVARS_CODEC37TABLE_INDEX 9
#define GBVARS_CODEC47TABLE_INDEX 10
#define GBVARS_TRANSITIONEFFECTS_INDEX 11
#define GBVARS_SIMON1SETTINGS_INDEX 0
#define GBVARS_SIMON1AMIGASETTINGS_INDEX 1
#define GBVARS_SIMON1DEMOSETTINGS_INDEX 2
#define GBVARS_SIMON2WINSETTINGS_INDEX 3
#define GBVARS_SIMON2MACSETTINGS_INDEX 4
#define GBVARS_SIMON2DOSSETTINGS_INDEX 5
#define GBVARS_HEBREWVIDEOFONT_INDEX 6
#define GBVARS_SPANISHVIDEOFONT_INDEX 7
#define GBVARS_VIDEOFONT_INDEX 8
#define GBVARS_SCUMM 0
#define GBVARS_SIMON 1
#define GBVARS_SKY 2
#define GSETPTR(var,index,format,id) var = (format *)GBGetRecord(index,id);
#define GRELEASEPTR(index,id) GBReleaseRecord(index,id);
void *GBGetRecord(UInt16 index, UInt16 id);
void GBReleaseRecord(UInt16 index, UInt16 id);
void IMuseDigital_initGlobals();
void IMuseDigital_releaseGlobals();
void Simon_initGlobals();
void Simon_releaseGlobals();
void NewGui_initGlobals();
void NewGui_releaseGlobals();
void Resource_initGlobals();
void Resource_releaseGlobals();
void Codec47_initGlobals();
void Codec47_releaseGlobals();
void Gfx_initGlobals();
void Gfx_releaseGlobals();
--- NEW FILE: skin.h ---
#define skinList 500
#define skinColors 600
//#define skinPalette 510
#define skinButtonNone 0
#define skinSliderUpArrow 2000
#define skinSliderDownArrow 2100
#define skinButtonGameParams 3000
#define skinButtonGameAdd 3100
#define skinButtonGameEdit 3200
#define skinButtonGameDelete 4000
#define skinButtonGameStart 7000
#define skinBackgroundImageTop 1000
#define skinBackgroundImageBottom 1010
///
#define skinToolsBackground 1100
#define skinListUpArrowNormal 1500
#define skinListUpArrowOver 1510
#define skinListUpArrowDisabled 1540
#define skinListDownArrowNormal 1800
#define skinListDownArrowOver 1810
#define skinListDownArrowDisabled 1840
#define skinButtonGameInfoNormal 2000
#define skinButtonGameInfoOver 2010
#define skinButtonGameInfoDisabled 2040
#define skinButtonGameParamNormal 3000
#define skinButtonGameParamOver 3010
#define skinButtonGameDeleteNormal 4000
#define skinButtonGameDeleteOver 4010
#define skinButtonGameDeleteDisabled 4040
#define skinButtonVibratorNormal 5000
#define skinButtonVibratorOver 5010
#define skinButtonVibratorSelected 5020
#define skinButtonVibratorSelectedOver 5030
#define skinButtonVibratorDisabled 5040
#define skinButtonSleepNormal 6000
#define skinButtonSleepOver 6010
#define skinButtonSleepSelected 6020
#define skinButtonSleepSelectedOver 9030
#define skinButtonPlayNormal 7000
#define skinButtonPlayOver 7010
#define skinButtonPlayDisabled 7040
--- NEW FILE: vibrate.h ---
/**********************************************************************
** **
** vibrate.h **
** **
** Definitions for setting/retrieving the state of the vibrator on **
** PalmOS 4.x devices. These calls are not officially supported by **
** Palm Inc and subsidiaries. It is not guaranteed that these calls **
** will work at all or at least the same on every device. YOU ARE **
** USING THESE ENTIRELY ON YOUR VERY OWN RISK ! **
** **
** Please send corrections to dseifert at dseifert.com **
**********************************************************************/
#include <PalmOS.h>
/* HwrVibrateAttributes takes three arguments:
** Boolean set Should the setting be set (1) or retrieved (0)
** UInt32 setting what should be set
** void* value pointer to the value to set, or to store the
** retrieved setting
*/
Err HwrVibrateAttributes(Boolean set, UInt32 setting, void *value)
SYS_TRAP(sysTrapHwrVibrateAttributes);
/* to determine whether the vibrator is supported on a specific device, you
** need to make sure that you are running on PalmOS 4.x (so that the
** trap exists), that the attention manager exists and you need to check
** whether HwrVibrateAttributes(0, 1, &active) returns an error code of
** 0. ('active' is a Boolean).
*/
/***************************************************************/
/* For the second parameter, the following defines can be used */
/***************************************************************/
/* *value points to a Boolean stating the state of the vibrator */
#define kHwrVibrateActive 1
/* *value points to a UInt16, specifying the length of one cycle.
** value is in ticks (1/100 seconds) */
#define kHwrVibrateRate 2
/* *value points to a UInt32, specifying the pattern of vibrating
**
** example:
** 0xFFFFFFFF stay on, no vibrating
** 0x0F0F0F0F vibrate four times in equal intervals
** 0xAAAAAAAA vibrate really fast (not recommended)
** 0x0F0F0000 vibrate twice, then pause
*/
#define kHwrVibratePattern 3
/* *value points to a UInt16, specifying the delay between two
** cycles in ticks */
#define kHwrVibrateDelay 4
/* *value points to a UInt16 specifying the amount of repeats. */
#define kHwrVibrateRepeatCount 5
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/backends/PalmOS/Src/missing _stdio.cpp,NONE,1.1 _stdlib.cpp,NONE,1.1 _string.cpp,NONE,1.1 _time.cpp,NONE,1.1 _unistd.cpp,NONE,1.1 assert.h,NONE,1.1 fcntl.h,NONE,1.1 math.h,NONE,1.1 stdio.h,NONE,1.1 stdlib.h,NONE,1.1 string.h,NONE,1.1 time.h,NONE,1.1 unistd.h,NONE,1.1
- Next message: [Scummvm-cvs-logs] CVS: scummvm/backends/PalmOS/Src/missing/sys stat.h,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list