Skip to content

Commit

Permalink
jak3: decomp bigmap, blit-displays, fix progress crash (#3657)
Browse files Browse the repository at this point in the history
`bigmap` and `blit-displays` mostly work. `blit-displays` is still
missing all of the special effects that were added in Jak 3 (brightness
and contrast settings, screen blur effect, etc.).

`bigmap` is missing the player marker texture (`hud-target-marker`) for
some reason, it's part of `tpage-17` which is coming from
`progress-minimap` and should already be included. The icons also
currently stretch when using aspect ratios other than 4:3.

The progress menu now also works for the most part. The draw order is a
bit messed up because some code was initially drawing things with the
ocean bucket, which was changed to use `hud-draw-hud-alpha` instead for
now. The texture for the volume and brightness/contrast sliders still
looks wrong.

Fixes #3653
Fixes #3656
  • Loading branch information
Hat-Kid authored Sep 7, 2024
1 parent bc66d41 commit 7053090
Show file tree
Hide file tree
Showing 49 changed files with 4,754 additions and 789 deletions.
9 changes: 5 additions & 4 deletions decompiler/ObjectFile/ObjectFileDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,11 @@ ObjectFileDB::ObjectFileDB(const std::vector<fs::path>& _dgos,
StrFileReader reader(obj, version());
// name from the file name
std::string base_name = obj_filename_to_name(obj.string());
ASSERT(reader.chunk_count() == 1);
auto name = reader.get_texture_name();
add_obj_from_dgo(name, name, reader.get_chunk(0).data(), reader.get_chunk(0).size(),
"TEXSPOOL", config, name);
for (int i = 0; i < reader.chunk_count(); i++) {
auto name = reader.get_chunk_texture_name(i);
add_obj_from_dgo(name, name, reader.get_chunk(i).data(), reader.get_chunk(i).size(),
"TEXSPOOL", config, name);
}
}
}

Expand Down
131 changes: 85 additions & 46 deletions decompiler/config/jak3/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -7541,27 +7541,27 @@
;; +++level-h:bigmap-id
(defenum bigmap-id
:type uint32
(bigmap-id-0 0)
(bigmap-id-1 1)
(city 0)
(comb 1)
(desert 2)
(factory 3)
(forest 4)
(mhcity 5)
(mine 6)
(nest 7)
(bigmap-id-8 8)
(no-map 9)
(precursor 10)
(bigmap-id-11 11)
(nest2 8)
(none 9)
(precursor1 10)
(precursor2 11)
(rubble 12)
(sewer0 13)
(sewer1 14)
(sewer2 15)
(sewer-hum-kg 13)
(sewer-kg-met 14)
(sewer-met-hum 15)
(stadium 16)
(temple 17)
(bigmap-id-18 18)
(bigmap-id-19 19)
(bigmap-id-20 20)
(temple1 17)
(temple2 18)
(temple3 19)
(temple4 20)
(tower 21)
(volcano 22)
(wascity 23)
Expand Down Expand Up @@ -10742,16 +10742,55 @@
:flag-assert #x900000180
)

;; +++bigmap-h:bigmap-flag
(defenum bigmap-flag
:type uint32
:bitfield #t
(bf00 0)
(bf01 1)
(bf02 2)
(bf03 3)
(bf04 4)
(bf05 5)
(bf06 6)
(bf07 7)
(bf08 8)
(bf09 9)
(bf10 10)
(bf11 11)
(bf12 12)
(bf13 13)
(bf14 14)
(bf15 15)
(bf16 16)
(bf17 17)
(ctywide 18)
(waswide 19)
(wasall 20)
(desert 21)
(bf22 22)
(bf23 23)
(bf24 24)
(bf25 25)
(bf26 26)
(bf27 27)
(bf28 28)
(bf29 29)
(bf30 30)
(bf31 31)
)
;; ---bigmap-h:bigmap-flag

