102 Dalmatians: Puppies to the Rescue
Decompilation Source Reference |
GitLab repository
Toggle main menu visibility
Loading...
Searching...
No Matches
rendering.c
Go to the documentation of this file.
1
/* Recovered game implementation; original addresses identify provenance. */
2
#include "
pcdogs/math/constants.h
"
3
#include "
pcdogs/game/constants.h
"
4
#include "
pcdogs/level/constants.h
"
5
#include "
pcdogs/ui/constants.h
"
6
#include "
pcdogs/menu/constants.h
"
7
#include "
pcdogs/graphics/constants.h
"
8
#include "
pcdogs/game/globals.h
"
9
#include "
pcdogs/graphics/globals.h
"
10
#include "
pcdogs/image/globals.h
"
11
#include "
pcdogs/input/globals.h
"
12
#include "
pcdogs/menu/functions.h
"
13
#include "
pcdogs/runtime/functions.h
"
14
#include "
pcdogs/text/functions.h
"
15
#include "
pcdogs/text/globals.h
"
16
#include "
pcdogs/ui/functions.h
"
17
#include <math.h>
18
#include <stdarg.h>
19
#include <string.h>
20
21
// Original pcdogs.exe: 0x4288d0
22
// Draws the enabled confirmation prompt near the bottom-right edge when frame flags allow it. Its modulo-twenty timer does not gate drawing, so this routine does not blink the prompt.
23
void
Menu_RenderConfirmPrompt
(int32_t right_edge_x)
24
{
25
if
(!
g_confirmTextEnabled
)
26
return
;
27
28
uint32_t frame_flags =
Game_FrameTransitionFlags
;
29
30
if
(frame_flags &
GAME_TRANSITION_GAME_OVER
)
31
return
;
32
33
bool
menu_active = (frame_flags &
GAME_TRANSITION_MENU_ACTIVE
) != 0;
34
char
next_prompt_frame;
35
36
if
(!menu_active)
37
{
38
next_prompt_frame =
g_confirmPromptFrameCounter
+ 1;
39
g_confirmPromptFrameCounter
= next_prompt_frame;
40
}
41
42
if
(menu_active || next_prompt_frame == 0x14)
43
g_confirmPromptFrameCounter
= 0;
44
45
int32_t resolved_right_edge_x = right_edge_x;
46
47
if
(resolved_right_edge_x < 0)
48
resolved_right_edge_x =
Graphics_WindowWidth
- 8;
49
50
if
(menu_active)
51
return
;
52
53
char
*prompt_scan =
g_inputButtonNameBuffers
[
INPUT_BUTTON_NAME_ACTION_3
];
54
int32_t scan_remaining =
UI_UNBOUNDED_SCAN_COUNT
;
55
char
*text = prompt_scan;
56
57
while
(scan_remaining)
58
{
59
bool
prompt_char_nonzero = 0 != *(uint8_t *)prompt_scan;
60
61
prompt_scan = &prompt_scan[1];
62
scan_remaining -= 1;
63
64
if
(!prompt_char_nonzero)
65
break
;
66
}
67
68
UI_RenderText
(
69
(uint32_t)(uint16_t)((uint16_t)resolved_right_edge_x - (int16_t)((~scan_remaining - 1) * 0x1e) - 8) | (
Graphics_WindowHeight
- 0x2e) <<
UI_PACKED_Y_SHIFT
,
70
text, (
SPRITE_RENDER_EXPLICIT_COLOR
|
GRAPHICS_COLOR_RGB_MASK
), NULL);
71
}
72
73
// Original pcdogs.exe: 0x42bc60
74
// Renders a centered title and a highlighted Yes/No selection. Selection zero means Yes and selection one means No.
75
void
Menu_RenderYesNoPrompt
(int32_t title_string_id, int32_t selected_index, uint32_t highlight_tint)
76
{
77
char
*text =
String_GetByIndex
(title_string_id);
78
int32_t title_window_height =
Graphics_WindowHeight
;
79
int32_t title_window_width =
Graphics_WindowWidth
;
80
81
UI_RenderText
(
82
((title_window_height / 2) - 0x80) <<
UI_PACKED_Y_SHIFT
| (uint32_t)(uint16_t)(title_window_width / 2), text,
83
UI_TEXT_ALIGN_CENTER
, NULL);
84
85
int32_t option_index = 0;
86
int16_t option_string_ids[2] = {3, 4};
87
int32_t option_y_offset = 0;
88
int16_t *option_string_cursor = option_string_ids;
89
90
do
91
{
92
int32_t option_tint;
93
94
if
(option_index != selected_index)
95
option_tint = 0;
96
else
97
{
98
uint32_t highlight_channel = (uint32_t)(uint8_t)highlight_tint;
99
100
option_tint = ((highlight_channel |
UI_TEXT_PACKED_COLOR_PREFIX
) << 8 | highlight_channel) << 8 | (highlight_tint &
GRAPHICS_COLOR_RGB_MASK
);
101
}
102
103
char
*option_text =
String_GetByIndex
((int32_t)*option_string_cursor);
104
int32_t option_window_height =
Graphics_WindowHeight
;
105
int32_t option_window_width =
Graphics_WindowWidth
;
106
107
UI_RenderText
(
108
((option_window_height / 2) + option_y_offset - 0x20) <<
UI_PACKED_Y_SHIFT
| (uint32_t)(uint16_t)(option_window_width / 2),
109
option_text, option_tint |
UI_TEXT_ALIGN_CENTER
, NULL);
110
option_y_offset += 0x20;
111
option_index += 1;
112
option_string_cursor += 1;
113
}
while
(option_y_offset < 0x40);
114
}
115
116
// Original pcdogs.exe: 0x42c6d0
117
// Measures and renders a localized control label and button name as one centered prompt row.
118
void
Menu_RenderFormattedText
(uint32_t packed_xy, int32_t label_string_id, int32_t button_prompt_id)
119
{
120
char
*label_text =
String_GetByIndex
(label_string_id);
121
int32_t label_text_width =
UI_ComputeStringWidth
(label_text);
122
char
button_name_buffer[0x100];
123
124
if
(button_prompt_id == 5)
125
String_FormatCRTString
(button_name_buffer,
"%s"
,
g_inputButtonNameBuffers
[
INPUT_BUTTON_NAME_ACTION_3
]);
126
else
if
(button_prompt_id == 6)
127
String_FormatCRTString
(button_name_buffer,
"%s"
,
String_GetByIndex
(0xf4));
128
else
if
(button_prompt_id != 7)
129
String_FormatCRTString
(button_name_buffer,
"%s"
,
String_GetByIndex
(0xf5));
130
else
131
String_FormatCRTString
(button_name_buffer,
"%s"
,
132
g_inputButtonNameBuffers
[button_prompt_id]);
133
134
char
*button_text_scan = button_name_buffer;
135
int32_t scan_remaining =
UI_UNBOUNDED_SCAN_COUNT
;
136
137
while
(scan_remaining)
138
{
139
bool
button_char_nonzero = 0 != *(uint8_t *)button_text_scan;
140
141
button_text_scan += 1;
142
scan_remaining -= 1;
143
144
if
(!button_char_nonzero)
145
break
;
146
}
147
148
int32_t button_text_pixel_width = ~scan_remaining * 0x14;
149
int32_t centered_packed_xy = packed_xy - ((button_text_pixel_width + label_text_width) >> 1);
150
151
UI_RenderText
(centered_packed_xy, button_name_buffer, (
SPRITE_RENDER_EXPLICIT_COLOR
|
GRAPHICS_COLOR_RGB_MASK
), NULL);
152
UI_RenderText
(button_text_pixel_width + centered_packed_xy + 0x20000, label_text, 0, NULL);
153
}
constants.h
GAME_TRANSITION_GAME_OVER
#define GAME_TRANSITION_GAME_OVER
Definition
constants.h:28
GAME_TRANSITION_MENU_ACTIVE
#define GAME_TRANSITION_MENU_ACTIVE
Definition
constants.h:7
globals.h
Game_FrameTransitionFlags
#define Game_FrameTransitionFlags
Definition
globals.h:47
constants.h
SPRITE_RENDER_EXPLICIT_COLOR
#define SPRITE_RENDER_EXPLICIT_COLOR
Definition
constants.h:33
GRAPHICS_COLOR_RGB_MASK
#define GRAPHICS_COLOR_RGB_MASK
Definition
constants.h:38
globals.h
Graphics_WindowWidth
#define Graphics_WindowWidth
Definition
globals.h:140
Graphics_WindowHeight
#define Graphics_WindowHeight
Definition
globals.h:143
globals.h
INPUT_BUTTON_NAME_ACTION_3
@ INPUT_BUTTON_NAME_ACTION_3
Definition
constants.h:123
globals.h
g_inputButtonNameBuffers
#define g_inputButtonNameBuffers
Definition
globals.h:75
constants.h
constants.h
constants.h
functions.h
Menu_RenderConfirmPrompt
void Menu_RenderConfirmPrompt(int32_t right_edge_x)
Definition
rendering.c:23
Menu_RenderYesNoPrompt
void Menu_RenderYesNoPrompt(int32_t title_string_id, int32_t selected_index, uint32_t highlight_tint)
Definition
rendering.c:75
Menu_RenderFormattedText
void Menu_RenderFormattedText(uint32_t packed_xy, int32_t label_string_id, int32_t button_prompt_id)
Definition
rendering.c:118
functions.h
String_FormatCRTString
int32_t String_FormatCRTString(char *buffer, char const *format,...)
Definition
formatting.c:18
functions.h
String_GetByIndex
char * String_GetByIndex(int32_t string_id)
Definition
strings.c:66
globals.h
constants.h
UI_TEXT_PACKED_COLOR_PREFIX
#define UI_TEXT_PACKED_COLOR_PREFIX
Definition
constants.h:14
UI_TEXT_ALIGN_CENTER
#define UI_TEXT_ALIGN_CENTER
Definition
constants.h:6
UI_PACKED_Y_SHIFT
#define UI_PACKED_Y_SHIFT
Definition
constants.h:93
UI_UNBOUNDED_SCAN_COUNT
#define UI_UNBOUNDED_SCAN_COUNT
Definition
constants.h:97
functions.h
UI_RenderText
void UI_RenderText(uint32_t packed_xy, char const *text, uint32_t text_flags, void *font_context)
Definition
text.c:226
UI_ComputeStringWidth
int32_t UI_ComputeStringWidth(char const *text)
Definition
text.c:152
g_confirmPromptFrameCounter
#define g_confirmPromptFrameCounter
Definition
values.h:390
g_confirmTextEnabled
#define g_confirmTextEnabled
Definition
values.h:825
src
menu
rendering.c
Generated by
1.17.0