rocksndiamonds-3.1.2
[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   if (game_status == GAME_MODE_PLAYING &&
27       level.game_engine_type == GAME_ENGINE_TYPE_EM)
28   {
29     BlitScreenToBitmap_EM(backbuffer);
30
31     return;
32   }
33
34   /* fill empty backbuffer for animation functions */
35   if (setup.direct_draw && game_status == GAME_MODE_PLAYING)
36   {
37     int xx, yy;
38
39     SetDrawtoField(DRAW_BACKBUFFER);
40
41     for (xx = 0; xx < SCR_FIELDX; xx++)
42       for (yy = 0; yy < SCR_FIELDY; yy++)
43         DrawScreenField(xx, yy);
44     DrawAllPlayers();
45
46     SetDrawtoField(DRAW_DIRECT);
47   }
48
49   if (setup.soft_scrolling && game_status == GAME_MODE_PLAYING)
50   {
51     int fx = FX, fy = FY;
52
53     fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
54     fy += (ScreenMovDir & (MV_UP|MV_DOWN)    ? ScreenGfxPos : 0);
55
56     BlitBitmap(fieldbuffer, backbuffer, fx, fy, SXSIZE, SYSIZE, SX, SY);
57   }
58 }
59
60 boolean ToonNeedsRedraw()
61 {
62 #if 1
63   return TRUE;
64 #else
65   return (game_status == GAME_MODE_INFO ||
66           game_status == GAME_MODE_LEVELS ||
67           game_status == GAME_MODE_SETUP ||
68           (game_status == GAME_MODE_MAIN &&
69            ((redraw_mask & REDRAW_MICROLEVEL) ||
70             (redraw_mask & REDRAW_MICROLABEL))));
71 #endif
72 }
73
74 void InitToons()
75 {
76   int num_toons = MAX_NUM_TOONS;
77   int i;
78
79   if (global.num_toons > 0 && global.num_toons < MAX_NUM_TOONS)
80     num_toons = global.num_toons;
81
82   for (i=0; i < num_toons; i++)
83   {
84     int graphic = IMG_TOON_1 + i;
85     struct FileInfo *image = getImageListEntryFromImageID(graphic);
86
87     toons[i].bitmap = graphic_info[graphic].bitmap;
88
89     toons[i].src_x = graphic_info[graphic].src_x;
90     toons[i].src_y = graphic_info[graphic].src_y;
91
92     toons[i].width  = graphic_info[graphic].width;
93     toons[i].height = graphic_info[graphic].height;
94
95     toons[i].anim_frames      = graphic_info[graphic].anim_frames;
96     toons[i].anim_delay       = graphic_info[graphic].anim_delay;
97     toons[i].anim_mode        = graphic_info[graphic].anim_mode;
98     toons[i].anim_start_frame = graphic_info[graphic].anim_start_frame;
99
100     toons[i].step_offset = graphic_info[graphic].step_offset;
101     toons[i].step_delay  = graphic_info[graphic].step_delay;
102
103     toons[i].direction = image->parameter[GFX_ARG_DIRECTION];
104     toons[i].position = image->parameter[GFX_ARG_POSITION];
105   }
106
107   InitToonScreen(bitmap_db_door,
108                  BackToFront, PrepareBackbuffer, ToonNeedsRedraw,
109                  toons, num_toons,
110                  REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
111                  GAME_FRAME_DELAY);
112 }