(deftype bigmap (basic)
((drawing-flag symbol :offset-assert 4) ;; guessed by decompiler
(loading-flag symbol :offset-assert 8) ;; guessed by decompiler
(bigmap-index uint32 :offset-assert 12)
(bigmap-index bigmap-id :offset-assert 12)
(bigmap-image external-art-buffer :offset-assert 16) ;; guessed by decompiler
(tpage external-art-buffer :offset-assert 20) ;; guessed by decompiler
(tpage2 basic :offset-assert 24)
(tpage2 external-art-buffer :offset-assert 24)
(progress-minimap texture-page :offset-assert 28) ;; guessed by decompiler
(progress-minimap2 texture-page :offset-assert 32)
(load-index uint32 :offset-assert 36)
(load-index bigmap-id :offset-assert 36)
(x0 int32 :offset-assert 40)
(y0 int32 :offset-assert 44)
(x1 int32 :offset-assert 48)
Expand All @@ -10766,29 +10805,29 @@
(scroll vector :inline :offset-assert 176)
(pos vector4w :inline :offset-assert 192)
(color vector4w :inline :offset-assert 208)
(corner vector 4 :inline :offset-assert 224) ;; guessed by decompiler
(corner vector 4 :inline :offset-assert 224) ;; guessed by decompiler
(auto-save-icon-flag symbol :offset-assert 288) ;; guessed by decompiler
(global-flags uint32 :offset-assert 292)
(global-flags bigmap-flag :offset-assert 292)
)
:method-count-assert 23
:size-assert #x128
:flag-assert #x1700000128
(:methods
(new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_)
(bigmap-method-9 () none) ;; 9 ;; (initialize (_type_) none)
(new (symbol type) _type_) ;; 0
(initialize (_type_) none) ;; 9
(update (_type_) none) ;; 10
(bigmap-method-11 (_type_) symbol) ;; 11
(bigmap-method-12 () none) ;; 12 ;; (handle-cpad-inputs (_type_) int)
(bigmap-method-13 () none) ;; 13 ;; (compress-all (_type_) int)
(loaded? (_type_) symbol) ;; 11
(draw! (_type_ int int int int) none) ;; 12 ;; (handle-cpad-inputs (_type_) int)
(handle-cpad-input (_type_) none) ;; 13 ;; (compress-all (_type_) int)
(enable-drawing (_type_) none) ;; 14
(disable-drawing (_type_) int) ;; 15
(bigmap-method-16 (_type_) none) ;; 16 ;; (dump-to-file (_type_) file-stream)
(bigmap-method-17 () none) ;; 17 ;; (set-pos! (_type_ vector) int)
(bigmap-method-18 () none) ;; 18 ;; (decompress-current-masks! (_type_) int)
(bigmap-method-19 () none) ;; 19 ;; (compress-current-masks! (_type_) int)
(bigmap-method-20 () none) ;; 20 ;; (set-enable-from-position! (_type_) int)
(bigmap-method-21 () none) ;; 21 ;; (maybe-fill-for-position (_type_ int int) int)
(bigmap-method-22 () none) ;; 22 ;; (texture-upload-dma (_type_ dma-buffer (pointer uint32) int int int gs-psm) none)
(set-map-indices! (_type_) none) ;; 16 ;; (dump-to-file (_type_) file-stream)
(set-pos! (_type_ vector) none) ;; 17
(bigmap-method-18 (_type_ (pointer int32)) none) ;; 18 ;; (decompress-current-masks! (_type_) int)
(texture-upload-dma (_type_ dma-buffer (pointer uint32) int int int gs-psm) none) ;; 19 ;; (compress-current-masks! (_type_) int)
(bigmap-method-20 (_type_ dma-buffer) symbol) ;; 20 ;; (set-enable-from-position! (_type_) int)
(sprite-dma (_type_ dma-buffer int int int int int int) object) ;; 21 ;; (maybe-fill-for-position (_type_ int int) int)
(draw-from-minimap (_type_ dma-buffer connection-minimap) none) ;; 22
)
)

