diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 3f0738e740..f825a17635 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -15817,9 +15817,10 @@ ;; - Functions -(define-extern entity-info-lookup function) +;; This is a terrible terrible function, here be dragons - https://github.com/water111/jak-project/pull/623! +(define-extern entity-info-lookup (function type entity-info)) -;; - Unknowns +;; - Symbols (define-extern *entity-info* (array entity-info)) diff --git a/goal_src/engine/entity/entity-table.gc b/goal_src/engine/entity/entity-table.gc index 19c7c168d4..67543495b5 100644 --- a/goal_src/engine/entity/entity-table.gc +++ b/goal_src/engine/entity/entity-table.gc @@ -5,3 +5,182 @@ ;; name in dgo: entity-table ;; dgos: GAME, ENGINE +;; definition for symbol *entity-info*, type (array entity-info) +(define + *entity-info* + (the-as (array entity-info) + (new + 'static + 'boxed-array + :type entity-info :length 19 :allocated-length 19 + (new 'static 'entity-info + :ptype + (type-ref sage-finalboss :method-count 53) + :package "l1" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x8000 + ) + (new 'static 'entity-info + :ptype (type-ref robotboss :method-count 21) + :package "l1" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x8000 + ) + (new 'static 'entity-info + :ptype + (type-ref assistant-levitator :method-count 53) + :package "l1" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x8000 + ) + (new 'static 'entity-info + :ptype (type-ref babak :method-count 76) + :package "l1" + :art-group '("babak") + :pool '*16k-dead-pool* + :heap-size #x2800 + ) + (new 'static 'entity-info + :ptype (type-ref racer :method-count 24) + :package "game" + :art-group '("racer") + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref springbox :method-count 20) + :package "game" + :art-group '("bounceytarp") + :pool '*16k-dead-pool* + :heap-size #x1400 + ) + (new 'static 'entity-info + :ptype (type-ref launcher :method-count 20) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x400 + ) + (new 'static 'entity-info + :ptype + (type-ref pickup-spawner :method-count 30) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #xc00 + ) + (new 'static 'entity-info + :ptype (type-ref bucket :method-count 30) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #xc00 + ) + (new 'static 'entity-info + :ptype (type-ref barrel :method-count 30) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #xc00 + ) + (new 'static 'entity-info + :ptype (type-ref crate :method-count 30) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #xc00 + ) + (new 'static 'entity-info + :ptype + (type-ref orb-cache-top :method-count 29) + :package "game" + :art-group '("orb-cache-top") + :pool '*16k-dead-pool* + :heap-size #x1000 + ) + (new 'static 'entity-info + :ptype (type-ref eco :method-count 31) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x1000 + ) + (new 'static 'entity-info + :ptype (type-ref ecovent :method-count 21) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x1000 + ) + (new 'static 'entity-info + :ptype (type-ref fuel-cell :method-count 31) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x1400 + ) + (new 'static 'entity-info + :ptype (type-ref buzzer :method-count 31) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x1000 + ) + (new 'static 'entity-info + :ptype (type-ref money :method-count 31) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x800 + ) + (new 'static 'entity-info + :ptype (type-ref water-vol :method-count 30) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #xc00 + ) + (new 'static 'entity-info + :ptype + (type-ref target-start :method-count 15) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x400 + ) + ) + ) + ) + +;; definition for function entity-info-lookup +;; INFO: Return type mismatch basic vs entity-info. +(defun entity-info-lookup ((arg0 type)) + (the-as entity-info (cond + ((nonzero? (-> arg0 method-table 13)) + (-> arg0 method-table 13) + ) + (else + (let ((v1-1 *entity-info*)) + (dotimes (a1-0 (-> v1-1 length)) + (if (= arg0 (-> v1-1 a1-0 ptype)) + (return (begin + (set! + (-> arg0 method-table 13) + (the-as function (-> v1-1 a1-0)) + ) + (-> v1-1 a1-0) + ) + ) + ) + ) + ) + (set! (-> arg0 method-table 13) #f) + #f + ) + ) + ) + ) + diff --git a/test/decompiler/reference/engine/entity/entity-table_REF.gc b/test/decompiler/reference/engine/entity/entity-table_REF.gc new file mode 100644 index 0000000000..c2a02f75e7 --- /dev/null +++ b/test/decompiler/reference/engine/entity/entity-table_REF.gc @@ -0,0 +1,185 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *entity-info*, type (array entity-info) +(define + *entity-info* + (the-as (array entity-info) + (new + 'static + 'boxed-array + :type entity-info :length 19 :allocated-length 19 + (new 'static 'entity-info + :ptype + (type-ref sage-finalboss :method-count 53) + :package "l1" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x8000 + ) + (new 'static 'entity-info + :ptype (type-ref robotboss :method-count 21) + :package "l1" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x8000 + ) + (new 'static 'entity-info + :ptype + (type-ref assistant-levitator :method-count 53) + :package "l1" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x8000 + ) + (new 'static 'entity-info + :ptype (type-ref babak :method-count 76) + :package "l1" + :art-group '("babak") + :pool '*16k-dead-pool* + :heap-size #x2800 + ) + (new 'static 'entity-info + :ptype (type-ref racer :method-count 24) + :package "game" + :art-group '("racer") + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref springbox :method-count 20) + :package "game" + :art-group '("bounceytarp") + :pool '*16k-dead-pool* + :heap-size #x1400 + ) + (new 'static 'entity-info + :ptype (type-ref launcher :method-count 20) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x400 + ) + (new 'static 'entity-info + :ptype + (type-ref pickup-spawner :method-count 30) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #xc00 + ) + (new 'static 'entity-info + :ptype (type-ref bucket :method-count 30) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #xc00 + ) + (new 'static 'entity-info + :ptype (type-ref barrel :method-count 30) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #xc00 + ) + (new 'static 'entity-info + :ptype (type-ref crate :method-count 30) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #xc00 + ) + (new 'static 'entity-info + :ptype + (type-ref orb-cache-top :method-count 29) + :package "game" + :art-group '("orb-cache-top") + :pool '*16k-dead-pool* + :heap-size #x1000 + ) + (new 'static 'entity-info + :ptype (type-ref eco :method-count 31) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x1000 + ) + (new 'static 'entity-info + :ptype (type-ref ecovent :method-count 21) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x1000 + ) + (new 'static 'entity-info + :ptype (type-ref fuel-cell :method-count 31) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x1400 + ) + (new 'static 'entity-info + :ptype (type-ref buzzer :method-count 31) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x1000 + ) + (new 'static 'entity-info + :ptype (type-ref money :method-count 31) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x800 + ) + (new 'static 'entity-info + :ptype (type-ref water-vol :method-count 30) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #xc00 + ) + (new 'static 'entity-info + :ptype + (type-ref target-start :method-count 15) + :package "game" + :art-group '() + :pool '*16k-dead-pool* + :heap-size #x400 + ) + ) + ) + ) + +;; definition for function entity-info-lookup +;; INFO: Return type mismatch basic vs entity-info. +(defun entity-info-lookup ((arg0 type)) + (the-as entity-info (cond + ((nonzero? (-> arg0 method-table 13)) + (-> arg0 method-table 13) + ) + (else + (let ((v1-1 *entity-info*)) + (dotimes (a1-0 (-> v1-1 length)) + (if (= arg0 (-> v1-1 a1-0 ptype)) + (return (begin + (set! + (-> arg0 method-table 13) + (the-as function (-> v1-1 a1-0)) + ) + (-> v1-1 a1-0) + ) + ) + ) + ) + ) + (set! (-> arg0 method-table 13) #f) + #f + ) + ) + ) + ) + + + + diff --git a/test/decompiler/reference/engine/level/level-h_REF.gc b/test/decompiler/reference/engine/level/level-h_REF.gc index 5c8c52c821..b956ed056e 100644 --- a/test/decompiler/reference/engine/level/level-h_REF.gc +++ b/test/decompiler/reference/engine/level/level-h_REF.gc @@ -204,7 +204,7 @@ (dummy-25 () none 25) (dummy-26 () none 26) (dummy-27 () none 27) - (dummy-28 () none 28) + (dummy-28 (_type_ string) symbol 28) ) ) @@ -301,7 +301,7 @@ (dummy-18 (_type_ symbol) none 18) (dummy-19 (_type_ pair) none 19) (dummy-20 () none 20) - (dummy-21 () none 21) + (dummy-21 (_type_ level-group int) pair 21) (dummy-22 () none 22) (dummy-23 () none 23) (dummy-24 () none 24)