-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialogue.c
133 lines (89 loc) · 2.09 KB
/
dialogue.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
124
125
126
127
128
129
130
131
132
133
#include <gb/gb.h>
#include <string.h>
#include "assets/alpha.c" // Sprite sheet with ASCII characters
#include "assets/frame.c"
#include "assets/arrow.c"
extern void clearBackground();
#include "narrative.c"
#include "credits.c"
// Constants
#define ASCII_START 0x20
#define CLEAR " "
// Macros
#define LEN(arr) sizeof(arr)/sizeof(arr[0])
#define PRINT(line, message) set_win_tiles(1, line, strlen(message), 1, message)
// Initialise the window layer for printing messages
void initWin() {
move_win(7, 112);
// Load ASCII tiles and box frame into window layer
set_win_data(0x10, 8, frame_tile_data);
set_win_data(ASCII_START, 64, alpha);
set_win_tiles(0, 0, 20, 4, frame_map_data);
}
void displayMessage(UINT16 openingLine, UINT16 numberOfLines) {
UINT8 i;
PRINT(1, CLEAR);
PRINT(2, CLEAR);
SHOW_WIN;
HIDE_SPRITES;
for (i = openingLine; i < openingLine + numberOfLines; i++) {
PRINT(2, lines[i]);
waitpad(J_A);
waitpadup();
PRINT(1, CLEAR);
PRINT(2, CLEAR);
PRINT(1, lines[i]);
}
SHOW_SPRITES;
HIDE_WIN;
}
UINT8 makeDecision(UINT16 openingLine, UINT16 dummy) {
UINT8 i;
UINT8 decision = 0;
dummy = dummy; // Avoid compiler warnings
BGP_REG = 0x1BU;
clearBackground();
SHOW_WIN;
PRINT(1, lines[openingLine]);
PRINT(2, lines[openingLine + 1]);
for (i = 0; i < 20; i++) {
move_sprite(i, -1, -1);
}
SHOW_SPRITES;
set_bkg_tiles(5, 8, 10, 1, "YES NO");
set_sprite_data(0x2F, 1, arrow);
set_sprite_tile(20, 0x2F);
move_sprite(20, 116, 88);
while (!(joypad() & J_A)) {
if (joypad() & J_LEFT) {
decision = 1;
move_sprite(20, 56, 88);
waitpadup();
}
if (joypad() & J_RIGHT) {
decision = 0;
move_sprite(20, 116, 88);
waitpadup();
}
}
waitpadup();
move_sprite(20, 0, 0);
HIDE_WIN;
HIDE_SPRITES;
BGP_REG = 0xE4U;
// Bring back the sprites and the background here
return decision;
}
void rollCreds() {
UINT8 i;
BGP_REG = 0x1BU;
SHOW_WIN;
for (i = 0; i < LEN(credits); i += 2) {
PRINT(1, CLEAR);
PRINT(2, CLEAR);
PRINT(1, credits[i]);
PRINT(2, credits[i + 1]);
delay(1500);
}
BGP_REG = 0xE4U;
}