XCopyArea(display,pix[PIX_DOOR],drawto,gc,
from_x,from_y, size_x,size_y, to_x,to_y);
- DrawMiniGraphicExtHiRes(drawto,gc,
- DX+ED_BUTTON_ELEM_XPOS+3+shift +
- (elem_pos % MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
- DY+ED_BUTTON_ELEM_YPOS+3-shift +
- (elem_pos / MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
- graphic);
+ DrawMiniGraphicExt(drawto,gc,
+ DX+ED_BUTTON_ELEM_XPOS+3+shift +
+ (elem_pos % MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
+ DY+ED_BUTTON_ELEM_YPOS+3-shift +
+ (elem_pos / MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
+ graphic);
}
redraw_mask |= REDRAW_DOOR_1;
if (reset_delay)
{
animstart_delay = Counter();
- animstart_delay_value = SimpleRND(500);
+ animstart_delay_value = SimpleRND(3000);
reset_delay = FALSE;
}
{
horiz_move = (anim->direction & (ANIMDIR_LEFT | ANIMDIR_RIGHT));
vert_move = (anim->direction & (ANIMDIR_UP | ANIMDIR_DOWN));
- anim_delay_value = 100/anim->frames_per_second;
+ anim_delay_value = 1000/anim->frames_per_second;
frame = 0;
if (horiz_move)
else
graphic = GFX_LEERRAUM;
- DrawMiniGraphicExtHiRes(pix[PIX_DB_DOOR],gc,
- DOOR_GFX_PAGEX1+ED_BUTTON_ELEM_XPOS+3 +
- (i%MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
- DOOR_GFX_PAGEY1+ED_BUTTON_ELEM_YPOS+3 +
- (i/MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
- graphic);
+ DrawMiniGraphicExt(pix[PIX_DB_DOOR],gc,
+ DOOR_GFX_PAGEX1+ED_BUTTON_ELEM_XPOS+3 +
+ (i%MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
+ DOOR_GFX_PAGEY1+ED_BUTTON_ELEM_YPOS+3 +
+ (i/MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
+ graphic);
}
- DrawMiniGraphicExtHiRes(pix[PIX_DB_DOOR],gc,
- DOOR_GFX_PAGEX1+ED_WIN_MB_LEFT_XPOS,
- DOOR_GFX_PAGEY1+ED_WIN_MB_LEFT_YPOS,
- el2gfx(new_element1));
- DrawMiniGraphicExtHiRes(pix[PIX_DB_DOOR],gc,
- DOOR_GFX_PAGEX1+ED_WIN_MB_MIDDLE_XPOS,
- DOOR_GFX_PAGEY1+ED_WIN_MB_MIDDLE_YPOS,
- el2gfx(new_element2));
- DrawMiniGraphicExtHiRes(pix[PIX_DB_DOOR],gc,
- DOOR_GFX_PAGEX1+ED_WIN_MB_RIGHT_XPOS,
- DOOR_GFX_PAGEY1+ED_WIN_MB_RIGHT_YPOS,
- el2gfx(new_element3));
+ DrawMiniGraphicExt(pix[PIX_DB_DOOR],gc,
+ DOOR_GFX_PAGEX1+ED_WIN_MB_LEFT_XPOS,
+ DOOR_GFX_PAGEY1+ED_WIN_MB_LEFT_YPOS,
+ el2gfx(new_element1));
+ DrawMiniGraphicExt(pix[PIX_DB_DOOR],gc,
+ DOOR_GFX_PAGEX1+ED_WIN_MB_MIDDLE_XPOS,
+ DOOR_GFX_PAGEY1+ED_WIN_MB_MIDDLE_YPOS,
+ el2gfx(new_element2));
+ DrawMiniGraphicExt(pix[PIX_DB_DOOR],gc,
+ DOOR_GFX_PAGEX1+ED_WIN_MB_RIGHT_XPOS,
+ DOOR_GFX_PAGEY1+ED_WIN_MB_RIGHT_YPOS,
+ el2gfx(new_element3));
DrawTextExt(pix[PIX_DB_DOOR],gc,
DOOR_GFX_PAGEX2+ED_WIN_LEVELNR_XPOS,
DOOR_GFX_PAGEY1+ED_WIN_LEVELNR_YPOS,
else if (last_button==3)
new_element3 = new_element;
- DrawMiniGraphicExtHiRes(drawto,gc,
- DX+ED_WIN_MB_LEFT_XPOS,
- DY+ED_WIN_MB_LEFT_YPOS,
- el2gfx(new_element1));
- DrawMiniGraphicExtHiRes(drawto,gc,
- DX+ED_WIN_MB_MIDDLE_XPOS,
- DY+ED_WIN_MB_MIDDLE_YPOS,
- el2gfx(new_element2));
- DrawMiniGraphicExtHiRes(drawto,gc,
- DX+ED_WIN_MB_RIGHT_XPOS,
- DY+ED_WIN_MB_RIGHT_YPOS,
- el2gfx(new_element3));
+ DrawMiniGraphicExt(drawto,gc,
+ DX+ED_WIN_MB_LEFT_XPOS,
+ DY+ED_WIN_MB_LEFT_YPOS,
+ el2gfx(new_element1));
+ DrawMiniGraphicExt(drawto,gc,
+ DX+ED_WIN_MB_MIDDLE_XPOS,
+ DY+ED_WIN_MB_MIDDLE_YPOS,
+ el2gfx(new_element2));
+ DrawMiniGraphicExt(drawto,gc,
+ DX+ED_WIN_MB_RIGHT_XPOS,
+ DY+ED_WIN_MB_RIGHT_YPOS,
+ el2gfx(new_element3));
redraw_mask |= REDRAW_DOOR_1;
}
if (game_status != PLAYING)
{
XSync(display, FALSE);
- Delay(10000);
+ Delay(10);
}
}
}
else
{
- Delay(1000);
+ Delay(1);
}
}
/*
- Delay(160000 / num_steps);
+ Delay(160 / num_steps);
*/
/*
- Delay(120000 / num_steps);
+ Delay(120 / num_steps);
*/
}
}
0,0);
XFlush(display);
XSync(display,FALSE);
- Delay(1000000);
+ Delay(1000);
}
break;
TimeLeft--;
DrawText(DX_TIME,DY_TIME,int2str(TimeLeft,3),FS_SMALL,FC_YELLOW);
BackToFront();
- Delay(10000);
+ Delay(10);
}
if (sound_loops_on)
MovDir[x][y] = direction;
MovDir[newx][newy] = direction;
- if (Feld[newx][newy]==EL_LEERRAUM)
+ if (Feld[newx][newy] == EL_LEERRAUM)
Feld[newx][newy] = EL_BLOCKED;
}
if (MovDelay[x][y]) /* neue Phase / in Wartezustand */
{
MovDelay[x][y]--;
- if (MovDelay[x][y] && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+ if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
DrawGraphic(SCROLLX(x),SCROLLY(y),graphic+4-MovDelay[x][y]/2);
if (!MovDelay[x][y])
if (MovDelay[x][y]) /* neue Phase / in Wartezustand */
{
MovDelay[x][y]--;
- if (MovDelay[x][y] && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+ if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_AMOEBING+3-MovDelay[x][y]/2);
if (!MovDelay[x][y])
void Blubber(int x, int y)
{
- DrawGraphicAnimation(x,y, GFX_GEBLUBBER, 4, 10, ANIM_NORMAL);
+ if (y > 0 && IS_MOVING(x,y-1) && MovDir[x][y-1] == MV_DOWN)
+ DrawLevelField(x,y-1);
+ else
+ DrawGraphicAnimation(x,y, GFX_GEBLUBBER, 4, 10, ANIM_NORMAL);
}
void NussKnacken(int x, int y)
if (MovDelay[x][y]) /* neue Phase / in Wartezustand */
{
MovDelay[x][y]--;
- if (MovDelay[x][y] && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+ if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_CRACKINGNUT+3-MovDelay[x][y]/2);
if (!MovDelay[x][y])
int src_x,src_y, dest_x,dest_y;
int phase = (MovDelay[x][y]-1)/2;
- src_x = SX+GFX_PER_LINE*TILEX;
- src_y = SY+(phase > 2 ? 4-phase : phase)*TILEY;
- dest_x = FX+SCROLLX(x)*TILEX;
- dest_y = FY+SCROLLY(y)*TILEY;
+ if (phase > 2)
+ phase = 4-phase;
+
+ src_x = SX + GFX_PER_LINE*TILEX;
+ src_y = SY + phase*TILEY;
+ dest_x = FX + SCROLLX(x)*TILEX;
+ dest_y = FY + SCROLLY(y)*TILEY;
+ /*
XSetClipOrigin(display,clip_gc[PIX_BACK],dest_x-src_x,dest_y-src_y);
XCopyArea(display,pix[PIX_BACK],drawto_field,clip_gc[PIX_BACK],
src_x,src_y, TILEX,TILEY, dest_x,dest_y);
+ */
+
+ XSetClipMask(display, tile_clip_gc,
+ tile_clipmask[GFX_MASK_SPARKLING + phase]);
+ XSetClipOrigin(display, tile_clip_gc, dest_x,dest_y);
+ XCopyArea(display, pix[PIX_BACK], drawto_field, tile_clip_gc,
+ src_x,src_y, TILEX,TILEY, dest_x,dest_y);
if (direct_draw_on)
{
ScrollFigure(0);
while(!DelayReached(&action_delay, action_delay_value))
- Delay(5000);
+ Delay(5);
if (tape.pausing || (tape.playing && !TapePlayDelay()))
return;
PlayerGfxPos = ScrollStepSize * (PlayerMovPos / ScrollStepSize);
actual_frame_counter = FrameCounter;
+ /*
if (Feld[lastJX][lastJY] == EL_LEERRAUM &&
IN_LEV_FIELD(lastJX,lastJY-1) &&
CAN_FALL(Feld[lastJX][lastJY-1]))
Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING;
+ */
+
+ if (Feld[lastJX][lastJY] == EL_LEERRAUM)
+ Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING;
DrawPlayerField();
return;
Feld[x][y] = EL_LEERRAUM;
Key[key_nr] = TRUE;
RaiseScoreElement(EL_SCHLUESSEL);
- DrawMiniGraphicExtHiRes(drawto,gc,
- DX_KEYS+key_nr*MINI_TILEX,DY_KEYS,
- GFX_SCHLUESSEL1+key_nr);
- DrawMiniGraphicExtHiRes(window,gc,
- DX_KEYS+key_nr*MINI_TILEX,DY_KEYS,
- GFX_SCHLUESSEL1+key_nr);
+ DrawMiniGraphicExt(drawto,gc,
+ DX_KEYS+key_nr*MINI_TILEX,DY_KEYS,
+ GFX_SCHLUESSEL1+key_nr);
+ DrawMiniGraphicExt(window,gc,
+ DX_KEYS+key_nr*MINI_TILEX,DY_KEYS,
+ GFX_SCHLUESSEL1+key_nr);
PlaySoundLevel(x,y,SND_PONG);
break;
}
#define EX_BORDER 2
/* fundamental game speed */
-#define GAME_FRAME_DELAY 2
+#define GAME_FRAME_DELAY 20 /* frame delay in milliseconds */
#define FFWD_FRAME_DELAY 1
-#define FRAMES_PER_SECOND (100 / GAME_FRAME_DELAY)
+#define FRAMES_PER_SECOND (1000 / GAME_FRAME_DELAY)
void GetPlayerConfig(void);
void InitGame(void);
#ifdef DEBUG_TIMING
count2 = Counter();
printf(" LOADING '%s' IN %.2f SECONDS\n",
- filename, (float)(count2-count1)/100.0);
+ filename, (float)(count2-count1)/1000.0);
count1 = Counter();
#endif
#ifdef DEBUG_TIMING
count2 = Counter();
printf(" COMPRESSING IMAGE COLORMAP IN %.2f SECONDS\n",
- (float)(count2-count1)/100.0);
+ (float)(count2-count1)/1000.0);
count1 = Counter();
#endif
#ifdef DEBUG_TIMING
count2 = Counter();
printf(" CONVERTING IMAGE TO XIMAGE IN %.2f SECONDS\n",
- (float)(count2-count1)/100.0);
+ (float)(count2-count1)/1000.0);
count1 = Counter();
#endif
#ifdef DEBUG_TIMING
count2 = Counter();
printf(" CONVERTING IMAGE TO PIXMAP IN %.2f SECONDS\n",
- (float)(count2-count1)/100.0);
+ (float)(count2-count1)/1000.0);
count1 = Counter();
#endif
#ifdef DEBUG_TIMING
count2 = Counter();
printf(" CONVERTING IMAGE TO MASK IN %.2f SECONDS\n",
- (float)(count2-count1)/100.0);
+ (float)(count2-count1)/1000.0);
count1 = Counter();
#endif
#ifdef DEBUG_TIMING
count2 = Counter();
printf(" CONVERTING MASK TO XIMAGE IN %.2f SECONDS\n",
- (float)(count2-count1)/100.0);
+ (float)(count2-count1)/1000.0);
count1 = Counter();
#endif
#ifdef DEBUG_TIMING
count2 = Counter();
printf(" CONVERTING MASK TO PIXMAP IN %.2f SECONDS\n",
- (float)(count2-count1)/100.0);
+ (float)(count2-count1)/1000.0);
count1 = Counter();
#endif
visual = DefaultVisual(display, screen);
depth = DefaultDepth(display, screen);
cmap = DefaultColormap(display, screen);
- pen_fg = WhitePixel(display,screen);
- pen_bg = BlackPixel(display,screen);
/* look for good enough visual */
vinfo_template.screen = screen;
Atom proto_atom = None, delete_atom = None;
int screen_width, screen_height;
int win_xpos = WIN_XPOS, win_ypos = WIN_YPOS;
+ unsigned long pen_fg = WhitePixel(display,screen);
+ unsigned long pen_bg = BlackPixel(display,screen);
#ifndef MSDOS
static struct IconFileInfo icon_pic =
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
KeyPressMask | KeyReleaseMask;
XSelectInput(display, window, window_event_mask);
-
#endif
+
/* create GC for drawing with window depth */
gc_values.graphics_exposures = False;
gc_values.foreground = pen_bg;
void InitGfx()
{
int i,j;
+ GC copy_clipmask_gc;
XGCValues clip_gc_values;
unsigned long clip_gc_valuemask;
+
#ifdef MSDOS
static struct PictureFileInfo pic[NUM_PICTURES] =
{
};
#endif
+ static struct
+ {
+ int start;
+ int count;
+ }
+ tile_needs_clipping[] =
+ {
+ { GFX_SPIELER_UP, 4 },
+ { GFX_SPIELER_DOWN, 4 },
+ { GFX_SPIELER_LEFT, 4 },
+ { GFX_SPIELER_RIGHT, 4 },
+ { GFX_SPIELER_PUSH_LEFT, 4 },
+ { GFX_SPIELER_PUSH_RIGHT, 4 },
+ { GFX_GEBLUBBER, 4 },
+ { GFX_DYNAMIT, 7 },
+ { GFX_DYNABOMB, 4 },
+ { GFX_SOKOBAN_OBJEKT, 1 },
+ { GFX_MASK_SPARKLING, 3 },
+ { -1, 0 }
+ };
+
#ifdef DEBUG_TIMING
long count1, count2;
count1 = Counter();
#endif MSDOS
DrawInitText("Loading graphics:",120,FC_GREEN);
- for(i=0;i<NUM_PICTURES;i++)
- if (i!=PIX_SMALLFONT)
+ for(i=0; i<NUM_PICTURES; i++)
+ if (i != PIX_SMALLFONT)
LoadGfx(i,&pic[i]);
#ifdef DEBUG_TIMING
count2 = Counter();
- printf("SUMMARY: %.2f SECONDS LOADING TIME\n",(float)(count2-count1)/100.0);
+ printf("SUMMARY: %.2f SECONDS LOADING TIME\n",(float)(count2-count1)/1000.0);
#endif
FXSIZE,FYSIZE,
XDefaultDepth(display,screen));
+ clip_gc_values.graphics_exposures = False;
+ clip_gc_valuemask = GCGraphicsExposures;
+ copy_clipmask_gc =
+ XCreateGC(display,clipmask[PIX_BACK],clip_gc_valuemask,&clip_gc_values);
+
+ clip_gc_values.graphics_exposures = False;
+ clip_gc_valuemask = GCGraphicsExposures;
+ tile_clip_gc =
+ XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values);
+
+ /* initialize pixmap array to Pixmap 'None' */
+ for(i=0; i<NUM_TILES; i++)
+ tile_clipmask[i] = None;
+
+ /* create only those clipping Pixmaps we really need */
+ for(i=0; tile_needs_clipping[i].start>=0; i++)
+ {
+ for(j=0; j<tile_needs_clipping[i].count; j++)
+ {
+ int tile = tile_needs_clipping[i].start + j;
+ int graphic = tile;
+ int src_x, src_y;
+ Pixmap src_pixmap;
+
+ if (tile_needs_clipping[i].start == GFX_MASK_SPARKLING)
+ {
+ /* special case -- should be cleaned up sometimes... */
+ src_pixmap = clipmask[PIX_BACK];
+ src_x = SX + GFX_PER_LINE*TILEX;
+ src_y = SY + j*TILEY;
+ }
+ else if (graphic >= GFX_START_ROCKSSCREEN &&
+ graphic <= GFX_END_ROCKSSCREEN)
+ {
+ src_pixmap = clipmask[PIX_BACK];
+ graphic -= GFX_START_ROCKSSCREEN;
+ src_x = SX + (graphic % GFX_PER_LINE) * TILEX;
+ src_y = SY + (graphic / GFX_PER_LINE) * TILEY;
+ }
+ else if (graphic >= GFX_START_ROCKSHEROES &&
+ graphic <= GFX_END_ROCKSHEROES)
+ {
+ src_pixmap = clipmask[PIX_HEROES];
+ graphic -= GFX_START_ROCKSHEROES;
+ src_x = (graphic % HEROES_PER_LINE) * TILEX;
+ src_y = (graphic / HEROES_PER_LINE) * TILEY;
+ }
+ else if (graphic >= GFX_START_ROCKSFONT &&
+ graphic <= GFX_END_ROCKSFONT)
+ {
+ src_pixmap = clipmask[PIX_BIGFONT];
+ graphic -= GFX_START_ROCKSFONT;
+ src_x = (graphic % FONT_CHARS_PER_LINE) * TILEX;
+ src_y = (graphic / FONT_CHARS_PER_LINE) * TILEY +
+ FC_SPECIAL1 * FONT_LINES_PER_FONT * TILEY;
+ }
+ else
+ break;
+
+ tile_clipmask[tile] = XCreatePixmap(display, window, TILEX,TILEY, 1);
+
+ XCopyArea(display,src_pixmap,tile_clipmask[tile],copy_clipmask_gc,
+ src_x,src_y, TILEX,TILEY, 0,0);
+ }
+ }
+
if (!pix[PIX_DB_BACK] || !pix[PIX_DB_DOOR])
{
fprintf(stderr, "%s: cannot create additional Pixmaps!\n",progname);
if (clipmask[i])
{
clip_gc_values.graphics_exposures = False;
- clip_gc_values.foreground = pen_fg;
- clip_gc_values.background = pen_bg;
clip_gc_values.clip_mask = clipmask[i];
- clip_gc_valuemask =
- GCGraphicsExposures | GCForeground | GCBackground | GCClipMask;
+ clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
clip_gc[i] = XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values);
}
}
#ifdef DEBUG_TIMING
count2 = Counter();
printf("XPM LOADING %s IN %.2f SECONDS\n",
- filename,(float)(count2-count1)/100.0);
+ filename,(float)(count2-count1)/1000.0);
#endif
#else
#ifdef DEBUG_TIMING
count2 = Counter();
printf("GIF LOADING %s IN %.2f SECONDS\n",
- filename,(float)(count2-count1)/100.0);
+ filename,(float)(count2-count1)/1000.0);
#endif
#endif
#ifdef DEBUG_TIMING
count2 = Counter();
printf("XBM LOADING %s IN %.2f SECONDS\n",
- filename,(float)(count2-count1)/100.0);
+ filename,(float)(count2-count1)/1000.0);
#endif
#endif
Visual *visual;
int screen;
Window window;
-GC gc, clip_gc[NUM_PIXMAPS];
+GC gc, clip_gc[NUM_PIXMAPS], tile_clip_gc;
Pixmap pix[NUM_PIXMAPS];
-Pixmap clipmask[NUM_PIXMAPS];
+Pixmap clipmask[NUM_PIXMAPS], tile_clipmask[NUM_TILES];
#ifdef XPM_INCLUDE_FILE
XpmAttributes xpm_att[NUM_PICTURES];
char *joystick_device_name[2] = { DEV_JOYSTICK_0, DEV_JOYSTICK_1 };
char *level_directory = LEVEL_PATH;
int width, height;
-unsigned long pen_fg, pen_bg;
int game_status = MAINMENU;
int game_emulation = EMU_NONE;
extern Visual *visual;
extern int screen;
extern Window window;
-extern GC gc, clip_gc[];
-extern XImage *image[];
-extern Pixmap clipmask[];
+extern GC gc, clip_gc[], tile_clip_gc;
extern Pixmap pix[];
+extern Pixmap clipmask[], tile_clipmask[];
#ifdef XPM_INCLUDE_FILE
extern XpmAttributes xpm_att[];
extern char *joystick_device_name[2];
extern char *level_directory;
extern int width, height;
-extern unsigned long pen_fg, pen_bg;
extern int game_status;
extern int game_emulation;
#define GFX_START_ROCKSHEROES 512
#define GFX_END_ROCKSHEROES 767
+#define NUM_TILES 768
+
/* graphics from "RocksScreen" */
/* Zeile 0 (0) */
#define GFX_LEERRAUM (-1)
#define GFX_FIREFLY_L 206
#define GFX_FIREFLY_U 207
+/* CHANGE THIS!!!! (NO REGULAR POSITIONS...) */
+#define GFX_MASK_SPARKLING 210
+/* CHANGE THIS!!!! (NO REGULAR POSITIONS...) */
+
#define GFX_SCHLUESSEL GFX_SCHLUESSEL1
#define GFX_SPIELFIGUR GFX_SPIELER1
therefore it's better to do a short interval of busy waiting
to get our sleeping time more accurate */
- long base_counter = Counter2(), actual_counter = Counter2();
+ long base_counter = Counter(), actual_counter = Counter();
long delay = usec/1000;
while (actual_counter < base_counter+delay &&
actual_counter >= base_counter)
- actual_counter = Counter2();
+ actual_counter = Counter();
}
else
{
counter_ms = (current_time.tv_sec - base_time.tv_sec)*1000
+ (current_time.tv_usec - base_time.tv_usec)/1000;
- if (mode == READ_COUNTER_100)
- return(counter_ms/10); /* return 1/100 secs since last init */
- else /* READ_COUNTER_1000 */
- return(counter_ms); /* return 1/1000 secs since last init */
+ return counter_ms; /* return milliseconds since last init */
}
void InitCounter() /* set counter back to zero */
mainCounter(INIT_COUNTER);
}
-long Counter() /* returns 1/100 secs since last call of InitCounter() */
+long Counter() /* get milliseconds since last call of InitCounter() */
{
- return(mainCounter(READ_COUNTER_100));
-}
-
-long Counter2() /* returns 1/1000 secs since last call of InitCounter() */
-{
- return(mainCounter(READ_COUNTER_1000));
+ return(mainCounter(READ_COUNTER));
}
void WaitCounter(long value) /* wait for counter to reach value */
long wait;
while((wait=value-Counter())>0)
- microsleep(wait*10000);
-}
-
-void WaitCounter2(long value) /* wait for counter to reach value */
-{
- long wait;
-
- while((wait=value-Counter2())>0)
- microsleep(wait*1000);
+ microsleep(wait * 1000);
}
-void Delay(long value)
+void Delay(long value) /* Delay 'value' milliseconds */
{
- microsleep(value);
+ microsleep(value * 1000);
}
BOOL DelayReached(long *counter_var, int delay)
{
long actual_frame_counter = FrameCounter;
- if (actual_frame_counter >= *frame_counter_var+frame_delay
- || actual_frame_counter < *frame_counter_var)
+ if (actual_frame_counter >= *frame_counter_var+frame_delay ||
+ actual_frame_counter < *frame_counter_var)
{
*frame_counter_var = actual_frame_counter;
return(TRUE);
#include "main.h"
#define INIT_COUNTER 0
-#define READ_COUNTER_100 1
-#define READ_COUNTER_1000 2
+#define READ_COUNTER 1
#define NEW_RANDOMIZE -1
long mainCounter(int);
void InitCounter(void);
long Counter(void);
-long Counter2(void);
void WaitCounter(long);
-void WaitCounter2(long);
void Delay(long);
BOOL DelayReached(long *, int);
BOOL FrameReached(long *, int);
}
j++;
- DrawGraphicExtHiRes(drawto,gc,xstart,ystart+(i-start)*ystep,
- graphic+frame);
+ DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame);
i++;
}
joystick_status=JOYSTICK_OFF;
goto error_out;
}
- Delay(10000);
+ Delay(10);
}
new_joystick_xleft = joy_ctrl.x;
joystick_status=JOYSTICK_OFF;
goto error_out;
}
- Delay(10000);
+ Delay(10);
}
new_joystick_xright = joy_ctrl.x;
joystick_status=JOYSTICK_OFF;
goto error_out;
}
- Delay(10000);
+ Delay(10);
}
new_joystick_xmiddle = joy_ctrl.x;
DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
BackToFront();
- Delay(3000000);
+ Delay(3000);
DrawSetupScreen();
}
void FadeToFront()
{
/*
- long fading_delay = 300000;
+ long fading_delay = 300;
if (fading_on && (redraw_mask & REDRAW_FIELD))
{
REAL_SX,REAL_SY+i, FULL_SXSIZE,1, REAL_SX,REAL_SY+i);
}
XFlush(display);
- Delay(10000);
+ Delay(10);
}
*/
return(phase);
}
-void DrawGraphicAnimation(int x, int y, int graphic,
- int frames, int delay, int mode)
+void DrawGraphicAnimationExt(int x, int y, int graphic,
+ int frames, int delay, int mode, int mask_mode)
{
int phase = getGraphicAnimationPhase(frames, delay, mode);
if (!(FrameCounter % delay) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
- DrawGraphic(SCROLLX(x),SCROLLY(y), graphic + phase);
+ {
+ if (mask_mode == USE_MASKING)
+ DrawGraphicThruMask(SCROLLX(x),SCROLLY(y), graphic + phase);
+ else
+ DrawGraphic(SCROLLX(x),SCROLLY(y), graphic + phase);
+ }
+}
+
+void DrawGraphicAnimation(int x, int y, int graphic,
+ int frames, int delay, int mode)
+{
+ DrawGraphicAnimationExt(x,y, graphic, frames,delay,mode, NO_MASKING);
+}
+
+void DrawGraphicAnimationThruMask(int x, int y, int graphic,
+ int frames, int delay, int mode)
+{
+ DrawGraphicAnimationExt(x,y, graphic, frames,delay,mode, USE_MASKING);
}
void DrawGraphic(int x, int y, int graphic)
}
#endif
- DrawGraphicExt(drawto_field, gc, x, y, graphic);
+ DrawGraphicExt(drawto_field, gc, FX+x*TILEX, FY+y*TILEY, graphic);
MarkTileDirty(x,y);
}
void DrawGraphicExt(Drawable d, GC gc, int x, int y, int graphic)
-{
- DrawGraphicExtHiRes(d, gc, FX+x*TILEX, FY+y*TILEY, graphic);
-}
-
-void DrawGraphicExtHiRes(Drawable d, GC gc, int x, int y, int graphic)
{
if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
{
graphic -= GFX_START_ROCKSSCREEN;
XCopyArea(display,pix[PIX_BACK],d,gc,
- SX+(graphic % GFX_PER_LINE)*TILEX,
- SY+(graphic / GFX_PER_LINE)*TILEY,
+ SX + (graphic % GFX_PER_LINE) * TILEX,
+ SY + (graphic / GFX_PER_LINE) * TILEY,
TILEX,TILEY, x,y);
}
else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
{
graphic -= GFX_START_ROCKSHEROES;
XCopyArea(display,pix[PIX_HEROES],d,gc,
- (graphic % HEROES_PER_LINE)*TILEX,
- (graphic / HEROES_PER_LINE)*TILEY,
+ (graphic % HEROES_PER_LINE) * TILEX,
+ (graphic / HEROES_PER_LINE) * TILEY,
TILEX,TILEY, x,y);
}
else if (graphic >= GFX_START_ROCKSFONT && graphic <= GFX_END_ROCKSFONT)
{
graphic -= GFX_START_ROCKSFONT;
XCopyArea(display,pix[PIX_BIGFONT],d,gc,
- (graphic % FONT_CHARS_PER_LINE)*TILEX,
- (graphic / FONT_CHARS_PER_LINE)*TILEY +
- FC_SPECIAL1*TILEY*FONT_LINES_PER_FONT,
+ (graphic % FONT_CHARS_PER_LINE) * TILEX,
+ (graphic / FONT_CHARS_PER_LINE) * TILEY +
+ FC_SPECIAL1 * FONT_LINES_PER_FONT * TILEY,
TILEX,TILEY, x,y);
}
else
void DrawGraphicThruMask(int x, int y, int graphic)
{
int src_x,src_y, dest_x,dest_y;
+ int tile = graphic;
+ Pixmap src_pixmap;
+ GC drawing_gc;
#if DEBUG
if (!IN_SCR_FIELD(x,y))
if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
{
+ src_pixmap = pix[PIX_BACK];
+ drawing_gc = clip_gc[PIX_BACK];
graphic -= GFX_START_ROCKSSCREEN;
src_x = SX+(graphic % GFX_PER_LINE)*TILEX;
src_y = SY+(graphic / GFX_PER_LINE)*TILEY;
- dest_x = FX+x*TILEX;
- dest_y = FY+y*TILEY;
-
- XSetClipOrigin(display,clip_gc[PIX_BACK],dest_x-src_x,dest_y-src_y);
- XCopyArea(display,pix[PIX_BACK],drawto_field,clip_gc[PIX_BACK],
- src_x,src_y, TILEX,TILEY, dest_x,dest_y);
}
else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
{
+ src_pixmap = pix[PIX_HEROES];
+ drawing_gc = clip_gc[PIX_HEROES];
graphic -= GFX_START_ROCKSHEROES;
src_x = (graphic % HEROES_PER_LINE)*TILEX;
src_y = (graphic / HEROES_PER_LINE)*TILEY;
- dest_x = FX+x*TILEX;
- dest_y = FY+y*TILEY;
-
- XSetClipOrigin(display,clip_gc[PIX_HEROES],dest_x-src_x,dest_y-src_y);
- XCopyArea(display,pix[PIX_HEROES],drawto_field,clip_gc[PIX_HEROES],
- src_x,src_y, TILEX,TILEY, dest_x,dest_y);
}
else
{
return;
}
- MarkTileDirty(x,y);
-}
+ dest_x = FX + x*TILEX;
+ dest_y = FY + y*TILEY;
-void DrawScreenElementThruMask(int x, int y, int element)
-{
- DrawGraphicThruMask(x,y,el2gfx(element));
-}
+ if (tile_clipmask[tile] != None)
+ {
+ XSetClipMask(display, tile_clip_gc, tile_clipmask[tile]);
+ XSetClipOrigin(display, tile_clip_gc, dest_x,dest_y);
+ XCopyArea(display, src_pixmap, drawto_field, tile_clip_gc,
+ src_x,src_y, TILEX,TILEY, dest_x,dest_y);
+ }
+ else
+ {
+#if DEBUG
+ printf("DrawGraphicThruMask(): tile '%d' needs clipping!\n", tile);
+#endif
-void DrawLevelElementThruMask(int x, int y, int element)
-{
- if (IN_LEV_FIELD(x,y) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
- DrawScreenElementThruMask(SCROLLX(x),SCROLLY(y),element);
+ XSetClipOrigin(display, drawing_gc, dest_x-src_x, dest_y-src_y);
+ XCopyArea(display, src_pixmap, drawto_field, drawing_gc,
+ src_x,src_y, TILEX,TILEY, dest_x,dest_y);
+ }
+
+ MarkTileDirty(x,y);
}
void DrawMiniGraphic(int x, int y, int graphic)
{
- DrawMiniGraphicExt(drawto, gc, x, y, graphic);
+ DrawMiniGraphicExt(drawto,gc, SX+x*MINI_TILEX,SY+y*MINI_TILEY, graphic);
MarkTileDirty(x/2, y/2);
}
void DrawMiniGraphicExt(Drawable d, GC gc, int x, int y, int graphic)
-{
- DrawMiniGraphicExtHiRes(d,gc, SX+x*MINI_TILEX,SY+y*MINI_TILEY, graphic);
-}
-
-void DrawMiniGraphicExtHiRes(Drawable d, GC gc, int x, int y, int graphic)
{
if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
{
int width = TILEX, height = TILEY;
int cx = 0, cy = 0;
int src_x,src_y, dest_x,dest_y;
+ int tile = graphic;
+ Pixmap src_pixmap;
+ GC drawing_gc;
if (graphic < 0)
{
if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
{
+ src_pixmap = pix[PIX_BACK];
+ drawing_gc = clip_gc[PIX_BACK];
graphic -= GFX_START_ROCKSSCREEN;
src_x = SX+(graphic % GFX_PER_LINE)*TILEX+cx;
src_y = SY+(graphic / GFX_PER_LINE)*TILEY+cy;
- dest_x = FX+x*TILEX+dx;
- dest_y = FY+y*TILEY+dy;
-
- if (mask_mode == USE_MASKING)
- {
- XSetClipOrigin(display,clip_gc[PIX_BACK],dest_x-src_x,dest_y-src_y);
- XCopyArea(display,pix[PIX_BACK],drawto_field,clip_gc[PIX_BACK],
- src_x,src_y, width,height, dest_x,dest_y);
- }
- else
- XCopyArea(display,pix[PIX_BACK],drawto_field,gc,
- src_x,src_y, width,height, dest_x,dest_y);
}
else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
{
+ src_pixmap = pix[PIX_HEROES];
+ drawing_gc = clip_gc[PIX_HEROES];
graphic -= GFX_START_ROCKSHEROES;
src_x = (graphic % HEROES_PER_LINE)*TILEX+cx;
src_y = (graphic / HEROES_PER_LINE)*TILEY+cy;
- dest_x = FX+x*TILEX+dx;
- dest_y = FY+y*TILEY+dy;
-
- if (mask_mode == USE_MASKING)
- {
- XSetClipOrigin(display,clip_gc[PIX_HEROES],dest_x-src_x,dest_y-src_y);
- XCopyArea(display,pix[PIX_HEROES],drawto_field,clip_gc[PIX_HEROES],
- src_x,src_y, width,height, dest_x,dest_y);
- }
- else
- XCopyArea(display,pix[PIX_HEROES],drawto_field,gc,
- src_x,src_y, width,height, dest_x,dest_y);
}
+ dest_x = FX + x*TILEX + dx;
+ dest_y = FY + y*TILEY + dy;
+
#if DEBUG
if (!IN_SCR_FIELD(x,y))
{
}
#endif
+ if (mask_mode == USE_MASKING)
+ {
+ if (tile_clipmask[tile] != None)
+ {
+ XSetClipMask(display, tile_clip_gc, tile_clipmask[tile]);
+ XSetClipOrigin(display, tile_clip_gc, dest_x,dest_y);
+ XCopyArea(display, src_pixmap, drawto_field, tile_clip_gc,
+ src_x,src_y, TILEX,TILEY, dest_x,dest_y);
+ }
+ else
+ {
+#if DEBUG
+ printf("DrawGraphicShifted(): tile '%d' needs clipping!\n", tile);
+#endif
+
+ XSetClipOrigin(display, drawing_gc, dest_x-src_x, dest_y-src_y);
+ XCopyArea(display, src_pixmap, drawto_field, drawing_gc,
+ src_x,src_y, width,height, dest_x,dest_y);
+ }
+ }
+ else
+ XCopyArea(display, src_pixmap, drawto_field, gc,
+ src_x,src_y, width,height, dest_x,dest_y);
+
MarkTileDirty(x,y);
}
DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode, USE_MASKING);
}
-void DrawScreenElementShifted(int x, int y, int dx, int dy, int element,
- int cut_mode)
+void DrawScreenElementExt(int x, int y, int dx, int dy, int element,
+ int cut_mode, int mask_mode)
{
int ux = UNSCROLLX(x), uy = UNSCROLLY(y);
int graphic = el2gfx(element);
{
graphic = GFX_SONDE_START + getGraphicAnimationPhase(8, 2, ANIM_NORMAL);
}
+ else if (element==EL_SALZSAEURE)
+ {
+ graphic = GFX_GEBLUBBER + getGraphicAnimationPhase(4, 10, ANIM_NORMAL);
+ }
else if (element==EL_BUTTERFLY || element==EL_FIREFLY)
{
graphic += !phase;
}
if (dx || dy)
- DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode, NO_MASKING);
+ DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode, mask_mode);
+ else if (mask_mode == USE_MASKING)
+ DrawGraphicThruMask(x,y, graphic);
else
DrawGraphic(x,y, graphic);
}
+void DrawLevelElementExt(int x, int y, int dx, int dy, int element,
+ int cut_mode, int mask_mode)
+{
+ if (IN_LEV_FIELD(x,y) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+ DrawScreenElementExt(SCROLLX(x),SCROLLY(y), dx,dy, element,
+ cut_mode, mask_mode);
+}
+
+void DrawScreenElementShifted(int x, int y, int dx, int dy, int element,
+ int cut_mode)
+{
+ DrawScreenElementExt(x,y, dx,dy, element, cut_mode, NO_MASKING);
+}
+
void DrawLevelElementShifted(int x, int y, int dx, int dy, int element,
int cut_mode)
{
- if (IN_LEV_FIELD(x,y) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
- DrawScreenElementShifted(SCROLLX(x),SCROLLY(y), dx,dy, element, cut_mode);
+ DrawLevelElementExt(x,y, dx,dy, element, cut_mode, NO_MASKING);
+}
+
+void DrawScreenElementThruMask(int x, int y, int element)
+{
+ DrawScreenElementExt(x,y, 0,0, element, NO_CUTTING, USE_MASKING);
+}
+
+void DrawLevelElementThruMask(int x, int y, int element)
+{
+ DrawLevelElementExt(x,y, 0,0, element, NO_CUTTING, USE_MASKING);
}
void ErdreichAnbroeckeln(int x, int y)
void DrawScreenElement(int x, int y, int element)
{
- DrawScreenElementShifted(x,y, 0,0, element, NO_CUTTING);
+ DrawScreenElementExt(x,y, 0,0, element, NO_CUTTING, NO_MASKING);
ErdreichAnbroeckeln(x,y);
}
Store[ux][uy]==EL_AMOEBE_NASS)
cut_mode = CUT_ABOVE;
else if (Store[ux][uy]==EL_MORAST_VOLL ||
+
+#if 0
+ Store[ux][uy]==EL_SALZSAEURE ||
+#endif
+
Store[ux][uy]==EL_SIEB_VOLL ||
- Store[ux][uy]==EL_SIEB2_VOLL ||
- Store[ux][uy]==EL_SALZSAEURE)
+ Store[ux][uy]==EL_SIEB2_VOLL)
cut_mode = CUT_BELOW;
if (cut_mode==CUT_ABOVE)
DrawScreenElementShifted(x,y, MovPos[ux][uy],0, element, NO_CUTTING);
else
DrawScreenElementShifted(x,y, 0,MovPos[ux][uy], element, cut_mode);
+
+#if 1
+ if (Store[ux][uy] == EL_SALZSAEURE)
+ DrawLevelElementThruMask(ux,uy+1, EL_SALZSAEURE);
+#endif
+
}
else if (IS_BLOCKED(ux,uy))
{
while(result<0)
{
DoAnimation();
- Delay(10000);
+ Delay(10);
if (XPending(display))
{
static unsigned int door2 = DOOR_CLOSE_2;
static long door_delay = 0;
int x, start, stepsize = 2;
- long door_delay_value = stepsize * 5000;
+ long door_delay_value = stepsize * 5;
if (door_state == DOOR_GET_STATE)
return(door1 | door2);
for(x=start; x<=DXSIZE; x+=stepsize)
{
- while(!DelayReached(&door_delay, door_delay_value/10000))
- Delay(1000);
+ while(!DelayReached(&door_delay, door_delay_value/10))
+ Delay(1);
if (door_state & DOOR_ACTION_1)
{
void DrawText(int, int, char *, int, int);
void DrawTextExt(Drawable, GC, int, int, char *, int, int);
void DrawPlayerField(void);
+void DrawGraphicAnimationExt(int, int, int, int, int, int, int);
void DrawGraphicAnimation(int, int, int, int, int, int);
+void DrawGraphicAnimationThruMask(int, int, int, int, int, int);
void DrawGraphic(int, int, int);
void DrawGraphicExt(Drawable, GC, int, int, int);
-void DrawGraphicExtHiRes(Drawable, GC, int, int, int);
void DrawGraphicThruMask(int, int, int);
-void DrawScreenElementThruMask(int, int, int);
-void DrawLevelElementThruMask(int, int, int);
void DrawMiniGraphic(int, int, int);
void DrawMiniGraphicExt(Drawable, GC, int, int, int);
-void DrawMiniGraphicExtHiRes(Drawable, GC, int, int, int);
void DrawGraphicShifted(int, int, int, int, int, int, int);
void DrawGraphicShiftedThruMask(int, int, int, int, int, int);
+void DrawScreenElementExt(int, int, int, int, int, int, int);
+void DrawLevelElementExt(int, int, int, int, int, int, int);
void DrawScreenElementShifted(int, int, int, int, int, int);
void DrawLevelElementShifted(int, int, int, int, int, int);
+void DrawScreenElementThruMask(int, int, int);
+void DrawLevelElementThruMask(int, int, int);
void ErdreichAnbroeckeln(int, int);
void DrawScreenElement(int, int, int);
void DrawLevelElement(int, int, int);