mirror of
https://github.com/open-goal/jak-project
synced 2026-08-17 21:43:27 -04:00
[Decomp] Decompile more files. (#290)
* decompile ocean trans tables * more * exclude tables from decomp progress * format'
This commit is contained in:
@@ -344,9 +344,8 @@ void SimpleExpressionElement::update_from_stack_identity(const Env& env,
|
||||
env.file->words_by_seg, env.dts->ts);
|
||||
result->push_back(pool.alloc_element<DecompiledDataElement>(decompiled_data));
|
||||
} else {
|
||||
auto type = env.dts->parse_type_spec(kv->second.type_name);
|
||||
auto decompiled_data =
|
||||
decompile_at_label(type, lab, env.file->labels, env.file->words_by_seg, env.dts->ts);
|
||||
auto decompiled_data = decompile_at_label_with_hint(kv->second, lab, env.file->labels,
|
||||
env.file->words_by_seg, *env.dts);
|
||||
result->push_back(pool.alloc_element<DecompiledDataElement>(decompiled_data));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -406,7 +406,7 @@ void ObjectFileDB::ir2_build_expressions() {
|
||||
(void)segment_id;
|
||||
(void)data;
|
||||
total++;
|
||||
if (func.ir2.top_form && func.ir2.env.has_type_analysis()) {
|
||||
if (func.ir2.top_form && func.ir2.env.has_type_analysis() && func.ir2.env.has_local_vars()) {
|
||||
attempted++;
|
||||
if (convert_to_expressions(func.ir2.top_form, *func.ir2.form_pool, func, dts)) {
|
||||
successful++;
|
||||
|
||||
@@ -134,7 +134,11 @@ void set_config(const std::string& path_to_config_file) {
|
||||
const auto& name = x.at(0).get<std::string>();
|
||||
const auto& type_name = x.at(1).get<std::string>();
|
||||
bool is_const = x.at(2).get<bool>();
|
||||
gConfig.label_types[obj_name][name] = {type_name, is_const};
|
||||
auto& config_entry = gConfig.label_types[obj_name][name];
|
||||
config_entry = {type_name, is_const, {}};
|
||||
if (x.size() > 3) {
|
||||
config_entry.array_size = x.at(3).get<int>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-5
@@ -1,12 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef JAK2_DISASSEMBLER_CONFIG_H
|
||||
#define JAK2_DISASSEMBLER_CONFIG_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include <optional>
|
||||
#include "decompiler/Disasm/Register.h"
|
||||
|
||||
namespace decompiler {
|
||||
@@ -18,6 +16,7 @@ struct TypeHint {
|
||||
struct LabelType {
|
||||
std::string type_name;
|
||||
bool is_const = false;
|
||||
std::optional<int> array_size;
|
||||
};
|
||||
|
||||
struct Config {
|
||||
@@ -59,5 +58,3 @@ struct Config {
|
||||
Config& get_config();
|
||||
void set_config(const std::string& path_to_config_file);
|
||||
} // namespace decompiler
|
||||
|
||||
#endif // JAK2_DISASSEMBLER_CONFIG_H
|
||||
|
||||
+191
-165
@@ -66,6 +66,9 @@
|
||||
(define-extern dma-sync (function pointer int int int))
|
||||
(define-extern flush-cache (function int none))
|
||||
|
||||
(define-extern mc-run (function none))
|
||||
(define-extern mc-check-result (function int))
|
||||
|
||||
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;; GCOMMON ;;;;;;;;;;;;;;;;;;;
|
||||
@@ -5372,7 +5375,7 @@
|
||||
|
||||
;; sky-h
|
||||
(deftype sky-color-day (structure)
|
||||
((hour uint128 24 :offset-assert 0)
|
||||
((hour sky-color-hour 24 :inline :offset-assert 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x180
|
||||
@@ -5381,7 +5384,7 @@
|
||||
|
||||
;; sky-h
|
||||
(deftype sky-circle-data (structure)
|
||||
((data uint128 17 :offset-assert 0)
|
||||
((data vector 17 :inline :offset-assert 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x110
|
||||
@@ -5427,6 +5430,7 @@
|
||||
(min-halo float :offset-assert 16)
|
||||
(max-halo float :offset-assert 20)
|
||||
)
|
||||
:allow-misaligned
|
||||
:method-count-assert 9
|
||||
:size-assert #x18
|
||||
:flag-assert #x900000018
|
||||
@@ -5446,19 +5450,23 @@
|
||||
:flag-assert #x9000001c0
|
||||
)
|
||||
|
||||
; ;; sky-h
|
||||
; (deftype sky-parms (basic)
|
||||
; ((orbit UNKNOWN 3 :offset-assert 4)
|
||||
; (upload-data sky-upload-data :inline :offset-assert 116)
|
||||
; (sun-lights light-group :inline :offset-assert 560)
|
||||
; (moon-lights light-group :inline :offset-assert 752)
|
||||
; (default-lights light-group :inline :offset-assert 944)
|
||||
; (default-vu-lights vu-lights :inline :offset-assert 1136)
|
||||
; )
|
||||
; :method-count-assert 9
|
||||
; :size-assert #x4e0
|
||||
; :flag-assert #x9000004e0
|
||||
; )
|
||||
;; sky-h
|
||||
(deftype sky-parms (basic)
|
||||
;; check - the alignment on some of these.
|
||||
((orbit sky-orbit 3 :inline :offset-assert 4)
|
||||
(upload-data sky-upload-data :inline :offset-assert 112)
|
||||
(sun-lights light-group :inline :offset-assert 560)
|
||||
(moon-lights light-group :inline :offset-assert 752)
|
||||
(default-lights light-group :inline :offset-assert 944)
|
||||
(default-vu-lights vu-lights :inline :offset-assert 1136)
|
||||
)
|
||||
(:methods
|
||||
(new (symbol type) _type_ 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x4e0
|
||||
:flag-assert #x9000004e0
|
||||
)
|
||||
|
||||
;; sky-h
|
||||
(deftype sky-tng-data (basic)
|
||||
@@ -5517,14 +5525,14 @@
|
||||
:flag-assert #x900000030
|
||||
)
|
||||
|
||||
; ;; mood-h
|
||||
; (deftype mood-fog-table (structure)
|
||||
; ((data UNKNOWN 8 :offset-assert 0)
|
||||
; )
|
||||
; :method-count-assert 9
|
||||
; :size-assert #x180
|
||||
; :flag-assert #x900000180
|
||||
; )
|
||||
;; mood-h
|
||||
(deftype mood-fog-table (structure)
|
||||
((data mood-fog 8 :inline :offset-assert 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x180
|
||||
:flag-assert #x900000180
|
||||
)
|
||||
|
||||
;; mood-h
|
||||
(deftype mood-lights (structure)
|
||||
@@ -5539,14 +5547,14 @@
|
||||
:flag-assert #x900000050
|
||||
)
|
||||
|
||||
; ;; mood-h
|
||||
; (deftype mood-lights-table (structure)
|
||||
; ((data UNKNOWN 8 :offset-assert 0)
|
||||
; )
|
||||
; :method-count-assert 9
|
||||
; :size-assert #x280
|
||||
; :flag-assert #x900000280
|
||||
; )
|
||||
;; mood-h
|
||||
(deftype mood-lights-table (structure)
|
||||
((data mood-lights 8 :inline :offset-assert 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x280
|
||||
:flag-assert #x900000280
|
||||
)
|
||||
|
||||
;; mood-h
|
||||
(deftype mood-sun (structure)
|
||||
@@ -5558,39 +5566,42 @@
|
||||
:flag-assert #x900000020
|
||||
)
|
||||
|
||||
; ;; mood-h
|
||||
; (deftype mood-sun-table (structure)
|
||||
; ((data UNKNOWN 8 :offset-assert 0)
|
||||
; )
|
||||
; :method-count-assert 9
|
||||
; :size-assert #x100
|
||||
; :flag-assert #x900000100
|
||||
; )
|
||||
;; mood-h
|
||||
(deftype mood-sun-table (structure)
|
||||
((data mood-sun 8 :inline :offset-assert 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x100
|
||||
:flag-assert #x900000100
|
||||
)
|
||||
|
||||
; ;; mood-h
|
||||
; (deftype mood-context (basic)
|
||||
; ((mood-fog-table mood-fog-table :offset-assert 4)
|
||||
; (mood-lights-table mood-lights-table :offset-assert 8)
|
||||
; (mood-sun-table mood-sun-table :offset-assert 12)
|
||||
; (fog-interp sky-color-day :offset-assert 16)
|
||||
; (palette-interp sky-color-day :offset-assert 20)
|
||||
; (sky-texture-interp sky-color-day :offset-assert 24)
|
||||
; (current-fog mood-fog :inline :offset-assert 32)
|
||||
; (current-sun mood-sun :inline :offset-assert 80)
|
||||
; (current-prt-color vector :inline :offset-assert 112)
|
||||
; (current-shadow vector :inline :offset-assert 128)
|
||||
; (current-shadow-color vector :inline :offset-assert 144)
|
||||
; (light-group UNKNOWN 8 :offset-assert 160)
|
||||
; (times UNKNOWN 8 :offset-assert 1696)
|
||||
; (sky-times UNKNOWN 8 :offset-assert 1824)
|
||||
; (itimes UNKNOWN 4 :offset-assert 1856)
|
||||
; (state UNKNOWN 16 :offset-assert 1920)
|
||||
; (num-stars float :offset-assert 1936)
|
||||
; )
|
||||
; :method-count-assert 9
|
||||
; :size-assert #x794
|
||||
; :flag-assert #x900000794
|
||||
; )
|
||||
;; mood-h
|
||||
(deftype mood-context (basic)
|
||||
((mood-fog-table mood-fog-table :offset-assert 4)
|
||||
(mood-lights-table mood-lights-table :offset-assert 8)
|
||||
(mood-sun-table mood-sun-table :offset-assert 12)
|
||||
(fog-interp sky-color-day :offset-assert 16)
|
||||
(palette-interp sky-color-day :offset-assert 20)
|
||||
(sky-texture-interp sky-color-day :offset-assert 24)
|
||||
(current-fog mood-fog :inline :offset-assert 32)
|
||||
(current-sun mood-sun :inline :offset-assert 80)
|
||||
(current-prt-color vector :inline :offset-assert 112)
|
||||
(current-shadow vector :inline :offset-assert 128)
|
||||
(current-shadow-color vector :inline :offset-assert 144)
|
||||
;; (light-group UNKNOWN 8 :offset-assert 160)
|
||||
(times vector 8 :inline :offset 1696)
|
||||
(sky-times float 8 :offset-assert 1824)
|
||||
;; (itimes UNKNOWN 4 :offset-assert 1856)
|
||||
;; (state UNKNOWN 16 :offset-assert 1920)
|
||||
(num-stars float :offset 1936)
|
||||
)
|
||||
(:methods
|
||||
(new (symbol type) _type_ 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x794
|
||||
:flag-assert #x900000794
|
||||
)
|
||||
|
||||
;; time-of-day-h
|
||||
(deftype palette-fade-control (structure)
|
||||
@@ -5603,18 +5614,18 @@
|
||||
:flag-assert #x900000018
|
||||
)
|
||||
|
||||
; ;; time-of-day-h
|
||||
; (deftype palette-fade-controls (basic)
|
||||
; ((control UNKNOWN 8 :offset-assert 16)
|
||||
; )
|
||||
; :method-count-assert 11
|
||||
; :size-assert #x110
|
||||
; :flag-assert #xb00000110
|
||||
; (:methods
|
||||
; (dummy-9 () none 9)
|
||||
; (dummy-10 () none 10)
|
||||
; )
|
||||
; )
|
||||
;; time-of-day-h
|
||||
(deftype palette-fade-controls (basic)
|
||||
((control palette-fade-control 8 :inline :offset-assert 16)
|
||||
)
|
||||
:method-count-assert 11
|
||||
:size-assert #x110
|
||||
:flag-assert #xb00000110
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
)
|
||||
)
|
||||
|
||||
;; time-of-day-h
|
||||
(deftype time-of-day-proc (process)
|
||||
@@ -5919,29 +5930,29 @@
|
||||
; )
|
||||
; )
|
||||
|
||||
; ;; generic-vu1-h
|
||||
; (deftype pris-mtx (structure)
|
||||
; ((data UNKNOWN 32 :offset-assert 0)
|
||||
; (vector UNKNOWN 8 :offset-assert 0)
|
||||
; (t-mtx matrix :inline :offset-assert 0)
|
||||
; (n-mtx matrix3 :inline :offset-assert 64)
|
||||
; (scale vector :inline :offset-assert 112)
|
||||
; )
|
||||
; :method-count-assert 9
|
||||
; :size-assert #x80
|
||||
; :flag-assert #x900000080
|
||||
; )
|
||||
;; generic-vu1-h
|
||||
(deftype pris-mtx (structure)
|
||||
((data float 32 :offset 0)
|
||||
(vector vector 8 :inline :offset 0)
|
||||
(t-mtx matrix :inline :offset 0)
|
||||
(n-mtx matrix3 :inline :offset 64)
|
||||
(scale vector :inline :offset 112)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x80
|
||||
:flag-assert #x900000080
|
||||
)
|
||||
|
||||
; ;; generic-vu1-h
|
||||
; (deftype generic-pris-mtx-save (structure)
|
||||
; ((loc-mtx pris-mtx :inline :offset-assert 0)
|
||||
; (par-mtx pris-mtx :inline :offset-assert 128)
|
||||
; (dif-mtx pris-mtx :inline :offset-assert 256)
|
||||
; )
|
||||
; :method-count-assert 9
|
||||
; :size-assert #x180
|
||||
; :flag-assert #x900000180
|
||||
; )
|
||||
;; generic-vu1-h
|
||||
(deftype generic-pris-mtx-save (structure)
|
||||
((loc-mtx pris-mtx :inline :offset-assert 0)
|
||||
(par-mtx pris-mtx :inline :offset-assert 128)
|
||||
(dif-mtx pris-mtx :inline :offset-assert 256)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x180
|
||||
:flag-assert #x900000180
|
||||
)
|
||||
|
||||
;; generic-vu1-h
|
||||
(deftype generic-constants (structure)
|
||||
@@ -6322,6 +6333,9 @@
|
||||
(send-query basic :offset-assert 32)
|
||||
(query basic :offset-assert 36)
|
||||
)
|
||||
(:methods
|
||||
(new (symbol type) _type_ 0)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x28
|
||||
:flag-assert #x900000028
|
||||
@@ -6369,20 +6383,20 @@
|
||||
:flag-assert #x9000001a0
|
||||
)
|
||||
|
||||
;; generic-merc-h
|
||||
; (deftype generic-merc-input (structure)
|
||||
; ((geo-tag generic-merc-tag :inline :offset-assert 0)
|
||||
; (geo-block UNKNOWN 1296 :offset-assert 16)
|
||||
; (byte-header merc-byte-header :inline :offset-assert 16)
|
||||
; (matrix UNKNOWN 9 :offset-assert 1312)
|
||||
; (control generic-merc-ctrl-with-sfx :inline :offset-assert 2464)
|
||||
; (end-tag generic-merc-tag :inline :offset-assert 2880)
|
||||
; (shader adgif-shader :inline :offset-assert 2896)
|
||||
; )
|
||||
; :method-count-assert 9
|
||||
; :size-assert #xba0
|
||||
; :flag-assert #x900000ba0
|
||||
; )
|
||||
; generic-merc-h
|
||||
(deftype generic-merc-input (structure)
|
||||
((geo-tag generic-merc-tag :inline :offset-assert 0)
|
||||
(geo-block uint8 1296 :offset-assert 16)
|
||||
(byte-header merc-byte-header :inline :offset 16)
|
||||
(matrix merc-matrix 9 :inline :offset-assert 1312)
|
||||
(control generic-merc-ctrl-with-sfx :inline :offset-assert 2464)
|
||||
(end-tag generic-merc-tag :inline :offset-assert 2880)
|
||||
(shader adgif-shader :inline :offset-assert 2896)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #xba0
|
||||
:flag-assert #x900000ba0
|
||||
)
|
||||
|
||||
; ;; generic-merc-h
|
||||
; (deftype generic-merc-output (structure)
|
||||
@@ -6819,10 +6833,11 @@
|
||||
:size-assert #x60
|
||||
:flag-assert #x1000000060
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
(new (symbol type float float float float float) _type_ 0)
|
||||
(clear-offset-bit (shadow-control) none 9)
|
||||
(set-offset-bit (shadow-control) none 10)
|
||||
(set-top-plane-offset (shadow-control float) none 11)
|
||||
(set-bottom-plane-offset (shadow-control float) none 12)
|
||||
(dummy-13 () none 13)
|
||||
(dummy-14 () none 14)
|
||||
(dummy-15 () none 15)
|
||||
@@ -6863,21 +6878,32 @@
|
||||
((first uint32 :offset-assert 0)
|
||||
(next uint32 :offset-assert 4)
|
||||
)
|
||||
:allow-misaligned
|
||||
:method-count-assert 9
|
||||
:size-assert #x8
|
||||
:flag-assert #x900000008
|
||||
)
|
||||
|
||||
;; shadow-cpu-h
|
||||
; (deftype shadow-queue (structure)
|
||||
; ((num-runs uint32 :offset-assert 0)
|
||||
; (cur-run uint32 :offset-assert 4)
|
||||
; (run UNKNOWN 15 :offset-assert 8)
|
||||
; )
|
||||
; :method-count-assert 9
|
||||
; :size-assert #xf8
|
||||
; :flag-assert #x9000000f8
|
||||
; )
|
||||
; shadow-cpu-h
|
||||
(deftype shadow-queue (structure)
|
||||
((num-runs uint32 :offset-assert 0)
|
||||
(cur-run uint32 :offset-assert 4)
|
||||
(run shadow-run 15 :inline :offset-assert 8)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #xf8
|
||||
:flag-assert #x9000000f8
|
||||
)
|
||||
|
||||
(define-extern shadow-queue-append (function shadow-queue uint))
|
||||
;;(define-extern shadow-work object) ;; unknown type
|
||||
;;(define-extern shadow-queue object) ;; unknown type
|
||||
;;(define-extern *shadow-queue* object) ;; unknown type
|
||||
;;(define-extern *shadow* object) ;; unknown type
|
||||
;;(define-extern shadow-settings object) ;; unknown type
|
||||
;;(define-extern *shadow-object* object) ;; unknown type
|
||||
(define-extern shadow-queue-reset (function shadow-queue int))
|
||||
|
||||
|
||||
;; shadow-cpu-h
|
||||
(deftype shadow-vertex (structure)
|
||||
@@ -7016,6 +7042,9 @@
|
||||
:flag-assert #x90000012c
|
||||
)
|
||||
|
||||
(define-extern show-mc-info (function none))
|
||||
(define-extern mc-sync (function int))
|
||||
|
||||
;; game-info-h
|
||||
(deftype game-bank (basic)
|
||||
((life-max-default float :offset-assert 4)
|
||||
@@ -7046,7 +7075,7 @@
|
||||
(deftype load-state (basic)
|
||||
((want level-buffer-state 2 :inline :offset-assert 4)
|
||||
(vis-nick basic :offset-assert 36)
|
||||
(command-list basic :offset-assert 40)
|
||||
(command-list pair :offset-assert 40)
|
||||
(object-name basic 256 :offset-assert 44)
|
||||
(object-status basic 256 :offset-assert 1068)
|
||||
)
|
||||
@@ -7054,7 +7083,8 @@
|
||||
:size-assert #x82c
|
||||
:flag-assert #x150000082c
|
||||
(:methods
|
||||
(dummy-9 () none 9)
|
||||
(new (symbol type) _type_ 0)
|
||||
(reset! (_type_) _type_ 9)
|
||||
(dummy-10 () none 10)
|
||||
(dummy-11 () none 11)
|
||||
(dummy-12 () none 12)
|
||||
@@ -7182,18 +7212,18 @@
|
||||
:flag-assert #x900000010
|
||||
)
|
||||
|
||||
; ;; wind-h
|
||||
; (deftype wind-work (basic)
|
||||
; ((wind-array UNKNOWN 64 :offset-assert 16)
|
||||
; (wind-normal vector :inline :offset-assert 1040)
|
||||
; (wind-temp vector :inline :offset-assert 1056)
|
||||
; (wind-force UNKNOWN 64 :offset-assert 1072)
|
||||
; (wind-time uint32 :offset-assert 1328)
|
||||
; )
|
||||
; :method-count-assert 9
|
||||
; :size-assert #x534
|
||||
; :flag-assert #x900000534
|
||||
; )
|
||||
;; wind-h
|
||||
(deftype wind-work (basic)
|
||||
((wind-array vector 64 :inline :offset-assert 16)
|
||||
(wind-normal vector :inline :offset-assert 1040)
|
||||
(wind-temp vector :inline :offset-assert 1056)
|
||||
(wind-force float 64 :offset-assert 1072)
|
||||
(wind-time uint32 :offset-assert 1328)
|
||||
)
|
||||
:method-count-assert 9
|
||||
:size-assert #x534
|
||||
:flag-assert #x900000534
|
||||
)
|
||||
|
||||
; ;; prototype-h
|
||||
; (deftype prototype-bucket (basic)
|
||||
@@ -7582,11 +7612,17 @@
|
||||
)
|
||||
|
||||
;; res-h
|
||||
|
||||
(deftype res-tag (uint128)
|
||||
()
|
||||
:flag-assert #x900000010
|
||||
)
|
||||
|
||||
(deftype res-lump (basic)
|
||||
((length int32 :offset-assert 4)
|
||||
(allocated-length int32 :offset-assert 8)
|
||||
(data-base uint32 :offset-assert 12)
|
||||
(data-top uint32 :offset-assert 16)
|
||||
(data-base pointer :offset-assert 12)
|
||||
(data-top pointer :offset-assert 16)
|
||||
(data-size int32 :offset-assert 20)
|
||||
(extra basic :offset-assert 24)
|
||||
(tag uint32 :offset-assert 28)
|
||||
@@ -32987,7 +33023,7 @@
|
||||
;;(define-extern *ocean-mid-indices-village2* object) ;; unknown type
|
||||
;;(define-extern *ocean-mid-masks-sunken* object) ;; unknown type
|
||||
;;(define-extern *ocean-map-village1* object) ;; unknown type
|
||||
;;(define-extern *ocean-spheres-village1* object) ;; unknown type
|
||||
(define-extern *ocean-spheres-village1* (inline-array sphere)) ;; unknown type
|
||||
;;(define-extern *ocean-wave-frames* object) ;; unknown type
|
||||
;;(define-extern sky-color-hour object) ;; unknown type
|
||||
;;(define-extern sky-circle-data object) ;; unknown type
|
||||
@@ -33001,7 +33037,7 @@
|
||||
;;(define-extern sky-upload-data object) ;; unknown type
|
||||
;;(define-extern *sky-parms* object) ;; unknown type
|
||||
;;(define-extern sky-moon-data object) ;; unknown type
|
||||
;;(define-extern *sky-upload-data* object) ;; unknown type
|
||||
(define-extern *sky-upload-data* sky-upload-data) ;; unknown type
|
||||
;;(define-extern sky-work object) ;; unknown type
|
||||
;;(define-extern sky-parms object) ;; unknown type
|
||||
;;(define-extern mood-fog object) ;; unknown type
|
||||
@@ -33017,7 +33053,7 @@
|
||||
;;(define-extern *time-of-day-mode* object) ;; unknown type
|
||||
;;(define-extern time-of-day-dma object) ;; unknown type
|
||||
;;(define-extern palette-fade-controls object) ;; unknown type
|
||||
;;(define-extern *palette-fade-controls* object) ;; unknown type
|
||||
(define-extern *palette-fade-controls* palette-fade-controls) ;; unknown type
|
||||
(define-extern time-of-day-palette type)
|
||||
;;(define-extern time-of-day-proc object) ;; unknown type
|
||||
(define-extern skeleton-group type)
|
||||
@@ -33057,7 +33093,7 @@
|
||||
;;(define-extern merc-effect object) ;; unknown type
|
||||
;;(define-extern ripple-wave object) ;; unknown type
|
||||
;;(define-extern merc-mat-dest object) ;; unknown type
|
||||
(define-extern merc-fragment-fp-data function)
|
||||
(define-extern merc-fragment-fp-data (function merc-fragment pointer))
|
||||
(define-extern ripple-wave-set type)
|
||||
;;(define-extern merc-fragment object) ;; unknown type
|
||||
;;(define-extern merc-vtx object) ;; unknown type
|
||||
@@ -33101,14 +33137,7 @@
|
||||
;;(define-extern generic-effect-buffer object) ;; unknown type
|
||||
;;(define-extern generic-vu1-texbuf object) ;; unknown type
|
||||
;;(define-extern *generic-debug* object) ;; unknown type
|
||||
(define-extern shadow-queue-append function)
|
||||
;;(define-extern shadow-work object) ;; unknown type
|
||||
;;(define-extern shadow-queue object) ;; unknown type
|
||||
;;(define-extern *shadow-queue* object) ;; unknown type
|
||||
;;(define-extern *shadow* object) ;; unknown type
|
||||
;;(define-extern shadow-settings object) ;; unknown type
|
||||
;;(define-extern *shadow-object* object) ;; unknown type
|
||||
(define-extern shadow-queue-reset function)
|
||||
|
||||
;;(define-extern shadow-matrix-ref object) ;; unknown type
|
||||
;;(define-extern *shadow-debug* object) ;; unknown type
|
||||
(define-extern shadow-geo type)
|
||||
@@ -33120,10 +33149,7 @@
|
||||
;;(define-extern shadow-edge object) ;; unknown type
|
||||
(define-extern shadow-control type)
|
||||
;;(define-extern mc-file-info object) ;; unknown type
|
||||
(define-extern show-mc-info function)
|
||||
;;(define-extern mc-handle object) ;; unknown type
|
||||
;;(define-extern mc-slot-info object) ;; unknown type
|
||||
(define-extern mc-sync function)
|
||||
|
||||
;;(define-extern mc-run object) ;; unknown type
|
||||
;;(define-extern mc-get-slot-info object) ;; unknown type
|
||||
;;(define-extern mc-check-result object) ;; unknown type
|
||||
@@ -33136,10 +33162,10 @@
|
||||
;;(define-extern actor-id object) ;; unknown type
|
||||
;;(define-extern *GAME-bank* object) ;; unknown type
|
||||
;;(define-extern wind-work object) ;; unknown type
|
||||
(define-extern wind-get-hashed-index function)
|
||||
(define-extern wind-get-hashed-index (function vector int))
|
||||
;;(define-extern *wind-scales* object) ;; unknown type
|
||||
;;(define-extern wind-vector object) ;; unknown type
|
||||
;;(define-extern *wind-work* object) ;; unknown type
|
||||
(define-extern *wind-work* wind-work) ;; unknown type
|
||||
(define-extern prototype-bucket-shrub type)
|
||||
(define-extern prototype-bucket-tie type)
|
||||
;;(define-extern instance object) ;; unknown type
|
||||
@@ -33164,7 +33190,7 @@
|
||||
;;(define-extern bone-buffer object) ;; unknown type
|
||||
;;(define-extern merc-global-array object) ;; unknown type
|
||||
;;(define-extern *merc-globals* object) ;; unknown type
|
||||
;;(define-extern *matrix-engine* object) ;; unknown type
|
||||
(define-extern *matrix-engine* (array handle)) ;; unknown type
|
||||
;;(define-extern camera-eng object) ;; unknown type
|
||||
;;(define-extern *camera-engine* object) ;; unknown type
|
||||
;;(define-extern *background-draw-engine* object) ;; unknown type
|
||||
@@ -33193,8 +33219,8 @@
|
||||
(define-extern light-group-process! function)
|
||||
;;(define-extern *default-lights* object) ;; unknown type
|
||||
(define-extern vu-lights<-light-group! function)
|
||||
(define-extern time-to-apex function)
|
||||
(define-extern time-to-ground function)
|
||||
(define-extern time-to-apex (function float float int))
|
||||
(define-extern time-to-ground (function float float float int))
|
||||
;;(define-extern *standard-dynamics* object) ;; unknown type
|
||||
(define-extern dynamics type)
|
||||
;;(define-extern standard object) ;; unknown type
|
||||
@@ -33208,7 +33234,7 @@
|
||||
;;(define-extern *smack-jump-mods* object) ;; unknown type
|
||||
;;(define-extern *dive-mods* object) ;; unknown type
|
||||
;;(define-extern *swim-surface* object) ;; unknown type
|
||||
(define-extern calc-terminal2-vel function)
|
||||
(define-extern calc-terminal2-vel (function float float float float float))
|
||||
;;(define-extern *wade-surface* object) ;; unknown type
|
||||
;;(define-extern *jump-mods* object) ;; unknown type
|
||||
;;(define-extern *turn-around-mods* object) ;; unknown type
|
||||
@@ -33226,11 +33252,11 @@
|
||||
;;(define-extern *run-attack-mods* object) ;; unknown type
|
||||
;;(define-extern *quicksand-surface* object) ;; unknown type
|
||||
;;(define-extern *walk-no-turn-mods* object) ;; unknown type
|
||||
(define-extern calc-terminal-vel function)
|
||||
(define-extern calc-terminal-vel (function float float float float))
|
||||
;;(define-extern *duck-mods* object) ;; unknown type
|
||||
;;(define-extern *duck-attack-mods* object) ;; unknown type
|
||||
;;(define-extern *slope-surface* object) ;; unknown type
|
||||
(define-extern calc-terminal4-vel function)
|
||||
(define-extern calc-terminal4-vel (function float float float float))
|
||||
;;(define-extern *edge-grab-mods* object) ;; unknown type
|
||||
;;(define-extern *standard-ground-surface* object) ;; unknown type
|
||||
;;(define-extern *flop-land-mods* object) ;; unknown type
|
||||
|
||||
@@ -142,6 +142,80 @@
|
||||
],
|
||||
|
||||
"text-h":[
|
||||
["L2", "_auto_", true]]
|
||||
["L2", "_auto_", true]],
|
||||
|
||||
"ocean-trans-tables":[
|
||||
["L1", "(pointer float)", true, 16],
|
||||
["L2", "(pointer float)", true, 160],
|
||||
["L3", "(pointer float)", true, 100],
|
||||
["L4", "(pointer float)", true, 72],
|
||||
["L5", "(pointer float)", true, 72],
|
||||
["L6", "(pointer float)", true, 72],
|
||||
["L7", "(pointer float)", true, 72],
|
||||
["L8", "(pointer float)", true, 44],
|
||||
["L9", "(pointer float)", true, 44],
|
||||
["L10", "(pointer float)", true, 44],
|
||||
["L11", "(pointer float)", true, 44],
|
||||
["L12", "(pointer float)", true, 40],
|
||||
["L13", "(pointer float)", true, 40],
|
||||
["L14", "(pointer float)", true, 40],
|
||||
["L15", "(pointer float)", true, 40],
|
||||
["L16", "(pointer float)", true, 28],
|
||||
["L17", "(pointer float)", true, 28],
|
||||
["L18", "(pointer float)", true, 28],
|
||||
["L19", "(pointer float)", true, 28]
|
||||
],
|
||||
|
||||
"ocean-tables":[
|
||||
["L26", "(inline-array sphere)", true, 36],
|
||||
["L25", "(pointer uint32)", true, 2548]
|
||||
],
|
||||
|
||||
"ocean-frames":[
|
||||
["L1", "(pointer uint32)", true, 16384]
|
||||
],
|
||||
|
||||
"sky-h":[
|
||||
["L73", "float", true],
|
||||
["L71", "float", true],
|
||||
["L72", "float", true]
|
||||
],
|
||||
|
||||
"mood-h":[
|
||||
["L3", "float", true]
|
||||
],
|
||||
|
||||
"merc-h":[
|
||||
["L4", "float", true],
|
||||
["L5", "float", true],
|
||||
["L6", "float", true],
|
||||
["L7", "float", true]
|
||||
],
|
||||
|
||||
"shadow-cpu-h":[
|
||||
["L9", "float", true],
|
||||
["L10", "float", true]
|
||||
],
|
||||
|
||||
"game-info-h":[
|
||||
["L4", "game-bank", true],
|
||||
["L3", "game-info", true]
|
||||
],
|
||||
|
||||
"wind-h":[
|
||||
["L3", "_auto_", true]
|
||||
],
|
||||
|
||||
"dynamics-h":[
|
||||
["L7", "float", true],
|
||||
["L6", "_auto_", true]
|
||||
],
|
||||
|
||||
"surface-h":[
|
||||
["L72", "float", true],
|
||||
["L71", "float", true]
|
||||
]
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -6,6 +6,74 @@
|
||||
|
||||
namespace decompiler {
|
||||
|
||||
/*!
|
||||
* Entry point from the decompiler to decompile data.
|
||||
*/
|
||||
goos::Object decompile_at_label_with_hint(const LabelType& hint,
|
||||
const DecompilerLabel& label,
|
||||
const std::vector<DecompilerLabel>& labels,
|
||||
const std::vector<std::vector<LinkedWord>>& words,
|
||||
DecompilerTypeSystem& dts) {
|
||||
auto type = dts.parse_type_spec(hint.type_name);
|
||||
if (!hint.array_size.has_value()) {
|
||||
// if we don't have an array size, treat it as just a normal type.
|
||||
return decompile_at_label(type, label, labels, words, dts.ts);
|
||||
}
|
||||
|
||||
if (type.base_type() == "pointer") {
|
||||
auto field_type_info = dts.ts.lookup_type(type.get_single_arg());
|
||||
if (field_type_info->is_reference()) {
|
||||
throw std::runtime_error(
|
||||
fmt::format("Type {} is not yet supported by the data decompiler.", hint.type_name));
|
||||
} else {
|
||||
auto stride = field_type_info->get_size_in_memory();
|
||||
|
||||
int word_count = ((stride * (*hint.array_size)) + 3) / 4;
|
||||
std::vector<LinkedWord> obj_words;
|
||||
obj_words.insert(obj_words.begin(),
|
||||
words.at(label.target_segment).begin() + (label.offset / 4),
|
||||
words.at(label.target_segment).begin() + (label.offset / 4) + word_count);
|
||||
|
||||
return decompile_value_array(type.get_single_arg(), field_type_info, *hint.array_size, stride,
|
||||
0, obj_words, dts.ts);
|
||||
}
|
||||
}
|
||||
|
||||
if (type.base_type() == "inline-array") {
|
||||
auto field_type_info = dts.ts.lookup_type(type.get_single_arg());
|
||||
if (!field_type_info->is_reference()) {
|
||||
throw std::runtime_error(
|
||||
fmt::format("Type {} is invalid, the element type is not inlineable.", hint.type_name));
|
||||
} else {
|
||||
// it's an inline array. let's figure out the len and stride
|
||||
auto len = *hint.array_size;
|
||||
// TODO - having this logic here isn't great.
|
||||
auto stride = align(field_type_info->get_size_in_memory(),
|
||||
field_type_info->get_inline_array_stride_alignment());
|
||||
|
||||
if (dynamic_cast<BasicType*>(field_type_info)) {
|
||||
throw std::runtime_error("Plan basic arrays not supported yet");
|
||||
// I just want to double check offsets....
|
||||
}
|
||||
|
||||
std::vector<goos::Object> array_def = {pretty_print::to_symbol(fmt::format(
|
||||
"new 'static 'inline-array '{} {}", type.get_single_arg().print(), *hint.array_size))};
|
||||
for (int elt = 0; elt < len; elt++) {
|
||||
DecompilerLabel fake_label;
|
||||
fake_label.target_segment = label.target_segment;
|
||||
fake_label.offset = label.offset + field_type_info->get_offset() + stride * elt;
|
||||
fake_label.name = fmt::format("fake-label-{}-elt-{}", type.get_single_arg().print(), elt);
|
||||
array_def.push_back(
|
||||
decompile_at_label(type.get_single_arg(), fake_label, labels, words, dts.ts));
|
||||
}
|
||||
return pretty_print::build_list(array_def);
|
||||
}
|
||||
}
|
||||
|
||||
throw std::runtime_error(
|
||||
fmt::format("Type {} is not yet supported by the data decompiler.", hint.type_name));
|
||||
}
|
||||
|
||||
/*!
|
||||
* Attempt to determine the type of this label. This does not make sure that the type system
|
||||
* actually knows about the type. If the thing is not a basic or pair, it will fail.
|
||||
@@ -140,6 +208,33 @@ goos::Object decompile_string_at_label(const DecompilerLabel& label,
|
||||
return goos::StringObject::make_new(result);
|
||||
}
|
||||
|
||||
goos::Object decompile_value_array(const TypeSpec& elt_type,
|
||||
const Type* elt_type_info,
|
||||
int length,
|
||||
int stride,
|
||||
int offset,
|
||||
const std::vector<LinkedWord>& obj_words,
|
||||
const TypeSystem& ts) {
|
||||
std::vector<goos::Object> array_def = {
|
||||
pretty_print::to_symbol(fmt::format("new 'static 'array '{} {}", elt_type.print(), length))};
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
auto start = offset + stride * i;
|
||||
auto end = start + elt_type_info->get_size_in_memory();
|
||||
std::vector<u8> elt_bytes;
|
||||
for (int j = start; j < end; j++) {
|
||||
auto& word = obj_words.at(j / 4);
|
||||
if (word.kind != LinkedWord::PLAIN_DATA) {
|
||||
throw std::runtime_error("Got bad word in kind in array of values");
|
||||
}
|
||||
elt_bytes.push_back(word.get_byte(j % 4));
|
||||
}
|
||||
array_def.push_back(decompile_value(elt_type, elt_bytes, ts));
|
||||
}
|
||||
|
||||
return pretty_print::build_list(array_def);
|
||||
}
|
||||
|
||||
goos::Object decompile_structure(const TypeSpec& type,
|
||||
const DecompilerLabel& label,
|
||||
const std::vector<DecompilerLabel>& labels,
|
||||
@@ -289,24 +384,9 @@ goos::Object decompile_structure(const TypeSpec& type,
|
||||
auto stride = ts.get_size_in_type(field) / len;
|
||||
assert(stride == field_type_info->get_size_in_memory());
|
||||
|
||||
std::vector<goos::Object> array_def = {pretty_print::to_symbol(
|
||||
fmt::format("new 'static 'array '{} {}", field.type().print(), field.array_size()))};
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
auto start = field_start + stride * i;
|
||||
auto end = start + field_type_info->get_size_in_memory();
|
||||
std::vector<u8> elt_bytes;
|
||||
for (int j = start; j < end; j++) {
|
||||
auto& word = obj_words.at(j / 4);
|
||||
if (word.kind != LinkedWord::PLAIN_DATA) {
|
||||
throw std::runtime_error("Got bad word in kind in array of values");
|
||||
}
|
||||
elt_bytes.push_back(word.get_byte(j % 4));
|
||||
}
|
||||
array_def.push_back(decompile_value(field.type(), elt_bytes, ts));
|
||||
}
|
||||
|
||||
field_defs_out.emplace_back(field.name(), pretty_print::build_list(array_def));
|
||||
field_defs_out.emplace_back(
|
||||
field.name(), decompile_value_array(field.type(), field_type_info, len, stride,
|
||||
field_start, obj_words, ts));
|
||||
} else if (field.is_dynamic()) {
|
||||
throw std::runtime_error(
|
||||
fmt::format("Dynamic value field {} in static data type {} not yet implemented",
|
||||
@@ -476,9 +556,12 @@ goos::Object decompile_value(const TypeSpec& type,
|
||||
float value;
|
||||
memcpy(&value, bytes.data(), 4);
|
||||
return pretty_print::float_representation(value);
|
||||
}
|
||||
|
||||
else {
|
||||
} else if (ts.typecheck(TypeSpec("uint8"), type, "", false, false)) {
|
||||
assert(bytes.size() == 1);
|
||||
u8 value;
|
||||
memcpy(&value, bytes.data(), 1);
|
||||
return pretty_print::to_symbol(fmt::format("#x{:x}", value));
|
||||
} else {
|
||||
throw std::runtime_error(fmt::format("decompile_value failed on a {}", type.print()));
|
||||
}
|
||||
}
|
||||
@@ -547,8 +630,27 @@ goos::Object decompile_boxed_array(const DecompilerLabel& label,
|
||||
|
||||
return pretty_print::build_list(result);
|
||||
} else {
|
||||
// value type.
|
||||
throw std::runtime_error("boxed value type array decompile not yet implemented.");
|
||||
// value array
|
||||
std::vector<goos::Object> result = {
|
||||
pretty_print::to_symbol("new"), pretty_print::to_symbol("'static"),
|
||||
pretty_print::to_symbol("'boxed-array"), pretty_print::to_symbol(content_type.print()),
|
||||
pretty_print::to_symbol(fmt::format("{}", array_length))};
|
||||
|
||||
auto stride = content_type_info->get_size_in_memory();
|
||||
for (int i = 0; i < array_length; i++) {
|
||||
auto start = first_elt_word_idx * 4 + stride * i;
|
||||
auto end = start + content_type_info->get_size_in_memory();
|
||||
std::vector<u8> elt_bytes;
|
||||
for (int j = start; j < end; j++) {
|
||||
auto& word = words.at(label.target_segment).at(j / 4);
|
||||
if (word.kind != LinkedWord::PLAIN_DATA) {
|
||||
throw std::runtime_error("Got bad word in kind in array of values");
|
||||
}
|
||||
elt_bytes.push_back(word.get_byte(j % 4));
|
||||
}
|
||||
result.push_back(decompile_value(content_type, elt_bytes, ts));
|
||||
}
|
||||
return pretty_print::build_list(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "decompiler/ObjectFile/LinkedWord.h"
|
||||
#include "common/type_system/TypeSpec.h"
|
||||
#include "common/type_system/TypeSystem.h"
|
||||
#include "decompiler/config.h"
|
||||
#include "decompiler/util/DecompilerTypeSystem.h"
|
||||
|
||||
namespace decompiler {
|
||||
std::optional<TypeSpec> get_type_of_label(const DecompilerLabel& label,
|
||||
@@ -18,6 +20,11 @@ goos::Object decompile_at_label(const TypeSpec& type,
|
||||
const std::vector<DecompilerLabel>& labels,
|
||||
const std::vector<std::vector<LinkedWord>>& words,
|
||||
const TypeSystem& ts);
|
||||
goos::Object decompile_at_label_with_hint(const LabelType& hint,
|
||||
const DecompilerLabel& label,
|
||||
const std::vector<DecompilerLabel>& labels,
|
||||
const std::vector<std::vector<LinkedWord>>& words,
|
||||
DecompilerTypeSystem& dts);
|
||||
goos::Object decompile_at_label_guess_type(const DecompilerLabel& label,
|
||||
const std::vector<DecompilerLabel>& labels,
|
||||
const std::vector<std::vector<LinkedWord>>& words,
|
||||
@@ -38,4 +45,11 @@ goos::Object decompile_boxed_array(const DecompilerLabel& label,
|
||||
goos::Object decompile_value(const TypeSpec& type,
|
||||
const std::vector<u8>& bytes,
|
||||
const TypeSystem& ts);
|
||||
goos::Object decompile_value_array(const TypeSpec& elt_type,
|
||||
const Type* elt_type_info,
|
||||
int length,
|
||||
int stride,
|
||||
int offset,
|
||||
const std::vector<LinkedWord>& obj_words,
|
||||
const TypeSystem& ts);
|
||||
} // namespace decompiler
|
||||
|
||||
Reference in New Issue
Block a user