Expand Down Expand Up @@ -11503,13 +11542,13 @@
(scan-tmpl dma-gif-packet :inline :offset-assert 192)
(color vector4w :inline :offset-assert 224)
(line-color uint64 :offset-assert 240)
(scan-colors vector4w 15 :inline :offset-assert 256) ;; guessed by decompiler
(scan-colors vector4w 15 :inline :offset-assert 256) ;; guessed by decompiler
(zoom-blur-pos vector :inline :offset-assert 496)
(zoom-blur-count int32 :offset-assert 512)
(zoom-blur-texels int32 :offset-assert 516)
(zoom-blur-alpha-target float :offset-assert 520)
(zoom-blur-alpha-current float :offset-assert 524)
(zoom-blur-2d basic :offset-assert 528)
(zoom-blur-2d symbol :offset-assert 528)
(menu-mode symbol :offset-assert 532) ;; guessed by decompiler
(screen-copied symbol :offset-assert 536) ;; guessed by decompiler
(vu1-enable-user-menu vu1-renderer-mask :offset-assert 544)
Expand All @@ -11527,18 +11566,18 @@
:size-assert #x24c
:flag-assert #x1b0000024c
(:methods
(blit-displays-work-method-9 () none) ;; 9
(blit-displays-work-method-10 () none) ;; 10
(blit-displays-work-method-11 () none) ;; 11
(blit-displays-work-method-12 () none) ;; 12
(blit-displays-work-method-13 () none) ;; 13
(blit-displays-work-method-14 () none) ;; 14
(blit-displays-work-method-15 () none) ;; 15
(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 (_type_) none) ;; 19 (called from main.gc)
(blit-displays-work-method-20 (_type_) none) ;; 20
(blit-displays-work-method-9 (_type_ dma-buffer int int int) none) ;; 9
(blit-displays-work-method-10 (_type_ dma-buffer int int int) none) ;; 10
(blit-displays-work-method-11 (_type_ dma-buffer int) none) ;; 11
(draw-letterbox (_type_ dma-buffer float int float) none) ;; 12
(blit-displays-work-method-13 (_type_ dma-buffer int int int) none) ;; 13
(blit-displays-work-method-14 (_type_ dma-buffer vector) none) ;; 14
(blit-displays-work-method-15 (_type_ dma-buffer) none) ;; 15
(draw-zoom-blur (_type_ dma-buffer int) none) ;; 16
(setup-zoom-blur-2d (_type_ vector int float symbol) none) ;; 17
(setup-brightness-and-contrast (_type_ dma-buffer float float) none) ;; 18
(do-blit-displays (_type_) none) ;; 19 (called from main.gc)
(draw-sky (_type_ dma-buffer) none) ;; 20
(get-menu-mode (_type_) symbol) ;; 21
(get-screen-copied (_type_) symbol) ;; 22
(get-horizontal-flip-flag (_type_) symbol) ;; 23
Expand Down Expand Up @@ -31082,7 +31121,7 @@

(define-extern *blit-displays-work* blit-displays-work)
(define-extern draw-color-bars (function blit-displays-work none))
(define-extern draw-raw-image (function bucket-id art-group int vector vector level int none))
(define-extern draw-raw-image (function blit-displays-work bucket-id art-group vector vector level int none))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; font-data ;;
Expand Down Expand Up @@ -39247,7 +39286,7 @@
;; bigmap ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; (define-extern *bigmap-info-array* object) ;; bigmap-info-array
(define-extern *bigmap-info-array* bigmap-info-array)
(define-extern *bigmap* bigmap)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
5 changes: 5 additions & 0 deletions decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -1000,5 +1000,10 @@
[12, "(function none :behavior scene-player)"],
[13, "(function none :behavior scene-player)"],
[14, "(function none :behavior scene-player)"]
],
"bigmap": [
[15, "(function external-art-buffer object)"],
[16, "(function external-art-buffer object)"],
[17, "(function external-art-buffer object)"]
]
}
16 changes: 13 additions & 3 deletions decompiler/config/jak3/ntsc_v1/inputs.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,17 @@
"DGO/PRECB.DGO",
"DGO/PRECC.DGO",
// "DGO/PRECD.DGO",
// // title/intro
// title/intro
"DGO/WIN.DGO", // wasintro
"DGO/TITLE.DGO",
"DGO/INTTITLE.DGO",
"DGO/INTPALRF.DGO", // intro-palace-roof
"DGO/IPF.DGO", // intro-palace-fall
"DGO/INTROCST.DGO",
// // outro
// outro
"DGO/OUTCAST3.DGO",
"DGO/OUTROCST.DGO",
// // museum
// museum
"DGO/MUSEUM.DGO",
"DGO/MUSEUM2.DGO",
"DGO/MUSEUM3.DGO",
Expand Down Expand Up @@ -311,6 +311,10 @@
"DGO/LWSTDPCK.DGO"
],

// STR files containing a texture that should be used by
// FR3 creation.
"str_texture_file_names": ["STR/PRMINIMA.STR"],

// some objects are part of STR files (streaming data).
"str_file_names": [],

Expand Down Expand Up @@ -343,6 +347,12 @@
"VAGWAD.INT"
],

// tpages that should always be possible to access.
"common_tpages": [
17, // PRMINIMA progress-minimap
3349 // PRMINIMA progress-minimap2
],

