-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow_text.c
103 lines (85 loc) · 2.35 KB
/
window_text.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
/*
* StickGBC by Matt Comben is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
* To view a copy of this license, visit
* http://creativecommons.org/licenses/by-nc-nd/4.0/.
*/
#pragma bank=8
#include "window_text.h"
/*
* show_window_character
*
* Show individual character on-screen at a given
* location
*/
void show_window_character(UINT8 character_number, UINT8 itx, UINT8 ity)
{
UBYTE tile_data;
// Load tile into high tile set
VBK_REG = 1;
set_bkg_data(character_number, 1, &(windowtexttiles[(UINT16)character_number << 4]));
VBK_REG = 0;
// Set screen tile to loaded tile
set_bkg_tiles(itx, ity, 1, 1, &(character_number));
VBK_REG = 1;
// Mark as using palette 1 and high bank of tiles
tile_data = 0x9;
set_bkg_tiles(itx, ity, 1, 1, &(tile_data));
VBK_REG = 0;
}
/*
* show_window_text
*
* Show array of text onscreen and wait
* for user to confirm
*/
void show_window_text(UINT8 *text)
{
show_window_text_xy(0, 0, text);
// Wait for original key press to be let go of
delay(300);
// Reset original key pressed
joypad_state.a_pressed = 0;
joypad_state.b_pressed = 0;
// Wait for user to press A or B
while (joypad_state.a_pressed == 0U && joypad_state.b_pressed == 0U)
{
wait_vbl_done();
main_check_joy(ROM_BANK_WINDOW_TEXT);
}
}
/*
* show_window_text_xy
*
* Show array of text onscreen at given co-ordinates
*/
void show_window_text_xy(UINT8 itx_x, UINT8 itx_y, UINT8 *text)
{
UINT8 text_index = 0;
UINT16 character_number;
while (1)
{
character_number = text[text_index];
// Check if reached end of text
if (character_number == WINDOW_TEXT_END)
{
break;
}
if (character_number != WINDOW_TEXT_SKIP)
show_window_character(character_number, itx_x, itx_y);
if (itx_x == (SCREEN_WIDTH_TILES - 1U))
{
itx_y += 1U;
itx_x = 0U;
}
else
itx_x += 1U;
text_index += 1U;
}
// File up remainder of row with blank tiles
while (itx_x != (SCREEN_WIDTH_TILES - 1U))
{
// Set screen tile to empty tile
show_window_character(0U, itx_x, itx_y);
itx_x += 1U;
}
}