rnd-20040301-1-src
[rocksndiamonds.git] / src / cartoons.c
1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back!               *
3 *----------------------------------------------------------*
4 * (c) 1995-2002 Artsoft Entertainment                      *
5 *               Holger Schemel                             *
6 *               Detmolder Strasse 189                      *
7 *               33604 Bielefeld                            *
8 *               Germany                                    *
9 *               e-mail: info@artsoft.org                   *
10 *----------------------------------------------------------*
11 * cartoons.c                                               *
12 ***********************************************************/
13
14 #include "cartoons.h"
15 #include "main.h"
16 #include "tools.h"
17
18
19 /* values for toon definition */
20 #define MAX_NUM_TOONS                   20
21
22 static struct ToonInfo toons[MAX_NUM_TOONS];
23
24 static void PrepareBackbuffer()
25 {
26   /* Fill empty backbuffer for animation functions */
27   if (setup.direct_draw && game_status == GAME_MODE_PLAYING)
28   {
29     int xx, yy;
30
31     SetDrawtoField(DRAW_BACKBUFFER);
32
33     for (xx = 0; xx < SCR_FIELDX; xx++)
34       for (yy = 0; yy < SCR_FIELDY; yy++)
35         DrawScreenField(xx, yy);
36     DrawAllPlayers();
37
38     SetDrawtoField(DRAW_DIRECT);
39   }
40
41   if (setup.soft_scrolling && game_status == GAME_MODE_PLAYING)
42   {
43     int fx = FX, fy = FY;
44
45     fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
46     fy += (ScreenMovDir & (MV_UP|MV_DOWN)    ? ScreenGfxPos : 0);
47
48     BlitBitmap(fieldbuffer, backbuffer, fx, fy, SXSIZE, SYSIZE, SX, SY);
49   }
50 }
51
52 boolean ToonNeedsRedraw()
53 {
54 #if 1
55   return TRUE;
56 #else
57   return (game_status == GAME_MODE_INFO ||
58           game_status == GAME_MODE_LEVELS ||
59           game_status == GAME_MODE_SETUP ||
60           (game_status == GAME_MODE_MAIN &&
61            ((redraw_mask & REDRAW_MICROLEVEL) ||
62             (redraw_mask & REDRAW_MICROLABEL))));
63 #endif
64 }
65
66 void InitToons()
67 {
68   int num_toons = MAX_NUM_TOONS;
69   int i;
70
71   if (global.num_toons > 0 && global.num_toons < MAX_NUM_TOONS)
72     num_toons = global.num_toons;
73
74   for (i=0; i < num_toons; i++)
75   {
76     int graphic = IMG_TOON_1 + i;
77     struct FileInfo *image = getImageListEntry(graphic);
78
79     toons[i].bitmap = graphic_info[graphic].bitmap;
80
81     toons[i].src_x = graphic_info[graphic].src_x;
82     toons[i].src_y = graphic_info[graphic].src_y;
83
84     toons[i].width  = graphic_info[graphic].width;
85     toons[i].height = graphic_info[graphic].height;
86
87     toons[i].anim_frames      = graphic_info[graphic].anim_frames;
88     toons[i].anim_delay       = graphic_info[graphic].anim_delay;
89     toons[i].anim_mode        = graphic_info[graphic].anim_mode;
90     toons[i].anim_start_frame = graphic_info[graphic].anim_start_frame;
91
92     toons[i].step_offset = graphic_info[graphic].step_offset;
93     toons[i].step_delay  = graphic_info[graphic].step_delay;
94
95     toons[i].direction = image->parameter[GFX_ARG_DIRECTION];
96     toons[i].position = image->parameter[GFX_ARG_POSITION];
97   }
98
99   InitToonScreen(bitmap_db_door,
100                  BackToFront, PrepareBackbuffer, ToonNeedsRedraw,
101                  toons, num_toons,
102                  REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
103                  GAME_FRAME_DELAY);
104 }