wince initial support

This commit is contained in:
p.kosyh 2010-09-10 10:06:30 +00:00
parent 164d701ab3
commit 8f16637598
25 changed files with 151 additions and 74 deletions

View file

@ -1,4 +1,4 @@
VERSION := 1.2.1
VERSION := 1.2.2
PREFIX=./
DESTDIR=

View file

@ -1,6 +1,6 @@
# Contributor: Peter Kosyh <p.kosyhgmail.com>
pkgname=instead
pkgver=1.2.1
pkgver=1.2.2
pkgrel=1
pkgdesc="instead quest interpreter"
arch=('i686' 'x86_64')

View file

@ -1,4 +1,4 @@
VERSION := 1.2.1
VERSION := 1.2.2
DESTDIR=
BIN=

View file

@ -1,4 +1,4 @@
VERSION := 1.2.1
VERSION := 1.2.2
DESTDIR=
BIN=

View file

@ -1,4 +1,4 @@
VERSION := 1.2.1
VERSION := 1.2.2
PREFIX=/usr/local
DESTDIR=

View file

@ -1,4 +1,4 @@
VERSION := 1.2.1
VERSION := 1.2.2
PREFIX=./
DESTDIR=

View file

@ -1,4 +1,4 @@
VERSION := 1.2.1
VERSION := 1.2.2
PREFIX=
DESTDIR=

View file

@ -1,6 +1,6 @@
[Desktop Entry]
Encoding=UTF-8
Version=1.2.1
Version=1.2.2
Type=Application
Name=INSTEAD
Name[ru]=INSTEAD

View file

