Skip to content

Commit 8abc918

Browse files
committed
Adjust letterbox effects for wide screens
Fixes #195
1 parent 89a2e09 commit 8abc918

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

docs/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Version 1.8.1 (not released yet)
2121
- Fix crash reporter URL
2222
- Fix buffer-overflow when importing mesh with more than 8000 faces in the editor
2323
- Fix various issues when server switches to a new level before player finishes downloading the previous one
24+
- Adjust letterbox effects in cutscenes and after death for wide screens
2425

2526
Version 1.8.0 (released 2022-09-17)
2627
-----------------------------------

game_patch/misc/game.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "../rf/ui.h"
1212
#include "../rf/gameseq.h"
1313
#include "../rf/level.h"
14+
#include "../rf/cutscene.h"
1415
#include "../multi/multi.h"
1516

1617
static std::unique_ptr<byte* []> g_screenshot_scanlines_buf;
@@ -163,6 +164,26 @@ static FunHook<void(rf::GameState, bool)> rf_do_state_hook{
163164
},
164165
};
165166

167+
int letterbox_clip_height()
168+
{
169+
// return std::min(9 * rf::gr::screen_width() / 16, rf::gr::screen_height() * 91 / 100);
170+
return rf::gr::screen_height() * 3 / 4;
171+
}
172+
173+
CodeInjection gameplay_render_frame_cutscene_letterbox_injection{
174+
0x00431B30,
175+
[](auto& regs) {
176+
regs.esi = letterbox_clip_height();
177+
},
178+
};
179+
180+
CodeInjection gameplay_render_frame_death_letterbox_injection{
181+
0x00432A82,
182+
[](auto& regs) {
183+
regs.edi = letterbox_clip_height();
184+
},
185+
};
186+
166187
void game_apply_patch()
167188
{
168189
// Override screenshot filename and directory
@@ -181,6 +202,10 @@ void game_apply_patch()
181202
// States support
182203
rf_do_state_hook.install();
183204

205+
// Adjust letterbox effects for wide screens
206+
gameplay_render_frame_cutscene_letterbox_injection.install();
207+
gameplay_render_frame_death_letterbox_injection.install();
208+
184209
// Commands
185210
screenshot_cmd.register_cmd();
186211
}

game_patch/object/cutscene.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ FunHook<void(bool)> cutscene_do_frame_hook{
6464
xlog::info("Skipping cutscene...");
6565
disable_sound_before_cutscene_skip();
6666

67-
while (rf::cutscene_is_active()) {
67+
while (rf::cutscene_is_playing()) {
6868
int shot_time_left_ms = rf::active_cutscene->next_stage_timestamp.time_until();
6969

7070
if (rf::active_cutscene->current_script_index == rf::active_cutscene->num_cam_scripts - 1) {

game_patch/object/glare.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static bool glare_collide_object(rf::Glare* glare, rf::Object* obj, const rf::Ve
3535
}
3636

3737
rf::Vector3 hit_pt;
38-
if (rf::cutscene_is_active() && obj->type == rf::OT_ENTITY) {
38+
if (rf::cutscene_is_playing() && obj->type == rf::OT_ENTITY) {
3939
// Fix glares/coronas being visible through characters during cutscenes
4040
rf::Vector3 root_bone_pos;
4141
rf::obj_find_root_bone_pos(static_cast<rf::Entity*>(obj), root_bone_pos);

game_patch/rf/cutscene.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ namespace rf
4444

4545
static auto& active_cutscene = addr_as_ref<Cutscene*>(0x00645320);
4646

47-
static auto& cutscene_is_active = addr_as_ref<bool()>(0x0045BE80);
47+
static auto& cutscene_is_playing = addr_as_ref<bool()>(0x0045BE80);
4848
}

0 commit comments

Comments
 (0)