updated contact info in source file headers
[rocksndiamonds.git] / src / cartoons.c
1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // cartoons.c
10 // ============================================================================
11
12 #include "cartoons.h"
13 #include "main.h"
14 #include "tools.h"
15
16
17 /* values for toon definition */
18 #define MAX_NUM_TOONS                   20
19
20 static struct ToonInfo toons[MAX_NUM_TOONS];
21
22 static void PrepareBackbuffer()
23 {
24   if (game_status != GAME_MODE_PLAYING)
25     return;
26
27 #if 1
28   BlitScreenToBitmap(backbuffer);
29 #else
30   if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
31   {
32     BlitScreenToBitmap_EM(backbuffer);
33   }
34   else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
35   {
36     BlitScreenToBitmap_SP(backbuffer);
37   }
38   else if (setup.soft_scrolling)        /* GAME_ENGINE_TYPE_RND */
39   {
40     int fx = FX, fy = FY;
41
42     fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
43     fy += (ScreenMovDir & (MV_UP|MV_DOWN)    ? ScreenGfxPos : 0);
44
45     BlitBitmap(fieldbuffer, backbuffer, fx, fy, SXSIZE, SYSIZE, SX, SY);
46   }
47 #endif
48 }
49
50 boolean ToonNeedsRedraw()
51 {
52   return TRUE;
53 }
54
55 void InitToons()
56 {
57   int num_toons = MAX_NUM_TOONS;
58   int i;
59
60   if (global.num_toons >= 0 && global.num_toons < MAX_NUM_TOONS)
61     num_toons = global.num_toons;
62
63   for (i = 0; i < num_toons; i++)
64   {
65     int graphic = IMG_TOON_1 + i;
66     struct FileInfo *image = getImageListEntryFromImageID(graphic);
67
68     toons[i].bitmap = graphic_info[graphic].bitmap;
69
70     toons[i].src_x = graphic_info[graphic].src_x;
71     toons[i].src_y = graphic_info[graphic].src_y;
72
73     toons[i].width  = graphic_info[graphic].width;
74     toons[i].height = graphic_info[graphic].height;
75
76     toons[i].anim_frames      = graphic_info[graphic].anim_frames;
77     toons[i].anim_delay       = graphic_info[graphic].anim_delay;
78     toons[i].anim_mode        = graphic_info[graphic].anim_mode;
79     toons[i].anim_start_frame = graphic_info[graphic].anim_start_frame;
80
81     toons[i].step_offset = graphic_info[graphic].step_offset;
82     toons[i].step_delay  = graphic_info[graphic].step_delay;
83
84     toons[i].direction = image->parameter[GFX_ARG_DIRECTION];
85     toons[i].position = image->parameter[GFX_ARG_POSITION];
86   }
87
88 #if 1
89   InitToonScreen(bitmap_db_toons,
90 #else
91   InitToonScreen(bitmap_db_door,
92 #endif
93                  BackToFront, PrepareBackbuffer, ToonNeedsRedraw,
94                  toons, num_toons,
95                  REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
96                  GAME_FRAME_DELAY);
97 }