[jak3] Decompile sprite and debug files (#3420)

This commit is contained in:
water111 2024-03-10 21:11:41 -04:00 committed by GitHub
parent 937af7984f
commit fae20a19fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 7546 additions and 147 deletions

View File

@ -8105,7 +8105,7 @@
:size-assert #xbec
:flag-assert #xa00000bec
(:methods
(font-work-method-9 () none) ;; 9
(set-context! (_type_ object) none) ;; 9
)
)
@ -25131,6 +25131,7 @@
(fade-b float :offset-assert 52)
(tex-id texture-id :offset-assert 56) ;; guessed by decompiler
(dummy uint32 :offset-assert 60)
(quads vector 4 :inline :offset 0)
)
:method-count-assert 10
:size-assert #x40
@ -25149,9 +25150,9 @@
:size-assert #x8
:flag-assert #xc00000008
(:methods
(simple-sprite-system-method-9 () none) ;; 9 ;; (add! (_type_ sprite-glow-data) none)
(draw-all-sprites! (_type_ dma-buffer) none) ;; 10
(simple-sprite-system-method-11 () none) ;; 11 ;; (clear! (_type_) none)
(add! "Add a sprite to the list, to be drawn later." (_type_ sprite-glow-data) none) ;; 9
(draw-all-sprites! "Submit all sprites to the sprite-glow renderer" (_type_ dma-buffer) none) ;; 10
(clear! "Reset the list." (_type_) none) ;; 11
)
)
@ -25970,7 +25971,7 @@
(flags sp-cpuinfo-flag :offset-assert 104) ;; guessed by decompiler
(user-int32 int32 :offset-assert 108)
(user-uint32 uint32 :offset 108)
(user-float float :offset 108)
(user-float float :offset 108 :score 1)
(user-pntr uint32 :offset 108)
(user-object basic :offset 108)
(user-sprite sprite-vec-data-2d :offset 108)
@ -29159,42 +29160,41 @@
;; sprite-distort ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#|
(deftype sprite-distorter-sine-tables (basic)
"Table of precomputed sine data for the sprite distorter renderer."
((aspx float :offset-assert 4)
(aspy float :offset-assert 8)
(entry vector 128 :offset-assert 16) ;; guessed by decompiler
(ientry qword 9 :offset-assert 2064) ;; guessed by decompiler
(giftag qword :inline :offset-assert 2208) ;; gs-gif-tag :inline
(entry vector 128 :inline :offset-assert 16) ;; guessed by decompiler
(ientry qword 9 :inline :offset-assert 2064) ;; guessed by decompiler
(giftag gs-gif-tag :inline :offset-assert 2208) ;; :inline
(color qword :inline :offset-assert 2224)
)
:method-count-assert 9
:size-assert #x8c0
:flag-assert #x9000008c0
)
|#
;; (define-extern *sprite-distorter-sine-tables* object) ;; sprite-distorter-sine-tables
(define-extern sprite-distorter-generate-tables (function none))
;; (define-extern sprite-distort-vu1-block object) ;; vu-function
(define-extern sprite-init-distorter (function dma-buffer none))
(define-extern sprite-draw-distorters (function dma-buffer none))
(define-extern *sprite-distorter-sine-tables* sprite-distorter-sine-tables)
(define-extern sprite-distorter-generate-tables "Regenerate the sprite-distorter-sine-tables for the current camera settings." (function none))
(define-extern sprite-distort-vu1-block vu-function)
(define-extern sprite-init-distorter "Generate DMA to initialize the distort renderer." (function dma-buffer none))
(define-extern sprite-draw-distorters "Generate DMA to draw all distort sprites." (function dma-buffer none))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; sprite-glow ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#|
(deftype sprite-glow-template (structure)
"Sprite glow GS data templates sent to VU1."
((clear-init-giftag gs-gif-tag :inline :offset-assert 0)
(clear-init-adcmds gs-adcmd 5 :offset-assert 16) ;; guessed by decompiler
(clear-init-adcmds gs-adcmd 5 :inline :offset-assert 16) ;; guessed by decompiler
(clear-draw-giftag gs-gif-tag :inline :offset-assert 96)
(clear-draw-clr-0 gs-packed-rgba :inline :offset-assert 112)
(clear-draw-xyz-0 gs-packed-xyzw 2 :offset-assert 128) ;; guessed by decompiler
(clear-draw-xyz-0 gs-packed-xyzw 2 :inline :offset-assert 128) ;; guessed by decompiler
(clear-draw-clr-1 gs-packed-rgba :inline :offset-assert 160)
(clear-draw-xyz-1 vector 2 :offset-assert 176) ;; guessed by decompiler
(clear-draw-xyz-1 vector 2 :inline :offset-assert 176) ;; guessed by decompiler
(offscr-setup-giftag gs-gif-tag :inline :offset-assert 208)
(offscr-setup-adcmds gs-adcmd 8 :offset-assert 224) ;; guessed by decompiler
(offscr-setup-adcmds gs-adcmd 8 :inline :offset-assert 224) ;; guessed by decompiler
(offscr-first-giftag gs-gif-tag :inline :offset-assert 352)
(offscr-first-clr gs-packed-rgba :inline :offset-assert 368)
(offscr-first-uv-0 gs-packed-uv :inline :offset-assert 384)
@ -29202,7 +29202,7 @@
(offscr-first-uv-1 gs-packed-uv :inline :offset-assert 416)
(offscr-first-xyzw-1 gs-packed-xyzw :inline :offset-assert 432)
(repeat-draw-giftag gs-gif-tag :inline :offset-assert 448)
(repeat-draw-adcmds gs-adcmd 29 :offset-assert 464) ;; guessed by decompiler
(repeat-draw-adcmds gs-adcmd 29 :inline :offset-assert 464) ;; guessed by decompiler
(flare-alpha-giftag gs-gif-tag :inline :offset-assert 928)
(flare-alpha-clr gs-packed-rgba :inline :offset-assert 944)
(flare-alpha-uv gs-packed-uv :inline :offset-assert 960)
@ -29211,7 +29211,7 @@
(flare-alpha-xyzw-2 gs-packed-xyzw :inline :offset-assert 1008)
(flare-alpha-xyzw-3 gs-packed-xyzw :inline :offset-assert 1024)
(flare-init-giftag gs-gif-tag :inline :offset-assert 1040)
(flare-init-adcmds gs-adcmd 8 :offset-assert 1056) ;; guessed by decompiler
(flare-init-adcmds gs-adcmd 8 :inline :offset-assert 1056) ;; guessed by decompiler
(flare-draw-giftag gs-gif-tag :inline :offset-assert 1184)
(flare-draw-clr gs-packed-rgba :inline :offset-assert 1200)
(flare-draw-stq-0 gs-packed-stq :inline :offset-assert 1216)
@ -29227,19 +29227,18 @@
:size-assert #x540
:flag-assert #x900000540
)
|#
#|
(deftype sprite-glow-consts (structure)
"Per-frame constants for sprite-glow VU1."
((camera matrix :inline :offset-assert 0)
(perspective matrix :inline :offset-assert 64)
(hvdf-offset vector :inline :offset-assert 128)
(hmge-scale vector :inline :offset-assert 144)
(consts vector :inline :offset-assert 160)
(pfog0 float :offset-assert 160)
(deg-to-rad float :offset-assert 164)
(min-scale float :offset-assert 168)
(inv-area float :offset-assert 172)
(pfog0 float :offset 160)
(deg-to-rad float :offset 164)
(min-scale float :offset 168)
(inv-area float :offset 172)
(sincos-01 vector :inline :offset-assert 176)
(sincos-23 vector :inline :offset-assert 192)
(sincos-45 vector :inline :offset-assert 208)
@ -29247,7 +29246,7 @@
(sincos-89 vector :inline :offset-assert 240)
(basis-x vector :inline :offset-assert 256)
(basis-y vector :inline :offset-assert 272)
(xy-array vector 4 :offset-assert 288) ;; guessed by decompiler
(xy-array vector 4 :inline :offset-assert 288) ;; guessed by decompiler
(clamp-min vector :inline :offset-assert 352)
(clamp-max vector :inline :offset-assert 368)
)
@ -29255,10 +29254,9 @@
:size-assert #x180
:flag-assert #x900000180
)
|#
#|
(deftype sprite-glow-dma-packet-data (structure)
"DMA templates for generating DMA to VU1."
((control-packet dma-packet :inline :offset-assert 0)
(vecdata-packet dma-packet :inline :offset-assert 16)
(shader-cnt-packet dma-packet :inline :offset-assert 32)
@ -29269,10 +29267,9 @@
:size-assert #x50
:flag-assert #x900000050
)
|#
#|
(deftype sprite-glow-cnt-template (structure)
"DMA layout for sending a sprite to VU1, with inline shader."
((control-packet dma-packet :inline :offset-assert 0)
(num-sprites uint32 :offset-assert 16)
(dummys uint32 3 :offset-assert 20) ;; guessed by decompiler
@ -29281,56 +29278,56 @@
(shader-packet dma-packet :inline :offset-assert 112)
(shader adgif-shader :inline :offset-assert 128)
(mscal-packet dma-packet :inline :offset-assert 208)
(quads vector 10 :inline :offset 0 :score -1)
)
:method-count-assert 9
:size-assert #xe0
:flag-assert #x9000000e0
)
|#
#|
(deftype sprite-glow-ref-template (structure)
"DMA layout for sending a sprite to VU1, with reference to shader."
((control-packet dma-packet :inline :offset-assert 0)
(num-sprites uint32 :offset-assert 16)
(dummys uint32 3 :offset-assert 20) ;; guessed by decompiler
(num-sprites-quad uint128 :offset 16)
(vecdata-packet dma-packet :inline :offset-assert 32)
(vecdata sprite-glow-data :inline :offset-assert 48)
(shader-packet dma-packet :inline :offset-assert 112)
(shader-packet-ptr pointer :offset 116) ;; pointer to adgif shader to upload.
(mscal-packet dma-packet :inline :offset-assert 128)
)
:method-count-assert 9
:size-assert #x90
:flag-assert #x900000090
)
|#
;; (define-extern *sprite-glow-template* object) ;; sprite-glow-template
;; (define-extern sprite-glow-vu1-block object) ;; vu-function
;; (define-extern sprite-glow-init-consts function) ;; (function sprite-glow-consts none)
(define-extern sprite-glow-init-engine (function dma-buffer none))
;; (define-extern *sprite-glow-dma-packet-data* object) ;; sprite-glow-dma-packet-data
;; (define-extern sprite-glow-add-sprite function) ;; (function dma-buffer sprite-vec-data-2d float float float adgif-shader none)
;; (define-extern sprite-glow-add-simple-sprite function) ;; (function dma-buffer sprite-glow-dma-packet-data sprite-glow-data pointer none)
(define-extern sprite-glow-draw (function dma-buffer none))
;; (define-extern add-shader-to-dma function) ;; (function dma-buffer adgif-shader)
(define-extern *sprite-glow-template* sprite-glow-template)
(define-extern sprite-glow-vu1-block vu-function)
(define-extern sprite-glow-init-consts "Fill out sprite-glow-consts to be sent to VU1." (function sprite-glow-consts none))
(define-extern sprite-glow-init-engine "Generate DMA to initialize sprite-glow VU1." (function dma-buffer none))
(define-extern *sprite-glow-dma-packet-data* sprite-glow-dma-packet-data)
(define-extern sprite-glow-add-sprite "Generate DMA to draw a single sprite from the aux-list." (function dma-buffer sprite-vec-data-2d float float float adgif-shader none))
(define-extern sprite-glow-add-simple-sprite "Generate DMA to draw a single sprite from the simple sprite system." (function dma-buffer sprite-glow-dma-packet-data sprite-glow-data pointer none))
(define-extern sprite-glow-draw "Generate DMA for all glow sprites in the aux-list (from sparticle system)" (function dma-buffer none))
(define-extern add-shader-to-dma (function dma-buffer adgif-shader))
(define-extern *simple-sprite-system* simple-sprite-system)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; debug-sphere ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (define-extern make-debug-sphere-table function) ;; (function vector-array float float vector-array)
;; (define-extern *debug-sphere-table* object) ;; (array vector-array)
;; (define-extern add-debug-sphere-from-table function) ;; (function bucket-id vector meters rgba int none)
(define-extern make-debug-sphere-table "Create a table of lines on a sphere." (function vector-array float float vector-array))
(define-extern *debug-sphere-table* (array vector-array))
(define-extern add-debug-sphere-from-table "Draw a sphere out of debug lines, using the precomputed table of lines." (function bucket-id vector meters rgba int none))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; debug ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#|
(deftype debug-line (structure)
((flags int32 :offset-assert 0)
(bucket int32 :offset-assert 4) ;; bucket-id
(bucket bucket-id :offset-assert 4) ;;
(v1 vector :inline :offset-assert 16)
(v2 vector :inline :offset-assert 32)
(color rgba :offset-assert 48) ;; guessed by decompiler
@ -29341,12 +29338,10 @@
:size-assert #x3c
:flag-assert #x90000003c
)
|#
#|
(deftype debug-text-3d (structure)
((flags int32 :offset-assert 0)
(bucket int32 :offset-assert 4) ;; bucket-id
(bucket bucket-id :offset-assert 4) ;;
(pos vector :inline :offset-assert 16)
(color font-color :offset-assert 32) ;; guessed by decompiler
(offset vector2h :inline :offset-assert 36)
@ -29356,9 +29351,7 @@
:size-assert #x2c
:flag-assert #x90000002c
)
|#
#|
(deftype debug-tracking-thang (basic)
((length int32 :offset-assert 4)
(allocated-length int32 :offset-assert 8)
@ -29367,74 +29360,93 @@
:size-assert #xc
:flag-assert #x90000000c
)
|#
;; debug-vertex-stats is already defined!
;; (define-extern transform-float-point function) ;; (function vector vector4w vector4w)
;; (define-extern add-debug-point function) ;; (function symbol bucket-id vector symbol)
;; (define-extern debug-line-clip? function) ;; (function vector vector vector vector symbol)
;; (define-extern internal-draw-debug-line function) ;; (function bucket-id vector vector rgba symbol rgba pointer)
;; (define-extern internal-draw-debug-text-3d function) ;; (function bucket-id string vector font-color vector2h pointer)
;; (define-extern add-debug-outline-triangle function) ;; (function symbol bucket-id vector vector vector rgba symbol)
;; (define-extern add-debug-triangle-normal function) ;; (function symbol bucket-id vector vector vector rgba symbol)
;; (define-extern add-debug-flat-triangle function) ;; (function symbol bucket-id vector vector vector rgba symbol)
;; (define-extern *debug-lines* object) ;; (inline-array debug-line)
;; (define-extern *debug-lines-trk* object) ;; debug-tracking-thang
;; (define-extern *debug-text-3ds* object) ;; (inline-array debug-text-3d)
;; (define-extern *debug-text-3d-trk* object) ;; debug-tracking-thang
;; (define-extern get-debug-line function) ;; (function debug-line)
;; (define-extern get-debug-text-3d function) ;; (function debug-text-3d)
;; (define-extern debug-reset-buffers function) ;; (function symbol)
;; (define-extern debug-draw-buffers function) ;; (function symbol)
(define-extern add-debug-line (function symbol bucket-id vector vector rgba symbol rgba symbol))
;; (define-extern add-debug-line2d function) ;; (function symbol bucket-id vector4w vector4w vector4w symbol)
;; (define-extern add-debug-box function) ;; (function symbol bucket-id vector vector rgba symbol)
;; (define-extern add-debug-box-with-transform function) ;; (function symbol bucket-id bounding-box matrix rgba symbol)
(define-extern add-debug-x (function symbol bucket-id vector rgba symbol))
;; (define-extern add-debug-cross function) ;; (function symbol bucket-id vector float symbol)
(define-extern add-debug-text-3d (function symbol bucket-id string vector font-color vector2h symbol))
;; (define-extern add-debug-sphere-with-transform function) ;; (function symbol bucket-id vector meters matrix rgba symbol)
(define-extern add-debug-sphere (function symbol bucket-id vector meters rgba symbol))
(define-extern add-debug-text-sphere (function symbol bucket-id vector meters string rgba symbol))
;; (define-extern add-debug-spheres function) ;; (function symbol bucket-id (inline-array vector) int rgba symbol)
;; (define-extern add-debug-line-sphere function) ;; (function symbol bucket-id vector vector float rgba none)
;; (define-extern add-debug-circle function) ;; (function symbol bucket-id vector float rgba matrix symbol)
(define-extern add-debug-vector (function symbol bucket-id vector vector meters rgba symbol))
(define-extern add-debug-matrix (function symbol bucket-id matrix meters matrix))
;; (define-extern add-debug-rot-matrix function) ;; (function symbol bucket-id matrix vector matrix)
(define-extern add-debug-quaternion (function symbol bucket-id vector quaternion none))
;; (define-extern add-debug-cspace function) ;; (function symbol bucket-id cspace cspace)
;; (define-extern add-debug-yrot-vector function) ;; (function symbol bucket-id vector float float rgba symbol)
;; (define-extern add-debug-arc function) ;; (function symbol bucket-id vector float float float rgba matrix symbol)
;; (define-extern add-debug-curve function) ;; (function symbol bucket-id (inline-array vector) int (pointer float) int rgba symbol)
;; (define-extern add-debug-curve2 function) ;; (function symbol bucket-id curve rgba symbol symbol)
;; (define-extern add-debug-points function) ;; (function symbol bucket-id (inline-array vector) int rgba float int symbol)
;; (define-extern debug-percent-bar function) ;; (function symbol bucket-id int int float rgba int int symbol)
;; (define-extern debug-pad-display function) ;; (function cpad-info symbol)
;; (define-extern add-debug-light function) ;; (function symbol bucket-id light vector string symbol)
;; (define-extern add-debug-lights function) ;; (function symbol bucket-id (inline-array light) vector symbol)
(define-extern transform-float-point
"Transform a point, using the cached matrix in VU0 registers, set from init-for-transform.
The argument order is backward - be careful!
After transformation, point is constrained to be within some region, but this is not proper clipping,
so you should do this yourself."
(function vector vector4w vector4w))
(define-extern add-debug-point "Draw a point." (function symbol bucket-id vector symbol))
(define-extern debug-line-clip? (function vector vector vector vector symbol))
(define-extern internal-draw-debug-line "Implementation of line drawing DMA." (function bucket-id vector vector rgba symbol rgba symbol))
(define-extern internal-draw-debug-text-3d "Implementation of 3D text drawing." (function bucket-id string vector font-color vector2h pointer))
(define-extern add-debug-outline-triangle "Draw a wireframe triangle." (function symbol bucket-id vector vector vector rgba symbol))
(define-extern add-debug-triangle-normal "Draw the normal of a triangle." (function symbol bucket-id vector vector vector rgba symbol))
(define-extern add-debug-flat-triangle "Draw a shaded triangle." (function symbol bucket-id vector vector vector rgba symbol))
(define-extern *debug-lines* (inline-array debug-line))
(define-extern *debug-lines-trk* debug-tracking-thang)
(define-extern *debug-text-3ds* (inline-array debug-text-3d))
(define-extern *debug-text-3d-trk* debug-tracking-thang)
(define-extern get-debug-line "Allocate a record for a debug line.
This is used to persist debug drawing for paused objects."
(function debug-line))
(define-extern get-debug-text-3d "Allocate a record for a debug 3d text.
This is used to persist debug drawing for paused objects." (function debug-text-3d))
(define-extern debug-reset-buffers
"Reset buffered debug drawing."
(function symbol))
(define-extern debug-draw-buffers
"Draw all buffered debug drawing."
(function symbol))
(define-extern add-debug-line
"Draw a line."
(function symbol bucket-id vector vector rgba symbol rgba symbol))
(define-extern add-debug-line2d
"Draw a screen-space line."
(function symbol bucket-id vector4w vector4w vector4w symbol))
(define-extern add-debug-box
"Draw an axis-aligned box."
(function symbol bucket-id vector vector rgba symbol))
(define-extern add-debug-box-with-transform
"Draw a box with arbitrary transform."
(function symbol bucket-id bounding-box matrix rgba symbol))
(define-extern add-debug-x "Draw an X." (function symbol bucket-id vector rgba symbol))
(define-extern add-debug-cross "Draw a cross." (function symbol bucket-id vector float symbol))
(define-extern add-debug-text-3d "Draw debug text." (function symbol bucket-id string vector font-color vector2h symbol))
(define-extern add-debug-sphere-with-transform "Draw a debug sphere, applying a transform to the given point first." (function symbol bucket-id vector meters matrix rgba symbol))
(define-extern add-debug-sphere "Draw a debug sphere." (function symbol bucket-id vector meters rgba symbol))
(define-extern add-debug-text-sphere "Draw a debug sphere with a text label." (function symbol bucket-id vector meters string rgba symbol))
(define-extern add-debug-spheres "Draw from an array of spheres. The radius is stored in w." (function symbol bucket-id (inline-array vector) int rgba symbol))
(define-extern add-debug-line-sphere "Draw a capsule as a cylinder." (function symbol bucket-id vector vector float rgba none))
(define-extern add-debug-circle "Draw a circle." (function symbol bucket-id vector float rgba matrix symbol))
(define-extern add-debug-vector "Draw a vector." (function symbol bucket-id vector vector meters rgba symbol))
(define-extern add-debug-matrix "Draw a matrix as a coordinate frame." (function symbol bucket-id matrix meters matrix))
(define-extern add-debug-rot-matrix "Draw a matrix as a coordinate frame, but use the given origin instead of the trans from the matrix." (function symbol bucket-id matrix vector matrix))
(define-extern add-debug-quaternion "Draw a quaternion as a coordinate frame." (function symbol bucket-id vector quaternion none))
(define-extern add-debug-cspace "Draw a cspace as a matrix." (function symbol bucket-id cspace cspace))
(define-extern add-debug-yrot-vector (function symbol bucket-id vector float float rgba symbol))
(define-extern add-debug-arc (function symbol bucket-id vector float float float rgba matrix symbol))
(define-extern add-debug-curve (function symbol bucket-id (inline-array vector) int (pointer float) int rgba symbol))
(define-extern add-debug-curve2 (function symbol bucket-id curve rgba symbol symbol))
(define-extern add-debug-points (function symbol bucket-id (inline-array vector) int rgba float int symbol))
(define-extern debug-percent-bar (function symbol bucket-id int int float rgba int int symbol))
(define-extern debug-pad-display (function cpad-info symbol))
(define-extern add-debug-light (function symbol bucket-id light vector string symbol))
(define-extern add-debug-lights (function symbol bucket-id (inline-array light) vector symbol))
(define-extern drawable-frag-count (function drawable int))
(define-extern drawable-tri-count (function drawable int)) ;; NOTE - defined in kernel?
(define-extern drawable-vertex-ratio (function drawable debug-vertex-stats int)) ;; NOTE - defined in kernel?
;; (define-extern history-init function) ;; (function pos-history int pos-history)
;; (define-extern history-draw-and-update function) ;; (function pos-history symbol vector symbol)
;; (define-extern dma-timeout-cam function) ;; (function vector)
;; (define-extern display-file-info function) ;; (function int)
(define-extern history-init (function pos-history int pos-history))
(define-extern history-draw-and-update (function pos-history symbol vector symbol))
(define-extern dma-timeout-cam (function vector))
(define-extern display-file-info (function int))
(define-extern add-debug-cursor (function symbol bucket-id int int mouse-buttons int))
;; (define-extern *boundary-polygon* object) ;; (inline-array sky-vertex)
;; (define-extern init-boundary-regs function) ;; (function none)
;; (define-extern add-boundary-shader function) ;; (function texture-id dma-buffer none)
(define-extern *boundary-polygon* (inline-array sky-vertex))
(define-extern init-boundary-regs (function none))
(define-extern add-boundary-shader (function texture-id dma-buffer none))
;; (define-extern draw-boundary-polygon function)
;; (define-extern render-boundary-quad function)
;; (define-extern render-boundary-tri function) ;; (function sky-vertex dma-buffer none)
;; (define-extern add-debug-bound-internal function) ;; (function dma-buffer (inline-array vector) int rgba rgba int none)
(define-extern render-boundary-tri (function sky-vertex dma-buffer none))
(define-extern add-debug-bound-internal (function dma-buffer (inline-array vector) int rgba rgba int none))
(define-extern add-debug-bound (function bucket-id (inline-array vector) int rgba rgba int none))
;; (define-extern cpu-delay function) ;; (function int none)
;; (define-extern qword-read-time function) ;; (function (array uint128) int int)
;; (define-extern bugfix? function) ;; (function symbol)
(define-extern qword-read-time (function (array uint128) int int))
(define-extern bugfix? (function symbol))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; history ;;
@ -30079,7 +30091,7 @@
)
;; (define-extern draw-string-asm function) ;; (function string dma-buffer font-context draw-string-result)
;; (define-extern draw-string function) ;; (function string dma-buffer font-context draw-string-result)
(define-extern draw-string (function string dma-buffer font-context draw-string-result))
;; (define-extern get-string-length function) ;; (function string font-context draw-string-result)
(define-extern draw-string-xy (function string dma-buffer int int font-color font-flags draw-string-result))
;; (define-extern draw-string-adv function) ;; (function string dma-buffer font-context none)
@ -31588,7 +31600,7 @@
;; sky-data ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (define-extern *sky-work* object) ;; sky-work
(define-extern *sky-work* sky-work)
;; (define-extern sky-base-polygons object) ;; (inline-array sky-vertex)
;; (define-extern sky-roof-polygons object) ;; (inline-array sky-vertex)
;; (define-extern *cloud-vert-array* object) ;; cloud-vert-array
@ -31610,7 +31622,7 @@
;; (define-extern clip-polygon-against-negative-hyperplane function)
;; (define-extern render-sky-quad function) ;; (function (inline-array sky-vertex) dma-buffer none)
;; (define-extern render-sky-tri function) ;; (function (inline-array sky-vertex) dma-buffer none)
;; (define-extern close-sky-buffer function) ;; (function dma-buffer none)
(define-extern close-sky-buffer (function dma-buffer none))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; load-state ;;
@ -33009,7 +33021,7 @@
;; (define-extern cam-collision-record-step function) ;; (function int none)
;; (define-extern cam-collision-record-draw function) ;; (function none)
;; (define-extern camera-master-debug function) ;; (function camera-master none)
;; (define-extern debug-set-camera-pos-rot! function) ;; (function vector matrix vector)
(define-extern debug-set-camera-pos-rot! (function vector matrix vector))
;; (define-extern cam-restore function) ;; (function none)
;; (define-extern cam-restore-generic-bug function)

View File

@ -90,9 +90,8 @@
"(method 16 ocean)",
// unknown instructions
"debug-line-clip?",
// logand with #f arg
"bugfix?",
// "bugfix?",
// CFG failed
"draw-inline-array-instance-shrub",
@ -273,7 +272,11 @@
"(method 9 curve-color-fast)": [0, 1],
"evaluate-color-curve-fast": [0, 1],
"(anon-function 0 target-death)": [71, 131, 132, 137],
"target-board-handler": [15, 16, 20]
"target-board-handler": [15, 16, 20],
"sprite-draw-distorters": [4, 5],
"(method 10 simple-sprite-system)": [0],
"add-debug-box-with-transform": [0, 3],
"add-debug-line-sphere": [0]
},
// Sometimes the game might use format strings that are fetched dynamically,
@ -409,7 +412,8 @@
"generic-warp-dest",
"generic-warp-envmap-dest",
"generic-no-light-proc",
"(method 21 cloth-system)"
"(method 21 cloth-system)",
"debug-line-clip?"
],
"mips2c_jump_table_functions": {},

View File

@ -275,5 +275,15 @@
["L683", "uint64", true],
["L685", "uint64", true],
["L678", "uint64", true]
],
"sprite-glow": [
["L29", "vu-function"],
["L27", "dma-packet"]
],
"debug": [
["L286", "(inline-array vector)", 3],
["L287", "(inline-array vector)", 3],
["L283", "(inline-array vector)", 32],
["L265", "(inline-array vector)", 4]
]
}

View File

@ -250,5 +250,51 @@
],
"add-a-bunch": [[16, "vector"]],
"birth-pickup-at-point": [[16, "vector"]],
"(code pickup eco)": [[16, "event-message-block"]]
"(code pickup eco)": [[16, "event-message-block"]],
"(method 10 simple-sprite-system)": [[16, ["array", "texture-id", 128]]],
"make-debug-sphere-table": [
[16, "vector"],
[32, "vector"],
[48, "vector"],
[64, "vector"],
[80, "vector"],
[96, "vector"],
[112, "vector"]
],
"add-debug-sphere-from-table": [
[16, "vector"],
[48, "vector"],
[64, "vector"]
],
"internal-draw-debug-line": [
[16, "vector4w-2"],
[48, "vector4w-2"],
[80, "vector"],
[96, "vector"]
],
"add-debug-box-with-transform": [
[16, ["inline-array", "vector", 8]],
[144, ["inline-array", "vector", 2]],
[176, "vector"]
],
"add-debug-line-sphere": [
[48, "matrix"],
[112, "matrix"],
[128, "vector"],
[144, "vector"],
[160, "vector"],
[176, "vector"],
[208, "vector"],
[192, "vector"]
],
"add-debug-arc": [
[16, "vector"],
[32, "vector"]
],
"add-debug-curve": [
[16, "vector"],
[32, "vector"]
],
"add-debug-points": [[16, "vector"]],
"add-debug-cursor": [[16, "vector"]]
}

