{
CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
CopyBrushToCursor(sx, sy);
- ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],MB_LEFT);
+ ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
+ MB_LEFTBUTTON);
draw_with_brush = TRUE;
}
else if (drawing_function == GADGET_ID_TEXT)
case GADGET_ID_PICK_ELEMENT:
if (button_release_event)
- ClickOnGadget(level_editor_gadget[last_drawing_function], MB_LEFT);
+ ClickOnGadget(level_editor_gadget[last_drawing_function],
+ MB_LEFTBUTTON);
else
PickDrawingElement(button, Feld[lx][ly]);
}
if (drawing_function == GADGET_ID_PICK_ELEMENT)
- ClickOnGadget(level_editor_gadget[last_drawing_function], MB_LEFT);
+ ClickOnGadget(level_editor_gadget[last_drawing_function],
+ MB_LEFTBUTTON);
}
#ifdef DEBUG
else if (gi->event.type == GD_EVENT_PRESSED)
void HandleLevelEditorKeyInput(Key key)
{
char letter = getCharFromKey(key);
- int button = MB_LEFT;
+ int button = MB_LEFTBUTTON;
if (drawing_function == GADGET_ID_TEXT &&
DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
break;
case KEY_Page_Up:
id = GADGET_ID_SCROLL_LIST_UP;
- button = 3;
+ button = MB_RIGHTBUTTON;
break;
case KEY_Page_Down:
id = GADGET_ID_SCROLL_LIST_DOWN;
- button = 3;
+ button = MB_RIGHTBUTTON;
break;
default:
return;
}
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
if (options.network)
HandleNetworking();
#endif
#define LEVELFILE_EXTENSION "lvl"
#define TAPEFILE_EXTENSION "tap"
#define SCOREFILE_EXTENSION "sco"
+#endif
+
+#if defined(MSDOS) || defined(WIN32)
#define ERROR_FILENAME "error.out"
#endif
+#ifdef WIN32
+#ifndef S_IRGRP
+#define S_IRGRP S_IRUSR
+#endif
+#ifndef S_IROTH
+#define S_IROTH S_IRUSR
+#endif
+#ifndef S_IWGRP
+#define S_IWGRP S_IWUSR
+#endif
+#ifndef S_IWOTH
+#define S_IWOTH S_IWUSR
+#endif
+#ifndef S_IXGRP
+#define S_IXGRP S_IXUSR
+#endif
+#ifndef S_IXOTH
+#define S_IXOTH S_IXUSR
+#endif
+#endif
+
/* file permissions for newly written files */
#define MODE_R_ALL (S_IRUSR | S_IRGRP | S_IROTH)
#define MODE_W_ALL (S_IWUSR | S_IWGRP | S_IWOTH)
static void createDirectory(char *dir, char *text)
{
if (access(dir, F_OK) != 0)
+#ifdef WIN32
+ if (mkdir(dir) != 0)
+#else
if (mkdir(dir, USERDATA_DIR_MODE) != 0)
+#endif
Error(ERR_WARN, "cannot create %s directory '%s'", text, dir);
}
chmod(filename, SETUP_PERMS);
}
-#ifdef MSDOS
+#if defined(MSDOS) || defined(WIN32)
void initErrorFile()
{
char *filename;
void LoadLevelSetup_SeriesInfo(void);
void SaveLevelSetup_SeriesInfo(void);
-#ifdef MSDOS
+#if defined(MSDOS) || defined(WIN32)
void initErrorFile();
FILE *openErrorFile();
void dumpErrorFile();
network_player_action_received = FALSE;
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
/* initial null action */
if (network_playing)
SendToServer_MovePlayer(MV_NO_MOVING);
#endif
*/
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
/* last chance to get network player actions without main loop delay */
HandleNetworking();
#endif
stored_player[i].effective_action = stored_player[i].action;
}
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
if (network_playing)
SendToServer_MovePlayer(summarized_player_action);
#endif
Request("Do you really want to quit the game ?",
REQ_ASK | REQ_STAY_CLOSED))
{
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
if (options.network)
SendToServer_StopPlaying();
else
case GAME_CTRL_ID_PAUSE:
if (options.network)
{
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
if (tape.pausing)
SendToServer_ContinuePlaying();
else
case GAME_CTRL_ID_PLAY:
if (tape.pausing)
{
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
if (options.network)
SendToServer_ContinuePlaying();
else
char *picturemask_filename;
};
+#ifndef USE_SDL_LIBRARY
static int sound_process_id = 0;
+#endif
static void InitLevelAndPlayerInfo(void);
static void InitNetworkServer(void);
void OpenAll(int argc, char *argv[])
{
-#ifdef MSDOS
+#if defined(MSDOS) || defined(WIN32)
initErrorFile();
#endif
if (options.serveronly)
{
+#ifdef WIN32
+ Error(ERR_WARN, "networking not supported in Windows version");
+#else
NetworkServer(options.server_port, options.serveronly);
+#endif
/* never reached */
exit(0);
void InitNetworkServer()
{
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
int nr_wanted;
#endif
if (!options.network)
return;
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
if (!ConnectToServer(options.server_host, options.server_port))
#else /* !USE_SDL_LIBRARY */
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
if (access(sound_device_name, W_OK) != 0)
{
Error(ERR_WARN, "cannot access sound device - no sounds");
*/
#endif
-#else /* MSDOS */
+#else /* MSDOS || WIN32 */
sound_loops_allowed = TRUE;
/*
setup.sound_loops_on = TRUE;
*/
-#endif /* MSDOS */
+#endif /* MSDOS || WIN32 */
#endif /* !USE_SDL_LIBRARY */
for(i=0; i<NUM_SOUNDS; i++)
if (sound_status == SOUND_OFF)
return;
-#ifdef USE_SDL_LIBRARY
- return;
-#endif
+#ifndef USE_SDL_LIBRARY
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
if (pipe(sound_pipe)<0)
{
else /* we are parent */
close(sound_pipe[0]); /* no reading from pipe needed */
-#else /* MSDOS */
+#else /* MSDOS || WIN32 */
SoundServer();
#endif /* MSDOS */
+
+#endif /* !USE_SDL_LIBRARY */
}
void InitJoysticks()
{
int i;
+#ifdef USE_SDL_LIBRARY
+ StopSounds();
+ FreeSounds(NUM_SOUNDS);
+#else
if (sound_process_id)
{
StopSounds();
kill(sound_process_id, SIGTERM);
FreeSounds(NUM_SOUNDS);
}
+#endif
for(i=0; i<NUM_BITMAPS; i++)
{
#define MB_MENU_CHOICE FALSE
#define MB_MENU_MARK TRUE
#define MB_MENU_INITIALIZE (-1)
-#define MB_LEFT 1
-#define MB_MIDDLE 2
-#define MB_RIGHT 3
+#define MB_LEFTBUTTON 1
+#define MB_MIDDLEBUTTON 2
+#define MB_RIGHTBUTTON 3
/* values for redraw_mask */
#define REDRAW_ALL (1 << 0)
* misc.c *
***********************************************************/
-#include <pwd.h>
#include <time.h>
#include <sys/time.h>
-#include <sys/param.h>
#include <sys/types.h>
#include <stdarg.h>
#include <ctype.h>
+#ifndef WIN32
+#include <pwd.h>
+#include <sys/param.h>
+#endif
+
#include "misc.h"
#include "init.h"
#include "tools.h"
#endif
-
/* maximal allowed length of a command line option */
#define MAX_OPTION_LEN 256
+#ifdef USE_SDL_LIBRARY
+
+static unsigned long mainCounter(int mode)
+{
+ static unsigned long base_ms = 0;
+ unsigned long current_ms;
+ unsigned long counter_ms;
+
+ current_ms = SDL_GetTicks();
+
+ /* reset base time in case of counter initializing or wrap-around */
+ if (mode == INIT_COUNTER || current_ms < base_ms)
+ base_ms = current_ms;
+
+ counter_ms = current_ms - base_ms;
+
+ return counter_ms; /* return milliseconds since last init */
+}
+
+#else /* !USE_SDL_LIBRARY */
#ifndef MSDOS
+
static unsigned long mainCounter(int mode)
{
static struct timeval base_time = { 0, 0 };
gettimeofday(¤t_time, NULL);
+ /* reset base time in case of counter initializing or wrap-around */
if (mode == INIT_COUNTER || current_time.tv_sec < base_time.tv_sec)
base_time = current_time;
return counter_ms; /* return milliseconds since last init */
}
-#endif
+
+#endif /* !MSDOS */
+#endif /* !USE_SDL_LIBRARY */
void InitCounter() /* set counter back to zero */
{
boolean do_busy_waiting = (milliseconds_delay < 5 ? TRUE : FALSE);
#ifdef MSDOS
- /* donït use select() to perform waiting operations under DOS/Windows
+ /* don't use select() to perform waiting operations under DOS/Windows
environment; always use a busy loop for waiting instead */
do_busy_waiting = TRUE;
#endif
}
else
{
+#ifdef USE_SDL_LIBRARY
+ SDL_Delay(milliseconds_delay);
+#else /* !USE_SDL_LIBRARY */
struct timeval delay;
delay.tv_sec = milliseconds_delay / 1000;
if (select(0, NULL, NULL, NULL, &delay) != 0)
Error(ERR_WARN, "sleep_milliseconds(): select() failed");
+#endif /* !USE_SDL_LIBRARY */
}
}
unsigned int SimpleRND(unsigned int max)
{
+#ifdef USE_SDL_LIBRARY
+
+ static unsigned long root = 654321;
+ unsigned long current_ms;
+
+ current_ms = SDL_GetTicks();
+ root = root * 4253261 + current_ms;
+ return (root % max);
+
+#else /* !USE_SDL_LIBRARY */
+
static unsigned long root = 654321;
struct timeval current_time;
- gettimeofday(¤t_time,NULL);
+ gettimeofday(¤t_time, NULL);
root = root * 4253261 + current_time.tv_sec + current_time.tv_usec;
return (root % max);
+
+#endif /* !USE_SDL_LIBRARY */
}
#ifdef DEBUG
unsigned int InitRND(long seed)
{
+#ifdef USE_SDL_LIBRARY
+ unsigned long current_ms;
+
+ if (seed == NEW_RANDOMIZE)
+ {
+ current_ms = SDL_GetTicks();
+ srandom_linux_libc((unsigned int) current_ms);
+ return (unsigned int) current_ms;
+ }
+ else
+ {
+ srandom_linux_libc((unsigned int) seed);
+ return (unsigned int) seed;
+ }
+#else /* !USE_SDL_LIBRARY */
struct timeval current_time;
if (seed == NEW_RANDOMIZE)
{
- gettimeofday(¤t_time,NULL);
+ gettimeofday(¤t_time, NULL);
srandom_linux_libc((unsigned int) current_time.tv_usec);
- return (unsigned int)current_time.tv_usec;
+ return (unsigned int) current_time.tv_usec;
}
else
{
srandom_linux_libc((unsigned int) seed);
- return (unsigned int)seed;
+ return (unsigned int) seed;
}
+#endif /* !USE_SDL_LIBRARY */
}
char *getLoginName()
{
+#ifdef WIN32
+ return ANONYMOUS_NAME;
+#else
struct passwd *pwd;
if ((pwd = getpwuid(getuid())) == NULL)
return ANONYMOUS_NAME;
else
return pwd->pw_name;
+#endif
}
char *getRealName()
{
-#ifndef MSDOS
+#if defined(MSDOS) || defined(WIN32)
+ return ANONYMOUS_NAME;
+#else
struct passwd *pwd;
if ((pwd = getpwuid(getuid())) == NULL || strlen(pwd->pw_gecos) == 0)
return real_name;
}
-#else
- return ANONYMOUS_NAME;
#endif
}
char *getHomeDir()
{
-#ifndef MSDOS
+#if defined(MSDOS) || defined(WIN32)
+ return ".";
+#else
static char *home_dir = NULL;
if (!home_dir)
}
return home_dir;
-#else
- return ".";
#endif
}
if (mode & ERR_WARN && !options.verbose)
return;
-#ifdef MSDOS
+#if defined(MSDOS) || defined(WIN32)
if ((error = openErrorFile()) == NULL)
{
printf("Cannot write to error output file!\n");
{ KEY_Meta_R, "XK_Meta_R", "right meta" },
{ KEY_Alt_L, "XK_Alt_L", "left alt" },
{ KEY_Alt_R, "XK_Alt_R", "right alt" },
- { KEY_Mode_switch, "XK_Mode_switch", "mode switch" },
- { KEY_Multi_key, "XK_Multi_key", "multi key" },
+ { KEY_Super_L, "XK_Super_L", "left super" }, /* Win-L */
+ { KEY_Super_R, "XK_Super_R", "right super" }, /* Win-R */
+ { KEY_Mode_switch, "XK_Mode_switch", "mode switch" }, /* Alt-R */
+ { KEY_Multi_key, "XK_Multi_key", "multi key" }, /* Ctrl-R */
/* some special keys */
{ KEY_BackSpace, "XK_BackSpace", "backspace" },
{ KEY_End, "XK_End", "end" },
{ KEY_Page_Up, "XK_Page_Up", "page up" },
{ KEY_Page_Down, "XK_Page_Down", "page down" },
-
+ { KEY_Menu, "XK_Menu", "menu" }, /* Win-Menu */
/* ASCII 0x20 to 0x40 keys (except numbers) */
{ KEY_space, "XK_space", "space" },
* network.c *
***********************************************************/
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
#include <fcntl.h>
#include <sys/time.h>
}
}
-#endif /* !MSDOS */
+#endif /* !MSDOS && !WIN32 */
* network.c *
***********************************************************/
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
#include <signal.h>
#include <sys/time.h>
}
}
-#endif /* !MSDOS */
+#endif /* !MSDOS && !WIN32 */
if (setup.autorecord)
TapeStartRecording();
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
if (options.network)
SendToServer_StartPlaying();
else
break;
}
+ /* all keys configured -- wait for "Escape" or "Return" key */
+ if (step_nr == 6)
+ break;
+
/* press 'Enter' to keep the existing key binding */
- if (key == KEY_Return || step_nr == 6)
+ if (key == KEY_Return)
key = *customize_step[step_nr].key;
/* check if key already used */
dst_rect.h = height;
SDL_BlitSurface(src_surface, &src_rect, dst_surface, &dst_rect);
-#if 1
- SDL_UpdateRect(dst_surface, dst_x, dst_y, width, height);
-#endif
+
+ if (dst_surface == window)
+ SDL_UpdateRect(dst_surface, dst_x, dst_y, width, height);
}
inline void SDLFillRectangle(SDL_Surface *surface, int x, int y,
#define KEY_Meta_R SDLK_RMETA
#define KEY_Alt_L SDLK_LALT
#define KEY_Alt_R SDLK_RALT
+#define KEY_Super_L SDLK_LSUPER
+#define KEY_Super_R SDLK_RSUPER
#define KEY_Mode_switch SDLK_MODE
-#define KEY_Multi_key KEY_UNDEFINED /* undefined */
+#define KEY_Multi_key SDLK_RCTRL
#define KEY_BackSpace SDLK_BACKSPACE
#define KEY_Delete SDLK_DELETE
#define KEY_End SDLK_END
#define KEY_Page_Up SDLK_PAGEUP
#define KEY_Page_Down SDLK_PAGEDOWN
+#define KEY_Menu SDLK_MENU
#define KEY_space SDLK_SPACE
#define KEY_exclam SDLK_EXCLAIM
-1,0,0, FALSE,FALSE,FALSE,FALSE,FALSE, 0,0L,0L,NULL
};
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
static int stereo_volume[PSND_MAX_LEFT2RIGHT+1];
static char premix_first_buffer[SND_BLOCKSIZE];
#ifdef VOXWARE
static int premix_last_buffer[SND_BLOCKSIZE];
#endif /* VOXWARE */
static unsigned char playing_buffer[SND_BLOCKSIZE];
-#endif /* MSDOS */
+#endif /* !MSDOS && !WIN32 */
/* forward declaration of internal functions */
#ifdef VOXWARE
static void SoundServer_InsertNewSound(struct SoundControl);
#endif
-#ifndef VOXWARE
-#ifndef MSDOS
+
+#if !defined(VOXWARE) && !defined(MSDOS) && !defined(WIN32)
static unsigned char linear_to_ulaw(int);
static int ulaw_to_linear(unsigned char);
#endif
-#endif
+
#ifdef HPUX_AUDIO
static void HPUX_Audio_Control();
#endif
+
#ifdef MSDOS
static void SoundServer_InsertNewSound(struct SoundControl);
static void SoundServer_StopSound(int);
void SoundServer()
{
int i;
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
struct SoundControl snd_ctrl;
fd_set sound_fdset;
playlist[i] = emptySoundControl;
playing_sounds = 0;
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
stereo_volume[PSND_MAX_LEFT2RIGHT] = 0;
for(i=0;i<PSND_MAX_LEFT2RIGHT;i++)
stereo_volume[i] =
/* Even if the stereo flag is used as being boolean, it must be
defined as an integer, else 'ioctl()' will fail! */
int stereo = TRUE;
+#if 0
int sample_rate = 8000;
+#else
+ int sample_rate = 22050;
+#endif
if (playing_sounds || (sound_device=open(sound_device_name,O_WRONLY))>=0)
{
#endif /* !VOXWARE */
}
-#endif /* !MSDOS */
+
+#endif /* !MSDOS && !WIN32 */
+
}
#ifdef MSDOS
}
#endif /* MSDOS */
+#ifndef WIN32
static void SoundServer_InsertNewSound(struct SoundControl snd_ctrl)
{
int i, k;
}
}
}
+#endif /* !WIN32 */
/*
void SoundServer_FadeSound(int nr)
}
*/
+#ifndef WIN32
#ifdef MSDOS
static void SoundServer_StopSound(int nr)
{
#endif
}
#endif /* MSDOS */
+#endif /* !WIN32 */
#ifdef HPUX_AUDIO
static void HPUX_Audio_Control()
}
#endif /* HPUX_AUDIO */
-#ifndef VOXWARE
-#ifndef MSDOS
+#if !defined(VOXWARE) && !defined(MSDOS) && !defined(WIN32)
+
/* these two are stolen from "sox"... :) */
/*
return(sample);
}
-#endif /* !MSDOS */
-#endif /* !VOXWARE */
+#endif /* !VOXWARE && !MSDOS && !WIN32 */
/*** THE STUFF ABOVE IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/
{
#ifndef USE_SDL_LIBRARY
XFlush(display);
-#else
-#if 0
- SDL_UpdateRect(window, 0, 0, 0, 0);
-#endif
#endif
}
inline Key GetEventKey(KeyEvent *event, boolean with_modifiers)
{
#ifdef USE_SDL_LIBRARY
+ /*
+ printf("unicode == '%d', sym == '%d', mod == '0x%04x'\n",
+ (int)event->keysym.unicode,
+ (int)event->keysym.sym,
+ (int)SDL_GetModState());
+ */
+
if (with_modifiers && event->keysym.unicode != 0)
return event->keysym.unicode;
else
return event->keysym.sym;
#else
+ /*
+ printf("with modifiers == '0x%04x', without modifiers == '0x%04x'\n",
+ (int)XLookupKeysym(event, event->state),
+ (int)XLookupKeysym(event, 0));
+ */
+
if (with_modifiers)
return XLookupKeysym(event, event->state);
else
{
TapeStartRecording();
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
if (options.network)
SendToServer_StartPlaying();
else
int mx, my, ty, result = -1;
unsigned int old_door_state;
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
/* pause network game while waiting for request to answer */
if (options.network &&
game_status == PLAYING &&
RemapAllGadgets();
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(WIN32)
/* continue network game after request */
if (options.network &&
game_status == PLAYING &&
#define KEY_Meta_R XK_Meta_R
#define KEY_Alt_L XK_Alt_L
#define KEY_Alt_R XK_Alt_R
+#define KEY_Super_L XK_Super_L
+#define KEY_Super_R XK_Super_R
#define KEY_Mode_switch XK_Mode_switch
#define KEY_Multi_key XK_Multi_key
#define KEY_End XK_End
#define KEY_Page_Up XK_Page_Up
#define KEY_Page_Down XK_Page_Down
+#define KEY_Menu XK_Menu
#define KEY_space XK_space
#define KEY_exclam XK_exclam