@ -13,7 +13,7 @@ body { font-family: Verdana, Arial, Helvetica, sans-serif;
</style>
<title>INSTEAD -- interpreter of simple text adventures for Unix and Windows</title>
</head><body bgcolor="#f0f0f0">
<h2>INSTEAD 1.2.1</h2>
<h2>INSTEAD 1.2.2</h2>
<p>INSTEAD -- interpreter of simple text adventures for Unix and Windows.<br>
INSTEAD was designed to interpret the games that are the mix of visual novels, text quests and classical 90'ss quests.</p>

View file

@ -1,4 +1,4 @@
.TH INSTEAD 6 "Version 1.2.1" Instead GAMES
.TH INSTEAD 6 "Version 1.2.2" Instead GAMES
.SH NAME

View file

@ -1,4 +1,4 @@
INSTEAD 1.2.1
INSTEAD 1.2.2
=============
WARNING! For successfull building you must install these development packages (names may vary in your distribution):

View file

@ -1,11 +1,11 @@
[Setup]
AppName=INSTEAD-KIT
AppVerName=INSTEAD 1.2.1
AppVerName=INSTEAD 1.2.2
DefaultDirName={pf}\Pinebrush games\INSTEAD
DefaultGroupName=Pinebrush games
UninstallDisplayIcon={app}\sdl-instead.exe
OutputDir=.
OutputBaseFilename=instead-kit-1.2.1
OutputBaseFilename=instead-kit-1.2.2
AllowNoIcons=true
[Languages]

View file

@ -1,11 +1,11 @@
[Setup]
AppName=INSTEAD
AppVerName=INSTEAD 1.2.1
AppVerName=INSTEAD 1.2.2
DefaultDirName={pf}\Pinebrush games\INSTEAD
DefaultGroupName=Pinebrush games
UninstallDisplayIcon={app}\sdl-instead.exe
OutputDir=.
OutputBaseFilename=instead-1.2.1
OutputBaseFilename=instead-1.2.2
AllowNoIcons=true
[Languages]

View file

@ -86,7 +86,7 @@ int game_select(const char *name)
g = game_lookup(name);
if ((!name || !*name) && !g)
return 0;
if (chdir(game_cwd))
if (setdir(game_cwd))
return -1;
if (g) {
char *oldgame = curgame_dir;
@ -96,11 +96,11 @@ int game_select(const char *name)
curgame_dir = oldgame;
return -1;
}
if (chdir(g->path)) {
if (setdir(g->path)) {
curgame_dir = oldgame;
return -1;
}
if (instead_load(MAIN_FILE)) {
if (instead_load(dirpath(MAIN_FILE))) {
curgame_dir = oldgame;
return -1;
}
@ -128,13 +128,13 @@ int games_rename(void)
{
int i;
char cwd[PATH_MAX];
getcwd(cwd, sizeof(cwd));
chdir(game_cwd);
getdir(cwd, sizeof(cwd));
setdir(game_cwd);
for (i = 0; i < games_nr; i++) {
FREE(games[i].name);
games[i].name = game_name(games[i].path, games[i].dir);
games[i].name = game_name(dirpath(games[i].path), games[i].dir);
}
chdir(cwd);
setdir(cwd);
return 0;
}
@ -670,7 +670,7 @@ int counter_fn(int interval, void *p)
int game_init(const char *name)
{
getcwd(game_cwd, sizeof(game_cwd));
getdir(game_cwd, sizeof(game_cwd));
unix_path(game_cwd);
if (name)
@ -690,12 +690,12 @@ int game_init(const char *name)
if (game_select(name))
return -1;
if (curgame_dir && !access(THEME_FILE, R_OK)) {
if (curgame_dir && !access(dirpath(THEME_FILE), R_OK)) {
game_own_theme = 1;
}
if (game_own_theme && opt_owntheme) {
if (theme_load(THEME_FILE))
if (theme_load(dirpath(THEME_FILE)))
return -1;
} else if (curtheme_dir && strcmp(DEFAULT_THEME, curtheme_dir)) {
game_theme_load(curtheme_dir);
@ -753,7 +753,7 @@ void game_done(int err)
if (opt_autosave && curgame_dir && !err)
game_save(0);
chdir(game_cwd);
setdir(game_cwd);
// cfg_save();
if (menu_shown)
@ -1238,11 +1238,11 @@ void game_music_player(void)
} else if (!last_music && mus) {
game_stop_mus(500);
last_music = mus;
snd_play_mus(mus, 0, loop - 1);
snd_play_mus(dirpath(mus), 0, loop - 1);
} else if (strcmp(last_music, mus)) {
game_stop_mus(500);
last_music = mus;
snd_play_mus(mus, 0, loop - 1);
snd_play_mus(dirpath(mus), 0, loop - 1);
} else
free(mus);
}
@ -1264,7 +1264,7 @@ static int wavs_pos = 0;
static wav_t sound_add(const char *fname)
{
wav_t w;
w = snd_load_wav(fname);
w = snd_load_wav(dirpath(fname));
if (!w)
return NULL;
snd_free_wav(wavs[wavs_pos].wav);
@ -1486,7 +1486,7 @@ int game_cmd(char *cmd)
img_t img;
if (new_pict) {
img = gfx_load_image(pict);
img = gfx_load_image(dirpath(pict));
if (el_img(el_spic))
gfx_free_image(el_img(el_spic));
el(el_spic)->p.p = NULL;

View file

@ -708,7 +708,7 @@ static img_t _gfx_load_combined_image(char *filename)
} else if (*ep) {
goto err;
}
img = _gfx_load_image(strip(p));
img = _gfx_load_image(dirpath(strip(p)));
if (img)
img = gfx_display_alpha(img);
if (img) {
@ -1032,8 +1032,11 @@ int gfx_set_mode(int w, int h, int fs)
screen = SDL_SetVideoMode(gfx_width, gfx_height, 16, SDL_DOUBLEBUF | SDL_HWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) );
#endif
if (screen == NULL) {
fprintf(stderr, "Unable to set %dx%d video: %s\n", w, h, SDL_GetError());
return -1;
screen = SDL_SetVideoMode(0, 0, 0, SDL_ANYFORMAT | SDL_HWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) );
if (!screen) {
fprintf(stderr, "Unable to set %dx%d video: %s\n", w, h, SDL_GetError());
return -1;
}
}
gfx_clear(0, 0, gfx_width, gfx_height);
return 0;
@ -2550,7 +2553,7 @@ img_t get_img(struct layout *layout, char *p)
img = cache_get(layout->img_cache, p);
if (!img) {
unix_path(p);
if (!(img = gfx_load_image(p)))
if (!(img = gfx_load_image(dirpath(p))))
goto out;
theme_img_scale(&img); /* bad style, no gfx layer :( */
}

View file

@ -257,6 +257,7 @@ typedef struct LoadF {
int extraline;
unsigned char byte;
FILE *f;
int enc;
unsigned char buff[4096];
} LoadF;
@ -271,11 +272,13 @@ static const char *getF (lua_State *L, void *ud, size_t *size) {
}
if (feof(lf->f)) return NULL;
*size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
for (i = 0; i < *size; i ++) {
unsigned char b = lf->buff[i];
lf->buff[i] ^= lf->byte;
lf->buff[i] = (lf->buff[i] >> 3) | (lf->buff[i] << 5);
lf->byte = b;
if (lf->enc) {
for (i = 0; i < *size; i ++) {
unsigned char b = lf->buff[i];
lf->buff[i] ^= lf->byte;
lf->buff[i] = (lf->buff[i] >> 3) | (lf->buff[i] << 5);
lf->byte = b;
}
}
return (*size > 0) ? (char*)lf->buff : NULL;
}
@ -288,7 +291,7 @@ static int errfile (lua_State *L, const char *what, int fnameindex) {
return LUA_ERRFILE;
}
static int loadfile (lua_State *L, const char *filename) {
static int loadfile (lua_State *L, const char *filename, int enc) {
LoadF lf;
int status, readstatus;
int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
@ -296,6 +299,7 @@ static int loadfile (lua_State *L, const char *filename) {
lua_pushfstring(L, "@%s", filename);
lf.f = fopen(filename, "rb");
lf.byte = 0xcc;
lf.enc = enc;
if (lf.f == NULL) return errfile(L, "open", fnameindex);
status = lua_load(L, getF, &lf, lua_tostring(L, -1));
readstatus = ferror(lf.f);
@ -312,7 +316,15 @@ static int loadfile (lua_State *L, const char *filename) {
static int luaB_doencfile (lua_State *L) {
const char *fname = luaL_optstring(L, 1, NULL);
int n = lua_gettop(L);
if (loadfile(L, fname) != 0) lua_error(L);
if (loadfile(L, dirpath(fname), 1) != 0) lua_error(L);
lua_call(L, 0, LUA_MULTRET);
return lua_gettop(L) - n;
}
static int luaB_dofile (lua_State *L) {
const char *fname = luaL_optstring(L, 1, NULL);
int n = lua_gettop(L);
if (loadfile(L, dirpath(fname), 0) != 0) lua_error(L);
lua_call(L, 0, LUA_MULTRET);
return lua_gettop(L) - n;
}
@ -404,6 +416,7 @@ static int luaB_set_timer(lua_State *L) {
static const luaL_Reg base_funcs[] = {
{"doencfile", luaB_doencfile},
{"dofile", luaB_dofile},
{"print", luaB_print}, /* for some mystic, it is needed in win version (with -debug) */
{"is_sound", luaB_is_sound},
{"get_savepath", luaB_get_savepath},
@ -467,11 +480,11 @@ int instead_init(void)
instead_package();
instead_lang();
if (dofile(L,STEAD_PATH"/stead.lua")) {
if (dofile(L, dirpath(STEAD_PATH"/stead.lua"))) {
return -1;
}
if (dofile(L,STEAD_PATH"/gui.lua")) {
if (dofile(L, dirpath(STEAD_PATH"/gui.lua"))) {
instead_clear();
return -1;
}

View file

@ -194,3 +194,18 @@ char *open_file_dialog(void)
}
return NULL;
}
int setdir(const char *path)
{
return chdir(path);
}
char *getdir(char *path, size_t size)
{
return getcwd(path, size);
}
char *dirpath(const char *path)
{
return (char*)path;
}

View file

@ -69,6 +69,29 @@ void macosx_init(void) {
}
#endif
#ifdef _WIN32_WCE
char *getcurdir(char *path)
{
char *p;
if (path == NULL || *path == '\0')
return ".";
p = path + strlen(path) - 1;
while (*p == '/') {
if (p == path)
return path;
*p-- = '\0';
}
while (p >= path && *p != '/')
p--;
return p < path ? "." : p == path ? "/" : (*p = '\0', path);
}
void wince_init(char *path)
{
unix_path(path);
strcpy(game_cwd, getcurdir(path));
}
#endif
int main(int argc, char *argv[])
{
int clean_tmp = 0;
@ -81,8 +104,13 @@ int main(int argc, char *argv[])
gtk_init(&argc, &argv);
#endif
putenv("SDL_MOUSE_RELATIVE=0"); /* test this! */
#ifdef _WIN32_WCE
wince_init(argv[0]);
#else
getcwd(game_cwd, sizeof(game_cwd));
#endif
unix_path(game_cwd);
setdir(game_cwd);
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i],"-alsa"))
alsa_sw = 1;
@ -100,7 +128,7 @@ int main(int argc, char *argv[])
else if (!strcmp(argv[i], "-debug"))
debug_sw = 1;
else if (!strcmp(argv[i], "-noautosave"))
noauto_sw = 1;
noauto_sw = 1;
else if (!strcmp(argv[i], "-game")) {
if ((i + 1) < argc)
game_sw = argv[++i];
@ -187,7 +215,7 @@ int main(int argc, char *argv[])
goto out;
}
menu_langs_lookup(LANG_PATH);
menu_langs_lookup(dirpath(LANG_PATH));
if (!langs_nr) {
fprintf(stderr, "No languages found in: %s.\n", LANG_PATH);
@ -207,14 +235,14 @@ int main(int argc, char *argv[])
if (games_sw)
games_lookup(games_sw);
if (!nostdgames_sw && games_lookup(GAMES_PATH))
if (!nostdgames_sw && games_lookup(dirpath(GAMES_PATH)))
fprintf(stderr, "No games found in: %s.\n", GAMES_PATH);
if (themes_sw)
themes_lookup(themes_sw);
if (!nostdthemes_sw) {
themes_lookup(THEMES_PATH);
themes_lookup(dirpath(THEMES_PATH));
themes_lookup(game_local_themes_path());
}

View file

@ -819,22 +819,22 @@ int menu_lang_select(const char *name)
char cwd[PATH_MAX];
if (!name)
return -1;
getcwd(cwd, sizeof(cwd));
chdir(game_cwd);
getdir(cwd, sizeof(cwd));
setdir(game_cwd);
for (i = 0; i<langs_nr; i ++) {
if (!strcmp(langs[i].file, name)) {
lang_free();
if (lang_parse(langs[i].path) || lang_ok()) {
fprintf(stderr,"Error while loading language: %s\n", langs[i].file);
chdir(cwd);
setdir(cwd);
return -1;
}
cur_lang = i;
FREE(opt_lang); opt_lang = strdup(langs[i].file);
chdir(cwd);
setdir(cwd);
return 0;
}
}
chdir(cwd);
setdir(cwd);
return -1;
}

View file

@ -51,12 +51,12 @@ static int parse_include(const char *v, void *data)
char cwd[PATH_MAX];
if (!strcmp(v, DEFAULT_THEME))
return 0;
getcwd(cwd, sizeof(cwd));
chdir(game_cwd);
getdir(cwd, sizeof(cwd));
setdir(game_cwd);
rc = game_theme_load(v);
// if (!rc)
// game_theme_select(v);
chdir(cwd);
setdir(cwd);
return rc;
}
@ -552,13 +552,13 @@ int themes_rename(void)
{
int i;
char cwd[PATH_MAX];
getcwd(cwd, sizeof(cwd));
chdir(game_cwd);
getdir(cwd, sizeof(cwd));
setdir(game_cwd);
for (i = 0; i < themes_nr; i++) {
FREE(themes[i].name);
themes[i].name = theme_name(themes[i].path, themes[i].dir);
themes[i].name = theme_name(dirpath(themes[i].path), themes[i].dir);
}
chdir(cwd);
setdir(cwd);
return 0;
}
@ -582,14 +582,14 @@ int game_theme_load(const char *name)
{
struct theme *theme;
char cwd[PATH_MAX];
getcwd(cwd, sizeof(cwd));
chdir(game_cwd);
getdir(cwd, sizeof(cwd));
setdir(game_cwd);
theme = theme_lookup(name);
if (!theme || chdir(theme->path) || theme_load(THEME_FILE)) {
chdir(cwd);
if (!theme || setdir(theme->path) || theme_load(dirpath(THEME_FILE))) {
setdir(cwd);
return -1;
}
chdir(cwd);
setdir(cwd);
return 0;
}

View file

@ -302,3 +302,18 @@ char *sdl_path(char *p)
unix_path(p);
return p;
}
int setdir(const char *path)
{
return chdir(path);
}
char *getdir(char *path, size_t size)
{
return getcwd(path, size);
}
char *dirpath(const char *path)
{
return (char*)path;
}

View file

@ -266,7 +266,7 @@ int parse_full_path(const char *v, void *data)
char **p = ((char **)data);
if (*p)
free(*p);
getcwd(cwd, sizeof(cwd));
getdir(cwd, sizeof(cwd));
*p = malloc(strlen(v) + strlen(cwd) + 2);
if (!*p)
return -1;

View file

@ -31,6 +31,9 @@ extern char *decode(iconv_t hiconv, const char *s);
extern void unix_path(char *path);
extern char *sdl_path(char *path);
extern int setdir(const char *path);
extern char *getdir(char *path, size_t size);
extern char *dirpath(const char *path);
extern char *parse_tag(char *line, const char *tag, const char *comm, int *brk);
extern int remove_dir(const char *path);

View file

@ -102,7 +102,7 @@ char *game_tmp_path(void)
return NULL;
}
strcat((char*)lpTempPathBuffer, "/instead-games");
if (mkdir((char*)lpTempPathBuffer) && errno != EEXIST)
if (mkdir((char*)lpTempPathBuffer) && access((char*)lpTempPathBuffer, W_OK))
return NULL;
unix_path((char*)lpTempPathBuffer);
return (char*)lpTempPathBuffer;
@ -115,12 +115,12 @@ char *game_local_games_path(int cr)
return NULL;
snprintf(local_games_path, sizeof(local_games_path) - 1 , "%s/", app);
if (cr) {
if (mkdir(local_games_path) && errno != EEXIST)
if (mkdir(local_games_path) && access(local_games_path, W_OK))
return NULL;
}
strcat(local_games_path,"/games");
if (cr) {
if (mkdir(local_games_path) && errno != EEXIST)
if (mkdir(local_games_path) && access(local_games_path, W_OK))
return NULL;
}
return local_games_path;
@ -182,7 +182,7 @@ char *game_cfg_path( void )
return cfg_path;
/* no at home? Try in dir */
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s", p);
if (mkdir(cfg_path) && errno != EEXIST) {
if (mkdir(cfg_path) && access(cfg_path, W_OK)) {
snprintf(cfg_path, sizeof(cfg_path) - 1 , "%src", p); /* appdir/insteadrc ;) */
return cfg_path;
}
@ -205,21 +205,21 @@ char *game_save_path( int cr, int nr )
snprintf(save_path, sizeof(save_path) - 1, "saves/autosave");
return save_path;
}
if (!p)
if (!p)
return NULL;
strcpy( appdir, p );
if (cr && mkdir(appdir) && errno != EEXIST)
if (cr && mkdir(appdir) && access(appdir, W_OK))
return NULL;
snprintf(save_path, sizeof(save_path) - 1 , "%s/saves", appdir);
if (cr && mkdir(save_path) && errno != EEXIST)
if (cr && mkdir(save_path) && access(save_path, W_OK))
return NULL;
snprintf(save_path, sizeof(save_path) - 1, "%s/saves/%s", appdir, curgame_dir);
if (cr && mkdir(save_path) && errno != EEXIST)
if (cr && mkdir(save_path) && access(save_path, W_OK))
return NULL;
if (nr)

View file

@ -1,5 +1,5 @@
stead = {
version = "1.2.1",
version = "1.2.2",
api_version = "1.1.6", -- last version before 1.2.0
table = table,
delim = ',',