Skip to content

Commit

Permalink
more drawing wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Jul 18, 2024
1 parent 358b5db commit f7950b6
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 10 deletions.
25 changes: 22 additions & 3 deletions max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,11 +657,30 @@ void *Max::load_asset(uint32_t id, uint8_t b) {
return ret;
}

void Max::draw_text(int x, int y, const wchar_t *text) {
using DrawTextFunc = void(int x, int y, const wchar_t *text);
static DrawTextFunc *draw = (DrawTextFunc *)get_address("draw_text");
using DrawTextFunc = void(int x, int y, const wchar_t *text);
using PushColorFunc = void(uint32_t color);
using PopColorFunc = void();
void Max::draw_text_big(int x, int y, const wchar_t *text) {
static DrawTextFunc *draw = (DrawTextFunc *)get_address("draw_text_big");
draw(x, y, text);
}
void Max::draw_text_small(int x, int y, const wchar_t *text, uint32_t color,
uint32_t shader) {
static DrawTextFunc *draw = (DrawTextFunc *)get_address("draw_text_small");
static PushColorFunc *push_color =
(PushColorFunc *)get_address("draw_push_color");
static PopColorFunc *pop_color =
(PopColorFunc *)get_address("draw_pop_color");
static PushColorFunc *push_shader =
(PushColorFunc *)get_address("draw_push_shader");
static PopColorFunc *pop_shader =
(PopColorFunc *)get_address("draw_pop_shader");
push_color(color);
push_shader(shader);
draw(x, y, text);
pop_shader();
pop_color();
}

std::array<uv_data, 1024> *Max::tile_uvs() {
return (std::array<uv_data, 1024> *)((size_t)get_asset(254)->data + 0xc);
Expand Down
4 changes: 3 additions & 1 deletion max.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ struct Max {
std::array<uv_data, 1024> *tile_uvs();
void decrypt_stuff();

void draw_text(int x, int y, const wchar_t *text);
void draw_text_big(int x, int y, const wchar_t *text);
void draw_text_small(int x, int y, const wchar_t *text,
uint32_t color = 0xffffffff, uint32_t shader = 0x29);

bool skip{false};
std::optional<bool> paused{std::nullopt};
Expand Down
32 changes: 30 additions & 2 deletions search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,13 +660,37 @@ std::unordered_map<std::string_view, AddressRule> g_address_rules{
.function_start(),
},
{
"draw_text"sv,
PatternCommandBuffer{} //.from_exe_base(0x71010),
"draw_text_big"sv,
PatternCommandBuffer{}
.set_optional(true)
.find_inst("48 83 ec 58 4d 85 c0"_gh)
.at_exe()
.function_start(),
},
{
"draw_text_small"sv,
PatternCommandBuffer{}
.set_optional(true)
.find_inst("48 83 ec 58 89 4c 24 54"_gh)
.at_exe()
.function_start(),
},
{
"draw_push_color"sv,
PatternCommandBuffer{}.from_exe_base(0x177d0),
},
{
"draw_pop_color"sv,
PatternCommandBuffer{}.from_exe_base(0x17830),
},
{
"draw_push_shader"sv,
PatternCommandBuffer{}.from_exe_base(0x17840),
},
{
"draw_pop_shader"sv,
PatternCommandBuffer{}.from_exe_base(0x178a0),
},
{
"render_player"sv,
PatternCommandBuffer{} //.from_exe_base(0x463c0),
Expand All @@ -675,6 +699,10 @@ std::unordered_map<std::string_view, AddressRule> g_address_rules{
.at_exe()
.function_start(),
},
{
"render_clouds"sv,
PatternCommandBuffer{}.from_exe_base(0x103264),
},
{
"get_room_params"sv,
PatternCommandBuffer{} //.from_exe_base(0x2d70),
Expand Down
17 changes: 13 additions & 4 deletions ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,9 @@ void UI::Play() {
else if (Max::get().inputs.size() > 0 && sequencer.b.has_value())
Max::get().mural_selection()[1] = sequencer.b.value();
if (!Max::get().pause()->paused)
Max::get().render_queue.push_back(
[&]() { Max::get().draw_text(57, 12, L"bunny sequencer 0.2"); });
Max::get().render_queue.push_back([&]() {
Max::get().draw_text_small(57, 17, L"bunny sequencer 0.2");
});
}
if (!sequencer.enabled)
recover_mem("mural_cursor");
Expand Down Expand Up @@ -1068,6 +1069,8 @@ bool UI::Keys() {
options["cheat_darkness"].value ^= true;
else if (ImGui::IsKeyChordPressed(keys["toggle_lights"]))
options["cheat_lights"].value ^= true;
else if (ImGui::IsKeyChordPressed(keys["toggle_clouds"]))
options["cheat_clouds"].value ^= true;
else if (ImGui::IsKeyChordPressed(keys["toggle_palette"])) {
options["cheat_palette"].value ^= true;
if (options["cheat_palette"].value) {
Expand All @@ -1089,8 +1092,7 @@ bool UI::Keys() {
else if (ImGui::IsKeyChordPressed(keys["pause"])) {
paused ^= true;
Max::get().set_pause = paused;
} else if (ImGui::IsKeyChordPressed(keys["skip"], ImGuiInputFlags_Repeat) &&
!ImGui::IsWindowFocused(ImGuiHoveredFlags_AnyWindow))
} else if (ImGui::IsKeyChordPressed(keys["skip"], ImGuiInputFlags_Repeat))
Max::get().skip = true;
else
return false;
Expand Down Expand Up @@ -1167,6 +1169,13 @@ void UI::Cheats() {
recover_mem("render_gameboy");
}

if (options["cheat_clouds"].value && get_address("render_clouds")) {
write_mem_recoverable("render_clouds", get_address("render_clouds"),
"EB 24"_gh, true);
} else {
recover_mem("render_clouds");
}

if (options["cheat_hud"].value && get_address("render_hud")) {
write_mem_recoverable(
"render_hud", get_address("render_hud"), "EB 74"_gh,
Expand Down
4 changes: 4 additions & 0 deletions ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class UI {
{"toggle_darkness", ImGuiMod_Ctrl | ImGuiKey_L},
{"toggle_lights", ImGuiMod_Shift | ImGuiKey_L},
{"toggle_palette", ImGuiMod_Alt | ImGuiKey_L},
{"toggle_clouds", ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_L},
{"toggle_player", ImGuiMod_Ctrl | ImGuiKey_B},
{"toggle_gameboy", ImGuiMod_Ctrl | ImGuiKey_K},
{"toggle_hud", ImGuiMod_Ctrl | ImGuiKey_H},
Expand Down Expand Up @@ -125,6 +126,9 @@ class UI {
{"cheat_player",
{false, "Hide player character", "Doesn't render the player character.",
"toggle_player"}},
{"cheat_clouds",
{false, "Remove clouds", "Removes the cloudy foreground effects.",
"toggle_clouds"}},
{"input_block",
{true, "Block game input on UI input",
"Blocks keyboard input from game\n"
Expand Down

0 comments on commit f7950b6

Please sign in to comment.