rnd-20030426-2-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   return (game_status == GAME_MODE_INFO ||
55           (game_status == GAME_MODE_MAIN &&
56            ((redraw_mask & REDRAW_MICROLEVEL) ||
57             (redraw_mask & REDRAW_MICROLABEL))));
58 }
59
60 void InitToons()
61 {
62   int num_toons = MAX_NUM_TOONS;
63   int i;
64
65   if (global.num_toons > 0 && global.num_toons < MAX_NUM_TOONS)
66     num_toons = global.num_toons;
67
68   for (i=0; i < num_toons; i++)
69   {
70     int graphic = IMG_TOON_1 + i;
71     struct FileInfo *image = getImageListEntry(graphic);
72
73     toons[i].bitmap = graphic_info[graphic].bitmap;
74
75     toons[i].src_x = graphic_info[graphic].src_x;
76     toons[i].src_y = graphic_info[graphic].src_y;
77
78     toons[i].width  = graphic_info[graphic].width;
79     toons[i].height = graphic_info[graphic].height;
80
81     toons[i].anim_frames      = graphic_info[graphic].anim_frames;
82     toons[i].anim_delay       = graphic_info[graphic].anim_delay;
83     toons[i].anim_mode        = graphic_info[graphic].anim_mode;
84     toons[i].anim_start_frame = graphic_info[graphic].anim_start_frame;
85
86     toons[i].step_offset = graphic_info[graphic].step_offset;
87     toons[i].step_delay  = graphic_info[graphic].step_delay;
88
89     toons[i].direction = image->parameter[GFX_ARG_DIRECTION];
90     toons[i].position = image->parameter[GFX_ARG_POSITION];
91   }
92
93   InitToonScreen(bitmap_db_door,
94                  BackToFront, PrepareBackbuffer, ToonNeedsRedraw,
95                  toons, num_toons,
96                  REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
97                  GAME_FRAME_DELAY);
98 }