View File

@ -2082,5 +2082,79 @@
[[109, 116], "a0", "dma-packet"],
[[127, 134], "a0", "dma-packet"],
[[148, 155], "a0", "dma-packet"]
],
"sprite-init-distorter": [
[50, "a3", "uint"],
[[46, 59], "a1", "dma-packet"]
],
"sprite-draw-distorters": [
[[73, 98], "a0", "vector"],
["_stack_", 32, "vector"],
["_stack_", 48, "vector"],
[[174, 199], "a1", "dma-packet"],
[[206, 213], "a0", "dma-packet"],
[[215, 221], "a0", "vector4w"],
[[223, 231], "a0", "dma-packet"],
[[251, 276], "a1", "dma-packet"],
[[281, 288], "a1", "dma-packet"],
[[290, 296], "a1", "vector4w"],
[[297, 305], "v1", "dma-packet"]
],
"sprite-glow-init-engine": [
[[8, 22], "a0", "dma-packet"],
[[32, 50], "a1", "dma-packet"],
[[52, 74], "a1", "dma-packet"],
[[76, 84], "a0", "dma-packet"],
[[85, 92], "v1", "dma-packet"]
],
"sprite-glow-add-sprite": [[[0, 33], "v1", "sprite-glow-cnt-template"]],
"sprite-glow-add-simple-sprite": [
[[0, 33], "v1", "sprite-glow-ref-template"]
],
"add-shader-to-dma": [[[6, 8], "v1", "(pointer uint32)"]],
"add-debug-sphere-from-table": [
[[38, 41], "v1", "vector"],
[[55, 59], "s0", "(inline-array vector)"]
],
"add-debug-point": [
[[36, 43], "a3", "dma-packet"],
[[45, 52], "a3", "gs-gif-tag"],
[[65, 73], "a3", "vector4w-2"],
[[85, 93], "a3", "vector4w-2"],
[[102, 110], "a3", "vector4w-2"],
[[122, 130], "a1", "vector4w-2"],
[[129, 148], "a0", "(pointer uint64)"]
],
"internal-draw-debug-line": [
[[5, 224], "s5", "rgba"],
[[27, 29], "v1", "rgba"],
[[109, 115], "a3", "dma-packet"],
[[118, 124], "a3", "gs-gif-tag"],
[[232, 245], "a1", "(inline-array vector4w-2)"],
[[107, 267], "a0", "(pointer uint64)"]
],
"add-debug-flat-triangle": [
[[73, 80], "a3", "dma-packet"],
[[82, 89], "a3", "gs-gif-tag"],
[[111, 131], "a3", "(inline-array vector)"],
[[68, 149], "a0", "(pointer uint64)"]
],
"add-debug-line2d": [
[[61, 68], "a2", "dma-packet"],
[[70, 77], "a2", "gs-gif-tag"],
[[79, 85], "a2", "vector4w-2"],
[[87, 93], "a2", "vector4w-2"],
[[97, 111], "a0", "(pointer uint64)"]
],
"drawable-frag-count": [[[14, 20], "s5", "drawable-group"]],
"add-boundary-shader": [
[[6, 12], "a0", "gs-gif-tag"],
[[14, 31], "s5", "adgif-shader"]
],
"add-debug-bound": [
//[105, "v1", "dma-packet"],
//[85, "a0", "dma-packet"],
["_stack_", 16, "dma-packet"],
[91, "v1", "dma-packet"]
]
}

View File

@ -1733,5 +1733,251 @@
"sv-56": "overhang-nrm",
"sv-52": "tangent"
}
},
"transform-float-point": {
"args": [
"src-world-pt",
"dst-gs-screen-pt"
]
},
"add-debug-point": {
"args": [
"enable",
"bucket",
"pt"
]
},
"internal-draw-debug-line": {
"args": [
"bucket",
"p0",
"p1",
"color",
"mode",
"color2"
]
},
"internal-draw-debug-text-3d": {
"args": [
"bucket",
"text",
"pos",
"color",
"offset"
]
},
"add-debug-outline-triangle": {
"args": [
"enable",
"bucket",
"p0",
"p1",
"p2",
"color"
]
},
"add-debug-triangle-normal": {
"args": [
"enable",
"bucket",
"p0",
"p1",
"p2",
"color"
]
},
"add-debug-flat-triangle": {
"args": [
"enable",
"bucket",
"p0",
"p1",
"p2",
"color"
]
},
"get-debug-text-3d": {
"args": [
"enable",
"bucket",
"p0",
"p1",
"color",
"mode",
"color2"
]
},
"debug-reset-buffers": {
"args": [
"enable",
"bucket",
"p0",
"p1",
"color"
]
},
"add-debug-line": {
"args": [
"enable",
"bucket",
"p0",
"p1",
"color",
"mode",
"color2"
]
},
"add-debug-line2d": {
"args": [
"enable",
"bucket",
"p0",
"p1",
"color"
]
},
"add-debug-box": {
"args": [
"enable",
"bucket",
"p0",
"p1",
"color"
]
},
"add-debug-box-with-transform": {
"args": [
"enable",
"bucket",
"box",
"mat",
"color"
]
},
"add-debug-x": {
"args": [
"enable",
"bucket",
"pos",
"color"
]
},
"add-debug-cross": {
"args": [
"enable",
"bucket",
"pos",
"len"
]
},
"add-debug-text-3d": {
"args": [
"enable",
"bucket",
"text",
"pos",
"color",
"offset"
]
},
"add-debug-sphere-with-transform": {
"args": [
"enable",
"bucket",
"pos",
"radius",
"mat",
"color"
]
},
"add-debug-sphere": {
"args": [
"enable",
"bucket",
"pos",
"radius",
"color"
]
},
"add-debug-text-sphere": {
"args": [
"enable",
"bucket",
"pos",
"radius",
"text",
"color"
]
},
"add-debug-spheres": {
"args": [
"enable",
"bucket",
"spheres",
"count",
"color"
]
},
"add-debug-line-sphere": {
"args": [
"enable",
"bucket",
"base",
"dir",
"rad",
"color"
]
},
"add-debug-circle": {
"args": [
"enable",
"bucket",
"origin",
"radius",
"color",
"mat"
]
},
"add-debug-vector": {
"args": [
"enable",
"bucket",
"base",
"dir",
"len-scale",
"color"
]
},
"add-debug-matrix": {
"args": [
"enable",
"bucket",
"mat",
"len"
]
},
"add-debug-rot-matrix": {
"args": [
"enable",
"bucket",
"mat",
"len",
"trans"
]
},
"add-debug-quaternion": {
"args": [
"enable",
"bucket",
"trans",
"quat"
]
},
"add-debug-cspace": {
"args": [
"enable",
"bucket",
"cs"
]
}
}

View File

