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