Skip to content

Commit

Permalink
[jak3] remove some stubs and fix health bar (#3468)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManDude authored Apr 15, 2024
1 parent ccd2c9e commit 20b76e3
Show file tree
Hide file tree
Showing 17 changed files with 961 additions and 219 deletions.
3 changes: 2 additions & 1 deletion decompiler/config/jak3/ntsc_v1/hacks.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,8 @@
"(method 9 prim-strip)",
"live-func-curve",
"birth-func-curve",
"sparticle-motion-blur-dirt"
"sparticle-motion-blur-dirt",
"foreground-draw-hud"
],

"mips2c_jump_table_functions": {},
Expand Down
2 changes: 1 addition & 1 deletion decompiler/config/jak3/ntsc_v1/label_types.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@
"hud": [["L240", "vector"]],
"hud-classes": [
["L205", "(inline-array hud-sprite)", 24],
["L214", "(inline-array vector)", 4]
["L214", "(inline-array vector)", 16]
],
"level": [
["L1004", "uint64", true],
Expand Down
2 changes: 1 addition & 1 deletion game/graphics/opengl_renderer/sprite/Sprite3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ void Sprite3::do_block_common(SpriteMode mode,
if ((flag & 0x10) || (flag & 0x20)) {
// these flags mean we need to swap vertex order around - not yet implemented since it's too
// hard to get right without this code running.
ASSERT_NOT_REACHED();
// ASSERT_NOT_REACHED();
}
}

Expand Down
3 changes: 3 additions & 0 deletions game/mips2c/jak3_functions/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ u64 execute(void* ctxt) {
if (bc) {goto block_2;} // branch non-likely

// Unknown instr: jr t9
draw_boundary_polygon::execute(ctxt);
goto end_of_function;
// nop // sll r0, r0, 0

block_2:
Expand All @@ -572,6 +574,7 @@ u64 execute(void* ctxt) {
c->sqc2(vf6, 176, a3); // sqc2 vf6, 176(a3)
// nop // sll r0, r0, 0
// Unknown instr: jr t9
draw_boundary_polygon::execute(ctxt);
// nop // sll r0, r0, 0
//jr ra // jr ra
c->daddu(sp, sp, r0); // daddu sp, sp, r0
Expand Down
310 changes: 310 additions & 0 deletions game/mips2c/jak3_functions/foreground.cpp

Large diffs are not rendered by default.

590 changes: 573 additions & 17 deletions game/mips2c/jak3_functions/sky.cpp

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion game/mips2c/mips2c_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ namespace nav_dma_send_to_spr_no_flush { extern void link(); }
namespace blerc_execute { extern void link(); }
namespace setup_blerc_chains_for_one_fragment { extern void link(); }
namespace sparticle_motion_blur_dirt { extern void link(); }
namespace foreground_draw_hud { extern void link(); }

}
// clang-format on
Expand Down Expand Up @@ -540,7 +541,7 @@ PerGameVersion<std::unordered_map<std::string, std::vector<void (*)()>>> gMips2C
{"joint", {jak3::cspace_parented_transformq_joint::link}},
{"foreground",
{jak3::foreground_check_longest_edge_asm::link, jak3::foreground_generic_merc::link,
jak3::foreground_merc::link}},
jak3::foreground_merc::link, jak3::foreground_draw_hud::link}},
{"particle-curves", {jak3::live_func_curve::link, jak3::birth_func_curve::link}},
{"collide-hash",
{jak3::method_11_collide_hash::link, jak3::method_12_collide_hash::link,
Expand Down
3 changes: 1 addition & 2 deletions goal_src/jak3/engine/game/game-info.gc
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,7 @@
"title-start"
)
((and *debug-segment* (= mode 'boot))
"halfpipe"
;; "wascity-start"
"wascity-start"
)
(else
"title-start"
Expand Down
6 changes: 4 additions & 2 deletions goal_src/jak3/engine/gfx/foreground/foreground.gc
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@
:shadow-dir (new 'static 'vector :x -0.4226 :y -0.9063 :w 409600.0)
:bot-plane (new 'static 'plane :y 1.0 :w 37683.2)
:top-plane (new 'static 'plane :y 1.0 :w 4096.0)
:fade-vec (new 'static 'vector :x 409600.0)
:fade-dist 409600.0
)
)

Expand Down Expand Up @@ -855,7 +855,7 @@
(let ((t1-5 (-> a3-3 flags)))
(-> arg0 cur-lod)
(when (not (logtest? t1-5 (shadow-flags disable-fade)))
(if (< (-> a3-3 fade-vec x) t0-0)
(if (< (-> a3-3 fade-dist) t0-0)
(set! t1-5 (logior t1-5 (shadow-flags disable-draw)))
)
)
Expand Down Expand Up @@ -2358,6 +2358,8 @@
)
)

(def-mips2c foreground-draw-hud (function draw-control dma-buffer float none))

(kmemopen global "foreground-engine")

(define *foreground* (new 'global 'foreground-globals))
Expand Down
19 changes: 19 additions & 0 deletions goal_src/jak3/engine/gfx/sky/sky-tng.gc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@

;; DECOMP BEGINS

(defun close-sky-buffer ((arg0 dma-buffer))
"Terminate dma from large polygon renderer. This should be called after the last
call to render-sky-tri/quad."
(nop!)
(let ((v1-0 #x8000)
(v0-0 (-> arg0 base))
)
(set! (-> (the-as (pointer uint128) v0-0)) (the uint128 0))
(nop!)
(set! (-> (the-as (pointer int32) v0-0)) v1-0)
(let ((v0-1 (&+ v0-0 16)))
;; to save like 1 instruction they put this in the delay slot of the jr-ra
;;(.jr ra-0)
(set! (-> arg0 base) v0-1)
)
)
(none)
)

(defmethod update-time-and-speed ((this sky-work) (arg0 float) (arg1 float))
(if (and (level-get-target-inside *level*) (= (-> (level-get-target-inside *level*) info taskname) 'nest))
(set! arg1 (* 10.0 arg1))
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak3/engine/level/level.gc
Original file line number Diff line number Diff line change
Expand Up @@ -2779,7 +2779,7 @@
(none)
)

(defconstant *default-boot-level* 'halfpipe)
(defconstant *default-boot-level* 'wasall)

(defmacro play-desert ()
`(start 'play (get-continue-by-name *game-info* "desert-start"))
Expand Down
16 changes: 8 additions & 8 deletions goal_src/jak3/engine/level/region.gc
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,14 @@
)
(add-debug-sphere #t (bucket-id debug) s5-0 (-> this bsphere w) (new 'static 'rgba :r #xff :a #x30))
)
;; (add-debug-bound
;; (bucket-id debug)
;; (-> this data points)
;; (the-as int (-> this data num-points))
;; (new 'static 'rgba :r #x80 :g #x80 :a #x40)
;; (new 'static 'rgba :r #x80 :a #x40)
;; 0
;; )
(add-debug-bound
(bucket-id debug)
(-> this data points)
(the-as int (-> this data num-points))
(new 'static 'rgba :r #x80 :g #x80 :a #x40)
(new 'static 'rgba :r #x80 :a #x40)
0
)
0
(none)
)
Expand Down
18 changes: 15 additions & 3 deletions goal_src/jak3/engine/ui/hud-classes.gc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

(defmethod update-values! ((this hud-map))
(cond
((and (nonzero? *minimap*) (update! *minimap*))
((update! *minimap*)
(logior! (-> this flags) (hud-flags show))
(let ((t9-1 (method-of-type hud update-values!)))
(t9-1 this)
Expand Down Expand Up @@ -110,7 +110,7 @@
(set! (-> this sprites 1 flags) (hud-sprite-flags hsf2))
(set! (-> this sprites 1 pos z) #xffff00)
(set! (-> this values 0 current) 0)
(if (nonzero? *minimap*) (update! *minimap*))
(update! *minimap*)
0
(none)
)
Expand Down Expand Up @@ -192,11 +192,23 @@
(let ((s5-0 (-> this values 4 current)))
(dotimes (s4-0 s5-0)
(let ((v1-38
(-> (new 'static 'inline-array vector 4
(-> (new 'static 'inline-array vector 16
(new 'static 'vector :x 23.0 :y 5.0 :w 1.0)
(new 'static 'vector :x 36.0 :y 2.0 :w 1.0)
(new 'static 'vector :x 49.0 :y 5.0 :w 1.0)
(new 'static 'vector :x 60.0 :y 12.0 :w 1.0)
(new 'static 'vector :x 67.0 :y 23.0 :w 1.0)
(new 'static 'vector :x 70.0 :y 36.0 :w 1.0)
(new 'static 'vector :x 67.0 :y 49.0 :w 1.0)
(new 'static 'vector :x 60.0 :y 60.0 :w 1.0)
(new 'static 'vector :x 49.0 :y 67.0 :w 1.0)
(new 'static 'vector :x 36.0 :y 70.0 :w 1.0)
(new 'static 'vector :x 23.0 :y 67.0 :w 1.0)
(new 'static 'vector :x 12.0 :y 60.0 :w 1.0)
(new 'static 'vector :x 5.0 :y 49.0 :w 1.0)
(new 'static 'vector :x 2.0 :y 36.0 :w 1.0)
(new 'static 'vector :x 5.0 :y 23.0 :w 1.0)
(new 'static 'vector :x 12.0 :y 12.0 :w 1.0)
)
(logand (+ (- 20 (/ s5-0 2)) s4-0) 15)
)
Expand Down
4 changes: 2 additions & 2 deletions goal_src/jak3/game.gp
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@
; (cgo-file "museum3b.gd" common-dep)
; (cgo-file "museum4.gd" common-dep)
; (cgo-file "museum4b.gd" common-dep)
; ;; test
; (cgo-file "halfpipe.gd" common-dep)
;; test
(cgo-file "halfpipe.gd" common-dep)
; ;; borrow
; (cgo-file "lashelin.gd" common-dep)
; (cgo-file "lbbring1.gd" common-dep)
Expand Down
4 changes: 4 additions & 0 deletions scripts/batch/gk3-display.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
cd ..\..
out\build\Release\bin\gk -v --game jak3 -- -boot -fakeiso -debug
pause
177 changes: 2 additions & 175 deletions test/decompiler/reference/jak3/engine/gfx/foreground/foreground_REF.gc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 20b76e3

Please sign in to comment.