-
Notifications
You must be signed in to change notification settings - Fork 9
/
unlocked.c
123 lines (100 loc) · 3.15 KB
/
unlocked.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <gb/gb.h>
#include "defines.h"
#include "unlocked.h"
#include "fade.h"
#include "gamestate.h"
#include "characters.h"
#include "zoom_circles.h"
#include "data/bg/unlocked.h"
#include "selection2.h"
#include "selection3.h"
#include "selection4.h"
#include "selection_jukebox.h"
extern UBYTE unlocked_song_data;
const UBYTE unlocked_messages[3][24] = {
{
10U, 24U, 15U, 34U, 30U, 10U, 22U, 15U, 32U, 15U, 22U, 10U, // " NEXT LEVEL "
10U, 10U, 31U, 24U, 22U, 25U, 13U, 21U, 15U, 14U, 10U, 10U // " UNLOCKED "
},
{
23U, 31U, 29U, 19U, 13U, 10U, 26U, 22U, 11U, 35U, 15U, 28U, // "MUSIC PLAYER"
10U, 10U, 31U, 24U, 22U, 25U, 13U, 21U, 15U, 14U, 10U, 10U // " UNLOCKED "
},
{
10U, 10U, 10U, 14U, 28U, 15U, 11U, 23U, 10U, 10U, 10U, 10U, // " DREAM "
10U, 10U, 31U, 24U, 22U, 25U, 13U, 21U, 15U, 14U, 10U, 10U // " UNLOCKED "
}
};
void initUnlocked() {
disable_interrupts();
DISPLAY_OFF;
move_bkg(0U, 0U);
set_bkg_data(0U, 38U, characters_data);
set_bkg_data(38U, zoom_circles_data_length, zoom_circles_data);
set_bkg_data(unlocked_tiles_offset, unlocked_data_length, unlocked_data);
set_bkg_data(47U, 8U, zoom_circles_data);
set_bkg_tiles(0U, 0U, unlocked_tiles_width, unlocked_tiles_height, unlocked_tiles);
if(unlocked_bits & UNLOCKED_CLOUDS) {
unlocked_bits ^= UNLOCKED_CLOUDS;
set_bkg_data(selection2_tiles_offset, selection2_data_length, selection2_data);
set_bkg_tiles(0U, 8U, 20U, 6U, selection2_tiles);
set_bkg_tiles(4U, 5U, 12U, 2U, unlocked_messages[0]);
}
else if(unlocked_bits & UNLOCKED_SPACE) {
unlocked_bits ^= UNLOCKED_SPACE;
set_bkg_data(selection3_tiles_offset, selection3_data_length, selection3_data);
set_bkg_tiles(0U, 8U, 20U, 6U, selection3_tiles);
set_bkg_tiles(4U, 5U, 12U, 2U, unlocked_messages[0]);
}
else if(unlocked_bits & UNLOCKED_MUSIC) {
unlocked_bits ^= UNLOCKED_MUSIC;
set_bkg_data(selection_jukebox_tiles_offset, selection_jukebox_data_length, selection_jukebox_data);
set_bkg_tiles(0U, 8U, 20U, 6U, selection_jukebox_tiles);
set_bkg_tiles(4U, 5U, 12U, 2U, unlocked_messages[1]);
}
else if(unlocked_bits & UNLOCKED_DREAM) {
unlocked_bits ^= UNLOCKED_DREAM;
set_bkg_data(selection4_tiles_offset, selection4_data_length, selection4_data);
set_bkg_tiles(0U, 8U, 20U, 6U, selection4_tiles);
set_bkg_tiles(4U, 5U, 12U, 2U, unlocked_messages[2]);
}
BGP_REG = 0xE4U; // 11100100
circle_index = 0U;
clearSprites();
SHOW_SPRITES;
HIDE_WIN;
SHOW_BKG;
DISPLAY_ON;
enable_interrupts();
}
void enterUnlocked() {
initUnlocked();
fadeFromWhite(6U);
setMusicBank(9U);
disable_interrupts();
playMusic(&unlocked_song_data);
enable_interrupts();
ticks = 0U;
while(1U) {
updateJoystate();
ticks++;
if((ticks & 3U) == 3U) {
circle_index = (circle_index+1U) & 7U;
set_bkg_data(47U+circle_index, 8U-circle_index, zoom_circles_data);
if(circle_index) {
set_bkg_data(47U, circle_index, &zoom_circles_data[(8U-circle_index) << 4]);
}
}
if(CLICKED(J_START) || CLICKED(J_A)) {
if(unlocked_bits == 0U) {
gamestate = GAMESTATE_HIGHSCORE;
}
break;
}
clearRemainingSprites();
wait_vbl_done();
}
clearRemainingSprites();
fadeToWhite(6U);
stopMusic();
}