[decomp] yet even more res (#565)

This commit is contained in:
ManDude
2021-06-07 21:26:21 +01:00
committed by GitHub
parent 63821755e6
commit e0a15d5990
7 changed files with 77 additions and 36 deletions
+5 -5
View File
@@ -8917,7 +8917,7 @@
((name symbol :offset 0)
(key-frame float :offset 32)
(elt-type type :offset 64)
(data-offset uint16 :offset 96) ;; guess. (data-offset is 16-bit in Crash)
(data-offset uint16 :offset 96)
(elt-count uint32 :offset 112 :size 15)
(inlined? uint8 :offset 127 :size 1) ;; guess.
)
@@ -8949,15 +8949,15 @@
(sort! (_type_) _type_ 16)
(dummy-17 (_type_ res-tag pointer) res-lump 17)
(dummy-18 (_type_ res-tag res-tag) res-lump 18)
(lookup-tag-idx (_type_ symbol symbol float) res-tag-pair 19)
(lookup-tag-idx (_type_ symbol symbol float) res-tag-pair :no-virtual 19)
(make-property-data (_type_ float res-tag-pair pointer) pointer 20)
(dummy-21 (_type_ pointer symbol symbol float) symbol 21)
(get-curve-data! (_type_ curve symbol symbol float) symbol 21)
)
)
;; - Symbols
(define-extern *res-key-string* string) ;; unknown type
(define-extern *res-key-string* string)
;; ----------------------
@@ -8968,7 +8968,7 @@
;; - Symbols
(define-extern *res-static-buf* pointer) ;; unknown type
(define-extern *res-static-buf* pointer)
(define-extern uinteger type)
(define-extern part-group-pointer? function)
@@ -166,11 +166,6 @@
"draw-sprite2d-xy": [[16, "draw-context"]],
"screen-gradient": [[16, "draw-context"]],
//"(method 18 res-lump)": [[16, "res-tag"]],
//"(method 21 res-lump)": [[16, "res-tag"], [32, "res-tag"]],
//"(method 0 fact-info)": [[16, "res-tag"]],
"(method 10 oscillating-vector)": [[16, "vector"]],
"show-mc-info": [[16, "mc-slot-info"]],
@@ -391,6 +391,13 @@
[22, "t1", "(pointer uint64)"],
[29, "t2", "(pointer uint64)"]
],
"(method 18 res-lump)": [
["_stack_", 16, "res-tag"]
],
"(method 21 res-lump)": [
["_stack_", 16, "res-tag"],
["_stack_", 32, "res-tag"]
],
// SHADOW-CPU-H
"(method 10 shadow-control)": [[1, "v1", "int"]],
+3 -3
View File
@@ -11,7 +11,7 @@
((name symbol :offset 0)
(key-frame float :offset 32)
(elt-type type :offset 64)
(data-offset uint16 :offset 96) ;; guess. (data-offset is 16-bit in Crash)
(data-offset uint16 :offset 96) ;; guess
(elt-count uint32 :offset 112 :size 15)
(inlined? uint8 :offset 127 :size 1) ;; guess.
)
@@ -51,9 +51,9 @@
(sort! (_type_) _type_ 16)
(dummy-17 (_type_ res-tag pointer) res-lump 17)
(dummy-18 (_type_ res-tag res-tag) res-lump 18)
(lookup-tag-idx (_type_ symbol symbol float) res-tag-pair 19)
(lookup-tag-idx (_type_ symbol symbol float) res-tag-pair :no-virtual 19)
(make-property-data (_type_ float res-tag-pair pointer) pointer 20)
(dummy-21 (_type_ pointer symbol symbol float) symbol 21)
(get-curve-data! (_type_ curve symbol symbol float) symbol 21)
)
)
+59 -20
View File
@@ -7,25 +7,30 @@
;; TODO! Needs a lot of 128-bit type support for res-tag
;; res is a generic storage system for values, used for the game entities.
;; The types of values it can store as follows: int8, int16, int32, int64, uint8, uint16, uint32, uint64, float, vector
;; The data itself can also be sorted as a single value or an array.
;;
;; A res-lump stores and is used to access all of the data for a single "resource".
;; This is similar to a C++ map or C# dictionary. The key is a res-tag and the value is the corresponding binary data.
;;
;; A res-tag is a tag that contains information about a particular property of this resource.
;; For example, information about an array of vectors that make up a path - for a moving platform - or an integer to store its entity ID.
;;
;; Keyframes are used to specify when/where the data is relevant.
;; For example (this is made-up), say you have a camera spline, and you want the FOV to change at three specific points:
;; when it starts, somewhere in the middle, and at the end.
;; You would store an array of three FOV values. The key-frame field could then be used to say at which point in the spline
;; the FOV should be at that value. If the camera is somewhere between those points, the result could then be interpolated.
;;
;; Properties are looked up from a res-lump using their name, stored as a symbol. This can return an index to a tag.
;;
;; This is updated from the entity system used in Crash 2, which had most of these features and worked very similarly!
#|
res is a generic storage system for not very large data, used mostly for the game entities.
These res files store collections of data, which can be as values (int8, int16, int32, int64, uint8, uint16, uint32, uint64, float, vector), or any structure (as references), which are tagged and identified with a res-tag.
The data is stored similar to an unboxed inline-array, the type of the data is stored in the res-tag.
A res-lump stores and is used to access all of the data for a single "resource", a collection of varying data.
This is similar to a C++ map or C# dictionary. The key is a res-tag and the value is the corresponding binary data.
A res-tag is a tag that contains information about a particular property of this resource, such as type, name, and amount of elements.
For example, information about an array of vectors that make up a path - for a moving platform - or an integer to store its entity ID.
Keyframes are used to specify when/where the data is relevant.
For example (this is made-up), say you have a camera spline, and you want the FOV to change at three specific points:
when it starts, somewhere in the middle, and at the end.
You would store an array of three FOV values. The key-frame field could then be used to say at which point in the spline
the FOV should be at that value. If the camera is somewhere between those points, the result could then be interpolated.
Properties are looked up from a res-lump using their name (a symbol).
You can look up the data of the property you want directly using the various get-property methods.
Curves can be quickly filled in using the get-curve-data! method.
This is updated from the entity system used in Crash 2, which had most of these features and worked very similarly!
|#
(defmacro res-ref? (tag)
"Checks resource tag, and returns #t if resource data is a reference type, #f if it is inlined."
@@ -656,10 +661,44 @@
obj
)
(defmethod get-curve-data! res-lump ((obj res-lump) (curve-target curve) (points-name symbol) (knots-name symbol) (time float))
"Read curve data and write it to curve-target. Return #t if both control points and knots data was succesfully read, #f otherwise."
(let ((result #f))
;; there's some macro here
(let* ((points-tag (new 'static 'res-tag))
(curve-data (get-property-data obj points-name 'exact time (the pointer #f) (& points-tag) *res-static-buf*)))
(when curve-data
(set! (-> curve-target cverts) (the uint curve-data))
(set! (-> curve-target num-cverts) (the int (-> points-tag elt-count)))
(when (< MAX_CURVE_CONTROL_POINTS (-> curve-target num-cverts))
(format 0 "ERROR<GMJ>: curve has ~D control points--only ~D are allowed. Increase MAX-CURVE-CONTROL-POINTS or shorten the curve.~%"
(-> curve-target num-cverts)
MAX_CURVE_CONTROL_POINTS
)
(set! (-> curve-target num-cverts) MAX_CURVE_CONTROL_POINTS)
)
(let ((knots-tag (new 'static 'res-tag)))
(set! curve-data (get-property-data obj knots-name 'exact time (the pointer #f) (& knots-tag) *res-static-buf*))
(when curve-data
(set! (-> curve-target knots) (the uint curve-data))
(set! (-> curve-target num-knots) (the int (-> knots-tag elt-count)))
(set! result #t)
)
)
)
)
result
)
)
;; method 15 res-lump
;; method 17 res-lump
;; method 18 res-lump
;; method 21 res-lump
;; mem-usage res-lump
+2 -2
View File
@@ -5,7 +5,8 @@
;; name in dgo: geometry-h
;; dgos: GAME, ENGINE
;; geometry-h
(defconstant MAX_CURVE_CONTROL_POINTS 256)
(deftype curve (structure)
((cverts uint32 :offset-assert 0)
(num-cverts int32 :offset-assert 4)
@@ -18,7 +19,6 @@
:flag-assert #x900000014
)
;; geometry-h
(deftype border-plane (basic)
((name basic :offset-assert 4)
(action basic :offset-assert 8)
@@ -42,7 +42,7 @@
(dummy-18 (_type_ res-tag res-tag) res-lump 18)
(lookup-tag-idx (_type_ symbol symbol float) res-tag-pair 19)
(make-property-data (_type_ float res-tag-pair pointer) pointer 20)
(dummy-21 (_type_ pointer symbol symbol float) symbol 21)
(get-curve-data! (_type_ curve symbol symbol float) symbol 21)
)
)