mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
cd68cb671e
Major change to how `deftype` shows up in our code: - the decompiler will no longer emit the `offset-assert`, `method-count-assert`, `size-assert` and `flag-assert` parameters. There are extremely few cases where having this in the decompiled code is helpful, as the types there come from `all-types` which already has those parameters. This also doesn't break type consistency because: - the asserts aren't compared. - the first step of the test uses `all-types`, which has the asserts, which will throw an error if they're bad. - the decompiler won't emit the `heap-base` parameter unless necessary now. - the decompiler will try its hardest to turn a fixed-offset field into an `overlay-at` field. It falls back to the old offset if all else fails. - `overlay-at` now supports field "dereferencing" to specify the offset that's within a field that's a structure, e.g.: ```lisp (deftype foobar (structure) ((vec vector :inline) (flags int32 :overlay-at (-> vec w)) ) ) ``` in this structure, the offset of `flags` will be 12 because that is the final offset of `vec`'s `w` field within this structure. - **removed ID from all method declarations.** IDs are only ever automatically assigned now. Fixes #3068. - added an `:overlay` parameter to method declarations, in order to declare a new method that goes on top of a previously-defined method. Syntax is `:overlay <method-name>`. Please do not ever use this. - added `state-methods` list parameter. This lets you quickly specify a list of states to be put in the method table. Same syntax as the `states` list parameter. The decompiler will try to put as many states in this as it can without messing with the method ID order. Also changes `defmethod` to make the first type definition (before the arguments) optional. The type can now be inferred from the first argument. Fixes #3093. --------- Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
284 lines
12 KiB
Common Lisp
284 lines
12 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: bigmap-h.gc
|
|
;; name in dgo: bigmap-h
|
|
;; dgos: ENGINE, GAME
|
|
|
|
(declare-type bigmap-compressed-layers structure)
|
|
(define-extern *bigmap-compressed-layers* bigmap-compressed-layers)
|
|
|
|
(declare-type bigmap basic)
|
|
(define-extern *bigmap* bigmap)
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype bigmap-bit-mask (structure)
|
|
((data uint8 6656)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype bigmap-layer-mask (structure)
|
|
((data uint8 26624)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype bigmap-image (structure)
|
|
((clut-offset uint32)
|
|
(image-offset uint32)
|
|
(pad uint32 2)
|
|
(data uint8 1)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype bigmap-info (vector)
|
|
((scale float :overlay-at (-> data 2))
|
|
(inv-scale float :overlay-at (-> data 3))
|
|
)
|
|
)
|
|
|
|
|
|
(deftype bigmap-info-array (structure)
|
|
((data bigmap-info 21 :inline)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype bigmap-compressed-layers (structure)
|
|
((data (pointer uint32) 20)
|
|
(layer0 (pointer uint32) :overlay-at (-> data 0))
|
|
(layer1 (pointer uint32) :overlay-at (-> data 1))
|
|
(layer2 (pointer uint32) :overlay-at (-> data 2))
|
|
(layer3 (pointer uint32) :overlay-at (-> data 3))
|
|
(layer4 (pointer uint32) :overlay-at (-> data 4))
|
|
(layer5 (pointer uint32) :overlay-at (-> data 5))
|
|
(layer6 (pointer uint32) :overlay-at (-> data 6))
|
|
(layer7 (pointer uint32) :overlay-at (-> data 7))
|
|
(layer8 (pointer uint32) :overlay-at (-> data 8))
|
|
(layer9 (pointer uint32) :overlay-at (-> data 9))
|
|
(layer10 (pointer uint32) :overlay-at (-> data 10))
|
|
(layer11 (pointer uint32) :overlay-at (-> data 11))
|
|
(layer12 (pointer uint32) :overlay-at (-> data 12))
|
|
(layer13 (pointer uint32) :overlay-at (-> data 13))
|
|
(layer14 (pointer uint32) :overlay-at (-> data 14))
|
|
(layer15 (pointer uint32) :overlay-at (-> data 15))
|
|
(layer16 (pointer uint32) :overlay-at (-> data 16))
|
|
(layer17 (pointer uint32) :overlay-at (-> data 17))
|
|
(layer18 (pointer uint32) :overlay-at (-> data 18))
|
|
(layer19 (pointer uint32) :overlay-at (-> data 19))
|
|
)
|
|
)
|
|
|
|
|
|
(deftype bigmap (basic)
|
|
((drawing-flag symbol)
|
|
(loading-flag symbol)
|
|
(recording-flag symbol)
|
|
(fill-flag symbol)
|
|
(bigmap-index uint32)
|
|
(bigmap-image external-art-buffer)
|
|
(tpage external-art-buffer)
|
|
(progress-minimap texture-page)
|
|
(mask-index uint32)
|
|
(bit-mask bigmap-bit-mask)
|
|
(compressed-next-index uint32)
|
|
(max-next-index uint32)
|
|
(compressed-masks (pointer int8) 20)
|
|
(compressed-data uint32)
|
|
(layer-index uint32)
|
|
(layer-mask bigmap-layer-mask)
|
|
(compressed-layers bigmap-compressed-layers)
|
|
(layer-mask-enable uint32)
|
|
(load-index uint32)
|
|
(x0 int32)
|
|
(y0 int32)
|
|
(x1 int32)
|
|
(y1 int32)
|
|
(y2 int32)
|
|
(goal-time float)
|
|
(sprite-tmpl dma-gif-packet :inline)
|
|
(draw-tmpl dma-gif-packet :inline)
|
|
(adgif-tmpl dma-gif-packet :inline)
|
|
(offset vector :inline)
|
|
(size float :overlay-at (-> offset data 2))
|
|
(scale float :overlay-at (-> offset data 3))
|
|
(draw-offset vector :inline)
|
|
(draw-size float :overlay-at (-> draw-offset data 2))
|
|
(draw-scale float :overlay-at (-> draw-offset data 3))
|
|
(scroll vector :inline)
|
|
(pos vector4w :inline)
|
|
(color vector4w :inline)
|
|
(corner vector 4 :inline)
|
|
(auto-save-icon-flag symbol)
|
|
)
|
|
(:methods
|
|
(new (symbol type) _type_)
|
|
(initialize (_type_) none)
|
|
(update (_type_) none)
|
|
(draw (_type_ int int int int) int)
|
|
(handle-cpad-inputs (_type_) int)
|
|
(compress-all (_type_) int)
|
|
(enable-drawing (_type_) none)
|
|
(disable-drawing (_type_) int)
|
|
(dump-to-file (_type_) file-stream)
|
|
(set-pos! (_type_ vector) int)
|
|
(decompress-current-masks! (_type_) int)
|
|
(compress-current-masks! (_type_) int)
|
|
(set-enable-from-position! (_type_) int)
|
|
(maybe-fill-for-position (_type_ int int) int)
|
|
(texture-upload-dma (_type_ dma-buffer (pointer uint32) int int int gs-psm) none)
|
|
(mask-image-from-bit-mask (_type_) none)
|
|
(draw-non-city-map (_type_ dma-buffer) none)
|
|
(draw-city-map (_type_ dma-buffer) none)
|
|
(sprite-dma (_type_ dma-buffer int int int int) none)
|
|
(draw-from-minimap (_type_ dma-buffer connection-minimap) int)
|
|
)
|
|
)
|
|
|
|
|
|
(defmethod new bigmap ((allocation symbol) (type-to-make type))
|
|
(let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
|
|
(set! (-> gp-0 bigmap-image)
|
|
((method-of-type external-art-buffer new)
|
|
allocation
|
|
external-art-buffer
|
|
0
|
|
(lambda ((arg0 external-art-buffer))
|
|
(let ((a1-3 (logand -64 (&+ (&+ (-> *display* frames 0 global-buf end) -430144) 63)))
|
|
(v1-1 (-> arg0 heap))
|
|
)
|
|
(set! (-> v1-1 base) a1-3)
|
|
(set! (-> v1-1 current) (-> v1-1 base))
|
|
(set! (-> v1-1 top-base) (&+ (-> v1-1 base) #x69000))
|
|
(set! (-> v1-1 top) (-> v1-1 top-base))
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
#f
|
|
)
|
|
)
|
|
(set! (-> gp-0 tpage)
|
|
((method-of-type external-art-buffer new)
|
|
allocation
|
|
external-art-buffer
|
|
0
|
|
(lambda ((arg0 external-art-buffer))
|
|
(let ((a1-3 (logand -64 (&+ (&+ (-> *display* frames 0 global-buf end) -774208) 63)))
|
|
(v1-1 (-> arg0 heap))
|
|
)
|
|
(set! (-> v1-1 base) a1-3)
|
|
(set! (-> v1-1 current) (-> v1-1 base))
|
|
(set! (-> v1-1 top-base) (&+ (-> v1-1 base) #xbd000))
|
|
(set! (-> v1-1 top) (-> v1-1 top-base))
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
#f
|
|
)
|
|
)
|
|
(set! (-> gp-0 bit-mask) (new 'global 'bigmap-bit-mask))
|
|
(set! (-> gp-0 compressed-data) (the-as uint (malloc 'global #x8000)))
|
|
(set! (-> gp-0 layer-mask) (new 'global 'bigmap-layer-mask))
|
|
(set! (-> gp-0 compressed-layers) *bigmap-compressed-layers*)
|
|
(set! (-> gp-0 sprite-tmpl dma-vif dma) (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)))
|
|
(set! (-> gp-0 sprite-tmpl dma-vif vif0) (new 'static 'vif-tag))
|
|
(set! (-> gp-0 sprite-tmpl dma-vif vif1) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1))
|
|
(set! (-> gp-0 sprite-tmpl gif0)
|
|
(the uint64 (new 'static 'gif-tag64
|
|
:nloop #x1
|
|
:eop #x1
|
|
:pre #x1
|
|
:prim (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :abe #x1 :fst #x1)
|
|
:nreg #x5
|
|
)
|
|
)
|
|
)
|
|
(set! (-> gp-0 sprite-tmpl gif1)
|
|
(the uint64 (new 'static 'gif-tag-regs
|
|
:regs0 (gif-reg-id rgbaq)
|
|
:regs1 (gif-reg-id uv)
|
|
:regs2 (gif-reg-id xyz2)
|
|
:regs3 (gif-reg-id uv)
|
|
:regs4 (gif-reg-id xyz2)
|
|
)
|
|
)
|
|
)
|
|
(set! (-> gp-0 draw-tmpl dma-vif dma) (new 'static 'dma-tag :qwc #xa :id (dma-tag-id cnt)))
|
|
(set! (-> gp-0 draw-tmpl dma-vif vif0) (new 'static 'vif-tag))
|
|
(set! (-> gp-0 draw-tmpl dma-vif vif1) (new 'static 'vif-tag :imm #xa :cmd (vif-cmd direct) :msk #x1))
|
|
(set! (-> gp-0 draw-tmpl gif0)
|
|
(the uint64 (new 'static 'gif-tag64
|
|
:nloop #x1
|
|
:eop #x1
|
|
:pre #x1
|
|
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :tme #x1 :abe #x1 :fst #x1)
|
|
:nreg #x9
|
|
)
|
|
)
|
|
)
|
|
(set! (-> gp-0 draw-tmpl gif1) (the uint64 (new 'static 'gif-tag-regs
|
|
:regs0 (gif-reg-id rgbaq)
|
|
:regs1 (gif-reg-id uv)
|
|
:regs2 (gif-reg-id xyz2)
|
|
:regs3 (gif-reg-id uv)
|
|
:regs4 (gif-reg-id xyz2)
|
|
:regs5 (gif-reg-id uv)
|
|
:regs6 (gif-reg-id xyz2)
|
|
:regs7 (gif-reg-id uv)
|
|
:regs8 (gif-reg-id xyz2)
|
|
)
|
|
)
|
|
)
|
|
(set! (-> gp-0 adgif-tmpl dma-vif dma) (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)))
|
|
(set! (-> gp-0 adgif-tmpl dma-vif vif0) (new 'static 'vif-tag))
|
|
(set! (-> gp-0 adgif-tmpl dma-vif vif1) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1))
|
|
(set! (-> gp-0 adgif-tmpl gif0) (the uint64 (new 'static 'gif-tag64 :nloop #x5 :eop #x1 :nreg #x1)))
|
|
(set! (-> gp-0 adgif-tmpl gif1) (the uint64 (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))))
|
|
(set-vector! (-> gp-0 offset) 0.0 0.0 0.0 0.0)
|
|
(set-vector! (-> gp-0 scroll) 0.0 0.0 0.0 0.0)
|
|
(set-vector! (-> gp-0 pos) 0 0 0 0)
|
|
(set-vector! (-> gp-0 color) 128 128 128 128)
|
|
(set! (-> gp-0 drawing-flag) #f)
|
|
(set! (-> gp-0 loading-flag) #f)
|
|
(set! (-> gp-0 recording-flag) #f)
|
|
(set! (-> gp-0 fill-flag) #t)
|
|
(set! (-> gp-0 progress-minimap) #f)
|
|
(set! (-> gp-0 auto-save-icon-flag) #f)
|
|
(initialize gp-0)
|
|
gp-0
|
|
)
|
|
)
|
|
|
|
(define *bigmap-info-array*
|
|
(new 'static 'bigmap-info-array
|
|
:data (new 'static 'inline-array bigmap-info 21
|
|
(new 'static 'bigmap-info :x -251215.88 :y -6390620.0 :scale 7477.334 :inv-scale 0.00006686875)
|
|
(new 'static 'bigmap-info :x -68266.805 :y -7629693.0 :scale 4266.668 :inv-scale 0.00011718746)
|
|
(new 'static 'bigmap-info :x -1612460.0 :y -7806484.5 :scale 3498.668 :inv-scale 0.00014291154)
|
|
(new 'static 'bigmap-info :x 339968.0 :y -8220672.0 :scale 3200.0 :inv-scale 0.00015625)
|
|
(new 'static 'bigmap-info :x -602935.3 :y -9531720.0 :scale 6933.332 :inv-scale 0.0000721154)
|
|
(new 'static 'bigmap-info :x -1565331.5 :y -1109332.0 :scale 5337.4277 :inv-scale 0.000093678085)
|
|
(new 'static 'bigmap-info :x -3681067.0 :y 2179413.2 :scale 4586.668 :inv-scale 0.0001090116)
|
|
(new 'static 'bigmap-info :x 1110016.0 :y -20480.0 :scale 4096.0 :inv-scale 0.00012207031)
|
|
(new 'static 'bigmap-info :x -4358144.0 :y -581632.0 :scale 5469.09 :inv-scale 0.00009142289)
|
|
(new 'static 'bigmap-info :x -1646719.0 :y -1395200.0 :scale 4000.002 :inv-scale 0.00012499993)
|
|
(new 'static 'bigmap-info :x -1292161.0 :y -935251.94 :scale 7253.332 :inv-scale 0.000068933834)
|
|
(new 'static 'bigmap-info :x -87520.055 :y 1879040.0 :scale 2880.0 :inv-scale 0.00017361112)
|
|
(new 'static 'bigmap-info :x -87520.055 :y 1879040.0 :scale 2880.0 :inv-scale 0.00017361112)
|
|
(new 'static 'bigmap-info :x 3053472.2 :y -2397868.0 :scale 3946.668 :inv-scale 0.00012668915)
|
|
(new 'static 'bigmap-info :x 4027306.8 :y 1112746.8 :scale 4693.332 :inv-scale 0.00010653412)
|
|
(new 'static 'bigmap-info :x 4027306.8 :y 1112746.8 :scale 4693.332 :inv-scale 0.00010653412)
|
|
(new 'static 'bigmap-info :x 4027306.8 :y 1112746.8 :scale 4693.332 :inv-scale 0.00010653412)
|
|
(new 'static 'bigmap-info :x 8574157.0 :y -1033420.8 :scale 5430.231 :inv-scale 0.00009207711)
|
|
(new 'static 'bigmap-info :x -787795.94 :y 4102697.0 :scale 5717.332 :inv-scale 0.00008745338)
|
|
(new 'static 'bigmap-info :x -1558401.0 :y 6746452.0 :scale 5866.668 :inv-scale 0.00008522726)
|
|
(new 'static 'bigmap-info)
|
|
)
|
|
)
|
|
)
|