From 9b4b54978a9c470df0dba434e5cba08eb0467b53 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Sun, 24 Mar 2024 12:27:04 -0400 Subject: [PATCH] decomp drawable, main (#3434) --- decompiler/IR2/bitfields.cpp | 21 +- decompiler/config/jak3/all-types.gc | 260 +- .../ntsc_v1/anonymous_function_types.jsonc | 9 +- decompiler/config/jak3/ntsc_v1/hacks.jsonc | 6 +- .../jak3/ntsc_v1/stack_structures.jsonc | 7 +- .../config/jak3/ntsc_v1/type_casts.jsonc | 69 + decompiler/util/data_decompile.cpp | 27 +- decompiler/util/data_decompile.h | 5 +- game/CMakeLists.txt | 1 + .../opengl_renderer/OpenGLRenderer.cpp | 26 + .../graphics/opengl_renderer/OpenGLRenderer.h | 1 + game/graphics/opengl_renderer/buckets.h | 6 + game/graphics/texture/TexturePool.cpp | 3 + game/graphics/texture/jak2_tpage_dir.cpp | 2 +- game/graphics/texture/jak2_tpage_dir.h | 1 - game/graphics/texture/jak3_tpage_dir.cpp | 1721 +++++++++++ game/graphics/texture/jak3_tpage_dir.h | 7 + .../jak3/engine/collide/collide-shape-h.gc | 1 + .../jak3/engine/collide/collide-touch-h.gc | 4 +- goal_src/jak3/engine/collide/collide.gc | 2 + goal_src/jak3/engine/collide/main-collide.gc | 188 ++ goal_src/jak3/engine/draw/drawable-group.gc | 95 + goal_src/jak3/engine/draw/drawable-h.gc | 4 +- .../jak3/engine/draw/drawable-inline-array.gc | 29 + goal_src/jak3/engine/draw/drawable-tree.gc | 87 + goal_src/jak3/engine/draw/drawable.gc | 2194 ++++++++++++++ goal_src/jak3/engine/entity/entity-h.gc | 1 + goal_src/jak3/engine/game/main-h.gc | 9 +- goal_src/jak3/engine/game/main.gc | 1720 +++++++++++ .../jak3/engine/gfx/background/prototype.gc | 107 + goal_src/jak3/engine/gfx/blit-displays-h.gc | 2 +- goal_src/jak3/engine/gfx/blit-displays.gc | 2 + goal_src/jak3/engine/gfx/foreground/eye-h.gc | 1 + .../engine/gfx/foreground/foreground-h.gc | 2 +- .../jak3/engine/gfx/foreground/lights-h.gc | 1 + .../gfx/foreground/merc/generic-merc-h.gc | 2 + .../gfx/foreground/merc/merc-blend-shape.gc | 3 + goal_src/jak3/engine/gfx/foreground/ripple.gc | 1 + .../engine/gfx/foreground/shadow-cpu-h.gc | 1 + .../gfx/generic/lightning/lightning-h.gc | 1 + goal_src/jak3/engine/gfx/hw/display-h.gc | 10 +- goal_src/jak3/engine/gfx/hw/video.gc | 114 + .../jak3/engine/gfx/mood/time-of-day-h.gc | 3 + goal_src/jak3/engine/gfx/ocean/ocean-h.gc | 4 +- goal_src/jak3/engine/gfx/sky/sky-h.gc | 2 +- .../gfx/sprite/particles/sparticle-h.gc | 2 + .../sprite/particles/sparticle-launcher-h.gc | 2 + goal_src/jak3/engine/gfx/vu1-user-h.gc | 2 +- goal_src/jak3/engine/level/level-h.gc | 6 +- goal_src/jak3/engine/level/level.gc | 15 + goal_src/jak3/engine/level/region-h.gc | 1 + .../jak3/engine/spatial-hash/actor-hash-h.gc | 2 + goal_src/jak3/engine/ui/bigmap-h.gc | 2 +- .../jak3/engine/ui/progress/progress-h.gc | 2 + goal_src/jak3/kernel-defs.gc | 3 +- goal_src/jak3/kernel/gkernel-h.gc | 2 +- goal_src/jak3/levels/city/common/trail-h.gc | 2 +- goalc/debugger/Debugger.cpp | 92 + goalc/debugger/Debugger.h | 1 + .../reference/jak3/decompiler-macros.gc | 18 +- .../engine/collide/collide-touch-h_REF.gc | 4 +- .../jak3/engine/collide/main-collide_REF.gc | 201 ++ .../jak3/engine/draw/drawable-group_REF.gc | 115 + .../jak3/engine/draw/drawable-h_REF.gc | 4 +- .../engine/draw/drawable-inline-array_REF.gc | 44 + .../jak3/engine/draw/drawable-tree_REF.gc | 101 + .../jak3/engine/draw/drawable_REF.gc | 2609 +++++++++++++++++ .../reference/jak3/engine/game/main-h_REF.gc | 8 +- .../reference/jak3/engine/game/main_REF.gc | 2021 +++++++++++++ .../engine/gfx/background/prototype_REF.gc | 119 + .../jak3/engine/gfx/blit-displays-h_REF.gc | 2 +- .../engine/gfx/foreground/lights-h_REF.gc | 5 +- .../jak3/engine/gfx/hw/display-h_REF.gc | 10 +- .../reference/jak3/engine/gfx/hw/video_REF.gc | 126 + .../jak3/engine/gfx/ocean/ocean-h_REF.gc | 4 +- .../jak3/engine/gfx/sky/sky-h_REF.gc | 6 +- .../jak3/engine/level/level-h_REF.gc | 6 +- .../reference/jak3/engine/ui/bigmap-h_REF.gc | 2 +- .../jak3/levels/city/common/trail-h_REF.gc | 6 +- test/offline/config/jak3/config.jsonc | 11 +- 80 files changed, 12118 insertions(+), 200 deletions(-) create mode 100644 game/graphics/texture/jak3_tpage_dir.cpp create mode 100644 game/graphics/texture/jak3_tpage_dir.h create mode 100644 test/decompiler/reference/jak3/engine/collide/main-collide_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/draw/drawable-group_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/draw/drawable-inline-array_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/draw/drawable-tree_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/draw/drawable_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/game/main_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/gfx/background/prototype_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/gfx/hw/video_REF.gc diff --git a/decompiler/IR2/bitfields.cpp b/decompiler/IR2/bitfields.cpp index 2199b6bd882..2fa4778ddfb 100644 --- a/decompiler/IR2/bitfields.cpp +++ b/decompiler/IR2/bitfields.cpp @@ -974,18 +974,29 @@ Form* cast_to_bitfield_enum(const EnumType* type_info, if (in == -1) { return nullptr; } - auto elts = decompile_bitfield_enum_from_int(TypeSpec(type_info->get_name()), env.dts->ts, in); + TypeSpec ts(type_info->get_name()); + auto elts = try_decompile_bitfield_enum_from_int(ts, env.dts->ts, in, no_head); if (no_head) { - ASSERT(elts.size() >= 1); + ASSERT(elts->size() >= 1); } + + if (!elts) { + if (in == 0xffff'ffff || in == INT64_MIN) { + return pool.form( + ts, pool.form(SimpleAtom::make_int_constant(in))); + } + // backup failed, run again to get the nice error print. + try_decompile_bitfield_enum_from_int(ts, env.dts->ts, in, true); + } + auto oper = GenericOperator::make_function( - pool.form(no_head ? elts.at(0) : type_info->get_name())); + pool.form(no_head ? elts->at(0) : type_info->get_name())); if (no_head) { - elts.erase(elts.begin()); + elts->erase(elts->begin()); } std::vector form_elts; - for (auto& x : elts) { + for (auto& x : *elts) { form_elts.push_back(pool.form(x)); } return pool.form(oper, form_elts); diff --git a/decompiler/config/jak3/all-types.gc b/decompiler/config/jak3/all-types.gc index 45970e73475..fef62c63b8f 100644 --- a/decompiler/config/jak3/all-types.gc +++ b/decompiler/config/jak3/all-types.gc @@ -100,7 +100,7 @@ (define-extern file-stream-write (function file-stream pointer uint uint)) (define-extern file-stream-close (function file-stream file-stream)) (define-extern new-dynamic-structure (function symbol type int structure)) -(define-extern kernel-shutdown (function none)) +(define-extern kernel-shutdown (function int none)) (define-extern scf-get-timeout (function int)) (define-extern scf-get-inactive-timeout (function int)) (define-extern syncv (function int int)) @@ -4258,7 +4258,7 @@ (tie-water) (etie-water) (etie-scissor-water) - (rn31) + (sprite) (rn32) (rn33) (rn34) @@ -5642,8 +5642,8 @@ ((on-screen int32 :offset-assert 4) (last-screen int32 :offset-assert 8) (frames display-frame 2 :offset-assert 12) ;; guessed by decompiler - (bgcolor uint64 :offset-assert 24) ;; gs-bgcolor - (pmode uint64 :offset-assert 32) ;; gs-pmode + (bgcolor gs-bgcolor :offset-assert 24) + (pmode gs-pmode :offset-assert 32) (clock clock 22 :offset-assert 40) ;; guessed by decompiler (session-clock clock :offset 40) ;; guessed by decompiler (game-clock clock :offset 44) ;; guessed by decompiler @@ -6937,7 +6937,7 @@ (bytes uint8 4 :offset 60) ;; guessed by decompiler (mask uint16 :offset 60) (palette-index int8 :offset 63) - (shadow uint32 :offset 32) + (shadow uint32 :offset 32 :score 1) ) :method-count-assert 9 :size-assert #x40 @@ -6948,6 +6948,7 @@ ((index uint16 :offset-assert 0) (count uint16 :offset-assert 2) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -7813,10 +7814,10 @@ the load. This should only be used when you might want to start a load." (_type_ symbol symbol) level) ;; 12 (activate-levels! "Make all levels 'active!" (_type_) int) ;; 13 (level-group-method-14 () none) ;; 14 ;; (debug-print-entities (_type_ symbol type) none) - (level-group-method-15 () none) ;; 15 ;; (debug-draw-actors (_type_ symbol) none) + (debug-draw-actors (_type_ symbol) none) ;; 15 (assign-draw-indices "Assign the order for levels to be drawn." (_type_) none) ;; 16 - (level-group-method-17 () none) ;; 17 ;; (actors-update (_type_) none) - (level-group-method-18 () none) ;; 18 ;; (update-nav-meshes-method (_type_) none) + (actors-update (_type_) none) ;; 17 + (update-nav-meshes-method (_type_) none) ;; 18 (level-update "Per-frame update of the level system." (_type_) none) ;; 19 (level-get-target-inside "Get the level that the player is 'in'." (_type_) level) ;; 20 (init-level-system "If needed, initialize the level system by loading common/art packages and allocating level heaps." (_type_ symbol) none) ;; 21 @@ -9788,9 +9789,9 @@ (trail-graph-method-9 () none) ;; 9 ;; (trail-graph-method-9 (_type_ int) none) (trail-graph-method-10 () none) ;; 10 ;; (trail-graph-method-10 (_type_ int) none) (trail-graph-method-11 () none) ;; 11 ;; (trail-graph-method-11 (_type_ int int) trail-node) - (trail-graph-method-12 () none) ;; 12 ;; (debug-draw (_type_) none) + (trail-graph-method-12 () none) ;; 12 (trail-graph-method-13 () none) ;; 13 ;; (debug-draw-cell (_type_ int) none) - (trail-graph-method-14 () none) ;; 14 ;; (debug-draw-path (_type_ int (pointer uint16) vector vector rgba float) symbol) + (debug-draw (_type_) none) ;; 14 ;; (debug-draw-path (_type_ int (pointer uint16) vector vector rgba float) symbol) (trail-graph-method-15 () none) ;; 15 ;; (do-path (_type_ vector vector) int) (trail-graph-method-16 () none) ;; 16 ;; (trail-graph-method-16 () none) (trail-graph-method-17 () none) ;; 17 ;; (get-node-location-by-id (_type_ uint vector) vector) @@ -10247,7 +10248,7 @@ (:methods (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) (bigmap-method-9 () none) ;; 9 ;; (initialize (_type_) none) - (bigmap-method-10 () none) ;; 10 ;; (update (_type_) none) + (update (_type_) none) ;; 10 (draw (_type_ int int int int) int) ;; 11 (bigmap-method-12 () none) ;; 12 ;; (handle-cpad-inputs (_type_) int) (bigmap-method-13 () none) ;; 13 ;; (compress-all (_type_) int) @@ -10846,7 +10847,7 @@ (tie-draw-points 13) (tie-debug 14) (tie-scissor 15) - + (tie-pal 16) (tie-generic 17) (instance-tie 18) (instance-tie-colors0 19) ;; somehow used by tfrag too.. @@ -10854,6 +10855,7 @@ (instance-tie-colors2 21) (instance-tie-colors3 22) (instance-tie-colors* 23) + (prototype-bucket-shrub 24) (shrubbery 27) @@ -10891,9 +10893,11 @@ (art-joint-anim 78) (texture 83) - + (string 84) (array 85) + (debug 88) + (eye-anim 112) ) @@ -10975,7 +10979,7 @@ (blit-displays-work-method-16 () none) ;; 16 (blit-displays-work-method-17 (_type_ vector int float symbol) none) ;; 17 (blit-displays-work-method-18 () none) ;; 18 - (blit-displays-work-method-19 () none) ;; 19 + (blit-displays-work-method-19 (_type_) none) ;; 19 (called from main.gc) (blit-displays-work-method-20 () none) ;; 20 (get-menu-mode (_type_) symbol) ;; 21 (get-screen-copied (_type_) symbol) ;; 22 @@ -11208,8 +11212,8 @@ (sky-work-method-10 () none) ;; 10 ;; (init-orbit-settings! (_type_ int float float float float float float) none) (sky-work-method-11 () none) ;; 11 ;; (update-colors-for-time (_type_ float) none) (sky-work-method-12 () none) ;; 12 ;; (update-time-and-speed (_type_ float float) none) - (sky-work-method-13 () none) ;; 13 ;; (draw (_type_) none) - (sky-work-method-14 () none) ;; 14 ;; (update-matrix (_type_ matrix) none) + (sky-work-method-13 () none) ;; 13 + (draw (_type_) none) ;; 14 ;; (update-matrix (_type_ matrix) none) (sky-work-method-15 () none) ;; 15 ;; (update-template-colors (_type_) none) (sky-work-method-16 () none) ;; 16 ;; (init-regs-for-large-polygon-draw (_type_) none) (sky-work-method-17 () none) ;; 17 ;; (init-regs-for-sky-asm (_type_) none) @@ -11714,8 +11718,8 @@ :flag-assert #x5c0000206c (:methods (get-height (_type_ vector symbol) float) ;; 11 - (ocean-method-12 () none) ;; 12 ;; (draw! (_type_) none) - (ocean-method-13 () none) ;; 13 ;; (update-map (_type_) none) + (draw! (_type_) none) ;; 12 + (update-map (_type_) none) ;; 13 (ocean-method-14 () none) ;; 14 ;; (interp-wave (_type_ ocean-wave-info uint float) none) (ocean-method-15 () none) ;; 15 ;; (ocean-method-15 (_type_ matrix matrix) none) (ocean-method-16 () none) ;; 16 ;; (generate-verts (_type_ ocean-vert-array ocean-height-array) none) @@ -12099,7 +12103,7 @@ (deftype screen-filter (basic) ((draw? symbol :offset-assert 4) ;; guessed by decompiler - (bucket int32 :offset-assert 8) ;; bucket-id + (bucket bucket-id :offset-assert 8) (depth int32 :offset-assert 12) (ztest uint64 :offset-assert 16) (color vector :inline :offset-assert 32) @@ -12108,14 +12112,14 @@ (extra vector :inline :offset-assert 80) (speed float :offset-assert 80 :overlay-at (-> extra x)) (current-interp float :offset-assert 84 :overlay-at (-> extra y)) - (lock-vsync? basic :offset-assert 96) + (lock-vsync? symbol :offset-assert 96) ) :method-count-assert 12 :size-assert #x64 :flag-assert #xc00000064 (:methods - (draw (_type_) none) ;; 9 - (setup (_type_ vector vector float bucket-id) none) ;; 10 + (draw "Add DMA data to our bucket to draw the filter." (_type_) none) ;; 9 + (setup "Initialize the screen-filter with the given settings." (_type_ vector vector float bucket-id int int symbol) none) ;; 10 (disable (_type_) none) ;; 11 ) ) @@ -12137,7 +12141,7 @@ :size-assert #x44 :flag-assert #xa00000044 (:methods - (col-rend-method-9 () none) ;; 9 ;; (col-rend-method-9 (_type_) none) + (draw (_type_) none) ;; 9 ) ) @@ -12367,8 +12371,8 @@ (login "Initialize the object after it is loaded." (_type_) _type_);; 9 (draw "Draw the drawable, and typically its children. This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." (_type_) none) ;; 10 - (drawable-method-11 () none) ;; 11 ;; (fill-collide-list-from-box (_type_ int collide-list collide-query) int) - (drawable-method-12 () none) ;; 12 ;; (fill-collide-list-from-line-sphere (_type_ int collide-list collide-query) int) + (drawable-method-11 (_type_) none) ;; 11 ;; (fill-collide-list-from-box (_type_ int collide-list collide-query) int) + (drawable-method-12 (_type_) none) ;; 12 ;; (fill-collide-list-from-line-sphere (_type_ int collide-list collide-query) int) (collect-stats "Collect triangle/perf statistics for rendering. This is only called when viewing stats. The vis-bits and culling registers are loaded during this time." (_type_) none) ;; 13 @@ -21436,9 +21440,9 @@ (:methods (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) (touching-list-method-9 () none) ;; 9 ;; (add-touching-prims (_type_ collide-shape-prim collide-shape-prim float collide-tri-result collide-tri-result) none) - (touching-list-method-10 () none) ;; 10 ;; (free-nodes (_type_) none) + (free-nodes (_type_) none) ;; 10 (touching-list-method-11 () none) ;; 11 ;; (update-from-step-size (_type_ float) none) - (touching-list-method-12 () none) ;; 12 ;; (send-events-for-touching-shapes (_type_) none) + (send-events-for-touching-shapes (_type_) none) ;; 12 (touching-list-method-13 () none) ;; 13 ;; (get-shapes-entry (_type_ collide-shape collide-shape) touching-shapes-entry) ) ) @@ -23120,7 +23124,7 @@ (proto-tie) (bones) (camera) - (foreground) + (foreground) ;; 50 (hover-path) (hover-spheres) (hover-update) @@ -29795,11 +29799,11 @@ ;; (define-extern *stats-blerc* object) ;; symbol ;; (define-extern *blerc-globals* object) ;; blerc-globals ;; (define-extern blerc-stats-init function) ;; (function none) -;; (define-extern blerc-init function) ;; (function none) +(define-extern blerc-init (function none)) ;; (define-extern blerc-a-fragment function) ;; (define-extern dma-from-spr function) ;; (define-extern merc-dma-chain-to-spr function) -;; (define-extern blerc-execute function) ;; (function none) +(define-extern blerc-execute (function none)) (define-extern merc-blend-shape (function process-drawable object)) ;; (define-extern setup-blerc-chains-for-one-fragment function) ;; (function object object object object object object object) ;; (define-extern setup-blerc-chains function) ;; (function merc-ctrl (pointer int16) dma-buffer none) @@ -29863,7 +29867,7 @@ ;; (define-extern ripple-execute-init function) ;; (function none) ;; (define-extern ripple-create-wave-table function) ;; (function ripple-wave-set int) ;; (define-extern ripple-apply-wave-table function) ;; (function merc-effect symbol) -;; (define-extern ripple-execute function) ;; (function none) +(define-extern ripple-execute (function none)) ;; (define-extern ripple-matrix-scale function) ;; function ;; (define-extern ripple-add-debug-sphere function) ;; (function process-drawable vector float float none) ;; (define-extern ripple-slow-add-sine-waves function) ;; (function ripple-wave-set float float float) @@ -29933,7 +29937,7 @@ (define-extern foreground-check-longest-edge-asm (function draw-control float symbol)) (define-extern foreground-ripple (function draw-control merc-ctrl pointer int pointer)) (define-extern foreground-draw (function draw-control dma-buffer float none)) -;; (define-extern foreground-draw-hud function) ;; (function draw-control dma-buffer float none) +(define-extern foreground-draw-hud (function draw-control dma-buffer float none)) (define-extern *foreground* foreground-globals) (define-extern *foreground-draw-engine* engine) @@ -30024,7 +30028,7 @@ ;; (define-extern generic-merc-death function) ;; (define-extern generic-merc-execute-asm function) ;; (define-extern generic-merc-do-chain function) ;; (function mercneric-chain dma-buffer pointer) -;; (define-extern generic-merc-execute-all function) ;; (function dma-buffer none) +(define-extern generic-merc-execute-all (function dma-buffer none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-tie ;; @@ -30117,7 +30121,7 @@ ;; (define-extern debug-draw-settings function) ;; (function shadow-settings symbol) ;; (define-extern shadow-execute function) ;; (function shadow-dma-packet pointer pointer) ;; (define-extern shadow-vu0-upload function) ;; (function none) -;; (define-extern shadow-execute-all function) ;; (function dma-buffer none) +(define-extern shadow-execute-all (function dma-buffer none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; shadow-vu1 ;; @@ -30254,7 +30258,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-extern *blit-displays-work* blit-displays-work) -;; (define-extern draw-color-bars function) ;; (function none) +(define-extern draw-color-bars (function blit-displays-work none)) ;; (define-extern draw-raw-image function) ;; (function bucket-id art-group int int level int none) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -30849,10 +30853,10 @@ ;; (define-extern sp-relaunch-setup-fields function) ;; (function object sparticle-launcher sparticle-cpuinfo sprite-vec-data-3d none) ;; (define-extern sp-relaunch-particle-2d function) ;; (function object sparticle-launcher sparticle-cpuinfo sprite-vec-data-3d none) ;; (define-extern sp-relaunch-particle-3d function) ;; (function object sparticle-launcher sparticle-cpuinfo sprite-vec-data-3d none) -;; (define-extern execute-particle-local-space-engine function) +(define-extern execute-particle-local-space-engine (function int none)) ;; (define-extern local-space-camera function) (define-extern local-space-proc-joint (function particle-local-space-info none)) -;; (define-extern execute-part-engine function) ;; (function none) +(define-extern execute-part-engine (function none)) ;; (define-extern sparticle-track-root function) ;; (function object sparticle-cpuinfo vector none) ;; (define-extern sparticle-track-root-prim function) ;; (function object sparticle-cpuinfo vector none) ;; (define-extern sparticle-track-joint function) ;; (function sparticle-system sparticle-cpuinfo vector none) @@ -30935,8 +30939,8 @@ ;; (define-extern all-particles-50-to-60 function) ;; (function none) ;; (define-extern all-particles-60-to-50 function) ;; (function none) ;; (define-extern remap-particle function) ;; (function sparticle-system sparticle-cpuinfo pointer none) -;; (define-extern remap-all-particles function) ;; (function none) -;; (define-extern process-particles function) ;; (function none) +(define-extern remap-all-particles (function none)) +(define-extern process-particles (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; entity-table ;; @@ -31754,11 +31758,11 @@ ;; (define-extern time-of-day-setup function) ;; (function symbol symbol) (define-extern time-of-day-interp-colors (function (pointer rgba) uint mood-context none)) (define-extern time-of-day-interp-colors-scratch (function (pointer rgba) time-of-day-palette mood-context none)) -;; (define-extern init-time-of-day-context function) ;; (function time-of-day-context symbol) +(define-extern init-time-of-day-context (function time-of-day-context symbol)) ;; (define-extern set-filter-color! function) ;; (function float float float none) ;; (define-extern tod-madd! function) ;; (function vector vector vector float) ;; (define-extern update-environment-colors function) ;; (function time-of-day-context vector) -;; (define-extern update-time-of-day function) ;; (function time-of-day-context none) +(define-extern update-time-of-day (function time-of-day-context none)) ;; (define-extern calc-fade-from-fog function) ;; (function vector float) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -32320,7 +32324,7 @@ (define-extern cshape-reaction-update-state (function control-info collide-query vector none)) (define-extern cshape-reaction-default (function control-info collide-query vector vector collide-status)) ;; (define-extern cshape-reaction-just-move function) ;; (function control-info collide-query vector collide-status) -;; (define-extern collide-shape-draw-debug-marks function) ;; (function none) +(define-extern collide-shape-draw-debug-marks (function none)) ;; (define-extern *col-timer* object) ;; stopwatch ;; (define-extern *frame-timer* object) ;; stopwatch ;; (define-extern *col-timer-enable* object) ;; symbol @@ -32335,7 +32339,7 @@ ;; collide ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *collide-vif0-init* array) ;; (array uint32) +(define-extern *collide-vif0-init* (array uint32)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-planes ;; @@ -32423,7 +32427,7 @@ (define-extern *actor-hash* spatial-hash) ;; (define-extern *actor-hash-buckets* object) ;; actor-hash-buckets -;; (define-extern update-actor-hash function) ;; (function none) +(define-extern update-actor-hash (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; merc-death ;; @@ -37215,54 +37219,62 @@ ;; drawable ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern sphere-cull function) ;; (function vector symbol) -;; (define-extern guard-band-cull function) ;; (function vector symbol) -(define-extern sphere-in-view-frustum? (function sphere symbol)) -(define-extern line-in-view-frustum? (function vector vector symbol)) -(define-extern vis-cull (function int symbol)) -;; (define-extern vis-cull-debug function) ;; (function work-area int symbol) -;; (define-extern error-sphere function) ;; (function drawable-error string none) -;; (define-extern *edit-instance* object) ;; string -;; (define-extern *instance-mem-usage* object) ;; memory-usage-block -;; (define-extern find-instance-by-name-level function) ;; (function string level prototype-bucket) -;; (define-extern find-instance-by-name function) ;; (function string prototype-bucket) -;; (define-extern prototypes-game-visible-set! function) ;; (function pair symbol int) -;; (define-extern find-instance-by-index function) ;; (function type int bsp-header prototype-bucket) -;; (define-extern prototype-bucket-type function) ;; (function prototype-bucket type) -;; (define-extern prototype-bucket-recalc-fields function) ;; (function prototype-bucket prototype-bucket) -;; (define-extern print-prototype-list function) ;; (function none) -;; (define-extern draw-instance-info function) ;; (function string none) -;; (define-extern set-shadow-by-name function) ;; (function string int int none) -;; (define-extern get-shadow-by-name function) ;; (function string none) -;; (define-extern teleport-camera-by-name function) ;; (function string none) -;; (define-extern teleport-camera-by-pos function) -;; (define-extern calc-vu1-shadow function) -;; (define-extern calc-shadow-masks function) -;; (define-extern calc-realtime-lights function) -(define-extern calc-vu1-lights (function vu-lights draw-control uint none)) -(define-extern dma-add-process-drawable (function process-drawable draw-control symbol dma-buffer none)) -;; (define-extern *hud-lights* object) ;; vu-lights -(define-extern dma-add-process-drawable-hud (function process-drawable draw-control float dma-buffer none)) -(define-extern add-process-drawable (function process-drawable draw-control symbol dma-buffer none)) -;; (define-extern foreground-engine-execute function) ;; (function engine display-frame none) -;; (define-extern main-debug-hook function) ;; (function none) -;; (define-extern *debug-hook* object) ;; pair -;; (define-extern *add-sphere* object) ;; symbol -;; (define-extern *generic-effect-mode* object) ;; int -;; (define-extern foreground-initialize-engines function) ;; (function none) -;; (define-extern foreground-execute-cpu-vu0-engines function) ;; (function none) -;; (define-extern real-main-draw-hook function) ;; (function none) -;; (define-extern main-draw-hook function) ;; (function none) -;; (define-extern *draw-hook* object) ;; (function none) -;; (define-extern default-init-buffer function) ;; (function bucket-id gs-zbuf gs-test none) -;; (define-extern default-end-buffer function) ;; (function bucket-id gs-zbuf gs-test none) -;; (define-extern screen-shot-scale function) ;; (function int string none) -;; (define-extern screen-shot function) ;; (function none) -;; (define-extern display-frame-start function) ;; (function display int float none) -;; (define-extern display-frame-finish function) ;; (function display display) -;; (define-extern determine-pause-mode function) ;; (function int) -;; (define-extern calc-ratio function) -;; (define-extern display-sync function) ;; (function display none) +(define-extern draw-vortex (function none)) ;; doesn't exist in jak 3!! +(define-extern sphere-cull "Is this sphere visible? Uses cached camera matrix registers, so use with care." (function vector symbol)) +(define-extern guard-band-cull "Is this sphere within the guard band, and maybe needs clipping? Uses cached camera matrix registers, so use with care." (function vector symbol)) +(define-extern sphere-in-view-frustum? "Check if sphere is in view frustum. Uses math-camera, so doesn't need register setup." (function sphere symbol)) +(define-extern line-in-view-frustum? "Check if line is in view frustum. Uses math-camera, so doesn't need register setup." (function vector vector symbol)) +(define-extern vis-cull "Check if object is visible by ID with precomputed visibility. Requres scratchpad to have vis-bits loaded." (function int symbol)) +(define-extern vis-cull-debug (function work-area int symbol)) +(define-extern error-sphere "Draw an error sphere and text for a drawable-error." (function drawable-error string none)) +(define-extern *edit-instance* string) +(define-extern *instance-mem-usage* memory-usage-block) +(define-extern find-instance-by-name-level "Find shrub or tie prototype by name in a level. + Yes it says instance. No it does not return an instance." (function string level prototype-bucket)) +(define-extern find-instance-by-name "Find shrub or tie prototype by name in any level. + Yes it says instance. No it does not return an instance." (function string prototype-bucket)) +(define-extern prototypes-game-visible-set! + "Disable collision/visibilty of tie/shrub based on a list of prototype names. + Only looks in the given level." + (function pair symbol level int)) +(define-extern find-instance-by-index (function type int bsp-header prototype-bucket)) +(define-extern prototype-bucket-type (function prototype-bucket type)) +(define-extern prototype-bucket-recalc-fields (function prototype-bucket prototype-bucket)) +(define-extern print-prototype-list (function none)) +(define-extern draw-instance-info (function string none)) +(define-extern set-shadow-by-name "Modify the shadow values for a process." (function string int int none)) +(define-extern get-shadow-by-name "Print to stdout the mask/values for the given process shadows" (function string none)) +(define-extern teleport-camera-by-name "Move camera to entity by name" (function string none)) +(define-extern teleport-camera-by-pos "Move camera to position" (function float float float none)) +(define-extern calc-vu1-shadow "Update shadow-ctrl based on lights" (function light-group draw-control none)) +(define-extern calc-shadow-masks (function light-group draw-control uint none)) +(define-extern calc-realtime-lights (function light-group draw-control uint none)) +(define-extern calc-vu1-lights (function vu-lights draw-control symbol none)) +(define-extern dma-add-process-drawable "Generate DMA for foreground object, calculate lights/shadows, etc." (function process-drawable draw-control symbol dma-buffer none)) +(define-extern *hud-lights* vu-lights) +(define-extern dma-add-process-drawable-hud "Special version of dma-add-process-drawable for drawing hud foreground objects" (function process-drawable draw-control float dma-buffer none)) +(define-extern add-process-drawable "Foreground engine function to generate dma for a process-drawable." (function process-drawable draw-control symbol dma-buffer none)) +(define-extern foreground-engine-execute "Draw all foreground objects!" (function engine none)) +(define-extern main-debug-hook "Run debug engine, collision renderer." (function none)) +(define-extern *debug-hook* pair) +(define-extern *add-sphere* symbol) +(define-extern *generic-effect-mode* int) +(define-extern foreground-initialize-engines "Initialize shadow chains prior to foreground drawing." (function none)) +(define-extern foreground-execute-cpu-vu0-engines "Run foreground drawing code on EE/VU0 (bones, generic merc, part of shadow, lightning, prim)" (function none)) +(define-extern real-main-draw-hook "Do all drawing! Called by main loop to run drawing for a frame. + Note that this also dispatches collide events, updates actors, etc. + It's a bit more than just drawing." (function none)) +(define-extern main-draw-hook "Wrapper of real-main-draw-hook" (function none)) +(define-extern *draw-hook* (function none)) +(define-extern default-init-buffer "Initialize DMA chain for a bucket." (function bucket-id gs-zbuf gs-test none)) +(define-extern default-end-buffer "Add DMA data at the end of a bucket to reset settings." (function bucket-id gs-zbuf gs-test none)) +(define-extern screen-shot-scale (function int string none)) +(define-extern screen-shot "Take a screenshot." (function none)) +(define-extern display-frame-start "Advance clocks, poll pads/mouse, set up buckets." (function display int float none)) +(define-extern display-frame-finish "Do final texture remaps, sync DMA (wait for previous rendering to finish), and finalize DMA chain." (function display display)) +(define-extern determine-pause-mode "Update pause modes" (function none)) +(define-extern calc-ratio (function int int float)) +(define-extern display-sync (function display none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-group ;; @@ -37288,52 +37300,56 @@ ;; main-collide ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern drawable-sphere-box-intersect? function) ;; (function drawable bounding-box4w symbol) -;; (define-extern instance-sphere-box-intersect? function) ;; (function drawable instance-tie bounding-box4w symbol) -;; (define-extern instance-tfragment-add-debug-sphere function) ;; (function drawable instance-tie symbol) +(define-extern drawable-sphere-box-intersect? (function drawable bounding-box4w symbol)) +(define-extern instance-sphere-box-intersect? (function drawable instance-tie bounding-box4w symbol)) +(define-extern instance-tfragment-add-debug-sphere (function drawable instance-tie symbol)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; video ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define-extern *video-mode* int) (define-extern set-video-mode (function symbol none)) (define-extern get-video-mode (function symbol)) (define-extern set-aspect-ratio (function symbol none)) (define-extern get-aspect-ratio (function symbol)) (define-extern set-progressive-scan (function symbol none)) -;; (define-extern get-progressive-scan function) ;; (function symbol) -;; (define-extern set-graphics-mode function) ;; (function none) +(define-extern get-progressive-scan (function symbol)) +(define-extern set-graphics-mode (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; main ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define-extern set-letterbox-frames (function time-frame none)) -(define-extern letterbox (function none)) -(define-extern set-blackout-frames (function time-frame none)) -(define-extern blackout (function none)) -(define-extern add-blackout (function time-frame int int int int int)) -(define-extern paused? (function symbol)) -(define-extern movie? (function symbol)) -;; (define-extern scene-select? function) -(define-extern demo? (function symbol)) -(define-extern kiosk? (function symbol)) +(define-extern set-letterbox-frames "Enable letterbox for the given amount of time." (function time-frame none)) +(define-extern letterbox "Draw letterbox" (function bucket-id float none)) +(define-extern set-blackout-frames "Enable blackout for the given amount of time." (function time-frame none)) +(define-extern blackout "Draw blackout as a sprite." (function bucket-id none)) +(define-extern add-blackout "Update display settings to do blackout with GS pmode alp." (function time-frame int int int int int)) +(define-extern paused? "Are we paused? Counts any type of pause/menu/freeze." (function symbol)) +(define-extern movie? "Are we in a movie?" (function symbol)) +(define-extern scene-select? (function symbol)) +(define-extern demo? "Is this a demo version?" (function symbol)) +(define-extern kiosk? "Is this a kiosk version of the game?" (function symbol)) (define-extern *last-master-mode* symbol) -(define-extern set-master-mode (function symbol none)) -;; (define-extern pause-allowed? function) ;; (function symbol) -;; (define-extern toggle-pause function) ;; (function int) +(define-extern set-master-mode "Change the master mode and adjust a few masks" (function symbol none)) +(define-extern pause-allowed? "Should we allow a pause?" (function symbol)) +(define-extern toggle-pause "Update the pause state. Call this if the user presses a pause button + This function will check the button and state and do a pause if needed." + (function int)) (define-extern *screen-filter* screen-filter) -;; (define-extern *cheat-temp* object) ;; (pointer int32) +(define-extern *cheat-temp* (pointer int32)) (define-extern *master-exit* symbol) (define-extern *progress-cheat* symbol) -;; (define-extern *first-boot* object) ;; symbol -;; (define-extern main-timeouts function) -;; (define-extern main-cheats function) ;; (function int) -;; (define-extern end-display function) ;; (function display none) -;; (define-extern display-loop-main function) ;; (function display none) -;; (define-extern display-loop function) ;; (function int :behavior process) -(define-extern on (function symbol process)) -;; (define-extern off function) ;; (function int) +(define-extern *first-boot* symbol) +(define-extern main-timeouts "Maybe reset/restart the game if no input has been given. + Mainly used for kiosk/demo modes." (function none)) +(define-extern main-cheats (function none)) +(define-extern end-display (function display none)) +(define-extern display-loop-main (function display none)) +(define-extern display-loop "Main loop for running the game." (function int :behavior process)) +(define-extern on "Start the display process." (function symbol process)) +(define-extern off "Stop the display process." (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-cache ;; @@ -37417,7 +37433,7 @@ ;; (define-extern *compact-actors* object) ;; symbol ;; (define-extern *vis-actors* object) ;; symbol (define-extern entity-by-name (function string entity)) -;; (define-extern entity-by-type function) ;; (function type entity-actor) +(define-extern entity-by-type (function type entity-actor)) (define-extern entity-by-aid (function uint entity)) ;; (define-extern entity-actor-from-level-name function) ;; (function symbol entity-actor) ;; (define-extern entity-nav-mesh-by-aid function) ;; (function actor-id entity-nav-mesh) @@ -38793,7 +38809,7 @@ ;; (define-extern anim-tester-add-newobj function) ;; (define-extern anim-tester-stop function) ;; (define-extern anim-tester-start function) ;; (function symbol) -;; (define-extern anim-tester-add-object function) ;; (function string none) +(define-extern anim-tester-add-object (function string none)) ;; (define-extern anim-tester-set-name function) ;; (define-extern anim-tester-add-sequence function) @@ -39914,7 +39930,7 @@ ;; (define-extern debug-menu-context-make-default-menus function) ;; (function debug-menu-context debug-menu-context) ;; (define-extern *popup-menu-context* object) ;; debug-menu-context ;; (define-extern popup-menu-context-make-default-menus function) ;; (function debug-menu-context debug-menu-context) -;; (define-extern menu-respond-to-pause function) ;; (function symbol) +(define-extern menu-respond-to-pause (function symbol)) ;; (define-extern *menu-hook* function) ;; (function debug-menu-context) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc b/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc index ff2b8329cf3..2d159c1faca 100644 --- a/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc +++ b/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc @@ -126,5 +126,12 @@ ], "trajectory": [[15, "(function trajectory none)"]], "progress": [[3, "(function int none :behavior process)"]], - "level": [[25, "(function level-group int symbol)"], [7, "(function none)"], [4, "(function load-state sound-bank-state symbol)"]] + "level": [[25, "(function level-group int symbol)"], [7, "(function none)"], [4, "(function load-state sound-bank-state symbol)"]], + "main": [ + [11, "(function int none)"], + [9, "(function none)"], + [8, "(function none)"], + [7, "(function none)"], + [3, "(function symbol :behavior process)"] + ] } diff --git a/decompiler/config/jak3/ntsc_v1/hacks.jsonc b/decompiler/config/jak3/ntsc_v1/hacks.jsonc index 3a14f4f60aa..ac0953606d3 100644 --- a/decompiler/config/jak3/ntsc_v1/hacks.jsonc +++ b/decompiler/config/jak3/ntsc_v1/hacks.jsonc @@ -340,7 +340,11 @@ "draw-drawable-tree-instance-tie": [21, 23, 31, 33], "(method 12 flow-control)": [3, 9, 22], "(method 26 level-group)": [40, 41, 67], - "borrow-city-expansion": [0, 9, 13, 15, 17] + "borrow-city-expansion": [0, 9, 13, 15, 17], + "dma-add-process-drawable": [0, 77], + "real-main-draw-hook": [120, 122], + "display-frame-finish": [61], + "display-loop-main": [130] }, // Sometimes the game might use format strings that are fetched dynamically, diff --git a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc index 934f6e171d3..a14c8e509e7 100644 --- a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc +++ b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc @@ -410,6 +410,11 @@ "(method 20 load-state)": [ [16, ["inline-array", "level-buffer-state", 10]], [176, ["inline-array", "level-buffer-state", 10]] - + ], + "calc-vu1-lights": [ + [16, "light-group"] + ], + "teleport-camera-by-pos": [ + [16, "vector"] ] } diff --git a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc index d9936867d69..425af81060e 100644 --- a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc @@ -2991,5 +2991,74 @@ "borrow-city-expansion": [ [23, "a0", "basic"], [52, "s5", "basic"] + ], + "find-instance-by-name-level": [ + [11, "v1", "drawable-tree-instance-shrub"], + [38, "v1", "drawable-tree-instance-tie"] + ], + "dma-add-process-drawable": [ + [42, "a0", "foreground-work"], + [45, "a0", "foreground-work"], + [78, "a0", "foreground-work"], + [198, "t0", "(pointer int128)"] + ], + "calc-shadow-masks": [ + [10, "v0", "(array float)"] + ], + "dma-add-process-drawable-hud": [ + [[43, 59], "v1", "level"], + [11, "a0", "foreground-work"] + ], + "default-init-buffer": [ + [[116, 126], "a1", "dma-packet"] + ], + "default-end-buffer": [ + [[117, 123], "a1", "dma-packet"], + [125, "a1", "(pointer uint32)"] + ], + "display-frame-start": [ + [4, "v1", "vif-bank"], + [9, "a0", "vif-bank"] + ], + "display-frame-finish": [ + [[504, 513], "a0", "dma-packet"], + [542, "a0", "(pointer uint64)"] + ], + "(method 15 drawable-tree)": [ + [[1, 4], "v1", "drawable-inline-array-node"], + [[29, 34], "t0", "drawable-inline-array-node"], + [[28, 32], "t2", "drawable-inline-array-node"], + [[42, 46], "t2", "(pointer int8)"] + ], + "get-shadow-by-name": [ + [7, "v1", "process-drawable"] + ], + "set-shadow-by-name": [ + [7, "v1", "process-drawable"] + ], + "find-instance-by-index": [ + [26, "t1", "drawable-tree-instance-shrub"], + [40, "t1", "drawable-tree-instance-tie"] + ], + "print-prototype-list": [ + [25, "v1", "drawable-tree-instance-shrub"], + [104, "v1", "drawable-tree-instance-tie"] + ], + "draw-instance-info": [ + [[188, 203], "s5", "prototype-bucket-shrub"], + [[192, 303], "s1", "prototype-shrubbery"], + [[359, 400], "v1", "prototype-tie"], + [[44, 64], "s1", "drawable-inline-array-instance-tie"], + [[331, 450], "s5", "prototype-bucket-tie"], + [[35, 41], "v1", "drawable-tree-instance-tie"] + ], + "set-graphics-mode": [[[0, 100], "gp", "gs-bank"]], + "(method 9 screen-filter)": [ + [[118, 128], "t1", "rgba"] + ], + "display-loop-main": [ + [231, "t9", "(function none)"] ] + + } diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index b6ef1ad6349..e33509e6da5 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -2078,9 +2078,10 @@ std::vector decompile_bitfield_from_int(const TypeSpec& typ return *try_decompile_bitfield_from_int(type, ts, value, true, {}); } -std::vector decompile_bitfield_enum_from_int(const TypeSpec& type, - const TypeSystem& ts, - u64 value) { +std::optional> try_decompile_bitfield_enum_from_int(const TypeSpec& type, + const TypeSystem& ts, + u64 value, + bool require_success) { u64 reconstructed = 0; std::vector result; auto type_info = ts.try_enum_lookup(type.base_type()); @@ -2116,10 +2117,14 @@ std::vector decompile_bitfield_enum_from_int(const TypeSpec& type, } if (reconstructed != value) { - throw std::runtime_error(fmt::format( - "Failed to decompile bitfield enum {}. Original value is 0x{:x} but we could only " - "make 0x{:x} using the available fields.", - type.print(), value, reconstructed)); + if (require_success) { + throw std::runtime_error(fmt::format( + "Failed to decompile bitfield enum {}. Original value is 0x{:x} but we could only " + "make 0x{:x} using the available fields.", + type.print(), value, reconstructed)); + } else { + return std::nullopt; + } } if (bit_count == (int)result.size()) { @@ -2137,6 +2142,14 @@ std::vector decompile_bitfield_enum_from_int(const TypeSpec& type, return result; } +std::vector decompile_bitfield_enum_from_int(const TypeSpec& type, + const TypeSystem& ts, + u64 value) { + auto ret = try_decompile_bitfield_enum_from_int(type, ts, value, true); + ASSERT(ret.has_value()); + return *ret; +} + std::string decompile_int_enum_from_int(const TypeSpec& type, const TypeSystem& ts, u64 value) { auto type_info = ts.try_enum_lookup(type.base_type()); ASSERT(type_info); diff --git a/decompiler/util/data_decompile.h b/decompiler/util/data_decompile.h index 8799ded631c..6dd5eae820d 100644 --- a/decompiler/util/data_decompile.h +++ b/decompiler/util/data_decompile.h @@ -107,7 +107,10 @@ T extract_bitfield(T input, int start_bit, int size) { std::vector decompile_bitfield_from_int(const TypeSpec& type, const TypeSystem& ts, u64 value); - +std::optional> try_decompile_bitfield_enum_from_int(const TypeSpec& type, + const TypeSystem& ts, + u64 value, + bool require_success); std::optional> try_decompile_bitfield_from_int( const TypeSpec& type, const TypeSystem& ts, diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index d655a94e130..a5e74f0d99b 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -83,6 +83,7 @@ set(RUNTIME_SOURCE graphics/sceGraphicsInterface.cpp graphics/texture/jak1_tpage_dir.cpp graphics/texture/jak2_tpage_dir.cpp + graphics/texture/jak3_tpage_dir.cpp graphics/texture/TextureConverter.cpp graphics/texture/TexturePool.cpp ${OG_ASM_FUNCS_FILE} diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index 44231af314e..8987b2c8f47 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -98,6 +98,9 @@ OpenGLRenderer::OpenGLRenderer(std::shared_ptr texture_pool, case GameVersion::Jak2: m_texture_animator = std::make_shared(m_render_state.shaders, common_level); break; + case GameVersion::Jak3: + // for now, no texture animation for jak3... + break; default: ASSERT(false); } @@ -114,11 +117,34 @@ OpenGLRenderer::OpenGLRenderer(std::shared_ptr texture_pool, case GameVersion::Jak2: init_bucket_renderers_jak2(); break; + case GameVersion::Jak3: + init_bucket_renderers_jak3(); + break; default: ASSERT(false); } } +void OpenGLRenderer::init_bucket_renderers_jak3() { + using namespace jak3; + m_bucket_renderers.resize((int)BucketId::MAX_BUCKETS); + m_bucket_categories.resize((int)BucketId::MAX_BUCKETS, BucketCategory::OTHER); + + { + auto p = scoped_prof("render-inits"); + // for now, for any unset renderers, just set them to an EmptyBucketRenderer. + for (size_t i = 0; i < m_bucket_renderers.size(); i++) { + if (!m_bucket_renderers[i]) { + init_bucket_renderer(fmt::format("bucket-{}", i), + BucketCategory::OTHER, i); + } + + m_bucket_renderers[i]->init_shaders(m_render_state.shaders); + m_bucket_renderers[i]->init_textures(*m_render_state.texture_pool, GameVersion::Jak3); + } + } +} + void OpenGLRenderer::init_bucket_renderers_jak2() { using namespace jak2; m_bucket_renderers.resize((int)BucketId::MAX_BUCKETS); diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.h b/game/graphics/opengl_renderer/OpenGLRenderer.h index caabb961d44..ce883bee475 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.h +++ b/game/graphics/opengl_renderer/OpenGLRenderer.h @@ -80,6 +80,7 @@ class OpenGLRenderer { void blit_display(); void init_bucket_renderers_jak1(); void init_bucket_renderers_jak2(); + void init_bucket_renderers_jak3(); void draw_renderer_selection_window(); void finish_screenshot(const std::string& output_name, int px, diff --git a/game/graphics/opengl_renderer/buckets.h b/game/graphics/opengl_renderer/buckets.h index 5601dab09e4..2a35e29dbaa 100644 --- a/game/graphics/opengl_renderer/buckets.h +++ b/game/graphics/opengl_renderer/buckets.h @@ -412,6 +412,12 @@ enum class BucketId { }; } +namespace jak3 { +enum class BucketId { + MAX_BUCKETS = 587, +}; +} + enum class BucketCategory { TFRAG, TIE, diff --git a/game/graphics/texture/TexturePool.cpp b/game/graphics/texture/TexturePool.cpp index 1f46ef43e75..7e73d2a64ae 100644 --- a/game/graphics/texture/TexturePool.cpp +++ b/game/graphics/texture/TexturePool.cpp @@ -10,6 +10,7 @@ #include "game/graphics/pipelines/opengl.h" #include "game/graphics/texture/jak1_tpage_dir.h" #include "game/graphics/texture/jak2_tpage_dir.h" +#include "game/graphics/texture/jak3_tpage_dir.h" #include "fmt/core.h" #include "third-party/imgui/imgui.h" @@ -312,6 +313,8 @@ const std::vector& get_tpage_dir(GameVersion version) { return get_jak1_tpage_dir(); case GameVersion::Jak2: return get_jak2_tpage_dir(); + case GameVersion::Jak3: + return get_jak3_tpage_dir(); default: ASSERT(false); } diff --git a/game/graphics/texture/jak2_tpage_dir.cpp b/game/graphics/texture/jak2_tpage_dir.cpp index 74fdb3aedae..af53b7f612a 100644 --- a/game/graphics/texture/jak2_tpage_dir.cpp +++ b/game/graphics/texture/jak2_tpage_dir.cpp @@ -4,7 +4,7 @@ #include "common/common_types.h" -#include "jak1_tpage_dir.h" +#include "game/graphics/texture/jak1_tpage_dir.h" // clang-format off namespace { diff --git a/game/graphics/texture/jak2_tpage_dir.h b/game/graphics/texture/jak2_tpage_dir.h index 97947c9f5d6..bffec3a6fd3 100644 --- a/game/graphics/texture/jak2_tpage_dir.h +++ b/game/graphics/texture/jak2_tpage_dir.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include "common/common_types.h" diff --git a/game/graphics/texture/jak3_tpage_dir.cpp b/game/graphics/texture/jak3_tpage_dir.cpp new file mode 100644 index 00000000000..7e2fa82d6c9 --- /dev/null +++ b/game/graphics/texture/jak3_tpage_dir.cpp @@ -0,0 +1,1721 @@ +#include "jak3_tpage_dir.h" + +#include "game/graphics/texture/jak1_tpage_dir.h" + +namespace { +std::vector tpage_dir = {0x0, 0x7, + 0x3, 0x5, + 0xba, 0x29, + 0x1b, 0x84, + 0x5, 0x5e, + 0x6, 0x19, + 0x6, 0x36, + 0x0, 0x26, + 0x0, 0x8c, + 0x1e, 0x0, + 0x17, 0x0, + 0x1, 0x4, + 0xe, 0x6, + 0x7, 0x7, + 0x6, 0x5, + 0x1e, 0x13, + 0x7, 0x7, + 0x2, 0x4, + 0x3, 0x3, + 0x0, 0x3, + 0xd, 0x10, + 0xa, 0x5, + 0x5, 0x3, + 0x3, 0x3, + 0x3, 0x5, + 0x5, 0x2, + 0x7, 0x7, + 0x5, 0x9, + 0x9, 0x6, + 0x1e, 0x12, + 0x2, 0x2, + 0x1, 0x1, + 0x1, 0x1, + 0x2, 0x2, + 0x2, 0x2, + 0x8, 0x8, + 0x5, 0xb, + 0xc, 0x9, + 0x16, 0x1, + 0x14, 0x1, + 0x10, 0x1, + 0x1, 0x1, + 0x1, 0x3, + 0x1f, 0x13, + 0x13, 0x12, + 0x17, 0x1e, + 0x1a, 0x17, + 0x11, 0xf, + 0x14, 0xe, + 0x10, 0x16, + 0x1c, 0x16, + 0x19, 0x13, + 0x13, 0x2, + 0x7, 0x8, + 0x2, 0x3, + 0x14, 0x14, + 0xb, 0xb, + 0x10, 0x10, + 0x2, 0x2, + 0x9, 0x2, + 0x0, 0x23, + 0x0, 0x20, + 0xaf, 0x1b, + 0x0, 0x90, + 0x6, 0x6, + 0x4, 0x1, + 0x23, 0x51, + 0x44, 0x23, + 0x42, 0x0, + 0x0, 0x7f, + 0x1, 0x58, + 0x6, 0x6, + 0x4, 0x1, + 0x6, 0x6, + 0x5, 0x2f, + 0xd, 0x1, + 0x26, 0x14, + 0x1, 0x10, + 0x1, 0x4, + 0x1, 0x1, + 0x0, 0x25, + 0xd, 0x80, + 0x0, 0x20, + 0x7d, 0x1, + 0x0, 0x23, + 0xe, 0x7a, + 0x0, 0x23, + 0x79, 0x1, + 0xc, 0x3, + 0x4d, 0xc, + 0x4c, 0x1, + 0xa, 0x11, + 0x4, 0x52, + 0xa, 0x11, + 0x52, 0x3, + 0x2, 0x8, + 0xb, 0x16, + 0x2e, 0x3, + 0x8, 0xb, + 0x2e, 0x1, + 0x2, 0x3, + 0x1, 0x8, + 0xc, 0x16, + 0x35, 0x3, + 0x8, 0xc, + 0x35, 0x2, + 0x2, 0x1, + 0xd, 0x19, + 0x45, 0xd, + 0x46, 0x1, + 0x4f, 0x14, + 0x5, 0x67, + 0x37, 0x14, + 0x58, 0x3, + 0x3, 0x2, + 0xc, 0x8, + 0x44, 0xc, + 0x44, 0x6, + 0x1d, 0x5, + 0x1, 0x16, + 0xb, 0x6, + 0x2e, 0x5, + 0x16, 0xb, + 0x2e, 0x1, + 0x1, 0x5, + 0x1, 0x19, + 0xb, 0x6, + 0x2a, 0x5, + 0x19, 0xb, + 0x2a, 0x1, + 0x1, 0x5, + 0x5, 0x5, + 0x4, 0x6, + 0x1d, 0x1f, + 0x10, 0x6, + 0x6, 0x65, + 0x14, 0x1e, + 0x63, 0x2, + 0x3, 0x4, + 0x5, 0x5, + 0x4, 0x4, + 0x2, 0x6, + 0x5, 0x48, + 0x6, 0x5, + 0x48, 0x0, + 0x4, 0x0, + 0x0, 0x2, + 0x2, 0x1, + 0x3, 0x3, + 0x3, 0x3, + 0x4, 0x4, + 0x4, 0x2, + 0x4, 0x4, + 0xd1, 0x17, + 0x3, 0x3, + 0x3, 0x9, + 0x1, 0x1, + 0x0, 0x37, + 0xc4, 0x1, + 0x31, 0x73, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x78, + 0xe, 0x2d, + 0x2, 0x0, + 0x0, 0x0, + 0x11, 0x11, + 0x1c, 0x0, + 0x1, 0x15, + 0x7, 0x1, + 0x2, 0x0, + 0x9, 0x2, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x2a, + 0x4, 0x27, + 0x58, 0x4, + 0x2d, 0x47, + 0x2, 0x27, + 0x1, 0x6, + 0x1, 0x26, + 0x0, 0x0, + 0x0, 0x2, + 0x20, 0x2, + 0x1, 0x2, + 0x1, 0x0, + 0x7, 0x0, + 0x0, 0x0, + 0xd, 0x3b, + 0x7, 0x1, + 0x0, 0x0, + 0x1, 0x0, + 0x0, 0x0, + 0x2, 0x0, + 0x35, 0x0, + 0x95, 0x7, + 0x7, 0x6, + 0x1, 0xd7, + 0x0, 0x0, + 0xe, 0x0, + 0x6, 0x0, + 0x6, 0xf, + 0xa, 0x85, + 0x1c, 0x0, + 0x79, 0x1a, + 0x34, 0x3, + 0x5d, 0x5f, + 0x5, 0x3, + 0x1f, 0x16, + 0x4, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x25, 0x1, + 0x0, 0x4, + 0x24, 0x4, + 0x1, 0x0, + 0x9, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x7, + 0x5, 0x1, + 0x5, 0x1, + 0xb, 0xb, + 0x0, 0x0, + 0x14, 0x2, + 0x2, 0x12, + 0x6, 0x0, + 0x1, 0x0, + 0x1, 0x1, + 0x2c, 0x82, + 0x3, 0x2, + 0x2, 0x0, + 0x0, 0x4, + 0x0, 0x6, + 0x6, 0x56, + 0x0, 0x0, + 0x0, 0x2, + 0x24, 0x5d, + 0x4, 0x46, + 0x7, 0xe, + 0x55, 0x15, + 0x5e, 0x57, + 0x16, 0x3b, + 0x5a, 0x2, + 0x12, 0x3, + 0x2, 0x3, + 0x3, 0x1, + 0x18, 0x2, + 0x0, 0x2, + 0x2, 0x0, + 0x1, 0x7, + 0x2, 0x2, + 0x2, 0x2, + 0x0, 0x0, + 0x1, 0x5, + 0x28, 0x5, + 0x31, 0x1, + 0xa3, 0x0, + 0x3, 0x0, + 0x37, 0x0, + 0x19, 0x3, + 0x3, 0x0, + 0x3, 0x3, + 0x2, 0x2, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x4, + 0xc8, 0x72, + 0xe, 0x21, + 0xdc, 0x9, + 0x20, 0x1a, + 0x7d, 0xa, + 0x10, 0xd8, + 0x19, 0x7, + 0x2d, 0x19, + 0x2c, 0x21, + 0x27, 0x64, + 0x12, 0x7, + 0x0, 0x2, + 0xc, 0x7, + 0x15, 0x13, + 0x45, 0x68, + 0x5, 0x2, + 0x0, 0x19, + 0x0, 0x6a, + 0x4, 0x5, + 0x1, 0x7, + 0x0, 0x4, + 0x0, 0x1e, + 0x10, 0xf, + 0xe, 0x0, + 0x1, 0x0, + 0x22, 0x2f, + 0x22, 0x70, + 0x82, 0x123, + 0x1c, 0x1e, + 0xf, 0x43, + 0x1c, 0x1f, + 0x16, 0x35, + 0x36, 0x47, + 0x1d, 0x1a, + 0x2, 0x20, + 0xe, 0x12, + 0x7, 0x5, + 0x2, 0x0, + 0x0, 0x0, + 0x5, 0x29, + 0x7, 0x0, + 0x13, 0x13, + 0x16, 0x16, + 0x0, 0x0, + 0x7, 0x25, + 0x3, 0x0, + 0x8, 0x8, + 0xd, 0x2, + 0x5d, 0x19, + 0x3, 0x34, + 0x50, 0x2c, + 0x10, 0x1, + 0x0, 0x82, + 0x8, 0x7, + 0x1, 0x0, + 0xd, 0x27, + 0x7, 0x2, + 0x2, 0x2, + 0x2, 0x2, + 0x2, 0x2, + 0x2, 0x2, + 0x7, 0x6, + 0xd, 0xe, + 0xd, 0xd, + 0x3, 0x1f, + 0x2c, 0x0, + 0x1, 0x40, + 0x0, 0x0, + 0x18, 0x3, + 0x3, 0x4, + 0x1, 0x0, + 0x0, 0x1, + 0x2, 0x2, + 0x1, 0x1, + 0x3, 0x3, + 0x96, 0x3a, + 0x4, 0xcc, + 0x1, 0x7, + 0x0, 0xa, + 0x0, 0x7, + 0x6, 0x0, + 0x5, 0x5, + 0x15, 0x13, + 0x32, 0x2d, + 0x2, 0xe, + 0x2, 0x23, + 0x0, 0x0, + 0x0, 0x7, + 0x7f, 0x0, + 0xd, 0x7, + 0x0, 0x0, + 0x1, 0x0, + 0xc, 0x6, + 0x1, 0xd, + 0x5, 0x5, + 0x5, 0xe, + 0x5, 0x5, + 0x5, 0xe, + 0x0, 0x0, + 0xe, 0x10, + 0x29, 0x18, + 0x18, 0x19, + 0x23, 0x7f, + 0x54, 0x3, + 0x48, 0x6, + 0x51, 0xe, + 0x52, 0xe, + 0x12, 0xe, + 0x6c, 0x40, + 0x57, 0x16, + 0x37, 0x54, + 0x3, 0x17, + 0x0, 0x0, + 0x7, 0x7, + 0xd, 0x5d, + 0x6c, 0x0, + 0x8, 0x6, + 0x5, 0x10, + 0x1, 0x34, + 0xc7, 0xe, + 0x0, 0x0, + 0x0, 0x9, + 0x12, 0xe, + 0x3, 0x6, + 0x84, 0x5, + 0x6d, 0x3, + 0x8, 0x16, + 0x1, 0x14, + 0x1, 0x10, + 0x1, 0x15, + 0x0, 0x0, + 0x82, 0x8, + 0x1, 0x2, + 0x30, 0x0, + 0x1, 0x5e, + 0x5b, 0x0, + 0x3b, 0x3, + 0x1, 0x2, + 0x44, 0x21, + 0x21, 0xe, + 0xa, 0x9, + 0xb, 0x16, + 0x23, 0xe, + 0x3, 0xe, + 0x5, 0x21, + 0x1, 0x2, + 0x93, 0x5, + 0x19, 0x1, + 0x82, 0x2, + 0x2, 0x1, + 0xd, 0x67, + 0x1, 0x0, + 0x0, 0x5a, + 0x3, 0x12, + 0x33, 0x0, + 0x1, 0x1, + 0x1, 0x5, + 0x1, 0x3, + 0x1, 0x3, + 0x1, 0x3, + 0x1, 0x8, + 0x3, 0x1, + 0x3, 0x1, + 0x8, 0x6, + 0x6, 0x8, + 0x3, 0x3, + 0x36, 0x68, + 0x1, 0x73, + 0x41, 0x1c, + 0x65, 0x3, + 0x2, 0x2, + 0x0, 0x15, + 0x13, 0x8, + 0x0, 0xa, + 0x2, 0x0, + 0x0, 0x3, + 0x1, 0x0, + 0x0, 0xd, + 0x0, 0xb3, + 0x50, 0x68, + 0xaa, 0x0, + 0x1d, 0xc, + 0xb, 0xc, + 0xc, 0xd, + 0xd, 0x8, + 0xa, 0x42, + 0xb, 0x0, + 0x3b, 0x9c, + 0x3b, 0x0, + 0x32, 0x5c, + 0x2a, 0x56, + 0x1f, 0x69, + 0x12, 0x5, + 0x3, 0x7, + 0x3a, 0x8f, + 0x3b, 0x0, + 0x30, 0x4f, + 0x56, 0x1f, + 0x59, 0x1, + 0x1, 0x4, + 0x0, 0x0, + 0x26, 0x25, + 0x13, 0x13, + 0xd, 0xd, + 0x5e, 0x6, + 0x1f, 0x31, + 0x12, 0xd, + 0x1b, 0x1, + 0xb, 0x9, + 0x0, 0x0, + 0x2c, 0x1e, + 0x7, 0x0, + 0xb, 0x4, + 0x3d, 0xa, + 0x4, 0x4, + 0x0, 0x4, + 0x7, 0x5, + 0x5, 0x4, + 0x0, 0x6, + 0x6, 0x3, + 0x7, 0x0, + 0xd, 0x8, + 0x6, 0x11, + 0x47, 0x3, + 0x17, 0x62, + 0x6, 0x7, + 0x14, 0x11, + 0xc, 0x2, + 0x7, 0x4, + 0x5e, 0x12, + 0x1f, 0x7, + 0x7, 0x0, + 0x3, 0x4, + 0x3, 0x3, + 0x3, 0x4, + 0x4, 0x4, + 0x0, 0x0, + 0x3, 0x0, + 0x0, 0x0, + 0x4d, 0xc, + 0x0, 0xc, + 0x4, 0x7, + 0x31, 0x66, + 0x0, 0x2d, + 0x66, 0x0, + 0x31, 0x2, + 0x0, 0xb, + 0x5, 0x5, + 0x4, 0xc, + 0x5, 0x36, + 0x4, 0x7, + 0x11, 0x3, + 0x2, 0x12, + 0x1, 0x22, + 0x0, 0xc, + 0x38, 0x0, + 0x0, 0x0, + 0x11, 0x1f, + 0x1, 0x0, + 0x0, 0x0, + 0x32, 0x0, + 0x0, 0x9, + 0x0, 0xe, + 0xd, 0x6, + 0x9, 0x9, + 0x6, 0x1, + 0x0, 0x0, + 0x21, 0x1, + 0x4, 0x3, + 0x1, 0x1, + 0x0, 0x0, + 0x1, 0x0, + 0xb, 0xb, + 0x1, 0x1, + 0x1, 0x3b, + 0xa, 0x24, + 0x41, 0x1, + 0x58, 0x0, + 0xa, 0x3d, + 0x1, 0x0, + 0x7, 0xa, + 0x4b, 0x2, + 0x1d, 0x1, + 0x1, 0x1, + 0x1, 0xf, + 0xd, 0x9, + 0xf, 0xe, + 0x5, 0x9, + 0x0, 0x4, + 0x2, 0x3, + 0x9, 0x1, + 0x5, 0x4, + 0x14, 0x44, + 0x8, 0x4c, + 0xd, 0x51, + 0x9, 0x4c, + 0x10, 0x9, + 0x3e, 0xa, + 0x44, 0x55, + 0x4, 0x54, + 0x6, 0x1f, + 0x56, 0xc, + 0xf, 0x1f, + 0x6, 0x54, + 0x6, 0x14, + 0x1f, 0x1, + 0x5, 0x5, + 0x3, 0x1, + 0x8, 0x1f, + 0x1, 0x0, + 0x73, 0x10, + 0x40, 0x1, + 0x19, 0xc, + 0x8, 0x19, + 0x0, 0x34, + 0x69, 0x6b, + 0x4, 0x8, + 0x0, 0x0, + 0x1, 0xc, + 0x1, 0x0, + 0x0, 0x3, + 0x1, 0x1, + 0x1, 0x1, + 0x1, 0x1, + 0x1, 0x0, + 0x0, 0x7, + 0x2, 0xc, + 0xb, 0x3, + 0x8, 0x8, + 0x0, 0x7, + 0x0, 0x14, + 0x13, 0x6, + 0x6, 0x3, + 0x4, 0xb, + 0xa, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x1, 0xa8, + 0x0, 0x23, + 0x6, 0x2, + 0x7, 0x0, + 0x4, 0x4, + 0x3, 0x6, + 0x20, 0x6, + 0x1a, 0x19, + 0x15, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x10, 0x11, + 0xc, 0xb, + 0x3, 0x3, + 0x7, 0x7, + 0x1, 0x7, + 0x9, 0xc, + 0x32, 0x84, + 0x59, 0x70, + 0x1, 0x0, + 0x0, 0x39, + 0x1, 0x1, + 0x2, 0x9, + 0x9, 0x9, + 0x9, 0x2, + 0x23, 0x6, + 0x5, 0x2, + 0xe, 0xe, + 0x5, 0x7, + 0x7, 0x5, + 0x8, 0x7, + 0x3, 0x6, + 0x6, 0x3, + 0xa, 0x2, + 0x5, 0x2, + 0x5, 0x2, + 0xe, 0x2, + 0x8, 0x2, + 0x6, 0x2, + 0xa, 0x2, + 0x5, 0x2, + 0x5, 0x2, + 0x0, 0x10, + 0x0, 0x1, + 0x0, 0x4, + 0x21, 0x6, + 0x9, 0x4, + 0x4, 0x0, + 0x1, 0x8, + 0x8, 0x1, + 0x16, 0x0, + 0xe, 0xa, + 0x7, 0xe, + 0x3, 0x0, + 0x0, 0x5, + 0x21, 0x4, + 0x54, 0x23, + 0x1, 0x3, + 0xc, 0x7, + 0x42, 0x2, + 0x0, 0x13, + 0xa, 0x7, + 0x9, 0x1, + 0x14, 0x14, + 0x0, 0x1, + 0x11, 0x17, + 0x1c, 0x1c, + 0x1c, 0x0, + 0x1, 0x34, + 0x1, 0x2, + 0x1, 0x2, + 0x5, 0x2, + 0x50, 0xf, + 0x1, 0xa, + 0x1, 0x4, + 0x9, 0x4, + 0x17, 0x2, + 0x3, 0xa, + 0xe, 0x48, + 0x18, 0x4, + 0x3, 0x18, + 0xe, 0x34, + 0x6, 0x0, + 0x42, 0x3c, + 0x10, 0x2, + 0x14, 0x3, + 0x1b, 0x9, + 0x35, 0x22, + 0x22, 0x7f, + 0x5, 0x1c, + 0x4a, 0x7a, + 0x5, 0x4a, + 0x22, 0xe, + 0x3, 0x2, + 0x1, 0x1, + 0x3, 0xc, + 0x6, 0x4, + 0x1, 0x3, + 0x3, 0x22, + 0x1a, 0x1, + 0x2, 0x9, + 0x8, 0x6, + 0x3, 0x3, + 0x2, 0x3, + 0x5, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x23, + 0x0, 0x12, + 0x3, 0x5, + 0x22, 0x0, + 0x3, 0x3, + 0x2, 0x2, + 0x76, 0x5, + 0x61, 0x3, + 0x0, 0x0, + 0x0, 0x6, + 0x1, 0x5, + 0x3d, 0x24, + 0x1f, 0x1, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x1d, 0x1d, + 0x1d, 0x7, + 0x27, 0x1b, + 0x1c, 0x3, + 0x3, 0x3, + 0x2, 0x3, + 0x3, 0x2, + 0x3, 0x8, + 0x0, 0x3a, + 0x26, 0x22, + 0x1, 0x4, + 0x4, 0x1, + 0x1, 0x3, + 0x1, 0x1, + 0x1, 0x1, + 0x3, 0x1, + 0x0, 0x0, + 0x0, 0x0, + 0x1, 0x26, + 0x2, 0x26, + 0x4, 0x7, + 0x42, 0x4, + 0x1, 0x0, + 0x4d, 0x1, + 0x0, 0x4, + 0x8, 0x1, + 0x1, 0x1, + 0x1, 0x74, + 0x4d, 0x1, + 0x13, 0x1, + 0x2, 0x11, + 0x0, 0x0, + 0x5, 0x1e, + 0x0, 0x18, + 0x0, 0x0, + 0x0, 0x2, + 0x0, 0x0, + 0x1e, 0x1f, + 0x1, 0x48, + 0x23, 0x3e, + 0x44, 0x25, + 0x2, 0x0, + 0x1c, 0x35, + 0x0, 0x10, + 0x21, 0x1, + 0xd, 0xc, + 0xa, 0xe, + 0x0, 0x35, + 0x0, 0x0, + 0x1, 0x9, + 0x2, 0x1, + 0x7, 0x2, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0xa, + 0x0, 0x3, + 0x1f, 0x6c, + 0xa, 0xa, + 0x16, 0x2, + 0x2, 0x2, + 0x2, 0x2, + 0x2, 0x2, + 0x2, 0x2, + 0xe, 0x38, + 0x17, 0x6, + 0x0, 0x0, + 0x0, 0x6, + 0x6c, 0x8f, + 0x39, 0x20, + 0x1d, 0x94, + 0x2, 0x20, + 0x4, 0x7, + 0x4, 0x0, + 0x0, 0x0, + 0x4, 0x0, + 0x1, 0x1, + 0x1, 0x1, + 0x1, 0x1, + 0x51, 0xb4, + 0x5, 0x26, + 0x65, 0x1, + 0xa, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x34, 0x23, + 0x7, 0x31, + 0x5, 0x0, + 0x4, 0x2, + 0x2, 0x7, + 0x6, 0x2, + 0x2, 0x2, + 0x2, 0x2, + 0x2, 0x2, + 0x2, 0x7, + 0x0, 0xe, + 0x1, 0x3, + 0xd, 0xc, + 0x0, 0x21, + 0x1, 0x10, + 0x14, 0x3f, + 0x0, 0x0, + 0x18, 0x5, + 0x1, 0xb, + 0x2, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x3, 0x3, + 0x1, 0x2, + 0x3, 0x4, + 0x4, 0x5, + 0x5, 0x5, + 0x5, 0x0, + 0x0, 0x10, + 0x10, 0x2, + 0x0, 0x0, + 0x2, 0x2, + 0x1, 0x0, + 0x2, 0x3, + 0x1, 0x6, + 0x9, 0x1, + 0x0, 0xe, + 0x16, 0x17, + 0x4, 0x4, + 0x6, 0x1, + 0x1a, 0x1, + 0x41, 0x31, + 0x1, 0x50, + 0x0, 0x0, + 0x0, 0x0, + 0x1, 0x0, + 0x6, 0x1, + 0x1, 0x1, + 0xc, 0x0, + 0x3, 0x3, + 0x1, 0x0, + 0x0, 0x0, + 0xd8, 0x2, + 0x2, 0x7, + 0x5, 0x2d, + 0x18, 0x5, + 0x3, 0xa, + 0x1, 0x0, + 0x1, 0x0, + 0x0, 0x2, + 0x2, 0x3, + 0x3, 0x20, + 0x5b, 0x0, + 0xf, 0x1, + 0x7, 0x6, + 0x7, 0x2, + 0x0, 0x88, + 0x3e, 0x1f, + 0x3, 0x1, + 0x5, 0x4, + 0x7, 0x6, + 0x7, 0x6, + 0x7, 0x7, + 0x5, 0x1, + 0x2, 0x3, + 0x4, 0x3, + 0xb, 0x7, + 0x68, 0x4, + 0x0, 0x20, + 0x2, 0x5, + 0x0, 0x5, + 0x6, 0xa5, + 0x2, 0x2, + 0x4, 0x7, + 0x5, 0x7, + 0xe, 0x4, + 0xe, 0xc, + 0x0, 0x3, + 0x1f, 0x1, + 0x44, 0x23, + 0x1c, 0x0, + 0x1, 0xe, + 0x2, 0x0, + 0x5, 0x47, + 0x0, 0x0, + 0x20, 0x0, + 0x0, 0x0, + 0x29, 0x5, + 0x3, 0xb, + 0x4, 0x1, + 0x1, 0x1f, + 0x1, 0x1b, + 0x2, 0x0, + 0xc, 0x6, + 0x0, 0x19, + 0x0, 0x1, + 0x3, 0x6, + 0x4, 0x6, + 0x81, 0x35, + 0x0, 0x3, + 0x4, 0x0, + 0x1, 0x2, + 0x2, 0xb, + 0x2, 0xb, + 0x0, 0x31, + 0x3, 0x5, + 0x4a, 0x2, + 0xa6, 0x4, + 0x0, 0x0, + 0x0, 0x0, + 0x9, 0x5, + 0x5, 0x4, + 0xe, 0xd, + 0x8d, 0x5, + 0x1e, 0x3, + 0x6, 0xb, + 0x4, 0x4, + 0x4, 0x4, + 0x3, 0x2, + 0x2, 0x2, + 0x7, 0x2, + 0x2, 0x6f, + 0x1, 0x1, + 0x5, 0x5, + 0x1, 0x2, + 0x1, 0x1, + 0x16, 0x1, + 0x14, 0x1, + 0x10, 0x1, + 0xf, 0xb, + 0x10, 0xc, + 0x11, 0x18, + 0x14, 0x13, + 0x1, 0x2, + 0x6, 0x0, + 0x0, 0x0, + 0x0, 0x47, + 0x2, 0x14, + 0x1, 0x1, + 0x1, 0x1, + 0x1, 0x1, + 0x4, 0x5, + 0x4f, 0x0, + 0x1d, 0x1, + 0x0, 0x1, + 0x0, 0x1, + 0x0, 0x0, + 0x1, 0x3, + 0xd, 0xd, + 0x84, 0x5, + 0x0, 0x8, + 0x7, 0x12, + 0x12, 0x1, + 0x1, 0x1, + 0x1, 0x83, + 0x5, 0x0, + 0x1b, 0x1, + 0x5, 0x43, + 0x5a, 0x1, + 0xa, 0x5a, + 0x1, 0x23, + 0x14, 0x10, + 0x15, 0x1, + 0x13, 0xf, + 0x2, 0x2, + 0x18, 0x21, + 0x1, 0x2, + 0x2, 0x13, + 0xd, 0xd, + 0xb, 0x1f, + 0x3, 0x2, + 0x68, 0x4, + 0x4, 0x6, + 0x6, 0x44, + 0x1, 0x18, + 0x4, 0x4, + 0x4, 0x8, + 0x4, 0x4, + 0x4, 0x8, + 0x4, 0x4, + 0x4, 0x8, + 0x4, 0x4, + 0x4, 0x8, + 0x4, 0x4, + 0x4, 0x8, + 0x4, 0x4, + 0x4, 0x8, + 0x22, 0x6, + 0x0, 0x8, + 0x1, 0x3, + 0x0, 0x0, + 0x32, 0x1, + 0x9, 0xa, + 0x13, 0x8, + 0x2, 0xd9, + 0x1a, 0x6, + 0x0, 0xad, + 0x18, 0x5, + 0x3a, 0x9, + 0xa, 0x6, + 0x2, 0x0, + 0x0, 0x9c, + 0x16, 0x5, + 0xb1, 0x18, + 0x6, 0x0, + 0x0, 0x0, + 0x6, 0x8d, + 0x10, 0x88, + 0x32, 0x1, + 0x6, 0x1b, + 0xe, 0x0, + 0x5, 0x1, + 0x0, 0x0, + 0x6, 0x2, + 0x1, 0x1, + 0x2, 0x2, + 0x2, 0x2, + 0xa, 0x0, + 0x0, 0x0, + 0x0, 0xf, + 0x3, 0x5, + 0x39, 0x1d, + 0xb, 0x4, + 0x5, 0x5, + 0x5, 0x0, + 0x0, 0x59, + 0x17, 0x0, + 0x2b, 0x0, + 0x3, 0x5, + 0x2, 0x3, + 0x0, 0x0, + 0x2, 0x6, + 0x3, 0x6, + 0x6, 0x5, + 0x6, 0x6, + 0x4, 0x3, + 0x6, 0x33, + 0xa, 0x9, + 0xa, 0x0, + 0x13, 0x1a, + 0x1, 0x19, + 0x7c, 0x1, + 0x1, 0x1, + 0x2, 0x0, + 0x20, 0x1, + 0x3b, 0x3, + 0x0, 0x0, + 0x0, 0x0, + 0x74, 0x3, + 0x3, 0x1, + 0x9, 0x61, + 0x1, 0x0, + 0x5, 0x5, + 0x5, 0x5, + 0x0, 0x9, + 0x5, 0xa, + 0x4, 0x6, + 0x0, 0x2a, + 0x2, 0x2, + 0x0, 0x1, + 0xc, 0x0, + 0x8, 0x6, + 0x0, 0x1, + 0xc, 0x0, + 0x0, 0x0, + 0x0, 0x3, + 0x3, 0x3, + 0x7, 0x10, + 0x1, 0x1b, + 0x0, 0x1c, + 0x7, 0x5f, + 0x3, 0x0, + 0x17, 0x3, + 0x3, 0x1d, + 0x8, 0x8, + 0x5, 0xb, + 0xb, 0xc, + 0x1a, 0x8, + 0x74, 0x1b, + 0x37, 0x1, + 0xb, 0x2, + 0x4, 0x3, + 0x1, 0x2, + 0x3, 0x9, + 0x11, 0x0, + 0x25, 0x0, + 0x1, 0x1, + 0x0, 0x9, + 0x3, 0x4c, + 0x3, 0xb, + 0x0, 0x6c, + 0x7, 0x25, + 0x2a, 0x40, + 0x29, 0x0, + 0x0, 0x0, + 0x4, 0x4, + 0x2c, 0x7, + 0x42, 0x2, + 0x0, 0x38, + 0x0, 0x3, + 0xb, 0xe, + 0xb, 0x3, + 0x3, 0x2, + 0x3, 0x1e, + 0x3, 0x7, + 0x91, 0x0, + 0x1d, 0x23, + 0x3, 0x7, + 0x0, 0x2, + 0x35, 0x2e, + 0x20, 0x4, + 0x4, 0x3, + 0x5, 0x0, + 0x4b, 0x2, + 0x1, 0x1c, + 0x8, 0x5, + 0x1, 0x0, + 0xa, 0x0, + 0x6, 0x7, + 0xd, 0x7, + 0x22, 0x1f, + 0x1, 0x3, + 0x8, 0x21, + 0x9, 0x7f, + 0x0, 0x0, + 0x13, 0x0, + 0x6, 0x3c, + 0x42, 0x5b, + 0x47, 0x9, + 0x0, 0x1d, + 0x4, 0x4f, + 0x3, 0x1, + 0x3, 0x0, + 0x0, 0x0, + 0x5, 0x2, + 0xe, 0x3c, + 0x0, 0x53, + 0x3, 0x1f, + 0x7, 0x0, + 0x4, 0x5, + 0x5, 0xf, + 0x1, 0x4, + 0x2c, 0x2, + 0x1f, 0x4, + 0x29, 0x0, + 0x2c, 0xd, + 0x0, 0x2d, + 0xa, 0x20, + 0xd, 0x23, + 0x0, 0x0, + 0x5, 0x0, + 0x0, 0x5, + 0x3, 0x1, + 0x0, 0x3, + 0x11, 0x6, + 0x35, 0x1, + 0x0, 0x0, + 0x0, 0x4a, + 0x4, 0x6, + 0x0, 0x1, + 0x6, 0x6, + 0x0, 0x0, + 0x6, 0x22, + 0x1, 0x1, + 0x10, 0x4, + 0xd, 0x0, + 0x1, 0x0, + 0x1, 0x0, + 0x0, 0x3, + 0x2, 0x2, + 0x5, 0x1, + 0x5, 0x6, + 0x1, 0x0, + 0x0, 0x0, + 0x1, 0x4, + 0x2, 0x1, + 0x8, 0x5, + 0x3, 0x0, + 0x2, 0x0, + 0x0, 0x4, + 0x3, 0x6, + 0x0, 0x4, + 0x4, 0x0, + 0x0, 0x1, + 0x1, 0x2, + 0x3, 0x7, + 0x5, 0xc, + 0x0, 0x0, + 0x33, 0x9, + 0x3, 0x23, + 0x4d, 0xa, + 0x6, 0x6, + 0x7, 0x7, + 0x6, 0x7, + 0x44, 0xf, + 0x7, 0x24, + 0x22, 0x0, + 0x0, 0x12, + 0x1, 0x2, + 0x1, 0x0, + 0xd, 0x3, + 0x3, 0x3, + 0x3, 0x2, + 0x2, 0x8, + 0x10, 0x3, + 0x3, 0x5, + 0x3, 0x3, + 0x6, 0x6, + 0x6, 0x6, + 0x0, 0x1, + 0x3, 0x3, + 0x6, 0x6, + 0x6, 0x6, + 0x4, 0x4, + 0x7, 0x12, + 0x7, 0x1b, + 0x1e, 0x1b, + 0x1f, 0x1d, + 0x4, 0x4, + 0x4, 0x4, + 0x4, 0x7, + 0x7, 0x2, + 0x4, 0x26, + 0x2c, 0x2b, + 0x2, 0x24, + 0x1, 0x9, + 0x9, 0x1f, + 0x3, 0x5, + 0x43, 0xe, + 0x6, 0x3, + 0x8f, 0x38, + 0x1, 0x4, + 0x12, 0x0, + 0x0, 0x0, + 0x1, 0x1, + 0x1, 0x0, + 0x1, 0xc, + 0x0, 0x16, + 0x4, 0x0, + 0x7f, 0x5, + 0x0, 0x66, + 0x1f, 0x3, + 0x0, 0x6, + 0x1a, 0x5, + 0x5, 0x5, + 0x2, 0x2, + 0x4, 0xa3, + 0x3, 0x8, + 0x5, 0x1, + 0x5, 0x3, + 0x1, 0x1a, + 0x3, 0x0, + 0x5, 0x0, + 0x0, 0x3, + 0x1, 0x4, + 0x3, 0x0, + 0x5, 0x6, + 0xb, 0x4, + 0x4, 0x4, + 0x3, 0x3, + 0x1c, 0x1f, + 0x9, 0x0, + 0x0, 0x0, + 0x6, 0x8, + 0x7, 0xa, + 0x43, 0x17, + 0x14, 0x0, + 0x0, 0x5, + 0x3, 0x0, + 0x8, 0x8, + 0x22, 0x0, + 0x0, 0x1, + 0x79, 0x6a, + 0x3, 0x21, + 0x0, 0x39, + 0x4, 0x12, + 0x4, 0x7c, + 0x5, 0x0, + 0x5, 0xb, + 0x3, 0x0, + 0x0, 0x3, + 0x3, 0x6, + 0x3c, 0x42, + 0x4, 0x48, + 0x30, 0x7f, + 0x17, 0x1, + 0x4f, 0x2, + 0x1, 0x7, + 0x43, 0x0, + 0x22, 0x0, + 0x44, 0x3e, + 0x3, 0x2, + 0x3, 0x40, + 0x39, 0x88, + 0x42, 0x0, + 0x4, 0x1, + 0x1d, 0x7, + 0x3, 0x1c, + 0x4, 0x3, + 0x1b, 0x3, + 0x7, 0x62, + 0x1f, 0x3, + 0x0, 0x4f, + 0x22, 0xd, + 0x35, 0x1f, + 0x1, 0x0, + 0x5, 0xd, + 0xa, 0x2, + 0x0, 0x1, + 0x12, 0x4, + 0x23, 0xb, + 0x4, 0x3, + 0x3, 0x23, + 0x4, 0x0, + 0x0, 0x0, + 0x6f, 0x2, + 0x7, 0x6, + 0x1, 0x4, + 0x4, 0x0, + 0x3, 0x2, + 0x4, 0x0, + 0x0, 0x0, + 0x6, 0x2, + 0x28, 0x2, + 0x1, 0x2, + 0x4c, 0x5, + 0x0, 0x0, + 0x2, 0x3, + 0x1a, 0x0, + 0x3, 0x26, + 0x7, 0xf, + 0x2, 0x2, + 0x2, 0x2, + 0x7, 0x0, + 0x4, 0x7f, + 0x5, 0x0, + 0xd, 0xd, + 0x1, 0x1, + 0x4, 0x1, + 0x1d, 0x8, + 0x0, 0x0, + 0x0, 0x0, + 0x6, 0x5, + 0x1, 0x5, + 0x5, 0x6, + 0x1a, 0x0, + 0x0, 0x1, + 0x3a, 0x0, + 0x0, 0x8, + 0x23, 0x1, + 0x8, 0x7, + 0x8, 0x1, + 0x29, 0x0, + 0x9, 0x8, + 0x8, 0x8, + 0x65, 0x3d, + 0x2, 0x0, + 0x7, 0x1, + 0x29, 0x1, + 0x0, 0x1, + 0x11, 0x5, + 0x4, 0xb, + 0x4, 0x1, + 0x0, 0xa, + 0x9, 0x4, + 0x4, 0x0, + 0x6, 0x9, + 0x3, 0x3, + 0x3, 0x3, + 0x3, 0x4, + 0x3, 0x3, + 0x3, 0x3, + 0x3, 0x2, + 0x3, 0x3, + 0x3, 0x3, + 0x3, 0x3, + 0x3, 0x3, + 0x3, 0x33, + 0x1, 0x1, + 0x27, 0x1, + 0x11, 0x0, + 0x4b, 0x1, + 0x1, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x4, + 0xc, 0x5, + 0xc, 0x0, + 0x22, 0x1, + 0x17, 0x4, + 0x5, 0xa, + 0x2, 0x2, + 0x2, 0x26, + 0x33, 0x1, + 0x1, 0x1, + 0x11, 0x4, + 0x4, 0xa, + 0x2, 0x6, + 0x5, 0x7, + 0x3, 0x3b, + 0x4, 0x3, + 0x1f, 0x4, + 0x8, 0x6, + 0x5, 0x5, + 0x5, 0x0, + 0x0, 0x40, + 0x3, 0xc, + 0x91, 0x1, + 0x0, 0x13, + 0xb, 0x1e, + 0x4, 0x19, + 0x3e, 0x2, + 0x1, 0x0, + 0x0, 0x6, + 0x1, 0x0, + 0x3, 0x16, + 0x4, 0x2, + 0xb, 0x1e, + 0x1, 0x6, + 0x6, 0x3f, + 0x6, 0x7, + 0xf, 0x3, + 0x18, 0x14, + 0x0, 0x0, + 0x4, 0x3, + 0x3, 0x3, + 0x3, 0x3, + 0x3, 0x3, + 0x3, 0x3, + 0x3, 0x2, + 0x3, 0x3, + 0x3, 0x3, + 0x3, 0x3, + 0x3, 0x3, + 0x3, 0x9, + 0x1, 0x2f, + 0x0, 0x0, + 0x2f, 0x0, + 0x0, 0x1, + 0x23, 0x4, + 0x0, 0x0, + 0x6, 0x77, + 0x1, 0xd, + 0xd, 0x0, + 0x1b, 0xf, + 0x1b, 0x44, + 0x1, 0x0, + 0x6, 0x4, + 0x5, 0x43, + 0x1f, 0x6, + 0x8, 0x8, + 0x0, 0x0, + 0x3, 0x5, + 0x13, 0x3f, + 0x1f, 0x1, + 0x5, 0x2, + 0x1e, 0x61, + 0x56, 0x2, + 0x16, 0x1, + 0xd, 0x0, + 0xb, 0xb, + 0xb, 0x3, + 0x4, 0x3, + 0x0, 0x7, + 0xe, 0x7, + 0x10, 0x0, + 0x0, 0x2, + 0x10, 0xe, + 0x4, 0x1, + 0x6, 0xf, + 0x5, 0x5, + 0x2, 0x0, + 0x6, 0x3, + 0x9, 0x1b, + 0x14, 0x0, + 0x3c, 0x0, + 0x0, 0x0, + 0x0, 0x1b, + 0x8, 0x5, + 0x34, 0x3, + 0x3c, 0x13, + 0x42, 0x1, + 0xa, 0x0, + 0x3, 0x11, + 0x18, 0x1c, + 0x1, 0x1, + 0x2, 0x3, + 0x7, 0x6, + 0x7, 0x7, + 0x7, 0x7, + 0x6, 0x9, + 0x1, 0x9, + 0xb, 0x1, + 0x2, 0x1, + 0xe, 0x0, + 0x4, 0x3, + 0x1, 0x2, + 0x0, 0x0, + 0x0, 0x0, + 0x9, 0x31, + 0x1, 0x0, + 0x4, 0x4, + 0x4, 0x4, + 0x10, 0xf, + 0x7, 0x7, + 0x2, 0x1, + 0x1, 0x1, + 0x1, 0x3, + 0x4, 0x2, + 0x0, 0x0, + 0xd, 0xa, + 0x6, 0x1, + 0x8, 0x0, + 0x18, 0x0, + 0x18, 0x2b, + 0x4, 0x2, + 0x2, 0x3, + 0x1, 0x4, + 0x5, 0x1, + 0x1, 0x1, + 0x1, 0x0, + 0x0, 0x0, + 0x0, 0x37, + 0x1, 0x0, + 0x3, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x0, 0x0, + 0x8, 0x6, + 0x2, 0x3, + 0x3, 0x0, + 0x0, 0x0, + 0x0, 0x11, + 0x0, 0x2, + 0x2, 0xf, + 0x8, 0x1, + 0x8, 0x9, + 0x10, 0x2, + 0x2, 0x2, + 0x2, 0x9, + 0x7, 0x3, + 0x0, 0x75, + 0xd, 0x0, + 0x0, 0x0, + 0x0, 0x7, + 0x8, 0x4, + 0xa, 0x6, + 0x4, 0x1, + 0x2, 0x8, + 0x2, 0x0, + 0x15, 0x15, + 0x15, 0x0, + 0x0, 0x26, + 0x1, 0xb, + 0x15, 0x5, + 0x2, 0x2, + 0x2, 0x1, + 0x15, 0x2, + 0x2, 0x2, + 0x2, 0x2, + 0x2, 0x19, + 0x0, 0x1, + 0x21, 0x1, + 0x2, 0x1, + 0x1, 0x3, + 0x1, 0x0, + 0x0, 0x4, + 0x4, 0x0, + 0x14, 0x1, + 0x1, 0x1, + 0x1, 0x2, + 0x2, 0x2, + 0x1, 0x1, + 0x5, 0x3, + 0x1, 0x12, + 0x3, 0x3, + 0xd, 0x0, + 0x11, 0x2, + 0x3, 0x3, + 0x5, 0x5, + 0x5, 0x7, + 0x2, 0x2, + 0x3, 0x2, + 0x2, 0x2, + 0x2, 0x2, + 0x2, 0x2, + 0x2, 0x2, + 0x1, 0x1, + 0x1, 0x1, + 0x4, 0x4, + 0x4, 0x2, + 0x4, 0x4, + 0x2, 0x1, + 0x4, 0x1, + 0x1, 0x67, + 0x1, 0x3, + 0x2, 0x1, + 0x1, 0x1, + 0x19, 0x19, + 0x1, 0x19, + 0x1, 0x7, + 0x1, 0x0, + 0x2, 0x10, + 0x7, 0x7, + 0x3, 0x3, + 0x1d, 0x1, + 0x1, 0x27, + 0x2, 0x3, + 0x5, 0x2, + 0x2, 0xa, + 0x0, 0x0, + 0xab, 0x85, + 0x1, 0x1, + 0x8, 0x1d, + 0x35, 0x1, + 0x1a, 0x1, + 0x35, 0x1, + 0x1, 0x1, + 0x1, 0x6f, + 0x92, 0x2, + 0x2, 0x2, + 0x2, 0x1, + 0x2, 0x1, + 0x1, 0x3, + 0xb, 0x0, + 0x0, 0x3, + 0x3, 0x3, + 0x3, 0x3, + 0x3, 0x4, + 0xc, 0x0, + 0x0, 0x1a, + 0x0, 0xf, + 0x19, 0xf, + 0x0, 0x13, + 0x13, 0x27, + 0x0, 0x14, + 0x13, 0x15, + 0x0, 0x45, + 0x11, 0x1d, + 0x1b, 0xb, + 0xb, 0x3, + 0x2, 0x1, + 0x3c, 0x3, + 0x10a, 0x42, + 0x1, 0x12, + 0x20, 0x1de, + 0x1, 0x0, + 0x3, 0x0, + 0x12, 0x18, + 0x18, 0x1c, + 0x1a, 0x0, + 0x20, 0x1e, + 0x1, 0x1, + 0x1, 0x1, + 0x1, 0x1, + 0x2, 0x4, + 0x61, 0x7, + 0x0, 0x10, + 0x35, 0x0, + 0x0, 0x0, + 0x10, 0x1f, + 0x0, 0x17, + 0x25, 0x26, + 0x1c, 0x7e, + 0x5, 0x2b, + 0x10, 0x56, + 0x47, 0x6, + 0x6, 0x1, + 0x1b, 0x0, + 0x0, 0x0, + 0x2b, 0x85, + 0x3c, 0xb, + 0x4, 0x4, + 0x6, EXTRA_PC_PORT_TEXTURE_COUNT}; +} + +const std::vector& get_jak3_tpage_dir() { + return tpage_dir; +} \ No newline at end of file diff --git a/game/graphics/texture/jak3_tpage_dir.h b/game/graphics/texture/jak3_tpage_dir.h new file mode 100644 index 00000000000..b68096098b0 --- /dev/null +++ b/game/graphics/texture/jak3_tpage_dir.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +#include "common/common_types.h" + +const std::vector& get_jak3_tpage_dir(); \ No newline at end of file diff --git a/goal_src/jak3/engine/collide/collide-shape-h.gc b/goal_src/jak3/engine/collide/collide-shape-h.gc index 5f9f8d397be..8e2fc50063d 100644 --- a/goal_src/jak3/engine/collide/collide-shape-h.gc +++ b/goal_src/jak3/engine/collide/collide-shape-h.gc @@ -91,6 +91,7 @@ (declare-type rigid-body structure) (define-extern cshape-reaction-update-state (function control-info collide-query vector none)) +(define-extern collide-shape-draw-debug-marks (function none)) ;; +++cshape-reaction-flags (defenum cshape-reaction-flags diff --git a/goal_src/jak3/engine/collide/collide-touch-h.gc b/goal_src/jak3/engine/collide/collide-touch-h.gc index 2705cd142b8..3143cb04b7a 100644 --- a/goal_src/jak3/engine/collide/collide-touch-h.gc +++ b/goal_src/jak3/engine/collide/collide-touch-h.gc @@ -114,9 +114,9 @@ storing a record of the primitives involved." (:methods (new (symbol type) _type_) (touching-list-method-9 () none) - (touching-list-method-10 () none) + (free-nodes (_type_) none) (touching-list-method-11 () none) - (touching-list-method-12 () none) + (send-events-for-touching-shapes (_type_) none) (touching-list-method-13 () none) ) ) diff --git a/goal_src/jak3/engine/collide/collide.gc b/goal_src/jak3/engine/collide/collide.gc index 0d3cb5ad88c..94f6615e3ef 100644 --- a/goal_src/jak3/engine/collide/collide.gc +++ b/goal_src/jak3/engine/collide/collide.gc @@ -5,5 +5,7 @@ ;; name in dgo: collide ;; dgos: GAME +(define-extern *collide-vif0-init* (array uint32)) + ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/collide/main-collide.gc b/goal_src/jak3/engine/collide/main-collide.gc index 863536c85be..9986bb57f54 100644 --- a/goal_src/jak3/engine/collide/main-collide.gc +++ b/goal_src/jak3/engine/collide/main-collide.gc @@ -7,3 +7,191 @@ ;; DECOMP BEGINS +(defun drawable-sphere-box-intersect? ((arg0 drawable) (arg1 bounding-box4w)) + (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128) (a0-1 uint128) (a1-2 uint128) (a2-0 uint128)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (nop!) + (nop!) + (.lvf vf1 (&-> arg0 bsphere quad)) + (.add.w.vf vf2 vf1 vf1 :mask #b111) + (let ((v1-0 (-> arg1 min quad))) + (.sub.w.vf vf1 vf1 vf1 :mask #b111) + (let ((a1-1 (-> arg1 max quad))) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf3 vf1) + (nop!) + (.mov a0-1 vf4) + (nop!) + (.mov a2-0 vf3) + (nop!) + (.pcgtw a1-2 a2-0 a1-1) + ) + (nop!) + (.pcgtw v1-1 v1-0 a0-1) + ) + (nop!) + (.por v1-2 a1-2 v1-1) + (nop!) + (.ppach v1-3 (the-as uint128 0) v1-2) + (nop!) + (let ((v1-4 (shl (the-as int v1-3) 16))) + (nop!) + (zero? v1-4) + ) + ) + ) + +(defun instance-sphere-box-intersect? ((arg0 drawable) (arg1 instance-tie) (arg2 bounding-box4w)) + (local-vars + (v1-3 uint128) + (v1-4 uint128) + (v1-5 uint128) + (a0-2 uint128) + (a1-2 uint128) + (a2-1 uint128) + (a3-1 uint128) + (a3-3 uint128) + (a3-4 uint128) + (t0-1 uint128) + (t0-2 uint128) + (t1-0 uint128) + (t2-1 uint128) + (t2-2 uint128) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (nop!) + (let ((v1-0 (-> arg1 max-scale))) + (nop!) + (let ((a3-0 (the-as uint128 (-> arg1 origin long 3)))) + (nop!) + (let ((t2-0 (the-as uint128 (-> arg1 origin long 0)))) + (.pextlh a3-1 a3-0 0) + (let ((t0-0 (the-as uint128 (-> arg1 origin long 1)))) + (.pw.sra t1-0 a3-1 10) + (let ((a3-2 (the-as uint128 (-> arg1 origin long 2)))) + (.pextlh t2-1 t2-0 0) + (nop!) + (.pw.sra t2-2 t2-1 16) + (nop!) + (.pextlh t0-1 t0-0 0) + (.mov vf8 t1-0) + (.pw.sra t0-2 t0-1 16) + (.mov vf5 t2-2) + (.pextlh a3-3 a3-2 0) + ) + ) + ) + ) + (.mov vf6 t0-2) + (.pw.sra a3-4 a3-3 16) + (.lvf vf9 (&-> arg1 bsphere quad)) + (nop!) + (.mov vf7 a3-4) + (nop!) + (.mov vf10 v1-0) + ) + (.itof.vf vf8 vf8) + (nop!) + (vitof12.xyzw vf5 vf5) + (nop!) + (vitof12.xyzw vf6 vf6) + (nop!) + (vitof12.xyzw vf7 vf7) + (nop!) + (.add.vf vf8 vf8 vf9 :mask #b111) + (nop!) + (nop!) + (.lvf vf9 (&-> arg0 bsphere quad)) + (vitof12.xyzw vf10 vf10) + (nop!) + (.mul.w.vf vf10 vf10 vf9 :mask #b1) + (nop!) + (.mul.x.vf acc vf5 vf9) + (nop!) + (.add.mul.y.vf acc vf6 vf9 acc) + (let ((v1-2 (-> arg2 min quad))) + (.add.mul.z.vf acc vf7 vf9 acc) + (let ((a1-1 (-> arg2 max quad))) + (.add.mul.w.vf vf1 vf8 vf0 acc) + (nop!) + (.add.x.vf vf2 vf1 vf10 :mask #b111) + (nop!) + (.sub.x.vf vf1 vf1 vf10 :mask #b111) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf3 vf1) + (nop!) + (.mov a0-2 vf4) + (nop!) + (.mov a2-1 vf3) + (nop!) + (.pcgtw a1-2 a2-1 a1-1) + ) + (nop!) + (.pcgtw v1-3 v1-2 a0-2) + ) + (nop!) + (.por v1-4 a1-2 v1-3) + (nop!) + (.ppach v1-5 (the-as uint128 0) v1-4) + (nop!) + (let ((v1-6 (shl (the-as int v1-5) 16))) + (nop!) + (zero? v1-6) + ) + ) + ) + +(defun instance-tfragment-add-debug-sphere ((arg0 drawable) (arg1 instance-tie)) + (local-vars (v1-1 uint128) (v1-2 uint128) (a3-0 float)) + (rlet ((vf0 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (nop!) + (let ((v1-0 (the-as uint128 (-> arg1 origin long 3)))) + (.pextlh v1-1 v1-0 0) + ) + (.lvf vf9 (&-> arg0 bsphere quad)) + (.pw.sra v1-2 v1-1 10) + (.lvf vf10 (&-> arg1 bsphere quad)) + (nop!) + (.mov vf12 v1-2) + (.itof.vf vf12 vf12) + (nop!) + (.add.vf vf10 vf10 vf12 :mask #b111) + (nop!) + (.add.vf vf9 vf9 vf10 :mask #b111) + (nop!) + (.add.w.vf vf11 vf0 vf9 :mask #b1) + (nop!) + (.mov a3-0 vf11) + (nop!) + (let ((a2-0 (new-stack-vector0))) + (.svf (&-> a2-0 quad) vf9) + (add-debug-sphere #t (bucket-id bucket583) a2-0 a3-0 (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)) + ) + ) + ) diff --git a/goal_src/jak3/engine/draw/drawable-group.gc b/goal_src/jak3/engine/draw/drawable-group.gc index 179caf55839..76124ebcbe7 100644 --- a/goal_src/jak3/engine/draw/drawable-group.gc +++ b/goal_src/jak3/engine/draw/drawable-group.gc @@ -7,3 +7,98 @@ ;; DECOMP BEGINS +(defmethod new drawable-group ((allocation symbol) (type-to-make type) (arg0 int)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* arg0 4)))))) + (set! (-> v0-0 length) arg0) + v0-0 + ) + ) + +(defmethod print ((this drawable-group)) + (format #t "#<~A @ #x~X [~D]" (-> this type) this (-> this length)) + (dotimes (s5-0 (-> this length)) + (format #t " ~A" (-> this data s5-0)) + ) + (format #t ">") + this + ) + +(defmethod length ((this drawable-group)) + (-> this length) + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this drawable-group)) + (the-as int (+ (-> drawable-group size) (* (-> this length) 4))) + ) + +(defmethod mem-usage ((this drawable-group) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 1 (-> usage length))) + (set! (-> usage data 0 name) "drawable-group") + (+! (-> usage data 0 count) 1) + (let ((v1-6 (asize-of this))) + (+! (-> usage data 0 used) v1-6) + (+! (-> usage data 0 total) (logand -16 (+ v1-6 15))) + ) + (dotimes (s3-0 (-> this length)) + (mem-usage (-> this data s3-0) usage flags) + ) + this + ) + +(defmethod login ((this drawable-group)) + "Initialize the object after it is loaded." + (dotimes (s5-0 (-> this length)) + (login (-> this data s5-0)) + ) + this + ) + +(defmethod draw ((this drawable-group)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + (when (vis-cull (-> this id)) + (when (sphere-cull (-> this bsphere)) + (dotimes (s5-0 (-> this length)) + (draw (-> this data s5-0)) + ) + ) + ) + 0 + (none) + ) + +(defmethod collect-stats ((this drawable-group)) + "Collect triangle/perf statistics for rendering. + This is only called when viewing stats. + The vis-bits and culling registers are loaded during this time." + (when (vis-cull (-> this id)) + (when (sphere-cull (-> this bsphere)) + (dotimes (s5-0 (-> this length)) + (collect-stats (-> this data s5-0)) + ) + ) + ) + 0 + (none) + ) + +(defmethod debug-draw ((this drawable-group)) + "Debug-draw a drawable and its children. Typically uses the debug-draw functions." + (when (vis-cull (-> this id)) + (when (sphere-cull (-> this bsphere)) + (dotimes (s5-0 (-> this length)) + (debug-draw (-> this data s5-0)) + ) + ) + ) + 0 + (none) + ) + +(defmethod unpack-vis ((this drawable-group) (arg0 (pointer int8)) (arg1 (pointer int8))) + (dotimes (s4-0 (-> this length)) + (set! arg1 (unpack-vis (-> this data s4-0) arg0 arg1)) + ) + arg1 + ) diff --git a/goal_src/jak3/engine/draw/drawable-h.gc b/goal_src/jak3/engine/draw/drawable-h.gc index dc3f33120a7..ae2e51af976 100644 --- a/goal_src/jak3/engine/draw/drawable-h.gc +++ b/goal_src/jak3/engine/draw/drawable-h.gc @@ -26,8 +26,8 @@ control over memory layout for use with DMA." (:methods (login (_type_) _type_) (draw (_type_) none) - (drawable-method-11 () none) - (drawable-method-12 () none) + (drawable-method-11 (_type_) none) + (drawable-method-12 (_type_) none) (collect-stats (_type_) none) (debug-draw (_type_) none) (unpack-vis (_type_ (pointer int8) (pointer int8)) (pointer int8)) diff --git a/goal_src/jak3/engine/draw/drawable-inline-array.gc b/goal_src/jak3/engine/draw/drawable-inline-array.gc index 0720a85c9a1..f24a0b98136 100644 --- a/goal_src/jak3/engine/draw/drawable-inline-array.gc +++ b/goal_src/jak3/engine/draw/drawable-inline-array.gc @@ -7,3 +7,32 @@ ;; DECOMP BEGINS +(defmethod length ((this drawable-inline-array)) + (-> this length) + ) + +(defmethod login ((this drawable-inline-array)) + "Initialize the object after it is loaded." + this + ) + +(defmethod draw ((this drawable-inline-array)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + 0 + (none) + ) + +(defmethod collect-stats ((this drawable-inline-array)) + "Collect triangle/perf statistics for rendering. + This is only called when viewing stats. + The vis-bits and culling registers are loaded during this time." + 0 + (none) + ) + +(defmethod debug-draw ((this drawable-inline-array)) + "Debug-draw a drawable and its children. Typically uses the debug-draw functions." + 0 + (none) + ) diff --git a/goal_src/jak3/engine/draw/drawable-tree.gc b/goal_src/jak3/engine/draw/drawable-tree.gc index ba42cf7453e..65fe2e378c0 100644 --- a/goal_src/jak3/engine/draw/drawable-tree.gc +++ b/goal_src/jak3/engine/draw/drawable-tree.gc @@ -7,3 +7,90 @@ ;; DECOMP BEGINS +(defmethod draw ((this drawable-tree-array)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + (case (-> *level* draw-level *draw-index* display?) + (('special #f) + ) + (else + (dotimes (s5-0 (-> this length)) + (draw (-> this data s5-0)) + ) + ) + ) + 0 + (none) + ) + +(defmethod collect-stats ((this drawable-tree-array)) + "Collect triangle/perf statistics for rendering. + This is only called when viewing stats. + The vis-bits and culling registers are loaded during this time." + (dotimes (s5-0 (-> this length)) + (collect-stats (-> this data s5-0)) + ) + 0 + (none) + ) + +(defmethod debug-draw ((this drawable-tree-array)) + "Debug-draw a drawable and its children. Typically uses the debug-draw functions." + (dotimes (s5-0 (-> this length)) + (debug-draw (-> this data s5-0)) + ) + 0 + (none) + ) + +(defmethod unpack-vis ((this drawable-tree) (arg0 (pointer int8)) (arg1 (pointer int8))) + (local-vars (t5-1 uint)) + (let* ((v1-0 (the-as drawable-inline-array-node (-> this data 0))) + (a3-1 (/ (-> v1-0 data 0 id) 8)) + (t0-0 (-> v1-0 length)) + (v1-1 (&+ arg0 a3-1)) + (a3-3 (/ (+ t0-0 7) 8)) + ) + (dotimes (t0-1 a3-3) + (let ((t1-0 (-> arg1 0))) + (set! arg1 (&-> arg1 1)) + (set! (-> v1-1 0) t1-0) + ) + (set! v1-1 (&-> v1-1 1)) + ) + ) + (let ((v1-5 (+ (-> this length) -1))) + (when (nonzero? v1-5) + (dotimes (a3-5 v1-5) + (let* ((t0-4 (-> this data a3-5)) + (t2-0 (the-as drawable-inline-array-node (-> this data (+ a3-5 1)))) + (t1-5 (/ (-> (the-as drawable-inline-array-node t0-4) data 0 id) 8)) + (t2-2 (/ (-> t2-0 data 0 id) 8)) + (t0-5 (-> (the-as drawable-inline-array-node t0-4) length)) + (t1-6 (&+ arg0 t1-5)) + (t2-3 (the-as object (&+ arg0 t2-2))) + ) + (loop + (let ((t3-0 (-> t1-6 0))) + (set! t1-6 (&-> t1-6 1)) + (let ((t4-0 128)) + (label cfg-7) + (b! (not (logtest? t3-0 t4-0)) cfg-9 :delay (set! t5-1 (the-as uint (-> arg1 0)))) + (set! arg1 (&-> arg1 1)) + (set! (-> (the-as (pointer int8) t2-3) 0) (the-as int t5-1)) + (label cfg-9) + (+! t0-5 -1) + (b! (zero? t0-5) cfg-12 :delay (shift-arith-right-32 t4-0 t4-0 1)) + (b! (nonzero? (the-as uint t4-0)) cfg-7 :delay (set! t2-3 (&-> (the-as (pointer int8) t2-3) 1))) + ) + ) + ) + ) + (label cfg-12) + (nop!) + 0 + ) + ) + ) + arg1 + ) diff --git a/goal_src/jak3/engine/draw/drawable.gc b/goal_src/jak3/engine/draw/drawable.gc index aa165ec06c9..aa0e16a9b2b 100644 --- a/goal_src/jak3/engine/draw/drawable.gc +++ b/goal_src/jak3/engine/draw/drawable.gc @@ -5,5 +5,2199 @@ ;; name in dgo: drawable ;; dgos: GAME +(defmacro spr-work () + `(the work-area *fake-scratchpad-data*)) + +(define-extern draw-vortex (function none)) ;; doesn't exist in jak 3!! + ;; DECOMP BEGINS +;; ERROR: Bad vector register dependency: vf16 +;; ERROR: Bad vector register dependency: vf17 +;; ERROR: Bad vector register dependency: vf18 +;; ERROR: Bad vector register dependency: vf19 +(defun sphere-cull ((arg0 vector)) + "Is this sphere visible? Uses cached camera matrix registers, so use with care." + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf9 :class vf) + ) + ;; og:preserve-this modified for PC: these register would be loaded by the draw method of bsp. + (let ((at-0 *math-camera*)) + (.lvf vf16 (&-> at-0 plane 0 quad)) + (.lvf vf17 (&-> at-0 plane 1 quad)) + (.lvf vf18 (&-> at-0 plane 2 quad)) + (.lvf vf19 (&-> at-0 plane 3 quad)) + ) + (init-vf0-vector) + (.lvf vf10 (&-> arg0 quad)) + (.mul.x.vf acc vf16 vf10) + (.add.mul.y.vf acc vf17 vf10 acc) + (.add.mul.z.vf acc vf18 vf10 acc) + (.sub.mul.w.vf vf9 vf19 vf0 acc) + (.add.w.vf vf9 vf9 vf10) + (.mov v1-0 vf9) + (.pcgtw v1-1 0 v1-0) + (.ppach v1-2 (the-as uint128 0) v1-1) + (zero? (the-as int v1-2)) + ) + ) + +;; ERROR: Bad vector register dependency: vf20 +;; ERROR: Bad vector register dependency: vf21 +;; ERROR: Bad vector register dependency: vf22 +;; ERROR: Bad vector register dependency: vf23 +(defun guard-band-cull ((arg0 vector)) + "Is this sphere within the guard band, and maybe needs clipping? Uses cached camera matrix registers, so use with care." + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf20 :class vf) + (vf21 :class vf) + (vf22 :class vf) + (vf23 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + ;; og:preserve-this modified for PC: these registers would be loaded in dma-add-process-drawable + (let ((at-0 *math-camera*)) + (.lvf vf20 (&-> at-0 guard-plane 0 quad)) + (.lvf vf21 (&-> at-0 guard-plane 1 quad)) + (.lvf vf22 (&-> at-0 guard-plane 2 quad)) + (.lvf vf23 (&-> at-0 guard-plane 3 quad)) + ) + (.lvf vf10 (&-> arg0 quad)) + (.mul.x.vf acc vf20 vf10) + (.add.mul.y.vf acc vf21 vf10 acc) + (.add.mul.z.vf acc vf22 vf10 acc) + (.sub.mul.w.vf vf9 vf23 vf0 acc) + (.sub.w.vf vf9 vf9 vf10) + (.mov v1-0 vf9) + (.pcgtw v1-1 0 v1-0) + (.ppach v1-2 (the-as uint128 0) v1-1) + (nonzero? (the-as int v1-2)) + ) + ) + +(defun sphere-in-view-frustum? ((arg0 sphere)) + "Check if sphere is in view frustum. Uses math-camera, so doesn't need register setup." + (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 *math-camera*)) + (.lvf vf6 (&-> arg0 quad)) + (.lvf vf1 (&-> v1-0 plane 0 quad)) + (.lvf vf2 (&-> v1-0 plane 1 quad)) + (.lvf vf3 (&-> v1-0 plane 2 quad)) + (.lvf vf4 (&-> v1-0 plane 3 quad)) + ) + (.mul.x.vf acc vf1 vf6) + (.add.mul.y.vf acc vf2 vf6 acc) + (.add.mul.z.vf acc vf3 vf6 acc) + (.sub.mul.w.vf vf5 vf4 vf0 acc) + (.add.w.vf vf5 vf5 vf6) + (.mov v1-1 vf5) + (.pcgtw v1-2 0 v1-1) + (.ppach v1-3 (the-as uint128 0) v1-2) + (zero? (the-as int v1-3)) + ) + ) + +(defun line-in-view-frustum? ((arg0 vector) (arg1 vector)) + "Check if line is in view frustum. Uses math-camera, so doesn't need register setup." + (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128) (a0-1 uint128) (a0-2 uint128) (a0-3 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 *math-camera*)) + (.lvf vf9 (&-> arg0 quad)) + (.lvf vf10 (&-> arg1 quad)) + (.lvf vf16 (&-> v1-0 plane 0 quad)) + (.lvf vf17 (&-> v1-0 plane 1 quad)) + (.lvf vf18 (&-> v1-0 plane 2 quad)) + (.lvf vf19 (&-> v1-0 plane 3 quad)) + ) + (.mul.x.vf acc vf16 vf9) + (.add.mul.y.vf acc vf17 vf9 acc) + (.add.mul.z.vf acc vf18 vf9 acc) + (.sub.mul.w.vf vf9 vf19 vf0 acc) + (.mul.x.vf acc vf16 vf10) + (.add.mul.y.vf acc vf17 vf10 acc) + (.add.mul.z.vf acc vf18 vf10 acc) + (.sub.mul.w.vf vf10 vf19 vf0 acc) + (.mov v1-1 vf9) + (.pcgtw v1-2 0 v1-1) + (.ppach v1-3 (the-as uint128 0) v1-2) + (.mov a0-1 vf10) + (.pcgtw a0-2 0 a0-1) + (.ppach a0-3 (the-as uint128 0) a0-2) + (not (logtest? (the-as int v1-3) (the-as int a0-3))) + ) + ) + +;; ERROR: failed type prop at 3: Could not figure out load: (set! v1 (l.b (+ v1 #x3800))) +;; WARN: Return type mismatch none vs symbol. +;; ERROR: Unsupported inline assembly instruction kind - [addiu a0, a0, 56] +(defun vis-cull ((id int)) + "Is this thing visible in the precomputed visiblity data? By draw-node id. + Assumes the scratchpad has the vis-list loaded." + (let* ((vis-byte (-> (spr-work) background vis-list (/ id 8))) ;; vis byte + (shift-amount (+ 56 (logand id 7))) + (shifted (shl vis-byte shift-amount)) + ) + (< (the-as int shifted) 0) + ) + ) + + +;; ERROR: Failed load: (set! v1-2 (l.b (+ v1-1 #x3800))) at op 2 +;; ERROR: Unsupported inline assembly instruction kind - [addiu a0, a0, 56] +(defun-debug vis-cull-debug ((a0-0 work-area) (id int)) + "Like vis-cull, but you can specify a different work-area. + Unused." + (let* ((vis-byte (-> a0-0 background vis-list (/ id 8))) ;; vis byte + (shift-amount (+ 56 (logand id 7))) + (shifted (shl vis-byte shift-amount)) + ) + (< (the-as int shifted) 0) + ) + ) + +(defun error-sphere ((arg0 drawable-error) (arg1 string)) + "Draw an error sphere and text for a drawable-error." + (when *artist-error-spheres* + (when (vis-cull (-> arg0 id)) + (when (sphere-cull (-> arg0 bsphere)) + (add-debug-sphere + #t + (bucket-id bucket583) + (-> arg0 bsphere) + (-> arg0 bsphere w) + (new 'static 'rgba :r #x80 :a #x80) + ) + (add-debug-text-3d + #t + (bucket-id debug-no-zbuf1) + arg1 + (-> arg0 bsphere) + (font-color white) + (the-as vector2h #f) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod login ((this drawable)) + "Initialize the object after it is loaded." + this + ) + +(defmethod draw ((this drawable)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + 0 + (none) + ) + +(defmethod drawable-method-11 ((this drawable)) + 0 + (none) + ) + +(defmethod drawable-method-12 ((this drawable)) + 0 + (none) + ) + +(defmethod collect-regions ((this drawable) (arg0 sphere) (arg1 int) (arg2 region-prim-list)) + "Fill the region-prim-list with regions that intersect the sphere." + 0 + (none) + ) + +(defmethod collect-stats ((this drawable)) + "Collect triangle/perf statistics for rendering. + This is only called when viewing stats. + The vis-bits and culling registers are loaded during this time." + 0 + (none) + ) + +(defmethod debug-draw ((this drawable)) + "Debug-draw a drawable and its children. Typically uses the debug-draw functions." + 0 + (none) + ) + +(defmethod draw ((this drawable-error)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + (error-sphere this (-> this name)) + 0 + (none) + ) + +(defmethod unpack-vis ((this drawable) (arg0 (pointer int8)) (arg1 (pointer int8))) + arg1 + ) + +(define *edit-instance* (the-as string #f)) + +(when *debug-segment* +(define *instance-mem-usage* (new 'debug 'memory-usage-block)) + +) +(defun find-instance-by-name-level ((arg0 string) (arg1 level)) + "Find shrub or tie prototype by name in a level. + Yes it says instance. No it does not return an instance." + (let ((s5-0 (-> arg1 bsp drawable-trees))) + (dotimes (s4-0 (-> s5-0 length)) + (let ((v1-3 (-> s5-0 data s4-0))) + (case (-> v1-3 type) + ((drawable-tree-instance-shrub) + (let ((s3-0 (-> (the-as drawable-tree-instance-shrub v1-3) info prototype-inline-array-shrub))) + (dotimes (s2-0 (-> s3-0 length)) + (if (string= arg0 (-> s3-0 data s2-0 name)) + (return (-> s3-0 data s2-0)) + ) + ) + ) + ) + ((drawable-tree-instance-tie) + (let ((s3-1 (-> (the-as drawable-tree-instance-tie v1-3) prototypes prototype-array-tie))) + (dotimes (s2-1 (-> s3-1 length)) + (if (string= arg0 (-> s3-1 array-data s2-1 name)) + (return (-> s3-1 array-data s2-1)) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as prototype-bucket #f) + ) + +(defun find-instance-by-name ((arg0 string)) + "Find shrub or tie prototype by name in any level. + Yes it says instance. No it does not return an instance." + (dotimes (s5-0 (-> *level* length)) + (let ((a1-0 (-> *level* level s5-0))) + (when (= (-> a1-0 status) 'active) + (let ((a0-4 (find-instance-by-name-level arg0 a1-0))) + (if a0-4 + (return a0-4) + ) + ) + ) + ) + ) + (the-as prototype-bucket #f) + ) + +(defun prototypes-game-visible-set! ((arg0 pair) (arg1 symbol) (arg2 level)) + "Disable collision/visibilty of tie/shrub based on a list of prototype names. + Only looks in the given level." + (let ((a0-1 (car arg0))) + (while (not (null? arg0)) + (let ((v1-0 (find-instance-by-name-level (the-as string a0-1) arg2))) + (when v1-0 + (if arg1 + (logclear! (-> v1-0 flags) (prototype-flags visible no-collide)) + (logior! (-> v1-0 flags) (prototype-flags visible no-collide)) + ) + ) + ) + (set! arg0 (cdr arg0)) + (set! a0-1 (car arg0)) + ) + ) + 0 + ) + +(defun-debug find-instance-by-index ((arg0 type) (arg1 int) (arg2 bsp-header)) + (dotimes (v1-0 (-> *level* length)) + (let ((a3-3 (-> *level* level v1-0))) + (when (= (-> a3-3 status) 'active) + (let ((a3-4 (-> a3-3 bsp))) + (when (or (not arg2) (= a3-4 arg2)) + (let ((a3-5 (-> a3-4 drawable-trees))) + (dotimes (t0-5 (-> a3-5 length)) + (let ((t1-3 (-> a3-5 data t0-5))) + (case (-> t1-3 type) + ((drawable-tree-instance-shrub) + (when (= arg0 (-> t1-3 type)) + (let ((v1-2 (-> (the-as drawable-tree-instance-shrub t1-3) info prototype-inline-array-shrub))) + (return (-> v1-2 data arg1)) + ) + ) + ) + ((drawable-tree-instance-tie) + (when (= arg0 (-> t1-3 type)) + (let ((v1-5 (-> (the-as drawable-tree-instance-tie t1-3) prototypes prototype-array-tie))) + (return (-> v1-5 array-data arg1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as prototype-bucket #f) + ) + +(defun-debug prototype-bucket-type ((arg0 prototype-bucket)) + (case (-> arg0 geometry 1 type) + ((prototype-shrubbery shrubbery) + instance-shrubbery + ) + ((prototype-tie prototype-tie tie-fragment) + instance-tie + ) + ) + ) + +(defun-debug prototype-bucket-recalc-fields ((arg0 prototype-bucket)) + (case (prototype-bucket-type arg0) + ((instance-shrubbery) + (set! (-> arg0 rdists x) (/ 1.0 (- (-> arg0 dists w) (-> arg0 dists x)))) + ) + (else + (set! (-> arg0 dists z) (+ (-> arg0 dists x) (* 0.33333334 (- (-> arg0 dists w) (-> arg0 dists x))))) + (set! (-> arg0 rdists x) (/ 1.0 (- (-> arg0 dists z) (-> arg0 dists x)))) + ) + ) + (set! (-> arg0 rdists z) (/ 1.0 (- (-> arg0 dists w) (-> arg0 dists z)))) + (set! (-> arg0 dists y) (* 0.5 (-> arg0 dists x))) + (set! (-> arg0 rdists y) (/ 1.0 (-> arg0 dists y))) + arg0 + ) + +(defun-debug print-prototype-list () + (local-vars (sv-16 (function prototype-bucket-shrub memory-usage-block int prototype-bucket-shrub))) + (dotimes (gp-0 (-> *level* length)) + (let ((s5-0 (-> *level* level gp-0))) + (when (= (-> s5-0 status) 'active) + (format #t "-------- level ~S~%" (-> s5-0 name)) + (let ((s5-1 (-> s5-0 bsp drawable-trees))) + (dotimes (s4-0 (-> s5-1 length)) + (let ((v1-8 (-> s5-1 data s4-0))) + (case (-> v1-8 type) + ((drawable-tree-instance-shrub) + (let ((s3-0 (-> (the-as drawable-tree-instance-shrub v1-8) info prototype-inline-array-shrub))) + (dotimes (s2-0 (-> s3-0 length)) + 0 + (let ((s1-0 (-> s3-0 data s2-0))) + (dotimes (s0-0 4) + (reset! *instance-mem-usage*) + (if (nonzero? (-> s1-0 geometry s0-0)) + (mem-usage (-> s1-0 geometry s0-0) *instance-mem-usage* 0) + ) + ) + (let ((s0-1 s1-0)) + (set! sv-16 (method-of-object s0-1 mem-usage)) + (let ((a1-4 (reset! *instance-mem-usage*)) + (a2-2 0) + ) + (sv-16 s0-1 a1-4 a2-2) + ) + ) + (let ((v1-29 (calculate-total *instance-mem-usage*))) + (format + #t + " ~-48S~4D shrub ~5,,2fK ~4,,2fK~%" + (-> s1-0 name) + (-> s1-0 in-level) + (* 0.0009765625 (the float v1-29)) + (* 0.0009765625 (the float (* (the-as uint 80) (-> s1-0 in-level)))) + ) + ) + ) + ) + ) + ) + ((drawable-tree-instance-tie) + (let ((s3-1 (-> (the-as drawable-tree-instance-tie v1-8) prototypes prototype-array-tie))) + (dotimes (s2-1 (-> s3-1 length)) + 0 + (let ((s1-1 (-> s3-1 array-data s2-1))) + (reset! *instance-mem-usage*) + (dotimes (s0-2 4) + (when (nonzero? (-> s1-1 tie-geom s0-2)) + (let* ((a0-13 (-> s1-1 tie-geom s0-2)) + (t9-8 (method-of-object a0-13 mem-usage)) + (a1-7 *instance-mem-usage*) + (v1-47 s0-2) + ) + (t9-8 a0-13 a1-7 (logior (cond + ((= v1-47 1) + 4 + ) + ((= v1-47 2) + 8 + ) + ((= v1-47 3) + 16 + ) + (else + 0 + ) + ) + 2 + ) + ) + ) + ) + ) + (mem-usage s1-1 *instance-mem-usage* 0) + (let ((v1-54 (calculate-total *instance-mem-usage*))) + (format + #t + " ~-48S~4D tie ~5,,2fK ~4,,2fK~%" + (-> s1-1 name) + (-> s1-1 in-level) + (* 0.0009765625 (the float v1-54)) + (* 0.0009765625 (the float (* (-> s1-1 in-level) 64))) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun-debug draw-instance-info ((arg0 string)) + (local-vars + (sv-16 uint) + (sv-32 uint) + (sv-48 uint) + (sv-64 int) + (sv-80 int) + (sv-96 int) + (sv-112 int) + (sv-128 int) + (sv-144 int) + ) + (when (and *display-instance-info* *edit-instance*) + (let ((s5-0 (find-instance-by-name *edit-instance*))) + (when s5-0 + (dotimes (s4-0 (-> *level* length)) + (let ((v1-5 (-> *level* level s4-0))) + (when (= (-> v1-5 status) 'active) + (let ((s3-0 (-> v1-5 bsp drawable-trees))) + (dotimes (s2-0 (-> s3-0 length)) + (let ((v1-9 (-> s3-0 data s2-0))) + (case (-> v1-9 type) + ((drawable-tree-instance-shrub) + ) + ((drawable-tree-instance-tie) + (let ((s1-0 (-> (the-as + drawable-tree-instance-tie + (+ (* (+ (-> (the-as drawable-tree-instance-tie v1-9) length) -1) 4) (the-as int v1-9)) + ) + data + 0 + ) + ) + ) + (dotimes (s0-0 (-> (the-as drawable-inline-array-instance-tie s1-0) length)) + (if (string= (-> (the-as drawable-inline-array-instance-tie s1-0) data s0-0 bucket-ptr name) *edit-instance*) + (add-debug-sphere + #t + (bucket-id debug-no-zbuf1) + (the-as + vector + (+ (the-as uint (-> (the-as drawable-inline-array-instance-tie s1-0) data 0 bsphere)) (* s0-0 64)) + ) + (-> (the-as drawable-inline-array-instance-tie s1-0) data s0-0 bsphere w) + (new 'static 'rgba :g #xff :a #x80) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let ((s2-1 (prototype-bucket-type s5-0))) + (let ((s4-1 0)) + 0 + (cond + ((= s2-1 instance-shrubbery) + (set! s4-1 80) + ) + ((= s2-1 instance-tie) + (reset! *instance-mem-usage*) + (dotimes (s4-2 4) + (when (nonzero? (-> s5-0 geometry s4-2)) + (let* ((a0-17 (-> s5-0 geometry s4-2)) + (t9-5 (method-of-object a0-17 mem-usage)) + (a1-6 *instance-mem-usage*) + (v1-40 s4-2) + ) + (t9-5 a0-17 a1-6 (logior (cond + ((= v1-40 1) + 4 + ) + ((= v1-40 2) + 8 + ) + ((= v1-40 3) + 16 + ) + (else + 0 + ) + ) + 2 + ) + ) + ) + ) + ) + (set! s4-1 (+ (calculate-total *instance-mem-usage*) 64)) + ) + ) + (mem-usage s5-0 (reset! *instance-mem-usage*) 0) + (let ((v1-50 (calculate-total *instance-mem-usage*))) + (format + arg0 + "~%~A ~A b @ #x~X ~,,2fK/~,,2fK~%" + s2-1 + (-> s5-0 name) + s5-0 + (* 0.0009765625 (the float v1-50)) + (* 0.0009765625 (the float s4-1)) + ) + ) + ) + (format arg0 "near: ~m mid: ~m far: ~m~%" (-> s5-0 dists x) (-> s5-0 dists z) (-> s5-0 dists w)) + (let ((s3-2 0) + (s4-3 0) + ) + (cond + ((= s2-1 instance-shrubbery) + (let ((f30-0 0.0)) + (format + arg0 + "usage: vis: ~D shrub: ~D trans-shrub ~D bill: ~D in level: ~D~%" + (-> (the-as prototype-bucket-shrub s5-0) count 0) + (-> (the-as prototype-bucket-shrub s5-0) count 1) + (-> (the-as prototype-bucket-shrub s5-0) count 2) + (-> (the-as prototype-bucket-shrub s5-0) count 3) + (-> (the-as prototype-bucket-shrub s5-0) in-level) + ) + (format arg0 "~%frag# tris dverts strlen tex~%") + (let ((s1-2 (the-as prototype-shrubbery (-> (the-as prototype-bucket-shrub s5-0) geometry 1))) + (s2-2 (+ (-> (the-as prototype-bucket-shrub s5-0) count 1) (-> (the-as prototype-bucket-shrub s5-0) count 2))) + ) + (dotimes (s0-1 (-> s1-2 length)) + (set! sv-16 (shrub-num-tris (-> s1-2 data s0-1))) + (set! sv-32 (-> s1-2 data s0-1 header data 2)) + (set! sv-48 (-> s1-2 data s0-1 header data 0)) + (format + arg0 + "~5D ~4D ~5D ~6f ~D~%" + s0-1 + sv-16 + sv-32 + (/ (* 2.0 (the float sv-16)) (the float (- sv-32 sv-16))) + sv-48 + ) + (+! s3-2 sv-16) + (+! s4-3 sv-32) + (set! f30-0 + (+ 29.0 + (* 5.5 (the float (- sv-32 sv-16))) + (* 22.0 (the float sv-48)) + (* 8.0 (the float sv-32)) + (* 53.0 (the float (/ (+ s2-2 9) (the-as uint 10)))) + (* (the float s2-2) (+ 15.0 (* 5.0 (the float sv-48)) (* 13.5 (the float sv-32)))) + f30-0 + ) + ) + ) + (format + arg0 + "total ~4D ~5D ~6f ~D speed: ~f~%" + s3-2 + s4-3 + (/ (* 2.0 (the float s3-2)) (the float (- s4-3 s3-2))) + (-> s5-0 utextures) + (/ f30-0 (* (the float s2-2) (the float s3-2))) + ) + ) + ) + ) + ((= s2-1 instance-tie) + (set! sv-144 0) + (let ((s1-3 0) + (s0-2 0) + (s2-3 0) + ) + (format arg0 "~%level visible frags tris dverts strlen tex ttris~%") + (set! sv-64 1) + (set! sv-80 3) + (while (>= sv-80 sv-64) + (let ((v1-100 (-> (the-as prototype-bucket-tie s5-0) tie-geom sv-64))) + (set! sv-96 0) + (set! sv-112 0) + (set! sv-128 0) + (dotimes (a0-36 (-> v1-100 length)) + (set! sv-96 (+ sv-96 (-> v1-100 data a0-36 debug num-tris))) + (set! sv-112 (+ sv-112 (-> v1-100 data a0-36 debug num-dverts))) + (set! sv-128 (+ sv-128 (-> v1-100 data a0-36 tex-count))) + ) + (set! sv-144 (+ sv-144 (-> (the-as prototype-bucket-tie s5-0) count sv-64))) + (format + arg0 + "~5D ~7D ~5D ~5D" + sv-64 + (-> (the-as prototype-bucket-tie s5-0) count sv-64) + (-> v1-100 length) + sv-96 + ) + ) + (format + arg0 + " ~5D ~6f ~3D ~5D~%" + sv-112 + (/ (* 2.0 (the float sv-96)) (the float (- sv-112 sv-96))) + sv-128 + (* (the-as uint sv-96) (-> (the-as prototype-bucket-tie s5-0) count sv-64)) + ) + (+! s1-3 (* (the-as uint sv-96) (-> (the-as prototype-bucket-tie s5-0) count sv-64))) + (+! s0-2 (* (the-as uint sv-112) (-> (the-as prototype-bucket-tie s5-0) count sv-64))) + (+! s3-2 sv-96) + (+! s4-3 sv-112) + (+! s2-3 sv-128) + (set! sv-64 (+ sv-64 1)) + ) + (let ((t9-20 format) + (a0-52 arg0) + (a1-28 "total ~7D/~3D ~5D") + (a3-12 (-> s5-0 in-level)) + ) + (t9-20 a0-52 a1-28 sv-144 a3-12 s3-2) + ) + (format + arg0 + " ~5D ~6f ~3D ~5D~%" + s4-3 + (/ (* 2.0 (the float s1-3)) (the float (- s0-2 s1-3))) + s2-3 + s1-3 + ) + ) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch uint vs none. +(defun-debug set-shadow-by-name ((arg0 string) (arg1 int) (arg2 int)) + "Modify the shadow values for a process." + (let ((v1-0 (process-by-name arg0 *active-pool*))) + (when v1-0 + (let ((v1-1 (-> (the-as process-drawable v1-0) draw))) + (cond + ((< arg2 16) + (logior! (-> v1-1 shadow-mask) (ash 1 arg1)) + (logclear! (-> v1-1 shadow-values) (ash 15 (* arg1 4))) + (logior! (-> v1-1 shadow-values) (ash arg2 (* arg1 4))) + ) + (else + (logclear! (-> v1-1 shadow-mask) (ash 1 arg1)) + (logclear! (-> v1-1 shadow-values) (ash 15 (* arg1 4))) + ) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun-debug get-shadow-by-name ((arg0 string)) + "Print to stdout the mask/values for the given process shadows" + (let ((v1-0 (process-by-name arg0 *active-pool*))) + (when v1-0 + (let ((s5-0 (-> (the-as process-drawable v1-0) draw))) + (format 0 "actor ~s {~%" arg0) + (format 0 " SHADOW_MASK(0x~02x)~%" (-> s5-0 shadow-mask)) + (format 0 " SHADOW_VALUES(0x~08x)~%" (-> s5-0 shadow-values)) + ) + (format 0 "}~%") + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun-debug teleport-camera-by-name ((arg0 string)) + "Move camera to entity by name" + (let* ((gp-0 (entity-by-name arg0)) + (v1-0 (if (type? gp-0 entity-actor) + gp-0 + ) + ) + ) + (if (and v1-0 *camera*) + (send-event *camera* 'teleport-to-vector-start-string (-> v1-0 trans)) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun-debug teleport-camera-by-pos ((arg0 float) (arg1 float) (arg2 float)) + "Move camera to position" + (let ((v1-0 (new 'stack-no-clear 'vector))) + (when *camera* + (set-vector! v1-0 (* 4096.0 arg0) (* 4096.0 arg1) (* 4096.0 arg2) 1.0) + (send-event *camera* 'teleport-to-vector-start-string v1-0) + ) + ) + (none) + ) + +;; WARN: Return type mismatch float vs none. +(defun calc-vu1-shadow ((arg0 light-group) (arg1 draw-control)) + "Update shadow-ctrl based on lights" + (rlet ((acc :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (s5-0 (-> arg1 shadow-ctrl settings shadow-dir)) + (f30-0 (-> arg1 shadow-ctrl settings shadow-dir w)) + ) + (.lvf vf1 (&-> arg0 dir0 direction quad)) + (.lvf vf2 (&-> arg0 dir1 direction quad)) + (.lvf vf3 (&-> arg0 dir2 direction quad)) + (.lvf vf4 (&-> arg0 dir0 extra quad)) + (.lvf vf5 (&-> arg0 dir1 extra quad)) + (.lvf vf6 (&-> arg0 dir2 extra quad)) + (.mul.x.vf acc vf1 vf4) + (.add.mul.x.vf acc vf2 vf5 acc) + (.add.mul.x.vf vf1 vf3 vf6 acc) + (.svf (&-> s4-0 quad) vf1) + (vector-normalize! s4-0 -1.0) + (when (< (- (-> s4-0 y)) 0.9063) + (let* ((f0-2 0.4226) + (f1-1 (-> s4-0 x)) + (f1-3 (* f1-1 f1-1)) + (f2-0 (-> s4-0 z)) + (f0-3 (/ f0-2 (sqrtf (+ f1-3 (* f2-0 f2-0))))) + ) + (set! (-> s4-0 x) (* (-> s4-0 x) f0-3)) + (set! (-> s4-0 y) -0.9063) + (set! (-> s4-0 z) (* (-> s4-0 z) f0-3)) + ) + ) + (cond + ((logtest? (-> arg1 shadow-ctrl settings flags) (shadow-flags shdf08)) + (set! (-> s5-0 quad) (-> s4-0 quad)) + ) + (else + (when (not (paused?)) + (vector-seek! s5-0 s4-0 (* 0.2 (seconds-per-frame))) + (vector-normalize! s5-0 1.0) + ) + ) + ) + (set! (-> arg1 shadow-ctrl settings shadow-dir w) f30-0) + ) + (none) + ) + ) + +;; WARN: Return type mismatch symbol vs none. +;; ERROR: Unsupported inline assembly instruction kind - [srl v1, v1, 24] +(defun calc-shadow-masks ((arg0 light-group) (arg1 draw-control) (arg2 uint)) + (local-vars (v1-25 uint) (v1-26 int) (sv-64 light-hash) (sv-68 vector) (sv-72 mood-context) (sv-76 pointer)) + (let ((s5-0 (the-as (array float) (new 'stack 'boxed-array float 6)))) + (let ((v1-1 (-> arg1 shadow-mask)) + (a0-2 (-> arg1 shadow-values)) + ) + (dotimes (a1-2 5) + (if (not (logtest? v1-1 (ash 1 a1-2))) + (set! (-> s5-0 a1-2) 1.0) + (set! (-> s5-0 a1-2) (* 0.0625 (the float (logand (ash a0-2 (* -4 a1-2)) 15)))) + ) + ) + ) + (when (or (and (>= (the-as int arg2) 10) (< (the-as int arg2) 18)) + (and (>= (the-as int arg2) 30) (< (the-as int arg2) 38)) + ) + (dotimes (s3-1 (-> *level* length)) + (let ((v1-10 (-> *level* level s3-1))) + (when (= (-> v1-10 status) 'active) + (set! sv-64 (-> v1-10 light-hash)) + (set! sv-68 (-> arg1 origin)) + (set! sv-72 (-> v1-10 mood-context)) + (when (nonzero? sv-64) + (let ((v1-13 (light-hash-get-bucket-index sv-64 (-> arg1 origin)))) + (when (!= v1-13 -1) + (let ((s2-0 (-> sv-64 bucket-array v1-13))) + (set! sv-76 (the pointer (+ (+ (-> s2-0 index) 0) (the-as uint (-> sv-64 index-array))))) + (dotimes (s1-0 (the-as int (-> s2-0 count))) + (let ((s0-0 (-> sv-64 light-sphere-array (-> (the-as (pointer uint8) (&+ sv-76 s1-0)))))) + (when (= (-> s0-0 palette-index) -2) + (let* ((f0-3 (-> s0-0 bsphere w)) + (f28-0 (* f0-3 (-> s0-0 decay-start))) + (f26-0 (- f0-3 f28-0)) + (f0-8 (fmax 0.0 (fmin 1.0 (/ (- (vector-vector-distance (-> s0-0 bsphere) sv-68) f28-0) f26-0)))) + ) + (when (!= f0-8 1.0) + ;; (.srl v1-26 v1-25 24) + ;; og:preserve-this + (set! v1-26 (logand #xffffffff (shr (-> s0-0 shadow) 24))) + (let ((a0-26 (shr (shl (-> s0-0 shadow) 40) 40))) + (dotimes (a1-6 5) + (when (logtest? v1-26 (ash 1 a1-6)) + (let ((f1-5 (* 0.0625 (the float (logand (ash a0-26 (* -4 a1-6)) 15))))) + 1.0 + (set! (-> s5-0 a1-6) (fmin (-> s5-0 a1-6) (+ f1-5 (* (- 1.0 f1-5) f0-8)))) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (dotimes (v1-35 4) + (when (nonzero? (-> arg0 lights v1-35 mask)) + (let ((a0-36 (-> arg0 lights v1-35 palette-index))) + (set! (-> arg0 lights v1-35 extra x) (* (-> arg0 lights v1-35 extra x) (-> s5-0 a0-36))) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defun calc-realtime-lights ((arg0 light-group) (arg1 draw-control) (arg2 uint)) + (local-vars (sv-16 light-hash) (sv-20 vector) (sv-24 mood-context)) + (when (or (and (>= (the-as int arg2) 10) (< (the-as int arg2) 18)) + (and (>= (the-as int arg2) 30) (< (the-as int arg2) 38)) + ) + (dotimes (s4-0 (-> *level* length)) + (let ((v1-5 (-> *level* level s4-0))) + (when (= (-> v1-5 status) 'active) + (set! sv-16 (-> v1-5 light-hash)) + (set! sv-20 (-> arg1 origin)) + (set! sv-24 (-> v1-5 mood-context)) + (when (nonzero? sv-16) + (let ((v1-8 (light-hash-get-bucket-index sv-16 (-> arg1 origin)))) + (when (!= v1-8 -1) + (let* ((s3-0 (-> sv-16 bucket-array v1-8)) + (s2-0 (+ (+ (-> s3-0 index) 0) (the-as uint (-> sv-16 index-array)))) + ) + (dotimes (s1-0 (the-as int (-> s3-0 count))) + (let* ((a1-3 (-> sv-16 light-sphere-array (-> (the-as (pointer uint8) (+ s2-0 s1-0))))) + (v1-14 (-> a1-3 palette-index)) + (f0-1 (if (= v1-14 -1) + 1.0 + (-> sv-24 times v1-14 w) + ) + ) + ) + (if (not (or (= (-> a1-3 palette-index) -2) (= (* (-> a1-3 brightness) f0-1) 0.0))) + (add-light-sphere-to-light-group arg0 a1-3 sv-20 sv-24) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +(defun calc-vu1-lights ((arg0 vu-lights) (arg1 draw-control) (arg2 symbol)) + (local-vars (v1-44 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (let ((s4-0 *time-of-day-context*)) + (cond + ((logtest? (-> arg1 global-effect) (draw-control-global-effect title-light)) + (when (not (-> s4-0 title-updated)) + (set! (-> s4-0 title-updated) #t) + (let ((s2-1 (-> *math-camera* inv-camera-rot)) + (a1-1 (new 'static 'vector :x 0.612 :y 0.5 :z -0.612)) + (s3-0 (new 'static 'vector :x -0.696 :y 0.174 :z 0.696)) + ) + (vector-matrix*! (the-as vector (-> s4-0 title-light-group)) a1-1 s2-1) + (vector-matrix*! (the-as vector (-> s4-0 title-light-group dir1)) s3-0 s2-1) + ) + ) + (vu-lights<-light-group! arg0 (-> s4-0 title-light-group)) + ) + ((logtest? (-> arg1 global-effect) (draw-control-global-effect rim-lights)) + (let ((s1-0 (-> *math-camera* inv-camera-rot)) + (a1-4 (new 'static 'vector :x 0.77455187 :y 0.44725248 :z 0.44725248)) + (s3-1 (new 'static 'vector :x -0.77455187 :y 0.44725248 :z 0.44725248)) + (s2-2 (new 'static 'vector :y -0.8944 :z 0.4472)) + (s4-1 (-> s4-0 rim-light-group)) + ) + (vector-matrix*! (the-as vector (-> s4-1 dir0)) a1-4 s1-0) + (vector-matrix*! (the-as vector (-> s4-1 dir1)) s3-1 s1-0) + (vector-matrix*! (the-as vector (-> s4-1 dir2)) s2-2 s1-0) + (vu-lights<-light-group! arg0 s4-1) + ) + ) + ((logtest? (-> arg1 global-effect) (draw-control-global-effect rim-lights2)) + (let ((s1-1 (-> *math-camera* inv-camera-rot)) + (a1-8 (new 'static 'vector :x 0.77455187 :y 0.44725248 :z 0.44725248)) + (s3-2 (new 'static 'vector :x -0.77455187 :y 0.44725248 :z 0.44725248)) + (s2-3 (new 'static 'vector :y -0.8944 :z 0.4472)) + (s4-2 (-> s4-0 rim-light-group2)) + ) + (vector-matrix*! (the-as vector (-> s4-2 dir0)) a1-8 s1-1) + (vector-matrix*! (the-as vector (-> s4-2 dir1)) s3-2 s1-1) + (vector-matrix*! (the-as vector (-> s4-2 dir2)) s2-3 s1-1) + (vu-lights<-light-group! arg0 s4-2) + ) + ) + ((logtest? (-> arg1 global-effect) (draw-control-global-effect rim-lights3)) + (let ((s1-2 (-> *math-camera* inv-camera-rot)) + (a1-12 (new 'static 'vector :x 0.77455187 :y 0.44725248 :z 0.44725248)) + (s3-3 (new 'static 'vector :x -0.77455187 :y 0.44725248 :z 0.44725248)) + (s2-4 (new 'static 'vector :y -0.8944 :z 0.4472)) + (s4-3 (-> s4-0 rim-light-group3)) + ) + (vector-matrix*! (the-as vector (-> s4-3 dir0)) a1-12 s1-2) + (vector-matrix*! (the-as vector (-> s4-3 dir1)) s3-3 s1-2) + (vector-matrix*! (the-as vector (-> s4-3 dir2)) s2-4 s1-2) + (vu-lights<-light-group! arg0 s4-3) + ) + ) + (else + (let ((v1-20 (-> arg1 level-index)) + (s1-3 (-> arg1 light-index)) + (s3-4 (new 'stack-no-clear 'light-group)) + ) + (if (and (>= v1-20 (the-as uint 10)) (< s1-3 (the-as uint 20))) + (+! s1-3 20) + ) + (let ((v1-22 (+ (the-as uint (-> *level* level0 mood-context)) (* (the-as uint 5424) v1-20)))) + (cond + ((< s1-3 (the-as uint 8)) + (quad-copy! (the-as pointer s3-4) (the-as pointer (+ (* (the-as uint 192) s1-3) 112 v1-22)) 12) + ) + ((< s1-3 (the-as uint 18)) + (quad-copy! (the-as pointer s3-4) (the-as pointer (+ (* (the-as uint 192) (+ s1-3 -10)) 112 v1-22)) 12) + ) + ((< s1-3 (the-as uint 28)) + (quad-copy! (the-as pointer s3-4) (the-as pointer (-> s4-0 light-group (+ s1-3 -20))) 12) + ) + ((< s1-3 (the-as uint 38)) + (quad-copy! (the-as pointer s3-4) (the-as pointer (-> s4-0 light-group (+ s1-3 -30))) 12) + ) + ) + ) + (calc-shadow-masks s3-4 arg1 s1-3) + (calc-realtime-lights s3-4 arg1 s1-3) + (vu-lights<-light-group! arg0 s3-4) + (if (and arg2 + (nonzero? (-> arg1 shadow-ctrl)) + (-> arg1 shadow-ctrl) + (not (logtest? (-> arg1 shadow-ctrl settings flags) (shadow-flags disable-draw))) + (not (logtest? (-> arg1 shadow-ctrl settings flags) (shadow-flags shdf07))) + ) + (calc-vu1-shadow s3-4 arg1) + ) + ) + ) + ) + ) + (.lvf vf5 (&-> arg1 color-mult quad)) + (.lvf vf6 (&-> arg1 color-emissive quad)) + (.lvf vf1 (&-> arg0 color 0 quad)) + (.lvf vf2 (&-> arg0 color 1 quad)) + (.lvf vf3 (&-> arg0 color 2 quad)) + (.lvf vf4 (&-> arg0 ambient quad)) + (.mul.vf vf4 vf4 vf5) + (.mul.vf vf1 vf1 vf5) + (.mul.vf vf2 vf2 vf5) + (.mul.vf vf3 vf3 vf5) + (.add.vf vf4 vf4 vf6) + (.svf (&-> arg0 color 0 quad) vf1) + (.svf (&-> arg0 color 1 quad) vf2) + (.svf (&-> arg0 color 2 quad) vf3) + (.svf (&-> arg0 ambient quad) vf4) + (.mov v1-44 vf4) + 0 + (none) + ) + ) + +;; WARN: Function dma-add-process-drawable has a return type of none, but the expression builder found a return statement. +(defun dma-add-process-drawable ((arg0 process-drawable) (arg1 draw-control) (arg2 symbol) (arg3 dma-buffer)) + "Generate DMA for foreground object, calculate lights/shadows, etc." + (local-vars (a0-41 int) (a0-43 int) (a3-9 uint128) (sv-16 process-drawable)) + (with-pp + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf20 :class vf) + (vf21 :class vf) + (vf22 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf29 :class vf) + ) + (init-vf0-vector) + (set! sv-16 arg0) + (start-profiling! (-> *perf-stats* data (perf-stat-bucket foreground))) + (when (get-menu-mode *blit-displays-work*) + (if (not (logtest? (-> arg1 status) (draw-control-status hud))) + (return #f) + ) + ) + (logclear! (-> arg1 status) (draw-control-status on-screen)) + (when (not (logtest? (-> arg1 status) (draw-control-status no-draw no-draw-temp uninited))) + (let ((s3-0 (-> (the-as foreground-work #x70000000) bounds)) + (s4-0 (-> (the-as foreground-work #x70000000) lights)) + ) + (.lvf vf16 (&-> arg1 origin quad)) + (.svf (&-> s3-0 quad) vf16) + (when (or (sphere-in-view-frustum? s3-0) (logtest? (-> arg1 status) (draw-control-status no-bounds-check))) + (calc-vu1-lights s4-0 arg1 #t) + (let ((at-0 *math-camera*)) + (.lvf vf16 (&-> at-0 plane 0 quad)) + (.lvf vf17 (&-> at-0 plane 1 quad)) + (.lvf vf18 (&-> at-0 plane 2 quad)) + (.lvf vf19 (&-> at-0 plane 3 quad)) + (.lvf vf20 (&-> at-0 guard-plane 0 quad)) + (.lvf vf21 (&-> at-0 guard-plane 1 quad)) + (.lvf vf22 (&-> at-0 guard-plane 2 quad)) + (.lvf vf23 (&-> at-0 guard-plane 3 quad)) + (.lvf vf24 (&-> at-0 camera-rot rvec quad)) + (.lvf vf25 (&-> at-0 camera-rot uvec quad)) + (.lvf vf26 (&-> at-0 camera-rot fvec quad)) + (.lvf vf27 (&-> at-0 camera-rot trans quad)) + ) + (let ((v1-20 (-> (the-as foreground-work #x70000000) distance))) + (.lvf vf15 (&-> s3-0 quad)) + (.mul.w.vf acc vf27 vf0) + (.add.mul.x.vf acc vf24 vf15 acc) + (.add.mul.y.vf acc vf25 vf15 acc) + (.add.mul.z.vf vf15 vf26 vf15 acc :mask #b111) + (.mul.vf vf28 vf15 vf15) + (.max.w.vf vf29 vf0 vf0) + (.add.y.vf acc vf28 vf28) + (.add.mul.z.vf vf28 vf29 vf28 acc :mask #b1) + (.sqrt.vf Q vf28 :ftf #b0) + (.sub.w.vf vf28 vf0 vf15 :mask #b1000) + (.wait.vf) + (.add.vf vf15 vf28 Q :mask #b1000) + (.svf (&-> v1-20 quad) vf15) + (when (< 0.0 (+ (-> v1-20 z) (-> arg1 bounds w))) + (let ((s4-1 0)) + (let ((f30-0 (-> v1-20 w))) + (if (and *debug-segment* (-> *screen-shot-work* highres-enable)) + (set! f30-0 0.0) + ) + (set! (-> arg1 distance) f30-0) + (when (nonzero? (-> arg1 lod-set max-lod)) + (cond + ((>= (-> arg1 force-lod) 0) + (set! s4-1 (-> arg1 force-lod)) + (if (< (-> arg1 lod-set lod (-> arg1 lod-set max-lod) dist) f30-0) + (return #f) + ) + ) + (else + (while (and (< s4-1 (-> arg1 lod-set max-lod)) (< (-> arg1 lod-set lod s4-1 dist) f30-0)) + (+! s4-1 1) + ) + ) + ) + ) + (if (and (< (-> arg1 lod-set lod s4-1 dist) f30-0) (< (-> arg1 force-lod) 0)) + (return #f) + ) + (let ((v1-49 (-> *level* level (-> arg1 level-index))) + (f0-5 (* f30-0 (-> *math-camera* fov-correction-factor))) + (a0-18 (-> arg1 mgeo header texture-usage-group)) + ) + (dotimes (a1-4 7) + (let ((a2-2 (+ a1-4 12))) + (if (not (logtest? (-> arg1 status) (draw-control-status no-closest-distance))) + (set! (-> v1-49 closest-object a2-2) (fmin (-> v1-49 closest-object a2-2) f30-0)) + ) + ) + (let ((t0-0 (cond + ((>= f0-5 (-> a0-18 data a1-4 data 0 dist)) + 0 + ) + ((>= f0-5 (-> a0-18 data a1-4 data 1 dist)) + 1 + ) + (else + 2 + ) + ) + ) + (a2-12 (+ a1-4 12)) + ) + (let ((a3-8 (-> v1-49 texture-mask a2-12 mask quad)) + (t0-3 (-> (the-as (pointer uint128) (+ (the-as uint a0-18) (* 48 a1-4) (* t0-0 16))) 0)) + ) + (.por a3-9 a3-8 t0-3) + ) + (set! (-> v1-49 texture-mask a2-12 mask quad) a3-9) + ) + ) + ) + (if (or (guard-band-cull s3-0) (< f30-0 (* 1.2 (-> *math-camera* d)))) + (logior! (-> arg1 status) (draw-control-status close-to-screen)) + (logclear! (-> arg1 status) (draw-control-status close-to-screen)) + ) + (logior! (-> arg1 status) (draw-control-status on-screen)) + (if (logtest? (-> arg1 status) (draw-control-status no-draw-bounds no-draw-bounds2)) + (return #f) + ) + (set! (-> pp clock) (-> sv-16 clock)) + (if (or (= s4-1 (-> arg1 cur-lod)) (logtest? (-> arg1 status) (draw-control-status lod-set))) + (foreground-draw arg1 arg3 f30-0) + ) + ) + (when (and (< s4-1 (-> arg1 cur-lod)) (logtest? (-> arg1 status) (draw-control-status math-skel))) + (let ((s5-1 *matrix-engine*)) + (when (= (-> s5-1 length) (-> s5-1 allocated-length)) + (format 0 "Matrix engine is too small!~%") + (format *stdcon* "Matrix engine is too small!~%") + (break!) + 0 + ) + (set! (-> s5-1 (-> s5-1 length)) (process->handle sv-16)) + (+! (-> s5-1 length) 1) + ) + ) + (lod-set! arg1 s4-1) + ) + (logior! (-> arg1 status) (draw-control-status lod-set)) + ) + ) + ) + ) + ) + (stop-profiling! (-> *perf-stats* data (perf-stat-bucket foreground))) + (label cfg-79) + 0 + 0 + (none) + ) + ) + ) + +(define *hud-lights* (new 'global 'vu-lights)) + +(set-vector! (-> *hud-lights* direction 0) 1.0 0.0 0.0 1.0) + +(set-vector! (-> *hud-lights* direction 1) 0.0 1.0 0.0 1.0) + +(set-vector! (-> *hud-lights* direction 2) 0.0 0.0 1.0 1.0) + +(set-vector! (-> *hud-lights* color 0) 0.0 0.0 0.0 1.0) + +(set-vector! (-> *hud-lights* color 1) 0.0 0.0 0.0 1.0) + +(set-vector! (-> *hud-lights* color 2) 0.5 0.5 0.5 1.0) + +(set-vector! (-> *hud-lights* ambient) 0.5 0.5 0.5 1.0) + +(defun dma-add-process-drawable-hud ((arg0 process-drawable) (arg1 draw-control) (arg2 float) (arg3 dma-buffer)) + "Special version of dma-add-process-drawable for drawing hud foreground objects" + (local-vars (a3-4 uint128)) + (logclear! (-> arg1 status) (draw-control-status on-screen)) + (when (not (logtest? (-> arg1 status) (draw-control-status no-draw no-draw-temp uninited))) + (let ((v1-6 (-> (the-as foreground-work #x70000000) lights)) + (a0-3 *hud-lights*) + ) + (set! (-> v1-6 direction 0 quad) (-> a0-3 direction 0 quad)) + (set! (-> v1-6 direction 1 quad) (-> a0-3 direction 1 quad)) + (set! (-> v1-6 direction 2 quad) (-> a0-3 direction 2 quad)) + (set! (-> v1-6 color 0 quad) (-> a0-3 color 0 quad)) + (set! (-> v1-6 color 1 quad) (-> a0-3 color 1 quad)) + (set! (-> v1-6 color 2 quad) (-> a0-3 color 2 quad)) + (set! (-> v1-6 ambient quad) (-> a0-3 ambient quad)) + ) + (lod-set! arg1 0) + (logior! (-> arg1 status) (draw-control-status on-screen)) + (foreground-draw-hud arg1 arg3 arg2) + (let ((v1-12 (-> *level* level-default)) + (a0-9 (-> arg1 mgeo header texture-usage-group)) + ) + (dotimes (a1-9 7) + (let ((a2-1 (+ a1-9 12))) + (let ((a3-3 (-> v1-12 texture-mask a2-1 mask quad)) + (t0-3 (-> a0-9 data a1-9 data 2 mask quad)) + ) + (.por a3-4 a3-3 t0-3) + ) + (set! (-> v1-12 texture-mask a2-1 mask quad) a3-4) + ) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defun add-process-drawable ((arg0 process-drawable) (arg1 draw-control) (arg2 symbol) (arg3 dma-buffer)) + "Foreground engine function to generate dma for a process-drawable." + ((-> arg1 dma-add-func) arg0 arg1 arg2 arg3) + (none) + ) + +;; ERROR: Unsupported inline assembly instruction kind - [cache dxwbin v1, 0] +;; ERROR: Unsupported inline assembly instruction kind - [cache dxwbin v1, 1] +(defun foreground-engine-execute ((arg0 engine)) + "Draw all foreground objects!" + (when (> (length arg0) 0) + (let ((gp-0 (-> *display* frames (-> *display* on-screen) global-buf base))) + (with-profiler 'foreground *profile-foreground-color* + (let ((s4-1 (-> *display* frames (-> *display* on-screen) global-buf))) + ; (let ((v1-34 (-> s4-1 base))) + ; (.sync.l) + ; (.cache dxwbin v1-34 0) + ; (.sync.l) + ; (.cache dxwbin v1-34 1) + ; ) + ; (.sync.l) + ; 0 + (foreground-init) + (execute-connections arg0 s4-1) + ) + (foreground-wrapup) + ) + (let ((v1-54 *dma-mem-usage*)) + (when (nonzero? v1-54) + (set! (-> v1-54 length) (max 36 (-> v1-54 length))) + (set! (-> v1-54 data 35 name) "pris-fragment") + (+! (-> v1-54 data 35 count) 1) + (+! (-> v1-54 data 35 used) + (&- (-> *display* frames (-> *display* on-screen) global-buf base) (the-as uint gp-0)) + ) + (set! (-> v1-54 data 35 total) (-> v1-54 data 35 used)) + ) + ) + ) + ) + 0 + (none) + ) + +(defun-debug main-debug-hook () + "Run debug engine, collision renderer." + (when (not (or (= *master-mode* 'menu) (= *master-mode* 'progress))) + (let ((a0-3 *col-rend*)) + (if (-> a0-3 draw?) + (draw a0-3) + ) + ) + (execute-connections *debug-engine* #f) + (draw-instance-info *stdcon*) + ) + (none) + ) + +(define *debug-hook* (cons main-debug-hook '())) + +(define *add-sphere* #f) + +(define *generic-effect-mode* 0) + +;; WARN: Return type mismatch symbol vs none. +(defun foreground-initialize-engines () + "Initialize shadow chains prior to foreground drawing." + (let ((v1-0 *shadow-globals*)) + (dotimes (a0-0 3) + (let ((a1-2 (-> v1-0 bucket a0-0))) + (set! (-> a1-2 first) (the-as pointer 0)) + (set! (-> a1-2 next) (the-as pointer 0)) + (set! (-> a1-2 shadow-color) (cond + ((zero? a0-0) + (new 'static 'rgba :r #xf0 :g #xf0 :b #xf0 :a #x80) + ) + ((= a0-0 1) + (the-as rgba (-> *setting-control* user-current spotlight-color)) + ) + (else + (the-as rgba (-> *setting-control* user-current highlight-color)) + ) + ) + ) + (set! (-> a1-2 constants) (the-as shadow-vu1-constants 0)) + ) + ) + ) + (none) + ) + +(defun foreground-execute-cpu-vu0-engines () + "Run foreground drawing code on EE/VU0 (bones, generic merc, part of shadow, lightning, prim)" + (let ((gp-0 (-> *display* frames (-> *display* on-screen) global-buf))) + (bones-init gp-0) + (bones-mtx-calc-execute) + (generic-merc-execute-all gp-0) + (shadow-execute-all gp-0) + ) + (lightning-draw-all) + (prim-engine-execute) + (none) + ) + +(defun real-main-draw-hook () + "Do all drawing! Called by main loop to run drawing for a frame. + Note that this also dispatches collide events, updates actors, etc. + It's a bit more than just drawing." + (local-vars (a0-115 int) (a0-117 int)) + (with-pp + (let ((v1-5 (-> *display* frames (-> *display* on-screen) global-buf))) + (set! (-> v1-5 end) (the pointer (&- (-> v1-5 end) (the-as uint (* (shr (+ (-> *display* mem-reserve-size) 8255) 6) 64))))) + ) + (when *display-bug-report* + (let ((v1-13 (-> *display* frames (-> *display* on-screen) global-buf))) + (&+! (-> v1-13 end) -262144) + ) + ) + (set! (-> *display* dma-buffer-overflow) #f) + (set! (-> *display* mem-reserve-size) (the-as uint 0)) + (when *slow-frame-rate* + (dotimes (v1-18 #xc3500) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + ) + ) + "Function to be executed to set up for engine dma" + + ;; update renderer enable masks from menu + (set! (-> *display* vu1-enable-user) (-> *display* vu1-enable-user-menu)) + (set! (-> *texture-pool* texture-enable-user) (-> *texture-pool* texture-enable-user-menu)) + + ;; print memory stats + (when *debug-segment* + (when (and *stats-memory* (!= *master-mode* 'menu)) + (cond + (*stats-memory-short* + (dotimes (gp-0 (-> *level* length)) + (let ((s5-0 (-> *level* level gp-0))) + (if (= (-> s5-0 status) 'active) + (print-mem-usage (compute-memory-usage! s5-0 #f) s5-0 *stdcon*) + ) + ) + ) + ) + (else + (let ((gp-1 (-> *level* level *stats-memory-level-index*))) + (if (and gp-1 (= (-> gp-1 status) 'active)) + (print-mem-usage (compute-memory-usage! gp-1 #f) gp-1 *stdcon*) + ) + ) + ) + ) + ) + (reset! *dma-mem-usage*) + ) + + ;; reset foreground + (foreground-initialize-engines) + (reset! *prim-work*) + + ;; update wind/time of day prior to drawing. + (let ((gp-2 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> *display* bg-clock)) + (set! (-> pp clock) (-> *display* real-clock)) + ) + (if (not (paused?)) + (update-wind *wind-work* *wind-scales*) + ) + (update-time-of-day *time-of-day-context*) + (set! (-> pp clock) gp-2) + ) + + ;; draw sky + (with-profiler 'sky *profile-sky-color* + (if (-> *sky-work* draw-vortex) + (draw-vortex) + (draw *sky-work*) + ) + (flush-cache 0) + ) + + + ;; draw ocean + (let ((gp-5 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> *display* bg-clock)) + (set! (-> pp clock) (-> *display* real-clock)) + ) + (with-profiler 'ocean *profile-ocean-color* + (draw! *ocean*) + (if *ocean-map* + (update-map *ocean*) + ) + ) + (set! (-> pp clock) gp-5) + ) + + ;; draw foreground + (foreground-engine-execute *foreground-draw-engine*) + + ;; do VU0/EE part of foreground drawing + (let ((gp-6 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> *display* bg-clock)) + (set! (-> pp clock) (-> *display* real-clock)) + ) + (foreground-execute-cpu-vu0-engines) + (set! (-> pp clock) gp-6) + ) + + + (when *add-sphere* + ) + + ;; sprites/particles + (if (not (paused?)) + (execute-part-engine) + ) + (when (logtest? (vu1-renderer-mask sprite) (-> *display* vu1-enable-user)) + (if (not (get-screen-copied *blit-displays-work*)) + (sprite-draw *display*) + ) + ) + + ;; debug drawing + (when *debug-segment* + (debug-draw-actors *level* *display-actor-marks*) + (collide-shape-draw-debug-marks) + ) + (when *display-trail-graph* + (let ((a0-67 *trail-graph*)) + (if a0-67 + (debug-draw a0-67) + ) + ) + ) + + ;; dispatch collision events + (send-events-for-touching-shapes *touching-list*) + (free-nodes *touching-list*) + (prepare *collide-rider-pool*) + (send-all! *event-queue*) + + ;; level update actors: + (with-profiler 'actors *profile-actors-color* + (actors-update *level*) + ) + + ;; do navigation math + (with-profiler 'nav *profile-nav-color* + (update-nav-meshes-method *level*) + ) + + ;; draw the backgroun + (with-profiler 'background *profile-background-color* + (init-background) + (execute-connections *background-draw-engine* #f) + (start-profiling! (-> *perf-stats* data (perf-stat-bucket background))) + (finish-background) + (stop-profiling! (-> *perf-stats* data (perf-stat-bucket background))) + (update-wait-stats + (-> *perf-stats* data (perf-stat-bucket background)) + (-> *background-work* wait-to-vu0) + (the-as uint 0) + (the-as uint 0) + ) + ) + + ;; end GOMI stats hack collection + (end-perf-stat-collection) + + ;; run collect-stats without the perf-stat collection running + (when (and (!= *master-mode* 'menu) *stats-poly*) + (dotimes (gp-13 (-> *level* length)) + (let ((v1-326 (-> *level* level gp-13))) + (if (= (-> v1-326 status) 'active) + (collect-stats (-> v1-326 bsp)) + ) + ) + ) + (print-terrain-stats) + ) + (when (not (paused?)) + (if (and (!= *master-mode* 'menu) *stats-perf*) + (print-perf-stats) + ) + (if (and (!= *master-mode* 'menu) *stats-collide*) + (print-collide-stats) + ) + ) + + ;; restart perf-stat collection + (start-perf-stat-collection) + 0 + (none) + ) + ) + +(defun main-draw-hook () + "Wrapper of real-main-draw-hook" + (real-main-draw-hook) + (none) + ) + +(define *draw-hook* main-draw-hook) + +;; WARN: Return type mismatch symbol vs none. +(defun default-init-buffer ((arg0 bucket-id) (arg1 gs-zbuf) (arg2 gs-test)) + "Initialize DMA chain for a bucket." + (let ((v1-0 *display*) + (t0-0 16) + ) + (+! (-> v1-0 mem-reserve-size) t0-0) + (when (not (-> v1-0 dma-buffer-overflow)) + (let ((t1-0 (-> v1-0 frames (-> v1-0 on-screen) global-buf))) + (if (< (-> t1-0 real-buffer-end) (the-as int (&+ (-> t1-0 base) t0-0))) + (set! (-> v1-0 dma-buffer-overflow) #t) + ) + ) + (when (not (-> v1-0 dma-buffer-overflow)) + (let ((v1-8 (-> *display* frames (-> *display* on-screen) bucket-group arg0))) + (when (!= v1-8 (-> v1-8 last)) + (let* ((a0-8 (-> *display* frames (-> *display* on-screen) global-buf)) + (a3-15 (-> a0-8 base)) + ) + (let ((t0-2 *display*) + (t1-2 176) + ) + (+! (-> t0-2 mem-reserve-size) t1-2) + (when (not (-> t0-2 dma-buffer-overflow)) + (let ((t3-0 (-> t0-2 frames (-> t0-2 on-screen) global-buf))) + (if (< (-> t3-0 real-buffer-end) (the-as int (&+ (-> t3-0 base) t1-2))) + (set! (-> t0-2 dma-buffer-overflow) #t) + ) + ) + (if (not (-> t0-2 dma-buffer-overflow)) + (dma-buffer-add-gs-set-flusha a0-8 + (zbuf-1 arg1) + (test-1 arg2) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + (pabe 0) + (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) + (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (texa (new 'static 'gs-texa :ta1 #x80)) + (texclut (new 'static 'gs-texclut :cbw #x4)) + (fogcol *fog-color*) + ) + ) + ) + ) + (let ((a1-17 (the-as dma-packet (-> a0-8 base)))) + (set! (-> a1-17 dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> v1-8 next))) + (set! (-> a1-17 vif0) (new 'static 'vif-tag)) + (set! (-> a1-17 vif1) (new 'static 'vif-tag)) + (set! (-> a0-8 base) (the-as pointer (&+ a1-17 16))) + ) + (set! (-> v1-8 next) (the-as uint a3-15)) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defun default-end-buffer ((arg0 bucket-id) (arg1 gs-zbuf) (arg2 gs-test)) + "Add DMA data at the end of a bucket to reset settings." + (let ((v1-0 *display*) + (a3-0 16) + ) + (+! (-> v1-0 mem-reserve-size) a3-0) + (when (not (-> v1-0 dma-buffer-overflow)) + (let ((t1-0 (-> v1-0 frames (-> v1-0 on-screen) global-buf))) + (if (< (-> t1-0 real-buffer-end) (the-as int (&+ (-> t1-0 base) a3-0))) + (set! (-> v1-0 dma-buffer-overflow) #t) + ) + ) + (when (not (-> v1-0 dma-buffer-overflow)) + (let ((v1-8 (-> *display* frames (-> *display* on-screen) bucket-group arg0))) + (when (!= v1-8 (-> v1-8 last)) + (let* ((a3-6 (-> *display* frames (-> *display* on-screen) global-buf)) + (a0-8 (-> a3-6 base)) + ) + (let ((t0-11 *display*) + (t1-2 176) + ) + (+! (-> t0-11 mem-reserve-size) t1-2) + (when (not (-> t0-11 dma-buffer-overflow)) + (let ((t3-0 (-> t0-11 frames (-> t0-11 on-screen) global-buf))) + (if (< (-> t3-0 real-buffer-end) (the-as int (&+ (-> t3-0 base) t1-2))) + (set! (-> t0-11 dma-buffer-overflow) #t) + ) + ) + (if (not (-> t0-11 dma-buffer-overflow)) + (dma-buffer-add-gs-set-flusha a3-6 + (zbuf-1 arg1) + (test-1 arg2) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + (pabe 0) + (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) + (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (texa (new 'static 'gs-texa :ta1 #x80)) + (texclut (new 'static 'gs-texclut :cbw #x4)) + (fogcol *fog-color*) + ) + ) + ) + ) + (let ((t0-16 (-> a3-6 base))) + (let ((a1-17 (the-as dma-packet (-> a3-6 base)))) + (set! (-> a1-17 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> a1-17 vif0) (new 'static 'vif-tag)) + (set! (-> a1-17 vif1) (new 'static 'vif-tag)) + (set! (-> a3-6 base) (the-as pointer (&+ a1-17 16))) + ) + (set! (-> (the-as (pointer uint32) (-> v1-8 last)) 1) (the-as uint a0-8)) + (set! (-> v1-8 last) (the-as (pointer dma-tag) t0-16)) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +(defun-debug screen-shot-scale ((arg0 int) (arg1 string)) + (set! (-> *screen-shot-work* size) arg0) + (set! (-> *screen-shot-work* name) arg1) + (set! *display-profile* #f) + 0 + (none) + ) + +(defun-debug screen-shot () + "Take a screenshot." + (screen-shot-scale 1 "image") + 0 + (none) + ) + +;; WARN: Return type mismatch display vs none. +(defun display-frame-start ((arg0 display) (arg1 int) (arg2 float)) + "Advance clocks, poll pads/mouse, set up buckets." + (set! (-> (the-as vif-bank #x10003c00) err me0) 1) + (set-time-ratios *display* 1.0) + (tick! (-> arg0 frame-clock)) + (tick! (-> arg0 real-frame-clock)) + (set-time-ratios *display* arg2) + (tick! (-> arg0 session-clock)) + (tick! (-> arg0 game-clock)) + (tick! (-> arg0 total-game-clock)) + (tick! (-> arg0 base-clock)) + (tick! (-> arg0 real-clock)) + (tick! (-> arg0 target-clock)) + (tick! (-> arg0 camera-clock)) + (tick! (-> arg0 entity-clock)) + (tick! (-> arg0 bg-clock)) + (tick! (-> arg0 user0-clock)) + (tick! (-> arg0 user1-clock)) + (tick! (-> arg0 user2-clock)) + (tick! (-> arg0 user3-clock)) + (tick! (-> arg0 user4-clock)) + (tick! (-> arg0 user5-clock)) + (tick! (-> arg0 user6-clock)) + (tick! (-> arg0 user7-clock)) + (tick! (-> arg0 user8-clock)) + (tick! (-> arg0 user9-clock)) + (set! (-> arg0 bg-clock frame-counter) (the-as time-frame (mod (-> arg0 bg-clock frame-counter) #x69780))) + (tick! (-> arg0 part-clock)) + (when (and (nonzero? *screen-shot-work*) (!= (-> *screen-shot-work* count) -1)) + (let ((v1-61 (-> *screen-shot-work* size))) + (if (!= (-> *screen-shot-work* count) (* v1-61 v1-61)) + (store-image *screen-shot-work*) + ) + ) + (+! (-> *screen-shot-work* count) -1) + (if (= (-> *screen-shot-work* count) -1) + (set! (-> *screen-shot-work* size) -1) + ) + ) + (let ((s5-1 (-> arg0 frames arg1))) + (if *sync-dma* + (sync-path 0 0) + ) + (let ((v1-75 (-> s5-1 global-buf))) + (set! (-> v1-75 base) (-> v1-75 data)) + (set! (-> v1-75 end) (the-as pointer (+ (+ (-> v1-75 allocated-length) 28) (the-as int v1-75)))) + ) + (when *debug-segment* + (let ((v1-78 (-> s5-1 debug-buf))) + (set! (-> v1-78 base) (-> v1-78 data)) + (set! (-> v1-78 end) (the-as pointer (+ (+ (-> v1-78 allocated-length) 28) (the-as int v1-78)))) + ) + ) + (let ((v1-79 (-> s5-1 calc-buf))) + (set! (-> v1-79 base) (-> v1-79 data)) + (set! (-> v1-79 end) (the-as pointer (+ (+ (-> v1-79 allocated-length) 28) (the-as int v1-79)))) + ) + (*pre-draw-hook* (-> s5-1 calc-buf)) + (when (not (paused?)) + (clear *stdcon1*) + (debug-reset-buffers) + (clear! *simple-sprite-system*) + ) + (set! (-> s5-1 bucket-group) (dma-buffer-add-buckets (-> s5-1 calc-buf) 586)) + ) + (service-cpads) + (service-mouse) + (service-keybd) + (execute-connections *pad-engine* #f) + (none) + ) + +(defun display-frame-finish ((arg0 display)) + "Do final texture remaps, sync DMA (wait for previous rendering to finish), and finalize DMA chain." + (local-vars (a0-54 int) (a0-56 int)) + (with-pp + (let* ((s4-0 (-> arg0 frames (-> arg0 on-screen))) + (s5-0 (-> s4-0 calc-buf)) + ) + (-> s4-0 global-buf base) + (tfrag-vu1-init-buffers) + (tie-vu1-init-buffers) + (merc-vu1-init-buffers) + (emerc-vu1-init-buffers) + (generic-vu1-init-buffers) + (with-profiler 'texture *profile-texture-color* + (when (-> *texture-pool* update-sprites-flag) + (update-sprites *texture-pool*) + (particle-adgif-cache-flush) + (remap-all-particles) + ) + (let ((s3-1 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> arg0 bg-clock)) + (set! (-> pp clock) (-> arg0 real-clock)) + ) + (upload-textures *texture-pool*) + (set! (-> pp clock) s3-1) + ) + (if (-> *texture-pool* update-flag) + (update-warp-and-hud *texture-pool*) + ) + (-> arg0 frames (-> arg0 on-screen) global-buf) + (update-eyes) + ) + (when *debug-segment* + (with-profiler 'debug *profile-debug-color* + (debug-draw-buffers) + ) + (with-profiler 'gs-sync *profile-gs-sync-color* + (when (nonzero? (sync-path 0 0)) + (*dma-timeout-hook*) + (reset-vif1-path) + (nop!) + (nop!) + 0 + ) + ) + (let ((s3-7 (-> arg0 frames (-> arg0 on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-148 (+ (-> s3-7 depth) -1)) + (s2-6 (-> s3-7 segment v1-148)) + (s1-6 (-> s3-7 base-time)) + ) + (when (>= v1-148 0) + (set! (-> s2-6 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s1-6)))) + (+! (-> s3-7 depth) -1) + ) + ) + ) + ) + 0 + (stop-profiling! (-> *perf-stats* data 0)) + ; (let ((v1-155 (-> *perf-stats* data))) + ; (b! (zero? (-> v1-155 0 ctrl)) cfg-63 :delay (nop!)) + ; (.mtc0 Perf 0) + ; (.sync.l) + ; (.sync.p) + ; (.mfpc a0-54 pcr0) + ; (+! (-> v1-155 0 accum0) a0-54) + ; (.mfpc a0-56 pcr1) + ; (+! (-> v1-155 0 accum1) a0-56) + ; ) + ; (label cfg-63) + ; 0 + (with-dma-buffer-add-bucket ((s2-7 (-> arg0 frames (-> arg0 on-screen) debug-buf)) + (bucket-id debug-no-zbuf2) + ) + (when (and (or *display-profile* *stats-profile-bars*) (not *display-capture-mode*)) + (postprocess-data! (-> arg0 frames (-> arg0 on-screen) profile-array)) + (let ((a2-0 7)) + (if *display-profile* + (draw-bars! *profile-array* s2-7 a2-0) + ) + ) + (if (and (!= *master-mode* 'menu) *stats-profile-bars*) + (draw-text! *profile-array*) + ) + ) + (when *display-deci-count* + (let ((s1-7 draw-string-xy)) + (format (clear *temp-string*) "~D" *deci-count*) + (s1-7 *temp-string* s2-7 448 210 (font-color default) (font-flags shadow kerning)) + ) + ) + (display-file-info) + ) + ) + (let ((s3-9 6) + (s2-8 583) + ) + (while (>= s2-8 s3-9) + (default-end-buffer + (the-as bucket-id s3-9) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24)) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) + ) + (+! s3-9 1) + ) + ) + (default-init-buffer + (bucket-id debug-no-zbuf1) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) + ) + (default-init-buffer + (bucket-id debug-no-zbuf2) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) + ) + (default-init-buffer + (bucket-id tex-hud-pris2) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) + ) + (default-init-buffer + (bucket-id bucket8) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24)) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) + ) + (*post-draw-hook* (-> arg0 frames (-> arg0 on-screen) calc-buf)) + (let ((v1-199 *display*) + (a0-75 16) + ) + (+! (-> v1-199 mem-reserve-size) a0-75) + (when (not (-> v1-199 dma-buffer-overflow)) + (let ((a2-9 (-> v1-199 frames (-> v1-199 on-screen) global-buf))) + (if (< (-> a2-9 real-buffer-end) (the-as int (&+ (-> a2-9 base) a0-75))) + (set! (-> v1-199 dma-buffer-overflow) #t) + ) + ) + (when (not (-> v1-199 dma-buffer-overflow)) + (let* ((v1-201 s5-0) + (a0-79 (the-as dma-packet (-> v1-201 base))) + ) + (set! (-> a0-79 dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> a0-79 vif0) (new 'static 'vif-tag :imm #x24b :cmd (vif-cmd mark))) + (set! (-> a0-79 vif1) (new 'static 'vif-tag :cmd (vif-cmd flushe) :irq #x1 :msk #x1)) + (set! (-> v1-201 base) (the-as pointer (&+ a0-79 16))) + ) + ) + ) + ) + (dma-buffer-patch-buckets (the-as dma-bucket (-> s4-0 bucket-group)) 586) + (let ((v1-202 *display*) + (a0-81 16) + ) + (+! (-> v1-202 mem-reserve-size) a0-81) + (when (not (-> v1-202 dma-buffer-overflow)) + (let ((a2-11 (-> v1-202 frames (-> v1-202 on-screen) global-buf))) + (if (< (-> a2-11 real-buffer-end) (the-as int (&+ (-> a2-11 base) a0-81))) + (set! (-> v1-202 dma-buffer-overflow) #t) + ) + ) + (when (not (-> v1-202 dma-buffer-overflow)) + (let* ((v1-204 s5-0) + (a0-85 (-> v1-204 base)) + ) + (set! (-> (the-as (pointer int64) a0-85)) #x70000000) + (set! (-> (the-as (pointer uint64) a0-85) 1) (the-as uint 0)) + (set! (-> v1-204 base) (&+ a0-85 16)) + ) + ) + ) + ) + (flush-cache 0) + (when (not (paused?)) + (when *stats-buffer* + (let* ((a0-87 (-> s4-0 global-buf)) + (v1-208 (-> s5-0 base)) + (a2-13 (-> s5-0 data)) + (s4-1 (-> a0-87 base)) + (s5-1 (-> a0-87 data)) + (s3-10 (-> a0-87 end)) + ) + (format *stdcon* "~0kvu1 buf = ~d~%" (&- v1-208 (the-as uint a2-13))) + (format *stdcon* "~0kglobal buf = ~d~%" (&- s4-1 (the-as uint s5-1))) + (format *stdcon* "~0kbase = #x~x~%" s4-1) + (format *stdcon* "~0kend = #x~x~%" s3-10) + ) + ) + ) + ) + arg0 + ) + ) + +(defun determine-pause-mode () + "Update pause modes" + (when (and (or (not *progress-process*) (can-go-back? (-> *progress-process* 0))) + (or (!= *master-mode* 'freeze) (and *debug-segment* (cpad-pressed? 0 select start) (cpad-hold? 0 l3))) + ) + (if (or (cpad-pressed? 0 select start) + (cond + ((= *master-mode* 'menu) + (cpad-pressed? 0 r3 r2 triangle circle) + ) + (*cam-layout* + #f + ) + (else + #f + ) + ) + (or (and (logtest? (-> *cpad-list* cpads 0 valid) 128) + (= *master-mode* 'game) + (>= (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (= (-> *setting-control* user-current bg-a) 0.0) + (and (= (-> *setting-control* user-current bg-a-force) 0.0) + (< (seconds 1003) (-> *display* real-clock frame-counter)) + ) + ) + (and (cpad-pressed? 0 r2) (or (= *master-mode* 'pause) (= *master-mode* 'menu))) + *pause-lock* + ) + ) + (toggle-pause) + ) + ) + (if (and *progress-process* (!= *master-mode* 'progress)) + (deactivate-progress) + ) + 0 + (none) + ) + +(defun calc-ratio ((arg0 int) (arg1 int)) + (let ((f0-1 (the float (sar (- arg0 arg1) 48)))) + (if (< f0-1 0.0) + (set! f0-1 (+ 65536.0 f0-1)) + ) + (/ f0-1 (the float *ticks-per-frame*)) + ) + ) + +(defun display-sync ((arg0 display)) + (sync-path 0 0) + (let* ((s4-0 (-> arg0 last-screen)) + (s2-0 (shl (timer-count (the-as timer-bank #x10000800)) 48)) + (s5-0 (shl (-> arg0 frames s4-0 start-time) 48)) + (a1-1 (shl (-> arg0 vblank-start-time 0) 48)) + (s1-0 (shl (-> arg0 vblank-start-time 1) 48)) + ) + (set! *ticks-per-frame* (max 9000 (min #x2ee0 (sar (- s1-0 a1-1) 48)))) + (let ((f28-0 (the float *ticks-per-frame*)) + (s3-0 (sar (- s2-0 s5-0) 48)) + (f30-1 (fmax 1.0 (calc-ratio (the-as int s2-0) (the-as int s5-0)))) + ) + (/ (the float (sar (- s2-0 (the-as uint s1-0)) 48)) f28-0) + (let ((f28-1 (/ (the float (sar (- s2-0 (the-as uint s1-0)) 48)) f28-0)) + (f26-0 (fmax 1.0 (fmin 4.0 (-> *display* dog-ratio)))) + ) + (if (< (the-as int s3-0) 0) + (set! s3-0 (the uint (+ #x10000 s3-0))) + ) + (set! (-> arg0 frames s4-0 run-time) s3-0) + (set! f30-1 (cond + ((-> arg0 run-half-speed) + (syncv 0) + (let ((a0-8 (shl (timer-count (the-as timer-bank #x10000800)) 48))) + (if (and (< (calc-ratio (the-as int a0-8) (the-as int s5-0)) 2.0) (< f28-1 0.9)) + (syncv 0) + ) + ) + 2.0 + ) + ((< 1.0 f30-1) + (when (> (-> arg0 force-sync) 0) + (syncv 0) + (+! (-> arg0 force-sync) -1) + (let ((a0-12 (shl (timer-count (the-as timer-bank #x10000800)) 48))) + (set! f30-1 (calc-ratio (the-as int a0-12) (the-as int s5-0))) + ) + ) + f30-1 + ) + ((and (= f30-1 1.0) (< f30-1 f26-0)) + (while (< f30-1 f26-0) + (let ((a0-14 (shl (timer-count (the-as timer-bank #x10000800)) 48))) + (set! f30-1 (calc-ratio (the-as int a0-14) (the-as int s5-0))) + ) + (if (< f30-1 0.0) + (set! f30-1 f26-0) + ) + ) + 1.0 + ) + (else + (if (< f28-1 0.9) + (syncv 0) + ) + f30-1 + ) + ) + ) + ) + (let ((s4-1 (-> arg0 on-screen))) + (let ((v1-50 (timer-count (the-as timer-bank #x10000800)))) + (let ((a0-19 (sar (- (shl v1-50 48) s5-0) 48))) + (if (< (the-as int a0-19) 0) + (set! a0-19 (the uint (+ #x10000 a0-19))) + ) + (+! (-> arg0 total-run-time) a0-19) + ) + (set! (-> arg0 frames s4-1 start-time) v1-50) + ) + (set-graphics-mode) + (let ((s5-1 (-> arg0 frames s4-1 calc-buf))) + (when (nonzero? (dma-buffer-length s5-1)) + (+! s4-1 1) + (if (< 1 s4-1) + (set! s4-1 0) + ) + (set! (-> arg0 last-screen) (-> arg0 on-screen)) + (set! (-> arg0 on-screen) s4-1) + (when *debug-segment* + (set! *profile-interrupt-segment* (-> *display* frames (-> *display* last-screen) profile-array data 1)) + (set! (-> *profile-interrupt-segment* depth) 0) + (set! (-> *profile-interrupt-segment* max-depth) 1) + ) + (if (not (-> *display* dma-buffer-overflow)) + (dma-buffer-send-chain (the-as dma-bank-source #x10009000) s5-1) + ) + ) + ) + (determine-pause-mode) + (when (and (nonzero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1) (!= (-> *screen-shot-work* size) -1)) + (let ((v1-82 (-> *screen-shot-work* size))) + (set! (-> *screen-shot-work* count) (* v1-82 v1-82)) + ) + (set-master-mode 'pause) + ) + (display-frame-start arg0 s4-1 f30-1) + ) + ) + ) + (none) + ) diff --git a/goal_src/jak3/engine/entity/entity-h.gc b/goal_src/jak3/engine/entity/entity-h.gc index 4651cb79220..9136acf1f94 100644 --- a/goal_src/jak3/engine/entity/entity-h.gc +++ b/goal_src/jak3/engine/entity/entity-h.gc @@ -38,6 +38,7 @@ (define-extern process-entity-status! (function process entity-perm-status symbol entity-perm-status)) (define-extern process-drawable-from-entity! (function process-drawable entity-actor none)) (define-extern init-entity (function process entity-actor type none)) +(define-extern entity-by-type (function type entity-actor)) (define-extern *spawn-actors* symbol) diff --git a/goal_src/jak3/engine/game/main-h.gc b/goal_src/jak3/engine/game/main-h.gc index c1973b7623c..c5f28b97a3d 100644 --- a/goal_src/jak3/engine/game/main-h.gc +++ b/goal_src/jak3/engine/game/main-h.gc @@ -13,6 +13,7 @@ (define-extern set-blackout-frames (function time-frame none)) (define-extern set-master-mode (function symbol none)) (define-extern on (function symbol process)) +(define-extern toggle-pause (function int)) ;; +++main-h:collide-spec (defenum collide-spec @@ -421,7 +422,7 @@ (deftype screen-filter (basic) ((draw? symbol) - (bucket int32) + (bucket bucket-id) (depth int32) (ztest uint64) (color vector :inline) @@ -430,11 +431,11 @@ (extra vector :inline) (speed float :overlay-at (-> extra data 0)) (current-interp float :overlay-at (-> extra data 1)) - (lock-vsync? basic) + (lock-vsync? symbol) ) (:methods (draw (_type_) none) - (setup (_type_ vector vector float bucket-id) none) + (setup (_type_ vector vector float bucket-id int int symbol) none) (disable (_type_) none) ) ) @@ -455,7 +456,7 @@ (camera-to-bbox-dist float) ) (:methods - (col-rend-method-9 () none) + (draw (_type_) none) ) ) diff --git a/goal_src/jak3/engine/game/main.gc b/goal_src/jak3/engine/game/main.gc index 815ebf1df7f..891a0565a8c 100644 --- a/goal_src/jak3/engine/game/main.gc +++ b/goal_src/jak3/engine/game/main.gc @@ -5,5 +5,1725 @@ ;; name in dgo: main ;; dgos: GAME +(define-extern menu-respond-to-pause (function symbol)) +(define-extern anim-tester-add-object (function string none)) + ;; DECOMP BEGINS +;; WARN: Return type mismatch time-frame vs none. +(defun set-letterbox-frames ((arg0 time-frame)) + "Enable letterbox for the given amount of time." + (with-pp + (set! (-> *game-info* letterbox-time) + (+ (-> *display* base-clock frame-counter) + (the int (/ (* (the float arg0) (-> *display* game-clock clock-ratio)) (-> pp clock clock-ratio))) + ) + ) + (none) + ) + ) + +(defun letterbox ((arg0 bucket-id) (arg1 float)) + "Draw letterbox" + (with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + arg0 + ) + (draw-sprite2d-xy-absolute s4-0 0 0 512 (the int (* 46.0 arg1)) (new 'static 'rgba :a #x80) #x3fffff) + (draw-sprite2d-xy-absolute + s4-0 + 0 + (- 416 (the int (* 46.0 arg1))) + 512 + (+ (the int (* 46.0 arg1)) 1) + (new 'static 'rgba :a #x80) + #x3fffff + ) + ) + 0 + (none) + ) + +(defun set-blackout-frames ((arg0 time-frame)) + "Enable blackout for the given amount of time." + (with-pp + (if (zero? arg0) + (set! (-> *game-info* blackout-time) (-> *display* base-clock frame-counter)) + (set! (-> *game-info* blackout-time) + (the-as + time-frame + (max + (-> *game-info* blackout-time) + (+ (-> *display* base-clock frame-counter) + (the int (/ (* (the float arg0) (-> *display* game-clock clock-ratio)) (-> pp clock clock-ratio))) + arg0 + ) + ) + ) + ) + ) + (none) + ) + ) + +(defun blackout ((arg0 bucket-id)) + "Draw blackout as a sprite." + (with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + arg0 + ) + (draw-sprite2d-xy-absolute s4-0 0 0 512 416 (new 'static 'rgba :a #x80) #x3fffff) + ) + 0 + (none) + ) + +(defun add-blackout ((arg0 time-frame) (r int) (g int) (b int) (arg4 int)) + "Update display settings to do blackout with GS pmode alp." + (let ((v1-0 *display*)) + (let ((a0-1 (new 'static 'array time-frame 2 (seconds 0) (seconds 0)))) + (set! (-> v1-0 bgcolor r) r) + (set! (-> v1-0 bgcolor g) g) + (set! (-> v1-0 bgcolor b) b) + (set! (-> v1-0 pmode alp) (- 255 arg4)) + (set! (-> a0-1 0) 0) + (set! (-> a0-1 1) 0) + ) + (if (nonzero? arg4) + (set! (-> v1-0 force-sync) (the-as uint (max 4 (the-as int (-> v1-0 force-sync))))) + ) + ) + 0 + ) + +(defun paused? () + "Are we paused? Counts any type of pause/menu/freeze." + (or (= *master-mode* 'pause) (= *master-mode* 'progress) (= *master-mode* 'menu) (= *master-mode* 'freeze)) + ) + +(defun movie? () + "Are we in a movie?" + (logtest? (-> *kernel-context* prevent-from-run) (process-mask movie)) + ) + +(defun scene-select? () + (and (>= (-> *game-info* demo-state) (the-as uint 100)) (< (-> *game-info* demo-state) (the-as uint 200))) + ) + +(defun demo? () + "Is this a demo version?" + (or (= *kernel-boot-message* 'demo) (= *kernel-boot-message* 'demo-shared)) + ) + +(defun kiosk? () + "Is this a kiosk version of the game?" + (= *kernel-boot-message* 'kiosk) + ) + +(define *last-master-mode* 'game) + +(defun set-master-mode ((arg0 symbol)) + "Change the master mode and adjust a few masks" + (when (!= arg0 *master-mode*) + (set! *last-master-mode* *master-mode*) + (set! *master-mode* arg0) + (case *master-mode* + (('pause) + (if (not *debug-pause*) + (logior! (-> *setting-control* user-default process-mask) (process-mask pause)) + ) + (logclear! (-> *setting-control* user-default process-mask) (process-mask freeze menu)) + (set! *pause-lock* #f) + (sound-group-pause (the-as sound-group #xffffffff)) + (set! (-> *game-info* pause-start-time) (-> *display* real-clock frame-counter)) + ) + (('freeze) + (logior! (-> *setting-control* user-default process-mask) (process-mask freeze)) + (logclear! (-> *setting-control* user-default process-mask) (process-mask pause menu)) + (sound-group-pause (sound-group sfx ambient)) + (set! (-> *game-info* pause-start-time) (-> *display* real-clock frame-counter)) + ) + (('menu) + (logior! (-> *setting-control* user-default process-mask) (process-mask menu)) + (logclear! (-> *setting-control* user-default process-mask) (process-mask freeze pause progress)) + (sound-group-pause (the-as sound-group #xffffffff)) + (set! *pause-lock* #f) + ) + (('progress) + (logclear! (-> *setting-control* user-default process-mask) (process-mask freeze pause menu)) + (sound-group-pause (the-as sound-group #xffffffff)) + (when (not *progress-process*) + (activate-progress *dproc* 'main) + (if (not *progress-process*) + (set-master-mode 'game) + ) + ) + (set! (-> *game-info* pause-start-time) (-> *display* real-clock frame-counter)) + ) + (('game) + (logclear! (-> *setting-control* user-default process-mask) (process-mask freeze pause menu)) + (sound-group-continue (the-as sound-group #xffffffff)) + ) + ) + (apply-settings *setting-control*) + ) + (if *debug-segment* + (menu-respond-to-pause) + ) + 0 + (none) + ) + +(defun pause-allowed? () + "Should we allow a pause?" + (not (or (< (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (!= (-> *setting-control* user-current bg-a) 0.0) + (!= (-> *setting-control* user-current bg-a-force) 0.0) + (not (-> *setting-control* user-current allow-pause)) + (handle->process (-> *game-info* auto-save-proc)) + (= *master-mode* 'freeze) + (not *target*) + *master-exit* + (not *common-text*) + ) + ) + ) + +(defun toggle-pause () + "Update the pause state. Call this if the user presses a pause button + This function will check the button and state and do a pause if needed." + (case *master-mode* + (('game) + (set-master-mode + (cond + ((and (logtest? (-> *cpad-list* cpads 0 valid) 128) + *target* + (>= (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (= (-> *setting-control* user-current bg-a) 0.0) + (and (= (-> *setting-control* user-current bg-a-force) 0.0) + (< (seconds 1003) (-> *display* real-clock frame-counter)) + ) + ) + (if (or *progress-process* (not (-> *setting-control* user-current allow-pause))) + *master-mode* + 'pause + ) + ) + ((and (cpad-pressed? 0 select start) (cpad-hold? 0 l3) *debug-segment*) + 'menu + ) + ((and (or (cpad-hold? 0 select) (cpad-hold? 0 r2)) *debug-segment*) + 'pause + ) + ((and (not *debug-segment*) (not (logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons start)))) + (if (pause-allowed?) + 'pause + *master-mode* + ) + ) + ((not (progress-allowed?)) + (if (pause-allowed?) + 'pause + *master-mode* + ) + ) + ((cpad-hold? 0 start) + 'progress + ) + (else + *master-mode* + ) + ) + ) + ) + (('menu) + (set-master-mode (cond + ((and *debug-segment* (cpad-hold? 0 l3) (cpad-pressed? 0 select start)) + 'menu + ) + ((cpad-hold? 0 select r2) + (if *debug-segment* + 'pause + *master-mode* + ) + ) + ((cpad-hold? 0 r3 r2 triangle circle) + 'game + ) + ((cpad-hold? 0 start) + 'game + ) + (else + *master-mode* + ) + ) + ) + (set! *pause-lock* #f) + ) + (('pause) + (set-master-mode (cond + ((and (cpad-pressed? 0 select start) (cpad-hold? 0 l3) *debug-segment*) + 'menu + ) + ((and (or (not *debug-segment*) (not *cheat-mode*)) (cpad-hold? 0 select)) + 'game + ) + ((and *cheat-mode* (cpad-hold? 0 select r2)) + 'game + ) + ((cpad-hold? 0 start) + 'game + ) + (else + *master-mode* + ) + ) + ) + (set! *pause-lock* (and *cheat-mode* (cpad-hold? 0 r2))) + ) + (('freeze) + (set-master-mode (if (and (cpad-pressed? 0 select start) (cpad-hold? 0 l3) *debug-segment*) + 'menu + *master-mode* + ) + ) + ) + (('progress) + (if (cpad-hold? 0 start) + (hide-progress-screen) + ) + (set! *pause-lock* (and *cheat-mode* (cpad-hold? 0 r2))) + ) + ) + 0 + ) + +(define *screen-filter* (new 'static 'screen-filter :draw? #f :bucket (bucket-id tex-hud-pris2))) + +;; WARN: Function (method 9 screen-filter) has a return type of none, but the expression builder found a return statement. +(defmethod draw ((this screen-filter)) + "Add DMA data to our bucket to draw the filter." + (local-vars (v1-1 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (when (not (paused?)) + (.lvf vf4 (&-> this extra quad)) + (.lvf vf1 (&-> this color-dest quad)) + (.lvf vf2 (&-> this color quad)) + (.sub.vf vf3 vf1 vf2) + (.add.x.vf vf4 vf4 vf4 :mask #b10) + (.min.w.vf vf4 vf4 vf0 :mask #b10) + (.max.y.vf vf4 vf4 vf0 :mask #b10) + (.mul.y.vf vf3 vf3 vf4) + (.add.vf vf1 vf2 vf3) + (.svf (&-> this extra quad) vf4) + (.svf (&-> this color quad) vf1) + (.mov v1-1 vf1) + ) + (let ((f0-0 0.1)) + (when (and (>= f0-0 (fabs (- (-> this color-dest x) (-> this color x)))) + (>= f0-0 (fabs (- (-> this color-dest y) (-> this color y)))) + (>= f0-0 (fabs (- (-> this color-dest z) (-> this color z)))) + (>= f0-0 (fabs (- (-> this color-dest w) (-> this color w)))) + (>= f0-0 (-> this color w)) + ) + (disable this) + (return 0) + ) + ) + (with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (-> this bucket) + ) + (dma-buffer-add-gs-set s4-0 (test-1 (-> this ztest))) + (let ((t1-0 (new 'static 'rgba + :r (the int (-> this color x)) + :g (the int (-> this color y)) + :b (the int (-> this color z)) + :a (the int (-> this color w)) + ) + ) + ) + (draw-sprite2d-xy s4-0 -256 -208 512 416 t1-0 (-> this depth)) + ) + ) + 0 + (none) + ) + ) + +(defmethod setup ((this screen-filter) + (arg0 vector) + (arg1 vector) + (arg2 float) + (arg3 bucket-id) + (arg4 int) + (arg5 int) + (arg6 symbol) + ) + "Initialize the screen-filter with the given settings." + (set! (-> this draw?) #t) + (set! (-> this color quad) (-> arg0 quad)) + (set! (-> this color-src quad) (-> arg0 quad)) + (set! (-> this color-dest quad) (-> arg1 quad)) + (set! (-> this extra x) arg2) + (set! (-> this extra y) 0.0) + (set! (-> this bucket) arg3) + (set! (-> this depth) arg4) + (set! (-> this ztest) (the-as uint arg5)) + (set! (-> this lock-vsync?) arg6) + 0 + (none) + ) + +(defmethod disable ((this screen-filter)) + (set! (-> this draw?) #f) + 0 + (none) + ) + +(define *cheat-temp* (the-as (pointer int32) (malloc 'global 20))) + +(define *master-exit* #f) + +(define *progress-cheat* #f) + +(define *first-boot* #t) + +(defun main-timeouts () + "Maybe reset/restart the game if no input has been given. + Mainly used for kiosk/demo modes." + (when (demo?) + (let ((gp-0 (scf-get-timeout)) + (v1-1 (scf-get-inactive-timeout)) + ) + (when (and (or (and (nonzero? gp-0) + (>= (+ -300000 (-> *display* real-clock frame-counter)) (the int (* 300.0 (the float gp-0)))) + ) + (and (nonzero? v1-1) + (or (and (>= (- (-> *display* base-clock frame-counter) (-> *cpad-list* cpads 0 change-time)) + (the int (* 300.0 (the float v1-1))) + ) + (>= (- (-> *display* game-clock frame-counter) (-> *game-info* kiosk-timeout)) + (the int (* 300.0 (the float v1-1))) + ) + ) + (and (or (= *master-mode* 'pause) (= *master-mode* 'progress) (= *master-mode* 'freeze)) + (>= (- (-> *display* real-clock frame-counter) (-> *game-info* pause-start-time)) + (the int (* 300.0 (the float v1-1))) + ) + ) + ) + ) + (or (= *master-exit* 'force) (= *master-exit* 'movie)) + ) + (or *master-exit* (-> *setting-control* user-current allow-timeout)) + (!= *master-exit* #t) + ) + (cond + ((and (= *kernel-boot-message* 'demo) (not *master-exit*)) + (let ((v1-17 (level-get-target-inside *level*))) + (when (and v1-17 (!= (-> v1-17 name) 'demo) (not (logtest? (-> v1-17 info level-flags) (level-flags lf0)))) + (persist-with-delay *setting-control* 'sfx-volume (seconds 0.5) 'sfx-volume 'abs 0.0 0) + (persist-with-delay *setting-control* 'music-volume (seconds 0.5) 'music-volume 'abs 0.0 0) + (persist-with-delay *setting-control* 'dialog-volume (seconds 0.5) 'dialog-volume 'abs 0.0 0) + (persist-with-delay *setting-control* 'ambient-volume (seconds 0.5) 'ambient-volume 'abs 0.0 0) + (set! (-> *setting-control* user-current sfx-volume) 0.01) + (set! (-> *setting-control* user-current music-volume) 0.01) + (set! (-> *setting-control* user-current dialog-volume) 0.01) + (set! (-> *setting-control* user-current ambient-volume) 0.01) + (apply-settings *setting-control*) + (set! (-> *game-info* mode) 'play) + (initialize! *game-info* 'game (the-as game-save #f) "title-restart" (the-as resetter-spec #f)) + ) + ) + ) + (else + (when (process-spawn-function + process + (lambda ((arg0 int)) + (set-blackout-frames (seconds 100)) + (set! (-> *setting-control* user-default allow-pause) #f) + (set! (-> *setting-control* user-default allow-progress) #f) + (apply-settings *setting-control*) + (set! (-> *setting-control* user-default sfx-volume) 0.0) + (set! (-> *setting-control* user-default music-volume) 0.0) + (set! (-> *setting-control* user-default dialog-volume) 0.0) + (set! (-> *setting-control* user-default ambient-volume) 0.0) + (let ((s5-0 (current-time))) + (until (time-elapsed? s5-0 (seconds 0.1)) + (suspend) + ) + ) + (kernel-shutdown arg0) + (none) + ) + (if (= *master-exit* 'movie) + 2 + 1 + ) + :to *display-pool* + ) + (set! (-> *setting-control* user-default sfx-volume) 0.0) + (set! (-> *setting-control* user-default music-volume) 0.0) + (set! (-> *setting-control* user-default dialog-volume) 0.0) + (set! (-> *setting-control* user-default ambient-volume) 0.0) + (set! *master-exit* #t) + ) + ) + ) + ) + ) + ) + (case *kernel-boot-message* + (('kiosk) + (if (and (= *master-mode* 'pause) + (>= (- (-> *display* real-clock frame-counter) (-> *cpad-list* cpads 0 real-change-time)) (seconds 60)) + ) + (set-master-mode 'game) + ) + ) + ) + 0 + (none) + ) + +(defun main-cheats () + (when (and (cpad-hold? 0 l3) (or *cheat-mode* (not (demo?)))) + ((lambda () + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-5 (-> *cheat-temp* 0))) + (cond + ((zero? v1-5) + (cond + ((cpad-pressed? 0 up) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 1) + (cond + ((cpad-pressed? 0 up) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 2) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 3) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 4) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 5) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 6) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 7) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 8) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 9) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 10) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 11) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 12) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 13) + (cond + ((cpad-pressed? 0 circle) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *cheat-mode* (not *cheat-mode*)) + (if *cheat-mode* + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 0) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ) + ) + ) + (when *cheat-mode* + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-146 (-> *cheat-temp* 1))) + (cond + ((zero? v1-146) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 1) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 2) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 3) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 4) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 5) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 6) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 7) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 8) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 9) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 10) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 11) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 12) + (cond + ((cpad-pressed? 0 up) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 13) + (cond + ((cpad-pressed? 0 up) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *cheat-mode* (if (= *cheat-mode* 'debug) + #t + 'debug + ) + ) + (if (= *cheat-mode* 'debug) + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 1) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + ((lambda () + (scf-get-territory) + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-6 (-> *cheat-temp* 2))) + (cond + ((zero? v1-6) + (cond + ((cpad-pressed? 0 l1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 1) + (cond + ((cpad-pressed? 0 r1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 2) + (cond + ((cpad-pressed? 0 l1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 3) + (cond + ((cpad-pressed? 0 r1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 4) + (cond + ((cpad-pressed? 0 triangle) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 5) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 6) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 7) + (cond + ((cpad-pressed? 0 square) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *progress-cheat* (if *progress-cheat* + #f + 'language + ) + ) + (if *progress-cheat* + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 2) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ) + ) + ) + (when *debug-segment* + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-94 (-> *cheat-temp* 3))) + (cond + ((zero? v1-94) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 1) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 2) + (cond + ((cpad-pressed? 0 triangle) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 3) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 4) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 5) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 6) + (cond + ((cpad-pressed? 0 triangle) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 7) + (cond + ((cpad-pressed? 0 circle) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *progress-cheat* (if *progress-cheat* + #f + 'pal + ) + ) + (if *progress-cheat* + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 3) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ) + ) + ) + (when (nonzero? (-> *cpad-list* cpads 1 button0-rel 0)) + (let ((v1-180 (-> *cheat-temp* 5))) + (cond + ((zero? v1-180) + (cond + ((cpad-pressed? 1 triangle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 1) + (cond + ((cpad-pressed? 1 x) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 2) + (cond + ((cpad-pressed? 1 circle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 3) + (cond + ((cpad-pressed? 1 square) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 4) + (cond + ((cpad-pressed? 1 triangle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 5) + (cond + ((cpad-pressed? 1 x) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 6) + (cond + ((cpad-pressed? 1 circle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 7) + (cond + ((cpad-pressed? 1 square) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *cheat-mode* (if (= *cheat-mode* 'camera) + #f + 'camera + ) + ) + (cond + (*cheat-mode* + (if (not *external-cam-mode*) + (external-cam-reset!) + ) + (set! *external-cam-mode* 'pad-1) + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (else + (set! *external-cam-mode* #f) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + (set! (-> *cheat-temp* 5) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + ) + (if (and *cheat-mode* (not *debug-segment*) (cpad-hold? 1 l3)) + ((lambda () + (cond + ((cpad-pressed? 1 x) + (send-event *target* 'get-pickup (pickup-type ammo-yellow) 1000.0) + (send-event *target* 'get-pickup (pickup-type ammo-red) 1000.0) + (send-event *target* 'get-pickup (pickup-type ammo-blue) 1000.0) + (send-event *target* 'get-pickup (pickup-type ammo-dark) 1000.0) + (send-event *target* 'get-pickup (pickup-type eco-pill-dark) 1000.0) + (send-event *target* 'get-pickup (pickup-type eco-pill-light) 1000.0) + (send-event *target* 'get-pickup (pickup-type skill) 1000.0) + (send-event *target* 'get-pickup (pickup-type gem) 1000.0) + (set! (-> *game-info* features) + (the-as + game-feature + (logior (game-feature + gun + gun-red-1 + gun-red-2 + gun-red-3 + gun-yellow-1 + gun-yellow-2 + gun-yellow-3 + gun-blue-1 + gun-blue-2 + gun-blue-3 + gun-dark-1 + gun-dark-2 + gun-dark-3 + board + darkjak + darkjak-smack + darkjak-bomb0 + darkjak-bomb1 + feature44 + feature45 + lightjak + lightjak-regen + lightjak-swoop + lightjak-freeze + lightjak-shield + ) + (-> *game-info* features) + ) + ) + ) + (set! (-> *game-info* debug-features) + (the-as + game-feature + (logior (game-feature gun gun-red-1 gun-yellow-1 gun-blue-1 gun-dark-1 board darkjak lightjak) + (-> *game-info* debug-features) + ) + ) + ) + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ((and (cpad-pressed? 1 triangle) (!= *cheat-mode* 'debug)) + (send-event *target* 'get-pickup (pickup-type ammo-yellow) 1000.0) + (send-event *target* 'get-pickup (pickup-type ammo-red) 1000.0) + (send-event *target* 'get-pickup (pickup-type ammo-blue) 1000.0) + (send-event *target* 'get-pickup (pickup-type ammo-dark) 1000.0) + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ((cpad-pressed? 1 square) + (set! (-> *level* disk-load-timing?) (not (-> *level* disk-load-timing?))) + (if (-> *level* disk-load-timing?) + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + ((cpad-pressed? 1 r1) + (set! *display-scene-control* (logxor *display-scene-control* (scene-controls bounds-spheres))) + (if (logtest? *display-scene-control* (scene-controls bounds-spheres)) + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + ((cpad-pressed? 1 circle) + (set! *display-bug-report* (not *display-bug-report*)) + (if *display-bug-report* + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + ) + (none) + ) + ) + ) + (if (and *display-bug-report* (not *progress-process*)) + (position->stream *stdcon* '*stdcon* #t) + ) + (when (and (= *cheat-mode* 'debug) (not *debug-segment*)) + (when (and (cpad-hold? 0 l1) (cpad-hold? 0 l2) (cpad-hold? 0 r1) (cpad-pressed? 0 r2)) + (if *target* + (stop 'debug) + (start 'play (get-current-continue-forced *game-info*)) + ) + ) + (if (and (cpad-hold? 0 left) (cpad-hold? 0 up) (cpad-pressed? 0 select)) + (initialize! *game-info* 'game (the-as game-save #f) "title-restart" (the-as resetter-spec #f)) + ) + (if (cpad-pressed? 1 r3) + (inspect global) + ) + (when (cpad-hold? 1 r3) + (with-dma-buffer-add-bucket ((s5-1 (if *debug-segment* + (-> *display* frames (-> *display* on-screen) debug-buf) + (-> *display* frames (-> *display* on-screen) global-buf) + ) + ) + (bucket-id bucket583) + ) + (show-iop-memory s5-1) + ) + ) + (if (cpad-pressed? 1 triangle) + (set! *display-level-border* (not *display-level-border*)) + ) + ) + (main-timeouts) + 0 + (none) + ) + +(defun end-display ((arg0 display)) + (let ((s5-0 (-> (if *debug-segment* + (-> arg0 frames (-> arg0 on-screen) debug-buf) + (-> arg0 frames (-> arg0 on-screen) global-buf) + ) + base + ) + ) + ) + (with-profiler 'debug *profile-debug-color* + (with-dma-buffer-add-bucket ((s3-1 (if *debug-segment* + (-> arg0 frames (-> arg0 on-screen) debug-buf) + (-> arg0 frames (-> arg0 on-screen) global-buf) + ) + ) + (bucket-id debug-no-zbuf2) + ) + (if (and (= *master-mode* 'pause) + (and (!= *cheat-mode* 'camera) (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1))) + ) + (draw-string-xy + (lookup-text! *common-text* (text-id progress-pause) #f) + s3-1 + 256 + (if (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time)) + 352 + 320 + ) + (font-color red) + (font-flags shadow kerning middle large) + ) + ) + (let ((s2-2 (the int (-> *font-context* origin y)))) + (cond + ((or (!= (-> *setting-control* user-current letterbox) 0.0) + (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time)) + ) + (+! s2-2 56) + ) + ((and *display-profile* (not *display-capture-mode*)) + (+! s2-2 48) + ) + ) + (when (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1) (-> *screen-shot-work* hud-enable)) + (let* ((v1-73 + (draw-string-xy + *stdcon0* + s3-1 + (the int (-> *font-context* origin x)) + s2-2 + (font-color default) + (font-flags shadow kerning) + ) + ) + (a3-4 (+ s2-2 (the int (* 2.0 (-> v1-73 b))))) + ) + (draw-string-xy + *stdcon1* + s3-1 + (the int (-> *font-context* origin x)) + a3-4 + (font-color default) + (font-flags shadow kerning) + ) + ) + ) + ) + (if (or (not *debug-segment*) *display-capture-mode*) + (set! *stdebug* *null*) + (set! *stdebug* *stdcon1*) + ) + (if *display-iop-info* + (show-iop-info s3-1) + ) + (if *display-memcard-info* + (show-mc-info s3-1) + ) + ) + (set! *stdcon* (clear *stdcon0*)) + ) + (let ((v1-113 *dma-mem-usage*)) + (when (nonzero? v1-113) + (set! (-> v1-113 length) (max 89 (-> v1-113 length))) + (set! (-> v1-113 data 88 name) "debug") + (+! (-> v1-113 data 88 count) 1) + (+! (-> v1-113 data 88 used) (&- + (-> (if *debug-segment* + (-> arg0 frames (-> arg0 on-screen) debug-buf) + (-> arg0 frames (-> arg0 on-screen) global-buf) + ) + base + ) + (the-as uint s5-0) + ) + ) + (set! (-> v1-113 data 88 total) (-> v1-113 data 88 used)) + ) + ) + ) + 0 + (none) + ) + +(defun display-loop-main ((arg0 display)) + "Main function to run entire game engine." + (with-pp + + ;; do some work on loading a level + (if (-> *level* loading-level) + (load-continue (-> *level* loading-level)) + ) + + ;; modify vertices for merc face animation. I believe this is somewhat racing DMA of merc data to VU1. + (with-profiler 'merc *profile-merc-color* + (blerc-execute) + (blerc-init) + ) + + ;; modify merc vertices for texture scrolling effect. Again, racing DMA. + (texscroll-execute) + + ;; modify merc vertices for water ripple effect. Again, racing DMA. + (ripple-execute) + + ;; detect player/camera entering/exiting regions, and run callbacks for those. + (region-execute) + + ;; decompress joint animations, compute joint and bone transformation for each actor. + ;; note that we also run this in a separate process. The math-engine will only run for + ;; actors that have changed their animation state. This is just a last chance for actors + ;; to update their joints before drawing. + (with-profiler 'joints *profile-joints-color* + (execute-math-engine) + ) + + ;; cloth simulation update + (execute-cloth-engine) + + (with-profiler 'debug *profile-debug-color* + ;; run debug callbacks + (let* ((s5-5 *debug-hook*) + (t9-13 (car s5-5)) + ) + (while (not (null? s5-5)) + ((the-as (function none) t9-13)) + (set! s5-5 (cdr s5-5)) + (set! t9-13 (car s5-5)) + ) + ) + ;; look for cheat-code inputs + (main-cheats) + ) + + ;; Update camera data for rendering based on the location of the in-game camera. + ;; (movement of the camera is handled by the camera process, this is just preparing + ;; to render) + (with-profiler 'camera *profile-camera-color* + (update-camera) + (execute-cam-post-hook-engine) + ) + + ;; Update start-menu map and masking + (update *bigmap*) + + ;; do some more level loading. + (if (-> *level* loading-level) + (load-continue (-> *level* loading-level)) + ) + + ;; run the drawing system! + ;; (note that this does a significant amount of non-drawing stuff, like collision callbacks, actors-update, + ;; navigation update...) + (with-profiler 'draw-hook *profile-draw-hook-color* + (*draw-hook*) + ) + + ;; more level loading + (if (-> *level* loading-level) + (load-continue (-> *level* loading-level)) + ) + + (if *display-color-bars* + (draw-color-bars *blit-displays-work*) + ) + + ;; run debug menu + (*menu-hook*) + ;; load the right language file. + (load-level-text-files -1) + + ;; draw screen filter + (when (-> *screen-filter* draw?) + (if (-> *screen-filter* lock-vsync?) + (set! (-> arg0 force-sync) (the-as uint (max 4 (the-as int (-> arg0 force-sync))))) + ) + (draw *screen-filter*) + ) + + ;; draw letterbox + (when (or (!= (-> *setting-control* user-current letterbox) 0.0) + (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time)) + ) + (if (< (-> *game-info* letterbox-time) (-> *display* base-clock frame-counter)) + (set! (-> *game-info* letterbox-time) (-> *display* base-clock frame-counter)) + ) + (if (and (= (-> *setting-control* user-current aspect-ratio) 'aspect4x3) + (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1) (-> *screen-shot-work* hud-enable)) + ) + (letterbox + (bucket-id tex-hud-pris2) + (if (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time)) + 1.0 + (-> *setting-control* user-current letterbox) + ) + ) + ) + ) + + ;; update blackout settings + (when (-> *setting-control* user-current render) + (if (< (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (set! (-> *setting-control* user-default bg-a-force) 1.0) + (set! (-> *setting-control* user-default bg-a-force) 0.0) + ) + ) + + ;; generate DMA to copy from render buffer to frame buffer. + (with-profiler 'blit-displays *profile-blit-color* + (blit-displays-work-method-19 *blit-displays-work*) + ) + + ;; wrap up this frame (drawing of stdcon, debugging, etc.) + (end-display arg0) + + ;; finalize the DMA chain. This does have some potentially complicated texture stuff. + ;; Note that, in debug mode, this will do a sync-path, waiting for VU1 to finish. + ;; this is required to be able to display profiling data for all VU1 renderers, since this + ;; function also draws the profiling bars + (display-frame-finish arg0) + + ;; flip DMA buffers! Wait for VU1 to finish, compute frame times, do a vsync, and send the next chain. + (display-sync arg0) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; new frame + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + ;; start stat collection for this frame + (start-profiling! (-> *perf-stats* data 0)) + + ;; update *teleport* flag, which is set when the game intentionally teleports the camera, + ;; and indicates that effects should not be gradually transitioned. + (set! (-> *time-of-day-context* title-updated) #f) + (set! *teleport* #f) + (when (nonzero? *teleport-count*) + (set! *teleport* #t) + (set! *teleport-count* (+ *teleport-count* -1)) + ) + + ;; do particles as soon as possible, since we're racing to send their data to VU1. + (execute-particle-local-space-engine 0) + (let ((gp-1 (-> pp clock))) + (set! (-> pp clock) (-> *display* part-clock)) + (process-particles) + (set! (-> pp clock) gp-1) + ) + (execute-particle-local-space-engine 1) + + ;; init unused? VU0 collision stuff. + (dma-send + (the-as dma-bank #x10008000) + (the-as uint (-> *collide-vif0-init* data)) + (the-as uint (/ (-> *collide-vif0-init* length) 4)) + ) + + ;; update sound system. + (swap-sound-buffers + (ear-trans 0) + (ear-trans 1) + (if (-> *setting-control* user-current lock-sound-camera-to-target) + (ear-trans 1) + (camera-pos) + ) + (-> (math-camera-matrix) fvec) + (-> (math-camera-matrix) rvec) + (-> *setting-control* user-current sound-ear-scale) + ) + + ;; update streaming animations + (str-play-kick) + + ;; update the level system + (level-update *level*) + + ;; update memory card + (mc-run) + + ;; check for memory card errors. + (auto-save-check) + 0 + (none) + ) + ) + +(defbehavior display-loop process () + "Main loop for running the game." + + (stack-size-set! (-> self main-thread) 512) + + ;; start process to run math (joints) engine. + (process-spawn-function + process + (lambda :behavior process + () + (logclear! (-> self mask) (process-mask freeze pause menu progress entity)) + (until #f + (with-profiler 'joints *profile-joints-color* + (execute-math-engine) + ) + (suspend) + ) + #f + ) + :name "matrix" + :from *4k-dead-pool* + :to *mid-pool* + ) + + + (let ((gp-1 *display*)) + ;; initial setup + (set! *teleport* #t) + (update *setting-control*) + (init-time-of-day-context *time-of-day-context*) + (display-sync gp-1) + (display-frame-finish gp-1) + (display-sync gp-1) + (install-handler 3 vblank-handler) + (free-nodes *touching-list*) + (prepare *collide-rider-pool*) + (update-actor-hash) + (blerc-init) + (dma-send + (the-as dma-bank #x10008000) + (the-as uint (-> *collide-vif0-init* data)) + (the-as uint (/ (-> *collide-vif0-init* length) 4)) + ) + (suspend) + (set! (-> *setting-control* user-default bg-a) 0.0) + (set! (-> gp-1 frames 0 start-time) (timer-count (the-as timer-bank #x10000800))) + (set! (-> gp-1 frames 1 start-time) (timer-count (the-as timer-bank #x10000800))) + (set! (-> gp-1 dog-ratio) 1.0) + + ;; main loop + (while *run* + (display-loop-main gp-1) + + ;; while we suspend, all actors will run. + (with-profiler 'actors *profile-actors-color* + (suspend) + ) + ) + ) + (set! *dproc* #f) + (format 0 "display is off #<#x~X>.~%" self) + 0 + ) + +(defun on ((arg0 symbol)) + "Start the display process." + (when (not *dproc*) + (when (not arg0) + (if (= (-> *level* level0 status) 'inactive) + (bg 'halfpipe) + ) + ) + (set! *run* #t) + (set! *dproc* (ppointer->process (process-spawn-function + process + display-loop + :name "display" + :from *4k-dead-pool* + :to *display-pool* + :stack *kernel-dram-stack* + ) + ) + ) + (cond + ((or (level-get-with-status *level* 'loaded) + (level-get-with-status *level* 'alive) + (level-get-with-status *level* 'active) + ) + (activate-levels! *level*) + (when (not arg0) + (let ((gp-1 (entity-by-type camera-start))) + (when (and gp-1 (type? gp-1 entity-actor)) + (while (not (camera-teleport-to-entity gp-1)) + (suspend) + ) + ) + ) + ) + (if (and (= *kernel-boot-message* 'art-group) *kernel-boot-art-group*) + (anim-tester-add-object *kernel-boot-art-group*) + ) + ) + (else + (kill-by-name "display" *active-pool*) + (set! *dproc* #f) + ) + ) + ) + *dproc* + ) + +(defun off () + "Stop the display process." + (stop 'debug) + (dotimes (gp-0 (-> *level* length)) + (let ((a0-2 (-> *level* level gp-0))) + (if (= (-> a0-2 status) 'active) + (deactivate a0-2) + ) + ) + ) + (set! *run* #f) + 0 + (none) + ) diff --git a/goal_src/jak3/engine/gfx/background/prototype.gc b/goal_src/jak3/engine/gfx/background/prototype.gc index c77321c0450..ae0e2303bb2 100644 --- a/goal_src/jak3/engine/gfx/background/prototype.gc +++ b/goal_src/jak3/engine/gfx/background/prototype.gc @@ -7,3 +7,110 @@ ;; DECOMP BEGINS +(defmethod login ((this prototype-inline-array-shrub)) + "Initialize the object after it is loaded." + (let ((s5-0 (-> *level* level *level-index* bsp))) + (dotimes (s4-0 (-> this length)) + (let ((s3-0 (-> this data s4-0))) + (when (and *debug-segment* (-> *screen-shot-work* highres-enable)) + (dotimes (v1-9 4) + (+! (-> s3-0 dists data v1-9) 40960000.0) + (set! (-> s3-0 rdists data v1-9) (/ 1.0 (-> s3-0 dists data v1-9))) + ) + ) + (set! *texture-masks* (-> s5-0 shrub-masks data (-> s3-0 texture-masks-index))) + (dotimes (s2-0 4) + (let ((a0-15 (-> s3-0 geometry s2-0))) + (if (nonzero? a0-15) + (login a0-15) + ) + ) + ) + ) + ) + ) + this + ) + +(defmethod mem-usage ((this prototype-array-tie) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 1 (-> usage length))) + (set! (-> usage data 0 name) "drawable-group") + (+! (-> usage data 0 count) 1) + (let ((v1-6 (asize-of this))) + (+! (-> usage data 0 used) v1-6) + (+! (-> usage data 0 total) (logand -16 (+ v1-6 15))) + ) + (dotimes (s3-0 (-> this length)) + (mem-usage (-> this array-data s3-0) usage flags) + ) + this + ) + +(defmethod mem-usage ((this prototype-bucket-tie) (usage memory-usage-block) (flags int)) + (dotimes (s3-0 4) + (let ((a0-1 (-> this tie-geom s3-0))) + (if (nonzero? a0-1) + (mem-usage a0-1 usage (logior flags 1)) + ) + ) + ) + (set! (-> usage length) (max 85 (-> usage length))) + (set! (-> usage data 84 name) "string") + (+! (-> usage data 84 count) 1) + (let ((v1-13 (asize-of (-> this name)))) + (+! (-> usage data 84 used) v1-13) + (+! (-> usage data 84 total) (logand -16 (+ v1-13 15))) + ) + (when (nonzero? (-> this tie-colors)) + (set! (-> usage length) (max 17 (-> usage length))) + (set! (-> usage data 16 name) "tie-pal") + (+! (-> usage data 16 count) 1) + (let ((v1-25 (asize-of (-> this tie-colors)))) + (+! (-> usage data 16 used) v1-25) + (+! (-> usage data 16 total) (logand -16 (+ v1-25 15))) + ) + ) + (if (nonzero? (-> this collide-hash-fragment-array)) + (mem-usage (-> this collide-hash-fragment-array) usage (logior flags 1)) + ) + this + ) + +(defmethod mem-usage ((this prototype-inline-array-shrub) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 1 (-> usage length))) + (set! (-> usage data 0 name) "drawable-group") + (+! (-> usage data 0 count) 1) + (let ((v1-6 (asize-of this))) + (+! (-> usage data 0 used) v1-6) + (+! (-> usage data 0 total) (logand -16 (+ v1-6 15))) + ) + (dotimes (s3-0 (-> this length)) + (mem-usage (-> this data s3-0) usage flags) + ) + this + ) + +(defmethod mem-usage ((this prototype-bucket-shrub) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 25 (-> usage length))) + (set! (-> usage data 24 name) "prototype-bucket-shrub") + (+! (-> usage data 24 count) 1) + (let ((v1-5 112)) + (+! (-> usage data 24 used) v1-5) + (+! (-> usage data 24 total) (logand -16 (+ v1-5 15))) + ) + (dotimes (s3-0 4) + (let ((a0-5 (-> this geometry s3-0))) + (if (nonzero? a0-5) + (mem-usage a0-5 usage (logior flags 1)) + ) + ) + ) + (set! (-> usage length) (max 85 (-> usage length))) + (set! (-> usage data 84 name) "string") + (+! (-> usage data 84 count) 1) + (let ((v1-22 (asize-of (-> this name)))) + (+! (-> usage data 84 used) v1-22) + (+! (-> usage data 84 total) (logand -16 (+ v1-22 15))) + ) + this + ) diff --git a/goal_src/jak3/engine/gfx/blit-displays-h.gc b/goal_src/jak3/engine/gfx/blit-displays-h.gc index 2d01452072f..33177d7164f 100644 --- a/goal_src/jak3/engine/gfx/blit-displays-h.gc +++ b/goal_src/jak3/engine/gfx/blit-displays-h.gc @@ -48,7 +48,7 @@ (blit-displays-work-method-16 () none) (blit-displays-work-method-17 (_type_ vector int float symbol) none) (blit-displays-work-method-18 () none) - (blit-displays-work-method-19 () none) + (blit-displays-work-method-19 (_type_) none) (blit-displays-work-method-20 () none) (get-menu-mode (_type_) symbol) (get-screen-copied (_type_) symbol) diff --git a/goal_src/jak3/engine/gfx/blit-displays.gc b/goal_src/jak3/engine/gfx/blit-displays.gc index 1b9cebe9aeb..681dda058bd 100644 --- a/goal_src/jak3/engine/gfx/blit-displays.gc +++ b/goal_src/jak3/engine/gfx/blit-displays.gc @@ -5,5 +5,7 @@ ;; name in dgo: blit-displays ;; dgos: GAME +(define-extern draw-color-bars (function blit-displays-work none)) + ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/gfx/foreground/eye-h.gc b/goal_src/jak3/engine/gfx/foreground/eye-h.gc index 9e294be4b37..bf8e619fcfe 100644 --- a/goal_src/jak3/engine/gfx/foreground/eye-h.gc +++ b/goal_src/jak3/engine/gfx/foreground/eye-h.gc @@ -9,6 +9,7 @@ (define-extern find-free-eye-index (function int string int int)) (define-extern free-eye-index (function int int)) (define-extern merc-eye-anim (function process-drawable none)) +(define-extern update-eyes (function none)) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/gfx/foreground/foreground-h.gc b/goal_src/jak3/engine/gfx/foreground/foreground-h.gc index 73a5e73e222..80d6ddc14c0 100644 --- a/goal_src/jak3/engine/gfx/foreground/foreground-h.gc +++ b/goal_src/jak3/engine/gfx/foreground/foreground-h.gc @@ -11,7 +11,7 @@ (define-extern *foreground-draw-engine* engine) (define-extern *default-shadow-settings* shadow-settings) (define-extern *foreground* foreground-globals) - +(define-extern foreground-draw-hud (function draw-control dma-buffer float none)) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/gfx/foreground/lights-h.gc b/goal_src/jak3/engine/gfx/foreground/lights-h.gc index f3d993e5dac..d866de3d9e3 100644 --- a/goal_src/jak3/engine/gfx/foreground/lights-h.gc +++ b/goal_src/jak3/engine/gfx/foreground/lights-h.gc @@ -56,6 +56,7 @@ ((index uint16) (count uint16) ) + :pack-me ) diff --git a/goal_src/jak3/engine/gfx/foreground/merc/generic-merc-h.gc b/goal_src/jak3/engine/gfx/foreground/merc/generic-merc-h.gc index ce5ea3c2558..2d591b57298 100644 --- a/goal_src/jak3/engine/gfx/foreground/merc/generic-merc-h.gc +++ b/goal_src/jak3/engine/gfx/foreground/merc/generic-merc-h.gc @@ -5,6 +5,8 @@ ;; name in dgo: generic-merc-h ;; dgos: GAME +(define-extern generic-merc-execute-all (function dma-buffer none)) + ;; DECOMP BEGINS (deftype merc-matrix (structure) diff --git a/goal_src/jak3/engine/gfx/foreground/merc/merc-blend-shape.gc b/goal_src/jak3/engine/gfx/foreground/merc/merc-blend-shape.gc index 48b4c3c9003..8040b5aba9a 100644 --- a/goal_src/jak3/engine/gfx/foreground/merc/merc-blend-shape.gc +++ b/goal_src/jak3/engine/gfx/foreground/merc/merc-blend-shape.gc @@ -5,5 +5,8 @@ ;; name in dgo: merc-blend-shape ;; dgos: GAME +(define-extern blerc-init (function none)) +(define-extern blerc-execute (function none)) + ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/gfx/foreground/ripple.gc b/goal_src/jak3/engine/gfx/foreground/ripple.gc index 95d0708eaa7..4485142e67a 100644 --- a/goal_src/jak3/engine/gfx/foreground/ripple.gc +++ b/goal_src/jak3/engine/gfx/foreground/ripple.gc @@ -7,6 +7,7 @@ (define-extern ripple-find-height (function process-drawable int vector float)) (define-extern ripple-make-request (function ripple-wave merc-effect none)) +(define-extern ripple-execute (function none)) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/gfx/foreground/shadow-cpu-h.gc b/goal_src/jak3/engine/gfx/foreground/shadow-cpu-h.gc index 5678883b841..48c3a249bcb 100644 --- a/goal_src/jak3/engine/gfx/foreground/shadow-cpu-h.gc +++ b/goal_src/jak3/engine/gfx/foreground/shadow-cpu-h.gc @@ -23,6 +23,7 @@ (declare-type shadow-vu1-constants structure) +(define-extern shadow-execute-all (function dma-buffer none)) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/gfx/generic/lightning/lightning-h.gc b/goal_src/jak3/engine/gfx/generic/lightning/lightning-h.gc index 16fbcb58b23..f1b75a22553 100644 --- a/goal_src/jak3/engine/gfx/generic/lightning/lightning-h.gc +++ b/goal_src/jak3/engine/gfx/generic/lightning/lightning-h.gc @@ -45,6 +45,7 @@ (define-extern process-drawable-art-error (state string process-drawable)) (define-extern unlink-lightning-spec-by-heap (function kheap none)) +(define-extern lightning-draw-all (function none)) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/gfx/hw/display-h.gc b/goal_src/jak3/engine/gfx/hw/display-h.gc index 3dfe0b6ef06..45f1b2ea882 100644 --- a/goal_src/jak3/engine/gfx/hw/display-h.gc +++ b/goal_src/jak3/engine/gfx/hw/display-h.gc @@ -62,8 +62,8 @@ At any point in time, there are 3 frames in progress: ((on-screen int32) (last-screen int32) (frames display-frame 2) - (bgcolor uint64) - (pmode uint64) + (bgcolor gs-bgcolor) + (pmode gs-pmode) (clock clock 22) (session-clock clock :overlay-at (-> clock 0)) (game-clock clock :overlay-at (-> clock 1)) @@ -111,7 +111,7 @@ At any point in time, there are 3 frames in progress: (set-display gp-0) (set! (-> gp-0 frames 0) (new 'global 'display-frame)) (set! (-> gp-0 frames 1) (new 'global 'display-frame)) - (set! (-> gp-0 pmode) (the-as uint 165)) + (set! (-> gp-0 pmode) (new 'static 'gs-pmode :en1 #x1 :crtmd #x1 :mmod #x1 :slbg #x1)) (set! (-> gp-0 run-half-speed) #f) (set! (-> gp-0 vu1-enable-user-menu) (vu1-renderer-mask rn3 @@ -142,7 +142,7 @@ At any point in time, there are 3 frames in progress: tie-water etie-water etie-scissor-water - rn31 + sprite rn32 rn33 rn34 @@ -178,7 +178,7 @@ At any point in time, there are 3 frames in progress: tie-water etie-water etie-scissor-water - rn31 + sprite rn32 rn33 rn34 diff --git a/goal_src/jak3/engine/gfx/hw/video.gc b/goal_src/jak3/engine/gfx/hw/video.gc index 009dfe33200..d7f67fa3363 100644 --- a/goal_src/jak3/engine/gfx/hw/video.gc +++ b/goal_src/jak3/engine/gfx/hw/video.gc @@ -5,5 +5,119 @@ ;; name in dgo: video ;; dgos: GAME +(define-extern *video-mode* int) + ;; DECOMP BEGINS +(defun set-video-mode ((arg0 symbol)) + (case arg0 + (('ntsc) + (set! (-> *setting-control* user-default screenx) 0) + (set! (-> *setting-control* user-default screeny) 8) + (set! (-> *video-params* display-fbp) 164) + (set! (-> *video-params* display-sy) 224) + (set! *video-mode* 0) + (sound-set-fps 60) + ) + (('pal) + (set! (-> *setting-control* user-default screenx) 0) + (set! (-> *setting-control* user-default screeny) 24) + (set! (-> *video-params* display-fbp) 144) + (set! (-> *video-params* display-sy) 256) + (set! *video-mode* 1) + (sound-set-fps 50) + ) + ) + (set-time-ratios *display* (-> *display* dog-ratio)) + (set! (-> *video-params* reset-video-mode) #t) + (set! (-> *math-camera* isometric uvec y) 0.5) + (set! (-> *math-camera* y-clip) 416.0) + (set! (-> *math-camera* y-pix) (* 0.5 (-> *math-camera* y-clip))) + (set! *profile-y* 1848) + (set! (-> *video-params* set-video-mode) #t) + 0 + (none) + ) + +(defun get-video-mode () + (-> *setting-control* user-current video-mode) + ) + +(defun set-aspect-ratio ((arg0 symbol)) + (case arg0 + (('aspect4x3) + (set! (-> *video-params* relative-x-scale) 1.0) + (set! (-> *video-params* relative-x-scale-reciprical) 1.0) + ) + (('aspect16x9) + (set! (-> *video-params* relative-x-scale) 0.75) + (set! (-> *video-params* relative-x-scale-reciprical) 1.3333334) + ) + ) + 0 + (none) + ) + +(defun get-aspect-ratio () + (-> *setting-control* user-current aspect-ratio) + ) + +(defun set-progressive-scan ((arg0 symbol)) + (set! (-> *setting-control* user-default set-video-mode) arg0) + 0 + (none) + ) + +(defun get-progressive-scan () + (-> *setting-control* user-current set-video-mode) + ) + +(defun set-graphics-mode () + (let ((v1-0 *setting-control*) + (gp-0 (the-as gs-bank #x12000000)) + (s5-0 *video-params*) + ) + (let ((s4-0 *display*)) + (cond + ((-> v1-0 user-current set-video-mode) + (when (nonzero? (-> s5-0 smode2)) + (reset-graph 0 0 80 0) + (set! (-> s5-0 smode2) (the-as uint 0)) + 0 + ) + (set! (-> gp-0 display1) (new 'static 'gs-display + :magh #x1 + :dw #x4ff + :dy (+ (-> s5-0 display-dy) 50) + :dx (+ (* (-> s5-0 display-dx) 2) 326) + :dh (+ (* (-> s5-0 display-sy) 2) -1) + ) + ) + ) + (else + (when (or (!= (-> s5-0 smode2) 1) (-> *video-params* set-video-mode)) + (if (= (-> *setting-control* user-current video-mode) 'ntsc) + (reset-graph 0 1 2 0) + (reset-graph 0 1 3 0) + ) + (set! (-> s5-0 smode2) (the-as uint 1)) + (set! (-> s5-0 set-video-mode) #f) + ) + (set! (-> gp-0 display1) (new 'static 'gs-display + :magh #x3 + :dw #x9ff + :dy (+ (-> s5-0 display-dy) 50) + :dx (+ (* (-> s5-0 display-dx) 4) 652) + :dh (+ (* (-> s5-0 display-sy) 2) -1) + ) + ) + ) + ) + (set! (-> gp-0 pmode) (-> s4-0 pmode)) + (set! (-> gp-0 bgcolor) (-> s4-0 bgcolor)) + ) + (set! (-> gp-0 dspfb1) (new 'static 'gs-display-fb :fbw #xa :fbp (-> s5-0 display-fbp))) + ) + 0 + (none) + ) diff --git a/goal_src/jak3/engine/gfx/mood/time-of-day-h.gc b/goal_src/jak3/engine/gfx/mood/time-of-day-h.gc index dce11e19611..8d7852d9b09 100644 --- a/goal_src/jak3/engine/gfx/mood/time-of-day-h.gc +++ b/goal_src/jak3/engine/gfx/mood/time-of-day-h.gc @@ -29,7 +29,10 @@ (define-extern time-of-day-interp-colors (function (pointer rgba) uint mood-context none)) (define-extern time-of-day-interp-colors-scratch (function (pointer rgba) time-of-day-palette mood-context none)) (declare-type time-of-day-proc process) +(declare-type time-of-day-context structure) (define-extern *time-of-day* (pointer time-of-day-proc)) +(define-extern update-time-of-day (function time-of-day-context none)) +(define-extern init-time-of-day-context (function time-of-day-context symbol)) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/gfx/ocean/ocean-h.gc b/goal_src/jak3/engine/gfx/ocean/ocean-h.gc index 3d336fdd719..c9b652abc22 100644 --- a/goal_src/jak3/engine/gfx/ocean/ocean-h.gc +++ b/goal_src/jak3/engine/gfx/ocean/ocean-h.gc @@ -411,8 +411,8 @@ ) (:methods (get-height (_type_ vector symbol) float) - (ocean-method-12 () none) - (ocean-method-13 () none) + (draw! (_type_) none) + (update-map (_type_) none) (ocean-method-14 () none) (ocean-method-15 () none) (ocean-method-16 () none) diff --git a/goal_src/jak3/engine/gfx/sky/sky-h.gc b/goal_src/jak3/engine/gfx/sky/sky-h.gc index 11aca67eddc..a0414130b3d 100644 --- a/goal_src/jak3/engine/gfx/sky/sky-h.gc +++ b/goal_src/jak3/engine/gfx/sky/sky-h.gc @@ -199,7 +199,7 @@ (sky-work-method-11 () none) (sky-work-method-12 () none) (sky-work-method-13 () none) - (sky-work-method-14 () none) + (draw (_type_) none) (sky-work-method-15 () none) (sky-work-method-16 () none) (sky-work-method-17 () none) diff --git a/goal_src/jak3/engine/gfx/sprite/particles/sparticle-h.gc b/goal_src/jak3/engine/gfx/sprite/particles/sparticle-h.gc index 1cd92429ce8..344221d1c60 100644 --- a/goal_src/jak3/engine/gfx/sprite/particles/sparticle-h.gc +++ b/goal_src/jak3/engine/gfx/sprite/particles/sparticle-h.gc @@ -46,6 +46,8 @@ ) (define-extern kill-all-particles-in-level (function level int)) +(define-extern remap-all-particles (function none)) +(define-extern process-particles (function none)) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/gfx/sprite/particles/sparticle-launcher-h.gc b/goal_src/jak3/engine/gfx/sprite/particles/sparticle-launcher-h.gc index 5e312b3f21d..6783910dac6 100644 --- a/goal_src/jak3/engine/gfx/sprite/particles/sparticle-launcher-h.gc +++ b/goal_src/jak3/engine/gfx/sprite/particles/sparticle-launcher-h.gc @@ -11,6 +11,8 @@ (define-extern unlink-part-group-by-heap (function kheap int)) (define-extern particle-adgif-cache-flush (function none)) +(define-extern execute-part-engine (function none)) +(define-extern execute-particle-local-space-engine (function int none)) ;; +++sp-field-id (defenum sp-field-id diff --git a/goal_src/jak3/engine/gfx/vu1-user-h.gc b/goal_src/jak3/engine/gfx/vu1-user-h.gc index ca22a18639c..447389fd8ce 100644 --- a/goal_src/jak3/engine/gfx/vu1-user-h.gc +++ b/goal_src/jak3/engine/gfx/vu1-user-h.gc @@ -728,7 +728,7 @@ (tie-water) (etie-water) (etie-scissor-water) - (rn31) + (sprite) (rn32) (rn33) (rn34) diff --git a/goal_src/jak3/engine/level/level-h.gc b/goal_src/jak3/engine/level/level-h.gc index 8e80bfd79fc..29f68ffe47f 100644 --- a/goal_src/jak3/engine/level/level-h.gc +++ b/goal_src/jak3/engine/level/level-h.gc @@ -475,10 +475,10 @@ (level-get-for-use (_type_ symbol symbol) level) (activate-levels! (_type_) int) (level-group-method-14 () none) - (level-group-method-15 () none) + (debug-draw-actors (_type_ symbol) none) (assign-draw-indices (_type_) none) - (level-group-method-17 () none) - (level-group-method-18 () none) + (actors-update (_type_) none) + (update-nav-meshes-method (_type_) none) (level-update (_type_) none) (level-get-target-inside (_type_) level) (init-level-system (_type_ symbol) none) diff --git a/goal_src/jak3/engine/level/level.gc b/goal_src/jak3/engine/level/level.gc index 8969a7be094..efac74e3d73 100644 --- a/goal_src/jak3/engine/level/level.gc +++ b/goal_src/jak3/engine/level/level.gc @@ -9,6 +9,21 @@ (define-extern *level-type-list* type) (define-extern city-sound-expand-want-list (function none)) +(defmacro start-debug (str &rest args) + `(format 0 ,(string-append "[START] " str) ,@args) + 0) + +(defmacro test-play () + "Temporary start macro" + `(begin + (start-debug "test-play~%") + (define *kernel-boot-message* 'play) + (start-debug "loading GAME.DGO~%") + (load-package "game" global) + (play-boot) + ) + ) + ;; DECOMP BEGINS (defun level-memory-mode->string ((arg0 level-memory-mode)) diff --git a/goal_src/jak3/engine/level/region-h.gc b/goal_src/jak3/engine/level/region-h.gc index d498d1576ac..d2be6e83a37 100644 --- a/goal_src/jak3/engine/level/region-h.gc +++ b/goal_src/jak3/engine/level/region-h.gc @@ -6,6 +6,7 @@ ;; dgos: GAME (declare-type region-prim-area structure) +(define-extern region-execute (function none)) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/spatial-hash/actor-hash-h.gc b/goal_src/jak3/engine/spatial-hash/actor-hash-h.gc index 73307c3da09..1537dbfa76d 100644 --- a/goal_src/jak3/engine/spatial-hash/actor-hash-h.gc +++ b/goal_src/jak3/engine/spatial-hash/actor-hash-h.gc @@ -5,6 +5,8 @@ ;; name in dgo: actor-hash-h ;; dgos: GAME +(define-extern update-actor-hash (function none)) + ;; DECOMP BEGINS (define *actor-list* (the-as (pointer collide-shape) (malloc 'global 1024))) diff --git a/goal_src/jak3/engine/ui/bigmap-h.gc b/goal_src/jak3/engine/ui/bigmap-h.gc index 4d651ad9987..cd1c7001bf8 100644 --- a/goal_src/jak3/engine/ui/bigmap-h.gc +++ b/goal_src/jak3/engine/ui/bigmap-h.gc @@ -61,7 +61,7 @@ (:methods (new (symbol type) _type_) (bigmap-method-9 () none) - (bigmap-method-10 () none) + (update (_type_) none) (draw (_type_ int int int int) int) (bigmap-method-12 () none) (bigmap-method-13 () none) diff --git a/goal_src/jak3/engine/ui/progress/progress-h.gc b/goal_src/jak3/engine/ui/progress/progress-h.gc index e6376337ce9..f16acea717d 100644 --- a/goal_src/jak3/engine/ui/progress/progress-h.gc +++ b/goal_src/jak3/engine/ui/progress/progress-h.gc @@ -11,6 +11,8 @@ (define-extern activate-progress (function process symbol none)) (define-extern *progress-work* progress-work) (define-extern progress-allowed? (function symbol)) +(define-extern deactivate-progress (function none)) +(define-extern hide-progress-screen (function none)) ;; +++progress-icon-flags (defenum progress-icon-flags diff --git a/goal_src/jak3/kernel-defs.gc b/goal_src/jak3/kernel-defs.gc index 4c909711e88..8f764201f7c 100644 --- a/goal_src/jak3/kernel-defs.gc +++ b/goal_src/jak3/kernel-defs.gc @@ -132,10 +132,11 @@ (define-extern scf-get-aspect "Defined in the kernel" (function uint)) (define-extern scf-get-timeout (function int)) (define-extern scf-get-inactive-timeout (function int)) -(define-extern kernel-shutdown (function none)) +(define-extern kernel-shutdown (function int none)) (define-extern *boot-video-mode* "Defined in the kernel" int) (define-extern *kernel-boot-message* symbol) (define-extern *kernel-symbol-warnings* symbol) +(define-extern *kernel-boot-art-group* string) (define-extern symbol->string (function symbol string)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/goal_src/jak3/kernel/gkernel-h.gc b/goal_src/jak3/kernel/gkernel-h.gc index e9efa34d77c..40d9e40d64b 100644 --- a/goal_src/jak3/kernel/gkernel-h.gc +++ b/goal_src/jak3/kernel/gkernel-h.gc @@ -424,7 +424,7 @@ ;; this uses the self field, which seems to always just get set to the object. ;; confirmed in Jak 1 that using self here is useless, not sure... `(let ((the-pp ,ppointer)) - (if the-pp (-> the-pp 0 self)) + (the process (if the-pp (-> the-pp 0 self))) ) ) diff --git a/goal_src/jak3/levels/city/common/trail-h.gc b/goal_src/jak3/levels/city/common/trail-h.gc index ab083fe78f9..baaac3aedc4 100644 --- a/goal_src/jak3/levels/city/common/trail-h.gc +++ b/goal_src/jak3/levels/city/common/trail-h.gc @@ -163,7 +163,7 @@ (trail-graph-method-11 () none) (trail-graph-method-12 () none) (trail-graph-method-13 () none) - (trail-graph-method-14 () none) + (debug-draw (_type_) none) (trail-graph-method-15 () none) (trail-graph-method-16 () none) (trail-graph-method-17 () none) diff --git a/goalc/debugger/Debugger.cpp b/goalc/debugger/Debugger.cpp index ab4fb9832d0..a14d207e6ff 100644 --- a/goalc/debugger/Debugger.cpp +++ b/goalc/debugger/Debugger.cpp @@ -732,6 +732,95 @@ void Debugger::read_symbol_table_jak2() { m_symbol_name_to_offset_map.size(), timer.getMs()); } +void Debugger::read_symbol_table_jak3() { + using namespace jak3_symbols; + using namespace jak3; + ASSERT(is_valid() && is_attached() && is_halted()); + u32 bytes_read = 0; + u32 reads = 0; + Timer timer; + + constexpr int kS7Offset = ((GOAL_MAX_SYMBOLS / 2) * 4 + 1); + static_assert(kS7Offset == 0x8001); // this is what we have hardcoded now + u32 st_base = m_debug_context.s7 - kS7Offset; + u32 empty_pair_offset = + (m_debug_context.s7 + S7_OFF_FIX_SYM_EMPTY_PAIR /*- PAIR_OFFSET*/) - st_base; + + constexpr u32 kSymbolMemSize = 2 * (GOAL_MAX_SYMBOLS * 4); // symbol, then strings. + std::vector mem; + mem.resize(kSymbolMemSize); + + if (!xdbg::read_goal_memory(mem.data(), kSymbolMemSize, st_base, m_debug_context, + m_memory_handle)) { + lg::print("Read failed during read_symbol_table\n"); + return; + } + reads++; + bytes_read += kSymbolMemSize; + + m_symbol_name_to_offset_map.clear(); + m_symbol_offset_to_name_map.clear(); + m_symbol_name_to_value_map.clear(); + + // now loop through all the symbols + for (int i = 0; i < GOAL_MAX_SYMBOLS; i++) { + u32 offset = i * 4; + if (offset == empty_pair_offset) { + continue; + } + auto sym_val = *(u32*)(mem.data() + offset); + auto info = *(u32*)(mem.data() + offset + kSymbolMemSize / 2); + if (info) { + // now get the string. + char str_buff[128]; + if (!xdbg::read_goal_memory((u8*)str_buff, 128, info + 4, m_debug_context, m_memory_handle)) { + lg::print("Read symbol string failed during read_symbol_table\n"); + return; + } + reads++; + bytes_read += 128; + // just in case + str_buff[127] = '\0'; + + // GOAL sym - s7 + auto sym_offset = s32(offset + st_base) - s32(m_debug_context.s7); + // ASSERT(sym_offset >= -SYM_TABLE_MEM_SIZE / 4); + // ASSERT(sym_offset < SYM_TABLE_MEM_SIZE / 4); + + std::string str(str_buff); + if (str.length() >= 50) { + lg::print("Invalid symbol #x{:x}!\n", sym_offset); + continue; + } + + printf("got %s\n", str.c_str()); + + // update maps + if (m_symbol_name_to_offset_map.find(str) != m_symbol_name_to_offset_map.end()) { + if (str == "asize-of-basic-func") { + // this is an actual bug in kscheme. The bug has no effect, but we replicate it so that + // the symbol table layout is closer. + + // to hide this duplicate symbol, we append "-hack-copy" to the end of it. + str += "-hack-copy"; + } else { + lg::print("Symbol {} (#x{:x}) appears multiple times!\n", str, sym_offset); + continue; + // ASSERT(false); + } + } + + m_symbol_name_to_offset_map[str] = sym_offset; + m_symbol_offset_to_name_map[sym_offset] = str; + m_symbol_name_to_value_map[str] = sym_val; + } + } + + ASSERT(m_symbol_offset_to_name_map.size() == m_symbol_name_to_offset_map.size()); + lg::print("Read symbol table ({} bytes, {} reads, {} symbols, {:.2f} ms)\n", bytes_read, reads, + m_symbol_name_to_offset_map.size(), timer.getMs()); +} + /*! * Read the GOAL Symbol table from an attached and halted target. */ @@ -743,6 +832,9 @@ void Debugger::read_symbol_table() { case GameVersion::Jak2: read_symbol_table_jak2(); break; + case GameVersion::Jak3: + read_symbol_table_jak3(); + break; default: ASSERT(false); } diff --git a/goalc/debugger/Debugger.h b/goalc/debugger/Debugger.h index 49c6aa12d7a..0915ef5c9ff 100644 --- a/goalc/debugger/Debugger.h +++ b/goalc/debugger/Debugger.h @@ -91,6 +91,7 @@ class Debugger { void read_symbol_table(); void read_symbol_table_jak1(); void read_symbol_table_jak2(); + void read_symbol_table_jak3(); u32 get_symbol_address(const std::string& sym_name); bool get_symbol_value(const std::string& sym_name, u32* output); const char* get_symbol_name_from_offset(s32 ofs) const; diff --git a/test/decompiler/reference/jak3/decompiler-macros.gc b/test/decompiler/reference/jak3/decompiler-macros.gc index 01cafdf17b1..69fede4dec6 100644 --- a/test/decompiler/reference/jak3/decompiler-macros.gc +++ b/test/decompiler/reference/jak3/decompiler-macros.gc @@ -82,7 +82,7 @@ ;; this uses the self field, which seems to always just get set to the object. ;; confirmed in Jak 1 that using self here is useless, not sure... `(let ((the-pp ,ppointer)) - (if the-pp (-> the-pp 0 self)) + (the process (if the-pp (-> the-pp 0 self))) ) ) @@ -1596,5 +1596,21 @@ `(lookup-texture-by-id ,(string->symbol-format "{}-{}" name tpage)) ) +(defmacro vitof12.xyzw (dst src) + "convert from a 20.12 integer. This does the multiply while the number is still + a float. This will have issues for very large floats, but it seems like this + is how PCSX2 does it as well, so maybe it's right? + NOTE: this is the only version of the instruction used in Jak 1, so we + don't need to worry about masks." + +`(begin + (rlet ((temp :class vf)) + (.itof.vf ,dst ,src) + (set! temp 0.000244140625) + (.mul.x.vf ,dst ,dst temp) + ) + ) +) + (import "goal_src/jak3/engine/data/tpages.gc") (import "goal_src/jak3/engine/data/textures.gc") \ No newline at end of file diff --git a/test/decompiler/reference/jak3/engine/collide/collide-touch-h_REF.gc b/test/decompiler/reference/jak3/engine/collide/collide-touch-h_REF.gc index 993bfa89e51..7be41fba4c8 100644 --- a/test/decompiler/reference/jak3/engine/collide/collide-touch-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/collide/collide-touch-h_REF.gc @@ -173,9 +173,9 @@ storing a record of the primitives involved." (:methods (new (symbol type) _type_) (touching-list-method-9 () none) - (touching-list-method-10 () none) + (free-nodes (_type_) none) (touching-list-method-11 () none) - (touching-list-method-12 () none) + (send-events-for-touching-shapes (_type_) none) (touching-list-method-13 () none) ) ) diff --git a/test/decompiler/reference/jak3/engine/collide/main-collide_REF.gc b/test/decompiler/reference/jak3/engine/collide/main-collide_REF.gc new file mode 100644 index 00000000000..ee50e2a3b79 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/collide/main-collide_REF.gc @@ -0,0 +1,201 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function drawable-sphere-box-intersect? +;; INFO: Used lq/sq +(defun drawable-sphere-box-intersect? ((arg0 drawable) (arg1 bounding-box4w)) + (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128) (a0-1 uint128) (a1-2 uint128) (a2-0 uint128)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (nop!) + (nop!) + (.lvf vf1 (&-> arg0 bsphere quad)) + (.add.w.vf vf2 vf1 vf1 :mask #b111) + (let ((v1-0 (-> arg1 min quad))) + (.sub.w.vf vf1 vf1 vf1 :mask #b111) + (let ((a1-1 (-> arg1 max quad))) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf3 vf1) + (nop!) + (.mov a0-1 vf4) + (nop!) + (.mov a2-0 vf3) + (nop!) + (.pcgtw a1-2 a2-0 a1-1) + ) + (nop!) + (.pcgtw v1-1 v1-0 a0-1) + ) + (nop!) + (.por v1-2 a1-2 v1-1) + (nop!) + (.ppach v1-3 (the-as uint128 0) v1-2) + (nop!) + (let ((v1-4 (shl (the-as int v1-3) 16))) + (nop!) + (zero? v1-4) + ) + ) + ) + +;; definition for function instance-sphere-box-intersect? +;; INFO: Used lq/sq +(defun instance-sphere-box-intersect? ((arg0 drawable) (arg1 instance-tie) (arg2 bounding-box4w)) + (local-vars + (v1-3 uint128) + (v1-4 uint128) + (v1-5 uint128) + (a0-2 uint128) + (a1-2 uint128) + (a2-1 uint128) + (a3-1 uint128) + (a3-3 uint128) + (a3-4 uint128) + (t0-1 uint128) + (t0-2 uint128) + (t1-0 uint128) + (t2-1 uint128) + (t2-2 uint128) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (nop!) + (let ((v1-0 (-> arg1 max-scale))) + (nop!) + (let ((a3-0 (the-as uint128 (-> arg1 origin long 3)))) + (nop!) + (let ((t2-0 (the-as uint128 (-> arg1 origin long 0)))) + (.pextlh a3-1 a3-0 0) + (let ((t0-0 (the-as uint128 (-> arg1 origin long 1)))) + (.pw.sra t1-0 a3-1 10) + (let ((a3-2 (the-as uint128 (-> arg1 origin long 2)))) + (.pextlh t2-1 t2-0 0) + (nop!) + (.pw.sra t2-2 t2-1 16) + (nop!) + (.pextlh t0-1 t0-0 0) + (.mov vf8 t1-0) + (.pw.sra t0-2 t0-1 16) + (.mov vf5 t2-2) + (.pextlh a3-3 a3-2 0) + ) + ) + ) + ) + (.mov vf6 t0-2) + (.pw.sra a3-4 a3-3 16) + (.lvf vf9 (&-> arg1 bsphere quad)) + (nop!) + (.mov vf7 a3-4) + (nop!) + (.mov vf10 v1-0) + ) + (.itof.vf vf8 vf8) + (nop!) + (vitof12.xyzw vf5 vf5) + (nop!) + (vitof12.xyzw vf6 vf6) + (nop!) + (vitof12.xyzw vf7 vf7) + (nop!) + (.add.vf vf8 vf8 vf9 :mask #b111) + (nop!) + (nop!) + (.lvf vf9 (&-> arg0 bsphere quad)) + (vitof12.xyzw vf10 vf10) + (nop!) + (.mul.w.vf vf10 vf10 vf9 :mask #b1) + (nop!) + (.mul.x.vf acc vf5 vf9) + (nop!) + (.add.mul.y.vf acc vf6 vf9 acc) + (let ((v1-2 (-> arg2 min quad))) + (.add.mul.z.vf acc vf7 vf9 acc) + (let ((a1-1 (-> arg2 max quad))) + (.add.mul.w.vf vf1 vf8 vf0 acc) + (nop!) + (.add.x.vf vf2 vf1 vf10 :mask #b111) + (nop!) + (.sub.x.vf vf1 vf1 vf10 :mask #b111) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf3 vf1) + (nop!) + (.mov a0-2 vf4) + (nop!) + (.mov a2-1 vf3) + (nop!) + (.pcgtw a1-2 a2-1 a1-1) + ) + (nop!) + (.pcgtw v1-3 v1-2 a0-2) + ) + (nop!) + (.por v1-4 a1-2 v1-3) + (nop!) + (.ppach v1-5 (the-as uint128 0) v1-4) + (nop!) + (let ((v1-6 (shl (the-as int v1-5) 16))) + (nop!) + (zero? v1-6) + ) + ) + ) + +;; definition for function instance-tfragment-add-debug-sphere +;; INFO: Used lq/sq +(defun instance-tfragment-add-debug-sphere ((arg0 drawable) (arg1 instance-tie)) + (local-vars (v1-1 uint128) (v1-2 uint128) (a3-0 float)) + (rlet ((vf0 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (nop!) + (let ((v1-0 (the-as uint128 (-> arg1 origin long 3)))) + (.pextlh v1-1 v1-0 0) + ) + (.lvf vf9 (&-> arg0 bsphere quad)) + (.pw.sra v1-2 v1-1 10) + (.lvf vf10 (&-> arg1 bsphere quad)) + (nop!) + (.mov vf12 v1-2) + (.itof.vf vf12 vf12) + (nop!) + (.add.vf vf10 vf10 vf12 :mask #b111) + (nop!) + (.add.vf vf9 vf9 vf10 :mask #b111) + (nop!) + (.add.w.vf vf11 vf0 vf9 :mask #b1) + (nop!) + (.mov a3-0 vf11) + (nop!) + (let ((a2-0 (new-stack-vector0))) + (.svf (&-> a2-0 quad) vf9) + (add-debug-sphere #t (bucket-id bucket583) a2-0 a3-0 (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)) + ) + ) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/draw/drawable-group_REF.gc b/test/decompiler/reference/jak3/engine/draw/drawable-group_REF.gc new file mode 100644 index 00000000000..b7ca6a44258 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/draw/drawable-group_REF.gc @@ -0,0 +1,115 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 0 of type drawable-group +(defmethod new drawable-group ((allocation symbol) (type-to-make type) (arg0 int)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* arg0 4)))))) + (set! (-> v0-0 length) arg0) + v0-0 + ) + ) + +;; definition for method 2 of type drawable-group +(defmethod print ((this drawable-group)) + (format #t "#<~A @ #x~X [~D]" (-> this type) this (-> this length)) + (dotimes (s5-0 (-> this length)) + (format #t " ~A" (-> this data s5-0)) + ) + (format #t ">") + this + ) + +;; definition for method 4 of type drawable-group +(defmethod length ((this drawable-group)) + (-> this length) + ) + +;; definition for method 5 of type drawable-group +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this drawable-group)) + (the-as int (+ (-> drawable-group size) (* (-> this length) 4))) + ) + +;; definition for method 8 of type drawable-group +(defmethod mem-usage ((this drawable-group) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 1 (-> usage length))) + (set! (-> usage data 0 name) "drawable-group") + (+! (-> usage data 0 count) 1) + (let ((v1-6 (asize-of this))) + (+! (-> usage data 0 used) v1-6) + (+! (-> usage data 0 total) (logand -16 (+ v1-6 15))) + ) + (dotimes (s3-0 (-> this length)) + (mem-usage (-> this data s3-0) usage flags) + ) + this + ) + +;; definition for method 9 of type drawable-group +(defmethod login ((this drawable-group)) + "Initialize the object after it is loaded." + (dotimes (s5-0 (-> this length)) + (login (-> this data s5-0)) + ) + this + ) + +;; definition for method 10 of type drawable-group +;; WARN: Return type mismatch int vs none. +(defmethod draw ((this drawable-group)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + (when (vis-cull (-> this id)) + (when (sphere-cull (-> this bsphere)) + (dotimes (s5-0 (-> this length)) + (draw (-> this data s5-0)) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 13 of type drawable-group +;; WARN: Return type mismatch int vs none. +(defmethod collect-stats ((this drawable-group)) + "Collect triangle/perf statistics for rendering. + This is only called when viewing stats. + The vis-bits and culling registers are loaded during this time." + (when (vis-cull (-> this id)) + (when (sphere-cull (-> this bsphere)) + (dotimes (s5-0 (-> this length)) + (collect-stats (-> this data s5-0)) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 14 of type drawable-group +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw ((this drawable-group)) + "Debug-draw a drawable and its children. Typically uses the debug-draw functions." + (when (vis-cull (-> this id)) + (when (sphere-cull (-> this bsphere)) + (dotimes (s5-0 (-> this length)) + (debug-draw (-> this data s5-0)) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 15 of type drawable-group +(defmethod unpack-vis ((this drawable-group) (arg0 (pointer int8)) (arg1 (pointer int8))) + (dotimes (s4-0 (-> this length)) + (set! arg1 (unpack-vis (-> this data s4-0) arg0 arg1)) + ) + arg1 + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/draw/drawable-h_REF.gc b/test/decompiler/reference/jak3/engine/draw/drawable-h_REF.gc index 62c41ce8abb..84d663d5d1a 100644 --- a/test/decompiler/reference/jak3/engine/draw/drawable-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/draw/drawable-h_REF.gc @@ -15,8 +15,8 @@ control over memory layout for use with DMA." (:methods (login (_type_) _type_) (draw (_type_) none) - (drawable-method-11 () none) - (drawable-method-12 () none) + (drawable-method-11 (_type_) none) + (drawable-method-12 (_type_) none) (collect-stats (_type_) none) (debug-draw (_type_) none) (unpack-vis (_type_ (pointer int8) (pointer int8)) (pointer int8)) diff --git a/test/decompiler/reference/jak3/engine/draw/drawable-inline-array_REF.gc b/test/decompiler/reference/jak3/engine/draw/drawable-inline-array_REF.gc new file mode 100644 index 00000000000..def4db5bc4e --- /dev/null +++ b/test/decompiler/reference/jak3/engine/draw/drawable-inline-array_REF.gc @@ -0,0 +1,44 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 4 of type drawable-inline-array +(defmethod length ((this drawable-inline-array)) + (-> this length) + ) + +;; definition for method 9 of type drawable-inline-array +(defmethod login ((this drawable-inline-array)) + "Initialize the object after it is loaded." + this + ) + +;; definition for method 10 of type drawable-inline-array +;; WARN: Return type mismatch int vs none. +(defmethod draw ((this drawable-inline-array)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + 0 + (none) + ) + +;; definition for method 13 of type drawable-inline-array +;; WARN: Return type mismatch int vs none. +(defmethod collect-stats ((this drawable-inline-array)) + "Collect triangle/perf statistics for rendering. + This is only called when viewing stats. + The vis-bits and culling registers are loaded during this time." + 0 + (none) + ) + +;; definition for method 14 of type drawable-inline-array +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw ((this drawable-inline-array)) + "Debug-draw a drawable and its children. Typically uses the debug-draw functions." + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/draw/drawable-tree_REF.gc b/test/decompiler/reference/jak3/engine/draw/drawable-tree_REF.gc new file mode 100644 index 00000000000..0ae495dfafc --- /dev/null +++ b/test/decompiler/reference/jak3/engine/draw/drawable-tree_REF.gc @@ -0,0 +1,101 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 10 of type drawable-tree-array +;; WARN: Return type mismatch int vs none. +(defmethod draw ((this drawable-tree-array)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + (case (-> *level* draw-level *draw-index* display?) + (('special #f) + ) + (else + (dotimes (s5-0 (-> this length)) + (draw (-> this data s5-0)) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 13 of type drawable-tree-array +;; WARN: Return type mismatch int vs none. +(defmethod collect-stats ((this drawable-tree-array)) + "Collect triangle/perf statistics for rendering. + This is only called when viewing stats. + The vis-bits and culling registers are loaded during this time." + (dotimes (s5-0 (-> this length)) + (collect-stats (-> this data s5-0)) + ) + 0 + (none) + ) + +;; definition for method 14 of type drawable-tree-array +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw ((this drawable-tree-array)) + "Debug-draw a drawable and its children. Typically uses the debug-draw functions." + (dotimes (s5-0 (-> this length)) + (debug-draw (-> this data s5-0)) + ) + 0 + (none) + ) + +;; definition for method 15 of type drawable-tree +(defmethod unpack-vis ((this drawable-tree) (arg0 (pointer int8)) (arg1 (pointer int8))) + (local-vars (t5-1 uint)) + (let* ((v1-0 (the-as drawable-inline-array-node (-> this data 0))) + (a3-1 (/ (-> v1-0 data 0 id) 8)) + (t0-0 (-> v1-0 length)) + (v1-1 (&+ arg0 a3-1)) + (a3-3 (/ (+ t0-0 7) 8)) + ) + (dotimes (t0-1 a3-3) + (let ((t1-0 (-> arg1 0))) + (set! arg1 (&-> arg1 1)) + (set! (-> v1-1 0) t1-0) + ) + (set! v1-1 (&-> v1-1 1)) + ) + ) + (let ((v1-5 (+ (-> this length) -1))) + (when (nonzero? v1-5) + (dotimes (a3-5 v1-5) + (let* ((t0-4 (-> this data a3-5)) + (t2-0 (the-as drawable-inline-array-node (-> this data (+ a3-5 1)))) + (t1-5 (/ (-> (the-as drawable-inline-array-node t0-4) data 0 id) 8)) + (t2-2 (/ (-> t2-0 data 0 id) 8)) + (t0-5 (-> (the-as drawable-inline-array-node t0-4) length)) + (t1-6 (&+ arg0 t1-5)) + (t2-3 (the-as object (&+ arg0 t2-2))) + ) + (loop + (let ((t3-0 (-> t1-6 0))) + (set! t1-6 (&-> t1-6 1)) + (let ((t4-0 128)) + (label cfg-7) + (b! (not (logtest? t3-0 t4-0)) cfg-9 :delay (set! t5-1 (the-as uint (-> arg1 0)))) + (set! arg1 (&-> arg1 1)) + (set! (-> (the-as (pointer int8) t2-3) 0) (the-as int t5-1)) + (label cfg-9) + (+! t0-5 -1) + (b! (zero? t0-5) cfg-12 :delay (shift-arith-right-32 t4-0 t4-0 1)) + (b! (nonzero? (the-as uint t4-0)) cfg-7 :delay (set! t2-3 (&-> (the-as (pointer int8) t2-3) 1))) + ) + ) + ) + ) + (label cfg-12) + (nop!) + 0 + ) + ) + ) + arg1 + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/draw/drawable_REF.gc b/test/decompiler/reference/jak3/engine/draw/drawable_REF.gc new file mode 100644 index 00000000000..c407c89a99a --- /dev/null +++ b/test/decompiler/reference/jak3/engine/draw/drawable_REF.gc @@ -0,0 +1,2609 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function sphere-cull +;; ERROR: Bad vector register dependency: vf16 +;; ERROR: Bad vector register dependency: vf17 +;; ERROR: Bad vector register dependency: vf18 +;; ERROR: Bad vector register dependency: vf19 +(defun sphere-cull ((arg0 vector)) + "Is this sphere visible? Uses cached camera matrix registers, so use with care." + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (.lvf vf10 (&-> arg0 quad)) + (.mul.x.vf acc vf16 vf10) + (.add.mul.y.vf acc vf17 vf10 acc) + (.add.mul.z.vf acc vf18 vf10 acc) + (.sub.mul.w.vf vf9 vf19 vf0 acc) + (.add.w.vf vf9 vf9 vf10) + (.mov v1-0 vf9) + (.pcgtw v1-1 0 v1-0) + (.ppach v1-2 (the-as uint128 0) v1-1) + (zero? (the-as int v1-2)) + ) + ) + +;; definition for function guard-band-cull +;; ERROR: Bad vector register dependency: vf20 +;; ERROR: Bad vector register dependency: vf21 +;; ERROR: Bad vector register dependency: vf22 +;; ERROR: Bad vector register dependency: vf23 +(defun guard-band-cull ((arg0 vector)) + "Is this sphere within the guard band, and maybe needs clipping? Uses cached camera matrix registers, so use with care." + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf20 :class vf) + (vf21 :class vf) + (vf22 :class vf) + (vf23 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (.lvf vf10 (&-> arg0 quad)) + (.mul.x.vf acc vf20 vf10) + (.add.mul.y.vf acc vf21 vf10 acc) + (.add.mul.z.vf acc vf22 vf10 acc) + (.sub.mul.w.vf vf9 vf23 vf0 acc) + (.sub.w.vf vf9 vf9 vf10) + (.mov v1-0 vf9) + (.pcgtw v1-1 0 v1-0) + (.ppach v1-2 (the-as uint128 0) v1-1) + (nonzero? (the-as int v1-2)) + ) + ) + +;; definition for function sphere-in-view-frustum? +(defun sphere-in-view-frustum? ((arg0 sphere)) + "Check if sphere is in view frustum. Uses math-camera, so doesn't need register setup." + (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 *math-camera*)) + (.lvf vf6 (&-> arg0 quad)) + (.lvf vf1 (&-> v1-0 plane 0 quad)) + (.lvf vf2 (&-> v1-0 plane 1 quad)) + (.lvf vf3 (&-> v1-0 plane 2 quad)) + (.lvf vf4 (&-> v1-0 plane 3 quad)) + ) + (.mul.x.vf acc vf1 vf6) + (.add.mul.y.vf acc vf2 vf6 acc) + (.add.mul.z.vf acc vf3 vf6 acc) + (.sub.mul.w.vf vf5 vf4 vf0 acc) + (.add.w.vf vf5 vf5 vf6) + (.mov v1-1 vf5) + (.pcgtw v1-2 0 v1-1) + (.ppach v1-3 (the-as uint128 0) v1-2) + (zero? (the-as int v1-3)) + ) + ) + +;; definition for function line-in-view-frustum? +(defun line-in-view-frustum? ((arg0 vector) (arg1 vector)) + "Check if line is in view frustum. Uses math-camera, so doesn't need register setup." + (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128) (a0-1 uint128) (a0-2 uint128) (a0-3 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 *math-camera*)) + (.lvf vf9 (&-> arg0 quad)) + (.lvf vf10 (&-> arg1 quad)) + (.lvf vf16 (&-> v1-0 plane 0 quad)) + (.lvf vf17 (&-> v1-0 plane 1 quad)) + (.lvf vf18 (&-> v1-0 plane 2 quad)) + (.lvf vf19 (&-> v1-0 plane 3 quad)) + ) + (.mul.x.vf acc vf16 vf9) + (.add.mul.y.vf acc vf17 vf9 acc) + (.add.mul.z.vf acc vf18 vf9 acc) + (.sub.mul.w.vf vf9 vf19 vf0 acc) + (.mul.x.vf acc vf16 vf10) + (.add.mul.y.vf acc vf17 vf10 acc) + (.add.mul.z.vf acc vf18 vf10 acc) + (.sub.mul.w.vf vf10 vf19 vf0 acc) + (.mov v1-1 vf9) + (.pcgtw v1-2 0 v1-1) + (.ppach v1-3 (the-as uint128 0) v1-2) + (.mov a0-1 vf10) + (.pcgtw a0-2 0 a0-1) + (.ppach a0-3 (the-as uint128 0) a0-2) + (not (logtest? (the-as int v1-3) (the-as int a0-3))) + ) + ) + +;; definition for function vis-cull +;; ERROR: failed type prop at 3: Could not figure out load: (set! v1 (l.b (+ v1 #x3800))) +;; WARN: Return type mismatch none vs symbol. +;; ERROR: Unsupported inline assembly instruction kind - [addiu a0, a0, 56] +(defun vis-cull ((a0-0 int)) + "Check if object is visible by ID with precomputed visibility. Requres scratchpad to have vis-bits loaded." + (local-vars (v0-0 none) (v1-0 int) (v1-1 int) (v1-2 none) (v1-3 none) (a0-1 none) (a0-2 none) (a1-0 int)) + (set! v1-0 #x70000000) + (shift-arith-right-32 a1-0 a0-0 3) + (set! v1-1 (+ a1-0 v1-0)) + (set! v1-2 (the-as none (l.b (+ v1-1 #x3800)))) + (set! a0-1 (the-as none (logand a0-0 7))) + (.addiu a0-2 a0-1 56) + (set! v1-3 (the-as none (sll v1-2 a0-2))) + (set! v0-0 (the-as none (<0.si v1-3))) + (ret-value v0-0) + ) + +;; definition (debug) for function vis-cull-debug +;; ERROR: Failed load: (set! v1-2 (l.b (+ v1-1 #x3800))) at op 2 +;; ERROR: Unsupported inline assembly instruction kind - [addiu a0, a0, 56] +(defun-debug vis-cull-debug ((arg0 work-area) (arg1 int)) + (local-vars (v1-0 int) (a0-2 int)) + (shift-arith-right-32 v1-0 arg1 3) + (let ((v1-2 (l.b (+ v1-0 (the-as int arg0) #x3800)))) + (let ((a0-1 (logand arg1 7))) + (.addiu a0-2 a0-1 56) + ) + (< (shl v1-2 a0-2) 0) + ) + ) + +;; definition for function error-sphere +;; WARN: Return type mismatch int vs none. +(defun error-sphere ((arg0 drawable-error) (arg1 string)) + "Draw an error sphere and text for a drawable-error." + (when *artist-error-spheres* + (when (vis-cull (-> arg0 id)) + (when (sphere-cull (-> arg0 bsphere)) + (add-debug-sphere + #t + (bucket-id bucket583) + (-> arg0 bsphere) + (-> arg0 bsphere w) + (new 'static 'rgba :r #x80 :a #x80) + ) + (add-debug-text-3d + #t + (bucket-id debug-no-zbuf1) + arg1 + (-> arg0 bsphere) + (font-color white) + (the-as vector2h #f) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 9 of type drawable +(defmethod login ((this drawable)) + "Initialize the object after it is loaded." + this + ) + +;; definition for method 10 of type drawable +;; WARN: Return type mismatch int vs none. +(defmethod draw ((this drawable)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + 0 + (none) + ) + +;; definition for method 11 of type drawable +;; WARN: Return type mismatch int vs none. +(defmethod drawable-method-11 ((this drawable)) + 0 + (none) + ) + +;; definition for method 12 of type drawable +;; WARN: Return type mismatch int vs none. +(defmethod drawable-method-12 ((this drawable)) + 0 + (none) + ) + +;; definition for method 16 of type drawable +;; WARN: Return type mismatch int vs none. +(defmethod collect-regions ((this drawable) (arg0 sphere) (arg1 int) (arg2 region-prim-list)) + "Fill the region-prim-list with regions that intersect the sphere." + 0 + (none) + ) + +;; definition for method 13 of type drawable +;; WARN: Return type mismatch int vs none. +(defmethod collect-stats ((this drawable)) + "Collect triangle/perf statistics for rendering. + This is only called when viewing stats. + The vis-bits and culling registers are loaded during this time." + 0 + (none) + ) + +;; definition for method 14 of type drawable +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw ((this drawable)) + "Debug-draw a drawable and its children. Typically uses the debug-draw functions." + 0 + (none) + ) + +;; definition for method 10 of type drawable-error +;; WARN: Return type mismatch int vs none. +(defmethod draw ((this drawable-error)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + (error-sphere this (-> this name)) + 0 + (none) + ) + +;; definition for method 15 of type drawable +(defmethod unpack-vis ((this drawable) (arg0 (pointer int8)) (arg1 (pointer int8))) + arg1 + ) + +;; definition for symbol *edit-instance*, type string +(define *edit-instance* (the-as string #f)) + +;; this part is debug only +(when *debug-segment* +;; definition for symbol *instance-mem-usage*, type memory-usage-block +(define *instance-mem-usage* (new 'debug 'memory-usage-block)) + +) +;; definition for function find-instance-by-name-level +(defun find-instance-by-name-level ((arg0 string) (arg1 level)) + "Find shrub or tie prototype by name in a level. + Yes it says instance. No it does not return an instance." + (let ((s5-0 (-> arg1 bsp drawable-trees))) + (dotimes (s4-0 (-> s5-0 length)) + (let ((v1-3 (-> s5-0 data s4-0))) + (case (-> v1-3 type) + ((drawable-tree-instance-shrub) + (let ((s3-0 (-> (the-as drawable-tree-instance-shrub v1-3) info prototype-inline-array-shrub))) + (dotimes (s2-0 (-> s3-0 length)) + (if (string= arg0 (-> s3-0 data s2-0 name)) + (return (-> s3-0 data s2-0)) + ) + ) + ) + ) + ((drawable-tree-instance-tie) + (let ((s3-1 (-> (the-as drawable-tree-instance-tie v1-3) prototypes prototype-array-tie))) + (dotimes (s2-1 (-> s3-1 length)) + (if (string= arg0 (-> s3-1 array-data s2-1 name)) + (return (-> s3-1 array-data s2-1)) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as prototype-bucket #f) + ) + +;; definition for function find-instance-by-name +(defun find-instance-by-name ((arg0 string)) + "Find shrub or tie prototype by name in any level. + Yes it says instance. No it does not return an instance." + (dotimes (s5-0 (-> *level* length)) + (let ((a1-0 (-> *level* level s5-0))) + (when (= (-> a1-0 status) 'active) + (let ((a0-4 (find-instance-by-name-level arg0 a1-0))) + (if a0-4 + (return a0-4) + ) + ) + ) + ) + ) + (the-as prototype-bucket #f) + ) + +;; definition for function prototypes-game-visible-set! +(defun prototypes-game-visible-set! ((arg0 pair) (arg1 symbol) (arg2 level)) + "Disable collision/visibilty of tie/shrub based on a list of prototype names. + Only looks in the given level." + (let ((a0-1 (car arg0))) + (while (not (null? arg0)) + (let ((v1-0 (find-instance-by-name-level (the-as string a0-1) arg2))) + (when v1-0 + (if arg1 + (logclear! (-> v1-0 flags) (prototype-flags visible no-collide)) + (logior! (-> v1-0 flags) (prototype-flags visible no-collide)) + ) + ) + ) + (set! arg0 (cdr arg0)) + (set! a0-1 (car arg0)) + ) + ) + 0 + ) + +;; definition (debug) for function find-instance-by-index +(defun-debug find-instance-by-index ((arg0 type) (arg1 int) (arg2 bsp-header)) + (dotimes (v1-0 (-> *level* length)) + (let ((a3-3 (-> *level* level v1-0))) + (when (= (-> a3-3 status) 'active) + (let ((a3-4 (-> a3-3 bsp))) + (when (or (not arg2) (= a3-4 arg2)) + (let ((a3-5 (-> a3-4 drawable-trees))) + (dotimes (t0-5 (-> a3-5 length)) + (let ((t1-3 (-> a3-5 data t0-5))) + (case (-> t1-3 type) + ((drawable-tree-instance-shrub) + (when (= arg0 (-> t1-3 type)) + (let ((v1-2 (-> (the-as drawable-tree-instance-shrub t1-3) info prototype-inline-array-shrub))) + (return (-> v1-2 data arg1)) + ) + ) + ) + ((drawable-tree-instance-tie) + (when (= arg0 (-> t1-3 type)) + (let ((v1-5 (-> (the-as drawable-tree-instance-tie t1-3) prototypes prototype-array-tie))) + (return (-> v1-5 array-data arg1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as prototype-bucket #f) + ) + +;; definition (debug) for function prototype-bucket-type +(defun-debug prototype-bucket-type ((arg0 prototype-bucket)) + (case (-> arg0 geometry 1 type) + ((prototype-shrubbery shrubbery) + instance-shrubbery + ) + ((prototype-tie prototype-tie tie-fragment) + instance-tie + ) + ) + ) + +;; definition (debug) for function prototype-bucket-recalc-fields +(defun-debug prototype-bucket-recalc-fields ((arg0 prototype-bucket)) + (case (prototype-bucket-type arg0) + ((instance-shrubbery) + (set! (-> arg0 rdists x) (/ 1.0 (- (-> arg0 dists w) (-> arg0 dists x)))) + ) + (else + (set! (-> arg0 dists z) (+ (-> arg0 dists x) (* 0.33333334 (- (-> arg0 dists w) (-> arg0 dists x))))) + (set! (-> arg0 rdists x) (/ 1.0 (- (-> arg0 dists z) (-> arg0 dists x)))) + ) + ) + (set! (-> arg0 rdists z) (/ 1.0 (- (-> arg0 dists w) (-> arg0 dists z)))) + (set! (-> arg0 dists y) (* 0.5 (-> arg0 dists x))) + (set! (-> arg0 rdists y) (/ 1.0 (-> arg0 dists y))) + arg0 + ) + +;; definition (debug) for function print-prototype-list +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun-debug print-prototype-list () + (local-vars (sv-16 (function prototype-bucket-shrub memory-usage-block int prototype-bucket-shrub))) + (dotimes (gp-0 (-> *level* length)) + (let ((s5-0 (-> *level* level gp-0))) + (when (= (-> s5-0 status) 'active) + (format #t "-------- level ~S~%" (-> s5-0 name)) + (let ((s5-1 (-> s5-0 bsp drawable-trees))) + (dotimes (s4-0 (-> s5-1 length)) + (let ((v1-8 (-> s5-1 data s4-0))) + (case (-> v1-8 type) + ((drawable-tree-instance-shrub) + (let ((s3-0 (-> (the-as drawable-tree-instance-shrub v1-8) info prototype-inline-array-shrub))) + (dotimes (s2-0 (-> s3-0 length)) + 0 + (let ((s1-0 (-> s3-0 data s2-0))) + (dotimes (s0-0 4) + (reset! *instance-mem-usage*) + (if (nonzero? (-> s1-0 geometry s0-0)) + (mem-usage (-> s1-0 geometry s0-0) *instance-mem-usage* 0) + ) + ) + (let ((s0-1 s1-0)) + (set! sv-16 (method-of-object s0-1 mem-usage)) + (let ((a1-4 (reset! *instance-mem-usage*)) + (a2-2 0) + ) + (sv-16 s0-1 a1-4 a2-2) + ) + ) + (let ((v1-29 (calculate-total *instance-mem-usage*))) + (format + #t + " ~-48S~4D shrub ~5,,2fK ~4,,2fK~%" + (-> s1-0 name) + (-> s1-0 in-level) + (* 0.0009765625 (the float v1-29)) + (* 0.0009765625 (the float (* (the-as uint 80) (-> s1-0 in-level)))) + ) + ) + ) + ) + ) + ) + ((drawable-tree-instance-tie) + (let ((s3-1 (-> (the-as drawable-tree-instance-tie v1-8) prototypes prototype-array-tie))) + (dotimes (s2-1 (-> s3-1 length)) + 0 + (let ((s1-1 (-> s3-1 array-data s2-1))) + (reset! *instance-mem-usage*) + (dotimes (s0-2 4) + (when (nonzero? (-> s1-1 tie-geom s0-2)) + (let* ((a0-13 (-> s1-1 tie-geom s0-2)) + (t9-8 (method-of-object a0-13 mem-usage)) + (a1-7 *instance-mem-usage*) + (v1-47 s0-2) + ) + (t9-8 a0-13 a1-7 (logior (cond + ((= v1-47 1) + 4 + ) + ((= v1-47 2) + 8 + ) + ((= v1-47 3) + 16 + ) + (else + 0 + ) + ) + 2 + ) + ) + ) + ) + ) + (mem-usage s1-1 *instance-mem-usage* 0) + (let ((v1-54 (calculate-total *instance-mem-usage*))) + (format + #t + " ~-48S~4D tie ~5,,2fK ~4,,2fK~%" + (-> s1-1 name) + (-> s1-1 in-level) + (* 0.0009765625 (the float v1-54)) + (* 0.0009765625 (the float (* (-> s1-1 in-level) 64))) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition (debug) for function draw-instance-info +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defun-debug draw-instance-info ((arg0 string)) + (local-vars + (sv-16 uint) + (sv-32 uint) + (sv-48 uint) + (sv-64 int) + (sv-80 int) + (sv-96 int) + (sv-112 int) + (sv-128 int) + (sv-144 int) + ) + (when (and *display-instance-info* *edit-instance*) + (let ((s5-0 (find-instance-by-name *edit-instance*))) + (when s5-0 + (dotimes (s4-0 (-> *level* length)) + (let ((v1-5 (-> *level* level s4-0))) + (when (= (-> v1-5 status) 'active) + (let ((s3-0 (-> v1-5 bsp drawable-trees))) + (dotimes (s2-0 (-> s3-0 length)) + (let ((v1-9 (-> s3-0 data s2-0))) + (case (-> v1-9 type) + ((drawable-tree-instance-shrub) + ) + ((drawable-tree-instance-tie) + (let ((s1-0 (-> (the-as + drawable-tree-instance-tie + (+ (* (+ (-> (the-as drawable-tree-instance-tie v1-9) length) -1) 4) (the-as int v1-9)) + ) + data + 0 + ) + ) + ) + (dotimes (s0-0 (-> (the-as drawable-inline-array-instance-tie s1-0) length)) + (if (string= (-> (the-as drawable-inline-array-instance-tie s1-0) data s0-0 bucket-ptr name) *edit-instance*) + (add-debug-sphere + #t + (bucket-id debug-no-zbuf1) + (the-as + vector + (+ (the-as uint (-> (the-as drawable-inline-array-instance-tie s1-0) data 0 bsphere)) (* s0-0 64)) + ) + (-> (the-as drawable-inline-array-instance-tie s1-0) data s0-0 bsphere w) + (new 'static 'rgba :g #xff :a #x80) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let ((s2-1 (prototype-bucket-type s5-0))) + (let ((s4-1 0)) + 0 + (cond + ((= s2-1 instance-shrubbery) + (set! s4-1 80) + ) + ((= s2-1 instance-tie) + (reset! *instance-mem-usage*) + (dotimes (s4-2 4) + (when (nonzero? (-> s5-0 geometry s4-2)) + (let* ((a0-17 (-> s5-0 geometry s4-2)) + (t9-5 (method-of-object a0-17 mem-usage)) + (a1-6 *instance-mem-usage*) + (v1-40 s4-2) + ) + (t9-5 a0-17 a1-6 (logior (cond + ((= v1-40 1) + 4 + ) + ((= v1-40 2) + 8 + ) + ((= v1-40 3) + 16 + ) + (else + 0 + ) + ) + 2 + ) + ) + ) + ) + ) + (set! s4-1 (+ (calculate-total *instance-mem-usage*) 64)) + ) + ) + (mem-usage s5-0 (reset! *instance-mem-usage*) 0) + (let ((v1-50 (calculate-total *instance-mem-usage*))) + (format + arg0 + "~%~A ~A b @ #x~X ~,,2fK/~,,2fK~%" + s2-1 + (-> s5-0 name) + s5-0 + (* 0.0009765625 (the float v1-50)) + (* 0.0009765625 (the float s4-1)) + ) + ) + ) + (format arg0 "near: ~m mid: ~m far: ~m~%" (-> s5-0 dists x) (-> s5-0 dists z) (-> s5-0 dists w)) + (let ((s3-2 0) + (s4-3 0) + ) + (cond + ((= s2-1 instance-shrubbery) + (let ((f30-0 0.0)) + (format + arg0 + "usage: vis: ~D shrub: ~D trans-shrub ~D bill: ~D in level: ~D~%" + (-> (the-as prototype-bucket-shrub s5-0) count 0) + (-> (the-as prototype-bucket-shrub s5-0) count 1) + (-> (the-as prototype-bucket-shrub s5-0) count 2) + (-> (the-as prototype-bucket-shrub s5-0) count 3) + (-> (the-as prototype-bucket-shrub s5-0) in-level) + ) + (format arg0 "~%frag# tris dverts strlen tex~%") + (let ((s1-2 (the-as prototype-shrubbery (-> (the-as prototype-bucket-shrub s5-0) geometry 1))) + (s2-2 (+ (-> (the-as prototype-bucket-shrub s5-0) count 1) (-> (the-as prototype-bucket-shrub s5-0) count 2))) + ) + (dotimes (s0-1 (-> s1-2 length)) + (set! sv-16 (shrub-num-tris (-> s1-2 data s0-1))) + (set! sv-32 (-> s1-2 data s0-1 header data 2)) + (set! sv-48 (-> s1-2 data s0-1 header data 0)) + (format + arg0 + "~5D ~4D ~5D ~6f ~D~%" + s0-1 + sv-16 + sv-32 + (/ (* 2.0 (the float sv-16)) (the float (- sv-32 sv-16))) + sv-48 + ) + (+! s3-2 sv-16) + (+! s4-3 sv-32) + (set! f30-0 + (+ 29.0 + (* 5.5 (the float (- sv-32 sv-16))) + (* 22.0 (the float sv-48)) + (* 8.0 (the float sv-32)) + (* 53.0 (the float (/ (+ s2-2 9) (the-as uint 10)))) + (* (the float s2-2) (+ 15.0 (* 5.0 (the float sv-48)) (* 13.5 (the float sv-32)))) + f30-0 + ) + ) + ) + (format + arg0 + "total ~4D ~5D ~6f ~D speed: ~f~%" + s3-2 + s4-3 + (/ (* 2.0 (the float s3-2)) (the float (- s4-3 s3-2))) + (-> s5-0 utextures) + (/ f30-0 (* (the float s2-2) (the float s3-2))) + ) + ) + ) + ) + ((= s2-1 instance-tie) + (set! sv-144 0) + (let ((s1-3 0) + (s0-2 0) + (s2-3 0) + ) + (format arg0 "~%level visible frags tris dverts strlen tex ttris~%") + (set! sv-64 1) + (set! sv-80 3) + (while (>= sv-80 sv-64) + (let ((v1-100 (-> (the-as prototype-bucket-tie s5-0) tie-geom sv-64))) + (set! sv-96 0) + (set! sv-112 0) + (set! sv-128 0) + (dotimes (a0-36 (-> v1-100 length)) + (set! sv-96 (+ sv-96 (-> v1-100 data a0-36 debug num-tris))) + (set! sv-112 (+ sv-112 (-> v1-100 data a0-36 debug num-dverts))) + (set! sv-128 (+ sv-128 (-> v1-100 data a0-36 tex-count))) + ) + (set! sv-144 (+ sv-144 (-> (the-as prototype-bucket-tie s5-0) count sv-64))) + (format + arg0 + "~5D ~7D ~5D ~5D" + sv-64 + (-> (the-as prototype-bucket-tie s5-0) count sv-64) + (-> v1-100 length) + sv-96 + ) + ) + (format + arg0 + " ~5D ~6f ~3D ~5D~%" + sv-112 + (/ (* 2.0 (the float sv-96)) (the float (- sv-112 sv-96))) + sv-128 + (* (the-as uint sv-96) (-> (the-as prototype-bucket-tie s5-0) count sv-64)) + ) + (+! s1-3 (* (the-as uint sv-96) (-> (the-as prototype-bucket-tie s5-0) count sv-64))) + (+! s0-2 (* (the-as uint sv-112) (-> (the-as prototype-bucket-tie s5-0) count sv-64))) + (+! s3-2 sv-96) + (+! s4-3 sv-112) + (+! s2-3 sv-128) + (set! sv-64 (+ sv-64 1)) + ) + (let ((t9-20 format) + (a0-52 arg0) + (a1-28 "total ~7D/~3D ~5D") + (a3-12 (-> s5-0 in-level)) + ) + (t9-20 a0-52 a1-28 sv-144 a3-12 s3-2) + ) + (format + arg0 + " ~5D ~6f ~3D ~5D~%" + s4-3 + (/ (* 2.0 (the float s1-3)) (the float (- s0-2 s1-3))) + s2-3 + s1-3 + ) + ) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; definition (debug) for function set-shadow-by-name +;; WARN: Return type mismatch uint vs none. +(defun-debug set-shadow-by-name ((arg0 string) (arg1 int) (arg2 int)) + "Modify the shadow values for a process." + (let ((v1-0 (process-by-name arg0 *active-pool*))) + (when v1-0 + (let ((v1-1 (-> (the-as process-drawable v1-0) draw))) + (cond + ((< arg2 16) + (logior! (-> v1-1 shadow-mask) (ash 1 arg1)) + (logclear! (-> v1-1 shadow-values) (ash 15 (* arg1 4))) + (logior! (-> v1-1 shadow-values) (ash arg2 (* arg1 4))) + ) + (else + (logclear! (-> v1-1 shadow-mask) (ash 1 arg1)) + (logclear! (-> v1-1 shadow-values) (ash 15 (* arg1 4))) + ) + ) + ) + ) + ) + (none) + ) + +;; definition (debug) for function get-shadow-by-name +;; WARN: Return type mismatch object vs none. +(defun-debug get-shadow-by-name ((arg0 string)) + "Print to stdout the mask/values for the given process shadows" + (let ((v1-0 (process-by-name arg0 *active-pool*))) + (when v1-0 + (let ((s5-0 (-> (the-as process-drawable v1-0) draw))) + (format 0 "actor ~s {~%" arg0) + (format 0 " SHADOW_MASK(0x~02x)~%" (-> s5-0 shadow-mask)) + (format 0 " SHADOW_VALUES(0x~08x)~%" (-> s5-0 shadow-values)) + ) + (format 0 "}~%") + ) + ) + (none) + ) + +;; definition (debug) for function teleport-camera-by-name +;; WARN: Return type mismatch object vs none. +(defun-debug teleport-camera-by-name ((arg0 string)) + "Move camera to entity by name" + (let* ((gp-0 (entity-by-name arg0)) + (v1-0 (if (type? gp-0 entity-actor) + gp-0 + ) + ) + ) + (if (and v1-0 *camera*) + (send-event *camera* 'teleport-to-vector-start-string (-> v1-0 trans)) + ) + ) + (none) + ) + +;; definition (debug) for function teleport-camera-by-pos +;; WARN: Return type mismatch object vs none. +(defun-debug teleport-camera-by-pos ((arg0 float) (arg1 float) (arg2 float)) + "Move camera to position" + (let ((v1-0 (new 'stack-no-clear 'vector))) + (when *camera* + (set-vector! v1-0 (* 4096.0 arg0) (* 4096.0 arg1) (* 4096.0 arg2) 1.0) + (send-event *camera* 'teleport-to-vector-start-string v1-0) + ) + ) + (none) + ) + +;; definition for function calc-vu1-shadow +;; INFO: Used lq/sq +;; WARN: Return type mismatch float vs none. +(defun calc-vu1-shadow ((arg0 light-group) (arg1 draw-control)) + "Update shadow-ctrl based on lights" + (rlet ((acc :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (s5-0 (-> arg1 shadow-ctrl settings shadow-dir)) + (f30-0 (-> arg1 shadow-ctrl settings shadow-dir w)) + ) + (.lvf vf1 (&-> arg0 dir0 direction quad)) + (.lvf vf2 (&-> arg0 dir1 direction quad)) + (.lvf vf3 (&-> arg0 dir2 direction quad)) + (.lvf vf4 (&-> arg0 dir0 extra quad)) + (.lvf vf5 (&-> arg0 dir1 extra quad)) + (.lvf vf6 (&-> arg0 dir2 extra quad)) + (.mul.x.vf acc vf1 vf4) + (.add.mul.x.vf acc vf2 vf5 acc) + (.add.mul.x.vf vf1 vf3 vf6 acc) + (.svf (&-> s4-0 quad) vf1) + (vector-normalize! s4-0 -1.0) + (when (< (- (-> s4-0 y)) 0.9063) + (let* ((f0-2 0.4226) + (f1-1 (-> s4-0 x)) + (f1-3 (* f1-1 f1-1)) + (f2-0 (-> s4-0 z)) + (f0-3 (/ f0-2 (sqrtf (+ f1-3 (* f2-0 f2-0))))) + ) + (set! (-> s4-0 x) (* (-> s4-0 x) f0-3)) + (set! (-> s4-0 y) -0.9063) + (set! (-> s4-0 z) (* (-> s4-0 z) f0-3)) + ) + ) + (cond + ((logtest? (-> arg1 shadow-ctrl settings flags) (shadow-flags shdf08)) + (set! (-> s5-0 quad) (-> s4-0 quad)) + ) + (else + (when (not (paused?)) + (vector-seek! s5-0 s4-0 (* 0.2 (seconds-per-frame))) + (vector-normalize! s5-0 1.0) + ) + ) + ) + (set! (-> arg1 shadow-ctrl settings shadow-dir w) f30-0) + ) + (none) + ) + ) + +;; definition for function calc-shadow-masks +;; WARN: Return type mismatch symbol vs none. +;; ERROR: Unsupported inline assembly instruction kind - [srl v1, v1, 24] +(defun calc-shadow-masks ((arg0 light-group) (arg1 draw-control) (arg2 uint)) + (local-vars (v1-25 uint) (v1-26 int) (sv-64 light-hash) (sv-68 vector) (sv-72 mood-context) (sv-76 pointer)) + (let ((s5-0 (the-as (array float) (new 'stack 'boxed-array float 6)))) + (let ((v1-1 (-> arg1 shadow-mask)) + (a0-2 (-> arg1 shadow-values)) + ) + (dotimes (a1-2 5) + (if (not (logtest? v1-1 (ash 1 a1-2))) + (set! (-> s5-0 a1-2) 1.0) + (set! (-> s5-0 a1-2) (* 0.0625 (the float (logand (ash a0-2 (* -4 a1-2)) 15)))) + ) + ) + ) + (when (or (and (>= (the-as int arg2) 10) (< (the-as int arg2) 18)) + (and (>= (the-as int arg2) 30) (< (the-as int arg2) 38)) + ) + (dotimes (s3-1 (-> *level* length)) + (let ((v1-10 (-> *level* level s3-1))) + (when (= (-> v1-10 status) 'active) + (set! sv-64 (-> v1-10 light-hash)) + (set! sv-68 (-> arg1 origin)) + (set! sv-72 (-> v1-10 mood-context)) + (when (nonzero? sv-64) + (let ((v1-13 (light-hash-get-bucket-index sv-64 (-> arg1 origin)))) + (when (!= v1-13 -1) + (let ((s2-0 (-> sv-64 bucket-array v1-13))) + (set! sv-76 (+ (+ (-> s2-0 index) 0) (the-as uint (-> sv-64 index-array)))) + (dotimes (s1-0 (the-as int (-> s2-0 count))) + (let ((s0-0 (-> sv-64 light-sphere-array (-> (the-as (pointer uint8) (&+ sv-76 s1-0)))))) + (when (= (-> s0-0 palette-index) -2) + (let* ((f0-3 (-> s0-0 bsphere w)) + (f28-0 (* f0-3 (-> s0-0 decay-start))) + (f26-0 (- f0-3 f28-0)) + (f0-8 (fmax 0.0 (fmin 1.0 (/ (- (vector-vector-distance (-> s0-0 bsphere) sv-68) f28-0) f26-0)))) + ) + (when (!= f0-8 1.0) + (.srl v1-26 v1-25 24) + (let ((a0-26 (shr (shl (-> s0-0 shadow) 40) 40))) + (dotimes (a1-6 5) + (when (logtest? v1-26 (ash 1 a1-6)) + (let ((f1-5 (* 0.0625 (the float (logand (ash a0-26 (* -4 a1-6)) 15))))) + 1.0 + (set! (-> s5-0 a1-6) (fmin (-> s5-0 a1-6) (+ f1-5 (* (- 1.0 f1-5) f0-8)))) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (dotimes (v1-35 4) + (when (nonzero? (-> arg0 lights v1-35 mask)) + (let ((a0-36 (-> arg0 lights v1-35 palette-index))) + (set! (-> arg0 lights v1-35 extra x) (* (-> arg0 lights v1-35 extra x) (-> s5-0 a0-36))) + ) + ) + ) + ) + (none) + ) + +;; definition for function calc-realtime-lights +;; WARN: Return type mismatch symbol vs none. +(defun calc-realtime-lights ((arg0 light-group) (arg1 draw-control) (arg2 uint)) + (local-vars (sv-16 light-hash) (sv-20 vector) (sv-24 mood-context)) + (when (or (and (>= (the-as int arg2) 10) (< (the-as int arg2) 18)) + (and (>= (the-as int arg2) 30) (< (the-as int arg2) 38)) + ) + (dotimes (s4-0 (-> *level* length)) + (let ((v1-5 (-> *level* level s4-0))) + (when (= (-> v1-5 status) 'active) + (set! sv-16 (-> v1-5 light-hash)) + (set! sv-20 (-> arg1 origin)) + (set! sv-24 (-> v1-5 mood-context)) + (when (nonzero? sv-16) + (let ((v1-8 (light-hash-get-bucket-index sv-16 (-> arg1 origin)))) + (when (!= v1-8 -1) + (let* ((s3-0 (-> sv-16 bucket-array v1-8)) + (s2-0 (+ (+ (-> s3-0 index) 0) (the-as uint (-> sv-16 index-array)))) + ) + (dotimes (s1-0 (the-as int (-> s3-0 count))) + (let* ((a1-3 (-> sv-16 light-sphere-array (-> (the-as (pointer uint8) (&+ s2-0 s1-0))))) + (v1-14 (-> a1-3 palette-index)) + (f0-1 (if (= v1-14 -1) + 1.0 + (-> sv-24 times v1-14 w) + ) + ) + ) + (if (not (or (= (-> a1-3 palette-index) -2) (= (* (-> a1-3 brightness) f0-1) 0.0))) + (add-light-sphere-to-light-group arg0 a1-3 sv-20 sv-24) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for function calc-vu1-lights +;; WARN: Return type mismatch int vs none. +(defun calc-vu1-lights ((arg0 vu-lights) (arg1 draw-control) (arg2 symbol)) + (local-vars (v1-44 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (let ((s4-0 *time-of-day-context*)) + (cond + ((logtest? (-> arg1 global-effect) (draw-control-global-effect title-light)) + (when (not (-> s4-0 title-updated)) + (set! (-> s4-0 title-updated) #t) + (let ((s2-1 (-> *math-camera* inv-camera-rot)) + (a1-1 (new 'static 'vector :x 0.612 :y 0.5 :z -0.612)) + (s3-0 (new 'static 'vector :x -0.696 :y 0.174 :z 0.696)) + ) + (vector-matrix*! (the-as vector (-> s4-0 title-light-group)) a1-1 s2-1) + (vector-matrix*! (the-as vector (-> s4-0 title-light-group dir1)) s3-0 s2-1) + ) + ) + (vu-lights<-light-group! arg0 (-> s4-0 title-light-group)) + ) + ((logtest? (-> arg1 global-effect) (draw-control-global-effect rim-lights)) + (let ((s1-0 (-> *math-camera* inv-camera-rot)) + (a1-4 (new 'static 'vector :x 0.77455187 :y 0.44725248 :z 0.44725248)) + (s3-1 (new 'static 'vector :x -0.77455187 :y 0.44725248 :z 0.44725248)) + (s2-2 (new 'static 'vector :y -0.8944 :z 0.4472)) + (s4-1 (-> s4-0 rim-light-group)) + ) + (vector-matrix*! (the-as vector (-> s4-1 dir0)) a1-4 s1-0) + (vector-matrix*! (the-as vector (-> s4-1 dir1)) s3-1 s1-0) + (vector-matrix*! (the-as vector (-> s4-1 dir2)) s2-2 s1-0) + (vu-lights<-light-group! arg0 s4-1) + ) + ) + ((logtest? (-> arg1 global-effect) (draw-control-global-effect rim-lights2)) + (let ((s1-1 (-> *math-camera* inv-camera-rot)) + (a1-8 (new 'static 'vector :x 0.77455187 :y 0.44725248 :z 0.44725248)) + (s3-2 (new 'static 'vector :x -0.77455187 :y 0.44725248 :z 0.44725248)) + (s2-3 (new 'static 'vector :y -0.8944 :z 0.4472)) + (s4-2 (-> s4-0 rim-light-group2)) + ) + (vector-matrix*! (the-as vector (-> s4-2 dir0)) a1-8 s1-1) + (vector-matrix*! (the-as vector (-> s4-2 dir1)) s3-2 s1-1) + (vector-matrix*! (the-as vector (-> s4-2 dir2)) s2-3 s1-1) + (vu-lights<-light-group! arg0 s4-2) + ) + ) + ((logtest? (-> arg1 global-effect) (draw-control-global-effect rim-lights3)) + (let ((s1-2 (-> *math-camera* inv-camera-rot)) + (a1-12 (new 'static 'vector :x 0.77455187 :y 0.44725248 :z 0.44725248)) + (s3-3 (new 'static 'vector :x -0.77455187 :y 0.44725248 :z 0.44725248)) + (s2-4 (new 'static 'vector :y -0.8944 :z 0.4472)) + (s4-3 (-> s4-0 rim-light-group3)) + ) + (vector-matrix*! (the-as vector (-> s4-3 dir0)) a1-12 s1-2) + (vector-matrix*! (the-as vector (-> s4-3 dir1)) s3-3 s1-2) + (vector-matrix*! (the-as vector (-> s4-3 dir2)) s2-4 s1-2) + (vu-lights<-light-group! arg0 s4-3) + ) + ) + (else + (let ((v1-20 (-> arg1 level-index)) + (s1-3 (-> arg1 light-index)) + (s3-4 (new 'stack-no-clear 'light-group)) + ) + (if (and (>= v1-20 (the-as uint 10)) (< s1-3 (the-as uint 20))) + (+! s1-3 20) + ) + (let ((v1-22 (+ (the-as uint (-> *level* level0 mood-context)) (* (the-as uint 5424) v1-20)))) + (cond + ((< s1-3 (the-as uint 8)) + (quad-copy! (the-as pointer s3-4) (the-as pointer (+ (* (the-as uint 192) s1-3) 112 v1-22)) 12) + ) + ((< s1-3 (the-as uint 18)) + (quad-copy! (the-as pointer s3-4) (the-as pointer (+ (* (the-as uint 192) (+ s1-3 -10)) 112 v1-22)) 12) + ) + ((< s1-3 (the-as uint 28)) + (quad-copy! (the-as pointer s3-4) (the-as pointer (-> s4-0 light-group (+ s1-3 -20))) 12) + ) + ((< s1-3 (the-as uint 38)) + (quad-copy! (the-as pointer s3-4) (the-as pointer (-> s4-0 light-group (+ s1-3 -30))) 12) + ) + ) + ) + (calc-shadow-masks s3-4 arg1 s1-3) + (calc-realtime-lights s3-4 arg1 s1-3) + (vu-lights<-light-group! arg0 s3-4) + (if (and arg2 + (nonzero? (-> arg1 shadow-ctrl)) + (-> arg1 shadow-ctrl) + (not (logtest? (-> arg1 shadow-ctrl settings flags) (shadow-flags disable-draw))) + (not (logtest? (-> arg1 shadow-ctrl settings flags) (shadow-flags shdf07))) + ) + (calc-vu1-shadow s3-4 arg1) + ) + ) + ) + ) + ) + (.lvf vf5 (&-> arg1 color-mult quad)) + (.lvf vf6 (&-> arg1 color-emissive quad)) + (.lvf vf1 (&-> arg0 color 0 quad)) + (.lvf vf2 (&-> arg0 color 1 quad)) + (.lvf vf3 (&-> arg0 color 2 quad)) + (.lvf vf4 (&-> arg0 ambient quad)) + (.mul.vf vf4 vf4 vf5) + (.mul.vf vf1 vf1 vf5) + (.mul.vf vf2 vf2 vf5) + (.mul.vf vf3 vf3 vf5) + (.add.vf vf4 vf4 vf6) + (.svf (&-> arg0 color 0 quad) vf1) + (.svf (&-> arg0 color 1 quad) vf2) + (.svf (&-> arg0 color 2 quad) vf3) + (.svf (&-> arg0 ambient quad) vf4) + (.mov v1-44 vf4) + 0 + (none) + ) + ) + +;; definition for function dma-add-process-drawable +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +;; WARN: Function dma-add-process-drawable has a return type of none, but the expression builder found a return statement. +(defun dma-add-process-drawable ((arg0 process-drawable) (arg1 draw-control) (arg2 symbol) (arg3 dma-buffer)) + "Generate DMA for foreground object, calculate lights/shadows, etc." + (local-vars (a0-41 int) (a0-43 int) (a3-9 uint128) (sv-16 process-drawable)) + (with-pp + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf20 :class vf) + (vf21 :class vf) + (vf22 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf29 :class vf) + ) + (init-vf0-vector) + (set! sv-16 arg0) + (let* ((v1-1 (-> *perf-stats* data 50)) + (a0-1 (-> v1-1 ctrl)) + ) + (+! (-> v1-1 count) 1) + (b! (zero? a0-1) cfg-2 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mtpc pcr0 0) + (.mtpc pcr1 0) + (.sync.l) + (.sync.p) + (.mtc0 Perf a0-1) + ) + (.sync.l) + (.sync.p) + (label cfg-2) + 0 + (when (get-menu-mode *blit-displays-work*) + (if (not (logtest? (-> arg1 status) (draw-control-status hud))) + (return #f) + ) + ) + (logclear! (-> arg1 status) (draw-control-status on-screen)) + (when (not (logtest? (-> arg1 status) (draw-control-status no-draw no-draw-temp uninited))) + (let ((s3-0 (-> (the-as foreground-work #x70000000) bounds)) + (s4-0 (-> (the-as foreground-work #x70000000) lights)) + ) + (.lvf vf16 (&-> arg1 origin quad)) + (.svf (&-> s3-0 quad) vf16) + (when (or (sphere-in-view-frustum? s3-0) (logtest? (-> arg1 status) (draw-control-status no-bounds-check))) + (calc-vu1-lights s4-0 arg1 #t) + (let ((at-0 *math-camera*)) + (.lvf vf16 (&-> at-0 plane 0 quad)) + (.lvf vf17 (&-> at-0 plane 1 quad)) + (.lvf vf18 (&-> at-0 plane 2 quad)) + (.lvf vf19 (&-> at-0 plane 3 quad)) + (.lvf vf20 (&-> at-0 guard-plane 0 quad)) + (.lvf vf21 (&-> at-0 guard-plane 1 quad)) + (.lvf vf22 (&-> at-0 guard-plane 2 quad)) + (.lvf vf23 (&-> at-0 guard-plane 3 quad)) + (.lvf vf24 (&-> at-0 camera-rot rvec quad)) + (.lvf vf25 (&-> at-0 camera-rot uvec quad)) + (.lvf vf26 (&-> at-0 camera-rot fvec quad)) + (.lvf vf27 (&-> at-0 camera-rot trans quad)) + ) + (let ((v1-20 (-> (the-as foreground-work #x70000000) distance))) + (.lvf vf15 (&-> s3-0 quad)) + (.mul.w.vf acc vf27 vf0) + (.add.mul.x.vf acc vf24 vf15 acc) + (.add.mul.y.vf acc vf25 vf15 acc) + (.add.mul.z.vf vf15 vf26 vf15 acc :mask #b111) + (.mul.vf vf28 vf15 vf15) + (.max.w.vf vf29 vf0 vf0) + (.add.y.vf acc vf28 vf28) + (.add.mul.z.vf vf28 vf29 vf28 acc :mask #b1) + (.sqrt.vf Q vf28 :ftf #b0) + (.sub.w.vf vf28 vf0 vf15 :mask #b1000) + (.wait.vf) + (.add.vf vf15 vf28 Q :mask #b1000) + (.svf (&-> v1-20 quad) vf15) + (when (< 0.0 (+ (-> v1-20 z) (-> arg1 bounds w))) + (let ((s4-1 0)) + (let ((f30-0 (-> v1-20 w))) + (if (and *debug-segment* (-> *screen-shot-work* highres-enable)) + (set! f30-0 0.0) + ) + (set! (-> arg1 distance) f30-0) + (when (nonzero? (-> arg1 lod-set max-lod)) + (cond + ((>= (-> arg1 force-lod) 0) + (set! s4-1 (-> arg1 force-lod)) + (if (< (-> arg1 lod-set lod (-> arg1 lod-set max-lod) dist) f30-0) + (return #f) + ) + ) + (else + (while (and (< s4-1 (-> arg1 lod-set max-lod)) (< (-> arg1 lod-set lod s4-1 dist) f30-0)) + (+! s4-1 1) + ) + ) + ) + ) + (if (and (< (-> arg1 lod-set lod s4-1 dist) f30-0) (< (-> arg1 force-lod) 0)) + (return #f) + ) + (let ((v1-49 (-> *level* level (-> arg1 level-index))) + (f0-5 (* f30-0 (-> *math-camera* fov-correction-factor))) + (a0-18 (-> arg1 mgeo header texture-usage-group)) + ) + (dotimes (a1-4 7) + (let ((a2-2 (+ a1-4 12))) + (if (not (logtest? (-> arg1 status) (draw-control-status no-closest-distance))) + (set! (-> v1-49 closest-object a2-2) (fmin (-> v1-49 closest-object a2-2) f30-0)) + ) + ) + (let ((t0-0 (cond + ((>= f0-5 (-> a0-18 data a1-4 data 0 dist)) + 0 + ) + ((>= f0-5 (-> a0-18 data a1-4 data 1 dist)) + 1 + ) + (else + 2 + ) + ) + ) + (a2-12 (+ a1-4 12)) + ) + (let ((a3-8 (-> v1-49 texture-mask a2-12 mask quad)) + (t0-3 (-> (the-as (pointer int128) (+ (the-as uint a0-18) (* 48 a1-4) (* t0-0 16))) 0)) + ) + (.por a3-9 a3-8 t0-3) + ) + (set! (-> v1-49 texture-mask a2-12 mask quad) a3-9) + ) + ) + ) + (if (or (guard-band-cull s3-0) (< f30-0 (* 1.2 (-> *math-camera* d)))) + (logior! (-> arg1 status) (draw-control-status close-to-screen)) + (logclear! (-> arg1 status) (draw-control-status close-to-screen)) + ) + (logior! (-> arg1 status) (draw-control-status on-screen)) + (if (logtest? (-> arg1 status) (draw-control-status no-draw-bounds no-draw-bounds2)) + (return #f) + ) + (set! (-> pp clock) (-> sv-16 clock)) + (if (or (= s4-1 (-> arg1 cur-lod)) (logtest? (-> arg1 status) (draw-control-status lod-set))) + (foreground-draw arg1 arg3 f30-0) + ) + ) + (when (and (< s4-1 (-> arg1 cur-lod)) (logtest? (-> arg1 status) (draw-control-status math-skel))) + (let ((s5-1 *matrix-engine*)) + (when (= (-> s5-1 length) (-> s5-1 allocated-length)) + (format 0 "Matrix engine is too small!~%") + (format *stdcon* "Matrix engine is too small!~%") + (break!) + 0 + ) + (set! (-> s5-1 (-> s5-1 length)) (process->handle sv-16)) + (+! (-> s5-1 length) 1) + ) + ) + (lod-set! arg1 s4-1) + ) + (logior! (-> arg1 status) (draw-control-status lod-set)) + ) + ) + ) + ) + ) + (let ((v1-88 (-> *perf-stats* data 50))) + (b! (zero? (-> v1-88 ctrl)) cfg-79 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mfpc a0-41 pcr0) + (+! (-> v1-88 accum0) a0-41) + (.mfpc a0-43 pcr1) + (+! (-> v1-88 accum1) a0-43) + ) + (label cfg-79) + 0 + 0 + (none) + ) + ) + ) + +;; definition for symbol *hud-lights*, type vu-lights +(define *hud-lights* (new 'global 'vu-lights)) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* direction 0) 1.0 0.0 0.0 1.0) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* direction 1) 0.0 1.0 0.0 1.0) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* direction 2) 0.0 0.0 1.0 1.0) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* color 0) 0.0 0.0 0.0 1.0) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* color 1) 0.0 0.0 0.0 1.0) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* color 2) 0.5 0.5 0.5 1.0) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* ambient) 0.5 0.5 0.5 1.0) + +;; definition for function dma-add-process-drawable-hud +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun dma-add-process-drawable-hud ((arg0 process-drawable) (arg1 draw-control) (arg2 float) (arg3 dma-buffer)) + "Special version of dma-add-process-drawable for drawing hud foreground objects" + (local-vars (a3-4 uint128)) + (logclear! (-> arg1 status) (draw-control-status on-screen)) + (when (not (logtest? (-> arg1 status) (draw-control-status no-draw no-draw-temp uninited))) + (let ((v1-6 (-> (the-as foreground-work #x70000000) lights)) + (a0-3 *hud-lights*) + ) + (set! (-> v1-6 direction 0 quad) (-> a0-3 direction 0 quad)) + (set! (-> v1-6 direction 1 quad) (-> a0-3 direction 1 quad)) + (set! (-> v1-6 direction 2 quad) (-> a0-3 direction 2 quad)) + (set! (-> v1-6 color 0 quad) (-> a0-3 color 0 quad)) + (set! (-> v1-6 color 1 quad) (-> a0-3 color 1 quad)) + (set! (-> v1-6 color 2 quad) (-> a0-3 color 2 quad)) + (set! (-> v1-6 ambient quad) (-> a0-3 ambient quad)) + ) + (lod-set! arg1 0) + (logior! (-> arg1 status) (draw-control-status on-screen)) + (foreground-draw-hud arg1 arg3 arg2) + (let ((v1-12 (-> *level* level-default)) + (a0-9 (-> arg1 mgeo header texture-usage-group)) + ) + (dotimes (a1-9 7) + (let ((a2-1 (+ a1-9 12))) + (let ((a3-3 (-> v1-12 texture-mask a2-1 mask quad)) + (t0-3 (-> a0-9 data a1-9 data 2 mask quad)) + ) + (.por a3-4 a3-3 t0-3) + ) + (set! (-> v1-12 texture-mask a2-1 mask quad) a3-4) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function add-process-drawable +;; WARN: Return type mismatch symbol vs none. +(defun add-process-drawable ((arg0 process-drawable) (arg1 draw-control) (arg2 symbol) (arg3 dma-buffer)) + "Foreground engine function to generate dma for a process-drawable." + ((-> arg1 dma-add-func) arg0 arg1 arg2 arg3) + (none) + ) + +;; definition for function foreground-engine-execute +;; WARN: Return type mismatch int vs none. +;; ERROR: Unsupported inline assembly instruction kind - [cache dxwbin v1, 0] +;; ERROR: Unsupported inline assembly instruction kind - [cache dxwbin v1, 1] +(defun foreground-engine-execute ((arg0 engine)) + "Draw all foreground objects!" + (when (> (length arg0) 0) + (let ((gp-0 (-> *display* frames (-> *display* on-screen) global-buf base))) + (when *debug-segment* + (let ((s4-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-16 'foreground) + (s3-0 *profile-foreground-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s2-0 (-> s4-0 data (-> s4-0 count)))) + (let ((s1-0 (-> s4-0 base-time))) + (set! (-> s2-0 name) v1-16) + (set! (-> s2-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s1-0)))) + ) + (set! (-> s2-0 depth) (the-as uint (-> s4-0 depth))) + (set! (-> s2-0 color) s3-0) + (set! (-> s4-0 segment (-> s4-0 depth)) s2-0) + ) + (set! (-> s4-0 count) (min 1023 (+ (-> s4-0 count) 1))) + (+! (-> s4-0 depth) 1) + (set! (-> s4-0 max-depth) (max (-> s4-0 max-depth) (-> s4-0 depth))) + ) + ) + 0 + ) + (let ((s4-1 (-> *display* frames (-> *display* on-screen) global-buf))) + (let ((v1-34 (-> s4-1 base))) + (.sync.l) + (.cache dxwbin v1-34 0) + (.sync.l) + (.cache dxwbin v1-34 1) + ) + (.sync.l) + 0 + (foreground-init) + (execute-connections arg0 s4-1) + ) + (foreground-wrapup) + (when *debug-segment* + (let ((s5-1 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-49 (+ (-> s5-1 depth) -1)) + (s4-2 (-> s5-1 segment v1-49)) + (s3-1 (-> s5-1 base-time)) + ) + (when (>= v1-49 0) + (set! (-> s4-2 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-1)))) + (+! (-> s5-1 depth) -1) + ) + ) + ) + ) + 0 + ) + (let ((v1-54 *dma-mem-usage*)) + (when (nonzero? v1-54) + (set! (-> v1-54 length) (max 36 (-> v1-54 length))) + (set! (-> v1-54 data 35 name) "pris-fragment") + (+! (-> v1-54 data 35 count) 1) + (+! (-> v1-54 data 35 used) + (&- (-> *display* frames (-> *display* on-screen) global-buf base) (the-as uint gp-0)) + ) + (set! (-> v1-54 data 35 total) (-> v1-54 data 35 used)) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition (debug) for function main-debug-hook +(defun-debug main-debug-hook () + "Run debug engine, collision renderer." + (when (not (or (= *master-mode* 'menu) (= *master-mode* 'progress))) + (let ((a0-3 *col-rend*)) + (if (-> a0-3 draw?) + (draw a0-3) + ) + ) + (execute-connections *debug-engine* #f) + (draw-instance-info *stdcon*) + ) + (none) + ) + +;; definition for symbol *debug-hook*, type pair +(define *debug-hook* (cons main-debug-hook '())) + +;; definition for symbol *add-sphere*, type symbol +(define *add-sphere* #f) + +;; definition for symbol *generic-effect-mode*, type int +(define *generic-effect-mode* 0) + +;; definition for function foreground-initialize-engines +;; WARN: Return type mismatch symbol vs none. +(defun foreground-initialize-engines () + "Initialize shadow chains prior to foreground drawing." + (let ((v1-0 *shadow-globals*)) + (dotimes (a0-0 3) + (let ((a1-2 (-> v1-0 bucket a0-0))) + (set! (-> a1-2 first) (the-as pointer 0)) + (set! (-> a1-2 next) (the-as pointer 0)) + (set! (-> a1-2 shadow-color) (cond + ((zero? a0-0) + (new 'static 'rgba :r #xf0 :g #xf0 :b #xf0 :a #x80) + ) + ((= a0-0 1) + (the-as rgba (-> *setting-control* user-current spotlight-color)) + ) + (else + (the-as rgba (-> *setting-control* user-current highlight-color)) + ) + ) + ) + (set! (-> a1-2 constants) (the-as shadow-vu1-constants 0)) + ) + ) + ) + (none) + ) + +;; definition for function foreground-execute-cpu-vu0-engines +(defun foreground-execute-cpu-vu0-engines () + "Run foreground drawing code on EE/VU0 (bones, generic merc, part of shadow, lightning, prim)" + (let ((gp-0 (-> *display* frames (-> *display* on-screen) global-buf))) + (bones-init gp-0) + (bones-mtx-calc-execute) + (generic-merc-execute-all gp-0) + (shadow-execute-all gp-0) + ) + (lightning-draw-all) + (prim-engine-execute) + (none) + ) + +;; definition for function real-main-draw-hook +;; WARN: Return type mismatch int vs none. +(defun real-main-draw-hook () + "Do all drawing! Called by main loop to run drawing for a frame. + Note that this also dispatches collide events, updates actors, etc. + It's a bit more than just drawing." + (local-vars (a0-115 int) (a0-117 int)) + (with-pp + (let ((v1-5 (-> *display* frames (-> *display* on-screen) global-buf))) + (set! (-> v1-5 end) (&- (-> v1-5 end) (the-as uint (* (shr (+ (-> *display* mem-reserve-size) 8255) 6) 64)))) + ) + (when *display-bug-report* + (let ((v1-13 (-> *display* frames (-> *display* on-screen) global-buf))) + (&+! (-> v1-13 end) -262144) + ) + ) + (set! (-> *display* dma-buffer-overflow) #f) + (set! (-> *display* mem-reserve-size) (the-as uint 0)) + (when *slow-frame-rate* + (dotimes (v1-18 #xc3500) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + ) + ) + "Function to be executed to set up for engine dma" + (set! (-> *display* vu1-enable-user) (-> *display* vu1-enable-user-menu)) + (set! (-> *texture-pool* texture-enable-user) (-> *texture-pool* texture-enable-user-menu)) + (when *debug-segment* + (when (and *stats-memory* (!= *master-mode* 'menu)) + (cond + (*stats-memory-short* + (dotimes (gp-0 (-> *level* length)) + (let ((s5-0 (-> *level* level gp-0))) + (if (= (-> s5-0 status) 'active) + (print-mem-usage (compute-memory-usage! s5-0 #f) s5-0 *stdcon*) + ) + ) + ) + ) + (else + (let ((gp-1 (-> *level* level *stats-memory-level-index*))) + (if (and gp-1 (= (-> gp-1 status) 'active)) + (print-mem-usage (compute-memory-usage! gp-1 #f) gp-1 *stdcon*) + ) + ) + ) + ) + ) + (reset! *dma-mem-usage*) + ) + (foreground-initialize-engines) + (reset! *prim-work*) + (let ((gp-2 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> *display* bg-clock)) + (set! (-> pp clock) (-> *display* real-clock)) + ) + (if (not (paused?)) + (update-wind *wind-work* *wind-scales*) + ) + (update-time-of-day *time-of-day-context*) + (set! (-> pp clock) gp-2) + ) + (when *debug-segment* + (let ((gp-3 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-73 'sky) + (s5-1 *profile-sky-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-0 (-> gp-3 data (-> gp-3 count)))) + (let ((s3-0 (-> gp-3 base-time))) + (set! (-> s4-0 name) v1-73) + (set! (-> s4-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-0)))) + ) + (set! (-> s4-0 depth) (the-as uint (-> gp-3 depth))) + (set! (-> s4-0 color) s5-1) + (set! (-> gp-3 segment (-> gp-3 depth)) s4-0) + ) + (set! (-> gp-3 count) (min 1023 (+ (-> gp-3 count) 1))) + (+! (-> gp-3 depth) 1) + (set! (-> gp-3 max-depth) (max (-> gp-3 max-depth) (-> gp-3 depth))) + ) + ) + 0 + ) + (if (-> *sky-work* draw-vortex) + (draw-vortex) + (draw *sky-work*) + ) + (flush-cache 0) + (when *debug-segment* + (let ((gp-4 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-102 (+ (-> gp-4 depth) -1)) + (s5-2 (-> gp-4 segment v1-102)) + (s4-1 (-> gp-4 base-time)) + ) + (when (>= v1-102 0) + (set! (-> s5-2 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-1)))) + (+! (-> gp-4 depth) -1) + ) + ) + ) + ) + 0 + ) + (let ((gp-5 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> *display* bg-clock)) + (set! (-> pp clock) (-> *display* real-clock)) + ) + (when *debug-segment* + (let ((s5-3 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-120 'ocean) + (s4-2 *profile-ocean-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-1 (-> s5-3 data (-> s5-3 count)))) + (let ((s2-0 (-> s5-3 base-time))) + (set! (-> s3-1 name) v1-120) + (set! (-> s3-1 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-0)))) + ) + (set! (-> s3-1 depth) (the-as uint (-> s5-3 depth))) + (set! (-> s3-1 color) s4-2) + (set! (-> s5-3 segment (-> s5-3 depth)) s3-1) + ) + (set! (-> s5-3 count) (min 1023 (+ (-> s5-3 count) 1))) + (+! (-> s5-3 depth) 1) + (set! (-> s5-3 max-depth) (max (-> s5-3 max-depth) (-> s5-3 depth))) + ) + ) + 0 + ) + (draw! *ocean*) + (if *ocean-map* + (update-map *ocean*) + ) + (when *debug-segment* + (let ((s5-4 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-150 (+ (-> s5-4 depth) -1)) + (s4-3 (-> s5-4 segment v1-150)) + (s3-2 (-> s5-4 base-time)) + ) + (when (>= v1-150 0) + (set! (-> s4-3 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-2)))) + (+! (-> s5-4 depth) -1) + ) + ) + ) + ) + 0 + ) + (set! (-> pp clock) gp-5) + ) + (foreground-engine-execute *foreground-draw-engine*) + (let ((gp-6 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> *display* bg-clock)) + (set! (-> pp clock) (-> *display* real-clock)) + ) + (foreground-execute-cpu-vu0-engines) + (set! (-> pp clock) gp-6) + ) + (when *add-sphere* + ) + (if (not (paused?)) + (execute-part-engine) + ) + (when (logtest? (vu1-renderer-mask sprite) (-> *display* vu1-enable-user)) + (if (not (get-screen-copied *blit-displays-work*)) + (sprite-draw *display*) + ) + ) + (when *debug-segment* + (debug-draw-actors *level* *display-actor-marks*) + (collide-shape-draw-debug-marks) + ) + (when *display-trail-graph* + (let ((a0-67 *trail-graph*)) + (if a0-67 + (debug-draw a0-67) + ) + ) + ) + (send-events-for-touching-shapes *touching-list*) + (free-nodes *touching-list*) + (prepare *collide-rider-pool*) + (send-all! *event-queue*) + (when *debug-segment* + (let ((gp-7 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-200 'actors) + (s5-5 *profile-actors-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-4 (-> gp-7 data (-> gp-7 count)))) + (let ((s3-3 (-> gp-7 base-time))) + (set! (-> s4-4 name) v1-200) + (set! (-> s4-4 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-3)))) + ) + (set! (-> s4-4 depth) (the-as uint (-> gp-7 depth))) + (set! (-> s4-4 color) s5-5) + (set! (-> gp-7 segment (-> gp-7 depth)) s4-4) + ) + (set! (-> gp-7 count) (min 1023 (+ (-> gp-7 count) 1))) + (+! (-> gp-7 depth) 1) + (set! (-> gp-7 max-depth) (max (-> gp-7 max-depth) (-> gp-7 depth))) + ) + ) + 0 + ) + (actors-update *level*) + (when *debug-segment* + (let ((gp-8 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-226 (+ (-> gp-8 depth) -1)) + (s5-6 (-> gp-8 segment v1-226)) + (s4-5 (-> gp-8 base-time)) + ) + (when (>= v1-226 0) + (set! (-> s5-6 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-5)))) + (+! (-> gp-8 depth) -1) + ) + ) + ) + ) + 0 + ) + (when *debug-segment* + (let ((gp-9 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-239 'nav) + (s5-7 *profile-nav-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-6 (-> gp-9 data (-> gp-9 count)))) + (let ((s3-4 (-> gp-9 base-time))) + (set! (-> s4-6 name) v1-239) + (set! (-> s4-6 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-4)))) + ) + (set! (-> s4-6 depth) (the-as uint (-> gp-9 depth))) + (set! (-> s4-6 color) s5-7) + (set! (-> gp-9 segment (-> gp-9 depth)) s4-6) + ) + (set! (-> gp-9 count) (min 1023 (+ (-> gp-9 count) 1))) + (+! (-> gp-9 depth) 1) + (set! (-> gp-9 max-depth) (max (-> gp-9 max-depth) (-> gp-9 depth))) + ) + ) + 0 + ) + (update-nav-meshes-method *level*) + (when *debug-segment* + (let ((gp-10 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-265 (+ (-> gp-10 depth) -1)) + (s5-8 (-> gp-10 segment v1-265)) + (s4-7 (-> gp-10 base-time)) + ) + (when (>= v1-265 0) + (set! (-> s5-8 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-7)))) + (+! (-> gp-10 depth) -1) + ) + ) + ) + ) + 0 + ) + (when *debug-segment* + (let ((gp-11 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-278 'background) + (s5-9 *profile-background-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-8 (-> gp-11 data (-> gp-11 count)))) + (let ((s3-5 (-> gp-11 base-time))) + (set! (-> s4-8 name) v1-278) + (set! (-> s4-8 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-5)))) + ) + (set! (-> s4-8 depth) (the-as uint (-> gp-11 depth))) + (set! (-> s4-8 color) s5-9) + (set! (-> gp-11 segment (-> gp-11 depth)) s4-8) + ) + (set! (-> gp-11 count) (min 1023 (+ (-> gp-11 count) 1))) + (+! (-> gp-11 depth) 1) + (set! (-> gp-11 max-depth) (max (-> gp-11 max-depth) (-> gp-11 depth))) + ) + ) + 0 + ) + (init-background) + (execute-connections *background-draw-engine* #f) + (let* ((v1-294 (-> *perf-stats* data 40)) + (a0-113 (-> v1-294 ctrl)) + ) + (+! (-> v1-294 count) 1) + (b! (zero? a0-113) cfg-122 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mtpc pcr0 0) + (.mtpc pcr1 0) + (.sync.l) + (.sync.p) + (.mtc0 Perf a0-113) + ) + (.sync.l) + (.sync.p) + (label cfg-122) + 0 + (finish-background) + (let ((v1-297 (-> *perf-stats* data 40))) + (b! (zero? (-> v1-297 ctrl)) cfg-124 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mfpc a0-115 pcr0) + (+! (-> v1-297 accum0) a0-115) + (.mfpc a0-117 pcr1) + (+! (-> v1-297 accum1) a0-117) + ) + (label cfg-124) + 0 + (update-wait-stats + (-> *perf-stats* data 40) + (-> *background-work* wait-to-vu0) + (the-as uint 0) + (the-as uint 0) + ) + (when *debug-segment* + (let ((gp-12 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-314 (+ (-> gp-12 depth) -1)) + (s5-10 (-> gp-12 segment v1-314)) + (s4-9 (-> gp-12 base-time)) + ) + (when (>= v1-314 0) + (set! (-> s5-10 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-9)))) + (+! (-> gp-12 depth) -1) + ) + ) + ) + ) + 0 + ) + (end-perf-stat-collection) + (when (and (!= *master-mode* 'menu) *stats-poly*) + (dotimes (gp-13 (-> *level* length)) + (let ((v1-326 (-> *level* level gp-13))) + (if (= (-> v1-326 status) 'active) + (collect-stats (-> v1-326 bsp)) + ) + ) + ) + (print-terrain-stats) + ) + (when (not (paused?)) + (if (and (!= *master-mode* 'menu) *stats-perf*) + (print-perf-stats) + ) + (if (and (!= *master-mode* 'menu) *stats-collide*) + (print-collide-stats) + ) + ) + (start-perf-stat-collection) + 0 + (none) + ) + ) + +;; definition for function main-draw-hook +(defun main-draw-hook () + "Wrapper of real-main-draw-hook" + (real-main-draw-hook) + (none) + ) + +;; definition for symbol *draw-hook*, type (function none) +(define *draw-hook* main-draw-hook) + +;; definition for function default-init-buffer +;; WARN: Return type mismatch symbol vs none. +(defun default-init-buffer ((arg0 bucket-id) (arg1 gs-zbuf) (arg2 gs-test)) + "Initialize DMA chain for a bucket." + (let ((v1-0 *display*) + (t0-0 16) + ) + (+! (-> v1-0 mem-reserve-size) t0-0) + (when (not (-> v1-0 dma-buffer-overflow)) + (let ((t1-0 (-> v1-0 frames (-> v1-0 on-screen) global-buf))) + (if (< (-> t1-0 real-buffer-end) (the-as int (&+ (-> t1-0 base) t0-0))) + (set! (-> v1-0 dma-buffer-overflow) #t) + ) + ) + (when (not (-> v1-0 dma-buffer-overflow)) + (let ((v1-8 (-> *display* frames (-> *display* on-screen) bucket-group arg0))) + (when (!= v1-8 (-> v1-8 last)) + (let* ((a0-8 (-> *display* frames (-> *display* on-screen) global-buf)) + (a3-15 (-> a0-8 base)) + ) + (let ((t0-2 *display*) + (t1-2 176) + ) + (+! (-> t0-2 mem-reserve-size) t1-2) + (when (not (-> t0-2 dma-buffer-overflow)) + (let ((t3-0 (-> t0-2 frames (-> t0-2 on-screen) global-buf))) + (if (< (-> t3-0 real-buffer-end) (the-as int (&+ (-> t3-0 base) t1-2))) + (set! (-> t0-2 dma-buffer-overflow) #t) + ) + ) + (if (not (-> t0-2 dma-buffer-overflow)) + (dma-buffer-add-gs-set-flusha a0-8 + (zbuf-1 arg1) + (test-1 arg2) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + (pabe 0) + (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) + (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (texa (new 'static 'gs-texa :ta1 #x80)) + (texclut (new 'static 'gs-texclut :cbw #x4)) + (fogcol *fog-color*) + ) + ) + ) + ) + (let ((a1-17 (the-as dma-packet (-> a0-8 base)))) + (set! (-> a1-17 dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> v1-8 next))) + (set! (-> a1-17 vif0) (new 'static 'vif-tag)) + (set! (-> a1-17 vif1) (new 'static 'vif-tag)) + (set! (-> a0-8 base) (the-as pointer (&+ a1-17 16))) + ) + (set! (-> v1-8 next) (the-as uint a3-15)) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for function default-end-buffer +;; WARN: Return type mismatch symbol vs none. +(defun default-end-buffer ((arg0 bucket-id) (arg1 gs-zbuf) (arg2 gs-test)) + "Add DMA data at the end of a bucket to reset settings." + (let ((v1-0 *display*) + (a3-0 16) + ) + (+! (-> v1-0 mem-reserve-size) a3-0) + (when (not (-> v1-0 dma-buffer-overflow)) + (let ((t1-0 (-> v1-0 frames (-> v1-0 on-screen) global-buf))) + (if (< (-> t1-0 real-buffer-end) (the-as int (&+ (-> t1-0 base) a3-0))) + (set! (-> v1-0 dma-buffer-overflow) #t) + ) + ) + (when (not (-> v1-0 dma-buffer-overflow)) + (let ((v1-8 (-> *display* frames (-> *display* on-screen) bucket-group arg0))) + (when (!= v1-8 (-> v1-8 last)) + (let* ((a3-6 (-> *display* frames (-> *display* on-screen) global-buf)) + (a0-8 (-> a3-6 base)) + ) + (let ((t0-11 *display*) + (t1-2 176) + ) + (+! (-> t0-11 mem-reserve-size) t1-2) + (when (not (-> t0-11 dma-buffer-overflow)) + (let ((t3-0 (-> t0-11 frames (-> t0-11 on-screen) global-buf))) + (if (< (-> t3-0 real-buffer-end) (the-as int (&+ (-> t3-0 base) t1-2))) + (set! (-> t0-11 dma-buffer-overflow) #t) + ) + ) + (if (not (-> t0-11 dma-buffer-overflow)) + (dma-buffer-add-gs-set-flusha a3-6 + (zbuf-1 arg1) + (test-1 arg2) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + (pabe 0) + (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) + (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (texa (new 'static 'gs-texa :ta1 #x80)) + (texclut (new 'static 'gs-texclut :cbw #x4)) + (fogcol *fog-color*) + ) + ) + ) + ) + (let ((t0-16 (-> a3-6 base))) + (let ((a1-17 (the-as dma-packet (-> a3-6 base)))) + (set! (-> a1-17 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> a1-17 vif0) (new 'static 'vif-tag)) + (set! (-> a1-17 vif1) (new 'static 'vif-tag)) + (set! (-> a3-6 base) (the-as pointer (&+ a1-17 16))) + ) + (set! (-> (the-as (pointer uint32) (-> v1-8 last)) 1) (the-as uint a0-8)) + (set! (-> v1-8 last) (the-as (pointer dma-tag) t0-16)) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; definition (debug) for function screen-shot-scale +;; WARN: Return type mismatch int vs none. +(defun-debug screen-shot-scale ((arg0 int) (arg1 string)) + (set! (-> *screen-shot-work* size) arg0) + (set! (-> *screen-shot-work* name) arg1) + (set! *display-profile* #f) + 0 + (none) + ) + +;; definition (debug) for function screen-shot +;; WARN: Return type mismatch int vs none. +(defun-debug screen-shot () + "Take a screenshot." + (screen-shot-scale 1 "image") + 0 + (none) + ) + +;; definition for function display-frame-start +;; WARN: Return type mismatch display vs none. +(defun display-frame-start ((arg0 display) (arg1 int) (arg2 float)) + "Advance clocks, poll pads/mouse, set up buckets." + (set! (-> (the-as vif-bank #x10003c00) err me0) 1) + (set-time-ratios *display* 1.0) + (tick! (-> arg0 frame-clock)) + (tick! (-> arg0 real-frame-clock)) + (set-time-ratios *display* arg2) + (tick! (-> arg0 session-clock)) + (tick! (-> arg0 game-clock)) + (tick! (-> arg0 total-game-clock)) + (tick! (-> arg0 base-clock)) + (tick! (-> arg0 real-clock)) + (tick! (-> arg0 target-clock)) + (tick! (-> arg0 camera-clock)) + (tick! (-> arg0 entity-clock)) + (tick! (-> arg0 bg-clock)) + (tick! (-> arg0 user0-clock)) + (tick! (-> arg0 user1-clock)) + (tick! (-> arg0 user2-clock)) + (tick! (-> arg0 user3-clock)) + (tick! (-> arg0 user4-clock)) + (tick! (-> arg0 user5-clock)) + (tick! (-> arg0 user6-clock)) + (tick! (-> arg0 user7-clock)) + (tick! (-> arg0 user8-clock)) + (tick! (-> arg0 user9-clock)) + (set! (-> arg0 bg-clock frame-counter) (the-as time-frame (mod (-> arg0 bg-clock frame-counter) #x69780))) + (tick! (-> arg0 part-clock)) + (when (and (nonzero? *screen-shot-work*) (!= (-> *screen-shot-work* count) -1)) + (let ((v1-61 (-> *screen-shot-work* size))) + (if (!= (-> *screen-shot-work* count) (* v1-61 v1-61)) + (store-image *screen-shot-work*) + ) + ) + (+! (-> *screen-shot-work* count) -1) + (if (= (-> *screen-shot-work* count) -1) + (set! (-> *screen-shot-work* size) -1) + ) + ) + (let ((s5-1 (-> arg0 frames arg1))) + (if *sync-dma* + (sync-path 0 0) + ) + (let ((v1-75 (-> s5-1 global-buf))) + (set! (-> v1-75 base) (-> v1-75 data)) + (set! (-> v1-75 end) (the-as pointer (+ (+ (-> v1-75 allocated-length) 28) (the-as int v1-75)))) + ) + (when *debug-segment* + (let ((v1-78 (-> s5-1 debug-buf))) + (set! (-> v1-78 base) (-> v1-78 data)) + (set! (-> v1-78 end) (the-as pointer (+ (+ (-> v1-78 allocated-length) 28) (the-as int v1-78)))) + ) + ) + (let ((v1-79 (-> s5-1 calc-buf))) + (set! (-> v1-79 base) (-> v1-79 data)) + (set! (-> v1-79 end) (the-as pointer (+ (+ (-> v1-79 allocated-length) 28) (the-as int v1-79)))) + ) + (*pre-draw-hook* (-> s5-1 calc-buf)) + (when (not (paused?)) + (clear *stdcon1*) + (debug-reset-buffers) + (clear! *simple-sprite-system*) + ) + (set! (-> s5-1 bucket-group) (dma-buffer-add-buckets (-> s5-1 calc-buf) 586)) + ) + (service-cpads) + (service-mouse) + (service-keybd) + (execute-connections *pad-engine* #f) + (none) + ) + +;; definition for function display-frame-finish +(defun display-frame-finish ((arg0 display)) + "Do final texture remaps, sync DMA (wait for previous rendering to finish), and finalize DMA chain." + (local-vars (a0-54 int) (a0-56 int)) + (with-pp + (let* ((s4-0 (-> arg0 frames (-> arg0 on-screen))) + (s5-0 (-> s4-0 calc-buf)) + ) + (-> s4-0 global-buf base) + (tfrag-vu1-init-buffers) + (tie-vu1-init-buffers) + (merc-vu1-init-buffers) + (emerc-vu1-init-buffers) + (generic-vu1-init-buffers) + (when *debug-segment* + (let ((s3-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-12 'texture) + (s2-0 *profile-texture-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s1-0 (-> s3-0 data (-> s3-0 count)))) + (let ((s0-0 (-> s3-0 base-time))) + (set! (-> s1-0 name) v1-12) + (set! (-> s1-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s0-0)))) + ) + (set! (-> s1-0 depth) (the-as uint (-> s3-0 depth))) + (set! (-> s1-0 color) s2-0) + (set! (-> s3-0 segment (-> s3-0 depth)) s1-0) + ) + (set! (-> s3-0 count) (min 1023 (+ (-> s3-0 count) 1))) + (+! (-> s3-0 depth) 1) + (set! (-> s3-0 max-depth) (max (-> s3-0 max-depth) (-> s3-0 depth))) + ) + ) + 0 + ) + (when (-> *texture-pool* update-sprites-flag) + (update-sprites *texture-pool*) + (particle-adgif-cache-flush) + (remap-all-particles) + ) + (let ((s3-1 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> arg0 bg-clock)) + (set! (-> pp clock) (-> arg0 real-clock)) + ) + (upload-textures *texture-pool*) + (set! (-> pp clock) s3-1) + ) + (if (-> *texture-pool* update-flag) + (update-warp-and-hud *texture-pool*) + ) + (-> arg0 frames (-> arg0 on-screen) global-buf) + (update-eyes) + (when *debug-segment* + (let ((s3-2 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-56 (+ (-> s3-2 depth) -1)) + (s2-1 (-> s3-2 segment v1-56)) + (s1-1 (-> s3-2 base-time)) + ) + (when (>= v1-56 0) + (set! (-> s2-1 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s1-1)))) + (+! (-> s3-2 depth) -1) + ) + ) + ) + ) + 0 + ) + (when *debug-segment* + (when *debug-segment* + (let ((s3-3 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-71 'debug) + (s2-2 *profile-debug-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s1-2 (-> s3-3 data (-> s3-3 count)))) + (let ((s0-1 (-> s3-3 base-time))) + (set! (-> s1-2 name) v1-71) + (set! (-> s1-2 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s0-1)))) + ) + (set! (-> s1-2 depth) (the-as uint (-> s3-3 depth))) + (set! (-> s1-2 color) s2-2) + (set! (-> s3-3 segment (-> s3-3 depth)) s1-2) + ) + (set! (-> s3-3 count) (min 1023 (+ (-> s3-3 count) 1))) + (+! (-> s3-3 depth) 1) + (set! (-> s3-3 max-depth) (max (-> s3-3 max-depth) (-> s3-3 depth))) + ) + ) + 0 + ) + (debug-draw-buffers) + (when *debug-segment* + (let ((s3-4 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-95 (+ (-> s3-4 depth) -1)) + (s2-3 (-> s3-4 segment v1-95)) + (s1-3 (-> s3-4 base-time)) + ) + (when (>= v1-95 0) + (set! (-> s2-3 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s1-3)))) + (+! (-> s3-4 depth) -1) + ) + ) + ) + ) + 0 + ) + (when *debug-segment* + (let ((s3-5 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-108 'gs-sync) + (s2-4 *profile-gs-sync-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s1-4 (-> s3-5 data (-> s3-5 count)))) + (let ((s0-2 (-> s3-5 base-time))) + (set! (-> s1-4 name) v1-108) + (set! (-> s1-4 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s0-2)))) + ) + (set! (-> s1-4 depth) (the-as uint (-> s3-5 depth))) + (set! (-> s1-4 color) s2-4) + (set! (-> s3-5 segment (-> s3-5 depth)) s1-4) + ) + (set! (-> s3-5 count) (min 1023 (+ (-> s3-5 count) 1))) + (+! (-> s3-5 depth) 1) + (set! (-> s3-5 max-depth) (max (-> s3-5 max-depth) (-> s3-5 depth))) + ) + ) + 0 + ) + (when (nonzero? (sync-path 0 0)) + (*dma-timeout-hook*) + (reset-vif1-path) + (nop!) + (nop!) + 0 + ) + (when *debug-segment* + (let ((s3-6 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-134 (+ (-> s3-6 depth) -1)) + (s2-5 (-> s3-6 segment v1-134)) + (s1-5 (-> s3-6 base-time)) + ) + (when (>= v1-134 0) + (set! (-> s2-5 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s1-5)))) + (+! (-> s3-6 depth) -1) + ) + ) + ) + ) + 0 + ) + (let ((s3-7 (-> arg0 frames (-> arg0 on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-148 (+ (-> s3-7 depth) -1)) + (s2-6 (-> s3-7 segment v1-148)) + (s1-6 (-> s3-7 base-time)) + ) + (when (>= v1-148 0) + (set! (-> s2-6 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s1-6)))) + (+! (-> s3-7 depth) -1) + ) + ) + ) + ) + 0 + (let ((v1-155 (-> *perf-stats* data))) + (b! (zero? (-> v1-155 0 ctrl)) cfg-63 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mfpc a0-54 pcr0) + (+! (-> v1-155 0 accum0) a0-54) + (.mfpc a0-56 pcr1) + (+! (-> v1-155 0 accum1) a0-56) + ) + (label cfg-63) + 0 + (with-dma-buffer-add-bucket ((s2-7 (-> arg0 frames (-> arg0 on-screen) debug-buf)) + (bucket-id debug-no-zbuf2) + ) + (when (and (or *display-profile* *stats-profile-bars*) (not *display-capture-mode*)) + (postprocess-data! (-> arg0 frames (-> arg0 on-screen) profile-array)) + (let ((a2-0 7)) + (if *display-profile* + (draw-bars! *profile-array* s2-7 a2-0) + ) + ) + (if (and (!= *master-mode* 'menu) *stats-profile-bars*) + (draw-text! *profile-array*) + ) + ) + (when *display-deci-count* + (let ((s1-7 draw-string-xy)) + (format (clear *temp-string*) "~D" *deci-count*) + (s1-7 *temp-string* s2-7 448 210 (font-color default) (font-flags shadow kerning)) + ) + ) + (display-file-info) + ) + ) + (let ((s3-9 6) + (s2-8 583) + ) + (while (>= s2-8 s3-9) + (default-end-buffer + (the-as bucket-id s3-9) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24)) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) + ) + (+! s3-9 1) + ) + ) + (default-init-buffer + (bucket-id debug-no-zbuf1) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) + ) + (default-init-buffer + (bucket-id debug-no-zbuf2) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) + ) + (default-init-buffer + (bucket-id tex-hud-pris2) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) + ) + (default-init-buffer + (bucket-id bucket8) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24)) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) + ) + (*post-draw-hook* (-> arg0 frames (-> arg0 on-screen) calc-buf)) + (let ((v1-199 *display*) + (a0-75 16) + ) + (+! (-> v1-199 mem-reserve-size) a0-75) + (when (not (-> v1-199 dma-buffer-overflow)) + (let ((a2-9 (-> v1-199 frames (-> v1-199 on-screen) global-buf))) + (if (< (-> a2-9 real-buffer-end) (the-as int (&+ (-> a2-9 base) a0-75))) + (set! (-> v1-199 dma-buffer-overflow) #t) + ) + ) + (when (not (-> v1-199 dma-buffer-overflow)) + (let* ((v1-201 s5-0) + (a0-79 (the-as dma-packet (-> v1-201 base))) + ) + (set! (-> a0-79 dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> a0-79 vif0) (new 'static 'vif-tag :imm #x24b :cmd (vif-cmd mark))) + (set! (-> a0-79 vif1) (new 'static 'vif-tag :cmd (vif-cmd flushe) :irq #x1 :msk #x1)) + (set! (-> v1-201 base) (the-as pointer (&+ a0-79 16))) + ) + ) + ) + ) + (dma-buffer-patch-buckets (the-as dma-bucket (-> s4-0 bucket-group)) 586) + (let ((v1-202 *display*) + (a0-81 16) + ) + (+! (-> v1-202 mem-reserve-size) a0-81) + (when (not (-> v1-202 dma-buffer-overflow)) + (let ((a2-11 (-> v1-202 frames (-> v1-202 on-screen) global-buf))) + (if (< (-> a2-11 real-buffer-end) (the-as int (&+ (-> a2-11 base) a0-81))) + (set! (-> v1-202 dma-buffer-overflow) #t) + ) + ) + (when (not (-> v1-202 dma-buffer-overflow)) + (let* ((v1-204 s5-0) + (a0-85 (-> v1-204 base)) + ) + (set! (-> (the-as (pointer int64) a0-85)) #x70000000) + (set! (-> (the-as (pointer uint64) a0-85) 1) (the-as uint 0)) + (set! (-> v1-204 base) (&+ a0-85 16)) + ) + ) + ) + ) + (flush-cache 0) + (when (not (paused?)) + (when *stats-buffer* + (let* ((a0-87 (-> s4-0 global-buf)) + (v1-208 (-> s5-0 base)) + (a2-13 (-> s5-0 data)) + (s4-1 (-> a0-87 base)) + (s5-1 (-> a0-87 data)) + (s3-10 (-> a0-87 end)) + ) + (format *stdcon* "~0kvu1 buf = ~d~%" (&- v1-208 (the-as uint a2-13))) + (format *stdcon* "~0kglobal buf = ~d~%" (&- s4-1 (the-as uint s5-1))) + (format *stdcon* "~0kbase = #x~x~%" s4-1) + (format *stdcon* "~0kend = #x~x~%" s3-10) + ) + ) + ) + ) + arg0 + ) + ) + +;; definition for function determine-pause-mode +;; WARN: Return type mismatch int vs none. +(defun determine-pause-mode () + "Update pause modes" + (when (and (or (not *progress-process*) (can-go-back? (-> *progress-process* 0))) + (or (!= *master-mode* 'freeze) (and *debug-segment* (cpad-pressed? 0 select start) (cpad-hold? 0 l3))) + ) + (if (or (cpad-pressed? 0 select start) + (cond + ((= *master-mode* 'menu) + (cpad-pressed? 0 r3 r2 triangle circle) + ) + (*cam-layout* + #f + ) + (else + #f + ) + ) + (or (and (logtest? (-> *cpad-list* cpads 0 valid) 128) + (= *master-mode* 'game) + (>= (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (= (-> *setting-control* user-current bg-a) 0.0) + (and (= (-> *setting-control* user-current bg-a-force) 0.0) + (< (seconds 1003) (-> *display* real-clock frame-counter)) + ) + ) + (and (cpad-pressed? 0 r2) (or (= *master-mode* 'pause) (= *master-mode* 'menu))) + *pause-lock* + ) + ) + (toggle-pause) + ) + ) + (if (and *progress-process* (!= *master-mode* 'progress)) + (deactivate-progress) + ) + 0 + (none) + ) + +;; definition for function calc-ratio +(defun calc-ratio ((arg0 int) (arg1 int)) + (let ((f0-1 (the float (sar (- arg0 arg1) 48)))) + (if (< f0-1 0.0) + (set! f0-1 (+ 65536.0 f0-1)) + ) + (/ f0-1 (the float *ticks-per-frame*)) + ) + ) + +;; definition for function display-sync +(defun display-sync ((arg0 display)) + (sync-path 0 0) + (let* ((s4-0 (-> arg0 last-screen)) + (s2-0 (shl (timer-count (the-as timer-bank #x10000800)) 48)) + (s5-0 (shl (-> arg0 frames s4-0 start-time) 48)) + (a1-1 (shl (-> arg0 vblank-start-time 0) 48)) + (s1-0 (shl (-> arg0 vblank-start-time 1) 48)) + ) + (set! *ticks-per-frame* (max 9000 (min #x2ee0 (sar (- s1-0 a1-1) 48)))) + (let ((f28-0 (the float *ticks-per-frame*)) + (s3-0 (sar (- s2-0 s5-0) 48)) + (f30-1 (fmax 1.0 (calc-ratio (the-as int s2-0) (the-as int s5-0)))) + ) + (/ (the float (sar (- s2-0 (the-as uint s1-0)) 48)) f28-0) + (let ((f28-1 (/ (the float (sar (- s2-0 (the-as uint s1-0)) 48)) f28-0)) + (f26-0 (fmax 1.0 (fmin 4.0 (-> *display* dog-ratio)))) + ) + (if (< (the-as int s3-0) 0) + (set! s3-0 (+ #x10000 s3-0)) + ) + (set! (-> arg0 frames s4-0 run-time) s3-0) + (set! f30-1 (cond + ((-> arg0 run-half-speed) + (syncv 0) + (let ((a0-8 (shl (timer-count (the-as timer-bank #x10000800)) 48))) + (if (and (< (calc-ratio (the-as int a0-8) (the-as int s5-0)) 2.0) (< f28-1 0.9)) + (syncv 0) + ) + ) + 2.0 + ) + ((< 1.0 f30-1) + (when (> (-> arg0 force-sync) 0) + (syncv 0) + (+! (-> arg0 force-sync) -1) + (let ((a0-12 (shl (timer-count (the-as timer-bank #x10000800)) 48))) + (set! f30-1 (calc-ratio (the-as int a0-12) (the-as int s5-0))) + ) + ) + f30-1 + ) + ((and (= f30-1 1.0) (< f30-1 f26-0)) + (while (< f30-1 f26-0) + (let ((a0-14 (shl (timer-count (the-as timer-bank #x10000800)) 48))) + (set! f30-1 (calc-ratio (the-as int a0-14) (the-as int s5-0))) + ) + (if (< f30-1 0.0) + (set! f30-1 f26-0) + ) + ) + 1.0 + ) + (else + (if (< f28-1 0.9) + (syncv 0) + ) + f30-1 + ) + ) + ) + ) + (let ((s4-1 (-> arg0 on-screen))) + (let ((v1-50 (timer-count (the-as timer-bank #x10000800)))) + (let ((a0-19 (sar (- (shl v1-50 48) s5-0) 48))) + (if (< (the-as int a0-19) 0) + (set! a0-19 (+ #x10000 a0-19)) + ) + (+! (-> arg0 total-run-time) a0-19) + ) + (set! (-> arg0 frames s4-1 start-time) v1-50) + ) + (set-graphics-mode) + (let ((s5-1 (-> arg0 frames s4-1 calc-buf))) + (when (nonzero? (dma-buffer-length s5-1)) + (+! s4-1 1) + (if (< 1 s4-1) + (set! s4-1 0) + ) + (set! (-> arg0 last-screen) (-> arg0 on-screen)) + (set! (-> arg0 on-screen) s4-1) + (when *debug-segment* + (set! *profile-interrupt-segment* (-> *display* frames (-> *display* last-screen) profile-array data 1)) + (set! (-> *profile-interrupt-segment* depth) 0) + (set! (-> *profile-interrupt-segment* max-depth) 1) + ) + (if (not (-> *display* dma-buffer-overflow)) + (dma-buffer-send-chain (the-as dma-bank-source #x10009000) s5-1) + ) + ) + ) + (determine-pause-mode) + (when (and (nonzero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1) (!= (-> *screen-shot-work* size) -1)) + (let ((v1-82 (-> *screen-shot-work* size))) + (set! (-> *screen-shot-work* count) (* v1-82 v1-82)) + ) + (set-master-mode 'pause) + ) + (display-frame-start arg0 s4-1 f30-1) + ) + ) + ) + (none) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/game/main-h_REF.gc b/test/decompiler/reference/jak3/engine/game/main-h_REF.gc index 9061925b795..b95230a75d4 100644 --- a/test/decompiler/reference/jak3/engine/game/main-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/game/main-h_REF.gc @@ -379,7 +379,7 @@ ;; definition of type screen-filter (deftype screen-filter (basic) ((draw? symbol) - (bucket int32) + (bucket bucket-id) (depth int32) (ztest uint64) (color vector :inline) @@ -388,11 +388,11 @@ (extra vector :inline) (speed float :overlay-at (-> extra data 0)) (current-interp float :overlay-at (-> extra data 1)) - (lock-vsync? basic) + (lock-vsync? symbol) ) (:methods (draw (_type_) none) - (setup (_type_ vector vector float bucket-id) none) + (setup (_type_ vector vector float bucket-id int int symbol) none) (disable (_type_) none) ) ) @@ -434,7 +434,7 @@ (camera-to-bbox-dist float) ) (:methods - (col-rend-method-9 () none) + (draw (_type_) none) ) ) diff --git a/test/decompiler/reference/jak3/engine/game/main_REF.gc b/test/decompiler/reference/jak3/engine/game/main_REF.gc new file mode 100644 index 00000000000..f15415a3aa7 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/game/main_REF.gc @@ -0,0 +1,2021 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function set-letterbox-frames +;; WARN: Return type mismatch time-frame vs none. +(defun set-letterbox-frames ((arg0 time-frame)) + "Enable letterbox for the given amount of time." + (with-pp + (set! (-> *game-info* letterbox-time) + (+ (-> *display* base-clock frame-counter) + (the int (/ (* (the float arg0) (-> *display* game-clock clock-ratio)) (-> pp clock clock-ratio))) + ) + ) + (none) + ) + ) + +;; definition for function letterbox +;; WARN: Return type mismatch int vs none. +(defun letterbox ((arg0 bucket-id) (arg1 float)) + "Draw letterbox" + (with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + arg0 + ) + (draw-sprite2d-xy-absolute s4-0 0 0 512 (the int (* 46.0 arg1)) (new 'static 'rgba :a #x80) #x3fffff) + (draw-sprite2d-xy-absolute + s4-0 + 0 + (- 416 (the int (* 46.0 arg1))) + 512 + (+ (the int (* 46.0 arg1)) 1) + (new 'static 'rgba :a #x80) + #x3fffff + ) + ) + 0 + (none) + ) + +;; definition for function set-blackout-frames +;; WARN: Return type mismatch int vs none. +(defun set-blackout-frames ((arg0 time-frame)) + "Enable blackout for the given amount of time." + (with-pp + (if (zero? arg0) + (set! (-> *game-info* blackout-time) (-> *display* base-clock frame-counter)) + (set! (-> *game-info* blackout-time) + (the-as + time-frame + (max + (-> *game-info* blackout-time) + (+ (-> *display* base-clock frame-counter) + (the int (/ (* (the float arg0) (-> *display* game-clock clock-ratio)) (-> pp clock clock-ratio))) + arg0 + ) + ) + ) + ) + ) + (none) + ) + ) + +;; definition for function blackout +;; WARN: Return type mismatch int vs none. +(defun blackout ((arg0 bucket-id)) + "Draw blackout as a sprite." + (with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + arg0 + ) + (draw-sprite2d-xy-absolute s4-0 0 0 512 416 (new 'static 'rgba :a #x80) #x3fffff) + ) + 0 + (none) + ) + +;; definition for function add-blackout +(defun add-blackout ((arg0 time-frame) (r int) (g int) (b int) (arg4 int)) + "Update display settings to do blackout with GS pmode alp." + (let ((v1-0 *display*)) + (let ((a0-1 (new 'static 'array time-frame 2 (seconds 0) (seconds 0)))) + (set! (-> v1-0 bgcolor r) r) + (set! (-> v1-0 bgcolor g) g) + (set! (-> v1-0 bgcolor b) b) + (set! (-> v1-0 pmode alp) (- 255 arg4)) + (set! (-> a0-1 0) 0) + (set! (-> a0-1 1) 0) + ) + (if (nonzero? arg4) + (set! (-> v1-0 force-sync) (the-as uint (max 4 (the-as int (-> v1-0 force-sync))))) + ) + ) + 0 + ) + +;; definition for function paused? +(defun paused? () + "Are we paused? Counts any type of pause/menu/freeze." + (or (= *master-mode* 'pause) (= *master-mode* 'progress) (= *master-mode* 'menu) (= *master-mode* 'freeze)) + ) + +;; definition for function movie? +(defun movie? () + "Are we in a movie?" + (logtest? (-> *kernel-context* prevent-from-run) (process-mask movie)) + ) + +;; definition for function scene-select? +(defun scene-select? () + (and (>= (-> *game-info* demo-state) (the-as uint 100)) (< (-> *game-info* demo-state) (the-as uint 200))) + ) + +;; definition for function demo? +(defun demo? () + "Is this a demo version?" + (or (= *kernel-boot-message* 'demo) (= *kernel-boot-message* 'demo-shared)) + ) + +;; definition for function kiosk? +(defun kiosk? () + "Is this a kiosk version of the game?" + (= *kernel-boot-message* 'kiosk) + ) + +;; definition for symbol *last-master-mode*, type symbol +(define *last-master-mode* 'game) + +;; definition for function set-master-mode +;; WARN: Return type mismatch int vs none. +(defun set-master-mode ((arg0 symbol)) + "Change the master mode and adjust a few masks" + (when (!= arg0 *master-mode*) + (set! *last-master-mode* *master-mode*) + (set! *master-mode* arg0) + (case *master-mode* + (('pause) + (if (not *debug-pause*) + (logior! (-> *setting-control* user-default process-mask) (process-mask pause)) + ) + (logclear! (-> *setting-control* user-default process-mask) (process-mask freeze menu)) + (set! *pause-lock* #f) + (sound-group-pause (the-as sound-group #xffffffff)) + (set! (-> *game-info* pause-start-time) (-> *display* real-clock frame-counter)) + ) + (('freeze) + (logior! (-> *setting-control* user-default process-mask) (process-mask freeze)) + (logclear! (-> *setting-control* user-default process-mask) (process-mask pause menu)) + (sound-group-pause (sound-group sfx ambient)) + (set! (-> *game-info* pause-start-time) (-> *display* real-clock frame-counter)) + ) + (('menu) + (logior! (-> *setting-control* user-default process-mask) (process-mask menu)) + (logclear! (-> *setting-control* user-default process-mask) (process-mask freeze pause progress)) + (sound-group-pause (the-as sound-group #xffffffff)) + (set! *pause-lock* #f) + ) + (('progress) + (logclear! (-> *setting-control* user-default process-mask) (process-mask freeze pause menu)) + (sound-group-pause (the-as sound-group #xffffffff)) + (when (not *progress-process*) + (activate-progress *dproc* 'main) + (if (not *progress-process*) + (set-master-mode 'game) + ) + ) + (set! (-> *game-info* pause-start-time) (-> *display* real-clock frame-counter)) + ) + (('game) + (logclear! (-> *setting-control* user-default process-mask) (process-mask freeze pause menu)) + (sound-group-continue (the-as sound-group #xffffffff)) + ) + ) + (apply-settings *setting-control*) + ) + (if *debug-segment* + (menu-respond-to-pause) + ) + 0 + (none) + ) + +;; definition for function pause-allowed? +(defun pause-allowed? () + "Should we allow a pause?" + (not (or (< (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (!= (-> *setting-control* user-current bg-a) 0.0) + (!= (-> *setting-control* user-current bg-a-force) 0.0) + (not (-> *setting-control* user-current allow-pause)) + (handle->process (-> *game-info* auto-save-proc)) + (= *master-mode* 'freeze) + (not *target*) + *master-exit* + (not *common-text*) + ) + ) + ) + +;; definition for function toggle-pause +(defun toggle-pause () + "Update the pause state. Call this if the user presses a pause button + This function will check the button and state and do a pause if needed." + (case *master-mode* + (('game) + (set-master-mode + (cond + ((and (logtest? (-> *cpad-list* cpads 0 valid) 128) + *target* + (>= (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (= (-> *setting-control* user-current bg-a) 0.0) + (and (= (-> *setting-control* user-current bg-a-force) 0.0) + (< (seconds 1003) (-> *display* real-clock frame-counter)) + ) + ) + (if (or *progress-process* (not (-> *setting-control* user-current allow-pause))) + *master-mode* + 'pause + ) + ) + ((and (cpad-pressed? 0 select start) (cpad-hold? 0 l3) *debug-segment*) + 'menu + ) + ((and (or (cpad-hold? 0 select) (cpad-hold? 0 r2)) *debug-segment*) + 'pause + ) + ((and (not *debug-segment*) (not (logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons start)))) + (if (pause-allowed?) + 'pause + *master-mode* + ) + ) + ((not (progress-allowed?)) + (if (pause-allowed?) + 'pause + *master-mode* + ) + ) + ((cpad-hold? 0 start) + 'progress + ) + (else + *master-mode* + ) + ) + ) + ) + (('menu) + (set-master-mode (cond + ((and *debug-segment* (cpad-hold? 0 l3) (cpad-pressed? 0 select start)) + 'menu + ) + ((cpad-hold? 0 select r2) + (if *debug-segment* + 'pause + *master-mode* + ) + ) + ((cpad-hold? 0 r3 r2 triangle circle) + 'game + ) + ((cpad-hold? 0 start) + 'game + ) + (else + *master-mode* + ) + ) + ) + (set! *pause-lock* #f) + ) + (('pause) + (set-master-mode (cond + ((and (cpad-pressed? 0 select start) (cpad-hold? 0 l3) *debug-segment*) + 'menu + ) + ((and (or (not *debug-segment*) (not *cheat-mode*)) (cpad-hold? 0 select)) + 'game + ) + ((and *cheat-mode* (cpad-hold? 0 select r2)) + 'game + ) + ((cpad-hold? 0 start) + 'game + ) + (else + *master-mode* + ) + ) + ) + (set! *pause-lock* (and *cheat-mode* (cpad-hold? 0 r2))) + ) + (('freeze) + (set-master-mode (if (and (cpad-pressed? 0 select start) (cpad-hold? 0 l3) *debug-segment*) + 'menu + *master-mode* + ) + ) + ) + (('progress) + (if (cpad-hold? 0 start) + (hide-progress-screen) + ) + (set! *pause-lock* (and *cheat-mode* (cpad-hold? 0 r2))) + ) + ) + 0 + ) + +;; definition for symbol *screen-filter*, type screen-filter +(define *screen-filter* (new 'static 'screen-filter :draw? #f :bucket (bucket-id tex-hud-pris2))) + +;; definition for method 9 of type screen-filter +;; WARN: Return type mismatch int vs none. +;; WARN: Function (method 9 screen-filter) has a return type of none, but the expression builder found a return statement. +(defmethod draw ((this screen-filter)) + "Add DMA data to our bucket to draw the filter." + (local-vars (v1-1 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (when (not (paused?)) + (.lvf vf4 (&-> this extra quad)) + (.lvf vf1 (&-> this color-dest quad)) + (.lvf vf2 (&-> this color quad)) + (.sub.vf vf3 vf1 vf2) + (.add.x.vf vf4 vf4 vf4 :mask #b10) + (.min.w.vf vf4 vf4 vf0 :mask #b10) + (.max.y.vf vf4 vf4 vf0 :mask #b10) + (.mul.y.vf vf3 vf3 vf4) + (.add.vf vf1 vf2 vf3) + (.svf (&-> this extra quad) vf4) + (.svf (&-> this color quad) vf1) + (.mov v1-1 vf1) + ) + (let ((f0-0 0.1)) + (when (and (>= f0-0 (fabs (- (-> this color-dest x) (-> this color x)))) + (>= f0-0 (fabs (- (-> this color-dest y) (-> this color y)))) + (>= f0-0 (fabs (- (-> this color-dest z) (-> this color z)))) + (>= f0-0 (fabs (- (-> this color-dest w) (-> this color w)))) + (>= f0-0 (-> this color w)) + ) + (disable this) + (return 0) + ) + ) + (with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (-> this bucket) + ) + (dma-buffer-add-gs-set s4-0 (test-1 (-> this ztest))) + (let ((t1-0 (new 'static 'rgba + :r (the int (-> this color x)) + :g (the int (-> this color y)) + :b (the int (-> this color z)) + :a (the int (-> this color w)) + ) + ) + ) + (draw-sprite2d-xy s4-0 -256 -208 512 416 t1-0 (-> this depth)) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 10 of type screen-filter +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod setup ((this screen-filter) + (arg0 vector) + (arg1 vector) + (arg2 float) + (arg3 bucket-id) + (arg4 int) + (arg5 int) + (arg6 symbol) + ) + "Initialize the screen-filter with the given settings." + (set! (-> this draw?) #t) + (set! (-> this color quad) (-> arg0 quad)) + (set! (-> this color-src quad) (-> arg0 quad)) + (set! (-> this color-dest quad) (-> arg1 quad)) + (set! (-> this extra x) arg2) + (set! (-> this extra y) 0.0) + (set! (-> this bucket) arg3) + (set! (-> this depth) arg4) + (set! (-> this ztest) (the-as uint arg5)) + (set! (-> this lock-vsync?) arg6) + 0 + (none) + ) + +;; definition for method 11 of type screen-filter +;; WARN: Return type mismatch int vs none. +(defmethod disable ((this screen-filter)) + (set! (-> this draw?) #f) + 0 + (none) + ) + +;; definition for symbol *cheat-temp*, type (pointer int32) +(define *cheat-temp* (the-as (pointer int32) (malloc 'global 20))) + +;; definition for symbol *master-exit*, type symbol +(define *master-exit* #f) + +;; definition for symbol *progress-cheat*, type symbol +(define *progress-cheat* #f) + +;; definition for symbol *first-boot*, type symbol +(define *first-boot* #t) + +;; definition for function main-timeouts +;; WARN: Return type mismatch int vs none. +(defun main-timeouts () + "Maybe reset/restart the game if no input has been given. + Mainly used for kiosk/demo modes." + (when (demo?) + (let ((gp-0 (scf-get-timeout)) + (v1-1 (scf-get-inactive-timeout)) + ) + (when (and (or (and (nonzero? gp-0) + (>= (+ -300000 (-> *display* real-clock frame-counter)) (the int (* 300.0 (the float gp-0)))) + ) + (and (nonzero? v1-1) + (or (and (>= (- (-> *display* base-clock frame-counter) (-> *cpad-list* cpads 0 change-time)) + (the int (* 300.0 (the float v1-1))) + ) + (>= (- (-> *display* game-clock frame-counter) (-> *game-info* kiosk-timeout)) + (the int (* 300.0 (the float v1-1))) + ) + ) + (and (or (= *master-mode* 'pause) (= *master-mode* 'progress) (= *master-mode* 'freeze)) + (>= (- (-> *display* real-clock frame-counter) (-> *game-info* pause-start-time)) + (the int (* 300.0 (the float v1-1))) + ) + ) + ) + ) + (or (= *master-exit* 'force) (= *master-exit* 'movie)) + ) + (or *master-exit* (-> *setting-control* user-current allow-timeout)) + (!= *master-exit* #t) + ) + (cond + ((and (= *kernel-boot-message* 'demo) (not *master-exit*)) + (let ((v1-17 (level-get-target-inside *level*))) + (when (and v1-17 (!= (-> v1-17 name) 'demo) (not (logtest? (-> v1-17 info level-flags) (level-flags lf0)))) + (persist-with-delay *setting-control* 'sfx-volume (seconds 0.5) 'sfx-volume 'abs 0.0 0) + (persist-with-delay *setting-control* 'music-volume (seconds 0.5) 'music-volume 'abs 0.0 0) + (persist-with-delay *setting-control* 'dialog-volume (seconds 0.5) 'dialog-volume 'abs 0.0 0) + (persist-with-delay *setting-control* 'ambient-volume (seconds 0.5) 'ambient-volume 'abs 0.0 0) + (set! (-> *setting-control* user-current sfx-volume) 0.01) + (set! (-> *setting-control* user-current music-volume) 0.01) + (set! (-> *setting-control* user-current dialog-volume) 0.01) + (set! (-> *setting-control* user-current ambient-volume) 0.01) + (apply-settings *setting-control*) + (set! (-> *game-info* mode) 'play) + (initialize! *game-info* 'game (the-as game-save #f) "title-restart" (the-as resetter-spec #f)) + ) + ) + ) + (else + (when (process-spawn-function + process + (lambda ((arg0 int)) + (set-blackout-frames (seconds 100)) + (set! (-> *setting-control* user-default allow-pause) #f) + (set! (-> *setting-control* user-default allow-progress) #f) + (apply-settings *setting-control*) + (set! (-> *setting-control* user-default sfx-volume) 0.0) + (set! (-> *setting-control* user-default music-volume) 0.0) + (set! (-> *setting-control* user-default dialog-volume) 0.0) + (set! (-> *setting-control* user-default ambient-volume) 0.0) + (let ((s5-0 (current-time))) + (until (time-elapsed? s5-0 (seconds 0.1)) + (suspend) + ) + ) + (kernel-shutdown arg0) + (none) + ) + (if (= *master-exit* 'movie) + 2 + 1 + ) + :to *display-pool* + ) + (set! (-> *setting-control* user-default sfx-volume) 0.0) + (set! (-> *setting-control* user-default music-volume) 0.0) + (set! (-> *setting-control* user-default dialog-volume) 0.0) + (set! (-> *setting-control* user-default ambient-volume) 0.0) + (set! *master-exit* #t) + ) + ) + ) + ) + ) + ) + (case *kernel-boot-message* + (('kiosk) + (if (and (= *master-mode* 'pause) + (>= (- (-> *display* real-clock frame-counter) (-> *cpad-list* cpads 0 real-change-time)) (seconds 60)) + ) + (set-master-mode 'game) + ) + ) + ) + 0 + (none) + ) + +;; definition for function main-cheats +;; WARN: Return type mismatch int vs none. +(defun main-cheats () + (when (and (cpad-hold? 0 l3) (or *cheat-mode* (not (demo?)))) + ((lambda () + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-5 (-> *cheat-temp* 0))) + (cond + ((zero? v1-5) + (cond + ((cpad-pressed? 0 up) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 1) + (cond + ((cpad-pressed? 0 up) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 2) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 3) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 4) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 5) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 6) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 7) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 8) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 9) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 10) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 11) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 12) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 13) + (cond + ((cpad-pressed? 0 circle) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *cheat-mode* (not *cheat-mode*)) + (if *cheat-mode* + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 0) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ) + ) + ) + (when *cheat-mode* + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-146 (-> *cheat-temp* 1))) + (cond + ((zero? v1-146) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 1) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 2) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 3) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 4) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 5) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 6) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 7) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 8) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 9) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 10) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 11) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 12) + (cond + ((cpad-pressed? 0 up) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 13) + (cond + ((cpad-pressed? 0 up) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *cheat-mode* (if (= *cheat-mode* 'debug) + #t + 'debug + ) + ) + (if (= *cheat-mode* 'debug) + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 1) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + ((lambda () + (scf-get-territory) + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-6 (-> *cheat-temp* 2))) + (cond + ((zero? v1-6) + (cond + ((cpad-pressed? 0 l1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 1) + (cond + ((cpad-pressed? 0 r1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 2) + (cond + ((cpad-pressed? 0 l1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 3) + (cond + ((cpad-pressed? 0 r1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 4) + (cond + ((cpad-pressed? 0 triangle) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 5) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 6) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-6 7) + (cond + ((cpad-pressed? 0 square) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *progress-cheat* (if *progress-cheat* + #f + 'language + ) + ) + (if *progress-cheat* + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 2) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ) + ) + ) + (when *debug-segment* + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-94 (-> *cheat-temp* 3))) + (cond + ((zero? v1-94) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 1) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 2) + (cond + ((cpad-pressed? 0 triangle) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 3) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 4) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 5) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 6) + (cond + ((cpad-pressed? 0 triangle) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-94 7) + (cond + ((cpad-pressed? 0 circle) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *progress-cheat* (if *progress-cheat* + #f + 'pal + ) + ) + (if *progress-cheat* + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 3) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ) + ) + ) + (when (nonzero? (-> *cpad-list* cpads 1 button0-rel 0)) + (let ((v1-180 (-> *cheat-temp* 5))) + (cond + ((zero? v1-180) + (cond + ((cpad-pressed? 1 triangle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 1) + (cond + ((cpad-pressed? 1 x) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 2) + (cond + ((cpad-pressed? 1 circle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 3) + (cond + ((cpad-pressed? 1 square) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 4) + (cond + ((cpad-pressed? 1 triangle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 5) + (cond + ((cpad-pressed? 1 x) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 6) + (cond + ((cpad-pressed? 1 circle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-180 7) + (cond + ((cpad-pressed? 1 square) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *cheat-mode* (if (= *cheat-mode* 'camera) + #f + 'camera + ) + ) + (cond + (*cheat-mode* + (if (not *external-cam-mode*) + (external-cam-reset!) + ) + (set! *external-cam-mode* 'pad-1) + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (else + (set! *external-cam-mode* #f) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + (set! (-> *cheat-temp* 5) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + ) + (if (and *cheat-mode* (not *debug-segment*) (cpad-hold? 1 l3)) + ((lambda () + (cond + ((cpad-pressed? 1 x) + (send-event *target* 'get-pickup (pickup-type ammo-yellow) 1000.0) + (send-event *target* 'get-pickup (pickup-type ammo-red) 1000.0) + (send-event *target* 'get-pickup (pickup-type ammo-blue) 1000.0) + (send-event *target* 'get-pickup (pickup-type ammo-dark) 1000.0) + (send-event *target* 'get-pickup (pickup-type eco-pill-dark) 1000.0) + (send-event *target* 'get-pickup (pickup-type eco-pill-light) 1000.0) + (send-event *target* 'get-pickup (pickup-type skill) 1000.0) + (send-event *target* 'get-pickup (pickup-type gem) 1000.0) + (set! (-> *game-info* features) + (the-as + game-feature + (logior (game-feature + gun + gun-red-1 + gun-red-2 + gun-red-3 + gun-yellow-1 + gun-yellow-2 + gun-yellow-3 + gun-blue-1 + gun-blue-2 + gun-blue-3 + gun-dark-1 + gun-dark-2 + gun-dark-3 + board + darkjak + darkjak-smack + darkjak-bomb0 + darkjak-bomb1 + feature44 + feature45 + lightjak + lightjak-regen + lightjak-swoop + lightjak-freeze + lightjak-shield + ) + (-> *game-info* features) + ) + ) + ) + (set! (-> *game-info* debug-features) + (the-as + game-feature + (logior (game-feature gun gun-red-1 gun-yellow-1 gun-blue-1 gun-dark-1 board darkjak lightjak) + (-> *game-info* debug-features) + ) + ) + ) + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ((and (cpad-pressed? 1 triangle) (!= *cheat-mode* 'debug)) + (send-event *target* 'get-pickup (pickup-type ammo-yellow) 1000.0) + (send-event *target* 'get-pickup (pickup-type ammo-red) 1000.0) + (send-event *target* 'get-pickup (pickup-type ammo-blue) 1000.0) + (send-event *target* 'get-pickup (pickup-type ammo-dark) 1000.0) + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ((cpad-pressed? 1 square) + (set! (-> *level* disk-load-timing?) (not (-> *level* disk-load-timing?))) + (if (-> *level* disk-load-timing?) + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + ((cpad-pressed? 1 r1) + (set! *display-scene-control* (logxor *display-scene-control* (scene-controls bounds-spheres))) + (if (logtest? *display-scene-control* (scene-controls bounds-spheres)) + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + ((cpad-pressed? 1 circle) + (set! *display-bug-report* (not *display-bug-report*)) + (if *display-bug-report* + (sound-play-by-spec (static-sound-spec "menu-pick" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :group 1 :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + ) + (none) + ) + ) + ) + (if (and *display-bug-report* (not *progress-process*)) + (position->stream *stdcon* '*stdcon* #t) + ) + (when (and (= *cheat-mode* 'debug) (not *debug-segment*)) + (when (and (cpad-hold? 0 l1) (cpad-hold? 0 l2) (cpad-hold? 0 r1) (cpad-pressed? 0 r2)) + (if *target* + (stop 'debug) + (start 'play (get-current-continue-forced *game-info*)) + ) + ) + (if (and (cpad-hold? 0 left) (cpad-hold? 0 up) (cpad-pressed? 0 select)) + (initialize! *game-info* 'game (the-as game-save #f) "title-restart" (the-as resetter-spec #f)) + ) + (if (cpad-pressed? 1 r3) + (inspect global) + ) + (when (cpad-hold? 1 r3) + (with-dma-buffer-add-bucket ((s5-1 (if *debug-segment* + (-> *display* frames (-> *display* on-screen) debug-buf) + (-> *display* frames (-> *display* on-screen) global-buf) + ) + ) + (bucket-id bucket583) + ) + (show-iop-memory s5-1) + ) + ) + (if (cpad-pressed? 1 triangle) + (set! *display-level-border* (not *display-level-border*)) + ) + ) + (main-timeouts) + 0 + (none) + ) + +;; definition for function end-display +;; WARN: Return type mismatch int vs none. +(defun end-display ((arg0 display)) + (let ((s5-0 (-> (if *debug-segment* + (-> arg0 frames (-> arg0 on-screen) debug-buf) + (-> arg0 frames (-> arg0 on-screen) global-buf) + ) + base + ) + ) + ) + (when *debug-segment* + (let ((s4-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-17 'debug) + (s3-0 *profile-debug-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s2-0 (-> s4-0 data (-> s4-0 count)))) + (let ((s1-0 (-> s4-0 base-time))) + (set! (-> s2-0 name) v1-17) + (set! (-> s2-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s1-0)))) + ) + (set! (-> s2-0 depth) (the-as uint (-> s4-0 depth))) + (set! (-> s2-0 color) s3-0) + (set! (-> s4-0 segment (-> s4-0 depth)) s2-0) + ) + (set! (-> s4-0 count) (min 1023 (+ (-> s4-0 count) 1))) + (+! (-> s4-0 depth) 1) + (set! (-> s4-0 max-depth) (max (-> s4-0 max-depth) (-> s4-0 depth))) + ) + ) + 0 + ) + (with-dma-buffer-add-bucket ((s3-1 (if *debug-segment* + (-> arg0 frames (-> arg0 on-screen) debug-buf) + (-> arg0 frames (-> arg0 on-screen) global-buf) + ) + ) + (bucket-id debug-no-zbuf2) + ) + (if (and (= *master-mode* 'pause) + (and (!= *cheat-mode* 'camera) (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1))) + ) + (draw-string-xy + (lookup-text! *common-text* (text-id progress-pause) #f) + s3-1 + 256 + (if (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time)) + 352 + 320 + ) + (font-color red) + (font-flags shadow kerning middle large) + ) + ) + (let ((s2-2 (the int (-> *font-context* origin y)))) + (cond + ((or (!= (-> *setting-control* user-current letterbox) 0.0) + (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time)) + ) + (+! s2-2 56) + ) + ((and *display-profile* (not *display-capture-mode*)) + (+! s2-2 48) + ) + ) + (when (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1) (-> *screen-shot-work* hud-enable)) + (let* ((v1-73 + (draw-string-xy + *stdcon0* + s3-1 + (the int (-> *font-context* origin x)) + s2-2 + (font-color default) + (font-flags shadow kerning) + ) + ) + (a3-4 (+ s2-2 (the int (* 2.0 (-> v1-73 b))))) + ) + (draw-string-xy + *stdcon1* + s3-1 + (the int (-> *font-context* origin x)) + a3-4 + (font-color default) + (font-flags shadow kerning) + ) + ) + ) + ) + (if (or (not *debug-segment*) *display-capture-mode*) + (set! *stdebug* *null*) + (set! *stdebug* *stdcon1*) + ) + (if *display-iop-info* + (show-iop-info s3-1) + ) + (if *display-memcard-info* + (show-mc-info s3-1) + ) + ) + (set! *stdcon* (clear *stdcon0*)) + (when *debug-segment* + (let ((s4-2 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-108 (+ (-> s4-2 depth) -1)) + (s3-2 (-> s4-2 segment v1-108)) + (s2-3 (-> s4-2 base-time)) + ) + (when (>= v1-108 0) + (set! (-> s3-2 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-3)))) + (+! (-> s4-2 depth) -1) + ) + ) + ) + ) + 0 + ) + (let ((v1-113 *dma-mem-usage*)) + (when (nonzero? v1-113) + (set! (-> v1-113 length) (max 89 (-> v1-113 length))) + (set! (-> v1-113 data 88 name) "debug") + (+! (-> v1-113 data 88 count) 1) + (+! (-> v1-113 data 88 used) (&- + (-> (if *debug-segment* + (-> arg0 frames (-> arg0 on-screen) debug-buf) + (-> arg0 frames (-> arg0 on-screen) global-buf) + ) + base + ) + (the-as uint s5-0) + ) + ) + (set! (-> v1-113 data 88 total) (-> v1-113 data 88 used)) + ) + ) + ) + 0 + (none) + ) + +;; definition for function display-loop-main +;; WARN: Return type mismatch int vs none. +(defun display-loop-main ((arg0 display)) + (with-pp + (if (-> *level* loading-level) + (load-continue (-> *level* loading-level)) + ) + (when *debug-segment* + (let ((s5-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-13 'merc) + (s4-0 *profile-merc-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-0 (-> s5-0 data (-> s5-0 count)))) + (let ((s2-0 (-> s5-0 base-time))) + (set! (-> s3-0 name) v1-13) + (set! (-> s3-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-0)))) + ) + (set! (-> s3-0 depth) (the-as uint (-> s5-0 depth))) + (set! (-> s3-0 color) s4-0) + (set! (-> s5-0 segment (-> s5-0 depth)) s3-0) + ) + (set! (-> s5-0 count) (min 1023 (+ (-> s5-0 count) 1))) + (+! (-> s5-0 depth) 1) + (set! (-> s5-0 max-depth) (max (-> s5-0 max-depth) (-> s5-0 depth))) + ) + ) + 0 + ) + (blerc-execute) + (blerc-init) + (when *debug-segment* + (let ((s5-1 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-37 (+ (-> s5-1 depth) -1)) + (s4-1 (-> s5-1 segment v1-37)) + (s3-1 (-> s5-1 base-time)) + ) + (when (>= v1-37 0) + (set! (-> s4-1 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-1)))) + (+! (-> s5-1 depth) -1) + ) + ) + ) + ) + 0 + ) + (texscroll-execute) + (ripple-execute) + (region-execute) + (when *debug-segment* + (let ((s5-2 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-50 'joints) + (s4-2 *profile-joints-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-2 (-> s5-2 data (-> s5-2 count)))) + (let ((s2-1 (-> s5-2 base-time))) + (set! (-> s3-2 name) v1-50) + (set! (-> s3-2 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-1)))) + ) + (set! (-> s3-2 depth) (the-as uint (-> s5-2 depth))) + (set! (-> s3-2 color) s4-2) + (set! (-> s5-2 segment (-> s5-2 depth)) s3-2) + ) + (set! (-> s5-2 count) (min 1023 (+ (-> s5-2 count) 1))) + (+! (-> s5-2 depth) 1) + (set! (-> s5-2 max-depth) (max (-> s5-2 max-depth) (-> s5-2 depth))) + ) + ) + 0 + ) + (execute-math-engine) + (when *debug-segment* + (let ((s5-3 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-74 (+ (-> s5-3 depth) -1)) + (s4-3 (-> s5-3 segment v1-74)) + (s3-3 (-> s5-3 base-time)) + ) + (when (>= v1-74 0) + (set! (-> s4-3 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-3)))) + (+! (-> s5-3 depth) -1) + ) + ) + ) + ) + 0 + ) + (execute-cloth-engine) + (when *debug-segment* + (let ((s5-4 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-87 'debug) + (s4-4 *profile-debug-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-4 (-> s5-4 data (-> s5-4 count)))) + (let ((s2-2 (-> s5-4 base-time))) + (set! (-> s3-4 name) v1-87) + (set! (-> s3-4 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-2)))) + ) + (set! (-> s3-4 depth) (the-as uint (-> s5-4 depth))) + (set! (-> s3-4 color) s4-4) + (set! (-> s5-4 segment (-> s5-4 depth)) s3-4) + ) + (set! (-> s5-4 count) (min 1023 (+ (-> s5-4 count) 1))) + (+! (-> s5-4 depth) 1) + (set! (-> s5-4 max-depth) (max (-> s5-4 max-depth) (-> s5-4 depth))) + ) + ) + 0 + ) + (let* ((s5-5 *debug-hook*) + (t9-13 (car s5-5)) + ) + (while (not (null? s5-5)) + ((the-as (function none) t9-13)) + (set! s5-5 (cdr s5-5)) + (set! t9-13 (car s5-5)) + ) + ) + (main-cheats) + (when *debug-segment* + (let ((s5-6 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-115 (+ (-> s5-6 depth) -1)) + (s4-5 (-> s5-6 segment v1-115)) + (s3-5 (-> s5-6 base-time)) + ) + (when (>= v1-115 0) + (set! (-> s4-5 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-5)))) + (+! (-> s5-6 depth) -1) + ) + ) + ) + ) + 0 + ) + (when *debug-segment* + (let ((s5-7 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-128 'camera) + (s4-6 *profile-camera-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-6 (-> s5-7 data (-> s5-7 count)))) + (let ((s2-3 (-> s5-7 base-time))) + (set! (-> s3-6 name) v1-128) + (set! (-> s3-6 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-3)))) + ) + (set! (-> s3-6 depth) (the-as uint (-> s5-7 depth))) + (set! (-> s3-6 color) s4-6) + (set! (-> s5-7 segment (-> s5-7 depth)) s3-6) + ) + (set! (-> s5-7 count) (min 1023 (+ (-> s5-7 count) 1))) + (+! (-> s5-7 depth) 1) + (set! (-> s5-7 max-depth) (max (-> s5-7 max-depth) (-> s5-7 depth))) + ) + ) + 0 + ) + (update-camera) + (execute-cam-post-hook-engine) + (when *debug-segment* + (let ((s5-8 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-152 (+ (-> s5-8 depth) -1)) + (s4-7 (-> s5-8 segment v1-152)) + (s3-7 (-> s5-8 base-time)) + ) + (when (>= v1-152 0) + (set! (-> s4-7 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-7)))) + (+! (-> s5-8 depth) -1) + ) + ) + ) + ) + 0 + ) + (update *bigmap*) + (if (-> *level* loading-level) + (load-continue (-> *level* loading-level)) + ) + (when *debug-segment* + (let ((s5-9 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-173 'draw-hook) + (s4-8 *profile-draw-hook-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-8 (-> s5-9 data (-> s5-9 count)))) + (let ((s2-4 (-> s5-9 base-time))) + (set! (-> s3-8 name) v1-173) + (set! (-> s3-8 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-4)))) + ) + (set! (-> s3-8 depth) (the-as uint (-> s5-9 depth))) + (set! (-> s3-8 color) s4-8) + (set! (-> s5-9 segment (-> s5-9 depth)) s3-8) + ) + (set! (-> s5-9 count) (min 1023 (+ (-> s5-9 count) 1))) + (+! (-> s5-9 depth) 1) + (set! (-> s5-9 max-depth) (max (-> s5-9 max-depth) (-> s5-9 depth))) + ) + ) + 0 + ) + (*draw-hook*) + (when *debug-segment* + (let ((s5-10 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-197 (+ (-> s5-10 depth) -1)) + (s4-9 (-> s5-10 segment v1-197)) + (s3-9 (-> s5-10 base-time)) + ) + (when (>= v1-197 0) + (set! (-> s4-9 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-9)))) + (+! (-> s5-10 depth) -1) + ) + ) + ) + ) + 0 + ) + (if (-> *level* loading-level) + (load-continue (-> *level* loading-level)) + ) + (if *display-color-bars* + (draw-color-bars *blit-displays-work*) + ) + (*menu-hook*) + (load-level-text-files -1) + (when (-> *screen-filter* draw?) + (if (-> *screen-filter* lock-vsync?) + (set! (-> arg0 force-sync) (the-as uint (max 4 (the-as int (-> arg0 force-sync))))) + ) + (draw *screen-filter*) + ) + (when (or (!= (-> *setting-control* user-current letterbox) 0.0) + (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time)) + ) + (if (< (-> *game-info* letterbox-time) (-> *display* base-clock frame-counter)) + (set! (-> *game-info* letterbox-time) (-> *display* base-clock frame-counter)) + ) + (if (and (= (-> *setting-control* user-current aspect-ratio) 'aspect4x3) + (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1) (-> *screen-shot-work* hud-enable)) + ) + (letterbox + (bucket-id tex-hud-pris2) + (if (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time)) + 1.0 + (-> *setting-control* user-current letterbox) + ) + ) + ) + ) + (when (-> *setting-control* user-current render) + (if (< (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (set! (-> *setting-control* user-default bg-a-force) 1.0) + (set! (-> *setting-control* user-default bg-a-force) 0.0) + ) + ) + (when *debug-segment* + (let ((s5-11 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-266 'blit-displays) + (s4-10 *profile-blit-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-10 (-> s5-11 data (-> s5-11 count)))) + (let ((s2-5 (-> s5-11 base-time))) + (set! (-> s3-10 name) v1-266) + (set! (-> s3-10 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-5)))) + ) + (set! (-> s3-10 depth) (the-as uint (-> s5-11 depth))) + (set! (-> s3-10 color) s4-10) + (set! (-> s5-11 segment (-> s5-11 depth)) s3-10) + ) + (set! (-> s5-11 count) (min 1023 (+ (-> s5-11 count) 1))) + (+! (-> s5-11 depth) 1) + (set! (-> s5-11 max-depth) (max (-> s5-11 max-depth) (-> s5-11 depth))) + ) + ) + 0 + ) + (blit-displays-work-method-19 *blit-displays-work*) + (when *debug-segment* + (let ((s5-12 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-292 (+ (-> s5-12 depth) -1)) + (s4-11 (-> s5-12 segment v1-292)) + (s3-11 (-> s5-12 base-time)) + ) + (when (>= v1-292 0) + (set! (-> s4-11 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-11)))) + (+! (-> s5-12 depth) -1) + ) + ) + ) + ) + 0 + ) + (end-display arg0) + (display-frame-finish arg0) + (display-sync arg0) + (when *debug-segment* + (start-frame! (-> arg0 frames (-> arg0 on-screen) profile-array data 0)) + (let* ((v1-307 (-> *perf-stats* data)) + (a0-109 (-> v1-307 0 ctrl)) + ) + (+! (-> v1-307 0 count) 1) + (b! (zero? a0-109) cfg-132 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mtpc pcr0 0) + (.mtpc pcr1 0) + (.sync.l) + (.sync.p) + (.mtc0 Perf a0-109) + ) + (.sync.l) + (.sync.p) + (label cfg-132) + 0 + ) + (set! (-> *time-of-day-context* title-updated) #f) + (set! *teleport* #f) + (when (nonzero? *teleport-count*) + (set! *teleport* #t) + (set! *teleport-count* (+ *teleport-count* -1)) + ) + (execute-particle-local-space-engine 0) + (let ((gp-1 (-> pp clock))) + (set! (-> pp clock) (-> *display* part-clock)) + (process-particles) + (set! (-> pp clock) gp-1) + ) + (execute-particle-local-space-engine 1) + (dma-send + (the-as dma-bank #x10008000) + (the-as uint (-> *collide-vif0-init* data)) + (the-as uint (/ (-> *collide-vif0-init* length) 4)) + ) + (swap-sound-buffers + (ear-trans 0) + (ear-trans 1) + (if (-> *setting-control* user-current lock-sound-camera-to-target) + (ear-trans 1) + (camera-pos) + ) + (-> (math-camera-matrix) fvec) + (-> (math-camera-matrix) rvec) + (-> *setting-control* user-current sound-ear-scale) + ) + (str-play-kick) + (level-update *level*) + (mc-run) + (auto-save-check) + 0 + (none) + ) + ) + +;; definition for function display-loop +(defbehavior display-loop process () + "Main loop for running the game." + (stack-size-set! (-> self main-thread) 512) + (process-spawn-function + process + (lambda :behavior process + () + (logclear! (-> self mask) (process-mask freeze pause menu progress entity)) + (until #f + (when *debug-segment* + (let ((gp-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-9 'joints) + (s5-0 *profile-joints-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-0 (-> gp-0 data (-> gp-0 count)))) + (let ((s3-0 (-> gp-0 base-time))) + (set! (-> s4-0 name) v1-9) + (set! (-> s4-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-0)))) + ) + (set! (-> s4-0 depth) (the-as uint (-> gp-0 depth))) + (set! (-> s4-0 color) s5-0) + (set! (-> gp-0 segment (-> gp-0 depth)) s4-0) + ) + (set! (-> gp-0 count) (min 1023 (+ (-> gp-0 count) 1))) + (+! (-> gp-0 depth) 1) + (set! (-> gp-0 max-depth) (max (-> gp-0 max-depth) (-> gp-0 depth))) + ) + ) + 0 + ) + (execute-math-engine) + (when *debug-segment* + (let ((gp-1 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-33 (+ (-> gp-1 depth) -1)) + (s5-1 (-> gp-1 segment v1-33)) + (s4-1 (-> gp-1 base-time)) + ) + (when (>= v1-33 0) + (set! (-> s5-1 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-1)))) + (+! (-> gp-1 depth) -1) + ) + ) + ) + ) + 0 + ) + (suspend) + ) + #f + ) + :name "matrix" + :from *4k-dead-pool* + :to *mid-pool* + ) + (let ((gp-1 *display*)) + (set! *teleport* #t) + (update *setting-control*) + (init-time-of-day-context *time-of-day-context*) + (display-sync gp-1) + (display-frame-finish gp-1) + (display-sync gp-1) + (install-handler 3 vblank-handler) + (free-nodes *touching-list*) + (prepare *collide-rider-pool*) + (update-actor-hash) + (blerc-init) + (dma-send + (the-as dma-bank #x10008000) + (the-as uint (-> *collide-vif0-init* data)) + (the-as uint (/ (-> *collide-vif0-init* length) 4)) + ) + (suspend) + (set! (-> *setting-control* user-default bg-a) 0.0) + (set! (-> gp-1 frames 0 start-time) (timer-count (the-as timer-bank #x10000800))) + (set! (-> gp-1 frames 1 start-time) (timer-count (the-as timer-bank #x10000800))) + (set! (-> gp-1 dog-ratio) 1.0) + (while *run* + (display-loop-main gp-1) + (when *debug-segment* + (let ((s5-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-27 'actors) + (s4-0 *profile-actors-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-0 (-> s5-0 data (-> s5-0 count)))) + (let ((s2-0 (-> s5-0 base-time))) + (set! (-> s3-0 name) v1-27) + (set! (-> s3-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-0)))) + ) + (set! (-> s3-0 depth) (the-as uint (-> s5-0 depth))) + (set! (-> s3-0 color) s4-0) + (set! (-> s5-0 segment (-> s5-0 depth)) s3-0) + ) + (set! (-> s5-0 count) (min 1023 (+ (-> s5-0 count) 1))) + (+! (-> s5-0 depth) 1) + (set! (-> s5-0 max-depth) (max (-> s5-0 max-depth) (-> s5-0 depth))) + ) + ) + 0 + ) + (suspend) + (when *debug-segment* + (let ((s5-1 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-51 (+ (-> s5-1 depth) -1)) + (s4-1 (-> s5-1 segment v1-51)) + (s3-1 (-> s5-1 base-time)) + ) + (when (>= v1-51 0) + (set! (-> s4-1 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-1)))) + (+! (-> s5-1 depth) -1) + ) + ) + ) + ) + 0 + ) + ) + ) + (set! *dproc* #f) + (format 0 "display is off #<#x~X>.~%" self) + 0 + ) + +;; definition for function on +(defun on ((arg0 symbol)) + "Start the display process." + (when (not *dproc*) + (when (not arg0) + (if (= (-> *level* level0 status) 'inactive) + (bg 'halfpipe) + ) + ) + (set! *run* #t) + (set! *dproc* (ppointer->process (process-spawn-function + process + display-loop + :name "display" + :from *4k-dead-pool* + :to *display-pool* + :stack *kernel-dram-stack* + ) + ) + ) + (cond + ((or (level-get-with-status *level* 'loaded) + (level-get-with-status *level* 'alive) + (level-get-with-status *level* 'active) + ) + (activate-levels! *level*) + (when (not arg0) + (let ((gp-1 (entity-by-type camera-start))) + (when (and gp-1 (type? gp-1 entity-actor)) + (while (not (camera-teleport-to-entity gp-1)) + (suspend) + ) + ) + ) + ) + (if (and (= *kernel-boot-message* 'art-group) *kernel-boot-art-group*) + (anim-tester-add-object *kernel-boot-art-group*) + ) + ) + (else + (kill-by-name "display" *active-pool*) + (set! *dproc* #f) + ) + ) + ) + *dproc* + ) + +;; definition for function off +;; WARN: Return type mismatch int vs none. +(defun off () + "Stop the display process." + (stop 'debug) + (dotimes (gp-0 (-> *level* length)) + (let ((a0-2 (-> *level* level gp-0))) + (if (= (-> a0-2 status) 'active) + (deactivate a0-2) + ) + ) + ) + (set! *run* #f) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/gfx/background/prototype_REF.gc b/test/decompiler/reference/jak3/engine/gfx/background/prototype_REF.gc new file mode 100644 index 00000000000..05699d8bf9a --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/background/prototype_REF.gc @@ -0,0 +1,119 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 9 of type prototype-inline-array-shrub +(defmethod login ((this prototype-inline-array-shrub)) + "Initialize the object after it is loaded." + (let ((s5-0 (-> *level* level *level-index* bsp))) + (dotimes (s4-0 (-> this length)) + (let ((s3-0 (-> this data s4-0))) + (when (and *debug-segment* (-> *screen-shot-work* highres-enable)) + (dotimes (v1-9 4) + (+! (-> s3-0 dists data v1-9) 40960000.0) + (set! (-> s3-0 rdists data v1-9) (/ 1.0 (-> s3-0 dists data v1-9))) + ) + ) + (set! *texture-masks* (-> s5-0 shrub-masks data (-> s3-0 texture-masks-index))) + (dotimes (s2-0 4) + (let ((a0-15 (-> s3-0 geometry s2-0))) + (if (nonzero? a0-15) + (login a0-15) + ) + ) + ) + ) + ) + ) + this + ) + +;; definition for method 8 of type prototype-array-tie +(defmethod mem-usage ((this prototype-array-tie) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 1 (-> usage length))) + (set! (-> usage data 0 name) "drawable-group") + (+! (-> usage data 0 count) 1) + (let ((v1-6 (asize-of this))) + (+! (-> usage data 0 used) v1-6) + (+! (-> usage data 0 total) (logand -16 (+ v1-6 15))) + ) + (dotimes (s3-0 (-> this length)) + (mem-usage (-> this array-data s3-0) usage flags) + ) + this + ) + +;; definition for method 8 of type prototype-bucket-tie +(defmethod mem-usage ((this prototype-bucket-tie) (usage memory-usage-block) (flags int)) + (dotimes (s3-0 4) + (let ((a0-1 (-> this tie-geom s3-0))) + (if (nonzero? a0-1) + (mem-usage a0-1 usage (logior flags 1)) + ) + ) + ) + (set! (-> usage length) (max 85 (-> usage length))) + (set! (-> usage data 84 name) "string") + (+! (-> usage data 84 count) 1) + (let ((v1-13 (asize-of (-> this name)))) + (+! (-> usage data 84 used) v1-13) + (+! (-> usage data 84 total) (logand -16 (+ v1-13 15))) + ) + (when (nonzero? (-> this tie-colors)) + (set! (-> usage length) (max 17 (-> usage length))) + (set! (-> usage data 16 name) "tie-pal") + (+! (-> usage data 16 count) 1) + (let ((v1-25 (asize-of (-> this tie-colors)))) + (+! (-> usage data 16 used) v1-25) + (+! (-> usage data 16 total) (logand -16 (+ v1-25 15))) + ) + ) + (if (nonzero? (-> this collide-hash-fragment-array)) + (mem-usage (-> this collide-hash-fragment-array) usage (logior flags 1)) + ) + this + ) + +;; definition for method 8 of type prototype-inline-array-shrub +(defmethod mem-usage ((this prototype-inline-array-shrub) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 1 (-> usage length))) + (set! (-> usage data 0 name) "drawable-group") + (+! (-> usage data 0 count) 1) + (let ((v1-6 (asize-of this))) + (+! (-> usage data 0 used) v1-6) + (+! (-> usage data 0 total) (logand -16 (+ v1-6 15))) + ) + (dotimes (s3-0 (-> this length)) + (mem-usage (-> this data s3-0) usage flags) + ) + this + ) + +;; definition for method 8 of type prototype-bucket-shrub +(defmethod mem-usage ((this prototype-bucket-shrub) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 25 (-> usage length))) + (set! (-> usage data 24 name) "prototype-bucket-shrub") + (+! (-> usage data 24 count) 1) + (let ((v1-5 112)) + (+! (-> usage data 24 used) v1-5) + (+! (-> usage data 24 total) (logand -16 (+ v1-5 15))) + ) + (dotimes (s3-0 4) + (let ((a0-5 (-> this geometry s3-0))) + (if (nonzero? a0-5) + (mem-usage a0-5 usage (logior flags 1)) + ) + ) + ) + (set! (-> usage length) (max 85 (-> usage length))) + (set! (-> usage data 84 name) "string") + (+! (-> usage data 84 count) 1) + (let ((v1-22 (asize-of (-> this name)))) + (+! (-> usage data 84 used) v1-22) + (+! (-> usage data 84 total) (logand -16 (+ v1-22 15))) + ) + this + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/gfx/blit-displays-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/blit-displays-h_REF.gc index de1c3685463..6d9d62bf968 100644 --- a/test/decompiler/reference/jak3/engine/gfx/blit-displays-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/blit-displays-h_REF.gc @@ -43,7 +43,7 @@ (blit-displays-work-method-16 () none) (blit-displays-work-method-17 (_type_ vector int float symbol) none) (blit-displays-work-method-18 () none) - (blit-displays-work-method-19 () none) + (blit-displays-work-method-19 (_type_) none) (blit-displays-work-method-20 () none) (get-menu-mode (_type_) symbol) (get-screen-copied (_type_) symbol) diff --git a/test/decompiler/reference/jak3/engine/gfx/foreground/lights-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/foreground/lights-h_REF.gc index 30166893f55..617b7b645e4 100644 --- a/test/decompiler/reference/jak3/engine/gfx/foreground/lights-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/foreground/lights-h_REF.gc @@ -90,7 +90,7 @@ (format #t "[~8x] ~A~%" this 'light-sphere) (format #t "~1Tname: ~A~%" (-> this name)) (format #t "~1Tbsphere: ~`vector`P~%" (-> this bsphere)) - (format #t "~1Tdirection: ~`vector`P~%" (-> this direction)) + (format #t "~1Tdirection: ~`vector`P~%" (&-> this shadow)) (format #t "~1Tcolor: ~`vector`P~%" (-> this color)) (format #t "~1Tdecay-start: ~f~%" (-> this decay-start)) (format #t "~1Tambient-point-ratio: ~f~%" (-> this ambient-point-ratio)) @@ -98,7 +98,7 @@ (format #t "~1Tbytes[4] @ #x~X~%" (&-> this color w)) (format #t "~1Tmask: ~D~%" (-> this mask)) (format #t "~1Tpalette-index: ~D~%" (-> this palette-index)) - (format #t "~1Tshadow: #x~X~%" (-> this direction x)) + (format #t "~1Tshadow: #x~X~%" (-> this shadow)) (label cfg-4) this ) @@ -108,6 +108,7 @@ ((index uint16) (count uint16) ) + :pack-me ) ;; definition for method 3 of type light-hash-bucket diff --git a/test/decompiler/reference/jak3/engine/gfx/hw/display-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/hw/display-h_REF.gc index 1c62cb75742..3055cedd5d5 100644 --- a/test/decompiler/reference/jak3/engine/gfx/hw/display-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/hw/display-h_REF.gc @@ -57,8 +57,8 @@ ((on-screen int32) (last-screen int32) (frames display-frame 2) - (bgcolor uint64) - (pmode uint64) + (bgcolor gs-bgcolor) + (pmode gs-pmode) (clock clock 22) (session-clock clock :overlay-at (-> clock 0)) (game-clock clock :overlay-at (-> clock 1)) @@ -154,7 +154,7 @@ (set-display gp-0) (set! (-> gp-0 frames 0) (new 'global 'display-frame)) (set! (-> gp-0 frames 1) (new 'global 'display-frame)) - (set! (-> gp-0 pmode) (the-as uint 165)) + (set! (-> gp-0 pmode) (new 'static 'gs-pmode :en1 #x1 :crtmd #x1 :mmod #x1 :slbg #x1)) (set! (-> gp-0 run-half-speed) #f) (set! (-> gp-0 vu1-enable-user-menu) (vu1-renderer-mask rn3 @@ -185,7 +185,7 @@ tie-water etie-water etie-scissor-water - rn31 + sprite rn32 rn33 rn34 @@ -221,7 +221,7 @@ tie-water etie-water etie-scissor-water - rn31 + sprite rn32 rn33 rn34 diff --git a/test/decompiler/reference/jak3/engine/gfx/hw/video_REF.gc b/test/decompiler/reference/jak3/engine/gfx/hw/video_REF.gc new file mode 100644 index 00000000000..920def006aa --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/hw/video_REF.gc @@ -0,0 +1,126 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function set-video-mode +;; WARN: Return type mismatch int vs none. +(defun set-video-mode ((arg0 symbol)) + (case arg0 + (('ntsc) + (set! (-> *setting-control* user-default screenx) 0) + (set! (-> *setting-control* user-default screeny) 8) + (set! (-> *video-params* display-fbp) 164) + (set! (-> *video-params* display-sy) 224) + (set! *video-mode* 0) + (sound-set-fps 60) + ) + (('pal) + (set! (-> *setting-control* user-default screenx) 0) + (set! (-> *setting-control* user-default screeny) 24) + (set! (-> *video-params* display-fbp) 144) + (set! (-> *video-params* display-sy) 256) + (set! *video-mode* 1) + (sound-set-fps 50) + ) + ) + (set-time-ratios *display* (-> *display* dog-ratio)) + (set! (-> *video-params* reset-video-mode) #t) + (set! (-> *math-camera* isometric uvec y) 0.5) + (set! (-> *math-camera* y-clip) 416.0) + (set! (-> *math-camera* y-pix) (* 0.5 (-> *math-camera* y-clip))) + (set! *profile-y* 1848) + (set! (-> *video-params* set-video-mode) #t) + 0 + (none) + ) + +;; definition for function get-video-mode +(defun get-video-mode () + (-> *setting-control* user-current video-mode) + ) + +;; definition for function set-aspect-ratio +;; WARN: Return type mismatch int vs none. +(defun set-aspect-ratio ((arg0 symbol)) + (case arg0 + (('aspect4x3) + (set! (-> *video-params* relative-x-scale) 1.0) + (set! (-> *video-params* relative-x-scale-reciprical) 1.0) + ) + (('aspect16x9) + (set! (-> *video-params* relative-x-scale) 0.75) + (set! (-> *video-params* relative-x-scale-reciprical) 1.3333334) + ) + ) + 0 + (none) + ) + +;; definition for function get-aspect-ratio +(defun get-aspect-ratio () + (-> *setting-control* user-current aspect-ratio) + ) + +;; definition for function set-progressive-scan +;; WARN: Return type mismatch int vs none. +(defun set-progressive-scan ((arg0 symbol)) + (set! (-> *setting-control* user-default set-video-mode) arg0) + 0 + (none) + ) + +;; definition for function get-progressive-scan +(defun get-progressive-scan () + (-> *setting-control* user-current set-video-mode) + ) + +;; definition for function set-graphics-mode +;; WARN: Return type mismatch int vs none. +(defun set-graphics-mode () + (let ((v1-0 *setting-control*) + (gp-0 (the-as gs-bank #x12000000)) + (s5-0 *video-params*) + ) + (let ((s4-0 *display*)) + (cond + ((-> v1-0 user-current set-video-mode) + (when (nonzero? (-> s5-0 smode2)) + (reset-graph 0 0 80 0) + (set! (-> s5-0 smode2) (the-as uint 0)) + 0 + ) + (set! (-> gp-0 display1) (new 'static 'gs-display + :magh #x1 + :dw #x4ff + :dy (+ (-> s5-0 display-dy) 50) + :dx (+ (* (-> s5-0 display-dx) 2) 326) + :dh (+ (* (-> s5-0 display-sy) 2) -1) + ) + ) + ) + (else + (when (or (!= (-> s5-0 smode2) 1) (-> *video-params* set-video-mode)) + (if (= (-> *setting-control* user-current video-mode) 'ntsc) + (reset-graph 0 1 2 0) + (reset-graph 0 1 3 0) + ) + (set! (-> s5-0 smode2) (the-as uint 1)) + (set! (-> s5-0 set-video-mode) #f) + ) + (set! (-> gp-0 display1) (new 'static 'gs-display + :magh #x3 + :dw #x9ff + :dy (+ (-> s5-0 display-dy) 50) + :dx (+ (* (-> s5-0 display-dx) 4) 652) + :dh (+ (* (-> s5-0 display-sy) 2) -1) + ) + ) + ) + ) + (set! (-> gp-0 pmode) (-> s4-0 pmode)) + (set! (-> gp-0 bgcolor) (-> s4-0 bgcolor)) + ) + (set! (-> gp-0 dspfb1) (new 'static 'gs-display-fb :fbw #xa :fbp (-> s5-0 display-fbp))) + ) + 0 + (none) + ) diff --git a/test/decompiler/reference/jak3/engine/gfx/ocean/ocean-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/ocean/ocean-h_REF.gc index 755de1a01d2..6e243e2ef75 100644 --- a/test/decompiler/reference/jak3/engine/gfx/ocean/ocean-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/ocean/ocean-h_REF.gc @@ -896,8 +896,8 @@ ) (:methods (get-height (_type_ vector symbol) float) - (ocean-method-12 () none) - (ocean-method-13 () none) + (draw! (_type_) none) + (update-map (_type_) none) (ocean-method-14 () none) (ocean-method-15 () none) (ocean-method-16 () none) diff --git a/test/decompiler/reference/jak3/engine/gfx/sky/sky-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/sky/sky-h_REF.gc index 6f733b365c7..d58db2b4eb7 100644 --- a/test/decompiler/reference/jak3/engine/gfx/sky/sky-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/sky/sky-h_REF.gc @@ -411,7 +411,7 @@ (sky-work-method-11 () none) (sky-work-method-12 () none) (sky-work-method-13 () none) - (sky-work-method-14 () none) + (draw (_type_) none) (sky-work-method-15 () none) (sky-work-method-16 () none) (sky-work-method-17 () none) @@ -501,7 +501,3 @@ ;; failed to figure out what this is: 0 - - - - diff --git a/test/decompiler/reference/jak3/engine/level/level-h_REF.gc b/test/decompiler/reference/jak3/engine/level/level-h_REF.gc index e07416a5bfd..5c3c7d47160 100644 --- a/test/decompiler/reference/jak3/engine/level/level-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/level/level-h_REF.gc @@ -667,10 +667,10 @@ (level-get-for-use (_type_ symbol symbol) level) (activate-levels! (_type_) int) (level-group-method-14 () none) - (level-group-method-15 () none) + (debug-draw-actors (_type_ symbol) none) (assign-draw-indices (_type_) none) - (level-group-method-17 () none) - (level-group-method-18 () none) + (actors-update (_type_) none) + (update-nav-meshes-method (_type_) none) (level-update (_type_) none) (level-get-target-inside (_type_) level) (init-level-system (_type_ symbol) none) diff --git a/test/decompiler/reference/jak3/engine/ui/bigmap-h_REF.gc b/test/decompiler/reference/jak3/engine/ui/bigmap-h_REF.gc index f66dd96ddcd..0af6ccf710b 100644 --- a/test/decompiler/reference/jak3/engine/ui/bigmap-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/ui/bigmap-h_REF.gc @@ -104,7 +104,7 @@ (:methods (new (symbol type) _type_) (bigmap-method-9 () none) - (bigmap-method-10 () none) + (update (_type_) none) (draw (_type_ int int int int) int) (bigmap-method-12 () none) (bigmap-method-13 () none) diff --git a/test/decompiler/reference/jak3/levels/city/common/trail-h_REF.gc b/test/decompiler/reference/jak3/levels/city/common/trail-h_REF.gc index 50e87edd140..3045f6570dc 100644 --- a/test/decompiler/reference/jak3/levels/city/common/trail-h_REF.gc +++ b/test/decompiler/reference/jak3/levels/city/common/trail-h_REF.gc @@ -289,7 +289,7 @@ (trail-graph-method-11 () none) (trail-graph-method-12 () none) (trail-graph-method-13 () none) - (trail-graph-method-14 () none) + (debug-draw (_type_) none) (trail-graph-method-15 () none) (trail-graph-method-16 () none) (trail-graph-method-17 () none) @@ -356,7 +356,3 @@ ;; definition for symbol *trail-graph*, type trail-graph (define *trail-graph* (the-as trail-graph #f)) - - - - diff --git a/test/offline/config/jak3/config.jsonc b/test/offline/config/jak3/config.jsonc index c13e6c13c65..9fa81d9b629 100644 --- a/test/offline/config/jak3/config.jsonc +++ b/test/offline/config/jak3/config.jsonc @@ -122,7 +122,16 @@ "(method 29 level)", "level-update-after-load", "(method 9 level)", - "(method 11 level)" + "(method 11 level)", + // drawable + "calc-shadow-masks", + "calc-realtime-lights", + "real-main-draw-hook", + "display-sync", + "dma-add-process-drawable", + "vis-cull", + "vis-cull-debug", + "foreground-engine-execute" ], "skip_compile_states": {}