d/jak2: some minor fixes and workarounds to make debugging easier (#2116)

- worked around audio code for gungame, the tutorials now function
- auto-exit cutscenes upon entry. This doesn't always work nicely (i
didnt want to cause any side-effects due to messing with load states)
but it atleast stops jak from being stuck forever waiting for the
cutscene to load
This commit is contained in:
Tyler Wilding
2023-01-14 12:36:41 -05:00
committed by GitHub
parent 8b12553d15
commit b072126764
16 changed files with 151 additions and 69 deletions
+1 -1
View File
@@ -10817,7 +10817,7 @@
(update-map (_type_) none 13)
(interp-wave (_type_ ocean-wave-info uint float) none 14)
(ocean-method-15 (_type_ matrix matrix) none 15)
(generate-verts () none 16)
(generate-verts (_type_ ocean-vert-array ocean-height-array) none 16)
(add-colors! (_type_ vector ocean-vertex) none 17)
(ocean-method-18 "Unused" (_type_ (pointer ocean-colors) (pointer ocean-colors)) none 18) ;; args are guesses
(init-buffer!
+7 -2
View File
@@ -101,7 +101,7 @@
"DGO/PAC.DGO",
// "DGO/LTENTOB.DGO",
// "DGO/LRACEBF.DGO",
// "DGO/LPROTECT.DGO",
"DGO/LPROTECT.DGO",
"DGO/FEA.DGO",
"DGO/ONINTENT.DGO",
"DGO/STA.DGO",
@@ -141,7 +141,7 @@
"DGO/VIN.DGO",
"DGO/CGA.DGO",
"DGO/CMB.DGO",
// "DGO/LGUARD.DGO",
"DGO/LGUARD.DGO",
"DGO/CPA.DGO",
// "DGO/LCITYLOW.DGO",
// "DGO/LTENTOUT.DGO",
@@ -191,6 +191,7 @@
"CPO.DGO",
"CTA.DGO",
"CTB.DGO",
"CTC.DGO",
"CWI.DGO",
"D3A.DGO",
"D3B.DGO",
@@ -205,8 +206,11 @@
"FORDUMPD.DGO",
"GGA.DGO",
"HIDEOUT.DGO",
"HIPHOG.DGO",
"KIOSK.DGO",
"LDJAKBRN.DGO",
"LGUARD.DGO",
"LPROTECT.DGO",
"LSACK.DGO",
"LWIDEA.DGO",
"LWIDEB.DGO",
@@ -214,6 +218,7 @@
"MCN.DGO",
"MTN.DGO",
"MTX.DGO",
"ORACLE.DGO",
"PRI.DGO",
"RUI.DGO",
"SAG.DGO",
@@ -93,6 +93,7 @@ void OpenGLRenderer::init_bucket_renderers_jak2() {
init_bucket_renderer<TextureUploadHandler>("tex-lcom-sky-pre", BucketCategory::TEX,
BucketId::TEX_LCOM_SKY_PRE);
init_bucket_renderer<DirectRenderer>("sky-draw", BucketCategory::OTHER, BucketId::SKY_DRAW, 1024);
init_bucket_renderer<SkipRenderer>("bucket-6", BucketCategory::OCEAN, BucketId::OCEAN_MID_FAR);
init_bucket_renderer<TextureUploadHandler>("tex-l0-tfrag", BucketCategory::TEX,
BucketId::TEX_L0_TFRAG);
init_bucket_renderer<TFragment>("tfrag-l0-tfrag", BucketCategory::TFRAG, BucketId::TFRAG_L0_TFRAG,
@@ -202,6 +203,8 @@ void OpenGLRenderer::init_bucket_renderers_jak2() {
BucketId::TEX_L1_PRIS2);
// 230
// 240
init_bucket_renderer<TextureUploadHandler>("tex-l4-pris2", BucketCategory::TEX,
BucketId::TEX_L4_PRIS2);
// 250
init_bucket_renderer<TextureUploadHandler>("tex-l0-water", BucketCategory::TEX,
BucketId::TEX_L0_WATER);
@@ -235,6 +238,7 @@ void OpenGLRenderer::init_bucket_renderers_jak2() {
init_bucket_renderer<TextureUploadHandler>("tex-lcom-sky-post", BucketCategory::TEX,
BucketId::TEX_LCOM_SKY_POST);
// 310
init_bucket_renderer<SkipRenderer>("bucket-310", BucketCategory::OCEAN, BucketId::OCEAN_NEAR);
init_bucket_renderer<TextureUploadHandler>("tex-all-sprite", BucketCategory::TEX,
BucketId::TEX_ALL_SPRITE);
init_bucket_renderer<Sprite3>("particles", BucketCategory::SPRITE, BucketId::PARTICLES);
+3
View File
@@ -84,6 +84,7 @@ enum class BucketId {
SPECIAL_BUCKET_2 = 2,
TEX_LCOM_SKY_PRE = 4,
SKY_DRAW = 5,
OCEAN_MID_FAR = 6,
TEX_L0_TFRAG = 7,
TFRAG_L0_TFRAG = 8,
TIE_L0_TFRAG = 9,
@@ -137,6 +138,7 @@ enum class BucketId {
MERC_LCOM_PRIS = 221,
TEX_L0_PRIS2 = 224,
TEX_L1_PRIS2 = 228,
TEX_L4_PRIS2 = 240,
TEX_L0_WATER = 252,
MERC_L0_WATER = 253,
TFRAG_W_L0_WATER = 255,
@@ -151,6 +153,7 @@ enum class BucketId {
TEX_LCOM_WATER = 306,
MERC_LCOM_WATER = 307,
TEX_LCOM_SKY_POST = 309,
OCEAN_NEAR = 310,
TEX_ALL_SPRITE = 312,
PARTICLES = 313,
TEX_ALL_WARP = 316,
+4 -1
View File
@@ -271,6 +271,7 @@ struct Cache {
void* sewerb; // sewerb
void* upload_vu0_program; // upload-vu0-program
void* vu_lights_light_group; // vu-lights<-light-group!
void* ocean_generate_verts_vector;
} cache;
void vcallms0(ExecutionContext* c) {
@@ -608,6 +609,7 @@ block_19:
block_20:
// daddiu v1, fp, L18 // daddiu v1, fp, L18
c->load_symbol2(v1, cache.ocean_generate_verts_vector); // HACK
c->daddiu(a2, s4, 8192); // daddiu a2, s4, 8192
c->daddiu(a0, s4, 8192); // daddiu a0, s4, 8192
c->mov64(a1, v1); // or a1, v1, r0
@@ -850,8 +852,9 @@ void link() {
cache.sewerb = intern_from_c("sewerb").c();
cache.upload_vu0_program = intern_from_c("upload-vu0-program").c();
cache.vu_lights_light_group = intern_from_c("vu-lights<-light-group!").c();
cache.ocean_generate_verts_vector = intern_from_c("*ocean-generate-verts-vector*").c();
gLinkedFunctionTable.reg("(method 16 ocean)", execute, 128);
}
} // namespace method_16_ocean
} // namespace Mips2C
} // namespace Mips2C
@@ -83,7 +83,7 @@
)
(return #f)
)
(if (not (and (logtest? (-> arg0 flags) (water-flags active))
(when (not (and (logtest? (-> arg0 flags) (water-flags active))
(logtest? (-> arg0 flags) (water-flags can-ground))
(logtest? (-> arg0 flags) (water-flags swim-ground under-water))
(logtest? (water-flags over-water) (-> arg0 flags))
+13 -13
View File
@@ -1452,19 +1452,19 @@
)
;; draw the 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)
; )
(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*)
(when *ocean-map*
(update-map *ocean*)
)
)
(set! (-> pp clock) gp-5)
)
;; run the foreground system
(foreground-engine-execute *foreground-draw-engine* (-> *display* frames (-> *display* on-screen)))
@@ -5,5 +5,47 @@
;; name in dgo: shadow-cpu
;; dgos: ENGINE, GAME
(defmethod shadow-control-method-13 shadow-control ((obj shadow-control) (arg0 vector) (arg1 float) (arg2 float) (arg3 float))
(with-pp
(let ((s4-0 (new 'stack-no-clear 'collide-query)))
(let ((v1-0 pp))
(set! (-> s4-0 start-pos quad) (-> arg0 quad))
(set! (-> s4-0 start-pos y) (+ 4096.0 (-> s4-0 start-pos y)))
(set-vector! (-> s4-0 move-dist) 0.0 (- arg3) 0.0 1.0)
(let ((a0-4 s4-0))
(set! (-> a0-4 radius) 8192.0)
(set! (-> a0-4 collide-with) (collide-spec backgnd))
(set! (-> a0-4 ignore-process0) v1-0)
(set! (-> a0-4 ignore-process1) #f)
(set! (-> a0-4 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1))
(set! (-> a0-4 action-mask) (collide-action solid))
)
)
(cond
((>= (fill-and-probe-using-line-sphere *collide-cache* s4-0) 0.0)
(let ((v1-5 obj))
(logclear! (-> v1-5 settings flags) (shadow-flags disable-draw))
)
0
(let ((v1-7 obj))
(set! (-> v1-7 settings bot-plane w) (- (+ (-> s4-0 best-other-tri intersect y) arg1)))
)
0
(set! (-> obj settings top-plane w) (- (+ (-> s4-0 best-other-tri intersect y) arg2)))
0
)
(else
(let ((v1-10 obj))
(logior! (-> v1-10 settings flags) (shadow-flags disable-draw))
)
0
)
)
)
0
(none)
)
)
;; DECOMP BEGINS
@@ -7,3 +7,9 @@
;; DECOMP BEGINS
(defun upload-vu0-program ((func vu-function) (wait-ptr pointer))
"Upload and block until done.
Generating the DMA is highly optimized."
(none)
)
+1 -1
View File
@@ -517,7 +517,7 @@
(update-map (_type_) none 13)
(interp-wave (_type_ ocean-wave-info uint float) none 14)
(ocean-method-15 (_type_ matrix matrix) none 15)
(generate-verts () none 16)
(generate-verts (_type_ ocean-vert-array ocean-height-array) none 16)
(add-colors! (_type_ vector ocean-vertex) none 17)
(ocean-method-18 (_type_ (pointer ocean-colors) (pointer ocean-colors)) none 18)
(init-buffer! (_type_ dma-buffer) pointer 19)
+16 -9
View File
@@ -1160,10 +1160,11 @@
(let ((f0-5 1.0)
(f30-0 1.0)
)
(when (= (-> *bigmap* bigmap-index) 13)
(set! f0-5 0.333)
(set! f30-0 0.75)
)
;; TODO - need bigmap
;; (when (= (-> *bigmap* bigmap-index) 13)
;; (set! f0-5 0.333)
;; (set! f30-0 0.75)
;; )
(set! (-> obj frame-speed) (* (+ 4.0 (-> *setting-control* user-current rain)) f0-5))
(set! (-> obj frame-speed2) (* (+ 5.0 (-> *setting-control* user-current rain)) f0-5))
(when (not (paused?))
@@ -1200,11 +1201,7 @@
(the-as vector4 (-> *time-of-day-context* current-sky-color))
0.0078125
)
(let ((t9-8 (method-of-type ocean generate-verts)))
(-> obj verts)
(-> obj heights)
(t9-8)
)
(generate-verts obj (-> obj verts) (-> obj heights))
(let* ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf))
(s5-2 (-> s4-0 base))
)
@@ -1280,6 +1277,16 @@
)
)
;; PC Port hack
(define *ocean-generate-verts-vector* (new 'global 'vector))
(set-vector! *ocean-generate-verts-vector*
(the-as float #x43000000) ;; in jak1, this component was different!
(the-as float #x43000000)
(the-as float #x43000000)
(the-as float #x43000000)
)
(defmethod draw! ocean ((obj ocean))
(do-tex-scroll! obj)
(set! *ocean-map* #f)
+5 -1
View File
@@ -870,6 +870,10 @@
(defstate wait (scene-player)
:virtual #t
:enter (behavior ((arg0 symbol))
;; HACK TO NOT GET STUCK WAITING FOR SCENE TO LOAD
;; progress from cutscenes however is handled by the command-list on the load-state cleanup
(go-virtual release)
;; END HACK - REMOVE ME EVENTUALLY
(set! (-> self state-time) (-> self clock frame-counter))
(when (or (-> self scene) (-> self preload-continue))
(let ((gp-0 (scene-decode-continue (the-as basic (if (-> self scene)
@@ -1610,7 +1614,7 @@
(defbehavior scene-player-init scene-player ((arg0 object) (arg1 symbol) (arg2 string))
"`object` arg can be an `(array scene)`, `pair of scene` or a `scene`"
(process-entity-set! self (the-as entity-actor #f))
(stack-size-set! (-> self main-thread) 512)
(stack-size-set! (-> self main-thread) 1024)
(set! (-> self root) (new 'process 'trsqv))
(case (rtype-of arg0)
((array)
+1
View File
@@ -1338,6 +1338,7 @@
;; WARN: Return type mismatch object vs none.
(defmethod init-from-entity! oracle-door ((obj oracle-door) (arg0 entity-actor))
(stack-size-set! (-> obj main-thread) 1024)
(let ((s5-0 (new 'process 'collide-shape obj (collide-list-enum usually-hit-by-player))))
(set! (-> s5-0 penetrated-by) (penetrate))
(let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 2) 0)))
+45 -34
View File
@@ -215,7 +215,7 @@
)
(defmethod render-text training-manager ((obj training-manager) (arg0 game-text-id))
(when (= (get-status *gui-control* (-> obj gui-id)) (gui-status active))
(when #t ;; TODO - disabled until sound is working (= (get-status *gui-control* (-> obj gui-id)) (gui-status active))
(let ((s5-1 (new
'stack
'font-context
@@ -278,9 +278,10 @@
(set! (-> self last-sound-id)
(add-process *gui-control* self (gui-channel sig) (gui-action play) "sigc003" -99.0 0)
)
(while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
(suspend)
)
;; TODO - disable until sound is ready
;; (while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
;; (suspend)
;; )
(until (cpad-pressed? 0 r1)
(render-text self (game-text-id gungame-tutorial-fire-button))
(suspend)
@@ -297,9 +298,10 @@
(set! (-> self last-sound-id)
(add-process *gui-control* self (gui-channel sig) (gui-action play) "sigc007" -99.0 0)
)
(while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
(suspend)
)
;; TODO - disable until sound is ready
;; (while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
;; (suspend)
;; )
(when *target*
(while (logtest? (focus-status gun) (-> *target* focus-status))
(render-text self (game-text-id gungame-tutorial-put-red-away))
@@ -312,9 +314,10 @@
(set! (-> self last-sound-id)
(add-process *gui-control* self (gui-channel sig) (gui-action play) "sigc009" -99.0 0)
)
(while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
(suspend)
)
;; TODO - disable until sound is ready
;; (while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
;; (suspend)
;; )
(while (or (not *target*) (zero? (logand (focus-status gun) (-> *target* focus-status))))
(render-text self (game-text-id gungame-tutorial-take-red-out))
(suspend)
@@ -325,9 +328,10 @@
(set! (-> self last-sound-id)
(add-process *gui-control* self (gui-channel sig) (gui-action play) "sigc011" -99.0 0)
)
(while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
(suspend)
)
;; TODO - disable until sound is ready
;; (while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
;; (suspend)
;; )
(when (nonzero? (training-manager-method-26 self))
(set! (-> self last-sound-id)
(add-process *gui-control* self (gui-channel sig) (gui-action play) "sigc012" -99.0 0)
@@ -345,9 +349,10 @@
(set! (-> self last-sound-id)
(add-process *gui-control* self (gui-channel sig) (gui-action play) "sigc014" -99.0 0)
)
(while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
(suspend)
)
;; TODO - disable until sound is ready
;; (while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
;; (suspend)
;; )
(task-node-close! (game-task-node city-red-gun-training-introduction))
(go-virtual red-training)
(none)
@@ -1014,9 +1019,10 @@
(set! (-> self last-sound-id)
(add-process *gui-control* self (gui-channel sig) (gui-action play) "sigc017" -99.0 0)
)
(while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
(suspend)
)
;; TODO - disable until sound is ready
;; (while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
;; (suspend)
;; )
(let ((gp-2 (-> *game-info* gun-type)))
(until (!= gp-2 (-> *game-info* gun-type))
(render-text self (game-text-id gungame-tutorial-switch-to-yellow))
@@ -1029,9 +1035,10 @@
(set! (-> self last-sound-id)
(add-process *gui-control* self (gui-channel sig) (gui-action play) "sigc075" -99.0 0)
)
(while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
(suspend)
)
;; TODO - disable until sound is ready
;; (while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
;; (suspend)
;; )
(set! (-> self combo-done?) #f)
(until #f
(let ((gp-3 *yellow-training-path-combo-info*))
@@ -1056,9 +1063,10 @@
(set! (-> self last-sound-id)
(add-process *gui-control* self (gui-channel sig) (gui-action play) "sigc080" -99.0 0)
)
(while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
(suspend)
)
;; TODO - disable until sound is ready
;; (while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
;; (suspend)
;; )
#t
(goto cfg-61)
)
@@ -1066,9 +1074,10 @@
(set! (-> self last-sound-id)
(add-process *gui-control* self (gui-channel sig) (gui-action play) "sigc077" -99.0 0)
)
(while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
(suspend)
)
;; TODO - disable until sound is ready
;; (while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
;; (suspend)
;; )
)
)
)
@@ -1080,9 +1089,10 @@
(set! (-> self last-sound-id)
(add-process *gui-control* self (gui-channel sig) (gui-action play) "sigc022" -99.0 0)
)
(while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
(suspend)
)
;; TODO - disable until sound is ready
;; (while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
;; (suspend)
;; )
(task-node-close! (game-task-node city-yellow-gun-training-introduction))
(go yellow-training)
(none)
@@ -1835,9 +1845,10 @@
(none)
)
:code (behavior ()
(while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
(suspend)
)
;; TODO - disable until sound is ready
;; (while (nonzero? (get-status *gui-control* (-> self last-sound-id)))
;; (suspend)
;; )
(when (> (-> self egg-count) 0)
(let* ((gp-0 (handle->process (-> self voicebox)))
(v1-8 (if (type? gp-0 process-drawable)
+1 -1
View File
@@ -999,7 +999,7 @@
(update-map (_type_) none 13)
(interp-wave (_type_ ocean-wave-info uint float) none 14)
(ocean-method-15 (_type_ matrix matrix) none 15)
(generate-verts () none 16)
(generate-verts (_type_ ocean-vert-array ocean-height-array) none 16)
(add-colors! (_type_ vector ocean-vertex) none 17)
(ocean-method-18 (_type_ (pointer ocean-colors) (pointer ocean-colors)) none 18)
(init-buffer! (_type_ dma-buffer) pointer 19)
+1 -5
View File
@@ -1458,11 +1458,7 @@
(the-as vector4 (-> *time-of-day-context* current-sky-color))
0.0078125
)
(let ((t9-8 (method-of-type ocean generate-verts)))
(-> obj verts)
(-> obj heights)
(t9-8)
)
(generate-verts obj (-> obj verts) (-> obj heights))
(let* ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf))
(s5-2 (-> s4-0 base))
)