@ -988,6 +988,8 @@ const std::unordered_map<
{{"init-specs", ArrayFieldDecompMeta(TypeSpec("sp-field-init-spec"), 16)}}},
{"sparticle-launch-group",
{{"launcher", ArrayFieldDecompMeta(TypeSpec("sparticle-group-item"), 32)}}},
{"simple-sprite-system",
{{"data", ArrayFieldDecompMeta(TypeSpec("sprite-glow-data"), 64)}}},
}}};
goos::Object decompile_structure(const TypeSpec& type,

View File

@ -185,7 +185,9 @@ set(RUNTIME_SOURCE
mips2c/jak2_functions/texture.cpp
mips2c/jak2_functions/vortex.cpp
mips2c/jak3_functions/collide_func.cpp
mips2c/jak3_functions/debug.cpp
mips2c/jak3_functions/lights.cpp
mips2c/jak3_functions/sky.cpp
mips2c/mips2c_table.cpp
overlord/common/dma.cpp
overlord/common/fake_iso.cpp

View File

@ -0,0 +1,597 @@
//--------------------------MIPS2C---------------------
// clang-format off
#include "game/mips2c/mips2c_private.h"
#include "game/kernel/jak3/kscheme.h"
#include "game/mips2c/jak3_functions/sky.h"
using ::jak3::intern_from_c;
namespace Mips2C::jak3 {
namespace debug_line_clip {
struct Cache {
void* math_camera; // *math-camera*
} cache;
void qfsrv_same_mtsab_4(ExecutionContext* c, int reg) {
u32 temp[4];
auto& val = c->gprs[reg];
temp[0] = val.du32[1];
temp[1] = val.du32[2];
temp[2] = val.du32[3];
temp[3] = val.du32[0];
val.du32[0] = temp[0];
val.du32[1] = temp[1];
val.du32[2] = temp[2];
val.du32[3] = temp[3];
}
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
bool bc = false;
bool cop1_bc = false;
c->load_symbol2(v1, cache.math_camera); // lw v1, *math-camera*(s7)
c->lqc2(vf9, 0, a2); // lqc2 vf9, 0(a2)
c->lqc2(vf10, 0, a3); // lqc2 vf10, 0(a3)
c->lqc2(vf16, 940, v1); // lqc2 vf16, 940(v1)
c->lqc2(vf17, 956, v1); // lqc2 vf17, 956(v1)
c->lqc2(vf18, 972, v1); // lqc2 vf18, 972(v1)
c->lqc2(vf19, 988, v1); // lqc2 vf19, 988(v1)
c->vmula_bc(DEST::xyzw, BC::x, vf16, vf9); // vmulax.xyzw acc, vf16, vf9
c->vmadda_bc(DEST::xyzw, BC::y, vf17, vf9); // vmadday.xyzw acc, vf17, vf9
c->vmadda_bc(DEST::xyzw, BC::z, vf18, vf9); // vmaddaz.xyzw acc, vf18, vf9
c->vmsub_bc(DEST::xyzw, BC::w, vf11, vf19, vf0); // vmsubw.xyzw vf11, vf19, vf0
c->vmula_bc(DEST::xyzw, BC::x, vf16, vf10); // vmulax.xyzw acc, vf16, vf10
c->vmadda_bc(DEST::xyzw, BC::y, vf17, vf10); // vmadday.xyzw acc, vf17, vf10
c->vmadda_bc(DEST::xyzw, BC::z, vf18, vf10); // vmaddaz.xyzw acc, vf18, vf10
c->vmsub_bc(DEST::xyzw, BC::w, vf12, vf19, vf0); // vmsubw.xyzw vf12, vf19, vf0
c->mov128_gpr_vf(v1, vf11); // qmfc2.i v1, vf11
c->pcgtw(v1, r0, v1); // pcgtw v1, r0, v1
c->ppach(a2, r0, v1); // ppach a2, r0, v1
c->mov128_gpr_vf(v1, vf12); // qmfc2.i v1, vf12
c->pcgtw(v1, r0, v1); // pcgtw v1, r0, v1
c->ppach(a3, r0, v1); // ppach a3, r0, v1
c->and_(v1, a2, a3); // and v1, a2, a3
bc = c->sgpr64(v1) != 0; // bne v1, r0, L253
// nop // sll r0, r0, 0
if (bc) {goto block_10;} // branch non-likely
c->vmove(DEST::xyzw, vf13, vf9); // vmove.xyzw vf13, vf9
c->vmove(DEST::xyzw, vf14, vf10); // vmove.xyzw vf14, vf10
c->or_(a2, a2, a3); // or a2, a2, a3
bc = c->sgpr64(a2) == 0; // beq a2, r0, L252
// nop // sll r0, r0, 0
if (bc) {goto block_9;} // branch non-likely
c->mov128_gpr_vf(a2, vf11); // qmfc2.i a2, vf11
c->mov128_gpr_vf(a3, vf12); // qmfc2.i a3, vf12
c->mtc1(f0, r0); // mtc1 f0, r0
c->mtc1(f1, r0); // mtc1 f1, r0
c->lui(t0, 16256); // lui t0, 16256
c->mtc1(f2, t0); // mtc1 f2, t0
c->addiu(t0, r0, 3); // addiu t0, r0, 3
// Unknown instr: mtsab r0, 4
block_3:
c->mtc1(f3, a2); // mtc1 f3, a2
c->mtc1(f4, a3); // mtc1 f4, a3
c->subs(f5, f3, f4); // sub.s f5, f3, f4
cop1_bc = c->fprs[f3] < c->fprs[f0]; // c.lt.s f3, f0
bc = !cop1_bc; // bc1f L250
// nop // sll r0, r0, 0
if (bc) {goto block_5;} // branch non-likely
c->divs(f6, f3, f5); // div.s f6, f3, f5
c->maxs(f1, f6, f1); // max.s f1, f6, f1
block_5:
cop1_bc = c->fprs[f4] < c->fprs[f0]; // c.lt.s f4, f0
bc = !cop1_bc; // bc1f L251
// nop // sll r0, r0, 0
if (bc) {goto block_7;} // branch non-likely
c->divs(f3, f3, f5); // div.s f3, f3, f5
c->mins(f2, f3, f2); // min.s f2, f3, f2
block_7:
// Unknown instr: qfsrv a2, a2, a2
qfsrv_same_mtsab_4(c, a2);
// Unknown instr: qfsrv a3, a3, a3
qfsrv_same_mtsab_4(c, a3);
bc = c->sgpr64(t0) != 0; // bne t0, r0, L249
c->daddiu(t0, t0, -1); // daddiu t0, t0, -1
if (bc) {goto block_3;} // branch non-likely
c->mfc1(a2, f1); // mfc1 a2, f1
c->mfc1(a3, f2); // mfc1 a3, f2
c->mov128_vf_gpr(vf20, a2); // qmtc2.i vf20, a2
c->mov128_vf_gpr(vf21, a3); // qmtc2.i vf21, a3
c->vsub(DEST::xyzw, vf15, vf10, vf9); // vsub.xyzw vf15, vf10, vf9
c->vmul_bc(DEST::xyzw, BC::x, vf13, vf15, vf20); // vmulx.xyzw vf13, vf15, vf20
c->vadd(DEST::xyzw, vf13, vf9, vf13); // vadd.xyzw vf13, vf9, vf13
c->vmul_bc(DEST::xyzw, BC::x, vf14, vf15, vf21); // vmulx.xyzw vf14, vf15, vf21
c->vadd(DEST::xyzw, vf14, vf9, vf14); // vadd.xyzw vf14, vf9, vf14
block_9:
c->sqc2(vf13, 0, a0); // sqc2 vf13, 0(a0)
c->sqc2(vf14, 0, a1); // sqc2 vf14, 0(a1)
block_10:
c->daddiu(v0, s7, 4); // daddiu v0, s7, 4
c->movn(v0, s7, v1); // movn v0, s7, v1
//jr ra // jr ra
c->daddu(sp, sp, r0); // daddu sp, sp, r0
goto end_of_function; // return
// nop // sll r0, r0, 0
// nop // sll r0, r0, 0
end_of_function:
return c->gprs[v0].du64[0];
}
void link() {
cache.math_camera = intern_from_c(-1, 0, "*math-camera*").c();
gLinkedFunctionTable.reg("debug-line-clip?", execute, 32);
}
} // namespace debug_line_clip
} // namespace Mips2C
//--------------------------MIPS2C---------------------
// clang-format off
#include "game/mips2c/mips2c_private.h"
#include "game/kernel/jak3/kscheme.h"
using ::jak3::intern_from_c;
namespace Mips2C::jak3 {
namespace init_boundary_regs {
struct Cache {
void* math_camera; // *math-camera*
void* sky_work; // *sky-work*
} cache;
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
bool bc = false;
u32 call_addr = 0;
c->load_symbol2(v1, cache.math_camera); // lw v1, *math-camera*(s7)
c->load_symbol2(a0, cache.sky_work); // lw a0, *sky-work*(s7)
c->daddiu(a0, a0, 1088); // daddiu a0, a0, 1088
c->lwc1(f0, 908, v1); // lwc1 f0, 908(v1)
c->swc1(f0, 0, a0); // swc1 f0, 0(a0)
c->lwc1(f0, 128, v1); // lwc1 f0, 128(v1)
c->swc1(f0, 4, a0); // swc1 f0, 4(a0)
c->lwc1(f0, 124, v1); // lwc1 f0, 124(v1)
c->swc1(f0, 8, a0); // swc1 f0, 8(a0)
c->lui(a1, 17727); // lui a1, 17727
c->ori(a1, a1, 61440); // ori a1, a1, 61440
c->mtc1(f0, a1); // mtc1 f0, a1
c->swc1(f0, 12, a0); // swc1 f0, 12(a0)
c->lqc2(vf31, 572, v1); // lqc2 vf31, 572(v1)
c->lqc2(vf30, 588, v1); // lqc2 vf30, 588(v1)
c->lqc2(vf29, 604, v1); // lqc2 vf29, 604(v1)
c->lqc2(vf28, 620, v1); // lqc2 vf28, 620(v1)
c->lqc2(vf14, 780, v1); // lqc2 vf14, 780(v1)
c->lqc2(vf26, 796, v1); // lqc2 vf26, 796(v1)
c->lqc2(vf25, 812, v1); // lqc2 vf25, 812(v1)
c->load_symbol2(v1, cache.sky_work); // lw v1, *sky-work*(s7)
c->lqc2(vf13, 1088, v1); // lqc2 vf13, 1088(v1)
c->vmul(DEST::xyzw, vf31, vf31, vf14); // vmul.xyzw vf31, vf31, vf14
c->vmul(DEST::xyzw, vf30, vf30, vf14); // vmul.xyzw vf30, vf30, vf14
c->vmul(DEST::xyzw, vf29, vf29, vf14); // vmul.xyzw vf29, vf29, vf14
c->vmul(DEST::xyzw, vf28, vf28, vf14); // vmul.xyzw vf28, vf28, vf14
c->vmove(DEST::xyzw, vf24, vf0); // vmove.xyzw vf24, vf0
c->mov128_gpr_vf(v1, vf24); // qmfc2.i v1, vf24
c->gprs[v0].du64[0] = 0; // or v0, r0, r0
//jr ra // jr ra
c->daddu(sp, sp, r0); // daddu sp, sp, r0
goto end_of_function; // return
// nop // sll r0, r0, 0
// nop // sll r0, r0, 0
end_of_function:
sky_regs_vfs.copy_vfs_from_other(c);
return c->gprs[v0].du64[0];
}
void link() {
cache.math_camera = intern_from_c(-1, 0, "*math-camera*").c();
cache.sky_work = intern_from_c(-1, 0, "*sky-work*").c();
gLinkedFunctionTable.reg("init-boundary-regs", execute, 128);
}
} // namespace init_boundary_regs
} // namespace Mips2C
//--------------------------MIPS2C---------------------
// clang-format off
#include "game/mips2c/mips2c_private.h"
#include "game/kernel/jak3/kscheme.h"
using ::jak3::intern_from_c;
namespace Mips2C::jak3 {
namespace draw_boundary_polygon {
struct Cache {
void* clip_polygon_against_negative_hyperplane; // clip-polygon-against-negative-hyperplane
void* clip_polygon_against_positive_hyperplane; // clip-polygon-against-positive-hyperplane
} cache;
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
bool bc = false;
u32 call_addr = 0;
// nop // sll r0, r0, 0
c->daddiu(sp, sp, -8); // daddiu sp, sp, -8
// nop // sll r0, r0, 0
c->sd(ra, 0, sp); // sd ra, 0(sp)
c->load_symbol2(t9, cache.clip_polygon_against_positive_hyperplane);// lw t9, clip-polygon-against-positive-hyperplane(s7)
c->mov64(a2, t4); // or a2, t4, r0
c->mov64(a3, t5); // or a3, t5, r0
call_addr = c->gprs[t9].du32[0]; // function call:
c->daddu(t2, a2, r0); // daddu t2, a2, r0
// c->jalr(call_addr); // jalr ra, t9
clip_polygon_against_positive_hyperplane::execute(ctxt);
bc = c->sgpr64(t0) == 0; // beq t0, r0, L36
// nop // sll r0, r0, 0
if (bc) {goto block_7;} // branch non-likely
c->mov64(a2, t5); // or a2, t5, r0
c->mov64(a3, t4); // or a3, t4, r0
call_addr = c->gprs[t9].du32[0]; // function call:
c->daddiu(t2, a2, 4); // daddiu t2, a2, 4
// c->jalr(call_addr); // jalr ra, t9
clip_polygon_against_positive_hyperplane::execute(ctxt);
bc = c->sgpr64(t0) == 0; // beq t0, r0, L36
c->load_symbol2(t9, cache.clip_polygon_against_negative_hyperplane);// lw t9, clip-polygon-against-negative-hyperplane(s7)
if (bc) {goto block_7;} // branch non-likely
c->mov64(a2, t4); // or a2, t4, r0
c->mov64(a3, t5); // or a3, t5, r0
call_addr = c->gprs[t9].du32[0]; // function call:
c->daddu(t2, a2, r0); // daddu t2, a2, r0
// c->jalr(call_addr); // jalr ra, t9
clip_polygon_against_negative_hyperplane::execute(ctxt);
bc = c->sgpr64(t0) == 0; // beq t0, r0, L36
// nop // sll r0, r0, 0
if (bc) {goto block_7;} // branch non-likely
c->mov64(a2, t5); // or a2, t5, r0
c->mov64(a3, t4); // or a3, t4, r0
call_addr = c->gprs[t9].du32[0]; // function call:
c->daddiu(t2, a2, 4); // daddiu t2, a2, 4
// c->jalr(call_addr); // jalr ra, t9
clip_polygon_against_negative_hyperplane::execute(ctxt);
bc = c->sgpr64(t0) == 0; // beq t0, r0, L36
c->lw(a3, 4, a1); // lw a3, 4(a1)
if (bc) {goto block_7;} // branch non-likely
c->mov64(a2, t4); // or a2, t4, r0
// nop // sll r0, r0, 0
c->sqc2(vf27, 0, a3); // sqc2 vf27, 0(a3)
c->daddiu(a3, a3, 16); // daddiu a3, a3, 16
c->sw(t0, -16, a3); // sw t0, -16(a3)
// nop // sll r0, r0, 0
block_5:
c->lqc2(vf1, 0, a2); // lqc2 vf1, 0(a2)
// nop // sll r0, r0, 0
c->lqc2(vf2, 16, a2); // lqc2 vf2, 16(a2)
// nop // sll r0, r0, 0
c->lqc2(vf3, 32, a2); // lqc2 vf3, 32(a2)
c->vdiv(vf0, BC::w, vf1, BC::w); // vdiv Q, vf0.w, vf1.w
c->vmul(DEST::xyzw, vf1, vf1, vf26); // vmul.xyzw vf1, vf1, vf26
// nop // sll r0, r0, 0
c->vftoi0(DEST::xyzw, vf3, vf3); // vftoi0.xyzw vf3, vf3
// nop // sll r0, r0, 0
c->vadd(DEST::xyzw, vf2, vf2, vf24); // vadd.xyzw vf2, vf2, vf24
// nop // sll r0, r0, 0
c->vwaitq(); // vwaitq
// nop // sll r0, r0, 0
c->vmulq(DEST::xyz, vf1, vf1); // vmulq.xyz vf1, vf1, Q
c->sqc2(vf3, 16, a3); // sqc2 vf3, 16(a3)
c->vmulq(DEST::xyzw, vf2, vf2); // vmulq.xyzw vf2, vf2, Q
c->daddiu(a2, a2, 48); // daddiu a2, a2, 48
c->vadd(DEST::xyzw, vf1, vf1, vf25); // vadd.xyzw vf1, vf1, vf25
c->daddiu(a3, a3, 48); // daddiu a3, a3, 48
c->vmax_bc(DEST::z, BC::z, vf1, vf1, vf0); // vmaxz.z vf1, vf1, vf0
// nop // sll r0, r0, 0
c->vmini_bc(DEST::w, BC::z, vf1, vf1, vf13); // vminiz.w vf1, vf1, vf13
// nop // sll r0, r0, 0
c->vmax_bc(DEST::w, BC::y, vf1, vf1, vf13); // vmaxy.w vf1, vf1, vf13
// nop // sll r0, r0, 0
c->sqc2(vf2, -48, a3); // sqc2 vf2, -48(a3)
c->daddiu(t0, t0, -1); // daddiu t0, t0, -1
c->vftoi4(DEST::xyzw, vf1, vf1); // vftoi4.xyzw vf1, vf1
// nop // sll r0, r0, 0
bc = c->sgpr64(t0) != 0; // bne t0, r0, L35
c->sqc2(vf1, -16, a3); // sqc2 vf1, -16(a3)
if (bc) {goto block_5;} // branch non-likely
c->sw(a3, 4, a1); // sw a3, 4(a1)
// nop // sll r0, r0, 0
c->ld(ra, 0, sp); // ld ra, 0(sp)
c->daddiu(v0, s7, 4); // daddiu v0, s7, 4
//jr ra // jr ra
c->daddiu(sp, sp, 8); // daddiu sp, sp, 8
goto end_of_function; // return
block_7:
c->ld(ra, 0, sp); // ld ra, 0(sp)
c->mov64(v0, s7); // or v0, s7, r0
//jr ra // jr ra
c->daddiu(sp, sp, 8); // daddiu sp, sp, 8
goto end_of_function; // return
//jr ra // jr ra
c->daddu(sp, sp, r0); // daddu sp, sp, r0
goto end_of_function; // return
// nop // sll r0, r0, 0
// nop // sll r0, r0, 0
end_of_function:
return c->gprs[v0].du64[0];
}
void link() {
cache.clip_polygon_against_negative_hyperplane = intern_from_c(-1, 0, "clip-polygon-against-negative-hyperplane").c();
cache.clip_polygon_against_positive_hyperplane = intern_from_c(-1, 0, "clip-polygon-against-positive-hyperplane").c();
gLinkedFunctionTable.reg("draw-boundary-polygon", execute, 1024);
}
} // namespace draw_boundary_polygon
} // namespace Mips2C
//--------------------------MIPS2C---------------------
// clang-format off
#include "game/mips2c/mips2c_private.h"
#include "game/kernel/jak3/kscheme.h"
using ::jak3::intern_from_c;
namespace Mips2C::jak3 {
namespace render_boundary_quad {
struct Cache {
void* fake_scratchpad_data; // *fake-scratchpad-data*
void* math_camera; // *math-camera*
void* draw_boundary_polygon; // draw-boundary-polygon
} cache;
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
c->copy_vfs_from_other(&sky_regs_vfs);
bool bc = false;
u32 call_addr = 0;
c->mov64(v1, a0); // or v1, a0, r0
c->load_symbol2(v1, cache.math_camera); // lw v1, *math-camera*(s7)
c->lqc2(vf14, 780, v1); // lqc2 vf14, 780(v1)
get_fake_spad_addr2(t4, cache.fake_scratchpad_data, 0, c);// lui t4, 28672
c->ori(t4, t4, 12288); // ori t4, t4, 12288
get_fake_spad_addr2(t5, cache.fake_scratchpad_data, 0, c);// lui t5, 28672
c->ori(t5, t5, 14336); // ori t5, t5, 14336
c->mov64(a3, t4); // or a3, t4, r0
// nop // sll r0, r0, 0
c->lqc2(vf1, 0, a0); // lqc2 vf1, 0(a0)
c->addiu(t0, r0, 4); // addiu t0, r0, 4
c->lqc2(vf2, 16, a0); // lqc2 vf2, 16(a0)
// nop // sll r0, r0, 0
c->lqc2(vf3, 32, a0); // lqc2 vf3, 32(a0)
c->vmula_bc(DEST::xyzw, BC::x, vf31, vf1); // vmulax.xyzw acc, vf31, vf1
c->lqc2(vf4, 48, a0); // lqc2 vf4, 48(a0)
c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf1); // vmadday.xyzw acc, vf30, vf1
c->lqc2(vf5, 64, a0); // lqc2 vf5, 64(a0)
c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf1); // vmaddaz.xyzw acc, vf29, vf1
c->lqc2(vf6, 80, a0); // lqc2 vf6, 80(a0)
c->vmadd_bc(DEST::xyzw, BC::w, vf1, vf28, vf1); // vmaddw.xyzw vf1, vf28, vf1
c->lqc2(vf7, 96, a0); // lqc2 vf7, 96(a0)
// nop // sll r0, r0, 0
c->lqc2(vf8, 112, a0); // lqc2 vf8, 112(a0)
c->vmula_bc(DEST::xyzw, BC::x, vf31, vf4); // vmulax.xyzw acc, vf31, vf4
// nop // sll r0, r0, 0
c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf4); // vmadday.xyzw acc, vf30, vf4
c->lqc2(vf10, 144, a0); // lqc2 vf10, 144(a0)
c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf4); // vmaddaz.xyzw acc, vf29, vf4
c->lqc2(vf11, 160, a0); // lqc2 vf11, 160(a0)
c->vmadd_bc(DEST::xyzw, BC::w, vf4, vf28, vf4); // vmaddw.xyzw vf4, vf28, vf4
// nop // sll r0, r0, 0
// nop // sll r0, r0, 0
c->sqc2(vf2, 16, a3); // sqc2 vf2, 16(a3)
c->vmula_bc(DEST::xyzw, BC::x, vf31, vf7); // vmulax.xyzw acc, vf31, vf7
c->sqc2(vf3, 32, a3); // sqc2 vf3, 32(a3)
c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf7); // vmadday.xyzw acc, vf30, vf7
c->sqc2(vf5, 64, a3); // sqc2 vf5, 64(a3)
c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf7); // vmaddaz.xyzw acc, vf29, vf7
c->sqc2(vf3, 80, a3); // sqc2 vf3, 80(a3)
c->vmadd_bc(DEST::xyzw, BC::w, vf7, vf28, vf7); // vmaddw.xyzw vf7, vf28, vf7
c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3)
// nop // sll r0, r0, 0
c->sqc2(vf3, 128, a3); // sqc2 vf3, 128(a3)
c->vmula_bc(DEST::xyzw, BC::x, vf31, vf10); // vmulax.xyzw acc, vf31, vf10
c->sqc2(vf11, 160, a3); // sqc2 vf11, 160(a3)
c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf10); // vmadday.xyzw acc, vf30, vf10
c->sqc2(vf3, 176, a3); // sqc2 vf3, 176(a3)
c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf10); // vmaddaz.xyzw acc, vf29, vf10
c->sqc2(vf2, 208, a3); // sqc2 vf2, 208(a3)
c->vmadd_bc(DEST::xyzw, BC::w, vf10, vf28, vf10); // vmaddw.xyzw vf10, vf28, vf10
c->sqc2(vf3, 224, a3); // sqc2 vf3, 224(a3)
// nop // sll r0, r0, 0
c->sqc2(vf1, 0, a3); // sqc2 vf1, 0(a3)
// nop // sll r0, r0, 0
c->sqc2(vf1, 192, a3); // sqc2 vf1, 192(a3)
// nop // sll r0, r0, 0
c->sqc2(vf4, 48, a3); // sqc2 vf4, 48(a3)
// nop // sll r0, r0, 0
c->sqc2(vf7, 96, a3); // sqc2 vf7, 96(a3)
// nop // sll r0, r0, 0
c->sqc2(vf10, 144, a3); // sqc2 vf10, 144(a3)
c->load_symbol2(t9, cache.draw_boundary_polygon); // lw t9, draw-boundary-polygon(s7)
c->vsub(DEST::xyzw, vf4, vf4, vf1); // vsub.xyzw vf4, vf4, vf1
// nop // sll r0, r0, 0
c->vsub(DEST::xyzw, vf7, vf7, vf1); // vsub.xyzw vf7, vf7, vf1
// nop // sll r0, r0, 0
c->vopmula(vf4, vf7); // vopmula.xyz acc, vf4, vf7
// nop // sll r0, r0, 0
c->vopmsub(vf10, vf7, vf4); // vopmsub.xyz vf10, vf7, vf4
// nop // sll r0, r0, 0
c->vmul(DEST::xyzw, vf10, vf10, vf1); // vmul.xyzw vf10, vf10, vf1
// nop // sll r0, r0, 0
c->vadd_bc(DEST::y, BC::x, vf10, vf10, vf10); // vaddx.y vf10, vf10, vf10
// nop // sll r0, r0, 0
c->vadd_bc(DEST::y, BC::z, vf10, vf10, vf10); // vaddz.y vf10, vf10, vf10
// nop // sll r0, r0, 0
c->mov128_gpr_vf(v0, vf10); // qmfc2.i v0, vf10
// nop // sll r0, r0, 0
bc = ((s64)c->sgpr64(v0)) >= 0; // bgez v0, L33
// nop // sll r0, r0, 0
if (bc) {goto block_2;} // branch non-likely
// Unknown instr: jr t9
draw_boundary_polygon::execute(ctxt);
// nop // sll r0, r0, 0
block_2:
c->sqc2(vf6, 32, a3); // sqc2 vf6, 32(a3)
// nop // sll r0, r0, 0
c->sqc2(vf6, 80, a3); // sqc2 vf6, 80(a3)
// nop // sll r0, r0, 0
c->sqc2(vf6, 128, a3); // sqc2 vf6, 128(a3)
// nop // sll r0, r0, 0
c->sqc2(vf6, 176, a3); // sqc2 vf6, 176(a3)
// nop // sll r0, r0, 0
// Unknown instr: jr t9
draw_boundary_polygon::execute(ctxt);
// nop // sll r0, r0, 0
//jr ra // jr ra
c->daddu(sp, sp, r0); // daddu sp, sp, r0
goto end_of_function; // return
// nop // sll r0, r0, 0
// nop // sll r0, r0, 0
end_of_function:
return c->gprs[v0].du64[0];
}
void link() {
cache.fake_scratchpad_data = intern_from_c(-1, 0, "*fake-scratchpad-data*").c();
cache.math_camera = intern_from_c(-1, 0, "*math-camera*").c();
cache.draw_boundary_polygon = intern_from_c(-1, 0, "draw-boundary-polygon").c();
gLinkedFunctionTable.reg("render-boundary-quad", execute, 32);
}
} // namespace render_boundary_quad
} // namespace Mips2C
// add render_boundary_quad::link to the link callback table for the object file.
// FWD DEC:
//--------------------------MIPS2C---------------------
// clang-format off
#include "game/mips2c/mips2c_private.h"
#include "game/kernel/jak3/kscheme.h"
using ::jak3::intern_from_c;
namespace Mips2C::jak3 {
namespace render_boundary_tri {
struct Cache {
void* fake_scratchpad_data; // *fake-scratchpad-data*
void* draw_boundary_polygon; // draw-boundary-polygon
} cache;
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
c->copy_vfs_from_other(&sky_regs_vfs);
bool bc = false;
u32 call_addr = 0;
c->mov64(v1, a0); // or v1, a0, r0
get_fake_spad_addr2(t4, cache.fake_scratchpad_data, 0, c);// lui t4, 28672
c->ori(t4, t4, 12288); // ori t4, t4, 12288
get_fake_spad_addr2(t5, cache.fake_scratchpad_data, 0, c);// lui t5, 28672
c->ori(t5, t5, 14336); // ori t5, t5, 14336
c->mov64(a3, t4); // or a3, t4, r0
// nop // sll r0, r0, 0
c->lqc2(vf1, 0, a0); // lqc2 vf1, 0(a0)
c->addiu(t0, r0, 3); // addiu t0, r0, 3
c->lqc2(vf2, 16, a0); // lqc2 vf2, 16(a0)
// nop // sll r0, r0, 0
c->lqc2(vf3, 32, a0); // lqc2 vf3, 32(a0)
c->vmula_bc(DEST::xyzw, BC::x, vf31, vf1); // vmulax.xyzw acc, vf31, vf1
c->lqc2(vf4, 48, a0); // lqc2 vf4, 48(a0)
c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf1); // vmadday.xyzw acc, vf30, vf1
c->lqc2(vf5, 64, a0); // lqc2 vf5, 64(a0)
c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf1); // vmaddaz.xyzw acc, vf29, vf1
c->lqc2(vf6, 80, a0); // lqc2 vf6, 80(a0)
c->vmadd_bc(DEST::xyzw, BC::w, vf1, vf28, vf1); // vmaddw.xyzw vf1, vf28, vf1
c->lqc2(vf7, 96, a0); // lqc2 vf7, 96(a0)
// nop // sll r0, r0, 0
c->lqc2(vf8, 112, a0); // lqc2 vf8, 112(a0)
c->vmula_bc(DEST::xyzw, BC::x, vf31, vf4); // vmulax.xyzw acc, vf31, vf4
// nop // sll r0, r0, 0
c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf4); // vmadday.xyzw acc, vf30, vf4
c->sqc2(vf2, 16, a3); // sqc2 vf2, 16(a3)
c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf4); // vmaddaz.xyzw acc, vf29, vf4
c->sqc2(vf3, 32, a3); // sqc2 vf3, 32(a3)
c->vmadd_bc(DEST::xyzw, BC::w, vf4, vf28, vf4); // vmaddw.xyzw vf4, vf28, vf4
c->sqc2(vf5, 64, a3); // sqc2 vf5, 64(a3)
// nop // sll r0, r0, 0
c->sqc2(vf3, 80, a3); // sqc2 vf3, 80(a3)
c->vmula_bc(DEST::xyzw, BC::x, vf31, vf7); // vmulax.xyzw acc, vf31, vf7
c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3)
c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf7); // vmadday.xyzw acc, vf30, vf7
c->sqc2(vf3, 128, a3); // sqc2 vf3, 128(a3)
c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf7); // vmaddaz.xyzw acc, vf29, vf7
c->sqc2(vf2, 160, a3); // sqc2 vf2, 160(a3)
c->vmadd_bc(DEST::xyzw, BC::w, vf7, vf28, vf7); // vmaddw.xyzw vf7, vf28, vf7
c->sqc2(vf3, 176, a3); // sqc2 vf3, 176(a3)
// nop // sll r0, r0, 0
c->sqc2(vf1, 0, a3); // sqc2 vf1, 0(a3)
// nop // sll r0, r0, 0
c->sqc2(vf1, 144, a3); // sqc2 vf1, 144(a3)
// nop // sll r0, r0, 0
c->sqc2(vf4, 48, a3); // sqc2 vf4, 48(a3)
// nop // sll r0, r0, 0
c->sqc2(vf7, 96, a3); // sqc2 vf7, 96(a3)
c->load_symbol2(t9, cache.draw_boundary_polygon); // lw t9, draw-boundary-polygon(s7)
c->vsub(DEST::xyzw, vf4, vf4, vf1); // vsub.xyzw vf4, vf4, vf1
// nop // sll r0, r0, 0
c->vsub(DEST::xyzw, vf7, vf7, vf1); // vsub.xyzw vf7, vf7, vf1
// nop // sll r0, r0, 0
c->vopmula(vf4, vf7); // vopmula.xyz acc, vf4, vf7
// nop // sll r0, r0, 0
c->vopmsub(vf10, vf7, vf4); // vopmsub.xyz vf10, vf7, vf4
// nop // sll r0, r0, 0
c->vmul(DEST::xyzw, vf10, vf10, vf1); // vmul.xyzw vf10, vf10, vf1
// nop // sll r0, r0, 0
c->vadd_bc(DEST::y, BC::x, vf10, vf10, vf10); // vaddx.y vf10, vf10, vf10
// nop // sll r0, r0, 0
c->vadd_bc(DEST::y, BC::z, vf10, vf10, vf10); // vaddz.y vf10, vf10, vf10
// nop // sll r0, r0, 0
c->mov128_gpr_vf(v0, vf10); // qmfc2.i v0, vf10
// nop // sll r0, r0, 0
bc = ((s64)c->sgpr64(v0)) >= 0; // bgez v0, L31
// nop // sll r0, r0, 0
if (bc) {goto block_2;} // branch non-likely
// Unknown instr: jr t9
// nop // sll r0, r0, 0
block_2:
c->sqc2(vf6, 32, a3); // sqc2 vf6, 32(a3)
// nop // sll r0, r0, 0
c->sqc2(vf6, 80, a3); // sqc2 vf6, 80(a3)
// nop // sll r0, r0, 0
c->sqc2(vf6, 128, a3); // sqc2 vf6, 128(a3)
// nop // sll r0, r0, 0
c->sqc2(vf6, 176, a3); // sqc2 vf6, 176(a3)
// nop // sll r0, r0, 0
// Unknown instr: jr t9
// nop // sll r0, r0, 0
//jr ra // jr ra
c->daddu(sp, sp, r0); // daddu sp, sp, r0
goto end_of_function; // return
// nop // sll r0, r0, 0
// nop // sll r0, r0, 0
end_of_function:
return c->gprs[v0].du64[0];
}
void link() {
cache.fake_scratchpad_data = intern_from_c(-1, 0, "*fake-scratchpad-data*").c();
cache.draw_boundary_polygon = intern_from_c(-1, 0, "draw-boundary-polygon").c();
gLinkedFunctionTable.reg("render-boundary-tri", execute, 32);
}
} // namespace render_boundary_tri
} // namespace Mips2C

