[Decomp] Decompile more files. (#290)

* decompile ocean trans tables

* more

* exclude tables from decomp progress

* format'
This commit is contained in:
water111 2021-02-27 14:40:18 -05:00 committed by GitHub
parent 049489c85b
commit 57eca1dee9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 19469 additions and 381 deletions

View file

@ -14,6 +14,12 @@
namespace pretty_print {
namespace {
const std::unordered_set<float> allowed_floats = {
0.0, 0.0625, 0.125, 0.1875, 0.25, 0.3125, 0.375, 0.4375, 0.5, 0.5625, 0.625,
0.6875, 0.75, 0.8125, 0.875, 0.9375, -0.0625, -0.125, -0.1875, -0.25, -0.3125, -0.375,
-0.4375, -0.5, -0.5625, -0.625, -0.6875, -0.75, -0.8125, -0.875, -0.9375};
}
/*!
* Print a float in a nice representation if possibly, or an exact 32-bit integer constant to
* be reinterpreted.
@ -21,7 +27,7 @@ namespace pretty_print {
goos::Object float_representation(float value) {
int rounded = value;
bool exact_int = ((float)rounded) == value;
if (value == 0.5 || value == -0.5 || value == 0.0 || value == 1.0 || value == -1.0 || exact_int) {
if (exact_int || allowed_floats.find(value) != allowed_floats.end()) {
return goos::Object::make_float(value);
} else {
u32 int_value;

View file

@ -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 {

View file

@ -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++;

View file

@ -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>();
}
}
}
}

View file

@ -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

View file

@ -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

View file

@ -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]
]
}

View file

@ -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);
}
}

View file

@ -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

View file

@ -5,3 +5,33 @@
;; name in dgo: art-h
;; dgos: GAME, ENGINE
;; TODO more
(deftype art (basic)
((name basic :offset 8)
(length int32 :offset-assert 12)
(extra basic :offset-assert 16)
)
:method-count-assert 13
:size-assert #x14
:flag-assert #xd00000014
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
(dummy-11 () none 11)
(dummy-12 () none 12)
)
)
;; art-h
(deftype art-element (art)
((pad uint8 12))
:method-count-assert 13
:size-assert #x20
:flag-assert #xd00000020
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
(dummy-11 () none 11)
(dummy-12 () none 12)
)
)

View file

@ -5,3 +5,37 @@
;; name in dgo: res-h
;; dgos: GAME, ENGINE
(deftype res-tag (uint128)
()
:flag-assert #x900000010
)
(deftype res-lump (basic)
((length int32 :offset-assert 4)
(allocated-length int32 :offset-assert 8)
(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)
)
:method-count-assert 22
:size-assert #x20
:flag-assert #x1600000020
;; field extra is a basic loaded with a signed load
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
(dummy-11 () none 11)
(dummy-12 () none 12)
(dummy-13 () none 13)
(dummy-14 () none 14)
(dummy-15 () none 15)
(dummy-16 () none 16)
(dummy-17 () none 17)
(dummy-18 () none 18)
(dummy-19 () none 19)
(dummy-20 () none 20)
(dummy-21 () none 21)
)
)

View file

@ -5,3 +5,13 @@
;; name in dgo: engines
;; dgos: GAME, ENGINE
;; Allocate some engines.
(define *background-draw-engine* (new 'global 'engine 'draw 10))
(define *matrix-engine* (new 'global 'boxed-array handle 1024))
(set! (-> *matrix-engine* length) 0)
(define *camera-engine* (new 'global 'engine 'camera-eng 128))
(if *debug-segment*
(define *debug-engine* (new 'debug 'engine 'debug 512))
)

View file

@ -5,188 +5,181 @@
; ;; name in dgo: game-info-h
; ;; dgos: GAME, ENGINE
; ;; Some very basic game info.
; ;; the life stuff seems to be unused.
; (deftype game-bank (basic)
; ((life-max-default float :offset-assert 4)
; (life-start-default float :offset-assert 8)
; (life-single-inc float :offset-assert 12)
; (money-task-inc float :offset-assert 16)
; (money-oracle-inc float :offset-assert 20)
; )
; :method-count-assert 9
; :size-assert #x18
; :flag-assert #x900000018
; )
(deftype game-bank (basic)
((life-max-default float :offset-assert 4)
(life-start-default float :offset-assert 8)
(life-single-inc float :offset-assert 12)
(money-task-inc float :offset-assert 16)
(money-oracle-inc float :offset-assert 20)
)
:method-count-assert 9
:size-assert #x18
:flag-assert #x900000018
)
; ;; Set up the default game parameters
; (define *GAME-bank* (new 'static 'game-bank
; :life-max-default 99.0
; :life-start-default 5.0
; :life-single-inc 1.0
; :money-task-inc 90.0
; :money-oracle-inc 120.0
; )
; )
(define *GAME-bank* (new 'static 'game-bank
:life-max-default 99.000000
:life-start-default 5.000000
:life-single-inc 1.000000
:money-task-inc 90.000000
:money-oracle-inc 120.000000
)
)
; ;; ??
; (deftype actor-id (uint32)
; ()
; )
(deftype actor-id (uint32)
()
:flag-assert #x900000004
)
; ;; main state for each loaded level.
; (deftype level-buffer-state (structure)
; ((name basic :offset-assert 0)
; (display? basic :offset-assert 4)
; (force-vis? basic :offset-assert 8)
; (force-inside? basic :offset-assert 12)
; )
; :pack-me
; :method-count-assert 9
; :size-assert #x10
; :flag-assert #x900000010
; )
(deftype level-buffer-state (structure)
((name basic :offset-assert 0)
(display? basic :offset-assert 4)
(force-vis? basic :offset-assert 8)
(force-inside? basic :offset-assert 12)
)
:pack-me
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
(deftype load-state (basic)
((want level-buffer-state 2 :inline :offset-assert 4)
(vis-nick basic :offset-assert 36)
(command-list pair :offset-assert 40)
(object-name basic 256 :offset-assert 44)
(object-status basic 256 :offset-assert 1068)
)
:method-count-assert 21
:size-assert #x82c
:flag-assert #x150000082c
(:methods
(new (symbol type) _type_ 0)
(reset! (_type_) _type_ 9)
(dummy-10 () none 10)
(dummy-11 () none 11)
(dummy-12 () none 12)
(dummy-13 () none 13)
(dummy-14 () none 14)
(dummy-15 () none 15)
(dummy-16 () none 16)
(dummy-17 () none 17)
(dummy-18 () none 18)
(dummy-19 () none 19)
(dummy-20 () none 20)
)
)
; (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)
; (object-name basic 256 :offset-assert 44)
; (object-status basic 256 :offset-assert 1068)
; )
; :method-count-assert 21
; :size-assert #x82c
; :flag-assert #x150000082c
; (:methods
; (new (symbol type) load-state 0)
; (init-load-state ((obj load-state)) load-state 9)
; (dummy-10 () none 10)
; (dummy-11 () none 11)
; (dummy-12 () none 12)
; (dummy-13 () none 13)
; (dummy-14 () none 14)
; (dummy-15 () none 15)
; (dummy-16 () none 16)
; (dummy-17 () none 17)
; (dummy-18 () none 18)
; (dummy-19 () none 19)
; (dummy-20 () none 20)
; )
; )
(defmethod new load-state ((allocation symbol) (type-to-make type))
(reset!
(object-new allocation type-to-make (the-as int (-> type-to-make size)))
)
)
; (defmethod new load-state ((allocation symbol) (type-to-make type))
; (let ((obj (object-new allocation type)))
; (init-load-state obj)
; )
; )
(deftype continue-point (basic)
((name basic :offset-assert 4)
(level basic :offset-assert 8)
(flags uint32 :offset-assert 12)
(trans vector :inline :offset-assert 16)
(quat vector :inline :offset-assert 32)
(camera-trans vector :inline :offset-assert 48)
(camera-rot float 9 :offset-assert 64)
(load-commands pair :offset-assert 100)
(vis-nick basic :offset-assert 104)
(lev0 basic :offset-assert 108)
(disp0 basic :offset-assert 112)
(lev1 basic :offset-assert 116)
(disp1 basic :offset-assert 120)
)
:method-count-assert 10
:size-assert #x7c
:flag-assert #xa0000007c
(:methods
(dummy-9 () none 9)
)
)
; (deftype continue-point (basic)
; ((name basic :offset-assert 4)
; (level basic :offset-assert 8)
; (flags uint32 :offset-assert 12)
; (trans vector :inline :offset-assert 16)
; (quat vector :inline :offset-assert 32)
; (camera-trans vector :inline :offset-assert 48)
; (camera-rot float 9 :offset-assert 64)
; (load-commands basic :offset-assert 100)
; (vis-nick basic :offset-assert 104)
; (lev0 basic :offset-assert 108)
; (disp0 basic :offset-assert 112)
; (lev1 basic :offset-assert 116)
; (disp1 basic :offset-assert 120)
; )
; :method-count-assert 10
; :size-assert #x7c
; :flag-assert #xa0000007c
; (:methods
; (dummy-9 () none 9)
; )
; )
(deftype game-info (basic)
((mode basic :offset-assert 4)
(save-name basic :offset-assert 8)
(life float :offset-assert 12)
(life-max float :offset-assert 16)
(money float :offset-assert 20)
(money-total float :offset-assert 24)
(money-per-level uint8 32 :offset-assert 28)
(deaths-per-level uint8 32 :offset-assert 60)
(buzzer-total float :offset-assert 92)
(fuel float :offset-assert 96)
(perm-list basic :offset-assert 100)
(task-perm-list basic :offset-assert 104)
(current-continue basic :offset-assert 108)
(text-ids-seen basic :offset-assert 112)
(level-opened uint8 32 :offset-assert 116)
(hint-control basic :offset-assert 148)
(task-hint-control basic :offset-assert 152)
(total-deaths int32 :offset-assert 156)
(continue-deaths int32 :offset-assert 160)
(fuel-cell-deaths int32 :offset-assert 164)
(game-start-time uint64 :offset-assert 168)
(continue-time uint64 :offset-assert 176)
(death-time uint64 :offset-assert 184)
(hit-time uint64 :offset-assert 192)
(fuel-cell-pickup-time uint64 :offset-assert 200)
(fuel-cell-time basic :offset-assert 208)
(enter-level-time basic :offset-assert 212)
(in-level-time basic :offset-assert 216)
(blackout-time uint64 :offset-assert 224)
(letterbox-time uint64 :offset-assert 232)
(hint-play-time uint64 :offset-assert 240)
(display-text-time uint64 :offset-assert 248)
(display-text-handle uint64 :offset-assert 256)
(death-movie-tick int32 :offset-assert 264)
(want-auto-save basic :offset-assert 268)
(auto-save-proc uint64 :offset-assert 272)
(auto-save-status uint32 :offset-assert 280)
(auto-save-card int32 :offset-assert 284)
(auto-save-which int32 :offset-assert 288)
(pov-camera-handle uint64 :offset-assert 296)
(other-camera-handle uint64 :offset-assert 304)
(death-pos basic :offset-assert 312)
(dummy basic :offset-assert 316)
(auto-save-count int32 :offset-assert 320)
)
:method-count-assert 29
:size-assert #x144
:flag-assert #x1d00000144
;; field dummy is a basic loaded with a signed load
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
(dummy-11 () none 11)
(dummy-12 () none 12)
(dummy-13 () none 13)
(dummy-14 () none 14)
(dummy-15 () none 15)
(dummy-16 () none 16)
(dummy-17 () none 17)
(dummy-18 () none 18)
(dummy-19 () none 19)
(dummy-20 () none 20)
(dummy-21 () none 21)
(dummy-22 () none 22)
(dummy-23 () none 23)
(dummy-24 () none 24)
(dummy-25 () none 25)
(dummy-26 () none 26)
(dummy-27 () none 27)
(dummy-28 () none 28)
)
)
; (deftype game-info (basic)
; ((mode basic :offset-assert 4)
; (save-name basic :offset-assert 8)
; (life float :offset-assert 12)
; (life-max float :offset-assert 16)
; (money float :offset-assert 20)
; (money-total float :offset-assert 24)
; (money-per-level uint8 32 :offset-assert 28)
; (deaths-per-level uint8 32 :offset-assert 60)
; (buzzer-total float :offset-assert 92)
; (fuel float :offset-assert 96)
; (perm-list basic :offset-assert 100)
; (task-perm-list basic :offset-assert 104)
; (current-continue basic :offset-assert 108)
; (text-ids-seen basic :offset-assert 112)
; (level-opened uint8 32 :offset-assert 116)
; (hint-control basic :offset-assert 148)
; (task-hint-control basic :offset-assert 152)
; (total-deaths int32 :offset-assert 156)
; (continue-deaths int32 :offset-assert 160)
; (fuel-cell-deaths int32 :offset-assert 164)
; (game-start-time uint64 :offset-assert 168)
; (continue-time uint64 :offset-assert 176)
; (death-time uint64 :offset-assert 184)
; (hit-time uint64 :offset-assert 192)
; (fuel-cell-pickup-time uint64 :offset-assert 200)
; (fuel-cell-time basic :offset-assert 208)
; (enter-level-time basic :offset-assert 212)
; (in-level-time basic :offset-assert 216)
; (blackout-time uint64 :offset-assert 224)
; (letterbox-time uint64 :offset-assert 232)
; (hint-play-time uint64 :offset-assert 240)
; (display-text-time uint64 :offset-assert 248)
; (display-text-handle uint64 :offset-assert 256)
; (death-movie-tick int32 :offset-assert 264)
; (want-auto-save basic :offset-assert 268)
; (auto-save-proc uint64 :offset-assert 272)
; (auto-save-status uint32 :offset-assert 280)
; (auto-save-card int32 :offset-assert 284)
; (auto-save-which int32 :offset-assert 288)
; (pov-camera-handle uint64 :offset-assert 296)
; (other-camera-handle uint64 :offset-assert 304)
; (death-pos basic :offset-assert 312)
; (dummy basic :offset-assert 316)
; (auto-save-count int32 :offset-assert 320)
; )
; :method-count-assert 29
; :size-assert #x144
; :flag-assert #x1d00000144
; ;; field dummy is a basic loaded with a signed load
; (:methods
; (dummy-9 () none 9)
; (dummy-10 () none 10)
; (dummy-11 () none 11)
; (dummy-12 () none 12)
; (dummy-13 () none 13)
; (dummy-14 () none 14)
; (dummy-15 () none 15)
; (dummy-16 () none 16)
; (dummy-17 () none 17)
; (dummy-18 () none 18)
; (dummy-19 () none 19)
; (dummy-20 () none 20)
; (dummy-21 () none 21)
; (dummy-22 () none 22)
; (dummy-23 () none 23)
; (dummy-24 () none 24)
; (dummy-25 () none 25)
; (dummy-26 () none 26)
; (dummy-27 () none 27)
; (dummy-28 () none 28)
; )
; )
(define-extern *game-info* game-info)
; (define-extern *game-info* game-info)
; (when (or (not *game-info*)
; (= 0 *game-info*))
; (set! *game-info* (new 'static 'game-info
; :mode 'debug
; :current-continue #f)
; )
; (set! (-> *game-info* fuel-cell-time) (new 'global 'boxed-array uint64 116))
; (set! (-> *game-info* enter-level-time) (new 'global 'boxed-array uint64 32))
; (set! (-> *game-info* in-level-time) (new 'global 'boxed-array uint64 32))
; )
(when (or (not *game-info*) (zero? *game-info*))
(let ((temp (new 'static 'game-info :mode 'debug :current-continue #f)))
(set! (-> temp fuel-cell-time) (new 'global 'boxed-array uint64 116))
(set! (-> temp enter-level-time) (new 'global 'boxed-array uint64 32))
(set! (-> temp in-level-time) (new 'global 'boxed-array uint64 32))
(set! *game-info* temp)
)
)

View file

@ -5,3 +5,42 @@
;; name in dgo: generic-vu1-h
;; dgos: GAME, ENGINE
(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
)
(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
)
(deftype generic-constants (structure)
((fog vector :inline :offset-assert 0)
(adgif qword :inline :offset-assert 16)
(giftag qword :inline :offset-assert 32)
(hvdf-offset vector :inline :offset-assert 48)
(hmge-scale vector :inline :offset-assert 64)
(invh-scale vector :inline :offset-assert 80)
(guard vector :inline :offset-assert 96)
(adnop qword :inline :offset-assert 112)
(flush qword :inline :offset-assert 128)
(stores qword :inline :offset-assert 144)
)
:method-count-assert 9
:size-assert #xa0
:flag-assert #x9000000a0
)

View file

@ -5,3 +5,392 @@
;; name in dgo: merc-h
;; dgos: GAME, ENGINE
(deftype ripple-merc-query (inline-array-class)
((start-vertex int32 :offset-assert 16)
(vertex-skip int32 :offset-assert 20)
(vertex-count int32 :offset-assert 24)
(current-loc int32 :offset-assert 28)
(data2 uint8 :dynamic :offset-assert 32) ;; renamed from data. suspect inline-array has some magic.
)
:method-count-assert 9
:size-assert #x20
:flag-assert #x900000020
)
(set! (-> ripple-merc-query heap-base) 16)
(deftype merc-byte-header (structure)
((srcdest-off uint8 :offset-assert 0)
(rgba-off uint8 :offset-assert 1)
(lump-off uint8 :offset-assert 2)
(fp-off uint8 :offset-assert 3)
(mat1-cnt uint8 :offset-assert 4)
(mat2-cnt uint8 :offset-assert 5)
(mat3-cnt uint8 :offset-assert 6)
(samecopy-cnt uint8 :offset-assert 7)
(crosscopy-cnt uint8 :offset-assert 8)
(strip-len uint8 :offset-assert 9)
(mm-quadword-fp-off uint8 :offset-assert 10)
(mm-quadword-size uint8 :offset-assert 11)
(perc-off uint8 :offset-assert 12)
(mat-slot uint8 10 :offset-assert 13)
)
:method-count-assert 9
:size-assert #x17
:flag-assert #x900000017
)
;; merc-h
(deftype merc-fragment (structure)
((header merc-byte-header :inline :offset-assert 0)
(rest uint8 1 :offset-assert 23)
)
:method-count-assert 10
:size-assert #x18
:flag-assert #xa00000018
(:methods
(dummy-9 () none 9)
)
)
;; merc-h
(deftype merc-vtx (structure)
((mat-0 uint8 :offset-assert 0)
(mat-1 uint8 :offset-assert 1)
(nrm-x uint8 :offset-assert 2)
(pos-x uint8 :offset-assert 3)
(dst-0 uint8 :offset-assert 4)
(dst-1 uint8 :offset-assert 5)
(nrm-y uint8 :offset-assert 6)
(pos-y uint8 :offset-assert 7)
(tex-s uint8 :offset-assert 8)
(tex-t uint8 :offset-assert 9)
(nrm-z uint8 :offset-assert 10)
(pos-z uint8 :offset-assert 11)
)
:method-count-assert 9
:size-assert #xc
:flag-assert #x90000000c
)
;; merc-h
(deftype merc-fp-header (structure)
((x-add float :offset-assert 0)
(y-add float :offset-assert 4)
(z-add float :offset-assert 8)
(shader-cnt uint8 :offset-assert 12)
(kick-info-offset uint8 :offset-assert 13)
(kick-info-step uint8 :offset-assert 14)
(hword-cnt uint8 :offset-assert 15)
)
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
(defun merc-fragment-fp-data ((arg0 merc-fragment))
"Get the floating-point data of a merc-fragment"
(the pointer (&+ arg0 (the-as uint (shl (-> arg0 header mm-quadword-fp-off) 4))))
)
;; merc-h
(deftype merc-mat-dest (structure)
((matrix-number uint8 :offset-assert 0)
(matrix-dest uint8 :offset-assert 1)
)
:method-count-assert 9
:size-assert #x2
:flag-assert #x900000002
)
;; merc-h
(deftype merc-fragment-control (structure)
((unsigned-four-count uint8 :offset-assert 0)
(lump-four-count uint8 :offset-assert 1)
(fp-qwc uint8 :offset-assert 2)
(mat-xfer-count uint8 :offset-assert 3)
(mat-dest-data uint8 :dynamic :offset-assert 4)
)
:method-count-assert 9
:size-assert #x4
:flag-assert #x900000004
)
;; merc-h
(deftype merc-blend-data (structure) ;; was unknown!
((int8-data int8 :dynamic :offset-assert 0)
)
)
;; merc-h
(deftype merc-blend-ctrl (structure)
((blend-vtx-count uint8 :offset-assert 0)
(nonzero-index-count uint8 :offset-assert 1)
(bt-index uint8 :dynamic :offset-assert 2)
)
:method-count-assert 9
:size-assert #x2
:flag-assert #x900000002
)
;; merc-h
(deftype mei-envmap-tint (structure)
((fade0 float :offset-assert 0)
(fade1 float :offset-assert 4)
(tint uint32 :offset-assert 8)
(dummy int32 :offset-assert 12)
)
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
;; merc-h
(deftype mei-texture-scroll (structure)
((max-dist float :offset-assert 0)
(st-int-scale uint8 :offset-assert 4)
(time-factor uint8 :offset-assert 5)
(scroll-dir uint8 :offset-assert 6)
(cached-time uint8 :offset-assert 7)
(time-delta uint8 :offset-assert 8)
(dummy uint8 7 :offset-assert 9)
)
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
;; merc-h
(deftype mei-ripple (structure)
((x-base float :offset-assert 0)
(z-base float :offset-assert 4)
(grid-size float :offset-assert 8)
(angle float :offset-assert 12)
)
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
;; merc-h
(deftype merc-extra-info (structure)
((envmap-tint-offset uint8 :offset-assert 0)
(shader-offset uint8 :offset-assert 1)
(texture-scroll-offset uint8 :offset-assert 2)
(ripple-offset uint8 :offset-assert 3)
(dummy uint8 12 :offset-assert 4)
)
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
; ;; merc-h
(deftype merc-effect (structure)
((frag-geo merc-fragment :offset-assert 0)
(frag-ctrl merc-fragment-control :offset-assert 4)
(blend-data merc-blend-data :offset-assert 8)
(blend-ctrl merc-blend-ctrl :offset-assert 12)
(dummy0 uint8 :offset-assert 16)
(effect-bits uint8 :offset-assert 17)
(frag-count uint16 :offset-assert 18)
(blend-frag-count uint16 :offset-assert 20)
(tri-count uint16 :offset-assert 22)
(dvert-count uint16 :offset-assert 24)
(dummy1 uint8 :offset-assert 26)
(envmap-usage uint8 :offset-assert 27)
(extra-info merc-extra-info :offset-assert 28)
)
:method-count-assert 10
:size-assert #x20
:flag-assert #xa00000020
(:methods
(dummy-9 () none 9)
)
)
;; merc-h
(deftype merc-eye-ctrl (structure)
((eye-slot int8 :offset-assert 0)
(shader-offset int8 :offset-assert 1)
(shader-count int8 :offset-assert 2)
;(shader UNKNOWN 3 :offset-assert 16)
(iris-shader adgif-shader :inline :offset-assert 16)
(pupil-shader adgif-shader :inline :offset-assert 96)
(lid-shader adgif-shader :inline :offset-assert 176)
)
:method-count-assert 9
:size-assert #x100
:flag-assert #x900000100
)
;; merc-h
(deftype merc-eye-anim-frame (structure)
((pupil-trans-x int8 :offset-assert 0)
(pupil-trans-y int8 :offset-assert 1)
(blink int8 :offset-assert 2)
(iris-scale int8 :offset 4)
(pupil-scale int8 :offset-assert 5)
(lid-scale int8 :offset-assert 6)
(dword uint64 :offset 0)
)
:method-count-assert 9
:size-assert #x8
:flag-assert #x900000008
)
;; merc-h
(deftype merc-eye-anim-block (structure)
((max-frame int16 :offset-assert 0)
(data uint8 :dynamic :offset 8)
)
:method-count-assert 9
:size-assert #x8
:flag-assert #x900000008
)
;; merc-h
(deftype merc-ctrl-header (structure)
((xyz-scale float :offset-assert 0)
(st-magic uint32 :offset-assert 4)
(st-out-a uint32 :offset-assert 8)
(st-out-b uint32 :offset-assert 12)
(st-vif-add uint32 :offset-assert 16)
(st-int-off uint16 :offset-assert 20)
(st-int-scale uint16 :offset-assert 22)
(effect-count uint32 :offset-assert 24)
(blend-target-count uint32 :offset-assert 28)
(fragment-count uint16 :offset-assert 32)
(tri-count uint16 :offset-assert 34)
(matrix-count uint8 :offset-assert 36)
(shader-count uint8 :offset-assert 37)
(transform-vertex-count uint16 :offset-assert 38)
(dvert-count uint16 :offset-assert 40)
(one-mat-count uint16 :offset-assert 42)
(two-mat-count uint16 :offset-assert 44)
(two-mat-reuse-count uint16 :offset-assert 46)
(three-mat-count uint16 :offset-assert 48)
(three-mat-reuse-count uint16 :offset-assert 50)
(shader-upload-count uint8 :offset-assert 52)
(matrix-upload-count uint8 :offset-assert 53)
(same-copy-count uint16 :offset-assert 54)
(cross-copy-count uint16 :offset-assert 56)
(num-verts uint16 :offset-assert 58)
(longest-edge float :offset-assert 60)
(eye-ctrl merc-eye-ctrl :offset-assert 64)
(masks uint32 3 :offset-assert 68)
(dummy-bytes uint8 48 :offset 32)
(envmap-tint uint32 :offset 32)
(query basic :offset 36)
(needs-clip uint8 :offset 40)
(use-isometric uint8 :offset 41)
(use-attached-shader uint8 :offset 42)
(display-triangles uint8 :offset 43)
(death-vertex-skip uint16 :offset 44)
(death-start-vertex uint16 :offset 46)
(death-effect uint32 :offset 48)
(use-translucent uint8 :offset 52)
(display-this-fragment uint8 :offset 53)
)
:method-count-assert 9
:size-assert #x50
:flag-assert #x900000050
;; field xyz-scale is a float printed as hex?
)
;; merc-h
(deftype merc-ctrl (art-element)
((num-joints int32 :offset 20)
(header merc-ctrl-header :inline :offset-assert 32)
(effect uint8 :dynamic :offset-assert 112)
)
:method-count-assert 13
:size-assert #x70
:flag-assert #xd00000070
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
(dummy-11 () none 11)
(dummy-12 () none 12)
)
)
;; merc-h
(deftype merc-vu1-low-mem (structure)
((tri-strip-gif qword :inline :offset-assert 0)
(ad-gif qword :inline :offset-assert 16)
(hvdf-offset vector :inline :offset-assert 32)
(perspective uint128 4 :offset-assert 48)
(fog vector :inline :offset-assert 112)
)
:method-count-assert 9
:size-assert #x80
:flag-assert #x900000080
)
;; merc-h
(deftype ripple-wave (structure)
((scale float :offset-assert 0)
(offs float :offset-assert 4)
(xdiv int16 :offset-assert 8)
(zdiv int16 :offset-assert 10)
(speed float :offset-assert 12)
(xmul float :offset-assert 16)
(zmul float :offset-assert 20)
(delta float :offset-assert 24)
)
:pack-me
:method-count-assert 9
:size-assert #x1c
:flag-assert #x90000001c
)
;; merc-h
(deftype ripple-wave-set (basic)
((count int32 :offset-assert 4)
(converted basic :offset-assert 8)
(frame-save uint32 :offset-assert 12)
(normal-scale float :offset-assert 16)
(wave ripple-wave 4 :inline :offset-assert 20)
)
:method-count-assert 9
:size-assert #x84
:flag-assert #x900000084
)
;; merc-h
(deftype ripple-control (basic)
((global-scale float :offset-assert 4)
(last-frame-scale float :offset-assert 8)
(close-fade-dist float :offset-assert 12)
(far-fade-dist float :offset-assert 16)
(faded-scale float :offset-assert 20)
(individual-normal-scale float :offset-assert 24)
(waveform basic :offset-assert 28)
(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
)
(defmethod new ripple-control ((allocation symbol) (type-to-make type))
(local-vars (v0-0 ripple-control))
(set! v0-0
(object-new allocation type-to-make (the-as int (-> type-to-make size)))
)
(set! (-> v0-0 global-scale) 0.000000)
(set! (-> v0-0 last-frame-scale) (the-as float #xba83126f))
(set! (-> v0-0 close-fade-dist) (the-as float #x4f742400))
(set! (-> v0-0 far-fade-dist) (the-as float #x4ff42400))
(set! (-> v0-0 faded-scale) (the-as float #xba83126f))
(set! (-> v0-0 waveform) #f)
(set! (-> v0-0 individual-normal-scale) 1.000000)
(set! (-> v0-0 send-query) #f)
(set! (-> v0-0 query) #f)
v0-0
)

View file

@ -5,3 +5,140 @@
;; name in dgo: mood-h
;; dgos: GAME, ENGINE
(deftype mood-fog (structure)
((fog-color vector :inline :offset-assert 0)
(fog-dists vector :inline :offset-assert 16)
(fog-start float :offset 16) ;; meters
(fog-end float :offset 20) ;;meters
(fog-max float :offset 24)
(fog-min float :offset 28)
(erase-color vector :inline :offset-assert 32)
)
:method-count-assert 9
:size-assert #x30
:flag-assert #x900000030
)
(deftype mood-fog-table (structure)
((data mood-fog 8 :inline :offset-assert 0)
)
:method-count-assert 9
:size-assert #x180
:flag-assert #x900000180
)
(deftype mood-lights (structure)
((direction vector :inline :offset-assert 0)
(lgt-color vector :inline :offset-assert 16)
(prt-color vector :inline :offset-assert 32)
(amb-color vector :inline :offset-assert 48)
(shadow vector :inline :offset-assert 64)
)
:method-count-assert 9
:size-assert #x50
:flag-assert #x900000050
)
(deftype mood-lights-table (structure)
((data mood-lights 8 :inline :offset-assert 0)
)
:method-count-assert 9
:size-assert #x280
:flag-assert #x900000280
)
(deftype mood-sun (structure)
((sun-color vector :inline :offset-assert 0)
(env-color vector :inline :offset-assert 16)
)
:method-count-assert 9
:size-assert #x20
:flag-assert #x900000020
)
(deftype mood-sun-table (structure)
((data mood-sun 8 :inline :offset-assert 0)
)
:method-count-assert 9
:size-assert #x100
:flag-assert #x900000100
)
(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
)
(defmethod new mood-context ((allocation symbol) (type-to-make type))
(local-vars
(v0-0 mood-context)
(v1 vector)
)
(set! v0-0
(object-new allocation type-to-make (the-as int (-> type-to-make size)))
)
(set! v1 (-> v0-0 times 0))
(set! (-> v1 data 0) 1.000000)
(set! (-> v1 data 1) 1.000000)
(set! (-> v1 data 2) 1.000000)
(set! (-> v1 data 3) 0.000000)
(set! v1 (-> v0-0 times 1))
(set! (-> v1 data 0) 1.000000)
(set! (-> v1 data 1) 1.000000)
(set! (-> v1 data 2) 1.000000)
(set! (-> v1 data 3) 0.000000)
(set! v1 (-> v0-0 times 2))
(set! (-> v1 data 0) 1.000000)
(set! (-> v1 data 1) 1.000000)
(set! (-> v1 data 2) 1.000000)
(set! (-> v1 data 3) 0.000000)
(set! v1 (-> v0-0 times 3))
(set! (-> v1 data 0) 1.000000)
(set! (-> v1 data 1) 1.000000)
(set! (-> v1 data 2) 1.000000)
(set! (-> v1 data 3) 0.000000)
(set! v1 (-> v0-0 times 4))
(set! (-> v1 data 0) 1.000000)
(set! (-> v1 data 1) 1.000000)
(set! (-> v1 data 2) 1.000000)
(set! (-> v1 data 3) 0.000000)
(set! v1 (-> v0-0 times 5))
(set! (-> v1 data 0) 1.000000)
(set! (-> v1 data 1) 1.000000)
(set! (-> v1 data 2) 1.000000)
(set! (-> v1 data 3) 0.000000)
(set! v1 (-> v0-0 times 6))
(set! (-> v1 data 0) 1.000000)
(set! (-> v1 data 1) 1.000000)
(set! (-> v1 data 2) 1.000000)
(set! (-> v1 data 3) 0.000000)
(set! v1 (-> v0-0 times 7))
(set! (-> v1 data 0) 1.000000)
(set! (-> v1 data 1) 1.000000)
(set! (-> v1 data 2) 1.000000)
(set! (-> v1 data 3) 0.000000)
v0-0
)

File diff suppressed because it is too large Load diff

View file

@ -411,3 +411,4 @@
:size-assert #x110
:flag-assert #x900000110
)

File diff suppressed because it is too large Load diff

View file

@ -5,3 +5,261 @@
;; name in dgo: shadow-cpu-h
;; dgos: GAME, ENGINE
(deftype shadow-settings (structure)
((center vector :inline :offset-assert 0)
(flags int32 :offset 12)
(shadow-dir vector :inline :offset-assert 16)
(dist-to-locus float :offset 28)
(bot-plane plane :inline :offset-assert 32)
(top-plane plane :inline :offset-assert 48)
(fade-dist float :offset-assert 64)
(fade-start float :offset-assert 68)
(dummy-2 int32 :offset-assert 72)
(dummy-3 int32 :offset-assert 76)
)
:method-count-assert 9
:size-assert #x50
:flag-assert #x900000050
)
(deftype shadow-control (basic)
((settings shadow-settings :inline :offset-assert 16)
)
:method-count-assert 16
:size-assert #x60
:flag-assert #x1000000060
(:methods
(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)
)
)
(defmethod clear-offset-bit shadow-control ((obj shadow-control))
"Clear a bit in w for the center of the shadow."
(set! (-> obj settings center w)
(the-as float (logand -33 (the-as int (-> obj settings center w))))
)
(none)
)
(defmethod set-offset-bit shadow-control ((obj shadow-control))
"Set a bit in w for the center position of the shadow"
(set! (-> obj settings center w)
(the-as float (logior (the-as int (-> obj settings center w))
32)
)
)
(none)
)
(defmethod set-bottom-plane-offset shadow-control ((obj shadow-control) (arg0 float))
(set! (-> obj settings bot-plane d) (- arg0))
(none)
)
(defmethod set-top-plane-offset shadow-control ((obj shadow-control) (arg0 float))
(set! (-> obj settings top-plane d) (- arg0))
(none)
)
(deftype shadow-data (structure)
((texoffset vector :inline :offset-assert 0)
(texscale vector :inline :offset-assert 16)
(clrs uint128 2 :offset-assert 32)
(dma-unpack-template dma-packet :inline :offset-assert 64)
(dma-cnt uint64 :offset-assert 80)
(vif-nop uint32 :offset-assert 88)
(vif-unpack-v4-8 uint32 :offset-assert 92)
(pdc basic :offset-assert 96)
(dist float :offset-assert 100)
(oddeven uint8 :offset-assert 104)
(waits uint32 :offset-assert 108)
)
:method-count-assert 9
:size-assert #x70
:flag-assert #x900000070
)
(deftype shadow-work (structure)
((shadow-data shadow-data :inline :offset-assert 0)
(inbuf uint128 600 :offset-assert 112)
)
:method-count-assert 9
:size-assert #x25f0
:flag-assert #x9000025f0
)
(deftype shadow-run (structure)
((first uint32 :offset-assert 0)
(next uint32 :offset-assert 4)
)
:allow-misaligned
:method-count-assert 9
:size-assert #x8
:flag-assert #x900000008
)
(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
)
(defun shadow-queue-append ((arg0 shadow-queue))
"Increment the run counter"
(local-vars (v0-0 uint))
(set! v0-0 (+ (-> arg0 cur-run) 1))
(set! (-> arg0 cur-run) v0-0)
v0-0
)
(defun shadow-queue-reset ((arg0 shadow-queue))
"Reset the run counter"
(set! (-> arg0 cur-run) 0)
0
)
(define *shadow-queue* (new 'global 'shadow-queue))
(deftype shadow-vertex (structure)
((x float :offset-assert 0)
(y float :offset-assert 4)
(z float :offset-assert 8)
(weight float :offset-assert 12)
)
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
(deftype shadow-matrix-ref (structure)
((joint-0 uint8 :offset-assert 0)
(joint-1 uint8 :offset-assert 1)
)
:method-count-assert 9
:size-assert #x2
:flag-assert #x900000002
)
;; BUG:
;; the shadow-edge type is multiply defined.
;; it seems like the first definition is not used.
;; The OpenGOAL compiler doesn't like this, so this is commented out.
#|
;; shadow-cpu-h
; (deftype shadow-edge (structure) ;
; ((ind-0 uint16 :offset-assert 0) ;
; (ind-1 uint16 :offset-assert 2) ;
; (tri-0 uint16 :offset-assert 4) ;
; (tri-1 uint16 :offset-assert 6) ;
; ) ;
; :method-count-assert 9 ;
; :size-assert #x4 ;
; :flag-assert #x900000004 ;
; ) ;
|#
(deftype shadow-tri (structure)
((ind-0 uint8 :offset-assert 0)
(ind-1 uint8 :offset-assert 1)
(ind-2 uint8 :offset-assert 2)
(faces uint8 :offset-assert 3)
)
:method-count-assert 9
:size-assert #x4
:flag-assert #x900000004
)
(deftype shadow-edge (structure)
((ind-0 uint8 :offset-assert 0)
(ind-1 uint8 :offset-assert 1)
(tri-0 uint8 :offset-assert 2)
(tri-1 uint8 :offset-assert 3)
)
:method-count-assert 9
:size-assert #x4
:flag-assert #x900000004
)
(deftype shadow-header (structure)
((qwc-data uint32 :offset-assert 0)
(num-joints uint32 :offset-assert 4)
(num-verts uint16 :offset-assert 8)
(num-twos uint16 :offset-assert 10)
(num-single-tris uint16 :offset-assert 12)
(num-single-edges uint16 :offset-assert 14)
(num-double-tris uint16 :offset-assert 16)
(num-double-edges uint16 :offset-assert 18)
(ofs-verts uint32 :offset-assert 20)
(ofs-refs uint32 :offset-assert 24)
(ofs-single-tris uint32 :offset-assert 28)
(ofs-single-edges uint32 :offset-assert 32)
(ofs-double-tris uint32 :offset-assert 36)
(ofs-double-edges uint32 :offset-assert 40)
)
:method-count-assert 9
:size-assert #x2c
:flag-assert #x90000002c
)
(deftype shadow-geo (art-element)
((total-size uint32 :offset-assert 32)
(header shadow-header :inline :offset 32)
(rest uint64 :dynamic :offset-assert 80)
)
:method-count-assert 13
:size-assert #x50
:flag-assert #xd00000050
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
(dummy-11 () none 11)
(dummy-12 () none 12)
)
)
(defmethod new shadow-control ((allocation symbol) (type-to-make type)
(bottom-offset float)
(top-offset float)
(dir float)
(center float)
(fade float)
)
(local-vars (v0-0 shadow-control) (v1-2 vector) (v1-3 plane) (v1-4 plane))
(set! v0-0
(object-new allocation type-to-make (the-as int (-> type-to-make size)))
)
(set! (-> v0-0 settings center data 3) center)
(set! v1-2 (-> v0-0 settings shadow-dir))
(set! (-> v1-2 x) 0.000000)
(set! (-> v1-2 y) -1.000000)
(set! (-> v1-2 z) 0.000000)
(set! (-> v1-2 w) dir)
(set! v1-3 (-> v0-0 settings bot-plane))
(set! (-> v1-3 a) 0.000000)
(set! (-> v1-3 b) 1.000000)
(set! (-> v1-3 c) 0.000000)
(set! (-> v1-3 d) (- bottom-offset))
(set! v1-4 (-> v0-0 settings top-plane))
(set! (-> v1-4 a) 0.000000)
(set! (-> v1-4 b) 1.000000)
(set! (-> v1-4 c) 0.000000)
(set! (-> v1-4 d) (- top-offset))
(set! (-> v0-0 settings fade-dist) fade)
v0-0
)
(define *shadow* #f)
(define *shadow-object* #f)
(define *shadow-debug* #f)

View file

@ -5,3 +5,4 @@
;; name in dgo: shadow-vu1-h
;; dgos: GAME, ENGINE
;; empty!

View file

@ -5,3 +5,177 @@
;; name in dgo: sky-h
;; dgos: GAME, ENGINE
(deftype sky-color-hour (structure)
((snapshot1 int32 :offset-assert 0)
(snapshot2 int32 :offset-assert 4)
(morph-start float :offset-assert 8)
(morph-end float :offset-assert 12)
)
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
(deftype sky-color-day (structure)
((hour sky-color-hour 24 :inline :offset-assert 0)
)
:method-count-assert 9
:size-assert #x180
:flag-assert #x900000180
)
(deftype sky-circle-data (structure)
((data vector 17 :inline :offset-assert 0)
)
:method-count-assert 9
:size-assert #x110
:flag-assert #x900000110
)
(deftype sky-sun-data (structure)
((data uint128 4 :offset-assert 0)
(pos vector :inline :offset 0)
(r-sun float :offset 16)
(r-halo float :offset 20)
(r-aurora float :offset 24)
(c-sun-start uint32 :offset 32)
(c-sun-end uint32 :offset 48)
(c-halo-start uint32 :offset 36)
(c-halo-end uint32 :offset 52)
(c-aurora-start uint32 :offset 40)
(c-aurora-end uint32 :offset 56)
)
:method-count-assert 9
:size-assert #x40
:flag-assert #x900000040
)
(deftype sky-moon-data (structure)
((data uint128 2 :offset-assert 0)
(pos vector :inline :offset 0)
(scale vector :inline :offset 16)
)
:method-count-assert 9
:size-assert #x20
:flag-assert #x900000020
)
(deftype sky-orbit (structure)
((high-noon float :offset-assert 0)
(tilt float :offset-assert 4)
(rise float :offset-assert 8)
(dist float :offset-assert 12)
(min-halo float :offset-assert 16)
(max-halo float :offset-assert 20)
)
:allow-misaligned
:method-count-assert 9
:size-assert #x18
:flag-assert #x900000018
)
(deftype sky-upload-data (basic)
(
;;(data UNKNOWN 27 :offset-assert 16)
(circle sky-circle-data :inline :offset-assert 16)
(sun sky-sun-data 2 :inline :offset-assert 288)
(moon sky-moon-data :inline :offset-assert 416)
(data uint128 27 :offset 16)
)
:method-count-assert 9
:size-assert #x1c0
:flag-assert #x9000001c0
)
(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
)
(defmethod new sky-parms ((allocation symbol) (type-to-make type))
(local-vars (v0-0 sky-parms))
(set! v0-0
(object-new allocation type-to-make (the-as int (-> type-to-make size)))
)
(set! (-> v0-0 upload-data type) sky-upload-data)
v0-0
)
(define *sky-parms* (new 'global 'sky-parms))
(define *sky-upload-data* (new 'global 'sky-upload-data))
;; generate some sky data.
(let ((gp-0 0))
(while (< gp-0 17)
(let* ((f30-0 (+ (the-as float #xc0490fda)
(* (the-as float #x3ec90fda) (the float (logand gp-0 15)))
)
)
(f0-2 (* (the-as float #x400ccccd) (sin-rad f30-0)))
)
(set! (-> *sky-upload-data* circle data gp-0 data 0)
(* (the-as float #x400ccccd) (sin-rad f30-0))
)
(set! (-> *sky-upload-data* circle data gp-0 data 1) (cos-rad f30-0))
(set! (-> *sky-upload-data* circle data gp-0 data 2) 0.000000)
(set! (-> *sky-upload-data* circle data gp-0 data 3) 0.000000)
(+! gp-0 1)
)
)
)
(deftype sky-tng-data (basic)
((giftag-base qword :inline :offset-assert 16)
(giftag-roof qword :inline :offset-assert 32)
(giftag-ocean qword :inline :offset-assert 48)
(fog vector :inline :offset-assert 64)
(sky uint32 8 :offset-assert 80)
(time float :offset-assert 112)
(off-s-0 uint16 :offset-assert 116)
(off-t-0 uint16 :offset-assert 118)
(off-s-1 uint16 :offset-assert 120)
(off-t-1 uint16 :offset-assert 122)
)
:method-count-assert 9
:size-assert #x7c
:flag-assert #x90000007c
)
(deftype sky-work (structure)
((adgif-tmpl dma-gif-packet :inline :offset-assert 0)
(draw-tmpl dma-gif-packet :inline :offset-assert 32)
(blend-tmpl dma-gif-packet :inline :offset-assert 64)
(sky-data uint128 5 :offset-assert 96)
(cloud-data uint128 5 :offset-assert 176)
)
:method-count-assert 9
:size-assert #x100
:flag-assert #x900000100
)
(deftype sky-vertex (structure)
((pos vector :inline :offset-assert 0)
(stq vector :inline :offset-assert 16)
(col vector :inline :offset-assert 32)
)
:method-count-assert 9
:size-assert #x30
:flag-assert #x900000030
)
(define *sky-drawn* #f)
(define *cloud-drawn* #f)

View file

@ -5,3 +5,46 @@
;; name in dgo: wind-h
;; dgos: GAME, ENGINE
(deftype wind-vector (structure)
((wind-pos vector2w :inline :offset-assert 0)
(wind-vel vector2w :inline :offset-assert 8)
)
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
(define *wind-scales* (new 'static 'boxed-array uint8 32
#x2 #x5 #x2 #x3
#x2 #x2 #x3 #x10
#xa #x2 #x4 #x2
#x8 #x2 #x2 #x10
#x2 #x2 #x8 #x2
#x10 #x2 #x4 #x10
#xa #x2 #x4 #x2
#x8 #x2 #x2 #x10
)
)
(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
)
(define-extern *wind-work* wind-work)
(defun wind-get-hashed-index ((arg0 vector))
(logand (+ (the int (-> arg0 data 0))
(the int (-> arg0 data 2))
(the-as int (-> *wind-work* wind-time))
)
63
)
)

View file

@ -5,3 +5,23 @@
;; name in dgo: load-boundary
;; dgos: GAME, ENGINE
(defmethod reset! load-state ((obj load-state))
(local-vars (v1-1 int))
(set! (-> obj want 0 name) #f)
(set! (-> obj want 0 display?) #f)
(set! (-> obj want 0 force-vis?) #f)
(set! (-> obj want 0 force-inside?) #f)
(set! (-> obj want 1 name) #f)
(set! (-> obj want 1 display?) #f)
(set! (-> obj want 1 force-vis?) #f)
(set! (-> obj want 1 force-inside?) #f)
(set! (-> obj command-list) '())
(set! v1-1 0)
(while (< v1-1 256)
(set! (-> obj object-name v1-1) #f)
(set! (-> obj object-status v1-1) (the basic 0))
(+! v1-1 1)
)
obj
)

View file

@ -5,3 +5,49 @@
;; name in dgo: dynamics-h
;; dgos: GAME, ENGINE
;; 1 / 300.
(defconstant TICKS_TO_SECONDS (the-as float #x3b5a740e))
(deftype dynamics (basic)
((name basic :offset-assert 4)
(gravity-max float :offset-assert 8) ;; meters
(gravity-length float :offset-assert 12) ;; meters
(gravity vector :inline :offset-assert 16)
(gravity-normal vector :inline :offset-assert 32)
(walk-distance float :offset-assert 48) ;meters
(run-distance float :offset-assert 52) ; meters
)
:method-count-assert 9
:size-assert #x38
:flag-assert #x900000038
)
(defun time-to-apex ((arg0 float) (arg1 float))
(the int (/ arg0 (- (* TICKS_TO_SECONDS arg1))))
)
(defun time-to-ground ((velocity float) (gravity float) (height float))
"How long to fall from height?"
(local-vars (v0-0 int) (position float))
(set! position 0.000000)
(set! v0-0 0)
;; loop in ticks until below the ground.
(while (< (- height) position)
(set! velocity (- velocity (* TICKS_TO_SECONDS gravity)))
(+! position (* TICKS_TO_SECONDS velocity))
(+! v0-0 1)
)
v0-0
)
(define *standard-dynamics*
(new 'static 'dynamics
:name 'standard
:gravity-max 163840.000000
:gravity-length 245760.000000
:gravity (new 'static 'vector :y 245760.000000 :w 1.000000)
:gravity-normal (new 'static 'vector :y 1.000000 :w 1.000000)
:walk-distance 8192.000000
:run-distance 20480.000000
)
)

View file

@ -5,3 +5,60 @@
;; name in dgo: memcard-h
;; dgos: GAME, ENGINE
(deftype mc-handle (int32)
()
:flag-assert #x900000004
)
(deftype mc-file-info (structure)
((present int32 :offset-assert 0)
(blind-data float 16 :offset-assert 4)
(blind-data-int8 int8 64 :offset 4)
(level-index int32 :offset 4)
(fuel-cell-count float :offset 8)
(money-count float :offset 12)
(buzzer-count float :offset 16)
(completion-percentage float :offset 20)
(minute uint8 :offset 24)
(hour uint8 :offset 25)
(week uint8 :offset 26)
(day uint8 :offset 27)
(month uint8 :offset 28)
(year uint8 :offset 29)
)
:pack-me
:method-count-assert 9
:size-assert #x44
:flag-assert #x900000044
)
(deftype mc-slot-info (structure)
((handle int32 :offset-assert 0)
(known int32 :offset-assert 4)
(formatted int32 :offset-assert 8)
(inited int32 :offset-assert 12)
(last-file int32 :offset-assert 16)
(mem-required int32 :offset-assert 20)
(mem-actual int32 :offset-assert 24)
(file mc-file-info 4 :inline :offset-assert 28)
)
:pack-me
:method-count-assert 9
:size-assert #x12c
:flag-assert #x90000012c
)
(defun mc-sync ()
"Block here, waiting for the memory card to finish being read/written.
Note - this will freeze the entire game, so this should not be used
outside of debugging."
(local-vars (v0-0 int))
(set! v0-0 0)
(while (zero? v0-0)
;; run the memory card state machine (in C Kenrel)
(mc-run)
;; see if we got a good response
(set! v0-0 (mc-check-result))
)
v0-0
)

View file

@ -4,4 +4,3 @@
;; name: surface-h.gc
;; name in dgo: surface-h
;; dgos: GAME, ENGINE

View file

@ -80,13 +80,13 @@
(define-extern dgo-load (function string kheap int int none))
(define-extern link-begin (function pointer string int kheap int int))
(define-extern link-resume (function int))
;; mc-run
(define-extern mc-run (function none))
;; mc-format
;; mc-unformat
;; mc-create-file
;; mc-save
;; mc-load
;; mc-check-result
(define-extern mc-check-result (function int))
;; mc-get-slot-info
;; mc-makefile
;; kset-language

View file

@ -41,7 +41,7 @@ def main():
file_stats = []
total_gc_files = 0
excluded_files = {"all_files.gc", "goal-lib.gc"}
excluded_files = {"all_files.gc", "goal-lib.gc", "ocean-trans-tables.gc", "ocean-frames.gc"}
for fn in all_files:

View file

@ -216,4 +216,129 @@ TEST_F(DataDecompTest, VifDisasmArray) {
" (new 'static 'vif-disasm-element :mask #x7f :tag #x1 :print #x2 :string1 \"stcycl\")\n"
" (new 'static 'vif-disasm-element :mask #x7f :tag #x2 :print #x1 :string1 \"offset\" "
" :string2 \"offset\"))");
}
TEST_F(DataDecompTest, ContinuePoint) {
std::string input =
" .type continue-point\n"
"L63:\n"
" .word L69\n"
" .symbol finalboss\n"
" .word 0x0\n"
" .word 0x4b303728\n"
" .word 0x4a073f00\n"
" .word 0xcb94152d\n"
" .word 0x3f800000\n"
" .word 0x0\n"
" .word 0x3f3b851f\n"
" .word 0x0\n"
" .word 0x3f2e425b\n"
" .word 0x4b2faddf\n"
" .word 0x4a0869de\n"
" .word 0xcb94485e\n"
" .word 0x3f800000\n"
" .word 0x3f169ad4\n"
" .word 0x0\n"
" .word 0xbf4ef9db\n"
" .word 0x3ddbf488\n"
" .word 0x3f7db8bb\n"
" .word 0x3d9ff2e5\n"
" .word 0x3f4d288d\n"
" .word 0xbe07fcb9\n"
" .word 0x3f15460b\n"
" .word L64\n"
" .symbol fin\n"
" .symbol finalboss\n"
" .symbol display\n"
" .symbol citadel\n"
" .symbol special\n"
" .word 0x0\n"
"L64: (offset 2)\n"
" .word L65\n"
" .empty-list\n"
"L65: (offset 2)\n"
" .symbol special\n"
" .word L66\n"
"L66: (offset 2)\n"
" .word L68\n"
" .word L67\n"
"L67: (offset 2)\n"
" .symbol #t\n"
" .empty-list\n"
" .type string\n"
"L68:\n"
" .word 0x10\n"
" .word 0x62746963\n"
" .word 0x6978652d\n"
" .word 0x6c702d74\n"
" .word 0x342d7461\n"
" .word 0x0\n"
" .word 0x0\n"
" .type string\n"
"L69:\n"
" .word 0xf\n"
" .word 0x616e6966\n"
" .word 0x736f626c\n"
" .word 0x74732d73\n"
" .word 0x747261";
auto parsed = parse_data(input);
auto decomp =
decompile_at_label_guess_type(parsed.label("L63"), parsed.labels, {parsed.words}, dts->ts);
check_forms_equal(decomp.print(),
"(new 'static 'continue-point\n"
" :name \"finalboss-start\"\n"
" :level 'finalboss\n"
" :trans (new 'static 'vector\n"
" :x 11548456.000000\n"
" :y 2215872.000000\n"
" :z -19409498.000000\n"
" :w 1.000000\n"
" )\n"
" :quat (new 'static 'vector\n"
" :y (the-as float #x3f3b851f)\n"
" :w (the-as float #x3f2e425b)\n"
" )\n"
" :camera-trans (new 'static 'vector\n"
" :x 11513311.000000\n"
" :y (the-as float #x4a0869de)\n"
" :z -19435708.000000\n"
" :w 1.000000\n"
" )\n"
" :camera-rot (new 'static 'array 'float 9\n"
" (the-as float #x3f169ad4)\n"
" 0.000000\n"
" (the-as float #xbf4ef9db)\n"
" (the-as float #x3ddbf488)\n"
" (the-as float #x3f7db8bb)\n"
" (the-as float #x3d9ff2e5)\n"
" (the-as float #x3f4d288d)\n"
" (the-as float #xbe07fcb9)\n"
" (the-as float #x3f15460b)\n"
" )\n"
" :load-commands (('special \"citb-exit-plat-4\" #t))\n"
" :vis-nick 'fin\n"
" :lev0 'finalboss\n"
" :disp0 'display\n"
" :lev1 'citadel\n"
" :disp1 'special\n"
" )");
}
TEST_F(DataDecompTest, FloatArray) {
std::string input =
" .type continue-point\n"
"L63:\n"
" .word 0x3f800000\n"
" .word 0x0\n"
" .word 0x3f800000\n"
" .word 0x0\n"
" .word 0x3f800000\n"
" .word 0x0\n"
" .word 0x3f800000\n\n";
auto parsed = parse_data(input);
auto decomp = decompile_at_label_with_hint({"(pointer float)", true, 7}, parsed.label("L63"),
parsed.labels, {parsed.words}, *dts);
check_forms_equal(decomp.print(),
"(new 'static 'array 'float 7\n"
"1.0 0.0 1.0 0.0 1.0 0.0 1.0)");
}

View file

@ -2534,4 +2534,37 @@ TEST_F(FormRegressionTest, ExprAssert) {
std::string expected = "(begin (if (not arg0) (format (quote #t) \"A ~A\" arg1)) 0)";
test_with_expr(func, type, expected, false, "", {{"L17", "A ~A"}});
}
}
//
// TEST_F(FormRegressionTest, ExprTerminal2) {
// std::string func =
// "sll r0, r0, 0\n"
// "L29:\n"
// " daddiu sp, sp, -16\n"
// " sd fp, 8(sp)\n"
// " or fp, t9, r0\n"
//
// //" lwc1 f0, L71(fp)\n"
// " mtc1 f0, r0\n"
// " mtc1 f1, a0\n"
// " mul.s f0, f0, f1\n"
// " mtc1 f1, a1\n"
// " sub.s f0, f0, f1\n"
// " mtc1 f1, a2\n"
// " div.s f0, f0, f1\n"
// " sqrt.s f0, f0\n"
// " mtc1 f1, a1\n"
// " mtc1 f2, a2\n"
// " mul.s f3, f0, f0\n"
// " mul.s f2, f2, f3\n"
// " add.s f1, f1, f2\n"
// " sub.s f0, f0, f1\n"
// " mfc1 v0, f0\n"
// " ld fp, 8(sp)\n"
// " jr ra\n"
// " daddiu sp, sp, 16\n";
// std::string type = "(function float float float float float)";
//
// std::string expected = "(begin (if (not arg0) (format (quote #t) \"A ~A\" arg1)) 0)";
// test_with_expr(func, type, expected, false, "", {{"L17", "A ~A"}});
//}