rnd-20140514-2-src
[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     return;
28
29 #if 1
30   BlitScreenToBitmap(backbuffer);
31 #else
32   if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
33   {
34     BlitScreenToBitmap_EM(backbuffer);
35   }
36   else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
37   {
38     BlitScreenToBitmap_SP(backbuffer);
39   }
40   else if (setup.soft_scrolling)        /* GAME_ENGINE_TYPE_RND */
41   {
42     int fx = FX, fy = FY;
43
44     fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
45     fy += (ScreenMovDir & (MV_UP|MV_DOWN)    ? ScreenGfxPos : 0);
46
47     BlitBitmap(fieldbuffer, backbuffer, fx, fy, SXSIZE, SYSIZE, SX, SY);
48   }
49 #endif
50 }
51
52 boolean ToonNeedsRedraw()
53 {
54   return TRUE;
55 }
56
57 void InitToons()
58 {
59   int num_toons = MAX_NUM_TOONS;
60   int i;
61
62   if (global.num_toons >= 0 && global.num_toons < MAX_NUM_TOONS)
63     num_toons = global.num_toons;
64
65   for (i = 0; i < num_toons; i++)
66   {
67     int graphic = IMG_TOON_1 + i;
68     struct FileInfo *image = getImageListEntryFromImageID(graphic);
69
70     toons[i].bitmap = graphic_info[graphic].bitmap;
71
72     toons[i].src_x = graphic_info[graphic].src_x;
73     toons[i].src_y = graphic_info[graphic].src_y;
74
75     toons[i].width  = graphic_info[graphic].width;
76     toons[i].height = graphic_info[graphic].height;
77
78     toons[i].anim_frames      = graphic_info[graphic].anim_frames;
79     toons[i].anim_delay       = graphic_info[graphic].anim_delay;
80     toons[i].anim_mode        = graphic_info[graphic].anim_mode;
81     toons[i].anim_start_frame = graphic_info[graphic].anim_start_frame;
82
83     toons[i].step_offset = graphic_info[graphic].step_offset;
84     toons[i].step_delay  = graphic_info[graphic].step_delay;
85
86     toons[i].direction = image->parameter[GFX_ARG_DIRECTION];
87     toons[i].position = image->parameter[GFX_ARG_POSITION];
88   }
89
90 #if 1
91   InitToonScreen(bitmap_db_toons,
92 #else
93   InitToonScreen(bitmap_db_door,
94 #endif
95                  BackToFront, PrepareBackbuffer, ToonNeedsRedraw,
96                  toons, num_toons,
97                  REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
98                  GAME_FRAME_DELAY);
99 }