View File

@ -0,0 +1,54 @@
#include "sky.h"
#include "game/kernel/jak3/kscheme.h"
#include "game/mips2c/mips2c_private.h"
namespace Mips2C::jak3 {
ExecutionContext sky_regs_vfs;
namespace set_sky_vf27 {
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
// sky_regs_vfs.vfs[27]
memcpy(&sky_regs_vfs.vfs[27].f[0], g_ee_main_mem + c->gpr_addr(a0), 16);
return 0;
}
void link() {
gLinkedFunctionTable.reg("set-sky-vf27", execute, 64);
}
} // namespace set_sky_vf27
} // namespace Mips2C::jak3
namespace Mips2C::jak3 {
namespace set_sky_vf23_value {
u64 execute(void* ctxt) {
auto* c = (ExecutionContext*)ctxt;
// sky_regs_vfs.vfs[27]
u64 value = c->sgpr64(a0);
memcpy(&sky_regs_vfs.vfs[23].f[0], &value, 8);
return 0;
}
void link() {
gLinkedFunctionTable.reg("set-sky-vf23-value", execute, 64);
}
} // namespace set_sky_vf23_value
} // namespace Mips2C::jak3
namespace Mips2C::jak3 {
namespace clip_polygon_against_positive_hyperplane {
u64 execute(void*) {
ASSERT_NOT_REACHED();
}
} // namespace clip_polygon_against_positive_hyperplane
namespace clip_polygon_against_negative_hyperplane {
u64 execute(void*) {
ASSERT_NOT_REACHED();
}
} // namespace clip_polygon_against_negative_hyperplane
} // namespace Mips2C::jak3

View File

@ -0,0 +1,14 @@
#pragma once
#include "game/mips2c/mips2c_private.h"
namespace Mips2C::jak3 {
extern ExecutionContext sky_regs_vfs;
namespace clip_polygon_against_positive_hyperplane {
extern u64 execute(void* ctxt);
}
namespace clip_polygon_against_negative_hyperplane {
extern u64 execute(void* ctxt);
}
} // namespace Mips2C::jak3

View File

@ -262,7 +262,12 @@ namespace jak3 {
namespace add_light_sphere_to_light_group { extern void link(); }
namespace light_hash_count_items { extern void link(); }
namespace light_hash_add_items { extern void link(); }
namespace debug_line_clip { extern void link(); }
namespace init_boundary_regs { extern void link(); }
namespace draw_boundary_polygon { extern void link(); }
namespace render_boundary_quad { extern void link(); }
namespace render_boundary_tri { extern void link(); }
namespace set_sky_vf27 { extern void link(); }
}
// clang-format on
@ -434,7 +439,11 @@ PerGameVersion<std::unordered_map<std::string, std::vector<void (*)()>>> gMips2C
/////////// JAK 3
{{"lights",
{jak3::light_hash_get_bucket_index::link, jak3::add_light_sphere_to_light_group::link,
jak3::light_hash_count_items::link, jak3::light_hash_add_items::link}}}};
jak3::light_hash_count_items::link, jak3::light_hash_add_items::link}},
{"debug",
{jak3::debug_line_clip::link, jak3::init_boundary_regs::link,
jak3::draw_boundary_polygon::link, jak3::render_boundary_quad::link,
jak3::render_boundary_tri::link, jak3::set_sky_vf27::link}}}};
void LinkedFunctionTable::reg(const std::string& name, u64 (*exec)(void*), u32 stack_size) {
const auto& it = m_executes.insert({name, {exec, Ptr<u8>()}});

View File

@ -5,6 +5,8 @@
;; name in dgo: cam-debug-h
;; dgos: GAME
(define-extern debug-set-camera-pos-rot! (function vector matrix vector))
;; DECOMP BEGINS
;; this file is debug only

View File

@ -7,3 +7,92 @@
;; DECOMP BEGINS
(defun make-debug-sphere-table ((arg0 vector-array) (arg1 float) (arg2 float))
"Create a table of lines on a sphere."
(local-vars (sv-80 vector) (sv-96 vector) (sv-112 int))
(let ((s2-0 (new-stack-vector0))
(f30-0 1.0)
(s5-0 0)
)
(set-vector! s2-0 0.0 0.0 0.0 1.0)
(dotimes (s1-0 (the int arg2))
(let ((f28-0 (* f30-0 (sin (* (the float s1-0) (/ 32768.0 arg2)))))
(f26-0 (* f30-0 (sin (* (the float (+ s1-0 1)) (/ 32768.0 arg2)))))
(s0-0 (new-stack-vector0))
)
(set! sv-80 (new 'stack-no-clear 'vector))
(set! (-> sv-80 quad) (the-as uint128 0))
(set! sv-96 (new 'stack-no-clear 'vector))
(set! (-> sv-96 quad) (the-as uint128 0))
(set! (-> s0-0 y) (+ (-> s2-0 y) (* (cos (* (the float s1-0) (/ 32768.0 arg2))) f30-0)))
(set! (-> sv-80 y) (-> s0-0 y))
(set! (-> sv-96 y) (+ (-> s2-0 y) (* (cos (* (the float (+ s1-0 1)) (/ 32768.0 arg2))) f30-0)))
(set! sv-112 0)
(while (< sv-112 (the int arg1))
(set! (-> s0-0 x) (+ (-> s2-0 x) (* (cos (* (the float sv-112) (/ 65536.0 arg1))) f28-0)))
(set! (-> s0-0 z) (+ (-> s2-0 z) (* (sin (* (the float sv-112) (/ 65536.0 arg1))) f28-0)))
(set! (-> sv-80 x) (+ (-> s2-0 x) (* (cos (* (the float (+ sv-112 1)) (/ 65536.0 arg1))) f28-0)))
(set! (-> sv-80 z) (+ (-> s2-0 z) (* (sin (* (the float (+ sv-112 1)) (/ 65536.0 arg1))) f28-0)))
(set! (-> sv-96 x) (+ (-> s2-0 x) (* (cos (* (the float sv-112) (/ 65536.0 arg1))) f26-0)))
(set! (-> sv-96 z) (+ (-> s2-0 z) (* (sin (* (the float sv-112) (/ 65536.0 arg1))) f26-0)))
(set! (-> arg0 data s5-0 quad) (-> s0-0 quad))
(set! (-> arg0 data (+ s5-0 1) quad) (-> sv-80 quad))
(set! (-> arg0 data (+ s5-0 2) quad) (-> sv-96 quad))
(+! s5-0 3)
(set! sv-112 (+ sv-112 1))
)
)
)
(set! (-> arg0 length) s5-0)
)
arg0
)
(when *debug-segment*
(define *debug-sphere-table* (new 'debug 'boxed-array vector-array 10))
)
(defun add-debug-sphere-from-table ((arg0 bucket-id) (arg1 vector) (arg2 meters) (arg3 rgba) (arg4 int))
"Draw a sphere out of debug lines, using the precomputed table of lines."
(local-vars (sv-32 vector-array) (sv-36 vector))
(rlet ((vf1 :class vf)
(vf2 :class vf)
(vf3 :class vf)
(vf4 :class vf)
(vf5 :class vf)
)
(if (zero? (-> *debug-sphere-table* arg4))
(set! (-> *debug-sphere-table* arg4)
(make-debug-sphere-table (new 'debug 'vector-array (* (* 3 arg4) arg4)) (the float arg4) (the float arg4))
)
)
(set! sv-32 (-> *debug-sphere-table* arg4))
(set! sv-36 (the-as vector (new-stack-vector0)))
(let ((s2-1 (new-stack-vector0))
(s1-1 (new-stack-vector0))
(s0-0 (the-as object (-> sv-32 data)))
)
(.lvf vf1 (&-> arg1 quad))
(.mov vf2 arg2)
(countdown (s4-1 (/ (-> sv-32 length) 3))
(.lvf vf3 (&-> (the-as (inline-array vector) s0-0) 0 quad))
(.lvf vf4 (&-> (the-as (inline-array vector) s0-0) 1 quad))
(.lvf vf5 (&-> (the-as (inline-array vector) s0-0) 2 quad))
(set! s0-0 (-> (the-as (inline-array vector) s0-0) 3))
(.mul.x.vf vf3 vf3 vf2)
(.mul.x.vf vf4 vf4 vf2)
(.mul.x.vf vf5 vf5 vf2)
(.add.vf vf3 vf3 vf1)
(.add.vf vf4 vf4 vf1)
(.add.vf vf5 vf5 vf1)
(.svf (&-> s2-1 quad) vf3)
(.svf (&-> s1-1 quad) vf4)
(.svf (&-> sv-36 quad) vf5)
(add-debug-line #t arg0 s2-1 s1-1 arg3 #f (the-as rgba -1))
(add-debug-line #t arg0 s2-1 sv-36 arg3 #f (the-as rgba -1))
)
)
0
(none)
)
)

File diff suppressed because it is too large Load Diff

View File

@ -301,7 +301,7 @@
(reg-save uint32 5)
)
(:methods
(font-work-method-9 () none)
(set-context! (_type_ object) none)
)
)
@ -728,3 +728,6 @@
(set! (-> *font-work* color-table arg0 color 3) arg4)
0
)
(define-extern draw-string (function string dma-buffer font-context draw-string-result))

View File

@ -5,6 +5,8 @@
;; name in dgo: sky-h
;; dgos: GAME
(define-extern close-sky-buffer (function dma-buffer none))
;; DECOMP BEGINS
(deftype sky-color-hour (structure)
@ -224,3 +226,5 @@
(sky-work-method-38 () none)
)
)
(define-extern *sky-work* sky-work)

View File

@ -9,8 +9,8 @@
(deftype sprite-glow-data (structure)
((position vector :inline)
(size-x float :overlay-at (-> position data 3))
(size-probe float :offset 16)
(size-x float :overlay-at (-> position data 3))
(size-probe float :offset 16)
(z-offset float)
(rot-angle float)
(size-y float)
@ -19,6 +19,7 @@
(fade-b float)
(tex-id texture-id)
(dummy uint32)
(quads vector 4 :inline :overlay-at position)
)
(:methods
(set-trans (_type_ vector) none)
@ -41,8 +42,8 @@
(data (inline-array sprite-glow-data))
)
(:methods
(simple-sprite-system-method-9 () none)
(add! (_type_ sprite-glow-data) none)
(draw-all-sprites! (_type_ dma-buffer) none)
(simple-sprite-system-method-11 () none)
(clear! (_type_) none)
)
)

View File

