Files
jak-project/test/decompiler/reference/jak2/engine/gfx/lightning-h_REF.gc
T
water111 f7bd0752f8 [decomp] Decompile first batch of files in engine (#1787)
* wip

* getting stuff set up so we can actually run test cases

* better handle block entry stuff

* types2 working on gstring

* comments

* math ref working

* up to first stack stuff

* stack fixes

* bounding box

* math stuff is working

* float fixes

* temp debug for (method 9 profile-array)

* stupid stupid bug

* debugging

* everything is broken

* some amount of type stuff works

* bitfield

* texture bitfields not working

* temp

* types

* more stuff

* type check

* temp

* float related fixes for light and res problems

* revisit broken files, fix bugs

* more types

* vector debug

* bug fixes for decompiler crashes in harder functions

* update goal_src
2022-08-24 00:29:51 -04:00

328 lines
13 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type lightning-spec
(deftype lightning-spec (basic)
((name string :offset-assert 4)
(flags lightning-spec-flags :offset-assert 8)
(rand-func uint8 :offset-assert 10)
(adjust-distance uint8 :offset-assert 11)
(start-color uint32 :offset-assert 12)
(end-color uint32 :offset-assert 16)
(fade-to-color uint32 :offset-assert 20)
(fade-start-factor float :offset-assert 24)
(fade-time float :offset-assert 28)
(texture uint32 :offset-assert 32)
(reduction float :offset-assert 36)
(num-points int32 :offset-assert 40)
(box-size float :offset-assert 44)
(merge-factor float :offset-assert 48)
(merge-count int32 :offset-assert 52)
(radius float :offset-assert 56)
(duration float :offset-assert 60)
(duration-rand float :offset-assert 64)
(sound basic :offset-assert 68)
(delay float :offset-assert 72)
(delay-rand float :offset-assert 76)
)
:method-count-assert 9
:size-assert #x50
:flag-assert #x900000050
)
;; definition for method 3 of type lightning-spec
(defmethod inspect lightning-spec ((obj lightning-spec))
(when (not obj)
(set! obj obj)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" obj (-> obj type))
(format #t "~1Tname: ~A~%" (-> obj name))
(format #t "~1Tflags: ~D~%" (-> obj flags))
(format #t "~1Trand-func: ~D~%" (-> obj rand-func))
(format #t "~1Tadjust-distance: ~D~%" (-> obj adjust-distance))
(format #t "~1Tstart-color: ~D~%" (-> obj start-color))
(format #t "~1Tend-color: ~D~%" (-> obj end-color))
(format #t "~1Tfade-to-color: ~D~%" (-> obj fade-to-color))
(format #t "~1Tfade-start-factor: ~f~%" (-> obj fade-start-factor))
(format #t "~1Tfade-time: ~f~%" (-> obj fade-time))
(format #t "~1Ttexture: ~D~%" (-> obj texture))
(format #t "~1Treduction: ~f~%" (-> obj reduction))
(format #t "~1Tnum-points: ~D~%" (-> obj num-points))
(format #t "~1Tbox-size: ~f~%" (-> obj box-size))
(format #t "~1Tmerge-factor: ~f~%" (-> obj merge-factor))
(format #t "~1Tmerge-count: ~D~%" (-> obj merge-count))
(format #t "~1Tradius: ~f~%" (-> obj radius))
(format #t "~1Tduration: ~f~%" (-> obj duration))
(format #t "~1Tduration-rand: ~f~%" (-> obj duration-rand))
(format #t "~1Tsound: ~A~%" (-> obj sound))
(format #t "~1Tdelay: ~f~%" (-> obj delay))
(format #t "~1Tdelay-rand: ~f~%" (-> obj delay-rand))
(label cfg-4)
obj
)
;; definition for function lookup-lightning-spec-by-name
(defun lookup-lightning-spec-by-name ((arg0 string))
(let* ((s5-0 *lightning-spec-id-table*)
(s4-0 (-> s5-0 length))
)
(dotimes (s3-0 s4-0)
(let ((s2-0 (-> s5-0 s3-0)))
(if (and (nonzero? s2-0) (string= arg0 (-> s2-0 name)))
(return s2-0)
)
)
)
)
(the-as lightning-spec #f)
)
;; definition of type lightning-state
(deftype lightning-state (structure)
((mode lightning-mode :offset-assert 0)
(counter float :offset-assert 4)
(points-to-draw int32 :offset-assert 8)
(box-size float :offset-assert 12)
(gcf-control gcf-control :inline :offset-assert 16)
(line vector-array :offset-assert 128)
(meet vector-array :offset-assert 132)
(path vector-array :offset-assert 136)
(start-color uint32 :offset-assert 140)
(end-color uint32 :offset-assert 144)
)
:method-count-assert 9
:size-assert #x94
:flag-assert #x900000094
)
;; definition for method 3 of type lightning-state
(defmethod inspect lightning-state ((obj lightning-state))
(when (not obj)
(set! obj obj)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" obj 'lightning-state)
(format #t "~1Tmode: ~D~%" (-> obj mode))
(format #t "~1Tcounter: ~f~%" (-> obj counter))
(format #t "~1Tpoints-to-draw: ~D~%" (-> obj points-to-draw))
(format #t "~1Tbox-size: ~f~%" (-> obj box-size))
(format #t "~1Tgcf-control: #<gcf-control @ #x~X>~%" (-> obj gcf-control))
(format #t "~1Tline: ~A~%" (-> obj line))
(format #t "~1Tmeet: ~A~%" (-> obj meet))
(format #t "~1Tpath: ~A~%" (-> obj path))
(format #t "~1Tstart-color: ~D~%" (-> obj start-color))
(format #t "~1Tend-color: ~D~%" (-> obj end-color))
(label cfg-4)
obj
)
;; definition of type lightning-control
(deftype lightning-control (basic)
((spec lightning-spec :offset-assert 4)
(process process :offset-assert 8)
(state lightning-state :inline :offset-assert 16)
)
:method-count-assert 14
:size-assert #xa4
:flag-assert #xe000000a4
(:methods
(new (symbol type lightning-spec process float) _type_ 0)
(change-mode (_type_ lightning-mode) lightning-mode 9)
(get-mode (_type_) lightning-mode 10)
(set-point (_type_ int vector) none 11)
(set-first-meet-point (_type_ vector) none 12)
(set-last-meet-point (_type_ vector) none 13)
)
)
;; definition for method 3 of type lightning-control
(defmethod inspect lightning-control ((obj lightning-control))
(when (not obj)
(set! obj obj)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" obj (-> obj type))
(format #t "~1Tspec: ~A~%" (-> obj spec))
(format #t "~1Tprocess: #x~X~%" (-> obj process))
(format #t "~1Tstate: #<lightning-state @ #x~X>~%" (-> obj state))
(label cfg-4)
obj
)
;; definition for method 9 of type lightning-control
(defmethod change-mode lightning-control ((obj lightning-control) (arg0 lightning-mode))
(let ((v1-1 (!= arg0 (-> obj state mode))))
(case arg0
(((lightning-mode lm3))
(if v1-1
(set! (-> obj state counter) 0.0)
)
)
(((lightning-mode lm1))
(set! (-> obj state start-color) (-> obj spec start-color))
(set! (-> obj state end-color) (-> obj spec end-color))
)
)
)
(set! (-> obj state mode) arg0)
arg0
)
;; definition for method 10 of type lightning-control
(defmethod get-mode lightning-control ((obj lightning-control))
(-> obj state mode)
)
;; definition for method 11 of type lightning-control
;; INFO: Used lq/sq
;; INFO: Return type mismatch int vs none.
(defmethod set-point lightning-control ((obj lightning-control) (arg0 int) (arg1 vector))
(let ((v1-0 (-> obj state)))
(when (and (-> v1-0 path) (>= arg0 0) (< arg0 (-> v1-0 path length)))
(set! (-> v1-0 path data arg0 quad) (-> arg1 quad))
(when (and (< (+ (-> v1-0 points-to-draw) -1) arg0) (case (-> v1-0 mode)
(((lightning-mode lm2) (lightning-mode lm3))
#t
)
(else
#f
)
)
)
(set! (-> v1-0 line data arg0 quad) (-> arg1 quad))
(set! (-> v1-0 meet data arg0 quad) (-> arg1 quad))
)
)
)
0
(none)
)
;; definition for method 12 of type lightning-control
;; INFO: Used lq/sq
;; INFO: Return type mismatch (inline-array vector) vs none.
(defmethod set-first-meet-point lightning-control ((obj lightning-control) (arg0 vector))
(set! (-> obj state meet data 0 quad) (-> arg0 quad))
(none)
)
;; definition for method 13 of type lightning-control
;; INFO: Used lq/sq
;; INFO: Return type mismatch vector vs none.
(defmethod set-last-meet-point lightning-control ((obj lightning-control) (arg0 vector))
(set! (-> obj state meet data (+ (-> obj state points-to-draw) -1) quad) (-> arg0 quad))
(none)
)
;; definition for method 7 of type lightning-control
(defmethod relocate lightning-control ((obj lightning-control) (arg0 int))
(&+! (-> obj state line) arg0)
(&+! (-> obj state meet) arg0)
(if (-> obj state path)
(&+! (-> obj state path) arg0)
)
(let ((v1-8 (-> obj spec)))
(if (and (>= (the-as int v1-8) (-> *kernel-context* relocating-min))
(< (the-as int v1-8) (-> *kernel-context* relocating-max))
)
(&+! (-> obj spec) arg0)
)
)
obj
)
;; definition for method 0 of type lightning-control
;; INFO: Return type mismatch object vs lightning-control.
(defmethod new lightning-control ((allocation symbol) (type-to-make type) (arg0 lightning-spec) (arg1 process) (arg2 float))
(with-pp
(let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
(when (zero? obj)
(go process-drawable-art-error "memory")
(set! obj (the-as lightning-control 0))
(goto cfg-14)
)
(let ((s3-0 (-> arg0 num-points)))
(let ((f0-0 (-> arg0 box-size)))
(when (logtest? (-> arg0 flags) (lightning-spec-flags size-from-adjust-dist))
(let ((f1-1 (fmax 1.0 (fmin 5.0 (/ arg2 (* 4096.0 (the float (-> arg0 adjust-distance))))))))
(set! s3-0 (* s3-0 (the int f1-1)))
(set! f0-0 (* f0-0 f1-1))
)
)
(set! (-> obj state box-size) f0-0)
)
(set! (-> obj process) (the-as process (process->ppointer arg1)))
(set! (-> obj state mode) (lightning-mode lm1))
(set! (-> obj state line) ((method-of-type vector-array new) allocation vector-array s3-0))
(set! (-> obj state meet) ((method-of-type vector-array new) allocation vector-array s3-0))
(let ((v1-18 (-> arg0 rand-func)))
(set! (-> obj state path) (if (or (= v1-18 2) (= v1-18 3))
((method-of-type vector-array new) allocation vector-array s3-0)
(the-as vector-array #f)
)
)
)
(set! (-> obj state counter) 0.0)
(set! (-> obj state points-to-draw) s3-0)
)
(set! (-> obj spec) arg0)
(set! (-> obj state start-color) (-> arg0 start-color))
(set! (-> obj state end-color) (-> arg0 end-color))
(add-connection *lightning-engine* pp nothing obj #f #f)
(label cfg-14)
(the-as lightning-control obj)
)
)
)
;; definition of type lightning-probe-vars
(deftype lightning-probe-vars (basic)
((src-joint-index uint32 :offset-assert 4)
(next-spawn-time time-frame :offset-assert 8)
(last-valid-time time-frame :offset-assert 16)
(point vector 2 :inline :offset-assert 32)
(start-pos vector :inline :offset 32)
(end-pos vector :inline :offset 48)
(probe-dirs (inline-array vector) :offset-assert 64)
)
:method-count-assert 9
:size-assert #x44
:flag-assert #x900000044
)
;; definition for method 3 of type lightning-probe-vars
(defmethod inspect lightning-probe-vars ((obj lightning-probe-vars))
(when (not obj)
(set! obj obj)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" obj (-> obj type))
(format #t "~1Tsrc-joint-index: ~D~%" (-> obj src-joint-index))
(format #t "~1Tnext-spawn-time: ~D~%" (-> obj next-spawn-time))
(format #t "~1Tlast-valid-time: ~D~%" (-> obj last-valid-time))
(format #t "~1Tpoint[2] @ #x~X~%" (-> obj point))
(format #t "~1Tstart-pos: #<vector @ #x~X>~%" (-> obj point))
(format #t "~1Tend-pos: #<vector @ #x~X>~%" (-> obj end-pos))
(format #t "~1Tprobe-dirs: #x~X~%" (-> obj probe-dirs))
(label cfg-4)
obj
)
;; definition for symbol *lightning-probe-vars*, type lightning-probe-vars
(define *lightning-probe-vars*
(new 'static 'lightning-probe-vars :probe-dirs (new 'static 'inline-array vector 6
(new 'static 'vector :z 1.0 :w 1.0)
(new 'static 'vector :x 1.0 :w 1.0)
(new 'static 'vector :z -1.0 :w 1.0)
(new 'static 'vector :x -1.0 :w 1.0)
(new 'static 'vector :y 1.0 :w 1.0)
(new 'static 'vector :y -1.0 :w 1.0)
)
)
)