From 91b1c26976ae50f1c4160b80522d5c6639a08f73 Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Mon, 10 Jan 2022 16:53:57 +0100 Subject: [PATCH] Explore removing text messages from gen5 games --- src/core/gen5.zig | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/core/gen5.zig b/src/core/gen5.zig index e8fa699..84f5ac0 100644 --- a/src/core/gen5.zig +++ b/src/core/gen5.zig @@ -15,6 +15,7 @@ const unicode = std.unicode; const nds = rom.nds; +const li32 = rom.int.li32; const lu128 = rom.int.lu128; const lu16 = rom.int.lu16; const lu32 = rom.int.lu32; @@ -1327,6 +1328,43 @@ pub const Game = struct { }; while (decoder.next() catch continue) |command| : (command_offset = decoder.i) { switch (command.toZigUnion()) { + .wait_button, + .message, + .message2, + .message3, + .bubble_message, + .close_bubble_message, + .bordered_message, + .close_bordered_message, + .close_message_k_p, + .close_message_k_p2, + .event_grey_message, + .closed_event_grey_message, + .multi2, + .close_multi, + .set_text_script_message, + .angry_message, + .close_angry_message, + .double_message, + .show_message_at, + .close_show_message_at, + => { + const bytes = mem.asBytes(command); + const len = @import("script.zig").packedLength(command.*) catch + unreachable; + if (len % 2 == 0) { + mem.set(u8, bytes[0..len], 0); + } else if (len == 3) { + unreachable; + } else if (len == 5) { + command.tag = .@"if"; + command.data().@"if".value = 0; + command.data().@"if".offset = li32.init(0); + } else { + command.tag = .jump; + command.data().jump.offset = li32.init(@intCast(i32, len) - 6); + } + }, .wild_battle => |battle| try static_pokemons.append(.{ .species = &battle.species, .level = &battle.level,