jak-project/goal_src/engine/level/level-h.gc
water111 a6258f3654
[compiler] support 128-bit bitfields (#500)
* support setting and accessing fields of a 128-bit bitfield

* remove print

* rework static constants

* support 128-bit bitfields as part of static structures

* dynamic construction
2021-05-18 21:25:29 -04:00

418 lines
19 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: level-h.gc
;; name in dgo: level-h
;; dgos: GAME, ENGINE
(defenum bucket-id
:type uint32
:bitfield #f
(tfrag-tex0 5)
;; merc0 10
;; generic0 11
(tfrag-tex1 12)
;; merc1 17
;; generic1 18
(shrub-tex0 19)
(shrub-tex1 25)
(alpha-tex0 31)
(alpha-tex1 38)
(pris-tex0 48)
;; merc0 49
;; generic0 50
(pris-tex1 51)
;; merc1 52
;; generic1 53
(water-tex0 57)
;; merc0 58 (+ default)
;; generic0 59 (+ default)
(water-tex1 60)
;; merc1 61
;; generic1 62
;; debug text 68
)
;; Information related to visibility data for a level.
;; Unclear why there are 8 of these per level.
;; Perhaps there are up to 8 "chunks" of the visibility loaded at a single time?
;; The full visibility data lives on the IOP.
(deftype level-vis-info (basic)
((level basic :offset-assert 4)
(from-level basic :offset-assert 8)
(from-bsp basic :offset-assert 12)
(flags uint32 :offset-assert 16)
(length uint32 :offset-assert 20)
(allocated-length uint32 :offset-assert 24)
(dictionary-length uint32 :offset-assert 28)
(dictionary uint32 :offset-assert 32)
(string-block uint32 :offset-assert 36)
(ramdisk uint32 :offset-assert 40)
(vis-bits uint32 :offset-assert 44)
(current-vis-string uint32 :offset-assert 48)
(vis-string uint8 :dynamic :offset-assert 52)
)
:method-count-assert 9
:size-assert #x34
:flag-assert #x900000034
)
(defmethod asize-of level-vis-info ((obj level-vis-info))
"Get the size of a level-vis-info in memory"
(the-as int (+ (-> level-vis-info size) (-> obj dictionary-length)))
)
;; Per level information related to how to load the level.
;; These are stored in level-info.gc
(deftype level-load-info (basic)
((name-list basic 3 :offset-assert 4)
(index int32 :offset-assert 16) ;; the level number (starting with 1?)
(name basic :offset 4) ;; symbol with full name, like "misty"
(visname basic :offset 8) ;; symbol with vis file name, like "misty-vis"
(nickname basic :offset 12) ;; 3 letter name for DGO, like "mis"
(packages pair :offset-assert 20) ;; list of symbols, usually empty or the level name
(sound-banks pair :offset-assert 24) ;; require sound bank files (list of symbols)
(music-bank basic :offset-assert 28) ;; name of level music
(ambient-sounds pair :offset-assert 32) ;; always empty list.
(mood basic :offset-assert 36) ;; mood object name
(mood-func basic :offset-assert 40) ;; mood update function name
(ocean basic :offset-assert 44) ;; ocean map object
(sky basic :offset-assert 48) ;; boolean to enable sky
(sun-fade float :offset-assert 52) ;; sun/sky setting
(continues pair :offset-assert 56) ;; list of checkpoints
(tasks pair :offset-assert 60) ;; list of boxed integers for tasks
(priority int32 :offset-assert 64) ;; either 100 or 200
(load-commands pair :offset-assert 68) ;; ??
(alt-load-commands pair :offset-assert 72) ;; ??
(bsp-mask uint64 :offset-assert 80) ;; ??
(bsphere sphere :offset-assert 88) ;; boundings sphere of level?
(buzzer int32 :offset-assert 92) ;; which task is the scout fly?
(bottom-height float :offset-assert 96) ;; meters
(run-packages pair :offset-assert 100) ;; possibly unused?
(prev-level basic :offset-assert 104)
(next-level basic :offset-assert 108)
(wait-for-load basic :offset-assert 112)
)
:method-count-assert 9
:size-assert #x74
:flag-assert #x900000074
)
(deftype login-state (basic)
((state int32 :offset-assert 4)
(pos uint32 :offset-assert 8)
(elts uint32 :offset-assert 12)
(elt uint32 16 :offset-assert 16)
)
:method-count-assert 9
:size-assert #x50
:flag-assert #x900000050
)
;; Per level-buffer info about the current loaded level.
(deftype level (basic)
((name basic :offset-assert 4)
(load-name basic :offset-assert 8)
(nickname basic :offset-assert 12)
(index int32 :offset-assert 16)
(status basic :offset-assert 20)
(other basic :offset-assert 24)
(heap kheap :inline :offset-assert 32)
(bsp basic :offset-assert 48)
(art-group basic :offset-assert 52)
(info basic :offset-assert 56)
(texture-page texture-page 9 :offset-assert 60)
(loaded-texture-page basic 16 :offset-assert 96)
(loaded-texture-page-count int32 :offset-assert 160)
(foreground-sink-group dma-foreground-sink-group 3 :inline :offset-assert 176) ;; inline basic, todo check stride.
(foreground-draw-engine basic 3 :offset-assert 272)
(entity basic :offset-assert 284)
(ambient basic :offset-assert 288)
(closest-object float 9 :offset-assert 292)
(upload-size int32 9 :offset-assert 328)
(level-distance float :offset-assert 364) ; meters
(inside-sphere? basic :offset-assert 368)
(inside-boxes? basic :offset-assert 372)
(display? basic :offset-assert 376)
(meta-inside? basic :offset-assert 380)
(mood basic :offset-assert 384)
(mood-func basic :offset-assert 388)
(vis-bits uint32 :offset-assert 392)
(all-visible? basic :offset-assert 396)
(force-all-visible? basic :offset-assert 400)
(linking basic :offset-assert 404)
(vis-info level-vis-info 8 :offset-assert 408)
(vis-self-index int32 :offset-assert 440)
(vis-adj-index int32 :offset-assert 444)
(vis-buffer uint8 2048 :offset-assert 448)
(mem-usage-block basic :offset-assert 2496)
(mem-usage int32 :offset-assert 2500)
(code-memory-start uint32 :offset-assert 2504)
(code-memory-end uint32 :offset-assert 2508)
(texture-mask uint32 9 :offset-assert 2512)
(force-inside? basic :offset-assert 2548)
(pad uint8 56)
)
:method-count-assert 29
:size-assert #xa30
:flag-assert #x1d00000a30
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
(dummy-11 (_type_) 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)
)
)
(declare-type entity-links structure)
;; Main *level* object.
;; There are actually three levels. level0 and level1 correspond to the actual buffered levels
;; The level-default seems to be a fake level that can possibly be used by renderers that
;; don't belong to any level, for example to render Jak.
(deftype level-group (basic)
((length int32 :offset-assert 4)
(unknown-level-1 level :offset-assert 8)
(unknown-level-2 level :offset-assert 12)
(entity-link entity-links :offset 16) ;; not sure what's going on here
(border? basic :offset-assert 20)
(vis? basic :offset-assert 24)
(want-level basic :offset-assert 28)
(receiving-level basic :offset-assert 32)
(load-commands pair :offset-assert 36)
(play? basic :offset-assert 40)
;; there's something? from 40 -> 96.
(hack-pad uint8 :offset 90)
;(level level 3 :inline :offset-assert 96)
;(data level 3 :inline :offset-assert 100)
(level0 level :inline :offset-assert 96) ;; inline basic
(level1 level :inline :offset-assert 2704) ;; inline basic
(level-default level :inline :offset-assert 5312) ;; inline basic
(level level 3 :inline :offset 96)
(pad uint32)
)
:method-count-assert 27
:size-assert #x1ef4
:flag-assert #x1b00001ef4
(: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)
)
)
(define-extern *level* level-group)
(if (zero? *level*)
(set! *level*
(new 'static 'level-group
:length 2
:unknown-level-1 #f
:unknown-level-2 #f
:entity-link #f
:border? #f
:want-level #f
:load-commands '()
:play? #f
:level0
(new 'static 'level
:name #f
:status 'inactive
:foreground-sink-group
(new 'static 'inline-array dma-foreground-sink-group 3
(new 'static 'dma-foreground-sink-group
:sink (new 'static 'array dma-foreground-sink 3
(new 'static 'dma-foreground-sink :bucket 10)
(new 'static 'generic-dma-foreground-sink
:bucket 11 :foreground-output-bucket 1
)
)
)
(new 'static 'dma-foreground-sink-group
:sink (new 'static 'array dma-foreground-sink 3
(new 'static 'dma-foreground-sink
:bucket 49
:foreground-texture-page 1
)
(new 'static 'generic-dma-foreground-sink
:bucket 50 :foreground-texture-page 1
:foreground-output-bucket 1)
)
)
(new 'static 'dma-foreground-sink-group
:sink (new 'static 'array dma-foreground-sink 3
(new 'static 'dma-foreground-sink
:bucket 58
:foreground-texture-page 2
)
(new 'static 'generic-dma-foreground-sink
:bucket 59
:foreground-texture-page 2
:foreground-output-bucket 1
)
)
)
)
:inside-sphere? #f
:inside-boxes? #f
:force-inside? #f
)
:level1
(new 'static 'level
:name #f
:index 1
:status 'inactive
:foreground-sink-group
(new 'static 'inline-array dma-foreground-sink-group 3
(new 'static 'dma-foreground-sink-group
:sink (new 'static 'array dma-foreground-sink 3
(new 'static 'dma-foreground-sink
:bucket 17
:foreground-texture-level 1
)
(new 'static 'generic-dma-foreground-sink
:bucket 18
:foreground-texture-level 1
:foreground-output-bucket 1
)
)
)
(new 'static 'dma-foreground-sink-group
:sink (new 'static 'array dma-foreground-sink 3
(new 'static 'dma-foreground-sink
:bucket 52
:foreground-texture-page 1
:foreground-texture-level 1
)
(new 'static 'generic-dma-foreground-sink
:bucket 53
:foreground-texture-page 1
:foreground-texture-level 1
:foreground-output-bucket 1
)
)
)
(new 'static 'dma-foreground-sink-group
:sink (new 'static 'array dma-foreground-sink 3
(new 'static 'dma-foreground-sink
:bucket 61
:foreground-texture-page 2
:foreground-texture-level 1
)
(new 'static 'generic-dma-foreground-sink
:bucket 62
:foreground-texture-page 2
:foreground-texture-level 1
:foreground-output-bucket 1
)
)
)
)
:inside-sphere? #f
:inside-boxes? #f
:force-inside? #f
)
:level-default
(new 'static 'level
:name 'default
:index 2
:status 'reserved
:foreground-sink-group
(new 'static 'inline-array dma-foreground-sink-group 3
(new 'static 'dma-foreground-sink-group
:sink (new 'static 'array dma-foreground-sink 3
(new 'static 'dma-foreground-sink
:bucket 45
:foreground-texture-level 2
)
(new 'static 'generic-dma-foreground-sink
:bucket 46
:foreground-texture-level 2
:foreground-output-bucket 1
)
)
)
(new 'static 'dma-foreground-sink-group
:sink (new 'static 'array dma-foreground-sink 3
(new 'static 'dma-foreground-sink
:bucket 55
:foreground-texture-page 1
:foreground-texture-level 2
)
(new 'static 'generic-dma-foreground-sink
:bucket 56
:foreground-texture-page 1
:foreground-texture-level 2
:foreground-output-bucket 1
)
)
)
(new 'static 'dma-foreground-sink-group
:sink (new 'static 'array dma-foreground-sink 3
(new 'static 'dma-foreground-sink
:bucket 58
:foreground-texture-page 2
:foreground-texture-level 2
)
(new 'static 'generic-dma-foreground-sink
:bucket 59
:foreground-texture-page 2
:foreground-texture-level 2
:foreground-output-bucket 1
)
)
)
)
:inside-sphere? #f
:inside-boxes? #f
:force-inside? #f
)
)
)
)