$(CONFIG_SCORE_ENTRIES) $(XPM_INCLUDE_FILE)
# DEBUG = -DDEBUG -g -Wall -ansi -pedantic
-DEBUG = -DDEBUG -g -Wall
+# DEBUG = -DDEBUG -g -Wall
# DEBUG = -O3 -Wall -ansi -pedantic
-# DEBUG = -O3 -Wall
+DEBUG = -O3 -Wall
# DEBUG = -O3
# SYSTEM = -Aa -D_HPUX_SOURCE -Dhpux # for HP-UX (obsolete)
static unsigned long pressed_delay = 0;
static int last_button = 0;
static int last_mx = 0, last_my = 0;
- int scrollbar_mouse_pos;
+ int scrollbar_mouse_pos = 0;
struct GadgetInfo *new_gi, *gi;
boolean press_event;
boolean release_event;
}
/* values for DrawLevelText() modes */
-#define TEXT_INIT 0
-#define TEXT_SETCURSOR 1
-#define TEXT_WRITECHAR 2
-#define TEXT_BACKSPACE 3
-#define TEXT_NEWLINE 4
-#define TEXT_END 5
+#define TEXT_INIT 0
+#define TEXT_SETCURSOR 1
+#define TEXT_WRITECHAR 2
+#define TEXT_BACKSPACE 3
+#define TEXT_NEWLINE 4
+#define TEXT_END 5
+#define TEXT_QUERY_TYPING 6
-static void DrawLevelText(int sx, int sy, char letter, int mode)
+static int DrawLevelText(int sx, int sy, char letter, int mode)
{
static short delete_buffer[MAX_LEV_FIELDX];
static int start_sx, start_sy;
static int last_sx, last_sy;
static boolean typing = FALSE;
int letter_element = EL_CHAR_ASCII0 + letter;
- int lx, ly;
+ int lx = 0, ly = 0;
/* map lower case letters to upper case and convert special characters */
if (letter >= 'a' && letter <= 'z')
if (mode != TEXT_INIT)
{
if (!typing)
- return;
+ return FALSE;
if (mode != TEXT_SETCURSOR)
{
if (sx > start_sx)
{
Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
- DrawMiniElement(sx - 1, sy, new_element3);
+ DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
}
break;
typing = FALSE;
break;
+ case TEXT_QUERY_TYPING:
+ break;
+
default:
break;
}
+
+ return typing;
}
static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy,
int sx = gi->event.x, sy = gi->event.y;
int min_sx = 0, min_sy = 0;
int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1;
- int lx, ly;
+ int lx = 0, ly = 0;
int min_lx = 0, min_ly = 0;
int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
int x, y;
char letter = getCharFromKeySym(key);
int button = MB_LEFT;
- if (drawing_function == GADGET_ID_TEXT)
+ if (drawing_function == GADGET_ID_TEXT &&
+ DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE)
{
if (letter)
DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
}
}
- if (game_status==PLAYING)
+ if (game_status == PLAYING)
XAutoRepeatOff(display);
}
if (event->type == FocusOut)
{
+ int i;
+
XAutoRepeatOn(display);
old_joystick_status = joystick_status;
joystick_status = JOYSTICK_OFF;
+
+ /* simulate key release events for still pressed keys */
key_joystick_mapping = 0;
+ for (i=0; i<MAX_PLAYERS; i++)
+ stored_player[i].action = 0;
}
else if (event->type == FocusIn)
{
+ /* When there are two Rocks'n'Diamonds windows which overlap and
+ the player moves the pointer from one game window to the other,
+ a 'FocusOut' event is generated for the window the pointer is
+ leaving and a 'FocusIn' event is generated for the window the
+ pointer is entering. In some cases, it can happen that the
+ 'FocusIn' event is handled by the one game process before the
+ 'FocusOut' event by the other game process. In this case the
+ X11 environment would end up with activated keyboard auto repeat,
+ because unfortunately this is a global setting and not (which
+ would be far better) set for each X11 window individually.
+ The effect would be keyboard auto repeat while playing the game
+ (game_status == PLAYING), which is not desired.
+ To avoid this special case, we just wait 1/50 second before
+ processing the 'FocusIn' event.
+ */
+
+ Delay(20);
if (game_status == PLAYING)
XAutoRepeatOff(display);
if (old_joystick_status != -1)
/* cut trailing comment or whitespace from input line */
for (line_ptr = line; *line_ptr; line_ptr++)
{
- if (*line_ptr == '#' || *line_ptr == '\n')
+ if (*line_ptr == '#' || *line_ptr == '\n' || *line_ptr == '\r')
{
*line_ptr = '\0';
break;
#define TAPES_DIRECTORY "tapes"
#define SCORES_DIRECTORY "scores"
-#define PROGRAM_VERSION_STRING "1.2.1"
+#define PROGRAM_VERSION_STRING "1.3.0"
#define PROGRAM_TITLE_STRING "Rocks'n'Diamonds"
#define PROGRAM_AUTHOR_STRING "Holger Schemel"
#define WINDOW_TITLE_STRING PROGRAM_TITLE_STRING " " PROGRAM_VERSION_STRING
char *getRealName()
{
+#ifndef MSDOS
struct passwd *pwd;
if ((pwd = getpwuid(getuid())) == NULL || strlen(pwd->pw_gecos) == 0)
return real_name;
}
+#else
+ return ANONYMOUS_NAME;
+#endif
}
char *getHomeDir()
extern int i_love_bill;
/* internal variables of msdos.c */
+static boolean keyboard_auto_repeat = TRUE;
static int key_press_state[MAX_SCANCODES];
static XEvent event_buffer[MAX_EVENT_BUFFER];
static int pending_events;
unhide_mouse(display);
}
+static unsigned long AllocColorCell(int r, int g, int b)
+{
+ byte pixel_mapping = 0;
+ int i;
+
+ r >>= 10;
+ g >>= 10;
+ b >>= 10;
+
+ /* try to use existing colors from the global colormap */
+ for (i=0; i<global_colormap_entries_used; i++)
+ {
+ if (r == global_colormap[i].r &&
+ g == global_colormap[i].g &&
+ b == global_colormap[i].b) /* color found */
+ {
+ pixel_mapping = i;
+ break;
+ }
+ }
+
+ if (i == global_colormap_entries_used) /* color not found */
+ {
+ if (global_colormap_entries_used < MAX_COLORS)
+ global_colormap_entries_used++;
+
+ global_colormap[i].r = r;
+ global_colormap[i].g = g;
+ global_colormap[i].b = b;
+
+ pixel_mapping = i;
+ }
+
+ return pixel_mapping;
+}
+
Display *XOpenDisplay(char *display_name)
{
Screen *screen;
screen[0].cmap = 0;
screen[0].root = 0;
+#if 0
screen[0].white_pixel = 0xFF;
screen[0].black_pixel = 0x00;
+#else
+ screen[0].white_pixel = AllocColorCell(0xFFFF, 0xFFFF, 0xFFFF);
+ screen[0].black_pixel = AllocColorCell(0x0000, 0x0000, 0x0000);
+#endif
screen[0].video_bitmap = NULL;
display->default_screen = 0;
mouse_off = hide_mouse(display, x, y, width, height);
}
- rectfill((BITMAP *)d, x, y, x + width, y + height,
+ rectfill((BITMAP *)d, x, y, x + width - 1, y + height - 1,
((XGCValues *)gc)->foreground);
if (mouse_off)
byte *src_ptr = image->data;
byte pixel_mapping[MAX_COLORS];
unsigned int depth = 8;
+
+#if 0
int i, j, x, y;
+#else
+ int i, x, y;
+#endif
/* allocate new allegro bitmap structure */
if ((bitmap = create_bitmap_ex(depth, image->width, image->height)) == NULL)
/* try to use existing colors from the global colormap */
for (i=0; i<MAX_COLORS; i++)
{
+
+#if 0
int r, g, b;
+#endif
if (!image->rgb.color_used[i])
continue;
+
+#if 0
r = image->rgb.red[i] >> 10;
g = image->rgb.green[i] >> 10;
b = image->rgb.blue[i] >> 10;
pixel_mapping[i] = j;
}
+#else
+ pixel_mapping[i] = AllocColorCell(image->rgb.red[i],
+ image->rgb.green[i],
+ image->rgb.blue[i]);
+#endif
+
}
/* copy bitmap data */
xkey->state = (unsigned int)keysym;
}
-#define HANDLE_RAW_KB_ALL_KEYS 0
+#define HANDLE_RAW_KB_ALL_KEYS 0
#define HANDLE_RAW_KB_MODIFIER_KEYS_ONLY 1
static int modifier_scancode[] =
else if (ascii == '.')
keysym = XK_KP_Separator;
}
+ else if (ascii >= ' ' && ascii <= 'Z')
+ keysym = XK_space + (KeySym)(ascii - ' ');
+ else if (ascii == '^')
+ keysym = XK_asciicircum;
+ else if (ascii == '_')
+ keysym = XK_underscore;
+ else if (ascii == 'Ä')
+ keysym = XK_Adiaeresis;
+ else if (ascii == 'Ö')
+ keysym = XK_Odiaeresis;
+ else if (ascii == 'Ü')
+ keysym = XK_Udiaeresis;
+ else if (ascii == 'ä')
+ keysym = XK_adiaeresis;
+ else if (ascii == 'ö')
+ keysym = XK_odiaeresis;
+ else if (ascii == 'ü')
+ keysym = XK_udiaeresis;
+ else if (ascii == 'ß')
+ keysym = XK_ssharp;
NewKeyEvent(KeyPress, keysym);
}
XMotionEvent *xmotion;
int i;
+ /* When using 'HandleKeyboardRaw()', keyboard input is also stored in
+ the allegro keyboard input buffer and would be available a second
+ time by calling 'HandleKeyboardEvent()'. To avoid double keyboard
+ events, the allegro function 'clear_keybuf()' must be called each
+ time when switching from calling 'HandleKeyboardRaw()' to calling
+ 'HandleKeyboardEvent()' to get keyboard input, which is actually
+ done by 'XAutoRepeatOn()' which sets keyboard_auto_repeat to TRUE. */
+
/* keyboard event */
- if (game_status == PLAYING)
- HandleKeyboardRaw(HANDLE_RAW_KB_ALL_KEYS);
- else
+ if (keyboard_auto_repeat)
HandleKeyboardEvent();
+ else
+ HandleKeyboardRaw(HANDLE_RAW_KB_ALL_KEYS);
/* mouse motion event */
- /* generate mouse motion event only if any mouse buttons are pressed */
- if (mouse_pos != last_mouse_pos && mouse_b)
+ if (mouse_pos != last_mouse_pos)
{
last_mouse_pos = mouse_pos;
pending_events++;
{
}
+Bool XQueryPointer(Display *display, Window window,
+ Window *root, Window *child, int *root_x, int *root_y,
+ int *win_x, int *win_y, unsigned int *mask)
+{
+ *win_x = mouse_x - display->screens[display->default_screen].x;
+ *win_y = mouse_y - display->screens[display->default_screen].y;
+
+ return True;
+}
+
+void XAutoRepeatOn(Display *display)
+{
+ keyboard_auto_repeat = TRUE;
+ clear_keybuf();
+}
+
+void XAutoRepeatOff(Display *display)
+{
+ keyboard_auto_repeat = FALSE;
+}
+
void NetworkServer(int port, int serveronly)
{
Error(ERR_WARN, "networking not supported in DOS version");
#define XFlush(a)
#define XGetImage(a,b,c,d,e,f,g,h) ((XImage *) NULL)
-#define XAutoRepeatOn(a)
-#define XAutoRepeatOff(a)
#define XDisplayName(a) ((char *) NULL)
#define XFreeColors(a,b,c,d,e)
#define XpmFreeAttributes(a)
void XSetForeground(Display *, GC, unsigned long);
void XDrawLine(Display *, Drawable, GC, int, int, int, int);
void XDestroyImage(XImage *);
+Bool XQueryPointer(Display *, Window, Window *, Window *, int *, int *,
+ int *, int *, unsigned int *);
+void XAutoRepeatOn(Display *);
+void XAutoRepeatOff(Display *);
void NetworkServer(int, int);
*/
#endif
- static last_dir = MV_LEFT;
+ static int last_dir = MV_LEFT;
if (player->Pushing)
{
for (i=0; i<NUM_TOOL_BUTTONS; i++)
{
Pixmap gd_pixmap = pix[PIX_DOOR];
- Pixmap deco_pixmap = 0;
- int deco_x, deco_y, deco_xpos, deco_ypos;
+ Pixmap deco_pixmap = None;
+ int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
struct GadgetInfo *gi;
unsigned long event_mask;
int gd_xoffset, gd_yoffset;