diff --git a/common/formatter/rules/rule_config.cpp b/common/formatter/rules/rule_config.cpp index 829e539d883..9c64a6adf7e 100644 --- a/common/formatter/rules/rule_config.cpp +++ b/common/formatter/rules/rule_config.cpp @@ -168,6 +168,39 @@ static FormFormattingConfig new_deftype_rule( return cfg; } +static FormFormattingConfig new_defproc_rule( + int start_index, + int num_columns_to_compute_widths, + const std::vector& inlining_preventation_indices) { + FormFormattingConfig cfg; + cfg.has_constant_pairs = true; + cfg.config_set = true; + cfg.hang_forms = false; + cfg.inline_until_index = [start_index](std::vector curr_lines) { + // if (curr_lines.size() >= 4 && curr_lines.at(3) == "()") { + // return 4; + // } + return start_index; + }; + for (const auto& index : inlining_preventation_indices) { + auto temp_config = std::make_shared(); + temp_config->config_set = true; + temp_config->prevent_inlining = true; + temp_config->hang_forms = false; + temp_config->indentation_width = 1; + auto temp_list_config = std::make_shared(); + temp_list_config->force_inline = false; + temp_list_config->hang_forms = false; + temp_config->default_index_config = temp_list_config; + if (index == 3) { + temp_config->determine_column_widths_for_list_elements = true; + temp_config->num_columns_to_compute_widths = num_columns_to_compute_widths; + } + cfg.index_configs.emplace(index, temp_config); + } + return cfg; +} + static FormFormattingConfig new_binding_rule(int form_head_width) { FormFormattingConfig cfg; cfg.config_set = true; @@ -253,6 +286,9 @@ const std::unordered_map opengoal_form_config {"defmethod", new_defmethod_rule(3)}, {"lambda", new_lambda_rule(2)}, {"deftype", new_deftype_rule(3, 1, {3, 4, 5, 6})}, + {"defproc", new_defproc_rule(3, 1, {3, 4, 5, 6})}, + {"suspend-for", new_flow_rule(2)}, + {"spawn-proc", new_flow_rule(2)}, {"defun", new_flow_rule(3)}, {"defun-recursive", new_flow_rule(4)}, {"defun-debug-recursive", new_flow_rule(4)}, @@ -281,12 +317,14 @@ const std::unordered_map opengoal_form_config {"protect", new_binding_rule(4)}, {"let*", new_binding_rule(5)}, {"rlet", new_binding_rule(5)}, + {"mlet", new_binding_rule(5)}, {"when", new_flow_rule(2)}, {"unless", new_flow_rule(2)}, {"with-profiler", new_flow_rule(2)}, {"with-pc", new_flow_rule(0)}, {"#unless", new_flow_rule(2)}, {"#when", new_flow_rule(2)}, + {"#when-game", new_flow_rule(2)}, {"countdown", new_flow_rule(2)}, {"until", new_flow_rule(2)}, {"loop", new_flow_rule(0)}, diff --git a/common/util/gltf_util.cpp b/common/util/gltf_util.cpp index 105a056414e..1d3115089f0 100644 --- a/common/util/gltf_util.cpp +++ b/common/util/gltf_util.cpp @@ -577,7 +577,7 @@ void setup_alpha_from_material(const tinygltf::Material& material, DrawMode* mod void setup_draw_mode_from_sampler(const tinygltf::Sampler& sampler, DrawMode* mode) { if (sampler.magFilter == TINYGLTF_TEXTURE_FILTER_NEAREST) { - ASSERT(sampler.minFilter == TINYGLTF_TEXTURE_FILTER_NEAREST); + ASSERT(sampler.minFilter == TINYGLTF_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST); mode->set_filt_enable(false); } else { ASSERT(sampler.minFilter != TINYGLTF_TEXTURE_FILTER_NEAREST); diff --git a/game/kernel/common/kmachine.cpp b/game/kernel/common/kmachine.cpp index f68fc07e84f..5e771e19ba4 100644 --- a/game/kernel/common/kmachine.cpp +++ b/game/kernel/common/kmachine.cpp @@ -904,6 +904,15 @@ void pc_register_screen_shot_settings(u32 ptr) { register_screen_shot_settings(Ptr(ptr).c()); } +void pc_encode_utf8_string(u32 src_str_ptr, u32 str_dest_ptr) { + auto str = std::string(Ptr(src_str_ptr).c()->data()); + std::string version = version_to_game_name(g_game_version); + const std::string font_bank_name = version == "jak1" ? "jak1-v2" : version; + std::string converted = + get_font_bank(get_text_version_from_name(font_bank_name))->convert_utf8_to_game(str); + strcpy(Ptr(str_dest_ptr).c()->data(), converted.c_str()); +} + /// Initializes all functions that are common across all game versions /// These functions have the same implementation and do not use any game specific functions (other /// than the one to create a function in the first place) @@ -1005,6 +1014,9 @@ void init_common_pc_port_functions( // RNG make_func_symbol_func("pc-rand", (void*)pc_rand); + // text + make_func_symbol_func("pc-encode-utf8-string", (void*)pc_encode_utf8_string); + // debugging tools make_func_symbol_func("pc-filter-debug-string?", (void*)pc_filter_debug_string); make_func_symbol_func("pc-screen-shot", (void*)pc_screen_shot); diff --git a/game/kernel/jak2/kmachine.cpp b/game/kernel/jak2/kmachine.cpp index aa11bc7fde4..f2bee0fd6fe 100644 --- a/game/kernel/jak2/kmachine.cpp +++ b/game/kernel/jak2/kmachine.cpp @@ -541,7 +541,6 @@ void InitMachine_PCPort() { make_function_symbol_from_c("__pc-get-tex-remap", (void*)lookup_jak2_texture_dest_offset); make_function_symbol_from_c("pc-init-autosplitter-struct", (void*)kmachine_extras::init_autosplit_struct); - make_function_symbol_from_c("pc-encode-utf8-string", (void*)kmachine_extras::encode_utf8_string); // discord rich presence make_function_symbol_from_c("pc-discord-rpc-update", (void*)kmachine_extras::update_discord_rpc); diff --git a/game/kernel/jak2/kmachine_extras.cpp b/game/kernel/jak2/kmachine_extras.cpp index 0f8c2c1a698..7faf3d806db 100644 --- a/game/kernel/jak2/kmachine_extras.cpp +++ b/game/kernel/jak2/kmachine_extras.cpp @@ -196,13 +196,6 @@ inline bool symbol_to_bool(const u32 symptr) { return symptr != s7.offset; } -// TODO - move to common -void encode_utf8_string(u32 src_str_ptr, u32 str_dest_ptr) { - auto str = std::string(Ptr(src_str_ptr).c()->data()); - std::string converted = get_font_bank(GameTextVersion::JAK2)->convert_utf8_to_game(str); - strcpy(Ptr(str_dest_ptr).c()->data(), converted.c_str()); -} - void init_autosplit_struct() { g_auto_splitter_block_jak2.pointer_to_symbol = (u64)g_ee_main_mem + (u64)intern_from_c("*autosplit-info-jak2*")->value(); diff --git a/game/kernel/jak3/kmachine.cpp b/game/kernel/jak3/kmachine.cpp index 64a48a14e6e..836168c6b36 100644 --- a/game/kernel/jak3/kmachine.cpp +++ b/game/kernel/jak3/kmachine.cpp @@ -370,7 +370,6 @@ void InitMachine_PCPort() { (void*)kmachine_extras::pc_set_active_levels); make_function_symbol_from_c("__pc-get-tex-remap", (void*)lookup_jak3_texture_dest_offset); // make_function_symbol_from_c("pc-init-autosplitter-struct", (void*)init_autosplit_struct); - make_function_symbol_from_c("pc-encode-utf8-string", (void*)kmachine_extras::encode_utf8_string); // discord rich presence make_function_symbol_from_c("pc-discord-rpc-update", (void*)kmachine_extras::update_discord_rpc); diff --git a/game/kernel/jak3/kmachine_extras.cpp b/game/kernel/jak3/kmachine_extras.cpp index 035bb104544..626be6a067e 100644 --- a/game/kernel/jak3/kmachine_extras.cpp +++ b/game/kernel/jak3/kmachine_extras.cpp @@ -183,12 +183,5 @@ inline bool symbol_to_bool(const u32 symptr) { return symptr != s7.offset; } -// TODO - move to common -void encode_utf8_string(u32 src_str_ptr, u32 str_dest_ptr) { - auto str = std::string(Ptr(src_str_ptr).c()->data()); - std::string converted = get_font_bank(GameTextVersion::JAK3)->convert_utf8_to_game(str); - strcpy(Ptr(str_dest_ptr).c()->data(), converted.c_str()); -} - } // namespace kmachine_extras } // namespace jak3 diff --git a/goal_src/jak1/kernel-defs.gc b/goal_src/jak1/kernel-defs.gc index aef55495df4..ec4aa4a4819 100644 --- a/goal_src/jak1/kernel-defs.gc +++ b/goal_src/jak1/kernel-defs.gc @@ -575,6 +575,8 @@ (define-extern pc-rand (function int)) +(define-extern pc-encode-utf8-string (function string string none)) + ;; Constants generated within the C++ runtime (define-extern *pc-user-dir-base-path* string)