-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpause.c
121 lines (98 loc) · 2.61 KB
/
pause.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
#include <gb/gb.h>
#include "defines.h"
#include "gamestate.h"
#include "fade.h"
#include "sound.h"
#include "ram.h"
#include "mmlgb/driver/music.h"
#include "characters.h"
const UBYTE pause_text_on[] = { 10U, 25U, 24U };
const UBYTE pause_text_off[] = { 25U, 16U, 16U };
const UBYTE pause_marker_x1[] = { 49U, 17U, 57U };
const UBYTE pause_marker_x2[] = { 110U, 142U, 102U };
const UBYTE pause_marker_y[] = { 112U, 124U, 136U };
UBYTE pause_selection;
UBYTE pause_ticks;
void pauseUpdateDashCounter() {
if(show_dashcounter) {
set_bkg_tiles(14U, 14U, 3U, 1U, pause_text_on);
} else {
set_bkg_tiles(14U, 14U, 3U, 1U, pause_text_off);
}
}
void initPause() {
disable_interrupts();
DISPLAY_OFF;
set_bkg_data(0, 38U, characters_data);
setIngameBackground(255U);
setCloudAnimation(player_skin);
pauseUpdateDashCounter();
move_bkg(0U, 0U);
SHOW_BKG;
SHOW_SPRITES;
HIDE_WIN;
DISPLAY_ON;
enable_interrupts();
}
UBYTE enterPause() {
UBYTE i, j, frame;
clearRemainingSprites();
initPause();
pause_selection = 0U;
pause_ticks = 0U;
mus_setPaused(0U);
while(1U) {
pause_ticks++;
updateJoystate();
if(CLICKED(J_START)) {
return 0U;
}
if(CLICKED(J_UP)) {
if(pause_selection != 0) {
pause_selection--;
playSound(SFX_MENU_SWITCH);
}
}
if(CLICKED(J_DOWN)) {
if(pause_selection != 2U) {
pause_selection++;
playSound(SFX_MENU_SWITCH);
}
}
if(CLICKED(J_A) || (pause_selection == 1U && (CLICKED(J_LEFT) || CLICKED(J_RIGHT)))) {
playSound(SFX_MENU_CONFIRM);
if(pause_selection == 0U) {
wait_sound_done();
return 0U;
} else if(pause_selection == 1U) {
ENABLE_RAM_MBC1;
SWITCH_RAM_MBC1(0);
show_dashcounter = !show_dashcounter;
ram_data[RAM_DASHCOUNTER] = !ram_data[RAM_DASHCOUNTER];
DISABLE_RAM_MBC1;
disable_interrupts();
pauseUpdateDashCounter();
enable_interrupts();
} else if(pause_selection == 2U) {
wait_sound_done();
return 3U;
}
}
// Draw cloud animation
frame = pause_ticks & 48U;
for(j = 0U; j != 2U; ++j) {
for(i = 0U; i != 4U; ++i) {
setSprite(72U+(i << 3U), 48U+(j << 4U), frame, OBJ_PAL0);
frame += 2U;
}
}
// Draw selection markers
setSprite(pause_marker_x1[pause_selection], pause_marker_y[pause_selection], 100U, OBJ_PAL0);
setSprite(pause_marker_x1[pause_selection]+8U, pause_marker_y[pause_selection], 102U, OBJ_PAL0);
setSprite(pause_marker_x2[pause_selection], pause_marker_y[pause_selection], 104U, OBJ_PAL0);
setSprite(pause_marker_x2[pause_selection]+8U, pause_marker_y[pause_selection], 106U, OBJ_PAL0);
clearRemainingSprites();
snd_update();
wait_vbl_done();
}
}