From: Holger Schemel Date: Fri, 22 Jan 1999 12:36:01 +0000 (+0100) Subject: rnd-19990122-2 X-Git-Tag: 1.3.0^2~22 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c16ef99848a25648feccaae350ada6f8665a18f4;p=rocksndiamonds.git rnd-19990122-2 --- diff --git a/src/buttons.c b/src/buttons.c index 95c29674..f8d181e4 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -2336,8 +2336,7 @@ void HandleGadgets(int mx, int my, int button) gi->event.off_borders = FALSE; /* initialize delay counter */ - pressed_delay = 0; - DelayReached(&pressed_delay, GADGET_FRAME_DELAY); + DelayReached(&pressed_delay, 0); if (gi->event_mask & GD_EVENT_PRESSED) gi->callback_action(gi); diff --git a/src/cartoons.c b/src/cartoons.c index 834996b7..bd00d1af 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -462,10 +462,12 @@ boolean AnimateToon(int toon_nr, boolean restart) if (!DelayReached(&anim_delay, anim_delay_value)) { - if (game_status==HELPSCREEN && !restart) - DrawAnim(anim_pixmap,anim_clip_gc, - src_x+cut_x,src_y+cut_y, width,height, - REAL_SX+dest_x,REAL_SY+dest_y, pad_x,pad_y); + if ((game_status == HELPSCREEN || + (game_status == MAINMENU && redraw_mask & REDRAW_MICROLEVEL)) + && !restart) + DrawAnim(anim_pixmap, anim_clip_gc, + src_x + cut_x, src_y + cut_y, width, height, + REAL_SX + dest_x, REAL_SY + dest_y, pad_x, pad_y); return(FALSE); } diff --git a/src/init.c b/src/init.c index b8e6704e..33cec176 100644 --- a/src/init.c +++ b/src/init.c @@ -887,7 +887,8 @@ void InitElementProperties() EL_SP_HARD_BASE5, EL_SP_HARD_BASE6, EL_SP_TERMINAL, - EL_SP_EXIT + EL_SP_EXIT, + EL_INVISIBLE_STEEL }; static int ep_solid_num = sizeof(ep_solid)/sizeof(int); @@ -919,6 +920,7 @@ void InitElementProperties() EL_SP_HARD_BASE4, EL_SP_HARD_BASE5, EL_SP_HARD_BASE6, + EL_INVISIBLE_STEEL }; static int ep_massive_num = sizeof(ep_massive)/sizeof(int); @@ -1007,7 +1009,8 @@ void InitElementProperties() EL_SP_HARD_BASE5, EL_SP_HARD_BASE6, EL_SP_TERMINAL, - EL_SP_EXIT + EL_SP_EXIT, + EL_INVISIBLE_STEEL }; static int ep_mauer_num = sizeof(ep_mauer)/sizeof(int); @@ -1201,7 +1204,8 @@ void InitElementProperties() EL_SOKOBAN_OBJEKT, EL_SOKOBAN_FELD_LEER, EL_SOKOBAN_FELD_VOLL, - EL_SPIELFIGUR + EL_SPIELFIGUR, + EL_INVISIBLE_STEEL }; static int ep_sb_element_num = sizeof(ep_sb_element)/sizeof(int); @@ -1299,7 +1303,8 @@ void InitElementProperties() EL_SP_HARD_BASE4, EL_SP_HARD_BASE5, EL_SP_HARD_BASE6, - EL_SP_EXIT + EL_SP_EXIT, + EL_INVISIBLE_STEEL }; static int ep_inactive_num = sizeof(ep_inactive)/sizeof(int); diff --git a/src/main.h b/src/main.h index 84fa41ea..da627421 100644 --- a/src/main.h +++ b/src/main.h @@ -213,6 +213,7 @@ typedef unsigned char byte; #define FFWD_FRAME_DELAY 10 /* 200% speed for fast forward */ #define FRAMES_PER_SECOND (1000 / GAME_FRAME_DELAY) #define GADGET_FRAME_DELAY 150 /* delay between gadget actions */ +#define MICROLEVEL_SCROLL_DELAY 50 /* delay for scrolling micro level */ struct HiScore { @@ -502,10 +503,10 @@ extern int num_bg_loops; #define EYSIZE (VXSIZE + 44) #define FULL_SXSIZE (2+SXSIZE+2) #define FULL_SYSIZE (2+SYSIZE+2) -#define MICROLEV_XPOS (SX+4*32+16) -#define MICROLEV_YPOS (SX+12*32) -#define MICROLEV_XSIZE (STD_LEV_FIELDX*MICRO_TILEX) -#define MICROLEV_YSIZE (STD_LEV_FIELDY*MICRO_TILEY) +#define MICROLEV_XSIZE ((STD_LEV_FIELDX + 2) * MICRO_TILEX) +#define MICROLEV_YSIZE ((STD_LEV_FIELDY + 2) * MICRO_TILEY) +#define MICROLEV_XPOS (SX + (SXSIZE - MICROLEV_XSIZE) / 2) +#define MICROLEV_YPOS (SX + 12 * TILEY - MICRO_TILEY) #define MICROLABEL_YPOS (MICROLEV_YPOS+MICROLEV_YSIZE+12) #define FONT1_XSIZE 32 #define FONT1_YSIZE 32 @@ -603,9 +604,7 @@ extern int num_bg_loops; #define EL_ERZ_EDEL_GELB 59 #define EL_MAMPFER2 60 #define EL_SIEB2_INAKTIV 61 - -#define EL_UNUSED_62 62 - +#define EL_INVISIBLE_STEEL 62 #define EL_DYNABOMB 63 #define EL_DYNABOMB_NR 64 #define EL_DYNABOMB_SZ 65 @@ -968,6 +967,8 @@ extern int num_bg_loops; #define GFX_FIREFLY_L 206 #define GFX_FIREFLY_U 207 +#define GFX_INVISIBLE_STEEL GFX_UNSICHTBAR + #define GFX_SCHLUESSEL GFX_SCHLUESSEL1 #define GFX_SPIELFIGUR GFX_SPIELER1 @@ -1263,13 +1264,21 @@ extern int num_bg_loops; #define REDRAW_VIDEO_1 (1L << 4) #define REDRAW_VIDEO_2 (1L << 5) #define REDRAW_VIDEO_3 (1L << 6) -#define REDRAW_MICROLEV (1L << 7) -#define REDRAW_FROM_BACKBUFFER (1L << 8) -#define REDRAW_DOOR_2 (REDRAW_VIDEO_1 | REDRAW_VIDEO_2 | REDRAW_VIDEO_3) -#define REDRAW_DOOR_3 (1L << 9) -#define REDRAW_DOORS (REDRAW_DOOR_1 | REDRAW_DOOR_2 | REDRAW_DOOR_3) -#define REDRAW_MAIN (REDRAW_FIELD | REDRAW_TILES | REDRAW_MICROLEV) -#define REDRAWTILES_THRESHOLD SCR_FIELDX*SCR_FIELDY/2 +#define REDRAW_MICROLEVEL (1L << 7) +#define REDRAW_MICROLEVEL_LABEL (1L << 8) +#define REDRAW_FROM_BACKBUFFER (1L << 9) +#define REDRAW_DOOR_2 (REDRAW_VIDEO_1 | \ + REDRAW_VIDEO_2 | \ + REDRAW_VIDEO_3) +#define REDRAW_DOOR_3 (1L << 10) +#define REDRAW_DOORS (REDRAW_DOOR_1 | \ + REDRAW_DOOR_2 | \ + REDRAW_DOOR_3) +#define REDRAW_MAIN (REDRAW_FIELD | \ + REDRAW_TILES | \ + REDRAW_MICROLEVEL | \ + REDRAW_MICROLEVEL_LABEL) +#define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2) /* areas in pixmap PIX_DOOR */ /* meaning in PIX_DB_DOOR: (3 PAGEs) diff --git a/src/screens.c b/src/screens.c index 30318da8..11c6bf2a 100644 --- a/src/screens.c +++ b/src/screens.c @@ -89,7 +89,7 @@ void DrawMainMenu() DrawText(SX + 32, SY + 8*32, "Setup", FS_BIG, FC_GREEN); DrawText(SX + 32, SY + 9*32, "Quit", FS_BIG, FC_GREEN); - DrawMicroLevel(MICROLEV_XPOS,MICROLEV_YPOS); + DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE); DrawTextF(7*32 + 6, 3*32 + 9, FC_RED, "%d-%d", leveldir[leveldir_nr].first_level, @@ -201,7 +201,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) int2str(level_nr, 3), FS_BIG, font_color); LoadLevel(level_nr); - DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS); + DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE); TapeErase(); LoadTape(level_nr); @@ -246,7 +246,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (y == 6) { - if (leveldir[leveldir_nr].readonly) + if (leveldir[leveldir_nr].readonly && + strcmp(setup.player_name, "Artsoft") != 0) Request("This level is read only !", REQ_CONFIRM); game_status = LEVELED; DrawLevelEd(); @@ -291,7 +292,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) out: if (game_status == MAINMENU) + { + DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE); DoAnimation(); + } } #define MAX_HELPSCREEN_ELS 10 diff --git a/src/tools.c b/src/tools.c index fe3291fa..900e5ef7 100644 --- a/src/tools.c +++ b/src/tools.c @@ -184,15 +184,20 @@ void BackToFront() redraw_mask &= ~REDRAW_DOORS; } - if (redraw_mask & REDRAW_MICROLEV) + if (redraw_mask & REDRAW_MICROLEVEL) { XCopyArea(display,backbuffer,window,gc, - MICROLEV_XPOS,MICROLEV_YPOS, MICROLEV_XSIZE,MICROLEV_YSIZE, - MICROLEV_XPOS,MICROLEV_YPOS); + MICROLEV_XPOS, MICROLEV_YPOS, MICROLEV_XSIZE, MICROLEV_YSIZE, + MICROLEV_XPOS, MICROLEV_YPOS); + redraw_mask &= ~REDRAW_MICROLEVEL; + } + + if (redraw_mask & REDRAW_MICROLEVEL_LABEL) + { XCopyArea(display,backbuffer,window,gc, - SX,MICROLABEL_YPOS, SXSIZE,FONT4_YSIZE, - SX,MICROLABEL_YPOS); - redraw_mask &= ~REDRAW_MICROLEV; + SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE, + SX, MICROLABEL_YPOS); + redraw_mask &= ~REDRAW_MICROLEVEL_LABEL; } if (redraw_mask & REDRAW_TILES) @@ -1401,43 +1406,113 @@ void DrawMiniLevel(int scroll_x, int scroll_y) redraw_mask |= REDRAW_FIELD; } -void DrawMicroLevel(int xpos, int ypos) +static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y) { - int x,y; + int x, y; /* determine border element for this level */ SetBorderElement(); XFillRectangle(display, drawto, gc, - xpos - MICRO_TILEX, ypos - MICRO_TILEY, - MICRO_TILEX * (STD_LEV_FIELDX + 2), - MICRO_TILEY * (STD_LEV_FIELDY + 2)); + xpos, ypos, MICROLEV_XSIZE, MICROLEV_YSIZE); + if (lev_fieldx < STD_LEV_FIELDX) - xpos += (STD_LEV_FIELDX - lev_fieldx)/2 * MICRO_TILEX; + xpos += (STD_LEV_FIELDX - lev_fieldx) / 2 * MICRO_TILEX; if (lev_fieldy < STD_LEV_FIELDY) - ypos += (STD_LEV_FIELDY - lev_fieldy)/2 * MICRO_TILEY; + ypos += (STD_LEV_FIELDY - lev_fieldy) / 2 * MICRO_TILEY; + + xpos += MICRO_TILEX; + ypos += MICRO_TILEY; for(x=-1; x<=STD_LEV_FIELDX; x++) + { for(y=-1; y<=STD_LEV_FIELDY; y++) - if (x >= 0 && x < lev_fieldx && y >= 0 && y < lev_fieldy) + { + int lx = from_x + x, ly = from_y + y; + + if (lx >= 0 && lx < lev_fieldx && ly >= 0 && ly < lev_fieldy) DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY, - Ur[x][y]); - else if (x >= -1 && x < lev_fieldx+1 && y >= -1 && y < lev_fieldy+1) + Ur[lx][ly]); + else if (lx >= -1 && lx < lev_fieldx+1 && ly >= -1 && ly < lev_fieldy+1) DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY, BorderElement); + } + } - XFillRectangle(display, drawto,gc, SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE); + redraw_mask |= REDRAW_MICROLEVEL; +} + +void DrawMicroLevel(int xpos, int ypos, boolean restart) +{ + static unsigned long scroll_delay = 0; + static int from_x, from_y, scroll_direction; - if (level.name) + if (restart) { - int len = strlen(level.name); - int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2; - int lypos = MICROLABEL_YPOS; + from_x = from_y = 0; + scroll_direction = MV_RIGHT; + + DrawMicroLevelExt(xpos, ypos, from_x, from_y); + + XFillRectangle(display, drawto,gc, + SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE); + + if (level.name && restart) + { + int len = strlen(level.name); + int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2; + int lypos = MICROLABEL_YPOS; + + DrawText(lxpos, lypos, level.name, FS_SMALL, FC_SPECIAL2); + } + + /* initialize delay counter */ + DelayReached(&scroll_delay, 0); - DrawText(lxpos, lypos, level.name, FS_SMALL, FC_SPECIAL2); + redraw_mask |= REDRAW_MICROLEVEL_LABEL; } + else + { + if ((lev_fieldx <= STD_LEV_FIELDX && lev_fieldy <= STD_LEV_FIELDY) || + !DelayReached(&scroll_delay, MICROLEVEL_SCROLL_DELAY)) + return; + + switch (scroll_direction) + { + case MV_LEFT: + if (from_x > 0) + from_x--; + else + scroll_direction = MV_UP; + break; + + case MV_RIGHT: + if (from_x < lev_fieldx - STD_LEV_FIELDX) + from_x++; + else + scroll_direction = MV_DOWN; + break; - redraw_mask |= REDRAW_MICROLEV; + case MV_UP: + if (from_y > 0) + from_y--; + else + scroll_direction = MV_RIGHT; + break; + + case MV_DOWN: + if (from_y < lev_fieldy - STD_LEV_FIELDY) + from_y++; + else + scroll_direction = MV_LEFT; + break; + + default: + break; + } + + DrawMicroLevelExt(xpos, ypos, from_x, from_y); + } } int REQ_in_range(int x, int y) @@ -1987,6 +2062,7 @@ int el2gfx(int element) case EL_SPEED_PILL: return GFX_SPEED_PILL; case EL_SP_TERMINAL_ACTIVE: return GFX_SP_TERMINAL; case EL_SP_BUG_ACTIVE: return GFX_SP_BUG_ACTIVE; + case EL_INVISIBLE_STEEL: return GFX_INVISIBLE_STEEL; default: { diff --git a/src/tools.h b/src/tools.h index 53879309..e83ebfa9 100644 --- a/src/tools.h +++ b/src/tools.h @@ -97,7 +97,7 @@ void DrawMiniElementOrWall(int, int, int, int); void DrawMicroElement(int, int, int); void DrawLevel(void); void DrawMiniLevel(int, int); -void DrawMicroLevel(int, int); +void DrawMicroLevel(int, int, boolean); boolean Request(char *, unsigned int); unsigned int OpenDoor(unsigned int); unsigned int CloseDoor(unsigned int);