@ -7,3 +7,347 @@
;; DECOMP BEGINS
(deftype sprite-distorter-sine-tables (basic)
"Table of precomputed sine data for the sprite distorter renderer."
((aspx float)
(aspy float)
(entry vector 128 :inline)
(ientry qword 9 :inline)
(giftag gs-gif-tag :inline)
(color qword :inline)
)
)
(kmemopen global "sprite-distort-tables")
(define *sprite-distorter-sine-tables* (new 'global 'sprite-distorter-sine-tables))
(kmemclose)
(defun sprite-distorter-generate-tables ()
"Regenerate the sprite-distorter-sine-tables for the current camera settings."
(let ((gp-0 *sprite-distorter-sine-tables*))
(let ((s3-0 0)
(s5-0 0)
(s4-0 3)
(f28-0 (- (-> *math-camera* perspective rvec x)))
(f30-0 (- (-> *math-camera* perspective uvec y)))
)
(when (or (!= f28-0 (-> gp-0 aspx)) (!= f30-0 (-> gp-0 aspy)))
(set! (-> gp-0 aspx) f28-0)
(set! (-> gp-0 aspy) f30-0)
(while (< s4-0 12)
(set! (-> gp-0 ientry s5-0 vector4w x) (+ s3-0 352))
(+! s5-0 1)
(dotimes (s2-0 s4-0)
(let ((f26-0 (* 65536.0 (/ (the float s2-0) (the float s4-0)))))
(set-vector! (-> gp-0 entry s3-0) (* (sin f26-0) f28-0) (* (cos f26-0) f30-0) 0.0 0.0)
(let ((s3-1 (+ s3-0 1)))
(set-vector! (-> gp-0 entry s3-1) (* 0.001953125 f28-0 (sin f26-0)) (* 0.001953125 f30-0 (cos f26-0)) 0.0 0.0)
(set! s3-0 (+ s3-1 1))
)
)
)
(+! s4-0 1)
)
(set-vector! (-> gp-0 entry s3-0) 0.0 f30-0 0.0 0.0)
(let ((v1-20 (+ s3-0 1)))
(set-vector! (-> gp-0 entry v1-20) 0.0 (* 0.001953125 f30-0) 0.0 0.0)
(+ v1-20 1)
)
)
)
(set! (-> gp-0 giftag tag) (new 'static 'gif-tag64
:nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :tme #x1)
:nreg #xf
)
)
(set! (-> gp-0 giftag regs) (new 'static 'gif-tag-regs
:regs0 (gif-reg-id st)
:regs1 (gif-reg-id rgbaq)
:regs2 (gif-reg-id xyzf2)
:regs3 (gif-reg-id st)
:regs4 (gif-reg-id rgbaq)
:regs5 (gif-reg-id xyzf2)
:regs6 (gif-reg-id st)
:regs7 (gif-reg-id rgbaq)
:regs8 (gif-reg-id xyzf2)
:regs9 (gif-reg-id st)
:regs10 (gif-reg-id rgbaq)
:regs11 (gif-reg-id xyzf2)
:regs12 (gif-reg-id st)
:regs13 (gif-reg-id rgbaq)
:regs14 (gif-reg-id xyzf2)
)
)
(set! (-> gp-0 color vector4w x) 128)
(set! (-> gp-0 color vector4w y) 128)
(set! (-> gp-0 color vector4w z) 128)
(set! (-> gp-0 color vector4w w) 128)
)
0
(none)
)
(define sprite-distort-vu1-block (new 'static 'vu-function :length 63 :qlength 32))
(defun sprite-init-distorter ((arg0 dma-buffer))
"Generate DMA to initialize the distort renderer."
(dma-buffer-add-gs-set arg0
(zbuf-1 (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1))
(tex0-1 (new 'static 'gs-tex0 :tbp0 #x3300 :tbw #x8 :tw #x9 :th #x9))
(tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
(miptbp1-1 (new 'static 'gs-miptbp))
(clamp-1 (new 'static 'gs-clamp
:wms (gs-tex-wrap-mode region-clamp)
:wmt (gs-tex-wrap-mode region-clamp)
:maxu #x1ff
:maxv #x19f
)
)
(alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
)
(let* ((v1-3 arg0)
(a1-6 (the-as dma-packet (-> v1-3 base)))
)
(set! (-> a1-6 dma) (new 'static 'dma-tag
:qwc #x8b
:id (dma-tag-id ref)
:addr (the-as uint (-> *sprite-distorter-sine-tables* entry))
)
)
(set! (-> a1-6 vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
(set! (-> a1-6 vif1) (new 'static 'vif-tag :imm #x160 :num #x8b :cmd (vif-cmd unpack-v4-32)))
(set! (-> v1-3 base) (the-as pointer (&+ a1-6 16)))
)
(dma-buffer-add-vu-function arg0 sprite-distort-vu1-block 1)
0
(none)
)
;; ERROR: Inline assembly instruction marked with TODO - [TODO.VCLIP]
;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping]
(defun sprite-draw-distorters ((arg0 dma-buffer))
"Generate DMA to draw all distort sprites."
(local-vars
(v1-15 float)
(v1-21 float)
(v1-26 int)
(v1-65 float)
(sv-16 sprite-vec-data-2d)
(sv-32 vector)
(sv-48 vector)
)
(rlet ((acc :class vf)
(Q :class vf)
(vf0 :class vf)
(vf1 :class vf)
(vf10 :class vf)
(vf2 :class vf)
(vf3 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
(vf8 :class vf)
(vf9 :class vf)
)
(init-vf0-vector)
(.lvf vf8 (&-> *math-camera* hmge-scale quad))
(let ((s0-0 (-> arg0 base))
(s4-0 0)
(s5-0 0)
)
(&+! (-> arg0 base) 16)
(let* ((s3-0 *sprite-aux-list*)
(s2-0 (-> s3-0 entry))
)
(dotimes (s1-0 s2-0)
(let ((v1-5 (-> s3-0 data s1-0)))
(when (= (-> v1-5 aux-type) (sprite-aux-type distort))
(set! sv-16 (-> v1-5 vec-data))
(let ((a0-3 (the-as object (-> arg0 base))))
(set! sv-32 (the-as vector (&+ (the-as pointer a0-3) 16)))
(set! sv-48 (the-as vector (&+ (the-as pointer a0-3) 32)))
(cond
((= (the-as int (-> sv-16 flag-rot-sy y)) 1)
(.lvf vf3 (&-> *math-camera* sprite-2d rvec quad))
(.lvf vf4 (&-> *math-camera* sprite-2d uvec quad))
(.lvf vf5 (&-> *math-camera* sprite-2d fvec quad))
(.lvf vf6 (&-> *math-camera* sprite-2d trans quad))
(.lvf vf9 (&-> *math-camera* sprite-2d-hvdf quad))
(.mov v1-15 vf9)
)
(else
(.lvf vf3 (&-> *math-camera* camera-temp rvec quad))
(.lvf vf4 (&-> *math-camera* camera-temp uvec quad))
(.lvf vf5 (&-> *math-camera* camera-temp fvec quad))
(.lvf vf6 (&-> *math-camera* camera-temp trans quad))
(.lvf vf9 (&-> *math-camera* hvdf-off quad))
(.mov v1-21 vf9)
)
)
(.lvf vf1 (&-> sv-16 x-y-z-sx quad))
(.lvf vf2 (&-> sv-16 r-g-b-a quad))
(.mul.w.vf acc vf6 vf0)
(.add.mul.x.vf acc vf3 vf1 acc)
(.add.mul.y.vf acc vf4 vf1 acc)
(.add.mul.z.vf vf1 vf5 vf1 acc)
(.mul.vf vf10 vf1 vf8)
(.div.vf Q vf0 vf10 :fsf #b11 :ftf #b11)
;; (TODO.VCLIP vf10 vf10) og:preserve-this
(b! (zero? (-> sv-16 flag-rot-sy x)) cfg-22 :delay (nop!))
(.wait.vf)
(.mul.vf vf1 vf1 Q :mask #b111)
(.mul.vf vf2 vf2 Q :mask #b111)
(set! v1-26 (vu-clip vf10 0)) ;; safe to just drop the higher bits. og:preserve-this
;; (.cfc2.i v1-26 Clipping)
(b! (logtest? v1-26 63) cfg-22 :delay (.add.vf vf1 vf1 vf9))
(.max.x.vf vf1 vf1 vf0 :mask #b1000)
(.svf (&-> (the-as vector a0-3) quad) vf1)
(.svf (&-> sv-48 quad) vf2)
(set! (-> (the-as vector a0-3) w) 255.0)
(set! (-> sv-32 x) (+ 0.0009765625 (* 0.001953125 (+ -1792.0 (-> (the-as vector a0-3) x)))))
(set! (-> sv-32 y) (+ 0.0009765625 (* 0.001953125 (+ -1840.0 (-> (the-as vector a0-3) y)))))
)
(set! (-> sv-32 z) 1.0)
(when (or (< (the-as int (-> sv-16 flag-rot-sy x)) 3) (< 11 (the-as int (-> sv-16 flag-rot-sy x))))
(format 0 "Turns = ~D!!!~%" (-> sv-16 flag-rot-sy x))
(set! (-> sv-16 flag-rot-sy x) (the-as float #xb))
)
(set! (-> sv-32 w) (-> sv-16 flag-rot-sy x))
(let* ((f1-4 (- (-> *math-camera* perspective uvec y)))
(f2-4 (-> sv-32 y))
(f4-0 (+ f2-4 (* (-> sv-48 x) f1-4)))
(f3-2 256.0)
(f0-9 (-> sv-48 x))
)
(if (< 416.0 f4-0)
(set! f3-2 (/ (- 416.0 f2-4) f1-4))
)
(if (< 128.0 f3-2)
(set! f3-2 128.0)
)
(when (< f3-2 f0-9)
(let ((v1-63 (/ f3-2 f0-9)))
(.mov vf1 v1-63)
)
(.mul.x.vf vf2 vf2 vf1)
(.svf (&-> sv-48 quad) vf2)
(.mov v1-65 vf2)
)
)
(&+! (-> arg0 base) 48)
(+! s4-0 1)
(when (= s4-0 85)
(let ((v1-70 (-> arg0 base)))
(set! (-> arg0 base) s0-0)
(let* ((a0-10 arg0)
(a1-3 (the-as dma-packet (-> a0-10 base)))
)
(set! (-> a1-3 dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc (* 3 s4-0)))
(set! (-> a1-3 vif0) (new 'static 'vif-tag))
(set! (-> a1-3 vif1)
(new 'static 'vif-tag :cmd (vif-cmd unpack-v4-32) :imm (shr (shl (+ (* 3 s5-0) 512) 54) 54) :num (* 3 s4-0))
)
(set! (-> a0-10 base) (the-as pointer (&+ a1-3 16)))
)
(set! (-> arg0 base) v1-70)
)
(set! s4-0 0)
(+! s5-0 85)
(when (= s5-0 170)
(let* ((v1-73 arg0)
(a0-11 (the-as dma-packet (-> v1-73 base)))
)
(set! (-> a0-11 dma) (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt)))
(set! (-> a0-11 vif0) (new 'static 'vif-tag))
(set! (-> a0-11 vif1) (new 'static 'vif-tag :imm #x1ff :num #x1 :cmd (vif-cmd unpack-v4-32)))
(set! (-> v1-73 base) (the-as pointer (&+ a0-11 16)))
)
(let* ((v1-74 arg0)
(a0-13 (the-as vector4w (-> v1-74 base)))
)
(set! (-> a0-13 x) s5-0)
(set! (-> a0-13 y) 0)
(set! (-> a0-13 z) 0)
(set! (-> a0-13 w) 0)
(set! (-> v1-74 base) (the-as pointer (&+ a0-13 16)))
)
(let* ((v1-75 arg0)
(a0-15 (the-as dma-packet (-> v1-75 base)))
)
(set! (-> a0-15 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> a0-15 vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1))
(set! (-> a0-15 vif1) (new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1))
(set! (-> v1-75 base) (the-as pointer (&+ a0-15 16)))
)
(set! s5-0 0)
)
(set! s0-0 (-> arg0 base))
(&+! (-> arg0 base) 16)
)
)
)
(label cfg-22)
0
)
)
(cond
((zero? s4-0)
(set! (-> arg0 base) s0-0)
(nop!)
0
)
(else
(let ((v1-83 (-> arg0 base)))
(set! (-> arg0 base) s0-0)
(let* ((a0-17 arg0)
(a1-10 (the-as dma-packet (-> a0-17 base)))
)
(set! (-> a1-10 dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc (* 3 s4-0)))
(set! (-> a1-10 vif0) (new 'static 'vif-tag))
(set! (-> a1-10 vif1)
(new 'static 'vif-tag :cmd (vif-cmd unpack-v4-32) :imm (shr (shl (+ (* 3 s5-0) 512) 54) 54) :num (* 3 s4-0))
)
(set! (-> a0-17 base) (the-as pointer (&+ a1-10 16)))
)
(set! (-> arg0 base) v1-83)
)
)
)
(let ((v1-84 (+ s4-0 s5-0)))
(when (nonzero? v1-84)
(let* ((a0-19 arg0)
(a1-12 (the-as dma-packet (-> a0-19 base)))
)
(set! (-> a1-12 dma) (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt)))
(set! (-> a1-12 vif0) (new 'static 'vif-tag))
(set! (-> a1-12 vif1) (new 'static 'vif-tag :imm #x1ff :num #x1 :cmd (vif-cmd unpack-v4-32)))
(set! (-> a0-19 base) (the-as pointer (&+ a1-12 16)))
)
(let* ((a0-20 arg0)
(a1-14 (the-as vector4w (-> a0-20 base)))
)
(set! (-> a1-14 x) v1-84)
(set! (-> a1-14 y) 0)
(set! (-> a1-14 z) 0)
(set! (-> a1-14 w) 0)
(set! (-> a0-20 base) (the-as pointer (&+ a1-14 16)))
)
(let ((v1-86 (the-as dma-packet (-> arg0 base))))
(set! (-> v1-86 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> v1-86 vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1))
(set! (-> v1-86 vif1) (new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1))
(set! (-> arg0 base) (the-as pointer (&+ v1-86 16)))
)
)
)
)
0
(none)
)
)

View File

@ -7,3 +7,761 @@
;; DECOMP BEGINS
(deftype sprite-glow-template (structure)
"Sprite glow GS data templates sent to VU1."
((clear-init-giftag gs-gif-tag :inline)
(clear-init-adcmds gs-adcmd 5 :inline)
(clear-draw-giftag gs-gif-tag :inline)
(clear-draw-clr-0 gs-packed-rgba :inline)
(clear-draw-xyz-0 gs-packed-xyzw 2 :inline)
(clear-draw-clr-1 gs-packed-rgba :inline)
(clear-draw-xyz-1 vector 2 :inline)
(offscr-setup-giftag gs-gif-tag :inline)
(offscr-setup-adcmds gs-adcmd 8 :inline)
(offscr-first-giftag gs-gif-tag :inline)
(offscr-first-clr gs-packed-rgba :inline)
(offscr-first-uv-0 gs-packed-uv :inline)
(offscr-first-xyzw-0 gs-packed-xyzw :inline)
(offscr-first-uv-1 gs-packed-uv :inline)
(offscr-first-xyzw-1 gs-packed-xyzw :inline)
(repeat-draw-giftag gs-gif-tag :inline)
(repeat-draw-adcmds gs-adcmd 29 :inline)
(flare-alpha-giftag gs-gif-tag :inline)
(flare-alpha-clr gs-packed-rgba :inline)
(flare-alpha-uv gs-packed-uv :inline)
(flare-alpha-xyzw-0 gs-packed-xyzw :inline)
(flare-alpha-xyzw-1 gs-packed-xyzw :inline)
(flare-alpha-xyzw-2 gs-packed-xyzw :inline)
(flare-alpha-xyzw-3 gs-packed-xyzw :inline)
(flare-init-giftag gs-gif-tag :inline)
(flare-init-adcmds gs-adcmd 8 :inline)
(flare-draw-giftag gs-gif-tag :inline)
(flare-draw-clr gs-packed-rgba :inline)
(flare-draw-stq-0 gs-packed-stq :inline)
(flare-draw-xyzw-0 gs-packed-xyzw :inline)
(flare-draw-stq-1 gs-packed-stq :inline)
(flare-draw-xyzw-1 gs-packed-xyzw :inline)
(flare-draw-stq-2 gs-packed-stq :inline)
(flare-draw-xyzw-2 gs-packed-xyzw :inline)
(flare-draw-stq-3 gs-packed-stq :inline)
(flare-draw-xyzw-3 gs-packed-xyzw :inline)
)
)
(deftype sprite-glow-consts (structure)
"Per-frame constants for sprite-glow VU1."
((camera matrix :inline)
(perspective matrix :inline)
(hvdf-offset vector :inline)
(hmge-scale vector :inline)
(consts vector :inline)
(pfog0 float :overlay-at (-> consts data 0))
(deg-to-rad float :overlay-at (-> consts data 1))
(min-scale float :overlay-at (-> consts data 2))
(inv-area float :overlay-at (-> consts data 3))
(sincos-01 vector :inline)
(sincos-23 vector :inline)
(sincos-45 vector :inline)
(sincos-67 vector :inline)
(sincos-89 vector :inline)
(basis-x vector :inline)
(basis-y vector :inline)
(xy-array vector 4 :inline)
(clamp-min vector :inline)
(clamp-max vector :inline)
)
)
(define *sprite-glow-template*
(new 'static 'sprite-glow-template
:clear-init-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64 :nloop #x5 :nreg #x1)
:regs (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))
)
:clear-init-adcmds (new 'static 'inline-array gs-adcmd 5
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
(new 'static 'gs-adcmd :cmds (gs-reg64 alpha-1) :x #x6a)
(new 'static 'gs-adcmd :cmds (gs-reg64 test-1) :x #x51001)
(new 'static 'gs-adcmd :cmds (gs-reg64 zbuf-1) :x #x1000130 :y #x1)
(new 'static 'gs-adcmd :cmds (gs-reg64 frame-1) :x #x80198 :y #xffffff)
)
:clear-draw-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64
:nloop #x2
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type sprite))
:nreg #x3
)
:regs (new 'static 'gif-tag-regs :regs0 (gif-reg-id rgbaq) :regs1 (gif-reg-id xyzf2) :regs2 (gif-reg-id xyzf2))
)
:clear-draw-xyz-0 (new 'static 'inline-array gs-packed-xyzw 2
(new 'static 'gs-packed-xyzw :iz -1)
(new 'static 'gs-packed-xyzw :iz -1)
)
:clear-draw-clr-1 (new 'static 'gs-packed-rgba :x #xff :w #xff)
:offscr-setup-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64 :nloop #x8 :nreg #x1)
:regs (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))
)
:offscr-setup-adcmds (new 'static 'inline-array gs-adcmd 8
(new 'static 'gs-adcmd :cmds (gs-reg64 frame-2) :x #x10090 :y #xffffff)
(new 'static 'gs-adcmd :cmds (gs-reg64 zbuf-2) :x #x1000130)
(new 'static 'gs-adcmd :cmds (gs-reg64 tex1-2) :x #x60)
(new 'static 'gs-adcmd :cmds (gs-reg64 tex0-2) :x #x64023300 :y #xe)
(new 'static 'gs-adcmd :cmds (gs-reg64 clamp-2) :x #x5)
(new 'static 'gs-adcmd :cmds (gs-reg64 test-2) :x #x31001)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyoffset-2))
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
)
:offscr-first-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64
:nloop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :fst #x1 :ctxt #x1)
:nreg #x5
)
:regs (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)
)
)
:offscr-first-clr (new 'static 'gs-packed-rgba :x #x80 :y #x80 :z #x80 :w #x80)
:offscr-first-xyzw-1 (new 'static 'gs-packed-xyzw :ix #x200 :iy #x200)
:repeat-draw-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64 :nloop #x1d :nreg #x1)
:regs (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))
)
:repeat-draw-adcmds (new 'static 'inline-array gs-adcmd 29
(new 'static 'gs-adcmd :cmds (gs-reg64 tex0-2) :x #x54005200 :y #xd)
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x100010)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x2100210)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2) :x #x1000100)
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x100010)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x1100110)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2) :x #x800080)
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x100010)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x900090)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2) :x #x400040)
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x100010)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x500050)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2) :x #x200020)
(new 'static 'gs-adcmd :cmds (gs-reg64 frame-2) :x #x80198 :y #xffffff)
(new 'static 'gs-adcmd :cmds (gs-reg64 test-2) :x #x51001)
(new 'static 'gs-adcmd :cmds (gs-reg64 zbuf-2) :x #x1000130 :y #x1)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyoffset-2) :x #x7000 :y #x7300)
(new 'static 'gs-adcmd :cmds (gs-reg64 scissor-2) :x #x1ff0000 :y #x19f0000)
(new 'static 'gs-adcmd :cmds (gs-reg64 test-2) :x #x50000)
(new 'static 'gs-adcmd :cmds (gs-reg64 alpha-2) :x #x6a)
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
)
:flare-alpha-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64
:nloop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1 :fst #x1 :ctxt #x1)
:nreg #x6
)
:regs (new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id uv)
:regs2 (gif-reg-id xyzf2)
:regs3 (gif-reg-id xyzf2)
:regs4 (gif-reg-id xyzf2)
:regs5 (gif-reg-id xyzf2)
)
)
:flare-alpha-clr (new 'static 'gs-packed-rgba :x #x80 :y #x80 :z #x80 :w #x80)
:flare-alpha-uv (new 'static 'gs-packed-uv :x (the-as float #x10) :y (the-as float #x10))
:flare-alpha-xyzw-0 (new 'static 'gs-packed-xyzw :iz -1)
:flare-alpha-xyzw-1 (new 'static 'gs-packed-xyzw :iz -1)
:flare-alpha-xyzw-2 (new 'static 'gs-packed-xyzw :iz -1)
:flare-alpha-xyzw-3 (new 'static 'gs-packed-xyzw :iz -1)
:flare-init-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64 :nloop #x8 :nreg #x1)
:regs (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))
)
:flare-init-adcmds (new 'static 'inline-array gs-adcmd 8
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
(new 'static 'gs-adcmd :cmds (gs-reg64 frame-1) :x #x80198)
(new 'static 'gs-adcmd :cmds (gs-reg64 hack))
(new 'static 'gs-adcmd :cmds (gs-reg64 hack))
(new 'static 'gs-adcmd :cmds (gs-reg64 hack))
(new 'static 'gs-adcmd :cmds (gs-reg64 hack))
(new 'static 'gs-adcmd :cmds (gs-reg64 hack))
(new 'static 'gs-adcmd :cmds (gs-reg64 alpha-1) :x #x58)
)
:flare-draw-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64
:nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1 :abe #x1)
:nreg #x9
)
:regs (new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id st)
:regs2 (gif-reg-id xyzf2)
:regs3 (gif-reg-id st)
:regs4 (gif-reg-id xyzf2)
:regs5 (gif-reg-id st)
:regs6 (gif-reg-id xyzf2)
:regs7 (gif-reg-id st)
:regs8 (gif-reg-id xyzf2)
)
)
:flare-draw-clr (new 'static 'gs-packed-rgba :y 64 :w #x80)
:flare-draw-stq-0 (new 'static 'gs-packed-stq :z 1.0)
:flare-draw-xyzw-0 (new 'static 'gs-packed-xyzw :iz -1)
:flare-draw-stq-1 (new 'static 'gs-packed-stq :x 1.0 :z 1.0)
:flare-draw-xyzw-1 (new 'static 'gs-packed-xyzw :iz -1)
:flare-draw-stq-2 (new 'static 'gs-packed-stq :x 1.0 :y 1.0 :z 1.0)
:flare-draw-xyzw-2 (new 'static 'gs-packed-xyzw :iz -1)
:flare-draw-stq-3 (new 'static 'gs-packed-stq :y 1.0 :z 1.0)
:flare-draw-xyzw-3 (new 'static 'gs-packed-xyzw :iz -1)
)
)
(define sprite-glow-vu1-block (new 'static 'vu-function :length #x86 :qlength 67))
;; WARN: Return type mismatch vector vs none.
(defun sprite-glow-init-consts ((arg0 sprite-glow-consts))
"Fill out sprite-glow-consts to be sent to VU1."
(let ((v1-0 *math-camera*))
(let* ((t0-0 (-> arg0 camera))
(t1-0 (-> v1-0 camera-rot))
(a1-0 (-> t1-0 rvec quad))
(a2-0 (-> t1-0 uvec quad))
(a3-0 (-> t1-0 fvec quad))
(t1-1 (-> t1-0 trans quad))
)
(set! (-> t0-0 rvec quad) a1-0)
(set! (-> t0-0 uvec quad) a2-0)
(set! (-> t0-0 fvec quad) a3-0)
(set! (-> t0-0 trans quad) t1-1)
)
(let* ((t0-1 (-> arg0 perspective))
(t1-2 (-> v1-0 perspective))
(a1-1 (-> t1-2 rvec quad))
(a2-1 (-> t1-2 uvec quad))
(a3-1 (-> t1-2 fvec quad))
(t1-3 (-> t1-2 trans quad))
)
(set! (-> t0-1 rvec quad) a1-1)
(set! (-> t0-1 uvec quad) a2-1)
(set! (-> t0-1 fvec quad) a3-1)
(set! (-> t0-1 trans quad) t1-3)
)
(set! (-> arg0 hvdf-offset quad) (-> v1-0 hvdf-off quad))
(set! (-> arg0 hmge-scale quad) (-> v1-0 hmge-scale quad))
(set! (-> arg0 basis-x quad) (the-as uint128 0))
(set! (-> arg0 basis-x x) (- (-> *math-camera* perspective rvec x)))
(set! (-> arg0 basis-y quad) (the-as uint128 0))
(set! (-> arg0 basis-y y) (- (-> *math-camera* perspective uvec y)))
(set! (-> arg0 consts x) (-> v1-0 pfog0))
)
(set! (-> arg0 consts y) 0.000095873795)
(set! (-> arg0 consts z) (sqrtf (* (/ 1.0 (-> arg0 basis-x x)) (/ 1.0 (-> arg0 basis-y y)))))
(set! (-> arg0 consts w) (/ 1.0 (* (-> arg0 consts z) (-> arg0 consts z))))
(let ((v1-5 (-> arg0 sincos-01)))
(set! (-> v1-5 z) 0.999998)
(set! (-> v1-5 w) 1.0)
)
(let ((v1-6 (-> arg0 sincos-23)))
(set! (-> v1-6 z) -0.16666014)
(set! (-> v1-6 w) -0.49998003)
)
(let ((v1-7 (-> arg0 sincos-45)))
(set! (-> v1-7 z) 0.008326521)
(set! (-> v1-7 w) 0.041620404)
)
(let ((v1-8 (-> arg0 sincos-67)))
(set! (-> v1-8 z) -0.0001956241)
(set! (-> v1-8 w) -0.0013636408)
)
(let ((v1-9 (-> arg0 sincos-89)))
(set! (-> v1-9 z) 0.0000023042373)
(set! (-> v1-9 w) 0.000020170546)
)
(set-vector! (-> arg0 xy-array 0) -0.5 -0.5 0.0 0.0)
(set-vector! (-> arg0 xy-array 1) 0.5 -0.5 0.0 0.0)
(set-vector! (-> arg0 xy-array 2) 0.5 0.5 0.0 0.0)
(set-vector! (-> arg0 xy-array 3) -0.5 0.5 0.0 0.0)
(set-vector! (-> arg0 clamp-min) 1792.0 1840.0 0.0 0.0)
(set-vector! (-> arg0 clamp-max) 2304.0 2256.0 2048.0 50.0)
(none)
)
(defun sprite-glow-init-engine ((arg0 dma-buffer))
"Generate DMA to initialize sprite-glow VU1."
(dma-buffer-add-vu-function arg0 sprite-glow-vu1-block 1)
(let ((s5-0 24))
(let* ((v1-0 arg0)
(a0-2 (the-as dma-packet (-> v1-0 base)))
)
(set! (-> a0-2 dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc s5-0))
(set! (-> a0-2 vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
(set! (-> a0-2 vif1) (new 'static 'vif-tag :imm #x3d4 :cmd (vif-cmd unpack-v4-32) :num s5-0))
(set! (-> v1-0 base) (the-as pointer (&+ a0-2 16)))
)
(sprite-glow-init-consts (the-as sprite-glow-consts (-> arg0 base)))
(&+! (-> arg0 base) (* s5-0 16))
)
(let ((v1-3 84))
(let* ((a0-6 arg0)
(a1-6 (the-as dma-packet (-> a0-6 base)))
)
(set! (-> a1-6 dma)
(new 'static 'dma-tag :id (dma-tag-id ref) :addr (the-as int *sprite-glow-template*) :qwc v1-3)
)
(set! (-> a1-6 vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
(set! (-> a1-6 vif1) (new 'static 'vif-tag :imm #x320 :cmd (vif-cmd unpack-v4-32) :num v1-3))
(set! (-> a0-6 base) (the-as pointer (&+ a1-6 16)))
)
(let* ((a0-7 arg0)
(a1-8 (the-as dma-packet (-> a0-7 base)))
)
(set! (-> a1-8 dma)
(new 'static 'dma-tag :id (dma-tag-id ref) :addr (the-as int *sprite-glow-template*) :qwc v1-3)
)
(set! (-> a1-8 vif0) (new 'static 'vif-tag :cmd (vif-cmd mscal) :msk #x1 :imm #x0))
(set! (-> a1-8 vif1) (new 'static 'vif-tag :imm #x374 :cmd (vif-cmd unpack-v4-32) :num v1-3))
(set! (-> a0-7 base) (the-as pointer (&+ a1-8 16)))
)
)
(let* ((v1-8 arg0)
(a0-8 (the-as dma-packet (-> v1-8 base)))
)
(set! (-> a0-8 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> a0-8 vif0) (new 'static 'vif-tag :cmd (vif-cmd base)))
(set! (-> a0-8 vif1) (new 'static 'vif-tag :imm #x190 :cmd (vif-cmd offset)))
(set! (-> v1-8 base) (the-as pointer (&+ a0-8 16)))
)
(let ((v1-9 (the-as dma-packet (-> arg0 base))))
(set! (-> v1-9 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> v1-9 vif0) (new 'static 'vif-tag))
(set! (-> v1-9 vif1) (new 'static 'vif-tag :cmd (vif-cmd flushe) :msk #x1))
(set! (-> arg0 base) (the-as pointer (&+ v1-9 16)))
)
0
(none)
)
(deftype sprite-glow-dma-packet-data (structure)
"DMA templates for generating DMA to VU1."
((control-packet dma-packet :inline)
(vecdata-packet dma-packet :inline)
(shader-cnt-packet dma-packet :inline)
(shader-ref-packet dma-packet :inline)
(mscal-packet dma-packet :inline)
)
)
(deftype sprite-glow-cnt-template (structure)
"DMA layout for sending a sprite to VU1, with inline shader."
((control-packet dma-packet :inline)
(num-sprites uint32)
(dummys uint32 3)
(vecdata-packet dma-packet :inline)
(vecdata sprite-glow-data :inline)
(shader-packet dma-packet :inline)
(shader adgif-shader :inline)
(mscal-packet dma-packet :inline)
(quads vector 10 :inline :overlay-at (-> control-packet dma))
)
)
(deftype sprite-glow-ref-template (structure)
"DMA layout for sending a sprite to VU1, with reference to shader."
((control-packet dma-packet :inline)
(num-sprites uint32)
(dummys uint32 3)
(num-sprites-quad uint128 :overlay-at num-sprites)
(vecdata-packet dma-packet :inline)
(vecdata sprite-glow-data :inline)
(shader-packet dma-packet :inline)
(shader-packet-ptr pointer :offset 116)
(mscal-packet dma-packet :inline)
)
)
(define *sprite-glow-dma-packet-data*
(new 'static 'sprite-glow-dma-packet-data
:control-packet (new 'static 'dma-packet
:dma (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt))
:vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
:vif1 (new 'static 'vif-tag :imm #x8000 :num #x1 :cmd (vif-cmd unpack-v4-32))
)
:vecdata-packet (new 'static 'dma-packet
:dma (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))
:vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
:vif1 (new 'static 'vif-tag :imm #x8001 :num #x4 :cmd (vif-cmd unpack-v4-32))
)
:shader-cnt-packet (new 'static 'dma-packet
:dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id cnt))
:vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
:vif1 (new 'static 'vif-tag :imm #x8091 :num #x5 :cmd (vif-cmd unpack-v4-32))
)
:shader-ref-packet (new 'static 'dma-packet
:dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))
:vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
:vif1 (new 'static 'vif-tag :imm #x8091 :num #x5 :cmd (vif-cmd unpack-v4-32))
)
:mscal-packet (new 'static 'dma-packet
:dma (new 'static 'dma-tag :id (dma-tag-id cnt))
:vif1 (new 'static 'vif-tag :cmd (vif-cmd flushe) :msk #x1)
)
)
)
(set! (-> *sprite-glow-dma-packet-data* mscal-packet vif0)
(new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #xa)
)
;; WARN: Return type mismatch sprite-glow-cnt-template vs none.
(defun sprite-glow-add-sprite ((arg0 dma-buffer) (arg1 sprite-vec-data-2d) (arg2 float) (arg3 float) (arg4 float) (arg5 adgif-shader))
"Generate DMA to draw a single sprite from the aux-list."
(let ((v1-0 (the-as sprite-glow-cnt-template (-> arg0 base))))
(let* ((t5-0 *sprite-glow-dma-packet-data*)
(t2-0 (-> t5-0 control-packet quad))
(t3-0 (-> t5-0 vecdata-packet quad))
(t4-0 (-> t5-0 shader-cnt-packet quad))
(t5-1 (-> t5-0 mscal-packet quad))
)
(set! (-> v1-0 control-packet quad) t2-0)
(set! (-> v1-0 quads 1 quad) (the-as uint128 0))
(set! (-> v1-0 vecdata-packet quad) t3-0)
(set! (-> v1-0 shader-packet quad) t4-0)
(set! (-> v1-0 mscal-packet quad) t5-1)
)
(let ((t2-1 (-> arg1 x-y-z-sx quad))
(t3-1 (-> arg1 flag-rot-sy quad))
(a1-1 (-> arg1 r-g-b-a quad))
)
(set! (-> v1-0 vecdata position quad) t2-1)
(set! (-> v1-0 vecdata quads 1 quad) t3-1)
(set! (-> v1-0 vecdata color quad) a1-1)
)
(let ((a1-2 1))
(set! (-> v1-0 vecdata z-offset) arg4)
(set! (-> v1-0 vecdata fade-a) arg2)
(set! (-> v1-0 vecdata fade-b) arg3)
(set! (-> v1-0 num-sprites) (the-as uint a1-2))
)
(let ((a1-3 (-> arg5 quad 0 quad))
(a2-1 (-> arg5 quad 1 quad))
(a3-1 (-> arg5 quad 2 quad))
(t0-1 (-> arg5 quad 3 quad))
(t1-1 (-> arg5 quad 4 quad))
)
(set! (-> v1-0 quads 8 quad) a1-3)
(set! (-> v1-0 quads 9 quad) a2-1)
(set! (-> v1-0 shader quad 2 quad) a3-1)
(set! (-> v1-0 shader quad 3 quad) t0-1)
(set! (-> v1-0 shader quad 4 quad) t1-1)
)
(set! (-> arg0 base) (the-as pointer (&+ v1-0 224)))
)
(none)
)
;; WARN: Return type mismatch sprite-glow-ref-template vs none.
(defun sprite-glow-add-simple-sprite ((arg0 dma-buffer) (arg1 sprite-glow-dma-packet-data) (arg2 sprite-glow-data) (arg3 pointer))
"Generate DMA to draw a single sprite from the simple sprite system."
(let ((v1-0 (the-as sprite-glow-ref-template (-> arg0 base))))
(let ((t0-0 (-> arg1 control-packet quad))
(t1-0 (-> arg1 vecdata-packet quad))
(t2-0 (-> arg1 shader-ref-packet quad))
(a1-1 (-> arg1 mscal-packet quad))
)
(set! (-> v1-0 control-packet quad) t0-0)
(set! (-> v1-0 num-sprites-quad) (the-as uint128 0))
(set! (-> v1-0 vecdata-packet quad) t1-0)
(set! (-> v1-0 shader-packet quad) t2-0)
(set! (-> v1-0 mscal-packet quad) a1-1)
)
(let ((a1-2 (-> arg2 position quad))
(t0-1 (-> arg2 quads 1 quad))
(t1-1 (-> arg2 color quad))
(a2-1 (-> arg2 quads 3 quad))
(t2-1 1)
)
(set! (-> v1-0 vecdata position quad) a1-2)
(set! (-> v1-0 vecdata quads 1 quad) t0-1)
(set! (-> v1-0 vecdata color quad) t1-1)
(set! (-> v1-0 vecdata quads 3 quad) a2-1)
(set! (-> v1-0 num-sprites) (the-as uint t2-1))
)
(set! (-> v1-0 shader-packet-ptr) arg3)
(set! (-> arg0 base) (the-as pointer (&+ v1-0 144)))
)
(none)
)
(defun sprite-glow-draw ((arg0 dma-buffer))
"Generate DMA for all glow sprites in the aux-list (from sparticle system)"
(local-vars (a2-0 float))
(let* ((s5-0 *sprite-aux-list*)
(s4-0 (-> s5-0 entry))
(s3-0 #f)
)
(dotimes (s2-0 s4-0)
(let ((v1-2 (-> s5-0 data s2-0)))
(when (and (not s3-0) (= (-> v1-2 aux-type) (sprite-aux-type glow)))
(let* ((a0-5 (-> v1-2 aux-data omega))
(a3-0 (cond
((zero? a0-5)
(set! a2-0 0.0)
1.0
)
(else
(let* ((f1-1 (* 0.00024414062 a0-5))
(f0-4 (- f1-1 (the float (the int f1-1))))
)
(let ((f1-3 (* 4096.0 (- f1-1 f0-4))))
(set! a2-0 (/ -1.0 (* (- 1.0 f0-4) f1-3)))
)
(/ f0-4 (- 1.0 f0-4))
)
)
)
)
)
(sprite-glow-add-sprite arg0 (-> v1-2 vec-data) a2-0 a3-0 (-> v1-2 aux-data user-float) (-> v1-2 gif-data))
)
)
)
)
)
0
(none)
)
(defmethod add! ((this simple-sprite-system) (arg0 sprite-glow-data))
"Add a sprite to the list, to be drawn later."
(let ((v1-0 (-> this count)))
(when (< v1-0 (-> this max-count))
(let* ((a2-3 (-> this data v1-0))
(v1-2 arg0)
(a1-1 a2-3)
(a2-4 (-> v1-2 position quad))
(a3-0 (-> v1-2 quads 1 quad))
(t0-0 (-> v1-2 color quad))
(v1-3 (-> v1-2 quads 3 quad))
)
(set! (-> a1-1 position quad) a2-4)
(set! (-> a1-1 quads 1 quad) a3-0)
(set! (-> a1-1 color quad) t0-0)
(set! (-> a1-1 quads 3 quad) v1-3)
)
(+! (-> this count) 1)
)
)
0
(none)
)
;; WARN: Return type mismatch pointer vs adgif-shader.
(defun add-shader-to-dma ((arg0 dma-buffer))
(let* ((a1-0 (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id next))))
(v1-0 (-> arg0 base))
(a1-1 (-> a1-0 quad))
(v0-0 (&+ v1-0 16))
)
(let ((a2-0 (&+ v1-0 96)))
(set! (-> (the-as (pointer uint128) v1-0)) a1-1)
(set! (-> (the-as (pointer uint32) v1-0) 1) (the-as uint a2-0))
(set! (-> arg0 base) a2-0)
)
(the-as adgif-shader v0-0)
)
)
(defmethod draw-all-sprites! ((this simple-sprite-system) (arg0 dma-buffer))
"Submit all sprites to the sprite-glow renderer"
(local-vars (sv-528 sprite-glow-dma-packet-data) (sv-532 (pointer texture-id)) (sv-536 pointer))
(b! (zero? (-> this count)) cfg-13 :delay (nop!))
(set! sv-528 *sprite-glow-dma-packet-data*)
(set! sv-532 (new 'stack-no-clear 'array 'texture-id 128))
(set! sv-536 (-> arg0 base))
(dotimes (v1-5 (-> this count))
(set! (-> sv-532 v1-5) (-> this data v1-5 tex-id))
)
(countdown (s4-0 (-> this count))
(let ((s3-0 (-> sv-532 s4-0)))
(when (nonzero? s3-0)
(let ((s2-0 (add-shader-to-dma arg0)))
(adgif-shader<-texture-simple! s2-0 (lookup-texture-by-id s3-0))
(countdown (s1-1 (+ s4-0 1))
(when (= s3-0 (-> sv-532 s1-1))
(set! (-> sv-532 s1-1) (new 'static 'texture-id))
(let ((a2-1 (-> this data s1-1)))
(sprite-glow-add-simple-sprite arg0 sv-528 a2-1 (the-as pointer s2-0))
)
)
)
)
)
)
)
(label cfg-13)
0
(none)
)
(defmethod clear! ((this simple-sprite-system))
"Reset the list."
(set! (-> this count) 0)
0
(none)
)
(define *simple-sprite-system*
(new 'static 'simple-sprite-system :max-count #x80 :data (new 'static 'inline-array sprite-glow-data 128
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
)
)
)

View File

@ -1538,4 +1538,20 @@
(defmacro current-frame ()
`(-> *display* frames (-> *display* on-screen))
)
)
(defmacro vftoi4.xyzw (dst src)
"convert to 28.4 integer. This does the multiply while the number is still
a float. This will have issues for very large floats, but it seems like this
is how PCSX2 does it as well, so maybe it's right?
NOTE: this is the only version of the instruction used in Jak 1, so we
don't need to worry about masks."
`(begin
(rlet ((temp :class vf))
(set! temp 16.0)
(.mul.x.vf temp ,src temp)
(.ftoi.vf ,dst temp)
)
)
)

View File

@ -0,0 +1,103 @@
;;-*-Lisp-*-
(in-package goal)
;; definition for function make-debug-sphere-table
;; INFO: Used lq/sq
(defun make-debug-sphere-table ((arg0 vector-array) (arg1 float) (arg2 float))
"Create a table of lines on a sphere."
(local-vars (sv-80 vector) (sv-96 vector) (sv-112 int))
(let ((s2-0 (new-stack-vector0))
(f30-0 1.0)
(s5-0 0)
)
(set-vector! s2-0 0.0 0.0 0.0 1.0)
(dotimes (s1-0 (the int arg2))
(let ((f28-0 (* f30-0 (sin (* (the float s1-0) (/ 32768.0 arg2)))))
(f26-0 (* f30-0 (sin (* (the float (+ s1-0 1)) (/ 32768.0 arg2)))))
(s0-0 (new-stack-vector0))
)
(set! sv-80 (new 'stack-no-clear 'vector))
(set! (-> sv-80 quad) (the-as uint128 0))
(set! sv-96 (new 'stack-no-clear 'vector))
(set! (-> sv-96 quad) (the-as uint128 0))
(set! (-> s0-0 y) (+ (-> s2-0 y) (* (cos (* (the float s1-0) (/ 32768.0 arg2))) f30-0)))
(set! (-> sv-80 y) (-> s0-0 y))
(set! (-> sv-96 y) (+ (-> s2-0 y) (* (cos (* (the float (+ s1-0 1)) (/ 32768.0 arg2))) f30-0)))
(set! sv-112 0)
(while (< sv-112 (the int arg1))
(set! (-> s0-0 x) (+ (-> s2-0 x) (* (cos (* (the float sv-112) (/ 65536.0 arg1))) f28-0)))
(set! (-> s0-0 z) (+ (-> s2-0 z) (* (sin (* (the float sv-112) (/ 65536.0 arg1))) f28-0)))
(set! (-> sv-80 x) (+ (-> s2-0 x) (* (cos (* (the float (+ sv-112 1)) (/ 65536.0 arg1))) f28-0)))
(set! (-> sv-80 z) (+ (-> s2-0 z) (* (sin (* (the float (+ sv-112 1)) (/ 65536.0 arg1))) f28-0)))
(set! (-> sv-96 x) (+ (-> s2-0 x) (* (cos (* (the float sv-112) (/ 65536.0 arg1))) f26-0)))
(set! (-> sv-96 z) (+ (-> s2-0 z) (* (sin (* (the float sv-112) (/ 65536.0 arg1))) f26-0)))
(set! (-> arg0 data s5-0 quad) (-> s0-0 quad))
(set! (-> arg0 data (+ s5-0 1) quad) (-> sv-80 quad))
(set! (-> arg0 data (+ s5-0 2) quad) (-> sv-96 quad))
(+! s5-0 3)
(set! sv-112 (+ sv-112 1))
)
)
)
(set! (-> arg0 length) s5-0)
)
arg0
)
;; this part is debug only
(when *debug-segment*
;; definition for symbol *debug-sphere-table*, type (array vector-array)
(define *debug-sphere-table* (new 'debug 'boxed-array vector-array 10))
)
;; definition for function add-debug-sphere-from-table
;; INFO: Used lq/sq
;; WARN: Return type mismatch int vs none.
(defun add-debug-sphere-from-table ((arg0 bucket-id) (arg1 vector) (arg2 meters) (arg3 rgba) (arg4 int))
"Draw a sphere out of debug lines, using the precomputed table of lines."
(local-vars (sv-32 vector-array) (sv-36 vector))
(rlet ((vf1 :class vf)
(vf2 :class vf)
(vf3 :class vf)
(vf4 :class vf)
(vf5 :class vf)
)
(if (zero? (-> *debug-sphere-table* arg4))
(set! (-> *debug-sphere-table* arg4)
(make-debug-sphere-table (new 'debug 'vector-array (* (* 3 arg4) arg4)) (the float arg4) (the float arg4))
)
)
(set! sv-32 (-> *debug-sphere-table* arg4))
(set! sv-36 (the-as vector (new-stack-vector0)))
(let ((s2-1 (new-stack-vector0))
(s1-1 (new-stack-vector0))
(s0-0 (the-as object (-> sv-32 data)))
)
(.lvf vf1 (&-> arg1 quad))
(.mov vf2 arg2)
(countdown (s4-1 (/ (-> sv-32 length) 3))
(.lvf vf3 (&-> (the-as (inline-array vector) s0-0) 0 quad))
(.lvf vf4 (&-> (the-as (inline-array vector) s0-0) 1 quad))
(.lvf vf5 (&-> (the-as (inline-array vector) s0-0) 2 quad))
(set! s0-0 (-> (the-as (inline-array vector) s0-0) 3))
(.mul.x.vf vf3 vf3 vf2)
(.mul.x.vf vf4 vf4 vf2)
(.mul.x.vf vf5 vf5 vf2)
(.add.vf vf3 vf3 vf1)
(.add.vf vf4 vf4 vf1)
(.add.vf vf5 vf5 vf1)
(.svf (&-> s2-1 quad) vf3)
(.svf (&-> s1-1 quad) vf4)
(.svf (&-> sv-36 quad) vf5)
(add-debug-line #t arg0 s2-1 s1-1 arg3 #f (the-as rgba -1))
(add-debug-line #t arg0 s2-1 sv-36 arg3 #f (the-as rgba -1))
)
)
0
(none)
)
)

1951
test/decompiler/reference/jak3/engine/debug/debug_REF.gc generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -284,7 +284,7 @@
(reg-save uint32 5)
)
(:methods
(font-work-method-9 () none)
(set-context! (_type_ object) none)
)
)
@ -775,7 +775,3 @@
;; failed to figure out what this is:
0

View File

@ -68,12 +68,12 @@
(format #t "~1Tfriction: ~f~%" (-> this friction))
(format #t "~1Ttimer: ~D~%" (-> this timer))
(format #t "~1Tflags: ~D~%" (-> this flags))
(format #t "~1Tuser-int32: ~D~%" (-> this user-int32))
(format #t "~1Tuser-uint32: ~D~%" (-> this user-uint32))
(format #t "~1Tuser-float: ~f~%" (the-as float (-> this user-uint32)))
(format #t "~1Tuser-pntr: #x~X~%" (-> this user-uint32))
(format #t "~1Tuser-object: ~A~%" (-> this user-int32))
(format #t "~1Tuser-sprite: #<sprite-vec-data-2d @ #x~X>~%" (-> this user-uint32))
(format #t "~1Tuser-int32: ~D~%" (-> this user-float))
(format #t "~1Tuser-uint32: ~D~%" (-> this user-float))
(format #t "~1Tuser-float: ~f~%" (the-as float (-> this user-float)))
(format #t "~1Tuser-pntr: #x~X~%" (-> this user-float))
(format #t "~1Tuser-object: ~A~%" (-> this user-float))
(format #t "~1Tuser-sprite: #<sprite-vec-data-2d @ #x~X>~%" (-> this user-float))
(format #t "~1Tsp-func: ~A~%" (-> this sp-func))
(format #t "~1Tnext-time: ~D~%" (-> this next-time))
(format #t "~1Tnext-launcher: ~A~%" (-> this next-launcher))
@ -172,7 +172,3 @@ There are separate systems for different modes of sprite rendering: 2D/billboard
;; failed to figure out what this is:
0

View File

@ -4,8 +4,8 @@
;; definition of type sprite-glow-data
(deftype sprite-glow-data (structure)
((position vector :inline)
(size-x float :overlay-at (-> position data 3))
(size-probe float :offset 16)
(size-x float :overlay-at (-> position data 3))
(size-probe float :offset 16)
(z-offset float)
(rot-angle float)
(size-y float)
@ -14,6 +14,7 @@
(fade-b float)
(tex-id texture-id)
(dummy uint32)
(quads vector 4 :inline :overlay-at position)
)
(:methods
(set-trans (_type_ vector) none)
@ -61,9 +62,9 @@
(data (inline-array sprite-glow-data))
)
(:methods
(simple-sprite-system-method-9 () none)
(add! (_type_ sprite-glow-data) none)
(draw-all-sprites! (_type_ dma-buffer) none)
(simple-sprite-system-method-11 () none)
(clear! (_type_) none)
)
)

View File

@ -0,0 +1,378 @@
;;-*-Lisp-*-
(in-package goal)
;; definition of type sprite-distorter-sine-tables
(deftype sprite-distorter-sine-tables (basic)
"Table of precomputed sine data for the sprite distorter renderer."
((aspx float)
(aspy float)
(entry vector 128 :inline)
(ientry qword 9 :inline)
(giftag gs-gif-tag :inline)
(color qword :inline)
)
)
;; definition for method 3 of type sprite-distorter-sine-tables
(defmethod inspect ((this sprite-distorter-sine-tables))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Taspx: ~f~%" (-> this aspx))
(format #t "~1Taspy: ~f~%" (-> this aspy))
(format #t "~1Tentry[128] @ #x~X~%" (-> this entry))
(format #t "~1Tientry[9] @ #x~X~%" (-> this ientry))
(format #t "~1Tgiftag: #<qword @ #x~X>~%" (-> this giftag))
(format #t "~1Tcolor: #<qword @ #x~X>~%" (-> this color))
(label cfg-4)
this
)
;; failed to figure out what this is:
(kmemopen global "sprite-distort-tables")
;; definition for symbol *sprite-distorter-sine-tables*, type sprite-distorter-sine-tables
(define *sprite-distorter-sine-tables* (new 'global 'sprite-distorter-sine-tables))
;; failed to figure out what this is:
(kmemclose)
;; definition for function sprite-distorter-generate-tables
;; WARN: Return type mismatch int vs none.
(defun sprite-distorter-generate-tables ()
"Regenerate the sprite-distorter-sine-tables for the current camera settings."
(let ((gp-0 *sprite-distorter-sine-tables*))
(let ((s3-0 0)
(s5-0 0)
(s4-0 3)
(f28-0 (- (-> *math-camera* perspective rvec x)))
(f30-0 (- (-> *math-camera* perspective uvec y)))
)
(when (or (!= f28-0 (-> gp-0 aspx)) (!= f30-0 (-> gp-0 aspy)))
(set! (-> gp-0 aspx) f28-0)
(set! (-> gp-0 aspy) f30-0)
(while (< s4-0 12)
(set! (-> gp-0 ientry s5-0 vector4w x) (+ s3-0 352))
(+! s5-0 1)
(dotimes (s2-0 s4-0)
(let ((f26-0 (* 65536.0 (/ (the float s2-0) (the float s4-0)))))
(set-vector! (-> gp-0 entry s3-0) (* (sin f26-0) f28-0) (* (cos f26-0) f30-0) 0.0 0.0)
(let ((s3-1 (+ s3-0 1)))
(set-vector! (-> gp-0 entry s3-1) (* 0.001953125 f28-0 (sin f26-0)) (* 0.001953125 f30-0 (cos f26-0)) 0.0 0.0)
(set! s3-0 (+ s3-1 1))
)
)
)
(+! s4-0 1)
)
(set-vector! (-> gp-0 entry s3-0) 0.0 f30-0 0.0 0.0)
(let ((v1-20 (+ s3-0 1)))
(set-vector! (-> gp-0 entry v1-20) 0.0 (* 0.001953125 f30-0) 0.0 0.0)
(+ v1-20 1)
)
)
)
(set! (-> gp-0 giftag tag) (new 'static 'gif-tag64
:nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :tme #x1)
:nreg #xf
)
)
(set! (-> gp-0 giftag regs) (new 'static 'gif-tag-regs
:regs0 (gif-reg-id st)
:regs1 (gif-reg-id rgbaq)
:regs2 (gif-reg-id xyzf2)
:regs3 (gif-reg-id st)
:regs4 (gif-reg-id rgbaq)
:regs5 (gif-reg-id xyzf2)
:regs6 (gif-reg-id st)
:regs7 (gif-reg-id rgbaq)
:regs8 (gif-reg-id xyzf2)
:regs9 (gif-reg-id st)
:regs10 (gif-reg-id rgbaq)
:regs11 (gif-reg-id xyzf2)
:regs12 (gif-reg-id st)
:regs13 (gif-reg-id rgbaq)
:regs14 (gif-reg-id xyzf2)
)
)
(set! (-> gp-0 color vector4w x) 128)
(set! (-> gp-0 color vector4w y) 128)
(set! (-> gp-0 color vector4w z) 128)
(set! (-> gp-0 color vector4w w) 128)
)
0
(none)
)
;; definition for symbol sprite-distort-vu1-block, type vu-function
(define sprite-distort-vu1-block (new 'static 'vu-function :length 63 :qlength 32))
;; definition for function sprite-init-distorter
;; WARN: Return type mismatch int vs none.
(defun sprite-init-distorter ((arg0 dma-buffer))
"Generate DMA to initialize the distort renderer."
(dma-buffer-add-gs-set arg0
(zbuf-1 (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1))
(tex0-1 (new 'static 'gs-tex0 :tbp0 #x3300 :tbw #x8 :tw #x9 :th #x9))
(tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
(miptbp1-1 (new 'static 'gs-miptbp))
(clamp-1 (new 'static 'gs-clamp
:wms (gs-tex-wrap-mode region-clamp)
:wmt (gs-tex-wrap-mode region-clamp)
:maxu #x1ff
:maxv #x19f
)
)
(alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
)
(let* ((v1-3 arg0)
(a1-6 (the-as dma-packet (-> v1-3 base)))
)
(set! (-> a1-6 dma) (new 'static 'dma-tag
:qwc #x8b
:id (dma-tag-id ref)
:addr (the-as uint (-> *sprite-distorter-sine-tables* entry))
)
)
(set! (-> a1-6 vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
(set! (-> a1-6 vif1) (new 'static 'vif-tag :imm #x160 :num #x8b :cmd (vif-cmd unpack-v4-32)))
(set! (-> v1-3 base) (the-as pointer (&+ a1-6 16)))
)
(dma-buffer-add-vu-function arg0 sprite-distort-vu1-block 1)
0
(none)
)
;; definition for function sprite-draw-distorters
;; INFO: Used lq/sq
;; WARN: Return type mismatch int vs none.
;; ERROR: Inline assembly instruction marked with TODO - [TODO.VCLIP]
;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping]
(defun sprite-draw-distorters ((arg0 dma-buffer))
"Generate DMA to draw all distort sprites."
(local-vars
(v1-15 float)
(v1-21 float)
(v1-26 int)
(v1-65 float)
(sv-16 sprite-vec-data-2d)
(sv-32 vector)
(sv-48 vector)
)
(rlet ((acc :class vf)
(Q :class vf)
(vf0 :class vf)
(vf1 :class vf)
(vf10 :class vf)
(vf2 :class vf)
(vf3 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
(vf8 :class vf)
(vf9 :class vf)
)
(init-vf0-vector)
(.lvf vf8 (&-> *math-camera* hmge-scale quad))
(let ((s0-0 (-> arg0 base))
(s4-0 0)
(s5-0 0)
)
(&+! (-> arg0 base) 16)
(let* ((s3-0 *sprite-aux-list*)
(s2-0 (-> s3-0 entry))
)
(dotimes (s1-0 s2-0)
(let ((v1-5 (-> s3-0 data s1-0)))
(when (= (-> v1-5 aux-type) (sprite-aux-type distort))
(set! sv-16 (-> v1-5 vec-data))
(let ((a0-3 (the-as object (-> arg0 base))))
(set! sv-32 (the-as vector (&+ (the-as pointer a0-3) 16)))
(set! sv-48 (the-as vector (&+ (the-as pointer a0-3) 32)))
(cond
((= (the-as int (-> sv-16 flag-rot-sy y)) 1)
(.lvf vf3 (&-> *math-camera* sprite-2d rvec quad))
(.lvf vf4 (&-> *math-camera* sprite-2d uvec quad))
(.lvf vf5 (&-> *math-camera* sprite-2d fvec quad))
(.lvf vf6 (&-> *math-camera* sprite-2d trans quad))
(.lvf vf9 (&-> *math-camera* sprite-2d-hvdf quad))
(.mov v1-15 vf9)
)
(else
(.lvf vf3 (&-> *math-camera* camera-temp rvec quad))
(.lvf vf4 (&-> *math-camera* camera-temp uvec quad))
(.lvf vf5 (&-> *math-camera* camera-temp fvec quad))
(.lvf vf6 (&-> *math-camera* camera-temp trans quad))
(.lvf vf9 (&-> *math-camera* hvdf-off quad))
(.mov v1-21 vf9)
)
)
(.lvf vf1 (&-> sv-16 x-y-z-sx quad))
(.lvf vf2 (&-> sv-16 r-g-b-a quad))
(.mul.w.vf acc vf6 vf0)
(.add.mul.x.vf acc vf3 vf1 acc)
(.add.mul.y.vf acc vf4 vf1 acc)
(.add.mul.z.vf vf1 vf5 vf1 acc)
(.mul.vf vf10 vf1 vf8)
(.div.vf Q vf0 vf10 :fsf #b11 :ftf #b11)
(TODO.VCLIP vf10 vf10)
(b! (zero? (-> sv-16 flag-rot-sy x)) cfg-22 :delay (nop!))
(.wait.vf)
(.mul.vf vf1 vf1 Q :mask #b111)
(.mul.vf vf2 vf2 Q :mask #b111)
(.cfc2.i v1-26 Clipping)
(b! (logtest? v1-26 63) cfg-22 :delay (.add.vf vf1 vf1 vf9))
(.max.x.vf vf1 vf1 vf0 :mask #b1000)
(.svf (&-> (the-as vector a0-3) quad) vf1)
(.svf (&-> sv-48 quad) vf2)
(set! (-> (the-as vector a0-3) w) 255.0)
(set! (-> sv-32 x) (+ 0.0009765625 (* 0.001953125 (+ -1792.0 (-> (the-as vector a0-3) x)))))
(set! (-> sv-32 y) (+ 0.0009765625 (* 0.001953125 (+ -1840.0 (-> (the-as vector a0-3) y)))))
)
(set! (-> sv-32 z) 1.0)
(when (or (< (the-as int (-> sv-16 flag-rot-sy x)) 3) (< 11 (the-as int (-> sv-16 flag-rot-sy x))))
(format 0 "Turns = ~D!!!~%" (-> sv-16 flag-rot-sy x))
(set! (-> sv-16 flag-rot-sy x) (the-as float #xb))
)
(set! (-> sv-32 w) (-> sv-16 flag-rot-sy x))
(let* ((f1-4 (- (-> *math-camera* perspective uvec y)))
(f2-4 (-> sv-32 y))
(f4-0 (+ f2-4 (* (-> sv-48 x) f1-4)))
(f3-2 256.0)
(f0-9 (-> sv-48 x))
)
(if (< 416.0 f4-0)
(set! f3-2 (/ (- 416.0 f2-4) f1-4))
)
(if (< 128.0 f3-2)
(set! f3-2 128.0)
)
(when (< f3-2 f0-9)
(let ((v1-63 (/ f3-2 f0-9)))
(.mov vf1 v1-63)
)
(.mul.x.vf vf2 vf2 vf1)
(.svf (&-> sv-48 quad) vf2)
(.mov v1-65 vf2)
)
)
(&+! (-> arg0 base) 48)
(+! s4-0 1)
(when (= s4-0 85)
(let ((v1-70 (-> arg0 base)))
(set! (-> arg0 base) s0-0)
(let* ((a0-10 arg0)
(a1-3 (the-as dma-packet (-> a0-10 base)))
)
(set! (-> a1-3 dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc (* 3 s4-0)))
(set! (-> a1-3 vif0) (new 'static 'vif-tag))
(set! (-> a1-3 vif1)
(new 'static 'vif-tag :cmd (vif-cmd unpack-v4-32) :imm (shr (shl (+ (* 3 s5-0) 512) 54) 54) :num (* 3 s4-0))
)
(set! (-> a0-10 base) (the-as pointer (&+ a1-3 16)))
)
(set! (-> arg0 base) v1-70)
)
(set! s4-0 0)
(+! s5-0 85)
(when (= s5-0 170)
(let* ((v1-73 arg0)
(a0-11 (the-as dma-packet (-> v1-73 base)))
)
(set! (-> a0-11 dma) (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt)))
(set! (-> a0-11 vif0) (new 'static 'vif-tag))
(set! (-> a0-11 vif1) (new 'static 'vif-tag :imm #x1ff :num #x1 :cmd (vif-cmd unpack-v4-32)))
(set! (-> v1-73 base) (the-as pointer (&+ a0-11 16)))
)
(let* ((v1-74 arg0)
(a0-13 (the-as vector4w (-> v1-74 base)))
)
(set! (-> a0-13 x) s5-0)
(set! (-> a0-13 y) 0)
(set! (-> a0-13 z) 0)
(set! (-> a0-13 w) 0)
(set! (-> v1-74 base) (the-as pointer (&+ a0-13 16)))
)
(let* ((v1-75 arg0)
(a0-15 (the-as dma-packet (-> v1-75 base)))
)
(set! (-> a0-15 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> a0-15 vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1))
(set! (-> a0-15 vif1) (new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1))
(set! (-> v1-75 base) (the-as pointer (&+ a0-15 16)))
)
(set! s5-0 0)
)
(set! s0-0 (-> arg0 base))
(&+! (-> arg0 base) 16)
)
)
)
(label cfg-22)
0
)
)
(cond
((zero? s4-0)
(set! (-> arg0 base) s0-0)
(nop!)
0
)
(else
(let ((v1-83 (-> arg0 base)))
(set! (-> arg0 base) s0-0)
(let* ((a0-17 arg0)
(a1-10 (the-as dma-packet (-> a0-17 base)))
)
(set! (-> a1-10 dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc (* 3 s4-0)))
(set! (-> a1-10 vif0) (new 'static 'vif-tag))
(set! (-> a1-10 vif1)
(new 'static 'vif-tag :cmd (vif-cmd unpack-v4-32) :imm (shr (shl (+ (* 3 s5-0) 512) 54) 54) :num (* 3 s4-0))
)
(set! (-> a0-17 base) (the-as pointer (&+ a1-10 16)))
)
(set! (-> arg0 base) v1-83)
)
)
)
(let ((v1-84 (+ s4-0 s5-0)))
(when (nonzero? v1-84)
(let* ((a0-19 arg0)
(a1-12 (the-as dma-packet (-> a0-19 base)))
)
(set! (-> a1-12 dma) (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt)))
(set! (-> a1-12 vif0) (new 'static 'vif-tag))
(set! (-> a1-12 vif1) (new 'static 'vif-tag :imm #x1ff :num #x1 :cmd (vif-cmd unpack-v4-32)))
(set! (-> a0-19 base) (the-as pointer (&+ a1-12 16)))
)
(let* ((a0-20 arg0)
(a1-14 (the-as vector4w (-> a0-20 base)))
)
(set! (-> a1-14 x) v1-84)
(set! (-> a1-14 y) 0)
(set! (-> a1-14 z) 0)
(set! (-> a1-14 w) 0)
(set! (-> a0-20 base) (the-as pointer (&+ a1-14 16)))
)
(let ((v1-86 (the-as dma-packet (-> arg0 base))))
(set! (-> v1-86 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> v1-86 vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1))
(set! (-> v1-86 vif1) (new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1))
(set! (-> arg0 base) (the-as pointer (&+ v1-86 16)))
)
)
)
)
0
(none)
)
)

View File

@ -0,0 +1,915 @@
;;-*-Lisp-*-
(in-package goal)
;; definition of type sprite-glow-template
(deftype sprite-glow-template (structure)
"Sprite glow GS data templates sent to VU1."
((clear-init-giftag gs-gif-tag :inline)
(clear-init-adcmds gs-adcmd 5 :inline)
(clear-draw-giftag gs-gif-tag :inline)
(clear-draw-clr-0 gs-packed-rgba :inline)
(clear-draw-xyz-0 gs-packed-xyzw 2 :inline)
(clear-draw-clr-1 gs-packed-rgba :inline)
(clear-draw-xyz-1 vector 2 :inline)
(offscr-setup-giftag gs-gif-tag :inline)
(offscr-setup-adcmds gs-adcmd 8 :inline)
(offscr-first-giftag gs-gif-tag :inline)
(offscr-first-clr gs-packed-rgba :inline)
(offscr-first-uv-0 gs-packed-uv :inline)
(offscr-first-xyzw-0 gs-packed-xyzw :inline)
(offscr-first-uv-1 gs-packed-uv :inline)
(offscr-first-xyzw-1 gs-packed-xyzw :inline)
(repeat-draw-giftag gs-gif-tag :inline)
(repeat-draw-adcmds gs-adcmd 29 :inline)
(flare-alpha-giftag gs-gif-tag :inline)
(flare-alpha-clr gs-packed-rgba :inline)
(flare-alpha-uv gs-packed-uv :inline)
(flare-alpha-xyzw-0 gs-packed-xyzw :inline)
(flare-alpha-xyzw-1 gs-packed-xyzw :inline)
(flare-alpha-xyzw-2 gs-packed-xyzw :inline)
(flare-alpha-xyzw-3 gs-packed-xyzw :inline)
(flare-init-giftag gs-gif-tag :inline)
(flare-init-adcmds gs-adcmd 8 :inline)
(flare-draw-giftag gs-gif-tag :inline)
(flare-draw-clr gs-packed-rgba :inline)
(flare-draw-stq-0 gs-packed-stq :inline)
(flare-draw-xyzw-0 gs-packed-xyzw :inline)
(flare-draw-stq-1 gs-packed-stq :inline)
(flare-draw-xyzw-1 gs-packed-xyzw :inline)
(flare-draw-stq-2 gs-packed-stq :inline)
(flare-draw-xyzw-2 gs-packed-xyzw :inline)
(flare-draw-stq-3 gs-packed-stq :inline)
(flare-draw-xyzw-3 gs-packed-xyzw :inline)
)
)
;; definition for method 3 of type sprite-glow-template
(defmethod inspect ((this sprite-glow-template))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'sprite-glow-template)
(format #t "~1Tclear-init-giftag: #<gs-gif-tag @ #x~X>~%" (-> this clear-init-giftag))
(format #t "~1Tclear-init-adcmds[5] @ #x~X~%" (-> this clear-init-adcmds))
(format #t "~1Tclear-draw-giftag: #<gs-gif-tag @ #x~X>~%" (-> this clear-draw-giftag))
(format #t "~1Tclear-draw-clr-0: #<gs-packed-rgba @ #x~X>~%" (-> this clear-draw-clr-0))
(format #t "~1Tclear-draw-xyz-0[2] @ #x~X~%" (-> this clear-draw-xyz-0))
(format #t "~1Tclear-draw-clr-1: #<gs-packed-rgba @ #x~X>~%" (-> this clear-draw-clr-1))
(format #t "~1Tclear-draw-xyz-1[2] @ #x~X~%" (-> this clear-draw-xyz-1))
(format #t "~1Toffscr-setup-giftag: #<gs-gif-tag @ #x~X>~%" (-> this offscr-setup-giftag))
(format #t "~1Toffscr-setup-adcmds[8] @ #x~X~%" (-> this offscr-setup-adcmds))
(format #t "~1Toffscr-first-giftag: #<gs-gif-tag @ #x~X>~%" (-> this offscr-first-giftag))
(format #t "~1Toffscr-first-clr: #<gs-packed-rgba @ #x~X>~%" (-> this offscr-first-clr))
(format #t "~1Toffscr-first-uv-0: #<gs-packed-uv @ #x~X>~%" (-> this offscr-first-uv-0))
(format #t "~1Toffscr-first-xyzw-0: #<gs-packed-xyzw @ #x~X>~%" (-> this offscr-first-xyzw-0))
(format #t "~1Toffscr-first-uv-1: #<gs-packed-uv @ #x~X>~%" (-> this offscr-first-uv-1))
(format #t "~1Toffscr-first-xyzw-1: #<gs-packed-xyzw @ #x~X>~%" (-> this offscr-first-xyzw-1))
(format #t "~1Trepeat-draw-giftag: #<gs-gif-tag @ #x~X>~%" (-> this repeat-draw-giftag))
(format #t "~1Trepeat-draw-adcmds[29] @ #x~X~%" (-> this repeat-draw-adcmds))
(format #t "~1Tflare-alpha-giftag: #<gs-gif-tag @ #x~X>~%" (-> this flare-alpha-giftag))
(format #t "~1Tflare-alpha-clr: #<gs-packed-rgba @ #x~X>~%" (-> this flare-alpha-clr))
(format #t "~1Tflare-alpha-uv: #<gs-packed-uv @ #x~X>~%" (-> this flare-alpha-uv))
(format #t "~1Tflare-alpha-xyzw-0: #<gs-packed-xyzw @ #x~X>~%" (-> this flare-alpha-xyzw-0))
(format #t "~1Tflare-alpha-xyzw-1: #<gs-packed-xyzw @ #x~X>~%" (-> this flare-alpha-xyzw-1))
(format #t "~1Tflare-alpha-xyzw-2: #<gs-packed-xyzw @ #x~X>~%" (-> this flare-alpha-xyzw-2))
(format #t "~1Tflare-alpha-xyzw-3: #<gs-packed-xyzw @ #x~X>~%" (-> this flare-alpha-xyzw-3))
(format #t "~1Tflare-init-giftag: #<gs-gif-tag @ #x~X>~%" (-> this flare-init-giftag))
(format #t "~1Tflare-init-adcmds[8] @ #x~X~%" (-> this flare-init-adcmds))
(format #t "~1Tflare-draw-giftag: #<gs-gif-tag @ #x~X>~%" (-> this flare-draw-giftag))
(format #t "~1Tflare-draw-clr: #<gs-packed-rgba @ #x~X>~%" (-> this flare-draw-clr))
(format #t "~1Tflare-draw-stq-0: #<gs-packed-stq @ #x~X>~%" (-> this flare-draw-stq-0))
(format #t "~1Tflare-draw-xyzw-0: #<gs-packed-xyzw @ #x~X>~%" (-> this flare-draw-xyzw-0))
(format #t "~1Tflare-draw-stq-1: #<gs-packed-stq @ #x~X>~%" (-> this flare-draw-stq-1))
(format #t "~1Tflare-draw-xyzw-1: #<gs-packed-xyzw @ #x~X>~%" (-> this flare-draw-xyzw-1))
(format #t "~1Tflare-draw-stq-2: #<gs-packed-stq @ #x~X>~%" (-> this flare-draw-stq-2))
(format #t "~1Tflare-draw-xyzw-2: #<gs-packed-xyzw @ #x~X>~%" (-> this flare-draw-xyzw-2))
(format #t "~1Tflare-draw-stq-3: #<gs-packed-stq @ #x~X>~%" (-> this flare-draw-stq-3))
(format #t "~1Tflare-draw-xyzw-3: #<gs-packed-xyzw @ #x~X>~%" (-> this flare-draw-xyzw-3))
(label cfg-4)
this
)
;; definition of type sprite-glow-consts
(deftype sprite-glow-consts (structure)
"Per-frame constants for sprite-glow VU1."
((camera matrix :inline)
(perspective matrix :inline)
(hvdf-offset vector :inline)
(hmge-scale vector :inline)
(consts vector :inline)
(pfog0 float :overlay-at (-> consts data 0))
(deg-to-rad float :overlay-at (-> consts data 1))
(min-scale float :overlay-at (-> consts data 2))
(inv-area float :overlay-at (-> consts data 3))
(sincos-01 vector :inline)
(sincos-23 vector :inline)
(sincos-45 vector :inline)
(sincos-67 vector :inline)
(sincos-89 vector :inline)
(basis-x vector :inline)
(basis-y vector :inline)
(xy-array vector 4 :inline)
(clamp-min vector :inline)
(clamp-max vector :inline)
)
)
;; definition for method 3 of type sprite-glow-consts
(defmethod inspect ((this sprite-glow-consts))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'sprite-glow-consts)
(format #t "~1Tcamera: #<matrix @ #x~X>~%" (-> this camera))
(format #t "~1Tperspective: #<matrix @ #x~X>~%" (-> this perspective))
(format #t "~1Thvdf-offset: #<vector @ #x~X>~%" (-> this hvdf-offset))
(format #t "~1Thmge-scale: #<vector @ #x~X>~%" (-> this hmge-scale))
(format #t "~1Tconsts: #<vector @ #x~X>~%" (-> this consts))
(format #t "~1Tpfog0: ~f~%" (-> this consts x))
(format #t "~1Tdeg-to-rad: ~f~%" (-> this consts y))
(format #t "~1Tmin-scale: ~f~%" (-> this consts z))
(format #t "~1Tinv-area: ~f~%" (-> this consts w))
(format #t "~1Tsincos-01: #<vector @ #x~X>~%" (-> this sincos-01))
(format #t "~1Tsincos-23: #<vector @ #x~X>~%" (-> this sincos-23))
(format #t "~1Tsincos-45: #<vector @ #x~X>~%" (-> this sincos-45))
(format #t "~1Tsincos-67: #<vector @ #x~X>~%" (-> this sincos-67))
(format #t "~1Tsincos-89: #<vector @ #x~X>~%" (-> this sincos-89))
(format #t "~1Tbasis-x: #<vector @ #x~X>~%" (-> this basis-x))
(format #t "~1Tbasis-y: #<vector @ #x~X>~%" (-> this basis-y))
(format #t "~1Txy-array[4] @ #x~X~%" (-> this xy-array))
(format #t "~1Tclamp-min: #<vector @ #x~X>~%" (-> this clamp-min))
(format #t "~1Tclamp-max: #<vector @ #x~X>~%" (-> this clamp-max))
(label cfg-4)
this
)
;; definition for symbol *sprite-glow-template*, type sprite-glow-template
(define *sprite-glow-template*
(new 'static 'sprite-glow-template
:clear-init-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64 :nloop #x5 :nreg #x1)
:regs (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))
)
:clear-init-adcmds (new 'static 'inline-array gs-adcmd 5
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
(new 'static 'gs-adcmd :cmds (gs-reg64 alpha-1) :x #x6a)
(new 'static 'gs-adcmd :cmds (gs-reg64 test-1) :x #x51001)
(new 'static 'gs-adcmd :cmds (gs-reg64 zbuf-1) :x #x1000130 :y #x1)
(new 'static 'gs-adcmd :cmds (gs-reg64 frame-1) :x #x80198 :y #xffffff)
)
:clear-draw-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64
:nloop #x2
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type sprite))
:nreg #x3
)
:regs (new 'static 'gif-tag-regs :regs0 (gif-reg-id rgbaq) :regs1 (gif-reg-id xyzf2) :regs2 (gif-reg-id xyzf2))
)
:clear-draw-xyz-0 (new 'static 'inline-array gs-packed-xyzw 2
(new 'static 'gs-packed-xyzw :iz -1)
(new 'static 'gs-packed-xyzw :iz -1)
)
:clear-draw-clr-1 (new 'static 'gs-packed-rgba :x #xff :w #xff)
:offscr-setup-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64 :nloop #x8 :nreg #x1)
:regs (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))
)
:offscr-setup-adcmds (new 'static 'inline-array gs-adcmd 8
(new 'static 'gs-adcmd :cmds (gs-reg64 frame-2) :x #x10090 :y #xffffff)
(new 'static 'gs-adcmd :cmds (gs-reg64 zbuf-2) :x #x1000130)
(new 'static 'gs-adcmd :cmds (gs-reg64 tex1-2) :x #x60)
(new 'static 'gs-adcmd :cmds (gs-reg64 tex0-2) :x #x64023300 :y #xe)
(new 'static 'gs-adcmd :cmds (gs-reg64 clamp-2) :x #x5)
(new 'static 'gs-adcmd :cmds (gs-reg64 test-2) :x #x31001)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyoffset-2))
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
)
:offscr-first-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64
:nloop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :fst #x1 :ctxt #x1)
:nreg #x5
)
:regs (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)
)
)
:offscr-first-clr (new 'static 'gs-packed-rgba :x #x80 :y #x80 :z #x80 :w #x80)
:offscr-first-xyzw-1 (new 'static 'gs-packed-xyzw :ix #x200 :iy #x200)
:repeat-draw-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64 :nloop #x1d :nreg #x1)
:regs (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))
)
:repeat-draw-adcmds (new 'static 'inline-array gs-adcmd 29
(new 'static 'gs-adcmd :cmds (gs-reg64 tex0-2) :x #x54005200 :y #xd)
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x100010)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x2100210)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2) :x #x1000100)
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x100010)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x1100110)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2) :x #x800080)
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x100010)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x900090)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2) :x #x400040)
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x100010)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2))
(new 'static 'gs-adcmd :cmds (gs-reg64 uv) :x #x500050)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyz2) :x #x200020)
(new 'static 'gs-adcmd :cmds (gs-reg64 frame-2) :x #x80198 :y #xffffff)
(new 'static 'gs-adcmd :cmds (gs-reg64 test-2) :x #x51001)
(new 'static 'gs-adcmd :cmds (gs-reg64 zbuf-2) :x #x1000130 :y #x1)
(new 'static 'gs-adcmd :cmds (gs-reg64 xyoffset-2) :x #x7000 :y #x7300)
(new 'static 'gs-adcmd :cmds (gs-reg64 scissor-2) :x #x1ff0000 :y #x19f0000)
(new 'static 'gs-adcmd :cmds (gs-reg64 test-2) :x #x50000)
(new 'static 'gs-adcmd :cmds (gs-reg64 alpha-2) :x #x6a)
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
)
:flare-alpha-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64
:nloop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1 :fst #x1 :ctxt #x1)
:nreg #x6
)
:regs (new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id uv)
:regs2 (gif-reg-id xyzf2)
:regs3 (gif-reg-id xyzf2)
:regs4 (gif-reg-id xyzf2)
:regs5 (gif-reg-id xyzf2)
)
)
:flare-alpha-clr (new 'static 'gs-packed-rgba :x #x80 :y #x80 :z #x80 :w #x80)
:flare-alpha-uv (new 'static 'gs-packed-uv :x (the-as float #x10) :y (the-as float #x10))
:flare-alpha-xyzw-0 (new 'static 'gs-packed-xyzw :iz -1)
:flare-alpha-xyzw-1 (new 'static 'gs-packed-xyzw :iz -1)
:flare-alpha-xyzw-2 (new 'static 'gs-packed-xyzw :iz -1)
:flare-alpha-xyzw-3 (new 'static 'gs-packed-xyzw :iz -1)
:flare-init-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64 :nloop #x8 :nreg #x1)
:regs (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))
)
:flare-init-adcmds (new 'static 'inline-array gs-adcmd 8
(new 'static 'gs-adcmd :cmds (gs-reg64 texflush))
(new 'static 'gs-adcmd :cmds (gs-reg64 frame-1) :x #x80198)
(new 'static 'gs-adcmd :cmds (gs-reg64 hack))
(new 'static 'gs-adcmd :cmds (gs-reg64 hack))
(new 'static 'gs-adcmd :cmds (gs-reg64 hack))
(new 'static 'gs-adcmd :cmds (gs-reg64 hack))
(new 'static 'gs-adcmd :cmds (gs-reg64 hack))
(new 'static 'gs-adcmd :cmds (gs-reg64 alpha-1) :x #x58)
)
:flare-draw-giftag (new 'static 'gs-gif-tag
:tag (new 'static 'gif-tag64
:nloop #x1
:eop #x1
:pre #x1
:prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :tme #x1 :abe #x1)
:nreg #x9
)
:regs (new 'static 'gif-tag-regs
:regs0 (gif-reg-id rgbaq)
:regs1 (gif-reg-id st)
:regs2 (gif-reg-id xyzf2)
:regs3 (gif-reg-id st)
:regs4 (gif-reg-id xyzf2)
:regs5 (gif-reg-id st)
:regs6 (gif-reg-id xyzf2)
:regs7 (gif-reg-id st)
:regs8 (gif-reg-id xyzf2)
)
)
:flare-draw-clr (new 'static 'gs-packed-rgba :y 64 :w #x80)
:flare-draw-stq-0 (new 'static 'gs-packed-stq :z 1.0)
:flare-draw-xyzw-0 (new 'static 'gs-packed-xyzw :iz -1)
:flare-draw-stq-1 (new 'static 'gs-packed-stq :x 1.0 :z 1.0)
:flare-draw-xyzw-1 (new 'static 'gs-packed-xyzw :iz -1)
:flare-draw-stq-2 (new 'static 'gs-packed-stq :x 1.0 :y 1.0 :z 1.0)
:flare-draw-xyzw-2 (new 'static 'gs-packed-xyzw :iz -1)
:flare-draw-stq-3 (new 'static 'gs-packed-stq :y 1.0 :z 1.0)
:flare-draw-xyzw-3 (new 'static 'gs-packed-xyzw :iz -1)
)
)
;; definition for symbol sprite-glow-vu1-block, type vu-function
(define sprite-glow-vu1-block (new 'static 'vu-function :length #x86 :qlength 67))
;; definition for function sprite-glow-init-consts
;; INFO: Used lq/sq
;; WARN: Return type mismatch vector vs none.
(defun sprite-glow-init-consts ((arg0 sprite-glow-consts))
"Fill out sprite-glow-consts to be sent to VU1."
(let ((v1-0 *math-camera*))
(let* ((t0-0 (-> arg0 camera))
(t1-0 (-> v1-0 camera-rot))
(a1-0 (-> t1-0 rvec quad))
(a2-0 (-> t1-0 uvec quad))
(a3-0 (-> t1-0 fvec quad))
(t1-1 (-> t1-0 trans quad))
)
(set! (-> t0-0 rvec quad) a1-0)
(set! (-> t0-0 uvec quad) a2-0)
(set! (-> t0-0 fvec quad) a3-0)
(set! (-> t0-0 trans quad) t1-1)
)
(let* ((t0-1 (-> arg0 perspective))
(t1-2 (-> v1-0 perspective))
(a1-1 (-> t1-2 rvec quad))
(a2-1 (-> t1-2 uvec quad))
(a3-1 (-> t1-2 fvec quad))
(t1-3 (-> t1-2 trans quad))
)
(set! (-> t0-1 rvec quad) a1-1)
(set! (-> t0-1 uvec quad) a2-1)
(set! (-> t0-1 fvec quad) a3-1)
(set! (-> t0-1 trans quad) t1-3)
)
(set! (-> arg0 hvdf-offset quad) (-> v1-0 hvdf-off quad))
(set! (-> arg0 hmge-scale quad) (-> v1-0 hmge-scale quad))
(set! (-> arg0 basis-x quad) (the-as uint128 0))
(set! (-> arg0 basis-x x) (- (-> *math-camera* perspective rvec x)))
(set! (-> arg0 basis-y quad) (the-as uint128 0))
(set! (-> arg0 basis-y y) (- (-> *math-camera* perspective uvec y)))
(set! (-> arg0 consts x) (-> v1-0 pfog0))
)
(set! (-> arg0 consts y) 0.000095873795)
(set! (-> arg0 consts z) (sqrtf (* (/ 1.0 (-> arg0 basis-x x)) (/ 1.0 (-> arg0 basis-y y)))))
(set! (-> arg0 consts w) (/ 1.0 (* (-> arg0 consts z) (-> arg0 consts z))))
(let ((v1-5 (-> arg0 sincos-01)))
(set! (-> v1-5 z) 0.999998)
(set! (-> v1-5 w) 1.0)
)
(let ((v1-6 (-> arg0 sincos-23)))
(set! (-> v1-6 z) -0.16666014)
(set! (-> v1-6 w) -0.49998003)
)
(let ((v1-7 (-> arg0 sincos-45)))
(set! (-> v1-7 z) 0.008326521)
(set! (-> v1-7 w) 0.041620404)
)
(let ((v1-8 (-> arg0 sincos-67)))
(set! (-> v1-8 z) -0.0001956241)
(set! (-> v1-8 w) -0.0013636408)
)
(let ((v1-9 (-> arg0 sincos-89)))
(set! (-> v1-9 z) 0.0000023042373)
(set! (-> v1-9 w) 0.000020170546)
)
(set-vector! (-> arg0 xy-array 0) -0.5 -0.5 0.0 0.0)
(set-vector! (-> arg0 xy-array 1) 0.5 -0.5 0.0 0.0)
(set-vector! (-> arg0 xy-array 2) 0.5 0.5 0.0 0.0)
(set-vector! (-> arg0 xy-array 3) -0.5 0.5 0.0 0.0)
(set-vector! (-> arg0 clamp-min) 1792.0 1840.0 0.0 0.0)
(set-vector! (-> arg0 clamp-max) 2304.0 2256.0 2048.0 50.0)
(none)
)
;; definition for function sprite-glow-init-engine
;; WARN: Return type mismatch int vs none.
(defun sprite-glow-init-engine ((arg0 dma-buffer))
"Generate DMA to initialize sprite-glow VU1."
(dma-buffer-add-vu-function arg0 sprite-glow-vu1-block 1)
(let ((s5-0 24))
(let* ((v1-0 arg0)
(a0-2 (the-as dma-packet (-> v1-0 base)))
)
(set! (-> a0-2 dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc s5-0))
(set! (-> a0-2 vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
(set! (-> a0-2 vif1) (new 'static 'vif-tag :imm #x3d4 :cmd (vif-cmd unpack-v4-32) :num s5-0))
(set! (-> v1-0 base) (the-as pointer (&+ a0-2 16)))
)
(sprite-glow-init-consts (the-as sprite-glow-consts (-> arg0 base)))
(&+! (-> arg0 base) (* s5-0 16))
)
(let ((v1-3 84))
(let* ((a0-6 arg0)
(a1-6 (the-as dma-packet (-> a0-6 base)))
)
(set! (-> a1-6 dma)
(new 'static 'dma-tag :id (dma-tag-id ref) :addr (the-as int *sprite-glow-template*) :qwc v1-3)
)
(set! (-> a1-6 vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)))
(set! (-> a1-6 vif1) (new 'static 'vif-tag :imm #x320 :cmd (vif-cmd unpack-v4-32) :num v1-3))
(set! (-> a0-6 base) (the-as pointer (&+ a1-6 16)))
)
(let* ((a0-7 arg0)
(a1-8 (the-as dma-packet (-> a0-7 base)))
)
(set! (-> a1-8 dma)
(new 'static 'dma-tag :id (dma-tag-id ref) :addr (the-as int *sprite-glow-template*) :qwc v1-3)
)
(set! (-> a1-8 vif0) (new 'static 'vif-tag :cmd (vif-cmd mscal) :msk #x1 :imm #x0))
(set! (-> a1-8 vif1) (new 'static 'vif-tag :imm #x374 :cmd (vif-cmd unpack-v4-32) :num v1-3))
(set! (-> a0-7 base) (the-as pointer (&+ a1-8 16)))
)
)
(let* ((v1-8 arg0)
(a0-8 (the-as dma-packet (-> v1-8 base)))
)
(set! (-> a0-8 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> a0-8 vif0) (new 'static 'vif-tag :cmd (vif-cmd base)))
(set! (-> a0-8 vif1) (new 'static 'vif-tag :imm #x190 :cmd (vif-cmd offset)))
(set! (-> v1-8 base) (the-as pointer (&+ a0-8 16)))
)
(let ((v1-9 (the-as dma-packet (-> arg0 base))))
(set! (-> v1-9 dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> v1-9 vif0) (new 'static 'vif-tag))
(set! (-> v1-9 vif1) (new 'static 'vif-tag :cmd (vif-cmd flushe) :msk #x1))
(set! (-> arg0 base) (the-as pointer (&+ v1-9 16)))
)
0
(none)
)
;; definition of type sprite-glow-dma-packet-data
(deftype sprite-glow-dma-packet-data (structure)
"DMA templates for generating DMA to VU1."
((control-packet dma-packet :inline)
(vecdata-packet dma-packet :inline)
(shader-cnt-packet dma-packet :inline)
(shader-ref-packet dma-packet :inline)
(mscal-packet dma-packet :inline)
)
)
;; definition for method 3 of type sprite-glow-dma-packet-data
(defmethod inspect ((this sprite-glow-dma-packet-data))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'sprite-glow-dma-packet-data)
(format #t "~1Tcontrol-packet: #<dma-packet @ #x~X>~%" (-> this control-packet))
(format #t "~1Tvecdata-packet: #<dma-packet @ #x~X>~%" (-> this vecdata-packet))
(format #t "~1Tshader-cnt-packet: #<dma-packet @ #x~X>~%" (-> this shader-cnt-packet))
(format #t "~1Tshader-ref-packet: #<dma-packet @ #x~X>~%" (-> this shader-ref-packet))
(format #t "~1Tmscal-packet: #<dma-packet @ #x~X>~%" (-> this mscal-packet))
(label cfg-4)
this
)
;; definition of type sprite-glow-cnt-template
(deftype sprite-glow-cnt-template (structure)
"DMA layout for sending a sprite to VU1, with inline shader."
((control-packet dma-packet :inline)
(num-sprites uint32)
(dummys uint32 3)
(vecdata-packet dma-packet :inline)
(vecdata sprite-glow-data :inline)
(shader-packet dma-packet :inline)
(shader adgif-shader :inline)
(mscal-packet dma-packet :inline)
(quads vector 10 :inline :overlay-at (-> control-packet dma))
)
)
;; definition for method 3 of type sprite-glow-cnt-template
(defmethod inspect ((this sprite-glow-cnt-template))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'sprite-glow-cnt-template)
(format #t "~1Tcontrol-packet: #<dma-packet @ #x~X>~%" (-> this control-packet))
(format #t "~1Tnum-sprites: ~D~%" (-> this num-sprites))
(format #t "~1Tdummys[3] @ #x~X~%" (-> this dummys))
(format #t "~1Tvecdata-packet: #<dma-packet @ #x~X>~%" (-> this vecdata-packet))
(format #t "~1Tvecdata: #<sprite-glow-data @ #x~X>~%" (-> this vecdata))
(format #t "~1Tshader-packet: #<dma-packet @ #x~X>~%" (-> this shader-packet))
(format #t "~1Tshader: #<adgif-shader @ #x~X>~%" (-> this shader))
(format #t "~1Tmscal-packet: #<dma-packet @ #x~X>~%" (-> this mscal-packet))
(label cfg-4)
this
)
;; definition of type sprite-glow-ref-template
(deftype sprite-glow-ref-template (structure)
"DMA layout for sending a sprite to VU1, with reference to shader."
((control-packet dma-packet :inline)
(num-sprites uint32)
(dummys uint32 3)
(num-sprites-quad uint128 :overlay-at num-sprites)
(vecdata-packet dma-packet :inline)
(vecdata sprite-glow-data :inline)
(shader-packet dma-packet :inline)
(shader-packet-ptr pointer :offset 116)
(mscal-packet dma-packet :inline)
)
)
;; definition for method 3 of type sprite-glow-ref-template
(defmethod inspect ((this sprite-glow-ref-template))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'sprite-glow-ref-template)
(format #t "~1Tcontrol-packet: #<dma-packet @ #x~X>~%" (-> this control-packet))
(format #t "~1Tnum-sprites: ~D~%" (-> this num-sprites))
(format #t "~1Tdummys[3] @ #x~X~%" (-> this dummys))
(format #t "~1Tvecdata-packet: #<dma-packet @ #x~X>~%" (-> this vecdata-packet))
(format #t "~1Tvecdata: #<sprite-glow-data @ #x~X>~%" (-> this vecdata))
(format #t "~1Tshader-packet: #<dma-packet @ #x~X>~%" (-> this shader-packet))
(format #t "~1Tmscal-packet: #<dma-packet @ #x~X>~%" (-> this mscal-packet))
(label cfg-4)
this
)
;; definition for symbol *sprite-glow-dma-packet-data*, type sprite-glow-dma-packet-data
(define *sprite-glow-dma-packet-data*
(new 'static 'sprite-glow-dma-packet-data
:control-packet (new 'static 'dma-packet
:dma (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt))
:vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
:vif1 (new 'static 'vif-tag :imm #x8000 :num #x1 :cmd (vif-cmd unpack-v4-32))
)
:vecdata-packet (new 'static 'dma-packet
:dma (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))
:vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
:vif1 (new 'static 'vif-tag :imm #x8001 :num #x4 :cmd (vif-cmd unpack-v4-32))
)
:shader-cnt-packet (new 'static 'dma-packet
:dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id cnt))
:vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
:vif1 (new 'static 'vif-tag :imm #x8091 :num #x5 :cmd (vif-cmd unpack-v4-32))
)
:shader-ref-packet (new 'static 'dma-packet
:dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))
:vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
:vif1 (new 'static 'vif-tag :imm #x8091 :num #x5 :cmd (vif-cmd unpack-v4-32))
)
:mscal-packet (new 'static 'dma-packet
:dma (new 'static 'dma-tag :id (dma-tag-id cnt))
:vif1 (new 'static 'vif-tag :cmd (vif-cmd flushe) :msk #x1)
)
)
)
;; failed to figure out what this is:
(set! (-> *sprite-glow-dma-packet-data* mscal-packet vif0)
(new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #xa)
)
;; definition for function sprite-glow-add-sprite
;; INFO: Used lq/sq
;; WARN: Return type mismatch sprite-glow-cnt-template vs none.
(defun sprite-glow-add-sprite ((arg0 dma-buffer) (arg1 sprite-vec-data-2d) (arg2 float) (arg3 float) (arg4 float) (arg5 adgif-shader))
"Generate DMA to draw a single sprite from the aux-list."
(let ((v1-0 (the-as sprite-glow-cnt-template (-> arg0 base))))
(let* ((t5-0 *sprite-glow-dma-packet-data*)
(t2-0 (-> t5-0 control-packet quad))
(t3-0 (-> t5-0 vecdata-packet quad))
(t4-0 (-> t5-0 shader-cnt-packet quad))
(t5-1 (-> t5-0 mscal-packet quad))
)
(set! (-> v1-0 control-packet quad) t2-0)
(set! (-> v1-0 quads 1 quad) (the-as uint128 0))
(set! (-> v1-0 vecdata-packet quad) t3-0)
(set! (-> v1-0 shader-packet quad) t4-0)
(set! (-> v1-0 mscal-packet quad) t5-1)
)
(let ((t2-1 (-> arg1 x-y-z-sx quad))
(t3-1 (-> arg1 flag-rot-sy quad))
(a1-1 (-> arg1 r-g-b-a quad))
)
(set! (-> v1-0 vecdata position quad) t2-1)
(set! (-> v1-0 vecdata quads 1 quad) t3-1)
(set! (-> v1-0 vecdata color quad) a1-1)
)
(let ((a1-2 1))
(set! (-> v1-0 vecdata z-offset) arg4)
(set! (-> v1-0 vecdata fade-a) arg2)
(set! (-> v1-0 vecdata fade-b) arg3)
(set! (-> v1-0 num-sprites) (the-as uint a1-2))
)
(let ((a1-3 (-> arg5 quad 0 quad))
(a2-1 (-> arg5 quad 1 quad))
(a3-1 (-> arg5 quad 2 quad))
(t0-1 (-> arg5 quad 3 quad))
(t1-1 (-> arg5 quad 4 quad))
)
(set! (-> v1-0 quads 8 quad) a1-3)
(set! (-> v1-0 quads 9 quad) a2-1)
(set! (-> v1-0 shader quad 2 quad) a3-1)
(set! (-> v1-0 shader quad 3 quad) t0-1)
(set! (-> v1-0 shader quad 4 quad) t1-1)
)
(set! (-> arg0 base) (the-as pointer (&+ v1-0 224)))
)
(none)
)
;; definition for function sprite-glow-add-simple-sprite
;; INFO: Used lq/sq
;; WARN: Return type mismatch sprite-glow-ref-template vs none.
(defun sprite-glow-add-simple-sprite ((arg0 dma-buffer) (arg1 sprite-glow-dma-packet-data) (arg2 sprite-glow-data) (arg3 pointer))
"Generate DMA to draw a single sprite from the simple sprite system."
(let ((v1-0 (the-as sprite-glow-ref-template (-> arg0 base))))
(let ((t0-0 (-> arg1 control-packet quad))
(t1-0 (-> arg1 vecdata-packet quad))
(t2-0 (-> arg1 shader-ref-packet quad))
(a1-1 (-> arg1 mscal-packet quad))
)
(set! (-> v1-0 control-packet quad) t0-0)
(set! (-> v1-0 num-sprites-quad) (the-as uint128 0))
(set! (-> v1-0 vecdata-packet quad) t1-0)
(set! (-> v1-0 shader-packet quad) t2-0)
(set! (-> v1-0 mscal-packet quad) a1-1)
)
(let ((a1-2 (-> arg2 position quad))
(t0-1 (-> arg2 quads 1 quad))
(t1-1 (-> arg2 color quad))
(a2-1 (-> arg2 quads 3 quad))
(t2-1 1)
)
(set! (-> v1-0 vecdata position quad) a1-2)
(set! (-> v1-0 vecdata quads 1 quad) t0-1)
(set! (-> v1-0 vecdata color quad) t1-1)
(set! (-> v1-0 vecdata quads 3 quad) a2-1)
(set! (-> v1-0 num-sprites) (the-as uint t2-1))
)
(set! (-> v1-0 shader-packet-ptr) arg3)
(set! (-> arg0 base) (the-as pointer (&+ v1-0 144)))
)
(none)
)
;; definition for function sprite-glow-draw
;; WARN: Return type mismatch int vs none.
(defun sprite-glow-draw ((arg0 dma-buffer))
"Generate DMA for all glow sprites in the aux-list (from sparticle system)"
(local-vars (a2-0 float))
(let* ((s5-0 *sprite-aux-list*)
(s4-0 (-> s5-0 entry))
(s3-0 #f)
)
(dotimes (s2-0 s4-0)
(let ((v1-2 (-> s5-0 data s2-0)))
(when (and (not s3-0) (= (-> v1-2 aux-type) (sprite-aux-type glow)))
(let* ((a0-5 (-> v1-2 aux-data omega))
(a3-0 (cond
((zero? a0-5)
(set! a2-0 0.0)
1.0
)
(else
(let* ((f1-1 (* 0.00024414062 a0-5))
(f0-4 (- f1-1 (the float (the int f1-1))))
)
(let ((f1-3 (* 4096.0 (- f1-1 f0-4))))
(set! a2-0 (/ -1.0 (* (- 1.0 f0-4) f1-3)))
)
(/ f0-4 (- 1.0 f0-4))
)
)
)
)
)
(sprite-glow-add-sprite arg0 (-> v1-2 vec-data) a2-0 a3-0 (-> v1-2 aux-data user-float) (-> v1-2 gif-data))
)
)
)
)
)
0
(none)
)
;; definition for method 9 of type simple-sprite-system
;; INFO: Used lq/sq
;; WARN: Return type mismatch int vs none.
(defmethod add! ((this simple-sprite-system) (arg0 sprite-glow-data))
"Add a sprite to the list, to be drawn later."
(let ((v1-0 (-> this count)))
(when (< v1-0 (-> this max-count))
(let* ((a2-3 (-> this data v1-0))
(v1-2 arg0)
(a1-1 a2-3)
(a2-4 (-> v1-2 position quad))
(a3-0 (-> v1-2 quads 1 quad))
(t0-0 (-> v1-2 color quad))
(v1-3 (-> v1-2 quads 3 quad))
)
(set! (-> a1-1 position quad) a2-4)
(set! (-> a1-1 quads 1 quad) a3-0)
(set! (-> a1-1 color quad) t0-0)
(set! (-> a1-1 quads 3 quad) v1-3)
)
(+! (-> this count) 1)
)
)
0
(none)
)
;; definition for function add-shader-to-dma
;; INFO: Used lq/sq
;; WARN: Return type mismatch pointer vs adgif-shader.
(defun add-shader-to-dma ((arg0 dma-buffer))
(let* ((a1-0 (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id next))))
(v1-0 (-> arg0 base))
(a1-1 (-> a1-0 quad))
(v0-0 (&+ v1-0 16))
)
(let ((a2-0 (&+ v1-0 96)))
(set! (-> (the-as (pointer uint128) v1-0)) a1-1)
(set! (-> (the-as (pointer uint32) v1-0) 1) (the-as uint a2-0))
(set! (-> arg0 base) a2-0)
)
(the-as adgif-shader v0-0)
)
)
;; definition for method 10 of type simple-sprite-system
;; WARN: Return type mismatch int vs none.
(defmethod draw-all-sprites! ((this simple-sprite-system) (arg0 dma-buffer))
"Submit all sprites to the sprite-glow renderer"
(local-vars (sv-528 sprite-glow-dma-packet-data) (sv-532 (pointer texture-id)) (sv-536 pointer))
(b! (zero? (-> this count)) cfg-13 :delay (nop!))
(set! sv-528 *sprite-glow-dma-packet-data*)
(set! sv-532 (new 'stack-no-clear 'array 'texture-id 128))
(set! sv-536 (-> arg0 base))
(dotimes (v1-5 (-> this count))
(set! (-> sv-532 v1-5) (-> this data v1-5 tex-id))
)
(countdown (s4-0 (-> this count))
(let ((s3-0 (-> sv-532 s4-0)))
(when (nonzero? s3-0)
(let ((s2-0 (add-shader-to-dma arg0)))
(adgif-shader<-texture-simple! s2-0 (lookup-texture-by-id s3-0))
(countdown (s1-1 (+ s4-0 1))
(when (= s3-0 (-> sv-532 s1-1))
(set! (-> sv-532 s1-1) (new 'static 'texture-id))
(let ((a2-1 (-> this data s1-1)))
(sprite-glow-add-simple-sprite arg0 sv-528 a2-1 (the-as pointer s2-0))
)
)
)
)
)
)
)
(label cfg-13)
0
(none)
)
;; definition for method 11 of type simple-sprite-system
;; WARN: Return type mismatch int vs none.
(defmethod clear! ((this simple-sprite-system))
"Reset the list."
(set! (-> this count) 0)
0
(none)
)
;; definition for symbol *simple-sprite-system*, type simple-sprite-system
(define *simple-sprite-system*
(new 'static 'simple-sprite-system :max-count #x80 :data (new 'static 'inline-array sprite-glow-data 128
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
(new 'static 'sprite-glow-data)
)
)
)

View File

@ -82,7 +82,9 @@
// find-nearest
"find-nearest-focusable",
"(method 3 sprite-aux-list)" // appears twice.
"(method 3 sprite-aux-list)", // appears twice.
"sprite-draw-distorters", // asm
"bugfix?"
],