"animated_textures": [
// dark jak
"jakc-arm",
Expand Down
7 changes: 7 additions & 0 deletions decompiler/config/jak3/ntsc_v1/stack_structures.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2513,5 +2513,12 @@
[80, "matrix"],
[144, "matrix"],
[208, "matrix"]
],
"(method 12 bigmap)": [[32, "matrix"]],
"(method 22 bigmap)": [
[16, "vector4w"],
[32, "vector"],
[48, "vector"],
[64, "vector"]
]
}
78 changes: 76 additions & 2 deletions decompiler/config/jak3/ntsc_v1/type_casts.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -10857,7 +10857,6 @@
["_stack_", 76, "float"],
["_stack_", 100, "float"]
],
"real-wang-texture-anim-func": [[[3, 31], "v1", "mood-context"]],
"(method 24 sky-work)": [
[256, "s4", "(pointer int32)"],
[261, "s4", "(pointer int32)"]
Expand Down Expand Up @@ -11266,5 +11265,80 @@
[[191, 249], "gp", "shadow-dcache"],
[96, "v1", "shadow-dcache"]
],
"real-fog-texture-anim-func": [[[6, 160], "s2", "(pointer uint32)"]]
"real-fog-texture-anim-func": [[[6, 160], "s2", "(pointer uint32)"]],
"(method 22 bigmap)": [
[22, "s3", "process-drawable"],
[[46, 49], "v1", "entity-actor"],
[58, "a0", "process-drawable"],
[65, "a0", "entity-actor"],
[42, "v1", "entity-actor"],
[55, "s3", "process-drawable"],
[[201, 243], "a1", "(inline-array vector4w)"]
],
"(method 20 bigmap)": [
[[3, 95], "s4", "(pointer uint32)"],
[99, "a2", "(pointer uint32)"],
[54, "a2", "(pointer uint32)"]
],
"(method 12 bigmap)": [
[85, "v1", "(pointer uint32)"],
[100, "v1", "(pointer uint32)"],
[[142, 145], "s0", "(pointer uint128)"],
["_stack_", 96, "(inline-array vector4w)"]
],
"(method 21 bigmap)": [[[10, 38], "v1", "(inline-array vector4w)"]],
"(method 19 blit-displays-work)": [
[764, "v1", "float"],
[759, "v1", "float"],
[[935, 954], "a1", "(inline-array vector4w)"],
[[857, 875], "a1", "(inline-array vector4w)"],
[[844, 847], "a0", "dma-gif-packet"],
[[921, 924], "v1", "dma-gif-packet"]
],
"(method 9 blit-displays-work)": [[[2, 36], "v1", "(inline-array vector4w)"]],
"(method 10 blit-displays-work)": [
[[2, 141], "v1", "(inline-array vector4w)"]
],
"(method 11 blit-displays-work)": [
[[2, 30], "v1", "(inline-array vector4w)"]
],
"(method 12 blit-displays-work)": [
[[4, 41], "v1", "(inline-array vector4w)"],
[[60, 112], "v1", "(inline-array vector4w)"]
],
"(method 13 blit-displays-work)": [
[[41, 44], "v1", "(inline-array vector4w)"],
[[53, 71], "a0", "(inline-array vector4w)"]
],
"(method 18 blit-displays-work)": [
[[28, 33], "v1", "dma-gif-packet"],
[[174, 177], "v1", "dma-gif-packet"],
[[186, 202], "a0", "(inline-array vector4w)"]
],
"draw-raw-image": [[[104, 154], "v1", "(inline-array vector4w)"]],
"draw-color-bars": [
[[11, 16], "v1", "dma-gif-packet"],
[[28, 54], "v1", "(inline-array vector4w)"]
],
"(method 20 blit-displays-work)": [
[[57, 89], "a3", "(inline-array vector4w)"],
[[102, 134], "t1", "(inline-array vector4w)"],
[[176, 209], "t1", "(inline-array vector4w)"],
[[310, 338], "t2", "(inline-array vector4w)"],
[[385, 422], "v1", "(inline-array vector4w)"]
],
"(method 14 blit-displays-work)": [
[[88, 91], "v1", "dma-gif-packet"],
[[100, 120], "a0", "(inline-array vector4w)"]
],
"(method 16 blit-displays-work)": [
[[35, 79], "s2", "(inline-array vector4w)"],
[[134, 178], "s2", "(inline-array vector4w)"]
],
"(method 15 blit-displays-work)": [
[[60, 63], "v1", "dma-gif-packet"],
[[81, 99], "a0", "(inline-array vector4w)"],
[[165, 190], "a0", "(inline-array vector4w)"]
],
"(event idle progress)": [[[10, 80], "v1", "mc-status-code"]]
}
6 changes: 6 additions & 0 deletions decompiler/config/jak3/ntsc_v1/var_names.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2135,5 +2135,11 @@
"vars": {
"v0-0": ["type", "assault-target-type"]
}
},
"(method 22 bigmap)": {
"vars": {
"a2-1": ["a2-1", "uint"],
"a3-0": ["a3-0", "uint"]
}
}
}
Loading

0 comments on commit 7053090

Please sign in to comment.