added initialization of textures for classic toon animations
[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 static struct ToonInfo toons[MAX_NUM_TOONS];
18
19 static void PrepareBackbuffer()
20 {
21   if (game_status != GAME_MODE_PLAYING)
22     return;
23
24   BlitScreenToBitmap(backbuffer);
25 }
26
27 boolean ToonNeedsRedraw()
28 {
29   return TRUE;
30 }
31
32 void InitToons()
33 {
34   int num_toons = MAX_NUM_TOONS;
35   int i;
36
37   if (global.num_toons >= 0 && global.num_toons < MAX_NUM_TOONS)
38     num_toons = global.num_toons;
39
40   for (i = 0; i < num_toons; i++)
41   {
42     int graphic = IMG_TOON_1 + i;
43     struct FileInfo *image = getImageListEntryFromImageID(graphic);
44
45     toons[i].bitmap = graphic_info[graphic].bitmap;
46
47     toons[i].src_x = graphic_info[graphic].src_x;
48     toons[i].src_y = graphic_info[graphic].src_y;
49
50     toons[i].width  = graphic_info[graphic].width;
51     toons[i].height = graphic_info[graphic].height;
52
53     toons[i].anim_frames      = graphic_info[graphic].anim_frames;
54     toons[i].anim_delay       = graphic_info[graphic].anim_delay;
55     toons[i].anim_mode        = graphic_info[graphic].anim_mode;
56     toons[i].anim_start_frame = graphic_info[graphic].anim_start_frame;
57
58     toons[i].step_offset = graphic_info[graphic].step_offset;
59     toons[i].step_delay  = graphic_info[graphic].step_delay;
60
61     toons[i].direction = image->parameter[GFX_ARG_DIRECTION];
62     toons[i].position = image->parameter[GFX_ARG_POSITION];
63   }
64
65   InitToonScreen(bitmap_db_toons,
66                  BackToFront, PrepareBackbuffer, ToonNeedsRedraw,
67                  toons, num_toons,
68                  REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
69                  GAME_FRAME_DELAY);
70 }
71
72 void DrawGlobalAnim()
73 {
74 }
75
76 void InitAnimation()
77 {
78   HandleAnimation(ANIM_START);
79 }
80
81 void StopAnimation()
82 {
83   HandleAnimation(ANIM_STOP);
84 }
85
86 void DoAnimation()
87 {
88   HandleAnimation(ANIM_CONTINUE);
89 }