diff --git a/common/cross_os_debug/xdbg.cpp b/common/cross_os_debug/xdbg.cpp index af90486654..05116f19e9 100644 --- a/common/cross_os_debug/xdbg.cpp +++ b/common/cross_os_debug/xdbg.cpp @@ -341,6 +341,9 @@ bool attach_and_break(const ThreadID& tid) { return false; } + // by default, windows debuggers will kill their debuggees on detach + DebugSetProcessKillOnExit(FALSE); + return true; } diff --git a/common/goos/Interpreter.cpp b/common/goos/Interpreter.cpp index b5fafcb99a..62d7ee7a76 100644 --- a/common/goos/Interpreter.cpp +++ b/common/goos/Interpreter.cpp @@ -1692,6 +1692,7 @@ Object Interpreter::eval_get_env(const Object& form, return args.get_named("default"); } else { throw_eval_error(form, fmt::format("env-var {} not found and no default provided", var_name)); + return Object::make_empty_list(); } } return StringObject::make_new(env_p); diff --git a/common/type_system/TypeSystem.cpp b/common/type_system/TypeSystem.cpp index 0acdfe5525..d5aec965fc 100644 --- a/common/type_system/TypeSystem.cpp +++ b/common/type_system/TypeSystem.cpp @@ -1102,11 +1102,11 @@ void TypeSystem::add_builtin_types() { // todo builtin_structure_inherit(file_stream_type); add_field_to_type(file_stream_type, "flags", make_typespec("uint32")); - add_field_to_type(file_stream_type, "mode", make_typespec("basic")); + add_field_to_type(file_stream_type, "mode", make_typespec("symbol")); add_field_to_type(file_stream_type, "name", make_typespec("string")); add_field_to_type(file_stream_type, "file", make_typespec("uint32")); declare_method(file_stream_type, "new", false, - make_function_typespec({"symbol", "type", "string", "basic"}, "_type_"), false); + make_function_typespec({"symbol", "type", "string", "symbol"}, "_type_"), false); } /*! @@ -1134,7 +1134,7 @@ int TypeSystem::get_next_method_id(const Type* type) const { if (type->has_parent()) { type = lookup_type(type->get_parent()); } else { - // nobody has defined any method yet. New is special and doens't use this, so we return + // nobody has defined any method yet. New is special and doesn't use this, so we return // one after new. return 1; } diff --git a/decompiler/analysis/final_output.cpp b/decompiler/analysis/final_output.cpp index f8fead055d..980ad3d5f9 100644 --- a/decompiler/analysis/final_output.cpp +++ b/decompiler/analysis/final_output.cpp @@ -256,6 +256,7 @@ std::string write_from_top_level_form(Form* top_form, if (entry.condition->to_string(env) == "*debug-segment*") { forms = entry.body->elts(); result += ";; this file is debug only\n"; + result += "(declare-file (debug))\n"; result += "(when *debug-segment*\n"; in_debug_only_file = true; } diff --git a/decompiler/config.cpp b/decompiler/config.cpp index bb9e65251d..fdc9f29a96 100644 --- a/decompiler/config.cpp +++ b/decompiler/config.cpp @@ -56,6 +56,7 @@ Config read_config_file(const std::string& path_to_config_file) { config.print_cfgs = cfg.at("print_cfgs").get(); config.generate_symbol_definition_map = cfg.at("generate_symbol_definition_map").get(); config.is_pal = cfg.at("is_pal").get(); + config.rip_levels = cfg.at("levels_convert_to_obj").get(); auto allowed = cfg.at("allowed_objects").get>(); for (const auto& x : allowed) { diff --git a/decompiler/config.h b/decompiler/config.h index 105d37973a..e870fcb2fe 100644 --- a/decompiler/config.h +++ b/decompiler/config.h @@ -98,6 +98,7 @@ struct Config { bool process_tpages = false; bool process_game_text = false; bool process_game_count = false; + bool rip_levels = false; bool regenerate_all_types = false; bool write_hex_near_instructions = false; diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 2ec7a41e8c..7c6d6b6f11 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -4738,12 +4738,12 @@ (deftype file-stream (basic) ((flags uint32 :offset-assert 4) - (mode basic :offset-assert 8) + (mode symbol :offset-assert 8) (name string :offset-assert 12) (file uint32 :offset-assert 16) ) (:methods - (new (symbol type string basic) _type_) + (new (symbol type string symbol) _type_) ) :method-count-assert 9 :size-assert #x14 @@ -5862,7 +5862,7 @@ (hint (pointer process) :offset-assert 60) ;; special print (ambient (pointer process) :offset-assert 64) ;; special print (video-mode symbol :offset-assert 68) - (aspect-ratio symbol :offset-assert 72) ;; a guess but, anything besides this doesnt make sense + (aspect-ratio symbol :offset-assert 72) (sound-flava uint8 :offset-assert 76) (auto-save symbol :offset-assert 80) (music-volume-movie float :offset-assert 84) @@ -12232,7 +12232,7 @@ (pat pointer :offset-assert 44) (pat-length int32 :offset-assert 48) - ;; some osrt of texture remapping info + ;; some sort of texture remapping info (texture-remap-table (pointer uint64) :offset-assert 52) (texture-remap-table-len int32 :offset-assert 56) @@ -16645,7 +16645,7 @@ ;; - Functions (define-extern get-string-length (function string font-context float)) -(define-extern draw-string-adv (function string dma-buffer font-context none)) ;; TODO - ret value unconfirmed! +(define-extern draw-string-adv (function string dma-buffer font-context none)) ;; - Unknowns @@ -19035,10 +19035,10 @@ ;; - Functions (define-extern move-camera-from-pad (function math-camera math-camera)) -(define-extern update-view-planes (function math-camera (inline-array plane) float float)) +(define-extern update-view-planes (function math-camera (inline-array plane) float none)) (define-extern update-visible (function math-camera symbol)) ;; second/third arg unused -(define-extern set-point (function vector float float float float)) -(define-extern plane-from-points (function (inline-array plane) vector vector vector int float)) +(define-extern set-point (function vector float float float none)) +(define-extern plane-from-points (function (inline-array plane) vector vector vector int none)) (define-extern update-camera (function symbol)) ;; - Symbols diff --git a/decompiler/config/jak1_ntsc_black_label.jsonc b/decompiler/config/jak1_ntsc_black_label.jsonc index 2e4775f998..6c599c4b63 100644 --- a/decompiler/config/jak1_ntsc_black_label.jsonc +++ b/decompiler/config/jak1_ntsc_black_label.jsonc @@ -5,7 +5,7 @@ // if you want to filter to only some object names. // it will make the decompiler much faster. "allowed_objects": [], - "banned_objects": ["collide-mesh"], + "banned_objects": [], //////////////////////////// // CODE ANALYSIS OPTIONS @@ -84,6 +84,9 @@ // LEVEL EXTRACTION //////////////////////////// + // turn this on if you want extracted levels to be saved out as .obj files + "levels_convert_to_obj": false, + // list of level DGOs to extract background graphics for "levels_to_extract":[ "BEA.DGO", "CIT.DGO", diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index cabf8cf96e..e2ec92de24 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -360,7 +360,8 @@ "a0-1": "str-ptr", "v0-0": "result", "a0-2": "next-char-1", - "a0-3": "next-char-2" + "a0-3": "next-char-2", + "v1-0": "negate" } }, diff --git a/decompiler/level_extractor/BspHeader.h b/decompiler/level_extractor/BspHeader.h index 326c3535d2..6d40bf572e 100644 --- a/decompiler/level_extractor/BspHeader.h +++ b/decompiler/level_extractor/BspHeader.h @@ -429,7 +429,7 @@ struct BspHeader { // (pat pointer :offset-assert 44) // (pat-length int32 :offset-assert 48) // - // ;; some osrt of texture remapping info + // ;; some sort of texture remapping info // (texture-remap-table (pointer uint64) :offset-assert 52) // (texture-remap-table-len int32 :offset-assert 56) std::vector texture_remap_table; diff --git a/decompiler/level_extractor/extract_level.cpp b/decompiler/level_extractor/extract_level.cpp index 72b519d6c3..7a170910ec 100644 --- a/decompiler/level_extractor/extract_level.cpp +++ b/decompiler/level_extractor/extract_level.cpp @@ -50,7 +50,8 @@ bool is_valid_bsp(const decompiler::LinkedObjectFile& file) { void extract_from_level(ObjectFileDB& db, TextureDB& tex_db, const std::string& dgo_name, - const DecompileHacks& hacks) { + const DecompileHacks& hacks, + bool dump_level) { if (db.obj_files_by_dgo.count(dgo_name) == 0) { lg::warn("Skipping extract for {} because the DGO was not part of the input", dgo_name); return; @@ -91,13 +92,14 @@ void extract_from_level(ObjectFileDB& db, expected_missing_textures = it->second; } extract_tfrag(as_tfrag_tree, fmt::format("{}-{}", dgo_name, i++), - bsp_header.texture_remap_table, tex_db, expected_missing_textures, tfrag_level); + bsp_header.texture_remap_table, tex_db, expected_missing_textures, tfrag_level, + dump_level); } else if (draw_tree->my_type() == "drawable-tree-instance-tie") { fmt::print(" extracting TIE\n"); auto as_tie_tree = dynamic_cast(draw_tree.get()); assert(as_tie_tree); extract_tie(as_tie_tree, fmt::format("{}-{}-tie", dgo_name, i++), - bsp_header.texture_remap_table, tex_db, tfrag_level); + bsp_header.texture_remap_table, tex_db, tfrag_level, dump_level); } else { fmt::print(" unsupported tree {}\n", draw_tree->my_type()); } diff --git a/decompiler/level_extractor/extract_level.h b/decompiler/level_extractor/extract_level.h index f7b2b691ee..66e0b9a2e6 100644 --- a/decompiler/level_extractor/extract_level.h +++ b/decompiler/level_extractor/extract_level.h @@ -9,5 +9,6 @@ namespace decompiler { void extract_from_level(ObjectFileDB& db, TextureDB& tex_db, const std::string& dgo_name, - const DecompileHacks& hacks); + const DecompileHacks& hacks, + bool dump_level); } diff --git a/decompiler/level_extractor/extract_tfrag.cpp b/decompiler/level_extractor/extract_tfrag.cpp index 351028cedb..7d6ff686f1 100644 --- a/decompiler/level_extractor/extract_tfrag.cpp +++ b/decompiler/level_extractor/extract_tfrag.cpp @@ -2073,7 +2073,8 @@ void emulate_tfrags(const std::vector& frags, tfrag3::Level& level_out, tfrag3::TfragTree& tree_out, const TextureDB& tdb, - const std::vector>& expected_missing_textures) { + const std::vector>& expected_missing_textures, + bool dump_level) { TFragExtractStats stats; std::vector vu_mem; @@ -2094,9 +2095,12 @@ void emulate_tfrags(const std::vector& frags, make_tfrag3_data(groups, tree_out, level_out.textures, tdb, expected_missing_textures); - auto debug_out = debug_dump_to_obj(all_draws); - file_util::write_text_file( - file_util::get_file_path({"debug_out", fmt::format("tfrag-{}.obj", debug_name)}), debug_out); + if (dump_level) { + auto debug_out = debug_dump_to_obj(all_draws); + file_util::write_text_file( + file_util::get_file_path({"debug_out", fmt::format("tfrag-{}.obj", debug_name)}), + debug_out); + } } void extract_time_of_day(const level_tools::DrawableTreeTfrag* tree, tfrag3::TfragTree& out) { @@ -2115,7 +2119,8 @@ void extract_tfrag(const level_tools::DrawableTreeTfrag* tree, const std::vector& map, const TextureDB& tex_db, const std::vector>& expected_missing_textures, - tfrag3::Level& out) { + tfrag3::Level& out, + bool dump_level) { tfrag3::TfragTree this_tree; if (tree->my_type() == "drawable-tree-tfrag") { this_tree.kind = tfrag3::TFragmentTreeKind::NORMAL; @@ -2171,7 +2176,7 @@ void extract_tfrag(const level_tools::DrawableTreeTfrag* tree, // assert(result.vis_nodes.last_child_node + 1 == idx); emulate_tfrags(as_tfrag_array->tfragments, debug_name, map, out, this_tree, tex_db, - expected_missing_textures); + expected_missing_textures, dump_level); extract_time_of_day(tree, this_tree); for (auto& draw : this_tree.draws) { @@ -2186,4 +2191,4 @@ void extract_tfrag(const level_tools::DrawableTreeTfrag* tree, } out.tfrag_trees.push_back(this_tree); } -} // namespace decompiler \ No newline at end of file +} // namespace decompiler diff --git a/decompiler/level_extractor/extract_tfrag.h b/decompiler/level_extractor/extract_tfrag.h index eb42339f38..985d43826c 100644 --- a/decompiler/level_extractor/extract_tfrag.h +++ b/decompiler/level_extractor/extract_tfrag.h @@ -35,6 +35,7 @@ void extract_tfrag(const level_tools::DrawableTreeTfrag* tree, const std::vector& map, const TextureDB& tex_db, const std::vector>& expected_missing_textures, - tfrag3::Level& out); + tfrag3::Level& out, + bool dump_level); -} // namespace decompiler \ No newline at end of file +} // namespace decompiler diff --git a/decompiler/level_extractor/extract_tie.cpp b/decompiler/level_extractor/extract_tie.cpp index b1994d0926..fc7058f5b8 100644 --- a/decompiler/level_extractor/extract_tie.cpp +++ b/decompiler/level_extractor/extract_tie.cpp @@ -1994,7 +1994,8 @@ void extract_tie(const level_tools::DrawableTreeInstanceTie* tree, const std::string& debug_name, const std::vector& tex_map, const TextureDB& tex_db, - tfrag3::Level& out) { + tfrag3::Level& out, + bool dump_level) { tfrag3::TieTree this_tree; // sanity check the vis tree (not a perfect check, but this is used in game and should be right) @@ -2036,16 +2037,18 @@ void extract_tie(const level_tools::DrawableTreeInstanceTie* tree, emulate_tie_instance_program(info); emulate_kicks(info); - auto dir = file_util::get_file_path({fmt::format("debug_out/tie-{}/", debug_name)}); - file_util::create_dir_if_needed(dir); - for (auto& proto : info) { - auto data = debug_dump_proto_to_obj(proto); - file_util::write_text_file(fmt::format("{}/{}.obj", dir, proto.name), data); - // file_util::create_dir_if_needed() - } + if (dump_level) { + auto dir = file_util::get_file_path({fmt::format("debug_out/tie-{}/", debug_name)}); + file_util::create_dir_if_needed(dir); + for (auto& proto : info) { + auto data = debug_dump_proto_to_obj(proto); + file_util::write_text_file(fmt::format("{}/{}.obj", dir, proto.name), data); + // file_util::create_dir_if_needed() + } - auto full = dump_full_to_obj(info); - file_util::write_text_file(fmt::format("{}/ALL.obj", dir), full); + auto full = dump_full_to_obj(info); + file_util::write_text_file(fmt::format("{}/ALL.obj", dir), full); + } auto full_palette = make_big_palette(info); add_vertices_and_static_draw(this_tree, out, tex_db, info); @@ -2065,4 +2068,4 @@ void extract_tie(const level_tools::DrawableTreeInstanceTie* tree, fmt::print("TIE tree has {} draws\n", this_tree.static_draws.size()); out.tie_trees.push_back(std::move(this_tree)); } -} // namespace decompiler \ No newline at end of file +} // namespace decompiler diff --git a/decompiler/level_extractor/extract_tie.h b/decompiler/level_extractor/extract_tie.h index 4f0154e4b6..59c5b167f5 100644 --- a/decompiler/level_extractor/extract_tie.h +++ b/decompiler/level_extractor/extract_tie.h @@ -11,5 +11,6 @@ void extract_tie(const level_tools::DrawableTreeInstanceTie* tree, const std::string& debug_name, const std::vector& tex_map, const TextureDB& tex_db, - tfrag3::Level& out); -} \ No newline at end of file + tfrag3::Level& out, + bool dump_level); +} diff --git a/decompiler/main.cpp b/decompiler/main.cpp index 3ec49f0681..5504820ce7 100644 --- a/decompiler/main.cpp +++ b/decompiler/main.cpp @@ -57,7 +57,9 @@ int main(int argc, char** argv) { } file_util::create_dir_if_needed(out_folder); - file_util::create_dir_if_needed(file_util::get_file_path({"debug_out"})); + if (config.rip_levels) { + file_util::create_dir_if_needed(file_util::get_file_path({"debug_out"})); + } fmt::print("[Mem] After config read: {} MB\n", get_peak_rss() / (1024 * 1024)); @@ -148,7 +150,7 @@ int main(int argc, char** argv) { } for (auto& lev : config.levels_to_extract) { - extract_from_level(db, tex_db, lev, config.hacks); + extract_from_level(db, tex_db, lev, config.hacks, config.rip_levels); } fmt::print("[Mem] After extraction: {} MB\n", get_peak_rss() / (1024 * 1024)); diff --git a/docs/markdown/debugging.md b/docs/markdown/debugging.md index afe88e0429..43ba6beeef 100644 --- a/docs/markdown/debugging.md +++ b/docs/markdown/debugging.md @@ -46,6 +46,10 @@ gc> (dbs) Continue the target if it has been stopped. +### `(:stop)` + +Detach from target. + ### `(:break)` Immediately stop the target if it is running. Will print some registers. diff --git a/docs/markdown/imgs/screenshot_hut.png b/docs/markdown/imgs/screenshot_hut.png index 832ac17006..f59f07a014 100644 Binary files a/docs/markdown/imgs/screenshot_hut.png and b/docs/markdown/imgs/screenshot_hut.png differ diff --git a/docs/markdown/imgs/screenshot_vi1.png b/docs/markdown/imgs/screenshot_vi1.png index 4628f44b82..5afdb6e14f 100644 Binary files a/docs/markdown/imgs/screenshot_vi1.png and b/docs/markdown/imgs/screenshot_vi1.png differ diff --git a/game/fake_iso.txt b/game/fake_iso.txt index 36806df31d..ad706bb464 100644 --- a/game/fake_iso.txt +++ b/game/fake_iso.txt @@ -28,26 +28,40 @@ VI1.DGO out/iso/VI1.DGO VI2.DGO out/iso/VI2.DGO VI3.DGO out/iso/VI3.DGO TRA.DGO out/iso/TRA.DGO -FIN.DGO out/iso/FIN.DGO FIC.DGO out/iso/FIC.DGO -JUN.DGO out/iso/JUN.DGO -MAI.DGO out/iso/MAI.DGO -BEA.DGO out/iso/BEA.DGO -CIT.DGO out/iso/CIT.DGO +ROL.DGO out/iso/ROL.DGO SUN.DGO out/iso/SUN.DGO +SUB.DGO out/iso/SUB.DGO +SWA.DGO out/iso/SWA.DGO +OGR.DGO out/iso/OGR.DGO +JUN.DGO out/iso/JUN.DGO +JUB.DGO out/iso/JUB.DGO +MAI.DGO out/iso/MAI.DGO +SNO.DGO out/iso/SNO.DGO +BEA.DGO out/iso/BEA.DGO +LAV.DGO out/iso/LAV.DGO +CIT.DGO out/iso/CIT.DGO +FIN.DGO out/iso/FIN.DGO ;; Level VIS VI1.VIS out/iso/VI1.VIS VI2.VIS out/iso/VI2.VIS VI3.VIS out/iso/VI3.VIS TRA.VIS out/iso/TRA.VIS -FIN.VIS out/iso/FIN.VIS FIC.VIS out/iso/FIC.VIS -JUN.VIS out/iso/JUN.VIS -MAI.VIS out/iso/MAI.VIS -BEA.VIS out/iso/BEA.VIS -CIT.VIS out/iso/CIT.VIS +ROL.VIS out/iso/ROL.VIS SUN.VIS out/iso/SUN.VIS +SUB.VIS out/iso/SUB.VIS +SWA.VIS out/iso/SWA.VIS +OGR.VIS out/iso/OGR.VIS +JUN.VIS out/iso/JUN.VIS +JUB.VIS out/iso/JUB.VIS +MAI.VIS out/iso/MAI.VIS +SNO.VIS out/iso/SNO.VIS +BEA.VIS out/iso/BEA.VIS +LAV.VIS out/iso/LAV.VIS +CIT.VIS out/iso/CIT.VIS +FIN.VIS out/iso/FIN.VIS ;; Streaming Animations FUCVICTO.STR out/iso/FUCVICTO.STR diff --git a/game/graphics/display.cpp b/game/graphics/display.cpp index 92415402ad..52717c24c3 100644 --- a/game/graphics/display.cpp +++ b/game/graphics/display.cpp @@ -85,6 +85,32 @@ void GfxDisplay::render_graphics() { m_renderer->render_display(this); } +int GfxDisplay::width() { + int w; + m_renderer->display_size(this, &w, NULL); + return w; +} + +int GfxDisplay::height() { + int h; + m_renderer->display_size(this, NULL, &h); + return h; +} + +void GfxDisplay::set_size(int w, int h) { + m_renderer->display_set_size(this, w, h); +} + +void GfxDisplay::get_scale(float* x, float* y) { + m_renderer->display_scale(this, x, y); +} + +void GfxDisplay::backup_params() { + m_renderer->display_size(this, &m_width, &m_height); + m_renderer->display_position(this, &m_xpos, &m_ypos); + fmt::print("backed up window: {},{} {}x{}\n", m_xpos, m_ypos, m_width, m_height); +} + /* ******************************** * DISPLAY @@ -106,8 +132,7 @@ int InitMainDisplay(int width, int height, const char* title, GfxSettings& setti return 1; } - auto display = - Gfx::GetRenderer(settings.renderer)->make_main_display(width, height, title, settings); + auto display = Gfx::GetCurrentRenderer()->make_main_display(width, height, title, settings); if (display == NULL) { lg::error("Failed to make main display."); return 1; diff --git a/game/graphics/display.h b/game/graphics/display.h index d559ff6df2..ba0bde1e17 100644 --- a/game/graphics/display.h +++ b/game/graphics/display.h @@ -18,6 +18,19 @@ class GfxDisplay { const GfxRendererModule* m_renderer = nullptr; + // NOT actual size! just backups + int m_width; + int m_height; + // same here + int m_xpos; + int m_ypos; + + bool m_update_fullscreen = false; + int m_fullscreen_mode = 0; + int m_fullscreen_screen; + int m_fullscreen_target_mode; + int m_fullscreen_target_screen; + public: GfxDisplay(GLFWwindow* a_window); // OpenGL window constructor ~GfxDisplay(); // destructor - this calls the renderer's function for getting rid of a window, @@ -33,8 +46,33 @@ class GfxDisplay { void set_renderer(GfxPipeline pipeline); void set_window(GLFWwindow* window); void set_title(const char* title); + void set_size(int w, int h); + void get_scale(float* w, float* h); const char* title() const { return m_title; } + bool fullscreen_pending() { return m_update_fullscreen; } + void fullscreen_flush() { + m_renderer->set_fullscreen(this, m_fullscreen_target_mode, m_fullscreen_target_screen); + m_fullscreen_mode = m_fullscreen_target_mode; + m_fullscreen_screen = m_fullscreen_target_screen; + m_update_fullscreen = false; + } + void set_fullscreen(int mode, int screen) { + m_fullscreen_target_mode = mode; + m_fullscreen_target_screen = screen; + m_update_fullscreen = true; + } + int fullscreen_mode() { return m_fullscreen_mode; } + int fullscreen_screen() { return m_fullscreen_screen; } + void backup_params(); + int width_backup() { return m_width; } + int height_backup() { return m_height; } + int xpos_backup() { return m_xpos; } + int ypos_backup() { return m_ypos; } + + int width(); + int height(); + void render_graphics(); }; diff --git a/game/graphics/gfx.cpp b/game/graphics/gfx.cpp index ebdfcaf435..95eeed3515 100644 --- a/game/graphics/gfx.cpp +++ b/game/graphics/gfx.cpp @@ -47,6 +47,7 @@ void InitSettings(GfxSettings& settings) { namespace Gfx { +GfxGlobalSettings g_global_settings; GfxSettings g_settings; // const std::vector renderers = {&moduleOpenGL}; @@ -93,8 +94,13 @@ const GfxRendererModule* GetRenderer(GfxPipeline pipeline) { } } +void SetRenderer(GfxPipeline pipeline) { + g_global_settings.renderer = GetRenderer(pipeline); + g_settings.renderer = pipeline; +} + const GfxRendererModule* GetCurrentRenderer() { - return GetRenderer(g_settings.renderer); + return g_global_settings.renderer; } u32 Init() { @@ -105,6 +111,7 @@ u32 Init() { Pad::ForceClearKeys(); LoadSettings(); + SetRenderer(g_settings.renderer); if (GetCurrentRenderer()->init(g_settings)) { lg::error("Gfx::Init error"); @@ -139,11 +146,17 @@ u32 Exit() { } u32 vsync() { - return GetCurrentRenderer()->vsync(); + if (GetCurrentRenderer()) { + return GetCurrentRenderer()->vsync(); + } + return 0; } u32 sync_path() { - return GetCurrentRenderer()->sync_path(); + if (GetCurrentRenderer()) { + return GetCurrentRenderer()->sync_path(); + } + return 0; } void send_chain(const void* data, u32 offset) { @@ -168,6 +181,45 @@ void poll_events() { GetCurrentRenderer()->poll_events(); } +u64 get_window_width() { + if (Display::GetMainDisplay()) { + return Display::GetMainDisplay()->width(); + } else { + return 0; + } +} + +u64 get_window_height() { + if (Display::GetMainDisplay()) { + return Display::GetMainDisplay()->height(); + } else { + return 0; + } +} + +void set_window_size(u64 w, u64 h) { + if (Display::GetMainDisplay()) { + Display::GetMainDisplay()->set_size(w, h); + } +} + +void get_window_scale(float* x, float* y) { + if (Display::GetMainDisplay()) { + Display::GetMainDisplay()->get_scale(x, y); + } +} + +void set_letterbox(int w, int h) { + g_global_settings.lbox_w = w; + g_global_settings.lbox_h = h; +} + +void set_fullscreen(int mode, int screen) { + if (Display::GetMainDisplay()) { + Display::GetMainDisplay()->set_fullscreen(mode, screen); + } +} + void input_mode_set(u32 enable) { if (enable == s7.offset + FIX_SYM_TRUE) { // #t Pad::g_input_mode_mapping = g_settings.pad_mapping_info; diff --git a/game/graphics/gfx.h b/game/graphics/gfx.h index f42badf80f..2a947e4b09 100644 --- a/game/graphics/gfx.h +++ b/game/graphics/gfx.h @@ -26,6 +26,11 @@ struct GfxRendererModule { make_main_display; std::function kill_display; std::function render_display; + std::function display_position; + std::function display_size; + std::function display_set_size; + std::function display_scale; + std::function set_fullscreen; std::function exit; std::function vsync; std::function sync_path; @@ -54,15 +59,28 @@ struct GfxSettings { int vsync; // (temp) number of screen update per frame bool debug; // graphics debugging - GfxPipeline renderer; // which rendering pipeline to use. + GfxPipeline renderer = GfxPipeline::Invalid; // which rendering pipeline to use. +}; + +// runtime settings +struct GfxGlobalSettings { + // note: this is actually the size of the display that ISN'T letterboxed + // the excess space is what will be letterboxed away. + int lbox_w; + int lbox_h; + + // current renderer + const GfxRendererModule* renderer; }; namespace Gfx { +extern GfxGlobalSettings g_global_settings; extern GfxSettings g_settings; // extern const std::vector renderers; const GfxRendererModule* GetRenderer(GfxPipeline pipeline); +const GfxRendererModule* GetCurrentRenderer(); u32 Init(); void Loop(std::function f); @@ -74,6 +92,12 @@ void send_chain(const void* data, u32 offset); void texture_upload_now(const u8* tpage, int mode, u32 s7_ptr); void texture_relocate(u32 destination, u32 source, u32 format); void poll_events(); +u64 get_window_width(); +u64 get_window_height(); +void set_window_size(u64 w, u64 h); +void get_window_scale(float* x, float* y); +void set_letterbox(int w, int h); +void set_fullscreen(int mode, int screen); void input_mode_set(u32 enable); void input_mode_save(); s64 get_mapped_button(s64 pad, s64 button); diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index 8cd1a1d066..a80b678dd5 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -26,7 +26,7 @@ void GLAPIENTRY opengl_error_callback(GLenum source, const void* /*userParam*/) { if (severity == GL_DEBUG_SEVERITY_NOTIFICATION) { // On some drivers this prints on every single texture upload, which is too much spam - // lg::debug("OpenGL notification 0x{:X} S{:X} T{:X}: {}", id, source, type, message); + lg::debug("OpenGL notification 0x{:X} S{:X} T{:X}: {}", id, source, type, message); } else if (severity == GL_DEBUG_SEVERITY_LOW) { lg::info("OpenGL message 0x{:X} S{:X} T{:X}: {}", id, source, type, message); } else if (severity == GL_DEBUG_SEVERITY_MEDIUM) { @@ -40,15 +40,12 @@ OpenGLRenderer::OpenGLRenderer(std::shared_ptr texture_pool) : m_render_state(texture_pool) { // setup OpenGL errors - // disable specific errors - const GLuint l_gl_error_ignores[1] = { - 0x64 // [API-PERFORMANCE] glDrawArrays uses non-native input attribute type - }; glEnable(GL_DEBUG_OUTPUT); glDebugMessageCallback(opengl_error_callback, nullptr); - // filter - glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_PERFORMANCE, GL_DONT_CARE, 1, - &l_gl_error_ignores[0], GL_FALSE); + // disable specific errors + // const GLuint gl_error_ignores_api_perf[1] = {}; + // glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_PERFORMANCE, GL_DONT_CARE, 0, + // &gl_error_ignores_api_perf[0], GL_FALSE); lg::debug("OpenGL context information: {}", (const char*)glGetString(GL_VERSION)); @@ -119,7 +116,8 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) { { auto prof = m_profiler.root()->make_scoped_child("frame-setup"); - setup_frame(settings.window_width_px, settings.window_height_px); + setup_frame(settings.window_width_px, settings.window_height_px, settings.lbox_width_px, + settings.lbox_height_px); } { auto prof = m_profiler.root()->make_scoped_child("texture-gc"); @@ -148,8 +146,8 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) { } if (settings.save_screenshot) { - finish_screenshot(settings.screenshot_path, settings.window_width_px, - settings.window_height_px); + finish_screenshot(settings.screenshot_path, settings.window_width_px, settings.window_height_px, + settings.lbox_width_px, settings.lbox_height_px); } } @@ -187,8 +185,11 @@ void OpenGLRenderer::draw_renderer_selection_window() { /*! * Pre-render frame setup. */ -void OpenGLRenderer::setup_frame(int window_width_px, int window_height_px) { - glViewport(0, 0, window_width_px, window_height_px); +void OpenGLRenderer::setup_frame(int window_width_px, + int window_height_px, + int offset_x, + int offset_y) { + glViewport(offset_x, offset_y, window_width_px, window_height_px); glClearColor(0.0, 0.0, 0.0, 0.0); glClearDepth(0.0); glDepthMask(GL_TRUE); @@ -305,11 +306,15 @@ void OpenGLRenderer::draw_test_triangle() { /*! * Take a screenshot! */ -void OpenGLRenderer::finish_screenshot(const std::string& output_name, int width, int height) { +void OpenGLRenderer::finish_screenshot(const std::string& output_name, + int width, + int height, + int x, + int y) { std::vector buffer(width * height); glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadBuffer(GL_BACK); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer.data()); + glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer.data()); // flip upside down in place for (int h = 0; h < height / 2; h++) { for (int w = 0; w < width; w++) { @@ -322,4 +327,4 @@ void OpenGLRenderer::finish_screenshot(const std::string& output_name, int width x |= 0xff000000; } file_util::write_rgba_png(output_name, buffer.data(), width, height); -} \ No newline at end of file +} diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.h b/game/graphics/opengl_renderer/OpenGLRenderer.h index 820296e47a..111ef0397f 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.h +++ b/game/graphics/opengl_renderer/OpenGLRenderer.h @@ -11,6 +11,8 @@ struct RenderOptions { int window_height_px = 0; int window_width_px = 0; + int lbox_height_px = 0; + int lbox_width_px = 0; bool draw_render_debug_window = false; bool draw_profiler_window = false; bool playing_from_dump = false; @@ -26,13 +28,13 @@ class OpenGLRenderer { void serialize(Serializer& ser); private: - void setup_frame(int window_width_px, int window_height_px); + void setup_frame(int window_width_px, int window_height_px, int offset_x, int offset_y); void draw_test_triangle(); void dispatch_buckets(DmaFollower dma, ScopedProfilerNode& prof); void init_bucket_renderers(); void draw_renderer_selection_window(); - void finish_screenshot(const std::string& output_name, int px, int py); + void finish_screenshot(const std::string& output_name, int px, int py, int x, int y); template void init_bucket_renderer(const std::string& name, BucketId id, Args&&... args) { diff --git a/game/graphics/opengl_renderer/shaders/tfrag3.vert b/game/graphics/opengl_renderer/shaders/tfrag3.vert index b8c9d0decb..a7d1305eae 100644 --- a/game/graphics/opengl_renderer/shaders/tfrag3.vert +++ b/game/graphics/opengl_renderer/shaders/tfrag3.vert @@ -2,7 +2,7 @@ layout (location = 0) in vec3 position_in; layout (location = 1) in vec3 tex_coord_in; -layout (location = 2) in float time_of_day_index; +layout (location = 2) in int time_of_day_index; uniform vec4 hvdf_offset; uniform mat4 camera; @@ -65,7 +65,7 @@ void main() { gl_Position = transformed; // time of day lookup - fragment_color = texture(tex_T1, time_of_day_index / 8192.f); + fragment_color = texelFetch(tex_T1, time_of_day_index, 0); fragment_color.w *= 2; tex_coord = tex_coord_in; -} \ No newline at end of file +} diff --git a/game/graphics/opengl_renderer/tfrag/Tfrag3.cpp b/game/graphics/opengl_renderer/tfrag/Tfrag3.cpp index 4aa147e837..43e15e9071 100644 --- a/game/graphics/opengl_renderer/tfrag/Tfrag3.cpp +++ b/game/graphics/opengl_renderer/tfrag/Tfrag3.cpp @@ -102,12 +102,11 @@ void Tfrag3::setup_for_level(const std::vector& tree_ (void*)offsetof(tfrag3::PreloadedVertex, s) // offset (0) ); - glVertexAttribPointer(2, // location 2 in the shader - 1, // 1 values per vert - GL_UNSIGNED_SHORT, // u16 - GL_FALSE, // don't normalize - sizeof(tfrag3::PreloadedVertex), // stride - (void*)offsetof(tfrag3::PreloadedVertex, color_index) // offset (0) + glVertexAttribIPointer(2, // location 2 in the shader + 1, // 1 values per vert + GL_UNSIGNED_SHORT, // u16 + sizeof(tfrag3::PreloadedVertex), // stride + (void*)offsetof(tfrag3::PreloadedVertex, color_index) // offset (0) ); glBindVertexArray(0); } diff --git a/game/graphics/opengl_renderer/tfrag/Tie3.cpp b/game/graphics/opengl_renderer/tfrag/Tie3.cpp index 266756af55..62fd0416fd 100644 --- a/game/graphics/opengl_renderer/tfrag/Tie3.cpp +++ b/game/graphics/opengl_renderer/tfrag/Tie3.cpp @@ -79,12 +79,11 @@ void Tie3::setup_for_level(const std::string& level, SharedRenderState* render_s (void*)offsetof(tfrag3::PreloadedVertex, s) // offset (0) ); - glVertexAttribPointer(2, // location 2 in the shader - 1, // 1 values per vert - GL_UNSIGNED_SHORT, // u16 - GL_FALSE, // don't normalize - sizeof(tfrag3::PreloadedVertex), // stride - (void*)offsetof(tfrag3::PreloadedVertex, color_index) // offset (0) + glVertexAttribIPointer(2, // location 2 in the shader + 1, // 1 values per vert + GL_UNSIGNED_SHORT, // u16 + sizeof(tfrag3::PreloadedVertex), // stride + (void*)offsetof(tfrag3::PreloadedVertex, color_index) // offset (0) ); glBindVertexArray(0); } @@ -428,4 +427,4 @@ void Tie3::draw_debug_window() { ImGui::Separator(); } ImGui::Text("All trees: %.2f", 1000.f * m_all_tree_time.get()); -} \ No newline at end of file +} diff --git a/game/graphics/pipelines/opengl.cpp b/game/graphics/pipelines/opengl.cpp index 61e8b6dddd..abe400db43 100644 --- a/game/graphics/pipelines/opengl.cpp +++ b/game/graphics/pipelines/opengl.cpp @@ -80,7 +80,7 @@ void SetDisplayCallbacks(GLFWwindow* d) { } void ErrorCallback(int err, const char* msg) { - lg::error("GLFW ERR {}: " + std::string(msg), err); + lg::error("GLFW ERR {}: {}", err, std::string(msg)); } bool HasError() { @@ -93,6 +93,10 @@ bool HasError() { } } +void FocusCallback(GLFWwindow* window, int focused) { + glfwSetWindowAttrib(window, GLFW_FLOATING, focused); +} + } // namespace static bool gl_inited = false; @@ -224,7 +228,7 @@ void make_gfx_dump() { compressed.data(), compressed.size()); } -void render_game_frame(int width, int height) { +void render_game_frame(int width, int height, int lbox_width, int lbox_height) { // wait for a copied chain. bool got_chain = false; { @@ -248,6 +252,8 @@ void render_game_frame(int width, int height) { RenderOptions options; options.window_height_px = height; options.window_width_px = width; + options.lbox_height_px = lbox_height; + options.lbox_width_px = lbox_width; options.draw_render_debug_window = g_gfx_data->debug_gui.should_draw_render_debug(); options.draw_profiler_window = g_gfx_data->debug_gui.should_draw_profiler(); options.playing_from_dump = false; @@ -271,7 +277,7 @@ void render_game_frame(int width, int height) { } } -void render_dump_frame(int width, int height) { +void render_dump_frame(int width, int height, int lbox_width, int lbox_height) { Timer deser_timer; if (g_gfx_data->debug_gui.want_dump_load()) { auto data = @@ -294,6 +300,8 @@ void render_dump_frame(int width, int height) { RenderOptions options; options.window_height_px = height; options.window_width_px = width; + options.lbox_height_px = lbox_height; + options.lbox_width_px = lbox_width; options.draw_render_debug_window = g_gfx_data->debug_gui.should_draw_render_debug(); options.draw_profiler_window = g_gfx_data->debug_gui.should_draw_profiler(); options.playing_from_dump = true; @@ -305,6 +313,63 @@ void render_dump_frame(int width, int height) { g_gfx_data->ogl_renderer.render(DmaFollower(chain.data.data(), chain.start_offset), options); } +static void gl_display_position(GfxDisplay* display, int* x, int* y) { + glfwGetWindowPos(display->window_glfw, x, y); +} + +static void gl_display_size(GfxDisplay* display, int* width, int* height) { + glfwGetFramebufferSize(display->window_glfw, width, height); +} + +static void gl_display_set_size(GfxDisplay* display, int width, int height) { + glfwSetWindowSize(display->window_glfw, width, height); +} + +static void gl_display_scale(GfxDisplay* display, float* xs, float* ys) { + glfwGetWindowContentScale(display->window_glfw, xs, ys); +} + +static void gl_set_fullscreen(GfxDisplay* display, int mode, int /*screen*/) { + GLFWmonitor* monitor = glfwGetPrimaryMonitor(); // todo + auto window = display->window_glfw; + switch (mode) { + case 0: { + // windowed + glfwSetWindowAttrib(window, GLFW_DECORATED, GLFW_TRUE); + glfwSetWindowFocusCallback(window, NULL); + glfwSetWindowAttrib(window, GLFW_FLOATING, GLFW_FALSE); + glfwSetWindowMonitor(window, NULL, display->xpos_backup(), display->ypos_backup(), + display->width_backup(), display->height_backup(), GLFW_DONT_CARE); + } break; + case 1: { + // fullscreen + if (display->fullscreen_mode() == 0) { + display->backup_params(); + } + const GLFWvidmode* vmode = glfwGetVideoMode(monitor); + glfwSetWindowMonitor(window, monitor, 0, 0, vmode->width, vmode->height, 60); + glfwSetWindowFocusCallback(window, FocusCallback); + } break; + case 2: { + // borderless fullscreen + if (display->fullscreen_mode() == 0) { + display->backup_params(); + } + int x, y; + glfwGetMonitorPos(monitor, &x, &y); + const GLFWvidmode* vmode = glfwGetVideoMode(monitor); + glfwSetWindowAttrib(window, GLFW_DECORATED, GLFW_FALSE); + glfwSetWindowAttrib(window, GLFW_FLOATING, GLFW_TRUE); + glfwSetWindowFocusCallback(window, FocusCallback); +#ifdef _WIN32 + glfwSetWindowMonitor(window, NULL, x, y - 1, vmode->width, vmode->height + 1, GLFW_DONT_CARE); +#else + glfwSetWindowMonitor(window, NULL, x, y, vmode->width, vmode->height, GLFW_DONT_CARE); +#endif + } break; + } +} + static void gl_render_display(GfxDisplay* display) { GLFWwindow* window = display->window_glfw; @@ -318,13 +383,23 @@ static void gl_render_display(GfxDisplay* display) { ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); - int width, height; - glfwGetFramebufferSize(window, &width, &height); + int width = Gfx::g_global_settings.lbox_w; + int height = Gfx::g_global_settings.lbox_h; + int fbuf_w, fbuf_h; + glfwGetFramebufferSize(window, &fbuf_w, &fbuf_h); +#ifdef _WIN32 + if (display->fullscreen_mode() == 2) { + // pretend the framebuffer is 1 pixel shorter on borderless. fullscreen issues! + fbuf_h--; + } +#endif + int lbox_w = (fbuf_w - width) / 2; + int lbox_h = (fbuf_h - height) / 2; if (g_gfx_data->debug_gui.want_dump_replay()) { - render_dump_frame(width, height); + render_dump_frame(width, height, lbox_w, lbox_h); } else if (g_gfx_data->debug_gui.should_advance_frame()) { - render_game_frame(width, height); + render_game_frame(width, height, lbox_w, lbox_h); } // render imgui @@ -337,6 +412,10 @@ static void gl_render_display(GfxDisplay* display) { glfwSwapBuffers(window); g_gfx_data->debug_gui.start_frame(); + if (display->fullscreen_pending()) { + display->fullscreen_flush(); + } + // toggle even odd and wake up engine waiting on vsync. if (!g_gfx_data->debug_gui.want_dump_replay()) { std::unique_lock lock(g_gfx_data->sync_mutex); @@ -438,6 +517,11 @@ const GfxRendererModule moduleOpenGL = { gl_make_main_display, // make_main_display gl_kill_display, // kill_display gl_render_display, // render_display + gl_display_position, // display_position + gl_display_size, // display_size + gl_display_set_size, // display_set_size + gl_display_scale, // display_scale + gl_set_fullscreen, // set_fullscreen gl_exit, // exit gl_vsync, // vsync gl_sync_path, // sync_path @@ -446,5 +530,5 @@ const GfxRendererModule moduleOpenGL = { gl_texture_relocate, // texture_relocate gl_poll_events, // poll_events GfxPipeline::OpenGL, // pipeline - "OpenGL 3.3" // name + "OpenGL 4.3" // name }; diff --git a/game/kernel/kmachine.cpp b/game/kernel/kmachine.cpp index 34a0283c50..36108d5159 100644 --- a/game/kernel/kmachine.cpp +++ b/game/kernel/kmachine.cpp @@ -718,6 +718,42 @@ void c_memmove(u32 dst, u32 src, u32 size) { memmove(Ptr(dst).c(), Ptr(src).c(), size); } +/*! + * PC Port function to return the current OS as a symbol. + */ +u64 get_os() { +#ifdef _WIN32 + return intern_from_c("windows").offset; +#elif __linux__ + return intern_from_c("linux").offset; +#else + return s7.offset; +#endif +} + +/*! + * PC Port function + */ +void get_window_size(u32 w_ptr, u32 h_ptr) { + if (w_ptr) { + auto w = Ptr(w_ptr).c(); + *w = Gfx::get_window_width(); + } + if (h_ptr) { + auto h = Ptr(h_ptr).c(); + *h = Gfx::get_window_height(); + } +} + +/*! + * PC Port function + */ +void get_window_scale(u32 x_ptr, u32 y_ptr) { + float* x = x_ptr ? Ptr(x_ptr).c() : NULL; + float* y = y_ptr ? Ptr(y_ptr).c() : NULL; + Gfx::get_window_scale(x, y); +} + void InitMachine_PCPort() { // PC Port added functions make_function_symbol_from_c("__read-ee-timer", (void*)read_ee_timer); @@ -736,6 +772,14 @@ void InitMachine_PCPort() { make_function_symbol_from_c("pc-pad-input-key-get", (void*)Pad::input_mode_get_key); make_function_symbol_from_c("pc-pad-input-index-get", (void*)Pad::input_mode_get_index); + // os stuff + make_function_symbol_from_c("pc-get-os", (void*)get_os); + make_function_symbol_from_c("pc-get-window-size", (void*)get_window_size); + make_function_symbol_from_c("pc-get-window-scale", (void*)get_window_scale); + make_function_symbol_from_c("pc-set-window-size", (void*)Gfx::set_window_size); + make_function_symbol_from_c("pc-set-letterbox", (void*)Gfx::set_letterbox); + make_function_symbol_from_c("pc-set-fullscreen", (void*)Gfx::set_fullscreen); + // init ps2 VM if (VM::use) { make_function_symbol_from_c("vm-ptr", (void*)VM::get_vm_ptr); @@ -826,7 +870,7 @@ void InitMachineScheme() { new_pair(s7.offset + FIX_SYM_GLOBAL_HEAP, *((s7 + FIX_SYM_PAIR_TYPE).cast()), make_string_from_c("common"), kernel_packages->value); - lg::info("calling fake play~"); + lg::info("calling fake play"); call_goal_function_by_name("play"); } } diff --git a/game/sce/sif_ee.cpp b/game/sce/sif_ee.cpp index b1df933e3e..fd2f056043 100644 --- a/game/sce/sif_ee.cpp +++ b/game/sce/sif_ee.cpp @@ -99,25 +99,20 @@ s32 sceSifBindRpc(sceSifClientData* bd, u32 request, u32 mode) { s32 sceOpen(const char* filename, s32 flag) { FILE* fp = nullptr; + auto name = file_util::get_file_path({filename}); switch (flag) { case SCE_RDONLY: { - auto name = file_util::get_file_path({filename}); - fp = fopen(name.c_str(), "r"); - if (!fp) { - printf("[SCE] sceOpen(%s) failed.\n", name.c_str()); - return -1; - } + fp = fopen(name.c_str(), "rb"); } break; default: { - auto name = file_util::get_file_path({"debug_out", filename}); fp = fopen(name.c_str(), "w"); - if (!fp) { - printf("[SCE] sceOpen(%s) failed.\n", name.c_str()); - return -1; - } } break; } + if (!fp) { + printf("[SCE] sceOpen(%s) failed.\n", name.c_str()); + return -1; + } s32 fp_idx = sce_fds.size() + 1; sce_fds[fp_idx] = fp; @@ -182,4 +177,4 @@ s32 sceLseek(s32 fd, s32 offset, s32 where) { } } -} // namespace ee \ No newline at end of file +} // namespace ee diff --git a/game/system/Deci2Server.h b/game/system/Deci2Server.h index 1bd164ffe6..5f11188057 100644 --- a/game/system/Deci2Server.h +++ b/game/system/Deci2Server.h @@ -6,9 +6,6 @@ * Works with deci2.cpp (sceDeci2) to implement the networking on target */ -#ifndef JAK1_DECI2SERVER_H -#define JAK1_DECI2SERVER_H - #ifdef __linux #include #elif _WIN32 @@ -56,5 +53,3 @@ class Deci2Server { Deci2Driver* d2_drivers = nullptr; int* d2_driver_count = nullptr; }; - -#endif // JAK1_DECI2SERVER_H diff --git a/game/system/newpad.cpp b/game/system/newpad.cpp index 50f3f5d248..263fe7ec90 100644 --- a/game/system/newpad.cpp +++ b/game/system/newpad.cpp @@ -124,7 +124,7 @@ int AnalogValue(MappingInfo& /*mapping*/, Analog analog, int pad = 0) { return 127; } // TODO - dead-zone support needed? - return (g_gamepad_analogs[(int)analog] * 127) + 127; + return int((g_gamepad_analogs[(int)analog] + 1) * 127); // TODO - support keyboard inputs as well } diff --git a/goal_src/build/all_files.gc b/goal_src/build/all_files.gc index e9a9a4b8cb..45861e74a9 100644 --- a/goal_src/build/all_files.gc +++ b/goal_src/build/all_files.gc @@ -42,6 +42,7 @@ "goal_src/engine/dma/dma-buffer.gc" "goal_src/engine/dma/dma-bucket.gc" "goal_src/engine/dma/dma-disasm.gc" + "goal_src/engine/pc/pckernel-h.gc" ;; added "goal_src/engine/ps2/pad.gc" "goal_src/engine/gfx/hw/gs.gc" "goal_src/engine/gfx/hw/display-h.gc" @@ -260,6 +261,7 @@ "goal_src/engine/gfx/tie/prototype.gc" "goal_src/engine/collide/main-collide.gc" "goal_src/engine/game/video.gc" + "goal_src/engine/pc/pckernel.gc" ;; added "goal_src/engine/game/main.gc" "goal_src/engine/collide/collide-cache.gc" "goal_src/engine/entity/relocate.gc" diff --git a/goal_src/build/game_dgos.gc b/goal_src/build/game_dgos.gc index 40d4cb3398..c0382731c5 100644 --- a/goal_src/build/game_dgos.gc +++ b/goal_src/build/game_dgos.gc @@ -243,6 +243,7 @@ ("dma-buffer.o" "dma-buffer") ("dma-bucket.o" "dma-bucket") ("dma-disasm.o" "dma-disasm") + ("pckernel-h.o" "pckernel-h") ;; added ("pad.o" "pad") ("gs.o" "gs") ("display-h.o" "display-h") @@ -461,6 +462,7 @@ ("prototype.o" "prototype") ("main-collide.o" "main-collide") ("video.o" "video") + ("pckernel.o" "pckernel") ;; added ("main.o" "main") ("collide-cache.o" "collide-cache") ("relocate.o" "relocate") @@ -603,6 +605,7 @@ ("dma-buffer.o" "dma-buffer") ("dma-bucket.o" "dma-bucket") ("dma-disasm.o" "dma-disasm") + ("pckernel-h.o" "pckernel-h") ;; added ("pad.o" "pad") ("gs.o" "gs") ("display-h.o" "display-h") @@ -821,6 +824,7 @@ ("prototype.o" "prototype") ("main-collide.o" "main-collide") ("video.o" "video") + ("pckernel.o" "pckernel") ;; added ("main.o" "main") ("collide-cache.o" "collide-cache") ("relocate.o" "relocate") diff --git a/goal_src/dgos/engine.gd b/goal_src/dgos/engine.gd index 44d32faccd..4d43dc2c63 100644 --- a/goal_src/dgos/engine.gd +++ b/goal_src/dgos/engine.gd @@ -34,6 +34,7 @@ ("dma-buffer.o" "dma-buffer") ("dma-bucket.o" "dma-bucket") ("dma-disasm.o" "dma-disasm") + ("pckernel-h.o" "pckernel-h") ;; added ("pad.o" "pad") ("gs.o" "gs") ("display-h.o" "display-h") @@ -252,6 +253,7 @@ ("prototype.o" "prototype") ("main-collide.o" "main-collide") ("video.o" "video") + ("pckernel.o" "pckernel") ;; added ("main.o" "main") ("collide-cache.o" "collide-cache") ("relocate.o" "relocate") diff --git a/goal_src/dgos/game.gd b/goal_src/dgos/game.gd index 331d940774..cd7445c47e 100644 --- a/goal_src/dgos/game.gd +++ b/goal_src/dgos/game.gd @@ -30,6 +30,7 @@ ("dma-buffer.o" "dma-buffer") ("dma-bucket.o" "dma-bucket") ("dma-disasm.o" "dma-disasm") + ("pckernel-h.o" "pckernel-h") ;; added ("pad.o" "pad") ("gs.o" "gs") ("display-h.o" "display-h") @@ -248,6 +249,7 @@ ("prototype.o" "prototype") ("main-collide.o" "main-collide") ("video.o" "video") + ("pckernel.o" "pckernel") ;; added ("main.o" "main") ("collide-cache.o" "collide-cache") ("relocate.o" "relocate") diff --git a/goal_src/dgos/jub.gd b/goal_src/dgos/jub.gd new file mode 100644 index 0000000000..93a12ce281 --- /dev/null +++ b/goal_src/dgos/jub.gd @@ -0,0 +1,21 @@ + +("JUB.DGO" + ("jungleb-obs.o" "jungleb-obs") + ("plat-flip.o" "plat-flip") + ("plant-boss-main+0-ag.go" "plant-boss-main+0") + ("aphid.o" "aphid") + ("plant-boss.o" "plant-boss") + ("tpage-485.go" "tpage-485") + ("tpage-510.go" "tpage-510") + ("tpage-507.go" "tpage-507") + ("tpage-966.go" "tpage-966") + ("aphid-lurker-ag.go" "aphid-lurker") + ("darkvine-ag-JUB.go" "darkvine") + ("ecovalve-ag-JUB-JUN.go" "ecovalve") + ("eggtop-ag.go" "eggtop") + ("jng-iris-door-ag-JUB.go" "jng-iris-door") + ("plant-boss-ag.go" "plant-boss") + ("plat-flip-ag.go" "plat-flip") + ("plat-jungleb-ag.go" "plat-jungleb") + ("jungleb-vis.go" "jungleb-vis") + ) \ No newline at end of file diff --git a/goal_src/dgos/lav.gd b/goal_src/dgos/lav.gd new file mode 100644 index 0000000000..1d0bf5b546 --- /dev/null +++ b/goal_src/dgos/lav.gd @@ -0,0 +1,40 @@ + +("LAV.DGO" + ("target-racer-h-FIC-LAV-MIS-OGR-ROL.o" "target-racer-h") + ("racer-part.o" "racer-part") + ("racer.o" "racer") + ("target-racer-FIC-LAV-MIS-OGR-ROL.o" "target-racer") + ("racer-states-FIC-LAV-MIS-OGR-ROL.o" "racer-states") + ("collide-reaction-racer.o" "collide-reaction-racer") + ("eichar-racer+0-ag.go" "eichar-racer+0") + ("tpage-1119.go" "tpage-1119") + ("blocking-plane.o" "blocking-plane") + ("lavatube-obs.o" "lavatube-obs") + ("lavatube-energy.o" "lavatube-energy") + ("lavatube-part.o" "lavatube-part") + ("assistant-lavatube.o" "assistant-lavatube") + ("tpage-1338.go" "tpage-1338") + ("tpage-1340.go" "tpage-1340") + ("tpage-1339.go" "tpage-1339") + ("tpage-1337.go" "tpage-1337") + ("assistant-lavatube-start-ag.go" "assistant-lavatube-start") + ("chainmine-ag.go" "chainmine") + ("darkecobarrel-ag.go" "darkecobarrel") + ("ecovalve-ag-LAV.go" "ecovalve") + ("ef-plane-ag-FIC-LAV-OGR-ROL-SNO-SWA.go" "ef-plane") + ("energyarm-ag.go" "energyarm") + ("energyball-ag.go" "energyball") + ("energybase-ag.go" "energybase") + ("energydoor-ag.go" "energydoor") + ("energyhub-ag.go" "energyhub") + ("lavaballoon-ag.go" "lavaballoon") + ("lavabase-ag.go" "lavabase") + ("lavafall-ag.go" "lavafall") + ("lavafallsewera-ag.go" "lavafallsewera") + ("lavafallsewerb-ag.go" "lavafallsewerb") + ("lavashortcut-ag.go" "lavashortcut") + ("lavayellowtarp-ag.go" "lavayellowtarp") + ("racer-ag-LAV.go" "racer") + ("water-anim-lavatube-ag.go" "water-anim-lavatube") + ("lavatube-vis.go" "lavatube-vis") + ) \ No newline at end of file diff --git a/goal_src/dgos/ogr.gd b/goal_src/dgos/ogr.gd new file mode 100644 index 0000000000..c078934303 --- /dev/null +++ b/goal_src/dgos/ogr.gd @@ -0,0 +1,38 @@ + +("OGR.DGO" + ("target-racer-h-FIC-LAV-MIS-OGR-ROL.o" "target-racer-h") + ("racer-part.o" "racer-part") + ("racer.o" "racer") + ("target-racer-FIC-LAV-MIS-OGR-ROL.o" "target-racer") + ("racer-states-FIC-LAV-MIS-OGR-ROL.o" "racer-states") + ("collide-reaction-racer.o" "collide-reaction-racer") + ("eichar-racer+0-ag.go" "eichar-racer+0") + ("tpage-1119.go" "tpage-1119") + ("blocking-plane.o" "blocking-plane") + ("firecanyon-obs.o" "firecanyon-obs") + ("ogre-part.o" "ogre-part") + ("ogreboss.o" "ogreboss") + ("ogre-obs.o" "ogre-obs") + ("flying-lurker.o" "flying-lurker") + ("tpage-875.go" "tpage-875") + ("tpage-967.go" "tpage-967") + ("tpage-884.go" "tpage-884") + ("tpage-1117.go" "tpage-1117") + ("crate-darkeco-cluster-ag-OGR.go" "crate-darkeco-cluster") + ("ecovalve-ag-FIC-OGR.go" "ecovalve") + ("ef-plane-ag-FIC-LAV-OGR-ROL-SNO-SWA.go" "ef-plane") + ("flying-lurker-ag.go" "flying-lurker") + ("medres-snow-ag.go" "medres-snow") + ("ogre-bridge-ag.go" "ogre-bridge") + ("ogre-bridgeend-ag.go" "ogre-bridgeend") + ("ogre-isle-ag.go" "ogre-isle") + ("ogre-step-ag.go" "ogre-step") + ("ogreboss-ag.go" "ogreboss") + ("ogrecam-ag.go" "ogrecam") + ("plunger-lurker-ag.go" "plunger-lurker") + ("racer-ag-OGR.go" "racer") + ("shortcut-boulder-ag.go" "shortcut-boulder") + ("tntbarrel-ag.go" "tntbarrel") + ("water-anim-ogre-ag.go" "water-anim-ogre") + ("ogre-vis.go" "ogre-vis") + ) \ No newline at end of file diff --git a/goal_src/dgos/rol.gd b/goal_src/dgos/rol.gd new file mode 100644 index 0000000000..ac41957e71 --- /dev/null +++ b/goal_src/dgos/rol.gd @@ -0,0 +1,35 @@ + +("ROL.DGO" + ("target-racer-h-FIC-LAV-MIS-OGR-ROL.o" "target-racer-h") + ("racer-part.o" "racer-part") + ("racer.o" "racer") + ("target-racer-FIC-LAV-MIS-OGR-ROL.o" "target-racer") + ("racer-states-FIC-LAV-MIS-OGR-ROL.o" "racer-states") + ("collide-reaction-racer.o" "collide-reaction-racer") + ("eichar-racer+0-ag.go" "eichar-racer+0") + ("tpage-1119.go" "tpage-1119") + ("blocking-plane.o" "blocking-plane") + ("rolling-obs.o" "rolling-obs") + ("rolling-lightning-mole.o" "rolling-lightning-mole") + ("rolling-robber.o" "rolling-robber") + ("rolling-race-ring.o" "rolling-race-ring") + ("tpage-923.go" "tpage-923") + ("tpage-926.go" "tpage-926") + ("tpage-924.go" "tpage-924") + ("tpage-925.go" "tpage-925") + ("tpage-1353.go" "tpage-1353") + ("babak-ag.go" "babak") + ("dark-plant-ag.go" "dark-plant") + ("ecovalve-ag-ROL.go" "ecovalve") + ("ef-plane-ag-FIC-LAV-OGR-ROL-SNO-SWA.go" "ef-plane") + ("happy-plant-ag.go" "happy-plant") + ("lightning-mole-ag.go" "lightning-mole") + ("pusher-ag.go" "pusher") + ("race-ring-ag.go" "race-ring") + ("racer-ag-FIC-ROL.go" "racer") + ("robber-ag.go" "robber") + ("rolling-start-ag.go" "rolling-start") + ("rollingcam-ag.go" "rollingcam") + ("water-anim-rolling-ag.go" "water-anim-rolling") + ("rolling-vis.go" "rolling-vis") + ) \ No newline at end of file diff --git a/goal_src/dgos/sno.gd b/goal_src/dgos/sno.gd new file mode 100644 index 0000000000..058d423f0a --- /dev/null +++ b/goal_src/dgos/sno.gd @@ -0,0 +1,54 @@ + +("SNO.DGO" + ("blocking-plane.o" "blocking-plane") + ("flut-part.o" "flut-part") + ("flutflut.o" "flutflut") + ("target-flut.o" "target-flut") + ("eichar-flut+0-ag.go" "eichar-flut+0") + ("target-snowball.o" "target-snowball") + ("target-ice.o" "target-ice") + ("ice-cube.o" "ice-cube") + ("snow-ball.o" "snow-ball") + ("snow-obs.o" "snow-obs") + ("snow-flutflut-obs.o" "snow-flutflut-obs") + ("snow-bumper.o" "snow-bumper") + ("snow-ram-h.o" "snow-ram-h") + ("snow-ram-boss.o" "snow-ram-boss") + ("snow-ram.o" "snow-ram") + ("snow-part.o" "snow-part") + ("yeti.o" "yeti") + ("eichar-pole+0-ag-SNO.go" "eichar-pole+0") + ("eichar-ice+0-ag.go" "eichar-ice+0") + ("snow-bunny.o" "snow-bunny") + ("tpage-710.go" "tpage-710") + ("tpage-842.go" "tpage-842") + ("tpage-711.go" "tpage-711") + ("tpage-712.go" "tpage-712") + ("babak-ag.go" "babak") + ("ecovalve-ag-SNO.go" "ecovalve") + ("ef-plane-ag-FIC-LAV-OGR-ROL-SNO-SWA.go" "ef-plane") + ("flut-saddle-ag-SNO.go" "flut-saddle") + ("flutflut-plat-large-ag.go" "flutflut-plat-large") + ("flutflut-plat-med-ag.go" "flutflut-plat-med") + ("flutflut-plat-small-ag.go" "flutflut-plat-small") + ("ice-cube-ag.go" "ice-cube") + ("ice-cube-break-ag.go" "ice-cube-break") + ("orb-cache-top-ag-SNO.go" "orb-cache-top") + ("ram-ag.go" "ram") + ("ram-boss-ag.go" "ram-boss") + ("snow-ball-ag.go" "snow-ball") + ("snow-bridge-36-ag.go" "snow-bridge-36") + ("snow-bumper-ag.go" "snow-bumper") + ("snow-bunny-ag.go" "snow-bunny") + ("snow-button-ag.go" "snow-button") + ("snow-eggtop-ag.go" "snow-eggtop") + ("snow-fort-gate-ag.go" "snow-fort-gate") + ("snow-gears-ag.go" "snow-gears") + ("snow-log-ag.go" "snow-log") + ("snow-spatula-ag.go" "snow-spatula") + ("snow-switch-ag.go" "snow-switch") + ("snowcam-ag.go" "snowcam") + ("snowpusher-ag.go" "snowpusher") + ("yeti-ag.go" "yeti") + ("snow-vis.go" "snow-vis") + ) \ No newline at end of file diff --git a/goal_src/dgos/sub.gd b/goal_src/dgos/sub.gd new file mode 100644 index 0000000000..a3fd766907 --- /dev/null +++ b/goal_src/dgos/sub.gd @@ -0,0 +1,24 @@ + +("SUB.DGO" + ("tpage-163.go" "tpage-163") + ("tpage-164.go" "tpage-164") + ("tpage-166.go" "tpage-166") + ("tpage-162.go" "tpage-162") + ("tpage-764.go" "tpage-764") + ("babak-ag.go" "babak") + ("blue-eco-charger-ag.go" "blue-eco-charger") + ("blue-eco-charger-orb-ag.go" "blue-eco-charger-orb") + ("bully-ag.go" "bully") + ("ecovalve-ag-SUB.go" "ecovalve") + ("floating-launcher-ag.go" "floating-launcher") + ("helix-button-ag.go" "helix-button") + ("helix-slide-door-ag.go" "helix-slide-door") + ("shover-ag-SUB.go" "shover") + ("steam-cap-ag-SUB.go" "steam-cap") + ("sunkencam-ag-SUB.go" "sunkencam") + ("sunkenfisha-ag.go" "sunkenfisha") + ("wall-plat-ag.go" "wall-plat") + ("water-anim-sunken-ag.go" "water-anim-sunken") + ("water-anim-sunken-dark-eco-ag.go" "water-anim-sunken-dark-eco") + ("sunkenb-vis.go" "sunkenb-vis") + ) \ No newline at end of file diff --git a/goal_src/dgos/swa.gd b/goal_src/dgos/swa.gd new file mode 100644 index 0000000000..dd11fceaca --- /dev/null +++ b/goal_src/dgos/swa.gd @@ -0,0 +1,39 @@ + +("SWA.DGO" + ("battlecontroller.o" "battlecontroller") + ("blocking-plane.o" "blocking-plane") + ("flut-part.o" "flut-part") + ("flutflut.o" "flutflut") + ("target-flut.o" "target-flut") + ("eichar-flut+0-ag.go" "eichar-flut+0") + ("swamp-obs.o" "swamp-obs") + ("swamp-bat.o" "swamp-bat") + ("swamp-rat.o" "swamp-rat") + ("swamp-rat-nest.o" "swamp-rat-nest") + ("kermit.o" "kermit") + ("swamp-part.o" "swamp-part") + ("billy.o" "billy") + ("eichar-pole+0-ag-SWA.go" "eichar-pole+0") + ("tpage-358.go" "tpage-358") + ("tpage-659.go" "tpage-659") + ("tpage-629.go" "tpage-629") + ("tpage-630.go" "tpage-630") + ("babak-ag.go" "babak") + ("balance-plat-ag.go" "balance-plat") + ("billy-ag.go" "billy") + ("billy-sidekick-ag.go" "billy-sidekick") + ("ecovalve-ag-SWA.go" "ecovalve") + ("ef-plane-ag-FIC-LAV-OGR-ROL-SNO-SWA.go" "ef-plane") + ("farthy-snack-ag.go" "farthy-snack") + ("flut-saddle-ag-SWA.go" "flut-saddle") + ("kermit-ag.go" "kermit") + ("sharkey-ag-SWA.go" "sharkey") + ("swamp-bat-ag.go" "swamp-bat") + ("swamp-rat-ag.go" "swamp-rat") + ("swamp-rat-nest-ag.go" "swamp-rat-nest") + ("swamp-rock-ag.go" "swamp-rock") + ("swamp-spike-ag.go" "swamp-spike") + ("swampcam-ag-SWA.go" "swampcam") + ("tar-plat-ag.go" "tar-plat") + ("swamp-vis.go" "swamp-vis") + ) \ No newline at end of file diff --git a/goal_src/engine/camera/cam-update.gc b/goal_src/engine/camera/cam-update.gc index 984d53fa84..436eba96d3 100644 --- a/goal_src/engine/camera/cam-update.gc +++ b/goal_src/engine/camera/cam-update.gc @@ -11,17 +11,15 @@ (defun plane-from-points ((arg0 (inline-array plane)) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 int)) "Get a plane that contains the 3 given points." (let ((s4-0 (new 'stack-no-clear 'vector))) - (vector-cross! s4-0 arg1 arg2) - (vector-normalize! s4-0 1.0) - (set! (-> s4-0 w) (vector-dot s4-0 arg3)) - (set! (-> (&-> arg0 0 data arg4) 0) (-> s4-0 x)) - (set! (-> (&-> arg0 0 data arg4) 4) (-> s4-0 y)) - (set! (-> (&-> arg0 0 data arg4) 8) (-> s4-0 z)) - (let ((f0-5 (-> s4-0 w))) - (set! (-> (&-> arg0 0 data arg4) 12) f0-5) - f0-5 + (vector-cross! s4-0 arg1 arg2) + (vector-normalize! s4-0 1.0) + (set! (-> s4-0 w) (vector-dot s4-0 arg3)) + (set! (-> (&-> arg0 0 data arg4) 0) (-> s4-0 x)) + (set! (-> (&-> arg0 0 data arg4) 4) (-> s4-0 y)) + (set! (-> (&-> arg0 0 data arg4) 8) (-> s4-0 z)) + (set! (-> (&-> arg0 0 data arg4) 12) (-> s4-0 w)) ) - ) + (none) ) (defun set-point ((arg0 vector) (arg1 float) (arg2 float) (arg3 float)) @@ -29,97 +27,64 @@ (set! (-> arg0 x) arg1) (set! (-> arg0 y) arg2) (set! (-> arg0 z) arg3) - (let ((f0-3 1.0)) - (set! (-> arg0 w) f0-3) - f0-3 - ) + (set! (-> arg0 w) 1.0) + (none) ) (defun update-view-planes ((arg0 math-camera) (arg1 (inline-array plane)) (arg2 float)) "Compute the frustum planes from the given camera." (local-vars (sv-240 vector)) (when (not *artist-fix-frustum*) - (let ((s5-0 (new 'stack 'view-frustum))) - (let ((f30-0 (* (* arg2 (-> arg0 x-ratio)) (-> arg0 d))) - (f26-0 (* (* arg2 (-> arg0 y-ratio)) (-> arg0 d))) - (f28-0 (* (* arg2 (-> arg0 x-ratio)) (-> arg0 f))) - (f24-0 (* (* arg2 (-> arg0 y-ratio)) (-> arg0 f))) + (let ((s5-0 (new 'stack 'view-frustum))) + (let ((f30-0 (* arg2 (-> arg0 x-ratio) (-> arg0 d))) + (f26-0 (* arg2 (-> arg0 y-ratio) (-> arg0 d))) + (f28-0 (* arg2 (-> arg0 x-ratio) (-> arg0 f))) + (f24-0 (* arg2 (-> arg0 y-ratio) (-> arg0 f))) + ) + (set-point (-> s5-0 hither-top-left) (- f30-0) f26-0 (-> arg0 d)) + (set-point (-> s5-0 hither-top-right) f30-0 f26-0 (-> arg0 d)) + (set-point (-> s5-0 hither-bottom-left) (- f30-0) (- f26-0) (-> arg0 d)) + (set-point (-> s5-0 hither-bottom-right) f30-0 (- f26-0) (-> arg0 d)) + (set-point (-> s5-0 yon-top-left) (- f28-0) f24-0 (-> arg0 f)) + (set-point (-> s5-0 yon-top-right) f28-0 f24-0 (-> arg0 f)) + (set-point (-> s5-0 yon-bottom-left) (- f28-0) (- f24-0) (-> arg0 f)) + (set-point (-> s5-0 yon-bottom-right) f28-0 (- f24-0) (-> arg0 f)) + ) + (vector-matrix*! (-> s5-0 hither-top-left) (-> s5-0 hither-top-left) (-> arg0 inv-camera-rot)) + (vector-matrix*! (-> s5-0 hither-top-right) (-> s5-0 hither-top-right) (-> arg0 inv-camera-rot)) + (vector-matrix*! (-> s5-0 hither-bottom-left) (-> s5-0 hither-bottom-left) (-> arg0 inv-camera-rot)) + (vector-matrix*! (-> s5-0 hither-bottom-right) (-> s5-0 hither-bottom-right) (-> arg0 inv-camera-rot)) + (vector-matrix*! (-> s5-0 yon-top-left) (-> s5-0 yon-top-left) (-> arg0 inv-camera-rot)) + (vector-matrix*! (-> s5-0 yon-top-right) (-> s5-0 yon-top-right) (-> arg0 inv-camera-rot)) + (vector-matrix*! (-> s5-0 yon-bottom-left) (-> s5-0 yon-bottom-left) (-> arg0 inv-camera-rot)) + (vector-matrix*! (-> s5-0 yon-bottom-right) (-> s5-0 yon-bottom-right) (-> arg0 inv-camera-rot)) + (let ((s2-0 (new-stack-vector0)) + (s3-1 (new-stack-vector0)) + (s1-0 (new-stack-vector0)) + (s0-0 (new-stack-vector0)) + ) + (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) + (set! sv-240 (new 'stack-no-clear 'vector)) + (set! (-> sv-240 quad) (the-as uint128 0)) + (let ((v1-5 (-> arg0 inv-camera-rot vector 3 quad))) + (set! (-> sv-240 quad) v1-5) ) - (set-point (-> s5-0 hither-top-left) (- f30-0) f26-0 (-> arg0 d)) - (set-point (-> s5-0 hither-top-right) f30-0 f26-0 (-> arg0 d)) - (set-point (-> s5-0 hither-bottom-left) (- f30-0) (- f26-0) (-> arg0 d)) - (set-point (-> s5-0 hither-bottom-right) f30-0 (- f26-0) (-> arg0 d)) - (set-point (-> s5-0 yon-top-left) (- f28-0) f24-0 (-> arg0 f)) - (set-point (-> s5-0 yon-top-right) f28-0 f24-0 (-> arg0 f)) - (set-point (-> s5-0 yon-bottom-left) (- f28-0) (- f24-0) (-> arg0 f)) - (set-point (-> s5-0 yon-bottom-right) f28-0 (- f24-0) (-> arg0 f)) - ) - (vector-matrix*! - (-> s5-0 hither-top-left) - (-> s5-0 hither-top-left) - (-> arg0 inv-camera-rot) - ) - (vector-matrix*! - (-> s5-0 hither-top-right) - (-> s5-0 hither-top-right) - (-> arg0 inv-camera-rot) - ) - (vector-matrix*! - (-> s5-0 hither-bottom-left) - (-> s5-0 hither-bottom-left) - (-> arg0 inv-camera-rot) - ) - (vector-matrix*! - (-> s5-0 hither-bottom-right) - (-> s5-0 hither-bottom-right) - (-> arg0 inv-camera-rot) - ) - (vector-matrix*! - (-> s5-0 yon-top-left) - (-> s5-0 yon-top-left) - (-> arg0 inv-camera-rot) - ) - (vector-matrix*! - (-> s5-0 yon-top-right) - (-> s5-0 yon-top-right) - (-> arg0 inv-camera-rot) - ) - (vector-matrix*! - (-> s5-0 yon-bottom-left) - (-> s5-0 yon-bottom-left) - (-> arg0 inv-camera-rot) - ) - (vector-matrix*! - (-> s5-0 yon-bottom-right) - (-> s5-0 yon-bottom-right) - (-> arg0 inv-camera-rot) - ) - (let ((s2-0 (new-stack-vector0)) - (s3-1 (new-stack-vector0)) - (s1-0 (new-stack-vector0)) - (s0-0 (new-stack-vector0)) + (vector-! s2-0 (-> s5-0 yon-top-left) sv-240) + (vector-! s3-1 (-> s5-0 yon-top-right) sv-240) + (vector-! s1-0 (-> s5-0 yon-bottom-left) sv-240) + (vector-! s0-0 (-> s5-0 yon-bottom-right) sv-240) + (plane-from-points arg1 s2-0 s1-0 sv-240 0) + (plane-from-points arg1 s0-0 s3-1 sv-240 1) + (plane-from-points arg1 s3-1 s2-0 sv-240 2) + (let ((t9-20 plane-from-points) + (t0-3 3) + ) + (t9-20 arg1 s1-0 s0-0 sv-240 t0-3) ) - (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) - (set! sv-240 (new 'stack-no-clear 'vector)) - (set! (-> sv-240 quad) (the-as uint128 0)) - (let ((v1-5 (-> arg0 inv-camera-rot vector 3 quad))) - (set! (-> sv-240 quad) v1-5) + ) ) - (vector-! s2-0 (-> s5-0 yon-top-left) sv-240) - (vector-! s3-1 (-> s5-0 yon-top-right) sv-240) - (vector-! s1-0 (-> s5-0 yon-bottom-left) sv-240) - (vector-! s0-0 (-> s5-0 yon-bottom-right) sv-240) - (plane-from-points arg1 s2-0 s1-0 sv-240 0) - (plane-from-points arg1 s0-0 s3-1 sv-240 1) - (plane-from-points arg1 s3-1 s2-0 sv-240 2) - (let ((t9-20 plane-from-points) - (t0-3 3) - ) - (t9-20 arg1 s1-0 s0-0 sv-240 t0-3) - ) - ) ) - ) + (none) ) ;; if we should still attempt vis updates when outside of the bsp's boxes. @@ -262,51 +227,40 @@ ) ) -;; definition for symbol *save-camera-inv-rot*, type matrix (define *save-camera-inv-rot* (new 'global 'matrix)) -;; failed to figure out what this is: (matrix-identity! *save-camera-inv-rot*) -;; definition for function move-camera-from-pad -;; Used lq/sq (defun move-camera-from-pad ((arg0 math-camera)) (let ((v1-0 *external-cam-mode*) (s5-0 0) ) - (cond - ((= v1-0 'locked) - (set! v1-0 #f) - ) - ((= v1-0 'pad-1) - (set! s5-0 1) - ) - ((not *camera-combiner*) - (set! v1-0 'pad-0) - ) - ) - (when v1-0 - (let - ((s4-1 - (vector-negate-in-place! - (vector-normalize-copy! - (new-stack-vector0) - (-> *standard-dynamics* gravity) - 1.0 - ) - ) + (cond + ((= v1-0 'locked) + (set! v1-0 #f) + ) + ((= v1-0 'pad-1) + (set! s5-0 1) + ) + ((not *camera-combiner*) + (set! v1-0 'pad-0) ) ) - (if (= (vector-length s4-1) 0.0) - (set! (-> s4-1 y) -1.0) + (when v1-0 + (let ((s4-1 + (vector-negate-in-place! (vector-normalize-copy! (new-stack-vector0) (-> *standard-dynamics* gravity) 1.0)) + ) + ) + (if (= (vector-length s4-1) 0.0) + (set! (-> s4-1 y) -1.0) + ) + (if (logtest? *external-cam-options* (external-cam-option allow-z)) + (set! s4-1 (the-as vector #f)) + ) + (cam-free-floating-move *save-camera-inv-rot* (-> arg0 trans) s4-1 s5-0) + ) ) - (if (logtest? *external-cam-options* 1) - (set! s4-1 (the-as vector #f)) - ) - (cam-free-floating-move *save-camera-inv-rot* (-> arg0 trans) s4-1 s5-0) - ) ) - ) (let* ((a2-2 (-> *math-camera* inv-camera-rot)) (a3-1 *save-camera-inv-rot*) (v1-11 (-> a3-1 vector 0 quad)) @@ -314,362 +268,301 @@ (a1-2 (-> a3-1 vector 2 quad)) (a3-2 (-> a3-1 vector 3 quad)) ) - (set! (-> a2-2 vector 0 quad) v1-11) - (set! (-> a2-2 vector 1 quad) a0-14) - (set! (-> a2-2 vector 2 quad) a1-2) - (set! (-> a2-2 vector 3 quad) a3-2) - ) + (set! (-> a2-2 vector 0 quad) v1-11) + (set! (-> a2-2 vector 1 quad) a0-14) + (set! (-> a2-2 vector 2 quad) a1-2) + (set! (-> a2-2 vector 3 quad) a3-2) + ) arg0 ) -;; definition for symbol *start-timer*, type int (define *start-timer* (the-as int #f)) -;; definition for symbol *timer-value*, type int (define *timer-value* 0) -;; definition for symbol *start-pos*, type vector (define *start-pos* (new 'global 'vector)) -;; definition for function update-camera -;; Used lq/sq (defun update-camera () (when *start-timer* - (when (= *timer-value* 180) - (format - #t - "Player pos = ~F ~F ~F~%" - (-> *target* control trans x) - (-> *target* control trans y) - (-> *target* control trans z) - ) - (set! (-> *start-pos* quad) (-> *target* control trans quad)) - ) - (when (= *timer-value* 480) - (format - #t - "Player pos = ~F ~F ~F~%" - (-> *target* control trans x) - (-> *target* control trans y) - (-> *target* control trans z) - ) - (format - #t - "Dist = ~F~%" - (* - 0.00024414062 - (vector-vector-xz-distance (-> *target* control trans) *start-pos*) - ) - ) - (set! *start-timer* (the-as int #f)) - ) - (if (< 179 *timer-value*) - (format *stdcon* "~%~%Time = ~D~%" *timer-value*) - ) - (set! *timer-value* (+ *timer-value* 1)) - ) - (when (not *start-timer*) - (set! *timer-value* 0) - 0 - ) - (dotimes (gp-1 2) - (let ((s5-1 (-> *level* level gp-1))) - (when (!= (-> s5-1 status) 'inactive) - (let ((a0-14 (new-stack-vector0))) - (vector-! - a0-14 - (the-as vector (-> s5-1 info bsphere)) - (-> *math-camera* trans) - ) - (set! - (-> s5-1 level-distance) - (fmax 0.0 (- (vector-length a0-14) (-> s5-1 info bsphere w))) - ) - ) - (when *display-level-spheres* - (add-debug-sphere - #t - (bucket-id debug-draw1) - (-> s5-1 info bsphere) - (-> s5-1 info bsphere w) - (new 'static 'rgba :r #xff :a #x80) - ) + (when (= *timer-value* 180) (format - *stdcon* - "~f ~f ~f ~f~%" - (* 0.00024414062 (-> s5-1 info bsphere x)) - (* 0.00024414062 (-> s5-1 info bsphere y)) - (* 0.00024414062 (-> s5-1 info bsphere z)) - (* 0.00024414062 (-> s5-1 info bsphere w)) - ) + #t + "Player pos = ~F ~F ~F~%" + (-> *target* control trans x) + (-> *target* control trans y) + (-> *target* control trans z) + ) + (set! (-> *start-pos* quad) (-> *target* control trans quad)) ) - ) + (when (= *timer-value* 480) + (format + #t + "Player pos = ~F ~F ~F~%" + (-> *target* control trans x) + (-> *target* control trans y) + (-> *target* control trans z) + ) + (format + #t + "Dist = ~F~%" + (* 0.00024414062 (vector-vector-xz-distance (-> *target* control trans) *start-pos*)) + ) + (set! *start-timer* (the-as int #f)) + ) + (if (< 179 *timer-value*) + (format *stdcon* "~%~%Time = ~D~%" *timer-value*) + ) + (set! *timer-value* (+ *timer-value* 1)) ) - ) - (update-math-camera - *math-camera* - (-> *setting-control* current video-mode) - (-> *setting-control* current aspect-ratio) - ) - (update! *camera-smush-control*) - (cond - ((or (= *master-mode* 'pause) (= *master-mode* 'progress) *progress-process*) - ) - ((>= *camera-look-through-other* 2) - (set! *camera-look-through-other* 1) - ) - ((and (= *camera-look-through-other* 1) (!= *master-mode* 'menu)) - (set! *camera-look-through-other* 0) + (when (not *start-timer*) + (set! *timer-value* 0) 0 ) - ) - (cond - (*external-cam-mode* - (move-camera-from-pad *math-camera*) - ) - ((nonzero? *camera-look-through-other*) - (set! (-> *math-camera* fov) (-> *camera-other-fov* data)) - (set! (-> *math-camera* trans quad) (-> *camera-other-trans* quad)) - (+! (-> *math-camera* trans y) (get-no-update *camera-smush-control*)) - (let* ((a2-9 (-> *math-camera* inv-camera-rot)) - (a3-4 *camera-other-matrix*) - (v1-86 (-> a3-4 vector 0 quad)) - (a0-29 (-> a3-4 vector 1 quad)) - (a1-10 (-> a3-4 vector 2 quad)) - (a3-5 (-> a3-4 vector 3 quad)) - ) - (set! (-> a2-9 vector 0 quad) v1-86) - (set! (-> a2-9 vector 1 quad) a0-29) - (set! (-> a2-9 vector 2 quad) a1-10) - (set! (-> a2-9 vector 3 quad) a3-5) - ) - (let* ((a2-10 *save-camera-inv-rot*) - (a3-6 *camera-other-matrix*) - (v1-87 (-> a3-6 vector 0 quad)) - (a0-30 (-> a3-6 vector 1 quad)) - (a1-11 (-> a3-6 vector 2 quad)) - (a3-7 (-> a3-6 vector 3 quad)) - ) - (set! (-> a2-10 vector 0 quad) v1-87) - (set! (-> a2-10 vector 1 quad) a0-30) - (set! (-> a2-10 vector 2 quad) a1-11) - (set! (-> a2-10 vector 3 quad) a3-7) - ) - ) - ((and *camera-combiner* (not *external-cam-mode*)) - (set! (-> *math-camera* fov) (-> *camera-combiner* fov)) - (set! (-> *math-camera* trans quad) (-> *camera-combiner* trans quad)) - (+! (-> *math-camera* trans y) (get-no-update *camera-smush-control*)) - (let* ((v1-100 (-> *math-camera* inv-camera-rot)) - (a3-8 (-> *camera-combiner* inv-camera-rot)) - (a0-36 (-> a3-8 vector 0 quad)) - (a1-12 (-> a3-8 vector 1 quad)) - (a2-11 (-> a3-8 vector 2 quad)) - (a3-9 (-> a3-8 vector 3 quad)) - ) - (set! (-> v1-100 vector 0 quad) a0-36) - (set! (-> v1-100 vector 1 quad) a1-12) - (set! (-> v1-100 vector 2 quad) a2-11) - (set! (-> v1-100 vector 3 quad) a3-9) - ) - (let* ((v1-101 *save-camera-inv-rot*) - (a3-10 (-> *camera-combiner* inv-camera-rot)) - (a0-38 (-> a3-10 vector 0 quad)) - (a1-13 (-> a3-10 vector 1 quad)) - (a2-12 (-> a3-10 vector 2 quad)) - (a3-11 (-> a3-10 vector 3 quad)) - ) - (set! (-> v1-101 vector 0 quad) a0-38) - (set! (-> v1-101 vector 1 quad) a1-13) - (set! (-> v1-101 vector 2 quad) a2-12) - (set! (-> v1-101 vector 3 quad) a3-11) - ) - ) - (else - (move-camera-from-pad *math-camera*) - ) - ) - (matrix-transpose! - (-> *math-camera* camera-rot) - (-> *math-camera* inv-camera-rot) - ) - (cond - (*camera-no-mip-correction* - (set! (-> *math-camera* fov-correction-factor) 1.0) - ) - (else - (let ((f0-28 (fmin 11650.845 (-> *math-camera* fov)))) - (set! (-> *math-camera* fov-correction-factor) (* 0.00008583069 f0-28)) - ) - ) - ) - (if (< 0.0 (-> *math-camera* smooth-t)) - (set! - (-> *math-camera* smooth-t) - (- (-> *math-camera* smooth-t) (-> *math-camera* smooth-step)) - ) - ) - (cond - ((< 0.0 (-> *math-camera* smooth-t)) - (let ((gp-2 (new-stack-quaternion0))) - (matrix->quaternion gp-2 (-> *math-camera* inv-camera-rot)) - (quaternion-slerp! - gp-2 - gp-2 - (-> *math-camera* inv-camera-rot-smooth-from) - (-> *math-camera* smooth-t) - ) - (quaternion->matrix (-> *math-camera* inv-camera-rot-smooth) gp-2) - ) - ) - (else - (let* ((v1-124 (-> *math-camera* inv-camera-rot-smooth)) - (a3-13 (-> *math-camera* inv-camera-rot)) - (a0-45 (-> a3-13 vector 0 quad)) - (a1-18 (-> a3-13 vector 1 quad)) - (a2-14 (-> a3-13 vector 2 quad)) - (a3-14 (-> a3-13 vector 3 quad)) - ) - (set! (-> v1-124 vector 0 quad) a0-45) - (set! (-> v1-124 vector 1 quad) a1-18) - (set! (-> v1-124 vector 2 quad) a2-14) - (set! (-> v1-124 vector 3 quad) a3-14) - ) - ) - ) - (if (and (!= *master-mode* 'menu) *display-camera-info*) - (format - *stdcon* - "cam pos ~M ~M ~M~%" - (-> *math-camera* trans x) - (-> *math-camera* trans y) - (-> *math-camera* trans z) - ) - ) - (when (zero? (-> *math-camera* reset)) - (let* ((v1-136 (-> *math-camera* prev-camera-temp)) - (a3-16 (-> *math-camera* camera-temp)) - (a0-50 (-> a3-16 vector 0 quad)) - (a1-20 (-> a3-16 vector 1 quad)) - (a2-16 (-> a3-16 vector 2 quad)) - (a3-17 (-> a3-16 vector 3 quad)) + (dotimes (gp-1 2) + (let ((s5-1 (-> *level* level gp-1))) + (when (!= (-> s5-1 status) 'inactive) + (let ((a0-14 (new-stack-vector0))) + (vector-! a0-14 (the-as vector (-> s5-1 info bsphere)) (-> *math-camera* trans)) + (set! (-> s5-1 level-distance) (fmax 0.0 (- (vector-length a0-14) (-> s5-1 info bsphere w)))) ) - (set! (-> v1-136 vector 0 quad) a0-50) - (set! (-> v1-136 vector 1 quad) a1-20) - (set! (-> v1-136 vector 2 quad) a2-16) - (set! (-> v1-136 vector 3 quad) a3-17) + (when *display-level-spheres* + (add-debug-sphere + #t + (bucket-id debug-draw1) + (-> s5-1 info bsphere) + (-> s5-1 info bsphere w) + (new 'static 'rgba :r #xff :a #x80) + ) + (format + *stdcon* + "~f ~f ~f ~f~%" + (* 0.00024414062 (-> s5-1 info bsphere x)) + (* 0.00024414062 (-> s5-1 info bsphere y)) + (* 0.00024414062 (-> s5-1 info bsphere z)) + (* 0.00024414062 (-> s5-1 info bsphere w)) + ) + ) + ) + ) + ) + (update-math-camera + *math-camera* + (-> *setting-control* current video-mode) + (-> *setting-control* current aspect-ratio) + ) + (update! *camera-smush-control*) + (cond + ((or (= *master-mode* 'pause) (= *master-mode* 'progress) *progress-process*) + ) + ((>= *camera-look-through-other* 2) + (set! *camera-look-through-other* 1) + ) + ((and (= *camera-look-through-other* 1) (!= *master-mode* 'menu)) + (set! *camera-look-through-other* 0) + 0 + ) + ) + (cond + (*external-cam-mode* + (move-camera-from-pad *math-camera*) + ) + ((nonzero? *camera-look-through-other*) + (set! (-> *math-camera* fov) (-> *camera-other-fov* data)) + (set! (-> *math-camera* trans quad) (-> *camera-other-trans* quad)) + (+! (-> *math-camera* trans y) (get-no-update *camera-smush-control*)) + (let* ((a2-9 (-> *math-camera* inv-camera-rot)) + (a3-4 *camera-other-matrix*) + (v1-86 (-> a3-4 vector 0 quad)) + (a0-29 (-> a3-4 vector 1 quad)) + (a1-10 (-> a3-4 vector 2 quad)) + (a3-5 (-> a3-4 vector 3 quad)) + ) + (set! (-> a2-9 vector 0 quad) v1-86) + (set! (-> a2-9 vector 1 quad) a0-29) + (set! (-> a2-9 vector 2 quad) a1-10) + (set! (-> a2-9 vector 3 quad) a3-5) + ) + (let* ((a2-10 *save-camera-inv-rot*) + (a3-6 *camera-other-matrix*) + (v1-87 (-> a3-6 vector 0 quad)) + (a0-30 (-> a3-6 vector 1 quad)) + (a1-11 (-> a3-6 vector 2 quad)) + (a3-7 (-> a3-6 vector 3 quad)) + ) + (set! (-> a2-10 vector 0 quad) v1-87) + (set! (-> a2-10 vector 1 quad) a0-30) + (set! (-> a2-10 vector 2 quad) a1-11) + (set! (-> a2-10 vector 3 quad) a3-7) + ) + ) + ((and *camera-combiner* (not *external-cam-mode*)) + (set! (-> *math-camera* fov) (-> *camera-combiner* fov)) + (set! (-> *math-camera* trans quad) (-> *camera-combiner* trans quad)) + (+! (-> *math-camera* trans y) (get-no-update *camera-smush-control*)) + (let* ((v1-100 (-> *math-camera* inv-camera-rot)) + (a3-8 (-> *camera-combiner* inv-camera-rot)) + (a0-36 (-> a3-8 vector 0 quad)) + (a1-12 (-> a3-8 vector 1 quad)) + (a2-11 (-> a3-8 vector 2 quad)) + (a3-9 (-> a3-8 vector 3 quad)) + ) + (set! (-> v1-100 vector 0 quad) a0-36) + (set! (-> v1-100 vector 1 quad) a1-12) + (set! (-> v1-100 vector 2 quad) a2-11) + (set! (-> v1-100 vector 3 quad) a3-9) + ) + (let* ((v1-101 *save-camera-inv-rot*) + (a3-10 (-> *camera-combiner* inv-camera-rot)) + (a0-38 (-> a3-10 vector 0 quad)) + (a1-13 (-> a3-10 vector 1 quad)) + (a2-12 (-> a3-10 vector 2 quad)) + (a3-11 (-> a3-10 vector 3 quad)) + ) + (set! (-> v1-101 vector 0 quad) a0-38) + (set! (-> v1-101 vector 1 quad) a1-13) + (set! (-> v1-101 vector 2 quad) a2-12) + (set! (-> v1-101 vector 3 quad) a3-11) + ) + ) + (else + (move-camera-from-pad *math-camera*) + ) + ) + (matrix-transpose! (-> *math-camera* camera-rot) (-> *math-camera* inv-camera-rot)) + (cond + (*camera-no-mip-correction* + (set! (-> *math-camera* fov-correction-factor) 1.0) + ) + (else + (let ((f0-28 (fmin 11650.845 (-> *math-camera* fov)))) + (set! (-> *math-camera* fov-correction-factor) (* 0.00008583069 f0-28)) + ) + ) + ) + (if (< 0.0 (-> *math-camera* smooth-t)) + (set! (-> *math-camera* smooth-t) (- (-> *math-camera* smooth-t) (-> *math-camera* smooth-step))) + ) + (cond + ((< 0.0 (-> *math-camera* smooth-t)) + (let ((gp-2 (new-stack-quaternion0))) + (matrix->quaternion gp-2 (-> *math-camera* inv-camera-rot)) + (quaternion-slerp! gp-2 gp-2 (-> *math-camera* inv-camera-rot-smooth-from) (-> *math-camera* smooth-t)) + (quaternion->matrix (-> *math-camera* inv-camera-rot-smooth) gp-2) + ) + ) + (else + (let* ((v1-124 (-> *math-camera* inv-camera-rot-smooth)) + (a3-13 (-> *math-camera* inv-camera-rot)) + (a0-45 (-> a3-13 vector 0 quad)) + (a1-18 (-> a3-13 vector 1 quad)) + (a2-14 (-> a3-13 vector 2 quad)) + (a3-14 (-> a3-13 vector 3 quad)) + ) + (set! (-> v1-124 vector 0 quad) a0-45) + (set! (-> v1-124 vector 1 quad) a1-18) + (set! (-> v1-124 vector 2 quad) a2-14) + (set! (-> v1-124 vector 3 quad) a3-14) + ) + ) + ) + (if (and (!= *master-mode* 'menu) *display-camera-info*) + (format + *stdcon* + "cam pos ~M ~M ~M~%" + (-> *math-camera* trans x) + (-> *math-camera* trans y) + (-> *math-camera* trans z) + ) + ) + (when (zero? (-> *math-camera* reset)) + (let* ((v1-136 (-> *math-camera* prev-camera-temp)) + (a3-16 (-> *math-camera* camera-temp)) + (a0-50 (-> a3-16 vector 0 quad)) + (a1-20 (-> a3-16 vector 1 quad)) + (a2-16 (-> a3-16 vector 2 quad)) + (a3-17 (-> a3-16 vector 3 quad)) + ) + (set! (-> v1-136 vector 0 quad) a0-50) + (set! (-> v1-136 vector 1 quad) a1-20) + (set! (-> v1-136 vector 2 quad) a2-16) + (set! (-> v1-136 vector 3 quad) a3-17) + ) ) - ) (let ((gp-3 (-> *math-camera* camera-temp)) (s4-1 (-> *math-camera* camera-rot)) (s5-2 (-> *math-camera* inv-camera-rot)) (s3-0 (-> *math-camera* trans)) ) - (let ((s2-0 (new-stack-vector0))) - (set! (-> s2-0 x) (- (-> s3-0 x))) - (set! (-> s2-0 y) (- (-> s3-0 y))) - (set! (-> s2-0 z) (- (-> s3-0 z))) - (set! (-> s2-0 w) 1.0) - (vector-matrix*! s2-0 s2-0 s4-1) - (set! (-> s4-1 vector 3 quad) (-> s2-0 quad)) + (let ((s2-0 (new-stack-vector0))) + (set! (-> s2-0 x) (- (-> s3-0 x))) + (set! (-> s2-0 y) (- (-> s3-0 y))) + (set! (-> s2-0 z) (- (-> s3-0 z))) + (set! (-> s2-0 w) 1.0) + (vector-matrix*! s2-0 s2-0 s4-1) + (set! (-> s4-1 vector 3 quad) (-> s2-0 quad)) + ) + (matrix*! gp-3 s4-1 (-> *math-camera* perspective)) + (set! (-> s5-2 vector 3 quad) (-> s3-0 quad)) ) - (matrix*! gp-3 s4-1 (-> *math-camera* perspective)) - (set! (-> s5-2 vector 3 quad) (-> s3-0 quad)) - ) (when (nonzero? (-> *math-camera* reset)) - (let* ((v1-148 (-> *math-camera* prev-camera-temp)) - (a3-18 (-> *math-camera* camera-temp)) - (a0-54 (-> a3-18 vector 0 quad)) - (a1-23 (-> a3-18 vector 1 quad)) - (a2-19 (-> a3-18 vector 2 quad)) - (a3-19 (-> a3-18 vector 3 quad)) - ) - (set! (-> v1-148 vector 0 quad) a0-54) - (set! (-> v1-148 vector 1 quad) a1-23) - (set! (-> v1-148 vector 2 quad) a2-19) - (set! (-> v1-148 vector 3 quad) a3-19) + (let* ((v1-148 (-> *math-camera* prev-camera-temp)) + (a3-18 (-> *math-camera* camera-temp)) + (a0-54 (-> a3-18 vector 0 quad)) + (a1-23 (-> a3-18 vector 1 quad)) + (a2-19 (-> a3-18 vector 2 quad)) + (a3-19 (-> a3-18 vector 3 quad)) + ) + (set! (-> v1-148 vector 0 quad) a0-54) + (set! (-> v1-148 vector 1 quad) a1-23) + (set! (-> v1-148 vector 2 quad) a2-19) + (set! (-> v1-148 vector 3 quad) a3-19) + ) + (set! (-> *math-camera* reset) 0) + 0 ) - (set! (-> *math-camera* reset) 0) - 0 - ) (let ((f0-45 (-> *math-camera* fog-min)) (f1-10 (-> *math-camera* fog-max)) ) - (let ((f2-0 (-> *math-camera* d))) - (set! (-> *instance-tie-work* hmge-d x) f0-45) - (set! (-> *instance-tie-work* hmge-d y) f1-10) - (set! (-> *instance-tie-work* hmge-d z) (* 32.0 f2-0)) - (set! - (-> *instance-tie-work* hmge-d w) - (* f2-0 (-> *math-camera* hmge-scale w)) - ) - (let ((v1-160 (-> *math-camera* hvdf-off quad))) - (set! (-> *instance-tie-work* hvdf-offset quad) v1-160) - ) - (set! (-> *instance-shrub-work* hmge-d x) f0-45) - (set! (-> *instance-shrub-work* hmge-d y) f1-10) - (set! (-> *instance-shrub-work* hmge-d z) (* 3.0 f2-0)) - (set! - (-> *instance-shrub-work* hmge-d w) - (* f2-0 (-> *math-camera* hmge-scale w)) - ) - (set! - (-> *instance-shrub-work* billboard-const x) - (/ (-> *math-camera* x-pix) (* f2-0 (-> *math-camera* x-ratio))) - ) - (set! - (-> *instance-shrub-work* billboard-const y) - (/ (-> *math-camera* y-pix) (* f2-0 (-> *math-camera* y-ratio))) - ) + (let ((f2-0 (-> *math-camera* d))) + (set! (-> *instance-tie-work* hmge-d x) f0-45) + (set! (-> *instance-tie-work* hmge-d y) f1-10) + (set! (-> *instance-tie-work* hmge-d z) (* 32.0 f2-0)) + (set! (-> *instance-tie-work* hmge-d w) (* f2-0 (-> *math-camera* hmge-scale w))) + (let ((v1-160 (-> *math-camera* hvdf-off quad))) + (set! (-> *instance-tie-work* hvdf-offset quad) v1-160) + ) + (set! (-> *instance-shrub-work* hmge-d x) f0-45) + (set! (-> *instance-shrub-work* hmge-d y) f1-10) + (set! (-> *instance-shrub-work* hmge-d z) (* 3.0 f2-0)) + (set! (-> *instance-shrub-work* hmge-d w) (* f2-0 (-> *math-camera* hmge-scale w))) + (set! (-> *instance-shrub-work* billboard-const x) + (/ (-> *math-camera* x-pix) (* f2-0 (-> *math-camera* x-ratio))) + ) + (set! (-> *instance-shrub-work* billboard-const y) + (/ (-> *math-camera* y-pix) (* f2-0 (-> *math-camera* y-ratio))) + ) + ) + (set! (-> *instance-shrub-work* billboard-const z) f0-45) + (set! (-> *instance-shrub-work* billboard-const w) f1-10) ) - (set! (-> *instance-shrub-work* billboard-const z) f0-45) - (set! (-> *instance-shrub-work* billboard-const w) f1-10) - ) - (set! - (-> *instance-shrub-work* constants w) - (the-as float (-> *math-camera* vis-gifs 0 fog0)) - ) + (set! (-> *instance-shrub-work* constants w) (the-as float (-> *math-camera* vis-gifs 0 fog0))) (let ((a0-56 (-> *math-camera* hvdf-off quad))) - (set! (-> *instance-shrub-work* hvdf-offset quad) a0-56) - ) + (set! (-> *instance-shrub-work* hvdf-offset quad) a0-56) + ) (update-view-planes *math-camera* (-> *math-camera* plane) 1.0) (update-view-planes *math-camera* (-> *math-camera* guard-plane) 4.0) - (set! - (-> *instance-shrub-work* guard-plane 0 quad) - (-> *math-camera* guard-plane 0 quad) - ) - (set! - (-> *instance-shrub-work* guard-plane 1 quad) - (-> *math-camera* guard-plane 1 quad) - ) - (set! - (-> *instance-shrub-work* guard-plane 2 quad) - (-> *math-camera* guard-plane 2 quad) - ) - (set! - (-> *instance-shrub-work* guard-plane 3 quad) - (-> *math-camera* guard-plane 3 quad) - ) - (set! - (-> *instance-tie-work* guard-plane 0 quad) - (-> *math-camera* guard-plane 0 quad) - ) - (set! - (-> *instance-tie-work* guard-plane 1 quad) - (-> *math-camera* guard-plane 1 quad) - ) - (set! - (-> *instance-tie-work* guard-plane 2 quad) - (-> *math-camera* guard-plane 2 quad) - ) - (set! - (-> *instance-tie-work* guard-plane 3 quad) - (-> *math-camera* guard-plane 3 quad) - ) + (set! (-> *instance-shrub-work* guard-plane 0 quad) (-> *math-camera* guard-plane 0 quad)) + (set! (-> *instance-shrub-work* guard-plane 1 quad) (-> *math-camera* guard-plane 1 quad)) + (set! (-> *instance-shrub-work* guard-plane 2 quad) (-> *math-camera* guard-plane 2 quad)) + (set! (-> *instance-shrub-work* guard-plane 3 quad) (-> *math-camera* guard-plane 3 quad)) + (set! (-> *instance-tie-work* guard-plane 0 quad) (-> *math-camera* guard-plane 0 quad)) + (set! (-> *instance-tie-work* guard-plane 1 quad) (-> *math-camera* guard-plane 1 quad)) + (set! (-> *instance-tie-work* guard-plane 2 quad) (-> *math-camera* guard-plane 2 quad)) + (set! (-> *instance-tie-work* guard-plane 3 quad) (-> *math-camera* guard-plane 3 quad)) (update-visible *math-camera*) (if (not (paused?)) - (update-wind *wind-work* *wind-scales*) - ) + (update-wind *wind-work* *wind-scales*) + ) #f ) diff --git a/goal_src/engine/camera/math-camera.gc b/goal_src/engine/camera/math-camera.gc index b5c590f47f..b4706f6cf6 100644 --- a/goal_src/engine/camera/math-camera.gc +++ b/goal_src/engine/camera/math-camera.gc @@ -36,9 +36,26 @@ (set! (-> math-cam x-ratio) (tan (* 0.5 (-> math-cam fov)))) ;;(format #t "aspect is ~A~%" aspect) (if (= aspect 'aspect4x3) - (set! (-> math-cam y-ratio) (* 0.75 (-> math-cam x-ratio))) - (set! (-> math-cam y-ratio) (* 0.5625 (-> math-cam x-ratio))) + (set! (-> math-cam y-ratio) (* (1/ ASPECT_4X3) (-> math-cam x-ratio))) + (set! (-> math-cam y-ratio) (* (1/ ASPECT_16X9) (-> math-cam x-ratio))) ) + (#when PC_PORT + (cond + ((not *pc-settings*) + ) + ((-> *pc-settings* use-vis?) + ;; using game vis, cannot allow seeing more of the view + ;; crops excess aspect ratio at the top and bottom + (set! (-> math-cam y-ratio) (* (1/ (-> *pc-settings* aspect-ratio)) (-> math-cam x-ratio))) + ) + (else + ;; not using game vis, allow *extended* aspect ratios + ;; there is no vertical cropping, and you can see more of the sides + (set! (-> math-cam y-ratio) (* (1/ ASPECT_4X3) (-> math-cam x-ratio))) ;; same cropping as 4x3 + (*! (-> math-cam x-ratio) (/ (-> *pc-settings* aspect-ratio) ASPECT_4X3)) ;; extend fov! shows more on the sides. + ) + ) + ) ;; compute some culling constants. Not sure what these mean yet (let ((x-rat (-> math-cam x-ratio)) @@ -47,22 +64,9 @@ ) (let ((unused-x-thing (/ (+ 1.0 (* (* 4.0 x-rat) x-rat)) (+ 1.0 (* x-rat x-rat)))))) (let ((y-thing (/ (+ 1.0 (* (* 4.0 y-rat) y-rat)) (+ 1.0 (* y-rat y-rat))))) - (set! (-> cull-info x-fact) - (/ (+ 1.0 (* (* 4.0 x-rat) x-rat)) - (* x-rat (sqrtf (+ 1.0 (* (* 16.0 x-rat) x-rat)))) - ) - ) - (set! (-> cull-info y-fact) - (/ (+ 1.0 (* (* 4.0 y-rat) y-rat)) - (* y-rat (sqrtf (+ 1.0 (* (* 16.0 y-rat) y-rat)))) - ) - ) - (set! (-> cull-info z-fact) - (sqrtf (+ (* (* (* (+ -4.0 y-thing) (+ -4.0 y-thing)) y-rat) y-rat) - (* (+ -1.0 y-thing) (+ -1.0 y-thing)) - ) - ) - ) + (set! (-> cull-info x-fact) (/ (+ 1.0 (* 4.0 x-rat x-rat)) (* x-rat (sqrtf (+ 1.0 (* 16.0 x-rat x-rat)))))) + (set! (-> cull-info y-fact) (/ (+ 1.0 (* 4.0 y-rat y-rat)) (* y-rat (sqrtf (+ 1.0 (* 16.0 y-rat y-rat)))))) + (set! (-> cull-info z-fact) (sqrtf (+ (* (+ -4.0 y-thing) (+ -4.0 y-thing) y-rat y-rat) (* (+ -1.0 y-thing) (+ -1.0 y-thing))))) ) ;; radius of sphere containing camera origin and intersection of near plane and frustum @@ -135,26 +139,16 @@ (let ((corrected-fog (/ fog-factor-2 (* (-> math-cam d) (- (-> math-cam f) (-> math-cam d))))) (cam-fov-mult (-> math-cam fov-correction-factor)) ) - (set! (-> math-cam perspective data 0) - (* cam-fov-mult - (- (/ (-> math-cam x-pix) (* (-> math-cam x-ratio) (-> math-cam d)))) - ) + (set! (-> math-cam perspective vector 0 x) + (* cam-fov-mult (- (/ (-> math-cam x-pix) (* (-> math-cam x-ratio) (-> math-cam d))))) ) - (set! (-> math-cam perspective data 5) - (* cam-fov-mult - (- (/ (-> math-cam y-pix) (* (-> math-cam y-ratio) (-> math-cam d)))) - ) + (set! (-> math-cam perspective vector 1 y) + (* cam-fov-mult (- (/ (-> math-cam y-pix) (* (-> math-cam y-ratio) (-> math-cam d))))) ) - (set! (-> math-cam perspective data 10) - (* (* cam-fov-mult (+ (-> math-cam f) (-> math-cam d))) corrected-fog) - ) - (set! (-> math-cam perspective data 11) - (* (/ cam-fov-mult (-> math-cam d)) fog-at-near-plane) - ) - (set! (-> math-cam perspective data 14) - (* (* (* (* -2.0 corrected-fog) (-> math-cam f)) (-> math-cam d)) - cam-fov-mult - ) + (set! (-> math-cam perspective vector 2 z) (* cam-fov-mult (+ (-> math-cam f) (-> math-cam d)) corrected-fog)) + (set! (-> math-cam perspective vector 2 w) (* (/ cam-fov-mult (-> math-cam d)) fog-at-near-plane)) + (set! (-> math-cam perspective vector 3 z) + (* -2.0 corrected-fog (-> math-cam f) (-> math-cam d) cam-fov-mult) ) ) @@ -190,52 +184,41 @@ (set! (-> math-cam guard y) (/ (-> math-cam y-clip) (-> math-cam y-pix))) (set! (-> math-cam guard z) 1.0) (set! (-> math-cam guard w) 1.0) - (set! (-> math-cam isometric data 14) (- 16777215.0 hvdf-z)) + (set! (-> math-cam isometric vector 3 z) (- 16777215.0 hvdf-z)) ;; PC HACK! ;; for whatever reason, the font render ends up computing a depth #x1000000 instead of ;; #xffffffff, which overflows the 24-bit z buffer. ;; cheating this by 1 bit seems to fix it. (#when PC_PORT ;; #x4b002032 -> #x4b002031 - (-! (-> math-cam isometric data 14) 1.) + (-! (-> math-cam isometric vector 3 z) 1.) ) ) - (set! (-> math-cam isometric data 15) fog-at-near-plane) + (set! (-> math-cam isometric vector 3 w) fog-at-near-plane) ;; perspective matrix - (let ((persp-xx (-> math-cam perspective data 0)) - (persp-yy (-> math-cam perspective data 5)) - (persp-x (* -1.9996 (-> math-cam perspective data 0))) + (let ((persp-xx (-> math-cam perspective vector 0 x)) + (persp-yy (-> math-cam perspective vector 1 y)) + (persp-x (* -1.9996 (-> math-cam perspective vector 0 x))) ) (let ((sprite-row-0 (-> math-cam sprite-2d))) - (set! (-> sprite-row-0 data 0) persp-x) - (set! (-> sprite-row-0 data 1) 0.0) - (set! (-> sprite-row-0 data 2) 0.0) - (set! (-> sprite-row-0 data 3) 0.0) + (set! (-> sprite-row-0 vector 0 x) persp-x) + (set! (-> sprite-row-0 vector 0 y) 0.0) + (set! (-> sprite-row-0 vector 0 z) 0.0) + (set! (-> sprite-row-0 vector 0 w) 0.0) ) - (let ((sprite-row-1 (&-> math-cam sprite-2d data 4))) - (set! (-> sprite-row-1 0) 0.0) - (set! (-> sprite-row-1 1) (- (* (/ persp-yy persp-xx) persp-x))) - (set! (-> sprite-row-1 2) 0.0) - (set! (-> sprite-row-1 3) 0.0) - ) - (let ((sprite-row-2 (&-> math-cam sprite-2d data 8))) - (set! (-> sprite-row-2 0) 0.0) - (set! (-> sprite-row-2 1) 0.0) - (set! (-> sprite-row-2 2) (- persp-x)) - (set! (-> sprite-row-2 3) 0.0) - ) - (let ((sprite-row-3 (&-> math-cam sprite-2d data 12))) - (set! (-> sprite-row-3 0) 0.0) - (set! (-> sprite-row-3 1) 0.0) - (set! (-> sprite-row-3 2) (* 500000000.0 persp-x)) - (set! (-> sprite-row-3 3) (* (* 60.0 persp-x) (-> math-cam pfog0))) + (set-vector! (-> math-cam sprite-2d vector 1) 0.0 (- (* (/ persp-yy persp-xx) persp-x)) 0.0 0.0) + (set-vector! (-> math-cam sprite-2d vector 2) 0.0 0.0 (- persp-x) 0.0) + (set-vector! + (-> math-cam sprite-2d vector 3) + 0.0 + 0.0 + (* 500000000.0 persp-x) + (* 60.0 persp-x (-> math-cam pfog0)) ) ) - (let ((v1-15 (-> math-cam sprite-2d-hvdf))) - (set! (-> v1-15 quad) (-> math-cam hvdf-off quad)) - ) + (set! (-> math-cam sprite-2d-hvdf quad) (-> math-cam hvdf-off quad)) (set! (-> math-cam sprite-2d-hvdf x) 2048.0) (set! (-> math-cam sprite-2d-hvdf y) 2048.0) (set! (-> math-cam sprite-2d-hvdf z) (-> math-cam hvdf-off z)) diff --git a/goal_src/engine/debug/debug.gc b/goal_src/engine/debug/debug.gc index 8030e9c416..48eda076f6 100644 --- a/goal_src/engine/debug/debug.gc +++ b/goal_src/engine/debug/debug.gc @@ -894,31 +894,11 @@ (set! (-> gp-0 0 x) (* (sin (-> arg0 stick0-dir)) (-> arg0 stick0-speed))) (set! (-> gp-0 0 y) (* (cos (-> arg0 stick0-dir)) (-> arg0 stick0-speed))) (dotimes (s5-1 32) - (let* ((s3-0 (-> (current-frame) debug-buf)) - (s4-0 (-> s3-0 base)) - ) - (draw-sprite2d-xy - s3-0 - (the int (* 120.0 (-> gp-0 s5-1 x))) - (the int (* 144.0 (-> gp-0 s5-1 y))) - 10 - 10 - (new 'static 'rgba :a #x80 :r (- 255 (* 7 s5-1))) - ) - (let ((a3-1 (-> s3-0 base))) - (let ((v1-12 (the-as dma-packet (-> s3-0 base)))) - (set! (-> v1-12 dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> v1-12 vif0) (new 'static 'vif-tag)) - (set! (-> v1-12 vif1) (new 'static 'vif-tag)) - (set! (-> s3-0 base) (&+ (the-as pointer v1-12) 16)) - ) - (dma-bucket-insert-tag - (-> (current-frame) bucket-group) - (bucket-id debug-draw0) - s4-0 - (the-as (pointer dma-tag) a3-1) - ) - ) + (with-dma-buffer-add-bucket ((s3-0 (-> (current-frame) debug-buf)) (bucket-id debug-draw0)) + (draw-sprite2d-xy s3-0 + (the int (* 120.0 (-> gp-0 s5-1 x))) + (the int (* 144.0 (-> gp-0 s5-1 y))) + 10 10 (new 'static 'rgba :a #x80 :r (- 255 (* 7 s5-1)))) ) ) ) diff --git a/goal_src/engine/debug/default-menu.gc b/goal_src/engine/debug/default-menu.gc index 0b42128aa6..75cbbf6570 100644 --- a/goal_src/engine/debug/default-menu.gc +++ b/goal_src/engine/debug/default-menu.gc @@ -5,8 +5,6 @@ ;; name in dgo: default-menu ;; dgos: GAME, ENGINE -(declare-file (debug)) - ;; Forward declarations for stuff we haven't written yet: (define-extern *edit-instance* string) @@ -16,12 +14,13 @@ ;; DECOMP BEGINS ;; this file is debug only +(declare-file (debug)) (when *debug-segment* (define *debug-menu-context* (new 'debug 'debug-menu-context)) (define *dm-cam-mode-interpolation* 0) -(defun-debug dm-cam-mode-func ((arg0 (state camera-slave)) (arg1 debug-menu-msg)) +(defun dm-cam-mode-func ((arg0 (state camera-slave)) (arg1 debug-menu-msg)) (if (and (= arg1 (debug-menu-msg press)) arg0) (send-event *camera* 'change-state arg0 *dm-cam-mode-interpolation*) ) @@ -31,7 +30,7 @@ ) ) -(defun-debug dm-cam-settings-func ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-cam-settings-func ((arg0 int) (arg1 debug-menu-msg)) (when (and (= arg1 (debug-menu-msg press)) *camera*) (cond ((zero? arg0) @@ -137,7 +136,7 @@ ) ) -(defun-debug dm-cam-settings-func-int ((arg0 int) (arg1 debug-menu-msg) (arg2 int) (arg3 int)) +(defun dm-cam-settings-func-int ((arg0 int) (arg1 debug-menu-msg) (arg2 int) (arg3 int)) (when (and (= arg1 (debug-menu-msg press)) *camera*) (if (= (/ arg0 8) 5) (set! *dm-cam-mode-interpolation* arg2) @@ -156,7 +155,7 @@ ) ) -(defun-debug dm-cam-externalize ((arg0 symbol) (arg1 debug-menu-msg)) +(defun dm-cam-externalize ((arg0 symbol) (arg1 debug-menu-msg)) (when (= arg1 (debug-menu-msg press)) (cond ((= arg0 'reset) @@ -184,7 +183,7 @@ ) ) -(defun-debug dm-cam-render-float ((arg0 int) (arg1 debug-menu-msg) (arg2 float) (arg3 float)) +(defun dm-cam-render-float ((arg0 int) (arg1 debug-menu-msg) (arg2 float) (arg3 float)) (with-pp (when (= arg1 (debug-menu-msg press)) (cond @@ -243,7 +242,7 @@ ) ) -(defun-debug dm-subdiv-float ((arg0 symbol) (arg1 debug-menu-msg) (arg2 float) (arg3 float)) +(defun dm-subdiv-float ((arg0 symbol) (arg1 debug-menu-msg) (arg2 float) (arg3 float)) (when (= arg1 (debug-menu-msg press)) (case arg0 (('close) @@ -277,7 +276,7 @@ ) ) -(defun-debug dm-subdiv-int ((arg0 symbol) (arg1 debug-menu-msg) (arg2 int) (arg3 int)) +(defun dm-subdiv-int ((arg0 symbol) (arg1 debug-menu-msg) (arg2 int) (arg3 int)) (when (= arg1 (debug-menu-msg press)) (case arg0 (('anim-speed) @@ -300,35 +299,35 @@ ) ) -(defun-debug dm-setting-language ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-setting-language ((arg0 int) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! (-> *setting-control* default language) (the-as language-enum (/ arg0 8))) ) (= (-> *setting-control* default language) (/ arg0 8)) ) -(defun-debug dm-current-continue ((arg0 string) (arg1 debug-menu-msg)) +(defun dm-current-continue ((arg0 string) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (start 'play (get-continue-by-name *game-info* arg0)) ) (string= (-> (get-or-create-continue! *game-info*) name) arg0) ) -(defun-debug dm-subdiv-draw-func ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-subdiv-draw-func ((arg0 int) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! *subdivide-draw-mode* (/ arg0 8)) ) (= (/ arg0 8) *subdivide-draw-mode*) ) -(defun-debug dm-ocean-subdiv-draw-func ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-ocean-subdiv-draw-func ((arg0 int) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! *ocean-subdivide-draw-mode* (/ arg0 8)) ) (= (/ arg0 8) *ocean-subdivide-draw-mode*) ) -(defun-debug dm-time-of-day-func ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-time-of-day-func ((arg0 int) (arg1 debug-menu-msg)) (when (= arg1 (debug-menu-msg press)) (set! *time-of-day-mode* (/ arg0 8)) (set! (-> *time-of-day-proc* 0 minute) 0) @@ -376,7 +375,7 @@ (= (/ arg0 8) *time-of-day-mode*) ) -(defun-debug dm-time-of-day-func2 ((arg0 (pointer symbol)) (arg1 debug-menu-msg)) +(defun dm-time-of-day-func2 ((arg0 (pointer symbol)) (arg1 debug-menu-msg)) (when (= arg1 (debug-menu-msg press)) (set! (-> arg0 0) (not (-> arg0 0))) (when (!= (-> *time-of-day-proc* 0 time-ratio) 0.0) @@ -389,89 +388,89 @@ (-> arg0 0) ) -(defun-debug dm-boolean-toggle-pick-func ((arg0 (pointer symbol)) (arg1 debug-menu-msg)) +(defun dm-boolean-toggle-pick-func ((arg0 (pointer symbol)) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! (-> arg0 0) (not (-> arg0 0))) ) (-> arg0 0) ) -(defun-debug dm-time-of-day-pick-func ((arg0 symbol) (arg1 debug-menu-msg)) +(defun dm-time-of-day-pick-func ((arg0 symbol) (arg1 debug-menu-msg)) (time-of-day-setup (= arg1 (debug-menu-msg press))) (none) ) -(defun-debug dm-actor-marks-pick-func ((arg0 symbol) (arg1 debug-menu-msg)) +(defun dm-actor-marks-pick-func ((arg0 symbol) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! *display-actor-marks* arg0) ) (= *display-actor-marks* arg0) ) -(defun-debug dm-compact-actor-pick-func ((arg0 symbol) (arg1 debug-menu-msg)) +(defun dm-compact-actor-pick-func ((arg0 symbol) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! *compact-actors* arg0) ) (= *compact-actors* arg0) ) -(defun-debug dm-actor-vis-pick-func ((arg0 symbol) (arg1 debug-menu-msg)) +(defun dm-actor-vis-pick-func ((arg0 symbol) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! *display-actor-vis* arg0) ) (= *display-actor-vis* arg0) ) -(defun-debug dm-game-mode-pick-func ((arg0 symbol) (arg1 debug-menu-msg)) +(defun dm-game-mode-pick-func ((arg0 symbol) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! (-> *game-info* mode) arg0) ) (= (-> *game-info* mode) arg0) ) -(defun-debug dm-vu1-user-toggle-pick-func ((arg0 vu1-renderer-mask) (arg1 debug-menu-msg)) +(defun dm-vu1-user-toggle-pick-func ((arg0 vu1-renderer-mask) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! *vu1-enable-user-menu* (logxor *vu1-enable-user-menu* (the-as uint arg0))) ) (logtest? *vu1-enable-user-menu* arg0) ) -(defun-debug dm-vu1-user-set-pick-func ((arg0 vu1-renderer-mask) (arg1 debug-menu-msg)) +(defun dm-vu1-user-set-pick-func ((arg0 vu1-renderer-mask) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! *vu1-enable-user-menu* arg0) ) (= *vu1-enable-user-menu* arg0) ) -(defun-debug dm-texture-user-toggle-pick-func ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-texture-user-toggle-pick-func ((arg0 int) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! *texture-enable-user-menu* (logxor *texture-enable-user-menu* arg0)) ) (logtest? *texture-enable-user-menu* arg0) ) -(defun-debug dm-texture-user-set-pick-func ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-texture-user-set-pick-func ((arg0 int) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! *texture-enable-user-menu* arg0) ) (= *texture-enable-user-menu* arg0) ) -(defun-debug dm-strip-lines-toggle-pick-func ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-strip-lines-toggle-pick-func ((arg0 int) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! *display-strip-lines* (logxor *display-strip-lines* (/ arg0 8))) ) (logtest? *display-strip-lines* (/ arg0 8)) ) -(defun-debug dm-strip-lines-set-pick-func ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-strip-lines-set-pick-func ((arg0 int) (arg1 debug-menu-msg)) (if (= arg1 (debug-menu-msg press)) (set! *display-strip-lines* (/ arg0 8)) ) (= *display-strip-lines* (/ arg0 8)) ) -(defun-debug dm-edit-instance-toggle-pick-func ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-edit-instance-toggle-pick-func ((arg0 int) (arg1 debug-menu-msg)) (let ((v1-0 (find-instance-by-name *edit-instance*))) (when v1-0 (if (= arg1 (debug-menu-msg press)) @@ -482,7 +481,7 @@ ) ) -(defun-debug all-texture-tweak-adjust ((arg0 texture-page-dir) (arg1 float)) +(defun all-texture-tweak-adjust ((arg0 texture-page-dir) (arg1 float)) ; (dotimes (s4-0 (-> arg0 length)) ; (let ((s3-0 (-> arg0 entries s4-0 page))) ; (dotimes (s2-0 (min (-> s3-0 length) (-> arg0 entries s4-0 length))) @@ -508,11 +507,11 @@ (none) ) -(defun-debug debug-menu-node arg0 name) (-> arg1 name)) ) -(defun-debug dm-shader-pick-func ((arg0 texture-id) (arg1 debug-menu-msg)) +(defun dm-shader-pick-func ((arg0 texture-id) (arg1 debug-menu-msg)) (if (and (= arg1 (debug-menu-msg press)) *texture-page-dir* @@ -527,7 +526,7 @@ (define *shader-pick-menu* (the-as debug-menu #f)) -(defun-debug build-shader-list () +(defun build-shader-list () (debug-menu-remove-all-items *shader-pick-menu*) (when *texture-page-dir* (dotimes (gp-0 (-> *texture-page-dir* length)) @@ -560,7 +559,7 @@ ) ) -(defun-debug dm-instance-pick-func ((arg0 string) (arg1 debug-menu-msg)) +(defun dm-instance-pick-func ((arg0 string) (arg1 debug-menu-msg)) (when (= arg1 (debug-menu-msg press)) (if (find-instance-by-name arg0) (set! *edit-instance* arg0) @@ -570,7 +569,7 @@ (and *edit-instance* (string= arg0 *edit-instance*)) ) -(defun-debug dm-enable-instance-func ((arg0 string) (arg1 debug-menu-msg)) +(defun dm-enable-instance-func ((arg0 string) (arg1 debug-menu-msg)) (let ((v1-0 (find-instance-by-name arg0))) (cond (v1-0 @@ -592,7 +591,7 @@ (define *enable-instance-tie-menu* (the-as debug-menu #f)) -(defun-debug build-instance-list ((arg0 object)) +(defun build-instance-list ((arg0 object)) (debug-menu-remove-all-items *instance-shrub-menu*) (debug-menu-remove-all-items *instance-tie-menu*) (debug-menu-remove-all-items *enable-instance-tie-menu*) @@ -689,10 +688,10 @@ (none) ) -(defun-debug debug-create-cam-restore () +(defun debug-create-cam-restore () (cond (*math-camera* - (format #t "(defun-debug cam-restore ()~%") + (format #t "(defun cam-restore ()~%") (format #t " ;;this function is a hack, don't use it as an example~%") (format #t " (let ((pos (new 'stack 'vector))~%") (format #t " (rot (new 'stack 'matrix)))~%") @@ -775,7 +774,7 @@ (none) ) -(defun-debug debug-menu-make-camera-mode-menu ((arg0 debug-menu) (arg1 debug-menu)) +(defun debug-menu-make-camera-mode-menu ((arg0 debug-menu) (arg1 debug-menu)) (new 'debug 'debug-menu-item-submenu "Camera" arg0) (let ((a1-3 (new 'debug 'debug-menu-item-submenu "Mode" arg1))) (debug-menu-append-item arg0 a1-3) @@ -846,7 +845,7 @@ (none) ) -(defun-debug debug-menu-make-camera-menu ((arg0 debug-menu-context)) +(defun debug-menu-make-camera-menu ((arg0 debug-menu-context)) (let* ((gp-0 (new 'debug 'debug-menu arg0 "Camera menu")) (s5-0 (new 'debug 'debug-menu-item-submenu "Camera" gp-0)) ) @@ -1055,7 +1054,7 @@ ) ) -(defun-debug debug-menu-make-shader-menu ((arg0 debug-menu-context)) +(defun debug-menu-make-shader-menu ((arg0 debug-menu-context)) (let* ((gp-0 (new 'debug 'debug-menu arg0 "Shader menu")) (s5-0 (new 'debug 'debug-menu-item-submenu "Shader" gp-0)) ) @@ -1966,7 +1965,7 @@ ) ) -(defun-debug debug-menu-make-instance-menu ((arg0 debug-menu-context)) +(defun debug-menu-make-instance-menu ((arg0 debug-menu-context)) (let* ((gp-0 (new 'debug 'debug-menu arg0 "Instance menu")) (s5-0 (new 'debug 'debug-menu-item-submenu "Instance" gp-0)) ) @@ -2071,7 +2070,7 @@ ) ) -(defun-debug dm-task-unknown ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-task-unknown ((arg0 int) (arg1 debug-menu-msg)) (let ((gp-0 (/ arg0 8))) (if (not (task-exists? (the-as game-task gp-0) (task-status unknown))) (return 'invalid) @@ -2083,7 +2082,7 @@ ) ) -(defun-debug dm-task-hint ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-task-hint ((arg0 int) (arg1 debug-menu-msg)) (let ((gp-0 (/ arg0 8))) (if (not (task-exists? (the-as game-task gp-0) (task-status need-hint))) (return 'invalid) @@ -2095,7 +2094,7 @@ ) ) -(defun-debug dm-task-introduction ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-task-introduction ((arg0 int) (arg1 debug-menu-msg)) (let ((gp-0 (/ arg0 8))) (if (not (task-exists? (the-as game-task gp-0) (task-status need-introduction))) (return 'invalid) @@ -2107,7 +2106,7 @@ ) ) -(defun-debug dm-task-reminder-a ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-task-reminder-a ((arg0 int) (arg1 debug-menu-msg)) (let ((gp-0 (/ arg0 8))) (if (not (task-exists? (the-as game-task gp-0) (task-status need-reminder-a))) (return 'invalid) @@ -2119,7 +2118,7 @@ ) ) -(defun-debug dm-task-reminder ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-task-reminder ((arg0 int) (arg1 debug-menu-msg)) (let ((gp-0 (/ arg0 8))) (if (not (task-exists? (the-as game-task gp-0) (task-status need-reminder))) (return 'invalid) @@ -2131,7 +2130,7 @@ ) ) -(defun-debug dm-task-reward-speech ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-task-reward-speech ((arg0 int) (arg1 debug-menu-msg)) (let ((gp-0 (/ arg0 8))) (if (not (task-exists? (the-as game-task gp-0) (task-status need-reward-speech))) (return 'invalid) @@ -2143,7 +2142,7 @@ ) ) -(defun-debug dm-task-resolution ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-task-resolution ((arg0 int) (arg1 debug-menu-msg)) (let ((gp-0 (/ arg0 8))) (if (not (task-exists? (the-as game-task gp-0) (task-status need-resolution))) (return 'invalid) @@ -2156,7 +2155,7 @@ ) ) -(defun-debug debug-menu-make-task-unknown-menu ((arg0 debug-menu) (arg1 debug-menu-context)) +(defun debug-menu-make-task-unknown-menu ((arg0 debug-menu) (arg1 debug-menu-context)) (debug-menu-append-item arg0 (debug-menu-make-from-template arg1 '(menu @@ -2291,7 +2290,7 @@ (none) ) -(defun-debug debug-menu-make-task-need-hint-menu ((arg0 debug-menu) (arg1 debug-menu-context)) +(defun debug-menu-make-task-need-hint-menu ((arg0 debug-menu) (arg1 debug-menu-context)) (debug-menu-append-item arg0 (debug-menu-make-from-template arg1 '(menu @@ -2426,7 +2425,7 @@ (none) ) -(defun-debug debug-menu-make-task-need-introduction-menu ((arg0 debug-menu) (arg1 debug-menu-context)) +(defun debug-menu-make-task-need-introduction-menu ((arg0 debug-menu) (arg1 debug-menu-context)) (debug-menu-append-item arg0 (debug-menu-make-from-template arg1 '(menu @@ -2561,7 +2560,7 @@ (none) ) -(defun-debug debug-menu-make-task-need-reminder-a-menu ((arg0 debug-menu) (arg1 debug-menu-context)) +(defun debug-menu-make-task-need-reminder-a-menu ((arg0 debug-menu) (arg1 debug-menu-context)) (debug-menu-append-item arg0 (debug-menu-make-from-template arg1 '(menu @@ -2696,7 +2695,7 @@ (none) ) -(defun-debug debug-menu-make-task-need-reminder-menu ((arg0 debug-menu) (arg1 debug-menu-context)) +(defun debug-menu-make-task-need-reminder-menu ((arg0 debug-menu) (arg1 debug-menu-context)) (debug-menu-append-item arg0 (debug-menu-make-from-template arg1 '(menu @@ -2831,7 +2830,7 @@ (none) ) -(defun-debug debug-menu-make-task-need-reward-speech-menu ((arg0 debug-menu) (arg1 debug-menu-context)) +(defun debug-menu-make-task-need-reward-speech-menu ((arg0 debug-menu) (arg1 debug-menu-context)) (debug-menu-append-item arg0 (debug-menu-make-from-template arg1 '(menu @@ -2966,7 +2965,7 @@ (none) ) -(defun-debug debug-menu-make-task-need-resolution-menu ((arg0 debug-menu) (arg1 debug-menu-context)) +(defun debug-menu-make-task-need-resolution-menu ((arg0 debug-menu) (arg1 debug-menu-context)) (debug-menu-append-item arg0 (debug-menu-make-from-template arg1 '(menu @@ -3101,7 +3100,7 @@ (none) ) -(defun-debug dm-task-get-money ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-task-get-money ((arg0 int) (arg1 debug-menu-msg)) (with-pp (if (= arg1 (debug-menu-msg press)) (send-event *target* 'get-pickup 5 (-> *GAME-bank* money-task-inc)) @@ -3117,7 +3116,7 @@ ) ) -(defun-debug dm-give-all-cells ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-give-all-cells ((arg0 int) (arg1 debug-menu-msg)) (when (= arg1 (debug-menu-msg press)) (dotimes (gp-0 100) (send-event *target* 'get-pickup 6 (the float (+ gp-0 2))) @@ -3132,13 +3131,13 @@ #t ) -(defun-debug dm-give-cell ((arg0 game-task)) +(defun dm-give-cell ((arg0 game-task)) (send-event *target* 'get-pickup 6 (the float arg0)) (close-specific-task! arg0 (task-status need-resolution)) (none) ) -(defun-debug dm-levitator-ready ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-levitator-ready ((arg0 int) (arg1 debug-menu-msg)) (when (= arg1 (debug-menu-msg press)) (close-specific-task! (game-task village2-levitator) (task-status need-introduction)) (close-specific-task! (game-task village2-levitator) (task-status need-reminder-a)) @@ -3192,7 +3191,7 @@ (= (get-task-status (game-task village2-levitator)) (task-status need-reward-speech)) ) -(defun-debug dm-lavabike-ready ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-lavabike-ready ((arg0 int) (arg1 debug-menu-msg)) (when (= arg1 (debug-menu-msg press)) (dm-give-cell (game-task jungle-eggtop)) (dm-give-cell (game-task jungle-lurkerm)) @@ -3273,7 +3272,7 @@ (= (get-task-status (game-task lavatube-start)) (task-status need-reward-speech)) ) -(defun-debug debug-menu-make-task-menu ((arg0 debug-menu-context)) +(defun debug-menu-make-task-menu ((arg0 debug-menu-context)) (let* ((s5-0 (new 'debug 'debug-menu arg0 "Task menu")) (s4-0 (new 'debug 'debug-menu-item-submenu "Task" s5-0)) ) @@ -3292,7 +3291,7 @@ ) ) -(defun-debug dm-anim-tester-flag-func ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-anim-tester-flag-func ((arg0 int) (arg1 debug-menu-msg)) (when *anim-tester* (case arg0 (('at-apply-align) @@ -3312,7 +3311,7 @@ #f ) -(defun-debug dm-anim-tester-func ((arg0 int) (arg1 debug-menu-msg)) +(defun dm-anim-tester-func ((arg0 int) (arg1 debug-menu-msg)) (if (not *anim-tester*) (anim-tester-start) ) @@ -3345,7 +3344,7 @@ (none) ) -(defun-debug build-continue-menu ((arg0 debug-menu) (arg1 game-info)) +(defun build-continue-menu ((arg0 debug-menu) (arg1 game-info)) (let ((s5-0 *level-load-list*)) (while (not (null? s5-0)) (let ((s4-0 (-> (the-as level-load-info (-> (the-as symbol (car s5-0)) value)) continues))) @@ -3364,7 +3363,7 @@ (the-as debug-menu-context arg0) ) -(defun-debug debug-menu-context-make-default-menus ((arg0 debug-menu-context)) +(defun debug-menu-context-make-default-menus ((arg0 debug-menu-context)) (let ((s5-0 (new 'debug 'debug-menu arg0 "Main menu"))) (debug-menu-context-set-root-menu arg0 s5-0) (debug-menu-append-item @@ -3894,7 +3893,7 @@ (define *popup-menu-context* (new 'debug 'debug-menu-context)) -(defun-debug popup-menu-context-make-default-menus ((arg0 debug-menu-context)) +(defun popup-menu-context-make-default-menus ((arg0 debug-menu-context)) (debug-menu-make-from-template arg0 '(main-menu @@ -3951,7 +3950,7 @@ (popup-menu-context-make-default-menus *popup-menu-context*) -(defun-debug menu-respond-to-pause () +(defun menu-respond-to-pause () (case *master-mode* (('menu) (if (cpad-hold? 0 l3) @@ -3967,12 +3966,12 @@ #f ) -(defun-debug *menu-hook* () +(defun *menu-hook* () (debug-menus-handler *debug-menu-context*) (debug-menus-handler *popup-menu-context*) ) -(#when (user? dass) +(#when PC_PORT (defmacro new-dm-function (text var func) `(new 'debug 'debug-menu-item-function ,text ,var (the-as (function int object) ,func)) @@ -3987,7 +3986,7 @@ `(new 'debug 'debug-menu-item-submenu ,text ,menu) ) -(defun-debug dm-want-level-toggle-pick-func ((arg0 pair) (arg1 debug-menu-msg)) +(defun dm-want-level-toggle-pick-func ((arg0 pair) (arg1 debug-menu-msg)) (let* ((levname (the-as symbol (car arg0))) (info (the-as level-load-info (-> levname value))) (idx (the int (cdr arg0))) @@ -4006,7 +4005,7 @@ ) ) -(defun-debug dm-display-level-toggle-pick-func ((arg0 symbol) (arg1 debug-menu-msg)) +(defun dm-display-level-toggle-pick-func ((arg0 symbol) (arg1 debug-menu-msg)) (let ((the-level (level-get *level* arg0))) (if (not the-level) (return 'invalid) @@ -4022,7 +4021,7 @@ ) ) -(defun-debug debug-menu-make-load-want-menu ((ctx debug-menu-context) (lev-idx int)) +(defun debug-menu-make-load-want-menu ((ctx debug-menu-context) (lev-idx int)) (let ((want-menu (new 'debug 'debug-menu ctx "Level want menu"))) @@ -4038,7 +4037,7 @@ ) ) -(defun-debug debug-menu-make-load-display-menu ((ctx debug-menu-context)) +(defun debug-menu-make-load-display-menu ((ctx debug-menu-context)) (let ((display-menu (new 'debug 'debug-menu ctx "Level display menu"))) @@ -4054,7 +4053,7 @@ ) ) -(defun-debug debug-menu-make-load-teleport-menu ((ctx debug-menu-context)) +(defun debug-menu-make-load-teleport-menu ((ctx debug-menu-context)) (let ((teleport-menu (new 'debug 'debug-menu ctx "Camera teleport menu"))) @@ -4083,9 +4082,19 @@ ) ) -(defun-debug debug-menu-make-load-menu ((ctx debug-menu-context)) +(defun debug-menu-make-load-menu ((ctx debug-menu-context)) (let ((load-menu (new 'debug 'debug-menu ctx "Load menu"))) (debug-menu-append-item load-menu (new-dm-bool "Level Border" *display-level-border* dm-boolean-toggle-pick-func)) + (debug-menu-append-item load-menu (debug-menu-make-from-template ctx '(flag + "border-mode" + #f + (lambda ((arg0 int) (arg1 debug-menu-msg)) + (if (= arg1 (debug-menu-msg press)) + (set! (-> *setting-control* default border-mode) (not (-> *setting-control* default border-mode))) + ) + (-> *setting-control* default border-mode) + ) + ))) (debug-menu-append-item load-menu (debug-menu-make-load-want-menu ctx 0)) ;; Want 0 (debug-menu-append-item load-menu (debug-menu-make-load-want-menu ctx 1)) ;; Want 1 @@ -4096,14 +4105,167 @@ ) ) +(defmacro dm-lambda-boolean-flag (val) + "helper macro for making boolean buttons that don't just access symbols directly" + `(lambda (arg (msg debug-menu-msg)) + (if (= msg (debug-menu-msg press)) + (not! ,val) + ) + ,val) + ) + +(defmacro dm-lambda-int-var (val) + "helper macro for making int buttons" + `(lambda (arg (msg debug-menu-msg) (newval int)) + (cond + ((= msg (debug-menu-msg press)) + (set! ,val newval) + ) + (else + ,val + ) + )) + ) + +(defmacro dm-lambda-meters-var (val) + "helper macro for making meters buttons" + `(lambda (arg (msg debug-menu-msg) (newval float)) + (cond + ((= msg (debug-menu-msg press)) + (set! ,val (meters newval)) + ) + (else + (* (1/ METER_LENGTH) ,val) + ) + )) + ) + +(defun dm-lod-int ((arg0 int) (arg1 debug-menu-msg) (arg2 int) (arg3 int)) + (when (= arg1 (debug-menu-msg press)) + (case (/ arg0 8) + ((0) (set! (-> *pc-settings* lod-force-tfrag) arg2)) + ((1) (set! (-> *pc-settings* lod-force-tie) arg2)) + ((2) (set! (-> *pc-settings* lod-force-ocean) arg2)) + ((3) (set! (-> *pc-settings* lod-force-actor) arg2)) + ) + ) + (case (/ arg0 8) + ((0) (-> *pc-settings* lod-force-tfrag)) + ((1) (-> *pc-settings* lod-force-tie)) + ((2) (-> *pc-settings* lod-force-ocean)) + ((3) (-> *pc-settings* lod-force-actor)) + (else arg3) + ) + ) + (when (-> *debug-menu-context* root-menu) (debug-menu-append-item (-> *debug-menu-context* root-menu) (debug-menu-make-load-menu *debug-menu-context*)) ;; Entity menu TODO ;; Music menu TODO ;; Secrets menu TODO ;; Scene menu TODO - ;; PC Settings menu TODO - ;; Other menu TODO + + (debug-menu-append-item (-> *debug-menu-context* root-menu) + (debug-menu-make-from-template *debug-menu-context* + '(menu "PC Settings" + (flag "Debug" #f (dm-lambda-boolean-flag (-> *pc-settings* debug?))) + (flag "Use native vis" #f (dm-lambda-boolean-flag (-> *pc-settings* use-vis?))) + (function "Toggle game aspect" #f (lambda () + (cond + ((= (-> *setting-control* default aspect-ratio) 'aspect4x3) + (set-aspect-ratio 'aspect16x9) + (set! (-> *setting-control* default aspect-ratio) 'aspect16x9) + ) + (else + (set-aspect-ratio 'aspect4x3) + (set! (-> *setting-control* default aspect-ratio) 'aspect4x3) + ) + ) + )) + (flag "Auto aspect" #f (dm-lambda-boolean-flag (-> *pc-settings* aspect-ratio-auto?))) + (menu "Aspect test" + (function "4 x 3" #f (lambda () (set-aspect! *pc-settings* 4 3))) + (function "16 x 9" #f (lambda () (set-aspect! *pc-settings* 16 9))) + (function "64 x 27 (21:9)" #f (lambda () (set-aspect! *pc-settings* 64 27))) + (function "16 x 10" #f (lambda () (set-aspect! *pc-settings* 16 10))) + (function "2 x 1" #f (lambda () (set-aspect! *pc-settings* 2 1))) + (function "37 x 20" #f (lambda () (set-aspect! *pc-settings* 37 20))) + (function "21 x 9" #f (lambda () (set-aspect! *pc-settings* 21 9))) + (function "64 x 18" #f (lambda () (set-aspect! *pc-settings* 64 18))) + (int-var "Custom aspect X" #f (dm-lambda-int-var (-> *pc-settings* aspect-custom-x)) 20 1 #t 1 1000) + (int-var "Custom aspect Y" #f (dm-lambda-int-var (-> *pc-settings* aspect-custom-y)) 20 1 #t 1 1000) + (function "Custom" #f (lambda () (set-aspect! *pc-settings* (-> *pc-settings* aspect-custom-x) (-> *pc-settings* aspect-custom-y)))) + ) + (menu "Fullscreen" + (function "Windowed" #f (lambda () (set-fullscreen! *pc-settings* #f))) + (function "Fullscreen" #f (lambda () (set-fullscreen! *pc-settings* #t))) + (function "Borderless" #f (lambda () (set-fullscreen! *pc-settings* 'borderless))) + ) + (menu "Sizes" + (function "640 x 480" #f (lambda () (set-size! *pc-settings* 640 480))) + (function "720 x 540" #f (lambda () (set-size! *pc-settings* 720 540))) + (function "960 x 540" #f (lambda () (set-size! *pc-settings* 960 540))) + (function "800 x 600" #f (lambda () (set-size! *pc-settings* 800 600))) + (function "960 x 720" #f (lambda () (set-size! *pc-settings* 960 720))) + (function "1280 x 720" #f (lambda () (set-size! *pc-settings* 1280 720))) + (function "1024 x 768" #f (lambda () (set-size! *pc-settings* 1024 768))) + (function "1366 x 768" #f (lambda () (set-size! *pc-settings* 1366 768))) + (function "1280 x 960" #f (lambda () (set-size! *pc-settings* 1280 960))) + (function "1440 x 1080" #f (lambda () (set-size! *pc-settings* 1440 1080))) + (function "1920 x 1080" #f (lambda () (set-size! *pc-settings* 1920 1080))) + (function "1920 x 1440" #f (lambda () (set-size! *pc-settings* 1920 1440))) + (function "2560 x 1440" #f (lambda () (set-size! *pc-settings* 2560 1440))) + (function "2880 x 2160" #f (lambda () (set-size! *pc-settings* 2880 2160))) + (function "3840 x 2160" #f (lambda () (set-size! *pc-settings* 3840 2160))) + ) + (flag "Letterbox" #f (dm-lambda-boolean-flag (-> *pc-settings* letterbox?))) + (flag "Skip movies" #f (dm-lambda-boolean-flag (-> *pc-settings* skip-movies?))) + (flag "Subtitles" #f (dm-lambda-boolean-flag (-> *pc-settings* subtitles?))) + (flag "Hinttitles" #f (dm-lambda-boolean-flag (-> *pc-settings* hinttitles?))) + (menu "Game fixes" + (flag "sagecage crash" #f (dm-lambda-boolean-flag (-> *pc-settings* fixes crash-sagecage))) + (flag "memory crash" #f (dm-lambda-boolean-flag (-> *pc-settings* fixes crash-dma))) + (flag "light eco crash" #f (dm-lambda-boolean-flag (-> *pc-settings* fixes crash-light-eco))) + (flag "softlock pelican" #f (dm-lambda-boolean-flag (-> *pc-settings* fixes lockout-pelican))) + (flag "softlock pipegame" #f (dm-lambda-boolean-flag (-> *pc-settings* fixes lockout-pipegame))) + (flag "softlock gambler" #f (dm-lambda-boolean-flag (-> *pc-settings* fixes lockout-gambler))) + (flag "fix movies" #f (dm-lambda-boolean-flag (-> *pc-settings* fixes fix-movies))) + (flag "fix credits" #f (dm-lambda-boolean-flag (-> *pc-settings* fixes fix-credits))) + ) + (menu "PS2 settings" + (flag "PS2 Load speed" #f (dm-lambda-boolean-flag (-> *pc-settings* ps2-read-speed?))) + (flag "PS2 Particles" #f (dm-lambda-boolean-flag (-> *pc-settings* ps2-parts?))) + (flag "PS2 Music" #f (dm-lambda-boolean-flag (-> *pc-settings* ps2-music?))) + (flag "PS2 Sound effects" #f (dm-lambda-boolean-flag (-> *pc-settings* ps2-se?))) + (flag "PS2 Hints" #f (dm-lambda-boolean-flag (-> *pc-settings* ps2-hints?))) + ) + (menu "Level of detail" + (flag "PS2 LOD " #f (dm-lambda-boolean-flag (-> *pc-settings* ps2-lod-dist?))) + (int-var "LOD Tfrag" 0 dm-lod-int 0 1 #t 0 3) + (int-var "LOD Tie" 1 dm-lod-int 0 1 #t 0 3) + (int-var "LOD Ocean" 2 dm-lod-int 0 1 #t 0 3) + (int-var "LOD Actor" 3 dm-lod-int 0 1 #t 0 3) + ) + ;(flag "Alt load boundaries" #f (dm-lambda-boolean-flag (-> *pc-settings* new-lb?))) + (flag "Display actor bank" #f (dm-lambda-boolean-flag (-> *pc-settings* display-actor-bank))) + (flag "Pad display" #f (dm-lambda-boolean-flag (-> *pc-settings* debug-pad-display))) + (function "Reset" #f (lambda () (reset *pc-settings*))) + (function "Save" #f (lambda () (write-to-file *pc-settings* PC_SETTINGS_FILE_NAME))) + (function "Load" #f (lambda () (read-from-file *pc-settings* PC_SETTINGS_FILE_NAME))) + ) + ) + ) + (debug-menu-append-item (-> *debug-menu-context* root-menu) + (debug-menu-make-from-template *debug-menu-context* + '(menu "Other" + (flag "DECI Count" *display-deci-count* dm-boolean-toggle-pick-func) + (flag "Actor graph" *display-actor-graph* dm-boolean-toggle-pick-func) + (flag "Update vis outside bsp" *update-leaf-when-outside-bsp* dm-boolean-toggle-pick-func) + (float-var "Actor birth dist" #f (dm-lambda-meters-var (-> *ACTOR-bank* birth-dist)) 20 1 #t 0 10000 1) + (float-var "Actor pause dist" #f (dm-lambda-meters-var (-> *ACTOR-bank* pause-dist)) 20 1 #t 0 10000 1) + ) + ) + ) ) ) diff --git a/goal_src/engine/debug/menu.gc b/goal_src/engine/debug/menu.gc index c66403d2a6..c03ea8a444 100644 --- a/goal_src/engine/debug/menu.gc +++ b/goal_src/engine/debug/menu.gc @@ -355,7 +355,7 @@ (set! (-> item fval) range-min) (set! (-> item fval) 0.0) ) - + ;; note: the return value of the callback is treated as an integer and int->float converted. This is a bug in the original code. (if callback (set! (-> item fval) @@ -375,7 +375,7 @@ (set! (-> gp-0 refresh-delay) 31) (set! (-> gp-0 refresh-ctr) (-> gp-0 refresh-delay)) (set! (-> gp-0 id) id) - (set! max-chars + (set! max-chars (if (< 3 max-chars) max-chars 3 @@ -443,7 +443,7 @@ (defun debug-menu-context-default-selection ((ctxt debug-menu-context) (keep-current symbol)) "Set the menu to a default selection. If keep-current-selection is set to #t, this will only change the selection if nothing is selected yet." - + ;; sel-length = 0 means nothing is selected (when (or (zero? (-> ctxt sel-length)) (not keep-current)) (let ((menu (-> ctxt root-menu))) @@ -502,7 +502,7 @@ (defun debug-menu-context-set-root-menu ((context debug-menu-context) (menu debug-menu)) "Set the root menu and reset everything." - + ;; deactivate, if we are active (let ((active (-> context is-active))) (if active @@ -512,7 +512,7 @@ ;; reset (debug-menu-context-default-selection context #f) ;; activate if needed - (if active + (if active (debug-menu-context-send-msg context (debug-menu-msg activate) (debug-menu-dest activation)) ) ) @@ -559,7 +559,7 @@ (defun debug-menu-func-decode ((arg0 object)) "Get a function. The input can be a symbol or a function. Otherwise it will give you the nothing function." (let ((v1-1 (rtype-of arg0))) - (the-as function + (the-as function (cond ((or (= v1-1 symbol) (= v1-1 type)) (-> (the-as symbol arg0) value) @@ -637,14 +637,14 @@ (else (set! s5-0 (cond ((= s4-0 'flag) - (new 'debug 'debug-menu-item-flag + (new 'debug 'debug-menu-item-flag s5-1 (the-as int (caddr arg1)) (the (function int debug-menu-msg object) (debug-menu-func-decode (cadddr arg1))) ) ) ((or (= s4-0 0) (= s4-0 'function)) - (new 'debug 'debug-menu-item-function + (new 'debug 'debug-menu-item-function s5-1 (the-as int (caddr arg1)) (the (function int object) (debug-menu-func-decode (cadddr arg1))) @@ -667,11 +667,12 @@ (/ (the-as int (ref arg1 8)) 8) (= s4-0 'hex-var) ) - (set! (-> (the-as debug-menu-item-var s5-0) ifloat-p) #t) + ;; changed... i have no idea what they were doing here + (set! (-> (the-as debug-menu-item-var s5-0) ifloat-p) (= s4-0 'int-var-gat1));;#t) s5-0 ) ((= s4-0 'float-var) - (set! s5-0 (new 'debug 'debug-menu-item-var s5-1 (the-as int (cddr arg1)) (the-as int (ref arg1 4)))) + (set! s5-0 (new 'debug 'debug-menu-item-var s5-1 (the-as int (caddr arg1)) (the-as int (ref arg1 4)))) (debug-menu-item-var-make-float (the-as debug-menu-item-var s5-0) (the-as (function int debug-menu-msg float float float) (debug-menu-func-decode (cadddr arg1))) @@ -760,6 +761,7 @@ (with-dma-buffer-add-bucket ((s3-0 (-> (current-frame) debug-buf)) (bucket-id debug-draw1)) ;; NOTE: the draw-string-adv advances too far on widescreen. + ;; NOTE 2: should be fixed? (draw-string-adv (-> item name) s3-0 s5-0) (draw-string-adv "..." s3-0 s5-0) ) @@ -771,7 +773,7 @@ "Draw the text for a function entry. Also updates the timer for the highlight." (let ((v1-2 (-> item parent context font))) (set-origin! v1-2 x y) - (set! (-> v1-2 color) + (set! (-> v1-2 color) (cond ((> (-> item hilite-timer) 0) ;; if the hilite is >0, we ran the function successfully, so we hilite in blue for a bit @@ -805,7 +807,7 @@ "Draw the text for a flag." (let ((v1-2 (-> item parent context font))) (set-origin! v1-2 x y) - (set! (-> v1-2 color) + (set! (-> v1-2 color) (cond ((= (-> item is-on) 'invalid) (font-color flat-dark-purple) ;; can't use this one. @@ -836,7 +838,7 @@ "Draw the text for a variable" (let ((s5-0 (-> item parent context font))) (set-origin! s5-0 x y) - (set! (-> s5-0 color) + (set! (-> s5-0 color) (cond ((zero? submenus) (if (-> item grabbed-joypad-p) @@ -864,7 +866,7 @@ (else ;; not enough room. normally just draw ... (draw-string "..." s1-0 s5-0) - + ;; display the whole thing if: we're selected and there are no submenus. (set! selected (and (zero? submenus) selected)) (when selected @@ -882,7 +884,7 @@ (defun debug-menu-item-render ((item debug-menu-item) (x int) (y int) (submenus int) (selected symbol)) "Draw an item. This feels like it should have been a method..." - + ;; do a refresh, if it's time. (when (> (-> item refresh-delay) 0) (+! (-> item refresh-ctr) -1) @@ -891,7 +893,7 @@ (debug-menu-item-send-msg item (debug-menu-msg update)) ) ) - + ;; call the appropriate render function. (cond ((= (-> item type) debug-menu-item-submenu) @@ -916,7 +918,7 @@ (defun debug-menu-render ((menu debug-menu) (x-pos int) (y-pos int) (selected debug-menu-node) (submenus int)) "Render a menu." - + ;; draw the background (let ((v1-0 0)) (let* ((a0-1 (-> menu items)) @@ -938,9 +940,10 @@ ) (with-dma-buffer-add-bucket ((s0-0 (-> (current-frame) debug-buf)) (bucket-id debug-draw1)) - (draw-sprite2d-xy s0-0 x-pos y-pos (-> menu pix-width) (-> menu pix-height) (static-rgba #x00 #x00 #x00 #x40)) + ;; PC PORT : fixed for widescreen + (draw-sprite2d-xy s0-0 (correct-x-int x-pos) y-pos (correct-x-int (-> menu pix-width)) (-> menu pix-height) (static-rgba #x00 #x00 #x00 #x40)) ) - + ;; draw each item (let* ((s3-1 (+ x-pos 3)) (s2-1 (+ y-pos 3)) @@ -948,11 +951,11 @@ (s0-1 (car s1-1)) ) (while (not (null? s1-1)) - + ;; draw > on the selected object (when (= s0-1 selected) ;; dim it if it's in a parent menu. - (set! (-> menu context font color) + (set! (-> menu context font color) (if (nonzero? submenus) (font-color dim-gray) (font-color dim-white) @@ -964,7 +967,7 @@ (draw-string ">" sv-16 (-> menu context font)) ) ) - + ;; actually draw the item. (debug-menu-item-render (the-as debug-menu-item s0-1) (+ s3-1 12) s2-1 submenus (= s0-1 selected)) (+! s2-1 8) @@ -1000,7 +1003,7 @@ (defun debug-menu-context-select-next-or-prev-item ((arg0 debug-menu-context) (arg1 int)) "Go up or down 1 in the currently open thing. The sign of arg1 determines direction" (local-vars (v1-6 object)) - + ;; search for the currently selected thing. (let ((s5-0 (-> arg0 sel-menu (+ (-> arg0 sel-length) -1)))) (let ((a2-0 (-> s5-0 selected-item)) diff --git a/goal_src/engine/dma/dma-buffer.gc b/goal_src/engine/dma/dma-buffer.gc index 155f2c821c..972f7afd53 100644 --- a/goal_src/engine/dma/dma-buffer.gc +++ b/goal_src/engine/dma/dma-buffer.gc @@ -55,7 +55,7 @@ ;; these two were added to make it easier. (gif0 uint64 :offset 16) (gif1 uint64 :offset 24) - + (quad uint128 2 :offset 0) ) :method-count-assert 9 @@ -126,15 +126,15 @@ (defmacro dma-buffer-add-base-type (buf pkt dma-type &rest body) "Base macro for adding stuff to a dma-buffer. Don't use this directly!" - + (with-gensyms (dma-buf) `(let* ((,dma-buf ,buf) (,pkt (the-as ,dma-type (-> ,dma-buf base)))) - + ,@body - + (set! (-> ,dma-buf base) (&+ (the-as pointer ,pkt) (size-of ,dma-type))) - + ) ) ) @@ -142,15 +142,15 @@ (defmacro dma-buffer-add-base-data (buf data-type forms) "Base macro for adding data words to a dma-buffer. Each form in forms is converted into data-type and added to the buffer. NO TYPE CHECKING is performed, so be careful!" - + (with-gensyms (dma-buf ptr) `(let* ((,dma-buf ,buf) (,ptr (the-as (pointer ,data-type) (-> ,dma-buf base)))) - + ,@(apply-i (lambda (x i) `(set! (-> ,ptr ,i) (the-as ,data-type ,x))) forms) - + (set! (-> ,dma-buf base) (&+ (the-as pointer ,ptr) (* ,(length forms) (size-of ,data-type)))) - + ) ) ) @@ -163,12 +163,12 @@ (with-gensyms (pkt) `(dma-buffer-add-base-type ,buf ,pkt dma-packet - + (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc ,qwc)) - + (set! (-> ,pkt vif0) ,vif0) (set! (-> ,pkt vif1) ,vif1) - + ) ) ) @@ -180,12 +180,12 @@ (with-gensyms (pkt) `(dma-buffer-add-base-type ,buf ,pkt dma-packet - + (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id ref) :qwc ,qwc :addr (the-as int ,addr))) - + (set! (-> ,pkt vif0) ,vif0) (set! (-> ,pkt vif1) ,vif1) - + ) ) ) @@ -195,39 +195,39 @@ (with-gensyms (pkt) `(dma-buffer-add-base-type ,buf ,pkt dma-packet - + (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id ret) :qwc 0)) - + (set! (-> ,pkt vif0) (new 'static 'vif-tag :cmd (vif-cmd nop))) (set! (-> ,pkt vif1) (new 'static 'vif-tag :cmd (vif-cmd nop))) - + ) ) ) (defmacro dma-buffer-add-gif-tag (buf giftag gifregs) "Add a giftag to a dma-buffer." - + (with-gensyms (pkt) `(dma-buffer-add-base-type ,buf ,pkt gs-gif-tag - + (set! (-> ,pkt tag) ,giftag) - + (set! (-> ,pkt regs) ,gifregs) - + ) ) ) (defmacro dma-buffer-add-uint64 (buf &rest body) "Add 64-bit words to a dma-buffer. See dma-buffer-add-base-data" - + `(dma-buffer-add-base-data ,buf uint64 ,body) ) (defmacro dma-buffer-add-uint128 (buf &rest body) "Add 128-bit words to a dma-buffer. See dma-buffer-add-base-data" - + `(dma-buffer-add-base-data ,buf uint128 ,body) ) @@ -295,7 +295,7 @@ "Add a gif cnt dma packet to a dma-buffer for setting GS registers. Up to 16 can be set at once. The packet runs the flusha command which waits for GIF transfer to end and VU1 microprogram to stop. reg-list is a list of pairs where the car is the register name and the cadr is the value to be set for that register." - + (let ((reg-count (length reg-list)) (qwc (+ (length reg-list) 1)) (reg-names (apply first reg-list)) @@ -307,12 +307,12 @@ (new 'static 'vif-tag :cmd (vif-cmd flusha)) (new 'static 'vif-tag :cmd (vif-cmd direct) :imm ,qwc) ) - + ;; gif tag for editing gs regs (dma-buffer-add-gif-tag ,buf (new 'static 'gif-tag64 :nloop 1 :eop 1 :nreg ,reg-count) (gs-reg-list a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d) ) - + ;; gs regs (dma-buffer-add-uint64 ,buf ,@(apply2 (lambda (x) x) (lambda (x) `(gs-reg64 ,x)) reg-datas reg-names) @@ -324,7 +324,7 @@ (defmacro dma-buffer-add-gs-set (buf &rest reg-list) "Add a gif cnt dma packet to a dma-buffer for setting GS registers. Up to 16 can be set at once. reg-list is a list of pairs where the car is the register name and the cadr is the value to be set for that register." - + (let ((reg-count (length reg-list)) (qwc (+ (length reg-list) 1)) (reg-names (apply first reg-list)) @@ -341,7 +341,7 @@ (dma-buffer-add-gif-tag ,buf (new 'static 'gif-tag64 :nloop 1 :eop 1 :nreg ,reg-count) (gs-reg-list a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d a+d) ) - + ;; gs regs (dma-buffer-add-uint64 ,buf ,@(apply2 (lambda (x) x) (lambda (x) `(gs-reg64 ,x)) reg-datas reg-names) @@ -354,21 +354,21 @@ "Start a cnt w/ vif direct to gif dma packet setup for the dma-buffer in bindings. With this, you can transfer data through PATH2 without having to setup the tag yourself. The qwc of the transfer is determined at runtime at the end of this block." - + (let ((buf (first bindings))) - + (with-gensyms (buf-start buf-qwc) `(let ((,buf-start (-> ,buf base))) - + ;; setup the dmatag for PATH2 transfer, qwc is 0 (patched later) (dma-buffer-add-cnt-vif2 ,buf 0 (new 'static 'vif-tag :cmd (vif-cmd nop)) (new 'static 'vif-tag :cmd (vif-cmd direct)) ) - + ;; things with this buffer! ,@body - + ;; patch qwc! just do the difference between the current ptr and the old one and turn it into qwords. ;; we take one qword out because it's the initial dmatag which isnt part of the count. ;; this rounds *down*, so make sure to fill the buffer in 128-bit boundaries. @@ -390,31 +390,64 @@ )) ) +(defmacro with-cnt-vif-block-qwc (bindings &rest body) + "Start a cnt w/ vif direct to gif dma packet setup for the dma-buffer in bindings. + With this, you can transfer data through PATH2 without having to setup the tag yourself. + The qwc of the transfer is determined at runtime at the end of this block. + WARNING: You MUST guarantee that the resulting qwc is NOT zero!" + + (let ((buf (first bindings))) + + (with-gensyms (buf-start buf-qwc) + `(let ((,buf-start (the-as dma-packet (-> ,buf base)))) + ;; dmatag will be added at the end so we reserve + (&+! (-> ,buf base) 16) + + ;; setup the dmatag for PATH2 transfer, qwc is 0 (patched later) + (dma-buffer-add-cnt-vif2 ,buf 0 + (new 'static 'vif-tag :cmd (vif-cmd nop)) + (new 'static 'vif-tag :cmd (vif-cmd direct)) + ) + + ;; things with this buffer! + ,@body + + ;; we make the dmatag now! its at the start. + (let ((,buf-qwc (/ (+ (- -16 (the-as int ,buf-start)) (the-as int (-> ,buf base))) 16))) + (set! (-> ,buf-start dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc ,buf-qwc)) + (set! (-> ,buf-start vif0) (new 'static 'vif-tag)) + (set! (-> ,buf-start vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm ,buf-qwc)) + ) + ) + + )) + ) + (defmacro with-dma-bucket (bindings &rest body) "Start a new dma-bucket in body that will be finished at the end. The bindings are the dma-buffer, dma-bucket and bucket-id respectively." - + (let ((buf (first bindings)) (bucket (second bindings)) (bucket-id (third bindings)) ) - + (with-gensyms (buf-start bucket-edge pkt) `(let ((,buf-start (-> ,buf base))) - + ,@body - + ;; we end the chain with a next. The bucket system will patch the next chain to this, ;; and then patch all the buckets togehter before sending the DMA. (let ((,bucket-edge (the (pointer dma-tag) (-> ,buf base)))) (let ((,pkt (the-as dma-packet (-> ,buf base)))) - + (set! (-> ,pkt dma) (new 'static 'dma-tag :id (dma-tag-id next))) (set! (-> ,pkt vif0) (new 'static 'vif-tag :cmd (vif-cmd nop))) (set! (-> ,pkt vif1) (new 'static 'vif-tag :cmd (vif-cmd nop))) - + (set! (-> ,buf base) (&+ (the-as pointer ,pkt) (size-of dma-packet))) - + ) (dma-bucket-insert-tag ,bucket ,bucket-id ,buf-start ;; the first thing in this chain, bucket will patch previous to this @@ -423,15 +456,15 @@ ) ) ) - + ) ) (defmacro with-dma-buffer-add-bucket (bindings &key (bucket-group (-> (current-frame) bucket-group)) &rest body) "Bind a dma-buffer to a variable and use it on a block to allow adding things to a new bucket. - usage: (with-dma-buffer-add-bucket ((buffer-name buffer) bucket-id) &rest body + usage: (with-dma-buffer-add-bucket ((buffer-name buffer) bucket-id) &rest body) example: (with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf)) (bucket-id debug-draw1)) ...)" - + `(let ((,(caar bindings) ,(cadar bindings))) (with-dma-bucket (,(caar bindings) ,bucket-group ,(cadr bindings)) ,@body diff --git a/goal_src/engine/game/main.gc b/goal_src/engine/game/main.gc index f22c8dd948..53d4354761 100644 --- a/goal_src/engine/game/main.gc +++ b/goal_src/engine/game/main.gc @@ -530,6 +530,10 @@ (stack-size-set! (-> self main-thread) 512) (let ((disp *display*)) + (#when PC_PORT + (read-from-file *pc-settings* PC_SETTINGS_FILE_NAME) + ) + ;; todo spad terrain context (set! *teleport* #t) (update-per-frame-settings! *setting-control*) @@ -659,7 +663,14 @@ ) ;; added - #| + (#when PC_PORT + (when (-> *pc-settings* debug?) + (draw *pc-settings* debug-buf) + ) + (when (-> *pc-settings* display-actor-bank) + (draw-string-xy (string-format "Actor Bank: ~,,1m/~,,1m (~D)" (-> *ACTOR-bank* pause-dist) (-> *ACTOR-bank* birth-dist) (-> *ACTOR-bank* birth-max)) debug-buf 512 232 (font-color default) (font-flags shadow kerning right)) + ) + ) (let ( (remain (&- (-> global top) (-> global current))) (total (&- (-> global top) (-> global base))) @@ -669,13 +680,11 @@ (* 100.0 (/ (the float remain) (the float total))) ) ) - - ;; added - (format *stdcon* "~3LDMA global: ~d debug: ~d~0L~%" + (format *stdcon* "~3Lfree DMA global: ~d debug: ~d~0L~%" (dma-buffer-free (-> disp frames (-> disp on-screen) frame global-buf)) (dma-buffer-free (-> disp frames (-> disp on-screen) frame debug-buf)) ) - + #| ;; added, prints some level status. (dotimes (i 2) (let ((level-heap (-> *level* level i heap))) @@ -744,10 +753,10 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (swap-display disp) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - + ;; teleport stuff ;; perf stats - + (process-particles) @@ -757,8 +766,12 @@ (level-update *level*) ;; also updates settings. (mc-run) ;; auto save check - ;; suspend + (#when PC_PORT + (update *pc-settings*) + ) + + ;; suspend (suspend) ) ) diff --git a/goal_src/engine/game/video.gc b/goal_src/engine/game/video.gc index 6f8f7b80c4..0de779ef31 100644 --- a/goal_src/engine/game/video.gc +++ b/goal_src/engine/game/video.gc @@ -5,20 +5,29 @@ ;; name in dgo: video ;; dgos: GAME, ENGINE -;; definition for function set-video-mode -;; INFO: Return type mismatch int vs none. +;; DECOMP BEGINS + (defun set-video-mode ((arg0 symbol)) - (case arg0 + (case arg0 (('ntsc) (set! (-> *video-parms* screen-sy) 224) (set! (-> *setting-control* default screenx) 0) (set! (-> *setting-control* default screeny) 8) (set! (-> *video-parms* screen-pages-high) 7) (set! (-> *video-parms* relative-y-scale) 1.0) - (set! *ticks-per-frame* 9765) + (set! *ticks-per-frame* 9765) ;; 585900 total? (set! (-> *math-camera* isometric vector 1 y) 0.5) - (set! (-> *math-camera* y-pix) 112.0) - (set! (-> *math-camera* y-clip) 448.0) + (#cond + (PC_PORT + ;; discard scissoring area + (set! (-> *math-camera* y-pix) 128.0) + (set! (-> *math-camera* y-clip) 512.0) + ) + (#t + (set! (-> *math-camera* y-pix) 112.0) + (set! (-> *math-camera* y-clip) 448.0) + ) + ) (set! (-> *shadow-data* texoffset y) 112.5) ) (('pal) @@ -27,7 +36,7 @@ (set! (-> *setting-control* default screeny) 24) (set! (-> *video-parms* screen-pages-high) 8) (set! (-> *video-parms* relative-y-scale) 1.1428572) - (set! *ticks-per-frame* #x2dc6) + (set! *ticks-per-frame* 11718) (set! (-> *math-camera* isometric vector 1 y) 0.4375) (set! (-> *math-camera* y-pix) 128.0) (set! (-> *math-camera* y-clip) 512.0) @@ -40,44 +49,27 @@ (set! (-> *video-parms* screen-miny) (- 2048 (-> *video-parms* screen-hy))) (set! (-> *video-parms* screen-maxy) (+ (-> *video-parms* screen-hy) 2048)) (set! (-> *video-parms* screen-masky) (+ (-> *video-parms* screen-sy) -1)) - (set! - (-> *pause-context* origin y) - (the float (+ (-> *video-parms* screen-sy) -54)) - ) + (set! (-> *pause-context* origin y) (the float (+ (-> *video-parms* screen-sy) -54))) (set! (-> *pause-context* height) (the float (-> *video-parms* screen-sy))) - (set! - (-> *font-default-matrix* vector 1 y) - (-> *video-parms* relative-y-scale) - ) - (set! - (-> *font-default-matrix* vector 3 y) - (- (the float (-> *video-parms* screen-hy))) - ) + (set! (-> *font-default-matrix* vector 1 y) (-> *video-parms* relative-y-scale)) + (set! (-> *font-default-matrix* vector 3 y) (- (the float (-> *video-parms* screen-hy)))) (set! (-> *video-parms* relative-y-scale-reciprical) 1.0) (set! *profile-y* (+ (-> *video-parms* screen-miny) 8)) (set! (-> *video-parms* set-video-mode) #t) - - ;; NOTE: added nonzero check - (if (nonzero? set-hud-aspect-ratio) - (set-hud-aspect-ratio (get-aspect-ratio) arg0) - ) + (set-hud-aspect-ratio (get-aspect-ratio) arg0) (if *progress-process* (adjust-ratios (-> *progress-process* 0) (get-aspect-ratio) arg0) ) - (let ((v0-3 0)) - ) + 0 (none) ) -;; definition for function get-video-mode (defun get-video-mode () (-> *setting-control* current video-mode) ) -;; definition for function set-aspect-ratio -;; INFO: Return type mismatch int vs none. (defun set-aspect-ratio ((arg0 symbol)) - (case arg0 + (case arg0 (('aspect4x3) (set! (-> *video-parms* relative-x-scale) 1.0) (set! (-> *video-parms* relative-x-scale-reciprical) 1.0) @@ -87,24 +79,19 @@ (set! (-> *video-parms* relative-x-scale-reciprical) 1.3333334) ) ) - (set! - (-> *font-default-matrix* vector 0 x) - (-> *video-parms* relative-x-scale) - ) - - ;; NOTE: added. - (if (nonzero? set-hud-aspect-ratio) - (set-hud-aspect-ratio arg0 (get-video-mode)) - ) + (set! (-> *font-default-matrix* vector 0 x) (-> *video-parms* relative-x-scale)) + (set-hud-aspect-ratio arg0 (get-video-mode)) (if *progress-process* (adjust-ratios (-> *progress-process* 0) arg0 (get-video-mode)) ) - (let ((v0-2 0)) - ) + 0 (none) ) -;; definition for function get-aspect-ratio (defun get-aspect-ratio () (-> *setting-control* current aspect-ratio) ) + + + + diff --git a/goal_src/engine/gfx/font.gc b/goal_src/engine/gfx/font.gc index 6941181a84..22a5add345 100644 --- a/goal_src/engine/gfx/font.gc +++ b/goal_src/engine/gfx/font.gc @@ -692,7 +692,10 @@ ) (.mul.vf vf25 vf25 vf1 :mask #b11) (.mul.vf vf23 vf23 vf1 :mask #b11) - (.mul.vf vf24 vf24 vf1 :mask #b11) + ;; hack! fixes small font widescreen + (if (logtest? (-> arg2 flags) (font-flags large right middle)) + (.mul.vf vf24 vf24 vf1 :mask #b11) + ) (let ((fw *font-work*)) (set! (-> fw buf) context) (let ((dma-out (-> context base))) @@ -1653,7 +1656,10 @@ ) (.mul.vf vf25 vf25 vf1 :mask #b11) (.mul.vf vf23 vf23 vf1 :mask #b11) - (.mul.vf vf24 vf24 vf1 :mask #b11) + ;; hack! fixes small font widescreen + (if (logtest? (-> arg1 flags) (font-flags large right middle)) + (.mul.vf vf24 vf24 vf1 :mask #b11) + ) (let ((a1-4 *font-work*)) (set! (-> a1-4 str-ptr) (the-as uint arg0)) (set! (-> a1-4 flags) (the-as font-flags v1-0)) diff --git a/goal_src/engine/gfx/hw/video-h.gc b/goal_src/engine/gfx/hw/video-h.gc index 0fdc36e697..b4cf12bf52 100644 --- a/goal_src/engine/gfx/hw/video-h.gc +++ b/goal_src/engine/gfx/hw/video-h.gc @@ -62,3 +62,8 @@ (define-extern set-hud-aspect-ratio (function symbol symbol none)) (define-extern set-aspect-ratio (function symbol none)) (define-extern set-video-mode (function symbol none)) + +(defmacro correct-x-int (pos) + `(the int (* (-> *video-parms* relative-x-scale) (the float ,pos))) + ) + diff --git a/goal_src/engine/level/level.gc b/goal_src/engine/level/level.gc index c98a31ae1c..503f5a353f 100644 --- a/goal_src/engine/level/level.gc +++ b/goal_src/engine/level/level.gc @@ -878,9 +878,9 @@ (set! (-> *level* loading-level) obj) (birth (-> obj bsp)) (set! (-> obj status) 'alive) - (load-dbg "copy perms~%") + ;;(load-dbg "copy perms~%") (copy-perms-to-level! *game-info* obj) - (load-dbg "send activate~%") + ;;(load-dbg "send activate~%") ;; note: this isn't a great name - the level isn't actually activated, just alive. (send-event *camera* 'level-activate (-> obj name)) (send-event *target* 'level-activate (-> obj name)) diff --git a/goal_src/engine/level/load-boundary.gc b/goal_src/engine/level/load-boundary.gc index 1e885fba8c..ade4a2b2e1 100644 --- a/goal_src/engine/level/load-boundary.gc +++ b/goal_src/engine/level/load-boundary.gc @@ -25,8 +25,6 @@ ;; Editor Rendering ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define-extern draw-boundary-cap (function load-boundary float dma-buffer symbol none)) -(define-extern draw-boundary-side (function load-boundary integer integer dma-buffer symbol none)) (define-extern triangulate-boundary (function load-boundary object)) (define-extern find-bounding-circle (function load-boundary none)) (define-extern check-boundary (function load-boundary none)) @@ -231,7 +229,7 @@ (none) ) ) - + (defun-debug draw-boundary-cap ((arg0 load-boundary) (arg1 float) (arg2 dma-buffer) (arg3 symbol)) (rlet ((vf27 :class vf)) (dotimes (s2-0 (-> arg0 tri-cnt)) @@ -309,10 +307,10 @@ (none) ) ) - + (defun-debug boundary-set-color ((arg0 lbvtx) (arg1 load-boundary-crossing-command)) "Set the color based on the color." - (case (-> arg1 cmd) + (case (-> arg1 cmd) (((load-boundary-cmd load)) (let ((v1-1 arg0)) (set! (-> v1-1 x) 128.0) @@ -378,119 +376,33 @@ (none) ) - + (defun-debug render-boundary ((arg0 load-boundary)) - (let* ((s3-0 (or (!= arg0 (-> *lb-editor-parms* boundary)) + (let ((s3-0 (or (!= arg0 (-> *lb-editor-parms* boundary)) (logtest? (-> *display* real-actual-frame-counter) 4) ) - ) - (s5-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) - (gp-0 (-> s5-0 base)) - ) - (let* ((v1-8 s5-0) - (a0-5 (the-as object (-> v1-8 base))) + )) + (with-dma-buffer-add-bucket ((s5-0 (-> (current-frame) global-buf)) (bucket-id debug-draw0)) + (dma-buffer-add-gs-set-flusha s5-0 + (zbuf-1 (new 'static 'gs-zbuf :zbp #x1c0 :psm (gs-psm ct24))) + (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest greater-equal) :aref #x26 :zte #x1 :ztst (gs-ztest greater-equal))) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + ) + (boundary-set-color (-> *boundary-polygon* 2) (-> arg0 cmd-fwd)) + (boundary-set-color (-> *boundary-polygon* 5) (-> arg0 cmd-bwd)) + (with-cnt-vif-block-qwc (s5-0) + (add-boundary-shader (new 'static 'texture-id :index #x33 :page #x2) s5-0) + (cond + ((logtest? (-> arg0 flags) (load-boundary-flags closed)) + (draw-boundary-cap arg0 (-> arg0 top-plane) s5-0 s3-0) ) - (set! (-> (the-as dma-packet a0-5) dma) - (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt)) - ) - (set! (-> (the-as dma-packet a0-5) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet a0-5) vif1) - (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1) - ) - (set! (-> v1-8 base) (&+ (the-as pointer a0-5) 16)) - ) - (let* ((v1-9 s5-0) - (a0-7 (the-as object (-> v1-9 base))) - ) - (set! (-> (the-as gs-gif-tag a0-7) tag) - (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3) - ) - (set! (-> (the-as gs-gif-tag a0-7) regs) - (new 'static 'gif-tag-regs - :regs0 (gif-reg-id a+d) - :regs1 (gif-reg-id a+d) - :regs2 (gif-reg-id a+d) - :regs3 (gif-reg-id a+d) - :regs4 (gif-reg-id a+d) - :regs5 (gif-reg-id a+d) - :regs6 (gif-reg-id a+d) - :regs7 (gif-reg-id a+d) - :regs8 (gif-reg-id a+d) - :regs9 (gif-reg-id a+d) - :regs10 (gif-reg-id a+d) - :regs11 (gif-reg-id a+d) - :regs12 (gif-reg-id a+d) - :regs13 (gif-reg-id a+d) - :regs14 (gif-reg-id a+d) - :regs15 (gif-reg-id a+d) - ) - ) - (set! (-> v1-9 base) (&+ (the-as pointer a0-7) 16)) - ) - (let* ((v1-10 s5-0) - (a0-9 (-> v1-10 base)) - ) - (set! (-> (the-as (pointer gs-zbuf) a0-9) 0) - (new 'static 'gs-zbuf :zbp #x1c0 :psm (gs-psm ct24)) - ) - (set! (-> (the-as (pointer gs-reg64) a0-9) 1) (gs-reg64 zbuf-1)) - (set! (-> (the-as (pointer gs-test) a0-9) 2) - (new 'static 'gs-test - :ate #x1 - :atst (gs-atest greater-equal) - :aref #x26 - :zte #x1 - :ztst (gs-ztest greater-equal) - ) - ) - (set! (-> (the-as (pointer gs-reg64) a0-9) 3) (gs-reg64 test-1)) - (set! (-> (the-as (pointer gs-alpha) a0-9) 4) - (new 'static 'gs-alpha :b #x1 :d #x1) - ) - (set! (-> (the-as (pointer gs-reg64) a0-9) 5) (gs-reg64 alpha-1)) - (set! (-> v1-10 base) (&+ a0-9 48)) - ) - (boundary-set-color (-> *boundary-polygon* 2) (-> arg0 cmd-fwd)) - (boundary-set-color (-> *boundary-polygon* 5) (-> arg0 cmd-bwd)) - (let ((s2-0 (the-as object (-> s5-0 base)))) - (&+! (-> s5-0 base) 16) - (add-boundary-shader (new 'static 'texture-id :index #x33 :page #x2) s5-0) - (cond - ((logtest? (-> arg0 flags) (load-boundary-flags closed)) - (draw-boundary-cap arg0 (-> arg0 top-plane) s5-0 s3-0) - ) - (else - (dotimes (s1-0 (the-as int (+ (-> arg0 num-points) -1))) - (draw-boundary-side arg0 s1-0 (+ s1-0 1) s5-0 s3-0) + (else + (dotimes (s1-0 (the-as int (+ (-> arg0 num-points) -1))) + (draw-boundary-side arg0 s1-0 (+ s1-0 1) s5-0 s3-0) + ) ) ) - ) - (close-sky-buffer s5-0) - (let ((v1-25 (/ (+ (- -16 (the-as int s2-0)) (the-as int (-> s5-0 base))) 16))) - (set! (-> (the-as dma-packet s2-0) dma) - (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-25) - ) - (set! (-> (the-as dma-packet s2-0) vif0) (new 'static 'vif-tag)) - (set! - (-> (the-as dma-packet s2-0) vif1) - (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm v1-25) - ) - ) - ) - (let ((a3-2 (-> s5-0 base))) - (let ((v1-29 (the-as object (-> s5-0 base)))) - (set! (-> (the-as dma-packet v1-29) dma) - (new 'static 'dma-tag :id (dma-tag-id next)) - ) - (set! (-> (the-as dma-packet v1-29) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet v1-29) vif1) (new 'static 'vif-tag)) - (set! (-> s5-0 base) (&+ (the-as pointer v1-29) 16)) - ) - (dma-bucket-insert-tag - (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug-draw0) - gp-0 - (the-as (pointer dma-tag) a3-2) + (close-sky-buffer s5-0) ) ) ) @@ -527,7 +439,7 @@ ) (defun-debug format-boundary-cmd ((arg0 load-boundary-crossing-command)) - (case (-> arg0 cmd) + (case (-> arg0 cmd) (((load-boundary-cmd load)) (format *stdcon* " LOAD(~A,~A)~%" (-> arg0 lev0) (-> arg0 lev1)) ) @@ -906,7 +818,7 @@ ) (defun-debug save-boundary-cmd ((arg0 load-boundary-crossing-command) (arg1 string) (arg2 object)) - (case (-> arg0 cmd) + (case (-> arg0 cmd) (((load-boundary-cmd load)) (format arg2 " :~S (load ~A ~A)~%" arg1 (-> arg0 lev0) (-> arg0 lev1)) ) @@ -2140,7 +2052,7 @@ (a0-86 s3-7) (a1-40 (the process-tree (ppointer->process (-> *setting-control* current movie)))) ) - (set! a1-40 + (set! a1-40 (cond (a1-40 a1-40 diff --git a/goal_src/engine/load/file-io.gc b/goal_src/engine/load/file-io.gc index 8306d39e46..333e1855c3 100644 --- a/goal_src/engine/load/file-io.gc +++ b/goal_src/engine/load/file-io.gc @@ -18,22 +18,34 @@ ;; It must be kept up to date with that definition as well. ;; 3). The C runtime constructs this type before anything is loaded. The sizes ;; must be kept up to date there as well. + (deftype file-stream (basic) ((flags uint32 :offset-assert 4) - (mode basic :offset-assert 8) + (mode symbol :offset-assert 8) (name string :offset-assert 12) (file uint32 :offset-assert 16) ) (:methods - (new (symbol type string basic) _type_) + (new (symbol type string symbol) _type_) ) :method-count-assert 9 :size-assert #x14 :flag-assert #x900000014 ) +(defconstant SCE_SEEK_SET 0) +(defconstant SCE_SEEK_CUR 1) +(defconstant SCE_SEEK_END 2) -(defmethod new file-stream ((allocation symbol) (type-to-make type) (name string) (mode basic)) +(defmacro file-stream-valid? (fs) + `(>= (the-as int (-> ,fs file)) 0) + ) + +(defmacro file-stream-tell (fs) + `(file-stream-seek ,fs 0 SCE_SEEK_CUR) + ) + +(defmethod new file-stream ((allocation symbol) (type-to-make type) (name string) (mode symbol)) "Allocate a file-stream and open it." (let ((stream (object-new allocation type-to-make))) (file-stream-open stream name mode) diff --git a/goal_src/engine/pc/pckernel-h.gc b/goal_src/engine/pc/pckernel-h.gc new file mode 100644 index 0000000000..21e24d1e87 --- /dev/null +++ b/goal_src/engine/pc/pckernel-h.gc @@ -0,0 +1,409 @@ +;;-*-Lisp-*- +(in-package goal) + +#| + + This file contains code that we need for the PC port of the game specifically. + It should be included as part of the game engine package (engine.cgo). + + This file contains various types and functions to store PC-specific information + and also to communicate between the game (GOAL) and the operating system. + This way we can poll, change and display information about the system the game + is running on, such as: + - display devices and their settings, such as fullscreen, DPI, refresh rate, etc. + - audio devices and their settings, such as audio latency, channel number, etc. + - graphics devices and their settings, such as resolution, FPS, anisotropy, shaders, etc. + - input devices and their settings, such as controllers, keyboards, mice, etc. + - information about the game window (position, size) + - PC-specific goodies, enhancements, fixes and settings. + - whatever else. + + If you do not want to include these PC things, you should exclude it from the build system. + + |# + + +(#when PC_PORT + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defglobalconstant PC_KERNEL_VERSION_BUILD #x0000) +(defglobalconstant PC_KERNEL_VERSION_REVISION #x0000) + +(defglobalconstant PC_KERNEL_VERSION_MINOR #x0000) +(defglobalconstant PC_KERNEL_VERSION_MAJOR #x0001) +(defglobalconstant PC_KERNEL_VERSION (logior + (ash PC_KERNEL_VERSION_MAJOR 48) + (ash PC_KERNEL_VERSION_MINOR 32) + (ash PC_KERNEL_VERSION_REVISION 16) + (ash PC_KERNEL_VERSION_BUILD 0) + )) + +(defconstant PS2_VOICE_AMOUNT 48) +(defconstant PC_VOICE_AMOUNT 256) + +(defconstant ASPECT_4X3 (/ 4.0 3.0)) +(defconstant ASPECT_16X9 (/ 16.0 9.0)) +(defconstant PC_BASE_WIDTH 640) +(defconstant PC_BASE_HEIGHT 480) + + +(defconstant PC_SETTINGS_FILE_NAME "game_config/pc-settings.txt") + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; types and enums +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + + +;; graphics renderers +(defenum pc-gfx-renderer + :type uint8 + (software) + (opengl) + (vulkan) + (direct3d) + ) + + +;; subtitle languages. +(defenum pc-subtitle-lang + :type uint16 + (english) + (french) + (german) + (spanish) + (italian) + (japanese) + (uk-english) + + ;; additional languages. + ;; these don't neccessarily have to work but I'm future-proofing a bit here, just in case. + + ;; languages that use the existing glyphs + (portuguese) + (finnish) + (swedish) + (danish) + (norwegian) + + ;; jak 1 has no glyphs for korean or cyrillic. + (korean) ;; future-proofing here + (russian) ;; same thing + + (custom 500) ;; temp + ) + + +;; concept arts +(defenum pc-jak1-concept-art + :bitfield #t + :type uint64 + (test) + ) + +;; secrets and goodies +(deftype pc-game-secrets (structure) + ((art pc-jak1-concept-art) ;; concept art unlocked + (music uint64 30) ;; flavas unlocked, for each track (there's like 30 musics, right?) + (hard-fish-hiscore int32) + (hard-rats? symbol) ;; enable this crap + (hard-rats-hiscore int32) + (hard-rats-hiwave int32) + (hero-mode? symbol) ;; unsure how this should work + (hud-map? symbol) ;; enable map in HUD/progress? + (hud-counters? symbol) ;; enable level orb counter/global buzzer counter? + ) + ) + +;; general fixes +(deftype pc-fixes (structure) + ((crash-sagecage symbol) ;; citadel + (crash-dma symbol) ;; general out of memory crash + (crash-light-eco symbol) ;; why does this one even happen? + (lockout-pelican symbol) ;; kill pelican during chase + (lockout-pipegame symbol) ;; last buzzer is pipegame + (lockout-gambler symbol) ;; talk without completing + (fix-movies symbol) ;; bad camera and single-frame crappiness + (fix-credits symbol) ;; one of the credits lines has the wrong color!! + ) + ) + +;; bingo integration. placeholder for now. +(deftype pc-bingo-info (structure) + () + ) + + +;; a 64-byte C-string. not sure if we need this. +(deftype pc-cstring-64 (structure) + ((chars uint8 64) + (last uint8 :offset 63) + ) + ) + + +;; generic device information: name and some ID +(deftype pc-device-info (structure) + ((id int) + (name pc-cstring-64 :inline) + ) + ) + + +;; input device information. comes with button mappings! +(deftype pc-pad-info (structure) + ((device-info pc-device-info :inline) + (buffered? symbol) + (valid? symbol) + (mapping int 16) + ) + ) + + +;; All of the configuration for the PC port in GOAL. Access things from here! +;; Includes some methods to change parameters. +(deftype pc-settings (basic) + ((version uint64) ;; version of this settings + + (target-fps int16) ;; the target framerate of the game + (width int32) ;; the width of the rendering, may not match window + (height int32) + (win-width int32) ;; the width of the display window + (win-height int32) + (dpi-x float) ;; DPI width scale + (dpi-y float) ;; DPI height scale + (aspect-ratio-auto? symbol) ;; if on, aspect ratio is calculated automatically. + (aspect-ratio float) ;; the desired aspect ratio. set auto to off and then this to 4/3 to force 4x3 aspect. + (fullscreen? symbol) ;; fullscreen status. can be #f, #t or borderless + (letterbox? symbol) ;; letterbox. #f = stretched + (vsync? symbol) ;; vsync. + (font-scale float) ;; font scaling. + + (os symbol) ;; windows, linux, macos + (user symbol) ;; username. not system username, just debug thing. + (debug? symbol) ;; more debug stuff just in case. + (new-lb? symbol) ;; different load boundary graphics. + (display-actor-bank symbol) ;; debug stuff. + (aspect-custom-x int) + (aspect-custom-y int) + (debug-pad-display symbol) + + (device-audio pc-device-info :inline) ;; used audio device + (device-screen pc-device-info :inline) ;; used display device + (device-gpu pc-device-info :inline) ;; used graphics device + (device-pad pc-pad-info 4 :inline) ;; used input devices, like controllers. + ;(device-keyboard pc-pad-info :inline) ;; keyboard input information. if nothing else, this must be usable. + (stick-deadzone float) ;; analog stick deadzone. 0-1 + + (audio-latency-ms int16) ;; audio latency in milliseconds + (audio-pan-override float) ;; audio pan modifier + (audio-volume-override float) ;; audio volume modifier + (audio-channel-nb int16) ;; audio channel amount. will be 48 on PS2 mode. + + (gfx-renderer pc-gfx-renderer) ;; the renderer to use + (gfx-resolution float) ;; for supersampling + (gfx-anisotropy float) ;; for anisotropy + + (ps2-read-speed? symbol) ;; emulate DVD loads + (ps2-parts? symbol) ;; if off, increase particle cap + (ps2-music? symbol) ;; if off, use .wav files stored somewhere + (ps2-se? symbol) ;; if off, use adjusted sound effects + (ps2-hints? symbol) ;; if off, enables extra game hints + + (ps2-lod-dist? symbol) ;; use original lod distances + (shrub-dist-mod float) ;; shrub render distance modifier + (lod-dist-mod float) ;; non-shrub lod distance modifier + (lod-force-tfrag int8) ;; tfrag lod tier override. 0 = highest detail + (lod-force-tie int8) ;; tie lod tier override + (lod-force-ocean int8) ;; ocean lod tier override + (lod-force-actor int8) ;; merc lod tier override + + (music-fade? symbol) ;; if off, music has no fade in + (use-vis? symbol) ;; if off, don't use vis trees. this MUST be off for custom (non-cropping) aspect ratios. + (skip-movies? symbol) ;; if on, enable cutscene skipping + (subtitles? symbol) ;; if on, cutscene subtitles will show up + (hinttitles? symbol) ;; if on, non-cutscene subtitles will show up + (subtitle-language pc-subtitle-lang) ;; language for subtitles + + (fixes pc-fixes :inline) ;; extra game fixes + + (bingo pc-bingo-info :inline) ;; bingo integration. does nothing for now. + + (secrets pc-game-secrets :inline) ;; hidden goodies and additional secrets! + + (scenes-seen uint8 197) ;; cutscenes that have been seen, by spool-anim (maybe use 8-char name or bits instead?) + ) + + (:methods + (new (symbol type) _type_) + (update (_type_) none) + (update-from-os (_type_) none) + (update-to-os (_type_) none) + (reset (_type_) none) + (reset-audio (_type_) none) + (reset-input (_type_) none) + (reset-gfx (_type_) none) + (reset-ps2 (_type_) none) + (reset-misc (_type_) none) + (reset-fixes (_type_) none) + (reset-extra (_type_) none) + (draw (_type_ dma-buffer) none) + (set-fullscreen! (_type_ symbol) int) + (set-size! (_type_ int int) int) + (set-aspect! (_type_ int int) int) + (read-from-file (_type_ string) symbol) + (write-to-file (_type_ string) symbol) + ) + ) + +;; information about a cutscene. placeholder. TODO look at jak 2 +(deftype pc-scene-info (structure) + ((name string) + (commands pair) + (level0 symbol) + (level1 symbol) + (level0-disp symbol) + (level1-disp symbol) + ) + ) + +(defconstant PC_TEMP_STRING_LEN 512) +(define *pc-temp-string* (new 'global 'string PC_TEMP_STRING_LEN (the-as string #f))) +(define *pc-settings* (the-as pc-settings #f)) +(format 0 "PC kernel version: ~D.~D~%" PC_KERNEL_VERSION_MAJOR PC_KERNEL_VERSION_MINOR) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; resets +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defmethod reset pc-settings ((obj pc-settings)) + "Set the default settings" + + ;(format #t "pc settings reset~%") + + (set! (-> obj version) PC_KERNEL_VERSION) + + (set! (-> obj user) #f) + (set! (-> obj debug?) #f) + (set! (-> obj new-lb?) #f) + (set! (-> obj display-actor-bank) #f) + (set! (-> obj debug-pad-display) #f) + (set! (-> obj font-scale) 1.0) + (set! (-> obj aspect-custom-x) 1) + (set! (-> obj aspect-custom-y) 1) + + (reset-gfx obj) + (reset-audio obj) + (reset-input obj) + (reset-ps2 obj) + (reset-misc obj) + (reset-fixes obj) + (reset-extra obj) + + (none)) + + +(defmethod reset-gfx pc-settings ((obj pc-settings)) + "Set the default graphics settings" + + (set! (-> obj target-fps) 60) + (set! (-> obj width) PC_BASE_WIDTH) + (set! (-> obj height) PC_BASE_HEIGHT) + (set! (-> obj use-vis?) #t) + (set! (-> obj aspect-ratio-auto?) #f) + (set! (-> obj fullscreen?) #f) + (set! (-> obj vsync?) #t) + (set! (-> obj letterbox?) #t) + + (none)) + +(defmethod reset-audio pc-settings ((obj pc-settings)) + "Set the default audio settings" + + (set! (-> obj audio-latency-ms) 80) + (set! (-> obj audio-pan-override) 0.0) + (set! (-> obj audio-volume-override) 1.0) + (set! (-> obj audio-channel-nb) PS2_VOICE_AMOUNT) + (none)) + +(defmethod reset-input pc-settings ((obj pc-settings)) + "Set the default input settings" + + (set! (-> obj stick-deadzone) 0.3) + (none)) + +(defmethod reset-ps2 pc-settings ((obj pc-settings)) + "Set the default ps2 settings" + + (set! (-> obj ps2-read-speed?) #f) + (set! (-> obj ps2-parts?) #t) + (set! (-> obj ps2-music?) #t) + (set! (-> obj ps2-se?) #t) + (set! (-> obj ps2-hints?) #t) + + (set! (-> obj ps2-lod-dist?) #f) + (set! (-> obj shrub-dist-mod) 1.0) + (set! (-> obj lod-dist-mod) 1.0) + (set! (-> obj lod-force-tfrag) 0) + (set! (-> obj lod-force-tie) 0) + (set! (-> obj lod-force-ocean) 0) + (set! (-> obj lod-force-actor) 0) + (none)) + +(defmethod reset-misc pc-settings ((obj pc-settings)) + "Set the default misc settings" + + (set! (-> obj music-fade?) #f) + (set! (-> obj skip-movies?) #t) + (set! (-> obj subtitles?) #t) + (set! (-> obj hinttitles?) #t) + (set! (-> obj subtitle-language) (pc-subtitle-lang english)) + (none)) + +(defmethod reset-fixes pc-settings ((obj pc-settings)) + "Set the default fixes settings" + + (set! (-> obj fixes crash-sagecage) #t) + (set! (-> obj fixes crash-dma) #t) + (set! (-> obj fixes crash-light-eco) #t) + (set! (-> obj fixes lockout-pelican) #t) + (set! (-> obj fixes lockout-pipegame) #t) + (set! (-> obj fixes lockout-gambler) #t) + (set! (-> obj fixes fix-movies) #f) + (set! (-> obj fixes fix-credits) #t) + (none)) + +(defmethod reset-extra pc-settings ((obj pc-settings)) + "Set the default goodies settings" + + (dotimes (i 197) + (set! (-> obj scenes-seen i) 0) + ) + (dotimes (i 30) + (set! (-> obj secrets music i) 0) + ) + + (set! (-> obj secrets art) (pc-jak1-concept-art)) + (set! (-> obj secrets hard-fish-hiscore) 0) + (set! (-> obj secrets hard-rats-hiscore) 0) + (set! (-> obj secrets hard-rats-hiwave) 0) + (set! (-> obj secrets hard-rats?) #f) + (set! (-> obj secrets hero-mode?) #f) + (set! (-> obj secrets hud-map?) #t) + (set! (-> obj secrets hud-counters?) #t) + (none)) + + + +) + + + diff --git a/goal_src/engine/pc/pckernel.gc b/goal_src/engine/pc/pckernel.gc new file mode 100644 index 0000000000..4f9ef1deee --- /dev/null +++ b/goal_src/engine/pc/pckernel.gc @@ -0,0 +1,579 @@ +;;-*-Lisp-*- +(in-package goal) + +#| + + This file contains code that we need for the PC port of the game specifically. + It should be included as part of the game engine package (engine.cgo). + + This file contains various types and functions to store PC-specific information + and also to communicate between the game (GOAL) and the operating system. + This way we can poll, change and display information about the system the game + is running on, such as: + - display devices and their settings, such as fullscreen, DPI, refresh rate, etc. + - audio devices and their settings, such as audio latency, channel number, etc. + - graphics devices and their settings, such as resolution, FPS, anisotropy, shaders, etc. + - input devices and their settings, such as controllers, keyboards, mice, etc. + - information about the game window (position, size) + - PC-specific goodies, enhancements, fixes and settings. + - whatever else. + + If you do not want to include these PC things, you should exclude it from the build system. + + |# + + +(#when PC_PORT + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; updates +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + + +(defmethod set-fullscreen! pc-settings ((obj pc-settings) (mode symbol)) + "toggles fullscreen mode" + + (if (= (-> obj fullscreen?) mode) ;; already fullscreen + (return 0)) + + (set! (-> obj fullscreen?) mode) + (pc-set-fullscreen + (cond ((= mode 'borderless) 2) + (mode 1) + (else 0) + ) + 0) + 0) + +(defmethod set-size! pc-settings ((obj pc-settings) (width int) (height int)) + "toggles fullscreen mode" + + (pc-set-window-size width height) + 0) + + +(defmethod set-aspect! pc-settings ((obj pc-settings) (aw int) (ah int)) + (let ((aspect (/ (the float aw) (the float ah)))) + (set! (-> *pc-settings* aspect-ratio) aspect) + (set! (-> *pc-settings* aspect-ratio-auto?) #f) + (set! (-> *pc-settings* use-vis?) #f) + ) + 0) + + + +(defmethod update-from-os pc-settings ((obj pc-settings)) + "Update settings from the PC kernel to GOAL." + + (set! (-> obj os) (pc-get-os)) + (pc-get-window-size (&-> obj win-width) (&-> obj win-height)) + (pc-get-window-scale (&-> obj dpi-x) (&-> obj dpi-y)) + + (when (-> obj use-vis?) + (if (= (-> *setting-control* default aspect-ratio) 'aspect4x3) + (set! (-> obj aspect-ratio) ASPECT_4X3) + (set! (-> obj aspect-ratio) ASPECT_16X9) + ) + ) + + (let ((win-aspect (/ (the float (-> obj win-width)) (the float (-> obj win-height))))) + (cond + ((and (not (-> obj use-vis?)) (-> obj aspect-ratio-auto?)) + ;; the window determines the resolution + (set! (-> obj aspect-ratio) win-aspect) + (set! (-> obj width) (-> obj win-width)) + (set! (-> obj height) (-> obj win-height)) + ) + ((> win-aspect (-> obj aspect-ratio)) + ;; too wide + (set! (-> obj width) (the int (* (-> obj aspect-ratio) (the float (-> obj win-height))))) + (set! (-> obj height) (-> obj win-height)) + ) + ((< win-aspect (-> obj aspect-ratio)) + ;; too tall + (set! (-> obj width) (-> obj win-width)) + (set! (-> obj height) (the int (/ (the float (-> obj win-width)) (-> obj aspect-ratio)))) + ) + (else + ;; just right + (set! (-> obj width) (-> obj win-width)) + (set! (-> obj height) (-> obj win-height)) + ) + ) + ) + + + (none)) + +(defmethod update-to-os pc-settings ((obj pc-settings)) + "Update settings from GOAL to the PC kernel." + + (cond + ((-> obj letterbox?) + (pc-set-letterbox (-> obj width) (-> obj height)) + ) + (else + (pc-set-letterbox (-> obj win-width) (-> obj win-height)) + ) + ) + + (none)) + +(defmethod update pc-settings ((obj pc-settings)) + "Update settings to/from PC kernel. Call this at the start of every frame. + This will update things like the aspect-ratio, which will be used for graphics code later." + + (update-from-os obj) + (update-to-os obj) + + (when #t ;;(not (-> obj use-vis?)) + (set! (-> *video-parms* relative-x-scale) (/ ASPECT_4X3 (-> obj aspect-ratio))) + (set! (-> *video-parms* relative-x-scale-reciprical) (/ (-> obj aspect-ratio) ASPECT_4X3)) + (set! (-> *font-default-matrix* vector 0 x) (-> *video-parms* relative-x-scale)) + ) + (if (and *debug-segment* (-> obj debug-pad-display)) + (debug-pad-display (-> *cpad-list* cpads 0)) + ) + + (none)) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; functions +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(when *debug-segment* + +(defmethod draw pc-settings ((obj pc-settings) (buf dma-buffer)) + "debug draw" + + (clear *pc-temp-string*) + (format *pc-temp-string* "game resolution: ~D x ~D~%" (-> obj width) (-> obj height)) + (format *pc-temp-string* "window size: ~D x ~D (~,,1f x ~,,1f)~%" (-> obj win-width) (-> obj win-height) (-> obj dpi-x) (-> obj dpi-y)) + (format *pc-temp-string* "target aspect: ~,,3f/~,,3f A: ~A/~A L: ~A~%" (-> obj aspect-ratio) (/ (the float (-> obj win-width)) (the float (-> obj win-height))) (-> obj aspect-ratio-auto?) (-> obj use-vis?) (-> obj letterbox?)) + (format *pc-temp-string* "fullscreen: ~A ~A~%" (-> obj fullscreen?) (-> obj vsync?)) + + (draw-string-xy *pc-temp-string* buf 0 (- 240 (* 8 4)) (font-color default) (font-flags shadow kerning)) + + (none)) + +) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; file IO +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + + +(defmacro file-stream-seek-until (fs func-name) + `(let ((done? #f) + (tell -1)) + + (until done? + + (let ((read (file-stream-read ,fs (-> *pc-temp-string* data) PC_TEMP_STRING_LEN))) + (cond + ((zero? read) + (set! (-> *pc-temp-string* data read) 0) + (true! done?) + ) + (else + (dotimes (i read) + (when (,func-name (-> *pc-temp-string* data i)) + (true! done?) + (set! tell (+ i (- (file-stream-tell ,fs) read))) + (set! i read) + ) + ) + ) + ) + + + ) + + ) + (if (!= tell -1) + (file-stream-seek ,fs tell SCE_SEEK_SET) + tell + ) + ) + ) + +(defmacro file-stream-read-until (fs func-name) + `(let ((read (file-stream-read ,fs (-> *pc-temp-string* data) PC_TEMP_STRING_LEN))) + (dotimes (i read) + (when (,func-name (-> *pc-temp-string* data i)) + (set! (-> *pc-temp-string* data i) 0) + (file-stream-seek ,fs (+ i (- (file-stream-tell ,fs) read)) SCE_SEEK_SET) + (set! i read) + ) + ) + *pc-temp-string* + ) + ) + +(defmacro is-whitespace-or-bracket? (c) + `(or (is-whitespace-char? ,c) (= #x28 ,c) (= #x29 ,c)) + ) + +(defun file-stream-seek-past-whitespace ((file file-stream)) + (file-stream-seek-until file not-whitespace-char?) + ) + +(defun file-stream-read-word ((file file-stream)) + (file-stream-read-until file is-whitespace-or-bracket?) + ;(format 0 "word ~A~%" *pc-temp-string*) + ) + +(defmacro file-stream-getc (fs) + `(let ((buf 255)) + (file-stream-read ,fs (& buf) 1) + ;(format 0 "getc got #x~X~%" buf) + buf + ) + ) + +(defun file-stream-read-int ((file file-stream)) + (file-stream-seek-past-whitespace file) + (file-stream-read-word file) + (string->int *pc-temp-string*) + ) + +(defun file-stream-read-float ((file file-stream)) + (file-stream-seek-past-whitespace file) + (file-stream-read-word file) + (string->float *pc-temp-string*) + ) + +(defun file-stream-read-symbol ((file file-stream)) + (file-stream-seek-past-whitespace file) + (file-stream-read-word file) + (cond + ((string= *pc-temp-string* "#f") #f) + ((string= *pc-temp-string* "#t") #t) + ((string= *pc-temp-string* "aspect4x3") 'aspect4x3) + ((string= *pc-temp-string* "aspect16x9") 'aspect16x9) + ((string= *pc-temp-string* "borderless") 'borderless) + (else #t) + ) + ) + +(defmacro pc-settings-read-throw-error (fs msg) + "not an actual throw..." + `(begin + (format 0 "pc settings read error: ~S~%" ,msg) + (file-stream-close ,fs) + (return #f) + ) + ) + +(defmacro with-settings-scope (bindings &rest body) + (let ((fs (first bindings))) + `(begin + (file-stream-seek-past-whitespace ,fs) + (when (!= #x28 (file-stream-getc ,fs)) + (pc-settings-read-throw-error ,fs "invalid char, ( not found") + ) + + ,@body + + (file-stream-seek-past-whitespace ,fs) + (when (!= #x29 (file-stream-getc ,fs)) + (pc-settings-read-throw-error ,fs "invalid char, ) not found") + ) + ) + ) + ) + +(defmacro dosettings (bindings &rest body) + "iterate over a list of key-value pairs like so: ( ) ( ) ... + the name of key is stored in *pc-temp-string*" + (let ((fs (first bindings))) + `(let ((c -1)) + (while (begin (file-stream-seek-past-whitespace ,fs) (set! c (file-stream-getc ,fs)) (= #x28 c)) + (file-stream-read-word ,fs) + + ,@body + + (file-stream-seek-past-whitespace ,fs) + (set! c (file-stream-getc ,fs)) + (when (!= #x29 c) + (break!) + (pc-settings-read-throw-error ,fs (string-format "invalid char, ) not found, got #x~X ~A" c *pc-temp-string*)) + ) + ) + (file-stream-seek ,fs -1 SCE_SEEK_CUR) + ) + ) + ) + +(defmethod read-from-file pc-settings ((obj pc-settings) (filename string)) + "read settings from a file" + + (if (not filename) + (return #f)) + + (let ((file (new 'stack 'file-stream filename 'read))) + (if (not (file-stream-valid? file)) + (return #f)) + + (let ((version PC_KERNEL_VERSION)) + (with-settings-scope (file) + (file-stream-read-word file) + (cond + ((string= *pc-temp-string* "settings") + (set! version (file-stream-read-int file)) + (dosettings (file) + (cond + ((string= *pc-temp-string* "fps") (set! (-> obj target-fps) (file-stream-read-int file))) + ((string= *pc-temp-string* "size") + (set! (-> obj width) (file-stream-read-int file)) + (set! (-> obj height) (file-stream-read-int file)) + (set-size! obj (-> obj width) (-> obj height)) + (set-aspect! obj (-> obj width) (-> obj height)) + ) + ((string= *pc-temp-string* "aspect") + (set! (-> obj aspect-custom-x) (file-stream-read-int file)) + (set! (-> obj aspect-custom-y) (file-stream-read-int file)) + ) + ((string= *pc-temp-string* "aspect-auto") (set! (-> obj aspect-ratio-auto?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "aspect-game") (set! (-> *setting-control* default aspect-ratio) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "fullscreen") (set-fullscreen! obj (file-stream-read-symbol file))) + ((string= *pc-temp-string* "letterbox") (set! (-> obj letterbox?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "vsync") (set! (-> obj vsync?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "font-scale") (set! (-> obj font-scale) (file-stream-read-float file))) + ((string= *pc-temp-string* "audio-latency-ms") (set! (-> obj audio-latency-ms) (file-stream-read-int file))) + ((string= *pc-temp-string* "audio-pan-override") (set! (-> obj audio-pan-override) (file-stream-read-float file))) + ((string= *pc-temp-string* "audio-volume-override") (set! (-> obj audio-volume-override) (file-stream-read-float file))) + ((string= *pc-temp-string* "audio-channel-nb") (set! (-> obj audio-channel-nb) (file-stream-read-int file))) + ((string= *pc-temp-string* "gfx-renderer") (set! (-> obj gfx-renderer) (the-as pc-gfx-renderer (file-stream-read-int file)))) + ((string= *pc-temp-string* "gfx-resolution") (set! (-> obj gfx-resolution) (file-stream-read-float file))) + ((string= *pc-temp-string* "gfx-anisotropy") (set! (-> obj gfx-anisotropy) (file-stream-read-float file))) + ((string= *pc-temp-string* "shrub-dist-mod") (set! (-> obj shrub-dist-mod) (file-stream-read-float file))) + ((string= *pc-temp-string* "lod-dist-mod") (set! (-> obj lod-dist-mod) (file-stream-read-float file))) + ((string= *pc-temp-string* "lod-force-tfrag") (set! (-> obj lod-force-tfrag) (file-stream-read-int file))) + ((string= *pc-temp-string* "lod-force-tie") (set! (-> obj lod-force-tie) (file-stream-read-int file))) + ((string= *pc-temp-string* "lod-force-ocean") (set! (-> obj lod-force-ocean) (file-stream-read-int file))) + ((string= *pc-temp-string* "lod-force-actor") (set! (-> obj lod-force-actor) (file-stream-read-int file))) + ((string= *pc-temp-string* "subtitle-language") (set! (-> obj subtitle-language) (the-as pc-subtitle-lang (file-stream-read-int file)))) + ((string= *pc-temp-string* "stick-deadzone") (set! (-> obj stick-deadzone) (file-stream-read-float file))) + ((string= *pc-temp-string* "ps2-read-speed?") (set! (-> obj ps2-read-speed?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "ps2-parts?") (set! (-> obj ps2-parts?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "ps2-music?") (set! (-> obj ps2-music?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "ps2-se?") (set! (-> obj ps2-se?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "ps2-hints?") (set! (-> obj ps2-hints?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "ps2-lod-dist?") (set! (-> obj ps2-lod-dist?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "music-fade?") (set! (-> obj music-fade?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "use-vis?") (set! (-> obj use-vis?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "skip-movies?") (set! (-> obj skip-movies?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "subtitles?") (set! (-> obj subtitles?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "hinttitles?") (set! (-> obj hinttitles?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "scenes-seen") + (dotimes (i 197) + (set! (-> obj scenes-seen i) (file-stream-read-int file)) + ) + ) + ((string= *pc-temp-string* "fixes") + (dosettings (file) + (cond + ((string= *pc-temp-string* "crash-sagecage") (set! (-> obj fixes crash-sagecage) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "crash-dma") (set! (-> obj fixes crash-dma) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "crash-light-eco") (set! (-> obj fixes crash-light-eco) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "lockout-pelican") (set! (-> obj fixes lockout-pelican) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "lockout-pipegame") (set! (-> obj fixes lockout-pipegame) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "lockout-gambler") (set! (-> obj fixes lockout-gambler) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "fix-movies") (set! (-> obj fixes fix-movies) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "fix-credits") (set! (-> obj fixes fix-credits) (file-stream-read-symbol file))) + ) + ) + ) + ((string= *pc-temp-string* "secrets") + (dosettings (file) + (cond + ((string= *pc-temp-string* "hard-rats?") (set! (-> obj secrets hard-rats?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "hero-mode?") (set! (-> obj secrets hero-mode?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "hud-map?") (set! (-> obj secrets hud-map?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "hud-counters?") (set! (-> obj secrets hud-counters?) (file-stream-read-symbol file))) + ((string= *pc-temp-string* "art") (set! (-> obj secrets art) (the-as pc-jak1-concept-art (file-stream-read-int file)))) + ((string= *pc-temp-string* "hard-fish-hiscore") (set! (-> obj secrets hard-fish-hiscore) (file-stream-read-int file))) + ((string= *pc-temp-string* "hard-rats-hiscore") (set! (-> obj secrets hard-rats-hiscore) (file-stream-read-int file))) + ((string= *pc-temp-string* "hard-rats-hiwave") (set! (-> obj secrets hard-rats-hiwave) (file-stream-read-int file))) + ((string= *pc-temp-string* "music") + (dotimes (i 30) + (set! (-> obj secrets music i) (file-stream-read-int file)) + ) + ) + ) + ) + ) + ((string= *pc-temp-string* "panic") + (when (file-stream-read-symbol file) + (file-stream-close file) + (reset obj) + (write-to-file obj filename) + (set-fullscreen! obj #f) + (return #f) + ) + ) + ) + ) + ) + ) + ) + + (when (!= PC_KERNEL_VERSION version) + (cond + ((= (logand version #xffffffff00000000) (logand PC_KERNEL_VERSION #xffffffff00000000)) + ;; minor difference + ) + (else + ;; major difference + (format 0 "PC kernel version mismatch! Got ~D.~D vs ~D.~D~%" PC_KERNEL_VERSION_MAJOR PC_KERNEL_VERSION_MINOR (bit-field int version 32 16) (bit-field int version 48 16)) + ) + ) + ) + + ) + + (file-stream-close file) + ) + + (format 0 "pc settings file read: ~A~%" filename) + + #t + ) + +(defmethod write-to-file pc-settings ((obj pc-settings) (filename string)) + "write settings to a file" + + (if (not filename) + (return #f)) + + (let ((file (new 'stack 'file-stream filename 'write))) + (if (not (file-stream-valid? file)) + (return #f)) + + + (format file "(settings #x~X~%" (-> obj version)) + + (format file " (fps ~D)~%" (-> obj target-fps)) + (format file " (size ~D ~D)~%" (-> obj width) (-> obj height)) + (format file " (aspect ~D ~D)~%" (-> obj aspect-custom-x) (-> obj aspect-custom-y)) + (format file " (aspect-auto ~A)~%" (-> obj aspect-ratio-auto?)) + (format file " (aspect-game ~A)~%" (-> *setting-control* default aspect-ratio)) + (format file " (fullscreen ~A)~%" (-> obj fullscreen?)) + (format file " (letterbox ~A)~%" (-> obj letterbox?)) + (format file " (vsync ~A)~%" (-> obj vsync?)) + (format file " (font-scale ~f)~%" (-> obj font-scale)) + + (format file " (audio-latency-ms ~D)~%" (-> obj audio-latency-ms)) + (format file " (audio-pan-override ~f)~%" (-> obj audio-pan-override)) + (format file " (audio-volume-override ~f)~%" (-> obj audio-volume-override)) + (format file " (audio-channel-nb ~D)~%" (-> obj audio-channel-nb)) + + (format file " (gfx-renderer ~D)~%" (-> obj gfx-renderer)) + (format file " (gfx-resolution ~f)~%" (-> obj gfx-resolution)) + (format file " (gfx-anisotropy ~f)~%" (-> obj gfx-anisotropy)) + (format file " (shrub-dist-mod ~f)~%" (-> obj shrub-dist-mod)) + (format file " (lod-dist-mod ~f)~%" (-> obj lod-dist-mod)) + (format file " (lod-force-tfrag ~D)~%" (-> obj lod-force-tfrag)) + (format file " (lod-force-tie ~D)~%" (-> obj lod-force-tie)) + (format file " (lod-force-ocean ~D)~%" (-> obj lod-force-ocean)) + (format file " (lod-force-actor ~D)~%" (-> obj lod-force-actor)) + + (format file " (stick-deadzone ~f)~%" (-> obj stick-deadzone)) + + (format file " (ps2-read-speed? ~A)~%" (-> obj ps2-read-speed?)) + (format file " (ps2-parts? ~A)~%" (-> obj ps2-parts?)) + (format file " (ps2-music? ~A)~%" (-> obj ps2-music?)) + (format file " (ps2-se? ~A)~%" (-> obj ps2-se?)) + (format file " (ps2-hints? ~A)~%" (-> obj ps2-hints?)) + (format file " (ps2-lod-dist? ~A)~%" (-> obj ps2-lod-dist?)) + (format file " (music-fade? ~A)~%" (-> obj music-fade?)) + (format file " (use-vis? ~A)~%" (-> obj use-vis?)) + (format file " (skip-movies? ~A)~%" (-> obj skip-movies?)) + (format file " (subtitles? ~A)~%" (-> obj subtitles?)) + (format file " (hinttitles? ~A)~%" (-> obj hinttitles?)) + (format file " (subtitle-language ~D)~%" (-> obj subtitle-language)) + + (format file " (scenes-seen") + (dotimes (i 197) + (if (zero? (mod i 16)) + (format file "~% ") + ) + (format file " ~D" (-> obj scenes-seen i)) + ) + (format file "~% )~%") + + (format file " (fixes~%") + (format file " (crash-sagecage ~A)~%" (-> obj fixes crash-sagecage)) + (format file " (crash-dma ~A)~%" (-> obj fixes crash-dma)) + (format file " (crash-light-eco ~A)~%" (-> obj fixes crash-light-eco)) + (format file " (lockout-pelican ~A)~%" (-> obj fixes lockout-pelican)) + (format file " (lockout-pipegame ~A)~%" (-> obj fixes lockout-pipegame)) + (format file " (lockout-gambler ~A)~%" (-> obj fixes lockout-gambler)) + (format file " (fix-movies ~A)~%" (-> obj fixes fix-movies)) + (format file " (fix-credits ~A)~%" (-> obj fixes fix-credits)) + (format file " )~%") + + (format file " (secrets~%") + (format file " (art #x~X)~%" (-> obj secrets art)) + (format file " (hard-rats? ~A)~%" (-> obj secrets hard-rats?)) + (format file " (hero-mode? ~A)~%" (-> obj secrets hero-mode?)) + (format file " (hud-map? ~A)~%" (-> obj secrets hud-map?)) + (format file " (hud-counters? ~A)~%" (-> obj secrets hud-counters?)) + (format file " (hard-fish-hiscore ~D)~%" (-> obj secrets hard-fish-hiscore)) + (format file " (hard-rats-hiscore ~D)~%" (-> obj secrets hard-rats-hiscore)) + (format file " (hard-rats-hiwave ~D)~%" (-> obj secrets hard-rats-hiwave)) + (format file " (music") + (dotimes (i 30) + (if (zero? (mod i 1)) + (format file "~% ") + ) + (format file " #x~X" (-> obj secrets music i)) + ) + (format file "~% )~%") + (format file " )~%") + + (format file " )~%") + (file-stream-close file) + ) + + (format 0 "pc settings file write: ~A~%" filename) + + #t + ) + + +(defmethod new pc-settings ((allocation symbol) (type-to-make type)) + "make a new pc-settings" + + (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + + (reset obj) + + obj + ) + ) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; PC settings +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(define *pc-settings* (new 'global 'pc-settings)) + + + +) + + + diff --git a/goal_src/engine/ps2/pad.gc b/goal_src/engine/ps2/pad.gc index 57d5ab66ee..314802fce9 100644 --- a/goal_src/engine/ps2/pad.gc +++ b/goal_src/engine/ps2/pad.gc @@ -231,6 +231,11 @@ ;; weird leftover debug thing, enabling overrides the x position of both sticks on both controllers. (define *cpad-debug* #f) +(#if PC_PORT + (defconstant STICK_DEADZONE (-> *pc-settings* stick-deadzone)) + (defconstant STICK_DEADZONE 0.3) + ) + (defun service-cpads () "Read from cpads and update vibration" ;; iterate over pads @@ -244,21 +249,14 @@ (dotimes (buzz-idx 2) (cond ;; check if okay to buzz: - ((and (-> pad buzz) - (< (get-current-time) (-> pad buzz-time buzz-idx)) - (= *master-mode* 'game) - ) + ((and (-> pad buzz) (< (get-current-time) (-> pad buzz-time buzz-idx)) (= *master-mode* 'game)) (let ((v1-10 buzz-idx)) (cond ((zero? v1-10) ;; vibration motor 0 only has on/off. This pulses it to approximate ;; an analog control (set! (-> pad direct buzz-idx) - (logand (ash (-> pad buzz-val buzz-idx) - (- (logand (get-integral-current-time) 7)) - ) - 1 - ) + (logand (ash (-> pad buzz-val buzz-idx) (- (logand (get-integral-current-time) 7))) 1) ) ) ((= v1-10 1) @@ -269,10 +267,10 @@ ) ) (else - ;; not okay to buzz this motor, set to zero. - (set! (-> pad buzz-val buzz-idx) 0) - (set! (-> pad direct buzz-idx) 0) - ) + ;; not okay to buzz this motor, set to zero. + (set! (-> pad buzz-val buzz-idx) (the-as uint 0)) + (set! (-> pad direct buzz-idx) (the-as uint 0)) + ) ) ) ;; update button history. @@ -280,15 +278,13 @@ (set! (-> pad button0-abs 1) (-> pad button0-shadow-abs 0)) (set! (-> pad button0-rel 2) (-> pad button0-rel 1)) (set! (-> pad button0-rel 1) (-> pad button0-rel 0)) - ;; update current button - (let ((current-button0 (the pad-buttons (-> pad button0)))) - (set! (-> pad button0-shadow-abs 0) current-button0) - (set! (-> pad button0-abs 0) current-button0) + ;; we might want to clear a button so we back it up in a "shadow" field + (let ((current-button0 (-> pad button0))) + (set! (-> pad button0-shadow-abs 0) (the-as pad-buttons current-button0)) + (set! (-> pad button0-abs 0) (the-as pad-buttons current-button0)) ) ;; buttons going down - (set! (-> pad button0-rel 0) - (logclear (-> pad button0-abs 0) (-> pad button0-abs 1)) - ) + (set! (-> pad button0-rel 0) (logclear (-> pad button0-abs 0) (-> pad button0-abs 1))) ;; ?? (when *cpad-debug* (set! (-> pad leftx) (the-as uint 255)) @@ -305,35 +301,33 @@ (f28-0 (* 0.0078125 (the float (- 127 (the-as int (-> pad lefty)))))) ) (set! (-> pad stick0-dir) (atan (- f30-0) f28-0)) - (set! (-> pad stick0-speed) - (fmin 1.0 (sqrtf (+ (* f30-0 f30-0) (* f28-0 f28-0)))) - ) + (set! (-> pad stick0-speed) (fmin 1.0 (sqrtf (+ (* f30-0 f30-0) (* f28-0 f28-0))))) ) - (if (< (-> pad stick0-speed) 0.3) + (if (< (-> pad stick0-speed) STICK_DEADZONE) (set! (-> pad stick0-speed) 0.0) ) ) (else - ;; analog is invalid? set to zero. - (set! (-> pad leftx) (the-as uint 128)) - (set! (-> pad lefty) (the-as uint 128)) - (set! (-> pad rightx) (the-as uint 128)) - (set! (-> pad righty) (the-as uint 128)) - (set! (-> pad stick0-dir) 0.0) - (set! (-> pad stick0-speed) 0.0) - ) + ;; analog is invalid? set to zero. + (set! (-> pad leftx) (the-as uint 128)) + (set! (-> pad lefty) (the-as uint 128)) + (set! (-> pad rightx) (the-as uint 128)) + (set! (-> pad righty) (the-as uint 128)) + (set! (-> pad stick0-dir) 0.0) + (set! (-> pad stick0-speed) 0.0) + ) ) ;; if the pad was changed or stick0 pushed, update the last changed time. (if (or (!= (-> pad button0-abs 0) (-> pad button0-abs 1)) - (or (< 0.3 (-> pad stick0-speed)) (zero? (-> pad change-time))) + (or (< STICK_DEADZONE (-> pad stick0-speed)) (zero? (-> pad change-time))) ) (set! (-> pad change-time) (get-current-time)) ) ) (else - ;; invalid bits set, controller is not connected. - (cpad-invalid! pad) - ) + ;; invalid bits set, controller is not connected. + (cpad-invalid! pad) + ) ) ) ) diff --git a/goal_src/game.gp b/goal_src/game.gp index 3cd4c5d548..2cdcb5d375 100644 --- a/goal_src/game.gp +++ b/goal_src/game.gp @@ -42,7 +42,7 @@ ) (defmacro goal-src-sequence (prefix &key (deps '()) &rest sequence) - "Add a sequence of GOAL files (each depending on the previous) in the given directory, + "Add a sequence of GOAL files (each depending on the previous) in the given directory, with all depending on the given deps." (let* ((first-thing `(goal-src ,(string-append prefix (first sequence)) ,@deps)) (result (cons first-thing '())) @@ -112,7 +112,7 @@ (defmacro copy-str (name) (let* ((folder (get-environment-variable "OPENGOAL_DECOMP_DIR" :default "")) - (path (string-append "iso_data/" folder "/STR/" name ".STR"))) + (path (string-append "iso_data/" folder "STR/" name ".STR"))) `(defstep :in ,path :tool 'copy :out '(,(string-append "out/iso/" name ".STR"))))) @@ -122,7 +122,7 @@ (defmacro copy-vis-file (name) (let* ((folder (get-environment-variable "OPENGOAL_DECOMP_DIR" :default "")) - (path (string-append "iso_data/" folder "/VIS/" name ".VIS"))) + (path (string-append "iso_data/" folder "VIS/" name ".VIS"))) `(defstep :in ,path :tool 'copy :out '(,(string-append "out/iso/" name ".VIS"))))) @@ -188,7 +188,7 @@ ;;;;;;;;;;;;;;;;;;;;; ;; Textures (Common) ;;;;;;;;;;;;;;;;;;;;; - + (copy-textures 463 2 880 256 1278 1032 62 1532) ;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -197,8 +197,14 @@ (copy-strs "FUCVICTO" + "FUCV2" "FUCV3" - "FUCV4") + "FUCV4" + "FUCV5" + "FUCV6" + "FUCV7" + "FUCV8" + ) ;;;;;;;;;;;;;;;;;;;;; @@ -248,36 +254,54 @@ "out/iso/VI2.DGO" "out/iso/VI3.DGO" "out/iso/TRA.DGO" - "out/iso/FIN.DGO" "out/iso/FIC.DGO" - "out/iso/JUN.DGO" - "out/iso/MAI.DGO" - "out/iso/BEA.DGO" - "out/iso/CIT.DGO" + "out/iso/ROL.DGO" "out/iso/SUN.DGO" + "out/iso/SUB.DGO" + "out/iso/SWA.DGO" + "out/iso/OGR.DGO" + "out/iso/JUN.DGO" + "out/iso/JUB.DGO" + "out/iso/MAI.DGO" + "out/iso/SNO.DGO" + "out/iso/BEA.DGO" + "out/iso/LAV.DGO" + "out/iso/CIT.DGO" + "out/iso/FIN.DGO" ;; level vis "out/iso/VI1.VIS" "out/iso/VI2.VIS" "out/iso/VI3.VIS" "out/iso/TRA.VIS" - "out/iso/FIN.VIS" "out/iso/FIC.VIS" + "out/iso/ROL.VIS" + "out/iso/SUN.VIS" + "out/iso/SUB.VIS" + "out/iso/SWA.VIS" + "out/iso/OGR.VIS" "out/iso/JUN.VIS" + "out/iso/JUB.VIS" "out/iso/MAI.VIS" + "out/iso/SNO.VIS" "out/iso/BEA.VIS" "out/iso/CIT.VIS" - "out/iso/SUN.VIS" + "out/iso/FIN.VIS" "out/iso/FUCVICTO.STR" + "out/iso/FUCV2.STR" "out/iso/FUCV3.STR" "out/iso/FUCV4.STR" + "out/iso/FUCV5.STR" + "out/iso/FUCV6.STR" + "out/iso/FUCV7.STR" + "out/iso/FUCV8.STR" ) ;;;;;;;;;;;;;;;;;;;;; ;; engine Group ;;;;;;;;;;;;;;;;;;;;; -;; the engine group is a group of files loaded as the game engine with no levels +;; the engine group is a group of files required to boot the game engine with no levels (group "engine" "out/iso/0COMMON.TXT" @@ -314,6 +338,8 @@ "eichar-racer+0-ag" "babak-ag" + + "eichar-flut+0-ag" ) @@ -343,6 +369,9 @@ "racer_common/racer-states-FIC-LAV-MIS-OGR-ROL.gc" "racer_common/collide-reaction-racer.gc" + "flut_common/flut-part.gc" + "flut_common/flutflut.gc" + "flut_common/target-flut.gc" ) @@ -420,6 +449,7 @@ "village1-vis" ) + ;;;;;;;;;;;;;;;;;;;;; ;; Jungle ;;;;;;;;;;;;;;;;;;;;; @@ -446,6 +476,8 @@ "jungle-part.gc" ) +(copy-textures 385 531 386 388 765) + (copy-gos "eichar-fish+0-ag-JUN" "accordian-ag" @@ -482,7 +514,39 @@ "jungle-vis" ) -(copy-textures 385 531 386 388 765) + +;;;;;;;;;;;;;;;;;;;;; +;; Jungle temple +;;;;;;;;;;;;;;;;;;;;; + +(cgo "JUB.DGO" "jub.gd") + +(copy-vis-files "JUB") + +(goal-src-sequence + "levels/jungleb/" + :deps ;; no idea what these depend on, make it depend on the whole engine + ("out/obj/default-menu.o") + + "jungleb-obs.gc" + "plat-flip.gc" + "aphid.gc" + "plant-boss.gc" + ) + +(copy-textures 485 510 507 966) + +(copy-gos + "plant-boss-main+0-ag" + "aphid-lurker-ag" + "darkvine-ag-JUB" + "eggtop-ag" + "jng-iris-door-ag-JUB" + "plant-boss-ag" + "plat-flip-ag" + "plat-jungleb-ag" + "jungleb-vis" + ) ;;;;;;;;;;;;;;;;;;;;; @@ -557,7 +621,7 @@ (copy-vis-files "FIC") -(copy-textures 1119) ;; might be common/zoomer hud?? +(copy-textures 1119) ;; might be common/zoomer hud?? also in misty, lavatube, ogre and racerpkg (goal-src-sequence "levels/firecanyon/" @@ -679,6 +743,40 @@ ) +;;;;;;;;;;;;;;;;;;;;; +;; rolling hills +;;;;;;;;;;;;;;;;;;;;; + +(cgo "ROL.DGO" "rol.gd") + +(copy-vis-files "ROL") + +(goal-src-sequence + "levels/rolling/" + :deps ("out/obj/default-menu.o") + "rolling-obs.gc" + "rolling-lightning-mole.gc" + "rolling-robber.gc" + "rolling-race-ring.gc" + ) + +(copy-textures 923 926 924 925 1353) + +(copy-gos + "ecovalve-ag-ROL" + "dark-plant-ag" + "happy-plant-ag" + "lightning-mole-ag" + "pusher-ag" + "race-ring-ag" + "robber-ag" + "rolling-start-ag" + "rollingcam-ag" + "water-anim-rolling-ag" + "rolling-vis" + ) + + ;;;;;;;;;;;;;;;;;;;;; ;; LPC ;;;;;;;;;;;;;;;;;;;;; @@ -750,7 +848,114 @@ "whirlpool-ag" "sunken-vis" ) - + + +;;;;;;;;;;;;;;;;;;;;; +;; sunken city b +;;;;;;;;;;;;;;;;;;;;; + +(cgo "SUB.DGO" "sub.gd") + +(copy-vis-files "SUB") + +(copy-textures 163 164 166 162 764) + +(copy-gos + "ecovalve-ag-SUB" + "eichar-tube+0-ag-SUB" + "blue-eco-charger-ag" + "blue-eco-charger-orb-ag" + "floating-launcher-ag" + "helix-button-ag" + "helix-slide-door-ag" + "shover-ag-SUB" + "steam-cap-ag-SUB" + "sunkencam-ag-SUB" + "sunkenb-vis" + ) + + +;;;;;;;;;;;;;;;;;;;;; +;; swamp +;;;;;;;;;;;;;;;;;;;;; + +(cgo "SWA.DGO" "swa.gd") + +(copy-vis-files "SWA") + +(goal-src-sequence + "levels/swamp/" + :deps ("out/obj/default-menu.o") + "swamp-obs.gc" + "swamp-bat.gc" + "swamp-rat.gc" + "swamp-rat-nest.gc" + "kermit.gc" + "swamp-part.gc" + "billy.gc" + ) + +(copy-textures 358 659 629 630) + +(copy-gos + "ecovalve-ag-SWA" + "sharkey-ag-SWA" + "eichar-pole+0-ag-SWA" + "flut-saddle-ag-SWA" + "balance-plat-ag" + "billy-ag" + "billy-sidekick-ag" + "farthy-snack-ag" + "kermit-ag" + "swamp-bat-ag" + "swamp-rat-ag" + "swamp-rat-nest-ag" + "swamp-rock-ag" + "swamp-spike-ag" + "swampcam-ag-SWA" + "tar-plat-ag" + "swamp-vis" + ) + + +;;;;;;;;;;;;;;;;;;;;; +;; ogre boss +;;;;;;;;;;;;;;;;;;;;; + +(cgo "OGR.DGO" "ogr.gd") + +(copy-vis-files "OGR") + +(goal-src-sequence + "levels/ogre/" + :deps ("out/obj/default-menu.o") + "ogre-part.gc" + "ogreboss.gc" + "ogre-obs.gc" + "flying-lurker.gc" + ) + +(copy-textures 875 967 884 1117) + +(copy-gos + "crate-darkeco-cluster-ag-OGR" + "racer-ag-OGR" + "flying-lurker-ag" + "medres-snow-ag" + "ogre-bridge-ag" + "ogre-bridgeend-ag" + "ogre-isle-ag" + "ogre-step-ag" + "ogreboss-ag" + "ogrecam-ag" + "plunger-lurker-ag" + "shortcut-boulder-ag" + "tntbarrel-ag" + "water-anim-ogre-ag" + "ogre-vis" + ) + + ;;;;;;;;;;;;;;;;;;;;; ;; Village 3 ;;;;;;;;;;;;;;;;;;;;; @@ -854,6 +1059,107 @@ ; "darkcave/darkcave-obs.gc" ; ) + +;;;;;;;;;;;;;;;;;;;;; +;; snow mountain +;;;;;;;;;;;;;;;;;;;;; + +(cgo "SNO.DGO" "sno.gd") + +(copy-vis-files "SNO") + +(goal-src-sequence + "levels/snow/" + :deps ("out/obj/default-menu.o") + "target-snowball.gc" + "target-ice.gc" + "ice-cube.gc" + "snow-ball.gc" + "snow-obs.gc" + "snow-flutflut-obs.gc" + "snow-bumper.gc" + "snow-ram-h.gc" + "snow-ram-boss.gc" + "snow-ram.gc" + "snow-part.gc" + "yeti.gc" + ) + +(copy-textures 710 842 711 712) + +(copy-gos + "ecovalve-ag-SNO" + "orb-cache-top-ag-SNO" + "eichar-pole+0-ag-SNO" + "eichar-ice+0-ag" + "flut-saddle-ag-SNO" + "flutflut-plat-large-ag" + "flutflut-plat-med-ag" + "flutflut-plat-small-ag" + "ice-cube-ag" + "ice-cube-break-ag" + "ram-ag" + "ram-boss-ag" + "snow-ball-ag" + "snow-bridge-36-ag" + "snow-bumper-ag" + "snow-bunny-ag" + "snow-button-ag" + "snow-eggtop-ag" + "snow-fort-gate-ag" + "snow-gears-ag" + "snow-log-ag" + "snow-spatula-ag" + "snow-switch-ag" + "snowcam-ag" + "snowpusher-ag" + "yeti-ag" + "snow-vis" + ) + + +;;;;;;;;;;;;;;;;;;;;; +;; lavatube +;;;;;;;;;;;;;;;;;;;;; + +(cgo "LAV.DGO" "lav.gd") + +(copy-vis-files "LAV") + +(goal-src-sequence + "levels/lavatube/" + :deps ("out/obj/default-menu.o") + + "lavatube-obs.gc" + "lavatube-energy.gc" + "lavatube-part.gc" + "assistant-lavatube.gc" + ) + +(copy-textures 1338 1340 1339 1337) + +(copy-gos + "ecovalve-ag-LAV" + "racer-ag-LAV" + "assistant-lavatube-start-ag" + "chainmine-ag" + "darkecobarrel-ag" + "energyarm-ag" + "energyball-ag" + "energybase-ag" + "energydoor-ag" + "energyhub-ag" + "lavaballoon-ag" + "lavabase-ag" + "lavafall-ag" + "lavafallsewera-ag" + "lavafallsewerb-ag" + "lavashortcut-ag" + "lavayellowtarp-ag" + "water-anim-lavatube-ag" + "lavatube-vis" + ) + ;;;;;;;;;;;;;;;;;;;;; ;; citadel ;;;;;;;;;;;;;;;;;;;;; @@ -1016,6 +1322,7 @@ "dma/dma-buffer.gc" "dma/dma-bucket.gc" "dma/dma-disasm.gc" + "pc/pckernel-h.gc" ;; added "ps2/pad.gc" "gfx/hw/gs.gc" "gfx/hw/display-h.gc" @@ -1234,6 +1541,7 @@ "gfx/tie/prototype.gc" "collide/main-collide.gc" "game/video.gc" + "pc/pckernel.gc" ;; added "game/main.gc" "collide/collide-cache.gc" "entity/relocate.gc" diff --git a/goal_src/goal-lib.gc b/goal_src/goal-lib.gc index 9f42fa8829..20ada7482c 100644 --- a/goal_src/goal-lib.gc +++ b/goal_src/goal-lib.gc @@ -493,6 +493,10 @@ `(set! ,place (* ,place ,amount)) ) +(defmacro /! (place amount) + `(set! ,place (/ ,place ,amount)) + ) + (defmacro zero? (thing) `(eq? ,thing 0) ) @@ -584,6 +588,19 @@ `(align-n ,val 64) ) +(defmacro bit-field (type val base size &key (signed #t)) + "extract bits from an integer value." + (when (and (integer? base) (integer? size)) + (when (> (+ base size) 64) + (error "cannot extract fields across 64-bit boundaries")) + (when (< base 0) + (error "bitfield base cannot be negative")) + (when (< size 0) + (error "bitfield size cannot be negative")) + ) + `(,(if signed 'sar 'shr) (shl ,val (- 64 (+ ,size ,base))) (- 64 ,size)) + ) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; TYPE STUFF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/goal_src/kernel-defs.gc b/goal_src/kernel-defs.gc index 8545cff652..d3ed993a92 100644 --- a/goal_src/kernel-defs.gc +++ b/goal_src/kernel-defs.gc @@ -186,10 +186,13 @@ (define-extern cpad-get-data (function cpad-info cpad-info)) (define-extern install-handler (function int function int)) ;; check return val ;; install-debug-handler +(defconstant SCE_SEEK_SET 0) +(defconstant SCE_SEEK_CUR 1) +(defconstant SCE_SEEK_END 2) (define-extern file-stream-open (function file-stream basic basic file-stream)) (define-extern file-stream-close (function file-stream file-stream)) (define-extern file-stream-length (function file-stream int)) -;; file-stream-seek +(define-extern file-stream-seek (function file-stream int int int)) (define-extern file-stream-read (function file-stream pointer int int)) (define-extern file-stream-write (function file-stream pointer uint uint)) @@ -315,6 +318,12 @@ (define-extern pc-pad-input-index-get (function int)) (define-extern pc-pad-input-map-save! (function none)) (define-extern pc-pad-get-mapped-button (function int int int)) +(define-extern pc-get-os (function symbol)) +(define-extern pc-get-window-size (function (pointer int32) (pointer int32) none)) +(define-extern pc-get-window-scale (function (pointer float) (pointer float) none)) +(define-extern pc-set-window-size (function int int none)) +(define-extern pc-set-letterbox (function int int none)) +(define-extern pc-set-fullscreen (function int int none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; vm functions diff --git a/goal_src/kernel/gstring.gc b/goal_src/kernel/gstring.gc index 1830116e78..77497873f8 100644 --- a/goal_src/kernel/gstring.gc +++ b/goal_src/kernel/gstring.gc @@ -410,6 +410,10 @@ ) ) +(defmacro not-whitespace-char? (c) + `(not (is-whitespace-char? ,c)) + ) + (defun string-skip-whitespace ((arg0 (pointer uint8))) "Skip over spaces, tabs, r's and n's" (while @@ -436,7 +440,7 @@ ;; null terminate (set! (-> str-ptr 0) 0) ) - '#f + #f ) ) @@ -450,26 +454,26 @@ (defun string-strip-trailing-whitespace! ((str string)) "Remove whitespace at the end of a string" - (local-vars (ptr (pointer uint8))) - (when (nonzero? ((method-of-type string length) str)) - (set! ptr (&+ (-> str data) - (the-as uint (+ ((method-of-type string length) str) -1))) - ) - (while (and (>= (the-as int ptr) (the-as int (-> str data))) - (is-whitespace-char? (-> ptr 0)) - ) - (set! ptr (&-> ptr -1)) + (when (nonzero? (length str)) + (let ((ptr (&+ (-> str data) (+ (length str) -1)))) + (while (and + (>= (the-as int ptr) (the-as int (-> str data))) + (is-whitespace-char? (-> ptr 0)) + ) + (set! ptr (&-> ptr -1)) + ) + (set! (-> ptr 1) (the-as uint 0)) ) - (set! (-> ptr 1) 0) + 0 ) - '#f + #f ) (defun string-strip-whitespace! ((arg0 string)) "Remove whitespace at the beginning and end of a string" (string-strip-trailing-whitespace! arg0) (string-strip-leading-whitespace! arg0) - '#f + #f ) (defun string-get-arg!! ((a-str string) (arg string)) @@ -532,130 +536,130 @@ (defun string->int ((str string)) "String to int. Supports binary, hex, and decimal. Negative is implemented for decimal and hex But I think it's broken?" - (local-vars - (result int) - (negative symbol) - (str-ptr (pointer uint8)) - (next-char-1 (pointer uint8)) - (next-char-2 (pointer uint8)) - (a0-4 (pointer uint8)) - (a0-5 symbol) - (a1-14 uint) - (a1-16 symbol) - (a1-20 uint) - (a1-23 uint) - (a1-33 symbol) - (a1-44 symbol) - (a1-47 (pointer uint8)) - ) - (set! str-ptr (-> str data)) - (set! result 0) - (set! negative '#f) - (cond - ((= (-> str-ptr 0) 35) ;; # - ;; starts with #. - (set! next-char-1 (&-> str-ptr 1)) - (cond - ((or (= (-> next-char-1 0) #\x) (= (-> next-char-1 0) #\X)) - ;; starts with #x or #X - (set! next-char-2 (&-> next-char-1 1)) - (when (= (-> next-char-2 1) #\-) - ;; negate! - (set! negative '#t) - (set! next-char-2 (&-> next-char-2 1)) - ) - (while - (or - ;; is in [0-9] - (and - (>= (-> next-char-2 0) #\0) - (>= (the-as uint #\9) (-> next-char-2 0)) - ) - ;; is in [A-F] - (and - (>= (-> next-char-2 0) (the-as uint 65)) - (>= (the-as uint 70) (-> next-char-2 0)) - ) - ;; is in [a-f] - (and - (>= (-> next-char-2 0) (the-as uint 97)) - (>= (the-as uint 102) (-> next-char-2 0)) - ) - ) - (cond - ;; is in [A-F] - ((and - (>= (-> next-char-2 0) (the-as uint 65)) - (>= (the-as uint 70) (-> next-char-2 0)) - ) - (set! - result - (the int (+ (+ (-> next-char-2 0) -55) (the-as uint (shl result 4)))) - ) - ) - (else - (set! - a1-16 - (and - (>= (-> next-char-2 0) (the-as uint 97)) - (>= (the-as uint 102) (-> next-char-2 0)) - ) - ) - (cond - (a1-16 - ;; in [a-f] - (set! result - (the int (+ (+ (-> next-char-2 0) -87) (the-as uint (shl result 4)))) - ) + (let ((str-ptr (-> str data)) + (result 0) + (negative #f) + ) + (cond + ((= (-> str-ptr 0) 35) + ;; starts with #. + (let ((next-char-1 (&-> str-ptr 1))) + (cond + ((or (= (-> next-char-1 0) 120) (= (-> next-char-1 0) 88)) + ;; starts with #x or #X + (let ((next-char-2 (&-> next-char-1 1))) + (when (= (-> next-char-2 1) 45) + ;; negate! + (set! negative #t) + (set! next-char-2 (&-> next-char-2 1)) ) - (else - ;; numeric - (set! result - (the int (+ (+ (-> next-char-2 0) -48) (the-as uint (shl result 4)))) - ) - ) ;; end numeric - ) ;; end numeric or [a-f] - ) ;; end not [A-F] - ) ;; end cond - (set! next-char-2 (&-> next-char-2 1)) - ) ;; end while - ) - ((or (zero? (+ (-> next-char-1 0) -98)) (zero? (+ (-> next-char-1 0) -66))) - ;; is #b (I guess we can't do negative binary?) - (set! a0-4 (&-> next-char-1 1)) - (while (and (>= (-> a0-4 0) (the-as uint 48)) (>= (the-as uint 49) (-> a0-4 0))) - (set! result (the int (+ (+ (-> a0-4 0) -48) (the-as uint (shl result 1))))) - (set! a0-4 (&-> a0-4 1)) + (while (or + (and (>= (-> next-char-2 0) (the-as uint 48)) (>= (the-as uint 57) (-> next-char-2 0))) + (and (>= (-> next-char-2 0) (the-as uint 65)) (>= (the-as uint 70) (-> next-char-2 0))) + (and (>= (-> next-char-2 0) (the-as uint 97)) (>= (the-as uint 102) (-> next-char-2 0))) + ) + (cond + ((and (>= (-> next-char-2 0) (the-as uint 65)) (>= (the-as uint 70) (-> next-char-2 0))) + ;; is in [A-F] + (set! result (the-as int (+ (-> next-char-2 0) -55 (* result 16)))) + ) + ((and (>= (-> next-char-2 0) (the-as uint 97)) (>= (the-as uint 102) (-> next-char-2 0))) + ;; is in [a-f] + (set! result (the-as int (+ (-> next-char-2 0) -87 (* result 16)))) + ) + (else + ;; is in [0-9] + (set! result (the-as int (+ (-> next-char-2 0) -48 (* result 16)))) + ) + ) + (set! next-char-2 (&-> next-char-2 1)) + ) + ) + ) + ((or (= (-> next-char-1 0) 98) (= (-> next-char-1 0) 66)) + ;; is #b (I guess we can't do negative binary?) + (let ((a0-4 (&-> next-char-1 1))) + (while (and (>= (-> a0-4 0) (the-as uint 48)) (>= (the-as uint 49) (-> a0-4 0))) + (set! result (the-as int (+ (-> a0-4 0) -48 (* result 2)))) + (set! a0-4 (&-> a0-4 1)) + ) + ) + ) + ) + ) + ) + (else + ;; decimal + + ;; check for negative + (when (= (-> str-ptr 1) 45) + (set! negative #t) + (set! str-ptr (&-> str-ptr 1)) + ) + (while (and (>= (-> str-ptr 0) (the-as uint 48)) (>= (the-as uint 57) (-> str-ptr 0))) + (set! result (the-as int (+ (-> str-ptr 0) -48 (* 10 result)))) + (set! str-ptr (&-> str-ptr 1)) ) ) - ) - ) - (else - ;; decimal - - ;; check for negative - (when (= (-> str-ptr 1) 45) - (set! negative '#t) - (set! str-ptr (&-> str-ptr 1)) - (set! a1-47 str-ptr) - ) - - (while (and - (>= (-> str-ptr 0) (the-as uint 48)) - (>= (the-as uint 57) (-> str-ptr 0)) - ) - (set! result (the int (+ (+ (-> str-ptr 0) -48) (the-as uint (* 10 result))))) - (set! str-ptr (&-> str-ptr 1)) - ) - ) + ) + (cond + (negative + (- result) + ) + (else + result + ) + ) ) - (cond (negative (- result)) (else result)) ) -(defun string->float ((arg0 string)) +(defun string->float ((str string)) "Convert a string to a float, but it is not implemented." - (format 0 "string->float left as an excersize for the reader~%") - 0.0 + ;(format 0 "string->float left as an excersize for the reader~%") + ;0.0 + + ;; added... + (let ((charp (-> str data)) + (result 0.0) + (negative #f)) + + (when (= (-> charp) #\-) + (set! negative #t) + (&+! charp 1) + ) + + (while (and (>= (-> charp) #\0) (<= (-> charp) #\9)) + ;; number + + (*! result 10) ;; bump oom (e.g. 123 -> 1230) + (+! result (- (-> charp) #\0)) ;; add unit (e.g. 1230 -> 1234) + (&+! charp 1) + ) + + (when (= (-> charp) #\.) + ;; dot + (&+! charp 1) + ;; fractional part begin + (let ((frac 1.0)) + (while (and (>= (-> charp) #\0) (<= (-> charp) #\9)) + ;; number + + (*! frac 10) ;; bump frac oom + (+! result (/ (the float (- (-> charp) #\0)) frac)) ;; add frac (e.g. 1234 -> 1234.5) + (&+! charp 1) + ) + ) + ) + + (cond + (negative + (- result) + ) + (else + result + ) + ) + ) ) (defun string-get-int32!! ((arg0 (pointer int32)) (arg1 string)) @@ -663,9 +667,9 @@ (cond ((string-get-arg!! *string-tmp-str* arg1) (set! (-> arg0 0) (string->int *string-tmp-str*)) - '#t + #t ) - (else '#f) + (else #f) ) ) @@ -673,14 +677,13 @@ (cond ((string-get-arg!! *string-tmp-str* arg1) (set! (-> arg0 0) (string->float *string-tmp-str*)) - '#t + #t ) - (else '#f) + (else #f) ) ) (defun string-get-flag!! ((result (pointer symbol)) (in string) (first-flag string) (second-flag string)) - (local-vars (v1-0 symbol)) (cond ((string-get-arg!! *string-tmp-str* in) (cond @@ -688,21 +691,22 @@ (string= *string-tmp-str* second-flag) ) (set! (-> result 0) (string= *string-tmp-str* first-flag)) - '#t + #t ) - (else '#f) + (else #f) ) ) - (else '#f) + (else #f) ) ) ;; what is this? (define *debug-draw-pauseable* #f) -;; console buffers. not sure what the two are for. +;; console buffers. sometimes console 0 is backed up and the game switches to console 1. (define *stdcon0* (new 'global 'string 16384 (the string #f))) (define *stdcon1* (new 'global 'string 16384 (the string #f))) +;; the current onscreen console (define *stdcon* *stdcon0*) ;; shared temporary string. diff --git a/goal_src/levels/citadel/citadel-sages.gc b/goal_src/levels/citadel/citadel-sages.gc index fb0cf03f19..d142fdd159 100644 --- a/goal_src/levels/citadel/citadel-sages.gc +++ b/goal_src/levels/citadel/citadel-sages.gc @@ -51,61 +51,51 @@ (defbehavior citb-sagecage-draw-bars citb-sagecage () - (when (logtest? (-> self draw status) 8) - (let ((gp-0 (-> self node-list data 3 bone transform)) - (s5-0 (new 'stack-no-clear 'vector)) - ) - (let ((s4-0 (new 'stack-no-clear 'vector))) - (let ((s3-0 (new 'stack-no-clear 'vector))) - (matrix->quaternion (the-as quaternion s4-0) gp-0) - (vector-! s3-0 (camera-pos) (-> self root-override trans)) - (let ((v1-7 (-> gp-0 vector 2))) - (set! (-> self angle-offset) (- (atan (-> v1-7 x) (-> v1-7 z)))) - ) - (quaternion-rotate-local-x! - (the-as quaternion s4-0) - (the-as quaternion s4-0) - 16384.0 - ) - (let ((f0-7 (+ (-> self angle-offset) (atan (-> s3-0 x) (-> s3-0 z))))) - (quaternion-rotate-local-z! - (the-as quaternion s4-0) - (the-as quaternion s4-0) - f0-7 - ) - ) - ) - (quaternion-copy! *particle-quat* (the-as quaternion s4-0)) - ) - (let ((s4-1 (-> *part-id-table* 2473)) - (s3-1 *sp-particle-system-3d*) + (when (logtest? (-> self draw status) (draw-status drwf03)) + (let ((gp-0 (-> self node-list data 3 bone transform)) + (s5-0 (new 'stack-no-clear 'vector)) ) - (dotimes (s2-2 12) - (vector-matrix*! s5-0 (-> self bar-array s2-2) gp-0) - (sp-launch-particles-var - s3-1 - s4-1 - s5-0 - (the-as sparticle-launch-state #f) - (the-as sparticle-launch-control #f) - 1.0 - ) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (matrix->quaternion (the-as quaternion s4-0) gp-0) + (vector-! s3-0 (camera-pos) (-> self root-override trans)) + (let ((v1-7 (-> gp-0 vector 2))) + (set! (-> self angle-offset) (- (atan (-> v1-7 x) (-> v1-7 z)))) + ) + (quaternion-rotate-local-x! (the-as quaternion s4-0) (the-as quaternion s4-0) 16384.0) + (let ((f0-7 (+ (-> self angle-offset) (atan (-> s3-0 x) (-> s3-0 z))))) + (quaternion-rotate-local-z! (the-as quaternion s4-0) (the-as quaternion s4-0) f0-7) + ) + ) + (quaternion-copy! *particle-quat* (the-as quaternion s4-0)) + ) + (let ((s4-1 (-> *part-id-table* 2473)) + (s3-1 *sp-particle-system-3d*) + ) + (dotimes (s2-2 12) + (vector-matrix*! s5-0 (-> self bar-array s2-2) gp-0) + (sp-launch-particles-var + s3-1 + s4-1 + s5-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + ) + ) ) - ) ) - ) 0 (none) ) (defbehavior citb-sagecage-update-collision citb-sagecage () - (change-mesh - (the-as collide-shape-prim-mesh (-> self root-override root-prim)) - (if (-> self bars-on) - 0 - 1 - ) - ) + (change-mesh (the-as collide-shape-prim-mesh (-> self root-override root-prim)) (if (-> self bars-on) + 0 + 1 + ) + ) 0 (none) ) @@ -113,130 +103,100 @@ (defstate citb-sagecage-idle (citb-sagecage) :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) - (local-vars (v0-3 none)) - (let ((v1-0 arg2)) - (the-as object (cond - ((= v1-0 'disable-bars) - (stop! (-> self sound)) - (sound-play-by-name - (static-sound-name "sagecage-off") - (new-sound-id) - 1024 - 0 - 0 - 1 - #t - ) - (set! (-> self bars-on) #f) - (citb-sagecage-update-collision) - ) - ((= v1-0 'enable-bars) - (set! (-> self bars-on) #t) - (citb-sagecage-update-collision) - ) - ((= v1-0 'start-cloning) - (set! v0-3 (the-as none #t)) - (set! (-> self cloning) (the-as symbol v0-3)) - v0-3 - ) - ((= v1-0 'stop-cloning) - (set! (-> self cloning) #f) - (let ((v1-7 (-> self skel root-channel 0))) - (set! v0-3 (the-as none (-> self draw art-group data 3))) - (set! (-> v1-7 frame-group) (the-as art-joint-anim v0-3)) - ) - v0-3 - ) - ) - ) + (local-vars (v0-3 none)) + (let ((v1-0 arg2)) + (the-as object (cond + ((= v1-0 'disable-bars) + (stop! (-> self sound)) + (sound-play-by-name (static-sound-name "sagecage-off") (new-sound-id) 1024 0 0 1 #t) + (set! (-> self bars-on) #f) + (citb-sagecage-update-collision) + ) + ((= v1-0 'enable-bars) + (set! (-> self bars-on) #t) + (citb-sagecage-update-collision) + ) + ((= v1-0 'start-cloning) + (set! v0-3 (the-as none #t)) + (set! (-> self cloning) (the-as symbol v0-3)) + v0-3 + ) + ((= v1-0 'stop-cloning) + (set! (-> self cloning) #f) + (let ((v1-7 (-> self skel root-channel 0))) + (set! v0-3 (the-as none (-> self draw art-group data 3))) + (set! (-> v1-7 frame-group) (the-as art-joint-anim v0-3)) + ) + v0-3 + ) + ) + ) + ) ) - ) :trans (the-as (function none :behavior citb-sagecage) rider-trans) :code (behavior () - (while #t - (cond - ((-> self cloning) - (let ((gp-0 (ppointer->process (-> self parent-override)))) - (when gp-0 - (joint-control-copy! (-> self skel) (-> (the-as citb-sage gp-0) skel)) - (joint-control-remap! - (-> self skel) - (-> self draw art-group) - (-> (the-as citb-sage gp-0) draw art-group) - '() - 0 - "" + (while #t + (cond + ((-> self cloning) + (let ((gp-0 (ppointer->process (-> self parent-override)))) + (when gp-0 + (joint-control-copy! (-> self skel) (-> (the-as citb-sage gp-0) skel)) + (joint-control-remap! + (-> self skel) + (-> self draw art-group) + (-> (the-as citb-sage gp-0) draw art-group) + '() + 0 + "" + ) + ) + ) ) + (else + (let ((a0-2 (-> self skel root-channel 0))) + (set! (-> a0-2 param 0) 1.0) + (joint-control-channel-group-eval! a0-2 (the-as art-joint-anim #f) num-func-loop!) + ) + ) ) - ) + (suspend) ) - (else - (let ((a0-2 (-> self skel root-channel 0))) - (set! (-> a0-2 param 0) 1.0) - (joint-control-channel-group-eval! - a0-2 - (the-as art-joint-anim #f) - num-func-loop! - ) - ) - ) - ) - (suspend) + (none) ) - (none) - ) :post (behavior () - (rider-post) - (when (-> self bars-on) - (update! (-> self sound)) - (citb-sagecage-draw-bars) + (rider-post) + (when (-> self bars-on) + (update! (-> self sound)) + (citb-sagecage-draw-bars) + ) + (none) ) - (none) - ) ) (defmethod dummy-20 citb-sagecage ((obj citb-sagecage)) - (let - ((s5-0 - (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)) - ) - ) - (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) - (set! (-> s5-0 reaction) default-collision-reaction) - (set! - (-> s5-0 no-reaction) - (the-as - (function collide-shape-moving collide-shape-intersect vector vector none) - nothing - ) - ) - (dummy-29 s5-0 1) - (let - ((s4-0 - (new - 'process - 'collide-shape-prim-mesh - s5-0 - (the-as uint 0) - (the-as uint 0) - ) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) default-collision-reaction) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing) + ) + (dummy-29 s5-0 1) + (let ((s4-0 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 0) (the-as uint 0)))) + (set! (-> s4-0 prim-core collide-as) (the-as uint 2048)) + (set! (-> s4-0 collide-with) (the-as uint 16)) + (set! (-> s4-0 prim-core action) (the-as uint 3)) + (set! (-> s4-0 prim-core offense) 4) + (set! (-> s4-0 transform-index) 3) + (set-vector! (-> s4-0 local-sphere) 0.0 20480.0 0.0 28672.0) + (set-root-prim! s5-0 s4-0) ) - ) - (set! (-> s4-0 prim-core collide-as) (the-as uint 2048)) - (set! (-> s4-0 collide-with) (the-as uint 16)) - (set! (-> s4-0 prim-core action) (the-as uint 3)) - (set! (-> s4-0 prim-core offense) 4) - (set! (-> s4-0 transform-index) 3) - (set-vector! (-> s4-0 local-sphere) 0.0 20480.0 0.0 28672.0) - (set-root-prim! s5-0 s4-0) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + (backup-collide-with-as s5-0) + (set! (-> obj root-override) s5-0) ) - (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) - (backup-collide-with-as s5-0) - (set! (-> obj root-override) s5-0) - ) 0 (none) ) @@ -250,41 +210,36 @@ (f1-0 -14745.6) (f2-0 7372.8) ) - (let ((f3-0 -7372.8)) - (set-vector! (-> obj bar-array 0) f4-0 f0-1 f3-0 1.0) - (set-vector! (-> obj bar-array 1) f4-0 f0-1 0.0 1.0) - (set-vector! (-> obj bar-array 2) f4-0 f0-1 f2-0 1.0) - (set-vector! (-> obj bar-array 3) f1-0 f0-1 f3-0 1.0) - (set-vector! (-> obj bar-array 4) f1-0 f0-1 0.0 1.0) - (set-vector! (-> obj bar-array 5) f1-0 f0-1 f2-0 1.0) - (set-vector! (-> obj bar-array 6) f3-0 f0-1 f4-0 1.0) - (set-vector! (-> obj bar-array 7) 0.0 f0-1 f4-0 1.0) - (set-vector! (-> obj bar-array 8) f2-0 f0-1 f4-0 1.0) - (set-vector! (-> obj bar-array 9) f3-0 f0-1 f1-0 1.0) + (let ((f3-0 -7372.8)) + (set-vector! (-> obj bar-array 0) f4-0 f0-1 f3-0 1.0) + (set-vector! (-> obj bar-array 1) f4-0 f0-1 0.0 1.0) + (set-vector! (-> obj bar-array 2) f4-0 f0-1 f2-0 1.0) + (set-vector! (-> obj bar-array 3) f1-0 f0-1 f3-0 1.0) + (set-vector! (-> obj bar-array 4) f1-0 f0-1 0.0 1.0) + (set-vector! (-> obj bar-array 5) f1-0 f0-1 f2-0 1.0) + (set-vector! (-> obj bar-array 6) f3-0 f0-1 f4-0 1.0) + (set-vector! (-> obj bar-array 7) 0.0 f0-1 f4-0 1.0) + (set-vector! (-> obj bar-array 8) f2-0 f0-1 f4-0 1.0) + (set-vector! (-> obj bar-array 9) f3-0 f0-1 f1-0 1.0) + ) + (set-vector! (-> obj bar-array 10) 0.0 f0-1 f1-0 1.0) + (set-vector! (-> obj bar-array 11) f2-0 f0-1 f1-0 1.0) ) - (set-vector! (-> obj bar-array 10) 0.0 f0-1 f1-0 1.0) - (set-vector! (-> obj bar-array 11) f2-0 f0-1 f1-0 1.0) - ) - (set! - (-> obj sound) - (new - 'process - 'ambient-sound - (new 'static 'sound-spec - :mask #x80 - :num 1.0 - :group #x1 - :sound-name (static-sound-name "sagecage-gen") - :volume #x400 - :fo-max 20 - ) - (-> obj root-override trans) - ) - ) - (set! - (-> obj bars-on) - (not (task-complete? *game-info* (-> obj entity extra perm task))) - ) + (set! (-> obj sound) (new + 'process + 'ambient-sound + (new 'static 'sound-spec + :mask #x80 + :num 1.0 + :group #x1 + :sound-name (static-sound-name "sagecage-gen") + :volume #x400 + :fo-max 20 + ) + (-> obj root-override trans) + ) + ) + (set! (-> obj bars-on) (not (task-complete? *game-info* (-> obj entity extra perm task)))) (citb-sagecage-update-collision) (set! (-> obj cloning) #t) (set! (-> obj event-hook) (-> citb-sagecage-idle event)) @@ -294,21 +249,9 @@ (defbehavior citb-sagecage-init-by-other citb-sagecage ((arg0 citb-sage)) (dummy-20 self) - (mem-copy! - (the-as pointer (-> self root-override trans)) - (the-as pointer (-> arg0 root-override trans)) - 16 - ) - (mem-copy! - (the-as pointer (-> self root-override quat)) - (the-as pointer (-> arg0 root-override quat)) - 16 - ) - (mem-copy! - (the-as pointer (-> self root-override scale)) - (the-as pointer (-> arg0 root-override scale)) - 16 - ) + (mem-copy! (the-as pointer (-> self root-override trans)) (the-as pointer (-> arg0 root-override trans)) 16) + (mem-copy! (the-as pointer (-> self root-override quat)) (the-as pointer (-> arg0 root-override quat)) 16) + (mem-copy! (the-as pointer (-> self root-override scale)) (the-as pointer (-> arg0 root-override scale)) 16) (dummy-21 self) (go citb-sagecage-idle) (none) @@ -395,15 +338,15 @@ (defmethod relocate citb-sage ((obj citb-sage) (arg0 int)) (if (nonzero? (-> obj part-impact)) - (&+! (-> obj part-impact) arg0) - ) + (&+! (-> obj part-impact) arg0) + ) (the-as citb-sage ((method-of-type process-taskable relocate) obj arg0)) ) (defmethod deactivate citb-sage ((obj citb-sage)) (if (nonzero? (-> obj part-impact)) - (kill-and-free-particles (-> obj part-impact)) - ) + (kill-and-free-particles (-> obj part-impact)) + ) (sound-stop (-> obj sound-id)) ((method-of-type process-taskable deactivate) obj) (none) @@ -412,63 +355,44 @@ (defmethod play-reminder citb-sage ((obj citb-sage)) (set! (-> obj root-override pause-adjust-distance) 409600.0) (let ((s5-0 (get-process *default-dead-pool* citb-sagecage #x4000))) - (set! (-> obj cage) (ppointer->handle (when s5-0 - (let - ((t9-1 - (method-of-type - citb-sagecage - activate - ) - ) - ) - (t9-1 - (the-as citb-sagecage s5-0) - obj - 'citb-sagecage - (the-as pointer #x70004000) - ) - ) - (run-now-in-process - s5-0 - citb-sagecage-init-by-other - obj - ) - (-> s5-0 ppointer) - ) - ) + (set! (-> obj cage) + (ppointer->handle (when s5-0 + (let ((t9-1 (method-of-type citb-sagecage activate))) + (t9-1 (the-as citb-sagecage s5-0) obj 'citb-sagecage (the-as pointer #x70004000)) + ) + (run-now-in-process s5-0 citb-sagecage-init-by-other obj) + (-> s5-0 ppointer) + ) + ) + ) ) - ) (set! (-> obj beam-on) #f) (set! (-> obj sound-id) (new-sound-id)) (if (zero? (-> obj sound-name)) - (set! (-> obj sound-name) "") - ) - (let - ((v1-9 (the-as entity (entity-actor-lookup (-> obj entity) 'alt-actor 0))) - (s5-1 (new 'stack-no-clear 'vector)) + (set! (-> obj sound-name) "") + ) + (let ((v1-9 (the-as entity (entity-actor-lookup (-> obj entity) 'alt-actor 0))) + (s5-1 (new 'stack-no-clear 'vector)) + ) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (if (not (the-as entity-actor v1-9)) + (set! v1-9 (entity-by-name "citb-robotboss-1")) + ) + (set! (-> obj alt-actor) (the-as entity-actor v1-9)) + (set! (-> obj spawn-pos quad) (-> obj root-override trans quad)) + (set! (-> s5-1 quad) (-> v1-9 extra trans quad)) + (set! (-> s5-1 y) (+ 81920.0 (-> s5-1 y))) + (vector-! s4-0 (-> obj spawn-pos) s5-1) + (set! (-> s4-0 y) 0.0) + (vector-normalize! s4-0 1.0) + (vector+*! (-> obj target-pos) s5-1 s4-0 116940.8) + ) + (when (nonzero? (-> obj part)) + (vector-! s5-1 (-> obj target-pos) (-> obj spawn-pos)) + (vector-float*! (the-as vector (-> obj part group bounds)) s5-1 0.5) + (set! (-> obj part group bounds w) (* 0.6 (vector-vector-distance (-> obj spawn-pos) (-> obj target-pos)))) + ) ) - (let ((s4-0 (new 'stack-no-clear 'vector))) - (if (not (the-as entity-actor v1-9)) - (set! v1-9 (entity-by-name "citb-robotboss-1")) - ) - (set! (-> obj alt-actor) (the-as entity-actor v1-9)) - (set! (-> obj spawn-pos quad) (-> obj root-override trans quad)) - (set! (-> s5-1 quad) (-> v1-9 extra trans quad)) - (set! (-> s5-1 y) (+ 81920.0 (-> s5-1 y))) - (vector-! s4-0 (-> obj spawn-pos) s5-1) - (set! (-> s4-0 y) 0.0) - (vector-normalize! s4-0 1.0) - (vector+*! (-> obj target-pos) s5-1 s4-0 116940.8) - ) - (when (nonzero? (-> obj part)) - (vector-! s5-1 (-> obj target-pos) (-> obj spawn-pos)) - (vector-float*! (the-as vector (-> obj part group bounds)) s5-1 0.5) - (set! - (-> obj part group bounds w) - (* 0.6 (vector-vector-distance (-> obj spawn-pos) (-> obj target-pos))) - ) - ) - ) (the-as symbol 0) ) @@ -480,9 +404,9 @@ (defmethod dummy-42 citb-sage ((obj citb-sage)) (if (not (should-display? obj)) - (go (method-of-object obj hidden)) - (go (method-of-object obj idle)) - ) + (go (method-of-object obj hidden)) + (go (method-of-object obj idle)) + ) (none) ) @@ -492,14 +416,14 @@ (defmethod get-art-elem citb-sage ((obj citb-sage)) (cond - ((= (current-status (-> obj tasks)) (task-status invalid)) - (set! (-> obj beam-on) #t) - (-> obj draw art-group data (-> obj attack-anim)) + ((= (current-status (-> obj tasks)) (task-status invalid)) + (set! (-> obj beam-on) #t) + (-> obj draw art-group data (-> obj attack-anim)) + ) + (else + (-> obj draw art-group data (-> obj idle-anim)) + ) ) - (else - (-> obj draw art-group data (-> obj idle-anim)) - ) - ) ) (defmethod should-display? citb-sage ((obj citb-sage)) @@ -510,29 +434,26 @@ :virtual #t :enter (behavior () - (send-event (handle->process (-> self cage)) 'disable-bars) - (send-event (handle->process (-> self cage)) 'stop-cloning) - ((-> (method-of-type process-taskable hidden) enter)) - (none) - ) + (send-event (handle->process (-> self cage)) 'disable-bars) + (send-event (handle->process (-> self cage)) 'stop-cloning) + ((-> (method-of-type process-taskable hidden) enter)) + (none) + ) ) (defbehavior citb-sage-draw-beam citb-sage () (if (< (vector-vector-distance (ear-trans) (-> self spawn-pos)) 409600.0) - (sound-play-by-name - (string->sound-name (-> self sound-name)) - (-> self sound-id) - 1024 - 0 - 0 - 1 - (the-as symbol (-> self spawn-pos)) - ) - ) - (set! - (-> self spawn-pos quad) - (-> self node-list data (-> self beam-joint) bone transform vector 3 quad) - ) + (sound-play-by-name + (string->sound-name (-> self sound-name)) + (-> self sound-id) + 1024 + 0 + 0 + 1 + (the-as symbol (-> self spawn-pos)) + ) + ) + (set! (-> self spawn-pos quad) (-> self node-list data (-> self beam-joint) bone transform vector 3 quad)) (vector-! (-> self dir) (-> self target-pos) (-> self spawn-pos)) (set! (-> self rot-y) (vector-y-angle (-> self dir))) (set! (-> self rot-x) (- 16384.0 (vector-x-angle (-> self dir)))) @@ -545,55 +466,46 @@ :virtual #t :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) - (case arg2 - (('disable-bars) - (send-event (handle->process (-> self cage)) 'disable-bars) + (case arg2 + (('disable-bars) + (send-event (handle->process (-> self cage)) 'disable-bars) + ) + (else + ((-> (method-of-type process-taskable play-anim) event) arg0 arg1 arg2 arg3) + ) ) - (else - ((-> (method-of-type process-taskable play-anim) event) - arg0 - arg1 - arg2 - arg3 - ) - ) ) - ) ) (defstate idle (citb-sage) :virtual #t :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) - (case arg2 - (('open) - (send-event (handle->process (-> self cage)) 'disable-bars) + (case arg2 + (('open) + (send-event (handle->process (-> self cage)) 'disable-bars) + ) + (else + ((-> (method-of-type process-taskable idle) event) arg0 arg1 arg2 arg3) + ) ) - (else - ((-> (method-of-type process-taskable idle) event) arg0 arg1 arg2 arg3) - ) ) - ) :trans (behavior () - (if (not (should-display? self)) - (go-virtual hidden) + (if (not (should-display? self)) + (go-virtual hidden) + ) + ((-> (method-of-type process-taskable idle) trans)) + (none) ) - ((-> (method-of-type process-taskable idle) trans)) - (none) - ) :post (behavior () - ((the-as - (function none :behavior citb-sage) - (-> (method-of-type process-taskable idle) post) - ) + ((the-as (function none :behavior citb-sage) (-> (method-of-type process-taskable idle) post))) + (if (-> self beam-on) + (citb-sage-draw-beam) + ) + (none) ) - (if (-> self beam-on) - (citb-sage-draw-beam) - ) - (none) - ) ) (deftype red-sagecage (citb-sage) @@ -607,42 +519,38 @@ (defmethod dummy-52 red-sagecage ((obj red-sagecage)) (let ((v1-1 (-> obj draw shadow-ctrl))) - (when v1-1 - (let ((a0-1 v1-1)) - (set! (-> a0-1 settings bot-plane w) (- -8192.0)) - ) - 0 - (let ((a0-3 v1-1)) - (set! (-> a0-3 settings top-plane w) (- 4096.0)) - ) - 0 - (set! (-> v1-1 settings flags) (logand -13 (-> v1-1 settings flags))) + (when v1-1 + (let ((a0-1 v1-1)) + (set! (-> a0-1 settings bot-plane w) (- -8192.0)) + ) + 0 + (let ((a0-3 v1-1)) + (set! (-> a0-3 settings top-plane w) (- 4096.0)) + ) + 0 + (set! (-> v1-1 settings flags) (logand -13 (-> v1-1 settings flags))) + ) ) - ) (none) ) (defmethod draw-npc-shadow red-sagecage ((obj red-sagecage)) (-> obj draw shadow-ctrl) (cond - ((and - (-> obj draw shadow) - (zero? (-> obj draw cur-lod)) - (logtest? (-> obj draw status) 8) + ((and (-> obj draw shadow) (zero? (-> obj draw cur-lod)) (logtest? (-> obj draw status) (draw-status drwf03))) + (let ((v1-9 (-> obj draw shadow-ctrl))) + (set! (-> v1-9 settings flags) (logand -33 (-> v1-9 settings flags))) + ) + 0 + (dummy-14 (-> obj draw shadow-ctrl)) ) - (let ((v1-9 (-> obj draw shadow-ctrl))) - (set! (-> v1-9 settings flags) (logand -33 (-> v1-9 settings flags))) - ) - 0 - (dummy-14 (-> obj draw shadow-ctrl)) + (else + (let ((v1-14 (-> obj draw shadow-ctrl))) + (logior! (-> v1-14 settings flags) 32) + ) + 0 + ) ) - (else - (let ((v1-14 (-> obj draw shadow-ctrl))) - (logior! (-> v1-14 settings flags) 32) - ) - 0 - ) - ) (none) ) @@ -662,39 +570,21 @@ (set! (-> obj attack-start-anim) 5) (set! (-> obj attack-anim) 6) (set! (-> obj beam-joint) 20) - (set! - (-> obj part) - (create-launch-control (-> *part-group-id-table* 604) obj) - ) - (set! - (-> obj part-impact) - (create-launch-control (-> *part-group-id-table* 608) obj) - ) - (set! - (-> obj resolution-anim) - (new 'static 'spool-anim - :name "redsage-resolution" - :index 7 - :parts 9 - :command-list - '( - ((the binteger 15) - send-event - self - disable-bars + (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 604) obj)) + (set! (-> obj part-impact) (create-launch-control (-> *part-group-id-table* 608) obj)) + (set! (-> obj resolution-anim) (new 'static 'spool-anim + :name "redsage-resolution" + :index 7 + :parts 9 + :command-list + '((15 send-event self disable-bars) + (45 joint "cameraB") + (216 joint "camera") + (435 joint "cameraB") + (685 joint "camera") + ) + ) ) - ((the binteger 45) - joint - "cameraB" - ) - ((the binteger 216) - joint - "camera" - ) - ((the binteger 435) joint "cameraB") ((the binteger 685) joint "camera") - ) - ) - ) (set! (-> obj sound-name) "redsage-fires") ((the-as (function citb-sage none) (find-parent-method red-sagecage 44)) obj) (the-as symbol 0) @@ -702,39 +592,29 @@ (defmethod TODO-RENAME-43 red-sagecage ((obj red-sagecage)) (if (-> obj beam-on) - (return #f) - ) - (when - (TODO-RENAME-10 - (-> obj ambient) - (new 'stack-no-clear 'vector) - 9000 - 122880.0 - obj - ) - (let* ((v1-6 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) - (v1-7 (the-as number (logior #x3f800000 v1-6))) - (f0-2 (+ -1.0 (the-as float v1-7))) + (return #f) + ) + (when (TODO-RENAME-10 (-> obj ambient) (new 'stack-no-clear 'vector) 9000 122880.0 obj) + (let* ((v1-6 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-7 (the-as number (logior #x3f800000 v1-6))) + (f0-2 (+ -1.0 (the-as float v1-7))) + ) + (cond + ((< 0.6666667 f0-2) + (play-ambient (-> obj ambient) "RED-AM01" #f (-> obj root-override trans)) + ) + ((< 0.33333334 f0-2) + (play-ambient (-> obj ambient) "RED-AM02" #f (-> obj root-override trans)) + ) + (else + (play-ambient (-> obj ambient) "RED-AM03" #f (-> obj root-override trans)) ) - (cond - ((< 0.6666667 f0-2) - (play-ambient (-> obj ambient) "RED-AM01" #f (-> obj root-override trans)) + ) ) - ((< 0.33333334 f0-2) - (play-ambient (-> obj ambient) "RED-AM02" #f (-> obj root-override trans)) - ) - (else - (play-ambient (-> obj ambient) "RED-AM03" #f (-> obj root-override trans)) - ) - ) ) - ) ) -(defmethod - init-from-entity! - red-sagecage - ((obj red-sagecage) (arg0 entity-actor)) +(defmethod init-from-entity! red-sagecage ((obj red-sagecage) (arg0 entity-actor)) (dummy-40 obj arg0 *redsage-sg* 3 33 (new 'static 'vector :w 8192.0) 5) (set! (-> obj tasks) (get-task-control (-> obj entity extra perm task))) (play-reminder obj) @@ -754,42 +634,38 @@ (defmethod dummy-52 blue-sagecage ((obj blue-sagecage)) (let ((v1-1 (-> obj draw shadow-ctrl))) - (when v1-1 - (let ((a0-1 v1-1)) - (set! (-> a0-1 settings bot-plane w) (- -10035.2)) - ) - 0 - (let ((a0-3 v1-1)) - (set! (-> a0-3 settings top-plane w) (- 4096.0)) - ) - 0 - (set! (-> v1-1 settings flags) (logand -13 (-> v1-1 settings flags))) + (when v1-1 + (let ((a0-1 v1-1)) + (set! (-> a0-1 settings bot-plane w) (- -10035.2)) + ) + 0 + (let ((a0-3 v1-1)) + (set! (-> a0-3 settings top-plane w) (- 4096.0)) + ) + 0 + (set! (-> v1-1 settings flags) (logand -13 (-> v1-1 settings flags))) + ) ) - ) (none) ) (defmethod draw-npc-shadow blue-sagecage ((obj blue-sagecage)) (-> obj draw shadow-ctrl) (cond - ((and - (-> obj draw shadow) - (zero? (-> obj draw cur-lod)) - (logtest? (-> obj draw status) 8) + ((and (-> obj draw shadow) (zero? (-> obj draw cur-lod)) (logtest? (-> obj draw status) (draw-status drwf03))) + (let ((v1-9 (-> obj draw shadow-ctrl))) + (set! (-> v1-9 settings flags) (logand -33 (-> v1-9 settings flags))) + ) + 0 + (dummy-14 (-> obj draw shadow-ctrl)) ) - (let ((v1-9 (-> obj draw shadow-ctrl))) - (set! (-> v1-9 settings flags) (logand -33 (-> v1-9 settings flags))) - ) - 0 - (dummy-14 (-> obj draw shadow-ctrl)) + (else + (let ((v1-14 (-> obj draw shadow-ctrl))) + (logior! (-> v1-14 settings flags) 32) + ) + 0 + ) ) - (else - (let ((v1-14 (-> obj draw shadow-ctrl))) - (logior! (-> v1-14 settings flags) 32) - ) - 0 - ) - ) (none) ) @@ -809,60 +685,26 @@ (set! (-> obj attack-start-anim) 5) (set! (-> obj attack-anim) 6) (set! (-> obj beam-joint) 53) - (set! - (-> obj part) - (create-launch-control (-> *part-group-id-table* 603) obj) - ) - (set! - (-> obj part-impact) - (create-launch-control (-> *part-group-id-table* 607) obj) - ) - (set! - (-> obj resolution-anim) - (new 'static 'spool-anim - :name "bluesage-resolution" - :index 7 - :parts 9 - :command-list - '( - ((the binteger 15) - send-event - self - disable-bars + (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 603) obj)) + (set! (-> obj part-impact) (create-launch-control (-> *part-group-id-table* 607) obj)) + (set! (-> obj resolution-anim) (new 'static 'spool-anim + :name "bluesage-resolution" + :index 7 + :parts 9 + :command-list + '((15 send-event self disable-bars) + (45 joint "cameraB") + (74 shadow self #f) + (185 joint "camera") + (256 joint "cameraB") + (505 joint "camera") + (590 joint "cameraB") + (670 joint "camera") + (875 shadow self #t) + (876 joint "cameraB") + ) + ) ) - ((the binteger 45) - joint - "cameraB" - ) - ((the binteger 74) - shadow - self - #f - ) - ((the binteger 185) - joint - "camera" - ) - ((the binteger 256) - joint - "cameraB" - ) - ((the binteger 505) - joint - "camera" - ) - ((the binteger 590) - joint - "cameraB" - ) - ((the binteger 670) - joint - "camera" - ) - ((the binteger 875) shadow self #t) ((the binteger 876) joint "cameraB") - ) - ) - ) (set! (-> obj sound-name) "bluesage-fires") ((the-as (function citb-sage none) (find-parent-method blue-sagecage 44)) obj) (the-as symbol 0) @@ -870,39 +712,29 @@ (defmethod TODO-RENAME-43 blue-sagecage ((obj blue-sagecage)) (if (-> obj beam-on) - (return #f) - ) - (when - (TODO-RENAME-10 - (-> obj ambient) - (new 'stack-no-clear 'vector) - 9000 - 122880.0 - obj - ) - (let* ((v1-6 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) - (v1-7 (the-as number (logior #x3f800000 v1-6))) - (f0-2 (+ -1.0 (the-as float v1-7))) + (return #f) + ) + (when (TODO-RENAME-10 (-> obj ambient) (new 'stack-no-clear 'vector) 9000 122880.0 obj) + (let* ((v1-6 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-7 (the-as number (logior #x3f800000 v1-6))) + (f0-2 (+ -1.0 (the-as float v1-7))) + ) + (cond + ((< 0.6666667 f0-2) + (play-ambient (-> obj ambient) "BLU-AM01" #f (-> obj root-override trans)) + ) + ((< 0.33333334 f0-2) + (play-ambient (-> obj ambient) "BLU-AM02" #f (-> obj root-override trans)) + ) + (else + (play-ambient (-> obj ambient) "BLU-AM03" #f (-> obj root-override trans)) ) - (cond - ((< 0.6666667 f0-2) - (play-ambient (-> obj ambient) "BLU-AM01" #f (-> obj root-override trans)) + ) ) - ((< 0.33333334 f0-2) - (play-ambient (-> obj ambient) "BLU-AM02" #f (-> obj root-override trans)) - ) - (else - (play-ambient (-> obj ambient) "BLU-AM03" #f (-> obj root-override trans)) - ) - ) ) - ) ) -(defmethod - init-from-entity! - blue-sagecage - ((obj blue-sagecage) (arg0 entity-actor)) +(defmethod init-from-entity! blue-sagecage ((obj blue-sagecage) (arg0 entity-actor)) (dummy-40 obj arg0 *bluesage-sg* 3 54 (new 'static 'vector :w 8192.0) 5) (set! (-> obj tasks) (get-task-control (-> obj entity extra perm task))) (play-reminder obj) @@ -922,42 +754,38 @@ (defmethod dummy-52 yellow-sagecage ((obj yellow-sagecage)) (let ((v1-1 (-> obj draw shadow-ctrl))) - (when v1-1 - (let ((a0-1 v1-1)) - (set! (-> a0-1 settings bot-plane w) (- -6144.0)) - ) - 0 - (let ((a0-3 v1-1)) - (set! (-> a0-3 settings top-plane w) (- 4096.0)) - ) - 0 - (set! (-> v1-1 settings flags) (logand -13 (-> v1-1 settings flags))) + (when v1-1 + (let ((a0-1 v1-1)) + (set! (-> a0-1 settings bot-plane w) (- -6144.0)) + ) + 0 + (let ((a0-3 v1-1)) + (set! (-> a0-3 settings top-plane w) (- 4096.0)) + ) + 0 + (set! (-> v1-1 settings flags) (logand -13 (-> v1-1 settings flags))) + ) ) - ) (none) ) (defmethod draw-npc-shadow yellow-sagecage ((obj yellow-sagecage)) (-> obj draw shadow-ctrl) (cond - ((and - (-> obj draw shadow) - (zero? (-> obj draw cur-lod)) - (logtest? (-> obj draw status) 8) + ((and (-> obj draw shadow) (zero? (-> obj draw cur-lod)) (logtest? (-> obj draw status) (draw-status drwf03))) + (let ((v1-9 (-> obj draw shadow-ctrl))) + (set! (-> v1-9 settings flags) (logand -33 (-> v1-9 settings flags))) + ) + 0 + (dummy-14 (-> obj draw shadow-ctrl)) ) - (let ((v1-9 (-> obj draw shadow-ctrl))) - (set! (-> v1-9 settings flags) (logand -33 (-> v1-9 settings flags))) - ) - 0 - (dummy-14 (-> obj draw shadow-ctrl)) + (else + (let ((v1-14 (-> obj draw shadow-ctrl))) + (logior! (-> v1-14 settings flags) 32) + ) + 0 + ) ) - (else - (let ((v1-14 (-> obj draw shadow-ctrl))) - (logior! (-> v1-14 settings flags) 32) - ) - 0 - ) - ) (none) ) @@ -977,81 +805,51 @@ (set! (-> obj attack-start-anim) 5) (set! (-> obj attack-anim) 6) (set! (-> obj beam-joint) 74) - (set! - (-> obj part) - (create-launch-control (-> *part-group-id-table* 605) obj) - ) - (set! - (-> obj part-impact) - (create-launch-control (-> *part-group-id-table* 609) obj) - ) - (set! - (-> obj resolution-anim) - (new 'static 'spool-anim - :name "yellowsage-resolution" - :index 7 - :parts 6 - :command-list - '( - ((the binteger 15) - send-event - self - disable-bars + (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 605) obj)) + (set! (-> obj part-impact) (create-launch-control (-> *part-group-id-table* 609) obj)) + (set! (-> obj resolution-anim) (new 'static 'spool-anim + :name "yellowsage-resolution" + :index 7 + :parts 6 + :command-list + '((15 send-event self disable-bars) + (45 joint "cameraB") + (256 joint "camera") + (314 joint "cameraB") + (600 joint "camera") + ) + ) ) - ((the binteger 45) - joint - "cameraB" - ) - ((the binteger 256) - joint - "camera" - ) - ((the binteger 314) joint "cameraB") ((the binteger 600) joint "camera") - ) - ) - ) (set! (-> obj sound-name) "yellsage-fire") - ((the-as (function citb-sage none) (find-parent-method yellow-sagecage 44)) - obj - ) + ((the-as (function citb-sage none) (find-parent-method yellow-sagecage 44)) obj) (the-as symbol 0) ) (defmethod TODO-RENAME-43 yellow-sagecage ((obj yellow-sagecage)) (if (-> obj beam-on) - (return #f) - ) - (when - (TODO-RENAME-10 - (-> obj ambient) - (new 'stack-no-clear 'vector) - 9000 - 122880.0 - obj - ) - (let* ((v1-6 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) - (v1-7 (the-as number (logior #x3f800000 v1-6))) - (f0-2 (+ -1.0 (the-as float v1-7))) + (return #f) + ) + (when (TODO-RENAME-10 (-> obj ambient) (new 'stack-no-clear 'vector) 9000 122880.0 obj) + (let* ((v1-6 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-7 (the-as number (logior #x3f800000 v1-6))) + (f0-2 (+ -1.0 (the-as float v1-7))) + ) + (cond + ((< 0.6666667 f0-2) + (play-ambient (-> obj ambient) "YEL-AM01" #f (-> obj root-override trans)) + ) + ((< 0.33333334 f0-2) + (play-ambient (-> obj ambient) "YEL-AM02" #f (-> obj root-override trans)) + ) + (else + (play-ambient (-> obj ambient) "YEL-AM03" #f (-> obj root-override trans)) ) - (cond - ((< 0.6666667 f0-2) - (play-ambient (-> obj ambient) "YEL-AM01" #f (-> obj root-override trans)) + ) ) - ((< 0.33333334 f0-2) - (play-ambient (-> obj ambient) "YEL-AM02" #f (-> obj root-override trans)) - ) - (else - (play-ambient (-> obj ambient) "YEL-AM03" #f (-> obj root-override trans)) - ) - ) ) - ) ) -(defmethod - init-from-entity! - yellow-sagecage - ((obj yellow-sagecage) (arg0 entity-actor)) +(defmethod init-from-entity! yellow-sagecage ((obj yellow-sagecage) (arg0 entity-actor)) (dummy-40 obj arg0 *yellowsage-sg* 3 50 (new 'static 'vector :w 8192.0) 5) (set! (-> obj tasks) (get-task-control (-> obj entity extra perm task))) (play-reminder obj) @@ -1090,667 +888,324 @@ (set! (-> obj attack-start-anim) 4) (set! (-> obj attack-anim) 4) (set! (-> obj beam-joint) 22) - (set! - (-> obj part) - (create-launch-control (-> *part-group-id-table* 606) obj) - ) - (set! - (-> obj part-impact) - (create-launch-control (-> *part-group-id-table* 610) obj) - ) - (set! - (-> obj resolution-anim) - (new 'static 'spool-anim - :name "green-sagecage-resolution" - :index 6 - :parts 12 - :command-list - '( - ((the binteger 33) - joint - "cameraB" + (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 606) obj)) + (set! (-> obj part-impact) (create-launch-control (-> *part-group-id-table* 610) obj)) + (set! (-> obj resolution-anim) (new 'static 'spool-anim + :name "green-sagecage-resolution" + :index 6 + :parts 12 + :command-list + '((33 joint "cameraB") + (156 joint "camera") + (405 joint "cameraB") + (576 joint "camera") + (823 joint "cameraB") + (1156 joint "camera") + (1199 joint "cameraB") + ) + ) ) - ((the binteger 156) - joint - "camera" - ) - ((the binteger 405) - joint - "cameraB" - ) - ((the binteger 576) - joint - "camera" - ) - ((the binteger 823) - joint - "cameraB" - ) - ((the binteger 1156) joint "camera") ((the binteger 1199) joint "cameraB") - ) - ) - ) (set! (-> obj sound-name) "greensage-fires") - ((the-as (function citb-sage none) (find-parent-method green-sagecage 44)) - obj - ) + ((the-as (function citb-sage none) (find-parent-method green-sagecage 44)) obj) (the-as symbol 0) ) (defmethod play-anim! green-sagecage ((obj green-sagecage) (arg0 symbol)) (local-vars (v1-7 int)) (let ((v1-1 (current-status (-> obj tasks)))) - (cond - ((= v1-1 (task-status need-hint)) - (when arg0 - (close-current! (-> obj tasks)) - (close-specific-task! - (game-task citadel-sage-blue) - (task-status need-hint) + (cond + ((= v1-1 (task-status need-hint)) + (when arg0 + (close-current! (-> obj tasks)) + (close-specific-task! (game-task citadel-sage-blue) (task-status need-hint)) + (close-specific-task! (game-task citadel-sage-red) (task-status need-hint)) + (close-specific-task! (game-task citadel-sage-yellow) (task-status need-hint)) + (set-continue! *game-info* "citadel-elevator") + ) + (new 'static 'spool-anim + :name "green-sagecage-introduction" + :index 5 + :parts 12 + :command-list + '((71 joint "cameraB") + (207 joint "camera") + (343 joint "cameraB") + (574 joint "camera") + (1060 joint "cameraB") + (1061 send-event camera teleport) + ) + ) ) - (close-specific-task! - (game-task citadel-sage-red) - (task-status need-hint) + ((begin (set! v1-7 (-> obj which-movie)) (zero? v1-7)) + (when arg0 + (send-event (handle->process (-> obj cage)) 'disable-bars) + (+! (-> obj which-movie) 1) + (set! (-> obj draw bounds w) 40960.0) + ) + (-> obj resolution-anim) ) - (close-specific-task! - (game-task citadel-sage-yellow) - (task-status need-hint) + ((= v1-7 1) + (when arg0 + (+! (-> obj which-movie) 1) + (set! (-> obj draw bounds w) 40960.0) + (let ((s5-1 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj evilbro) + (ppointer->handle + (when s5-1 + (let ((t9-8 (method-of-type manipy activate))) + (t9-8 (the-as manipy s5-1) obj 'manipy (the-as pointer #x70004000)) + ) + (run-now-in-process s5-1 manipy-init (-> obj root-override trans) (-> obj entity) *evilbro-citadel-sg* #f) + (-> s5-1 ppointer) + ) + ) + ) + ) + (send-event (handle->process (-> obj evilbro)) 'anim-mode 'clone-anim) + (send-event (handle->process (-> obj evilbro)) 'blend-shape #t) + (send-event (handle->process (-> obj evilbro)) 'center-joint 3) + (let ((s5-2 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj evilsis) + (ppointer->handle + (when s5-2 + (let ((t9-14 (method-of-type manipy activate))) + (t9-14 (the-as manipy s5-2) obj 'manipy (the-as pointer #x70004000)) + ) + (run-now-in-process s5-2 manipy-init (-> obj root-override trans) (-> obj entity) *evilsis-citadel-sg* #f) + (-> s5-2 ppointer) + ) + ) + ) + ) + (send-event (handle->process (-> obj evilsis)) 'anim-mode 'clone-anim) + (send-event (handle->process (-> obj evilsis)) 'blend-shape #t) + (send-event (handle->process (-> obj evilsis)) 'center-joint 3) + (if (handle->process (-> obj exitplat)) + (format 0 "exitplat activated~%") + ) + ) + (new 'static 'spool-anim + :name "green-sagecage-outro-preboss" + :index 7 + :parts 22 + :command-list + '((0 blackout 0) + (0 want-levels citadel finalboss) + (0 display-level finalboss special) + (0 send-event "citb-robotboss-1" 'die) + (335 joint "cameraB") + (581 joint "camera") + (696 joint "cameraB") + (828 joint "camera") + (1180 joint "cameraB") + (1380 send-event self 'spawn-robot) + (1382 joint "camera") + (1382 kill "citb-disc-d-2") + (1382 kill "citb-disc-c-4") + (1382 kill "citb-disc-c-5") + (1382 kill "citb-disc-c-6") + (1382 kill "citb-disc-b-12") + (1382 kill "citb-disc-b-13") + (1382 kill "citb-disc-b-14") + (1382 kill "citb-disc-a-11") + (1382 kill "citb-disc-a-12") + (1382 kill "citb-disc-a-13") + (1382 kill "citb-disc-a-14") + (1382 kill "citb-disc-a-15") + (1382 kill "citb-disc-a-16") + (1382 kill "citb-disc-b-21") + (1382 kill "citb-button-28") + (1382 kill "citb-button-32") + (1382 kill "citb-generator-1") + (1382 kill "citb-generator-2") + (1382 kill "citb-generator-3") + (1382 kill "citb-generator-4") + (1382 kill "citb-iris-door-15") + (1382 kill "citb-iris-door-16") + (1382 kill "crate-2996") + (1382 kill "crate-2997") + (1382 kill "crate-2998") + (1382 kill "crate-3000") + (1382 kill "citb-plat-eco-1") + (1382 kill "citb-plat-eco-2") + (1382 kill "citb-plat-eco-3") + (1382 kill "citb-stair-plat-1") + (1382 kill "citb-stair-plat-2") + (1382 kill "citb-stair-plat-3") + (1382 kill "citb-stair-plat-4") + (1382 kill "citb-stair-plat-5") + (1382 kill "citb-stair-plat-6") + (1382 kill "red-sagecage-1") + (1382 kill "blue-sagecage-1") + (1382 kill "yellow-sagecage-1") + (1382 kill "babak-391") + (1382 kill "citb-disc-c-10") + (1382 kill "citb-iris-door-32") + (1382 kill "citb-disc-b-18") + (1382 kill "citb-disc-b-19") + (1382 kill "citb-disc-b-20") + (1382 kill "citb-iris-door-14") + (1382 kill "orb-cache-top-32") + (1382 kill "citb-disc-b-17") + (1382 kill "citb-iris-door-13") + (1382 kill "citb-button-39") + (1382 kill "citb-button-40") + (1382 kill "babak-392") + (1382 kill "babak-393") + (1382 kill "citb-button-33") + (1382 kill "citb-button-34") + (1382 kill "citb-drop-plat-365") + (1382 kill "citb-drop-plat-366") + (1382 kill "citb-drop-plat-367") + (1382 kill "citb-iris-door-21") + (1382 kill "assistant-lavatube-end-3") + (1382 kill "babak-394") + (1382 kill "babak-396") + (1382 kill "citb-drop-plat-376") + (1605 joint "cameraB") + (1733 kill "citb-iris-door-2") + (1736 joint "camera") + ) + ) ) - (set-continue! *game-info* "citadel-elevator") - ) - (new 'static 'spool-anim - :name "green-sagecage-introduction" - :index 5 - :parts 12 - :command-list - '( - ((the binteger 71) - joint - "cameraB" - ) - ((the binteger 207) - joint - "camera" - ) - ((the binteger 343) - joint - "cameraB" - ) - ((the binteger 574) - joint - "camera" - ) - ((the binteger 1060) - joint - "cameraB" - ) - ((the binteger 1061) send-event camera teleport) + (else + (if arg0 + (format + 0 + "ERROR: : ~S playing anim for task status ~S~%" + (-> obj name) + (task-status->string (current-status (-> obj tasks))) + ) + ) + (-> obj draw art-group data 4) ) ) - ) - ((begin - (set! v1-7 (-> obj which-movie)) - (zero? v1-7) - ) - (when arg0 - (send-event (handle->process (-> obj cage)) 'disable-bars) - (+! (-> obj which-movie) 1) - (set! (-> obj draw bounds w) 40960.0) - ) - (-> obj resolution-anim) - ) - ((= v1-7 1) - (when arg0 - (+! (-> obj which-movie) 1) - (set! (-> obj draw bounds w) 40960.0) - (let ((s5-1 (get-process *default-dead-pool* manipy #x4000))) - (set! (-> obj evilbro) (ppointer->handle (when s5-1 - (let - ((t9-8 - (method-of-type - manipy - activate - ) - ) - ) - (t9-8 - (the-as manipy s5-1) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - (run-now-in-process - s5-1 - manipy-init - (-> obj root-override trans) - (-> obj entity) - *evilbro-citadel-sg* - #f - ) - (-> s5-1 ppointer) - ) - ) - ) - ) - (send-event (handle->process (-> obj evilbro)) 'anim-mode 'clone-anim) - (send-event (handle->process (-> obj evilbro)) 'blend-shape #t) - (send-event (handle->process (-> obj evilbro)) 'center-joint 3) - (let ((s5-2 (get-process *default-dead-pool* manipy #x4000))) - (set! (-> obj evilsis) (ppointer->handle (when s5-2 - (let - ((t9-14 - (method-of-type - manipy - activate - ) - ) - ) - (t9-14 - (the-as manipy s5-2) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - (run-now-in-process - s5-2 - manipy-init - (-> obj root-override trans) - (-> obj entity) - *evilsis-citadel-sg* - #f - ) - (-> s5-2 ppointer) - ) - ) - ) - ) - (send-event (handle->process (-> obj evilsis)) 'anim-mode 'clone-anim) - (send-event (handle->process (-> obj evilsis)) 'blend-shape #t) - (send-event (handle->process (-> obj evilsis)) 'center-joint 3) - (if (handle->process (-> obj exitplat)) - (format 0 "exitplat activated~%") - ) - ) - (new 'static 'spool-anim - :name "green-sagecage-outro-preboss" - :index 7 - :parts 22 - :command-list - '( - (0 - blackout - 0 - ) - (0 - want-levels - citadel - finalboss - ) - (0 - display-level - finalboss - special - ) - (0 - send-event - "citb-robotboss-1" - 'die - ) - ((the binteger 335) - joint - "cameraB" - ) - ((the binteger 581) - joint - "camera" - ) - ((the binteger 696) - joint - "cameraB" - ) - ((the binteger 828) - joint - "camera" - ) - ((the binteger 1180) - joint - "cameraB" - ) - ((the binteger 1380) - send-event - self - 'spawn-robot - ) - ((the binteger 1382) - joint - "camera" - ) - ((the binteger 1382) - kill - "citb-disc-d-2" - ) - ((the binteger 1382) - kill - "citb-disc-c-4" - ) - ((the binteger 1382) - kill - "citb-disc-c-5" - ) - ((the binteger 1382) - kill - "citb-disc-c-6" - ) - ((the binteger 1382) - kill - "citb-disc-b-12" - ) - ((the binteger 1382) - kill - "citb-disc-b-13" - ) - ((the binteger 1382) - kill - "citb-disc-b-14" - ) - ((the binteger 1382) - kill - "citb-disc-a-11" - ) - ((the binteger 1382) - kill - "citb-disc-a-12" - ) - ((the binteger 1382) - kill - "citb-disc-a-13" - ) - ((the binteger 1382) - kill - "citb-disc-a-14" - ) - ((the binteger 1382) - kill - "citb-disc-a-15" - ) - ((the binteger 1382) - kill - "citb-disc-a-16" - ) - ((the binteger 1382) - kill - "citb-disc-b-21" - ) - ((the binteger 1382) - kill - "citb-button-28" - ) - ((the binteger 1382) - kill - "citb-button-32" - ) - ((the binteger 1382) - kill - "citb-generator-1" - ) - ((the binteger 1382) - kill - "citb-generator-2" - ) - ((the binteger 1382) - kill - "citb-generator-3" - ) - ((the binteger 1382) - kill - "citb-generator-4" - ) - ((the binteger 1382) - kill - "citb-iris-door-15" - ) - ((the binteger 1382) - kill - "citb-iris-door-16" - ) - ((the binteger 1382) - kill - "crate-2996" - ) - ((the binteger 1382) - kill - "crate-2997" - ) - ((the binteger 1382) - kill - "crate-2998" - ) - ((the binteger 1382) - kill - "crate-3000" - ) - ((the binteger 1382) - kill - "citb-plat-eco-1" - ) - ((the binteger 1382) - kill - "citb-plat-eco-2" - ) - ((the binteger 1382) - kill - "citb-plat-eco-3" - ) - ((the binteger 1382) - kill - "citb-stair-plat-1" - ) - ((the binteger 1382) - kill - "citb-stair-plat-2" - ) - ((the binteger 1382) - kill - "citb-stair-plat-3" - ) - ((the binteger 1382) - kill - "citb-stair-plat-4" - ) - ((the binteger 1382) - kill - "citb-stair-plat-5" - ) - ((the binteger 1382) - kill - "citb-stair-plat-6" - ) - ((the binteger 1382) - kill - "red-sagecage-1" - ) - ((the binteger 1382) - kill - "blue-sagecage-1" - ) - ((the binteger 1382) - kill - "yellow-sagecage-1" - ) - ((the binteger 1382) - kill - "babak-391" - ) - ((the binteger 1382) - kill - "citb-disc-c-10" - ) - ((the binteger 1382) - kill - "citb-iris-door-32" - ) - ((the binteger 1382) - kill - "citb-disc-b-18" - ) - ((the binteger 1382) - kill - "citb-disc-b-19" - ) - ((the binteger 1382) - kill - "citb-disc-b-20" - ) - ((the binteger 1382) - kill - "citb-iris-door-14" - ) - ((the binteger 1382) - kill - "orb-cache-top-32" - ) - ((the binteger 1382) - kill - "citb-disc-b-17" - ) - ((the binteger 1382) - kill - "citb-iris-door-13" - ) - ((the binteger 1382) - kill - "citb-button-39" - ) - ((the binteger 1382) - kill - "citb-button-40" - ) - ((the binteger 1382) - kill - "babak-392" - ) - ((the binteger 1382) - kill - "babak-393" - ) - ((the binteger 1382) - kill - "citb-button-33" - ) - ((the binteger 1382) - kill - "citb-button-34" - ) - ((the binteger 1382) - kill - "citb-drop-plat-365" - ) - ((the binteger 1382) - kill - "citb-drop-plat-366" - ) - ((the binteger 1382) - kill - "citb-drop-plat-367" - ) - ((the binteger 1382) - kill - "citb-iris-door-21" - ) - ((the binteger 1382) - kill - "assistant-lavatube-end-3" - ) - ((the binteger 1382) - kill - "babak-394" - ) - ((the binteger 1382) - kill - "babak-396" - ) - ((the binteger 1382) - kill - "citb-drop-plat-376" - ) - ((the binteger 1605) - joint - "cameraB" - ) - ((the binteger 1733) - kill - "citb-iris-door-2" - ) - ((the binteger 1736) joint "camera") - ) - ) - ) - (else - (if arg0 - (format - 0 - "ERROR: : ~S playing anim for task status ~S~%" - (-> obj name) - (task-status->string (current-status (-> obj tasks))) - ) - ) - (-> obj draw art-group data 4) - ) ) - ) ) (defstate play-anim (green-sagecage) :virtual #t :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) - (case arg2 - (('spawn-robot) - (let ((gp-0 (entity-by-name "robotboss-3"))) - (format 0 "robotboss ent ~A~%" gp-0) - (when gp-0 - (let ((s5-0 (get-process *default-dead-pool* manipy #x4000))) - (set! (-> self robotboss) (ppointer->handle (when s5-0 - (let - ((t9-3 - (method-of-type - manipy - activate - ) - ) - ) - (t9-3 - (the-as manipy s5-0) - self - 'manipy - (the-as - pointer - #x70004000 - ) - ) - ) - (run-now-in-process - s5-0 - manipy-init - (-> - self - root-override - trans - ) - gp-0 - *robotboss-sg* - #f - ) - (-> s5-0 ppointer) - ) - ) - ) - ) - (send-event - (handle->process (-> self robotboss)) - 'anim-mode - 'clone-anim - ) - (send-event (handle->process (-> self robotboss)) 'center-joint 3) - (send-event (handle->process (-> self robotboss)) 'origin-joint-index 3) - (let ((s5-1 (handle->process (-> self robotboss)))) - (when s5-1 - (format 0 "robotboss activated ent ~A~%" gp-0) - (let ((f0-0 327680.0)) - (set! (-> (the-as robotboss s5-1) draw bounds w) f0-0) - f0-0 + (case arg2 + (('spawn-robot) + (let ((gp-0 (entity-by-name "robotboss-3"))) + (format 0 "robotboss ent ~A~%" gp-0) + (when gp-0 + (let ((s5-0 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> self robotboss) + (ppointer->handle + (when s5-0 + (let ((t9-3 (method-of-type manipy activate))) + (t9-3 (the-as manipy s5-0) self 'manipy (the-as pointer #x70004000)) + ) + (run-now-in-process s5-0 manipy-init (-> self root-override trans) gp-0 *robotboss-sg* #f) + (-> s5-0 ppointer) + ) + ) + ) + ) + (send-event (handle->process (-> self robotboss)) 'anim-mode 'clone-anim) + (send-event (handle->process (-> self robotboss)) 'center-joint 3) + (send-event (handle->process (-> self robotboss)) 'origin-joint-index 3) + (let ((s5-1 (handle->process (-> self robotboss)))) + (when s5-1 + (format 0 "robotboss activated ent ~A~%" gp-0) + (let ((f0-0 327680.0)) + (set! (-> (the-as robotboss s5-1) draw bounds w) f0-0) + f0-0 + ) + ) + ) ) - ) ) - ) ) + (else + ((-> (method-of-type citb-sage play-anim) event) arg0 arg1 arg2 arg3) + ) ) - (else - ((-> (method-of-type citb-sage play-anim) event) arg0 arg1 arg2 arg3) - ) ) - ) :exit (behavior () - (let ((a0-1 (handle->process (-> self evilbro)))) - (if a0-1 - (deactivate a0-1) - ) - ) - (let ((a0-5 (handle->process (-> self evilsis)))) - (if a0-5 - (deactivate a0-5) - ) - ) - (let ((a0-9 (handle->process (-> self robotboss)))) - (if a0-9 - (deactivate a0-9) - ) - ) - (let ((a0-13 (handle->process (-> self exitplat)))) - (if a0-13 - (deactivate a0-13) - ) - ) - (when (= (current-status (-> self tasks)) (task-status invalid)) - (let ((a1-4 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-4 from) self) - (set! (-> a1-4 num-params) 0) - (set! (-> a1-4 message) 'shield-off) - (let ((t9-5 send-event-function) - (v1-28 (-> self alt-actor)) - ) - (t9-5 (if v1-28 - (-> v1-28 extra process) - ) - a1-4 + (let ((a0-1 (handle->process (-> self evilbro)))) + (if a0-1 + (deactivate a0-1) + ) + ) + (let ((a0-5 (handle->process (-> self evilsis)))) + (if a0-5 + (deactivate a0-5) + ) + ) + (let ((a0-9 (handle->process (-> self robotboss)))) + (if a0-9 + (deactivate a0-9) + ) + ) + (let ((a0-13 (handle->process (-> self exitplat)))) + (if a0-13 + (deactivate a0-13) + ) + ) + (when (= (current-status (-> self tasks)) (task-status invalid)) + (let ((a1-4 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-4 from) self) + (set! (-> a1-4 num-params) 0) + (set! (-> a1-4 message) 'shield-off) + (let ((t9-5 send-event-function) + (v1-28 (-> self alt-actor)) + ) + (t9-5 + (if v1-28 + (-> v1-28 extra process) + ) + a1-4 + ) + ) + ) + ) + (cond + ((= (-> self which-movie) 1) + (set-blackout-frames #x7530) + ) + ((= (-> self which-movie) 2) + (start 'play (get-continue-by-name *game-info* "citadel-elevator")) ) ) - ) + (set! (-> self draw bounds w) 10240.0) + ((-> (method-of-type process-taskable play-anim) exit)) + (none) ) - (cond - ((= (-> self which-movie) 1) - (set-blackout-frames #x7530) - ) - ((= (-> self which-movie) 2) - (start 'play (get-continue-by-name *game-info* "citadel-elevator")) - ) - ) - (set! (-> self draw bounds w) 10240.0) - ((-> (method-of-type process-taskable play-anim) exit)) - (none) - ) :trans (behavior () - (case (-> self which-movie) - ((1) - (spool-push *art-control* "green-sagecage-outro-preboss" 0 self -1.0) - (if (< 1200.0 (ja-aframe-num 0)) - (citb-sage-draw-beam) - ) - (when (< 1310.0 (ja-aframe-num 0)) - (let ((a1-1 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-1 from) self) - (set! (-> a1-1 num-params) 0) - (set! (-> a1-1 message) 'shield-off) - (let ((t9-4 send-event-function) - (v1-8 (-> self alt-actor)) - ) - (t9-4 (if v1-8 - (-> v1-8 extra process) - ) - a1-1 - ) + (case (-> self which-movie) + ((1) + (spool-push *art-control* "green-sagecage-outro-preboss" 0 self -1.0) + (if (< 1200.0 (ja-aframe-num 0)) + (citb-sage-draw-beam) + ) + (when (< 1310.0 (ja-aframe-num 0)) + (let ((a1-1 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-1 from) self) + (set! (-> a1-1 num-params) 0) + (set! (-> a1-1 message) 'shield-off) + (let ((t9-4 send-event-function) + (v1-8 (-> self alt-actor)) + ) + (t9-4 + (if v1-8 + (-> v1-8 extra process) + ) + a1-1 + ) + ) + ) ) - ) ) ) + ((-> (method-of-type process-taskable play-anim) trans)) + (none) ) - ((-> (method-of-type process-taskable play-anim) trans)) - (none) - ) ) (defmethod should-display? green-sagecage ((obj green-sagecage)) @@ -1761,29 +1216,23 @@ :virtual #t :trans (behavior () - (cond - ((and - *target* - (and - (< (-> (target-pos 0) z) -18821530.0) - (= (current-status (-> self tasks)) (task-status need-hint)) + (cond + ((and + *target* + (and (< (-> (target-pos 0) z) -18821530.0) (= (current-status (-> self tasks)) (task-status need-hint))) + ) + (send-event self 'play-anim) + ) + ((= (-> self which-movie) 1) + (send-event self 'play-anim) ) ) - (send-event self 'play-anim) - ) - ((= (-> self which-movie) 1) - (send-event self 'play-anim) - ) + ((-> (method-of-type citb-sage idle) trans)) + (none) ) - ((-> (method-of-type citb-sage idle) trans)) - (none) - ) ) -(defmethod - init-from-entity! - green-sagecage - ((obj green-sagecage) (arg0 entity-actor)) +(defmethod init-from-entity! green-sagecage ((obj green-sagecage) (arg0 entity-actor)) (dummy-40 obj arg0 *green-sagecage-sg* 3 40 (new 'static 'vector :w 4096.0) 5) (set! (-> obj tasks) (get-task-control (-> obj entity extra perm task))) (play-reminder obj) @@ -1792,14 +1241,14 @@ (set! (-> obj robotboss) (the-as handle #f)) (set! (-> obj exitplat) (the-as handle #f)) (cond - ((= (current-status (-> obj tasks)) (task-status invalid)) - (set! (-> obj which-movie) 2) + ((= (current-status (-> obj tasks)) (task-status invalid)) + (set! (-> obj which-movie) 2) + ) + (else + (set! (-> obj which-movie) 0) + 0 + ) ) - (else - (set! (-> obj which-movie) 0) - 0 - ) - ) (set! (-> obj sound-flava) (the-as uint 5)) (dummy-42 obj) (none) diff --git a/goalc/compiler/Compiler.h b/goalc/compiler/Compiler.h index 56fc95d145..2b3bf17524 100644 --- a/goalc/compiler/Compiler.h +++ b/goalc/compiler/Compiler.h @@ -339,7 +339,10 @@ class Compiler { int seg); Val* compile_static_pair(const goos::Object& form, Env* env, int seg); StaticResult compile_static(const goos::Object& form, Env* env); - StaticResult compile_static_no_eval_for_pairs(const goos::Object& form, Env* env, int seg); + StaticResult compile_static_no_eval_for_pairs(const goos::Object& form, + Env* env, + int seg, + bool can_macro); Val* compile_bitfield_definition(const goos::Object& form, const TypeSpec& type, @@ -573,6 +576,7 @@ class Compiler { Val* compile_dbs(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_break(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_cont(const goos::Object& form, const goos::Object& rest, Env* env); + Val* compile_stop(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_dump_all(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_pm(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_di(const goos::Object& form, const goos::Object& rest, Env* env); diff --git a/goalc/compiler/compilation/Atoms.cpp b/goalc/compiler/compilation/Atoms.cpp index 96ce9a1209..cb30c05552 100644 --- a/goalc/compiler/compilation/Atoms.cpp +++ b/goalc/compiler/compilation/Atoms.cpp @@ -175,6 +175,7 @@ const std::unordered_map< {"dbs", &Compiler::compile_dbs}, {"dbg", &Compiler::compile_dbg}, {":cont", &Compiler::compile_cont}, + {":stop", &Compiler::compile_stop}, {":break", &Compiler::compile_break}, {":dump-all-mem", &Compiler::compile_dump_all}, {":pm", &Compiler::compile_pm}, diff --git a/goalc/compiler/compilation/Debug.cpp b/goalc/compiler/compilation/Debug.cpp index b5225ca6dc..923d6fd722 100644 --- a/goalc/compiler/compilation/Debug.cpp +++ b/goalc/compiler/compilation/Debug.cpp @@ -115,6 +115,22 @@ Val* Compiler::compile_cont(const goos::Object& form, const goos::Object& rest, return get_none(); } +Val* Compiler::compile_stop(const goos::Object& form, const goos::Object& rest, Env* env) { + // todo - do something with args. + (void)form; + (void)rest; + (void)env; + + if (m_debugger.is_valid() && m_debugger.is_attached() && m_debugger.is_halted()) { + m_debugger.detach(); + } else { + fmt::print("Couldn't do :stop. Valid {}, attached {}, halted {}\n", m_debugger.is_valid(), + m_debugger.is_attached(), m_debugger.is_halted()); + } + + return get_none(); +} + Val* Compiler::compile_break(const goos::Object& form, const goos::Object& rest, Env* env) { // todo - do something with args. (void)form; diff --git a/goalc/compiler/compilation/Macro.cpp b/goalc/compiler/compilation/Macro.cpp index f0774ae408..13cb7e5695 100644 --- a/goalc/compiler/compilation/Macro.cpp +++ b/goalc/compiler/compilation/Macro.cpp @@ -278,4 +278,4 @@ goos::Object Compiler::expand_macro_completely(const goos::Object& src, Env* env while (expand_macro_once(result, &result, env)) { } return result; -} \ No newline at end of file +} diff --git a/goalc/compiler/compilation/Static.cpp b/goalc/compiler/compilation/Static.cpp index 7aab3f6e7f..6b2be2cc68 100644 --- a/goalc/compiler/compilation/Static.cpp +++ b/goalc/compiler/compilation/Static.cpp @@ -557,7 +557,8 @@ Val* Compiler::compile_bitfield_definition(const goos::Object& form, */ StaticResult Compiler::compile_static_no_eval_for_pairs(const goos::Object& form, Env* env, - int seg) { + int seg, + bool can_macro) { auto fie = env->file_env(); if (form.is_pair()) { if (form.as_pair()->car.is_symbol() && (form.as_pair()->car.as_symbol()->name == "new" || @@ -565,8 +566,17 @@ StaticResult Compiler::compile_static_no_eval_for_pairs(const goos::Object& form form.as_pair()->car.as_symbol()->name == "lambda")) { return compile_static(form, env); } - auto car = compile_static_no_eval_for_pairs(form.as_pair()->car, env, seg); - auto cdr = compile_static_no_eval_for_pairs(form.as_pair()->cdr, env, seg); + // try as a macro + if (can_macro && form.as_pair()->car.is_symbol()) { + goos::Object macro_obj; + if (try_getting_macro_from_goos(form.as_pair()->car, ¯o_obj)) { + return compile_static_no_eval_for_pairs(expand_macro_completely(form, env), env, seg, + false); + } + } + auto car = compile_static_no_eval_for_pairs(form.as_pair()->car, env, seg, + form.as_pair()->car.is_pair()); + auto cdr = compile_static_no_eval_for_pairs(form.as_pair()->cdr, env, seg, false); auto pair_structure = std::make_unique(car, cdr, seg); auto result = StaticResult::make_structure_reference(pair_structure.get(), m_ts.make_typespec("pair")); @@ -655,7 +665,7 @@ StaticResult Compiler::compile_static(const goos::Object& form_before_macro, Env throw_compiler_error(form, "The form {} is an invalid quoted form.", form.print()); } if (second.is_pair() || second.is_empty_list()) { - return compile_static_no_eval_for_pairs(second, env, segment); + return compile_static_no_eval_for_pairs(second, env, segment, true); } else { throw_compiler_error(form, "Could not evaluate the quoted form {} at compile time.", second.print()); @@ -1033,7 +1043,7 @@ StaticResult Compiler::fill_static_inline_array(const goos::Object& form, Val* Compiler::compile_static_pair(const goos::Object& form, Env* env, int seg) { assert(form.is_pair()); // (quote PAIR) - auto result = compile_static_no_eval_for_pairs(form, env, seg); + auto result = compile_static_no_eval_for_pairs(form, env, seg, true); assert(result.is_reference()); auto fe = env->function_env(); auto static_result = fe->alloc_val(result.reference(), result.typespec()); diff --git a/goalc/debugger/Debugger.cpp b/goalc/debugger/Debugger.cpp index 582776a9da..a91778c11c 100644 --- a/goalc/debugger/Debugger.cpp +++ b/goalc/debugger/Debugger.cpp @@ -55,18 +55,35 @@ bool Debugger::is_attached() const { * Will silently do nothing if we aren't attached, so it is safe to just call detach() to try to * clean up when exiting. */ -void Debugger::detach() { +bool Debugger::detach() { + bool succ = true; if (is_valid() && m_attached) { +#ifdef __linux__ if (!is_halted()) { - do_break(); + succ = do_break(); } stop_watcher(); xdbg::close_memory(m_debug_context.tid, &m_memory_handle); xdbg::detach_and_resume(m_debug_context.tid); - m_context_valid = false; +#elif _WIN32 + if (is_halted()) { + succ = do_continue(); + } + { + std::unique_lock lk(m_watcher_mutex); + m_attach_return = false; + stop_watcher(); + m_attach_cv.wait(lk, [&]() { return m_attach_return; }); + } + xdbg::close_memory(m_debug_context.tid, &m_memory_handle); +#endif + // m_context_valid = false; m_attached = false; + } else { + succ = false; } // todo, should we print something if we can't detach? + return succ; } /*! @@ -751,6 +768,13 @@ void Debugger::watcher() { std::this_thread::sleep_for(std::chrono::milliseconds(10)); } } + +// watcher will now detach from target. +// again, windows needs the debugger thread to remain consistent +#ifdef _WIN32 + m_attach_response = xdbg::detach_and_resume(m_debug_context.tid); + m_attach_return = true; +#endif } void Debugger::handle_disappearance() { diff --git a/goalc/debugger/Debugger.h b/goalc/debugger/Debugger.h index 506103e910..c8f0cfb5ec 100644 --- a/goalc/debugger/Debugger.h +++ b/goalc/debugger/Debugger.h @@ -65,7 +65,7 @@ class Debugger { bool is_valid() const; bool is_attached() const; bool is_running() const; - void detach(); + bool detach(); void invalidate(); void set_context(u32 s7, uintptr_t base, const std::string& thread_id); std::string get_context_string() const; diff --git a/scripts/batch/gc-dbg.bat b/scripts/batch/gc-dbg.bat new file mode 100644 index 0000000000..5c69b5e26b --- /dev/null +++ b/scripts/batch/gc-dbg.bat @@ -0,0 +1,4 @@ +@echo off +cd ..\.. +out\build\Release\bin\goalc -v -auto-dbg -user-auto +pause diff --git a/scripts/batch/gc.bat b/scripts/batch/gc.bat index 5c69b5e26b..2e72bdb9b7 100644 --- a/scripts/batch/gc.bat +++ b/scripts/batch/gc.bat @@ -1,4 +1,4 @@ @echo off cd ..\.. -out\build\Release\bin\goalc -v -auto-dbg -user-auto +out\build\Release\bin\goalc -v -auto-lt -user-auto pause diff --git a/test/decompiler/reference/engine/camera/cam-debug-h_REF.gc b/test/decompiler/reference/engine/camera/cam-debug-h_REF.gc index fdc815a578..f231974472 100644 --- a/test/decompiler/reference/engine/camera/cam-debug-h_REF.gc +++ b/test/decompiler/reference/engine/camera/cam-debug-h_REF.gc @@ -2,6 +2,7 @@ (in-package goal) ;; this file is debug only +(declare-file (debug)) (when *debug-segment* ;; definition for symbol *redline-table*, type (pointer float) (define *redline-table* (the-as (pointer float) (malloc 'debug 1600))) diff --git a/test/decompiler/reference/engine/camera/cam-layout_REF.gc b/test/decompiler/reference/engine/camera/cam-layout_REF.gc index 6044324eb9..4e40883036 100644 --- a/test/decompiler/reference/engine/camera/cam-layout_REF.gc +++ b/test/decompiler/reference/engine/camera/cam-layout_REF.gc @@ -2,6 +2,7 @@ (in-package goal) ;; this file is debug only +(declare-file (debug)) (when *debug-segment* ;; definition for symbol *camera-layout-blink*, type symbol (define *camera-layout-blink* #f) diff --git a/test/decompiler/reference/engine/camera/cam-update_REF.gc b/test/decompiler/reference/engine/camera/cam-update_REF.gc index 78b0b4ad28..8ab8eefb9c 100644 --- a/test/decompiler/reference/engine/camera/cam-update_REF.gc +++ b/test/decompiler/reference/engine/camera/cam-update_REF.gc @@ -2,6 +2,7 @@ (in-package goal) ;; definition for function plane-from-points +;; INFO: Return type mismatch float vs none. (defun plane-from-points ((arg0 (inline-array plane)) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 int)) (let ((s4-0 (new 'stack-no-clear 'vector))) (vector-cross! s4-0 arg1 arg2) @@ -10,22 +11,19 @@ (set! (-> (&-> arg0 0 data arg4) 0) (-> s4-0 x)) (set! (-> (&-> arg0 0 data arg4) 4) (-> s4-0 y)) (set! (-> (&-> arg0 0 data arg4) 8) (-> s4-0 z)) - (let ((f0-5 (-> s4-0 w))) - (set! (-> (&-> arg0 0 data arg4) 12) f0-5) - f0-5 - ) + (set! (-> (&-> arg0 0 data arg4) 12) (-> s4-0 w)) ) + (none) ) ;; definition for function set-point +;; INFO: Return type mismatch float vs none. (defun set-point ((arg0 vector) (arg1 float) (arg2 float) (arg3 float)) (set! (-> arg0 x) arg1) (set! (-> arg0 y) arg2) (set! (-> arg0 z) arg3) - (let ((f0-3 1.0)) - (set! (-> arg0 w) f0-3) - f0-3 - ) + (set! (-> arg0 w) 1.0) + (none) ) ;; definition for function update-view-planes @@ -82,6 +80,7 @@ ) ) ) + (none) ) ;; definition for symbol *update-leaf-when-outside-bsp*, type symbol diff --git a/test/decompiler/reference/engine/debug/anim-tester_REF.gc b/test/decompiler/reference/engine/debug/anim-tester_REF.gc index 3493aac72d..0ef54e503d 100644 --- a/test/decompiler/reference/engine/debug/anim-tester_REF.gc +++ b/test/decompiler/reference/engine/debug/anim-tester_REF.gc @@ -2,6 +2,7 @@ (in-package goal) ;; this file is debug only +(declare-file (debug)) (when *debug-segment* ;; definition of type list-control (deftype list-control (structure) diff --git a/test/decompiler/reference/engine/debug/default-menu_REF.gc b/test/decompiler/reference/engine/debug/default-menu_REF.gc index a015718e46..d34a89b4ec 100644 --- a/test/decompiler/reference/engine/debug/default-menu_REF.gc +++ b/test/decompiler/reference/engine/debug/default-menu_REF.gc @@ -2,6 +2,7 @@ (in-package goal) ;; this file is debug only +(declare-file (debug)) (when *debug-segment* ;; definition for symbol *debug-menu-context*, type debug-menu-context (define *debug-menu-context* (new 'debug 'debug-menu-context)) diff --git a/test/decompiler/reference/engine/debug/memory-usage-h_REF.gc b/test/decompiler/reference/engine/debug/memory-usage-h_REF.gc index 4a4a1261e1..f114a1d288 100644 --- a/test/decompiler/reference/engine/debug/memory-usage-h_REF.gc +++ b/test/decompiler/reference/engine/debug/memory-usage-h_REF.gc @@ -2,6 +2,7 @@ (in-package goal) ;; this file is debug only +(declare-file (debug)) (when *debug-segment* ;; definition of type memory-usage-info (deftype memory-usage-info (structure) diff --git a/test/decompiler/reference/engine/debug/memory-usage_REF.gc b/test/decompiler/reference/engine/debug/memory-usage_REF.gc index a3665e96f8..6095f5c159 100644 --- a/test/decompiler/reference/engine/debug/memory-usage_REF.gc +++ b/test/decompiler/reference/engine/debug/memory-usage_REF.gc @@ -2,6 +2,7 @@ (in-package goal) ;; this file is debug only +(declare-file (debug)) (when *debug-segment* ;; definition for method 3 of type memory-usage-block ;; INFO: this function exists in multiple non-identical object files diff --git a/test/decompiler/reference/engine/debug/menu_REF.gc b/test/decompiler/reference/engine/debug/menu_REF.gc index bb93295132..10862eae61 100644 --- a/test/decompiler/reference/engine/debug/menu_REF.gc +++ b/test/decompiler/reference/engine/debug/menu_REF.gc @@ -2,6 +2,7 @@ (in-package goal) ;; this file is debug only +(declare-file (debug)) (when *debug-segment* ;; definition of type debug-menu-context (deftype debug-menu-context (basic) diff --git a/test/decompiler/reference/engine/debug/part-tester_REF.gc b/test/decompiler/reference/engine/debug/part-tester_REF.gc index 9fbeb80d5a..45942e713e 100644 --- a/test/decompiler/reference/engine/debug/part-tester_REF.gc +++ b/test/decompiler/reference/engine/debug/part-tester_REF.gc @@ -2,6 +2,7 @@ (in-package goal) ;; this file is debug only +(declare-file (debug)) (when *debug-segment* ;; failed to figure out what this is: (set! (-> *part-group-id-table* 105) diff --git a/test/decompiler/reference/engine/dma/dma-disasm_REF.gc b/test/decompiler/reference/engine/dma/dma-disasm_REF.gc index dcb3be880f..c36a345e98 100644 --- a/test/decompiler/reference/engine/dma/dma-disasm_REF.gc +++ b/test/decompiler/reference/engine/dma/dma-disasm_REF.gc @@ -2,6 +2,7 @@ (in-package goal) ;; this file is debug only +(declare-file (debug)) (when *debug-segment* ;; definition of type vif-disasm-element (deftype vif-disasm-element (structure) diff --git a/test/decompiler/reference/engine/gfx/capture_REF.gc b/test/decompiler/reference/engine/gfx/capture_REF.gc index 5ea6098cc3..f61672e019 100644 --- a/test/decompiler/reference/engine/gfx/capture_REF.gc +++ b/test/decompiler/reference/engine/gfx/capture_REF.gc @@ -2,6 +2,7 @@ (in-package goal) ;; this file is debug only +(declare-file (debug)) (when *debug-segment* ;; definition of type gs-store-image-packet (deftype gs-store-image-packet (structure) diff --git a/test/decompiler/reference/engine/load/file-io_REF.gc b/test/decompiler/reference/engine/load/file-io_REF.gc index 39b6097c19..3906d1b1d3 100644 --- a/test/decompiler/reference/engine/load/file-io_REF.gc +++ b/test/decompiler/reference/engine/load/file-io_REF.gc @@ -4,7 +4,7 @@ ;; definition of type file-stream (deftype file-stream (basic) ((flags uint32 :offset-assert 4) - (mode basic :offset-assert 8) + (mode symbol :offset-assert 8) (name string :offset-assert 12) (file uint32 :offset-assert 16) ) @@ -12,7 +12,7 @@ :size-assert #x14 :flag-assert #x900000014 (:methods - (new (symbol type string basic) _type_ 0) + (new (symbol type string symbol) _type_ 0) ) ) @@ -27,7 +27,7 @@ ) ;; definition for method 0 of type file-stream -(defmethod new file-stream ((allocation symbol) (type-to-make type) (arg0 string) (arg1 basic)) +(defmethod new file-stream ((allocation symbol) (type-to-make type) (arg0 string) (arg1 symbol)) (let ((a0-1 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) (file-stream-open a0-1 arg0 arg1) ) diff --git a/test/decompiler/reference/kernel/gstring_REF.gc b/test/decompiler/reference/kernel/gstring_REF.gc index 1b4075178c..75b201b664 100644 --- a/test/decompiler/reference/kernel/gstring_REF.gc +++ b/test/decompiler/reference/kernel/gstring_REF.gc @@ -452,7 +452,7 @@ (defun string->int ((str string)) (let ((str-ptr (-> str data)) (result 0) - (v1-0 #f) + (negate #f) ) (cond ((= (-> str-ptr 0) 35) @@ -461,7 +461,7 @@ ((or (= (-> next-char-1 0) 120) (= (-> next-char-1 0) 88)) (let ((next-char-2 (&-> next-char-1 1))) (when (= (-> next-char-2 1) 45) - (set! v1-0 #t) + (set! negate #t) (set! next-char-2 (&-> next-char-2 1)) ) (while (or @@ -497,7 +497,7 @@ ) (else (when (= (-> str-ptr 1) 45) - (set! v1-0 #t) + (set! negate #t) (set! str-ptr (&-> str-ptr 1)) ) (while (and (>= (-> str-ptr 0) (the-as uint 48)) (>= (the-as uint 57) (-> str-ptr 0))) @@ -507,7 +507,7 @@ ) ) (cond - (v1-0 + (negate (- result) ) (else diff --git a/third-party/glfw b/third-party/glfw index 4afa227a05..7d060ba4f1 160000 --- a/third-party/glfw +++ b/third-party/glfw @@ -1 +1 @@ -Subproject commit 4afa227a056681d2628894b0893527bf69496a41 +Subproject commit 7d060ba4f1237c87ed53e007db619da8c25df282