more PalmOS changes

svn-id: r7220
This commit is contained in:
Max Horn 2003-04-30 12:43:56 +00:00
parent 42f156ddad
commit 81c3ade331
9 changed files with 116 additions and 13 deletions

View file

@ -54,6 +54,8 @@ const char *Engine::getSavePath() const {
#ifdef _WIN32_WCE
dir = _gameDataPath;
#elif defined(__PALM_OS__)
dir = SCUMMVM_SAVEPATH;
#else
#if !defined(MACOS_CARBON)
@ -104,8 +106,13 @@ Engine *Engine::createFromDetector(GameDetector *detector, OSystem *syst) {
}
void NORETURN CDECL error(const char *s, ...) {
#ifdef __PALM_OS__
char buf_input[256]; // 1024 is too big overflow the stack
char buf_output[256];
#else
char buf_input[1024];
char buf_output[1024];
#endif
va_list va;
va_start(va, s);
@ -132,6 +139,10 @@ void NORETURN CDECL error(const char *s, ...) {
drawError(buf_output);
#endif
#ifdef __PALM_OS__
PalmFatalError(buf_output);
#endif
// Finally exit. quit() will terminate the program if g_system iss present
if (g_system)
g_system->quit();
@ -140,7 +151,11 @@ void NORETURN CDECL error(const char *s, ...) {
}
void CDECL warning(const char *s, ...) {
#ifdef __PALM_OS__
char buf[256]; // 1024 is too big overflow the stack
#else
char buf[1024];
#endif
va_list va;
va_start(va, s);
@ -161,7 +176,11 @@ void CDECL warning(const char *s, ...) {
uint16 _debugLevel = 1;
void CDECL debug(int level, const char *s, ...) {
#ifdef __PALM_OS__
char buf[256]; // 1024 is too big overflow the stack
#else
char buf[1024];
#endif
va_list va;
if (level > _debugLevel)

View file

@ -82,7 +82,6 @@ void checkHeap();
// in this header. This serves two purposes:
// 1) Clean seperation from the game modules (scumm, simon) and the generic code
// 2) Faster (compiler doesn't have to parse lengthy header files)
#ifndef DISABLE_SCUMM
extern const VersionSettings *Engine_SCUMM_targetList();
extern Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst);

View file

@ -33,8 +33,8 @@ FILE *File::fopenNoCase(const char *filename, const char *directory, const char
if (buf[strlen(buf)-1] != ':' && buf[strlen(buf)-1] != '/')
#endif
#ifndef __GP32__
strcat(buf, "/");
#if !defined(__GP32__) && !defined(__PALM_OS__)
strcat(buf, "/"); // prevent double /
#endif
}
strcat(buf, filename);
@ -61,7 +61,9 @@ FILE *File::fopenNoCase(const char *filename, const char *directory, const char
#ifdef __MORPHOS__
if (buf[strlen(buf) - 1] != ':' && buf[strlen(buf) - 1] != '/')
#endif
strcat(buf, "/");
#ifndef __PALM_OS__
strcat(buf, "/"); // PALMOS
#endif
}
strcat(buf, dirs[l]);
int8 len = strlen(buf);

View file

@ -38,6 +38,9 @@
current_option = NULL
// DONT FIXME: DO NOT ORDER ALPHABETICALY, THIS IS ORDERED BY IMPORTANCE/CATEGORY! :)
#ifdef __PALM_OS__
static const char USAGE_STRING[] = "NoUsageString"; // save more data segment space
#else
static const char USAGE_STRING[] =
"ScummVM - Scumm Interpreter\n"
"Syntax:\n"
@ -73,13 +76,14 @@ static const char USAGE_STRING[] =
"\t-d[<num>] - enable debug output (debug level [1])\n"
"\t-u - dump scripts\n"
;
#endif
// This contains a pointer to a list of all supported games.
const VersionSettings *version_settings = NULL;
static const struct GraphicsMode gfx_modes[] = {
{"normal", "Normal (no scaling)", GFX_NORMAL},
{"1x", "Normal (no scaling)", GFX_NORMAL},
#ifndef __PALM_OS__ // reduce contant data size
{"2x", "2x", GFX_DOUBLESIZE},
{"3x", "3x", GFX_TRIPLESIZE},
{"2xsai", "2xSAI", GFX_2XSAI},
@ -88,6 +92,10 @@ static const struct GraphicsMode gfx_modes[] = {
{"advmame2x", "AdvMAME2x", GFX_ADVMAME2X},
{"tv2x", "TV2x", GFX_TV2X},
{"dotmatrix", "DotMatrix", GFX_DOTMATRIX},
#else
{"flipping", "Page Flipping", GFX_FLIPPING},
{"dbuffer", "Double Buffer", GFX_DOUBLEBUFFER},
#endif
{0, 0}
};
@ -108,6 +116,7 @@ static const struct Language languages[] = {
static const struct MusicDriver music_drivers[] = {
{"auto", "Default", MD_AUTO},
{"null", "No music", MD_NULL},
#ifndef __PALM_OS__ // reduce contant data size
{"windows", "Windows MIDI", MD_WINDOWS},
{"seq", "SEQ", MD_SEQ},
{"qt", "QuickTime", MD_QTMUSIC},
@ -115,6 +124,9 @@ static const struct MusicDriver music_drivers[] = {
{"etude", "Etude", MD_ETUDE},
{"alsa", "ALSA", MD_ALSA},
{"adlib", "Adlib", MD_ADLIB},
#else
{"ypa1", "Yamaha Pa1", MD_YPA1},
#endif
{0, 0, 0}
};
@ -493,7 +505,11 @@ bool GameDetector::isMusicDriverAvailable(int drv) {
switch(drv) {
case MD_AUTO:
case MD_NULL: return true;
#ifndef __PALM_OS__ // not avalaible on palmos : Clie use only ADPCM data and cannot be converted on the fly, may be possible on TT ?
case MD_ADLIB: return true;
#else
case MD_YPA1: return true;
#endif
#if defined(WIN32) && !defined(_WIN32_WCE)
case MD_WINDOWS: return true;
#endif
@ -588,14 +604,17 @@ int GameDetector::detectMain() {
/* Use the adlib sound driver if auto mode is selected,
* and the game is one of those that want adlib as
* default */
#ifndef __PALM_OS__ // currently adlib is not supported, is this really needed ?
if (_midi_driver == MD_AUTO && _features & GF_ADLIB_DEFAULT) {
_midi_driver = MD_ADLIB;
_use_adlib = true;
}
#endif
if (!_gameDataPath) {
warning("No path was provided. Assuming the data files are in the current directory");
_gameDataPath = "";
#ifndef __PALM_OS__ // add last slash also in File::fopenNoCase, so this is not needed
} else if (_gameDataPath[strlen(_gameDataPath)-1] != '/'
#ifdef __MORPHOS__
&& _gameDataPath[strlen(_gameDataPath)-1] != ':'
@ -607,6 +626,7 @@ int GameDetector::detectMain() {
// need to allocate 2 extra bytes, one for the "/" and one for the NULL terminator
_gameDataPath = (char *)malloc((strlen(slashless) + 2) * sizeof(char));
sprintf(_gameDataPath, "%s/", slashless);
#endif
}
return (0);
@ -627,6 +647,8 @@ OSystem *GameDetector::createSystem() {
return OSystem_MAC_create(_gfx_mode, _fullScreen);
#elif defined(__GP32__) // ph0x
return OSystem_GP32_create(GFX_NORMAL, true);
#elif defined(__PALM_OS__) //chrilith
return OSystem_PALMOS_create(_gfx_mode);
#else
/* SDL is the default driver for now */
return OSystem_SDL_create(_gfx_mode, _fullScreen);
@ -642,6 +664,8 @@ MidiDriver *GameDetector::createMidi() {
drv = MD_WINDOWS; // MD_WINDOWS is default MidiDriver on windows targets
#elif defined(MACOSX)
drv = MD_COREAUDIO;
#elif defined(__PALM_OS__) // must be before mac
drv = MD_YPA1;
#elif defined(macintosh)
drv = MD_QTMUSIC;
#elif defined(__MORPHOS__)
@ -658,7 +682,11 @@ MidiDriver *GameDetector::createMidi() {
switch(drv) {
case MD_AUTO:
case MD_NULL: return MidiDriver_NULL_create();
#ifndef __PALM_OS__
case MD_ADLIB: _use_adlib = true; return MidiDriver_ADLIB_create();
#else
case MD_YPA1: return MidiDriver_YamahaPa1_create();
#endif
#if defined(WIN32) && !defined(_WIN32_WCE)
case MD_WINDOWS: return MidiDriver_WIN_create();
#endif
@ -668,7 +696,7 @@ MidiDriver *GameDetector::createMidi() {
#if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX)
case MD_SEQ: return MidiDriver_SEQ_create();
#endif
#if defined(MACOSX) || defined(macintosh)
#if (defined(MACOSX) || defined(macintosh)) && !defined(__PALM_OS__)
case MD_QTMUSIC: return MidiDriver_QT_create();
#endif
#if defined(MACOSX)

View file

@ -160,6 +160,9 @@ int main(int argc, char *argv[]) {
GetWindowsDirectory(scummhome, 256);
strcat(scummhome, "\\");
strcat(scummhome, DEFAULT_CONFIG_FILE);
#elif defined(__PALM_OS__)
strcpy(scummhome,"/PALM/Programs/ScummVM/");
strcat(scummhome, DEFAULT_CONFIG_FILE);
#else
strcpy(scummhome, DEFAULT_CONFIG_FILE);
#endif
@ -225,10 +228,11 @@ int main(int argc, char *argv[]) {
// ...and quit (the return 0 should never be reached)
system->quit();
delete system; // palmos leaks
return 0;
}
#ifndef __PALM_OS__
void *operator new(size_t size) {
return calloc(size, 1);
}
@ -236,4 +240,4 @@ void *operator new(size_t size) {
void operator delete(void *ptr) {
free(ptr);
}
#endif

View file

@ -35,6 +35,8 @@ public:
//Should go away. See scumm/saveload.cpp and scumm/imuse.cpp
virtual int fseek(long offs, int whence) = 0;
virtual int feof() = 0;
#elif defined(__PALM_OS__)
virtual int feof() = 0;
#endif
};
@ -60,6 +62,9 @@ public:
{ return ::fseek(fh, offs, whence); }
int feof()
{ return ::feof(fh); }
#elif defined(__PALM_OS__)
int feof()
{ return ::feof(fh); }
#endif
};

View file

@ -151,6 +151,41 @@
#define NORETURN
#endif
#elif defined(__PALMOS_TRAPS__) // PALMOS
#include <PalmOS.h>
#include <stdio.h>
#include "extend.h"
#define __PALM_OS__
#define scumm_stricmp stricmp// FIXME - this is definitly wrong. Try strcasecmp?
#define CHECK_HEAP
#define SCUMM_BIG_ENDIAN
#define SCUMM_NEED_ALIGNMENT
#define NONSTANDARD_SAVE
#define FORCEINLINE inline
#define CDECL
typedef unsigned char byte;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned long uint32;
typedef unsigned int uint;
typedef signed char int8;
typedef signed short int16;
typedef signed long int32;
typedef Boolean bool;
#define START_PACK_STRUCTS pack (1)
#define END_PACK_STRUCTS pack ()
#define GCC_PACK
#define NORETURN
#define NEED_STRDUP
#define NEWGUI_256
typedef byte NewGuiColor; // NEWGUI to 256 colors
#elif defined(macintosh)
#include <stdio.h>
@ -384,7 +419,9 @@
/* Initialized operator new */
// FIXME - get rid of these new/delete overrides!!! They conflict with the
// Standard C++ library, and they are only there to support lazy programmers anyway.
#ifndef __PALM_OS__
void * operator new(size_t size);
void operator delete(void *ptr);
#endif
#endif

View file

@ -27,6 +27,8 @@
static Engine * eng;
Timer::Timer(Engine * engine) {
memset(this,0,sizeof(Timer)); //palmos
_initialized = false;
_timerRunning = false;
eng = _engine = engine;

View file

@ -24,8 +24,9 @@
//
// 8-bit alpha blending routines
//
#ifndef __PALM_OS__
static int BlendCache[256][256];
#endif
//
// Find the entry in the given palette which matches the color defined by
// the tripel (r,b,g) most closely.
@ -54,6 +55,7 @@ int RGBMatch(byte *palette, int r, int g, int b) {
// Blend two 8 bit colors into a third, all colors being defined by palette indices.
//
int Blend(int src, int dst, byte *palette) {
#ifndef __PALM_OS__
int r, g, b;
int alpha = 128; // Level of transparency [0-256]
byte *srcpal = palette + (dst * 3);
@ -75,17 +77,22 @@ int Blend(int src, int dst, byte *palette) {
b /= 256;
return (BlendCache[dst][src] = RGBMatch(palette, r , g , b ));
#else
return 0;
#endif
}
//
// Reset the blending cache
//
void ClearBlendCache(byte *palette, int weight) {
#ifndef __PALM_OS__
for (int i = 0; i < 256; i++)
for (int j = 0 ; j < 256 ; j++)
// BlendCache[i][j] = i; // No alphablending
// BlendCache[i][j] = j; // 100% translucent
BlendCache[i][j] = -1; // Enable alphablending
#endif
}
//