rocksndiamonds-3.2.4
[rocksndiamonds.git] / src / cartoons.c
1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back!               *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 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   if (setup.soft_scrolling && game_status == GAME_MODE_PLAYING)
35   {
36     int fx = FX, fy = FY;
37
38     fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
39     fy += (ScreenMovDir & (MV_UP|MV_DOWN)    ? ScreenGfxPos : 0);
40
41     BlitBitmap(fieldbuffer, backbuffer, fx, fy, SXSIZE, SYSIZE, SX, SY);
42   }
43 }
44
45 boolean ToonNeedsRedraw()
46 {
47   return TRUE;
48 }
49
50 void InitToons()
51 {
52   int num_toons = MAX_NUM_TOONS;
53   int i;
54
55   if (global.num_toons >= 0 && global.num_toons < MAX_NUM_TOONS)
56     num_toons = global.num_toons;
57
58   for (i = 0; i < num_toons; i++)
59   {
60     int graphic = IMG_TOON_1 + i;
61     struct FileInfo *image = getImageListEntryFromImageID(graphic);
62
63     toons[i].bitmap = graphic_info[graphic].bitmap;
64
65     toons[i].src_x = graphic_info[graphic].src_x;
66     toons[i].src_y = graphic_info[graphic].src_y;
67
68     toons[i].width  = graphic_info[graphic].width;
69     toons[i].height = graphic_info[graphic].height;
70
71     toons[i].anim_frames      = graphic_info[graphic].anim_frames;
72     toons[i].anim_delay       = graphic_info[graphic].anim_delay;
73     toons[i].anim_mode        = graphic_info[graphic].anim_mode;
74     toons[i].anim_start_frame = graphic_info[graphic].anim_start_frame;
75
76     toons[i].step_offset = graphic_info[graphic].step_offset;
77     toons[i].step_delay  = graphic_info[graphic].step_delay;
78
79     toons[i].direction = image->parameter[GFX_ARG_DIRECTION];
80     toons[i].position = image->parameter[GFX_ARG_POSITION];
81   }
82
83 #if 1
84   InitToonScreen(bitmap_db_toons,
85 #else
86   InitToonScreen(bitmap_db_door,
87 #endif
88                  BackToFront, PrepareBackbuffer, ToonNeedsRedraw,
89                  toons, num_toons,
90                  REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
91                  GAME_FRAME_DELAY);
92 }