jak-project/goal_src/engine/data/res-h.gc
water111 be74613332
cleanup and bug fix (#1161)
* cleanup and bug fix

* crashing

* fix crash bug

* fix tests
2022-02-13 13:03:30 -05:00

68 lines
2.9 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: res-h.gc
;; name in dgo: res-h
;; dgos: GAME, ENGINE
;; res is the very generic resource storage system. See res.gc for more information.
;; the res-tag describes some data
(deftype res-tag (uint128)
((name symbol :offset 0) ;; name used for lookups
(key-frame float :offset 32) ;; if it has a time value associated with it
(elt-type type :offset 64) ;; the type of the data stored
(data-offset uint16 :offset 96) ;; offset to our data within our lump
(elt-count uint32 :offset 112 :size 15) ;; if we're an array
(inlined? uint8 :offset 127 :size 1) ;; if our data is an inline array or not.
)
:flag-assert #x900000010
)
;; the indices of two res tags. If the specific key-frame time is in between two
;; res-tags, this type is used to return the indices of the first res tag before and after
;; the specified time.
(deftype res-tag-pair (uint64)
((lo int32 :offset 0)
(hi int32 :offset 32)
)
;; made-up type
)
;; a res-lump is a collection of res-tags and the associated data.
;; it's used as the base type for entities where the res stores various parameters.
(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 entity-links :offset-assert 24)
(tag (pointer res-tag) :offset-assert 28)
)
:method-count-assert 22
:size-assert #x20
:flag-assert #x1600000020
;; field extra is a basic loaded with a signed load
(:methods
(new (symbol type int int) _type_ 0)
(get-property-data (_type_ symbol symbol float pointer (pointer res-tag) pointer) pointer :no-virtual 9)
(get-property-struct (_type_ symbol symbol float structure (pointer res-tag) pointer) structure :no-virtual 10)
(get-property-value (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 :no-virtual 11)
(get-property-value-float (_type_ symbol symbol float float (pointer res-tag) pointer) float :no-virtual 12)
(get-tag-index-data (_type_ int) pointer 13)
(get-tag-data (_type_ res-tag) pointer 14)
(allocate-data-memory-for-tag! (_type_ res-tag) res-tag 15)
(sort! (_type_) _type_ 16)
(add-data! (_type_ res-tag pointer) res-lump 17)
(add-32bit-data! (_type_ res-tag object) res-lump 18)
(lookup-tag-idx (_type_ symbol symbol float) res-tag-pair :no-virtual 19)
(make-property-data (_type_ float res-tag-pair pointer) pointer 20)
(get-curve-data! (_type_ curve symbol symbol float) symbol 21)
)
)
(define *res-key-string* (new 'global 'string 64 (the-as string #f))) ;; why 64?
(define-extern *res-static-buf* pointer)