Skip to content

Commit

Permalink
Continue cleanup of source files (#1138)
Browse files Browse the repository at this point in the history
* more cleanup

* tests
  • Loading branch information
water111 authored Feb 6, 2022
1 parent f142f46 commit bcbd115
Show file tree
Hide file tree
Showing 61 changed files with 359 additions and 205 deletions.
12 changes: 3 additions & 9 deletions common/util/Trie.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,9 @@ class Trie {
~Trie();

private:
static constexpr int CHAR_START = ' ';
static constexpr int CHAR_END = '~' + 1;
static constexpr int CHAR_SIZE = CHAR_END - CHAR_START;

static int idx(char c) {
assert(c >= CHAR_START);
assert(c < CHAR_END);
return c - CHAR_START;
}
static constexpr int CHAR_SIZE = 256;

static int idx(char c) { return (u8)c; }

struct Node {
T* value = nullptr;
Expand Down
18 changes: 8 additions & 10 deletions decompiler/config/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -6503,7 +6503,7 @@
:size-assert #x20
:flag-assert #x1300000020
(:methods
(dummy-18 (_type_ vector) none 18)
(execute-ambient (_type_ vector) none 18)
)
)

Expand Down Expand Up @@ -6536,7 +6536,7 @@
;; inherited inspect of process
(:methods
(print-text (_type_) none 14)
(dummy-15 (_type_) symbol 15)
(appeared-for-long-enough? (_type_) symbol 15)
)
(:states
(level-hint-sidekick string)
Expand Down Expand Up @@ -7845,9 +7845,8 @@
:flag-assert #x90000000c
)

(declare-type joint-anim-compressed-hdr structure)
(deftype joint-anim-compressed (joint-anim)
((data joint-anim-compressed-hdr :dynamic :offset-assert 12) ;; guess
((data uint32 :dynamic :offset-assert 12)
)
:method-count-assert 9
:size-assert #xc
Expand All @@ -7856,7 +7855,7 @@

(deftype joint-anim-frame (structure)
((matrices matrix 2 :inline :offset-assert 0)
(data uint32 :dynamic :offset-assert 128) ;; guess
(data matrix :inline :dynamic :offset-assert 128)
)
:method-count-assert 9
:size-assert #x80
Expand All @@ -7868,7 +7867,6 @@

(deftype joint-anim-compressed-hdr (structure)
((control-bits uint32 14 :offset-assert 0)
(unknown-half int16 :score 100 :offset 6) ;; see pov-camera-play-and-reposition
(num-joints uint32 :offset-assert 56)
(matrix-bits uint32 :offset-assert 60)
)
Expand Down Expand Up @@ -7925,8 +7923,8 @@
:flag-assert #xd00000014
(:methods
(login (_type_) _type_ 9)
(dummy-10 (_type_ string type) joint 10) ;; can also be art-joint-anim
(dummy-11 (_type_ string type) int 11)
(lookup-art (_type_ string type) joint 10) ;; can also be art-joint-anim
(lookup-idx-of-art (_type_ string type) int 11)
(needs-link? (_type_) symbol 12)
)
)
Expand Down Expand Up @@ -8033,7 +8031,7 @@
:size-assert #x21
:flag-assert #xa00000021
(:methods
(dummy-9 (_type_ skeleton-group art-group entity) _type_ 9)
(setup-lods! (_type_ skeleton-group art-group entity) _type_ 9)
)
)

Expand Down Expand Up @@ -21255,7 +21253,7 @@

;; - Functions

(define-extern pov-camera-play-and-reposition (function joint-anim-compressed vector float none :behavior pov-camera))
(define-extern pov-camera-play-and-reposition (function art-joint-anim vector float none :behavior pov-camera))


;; ----------------------
Expand Down
6 changes: 3 additions & 3 deletions goal_src/engine/ambient/ambient.gc
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
(the-as
symbol
(and (the-as level-hint a0-0) (and (= (-> (the-as level-hint a0-0) next-state name) 'level-hint-normal)
(not (dummy-15 (the-as level-hint a0-0)))
(not (appeared-for-long-enough? (the-as level-hint a0-0)))
)
)
)
Expand Down Expand Up @@ -398,7 +398,7 @@
(none)
)

(defmethod dummy-15 level-hint ((obj level-hint))
(defmethod appeared-for-long-enough? level-hint ((obj level-hint))
(and (!= (-> obj next-state name) 'level-hint-sidekick) (< 1500 (-> obj total-time)))
)

Expand Down Expand Up @@ -1097,7 +1097,7 @@

(define *execute-ambients* #t)

(defmethod dummy-18 drawable-ambient ((obj drawable-ambient) (arg0 vector))
(defmethod execute-ambient drawable-ambient ((obj drawable-ambient) (arg0 vector))
((-> obj ambient ambient-data function) obj arg0)
0
(none)
Expand Down
22 changes: 11 additions & 11 deletions goal_src/engine/anim/joint.gc
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@
#f
)

(defmethod dummy-10 art ((obj art) (arg0 string) (arg1 type))
(defmethod lookup-art art ((obj art) (arg0 string) (arg1 type))
"Look-up an art with the given name and type."
(the-as joint #f)
)

(defmethod dummy-11 art ((obj art) (arg0 string) (arg1 type))
(defmethod lookup-idx-of-art art ((obj art) (arg0 string) (arg1 type))
"Look up the index of an art with the given name and type."
(the-as int #f)
)
Expand Down Expand Up @@ -351,7 +351,7 @@
)
)

(defmethod dummy-10 art-group ((obj art-group) (arg0 string) (arg1 type))
(defmethod lookup-art art-group ((obj art-group) (arg0 string) (arg1 type))
"Get the art with the given name and type. Set type to false if you don't care."
(the-as
joint
Expand All @@ -369,7 +369,7 @@
)
)
)
(the-as art-element #f)
(the-as art #f)
)
(else
;; no type (also no weird after ag name check)
Expand All @@ -378,13 +378,13 @@
(return (the-as joint (-> obj data s4-1)))
)
)
(the-as art-element #f)
(the-as art #f)
)
)
)
)

(defmethod dummy-11 art-group ((obj art-group) (arg0 string) (arg1 type))
(defmethod lookup-idx-of-art art-group ((obj art-group) (arg0 string) (arg1 type))
"Get the index of the art with the given name and type. Set type to false if you don't care.
Will return #f if the art is not found."
(cond
Expand Down Expand Up @@ -507,7 +507,7 @@
(the-as int (+ (-> art size) (* (-> obj length) 4)))
)

(defmethod dummy-10 art-joint-geo ((obj art-joint-geo) (arg0 string) (arg1 type))
(defmethod lookup-art art-joint-geo ((obj art-joint-geo) (arg0 string) (arg1 type))
(cond
(arg1
(dotimes (s3-0 (-> obj length))
Expand All @@ -528,7 +528,7 @@
)
)

(defmethod dummy-11 art-joint-geo ((obj art-joint-geo) (arg0 string) (arg1 type))
(defmethod lookup-idx-of-art art-joint-geo ((obj art-joint-geo) (arg0 string) (arg1 type))
(cond
(arg1
(dotimes (s3-0 (-> obj length))
Expand Down Expand Up @@ -655,7 +655,7 @@
(sv-48 joint-control-channel)
(sv-52 object)
(sv-56 int)
(sv-64 joint)
(sv-64 art-joint-anim)
(sv-80 string)
)
(set! sv-16 (+ (length (-> arg2 name)) 1))
Expand Down Expand Up @@ -687,10 +687,10 @@
)
)
)
(set! sv-64 (dummy-10 arg1 *temp-string* art-joint-anim))
(set! sv-64 (the-as art-joint-anim (lookup-art arg1 *temp-string* art-joint-anim)))
(cond
(sv-64
(set! (-> sv-48 frame-group) (the-as art-joint-anim sv-64))
(set! (-> sv-48 frame-group) sv-64)
)
(else
(set! (-> sv-48 frame-group) (the-as art-joint-anim (-> arg1 data sv-40)))
Expand Down
26 changes: 11 additions & 15 deletions goal_src/engine/anim/mspace-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,18 @@
;; name in dgo: mspace-h
;; dgos: GAME, ENGINE

;; There's three main types:
;; this file contains types for the skeletal animation system.
;; the "bones" are the actual things with positions/orientations/scales in the game world.
;; the "joints" define how the bones are connected.
;; a "cspace" links together a bone, joint, and a way to control the joint (and bone)

;; There's three main container types:
;; - The cspace-array. This contains references to the bones and the joints. (called node-list)
;; - The skeleton: This contains the bones. (called skeleton)
;; - The joint-control: this has the logic for running joint animations. (called skel)

;; There's three system's involved with animation:
;; - joint control - this figures out which animations to play.
;; the big list of playing animations in *stats-target* are all the joint control channels.

;; - joint decompression. The compressed joint animations store compressed joint data that must
;; be streamed and decompressed.

;; - bones. This is figuring out the location of each "bone" in the world.
;; - The joint-control (not in this file): this has the logic for running joint animations. (called skel)


;; First, the joint. This type just describes how the skeleton is connected.
;; First, the joint. This type just describes how the skeleton is connected and the bind pose.
(deftype joint (basic)
((name basic :offset-assert 4) ;; the joint's name (neckA, neckB, Rtoes, etc)
(number int32 :offset-assert 8) ;; the joint's number in the cspace-array
Expand Down Expand Up @@ -85,9 +81,9 @@
(joint-num int16 :offset-assert 8) ;; seems to be 0 always??
(geo basic :offset-assert 12) ;; seems to be #f always
(bone bone :offset-assert 16) ;; points to our bone.
(param0 function :offset-assert 20) ;; ??
(param1 basic :offset-assert 24) ;; ??
(param2 basic :offset-assert 28) ;; ??
(param0 function :offset-assert 20) ;; function to run to update.
(param1 basic :offset-assert 24) ;; parameter
(param2 basic :offset-assert 28) ;; parameter
)
:method-count-assert 10
:size-assert #x20
Expand Down
12 changes: 6 additions & 6 deletions goal_src/engine/camera/pov-camera.gc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
(suspend)
)
(let ((gp-0 0))
(let ((v1-7 (dummy-10 (-> self draw jgeo) "camera" (the-as type #f))))
(let ((v1-7 (lookup-art (-> self draw jgeo) "camera" (the-as type #f))))
(if v1-7
(set! gp-0 (+ (-> v1-7 number) 1))
)
Expand All @@ -71,14 +71,14 @@
)
)

(defbehavior pov-camera-play-and-reposition pov-camera ((arg0 joint-anim-compressed) (arg1 vector) (arg2 float))
(defbehavior pov-camera-play-and-reposition pov-camera ((arg0 art-joint-anim) (arg1 vector) (arg2 float))
(let ((s4-0 #f))
(let ((v1-2 (-> self skel root-channel 0)))
(set! (-> v1-2 frame-group) (the-as art-joint-anim arg0))
(set! (-> v1-2 param 0) (the float (+ (-> arg0 data 9 unknown-half) -1)))
(set! (-> v1-2 frame-group) arg0)
(set! (-> v1-2 param 0) (the float (+ (-> arg0 data 0 length) -1)))
(set! (-> v1-2 param 1) arg2)
(set! (-> v1-2 frame-num) 0.0)
(joint-control-channel-group! v1-2 (the-as art-joint-anim arg0) num-func-seek!)
(joint-control-channel-group! v1-2 arg0 num-func-seek!)
)
(until (ja-done? 0)
(let ((v1-4 (and (not s4-0) (< (the float (+ (-> (if (> (-> self skel active-channels) 0)
Expand Down Expand Up @@ -282,7 +282,7 @@
(cond
((= (-> arg2 type) string)
(logior! (-> self skel status) 32)
(let ((s5-1 (dummy-10 (-> self draw art-group) arg2 art-joint-anim)))
(let ((s5-1 (lookup-art (-> self draw art-group) arg2 art-joint-anim)))
(if (not s5-1)
(go process-drawable-art-error arg2)
)
Expand Down
17 changes: 0 additions & 17 deletions goal_src/engine/collide/collide-shape.gc
Original file line number Diff line number Diff line change
Expand Up @@ -2177,23 +2177,6 @@
(v1-0 (-> obj cshape))
(a0-1 (-> obj transform-index))
)
;; HACK set all bones to identity. Fixes some issues with press O to talk
;; but doesn't seem to fix mesh issues (may be another bug there)
(#when NO_BONES_HACK
(cond
((nonzero? a1-1)
(cond
((>= a0-1 0)
(dotimes (i (-> a1-1 length))
(matrix-identity! (-> a1-1 data i bone transform))
(set! (-> a1-1 data i bone transform vector 3 quad) (-> v1-0 trans quad))
)
)
)
)
)
(set! a0-1 -2)
)

(cond
((nonzero? a1-1)
Expand Down
Loading

0 comments on commit bcbd115

Please sign in to comment.