From 5aa15afe29fadc89b9fb8ba1e1fca6e6ca72b015 Mon Sep 17 00:00:00 2001 From: water Date: Fri, 13 Aug 2021 18:50:29 -0400 Subject: [PATCH 1/7] decompile sprite-distort without vu1 stuff --- .../jak1_ntsc_black_label/type_casts.jsonc | 9 +- .../jak1_ntsc_black_label/var_names.jsonc | 136 +++--- goal_src/engine/gfx/sprite/sprite-distort.gc | 423 ++++++++++++++++++ goalc/debugger/Debugger.cpp | 4 +- test/offline/offline_test_main.cpp | 3 + 5 files changed, 503 insertions(+), 72 deletions(-) diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index 740bdf899f..3ae38772df 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -1652,7 +1652,14 @@ [119, "a0", "(pointer int32)"], [124, "v1", "vector"], [154, "v1", "vector"], - [[172, 189], "a1", "dma-packet"] + [[172, 189], "a1", "dma-packet"], + [[199, 203], "a0", "dma-packet"], + [[207, 211], "a0", "vector4w"], + [[216, 221], "a0", "dma-packet"], + [[248, 265], "a1", "dma-packet"], + [[273, 277], "a1", "dma-packet"], + [[281, 285], "a1", "vector4w"], + [[289, 294], "v1", "dma-packet"] ], "debug-menu-make-from-template": [ diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index 783ee66d8d..404574b828 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -1386,9 +1386,9 @@ "display-loop": { "vars": { - "s3-0":"debug-buf", - "gp-0":"disp", - "s5-2":"debug-txt-buf" + "s3-0": "debug-buf", + "gp-0": "disp", + "s5-2": "debug-txt-buf" } }, @@ -3035,101 +3035,97 @@ }, "(method 15 trajectory)": { - "vars":{ - "s5-0":"prev-pos", - "s4-0":"pos", - "s3-0":"num-segments", - "f0-1":"t-eval" + "vars": { + "s5-0": "prev-pos", + "s4-0": "pos", + "s3-0": "num-segments", + "f0-1": "t-eval" } - }, + }, "set-font-color-alpha": { - "args":["idx", "alpha"] + "args": ["idx", "alpha"] }, "print-game-text-scaled": { - "args":["str", "scale", "font-ctxt", "alpha"] + "args": ["str", "scale", "font-ctxt", "alpha"] }, "print-game-text": { - "args":["str", "font-ctxt", "alpha", "offset-thing"] + "args": ["str", "font-ctxt", "alpha", "offset-thing"] }, "display-frame-start": { - "args":["disp", "new-frame-idx", "odd-even"], + "args": ["disp", "new-frame-idx", "odd-even"], "vars": { - "f30-0":"time-ratio", - "s3-0":"scaled-seconds", - "s3-1":"new-frame" + "f30-0": "time-ratio", + "s3-0": "scaled-seconds", + "s3-1": "new-frame" } }, "display-frame-finish": { - "args":["disp"], + "args": ["disp"], "vars": { - "s4-0":"this-frame", - "s5-0":"this-calc-buf", - "s3-0":"bucket-idx", - "v1-7":"this-global-buf", - "a0-16":"global-buf", - "v1-19":"calc-current", - "a2-1":"calc-start", - "s4-1":"global-current", - "s5-1":"global-start", - "s3-1":"global-end" + "s4-0": "this-frame", + "s5-0": "this-calc-buf", + "s3-0": "bucket-idx", + "v1-7": "this-global-buf", + "a0-16": "global-buf", + "v1-19": "calc-current", + "a2-1": "calc-start", + "s4-1": "global-current", + "s5-1": "global-start", + "s3-1": "global-end" } }, "display-sync": { - "args":["disp"], + "args": ["disp"], "vars": { - "s4-0":"frame-idx", - "s5-0":"syncv-result", - "s3-0":"dma-buf-to-send", - "a1-4":"next-frame" + "s4-0": "frame-idx", + "s5-0": "syncv-result", + "s3-0": "dma-buf-to-send", + "a1-4": "next-frame" } }, "draw-string": { - "args":["str-in", "context"], - "vars": { - "v1-5":"fw", - "a1-1":"dma-out", - "t2-0":"flags", - "a3-0":"has-flag-size24", - "a3-1":"font-table-12", - "a3-2":"font-table-to-use", - "t0-0":"q-lo-tmpl", - "t1-0":"q-hi-tmpl", - "t3-0":"in-color", - "t3-1":"color-array-prod", - "t4-0":"fw+col", - "t3-2":"q-verts-0p", - "t5-0":"q-verts-1p", - "t3-3":"q-verts-2p", - "t4-1":"q-verts-3p", - "t5-1":"q-verts-1t", - "t5-2":"q-verts-1", - "t3-4":"q-verts-2t", - "t3-5":"q-verts-2", - "t6-0":"q-verts-0t", - "t6-1":"q-verts-0", - "t4-2":"q-verts-3t", - "t4-3":"q-verts-3", - "t3-6":"fw2", - "t4-4":"str-char", - "t5-3":"not-sc-lit1", - "t5-4":"not-sc-~", - "t4-14":"fc-cr", - "r0-0":"r0", - "r0-1":"r0", - "r0-2":"r0", - "r0-3":"r0" - - - + "args": ["str-in", "context"], + "vars": { + "v1-5": "fw", + "a1-1": "dma-out", + "t2-0": "flags", + "a3-0": "has-flag-size24", + "a3-1": "font-table-12", + "a3-2": "font-table-to-use", + "t0-0": "q-lo-tmpl", + "t1-0": "q-hi-tmpl", + "t3-0": "in-color", + "t3-1": "color-array-prod", + "t4-0": "fw+col", + "t3-2": "q-verts-0p", + "t5-0": "q-verts-1p", + "t3-3": "q-verts-2p", + "t4-1": "q-verts-3p", + "t5-1": "q-verts-1t", + "t5-2": "q-verts-1", + "t3-4": "q-verts-2t", + "t3-5": "q-verts-2", + "t6-0": "q-verts-0t", + "t6-1": "q-verts-0", + "t4-2": "q-verts-3t", + "t4-3": "q-verts-3", + "t3-6": "fw2", + "t4-4": "str-char", + "t5-3": "not-sc-lit1", + "t5-4": "not-sc-~", + "t4-14": "fc-cr", + "r0-0": "r0", + "r0-1": "r0", + "r0-2": "r0", + "r0-3": "r0" } }, - "aaaaaaaaaaaaaaaaaaaaaaa": {} } diff --git a/goal_src/engine/gfx/sprite/sprite-distort.gc b/goal_src/engine/gfx/sprite/sprite-distort.gc index 0817fc2126..23fd68dce4 100644 --- a/goal_src/engine/gfx/sprite/sprite-distort.gc +++ b/goal_src/engine/gfx/sprite/sprite-distort.gc @@ -5,3 +5,426 @@ ;; name in dgo: sprite-distort ;; dgos: GAME, ENGINE +;; The sprite-distort is a VU1 renderer. +;; It likely does some of the effects with sprites. + +;; Scratch information used by the sprite-distorter. +(deftype sprite-distorter-sine-tables (basic) + ((aspx float :offset-assert 4) + (aspy float :offset-assert 8) + (entry vector 128 :inline :offset-assert 16) + (ientry qword 9 :inline :offset-assert 2064) + (giftag gs-gif-tag :inline :offset-assert 2208) + (color qword :inline :offset-assert 2224) + ) + :method-count-assert 9 + :size-assert #x8c0 + :flag-assert #x9000008c0 + ) + +(define *sprite-distorter-sine-tables* (new 'global 'sprite-distorter-sine-tables)) + +(defun sprite-distorter-generate-tables () + "Regenerate sprite-distorter tables. This should be done whenever the aspect ratio changes" + (let ((gp-0 *sprite-distorter-sine-tables*)) + (let ((s3-0 0) + (s5-0 0) + (s4-0 3) + (f28-0 (- (-> *math-camera* perspective vector 0 x))) + (f30-0 (- (-> *math-camera* perspective vector 1 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.00390625 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-17 (+ s3-0 1))) + (set-vector! (-> gp-0 entry v1-17) 0.0 (* 0.00390625 f30-0) 0.0 0.0) + (+ v1-17 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) + ) + + +;; TODO +(define sprite-distort-vu1-block (the-as vu-function 0)) + + +(defun sprite-init-distorter ((arg0 dma-buffer) (arg1 uint)) + "Set up DMA for setting up the sprite-distorter renderer" + (let* ((v1-0 arg0) + (a2-0 (the-as object (-> v1-0 base))) + ) + (set! (-> (the-as dma-packet a2-0) dma) (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a2-0) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a2-0) vif1) (new 'static 'vif-tag :imm #x7 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-0 base) (&+ (the-as pointer a2-0) 16)) + ) + (let* ((v1-1 arg0) + (a2-2 (the-as object (-> v1-1 base))) + ) + (set! (-> (the-as gs-gif-tag a2-2) tag) + (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x6) + ) + (set! (-> (the-as gs-gif-tag a2-2) regs) + (new 'static 'gif-tag-regs + :regs0 (gif-reg-id a+d) + :regs1 (gif-reg-id a+d) + :regs2 (gif-reg-id a+d) + :regs3 (gif-reg-id a+d) + :regs4 (gif-reg-id a+d) + :regs5 (gif-reg-id a+d) + :regs6 (gif-reg-id a+d) + :regs7 (gif-reg-id a+d) + :regs8 (gif-reg-id a+d) + :regs9 (gif-reg-id a+d) + :regs10 (gif-reg-id a+d) + :regs11 (gif-reg-id a+d) + :regs12 (gif-reg-id a+d) + :regs13 (gif-reg-id a+d) + :regs14 (gif-reg-id a+d) + :regs15 (gif-reg-id a+d) + ) + ) + (set! (-> v1-1 base) (&+ (the-as pointer a2-2) 16)) + ) + (let* ((v1-2 arg0) + (a2-4 (-> v1-2 base)) + ) + (set! (-> (the-as (pointer gs-zbuf) a2-4) 0) + (new 'static 'gs-zbuf :zbp #x1c0 :psm (gs-psm ct24) :zmsk #x1) + ) + (set! (-> (the-as (pointer gs-reg64) a2-4) 1) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-tex0) a2-4) 2) + (new 'static 'gs-tex0 :tbw #x8 :tw #x9 :th #x8 :tbp0 (* arg1 32)) + ) + (set! (-> (the-as (pointer gs-reg64) a2-4) 3) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer gs-tex1) a2-4) 4) + (new 'static 'gs-tex1 :mmag #x1 :mmin #x1) + ) + (set! (-> (the-as (pointer gs-reg64) a2-4) 5) (gs-reg64 tex1-1)) + (set! (-> (the-as (pointer gs-miptbp) a2-4) 6) (new 'static 'gs-miptbp)) + (set! (-> (the-as (pointer gs-reg64) a2-4) 7) (gs-reg64 miptbp1-1)) + (set! (-> (the-as (pointer gs-clamp) a2-4) 8) + (new 'static 'gs-clamp + :wms (gs-tex-wrap-mode region-clamp) + :wmt (gs-tex-wrap-mode region-clamp) + :maxu #x1ff + :maxv (-> *video-parms* screen-masky) + ) + ) + (set! (-> (the-as (pointer gs-reg64) a2-4) 9) (gs-reg64 clamp-1)) + (set! (-> (the-as (pointer gs-alpha) a2-4) 10) + (new 'static 'gs-alpha :b #x1 :d #x1) + ) + (set! (-> (the-as (pointer gs-reg64) a2-4) 11) (gs-reg64 alpha-1)) + (set! (-> v1-2 base) (&+ a2-4 96)) + ) + (let* ((v1-3 arg0) + (a1-15 (the-as object (-> v1-3 base))) + ) + (set! (-> (the-as dma-packet a1-15) dma) + (new 'static 'dma-tag + :qwc #x8b + :id (dma-tag-id ref) + :addr (the-as uint (-> *sprite-distorter-sine-tables* entry)) + ) + ) + (set! (-> (the-as dma-packet a1-15) vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))) + (set! (-> (the-as dma-packet a1-15) vif1) (new 'static 'vif-tag :imm #x160 :num #x8b :cmd (vif-cmd unpack-v4-32))) + (set! (-> v1-3 base) (&+ (the-as pointer a1-15) 16)) + ) + (dma-buffer-add-vu-function arg0 sprite-distort-vu1-block 1) + 0 + (none) + ) + +(defun sprite-draw-distorters ((arg0 dma-buffer)) + "Set up DMA for the sprite-distorter renderer" + (local-vars + (v1-25 int) + (sv-16 sprite-vec-data-2d) + (sv-32 pointer) + (sv-48 pointer) + ) + (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) + (set! sv-16 (-> s3-0 data s1-0)) + (let ((a0-1 (the-as object (-> arg0 base)))) + (set! sv-32 (&+ (the-as pointer a0-1) 16)) + (set! sv-48 (&+ (the-as pointer a0-1) 32)) + (cond + ((= (-> sv-16 matrix) 1) + (.lvf vf3 (&-> *math-camera* sprite-2d vector 0 quad)) + (.lvf vf4 (&-> *math-camera* sprite-2d vector 1 quad)) + (.lvf vf5 (&-> *math-camera* sprite-2d vector 2 quad)) + (.lvf vf6 (&-> *math-camera* sprite-2d vector 3 quad)) + (.lvf vf9 (&-> *math-camera* sprite-2d-hvdf quad)) + ) + (else + (.lvf vf3 (&-> *math-camera* camera-temp vector 0 quad)) + (.lvf vf4 (&-> *math-camera* camera-temp vector 1 quad)) + (.lvf vf5 (&-> *math-camera* camera-temp vector 2 quad)) + (.lvf vf6 (&-> *math-camera* camera-temp vector 3 quad)) + (.lvf vf9 (&-> *math-camera* hvdf-off quad)) + ) + ) + (.lvf vf1 (&-> sv-16 x-y-z-sx quad)) + (.lvf vf2 (&-> sv-16 color 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)) cfg-21) + (.wait.vf) + (.mul.vf vf1 vf1 Q :mask #b111) + (.mul.vf vf2 vf2 Q :mask #b111) + ;;(.cfc2.i v1-25 Clipping) + (set! v1-25 (vu-clip vf10 0)) ;; safe to just drop the higher bits. + (b! (logtest? v1-25 63) cfg-21 :delay (.add.vf vf1 vf1 vf9)) + (.max.x.vf vf1 vf1 vf0 :mask #b1000) + (.svf (&-> (the-as vector a0-1) quad) vf1) + (.svf (&-> (the-as vector sv-48) quad) vf2) + (set! (-> (the-as vector a0-1) w) 255.0) + (set! (-> (the-as (pointer float) sv-32)) (* 0.001953125 (+ -1792.0 (-> (the-as vector a0-1) x)))) + (set! (-> (the-as vector sv-32) y) + (* 0.00390625 + (+ (+ -2048.0 (the float (-> *video-parms* screen-hy))) + (-> (the-as vector a0-1) y) + ) + ) + ) + ) + (set! (-> (the-as vector sv-32) z) 1.0) + (when (or (< (-> sv-16 flag) 3) (< 11 (-> sv-16 flag))) + (format 0 "Turns = ~D!!!~%" (-> sv-16 flag)) + (set! (-> (the-as (pointer int32) sv-16) 4) 11) + ) + (set! (-> (the-as (pointer int32) sv-32) 3) (-> sv-16 flag)) + (let* ((f0-7 (- (-> *math-camera* perspective vector 1 y))) + (f2-4 (-> (the-as vector sv-32) y)) + (f4-0 (+ f2-4 (* (-> (the-as (pointer float) sv-48)) f0-7))) + (f3-0 256.0) + (f1-7 (-> (the-as (pointer float) sv-48))) + ) + (if (< (the float (-> *video-parms* screen-sy)) f4-0) + (set! f3-0 (/ (- (the float (-> *video-parms* screen-sy)) f2-4) f0-7)) + ) + (if (< 128.0 f3-0) + (set! f3-0 128.0) + ) + (when (< f3-0 f1-7) + (let ((v1-55 (/ f3-0 f1-7))) + (.mov vf1 v1-55) + ) + (.mul.x.vf vf2 vf2 vf1) + (.svf (&-> (the-as vector sv-48) quad) vf2) + ) + ) + (&+! (-> arg0 base) 48) + (+! s4-0 1) + (when (= s4-0 85) + (let ((v1-62 (-> arg0 base))) + (set! (-> arg0 base) s0-0) + (let* ((a0-8 arg0) + (a1-3 (the-as object (-> a0-8 base))) + ) + (set! + (-> (the-as dma-packet a1-3) dma) + (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc (* 3 s4-0)) + ) + (set! (-> (the-as dma-packet a1-3) vif0) (new 'static 'vif-tag)) + (set! + (-> (the-as dma-packet 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-8 base) (&+ (the-as pointer a1-3) 16)) + ) + (set! (-> arg0 base) v1-62) + ) + (set! s4-0 0) + (+! s5-0 85) + (when (= s5-0 170) + (let* ((v1-65 arg0) + (a0-9 (the-as object (-> v1-65 base))) + ) + (set! (-> (the-as dma-packet a0-9) dma) (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-9) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a0-9) vif1) (new 'static 'vif-tag :imm #x1ff :num #x1 :cmd (vif-cmd unpack-v4-32))) + (set! (-> v1-65 base) (&+ (the-as pointer a0-9) 16)) + ) + (let* ((v1-66 arg0) + (a0-11 (the-as object (-> v1-66 base))) + ) + (set! (-> (the-as vector4w a0-11) x) s5-0) + (set! (-> (the-as vector4w a0-11) y) 0) + (set! (-> (the-as vector4w a0-11) z) 0) + (set! (-> (the-as vector4w a0-11) w) 0) + (set! (-> v1-66 base) (&+ (the-as pointer a0-11) 16)) + ) + (let* ((v1-67 arg0) + (a0-13 (the-as object (-> v1-67 base))) + ) + (set! (-> (the-as dma-packet a0-13) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-13) vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1)) + (set! (-> (the-as dma-packet a0-13) vif1) (new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1)) + (set! (-> v1-67 base) (&+ (the-as pointer a0-13) 16)) + ) + (set! s5-0 0) + ) + (set! s0-0 (-> arg0 base)) + (&+! (-> arg0 base) 16) + ) + (label cfg-21) + ) + ) + (cond + ((zero? s4-0) + (set! (-> arg0 base) s0-0) + (nop!) + 0 + ) + (else + (let ((v1-74 (-> arg0 base))) + (set! (-> arg0 base) s0-0) + (let* ((a0-15 arg0) + (a1-10 (the-as object (-> a0-15 base))) + ) + (set! (-> (the-as dma-packet a1-10) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc (* 3 s4-0))) + (set! (-> (the-as dma-packet a1-10) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet 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-15 base) (&+ (the-as pointer a1-10) 16)) + ) + (set! (-> arg0 base) v1-74) + ) + ) + ) + (let ((v1-75 (+ s4-0 s5-0))) + (when (nonzero? v1-75) + (let* ((a0-17 arg0) + (a1-12 (the-as object (-> a0-17 base))) + ) + (set! (-> (the-as dma-packet a1-12) dma) (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a1-12) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a1-12) vif1) (new 'static 'vif-tag :imm #x1ff :num #x1 :cmd (vif-cmd unpack-v4-32))) + (set! (-> a0-17 base) (&+ (the-as pointer a1-12) 16)) + ) + (let* ((a0-18 arg0) + (a1-14 (the-as object (-> a0-18 base))) + ) + (set! (-> (the-as vector4w a1-14) x) v1-75) + (set! (-> (the-as vector4w a1-14) y) 0) + (set! (-> (the-as vector4w a1-14) z) 0) + (set! (-> (the-as vector4w a1-14) w) 0) + (set! (-> a0-18 base) (&+ (the-as pointer a1-14) 16)) + ) + (let ((v1-77 (the-as object (-> arg0 base)))) + (set! (-> (the-as dma-packet v1-77) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet v1-77) vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1)) + (set! (-> (the-as dma-packet v1-77) vif1) (new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1)) + (set! (-> arg0 base) (&+ (the-as pointer v1-77) 16)) + ) + ) + ) + ) + 0 + (none) + ) + ) + diff --git a/goalc/debugger/Debugger.cpp b/goalc/debugger/Debugger.cpp index 91d6e7a7ac..27d5fbfa70 100644 --- a/goalc/debugger/Debugger.cpp +++ b/goalc/debugger/Debugger.cpp @@ -107,7 +107,9 @@ bool Debugger::attach_and_break() { m_continue_info.subtract_1 = false; // this may fail if you crash at exactly the wrong time. todo - remove? - assert(info.kind == xdbg::SignalInfo::BREAK); + if (info.kind != xdbg::SignalInfo::BREAK) { + fmt::print("[Debugger] got signal {} when expecting break.\n", (int)info.kind); + } // open the memory of the process if (!xdbg::open_memory(m_debug_context.tid, &m_memory_handle)) { diff --git a/test/offline/offline_test_main.cpp b/test/offline/offline_test_main.cpp index e566af7ce8..6bad97c57c 100644 --- a/test/offline/offline_test_main.cpp +++ b/test/offline/offline_test_main.cpp @@ -143,6 +143,9 @@ const std::unordered_set g_functions_to_skip_compiling = { // stats-h "(method 11 perf-stat)", "(method 12 perf-stat)", + // sprite-distorter + "sprite-draw-distorters", // uses clipping flag. + // sync-info "(method 15 sync-info)", // needs display stuff first "(method 15 sync-info-eased)", // needs display stuff first From 635b10944786d51b70473d44d9ed82c2c4a717e4 Mon Sep 17 00:00:00 2001 From: water Date: Fri, 13 Aug 2021 18:54:21 -0400 Subject: [PATCH 2/7] add ref file --- .../engine/gfx/sprite/sprite-distort_REF.gc | 516 ++++++++++++++++++ 1 file changed, 516 insertions(+) create mode 100644 test/decompiler/reference/engine/gfx/sprite/sprite-distort_REF.gc diff --git a/test/decompiler/reference/engine/gfx/sprite/sprite-distort_REF.gc b/test/decompiler/reference/engine/gfx/sprite/sprite-distort_REF.gc new file mode 100644 index 0000000000..de12a512f3 --- /dev/null +++ b/test/decompiler/reference/engine/gfx/sprite/sprite-distort_REF.gc @@ -0,0 +1,516 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type sprite-distorter-sine-tables +(deftype sprite-distorter-sine-tables (basic) + ((aspx float :offset-assert 4) + (aspy float :offset-assert 8) + (entry vector 128 :inline :offset-assert 16) + (ientry qword 9 :inline :offset-assert 2064) + (giftag gs-gif-tag :inline :offset-assert 2208) + (color qword :inline :offset-assert 2224) + ) + :method-count-assert 9 + :size-assert #x8c0 + :flag-assert #x9000008c0 + ) + +;; definition for method 3 of type sprite-distorter-sine-tables +(defmethod + inspect + sprite-distorter-sine-tables + ((obj sprite-distorter-sine-tables)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Taspx: ~f~%" (-> obj aspx)) + (format #t "~Taspy: ~f~%" (-> obj aspy)) + (format #t "~Tentry[128] @ #x~X~%" (-> obj entry)) + (format #t "~Tientry[9] @ #x~X~%" (-> obj ientry)) + (format #t "~Tgiftag: #~%" (-> obj giftag)) + (format #t "~Tcolor: #~%" (-> obj color)) + obj + ) + +;; definition for symbol *sprite-distorter-sine-tables*, type sprite-distorter-sine-tables +(define + *sprite-distorter-sine-tables* + (new 'global 'sprite-distorter-sine-tables) + ) + +;; definition for function sprite-distorter-generate-tables +;; INFO: Return type mismatch int vs none. +(defun sprite-distorter-generate-tables () + (let ((gp-0 *sprite-distorter-sine-tables*)) + (let ((s3-0 0) + (s5-0 0) + (s4-0 3) + (f28-0 (- (-> *math-camera* perspective vector 0 x))) + (f30-0 (- (-> *math-camera* perspective vector 1 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.00390625 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-17 (+ s3-0 1))) + (set-vector! (-> gp-0 entry v1-17) 0.0 (* 0.00390625 f30-0) 0.0 0.0) + (+ v1-17 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 (the-as vu-function 0)) + +;; definition for function sprite-init-distorter +;; INFO: Return type mismatch int vs none. +(defun sprite-init-distorter ((arg0 dma-buffer) (arg1 uint)) + (let* ((v1-0 arg0) + (a2-0 (the-as object (-> v1-0 base))) + ) + (set! + (-> (the-as dma-packet a2-0) dma) + (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)) + ) + (set! (-> (the-as dma-packet a2-0) vif0) (new 'static 'vif-tag)) + (set! + (-> (the-as dma-packet a2-0) vif1) + (new 'static 'vif-tag :imm #x7 :cmd (vif-cmd direct) :msk #x1) + ) + (set! (-> v1-0 base) (&+ (the-as pointer a2-0) 16)) + ) + (let* ((v1-1 arg0) + (a2-2 (the-as object (-> v1-1 base))) + ) + (set! + (-> (the-as gs-gif-tag a2-2) tag) + (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x6) + ) + (set! + (-> (the-as gs-gif-tag a2-2) regs) + (new 'static 'gif-tag-regs + :regs0 (gif-reg-id a+d) + :regs1 (gif-reg-id a+d) + :regs2 (gif-reg-id a+d) + :regs3 (gif-reg-id a+d) + :regs4 (gif-reg-id a+d) + :regs5 (gif-reg-id a+d) + :regs6 (gif-reg-id a+d) + :regs7 (gif-reg-id a+d) + :regs8 (gif-reg-id a+d) + :regs9 (gif-reg-id a+d) + :regs10 (gif-reg-id a+d) + :regs11 (gif-reg-id a+d) + :regs12 (gif-reg-id a+d) + :regs13 (gif-reg-id a+d) + :regs14 (gif-reg-id a+d) + :regs15 (gif-reg-id a+d) + ) + ) + (set! (-> v1-1 base) (&+ (the-as pointer a2-2) 16)) + ) + (let* ((v1-2 arg0) + (a2-4 (-> v1-2 base)) + ) + (set! + (-> (the-as (pointer gs-zbuf) a2-4) 0) + (new 'static 'gs-zbuf :zbp #x1c0 :psm (gs-psm ct24) :zmsk #x1) + ) + (set! (-> (the-as (pointer gs-reg64) a2-4) 1) (gs-reg64 zbuf-1)) + (set! + (-> (the-as (pointer gs-tex0) a2-4) 2) + (new 'static 'gs-tex0 :tbw #x8 :tw #x9 :th #x8 :tbp0 (* arg1 32)) + ) + (set! (-> (the-as (pointer gs-reg64) a2-4) 3) (gs-reg64 tex0-1)) + (set! + (-> (the-as (pointer gs-tex1) a2-4) 4) + (new 'static 'gs-tex1 :mmag #x1 :mmin #x1) + ) + (set! (-> (the-as (pointer gs-reg64) a2-4) 5) (gs-reg64 tex1-1)) + (set! (-> (the-as (pointer gs-miptbp) a2-4) 6) (new 'static 'gs-miptbp)) + (set! (-> (the-as (pointer gs-reg64) a2-4) 7) (gs-reg64 miptbp1-1)) + (set! + (-> (the-as (pointer gs-clamp) a2-4) 8) + (new 'static 'gs-clamp + :wms (gs-tex-wrap-mode region-clamp) + :wmt (gs-tex-wrap-mode region-clamp) + :maxu #x1ff + :maxv (-> *video-parms* screen-masky) + ) + ) + (set! (-> (the-as (pointer gs-reg64) a2-4) 9) (gs-reg64 clamp-1)) + (set! + (-> (the-as (pointer gs-alpha) a2-4) 10) + (new 'static 'gs-alpha :b #x1 :d #x1) + ) + (set! (-> (the-as (pointer gs-reg64) a2-4) 11) (gs-reg64 alpha-1)) + (set! (-> v1-2 base) (&+ a2-4 96)) + ) + (let* ((v1-3 arg0) + (a1-15 (the-as object (-> v1-3 base))) + ) + (set! + (-> (the-as dma-packet a1-15) dma) + (new 'static 'dma-tag + :qwc #x8b + :id (dma-tag-id ref) + :addr (the-as uint (-> *sprite-distorter-sine-tables* entry)) + ) + ) + (set! + (-> (the-as dma-packet a1-15) vif0) + (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)) + ) + (set! + (-> (the-as dma-packet a1-15) vif1) + (new 'static 'vif-tag :imm #x160 :num #x8b :cmd (vif-cmd unpack-v4-32)) + ) + (set! (-> v1-3 base) (&+ (the-as pointer a1-15) 16)) + ) + (dma-buffer-add-vu-function arg0 sprite-distort-vu1-block 1) + 0 + (none) + ) + +;; definition for function sprite-draw-distorters +;; INFO: Return type mismatch int vs none. +;; WARN: Inline assembly instruction marked with TODO - [TODO.VCLIP] +;; WARN: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping] +;; Used lq/sq +(defun sprite-draw-distorters ((arg0 dma-buffer)) + (local-vars + (v1-14 float) + (v1-20 float) + (v1-25 int) + (v1-57 float) + (sv-16 sprite-vec-data-2d) + (sv-32 pointer) + (sv-48 pointer) + ) + (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) + (set! sv-16 (-> s3-0 data s1-0)) + (let ((a0-1 (the-as object (-> arg0 base)))) + (set! sv-32 (&+ (the-as pointer a0-1) 16)) + (set! sv-48 (&+ (the-as pointer a0-1) 32)) + (cond + ((= (-> sv-16 matrix) 1) + (.lvf vf3 (&-> *math-camera* sprite-2d vector 0 quad)) + (.lvf vf4 (&-> *math-camera* sprite-2d vector 1 quad)) + (.lvf vf5 (&-> *math-camera* sprite-2d vector 2 quad)) + (.lvf vf6 (&-> *math-camera* sprite-2d vector 3 quad)) + (.lvf vf9 (&-> *math-camera* sprite-2d-hvdf quad)) + (.mov v1-14 vf9) + ) + (else + (.lvf vf3 (&-> *math-camera* camera-temp vector 0 quad)) + (.lvf vf4 (&-> *math-camera* camera-temp vector 1 quad)) + (.lvf vf5 (&-> *math-camera* camera-temp vector 2 quad)) + (.lvf vf6 (&-> *math-camera* camera-temp vector 3 quad)) + (.lvf vf9 (&-> *math-camera* hvdf-off quad)) + (.mov v1-20 vf9) + ) + ) + (.lvf vf1 (&-> sv-16 x-y-z-sx quad)) + (.lvf vf2 (&-> sv-16 color 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)) cfg-21) + (.wait.vf) + (.mul.vf vf1 vf1 Q :mask #b111) + (.mul.vf vf2 vf2 Q :mask #b111) + (.cfc2.i v1-25 Clipping) + (b! (logtest? v1-25 63) cfg-21 :delay (.add.vf vf1 vf1 vf9)) + (.max.x.vf vf1 vf1 vf0 :mask #b1000) + (.svf (&-> (the-as vector a0-1) quad) vf1) + (.svf (&-> (the-as vector sv-48) quad) vf2) + (set! (-> (the-as vector a0-1) w) 255.0) + (set! + (-> (the-as (pointer float) sv-32)) + (* 0.001953125 (+ -1792.0 (-> (the-as vector a0-1) x))) + ) + (set! + (-> (the-as vector sv-32) y) + (* + 0.00390625 + (+ + (+ -2048.0 (the float (-> *video-parms* screen-hy))) + (-> (the-as vector a0-1) y) + ) + ) + ) + ) + (set! (-> (the-as vector sv-32) z) 1.0) + (when (or (< (-> sv-16 flag) 3) (< 11 (-> sv-16 flag))) + (format 0 "Turns = ~D!!!~%" (-> sv-16 flag)) + (set! (-> (the-as (pointer int32) sv-16) 4) 11) + ) + (set! (-> (the-as (pointer int32) sv-32) 3) (-> sv-16 flag)) + (let* ((f0-7 (- (-> *math-camera* perspective vector 1 y))) + (f2-4 (-> (the-as vector sv-32) y)) + (f4-0 (+ f2-4 (* (-> (the-as (pointer float) sv-48)) f0-7))) + (f3-0 256.0) + (f1-7 (-> (the-as (pointer float) sv-48))) + ) + (if (< (the float (-> *video-parms* screen-sy)) f4-0) + (set! f3-0 (/ (- (the float (-> *video-parms* screen-sy)) f2-4) f0-7)) + ) + (if (< 128.0 f3-0) + (set! f3-0 128.0) + ) + (when (< f3-0 f1-7) + (let ((v1-55 (/ f3-0 f1-7))) + (.mov vf1 v1-55) + ) + (.mul.x.vf vf2 vf2 vf1) + (.svf (&-> (the-as vector sv-48) quad) vf2) + (.mov v1-57 vf2) + ) + ) + (&+! (-> arg0 base) 48) + (+! s4-0 1) + (when (= s4-0 85) + (let ((v1-62 (-> arg0 base))) + (set! (-> arg0 base) s0-0) + (let* ((a0-8 arg0) + (a1-3 (the-as object (-> a0-8 base))) + ) + (set! + (-> (the-as dma-packet a1-3) dma) + (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc (* 3 s4-0)) + ) + (set! (-> (the-as dma-packet a1-3) vif0) (new 'static 'vif-tag)) + (set! + (-> (the-as dma-packet 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-8 base) (&+ (the-as pointer a1-3) 16)) + ) + (set! (-> arg0 base) v1-62) + ) + (set! s4-0 0) + (+! s5-0 85) + (when (= s5-0 170) + (let* ((v1-65 arg0) + (a0-9 (the-as object (-> v1-65 base))) + ) + (set! + (-> (the-as dma-packet a0-9) dma) + (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt)) + ) + (set! (-> (the-as dma-packet a0-9) vif0) (new 'static 'vif-tag)) + (set! + (-> (the-as dma-packet a0-9) vif1) + (new 'static 'vif-tag :imm #x1ff :num #x1 :cmd (vif-cmd unpack-v4-32)) + ) + (set! (-> v1-65 base) (&+ (the-as pointer a0-9) 16)) + ) + (let* ((v1-66 arg0) + (a0-11 (the-as object (-> v1-66 base))) + ) + (set! (-> (the-as vector4w a0-11) x) s5-0) + (set! (-> (the-as vector4w a0-11) y) 0) + (set! (-> (the-as vector4w a0-11) z) 0) + (set! (-> (the-as vector4w a0-11) w) 0) + (set! (-> v1-66 base) (&+ (the-as pointer a0-11) 16)) + ) + (let* ((v1-67 arg0) + (a0-13 (the-as object (-> v1-67 base))) + ) + (set! + (-> (the-as dma-packet a0-13) dma) + (new 'static 'dma-tag :id (dma-tag-id cnt)) + ) + (set! + (-> (the-as dma-packet a0-13) vif0) + (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1) + ) + (set! + (-> (the-as dma-packet a0-13) vif1) + (new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1) + ) + (set! (-> v1-67 base) (&+ (the-as pointer a0-13) 16)) + ) + (set! s5-0 0) + ) + (set! s0-0 (-> arg0 base)) + (&+! (-> arg0 base) 16) + ) + (label cfg-21) + ) + ) + (cond + ((zero? s4-0) + (set! (-> arg0 base) s0-0) + (nop!) + 0 + ) + (else + (let ((v1-74 (-> arg0 base))) + (set! (-> arg0 base) s0-0) + (let* ((a0-15 arg0) + (a1-10 (the-as object (-> a0-15 base))) + ) + (set! + (-> (the-as dma-packet a1-10) dma) + (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc (* 3 s4-0)) + ) + (set! (-> (the-as dma-packet a1-10) vif0) (new 'static 'vif-tag)) + (set! + (-> (the-as dma-packet 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-15 base) (&+ (the-as pointer a1-10) 16)) + ) + (set! (-> arg0 base) v1-74) + ) + ) + ) + (let ((v1-75 (+ s4-0 s5-0))) + (when (nonzero? v1-75) + (let* ((a0-17 arg0) + (a1-12 (the-as object (-> a0-17 base))) + ) + (set! + (-> (the-as dma-packet a1-12) dma) + (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt)) + ) + (set! (-> (the-as dma-packet a1-12) vif0) (new 'static 'vif-tag)) + (set! + (-> (the-as dma-packet a1-12) vif1) + (new 'static 'vif-tag :imm #x1ff :num #x1 :cmd (vif-cmd unpack-v4-32)) + ) + (set! (-> a0-17 base) (&+ (the-as pointer a1-12) 16)) + ) + (let* ((a0-18 arg0) + (a1-14 (the-as object (-> a0-18 base))) + ) + (set! (-> (the-as vector4w a1-14) x) v1-75) + (set! (-> (the-as vector4w a1-14) y) 0) + (set! (-> (the-as vector4w a1-14) z) 0) + (set! (-> (the-as vector4w a1-14) w) 0) + (set! (-> a0-18 base) (&+ (the-as pointer a1-14) 16)) + ) + (let ((v1-77 (the-as object (-> arg0 base)))) + (set! + (-> (the-as dma-packet v1-77) dma) + (new 'static 'dma-tag :id (dma-tag-id cnt)) + ) + (set! + (-> (the-as dma-packet v1-77) vif0) + (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1) + ) + (set! + (-> (the-as dma-packet v1-77) vif1) + (new 'static 'vif-tag :cmd (vif-cmd flush) :msk #x1) + ) + (set! (-> arg0 base) (&+ (the-as pointer v1-77) 16)) + ) + ) + ) + ) + 0 + (none) + ) + ) + + + + From 23748dfeefc33b44dfdbd3fb9f18ffed96140674 Mon Sep 17 00:00:00 2001 From: water Date: Fri, 13 Aug 2021 21:48:56 -0400 Subject: [PATCH 3/7] start on debug graphics --- decompiler/config/all-types.gc | 2 +- .../opengl_renderer/DirectRenderer.cpp | 76 +++++----- .../opengl_renderer/OpenGLRenderer.cpp | 2 +- goal_src/engine/camera/math-camera.gc | 6 +- goal_src/engine/debug/debug.gc | 43 +++--- goal_src/examples/debug-draw-example.gc | 130 ++++++++++++++++++ 6 files changed, 202 insertions(+), 57 deletions(-) create mode 100644 goal_src/examples/debug-draw-example.gc diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 16c174f8b8..65774c1ca7 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -15186,7 +15186,7 @@ (define-extern get-debug-line (function debug-line)) (define-extern internal-draw-debug-line (function bucket-id vector vector rgba symbol rgba pointer)) (define-extern draw-string (function string dma-buffer font-context float)) -(define-extern transform-float-point (function vector vector vector)) +(define-extern transform-float-point (function vector vector4w vector4w)) (define-extern add-debug-point (function symbol bucket-id vector symbol)) ;; unused (define-extern add-debug-outline-triangle (function symbol bucket-id vector vector vector rgba symbol)) (define-extern add-debug-triangle-normal (function symbol bucket-id vector vector vector rgba symbol)) diff --git a/game/graphics/opengl_renderer/DirectRenderer.cpp b/game/graphics/opengl_renderer/DirectRenderer.cpp index c1f2ec8738..a54e4cdcef 100644 --- a/game/graphics/opengl_renderer/DirectRenderer.cpp +++ b/game/graphics/opengl_renderer/DirectRenderer.cpp @@ -540,7 +540,7 @@ void DirectRenderer::handle_xyzf2_packed(const u8* data, SharedRenderState* rend u8 f = (upper >> 36); bool adc = upper & (1ull << 47); assert(!adc); - assert(!f); + // assert(!f); handle_xyzf2_common(x, y, z, f, render_state); } @@ -619,7 +619,8 @@ void DirectRenderer::handle_xyzf2_common(u32 x, if (m_prim_buffer.is_full()) { flush_pending(render_state); } - assert(f == 0); + // assert(f == 0); + m_prim_building.building_st.at(m_prim_building.building_idx) = m_prim_building.st_reg; m_prim_building.building_rgba.at(m_prim_building.building_idx) = m_prim_building.rgba_reg; m_prim_building.building_vert.at(m_prim_building.building_idx) = {x << 16, y << 16, z}; @@ -669,39 +670,44 @@ void DirectRenderer::handle_xyzf2_common(u32 x, } } break; - // case GsPrim::Kind::LINE: { - // if (m_prim_building.building_idx == 1) { - // math::Vector pt0 = m_prim_building.building_vert[0].cast(); - // math::Vector pt1 = m_prim_building.building_vert[1].cast(); - // auto normal = (pt1 - pt0).normalized().cross({0, 0, 1}); - // - // double line_width = (1 << 28); - // fmt::print("Line:\n "); - // fmt::print(" {} {} {} {}\n", m_prim_building.building_vert[0].x(), - // m_prim_building.building_vert[0].y(), - // m_prim_building.building_vert[1].x(), - // m_prim_building.building_vert[1].y()); - // // debug_print_vtx(m_prim_building.building_vert[0]); - // // debug_print_vtx(m_prim_building.building_vert[1]); - // - // math::Vector a = pt0 + normal * line_width; - // math::Vector b = pt1 + normal * line_width; - // math::Vector c = pt0 - normal * line_width; - // math::Vector d = pt1 - normal * line_width; - // - // // ACB: - // m_prim_buffer.push(m_prim_building.building_rgba[0], a.cast(), {}); - // m_prim_buffer.push(m_prim_building.building_rgba[0], c.cast(), {}); - // m_prim_buffer.push(m_prim_building.building_rgba[1], b.cast(), {}); - // // b c d - // m_prim_buffer.push(m_prim_building.building_rgba[1], b.cast(), {}); - // m_prim_buffer.push(m_prim_building.building_rgba[0], c.cast(), {}); - // m_prim_buffer.push(m_prim_building.building_rgba[1], d.cast(), {}); - // // - // - // m_prim_building.building_idx = 0; - // } - // } break; + + case GsPrim::Kind::TRI: + if (m_prim_building.building_idx == 3) { + m_prim_building.building_idx = 0; + for (int i = 0; i < 3; i++) { + m_prim_buffer.push(m_prim_building.building_rgba[i], m_prim_building.building_vert[i], + m_prim_building.building_st[i]); + } + } + break; + case GsPrim::Kind::LINE: { + if (m_prim_building.building_idx == 2) { + math::Vector pt0 = m_prim_building.building_vert[0].cast(); + math::Vector pt1 = m_prim_building.building_vert[1].cast(); + auto normal = (pt1 - pt0).normalized().cross({0, 0, 1}); + + double line_width = (1 << 19); + // debug_print_vtx(m_prim_building.building_vert[0]); + // debug_print_vtx(m_prim_building.building_vert[1]); + + math::Vector a = pt0 + normal * line_width; + math::Vector b = pt1 + normal * line_width; + math::Vector c = pt0 - normal * line_width; + math::Vector d = pt1 - normal * line_width; + + // ACB: + m_prim_buffer.push(m_prim_building.building_rgba[0], a.cast(), {}); + m_prim_buffer.push(m_prim_building.building_rgba[0], c.cast(), {}); + m_prim_buffer.push(m_prim_building.building_rgba[1], b.cast(), {}); + // b c d + m_prim_buffer.push(m_prim_building.building_rgba[1], b.cast(), {}); + m_prim_buffer.push(m_prim_building.building_rgba[0], c.cast(), {}); + m_prim_buffer.push(m_prim_building.building_rgba[1], d.cast(), {}); + // + + m_prim_building.building_idx = 0; + } + } break; default: fmt::print("prim type {} is unsupported.\n", (int)m_prim_building.kind); assert(false); diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index 588145991d..6c1896f400 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -70,7 +70,7 @@ void OpenGLRenderer::init_bucket_renderers() { */ void OpenGLRenderer::render(DmaFollower dma, int window_width_px, int window_height_px) { setup_frame(window_width_px, window_height_px); - draw_test_triangle(); + // draw_test_triangle(); // render the buckets! dispatch_buckets(dma); } diff --git a/goal_src/engine/camera/math-camera.gc b/goal_src/engine/camera/math-camera.gc index 8648c84998..3c53a02e98 100644 --- a/goal_src/engine/camera/math-camera.gc +++ b/goal_src/engine/camera/math-camera.gc @@ -467,9 +467,9 @@ (.mul.x.vf acc vf24 vf28) (.add.mul.y.vf acc vf25 vf28 acc) (.add.mul.z.vf acc vf26 vf28 acc) - (.add.mul.w.vf vf28 vf27 vf0 acc) - (.add.w.vf vf23 vf0 vf0) - (.mul.vf vf31 vf28 vf29) + (.add.mul.w.vf vf28 vf27 vf0 acc) ;; matrix mult. + (.add.w.vf vf23 vf0 vf0) ;; clear w. + (.mul.vf vf31 vf28 vf29) ;; scale. ;;(TODO.VCLIP vf31 vf31) (let ((clip (vu-clip vf31 0))) (.div.vf Q vf0 vf31 :fsf #b11 :ftf #b11) diff --git a/goal_src/engine/debug/debug.gc b/goal_src/engine/debug/debug.gc index 2843cc4e0a..85b323bae4 100644 --- a/goal_src/engine/debug/debug.gc +++ b/goal_src/engine/debug/debug.gc @@ -5,8 +5,12 @@ ;; name in dgo: debug ;; dgos: GAME, ENGINE +;; This file contains functions for debug drawing. +;; In general, the 3d functions draw using the camera and the 2d functions draw in screen coordinated. +;; Most functions take a boolean as their first argument. If the boolean is set to #f, it will skip drawing the point. -(defun transform-float-point ((in vector) (out vector)) + +(defun transform-float-point ((in vector) (out vector4w)) "Transform point in and store the result in out. This uses the cached vf register transformation matrix Note that the input/output order of the arguments is swapped from usual" @@ -44,7 +48,8 @@ ;; They do a DMA packet per thing drawn. (defun-debug add-debug-point ((enable-draw symbol) (bucket bucket-id) (pt vector)) - "Draw a point." + "Draw a point. + The point is actually a pretty large square with some weird rgb gradient." (if (not enable-draw) (return #f) ) @@ -60,8 +65,9 @@ (new 'static 'gif-tag64 :nloop 1 :eop 1 :pre 1 :nreg 8 :prim (gif-prim tri-strip)) (gs-reg-list rgbaq xyzf2 rgbaq xyzf2 rgbaq xyzf2 rgbaq xyzf2) ) - - (set! (-> s5-0 vector 1 x) 255) + + ;; upper point is red + (set! (-> s5-0 vector 1 x) 255) ;; r (set! (-> s5-0 vector 1 y) 128) (set! (-> s5-0 vector 1 z) 128) (set! (-> s5-0 vector 1 w) 128) @@ -70,16 +76,18 @@ (-> s5-0 quad 1) (-> s5-0 quad 0) ) - + + ;; left point is green (+! (-> s5-0 vector 0 x) -256) (+! (-> s5-0 vector 0 y) -160) (set! (-> s5-0 vector 1 x) 128) - (set! (-> s5-0 vector 1 y) 255) + (set! (-> s5-0 vector 1 y) 255) ;; g (dma-buffer-add-uint128 v1-7 (-> s5-0 quad 1) (-> s5-0 quad 0) ) - + + ;; right point is blue (+! (-> s5-0 vector 0 x) 512) (set! (-> s5-0 vector 1 y) 128) (set! (-> s5-0 vector 1 z) 255) @@ -87,7 +95,8 @@ (-> s5-0 quad 1) (-> s5-0 quad 0) ) - + + ;; bottom point is red again (+! (-> s5-0 vector 0 x) -256) (+! (-> s5-0 vector 0 y) -160) (set! (-> s5-0 vector 1 x) 255) @@ -244,21 +253,21 @@ #f ) -(defun-debug add-debug-flat-triangle ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 vector) (arg5 rgba)) - (if (not arg0) +(defun-debug add-debug-flat-triangle ((enable-draw symbol) (bucket bucket-id) (p0 vector) (p1 vector) (p2 vector) (arg5 rgba)) + (if (not enable-draw) (return #f) ) (let ((s5-0 (new 'stack 'vector4w-3)) (s4-0 (new 'stack 'vector4w-3)) ) - (set! (-> arg2 w) 1.0) - (set! (-> arg3 w) 1.0) - (set! (-> arg4 w) 1.0) - (when (and (transform-point-qword! (-> s5-0 vector 0) arg2) - (transform-point-qword! (-> s5-0 vector 1) arg3) - (transform-point-qword! (-> s5-0 vector 2) arg4) + (set! (-> p0 w) 1.0) + (set! (-> p1 w) 1.0) + (set! (-> p2 w) 1.0) + (when (and (transform-point-qword! (-> s5-0 vector 0) p0) + (transform-point-qword! (-> s5-0 vector 1) p1) + (transform-point-qword! (-> s5-0 vector 2) p2) ) - (with-dma-buffer-add-bucket ((v1-9 (current-display-frame debug-buf)) (current-display-frame bucket-group) arg1) + (with-dma-buffer-add-bucket ((v1-9 (current-display-frame debug-buf)) (current-display-frame bucket-group) bucket) (with-cnt-vif-block (v1-9) (dma-buffer-add-gif-tag v1-9 (new 'static 'gif-tag64 :nloop 1 :eop 1 :pre 1 :nreg 6 :prim (gif-prim tri)) diff --git a/goal_src/examples/debug-draw-example.gc b/goal_src/examples/debug-draw-example.gc new file mode 100644 index 0000000000..d5e92e4356 --- /dev/null +++ b/goal_src/examples/debug-draw-example.gc @@ -0,0 +1,130 @@ +;; This file demonstrates how to use the debug draw. + +;; To run this: + +#| +(make-group "iso") ;; build the game +(lt) ;; connect to the runtime +(lg) ;; have the runtime load the game engine +(test-play) ;; start the game loop +(ml "goal_src/examples/debug-draw-example.gc") ;; build and load this file. +|# + +(defun hack-update-camera ((location vector) (inv-rot matrix)) + "Debugging function to set the camera's position and orientation" + ;; update to compute the perspective matrix. + (update-math-camera + *math-camera* + (-> *setting-control* current video-mode) + (-> *setting-control* current aspect-ratio) + ) + + ;; copy the input rotation + (matrix-copy! (-> *math-camera* inv-camera-rot) inv-rot) + ;; inverse of rotation matrix matrix is its transpose + (matrix-transpose! (-> *math-camera* camera-rot) (-> *math-camera* inv-camera-rot)) + + ;; fake some value here + (set! (-> *math-camera* fov-correction-factor) 1.0) + + ;; do the math + (set! (-> *math-camera* trans quad) (-> location quad)) + (let ((cam-temp (-> *math-camera* camera-temp)) + (cam-rot (-> *math-camera* camera-rot)) + (inv-cam-rot (-> *math-camera* inv-camera-rot)) + (cam-trans (-> *math-camera* trans)) + ) + (let ((rotated-trans (new-stack-vector0))) + (set! (-> rotated-trans x) (- (-> cam-trans x))) + (set! (-> rotated-trans y) (- (-> cam-trans y))) + (set! (-> rotated-trans z) (- (-> cam-trans z))) + (set! (-> rotated-trans w) 1.0) + (vector-matrix*! rotated-trans rotated-trans cam-rot) + (set! (-> cam-rot vector 3 quad) (-> rotated-trans quad)) + ) + (matrix*! cam-temp cam-rot (-> *math-camera* perspective)) + (set! (-> inv-cam-rot vector 3 quad) (-> cam-trans quad)) + ) + + (none) + ) + +(defun test-function ((iter int)) + "This function draws the debug stuff. You can edit this, then reload this file to play with it." + + ;; val will increase from 0 to 1, then reset back to 0. + (let* ((frame (the float (mod (* 4 iter) 1600))) + (val (/ frame 1600.0))) + (format *stdcon* "~0kval ~f~%" val) + + ;; orbit the camera around in a circle with radius 5 m. + (let* ((rad (meters 5.0)) + (x (* rad (sin (* (degrees 360.0) val)))) + (z (* rad (cos (* (degrees 360.0) val)))) + (cam-pos (new 'stack 'vector)) + (cam-inv-rot (new 'stack 'matrix)) + ) + ;; this matrix will look directly at the origin... + (set! (-> cam-pos x) x) + (set! (-> cam-pos z) z) + (set! (-> cam-pos y) (meters 2.)) + (forward-down->inv-matrix cam-inv-rot cam-pos (new 'static 'vector :y 1.0)) + + ;; if the camera is here. + (set! (-> cam-pos x) (- 0. x)) + (set! (-> cam-pos z) (- 0. z)) + (set! (-> cam-pos y) (meters -2.)) + (hack-update-camera cam-pos cam-inv-rot) + + + ;; create some test points + (let ((p0 (new 'static 'vector :x (meters .8) :y (meters .2) :z (meters 2.0))) + (p1 (new 'static 'vector :x (meters .3) :y (meters .3) :z (meters 2.5))) + (p2 (new 'static 'vector :x (meters .5) :y (meters .7) :z (meters 1.5))) + ) + + ;;(add-debug-point #t (bucket-id debug-draw0) (new 'static 'vector)) + (add-debug-x #t (bucket-id debug-draw0) (new 'static 'vector) (new 'static 'rgba :g #x80 :a #x80)) + (add-debug-box #t (bucket-id debug-draw0) p0 p2 (new 'static 'rgba :b #x80 :a #x80)) + (add-debug-flat-triangle #t (bucket-id debug-draw0) p0 p1 p2 (new 'static 'rgba :r #x80)) + (add-debug-text-3d #t (bucket-id debug-draw0) "triangle!" p0 (the rgba 1) (the vector2h #f)) + (add-debug-sphere #t (bucket-id debug-draw0) p2 (meters 0.5) (new 'static 'rgba :r #x80)) + ) + ) + + ;; these also work + ;; (draw-end-credits (the int frame)) + ;; (draw-title-credits val) + + ) + (none) + ) + + +(defun launch-test-process () + "Call this to launch a process that draws the debug demo" + (let ((proc (get-process *nk-dead-pool* process 1024))) + (activate proc *active-pool* 'test *kernel-dram-stack*) + (run-next-time-in-process proc (lambda () + (let ((iter 0)) + (while #t + (test-function iter) + (suspend) + (+! iter 1) + ) + ) + ) + ) + proc) + + ) + +;; This will spawn a process the first time this file is loaded +(define-perm *test-process* process (launch-test-process)) + +(defun kill-test-procs () + "Kill all processes started by launch-test-process" + (kill-by-name "test" *active-pool*) + ) + +(set! *display-profile* #t) From fbf2a646a30597b0e93650752a74483b63ff3d12 Mon Sep 17 00:00:00 2001 From: water Date: Sat, 14 Aug 2021 11:28:02 -0400 Subject: [PATCH 4/7] add sublime text config --- scripts/sublime_text/goal.sublime-settings | 6 ++ scripts/sublime_text/goal.sublime-syntax | 92 +++++++++++++++++++ .../sublime_text/lispindent.sublime-settings | 12 +++ scripts/sublime_text/readme.txt | 7 ++ 4 files changed, 117 insertions(+) create mode 100644 scripts/sublime_text/goal.sublime-settings create mode 100644 scripts/sublime_text/goal.sublime-syntax create mode 100644 scripts/sublime_text/lispindent.sublime-settings create mode 100644 scripts/sublime_text/readme.txt diff --git a/scripts/sublime_text/goal.sublime-settings b/scripts/sublime_text/goal.sublime-settings new file mode 100644 index 0000000000..f713b77d90 --- /dev/null +++ b/scripts/sublime_text/goal.sublime-settings @@ -0,0 +1,6 @@ +{ + "extensions": + [ + "gc" + ] +} diff --git a/scripts/sublime_text/goal.sublime-syntax b/scripts/sublime_text/goal.sublime-syntax new file mode 100644 index 0000000000..5c9cd73640 --- /dev/null +++ b/scripts/sublime_text/goal.sublime-syntax @@ -0,0 +1,92 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: goal +file_extensions: + - gc +scope: source.goal +contexts: + main: + + # Important keywords for blocks/control flow/etc + - match: \b(?i:begin|block|return-from|cond|when|if|unless|let|else|while|rlet|countdown|dotimes)\b + scope: keyword.control.goal + + # Less important keywords + - match: \b(?i:the-as|the|logior|logand|ash|cons|car|cdr|new|break|none|method-of-type|method-of-object|declare|and|not)\b + scope: keyword.operator.goal + + # Definition forms like (def thing value) + - match: \b(?i:(defun|defmacro|deftype|define|defconstant|defun-debug|define-extern))\b\s+([\w\-!?<>]*) + scope: meta.function.goal + captures: + 1: keyword.declaration.function.goal + 2: entity.name.function.goal + + # Special case for defmethod + - match: \b(?i:(defmethod))\b\s+([\w\-!?<>]*)\b\s+([\w\-!?<>]*) + scope: meta.function.goal + captures: + 1: keyword.declaration.function.goal + 2: entity.name.function.goal + 3: entity.name.class.lisgoalp + + # Special case for set. Need a special case because of the !, and don't want to match reset! + - match: \b(?i:set!|neq\?|eq\?|zero\?) + scope: keyword.operator.goal + + - match: (?i:->) + scope: keyword.operator.goal + + # Quoted symbols. I abuse these as "parameter" + - match: (?i:'([\w\-!?<>]+)) + scope: variable.parameter.goal + + # Block comments + - match: '#\|' + scope: punctuation.definition.comment.begin.goal + push: + - meta_scope: comment.block.goal + - include: block-comment + - match: '\|#' + scope: punctuation.definition.comment.end.goal + pop: true + + # Normal Comments + - match: (;).*$\n? + scope: comment.line.semicolon.goal + captures: + 1: punctuation.definition.comment.goal + + # Built-in, numeric type + - match: \b(uint128|int128|float|int64|uint64|int32|uint32|int16|uint16|int8|uint8|binteger|int|uint|pointer)\b + scope: storage.type + + - match: (?i:#t|#f|'\(\)) + scope: constant.language.goal + + - match: '(#)(\w|[\\+-=<>''."&#])+' + scope: constant.character.goal + captures: + 1: constant.character.goal # change this to change the color of the prefix. + + - match: (\*)(\S*)(\*) + scope: variable.function.goal + + - match: :(\S*) + scope: variable.function.goal + + + - match: '"' + captures: + 0: punctuation.definition.string.begin.goal + push: + - meta_scope: string.quoted.double.goal + - match: '"' + captures: + 0: punctuation.definition.string.end.goal + pop: true + - match: \\. + scope: constant.character.escape.goal + + diff --git a/scripts/sublime_text/lispindent.sublime-settings b/scripts/sublime_text/lispindent.sublime-settings new file mode 100644 index 0000000000..836528e45f --- /dev/null +++ b/scripts/sublime_text/lispindent.sublime-settings @@ -0,0 +1,12 @@ +{ + "languages": { + "goal": { + "detect": ".*\\.(gc)$", + "default_indent": "function", + "regex": + ["(with-gensyms|defenum|countdown|while|defglobalconstant|desfun|defsmacro|catch|defvar|defclass|defconstant|defcustom|defparameter|defconst|define-condition|define-modify-macro|", + "defsetf|defun|defgeneric|define-setf-method|define-self-expander|defmacro|defsubst|deftype|defmethod|", + "defpackage|defstruct|dolist|dotimes|lambda|let|let\\*|prog1|prog2|unless|when)$"] + } + } +} diff --git a/scripts/sublime_text/readme.txt b/scripts/sublime_text/readme.txt new file mode 100644 index 0000000000..28e5d8fbd3 --- /dev/null +++ b/scripts/sublime_text/readme.txt @@ -0,0 +1,7 @@ +move the goal.sublime-syntax file to your Packages/User directory. To find this, you can go to Preferences -> Browse Packages -> User. + +To enable the syntax highlighting, set the language to goal. It should show up in the "User" category. + +For formatting, install the lispindent plugin and move the lispindent config file to the same User folder. + + From 097ae07bb8ff05fccdc13877532b1718211259cc Mon Sep 17 00:00:00 2001 From: water Date: Sat, 14 Aug 2021 13:06:43 -0400 Subject: [PATCH 5/7] clean up font color --- decompiler/IR2/AtomicOpTypeAnalysis.cpp | 14 + decompiler/analysis/final_output.cpp | 72 +++-- decompiler/config/all-types.gc | 61 +++- .../jak1_ntsc_black_label/var_names.jsonc | 5 +- goal_src/engine/debug/debug.gc | 288 ++++++++++-------- goal_src/engine/debug/menu.gc | 38 +-- goal_src/engine/game/game-info.gc | 2 +- goal_src/engine/game/main.gc | 6 +- goal_src/engine/gfx/font-h.gc | 66 ++-- goal_src/engine/gfx/font.gc | 2 +- goal_src/engine/gfx/hw/display.gc | 10 +- goal_src/engine/nav/path.gc | 8 +- goal_src/engine/ps2/memcard-h.gc | 2 +- goal_src/engine/sound/gsound.gc | 8 +- goal_src/engine/ui/credits.gc | 4 +- goal_src/engine/ui/text.gc | 6 +- goal_src/examples/debug-draw-example.gc | 40 +-- scripts/sublime_text/goal.sublime-syntax | 2 +- .../reference/engine/debug/debug-h_REF.gc | 1 + .../reference/engine/debug/menu_REF.gc | 151 +++++---- .../reference/engine/dma/dma-disasm_REF.gc | 2 +- .../reference/engine/engine/engines_REF.gc | 12 +- .../reference/engine/game/settings_REF.gc | 9 +- .../reference/engine/gfx/font-h_REF.gc | 38 +-- .../engine/gfx/generic/generic_REF.gc | 4 +- .../reference/engine/gfx/hw/display_REF.gc | 29 +- .../reference/engine/gfx/texture_REF.gc | 38 +-- .../reference/engine/nav/navigate-h_REF.gc | 5 +- .../reference/engine/nav/path_REF.gc | 8 +- .../reference/engine/ps2/memcard-h_REF.gc | 9 +- .../reference/engine/sound/gsound_REF.gc | 8 +- .../reference/engine/ui/credits_REF.gc | 13 +- .../reference/kernel/gkernel_REF.gc | 13 +- 33 files changed, 574 insertions(+), 400 deletions(-) diff --git a/decompiler/IR2/AtomicOpTypeAnalysis.cpp b/decompiler/IR2/AtomicOpTypeAnalysis.cpp index 6c5c5ccd89..59f23b1e5b 100644 --- a/decompiler/IR2/AtomicOpTypeAnalysis.cpp +++ b/decompiler/IR2/AtomicOpTypeAnalysis.cpp @@ -770,6 +770,20 @@ TypeState AsmOp::propagate_types_internal(const TypeState& input, } } + // srl out, bitfield, int + if (m_instr.kind == InstructionKind::SRL) { + auto type = dts.ts.lookup_type(result.get(m_src[0]->reg()).typespec()); + auto as_bitfield = dynamic_cast(type); + if (as_bitfield) { + int sa = m_instr.src[1].get_imm(); + int offset = sa; + int size = 32 - offset; + auto field = find_field(dts.ts, as_bitfield, offset, size, {}); + result.get(m_dst->reg()) = TP_Type::make_from_ts(coerce_to_reg_type(field.type())); + return result; + } + } + if (m_dst.has_value()) { auto kind = m_dst->reg().get_kind(); if (kind == Reg::FPR) { diff --git a/decompiler/analysis/final_output.cpp b/decompiler/analysis/final_output.cpp index 4a34c5060d..14312a40bd 100644 --- a/decompiler/analysis/final_output.cpp +++ b/decompiler/analysis/final_output.cpp @@ -199,28 +199,11 @@ std::string add_indent(const std::string& in, int indent, bool indent_first_line return result; } -std::string write_from_top_level(const Function& top_level, - const DecompilerTypeSystem& dts, - const LinkedObjectFile& file, - const std::unordered_set& skip_functions) { - auto top_form = top_level.ir2.top_form; - if (!top_form) { - return ";; ERROR: top level function was not converted to expressions. Cannot decompile.\n\n"; - } - - auto& env = top_level.ir2.env; - if (!env.has_type_analysis()) { - return ";; ERROR: top level has no type analysis. Cannot decompile.\n\n"; - } - - if (!env.has_local_vars()) { - return ";; ERROR: top level has no local vars. Cannot decompile.\n\n"; - } - - if (!env.has_reg_use()) { - return ";; ERROR: top level has no register use analysis. Cannot decompile.\n\n"; - } - +std::string write_from_top_level_form(Form* top_form, + const DecompilerTypeSystem& dts, + const LinkedObjectFile& file, + const std::unordered_set& skip_functions, + const Env& env) { std::vector forms = top_form->elts(); assert(!forms.empty()); @@ -232,7 +215,7 @@ std::string write_from_top_level(const Function& top_level, std::string result; // local vars: - auto var_dec = env.local_var_type_list(top_level.ir2.top_form, 0); + auto var_dec = env.local_var_type_list(top_form, 0); if (var_dec.local_vars) { result += pretty_print::to_string(*var_dec.local_vars); result += '\n'; @@ -424,6 +407,24 @@ std::string write_from_top_level(const Function& top_level, } } + if (!something_matched) { + auto as_cne = f.try_as_element(); + if (as_cne && as_cne->entries.size() == 1) { + auto& entry = as_cne->entries.at(0); + // a bit gross... + if (entry.condition->to_string(env) == "*debug-segment*") { + something_matched = true; + // forms = entry.body->elts(); + result += ";; this part is debug only\n"; + result += "(when *debug-segment*\n"; + + result += write_from_top_level_form(entry.body, dts, file, skip_functions, env); + + result += ")\n"; + } + } + } + if (!something_matched) { auto empty = dynamic_cast(x); if (empty) { @@ -450,4 +451,29 @@ std::string write_from_top_level(const Function& top_level, return result; } + +std::string write_from_top_level(const Function& top_level, + const DecompilerTypeSystem& dts, + const LinkedObjectFile& file, + const std::unordered_set& skip_functions) { + auto top_form = top_level.ir2.top_form; + if (!top_form) { + return ";; ERROR: top level function was not converted to expressions. Cannot decompile.\n\n"; + } + + auto& env = top_level.ir2.env; + if (!env.has_type_analysis()) { + return ";; ERROR: top level has no type analysis. Cannot decompile.\n\n"; + } + + if (!env.has_local_vars()) { + return ";; ERROR: top level has no local vars. Cannot decompile.\n\n"; + } + + if (!env.has_reg_use()) { + return ";; ERROR: top level has no register use analysis. Cannot decompile.\n\n"; + } + + return write_from_top_level_form(top_form, dts, file, skip_functions, env); +} } // namespace decompiler \ No newline at end of file diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 65774c1ca7..d984844c99 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -5198,6 +5198,45 @@ :flag-assert #x900000010 ) +(defenum font-color + :type uint64 + (default 0) + (white 1) + (gray 2) + (orange-red 3) + (bright-orange-red 4) + (dark-yellow 5) + (bright-green 6) + (dark-blue 7) + (light-blue 8) + (dark-pink 9) + (lighter-blue 10) + (dark-light-blue 11) + (dim-white 12) + (dim-gray 13) + (orange-red-2 14) + (yellow-green 15) + (dark-green 16) + (another-gray 17) + (dark-dark-green 18) + (flat-dark-purple 19) + (yellow 20) + (blue-white 21) + (flat-dark-gray 22) + (flat-gray 23) + (flat-pink 24) + (flat-red 25) + (flat-green 26) + (flat-purple 27) + (lighter-lighter-blue 28) + (yellow-orange 29) + (yellow-green-2 30) + (another-light-blue 31) + (another-default 32) + (red-orange 33) + (another-orange-red 34) + ) + (deftype font-context (basic) ((origin vector :inline :offset-assert 16) (strip-gif vector :inline :offset-assert 32) @@ -5205,7 +5244,7 @@ (height float :offset-assert 52) (projection float :offset-assert 56) (context-vec vector :inline :offset 48) ;; added - (color int64 :offset-assert 64) + (color font-color :offset-assert 64) (color-s32 int32 :offset 64) ;; added for asm (flags uint32 :offset-assert 72) (flags-signed int32 :offset 72) ;; added for asm @@ -5217,7 +5256,7 @@ :size-assert #x58 :flag-assert #x1400000058 (:methods - (new (symbol type matrix int int float int uint) _type_ 0) + (new (symbol type matrix int int float font-color uint) _type_ 0) (set-mat! (font-context matrix) font-context 9) (set-origin! (font-context int int) font-context 10) (set-depth! (font-context int) font-context 11) @@ -5225,7 +5264,7 @@ (set-width! (font-context int) font-context 13) (set-height! (font-context int) font-context 14) (set-projection! (font-context float) font-context 15) - (set-color! (font-context int) font-context 16) + (set-color! (font-context font-color) font-context 16) (set-flags! (font-context uint) font-context 17) (set-start-line! (font-context uint) font-context 18) (set-scale! (font-context float) font-context 19) @@ -5261,9 +5300,9 @@ (justify vector 64 :inline :offset-assert 944) (color-shadow vector4w :inline :offset-assert 1968) (color-table char-color 64 :inline :offset-assert 1984) - (last-color uint64 :offset-assert 3008) + (last-color font-color :offset-assert 3008) (last-color-32 int32 :offset 3008) - (save-last-color uint64 :offset-assert 3016) + (save-last-color font-color :offset-assert 3016) (save-last-color-32 int32 :offset 3016) ;; added (buf basic :offset-assert 3024) (str-ptr uint32 :offset-assert 3028) @@ -5321,7 +5360,7 @@ (define-extern set-display-env (function display-env int int int int int int display-env)) (define-extern set-draw-env (function draw-env int int int int int int draw-env)) (define-extern get-video-mode (function symbol)) -(define-extern draw-string-xy (function string dma-buffer int int int int none)) +(define-extern draw-string-xy (function string dma-buffer int int font-color int none)) (define-extern set-draw-env-offset (function draw-env int int int draw-env)) (define-extern put-display-alpha-env (function display-env none)) (define-extern set-display2 (function display int int int int int display)) @@ -15154,7 +15193,7 @@ ((flags int32 :offset-assert 0) (bucket bucket-id :offset-assert 4) (pos vector :inline :offset-assert 16) - (color uint64 :offset-assert 32) + (color font-color :offset-assert 32) (offset vector2h :inline :offset-assert 40) (str string :offset-assert 44) ) @@ -15177,12 +15216,12 @@ (define-extern debug-set-camera-pos-rot! (function vector matrix int)) (define-extern drawable-frag-count (function drawable int)) (define-extern add-debug-light (function symbol bucket-id light vector string symbol)) -(define-extern add-debug-text-3d (function symbol bucket-id string vector rgba vector2h symbol)) +(define-extern add-debug-text-3d (function symbol bucket-id string vector font-color vector2h symbol)) (define-extern add-debug-x (function symbol bucket-id vector rgba symbol)) (define-extern add-debug-curve (function symbol bucket-id pointer int (inline-array vector) int rgba symbol)) (define-extern add-debug-sphere (function symbol bucket-id vector float rgba symbol)) (define-extern get-debug-text-3d (function debug-text-3d)) -(define-extern internal-draw-debug-text-3d (function bucket-id string vector rgba vector2h pointer)) +(define-extern internal-draw-debug-text-3d (function bucket-id string vector font-color vector2h pointer)) (define-extern get-debug-line (function debug-line)) (define-extern internal-draw-debug-line (function bucket-id vector vector rgba symbol rgba pointer)) (define-extern draw-string (function string dma-buffer font-context float)) @@ -15195,7 +15234,7 @@ (define-extern debug-draw-buffers (function symbol)) (define-extern add-debug-line2d (function symbol bucket-id vector vector vector symbol)) (define-extern add-debug-box (function symbol bucket-id vector vector rgba symbol)) -(define-extern add-debug-sphere-with-transform (function symbol bucket-id vector float matrix rgba symbol)) +(define-extern add-debug-sphere-with-transform (function symbol bucket-id vector meters matrix rgba symbol)) (define-extern add-debug-spheres (function symbol bucket-id (inline-array vector) int rgba symbol)) (define-extern add-debug-circle (function symbol bucket-id vector float rgba matrix symbol)) (define-extern add-debug-rot-matrix (function symbol bucket-id matrix vector matrix)) @@ -17421,7 +17460,7 @@ ;; - Functions -(define-extern set-font-color-alpha (function int int none)) +(define-extern set-font-color-alpha (function font-color int none)) (define-extern load-game-text-info (function string symbol kheap int)) (define-extern load-level-text-files (function int none)) (define-extern draw-debug-text-box (function font-context none)) diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index 404574b828..4cfc3d9937 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -2224,7 +2224,6 @@ "v1-11": ["v1-11", "dma-packet"] } }, - "add-debug-light": { "vars": { "s1-0": ["s1-0", "rgba"] } }, "generic-init-buffers": { "vars": { @@ -3127,5 +3126,9 @@ "r0-3": "r0" } }, + + "add-debug-outline-triangle": { + "args":["enable", "bucket", "p0", "p1", "p2", "color"] + }, "aaaaaaaaaaaaaaaaaaaaaaa": {} } diff --git a/goal_src/engine/debug/debug.gc b/goal_src/engine/debug/debug.gc index 85b323bae4..ca97504b89 100644 --- a/goal_src/engine/debug/debug.gc +++ b/goal_src/engine/debug/debug.gc @@ -113,147 +113,148 @@ ) -(defun-debug internal-draw-debug-line ((arg0 bucket-id) (arg1 vector) (arg2 vector) (arg3 rgba) (arg4 symbol) (arg5 rgba)) - (let ((sv-80 arg2) - (s2-0 arg3) - (s3-0 arg4) - (s5-0 arg5) - ) - (let ((a0-4 (current-display-frame debug-buf))) - (if (< (the-as uint (shr (+ (&- (-> a0-4 end) (the-as uint (-> a0-4 base))) 15) 4)) (the-as uint #x8000)) +(defun-debug internal-draw-debug-line ((bucket bucket-id) (p0 vector) (p1 vector) (first-color rgba) (mode symbol) (second-color rgba)) + "Draw a debug line from p0 to p1. Mode can be: + 'fade, 'fade-depth, or #f. + second-color can be -1 to just use the same color. + " + (let ((a0-4 (current-display-frame debug-buf))) + (if (< (the-as uint (shr (+ (&- (-> a0-4 end) (the-as uint (-> a0-4 base))) 15) 4)) (the-as uint #x8000)) (return (the-as pointer #f)) ) - ) - (if (or (zero? (+ s5-0 (the-as uint 1))) - (= s5-0 (static-rgba #xff #xff #xff #xff)) - ) - (set! s5-0 s2-0) - ) - (case s3-0 - (('fade) - (set! s5-0 (new 'static 'rgba - :r (shr (-> s5-0 r) 1) - :g (shr (-> s5-0 g) 1) - :b (shr (-> s5-0 b) 1) - :a (-> s5-0 a) - )) - ) - ) - (let ((s4-0 (new 'stack 'vector4w-2)) - (s1-0 (new 'stack 'vector4w-2)) + ) + (if (or (zero? (+ second-color (the-as uint 1))) + (= second-color (static-rgba #xff #xff #xff #xff)) ) - (set! (-> arg1 w) 1.0) - (set! (-> sv-80 w) 1.0) - - (when (and (transform-point-qword! (-> s4-0 vector 0) arg1) - (transform-point-qword! (-> s4-0 vector 1) sv-80) - ) - (with-dma-buffer-add-bucket ((v1-28 (current-display-frame debug-buf)) (current-display-frame bucket-group) arg0) - - (with-cnt-vif-block (v1-28) - (dma-buffer-add-gif-tag v1-28 (new 'static 'gif-tag64 :nloop 1 :eop 1 :pre 1 :nreg 4 - :prim (gif-prim line)) - (gs-reg-list rgbaq xyzf2 rgbaq xyzf2) - ) - (case s3-0 + (set! second-color first-color) + ) + (case mode + (('fade) + (set! second-color (new 'static 'rgba + :r (shr (-> second-color r) 1) + :g (shr (-> second-color g) 1) + :b (shr (-> second-color b) 1) + :a (-> second-color a) + )) + ) + ) + (let ((s4-0 (new 'stack 'vector4w-2)) + (s1-0 (new 'stack 'vector4w-2)) + ) + (set! (-> p0 w) 1.0) + (set! (-> p1 w) 1.0) + + (when (and (transform-point-qword! (-> s4-0 vector 0) p0) + (transform-point-qword! (-> s4-0 vector 1) p1) + ) + (with-dma-buffer-add-bucket ((v1-28 (current-display-frame debug-buf)) (current-display-frame bucket-group) bucket) + (with-cnt-vif-block (v1-28) + (dma-buffer-add-gif-tag v1-28 (new 'static 'gif-tag64 :nloop 1 :eop 1 :pre 1 :nreg 4 + :prim (gif-prim line)) + (gs-reg-list rgbaq xyzf2 rgbaq xyzf2) + ) + (case mode (('fade-depth) (let ((f0-3 (fminmax (* (1/ #xffffff) (the float (-> s4-0 vector 0 z))) 0.2 1.0))) - (set! (-> s1-0 vector 0 x) (the int (* (the float (-> s2-0 r)) f0-3))) - (set! (-> s1-0 vector 0 y) (the int (* (the float (-> s2-0 g)) f0-3))) - (set! (-> s1-0 vector 0 z) (the int (* (the float (-> s2-0 b)) f0-3))) - ) - (set! (-> s1-0 vector 0 w) (the-as int (-> s2-0 a))) - ) - (else - (set! (-> s1-0 vector 0 x) (the-as int (-> s2-0 r))) - (set! (-> s1-0 vector 0 y) (the-as int (-> s2-0 g))) - (set! (-> s1-0 vector 0 z) (the-as int (-> s2-0 b))) - (set! (-> s1-0 vector 0 w) (the-as int (-> s2-0 a))) - ) - ) - (cond - ((= s3-0 'fade-depth) - (let ((f0-7 (fminmax (* (1/ #xffffff) (the float (-> s4-0 vector 1 z))) 0.2 1.0))) - (set! (-> s1-0 vector 1 x) (the int (* (the float (-> s5-0 r)) f0-7))) - (set! (-> s1-0 vector 1 y) (the int (* (the float (-> s5-0 g)) f0-7))) - (set! (-> s1-0 vector 1 z) (the int (* (the float (-> s5-0 b)) f0-7))) + (set! (-> s1-0 vector 0 x) (the int (* (the float (-> first-color r)) f0-3))) + (set! (-> s1-0 vector 0 y) (the int (* (the float (-> first-color g)) f0-3))) + (set! (-> s1-0 vector 0 z) (the int (* (the float (-> first-color b)) f0-3))) ) - (set! (-> s1-0 vector 1 w) (the-as int (-> s5-0 a))) + (set! (-> s1-0 vector 0 w) (the-as int (-> first-color a))) ) (else - (set! (-> s1-0 vector 1 x) (the-as int (-> s5-0 r))) - (set! (-> s1-0 vector 1 y) (the-as int (-> s5-0 g))) - (set! (-> s1-0 vector 1 z) (the-as int (-> s5-0 b))) - (set! (-> s1-0 vector 1 w) (the-as int (-> s5-0 a))) - ) + (set! (-> s1-0 vector 0 x) (the-as int (-> first-color r))) + (set! (-> s1-0 vector 0 y) (the-as int (-> first-color g))) + (set! (-> s1-0 vector 0 z) (the-as int (-> first-color b))) + (set! (-> s1-0 vector 0 w) (the-as int (-> first-color a))) + ) ) - (+! (-> s4-0 vector 0 z) -8192) - (+! (-> s4-0 vector 1 z) -8192) - (dma-buffer-add-uint128 v1-28 (-> s1-0 quad 0) - (-> s4-0 quad 0) - (-> s1-0 quad 1) - (-> s4-0 quad 1) - ) + (cond + ((= mode 'fade-depth) + (let ((f0-7 (fminmax (* (1/ #xffffff) (the float (-> s4-0 vector 1 z))) 0.2 1.0))) + (set! (-> s1-0 vector 1 x) (the int (* (the float (-> second-color r)) f0-7))) + (set! (-> s1-0 vector 1 y) (the int (* (the float (-> second-color g)) f0-7))) + (set! (-> s1-0 vector 1 z) (the int (* (the float (-> second-color b)) f0-7))) + ) + (set! (-> s1-0 vector 1 w) (the-as int (-> second-color a))) + ) + (else + (set! (-> s1-0 vector 1 x) (the-as int (-> second-color r))) + (set! (-> s1-0 vector 1 y) (the-as int (-> second-color g))) + (set! (-> s1-0 vector 1 z) (the-as int (-> second-color b))) + (set! (-> s1-0 vector 1 w) (the-as int (-> second-color a))) ) ) + (+! (-> s4-0 vector 0 z) -8192) + (+! (-> s4-0 vector 1 z) -8192) + (dma-buffer-add-uint128 v1-28 (-> s1-0 quad 0) + (-> s4-0 quad 0) + (-> s1-0 quad 1) + (-> s4-0 quad 1) + ) ) ) + ) ) ) + -(defun-debug internal-draw-debug-text-3d ((arg0 bucket-id) (arg1 string) (arg2 vector) (arg3 rgba) (arg4 vector2h)) +(defun-debug internal-draw-debug-text-3d ((bucket bucket-id) (str string) (location vector) (font-color-id font-color) (offset vector2h)) + "Draw text at the given location (in 3D), with a 2D offset." (let ((s2-0 (new 'stack-no-clear 'vector4w))) (set! (-> s2-0 quad) (the-as uint128 0)) - (when (transform-point-qword! (the-as vector4w s2-0) arg2) - - (with-dma-buffer-add-bucket ((s3-0 (current-display-frame debug-buf)) (current-display-frame bucket-group) arg0) - + (when (transform-point-qword! (the-as vector4w s2-0) location) + + (with-dma-buffer-add-bucket ((s3-0 (current-display-frame debug-buf)) (current-display-frame bucket-group) bucket) + (let ((a2-2 (new 'stack 'font-context *font-default-matrix* - (+ (+ (-> arg4 x) -1792) (/ (-> s2-0 x) 16)) - (- (+ (+ (-> arg4 y) -8) (/ (-> s2-0 y) 16)) - (-> *video-parms* screen-miny) - ) - 0.0 - (the-as int arg3) - (the-as uint 3) - ))) + (+ (+ (-> offset x) -1792) (/ (-> s2-0 x) 16)) + (- (+ (+ (-> offset y) -8) (/ (-> s2-0 y) 16)) + (-> *video-parms* screen-miny) + ) + 0.0 + font-color-id + (the-as uint 3) + ))) (let ((v1-9 a2-2)) (set! (-> v1-9 origin z) (the float (/ (-> s2-0 z) 16))) ) - (draw-string arg1 s3-0 a2-2) + (draw-string str s3-0 a2-2) ) ) ) ) ) -(defun-debug add-debug-outline-triangle ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 vector) (arg5 rgba)) - (when arg0 - (add-debug-line #t arg1 arg2 arg3 arg5 #f (the-as rgba -1)) - (add-debug-line #t arg1 arg3 arg4 arg5 #f (the-as rgba -1)) - (add-debug-line #t arg1 arg4 arg2 arg5 #f (the-as rgba -1)) +(defun-debug add-debug-outline-triangle ((enable symbol) (bucket bucket-id) (p0 vector) (p1 vector) (p2 vector) (color rgba)) + "Draw outline of a triangle using lines." + (when enable + (add-debug-line #t bucket p0 p1 color #f (the-as rgba -1)) + (add-debug-line #t bucket p1 p2 color #f (the-as rgba -1)) + (add-debug-line #t bucket p2 p0 color #f (the-as rgba -1)) ) #f ) -(defun-debug add-debug-triangle-normal ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 vector) (arg5 rgba)) - - (when arg0 +(defun-debug add-debug-triangle-normal ((enable symbol) (bucket bucket-id) (p0 vector) (p1 vector) (p2 vector) (color rgba)) + "Draw the normal of a triangle, with length of 1 meter." + (when enable (let ((s4-0 (new 'stack-no-clear 'vector)) - (s3-0 (vector-3pt-cross! (new 'stack-no-clear 'vector) arg2 arg3 arg4)) + (s3-0 (vector-3pt-cross! (new 'stack-no-clear 'vector) p0 p1 p2)) ) (vector-float/! s3-0 s3-0 (* (1/ METER_LENGTH) (vector-length s3-0))) - (vector+! s4-0 arg2 arg3) - (vector+! s4-0 s4-0 arg4) + (vector+! s4-0 p0 p1) + (vector+! s4-0 s4-0 p2) (vector-float/! s4-0 s4-0 3.0) (vector+! s3-0 s3-0 s4-0) - (add-debug-line #t arg1 s4-0 s3-0 arg5 #f (the-as rgba -1)) + (add-debug-line #t bucket s4-0 s3-0 color #f (the-as rgba -1)) ) ) #f ) -(defun-debug add-debug-flat-triangle ((enable-draw symbol) (bucket bucket-id) (p0 vector) (p1 vector) (p2 vector) (arg5 rgba)) +(defun-debug add-debug-flat-triangle ((enable-draw symbol) (bucket bucket-id) (p0 vector) (p1 vector) (p2 vector) (color rgba)) + "Draw a triangle with flat shading" (if (not enable-draw) (return #f) ) @@ -273,10 +274,10 @@ (dma-buffer-add-gif-tag v1-9 (new 'static 'gif-tag64 :nloop 1 :eop 1 :pre 1 :nreg 6 :prim (gif-prim tri)) (gs-reg-list rgbaq xyzf2 rgbaq xyzf2 rgbaq xyzf2) ) - (set! (-> s4-0 vector 0 x) (the-as int (-> arg5 r))) - (set! (-> s4-0 vector 0 y) (the-as int (-> arg5 g))) - (set! (-> s4-0 vector 0 z) (the-as int (-> arg5 b))) - (set! (-> s4-0 vector 0 w) (the-as int (-> arg5 a))) + (set! (-> s4-0 vector 0 x) (the-as int (-> color r))) + (set! (-> s4-0 vector 0 y) (the-as int (-> color g))) + (set! (-> s4-0 vector 0 z) (the-as int (-> color b))) + (set! (-> s4-0 vector 0 w) (the-as int (-> color a))) (set! (-> s5-0 vector 0 z) (+ (-> s5-0 vector 0 z) -8192)) (set! (-> s5-0 vector 1 z) (+ (-> s5-0 vector 1 z) -8192)) (set! (-> s5-0 vector 2 z) (+ (-> s5-0 vector 2 z) -8192)) @@ -294,6 +295,16 @@ #f ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Buffered debug draw +;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Some of the debug draw stuff just adds a line to a list of lines to draw. +;; This is used when pausing - the actual calls to debug-draw-line won't happen, but +;; we won't clear the debug draw buffer so they will still be drawn. + + (when *debug-segment* (deftype debug-line (structure) @@ -314,7 +325,7 @@ ((flags int32 :offset-assert 0) (bucket bucket-id :offset-assert 4) (pos vector :inline :offset-assert 16) - (color uint64 :offset-assert 32) + (color font-color :offset-assert 32) (offset vector2h :inline :offset-assert 40) (str string :offset-assert 44) ) @@ -332,20 +343,22 @@ :flag-assert #x90000000c ) - (define *debug-lines* (the (inline-array debug-line) (malloc 'debug #x100000))) - (define *debug-lines-trk* (new 'debug 'debug-tracking-thang)) - (set! (-> *debug-lines-trk* allocated-length) 16384) +;; allocate debug draw buffers +(define *debug-lines* (the (inline-array debug-line) (malloc 'debug #x100000))) +(define *debug-lines-trk* (new 'debug 'debug-tracking-thang)) +(set! (-> *debug-lines-trk* allocated-length) 16384) +(define *debug-text-3ds* (the (inline-array debug-text-3d) (malloc 'debug #x6000))) +(define *debug-text-3d-trk* (new 'debug 'debug-tracking-thang)) +(set! (-> *debug-text-3d-trk* allocated-length) 512) - (define *debug-text-3ds* (the (inline-array debug-text-3d) (malloc 'debug #x6000))) - (define *debug-text-3d-trk* (new 'debug 'debug-tracking-thang)) - (set! (-> *debug-text-3d-trk* allocated-length) 512) - - (dotimes (i (-> *debug-text-3d-trk* allocated-length)) - (set! (-> *debug-text-3ds* i str) (new 'debug 'string 80 (the string #f))) - ) +(dotimes (i (-> *debug-text-3d-trk* allocated-length)) + (set! (-> *debug-text-3ds* i str) (new 'debug 'string 80 (the string #f))) ) +) + (defun-debug get-debug-line () + "Allocate a debug-line from the list." (cond ((< (-> *debug-lines-trk* length) (-> *debug-lines-trk* allocated-length)) (+! (-> *debug-lines-trk* length) 1) @@ -358,6 +371,7 @@ ) (defun-debug get-debug-text-3d () + "Allocate a debug text 3d from the list." (cond ((< (-> *debug-text-3d-trk* length) (-> *debug-text-3d-trk* allocated-length)) (+! (-> *debug-text-3d-trk* length) 1) @@ -370,6 +384,7 @@ ) (defun-debug debug-reset-buffers () + "Clear all allocated debug things" (set! (-> *debug-lines-trk* length) 0) (set! (-> *debug-text-3d-trk* length) 0) (set! *debug-draw-pauseable* #f) @@ -377,6 +392,7 @@ ) (defun-debug debug-draw-buffers () + "Draw all debug lines and debug text." (dotimes (gp-0 (-> *debug-lines-trk* length)) (let ((v1-1 (-> *debug-lines* gp-0))) (internal-draw-debug-line @@ -395,7 +411,7 @@ (-> v1-8 bucket) (-> v1-8 str) (-> v1-8 pos) - (the-as rgba (-> v1-8 color)) + (-> v1-8 color) (-> v1-8 offset) ) ) @@ -403,23 +419,24 @@ #f ) -(defun-debug add-debug-line ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 rgba) (arg5 symbol) (arg6 rgba)) - (when arg0 +(defun-debug add-debug-line ((enable-draw symbol) (bucket bucket-id) (p0 vector) (p1 vector) (color rgba) (mode symbol) (color2 rgba)) + "Draw a debug line between p0 and p1, in 3D." + (when enable-draw (cond (*debug-draw-pauseable* (let ((v1-2 (get-debug-line))) (when v1-2 - (set! (-> v1-2 bucket) arg1) - (set! (-> v1-2 v1 quad) (-> arg2 quad)) - (set! (-> v1-2 v2 quad) (-> arg3 quad)) - (set! (-> v1-2 color) arg4) - (set! (-> v1-2 color2) arg6) - (set! (-> v1-2 mode) arg5) + (set! (-> v1-2 bucket) bucket) + (set! (-> v1-2 v1 quad) (-> p0 quad)) + (set! (-> v1-2 v2 quad) (-> p1 quad)) + (set! (-> v1-2 color) color) + (set! (-> v1-2 color2) color2) + (set! (-> v1-2 mode) mode) ) ) ) (else - (internal-draw-debug-line arg1 arg2 arg3 arg4 arg5 arg6) + (internal-draw-debug-line bucket p0 p1 color mode color2) ) ) ) @@ -427,6 +444,7 @@ ) (defun-debug add-debug-line2d ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 vector)) + "Draw a line in screen coordinates" (if (not arg0) (return #f) ) @@ -461,6 +479,7 @@ ) (defun-debug add-debug-box ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 rgba)) + "Draw an axis-aligned box" (let ((s5-0 (new-stack-vector0))) (set! (-> s5-0 quad) (-> arg2 quad)) (let ((s1-0 (new-stack-vector0))) @@ -509,6 +528,7 @@ ) (defun-debug add-debug-x ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 rgba)) + "Draw an X in the xz plane" (if (not arg0) (return #f) ) @@ -525,7 +545,8 @@ #f ) -(defun-debug add-debug-text-3d ((arg0 symbol) (arg1 bucket-id) (arg2 string) (arg3 vector) (arg4 rgba) (arg5 vector2h)) +(defun-debug add-debug-text-3d ((arg0 symbol) (arg1 bucket-id) (arg2 string) (arg3 vector) (arg4 font-color) (arg5 vector2h)) + "Draw text at the given point. arg4 is the font-color index. arg5 is an offset and can be #f." (when arg0 (cond (*debug-draw-pauseable* @@ -545,7 +566,7 @@ 0 ) ) - (set! (-> v1-2 color) (the-as uint arg4)) + (set! (-> v1-2 color) arg4) (let ((a0-6 0) (a1-2 (-> arg2 data)) (v1-4 (-> v1-2 str data)) @@ -574,7 +595,9 @@ #f ) -(defun-debug add-debug-sphere-with-transform ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 float) (arg4 matrix) (arg5 rgba)) +(defun-debug add-debug-sphere-with-transform ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 meters) (arg4 matrix) (arg5 rgba)) + "Transform the given point by the given transform, then draw a debug sphere there. The orientation of the debug sphere itself + is not changed by the transform, just its origin." (rlet ((acc :class vf) (vf0 :class vf) (vf1 :class vf) @@ -603,20 +626,23 @@ ) ) -(defun-debug add-debug-sphere ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 float) (arg4 rgba)) +(defun-debug add-debug-sphere ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 meters) (arg4 rgba)) + "Add a debug sphere at the given point. arg3 is radius." (if arg0 (add-debug-sphere-from-table arg1 arg2 arg3 arg4) ) #f ) -(defun-debug add-debug-text-sphere ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 float) (arg4 string) (arg5 rgba)) +(defun-debug add-debug-text-sphere ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 meters) (arg4 string) (arg5 rgba)) + "Add a debug sphere at the given point, withe some text. The color is for the sphere - the text is color 0." (add-debug-sphere arg0 arg1 arg2 arg3 arg5) - (add-debug-text-3d arg0 arg1 arg4 arg2 (new 'static 'rgba) (the-as vector2h #f)) + (add-debug-text-3d arg0 arg1 arg4 arg2 (font-color default) (the-as vector2h #f)) #f ) (defun-debug add-debug-spheres ((arg0 symbol) (arg1 bucket-id) (arg2 (inline-array vector)) (arg3 int) (arg4 rgba)) + "Add a bunch of spheres. The radius is taken from the w component of the origin." (when arg0 (let ((s4-0 (-> arg2 0))) (countdown (s3-0 arg3) @@ -795,7 +821,7 @@ (if (!= arg5 0.0) (set! (-> sv-96 y) arg5) ) - (add-debug-text-3d #t arg1 (string-format "~d" s0-0) sv-96 (the rgba 1) (the vector2h #f)) + (add-debug-text-3d #t arg1 (string-format "~d" s0-0) sv-96 (font-color white) (the vector2h #f)) (add-debug-x #t arg1 sv-96 (if (= s0-0 arg6) (static-rgba #xff #xff #xff #x80) arg4 diff --git a/goal_src/engine/debug/menu.gc b/goal_src/engine/debug/menu.gc index c962f500e3..c178378b7d 100644 --- a/goal_src/engine/debug/menu.gc +++ b/goal_src/engine/debug/menu.gc @@ -38,7 +38,7 @@ (set! (-> gp-0 root-menu) #f) (set! (-> gp-0 joypad-func) #f) (set! (-> gp-0 joypad-item) #f) - (set! (-> gp-0 font) (new 'debug 'font-context *font-default-matrix* 0 0 0.0 0 (the-as uint 3))) + (set! (-> gp-0 font) (new 'debug 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (the-as uint 3))) gp-0 ) ) @@ -618,9 +618,9 @@ (defun debug-menu-item-submenu-render ((arg0 debug-menu-item-submenu) (arg1 int) (arg2 int) (arg3 int) (arg4 symbol)) (let ((s5-0 (-> arg0 parent context font))) (set-origin! s5-0 arg1 arg2) - (set! (-> s5-0 color) (cond ((zero? arg3) 12) - (arg4 11) - (else 13) + (set! (-> s5-0 color) (cond ((zero? arg3) (font-color dim-white)) + (arg4 (font-color dark-light-blue)) + (else (font-color dim-gray)) )) (with-dma-buffer-add-bucket ((s3-0 (current-display-frame debug-buf)) (current-display-frame bucket-group) @@ -638,17 +638,17 @@ (set! (-> v1-2 color) (cond ((> (-> arg0 hilite-timer) 0) (1-! (-> arg0 hilite-timer)) - 10 + (font-color lighter-blue) ) ((< (-> arg0 hilite-timer) 0) (1+! (-> arg0 hilite-timer)) - 14 + (font-color orange-red-2) ) ((nonzero? arg3) - 13 + (font-color dim-gray) ) (else - 12 + (font-color dim-white) ) ) ) @@ -666,19 +666,19 @@ (set-origin! v1-2 arg1 arg2) (set! (-> v1-2 color) (cond ((= (-> arg0 is-on) 'invalid) - 19 + (font-color flat-dark-purple) ) ((-> arg0 is-on) (if (zero? arg3) - 15 - 16 + (font-color yellow-green) + (font-color dark-green) ) ) ((zero? arg3) - 17 + (font-color another-gray) ) (else - 18 + (font-color dark-dark-green) ) ) ) @@ -697,15 +697,15 @@ (set! (-> s5-0 color) (cond ((zero? arg3) (if (-> arg0 grabbed-joypad-p) - 10 - 12 + (font-color lighter-blue) + (font-color dim-white) ) ) (arg4 - 11 + (font-color dark-light-blue) ) (else - 13 + (font-color dim-gray) ) ) ) @@ -796,8 +796,8 @@ (while (not (null? s1-1)) (when (= s0-1 arg3) (set! (-> arg0 context font color) (if (nonzero? arg4) - 13 - 12 + (font-color dim-gray) + (font-color dim-white) ) ) (set-origin! (-> arg0 context font) s3-1 s2-1) diff --git a/goal_src/engine/game/game-info.gc b/goal_src/engine/game/game-info.gc index ae81eeb8b6..83677382f7 100644 --- a/goal_src/engine/game/game-info.gc +++ b/goal_src/engine/game/game-info.gc @@ -642,7 +642,7 @@ (bucket-id debug-draw1) (-> obj name) (-> obj trans) - (new 'static 'rgba :r #x1) + (font-color white) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) (let ((a3-2 (vector-z-quaternion! (new-stack-vector0) (-> obj quat)))) diff --git a/goal_src/engine/game/main.gc b/goal_src/engine/game/main.gc index d5b00486df..18983ed3ee 100644 --- a/goal_src/engine/game/main.gc +++ b/goal_src/engine/game/main.gc @@ -1146,7 +1146,7 @@ (when *display-deci-count* (let ((s2-1 draw-string-xy)) (format (clear *temp-string*) "~D" *deci-count*) - (s2-1 *temp-string* debug-buf 448 210 0 3) + (s2-1 *temp-string* debug-buf 448 210 (font-color default) 3) ) ) @@ -1183,7 +1183,7 @@ (if (= *master-mode* 'pause) (draw-string-xy (lookup-text! *common-text* (game-text-id pause) #f) - s3-1 256 160 3 39) + s3-1 256 160 (font-color orange-red) 39) ) ;; draw console text on screen @@ -1192,7 +1192,7 @@ s3-1 (the int (-> *font-context* origin x)) a3-8 - 0 + (font-color default) 3 ) ) diff --git a/goal_src/engine/gfx/font-h.gc b/goal_src/engine/gfx/font-h.gc index 8a656a12c8..d8f49ed058 100644 --- a/goal_src/engine/gfx/font-h.gc +++ b/goal_src/engine/gfx/font-h.gc @@ -16,6 +16,45 @@ ;; 16 ;; 32 (use size 24) +(defenum font-color + :type uint64 + (default 0) + (white 1) + (gray 2) + (orange-red 3) + (bright-orange-red 4) + (dark-yellow 5) + (bright-green 6) + (dark-blue 7) + (light-blue 8) + (dark-pink 9) + (lighter-blue 10) + (dark-light-blue 11) + (dim-white 12) + (dim-gray 13) + (orange-red-2 14) + (yellow-green 15) + (dark-green 16) + (another-gray 17) + (dark-dark-green 18) + (flat-dark-purple 19) + (yellow 20) + (blue-white 21) + (flat-dark-gray 22) + (flat-gray 23) + (flat-pink 24) + (flat-red 25) + (flat-green 26) + (flat-purple 27) + (lighter-lighter-blue 28) + (yellow-orange 29) + (yellow-green-2 30) + (another-light-blue 31) + (another-default 32) + (red-orange 33) + (another-orange-red 34) + ) + (deftype char-verts (structure) ((pos vector 4 :inline :offset-assert 0) (color vector 4 :inline :offset-assert 64) @@ -51,7 +90,7 @@ (height float :offset-assert 52) (projection float :offset-assert 56) (context-vec vector :inline :offset 48) ;; added - (color int64 :offset-assert 64) + (color font-color :offset-assert 64) (color-s32 int32 :offset 64) ;; added for asm (flags uint32 :offset-assert 72) (flags-signed int32 :offset 72) ;; added for asm @@ -63,7 +102,7 @@ :size-assert #x58 :flag-assert #x1400000058 (:methods - (new (symbol type matrix int int float int uint) _type_ 0) + (new (symbol type matrix int int float font-color uint) _type_ 0) (set-mat! (font-context matrix) font-context 9) (set-origin! (font-context int int) font-context 10) (set-depth! (font-context int) font-context 11) @@ -71,7 +110,7 @@ (set-width! (font-context int) font-context 13) (set-height! (font-context int) font-context 14) (set-projection! (font-context float) font-context 15) - (set-color! (font-context int) font-context 16) + (set-color! (font-context font-color) font-context 16) (set-flags! (font-context uint) font-context 17) (set-start-line! (font-context uint) font-context 18) (set-scale! (font-context float) font-context 19) @@ -130,7 +169,7 @@ obj ) -(defmethod set-color! font-context ((obj font-context) (color int)) +(defmethod set-color! font-context ((obj font-context) (color font-color)) (declare (inline)) (set! (-> obj color) color) @@ -158,18 +197,7 @@ obj ) -(defmethod - new - font-context - ((allocation symbol) - (type-to-make type) - (mat matrix) - (x int) - (y int) - (z float) - (color int) - (flags uint) - ) +(defmethod new font-context ((allocation symbol) (type-to-make type) (mat matrix) (x int) (y int) (z float) (color font-color) (flags uint)) (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))) @@ -245,9 +273,9 @@ (justify vector 64 :inline :offset-assert 944) (color-shadow vector4w :inline :offset-assert 1968) (color-table char-color 64 :inline :offset-assert 1984) - (last-color uint64 :offset-assert 3008) + (last-color font-color :offset-assert 3008) (last-color-32 int32 :offset 3008) - (save-last-color uint64 :offset-assert 3016) + (save-last-color font-color :offset-assert 3016) (save-last-color-32 int32 :offset 3016) ;; added (buf basic :offset-assert 3024) (str-ptr uint32 :offset-assert 3028) @@ -722,4 +750,4 @@ (define-extern draw-string (function string dma-buffer font-context float)) - +(define-extern draw-string-xy (function string dma-buffer int int font-color int none)) \ No newline at end of file diff --git a/goal_src/engine/gfx/font.gc b/goal_src/engine/gfx/font.gc index e3c7f1a155..4969f9ae64 100644 --- a/goal_src/engine/gfx/font.gc +++ b/goal_src/engine/gfx/font.gc @@ -2231,7 +2231,7 @@ ) ) -(defun draw-string-xy ((arg0 string) (arg1 dma-buffer) (arg2 int) (arg3 int) (arg4 int) (arg5 int)) +(defun draw-string-xy ((arg0 string) (arg1 dma-buffer) (arg2 int) (arg3 int) (arg4 font-color) (arg5 int)) ;(format #t "call to ds: ~A~%" arg0) (let ((a2-2 (new 'stack 'font-context *font-default-matrix* diff --git a/goal_src/engine/gfx/hw/display.gc b/goal_src/engine/gfx/hw/display.gc index 304a1cae51..62e59dd448 100644 --- a/goal_src/engine/gfx/hw/display.gc +++ b/goal_src/engine/gfx/hw/display.gc @@ -5,8 +5,6 @@ ;; name in dgo: display ;; dgos: GAME, ENGINE -;; todo - move to font-h -(define-extern draw-string-xy (function string dma-buffer int int int int none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; TIME @@ -282,8 +280,8 @@ ) -(define *font-context* (new 'global 'font-context *font-default-matrix* 0 24 0.0 0 (the uint 3))) -(define *pause-context* (new 'global 'font-context *font-default-matrix* 256 170 0.0 3 (the uint 3))) +(define *font-context* (new 'global 'font-context *font-default-matrix* 0 24 0.0 (font-color default) (the uint 3))) +(define *pause-context* (new 'global 'font-context *font-default-matrix* 256 170 0.0 (font-color orange-red) (the uint 3))) @@ -412,7 +410,7 @@ (cond (*profile-ticks* (draw-string-xy (string-format "~5D" (-> worst-time-cache (/ bar-pos 10))) - buf 488 (+ bar-pos 8) 0 17) + buf 488 (+ bar-pos 8) (font-color default) 17) (the float (-> worst-time-cache (/ bar-pos 10))) ) (else @@ -424,7 +422,7 @@ (the float *ticks-per-frame*) ))) (draw-string-xy (string-format "~5,,2f" f30-0) buf 488 (+ bar-pos 8) - (if (>= f30-0 100.0) 3 0) ;; turn red if over 100. + (if (>= f30-0 100.0) (font-color orange-red) (font-color default)) ;; turn red if over 100. 17 ) f30-0 diff --git a/goal_src/engine/nav/path.gc b/goal_src/engine/nav/path.gc index 358bd92232..c456ef50f3 100644 --- a/goal_src/engine/nav/path.gc +++ b/goal_src/engine/nav/path.gc @@ -29,7 +29,7 @@ (the-as bucket-id s3-0) *temp-string* (-> obj process root trans) - (new 'static 'rgba :r #x3) + (font-color orange-red) (the-as vector2h #f) ) ) @@ -77,7 +77,7 @@ (the-as bucket-id s1-0) *temp-string* s4-1 - (new 'static 'rgba :r #x4) + (font-color bright-orange-red) (the-as vector2h #f) ) ) @@ -403,7 +403,7 @@ (the-as bucket-id s3-0) *temp-string* (-> obj process root trans) - (new 'static 'rgba :r #x3) + (font-color orange-red) (the-as vector2h #f) ) ) @@ -449,7 +449,7 @@ (the-as bucket-id s1-0) *temp-string* s4-1 - (new 'static 'rgba :r #x4) + (font-color bright-orange-red) (the-as vector2h #f) ) ) diff --git a/goal_src/engine/ps2/memcard-h.gc b/goal_src/engine/ps2/memcard-h.gc index 5c5e0aa924..90c6518773 100644 --- a/goal_src/engine/ps2/memcard-h.gc +++ b/goal_src/engine/ps2/memcard-h.gc @@ -93,7 +93,7 @@ ) ) ) - (draw-string-xy *temp-string* dma-buf 32 (+ (* 12 slot-idx) 8) 3 1) + (draw-string-xy *temp-string* dma-buf 32 (+ (* 12 slot-idx) 8) (font-color orange-red) 1) ) ) (none) diff --git a/goal_src/engine/sound/gsound.gc b/goal_src/engine/sound/gsound.gc index 76c6b515d5..993bc02200 100644 --- a/goal_src/engine/sound/gsound.gc +++ b/goal_src/engine/sound/gsound.gc @@ -734,12 +734,12 @@ (dotimes (ch 24) (draw-string-xy (if (zero? (-> *sound-iop-info* chinfo ch)) "." "X") - buf (+ (* ch 16) 16) 48 0 1) + buf (+ (* ch 16) 16) 48 (font-color default) 1) ) (dotimes (ch 24) (draw-string-xy (if (zero? (-> *sound-iop-info* chinfo (+ ch 24))) "." "X") - buf (+ (* ch 16) 16) 64 0 1) + buf (+ (* ch 16) 16) 64 (font-color default) 1) ) 0 ) @@ -748,11 +748,11 @@ (draw-string-xy (string-format "~8D [~4D]" (-> *sound-iop-info* freemem) (shr (-> *sound-iop-info* freemem) 10)) - buf 32 96 0 1) + buf 32 96 (font-color default) 1) (draw-string-xy (string-format "~8D [~4D]" (-> *sound-iop-info* freemem2) (shr (-> *sound-iop-info* freemem2) 10)) - buf 32 64 0 1) + buf 32 64 (font-color default) 1) 0 ) diff --git a/goal_src/engine/ui/credits.gc b/goal_src/engine/ui/credits.gc index 7c9273b128..ce918151ef 100644 --- a/goal_src/engine/ui/credits.gc +++ b/goal_src/engine/ui/credits.gc @@ -59,7 +59,7 @@ 0 0 0.0 - 0 + (font-color default) (the-as uint 3) ) ) @@ -137,7 +137,7 @@ (gp-0 2815) (s3-0 0) (s2-0 #t) - (s5-0 (new 'stack 'font-context *font-default-matrix* 31 0 0.0 0 (the-as uint 3))) + (s5-0 (new 'stack 'font-context *font-default-matrix* 31 0 0.0 (font-color default) (the-as uint 3))) ) (let ((v1-2 s5-0)) (set! (-> v1-2 width) (the float 450)) diff --git a/goal_src/engine/ui/text.gc b/goal_src/engine/ui/text.gc index 69000a30e6..6b1e19283a 100644 --- a/goal_src/engine/ui/text.gc +++ b/goal_src/engine/ui/text.gc @@ -357,7 +357,7 @@ (none) ) -(defun set-font-color-alpha ((idx int) (alpha int)) +(defun set-font-color-alpha ((idx font-color) (alpha int)) "Set the alpha for a given color index" (set! (-> *font-work* color-table idx color 0 a) alpha) (set! (-> *font-work* color-table idx color 1 a) alpha) @@ -436,7 +436,7 @@ (the int (-> font-ctxt origin x)) (the int (-> font-ctxt origin y)) 0.0 - 0 + (font-color default) (the-as uint 3) ) ) @@ -603,7 +603,7 @@ (set-font-color-alpha (-> font-ctxt color) offset-thing) (draw-string *game-text-line* s1-1 gp-0) (set-font-color-alpha (-> font-ctxt color) 128) - (set! (-> gp-0 color) (the-as int (-> *font-work* last-color))) + (set! (-> gp-0 color) (-> *font-work* last-color)) (let ((a3-3 (-> s1-1 base))) (let ((v1-127 (the-as object (-> s1-1 base)))) (set! diff --git a/goal_src/examples/debug-draw-example.gc b/goal_src/examples/debug-draw-example.gc index d5e92e4356..1c045dc74c 100644 --- a/goal_src/examples/debug-draw-example.gc +++ b/goal_src/examples/debug-draw-example.gc @@ -14,38 +14,38 @@ "Debugging function to set the camera's position and orientation" ;; update to compute the perspective matrix. (update-math-camera - *math-camera* - (-> *setting-control* current video-mode) - (-> *setting-control* current aspect-ratio) - ) - + *math-camera* + (-> *setting-control* current video-mode) + (-> *setting-control* current aspect-ratio) + ) + ;; copy the input rotation (matrix-copy! (-> *math-camera* inv-camera-rot) inv-rot) ;; inverse of rotation matrix matrix is its transpose (matrix-transpose! (-> *math-camera* camera-rot) (-> *math-camera* inv-camera-rot)) - + ;; fake some value here (set! (-> *math-camera* fov-correction-factor) 1.0) - + ;; do the math (set! (-> *math-camera* trans quad) (-> location quad)) - (let ((cam-temp (-> *math-camera* camera-temp)) + (let ((cam-temp (-> *math-camera* camera-temp)) (cam-rot (-> *math-camera* camera-rot)) (inv-cam-rot (-> *math-camera* inv-camera-rot)) (cam-trans (-> *math-camera* trans)) ) - (let ((rotated-trans (new-stack-vector0))) - (set! (-> rotated-trans x) (- (-> cam-trans x))) - (set! (-> rotated-trans y) (- (-> cam-trans y))) - (set! (-> rotated-trans z) (- (-> cam-trans z))) - (set! (-> rotated-trans w) 1.0) - (vector-matrix*! rotated-trans rotated-trans cam-rot) - (set! (-> cam-rot vector 3 quad) (-> rotated-trans quad)) + (let ((rotated-trans (new-stack-vector0))) + (set! (-> rotated-trans x) (- (-> cam-trans x))) + (set! (-> rotated-trans y) (- (-> cam-trans y))) + (set! (-> rotated-trans z) (- (-> cam-trans z))) + (set! (-> rotated-trans w) 1.0) + (vector-matrix*! rotated-trans rotated-trans cam-rot) + (set! (-> cam-rot vector 3 quad) (-> rotated-trans quad)) + ) + (matrix*! cam-temp cam-rot (-> *math-camera* perspective)) + (set! (-> inv-cam-rot vector 3 quad) (-> cam-trans quad)) ) - (matrix*! cam-temp cam-rot (-> *math-camera* perspective)) - (set! (-> inv-cam-rot vector 3 quad) (-> cam-trans quad)) - ) - + (none) ) @@ -87,7 +87,7 @@ (add-debug-x #t (bucket-id debug-draw0) (new 'static 'vector) (new 'static 'rgba :g #x80 :a #x80)) (add-debug-box #t (bucket-id debug-draw0) p0 p2 (new 'static 'rgba :b #x80 :a #x80)) (add-debug-flat-triangle #t (bucket-id debug-draw0) p0 p1 p2 (new 'static 'rgba :r #x80)) - (add-debug-text-3d #t (bucket-id debug-draw0) "triangle!" p0 (the rgba 1) (the vector2h #f)) + (add-debug-text-3d #t (bucket-id debug-draw0) "triangle!" p0 (font-color yellow-green) (the vector2h #f)) (add-debug-sphere #t (bucket-id debug-draw0) p2 (meters 0.5) (new 'static 'rgba :r #x80)) ) ) diff --git a/scripts/sublime_text/goal.sublime-syntax b/scripts/sublime_text/goal.sublime-syntax index 5c9cd73640..a3cbaab043 100644 --- a/scripts/sublime_text/goal.sublime-syntax +++ b/scripts/sublime_text/goal.sublime-syntax @@ -13,7 +13,7 @@ contexts: scope: keyword.control.goal # Less important keywords - - match: \b(?i:the-as|the|logior|logand|ash|cons|car|cdr|new|break|none|method-of-type|method-of-object|declare|and|not)\b + - match: \b(?i:the-as|the|logior|logand|ash|cons|car|cdr|new|break|none|method-of-type|method-of-object|declare|and|not|suspend|lambda)\b scope: keyword.operator.goal # Definition forms like (def thing value) diff --git a/test/decompiler/reference/engine/debug/debug-h_REF.gc b/test/decompiler/reference/engine/debug/debug-h_REF.gc index 2f88ebf06b..2f72be3c8e 100644 --- a/test/decompiler/reference/engine/debug/debug-h_REF.gc +++ b/test/decompiler/reference/engine/debug/debug-h_REF.gc @@ -57,6 +57,7 @@ ) ;; definition for method 3 of type debug-vertex-stats +;; INFO: this function exists in multiple non-identical object files (defmethod inspect debug-vertex-stats ((obj debug-vertex-stats)) (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) diff --git a/test/decompiler/reference/engine/debug/menu_REF.gc b/test/decompiler/reference/engine/debug/menu_REF.gc index b6ceaa5a53..7a5cb6dcf9 100644 --- a/test/decompiler/reference/engine/debug/menu_REF.gc +++ b/test/decompiler/reference/engine/debug/menu_REF.gc @@ -51,7 +51,16 @@ (set! (-> gp-0 joypad-item) #f) (set! (-> gp-0 font) - (new 'debug 'font-context *font-default-matrix* 0 0 0.0 0 (the-as uint 3)) + (new + 'debug + 'font-context + *font-default-matrix* + 0 + 0 + 0.0 + (font-color default) + (the-as uint 3) + ) ) gp-0 ) @@ -773,8 +782,11 @@ ) (cond ((= s4-0 'menu) - (let ((s4-1 (new 'debug 'debug-menu arg0 s5-1))) - (set! s5-0 (new 'debug 'debug-menu-item-submenu s5-1 s4-1)) + (let ((s4-1 (new 'debug 'debug-menu arg0 (the-as string s5-1)))) + (set! + s5-0 + (new 'debug 'debug-menu-item-submenu (the-as string s5-1) s4-1) + ) (let* ((gp-1 (cdr (cdr arg1))) (a1-3 (car gp-1)) ) @@ -791,7 +803,7 @@ ) ) ((= s4-0 'main-menu) - (set! s5-0 (new 'debug 'debug-menu arg0 s5-1)) + (set! s5-0 (new 'debug 'debug-menu arg0 (the-as string s5-1))) (let* ((gp-2 (cdr (cdr arg1))) (a1-6 (car gp-2)) ) @@ -816,7 +828,7 @@ (new 'debug 'debug-menu-item-flag - s5-1 + (the-as string s5-1) (the-as symbol (car (cdr (cdr arg1)))) (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) ) @@ -825,7 +837,7 @@ (new 'debug 'debug-menu-item-function - s5-1 + (the-as string s5-1) (the-as int (car (cdr (cdr arg1)))) (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) ) @@ -834,7 +846,7 @@ (new 'debug 'debug-menu-item-var - s5-1 + (the-as string s5-1) (the-as int (car (cdr (cdr arg1)))) (the-as int (car (cdr (cdr (cdr arg1))))) ) @@ -849,7 +861,7 @@ (new 'debug 'debug-menu-item-var - s5-1 + (the-as string s5-1) (the-as int (car (cdr (cdr arg1)))) (the-as int (ref arg1 4)) ) @@ -886,7 +898,7 @@ (new 'debug 'debug-menu-item-var - s5-1 + (the-as string s5-1) (the-as int (car (cdr (cdr arg1)))) (the-as int (ref arg1 4)) ) @@ -921,7 +933,7 @@ (new 'debug 'debug-menu-item-var - s5-1 + (the-as string s5-1) (the-as int (car (cdr (cdr arg1)))) (the-as int (ref arg1 4)) ) @@ -1025,16 +1037,17 @@ (set! (-> v1-2 origin x) (the float arg1)) (set! (-> v1-2 origin y) (the float a0-1)) ) - (set! (-> s5-0 color) (cond - ((zero? arg3) - 12 - ) - (arg4 - 11 - ) - (else - 13 - ) + (set! (-> s5-0 color) (the-as font-color (cond + ((zero? arg3) + 12 + ) + (arg4 + 11 + ) + (else + 13 + ) + ) ) ) (let* ((s3-0 (-> *display* frames (-> *display* on-screen) frame debug-buf)) @@ -1080,21 +1093,22 @@ (set! (-> a0-1 origin x) (the float arg1)) (set! (-> a0-1 origin y) (the float a1-1)) ) - (set! (-> v1-2 color) (cond - ((> (-> arg0 hilite-timer) 0) - (+! (-> arg0 hilite-timer) -1) - 10 - ) - ((< (-> arg0 hilite-timer) 0) - (+! (-> arg0 hilite-timer) 1) - 14 - ) - ((nonzero? arg3) - 13 - ) - (else - 12 - ) + (set! (-> v1-2 color) (the-as font-color (cond + ((> (-> arg0 hilite-timer) 0) + (+! (-> arg0 hilite-timer) -1) + 10 + ) + ((< (-> arg0 hilite-timer) 0) + (+! (-> arg0 hilite-timer) 1) + 14 + ) + ((nonzero? arg3) + 13 + ) + (else + 12 + ) + ) ) ) (let* ((s4-0 (-> *display* frames (-> *display* on-screen) frame debug-buf)) @@ -1134,22 +1148,23 @@ (set! (-> a0-1 origin x) (the float arg1)) (set! (-> a0-1 origin y) (the float a1-1)) ) - (set! (-> v1-2 color) (cond - ((= (-> arg0 is-on) 'invalid) - 19 - ) - ((-> arg0 is-on) - (if (zero? arg3) - 15 - 16 - ) - ) - ((zero? arg3) - 17 - ) - (else - 18 - ) + (set! (-> v1-2 color) (the-as font-color (cond + ((= (-> arg0 is-on) 'invalid) + 19 + ) + ((-> arg0 is-on) + (if (zero? arg3) + 15 + 16 + ) + ) + ((zero? arg3) + 17 + ) + (else + 18 + ) + ) ) ) (let* ((s4-0 (-> *display* frames (-> *display* on-screen) frame debug-buf)) @@ -1189,19 +1204,20 @@ (set! (-> v1-2 origin x) (the float arg1)) (set! (-> v1-2 origin y) (the float a0-1)) ) - (set! (-> s5-0 color) (cond - ((zero? arg3) - (if (-> arg0 grabbed-joypad-p) - 10 - 12 - ) - ) - (arg4 - 11 - ) - (else - 13 - ) + (set! (-> s5-0 color) (the-as font-color (cond + ((zero? arg3) + (if (-> arg0 grabbed-joypad-p) + 10 + 12 + ) + ) + (arg4 + 11 + ) + (else + 13 + ) + ) ) ) (let* ((s1-0 (-> *display* frames (-> *display* on-screen) frame debug-buf)) @@ -1364,9 +1380,10 @@ ) (while (not (null? s1-1)) (when (= s0-1 arg3) - (set! (-> arg0 context font color) (if (nonzero? arg4) - 13 - 12 + (set! (-> arg0 context font color) (the-as font-color (if (nonzero? arg4) + 13 + 12 + ) ) ) (let ((v1-16 (-> arg0 context font)) diff --git a/test/decompiler/reference/engine/dma/dma-disasm_REF.gc b/test/decompiler/reference/engine/dma/dma-disasm_REF.gc index a51977aa23..3415a03d71 100644 --- a/test/decompiler/reference/engine/dma/dma-disasm_REF.gc +++ b/test/decompiler/reference/engine/dma/dma-disasm_REF.gc @@ -608,7 +608,7 @@ (if (> (-> arg0 spr) 0) (format arg1 " :spr ~d" (-> arg0 spr)) ) - (if (> (the-as uint (-> arg0 irq)) 0) + (if (> (-> arg0 irq) 0) (format arg1 " :irq ~d" (-> arg0 irq)) ) (if (> (-> arg0 pce) 0) diff --git a/test/decompiler/reference/engine/engine/engines_REF.gc b/test/decompiler/reference/engine/engine/engines_REF.gc index 7ba3bd84d8..df4aacdf21 100644 --- a/test/decompiler/reference/engine/engine/engines_REF.gc +++ b/test/decompiler/reference/engine/engine/engines_REF.gc @@ -16,11 +16,9 @@ ;; definition for symbol *camera-engine*, type engine (define *camera-engine* (new 'global 'engine 'camera-eng 128)) -;; failed to figure out what this is: -(if *debug-segment* - (set! *debug-engine* (new 'debug 'engine 'debug 512)) - ) - - - +;; this part is debug only +(when *debug-segment* +;; definition for symbol *debug-engine*, type engine +(define *debug-engine* (new 'debug 'engine 'debug 512)) +) diff --git a/test/decompiler/reference/engine/game/settings_REF.gc b/test/decompiler/reference/engine/game/settings_REF.gc index a05af74d44..ec1ba65a45 100644 --- a/test/decompiler/reference/engine/game/settings_REF.gc +++ b/test/decompiler/reference/engine/game/settings_REF.gc @@ -42,9 +42,12 @@ (zero? (logand (-> *kernel-context* prevent-from-run) (process-mask progress)) ) - (let ((v1-18 (get-process conn)) - (a0-22 *progress-process*) - ) + (let + ((v1-18 + ((method-of-type connection get-process) (the-as connection conn)) + ) + (a0-22 *progress-process*) + ) (= v1-18 (if a0-22 (-> a0-22 0 self) ) diff --git a/test/decompiler/reference/engine/gfx/font-h_REF.gc b/test/decompiler/reference/engine/gfx/font-h_REF.gc index c11b5c388c..4fad551113 100644 --- a/test/decompiler/reference/engine/gfx/font-h_REF.gc +++ b/test/decompiler/reference/engine/gfx/font-h_REF.gc @@ -53,25 +53,25 @@ ;; definition of type font-context (deftype font-context (basic) - ((origin vector :inline :offset-assert 16) - (strip-gif vector :inline :offset-assert 32) - (width float :offset-assert 48) - (height float :offset-assert 52) - (projection float :offset-assert 56) - (context-vec vector :inline :offset 48) - (color int64 :offset-assert 64) - (color-s32 int32 :offset 64) - (flags uint32 :offset-assert 72) - (flags-signed int32 :offset 72) - (mat matrix :offset-assert 76) - (start-line uint32 :offset-assert 80) - (scale float :offset-assert 84) + ((origin vector :inline :offset-assert 16) + (strip-gif vector :inline :offset-assert 32) + (width float :offset-assert 48) + (height float :offset-assert 52) + (projection float :offset-assert 56) + (context-vec vector :inline :offset 48) + (color font-color :offset-assert 64) + (color-s32 int32 :offset 64) + (flags uint32 :offset-assert 72) + (flags-signed int32 :offset 72) + (mat matrix :offset-assert 76) + (start-line uint32 :offset-assert 80) + (scale float :offset-assert 84) ) :method-count-assert 20 :size-assert #x58 :flag-assert #x1400000058 (:methods - (new (symbol type matrix int int float int uint) _type_ 0) + (new (symbol type matrix int int float font-color uint) _type_ 0) (set-mat! (font-context matrix) font-context 9) (set-origin! (font-context int int) font-context 10) (set-depth! (font-context int) font-context 11) @@ -79,7 +79,7 @@ (set-width! (font-context int) font-context 13) (set-height! (font-context int) font-context 14) (set-projection! (font-context float) font-context 15) - (set-color! (font-context int) font-context 16) + (set-color! (font-context font-color) font-context 16) (set-flags! (font-context uint) font-context 17) (set-start-line! (font-context uint) font-context 18) (set-scale! (font-context float) font-context 19) @@ -146,7 +146,7 @@ ) ;; definition for method 16 of type font-context -(defmethod set-color! font-context ((obj font-context) (color int)) +(defmethod set-color! font-context ((obj font-context) (color font-color)) (set! (-> obj color) color) obj ) @@ -179,7 +179,7 @@ (x int) (y int) (z float) - (color int) + (color font-color) (flags uint) ) (let @@ -258,9 +258,9 @@ (justify vector 64 :inline :offset-assert 944) (color-shadow vector4w :inline :offset-assert 1968) (color-table char-color 64 :inline :offset-assert 1984) - (last-color uint64 :offset-assert 3008) + (last-color font-color :offset-assert 3008) (last-color-32 int32 :offset 3008) - (save-last-color uint64 :offset-assert 3016) + (save-last-color font-color :offset-assert 3016) (save-last-color-32 int32 :offset 3016) (buf basic :offset-assert 3024) (str-ptr uint32 :offset-assert 3028) diff --git a/test/decompiler/reference/engine/gfx/generic/generic_REF.gc b/test/decompiler/reference/engine/gfx/generic/generic_REF.gc index 6cf27abe3c..ae59c6a616 100644 --- a/test/decompiler/reference/engine/gfx/generic/generic_REF.gc +++ b/test/decompiler/reference/engine/gfx/generic/generic_REF.gc @@ -93,8 +93,8 @@ (s2-0 (-> s0-0 base)) ) (if (>= s4-0 7) - (generic-init-buf s0-0 1 s5-0) - (generic-init-buf s0-0 1 gp-0) + (generic-init-buf s0-0 1 (the-as gs-zbuf s5-0)) + (generic-init-buf s0-0 1 (the-as gs-zbuf gp-0)) ) (generic-dma-foreground-sink-init s1-0) (let ((a3-0 (-> s0-0 base))) diff --git a/test/decompiler/reference/engine/gfx/hw/display_REF.gc b/test/decompiler/reference/engine/gfx/hw/display_REF.gc index 290c116cbf..bce48f0cec 100644 --- a/test/decompiler/reference/engine/gfx/hw/display_REF.gc +++ b/test/decompiler/reference/engine/gfx/hw/display_REF.gc @@ -259,7 +259,16 @@ ;; definition for symbol *font-context*, type font-context (define *font-context* - (new 'global 'font-context *font-default-matrix* 0 24 0.0 0 (the-as uint 3)) + (new + 'global + 'font-context + *font-default-matrix* + 0 + 24 + 0.0 + (font-color default) + (the-as uint 3) + ) ) ;; definition for symbol *pause-context*, type font-context @@ -272,7 +281,7 @@ 256 170 0.0 - 3 + (font-color orange-red) (the-as uint 3) ) ) @@ -457,7 +466,7 @@ (*profile-ticks* (let ((s3-0 draw-string-xy)) (format (clear *temp-string*) "~5D" (-> worst-time-cache (/ bar-pos 10))) - (s3-0 *temp-string* buf 488 (+ bar-pos 8) 0 17) + (s3-0 *temp-string* buf 488 (+ bar-pos 8) (font-color default) 17) ) (the float (-> worst-time-cache (/ bar-pos 10))) ) @@ -472,10 +481,16 @@ ) (let ((s4-1 draw-string-xy)) (format (clear *temp-string*) "~5,,2f" f30-0) - (s4-1 *temp-string* buf 488 (+ bar-pos 8) (if (>= f30-0 100.0) - 3 - 0 - ) + (s4-1 + *temp-string* + buf + 488 + (+ bar-pos 8) + (the-as font-color (if (>= f30-0 100.0) + 3 + 0 + ) + ) 17 ) ) diff --git a/test/decompiler/reference/engine/gfx/texture_REF.gc b/test/decompiler/reference/engine/gfx/texture_REF.gc index 62b63d4367..2973fb802d 100644 --- a/test/decompiler/reference/engine/gfx/texture_REF.gc +++ b/test/decompiler/reference/engine/gfx/texture_REF.gc @@ -2944,9 +2944,9 @@ (when (and (nonzero? (-> id page)) - (< (the-as uint (-> id page)) (the-as uint (-> *texture-page-dir* length))) + (< (-> id page) (the-as uint (-> *texture-page-dir* length))) ) - (let ((dir-entry (-> *texture-page-dir* entries (the-as uint (-> id page))))) + (let ((dir-entry (-> *texture-page-dir* entries (-> id page)))) (when (not (-> dir-entry page)) (let ((old-alloc-func (-> *texture-pool* allocate-func))) (set! (-> *texture-pool* allocate-func) alloc-func) @@ -3016,14 +3016,10 @@ (not (or (zero? (-> arg0 page)) - (>= - (the-as uint (-> arg0 page)) - (the-as uint (-> *texture-page-dir* length)) - ) + (>= (-> arg0 page) (the-as uint (-> *texture-page-dir* length))) ) ) - (let - ((dir-entry (-> *texture-page-dir* entries (the-as uint (-> arg0 page))))) + (let ((dir-entry (-> *texture-page-dir* entries (-> arg0 page)))) (if (not (-> dir-entry link)) (set! (-> dir-entry link) @@ -3066,12 +3062,12 @@ (let ((link-slot (&-> link-arr 0)) (shader (the-as adgif-shader (* (-> link-arr 0 shader) 16))) ) - (while (nonzero? (the-as int shader)) + (while (nonzero? (the-as uint shader)) (b! - (< (the-as int (- (the-as int shader) (the-as int mem-start))) 0) + (< (the-as int (- (the-as uint shader) (the-as uint mem-start))) 0) cfg-7 :delay - (set! dist-past-end (- (the-as int shader) mem-end)) + (set! dist-past-end (- (the-as uint shader) mem-end)) ) (b! (>= (the-as int dist-past-end) 0) cfg-7 :delay (nop!)) (let ((t4-2 (-> shader next))) @@ -3352,16 +3348,9 @@ (when (and (nonzero? (-> tex-id page)) - (< - (the-as uint (-> tex-id page)) - (the-as uint (-> *texture-page-dir* length)) - ) + (< (-> tex-id page) (the-as uint (-> *texture-page-dir* length))) ) - (let - ((dir-entry - (-> *texture-page-dir* entries (the-as uint (-> tex-id page))) - ) - ) + (let ((dir-entry (-> *texture-page-dir* entries (-> tex-id page)))) (when (and (< (-> tex-id index) (the-as uint (-> dir-entry length))) @@ -3402,12 +3391,9 @@ (when (and (nonzero? (-> v1-4 page)) - (< - (the-as uint (-> v1-4 page)) - (the-as uint (-> *texture-page-dir* length)) - ) + (< (-> v1-4 page) (the-as uint (-> *texture-page-dir* length))) ) - (let ((a1-7 (-> *texture-page-dir* entries (the-as uint (-> v1-4 page))))) + (let ((a1-7 (-> *texture-page-dir* entries (-> v1-4 page)))) (when (and (< (-> v1-4 index) (the-as uint (-> a1-7 length))) (-> a1-7 link)) (set! (-> arg0 next shader) (-> a1-7 link next (-> v1-4 index) shader)) @@ -3539,7 +3525,7 @@ (the-as object (* (-> entry-link next entry-list-length shader) 16)) ) ) - (while (nonzero? (the-as int v1-40)) + (while (nonzero? (the-as uint v1-40)) (nop!) (+! a3-7 1) (set! v1-40 (* (-> (the-as adgif-shader v1-40) next shader) 16)) diff --git a/test/decompiler/reference/engine/nav/navigate-h_REF.gc b/test/decompiler/reference/engine/nav/navigate-h_REF.gc index e298ccdbcf..5764b04240 100644 --- a/test/decompiler/reference/engine/nav/navigate-h_REF.gc +++ b/test/decompiler/reference/engine/nav/navigate-h_REF.gc @@ -557,7 +557,10 @@ ) (set! (-> obj max-spheres) sphere-count) (set! (-> obj flags) (nav-control-flags bit8 bit13)) - (set! (-> obj mesh) (nav-mesh-connect (-> shape process) shape obj)) + (set! + (-> obj mesh) + (nav-mesh-connect (-> shape process) shape (the-as nav-control obj)) + ) (let ((ent (-> shape process entity))) (set! (-> obj nearest-y-threshold) diff --git a/test/decompiler/reference/engine/nav/path_REF.gc b/test/decompiler/reference/engine/nav/path_REF.gc index 7968fe9cbe..52ed8ede33 100644 --- a/test/decompiler/reference/engine/nav/path_REF.gc +++ b/test/decompiler/reference/engine/nav/path_REF.gc @@ -25,7 +25,7 @@ (the-as bucket-id s3-0) *temp-string* (-> obj process root trans) - (new 'static 'rgba :r #x3) + (font-color orange-red) (the-as vector2h #f) ) ) @@ -73,7 +73,7 @@ (the-as bucket-id s1-0) *temp-string* s4-1 - (new 'static 'rgba :r #x4) + (font-color bright-orange-red) (the-as vector2h #f) ) ) @@ -395,7 +395,7 @@ (the-as bucket-id s3-0) *temp-string* (-> obj process root trans) - (new 'static 'rgba :r #x3) + (font-color orange-red) (the-as vector2h #f) ) ) @@ -441,7 +441,7 @@ (the-as bucket-id s1-0) *temp-string* s4-1 - (new 'static 'rgba :r #x4) + (font-color bright-orange-red) (the-as vector2h #f) ) ) diff --git a/test/decompiler/reference/engine/ps2/memcard-h_REF.gc b/test/decompiler/reference/engine/ps2/memcard-h_REF.gc index f8af12dc2f..0719980874 100644 --- a/test/decompiler/reference/engine/ps2/memcard-h_REF.gc +++ b/test/decompiler/reference/engine/ps2/memcard-h_REF.gc @@ -142,7 +142,14 @@ ) ) ) - (draw-string-xy *temp-string* dma-buf 32 (+ (* 12 slot-idx) 8) 3 1) + (draw-string-xy + *temp-string* + dma-buf + 32 + (+ (* 12 slot-idx) 8) + (font-color orange-red) + 1 + ) ) ) 0 diff --git a/test/decompiler/reference/engine/sound/gsound_REF.gc b/test/decompiler/reference/engine/sound/gsound_REF.gc index 6c006b9821..7f918ee495 100644 --- a/test/decompiler/reference/engine/sound/gsound_REF.gc +++ b/test/decompiler/reference/engine/sound/gsound_REF.gc @@ -1021,7 +1021,7 @@ arg0 (+ (* s5-0 16) 16) 48 - 0 + (font-color default) 1 ) ) @@ -1033,7 +1033,7 @@ arg0 (+ (* s5-1 16) 16) 64 - 0 + (font-color default) 1 ) ) @@ -1049,7 +1049,7 @@ (-> *sound-iop-info* freemem) (shr (-> *sound-iop-info* freemem) 10) ) - (s5-0 *temp-string* arg0 32 96 0 1) + (s5-0 *temp-string* arg0 32 96 (font-color default) 1) ) (let ((s5-1 draw-string-xy)) (format @@ -1058,7 +1058,7 @@ (-> *sound-iop-info* freemem2) (shr (-> *sound-iop-info* freemem2) 10) ) - (s5-1 *temp-string* arg0 32 64 0 1) + (s5-1 *temp-string* arg0 32 64 (font-color default) 1) ) 0 ) diff --git a/test/decompiler/reference/engine/ui/credits_REF.gc b/test/decompiler/reference/engine/ui/credits_REF.gc index 62b7490664..a7956d0c2f 100644 --- a/test/decompiler/reference/engine/ui/credits_REF.gc +++ b/test/decompiler/reference/engine/ui/credits_REF.gc @@ -84,7 +84,7 @@ 0 0 0.0 - 0 + (font-color default) (the-as uint 3) ) ) @@ -165,7 +165,16 @@ (s3-0 0) (s2-0 #t) (s5-0 - (new 'stack 'font-context *font-default-matrix* 31 0 0.0 0 (the-as uint 3)) + (new + 'stack + 'font-context + *font-default-matrix* + 31 + 0 + 0.0 + (font-color default) + (the-as uint 3) + ) ) ) (let ((v1-2 s5-0)) diff --git a/test/decompiler/reference/kernel/gkernel_REF.gc b/test/decompiler/reference/kernel/gkernel_REF.gc index 5efeae6b9c..140ba11030 100644 --- a/test/decompiler/reference/kernel/gkernel_REF.gc +++ b/test/decompiler/reference/kernel/gkernel_REF.gc @@ -1884,14 +1884,15 @@ (new 'global 'dead-pool 1 8192 '*camera-master-dead-pool*) ) -;; failed to figure out what this is: -(if *debug-segment* - (set! - *debug-dead-pool* - (new 'debug 'dead-pool-heap '*debug-dead-pool* 768 #x100000) - ) +;; this part is debug only +(when *debug-segment* +;; definition for symbol *debug-dead-pool*, type dead-pool-heap +(define + *debug-dead-pool* + (new 'debug 'dead-pool-heap '*debug-dead-pool* 768 #x100000) ) +) ;; definition for symbol *nk-dead-pool*, type dead-pool-heap (define *nk-dead-pool* (new 'global 'dead-pool-heap '*nk-dead-pool* 768 #xf6000)) From 4b9830538152f90e274c961dc6a9272ebee150ff Mon Sep 17 00:00:00 2001 From: water Date: Sat, 14 Aug 2021 13:06:54 -0400 Subject: [PATCH 6/7] add ref --- .../reference/engine/debug/debug_REF.gc | 1857 +++++++++++++++++ 1 file changed, 1857 insertions(+) create mode 100644 test/decompiler/reference/engine/debug/debug_REF.gc diff --git a/test/decompiler/reference/engine/debug/debug_REF.gc b/test/decompiler/reference/engine/debug/debug_REF.gc new file mode 100644 index 0000000000..2cb4169d05 --- /dev/null +++ b/test/decompiler/reference/engine/debug/debug_REF.gc @@ -0,0 +1,1857 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function transform-float-point +;; WARN: Bad vector register dependency: vf1 +;; WARN: Bad vector register dependency: vf2 +;; WARN: Bad vector register dependency: vf3 +;; WARN: Bad vector register dependency: vf4 +;; WARN: Bad vector register dependency: vf6 +;; WARN: Bad vector register dependency: vf8 +;; WARN: Bad vector register dependency: vf9 +(defun transform-float-point ((arg0 vector) (arg1 vector4w)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :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 vf5 (&-> arg0 quad)) + (.mul.w.vf acc vf4 vf5) + (.add.mul.x.vf acc vf1 vf5 acc) + (.add.mul.y.vf acc vf2 vf5 acc) + (.add.mul.z.vf vf5 vf3 vf5 acc) + (.div.vf Q vf9 vf5 :fsf #b0 :ftf #b11) + (.wait.vf) + (.mul.vf vf5 vf5 Q :mask #b111) + (.add.vf vf5 vf5 vf8) + (.max.x.vf vf5 vf5 vf0 :mask #b1000) + (.min.x.vf vf5 vf5 vf6 :mask #b1000) + (vftoi4.xyzw vf5 vf5) + (.svf (&-> arg1 quad) vf5) + arg1 + ) + ) + +;; definition (debug) for function add-debug-point +;; Used lq/sq +(defun-debug + add-debug-point + ((enable-draw symbol) (bucket bucket-id) (pt vector)) + (if (not enable-draw) + (return #f) + ) + (let ((s5-0 (new 'stack 'vector4w-2))) + (set! (-> pt w) 1.0) + (when (transform-point-qword! (the-as vector4w (-> s5-0 quad)) pt) + (let* ((buf (-> *display* frames (-> *display* on-screen) frame debug-buf)) + (a2-1 (-> buf base)) + ) + (let ((a0-6 (the-as (pointer uint64) (-> buf base)))) + (let* ((a1-3 buf) + (a3-0 (the-as dma-packet (-> a1-3 base))) + ) + (set! (-> a3-0 dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> a3-0 vif0) (new 'static 'vif-tag)) + (set! + (-> a3-0 vif1) + (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1) + ) + (set! (-> a1-3 base) (&+ (the-as pointer a3-0) 16)) + ) + (let* ((a1-4 buf) + (a3-2 (the-as gs-gif-tag (-> a1-4 base))) + ) + (set! + (-> a3-2 tag) + (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :abe #x1) + :nreg #x8 + ) + ) + (set! + (-> a3-2 regs) + (new 'static 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id xyzf2) + :regs2 (gif-reg-id rgbaq) + :regs3 (gif-reg-id xyzf2) + :regs4 (gif-reg-id rgbaq) + :regs5 (gif-reg-id xyzf2) + :regs6 (gif-reg-id rgbaq) + :regs7 (gif-reg-id xyzf2) + ) + ) + (set! (-> a1-4 base) (&+ (the-as pointer a3-2) 16)) + ) + (set! (-> s5-0 vector 1 x) 255) + (set! (-> s5-0 vector 1 y) 128) + (set! (-> s5-0 vector 1 z) 128) + (set! (-> s5-0 vector 1 w) 128) + (+! (-> s5-0 vector 0 y) 160) + (let* ((a1-11 buf) + (a3-4 (the-as vector4w-2 (-> a1-11 base))) + ) + (set! (-> a3-4 quad 0) (-> (&-> s5-0 quad 1) 0)) + (set! (-> a3-4 quad 1) (-> s5-0 quad 0)) + (set! (-> a1-11 base) (&+ (the-as pointer a3-4) 32)) + ) + (+! (-> s5-0 vector 0 x) -256) + (+! (-> s5-0 vector 0 y) -160) + (set! (-> s5-0 vector 1 x) 128) + (set! (-> s5-0 vector 1 y) 255) + (let* ((a1-18 buf) + (a3-6 (the-as vector4w-2 (-> a1-18 base))) + ) + (set! (-> a3-6 quad 0) (-> (&-> s5-0 quad 1) 0)) + (set! (-> a3-6 quad 1) (-> s5-0 quad 0)) + (set! (-> a1-18 base) (&+ (the-as pointer a3-6) 32)) + ) + (+! (-> s5-0 vector 0 x) 512) + (set! (-> s5-0 vector 1 y) 128) + (set! (-> s5-0 vector 1 z) 255) + (let* ((a1-23 buf) + (a3-8 (the-as vector4w-2 (-> a1-23 base))) + ) + (set! (-> a3-8 quad 0) (-> (&-> s5-0 quad 1) 0)) + (set! (-> a3-8 quad 1) (-> s5-0 quad 0)) + (set! (-> a1-23 base) (&+ (the-as pointer a3-8) 32)) + ) + (+! (-> s5-0 vector 0 x) -256) + (+! (-> s5-0 vector 0 y) -160) + (set! (-> s5-0 vector 1 x) 255) + (set! (-> s5-0 vector 1 y) 128) + (let* ((a3-10 buf) + (a1-30 (the-as vector4w-2 (-> a3-10 base))) + ) + (set! (-> a1-30 quad 0) (-> (&-> s5-0 quad 1) 0)) + (set! (-> a1-30 quad 1) (-> s5-0 quad 0)) + (set! (-> a3-10 base) (&+ (the-as pointer a1-30) 32)) + ) + (let + ((a3-14 + (/ + (the-as + int + (+ + (&- (the-as pointer -16) (the-as uint a0-6)) + (the-as int (-> buf base)) + ) + ) + 16 + ) + ) + ) + (cond + ((nonzero? a3-14) + (logior! (-> a0-6 0) (shr (shl a3-14 48) 48)) + (logior! (-> a0-6 1) (shl (shr (shl a3-14 48) 48) 32)) + ) + (else + (set! (-> buf base) a0-6) + ) + ) + ) + ) + (let ((a3-20 (-> buf base))) + (let ((a0-7 (the-as dma-packet (-> buf base)))) + (set! (-> a0-7 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> a0-7 vif0) (new 'static 'vif-tag)) + (set! (-> a0-7 vif1) (new 'static 'vif-tag)) + (set! (-> buf base) (&+ (the-as pointer a0-7) 16)) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) frame bucket-group) + bucket + a2-1 + (the-as (pointer dma-tag) a3-20) + ) + ) + ) + ) + ) + #f + ) + +;; definition (debug) for function internal-draw-debug-line +;; Used lq/sq +(defun-debug + internal-draw-debug-line + ((arg0 bucket-id) + (arg1 vector) + (arg2 vector) + (arg3 rgba) + (arg4 symbol) + (arg5 rgba) + ) + (local-vars (sv-80 vector)) + (set! sv-80 arg2) + (let ((s2-0 arg3) + (s3-0 arg4) + (s5-0 arg5) + ) + (let ((a0-4 (-> *display* frames (-> *display* on-screen) frame debug-buf))) + (if + (< + (the-as + uint + (shr (+ (&- (-> a0-4 end) (the-as uint (-> a0-4 base))) 15) 4) + ) + (the-as uint #x8000) + ) + (return (the-as pointer #f)) + ) + ) + (if + (or + (= s5-0 -1) + (= s5-0 (new 'static 'rgba :r #xff :g #xff :b #xff :a #xff)) + ) + (set! s5-0 s2-0) + ) + (case s3-0 + (('fade) + (set! + s5-0 + (new 'static 'rgba + :r (shr (-> s5-0 r) 1) + :g (shr (-> s5-0 g) 1) + :b (shr (-> s5-0 b) 1) + :a (-> s5-0 a) + ) + ) + ) + ) + (let ((s4-0 (new 'stack 'vector4w-2)) + (s1-0 (new 'stack 'vector4w-2)) + ) + (set! (-> arg1 w) 1.0) + (set! (-> sv-80 w) 1.0) + (when + (and + (transform-point-qword! (the-as vector4w (-> s4-0 quad)) arg1) + (transform-point-qword! (the-as vector4w (&-> s4-0 quad 1)) sv-80) + ) + (let* + ((v1-28 (-> *display* frames (-> *display* on-screen) frame debug-buf)) + (a2-1 (-> v1-28 base)) + ) + (let ((a0-31 (the-as (pointer uint64) (-> v1-28 base)))) + (let* ((a1-5 v1-28) + (a3-1 (the-as dma-packet (-> a1-5 base))) + ) + (set! (-> a3-1 dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> a3-1 vif0) (new 'static 'vif-tag)) + (set! + (-> a3-1 vif1) + (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1) + ) + (set! (-> a1-5 base) (&+ (the-as pointer a3-1) 16)) + ) + (let* ((a1-6 v1-28) + (a3-3 (the-as gs-gif-tag (-> a1-6 base))) + ) + (set! + (-> a3-3 tag) + (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line) :iip #x1 :abe #x1) + :nreg #x4 + ) + ) + (set! + (-> a3-3 regs) + (new 'static 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id xyzf2) + :regs2 (gif-reg-id rgbaq) + :regs3 (gif-reg-id xyzf2) + ) + ) + (set! (-> a1-6 base) (&+ (the-as pointer a3-3) 16)) + ) + (case s3-0 + (('fade-depth) + (let + ((f0-3 + (fmax + 0.2 + (fmin 1.0 (* 0.00000005960465 (the float (-> s4-0 vector 0 z)))) + ) + ) + ) + (set! + (-> s1-0 vector 0 x) + (the int (* (the float (-> s2-0 r)) f0-3)) + ) + (set! + (-> s1-0 vector 0 y) + (the int (* (the float (-> s2-0 g)) f0-3)) + ) + (set! + (-> s1-0 vector 0 z) + (the int (* (the float (-> s2-0 b)) f0-3)) + ) + ) + (set! (-> s1-0 vector 0 w) (the-as int (-> s2-0 a))) + ) + (else + (set! (-> s1-0 vector 0 x) (the-as int (-> s2-0 r))) + (set! (-> s1-0 vector 0 y) (the-as int (-> s2-0 g))) + (set! (-> s1-0 vector 0 z) (the-as int (-> s2-0 b))) + (set! (-> s1-0 vector 0 w) (the-as int (-> s2-0 a))) + ) + ) + (cond + ((= s3-0 'fade-depth) + (let + ((f0-7 + (fmax + 0.2 + (fmin 1.0 (* 0.00000005960465 (the float (-> s4-0 vector 1 z)))) + ) + ) + ) + (set! (-> s1-0 vector 1 x) (the int (* (the float (-> s5-0 r)) f0-7))) + (set! (-> s1-0 vector 1 y) (the int (* (the float (-> s5-0 g)) f0-7))) + (set! (-> s1-0 vector 1 z) (the int (* (the float (-> s5-0 b)) f0-7))) + ) + (set! (-> s1-0 vector 1 w) (the-as int (-> s5-0 a))) + ) + (else + (set! (-> s1-0 vector 1 x) (the-as int (-> s5-0 r))) + (set! (-> s1-0 vector 1 y) (the-as int (-> s5-0 g))) + (set! (-> s1-0 vector 1 z) (the-as int (-> s5-0 b))) + (set! (-> s1-0 vector 1 w) (the-as int (-> s5-0 a))) + ) + ) + (+! (-> s4-0 vector 0 z) -8192) + (+! (-> s4-0 vector 1 z) -8192) + (let* ((a3-6 v1-28) + (a1-43 (the-as (inline-array vector4w-2) (-> a3-6 base))) + ) + (set! (-> a1-43 0 quad 0) (-> s1-0 quad 0)) + (set! (-> a1-43 0 quad 1) (-> s4-0 quad 0)) + (set! (-> a1-43 1 quad 0) (-> (&-> s1-0 quad 1) 0)) + (set! (-> a1-43 1 quad 1) (-> (&-> s4-0 quad 1) 0)) + (set! (-> a3-6 base) (&+ (the-as pointer a1-43) 64)) + ) + (let + ((a3-10 + (/ + (the-as + int + (+ + (&- (the-as pointer -16) (the-as uint a0-31)) + (the-as int (-> v1-28 base)) + ) + ) + 16 + ) + ) + ) + (cond + ((nonzero? a3-10) + (logior! (-> a0-31 0) (shr (shl a3-10 48) 48)) + (logior! (-> a0-31 1) (shl (shr (shl a3-10 48) 48) 32)) + ) + (else + (set! (-> v1-28 base) a0-31) + ) + ) + ) + ) + (let ((a3-16 (-> v1-28 base))) + (let ((a0-32 (the-as dma-packet (-> v1-28 base)))) + (set! (-> a0-32 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> a0-32 vif0) (new 'static 'vif-tag)) + (set! (-> a0-32 vif1) (new 'static 'vif-tag)) + (set! (-> v1-28 base) (&+ (the-as pointer a0-32) 16)) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) frame bucket-group) + arg0 + a2-1 + (the-as (pointer dma-tag) a3-16) + ) + ) + ) + ) + ) + ) + ) + +;; definition (debug) for function internal-draw-debug-text-3d +;; Used lq/sq +(defun-debug + internal-draw-debug-text-3d + ((arg0 bucket-id) + (arg1 string) + (arg2 vector) + (arg3 font-color) + (arg4 vector2h) + ) + (let ((s2-0 (new 'stack-no-clear 'vector4w))) + (set! (-> s2-0 quad) (the-as uint128 0)) + (when (transform-point-qword! s2-0 arg2) + (let* ((s3-0 (-> *display* frames (-> *display* on-screen) frame debug-buf)) + (s5-0 (-> s3-0 base)) + ) + (let + ((a2-2 + (new + 'stack + 'font-context + *font-default-matrix* + (+ (-> arg4 x) -1792 (/ (-> s2-0 x) 16)) + (- + (+ (-> arg4 y) -8 (/ (-> s2-0 y) 16)) + (-> *video-parms* screen-miny) + ) + 0.0 + arg3 + (the-as uint 3) + ) + ) + ) + (let ((v1-9 a2-2)) + (set! (-> v1-9 origin z) (the float (/ (-> s2-0 z) 16))) + ) + (draw-string arg1 s3-0 a2-2) + ) + (let ((a3-4 (-> s3-0 base))) + (let ((v1-11 (the-as dma-packet (-> s3-0 base)))) + (set! (-> v1-11 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> v1-11 vif0) (new 'static 'vif-tag)) + (set! (-> v1-11 vif1) (new 'static 'vif-tag)) + (set! (-> s3-0 base) (&+ (the-as pointer v1-11) 16)) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) frame bucket-group) + arg0 + s5-0 + (the-as (pointer dma-tag) a3-4) + ) + ) + ) + ) + ) + ) + +;; definition (debug) for function add-debug-outline-triangle +(defun-debug + add-debug-outline-triangle + ((enable symbol) + (bucket bucket-id) + (p0 vector) + (p1 vector) + (p2 vector) + (color rgba) + ) + (when enable + (add-debug-line #t bucket p0 p1 color #f (the-as rgba -1)) + (add-debug-line #t bucket p1 p2 color #f (the-as rgba -1)) + (add-debug-line #t bucket p2 p0 color #f (the-as rgba -1)) + ) + #f + ) + +;; definition (debug) for function add-debug-triangle-normal +;; Used lq/sq +(defun-debug + add-debug-triangle-normal + ((arg0 symbol) + (arg1 bucket-id) + (arg2 vector) + (arg3 vector) + (arg4 vector) + (arg5 rgba) + ) + (local-vars + (sv-48 (function vector vector float vector)) + (sv-64 vector) + (sv-80 vector) + ) + (when arg0 + (let ((s4-0 (new 'stack-no-clear 'vector)) + (s3-0 (vector-3pt-cross! (new 'stack-no-clear 'vector) arg2 arg3 arg4)) + ) + (set! sv-48 vector-float/!) + (set! sv-64 s3-0) + (set! sv-80 s3-0) + (let ((a2-2 (* 0.00024414062 (vector-length s3-0)))) + (sv-48 sv-64 sv-80 a2-2) + ) + (vector+! s4-0 arg2 arg3) + (vector+! s4-0 s4-0 arg4) + (vector-float/! s4-0 s4-0 3.0) + (vector+! s3-0 s3-0 s4-0) + (add-debug-line #t arg1 s4-0 s3-0 arg5 #f (the-as rgba -1)) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-flat-triangle +;; Used lq/sq +(defun-debug + add-debug-flat-triangle + ((arg0 symbol) + (arg1 bucket-id) + (arg2 vector) + (arg3 vector) + (arg4 vector) + (arg5 rgba) + ) + (if (not arg0) + (return #f) + ) + (let ((s5-0 (new 'stack 'vector4w-3)) + (s4-0 (new 'stack 'vector4w-3)) + ) + (set! (-> arg2 w) 1.0) + (set! (-> arg3 w) 1.0) + (set! (-> arg4 w) 1.0) + (when + (and + (transform-point-qword! (the-as vector4w (-> s5-0 quad)) arg2) + (transform-point-qword! (the-as vector4w (&-> s5-0 quad 1)) arg3) + (transform-point-qword! (the-as vector4w (&-> s5-0 quad 2)) arg4) + ) + (let* ((v1-9 (-> *display* frames (-> *display* on-screen) frame debug-buf)) + (a2-1 (-> v1-9 base)) + ) + (let ((a0-9 (the-as (pointer uint64) (-> v1-9 base)))) + (let* ((a1-6 v1-9) + (a3-1 (the-as dma-packet (-> a1-6 base))) + ) + (set! (-> a3-1 dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> a3-1 vif0) (new 'static 'vif-tag)) + (set! + (-> a3-1 vif1) + (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1) + ) + (set! (-> a1-6 base) (&+ (the-as pointer a3-1) 16)) + ) + (let* ((a1-7 v1-9) + (a3-3 (the-as gs-gif-tag (-> a1-7 base))) + ) + (set! + (-> a3-3 tag) + (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri) :iip #x1 :abe #x1) + :nreg #x6 + ) + ) + (set! + (-> a3-3 regs) + (new 'static 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id xyzf2) + :regs2 (gif-reg-id rgbaq) + :regs3 (gif-reg-id xyzf2) + :regs4 (gif-reg-id rgbaq) + :regs5 (gif-reg-id xyzf2) + ) + ) + (set! (-> a1-7 base) (&+ (the-as pointer a3-3) 16)) + ) + (set! (-> s4-0 vector 0 x) (the-as int (-> arg5 r))) + (set! (-> s4-0 vector 0 y) (the-as int (-> arg5 g))) + (set! (-> s4-0 vector 0 z) (the-as int (-> arg5 b))) + (set! (-> s4-0 vector 0 w) (the-as int (-> arg5 a))) + (+! (-> s5-0 vector 0 z) -8192) + (+! (-> s5-0 vector 1 z) -8192) + (+! (-> s5-0 vector 2 z) -8192) + (let* ((a1-21 v1-9) + (a3-5 (the-as (inline-array vector4w-3) (-> a1-21 base))) + ) + (set! (-> a3-5 0 quad 0) (-> s4-0 quad 0)) + (set! (-> a3-5 0 quad 1) (-> s5-0 quad 0)) + (set! (-> a3-5 0 quad 2) (-> s4-0 quad 0)) + (set! (-> a3-5 1 quad 0) (-> (&-> s5-0 quad 1) 0)) + (set! (-> a3-5 1 quad 1) (-> s4-0 quad 0)) + (set! (-> a3-5 1 quad 2) (-> (&-> s5-0 quad 2) 0)) + (set! (-> a1-21 base) (&+ (the-as pointer a3-5) 96)) + ) + (let + ((a1-25 + (/ + (the-as + int + (+ + (&- (the-as pointer -16) (the-as uint a0-9)) + (the-as int (-> v1-9 base)) + ) + ) + 16 + ) + ) + ) + (cond + ((nonzero? a1-25) + (logior! (-> a0-9 0) (shr (shl a1-25 48) 48)) + (logior! (-> a0-9 1) (shl (shr (shl a1-25 48) 48) 32)) + ) + (else + (set! (-> v1-9 base) a0-9) + ) + ) + ) + ) + (let ((a3-7 (-> v1-9 base))) + (let ((a0-10 (the-as dma-packet (-> v1-9 base)))) + (set! (-> a0-10 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> a0-10 vif0) (new 'static 'vif-tag)) + (set! (-> a0-10 vif1) (new 'static 'vif-tag)) + (set! (-> v1-9 base) (&+ (the-as pointer a0-10) 16)) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) frame bucket-group) + arg1 + a2-1 + (the-as (pointer dma-tag) a3-7) + ) + ) + ) + ) + ) + #f + ) + +;; this part is debug only +(when *debug-segment* +;; definition of type debug-line +(deftype debug-line (structure) + ((flags int32 :offset-assert 0) + (bucket bucket-id :offset-assert 4) + (v1 vector :inline :offset-assert 16) + (v2 vector :inline :offset-assert 32) + (color rgba :offset-assert 48) + (mode symbol :offset-assert 52) + (color2 rgba :offset-assert 56) + ) + :method-count-assert 9 + :size-assert #x3c + :flag-assert #x90000003c + ) + +;; definition for method 3 of type debug-line +(defmethod inspect debug-line ((obj debug-line)) + (format #t "[~8x] ~A~%" obj 'debug-line) + (format #t "~Tflags: ~D~%" (-> obj flags)) + (format #t "~Tbucket: ~D~%" (-> obj bucket)) + (format #t "~Tv1: #~%" (-> obj v1)) + (format #t "~Tv2: #~%" (-> obj v2)) + (format #t "~Tcolor: ~D~%" (-> obj color)) + (format #t "~Tmode: ~A~%" (-> obj mode)) + (format #t "~Tcolor2: ~D~%" (-> obj color2)) + obj + ) + +;; definition of type debug-text-3d +(deftype debug-text-3d (structure) + ((flags int32 :offset-assert 0) + (bucket bucket-id :offset-assert 4) + (pos vector :inline :offset-assert 16) + (color font-color :offset-assert 32) + (offset vector2h :inline :offset-assert 40) + (str string :offset-assert 44) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +;; definition for method 3 of type debug-text-3d +(defmethod inspect debug-text-3d ((obj debug-text-3d)) + (format #t "[~8x] ~A~%" obj 'debug-text-3d) + (format #t "~Tflags: ~D~%" (-> obj flags)) + (format #t "~Tbucket: ~D~%" (-> obj bucket)) + (format #t "~Tpos: #~%" (-> obj pos)) + (format #t "~Tcolor: ~D~%" (-> obj color)) + (format #t "~Toffset: #~%" (-> obj offset)) + (format #t "~Tstr: ~A~%" (-> obj str)) + obj + ) + +;; definition of type debug-tracking-thang +(deftype debug-tracking-thang (basic) + ((length int32 :offset-assert 4) + (allocated-length int32 :offset-assert 8) + ) + :method-count-assert 9 + :size-assert #xc + :flag-assert #x90000000c + ) + +;; definition for method 3 of type debug-tracking-thang +(defmethod inspect debug-tracking-thang ((obj debug-tracking-thang)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tlength: ~D~%" (-> obj length)) + (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) + obj + ) + +;; definition for symbol *debug-lines*, type (inline-array debug-line) +(define + *debug-lines* + (the-as (inline-array debug-line) (malloc 'debug #x100000)) + ) + +;; definition for symbol *debug-lines-trk*, type debug-tracking-thang +(define *debug-lines-trk* (new 'debug 'debug-tracking-thang)) + +;; failed to figure out what this is: +(set! (-> *debug-lines-trk* allocated-length) #x4000) + +;; definition for symbol *debug-text-3ds*, type (inline-array debug-text-3d) +(define + *debug-text-3ds* + (the-as (inline-array debug-text-3d) (malloc 'debug #x6000)) + ) + +;; definition for symbol *debug-text-3d-trk*, type debug-tracking-thang +(define *debug-text-3d-trk* (new 'debug 'debug-tracking-thang)) + +;; failed to figure out what this is: +(set! (-> *debug-text-3d-trk* allocated-length) 512) + +;; failed to figure out what this is: +(dotimes (gp-0 (-> *debug-text-3d-trk* allocated-length)) + (set! + (-> *debug-text-3ds* gp-0 str) + (new 'debug 'string 80 (the-as string #f)) + ) + ) + +) +;; definition (debug) for function get-debug-line +(defun-debug get-debug-line () + (the-as debug-line (cond + ((< + (-> *debug-lines-trk* length) + (-> *debug-lines-trk* allocated-length) + ) + (+! (-> *debug-lines-trk* length) 1) + (-> *debug-lines* (+ (-> *debug-lines-trk* length) -1)) + ) + (else + (the-as debug-line #f) + ) + ) + ) + ) + +;; definition (debug) for function get-debug-text-3d +(defun-debug get-debug-text-3d () + (the-as debug-text-3d (cond + ((< + (-> *debug-text-3d-trk* length) + (-> *debug-text-3d-trk* allocated-length) + ) + (+! (-> *debug-text-3d-trk* length) 1) + (-> + *debug-text-3ds* + (+ (-> *debug-text-3d-trk* length) -1) + ) + ) + (else + (the-as debug-text-3d #f) + ) + ) + ) + ) + +;; definition (debug) for function debug-reset-buffers +(defun-debug debug-reset-buffers () + (set! (-> *debug-lines-trk* length) 0) + (set! (-> *debug-text-3d-trk* length) 0) + (set! *debug-draw-pauseable* #f) + #f + ) + +;; definition (debug) for function debug-draw-buffers +(defun-debug debug-draw-buffers () + (dotimes (gp-0 (-> *debug-lines-trk* length)) + (let ((v1-1 (-> *debug-lines* gp-0))) + (internal-draw-debug-line + (-> v1-1 bucket) + (-> v1-1 v1) + (-> v1-1 v2) + (-> v1-1 color) + (-> v1-1 mode) + (-> v1-1 color2) + ) + ) + ) + (dotimes (gp-1 (-> *debug-text-3d-trk* length)) + (let ((v1-8 (-> *debug-text-3ds* gp-1))) + (internal-draw-debug-text-3d + (-> v1-8 bucket) + (-> v1-8 str) + (-> v1-8 pos) + (-> v1-8 color) + (-> v1-8 offset) + ) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-line +;; Used lq/sq +(defun-debug + add-debug-line + ((arg0 symbol) + (arg1 bucket-id) + (arg2 vector) + (arg3 vector) + (arg4 rgba) + (arg5 symbol) + (arg6 rgba) + ) + (when arg0 + (cond + (*debug-draw-pauseable* + (let ((v1-2 (get-debug-line))) + (when v1-2 + (set! (-> v1-2 bucket) arg1) + (set! (-> v1-2 v1 quad) (-> arg2 quad)) + (set! (-> v1-2 v2 quad) (-> arg3 quad)) + (set! (-> v1-2 color) arg4) + (set! (-> v1-2 color2) arg6) + (set! (-> v1-2 mode) arg5) + ) + ) + ) + (else + (internal-draw-debug-line arg1 arg2 arg3 arg4 arg5 arg6) + ) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-line2d +;; Used lq/sq +(defun-debug + add-debug-line2d + ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 vector)) + (if (not arg0) + (return #f) + ) + (let* ((s4-0 (-> *display* frames (-> *display* on-screen) frame debug-buf)) + (s5-0 (-> s4-0 base)) + ) + (let ((s2-0 (new 'stack 'vector4w)) + (v1-7 (new 'stack 'vector4w)) + ) + (set! (-> s2-0 quad) (-> arg2 quad)) + (set! (-> v1-7 quad) (-> arg3 quad)) + (set! (-> s2-0 x) (* (+ (-> s2-0 x) 2048) 16)) + (set! (-> s2-0 y) (* -16 (- 2048 (-> s2-0 y)))) + (set! (-> s2-0 z) #x7fffff) + (set! (-> v1-7 x) (* (+ (-> v1-7 x) 2048) 16)) + (set! (-> v1-7 y) (* -16 (- 2048 (-> v1-7 y)))) + (set! (-> v1-7 z) #x7fffff) + (let ((a0-20 (the-as (pointer uint64) (-> s4-0 base)))) + (let* ((a1-7 s4-0) + (a2-3 (the-as dma-packet (-> a1-7 base))) + ) + (set! (-> a2-3 dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> a2-3 vif0) (new 'static 'vif-tag)) + (set! + (-> a2-3 vif1) + (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1) + ) + (set! (-> a1-7 base) (&+ (the-as pointer a2-3) 16)) + ) + (let* ((a1-8 s4-0) + (a2-5 (the-as gs-gif-tag (-> a1-8 base))) + ) + (set! + (-> a2-5 tag) + (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line) :iip #x1 :abe #x1) + :nreg #x4 + ) + ) + (set! + (-> a2-5 regs) + (new 'static 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id xyzf2) + :regs2 (gif-reg-id rgbaq) + :regs3 (gif-reg-id xyzf2) + ) + ) + (set! (-> a1-8 base) (&+ (the-as pointer a2-5) 16)) + ) + (let* ((a1-9 s4-0) + (a2-7 (the-as (inline-array vector4w) (-> a1-9 base))) + ) + (set! (-> a2-7 0 quad) (-> arg4 quad)) + (set! (-> a2-7 1 quad) (-> s2-0 quad)) + (set! (-> a1-9 base) (&+ (the-as pointer a2-7) 32)) + ) + (let* ((a1-10 s4-0) + (a2-9 (the-as (inline-array vector4w) (-> a1-10 base))) + ) + (set! (-> a2-9 0 quad) (-> arg4 quad)) + (set! (-> a2-9 1 quad) (-> v1-7 quad)) + (set! (-> a1-10 base) (&+ (the-as pointer a2-9) 32)) + ) + (let + ((a1-14 + (/ + (the-as + int + (+ + (&- (the-as pointer -16) (the-as uint a0-20)) + (the-as int (-> s4-0 base)) + ) + ) + 16 + ) + ) + ) + (cond + ((nonzero? a1-14) + (logior! (-> a0-20 0) (shr (shl a1-14 48) 48)) + (logior! (-> a0-20 1) (shl (shr (shl a1-14 48) 48) 32)) + ) + (else + (set! (-> s4-0 base) a0-20) + ) + ) + ) + ) + ) + (let ((a3-11 (-> s4-0 base))) + (let ((v1-10 (the-as dma-packet (-> s4-0 base)))) + (set! (-> v1-10 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> v1-10 vif0) (new 'static 'vif-tag)) + (set! (-> v1-10 vif1) (new 'static 'vif-tag)) + (set! (-> s4-0 base) (&+ (the-as pointer v1-10) 16)) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) frame bucket-group) + arg1 + s5-0 + (the-as (pointer dma-tag) a3-11) + ) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-box +;; Used lq/sq +(defun-debug + add-debug-box + ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 vector) (arg4 rgba)) + (let ((s5-0 (new-stack-vector0))) + (set! (-> s5-0 quad) (-> arg2 quad)) + (let ((s1-0 (new-stack-vector0))) + (set! (-> s1-0 quad) (-> arg2 quad)) + (when arg0 + (set! (-> s1-0 x) (-> arg3 x)) + (add-debug-line #t arg1 s5-0 s1-0 arg4 #f (the-as rgba -1)) + (set! (-> s1-0 x) (-> arg2 x)) + (set! (-> s1-0 y) (-> arg3 y)) + (add-debug-line #t arg1 s5-0 s1-0 arg4 #f (the-as rgba -1)) + (set! (-> s1-0 y) (-> arg2 y)) + (set! (-> s1-0 z) (-> arg3 z)) + (add-debug-line #t arg1 s5-0 s1-0 arg4 #f (the-as rgba -1)) + (set! (-> s5-0 y) (-> arg3 y)) + (set! (-> s1-0 y) (-> arg3 y)) + (add-debug-line #t arg1 s5-0 s1-0 arg4 #f (the-as rgba -1)) + (set! (-> s1-0 z) (-> arg2 z)) + (set! (-> s1-0 x) (-> arg3 x)) + (add-debug-line #t arg1 s5-0 s1-0 arg4 #f (the-as rgba -1)) + (set! (-> s1-0 y) (-> arg2 y)) + (set! (-> s5-0 x) (-> arg3 x)) + (add-debug-line #t arg1 s5-0 s1-0 arg4 #f (the-as rgba -1)) + (set! (-> s5-0 quad) (-> arg3 quad)) + (set! (-> s1-0 quad) (-> arg3 quad)) + (set! (-> s1-0 x) (-> arg2 x)) + (add-debug-line #t arg1 s5-0 s1-0 arg4 #f (the-as rgba -1)) + (set! (-> s1-0 x) (-> arg3 x)) + (set! (-> s1-0 y) (-> arg2 y)) + (add-debug-line #t arg1 s5-0 s1-0 arg4 #f (the-as rgba -1)) + (set! (-> s1-0 y) (-> arg3 y)) + (set! (-> s1-0 z) (-> arg2 z)) + (add-debug-line #t arg1 s5-0 s1-0 arg4 #f (the-as rgba -1)) + (set! (-> s5-0 y) (-> arg2 y)) + (set! (-> s1-0 y) (-> arg2 y)) + (add-debug-line #t arg1 s5-0 s1-0 arg4 #f (the-as rgba -1)) + (set! (-> s1-0 z) (-> arg3 z)) + (set! (-> s1-0 x) (-> arg2 x)) + (add-debug-line #t arg1 s5-0 s1-0 arg4 #f (the-as rgba -1)) + (set! (-> s1-0 y) (-> arg3 y)) + (set! (-> s5-0 x) (-> arg2 x)) + (add-debug-line #t arg1 s5-0 s1-0 arg4 #f (the-as rgba -1)) + ) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-x +;; Used lq/sq +(defun-debug + add-debug-x + ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 rgba)) + (if (not arg0) + (return #f) + ) + (let ((s3-0 (new-stack-vector0)) + (s2-0 (new-stack-vector0)) + ) + (vector+! s3-0 arg2 (new 'static 'vector :x -1228.8)) + (vector+! s2-0 arg2 (new 'static 'vector :x 1228.8)) + (add-debug-line #t arg1 s3-0 s2-0 arg3 #f (the-as rgba -1)) + (vector+! s3-0 arg2 (new 'static 'vector :z -1228.8)) + (vector+! s2-0 arg2 (new 'static 'vector :z 1228.8)) + (add-debug-line #t arg1 s3-0 s2-0 arg3 #f (the-as rgba -1)) + ) + #f + ) + +;; definition (debug) for function add-debug-text-3d +;; Used lq/sq +(defun-debug + add-debug-text-3d + ((arg0 symbol) + (arg1 bucket-id) + (arg2 string) + (arg3 vector) + (arg4 font-color) + (arg5 vector2h) + ) + (when arg0 + (cond + (*debug-draw-pauseable* + (let ((v1-2 (get-debug-text-3d))) + (when v1-2 + (set! (-> v1-2 flags) 0) + (set! (-> v1-2 bucket) arg1) + (set! (-> v1-2 pos quad) (-> arg3 quad)) + (cond + (arg5 + (set! (-> v1-2 offset x) (-> arg5 x)) + (set! (-> v1-2 offset y) (-> arg5 y)) + ) + (else + (set! (-> v1-2 offset x) 0) + (set! (-> v1-2 offset y) 0) + 0 + ) + ) + (set! (-> v1-2 color) arg4) + (let ((a0-6 0) + (a1-2 (-> arg2 data)) + (v1-4 (-> v1-2 str data)) + ) + (while (and (nonzero? (-> a1-2 0)) (< a0-6 79)) + (set! (-> v1-4 0) (-> a1-2 0)) + (set! a1-2 (&-> a1-2 1)) + (set! v1-4 (&-> v1-4 1)) + (+! a0-6 1) + ) + (set! (-> v1-4 0) (the-as uint 0)) + ) + 0 + ) + ) + ) + (else + (internal-draw-debug-text-3d arg1 arg2 arg3 arg4 (cond + (arg5 + (empty) + arg5 + ) + (else + (new 'static 'vector2h) + ) + ) + ) + ) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-sphere-with-transform +(defun-debug + add-debug-sphere-with-transform + ((arg0 symbol) + (arg1 bucket-id) + (arg2 vector) + (arg3 meters) + (arg4 matrix) + (arg5 rgba) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (when arg0 + (.lvf vf5 (&-> arg2 quad)) + (.lvf vf1 (&-> arg4 vector 0 quad)) + (.lvf vf2 (&-> arg4 vector 1 quad)) + (.lvf vf3 (&-> arg4 vector 2 quad)) + (.lvf vf4 (&-> arg4 vector 3 quad)) + (.mul.w.vf acc vf4 vf0) + (.add.mul.x.vf acc vf1 vf5 acc) + (.add.mul.y.vf acc vf2 vf5 acc) + (.add.mul.z.vf vf5 vf3 vf5 acc) + (let ((a2-1 (new 'stack-no-clear 'vector))) + (.svf (&-> a2-1 quad) vf5) + (add-debug-sphere arg0 arg1 a2-1 arg3 arg5) + ) + ) + #f + ) + ) + +;; definition (debug) for function add-debug-sphere +(defun-debug + add-debug-sphere + ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 float) (arg4 rgba)) + (if arg0 + (add-debug-sphere-from-table arg1 arg2 arg3 arg4) + ) + #f + ) + +;; definition (debug) for function add-debug-text-sphere +(defun-debug + add-debug-text-sphere + ((arg0 symbol) + (arg1 bucket-id) + (arg2 vector) + (arg3 float) + (arg4 string) + (arg5 rgba) + ) + (add-debug-sphere arg0 arg1 arg2 arg3 arg5) + (add-debug-text-3d + arg0 + arg1 + arg4 + arg2 + (font-color default) + (the-as vector2h #f) + ) + #f + ) + +;; definition (debug) for function add-debug-spheres +(defun-debug + add-debug-spheres + ((arg0 symbol) + (arg1 bucket-id) + (arg2 (inline-array vector)) + (arg3 int) + (arg4 rgba) + ) + (when arg0 + (let ((s4-0 (-> arg2 0))) + (countdown (s3-0 arg3) + (add-debug-sphere #t arg1 s4-0 (-> s4-0 w) arg4) + (&+! s4-0 16) + ) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-circle +;; Used lq/sq +(defun-debug + add-debug-circle + ((arg0 symbol) + (arg1 bucket-id) + (arg2 vector) + (arg3 float) + (arg4 rgba) + (arg5 matrix) + ) + (local-vars (sv-48 int) (sv-64 vector) (sv-80 vector)) + "note: you may pass #f for orientation" + (if (not arg0) + (return #f) + ) + (let ((f30-0 0.0) + (s1-0 (new-stack-vector0)) + (s0-0 (new-stack-vector0)) + ) + (set! sv-48 0) + (while (< sv-48 12) + (set! sv-64 s1-0) + (set! (-> sv-64 x) (* arg3 (cos f30-0))) + (set! (-> sv-64 y) 0.0) + (set! (-> sv-64 z) (* arg3 (sin f30-0))) + (set! (-> sv-64 w) 1.0) + (set! f30-0 (+ 5461.3335 f30-0)) + (set! sv-80 s0-0) + (set! (-> sv-80 x) (* arg3 (cos f30-0))) + (set! (-> sv-80 y) 0.0) + (set! (-> sv-80 z) (* arg3 (sin f30-0))) + (set! (-> sv-80 w) 1.0) + (when arg5 + (vector-matrix*! s1-0 s1-0 arg5) + (vector-matrix*! s0-0 s0-0 arg5) + ) + (vector+! s1-0 s1-0 arg2) + (vector+! s0-0 s0-0 arg2) + (add-debug-line #t arg1 s1-0 s0-0 arg4 #f (the-as rgba -1)) + (set! sv-48 (+ sv-48 1)) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-vector +;; Used lq/sq +(defun-debug + add-debug-vector + ((arg0 symbol) + (arg1 bucket-id) + (arg2 vector) + (arg3 vector) + (arg4 meters) + (arg5 rgba) + ) + (if (not arg0) + (return #f) + ) + (let ((v1-2 (new-stack-vector0))) + (set! (-> v1-2 x) (+ (-> arg2 x) (* (-> arg3 x) arg4))) + (set! (-> v1-2 y) (+ (-> arg2 y) (* (-> arg3 y) arg4))) + (set! (-> v1-2 z) (+ (-> arg2 z) (* (-> arg3 z) arg4))) + (add-debug-line #t arg1 arg2 v1-2 arg5 #f (the-as rgba -1)) + ) + #f + ) + +;; definition (debug) for function add-debug-matrix +(defun-debug add-debug-matrix ((arg0 symbol) (arg1 bucket-id) (arg2 matrix)) + (add-debug-vector + arg0 + arg1 + (-> arg2 vector 3) + (the-as vector (-> arg2 vector)) + (meters 2.0) + (new 'static 'rgba :r #xff :a #x80) + ) + (add-debug-vector + arg0 + arg1 + (-> arg2 vector 3) + (-> arg2 vector 1) + (meters 2.0) + (new 'static 'rgba :g #xff :a #x80) + ) + (add-debug-vector + arg0 + arg1 + (-> arg2 vector 3) + (-> arg2 vector 2) + (meters 2.0) + (new 'static 'rgba :b #xff :a #x80) + ) + arg2 + ) + +;; definition (debug) for function add-debug-rot-matrix +(defun-debug + add-debug-rot-matrix + ((arg0 symbol) (arg1 bucket-id) (arg2 matrix) (arg3 vector)) + (add-debug-vector + arg0 + arg1 + arg3 + (the-as vector (-> arg2 vector)) + (meters 2.0) + (new 'static 'rgba :r #xff :a #x80) + ) + (add-debug-vector + arg0 + arg1 + arg3 + (-> arg2 vector 1) + (meters 2.0) + (new 'static 'rgba :g #xff :a #x80) + ) + (add-debug-vector + arg0 + arg1 + arg3 + (-> arg2 vector 2) + (meters 2.0) + (new 'static 'rgba :b #xff :a #x80) + ) + arg2 + ) + +;; definition (debug) for function add-debug-yrot-vector +;; WARN: Stack slot offset 32 signed mismatch +;; WARN: Stack slot load mismatch: defined as size 4, got size 16 +;; Used lq/sq +(defun-debug + add-debug-yrot-vector + ((arg0 symbol) + (arg1 bucket-id) + (arg2 vector) + (arg3 float) + (arg4 float) + (arg5 rgba) + ) + (local-vars (sv-32 float)) + (set! sv-32 arg3) + (let ((s0-0 arg4) + (s3-0 arg5) + ) + (if (not arg0) + (return #f) + ) + (let ((s1-0 (new-stack-vector0))) + (set-vector! + s1-0 + (+ (-> arg2 x) (* (sin sv-32) s0-0)) + (-> arg2 y) + (+ (-> arg2 z) (* (cos sv-32) s0-0)) + 1.0 + ) + (add-debug-line arg0 arg1 s1-0 arg2 s3-0 #f (the-as rgba -1)) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-arc +;; Used lq/sq +(defun-debug + add-debug-arc + ((arg0 symbol) + (arg1 bucket-id) + (arg2 vector) + (arg3 float) + (arg4 float) + (arg5 float) + (arg6 rgba) + (arg7 matrix) + ) + (local-vars + (sv-48 vector) + (sv-64 vector) + (sv-80 int) + (sv-96 vector) + (sv-112 vector) + ) + "note: you may pass #f for orientation" + (if (not arg0) + (return #f) + ) + (let ((f30-0 arg3)) + (set! sv-48 (new 'stack-no-clear 'vector)) + (set! (-> sv-48 quad) (the-as uint128 0)) + (set! sv-64 (new 'stack-no-clear 'vector)) + (set! (-> sv-64 quad) (the-as uint128 0)) + (set! sv-80 0) + (while (< sv-80 12) + (set! sv-96 sv-48) + (set! (-> sv-96 x) (* arg5 (sin f30-0))) + (set! (-> sv-96 y) 0.0) + (set! (-> sv-96 z) (* arg5 (cos f30-0))) + (set! (-> sv-96 w) 1.0) + (+! f30-0 (the float (/ (the int (- arg4 arg3)) 12))) + (set! sv-112 sv-64) + (set! (-> sv-112 x) (* arg5 (sin f30-0))) + (set! (-> sv-112 y) 0.0) + (set! (-> sv-112 z) (* arg5 (cos f30-0))) + (set! (-> sv-112 w) 1.0) + (when arg7 + (vector-matrix*! sv-48 sv-48 arg7) + (vector-matrix*! sv-64 sv-64 arg7) + ) + (vector+! sv-48 sv-48 arg2) + (vector+! sv-64 sv-64 arg2) + (add-debug-line #t arg1 sv-48 sv-64 arg6 #f (the-as rgba -1)) + (cond + ((zero? sv-80) + (add-debug-line #t arg1 sv-48 arg2 arg6 #f (the-as rgba -1)) + ) + ((= sv-80 11) + (add-debug-line #t arg1 sv-64 arg2 arg6 #f (the-as rgba -1)) + ) + ) + (set! sv-80 (+ sv-80 1)) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-curve +;; Used lq/sq +(defun-debug + add-debug-curve + ((arg0 symbol) + (arg1 bucket-id) + (arg2 pointer) + (arg3 int) + (arg4 (inline-array vector)) + (arg5 int) + (arg6 rgba) + ) + (local-vars (sv-48 vector) (sv-64 int) (sv-80 int)) + (if (not arg0) + (return #f) + ) + (let ((s0-0 (new-stack-vector0))) + (set! sv-48 (new 'stack-no-clear 'vector)) + (set! (-> sv-48 quad) (the-as uint128 0)) + (set! sv-64 (* arg3 4)) + (curve-evaluate! sv-48 (-> arg4 0 x) arg2 arg3 arg4 arg5) + (set! sv-80 0) + (while (< sv-80 sv-64) + (set! (-> s0-0 quad) (-> sv-48 quad)) + (curve-evaluate! + sv-48 + (/ (the float (+ sv-80 1)) (the float sv-64)) + arg2 + arg3 + arg4 + arg5 + ) + (add-debug-line #t arg1 s0-0 sv-48 arg6 #f (the-as rgba -1)) + (set! sv-80 (+ sv-80 1)) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-curve2 +(defun-debug + add-debug-curve2 + ((arg0 symbol) (arg1 bucket-id) (arg2 curve) (arg3 rgba) (arg4 symbol)) + (if arg0 + (add-debug-curve + #t + arg1 + (-> arg2 cverts) + (-> arg2 num-cverts) + (-> arg2 knots) + (-> arg2 num-knots) + arg3 + ) + ) + #f + ) + +;; definition (debug) for function add-debug-points +;; Used lq/sq +(defun-debug + add-debug-points + ((arg0 symbol) + (arg1 bucket-id) + (arg2 (inline-array vector)) + (arg3 int) + (arg4 rgba) + (arg5 float) + (arg6 int) + ) + (local-vars + (sv-32 (function symbol bucket-id string vector font-color vector2h symbol)) + (sv-48 symbol) + (sv-64 bucket-id) + (sv-80 (function _varargs_ object)) + (sv-96 vector) + ) + (when arg0 + (dotimes (s0-0 arg3) + (set! sv-96 (new 'stack-no-clear 'vector)) + (set! (-> sv-96 quad) (the-as uint128 0)) + (set! (-> sv-96 quad) (-> arg2 s0-0 quad)) + (if (!= arg5 0.0) + (set! (-> sv-96 y) arg5) + ) + (set! sv-32 add-debug-text-3d) + (set! sv-48 #t) + (set! sv-64 arg1) + (set! sv-80 format) + (let ((a0-5 (clear *temp-string*)) + (a1-1 "~d") + (a2-1 s0-0) + ) + (sv-80 a0-5 a1-1 a2-1) + ) + (let ((a2-2 *temp-string*) + (a3-1 sv-96) + (t0-1 1) + (t1-1 #f) + ) + (sv-32 + sv-48 + sv-64 + a2-2 + a3-1 + (the-as font-color t0-1) + (the-as vector2h t1-1) + ) + ) + (let ((t9-3 add-debug-x) + (a0-7 #t) + (a1-3 arg1) + (a3-2 (if (= s0-0 arg6) + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + arg4 + ) + ) + ) + (t9-3 a0-7 a1-3 sv-96 a3-2) + ) + ) + ) + #f + ) + +;; definition (debug) for function debug-percent-bar +(defun-debug + debug-percent-bar + ((arg0 symbol) + (arg1 bucket-id) + (arg2 int) + (arg3 int) + (arg4 float) + (arg5 rgba) + ) + (if (not arg0) + (return #f) + ) + (let* ((s0-0 (-> *display* frames (-> *display* on-screen) frame debug-buf)) + (s5-0 (-> s0-0 base)) + ) + (draw-sprite2d-xy s0-0 arg2 arg3 255 14 (new 'static 'rgba :a #x40)) + (draw-sprite2d-xy s0-0 arg2 (+ arg3 2) (the int (* 255.0 arg4)) 10 arg5) + (let ((a3-3 (-> s0-0 base))) + (let ((v1-5 (the-as dma-packet (-> s0-0 base)))) + (set! (-> v1-5 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> v1-5 vif0) (new 'static 'vif-tag)) + (set! (-> v1-5 vif1) (new 'static 'vif-tag)) + (set! (-> s0-0 base) (&+ (the-as pointer v1-5) 16)) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) frame bucket-group) + arg1 + s5-0 + (the-as (pointer dma-tag) a3-3) + ) + ) + ) + #f + ) + +;; definition (debug) for function debug-pad-display +;; Used lq/sq +(defun-debug debug-pad-display ((arg0 cpad-info)) + (let + ((gp-0 + (new 'static 'inline-array vector 8 + (new 'static 'vector) + (new 'static 'vector) + (new 'static 'vector) + (new 'static 'vector) + (new 'static 'vector) + (new 'static 'vector) + (new 'static 'vector) + (new 'static 'vector) + ) + ) + ) + (countdown (v1-0 31) + (let ((a0-3 (-> gp-0 v1-0 quad))) + (set! (-> gp-0 (+ v1-0 1) quad) a0-3) + ) + ) + (set! (-> gp-0 0 x) (* (sin (-> arg0 stick0-dir)) (-> arg0 stick0-speed))) + (set! (-> gp-0 0 y) (* (cos (-> arg0 stick0-dir)) (-> arg0 stick0-speed))) + (dotimes (s5-1 32) + (let* ((s3-0 (-> *display* frames (-> *display* on-screen) frame debug-buf)) + (s4-0 (-> s3-0 base)) + ) + (draw-sprite2d-xy + s3-0 + (the int (* 120.0 (-> gp-0 s5-1 x))) + (the int (* 144.0 (-> gp-0 s5-1 y))) + 10 + 10 + (new 'static 'rgba :a #x80 :r (- 255 (* 7 s5-1))) + ) + (let ((a3-1 (-> s3-0 base))) + (let ((v1-12 (the-as dma-packet (-> s3-0 base)))) + (set! (-> v1-12 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> v1-12 vif0) (new 'static 'vif-tag)) + (set! (-> v1-12 vif1) (new 'static 'vif-tag)) + (set! (-> s3-0 base) (&+ (the-as pointer v1-12) 16)) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) frame bucket-group) + (bucket-id debug-draw0) + s4-0 + (the-as (pointer dma-tag) a3-1) + ) + ) + ) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-light +;; Used lq/sq +(defun-debug + add-debug-light + ((arg0 symbol) (arg1 bucket-id) (arg2 light) (arg3 vector) (arg4 string)) + (if (not arg0) + (return #f) + ) + (when (!= (-> arg2 levels x) 0.0) + (add-debug-vector + arg0 + arg1 + arg3 + (-> arg2 direction) + (meters 3.0) + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + (let + ((s2-1 + (vector+*! + (new-stack-vector0) + arg3 + (-> arg2 direction) + (* 12288.0 (-> arg2 levels x)) + ) + ) + (s1-0 + (logior + (logior + (logior + (shr (shl (the int (* 128.0 (-> arg2 color w))) 56) 32) + (shr (shl (the int (* 128.0 (-> arg2 color z))) 56) 40) + ) + (shr (shl (the int (* 128.0 (-> arg2 color y))) 56) 48) + ) + (shr (shl (the int (* 128.0 (-> arg2 color x))) 56) 56) + ) + ) + ) + (format (clear *temp-string*) "~S ~,,2f" arg4 (-> arg2 levels x)) + (let ((t0-2 *temp-string*)) + (add-debug-text-sphere + arg0 + arg1 + s2-1 + (* 2048.0 (-> arg2 levels x)) + t0-2 + (the-as rgba s1-0) + ) + ) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-lights +(defun-debug + add-debug-lights + ((arg0 symbol) (arg1 bucket-id) (arg2 (inline-array light)) (arg3 vector)) + (if (not arg0) + (return #f) + ) + (add-debug-light arg0 arg1 (-> arg2 0) arg3 "dir0") + (add-debug-light arg0 arg1 (-> arg2 1) arg3 "dir1") + (add-debug-light arg0 arg1 (-> arg2 2) arg3 "dir2") + (add-debug-light arg0 arg1 (-> arg2 3) arg3 "ambi") + #f + ) + +;; definition (debug) for function drawable-frag-count +(defun-debug drawable-frag-count ((arg0 drawable)) + (let ((gp-0 0)) + (cond + ((not arg0) + ) + ((type-type? (-> arg0 type) drawable-group) + (dotimes (s4-0 (-> (the-as drawable-group arg0) length)) + (+! + gp-0 + (drawable-frag-count (-> (the-as drawable-group arg0) data s4-0)) + ) + ) + ) + (else + (+! gp-0 1) + ) + ) + gp-0 + ) + ) + +;; definition for method 3 of type debug-vertex-stats +;; INFO: this function exists in multiple non-identical object files +(defmethod inspect debug-vertex-stats ((obj debug-vertex-stats)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tlength: ~D~%" (-> obj length)) + (format #t "~Tpos-count: ~D~%" (-> obj pos-count)) + (format #t "~Tdata[~D]: @ #x~X~%" (-> obj length) (-> obj vertex)) + (dotimes (s5-0 (-> obj length)) + (let ((s4-0 (-> obj vertex s5-0))) + (format + #t + " ~D : trans: ~D ~D ~D ~D" + s5-0 + (-> s4-0 trans x) + (-> s4-0 trans y) + (-> s4-0 trans z) + (-> s4-0 trans w) + ) + (format #t " st: ~D ~D~%" (-> s4-0 st x) (-> s4-0 st y)) + (format + #t + " col: ~X norm: ~D ~D ~D~%" + (-> s4-0 color) + (-> s4-0 normal x) + (-> s4-0 normal y) + (-> s4-0 normal z) + ) + ) + ) + obj + ) + +;; definition (debug) for function history-init +(defun-debug history-init ((arg0 pos-history) (arg1 int)) + (set! (-> arg0 num-points) arg1) + (set! (-> arg0 points) (the-as (inline-array vector) #f)) + arg0 + ) + +;; definition (debug) for function history-draw-and-update +;; Used lq/sq +(defun-debug + history-draw-and-update + ((arg0 pos-history) (arg1 int) (arg2 vector)) + (if (and arg1 (not (-> arg0 points))) + (set! + (-> arg0 points) + (the-as (inline-array vector) (malloc 'debug (* (-> arg0 num-points) 16))) + ) + ) + (when (-> arg0 points) + (set! (-> arg0 points (-> arg0 h-first) quad) (-> arg2 quad)) + (+! (-> arg0 h-first) 1) + (when (>= (-> arg0 h-first) (-> arg0 num-points)) + (set! (-> arg0 h-first) 0) + 0 + ) + ) + (when arg1 + (dotimes (s5-1 (+ (-> arg0 num-points) -1)) + (if (!= (+ s5-1 1) (-> arg0 h-first)) + (add-debug-line + #t + (bucket-id debug-draw1) + (-> arg0 points s5-1) + (-> arg0 points (+ s5-1 1)) + (new 'static 'rgba :r #x80 :g #xc0 :b #x80 :a #x80) + #f + (the-as rgba -1) + ) + ) + ) + ) + #f + ) + +;; definition (debug) for function dma-timeout-cam +;; Used lq/sq +(defun-debug dma-timeout-cam () + (let ((a0-0 (new-stack-vector0)) + (a1-0 (new-stack-matrix0)) + ) + (set! (-> a0-0 x) -666764.4) + (set! (-> a0-0 y) 21102.984) + (set! (-> a0-0 z) 51613.348) + (set! (-> a0-0 w) 1.0) + (set! (-> a1-0 vector 0 x) -0.911) + (set! (-> a1-0 vector 0 y) 0.0) + (set! (-> a1-0 vector 0 z) 0.4122) + (set! (-> a1-0 vector 0 w) 0.0) + (set! (-> a1-0 vector 1 x) -0.0984) + (set! (-> a1-0 vector 1 y) 0.971) + (set! (-> a1-0 vector 1 z) -0.2174) + (set! (-> a1-0 vector 1 w) 0.0) + (set! (-> a1-0 vector 2 x) -0.4003) + (set! (-> a1-0 vector 2 y) -0.2387) + (set! (-> a1-0 vector 2 z) -0.8847) + (set! (-> a1-0 vector 2 w) 0.0) + (set! (-> a1-0 vector 3 x) 0.0) + (set! (-> a1-0 vector 3 y) 0.0) + (set! (-> a1-0 vector 3 z) 0.0) + (set! (-> a1-0 vector 3 w) 1.0) + (debug-set-camera-pos-rot! a0-0 a1-0) + ) + ) + +;; definition (debug) for function display-file-info +(defun-debug display-file-info () + (when (and *display-file-info* (!= *master-mode* 'menu)) + (dotimes (gp-0 (-> *level* length)) + (let ((v1-7 (-> *level* level gp-0))) + (when (= (-> v1-7 status) 'active) + (let ((s5-0 (-> v1-7 bsp))) + (format *stdcon* "file name: ~S~%" (-> s5-0 info file-name)) + (format + *stdcon* + "version: ~D.~D~%" + (-> s5-0 info major-version) + (-> s5-0 info minor-version) + ) + (format *stdcon* "maya file: ~S~%" (-> s5-0 info maya-file-name)) + (format *stdcon* "mdb file: ~S~%" (-> s5-0 info mdb-file-name)) + (format *stdcon* "~S" (-> s5-0 info tool-debug)) + ) + ) + ) + ) + ) + 0 + ) From e473ede677700f99a6d9baae7c68930dd97ef62a Mon Sep 17 00:00:00 2001 From: water Date: Sat, 14 Aug 2021 13:17:24 -0400 Subject: [PATCH 7/7] sort enum bit fields --- decompiler/util/data_decompile.cpp | 13 ++++++++++-- .../reference/engine/debug/menu_REF.gc | 21 ++++++++----------- .../reference/engine/game/settings_REF.gc | 9 +++----- .../engine/gfx/generic/generic_REF.gc | 4 ++-- .../reference/engine/nav/navigate-h_REF.gc | 7 ++----- .../reference/levels/common/nav-enemy_REF.gc | 2 +- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index f36eecc5a6..0f124156a1 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -1246,11 +1246,20 @@ std::vector decompile_bitfield_enum_from_int(const TypeSpec& type, assert(type_info); assert(type_info->is_bitfield()); + std::vector bit_sorted_names; for (auto& field : type_info->entries()) { - u64 mask = ((u64)1) << field.second; + bit_sorted_names.push_back(field.first); + } + std::sort(bit_sorted_names.begin(), bit_sorted_names.end(), + [&](const std::string& a, const std::string& b) { + return type_info->entries().at(a) < type_info->entries().at(b); + }); + + for (auto& field_name : bit_sorted_names) { + u64 mask = ((u64)1) << type_info->entries().at(field_name); if (value & mask) { reconstructed |= mask; - result.push_back(field.first); + result.push_back(field_name); } } diff --git a/test/decompiler/reference/engine/debug/menu_REF.gc b/test/decompiler/reference/engine/debug/menu_REF.gc index 7a5cb6dcf9..f283695fd7 100644 --- a/test/decompiler/reference/engine/debug/menu_REF.gc +++ b/test/decompiler/reference/engine/debug/menu_REF.gc @@ -782,11 +782,8 @@ ) (cond ((= s4-0 'menu) - (let ((s4-1 (new 'debug 'debug-menu arg0 (the-as string s5-1)))) - (set! - s5-0 - (new 'debug 'debug-menu-item-submenu (the-as string s5-1) s4-1) - ) + (let ((s4-1 (new 'debug 'debug-menu arg0 s5-1))) + (set! s5-0 (new 'debug 'debug-menu-item-submenu s5-1 s4-1)) (let* ((gp-1 (cdr (cdr arg1))) (a1-3 (car gp-1)) ) @@ -803,7 +800,7 @@ ) ) ((= s4-0 'main-menu) - (set! s5-0 (new 'debug 'debug-menu arg0 (the-as string s5-1))) + (set! s5-0 (new 'debug 'debug-menu arg0 s5-1)) (let* ((gp-2 (cdr (cdr arg1))) (a1-6 (car gp-2)) ) @@ -828,7 +825,7 @@ (new 'debug 'debug-menu-item-flag - (the-as string s5-1) + s5-1 (the-as symbol (car (cdr (cdr arg1)))) (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) ) @@ -837,7 +834,7 @@ (new 'debug 'debug-menu-item-function - (the-as string s5-1) + s5-1 (the-as int (car (cdr (cdr arg1)))) (debug-menu-func-decode (car (cdr (cdr (cdr arg1))))) ) @@ -846,7 +843,7 @@ (new 'debug 'debug-menu-item-var - (the-as string s5-1) + s5-1 (the-as int (car (cdr (cdr arg1)))) (the-as int (car (cdr (cdr (cdr arg1))))) ) @@ -861,7 +858,7 @@ (new 'debug 'debug-menu-item-var - (the-as string s5-1) + s5-1 (the-as int (car (cdr (cdr arg1)))) (the-as int (ref arg1 4)) ) @@ -898,7 +895,7 @@ (new 'debug 'debug-menu-item-var - (the-as string s5-1) + s5-1 (the-as int (car (cdr (cdr arg1)))) (the-as int (ref arg1 4)) ) @@ -933,7 +930,7 @@ (new 'debug 'debug-menu-item-var - (the-as string s5-1) + s5-1 (the-as int (car (cdr (cdr arg1)))) (the-as int (ref arg1 4)) ) diff --git a/test/decompiler/reference/engine/game/settings_REF.gc b/test/decompiler/reference/engine/game/settings_REF.gc index ec1ba65a45..a05af74d44 100644 --- a/test/decompiler/reference/engine/game/settings_REF.gc +++ b/test/decompiler/reference/engine/game/settings_REF.gc @@ -42,12 +42,9 @@ (zero? (logand (-> *kernel-context* prevent-from-run) (process-mask progress)) ) - (let - ((v1-18 - ((method-of-type connection get-process) (the-as connection conn)) - ) - (a0-22 *progress-process*) - ) + (let ((v1-18 (get-process conn)) + (a0-22 *progress-process*) + ) (= v1-18 (if a0-22 (-> a0-22 0 self) ) diff --git a/test/decompiler/reference/engine/gfx/generic/generic_REF.gc b/test/decompiler/reference/engine/gfx/generic/generic_REF.gc index ae59c6a616..6cf27abe3c 100644 --- a/test/decompiler/reference/engine/gfx/generic/generic_REF.gc +++ b/test/decompiler/reference/engine/gfx/generic/generic_REF.gc @@ -93,8 +93,8 @@ (s2-0 (-> s0-0 base)) ) (if (>= s4-0 7) - (generic-init-buf s0-0 1 (the-as gs-zbuf s5-0)) - (generic-init-buf s0-0 1 (the-as gs-zbuf gp-0)) + (generic-init-buf s0-0 1 s5-0) + (generic-init-buf s0-0 1 gp-0) ) (generic-dma-foreground-sink-init s1-0) (let ((a3-0 (-> s0-0 base))) diff --git a/test/decompiler/reference/engine/nav/navigate-h_REF.gc b/test/decompiler/reference/engine/nav/navigate-h_REF.gc index cbf2886faa..5c35f8601c 100644 --- a/test/decompiler/reference/engine/nav/navigate-h_REF.gc +++ b/test/decompiler/reference/engine/nav/navigate-h_REF.gc @@ -557,10 +557,7 @@ ) (set! (-> obj max-spheres) sphere-count) (set! (-> obj flags) (nav-control-flags bit8 bit13)) - (set! - (-> obj mesh) - (nav-mesh-connect (-> shape process) shape (the-as nav-control obj)) - ) + (set! (-> obj mesh) (nav-mesh-connect (-> shape process) shape obj)) (let ((ent (-> shape process entity))) (set! (-> obj nearest-y-threshold) @@ -594,7 +591,7 @@ (defmethod should-display? nav-control ((obj nav-control)) (and *display-nav-marks* - (nonzero? (logand (-> obj flags) (nav-control-flags display-marks bit0))) + (nonzero? (logand (-> obj flags) (nav-control-flags bit0 display-marks))) ) ) diff --git a/test/decompiler/reference/levels/common/nav-enemy_REF.gc b/test/decompiler/reference/levels/common/nav-enemy_REF.gc index 40f53811d2..e088a084a6 100644 --- a/test/decompiler/reference/levels/common/nav-enemy_REF.gc +++ b/test/decompiler/reference/levels/common/nav-enemy_REF.gc @@ -3759,7 +3759,7 @@ nav-enemy-default-event-handler ) (logior! (-> obj nav flags) - (nav-control-flags display-marks bit0 bit3 bit5 bit6 bit7) + (nav-control-flags bit0 display-marks bit3 bit5 bit6 bit7) ) (set! (-> obj nav gap-event) 'jump) (dummy-26 (-> obj nav))