|
@@ -1,4 +1,49 @@
|
1
|
|
-#include "cutscene_meteor.h"
|
|
1
|
+/****************************************************************************
|
|
2
|
+ * Copyright (C) 2015-2016 by the SotS Team *
|
|
3
|
+ * *
|
|
4
|
+ * This file is part of Sovereign of the Skies. *
|
|
5
|
+ * *
|
|
6
|
+ * Sovereign of the Skies is free software: you can redistribute it *
|
|
7
|
+ * and/or modify it *
|
|
8
|
+ * under the terms of the GNU Lesser General Public License as published *
|
|
9
|
+ * by the Free Software Foundation, either version 3 of the License, or *
|
|
10
|
+ * (at your option) any later version provided you include a copy of the *
|
|
11
|
+ * licence and this header. *
|
|
12
|
+ * *
|
|
13
|
+ * Sovereign of the Skies is distributed in the hope that it will be *
|
|
14
|
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
15
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
16
|
+ * GNU Lesser General Public License for more details. *
|
|
17
|
+ * *
|
|
18
|
+ * You should have received a copy of the GNU Lesser General Public *
|
|
19
|
+ * License along with Sovereign of the Skies. *
|
|
20
|
+ * If not, see <http://www.gnu.org/licenses/>. *
|
|
21
|
+ ****************************************************************************/
|
|
22
|
+
|
|
23
|
+/**
|
|
24
|
+ * @file cutscene_meteor.c
|
|
25
|
+ * @author Sturmvogel
|
|
26
|
+ * @date 15 dec 2016
|
|
27
|
+ * @brief Cutscene to play "crashing meteor"
|
|
28
|
+ *
|
|
29
|
+ * This source is able to play a cutscene, a meteor crashing on earth.
|
|
30
|
+ */
|
|
31
|
+
|
|
32
|
+/* === INCLUDES === */
|
|
33
|
+
|
|
34
|
+#include "../assets/meteor/met_background.h"
|
|
35
|
+#include "../assets/meteor/met_foreground.h"
|
|
36
|
+#include "../assets/meteor/met_sky.h"
|
|
37
|
+#include "../assets/meteor/met_meteor.h"
|
|
38
|
+#include "../assets/meteor/met_clouds.h"
|
|
39
|
+
|
|
40
|
+#include <callback.h>
|
|
41
|
+#include <lcd.h>
|
|
42
|
+#include <fade.h>
|
|
43
|
+#include <sound.h>
|
|
44
|
+#include <memory.h>
|
|
45
|
+
|
|
46
|
+/* === MACROS & DEFINES === */
|
2
|
47
|
|
3
|
48
|
#define CLOUD_THROTTLE 4
|
4
|
49
|
#define PALETTE_BG 0
|
|
@@ -8,6 +53,8 @@
|
8
|
53
|
|
9
|
54
|
#define TAG_METEOR 0x2000
|
10
|
55
|
|
|
56
|
+/* === STRUCTURES === */
|
|
57
|
+
|
11
|
58
|
struct meteor_memory{
|
12
|
59
|
void* bg_gfx;
|
13
|
60
|
void* bg_map;
|
|
@@ -27,10 +74,53 @@ struct meteor_memory{
|
27
|
74
|
u16 delay_end;
|
28
|
75
|
};
|
29
|
76
|
|
|
77
|
+/* === PROTOTYPES === */
|
|
78
|
+
|
|
79
|
+/**
|
|
80
|
+ * @brief readies VRAM for our graphic setup
|
|
81
|
+ */
|
|
82
|
+void met_setup_vram();
|
|
83
|
+
|
|
84
|
+/**
|
|
85
|
+ * @brief callback for doing the actual animation
|
|
86
|
+ */
|
|
87
|
+void met_cutscene_cb();
|
|
88
|
+
|
|
89
|
+/**
|
|
90
|
+ * @brief callback to update the screen elements
|
|
91
|
+ */
|
|
92
|
+void met_update_screen();
|
|
93
|
+
|
|
94
|
+/**
|
|
95
|
+ * @brief callback for the meteor object entity
|
|
96
|
+ * @param self pointer to the meteor object entity
|
|
97
|
+ */
|
|
98
|
+void met_entity_cb(struct obj_entity* self);
|
|
99
|
+
|
|
100
|
+/**
|
|
101
|
+ * @brief finish the animation and free memory
|
|
102
|
+ */
|
|
103
|
+void met_free_end();
|
|
104
|
+
|
|
105
|
+/**
|
|
106
|
+ * @brief disable overworld scrolling in scrolling controller
|
|
107
|
+ */
|
|
108
|
+void met_setup_scrolling();
|
|
109
|
+
|
|
110
|
+/**
|
|
111
|
+ * @brief setup palettes for cutscene environment
|
|
112
|
+ */
|
|
113
|
+void met_setup_palettes();
|
|
114
|
+
|
|
115
|
+/* === STATIC ELEMENTS === */
|
|
116
|
+
|
|
117
|
+/*static memory block pointer for used structure*/
|
30
|
118
|
static struct meteor_memory* memory = (struct meteor_memory*)(0x0203FFC0);
|
31
|
119
|
|
|
120
|
+/*oam attributes for the meteor object entity*/
|
32
|
121
|
static struct obj_oam_attributes sprite_meteor = {0, 0x8000, 0x800, 0x0};
|
33
|
122
|
|
|
123
|
+/*frame list for the meteor object entity*/
|
34
|
124
|
static struct obj_frame meteor_frames [4] = {
|
35
|
125
|
{0, 10},
|
36
|
126
|
{16, 10},
|
|
@@ -38,10 +128,12 @@ static struct obj_frame meteor_frames [4] = {
|
38
|
128
|
{0xFFFE, 0}
|
39
|
129
|
};
|
40
|
130
|
|
|
131
|
+/*pointer to the frame list*/
|
41
|
132
|
static struct obj_frame* meteor_frames_a [1] = {
|
42
|
133
|
meteor_frames
|
43
|
134
|
};
|
44
|
135
|
|
|
136
|
+/*template for the meteor object entity*/
|
45
|
137
|
static struct obj_template template_meteor = {
|
46
|
138
|
TAG_METEOR,
|
47
|
139
|
TAG_METEOR,
|
|
@@ -49,34 +141,34 @@ static struct obj_template template_meteor = {
|
49
|
141
|
meteor_frames_a,
|
50
|
142
|
0,
|
51
|
143
|
(struct obj_rotscale_frame **) 0x08231CFC,
|
52
|
|
- meteor_callback
|
|
144
|
+ met_entity_cb
|
53
|
145
|
};
|
54
|
146
|
|
55
|
|
-void meteor_callback(struct obj_entity* self)
|
|
147
|
+void met_entity_cb(struct obj_entity* self)
|
56
|
148
|
{
|
57
|
|
- if(memory->meteor_moving > 0)
|
58
|
|
- {
|
59
|
|
- self->x--;
|
60
|
|
- self->y++;
|
61
|
|
- if(self->y > 130)
|
62
|
|
- {
|
63
|
|
- memory->meteor_moving = 0;
|
64
|
|
- m4aSongNumStart(0xAB);
|
65
|
|
- }
|
66
|
|
-
|
67
|
|
- }
|
|
149
|
+ if(memory->meteor_moving > 0)
|
|
150
|
+ {
|
|
151
|
+ self->x--;
|
|
152
|
+ self->y++;
|
|
153
|
+ if(self->y > 130)
|
|
154
|
+ {
|
|
155
|
+ memory->meteor_moving = 0;
|
|
156
|
+ m4aSongNumStart(0xAB);
|
|
157
|
+ }
|
|
158
|
+ }
|
68
|
159
|
}
|
69
|
160
|
|
70
|
|
-void play_meteor()
|
|
161
|
+void met_play()
|
71
|
162
|
{
|
|
163
|
+
|
72
|
164
|
memory->animate_clouds = 0;
|
73
|
165
|
memory->cloud_animation_state = 0;
|
74
|
166
|
memory-> meteor_moving = 0;
|
75
|
167
|
superstate.multi_purpose_state_tracker = 0;
|
76
|
|
- vblank_handler_set(update_screen);
|
77
|
|
- set_callback2(cutscene);
|
|
168
|
+ vblank_handler_set(met_update_screen);
|
|
169
|
+ set_callback2(met_cutscene_cb);
|
78
|
170
|
}
|
79
|
|
-void cutscene()
|
|
171
|
+void met_cutscene_cb()
|
80
|
172
|
{
|
81
|
173
|
if(superstate.multi_purpose_state_tracker == 0)
|
82
|
174
|
{
|
|
@@ -87,7 +179,7 @@ void cutscene()
|
87
|
179
|
{
|
88
|
180
|
if((fade_controller.mix_color & 0x8000) == 0)
|
89
|
181
|
{
|
90
|
|
- setup_vram();
|
|
182
|
+ met_setup_vram();
|
91
|
183
|
fade_screen(0xFFFFFFFF,0,0x10,0,0x0000);
|
92
|
184
|
memory->delay = 60*3;
|
93
|
185
|
memory->delay_end = 90;
|
|
@@ -132,7 +224,7 @@ void cutscene()
|
132
|
224
|
else if(superstate.multi_purpose_state_tracker == 6)
|
133
|
225
|
{
|
134
|
226
|
if(memory->delay_end == 0)
|
135
|
|
- end_playback();
|
|
227
|
+ met_free_end();
|
136
|
228
|
else
|
137
|
229
|
memory->delay_end--;
|
138
|
230
|
}
|
|
@@ -141,7 +233,7 @@ void cutscene()
|
141
|
233
|
memory->cloud_animation_state=0;
|
142
|
234
|
}
|
143
|
235
|
|
144
|
|
-void end_playback()
|
|
236
|
+void met_free_end()
|
145
|
237
|
{
|
146
|
238
|
set_callback2(callback_overworld);
|
147
|
239
|
free(memory->bg_gfx);
|
|
@@ -157,7 +249,7 @@ void end_playback()
|
157
|
249
|
free(memory->cloud_map);
|
158
|
250
|
}
|
159
|
251
|
|
160
|
|
-void setup_scrolling()
|
|
252
|
+void met_setup_scrolling()
|
161
|
253
|
{
|
162
|
254
|
lcd_io_set_func(0x14, 0x0);
|
163
|
255
|
lcd_io_set_func(0x16, 0x0);
|
|
@@ -167,7 +259,7 @@ void setup_scrolling()
|
167
|
259
|
lcd_io_set_func(0x1E, 0x0);
|
168
|
260
|
}
|
169
|
261
|
|
170
|
|
-void setup_palettes()
|
|
262
|
+void met_setup_palettes()
|
171
|
263
|
{
|
172
|
264
|
wram_decompress((void*)met_skyPal, palette_unfaded_buffer + PALETTE_SKY*32);
|
173
|
265
|
wram_decompress((void*)met_cloudsPal, palette_unfaded_buffer + PALETTE_CLOUD*32);
|
|
@@ -175,7 +267,7 @@ void setup_palettes()
|
175
|
267
|
wram_decompress((void*)met_backgroundPal, palette_unfaded_buffer + PALETTE_BG*32);
|
176
|
268
|
}
|
177
|
269
|
|
178
|
|
-void setup_vram()
|
|
270
|
+void met_setup_vram()
|
179
|
271
|
{
|
180
|
272
|
gpu_tile_bg_drop_all_sets(0);
|
181
|
273
|
gpu_tile_bg_drop_all_sets(1);
|
|
@@ -190,8 +282,7 @@ void setup_vram()
|
190
|
282
|
gpu_bg_show(3);
|
191
|
283
|
|
192
|
284
|
gpu_sync_bg_visibility_and_mode();
|
193
|
|
-
|
194
|
|
- setup_scrolling();
|
|
285
|
+ met_setup_scrolling();
|
195
|
286
|
|
196
|
287
|
//copy tilesets
|
197
|
288
|
memory->bg_gfx = malloc(0x40);
|
|
@@ -210,9 +301,7 @@ void setup_vram()
|
210
|
301
|
wram_decompress((void*)met_skyTiles, memory->sky_gfx);
|
211
|
302
|
gpu_copy_to_vram_by_bgid(3, memory->sky_gfx,0x7A0,0,1);
|
212
|
303
|
|
213
|
|
-
|
214
|
|
-
|
215
|
|
-
|
|
304
|
+
|
216
|
305
|
//copy tilemaps
|
217
|
306
|
memory->bg_map = malloc(0x500);
|
218
|
307
|
wram_decompress((void*)met_backgroundMap, memory->bg_map);
|
|
@@ -230,12 +319,7 @@ void setup_vram()
|
230
|
319
|
wram_decompress((void*)met_skyMap, memory->sky_map);
|
231
|
320
|
gpu_copy_to_vram_by_bgid(3, memory->sky_map,0x500,0,2);
|
232
|
321
|
|
233
|
|
-
|
234
|
|
- //copy palettes
|
235
|
|
- //pal_decompress_slice_to_faded_and_unfaded((void*)met_skyPal, 16, 32);
|
236
|
|
- //pal_decompress_slice_to_faded_and_unfaded((void*)met_foregroundPal, 48, 32);
|
237
|
|
- //pal_decompress_slice_to_faded_and_unfaded((void*)met_cloudsPal, 32, 32);
|
238
|
|
- setup_palettes();
|
|
322
|
+ met_setup_palettes();
|
239
|
323
|
|
240
|
324
|
//setup oam
|
241
|
325
|
obj_delete_all();
|
|
@@ -251,7 +335,7 @@ void setup_vram()
|
251
|
335
|
memory->animate_clouds = 1;
|
252
|
336
|
}
|
253
|
337
|
|
254
|
|
-void update_screen()
|
|
338
|
+void met_update_screen()
|
255
|
339
|
{
|
256
|
340
|
fade_update();
|
257
|
341
|
task_exec();
|