From 7cb04c6cd56aeed56690bd8619d3fdc18955db06 Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Sun, 2 May 2021 02:09:48 +0100 Subject: [PATCH] [decomp] font-h, fix a vector type, minor decompiler fixes (#411) * Make `:do-not-decompile` work on field lookup as well * decompile `font-h` and update a vector type + minor fixes * fix some types * fix font-h * fix font-h (again) * update a script * fixes * Fix segfault * Fix `PROT_NONE` page protection on windows --- common/type_system/TypeFieldLookup.cpp | 6 +- decompiler/config/all-types.gc | 189 ++--- .../jak1_ntsc_black_label/label_types.jsonc | 6 - .../jak1_ntsc_black_label/var_names.jsonc | 41 ++ goal_src/engine/camera/math-camera.gc | 2 + goal_src/engine/gfx/font-h.gc | 658 ++++++++++++++++++ goal_src/engine/gfx/hw/display-h.gc | 2 +- goal_src/engine/gfx/hw/display.gc | 143 ++-- goal_src/engine/gfx/hw/gs.gc | 87 +-- goal_src/engine/math/vector-h.gc | 2 +- goalc/compiler/compilation/Static.cpp | 3 +- scripts/batch/gc.bat | 2 +- .../reference/all_forward_declarations.gc | 34 +- test/decompiler/reference/bounding-box_REF.gc | 27 +- test/decompiler/reference/decomp-h_REF.gc | 32 + test/decompiler/reference/display-h_REF.gc | 5 +- test/decompiler/reference/display_REF.gc | 143 ++-- test/decompiler/reference/euler-h_REF.gc | 11 +- test/decompiler/reference/euler_REF.gc | 80 +-- test/decompiler/reference/gs_REF.gc | 48 +- test/decompiler/reference/matrix_REF.gc | 104 +-- test/decompiler/reference/quaternion_REF.gc | 70 +- test/decompiler/reference/sync-info_REF.gc | 8 +- test/decompiler/reference/texture-h_REF.gc | 410 +++++++++++ test/decompiler/reference/transform_REF.gc | 42 +- test/decompiler/reference/vector-h_REF.gc | 125 ++-- test/decompiler/reference/vector_REF.gc | 186 +++-- test/offline/offline_test_main.cpp | 2 + third-party/mman/mman.c | 2 +- 29 files changed, 1822 insertions(+), 648 deletions(-) create mode 100644 test/decompiler/reference/decomp-h_REF.gc create mode 100644 test/decompiler/reference/texture-h_REF.gc diff --git a/common/type_system/TypeFieldLookup.cpp b/common/type_system/TypeFieldLookup.cpp index 6ea71ea430..c992bc0726 100644 --- a/common/type_system/TypeFieldLookup.cpp +++ b/common/type_system/TypeFieldLookup.cpp @@ -369,6 +369,10 @@ bool TypeSystem::try_reverse_lookup_other(const FieldReverseLookupInput& input, auto corrected_offset = input.offset + type_info->get_offset(); // loop over fields. We may need to try multiple fields. for (auto& field : structure_type->fields()) { + if (field.skip_in_decomp()) { + continue; + } + auto field_deref = lookup_field_info(type_info->get_name(), field.name()); // how many bytes do we look at? In the case where we're just getting an address, we assume @@ -463,4 +467,4 @@ bool TypeSystem::try_reverse_lookup_other(const FieldReverseLookupInput& input, } } return false; -} \ No newline at end of file +} diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index fe819d8d70..ba48d930d9 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -924,7 +924,7 @@ ) (deftype vector4w (structure) - ((data int32 4 :offset-assert 0) + ((data int32 4 :do-not-decompile :offset-assert 0) (x int32 :offset 0) (y int32 :offset 4) (z int32 :offset 8) @@ -2379,7 +2379,7 @@ (end 7) ;; next, but ends. ) -; ;; dma-h +;; dma-h (deftype dma-tag (uint64) ((qwc uint16 :offset 0) ;; quadword count (pce uint8 :offset 26 :size 2) ;; priority (source mode) @@ -2393,7 +2393,7 @@ :flag-assert #x900000008 ) -; ;; dma-h +;; dma-h (deftype dma-bucket (structure) ((tag dma-tag :offset-assert 0) ;; the DMA tag to transfer the bucket's data (last (pointer dma-tag) :offset-assert 8) ;; the last tag of this bucket. @@ -2432,7 +2432,7 @@ (unpack-s-32 96) (unpack-s-16 97) (unpack-s-8 98) - ;; 99 is invllid + ;; 99 is invalid (unpack-v2-32 100) (unpack-v2-16 101) (unpack-v2-8 102) @@ -2520,7 +2520,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; -; ;; video-h (deftype video-parms (structure) ((set-video-mode basic :offset-assert 0) (reset-video-mode basic :offset-assert 4) @@ -2709,9 +2708,92 @@ :flag-assert #x900000010 ) +;; moved these here for the decompiler for now! +;; gs +(defenum gs-prim-type + :type uint8 + (point 0) + (line 1) + (line-strip 2) + (tri 3) + (tri-strip 4) + (tri-fan 5) + (sprite 6) + ) + +(deftype gs-prim (uint64) + ((prim gs-prim-type :offset 0 :size 3) + (iip uint8 :offset 3 :size 1) + (tme uint8 :offset 4 :size 1) + (fge uint8 :offset 5 :size 1) + (abe uint8 :offset 6 :size 1) + (aa1 uint8 :offset 7 :size 1) + (fst uint8 :offset 8 :size 1) + (ctxt uint8 :offset 9 :size 1) + (fix uint8 :offset 10 :size 1) + ) + :flag-assert #x900000008 + ) + +(deftype gif-tag64 (uint64) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim gs-prim :offset 47 :size 11) + (flg uint8 :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4)) + :flag-assert #x900000008 + ) + +(defenum gif-reg-id + :bitfield #f + :type uint8 + (prim 0) + (rgbaq 1) + (st 2) + (uv 3) + (xyzf2 4) + (xyz2 5) + (tex0-1 6) + (tex0-2 7) + (clamp-1 8) + (clamp-2 9) + (fog 10) + (xyzf3 12) + (xyz3 13) + (a+d 14) + (nop 15) + ) + +(deftype gif-tag-regs (uint64) + ((regs0 gif-reg-id :offset 0 :size 4) + (regs1 gif-reg-id :offset 4 :size 4) + (regs2 gif-reg-id :offset 8 :size 4) + (regs3 gif-reg-id :offset 12 :size 4) + (regs4 gif-reg-id :offset 16 :size 4) + (regs5 gif-reg-id :offset 20 :size 4) + (regs6 gif-reg-id :offset 24 :size 4) + (regs7 gif-reg-id :offset 28 :size 4) + (regs8 gif-reg-id :offset 32 :size 4) + (regs9 gif-reg-id :offset 36 :size 4) + (regs10 gif-reg-id :offset 40 :size 4) + (regs11 gif-reg-id :offset 44 :size 4) + (regs12 gif-reg-id :offset 48 :size 4) + (regs13 gif-reg-id :offset 52 :size 4) + (regs14 gif-reg-id :offset 56 :size 4) + (regs15 gif-reg-id :offset 60 :size 4) + ) + ) + +;; change this type when you want the decompiler to output nice gif-tags, +;; change it back when you're done or other stuff breaks. +;; ND did something REALLY strange with these and now we have to suffer from it (deftype dma-gif-packet (structure) ((dma-vif dma-packet :inline :offset-assert 0) - (gif uint64 2 :offset-assert 16) ;; guess + ;(gif gif-tag64 :offset-assert 16) + ;(gif-regs gif-tag-regs :offset-assert 24) + (gif uint64 2 :offset-assert 16) (quad uint128 2 :offset 0) ) :method-count-assert 9 @@ -3066,31 +3148,8 @@ :flag-assert #x900000008 ) -(defenum gs-prim-type - :type uint8 - (point 0) - (line 1) - (line-strip 2) - (tri 3) - (tri-strip 4) - (tri-fan 5) - (sprite 6) - ) -;; the GS's PRIM register specifies the types of drawing primitives and various attributes, and -;; initializes the contents of the vertex queue. -(deftype gs-prim (uint64) - ((prim gs-prim-type :offset 0 :size 3) - (iip uint8 :offset 3 :size 1) - (tme uint8 :offset 4 :size 1) - (fge uint8 :offset 5 :size 1) - (abe uint8 :offset 6 :size 1) - (aa1 uint8 :offset 7 :size 1) - (fst uint8 :offset 8 :size 1) - (ctxt uint8 :offset 9 :size 1) - (fix uint8 :offset 10 :size 1) - ) - :flag-assert #x900000008 - ) +;; gap! + ;; the GS's RGBAQ register sets the RGBA value of the vertex and the Q value of the normalized ;; texture coordinates. (deftype gs-rgbaq (uint64) @@ -3340,16 +3399,6 @@ () :flag-assert #x900000004 ) -(deftype gif-tag64 (uint64) - ((nloop uint16 :offset 0 :size 15) - (eop uint8 :offset 15 :size 1) - (id uint16 :offset 32 :size 14) - (pre uint8 :offset 46 :size 1) - (prim uint16 :offset 47 :size 11) - (flg uint8 :offset 58 :size 2) - (nreg uint8 :offset 60 :size 4)) - :flag-assert #x900000008 - ) (deftype gif-tag (uint128) ((nloop uint16 :offset 0 :size 15) (eop uint8 :offset 15 :size 1) @@ -3378,46 +3427,6 @@ :flag-assert #x900000010 ) -(defenum gs-reg-id - :bitfield #f - :type uint8 - (prim 0) - (rgbaq 1) - (st 2) - (uv 3) - (xyzf2 4) - (xyz2 5) - (tex0-1 6) - (tex0-2 7) - (clamp-1 8) - (clamp-2 9) - (fog 10) - (xyzf3 12) - (xyz3 13) - (a+d 14) - (nop 15) - ) - -(deftype gif-tag-regs (uint64) - ((regs0 gs-reg-id :offset 0 :size 4) - (regs1 gs-reg-id :offset 4 :size 4) - (regs2 gs-reg-id :offset 8 :size 4) - (regs3 gs-reg-id :offset 12 :size 4) - (regs4 gs-reg-id :offset 16 :size 4) - (regs5 gs-reg-id :offset 20 :size 4) - (regs6 gs-reg-id :offset 24 :size 4) - (regs7 gs-reg-id :offset 28 :size 4) - (regs8 gs-reg-id :offset 32 :size 4) - (regs9 gs-reg-id :offset 36 :size 4) - (regs10 gs-reg-id :offset 40 :size 4) - (regs11 gs-reg-id :offset 44 :size 4) - (regs12 gs-reg-id :offset 48 :size 4) - (regs13 gs-reg-id :offset 52 :size 4) - (regs14 gs-reg-id :offset 56 :size 4) - (regs15 gs-reg-id :offset 60 :size 4) - ) - ) - (deftype gs-gif-tag (structure) ((qword uint128 :offset-assert 0) ;; is "qword" and inline? in game @@ -3675,7 +3684,7 @@ :flag-assert #xa0000039c (:methods (new (symbol type int int int int int) _type_ 0) - (set-video-time-params (_type_ float) float 9) + (set-time-ratios (_type_ float) float 9) ) ) @@ -4510,7 +4519,7 @@ ) (deftype char-color (structure) - ((color uint32 4 :offset-assert 0) + ((color rgba 4 :offset-assert 0) ) :method-count-assert 9 :size-assert #x10 @@ -4523,7 +4532,7 @@ (width float :offset-assert 48) (height float :offset-assert 52) (projection float :offset-assert 56) - (color uint64 :offset-assert 64) + (color int64 :offset-assert 64) (flags uint32 :offset-assert 72) (mat matrix :offset-assert 76) (start-line uint32 :offset-assert 80) @@ -4533,17 +4542,17 @@ :size-assert #x58 :flag-assert #x1400000058 (:methods - (new (symbol type matrix int int float int int) _type_ 0) + (new (symbol type matrix int int float int 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) - (set-w! (font-context int) font-context 12) + (set-w! (font-context float) font-context 12) (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 uint64) font-context 16) - (set-flags! (font-context uint32) font-context 17) - (set-start-line! (font-context uint32) font-context 18) + (set-color! (font-context int) 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) ) ) @@ -4572,7 +4581,7 @@ (dest-verts char-verts :inline :offset-assert 752) (justify vector 64 :inline :offset-assert 944) (color-shadow vector4w :inline :offset-assert 1968) - (color-table vector16b 64 :inline :offset-assert 1984) + (color-table char-color 64 :inline :offset-assert 1984) (last-color uint64 :offset-assert 3008) (save-last-color uint64 :offset-assert 3016) (buf basic :offset-assert 3024) diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index e070878f15..22eaebd119 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -209,12 +209,6 @@ "text-h": [["L2", "_auto_", true]], - "font-h": [ - ["L18", "matrix", true], - ["L19", "float", true], - ["L17", "font-work", true] - ], - "display": [ ["L47", "float", true], ["L42", "float", true], diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index 6414df9646..f671901c21 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -778,6 +778,47 @@ "args": ["packet", "reg-idx", "reg-val"], "vars": { "v1-0": "tag" } }, + + "(method 9 font-context)": { + "args": ["obj", "mat"] + }, + "(method 10 font-context)": { + "args": ["obj", "x", "y"] + }, + "(method 11 font-context)": { + "args": ["obj", "z"] + }, + "(method 12 font-context)": { + "args": ["obj", "w"] + }, + "(method 13 font-context)": { + "args": ["obj", "width"] + }, + "(method 14 font-context)": { + "args": ["obj", "height"] + }, + "(method 15 font-context)": { + "args": ["obj", "proj"] + }, + "(method 16 font-context)": { + "args": ["obj", "color"] + }, + "(method 17 font-context)": { + "args": ["obj", "flags"] + }, + "(method 18 font-context)": { + "args": ["obj", "start-line"] + }, + "(method 19 font-context)": { + "args": ["obj", "scale"] + }, + "(method 0 font-context)": { + "args": ["allocation", "type-to-make", "mat", "x", "y", "z", "color", "flags"], + "vars": { "v0-0": "obj" } + }, + "font-set-tex0": { + "args": ["ptr-tex0", "tex", "tex-addr", "psm", "clut-addr"] + }, "(method 0 display-frame)": { "vars": { "gp-0": "obj" } diff --git a/goal_src/engine/camera/math-camera.gc b/goal_src/engine/camera/math-camera.gc index 9d6daea950..4db850d116 100644 --- a/goal_src/engine/camera/math-camera.gc +++ b/goal_src/engine/camera/math-camera.gc @@ -404,4 +404,6 @@ (update-math-camera obj 'ntsc 'aspect4x3) ) +(define *math-camera* (new 'global 'math-camera)) + diff --git a/goal_src/engine/gfx/font-h.gc b/goal_src/engine/gfx/font-h.gc index 4d3eaec50f..42a1412bf6 100644 --- a/goal_src/engine/gfx/font-h.gc +++ b/goal_src/engine/gfx/font-h.gc @@ -5,3 +5,661 @@ ;; name in dgo: font-h ;; dgos: GAME, ENGINE + +(deftype char-verts (structure) + ((pos vector 4 :inline :offset-assert 0) + (color vector 4 :inline :offset-assert 64) + (tex-st vector 4 :inline :offset-assert 128) + ) + :method-count-assert 9 + :size-assert #xc0 + :flag-assert #x9000000c0 + ) + +(deftype char-color (structure) + ((color rgba 4 :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(define *font-default-matrix* (new 'static 'matrix + :data (new 'static 'array float 16 + 1.0 0.0 0.0 0.0 + 0.0 1.0 0.0 0.0 + 0.0 0.0 1.0 0.0 + -256.0 0.0 0.0 1.0 + ) + ) + ) + +(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) + (color int64 :offset-assert 64) + (flags uint32 :offset-assert 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) + (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) + (set-w! (font-context float) font-context 12) + (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-flags! (font-context uint) font-context 17) + (set-start-line! (font-context uint) font-context 18) + (set-scale! (font-context float) font-context 19) + ) + ) + +;; I don't believe these methods are called, so they might be inlined + +(defmethod set-mat! font-context ((obj font-context) (mat matrix)) + (declare (inline)) + + (set! (-> obj mat) mat) + obj + ) + +(defmethod set-origin! font-context ((obj font-context) (x int) (y int)) + (declare (inline)) + + (set! (-> obj origin x) (the float x)) + (set! (-> obj origin y) (the float y)) + obj + ) + +(defmethod set-depth! font-context ((obj font-context) (z int)) + (declare (inline)) + + (set! (-> obj origin z) (the float z)) + obj + ) + +(defmethod set-w! font-context ((obj font-context) (w float)) + (declare (inline)) + + (set! (-> obj origin w) w) + obj + ) + +(defmethod set-width! font-context ((obj font-context) (width int)) + (declare (inline)) + + (set! (-> obj width) (the float width)) + obj + ) + +(defmethod set-height! font-context ((obj font-context) (height int)) + (declare (inline)) + + (set! (-> obj height) (the float height)) + obj + ) + +(defmethod set-projection! font-context ((obj font-context) (proj float)) + (declare (inline)) + + (set! (-> obj projection) proj) + obj + ) + +(defmethod set-color! font-context ((obj font-context) (color int)) + (declare (inline)) + + (set! (-> obj color) color) + obj + ) + +(defmethod set-flags! font-context ((obj font-context) (flags uint)) + (declare (inline)) + + (set! (-> obj flags) flags) + obj + ) + +(defmethod set-start-line! font-context ((obj font-context) (start-line uint)) + (declare (inline)) + + (set! (-> obj start-line) start-line) + obj + ) + +(defmethod set-scale! font-context ((obj font-context) (scale float)) + (declare (inline)) + + (set! (-> obj scale) scale) + obj + ) + +(defmethod new font-context ((allocation symbol) (type-to-make type) (mat matrix) (x int) (y int) (z float) (color int) (flags uint)) + "Allocate a new font-context with the given parameters" + + (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set-mat! obj mat) + (set-origin! obj x y) + (if (= z 0) + (set! (-> obj origin z) (-> *math-camera* isometric data 14)) ;; inlined set-depth! + (set! (-> obj origin z) z) ;; inlined set-depth! + ) + (set-w! obj 1.0) + (set-width! obj 512) + (set-width! obj 256) + (set-projection! obj 1.0) + (set-color! obj color) + (set-flags! obj flags) + (set-start-line! obj (the-as uint 0)) + (set-scale! obj 1.0) + obj + ) + ) + +(deftype font-work (structure) + ((font-tmpl dma-gif-packet :inline :offset-assert 0) + (char-tmpl dma-gif-packet :inline :offset-assert 32) + (tex1-tmpl uint64 2 :offset-assert 64) + (small-font-lo-tmpl uint64 2 :offset-assert 80) + (small-font-hi-tmpl uint64 2 :offset-assert 96) + (large-font-lo-tmpl uint64 2 :offset-assert 112) + (large-font-hi-tmpl uint64 2 :offset-assert 128) + (size1-small vector :inline :offset-assert 144) + (size2-small vector :inline :offset-assert 160) + (size3-small vector :inline :offset-assert 176) + (size1-large vector :inline :offset-assert 192) + (size2-large vector :inline :offset-assert 208) + (size3-large vector :inline :offset-assert 224) + (size-st1 vector :inline :offset-assert 240) + (size-st2 vector :inline :offset-assert 256) + (size-st3 vector :inline :offset-assert 272) + (save vector :inline :offset-assert 288) + (save-color vector 4 :inline :offset-assert 304) + (current-verts char-verts :inline :offset-assert 368) + (src-verts char-verts :inline :offset-assert 560) + (dest-verts char-verts :inline :offset-assert 752) + (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) + (save-last-color uint64 :offset-assert 3016) + (buf basic :offset-assert 3024) + (str-ptr uint32 :offset-assert 3028) + (flags uint32 :offset-assert 3032) + (reg-save uint32 5 :offset-assert 3036) + ) + :method-count-assert 9 + :size-assert #xbf0 + :flag-assert #x900000bf0 + ) + +(define *font-work* (new 'static 'font-work + :font-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (gif-tag->static-array + (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :pre #x1 :prim #x5c :nreg #x1) ;; (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip 1 :tme 1 :abe 1) + (new 'static 'gif-tag-regs + :regs0 (gif-reg-id a+d) + )) + ) + :char-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #xe :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #xe :cmd (vif-cmd direct) :msk #x1) + ) + :gif (gif-tag->static-array + (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :pre #x1 :prim #x5c :nreg #xd) ;; (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip 1 :tme 1 :abe 1) + (new 'static 'gif-tag-regs + :regs0 (gif-reg-id a+d) + :regs1 (gif-reg-id st) + :regs2 (gif-reg-id rgbaq) + :regs3 (gif-reg-id xyzf2) + :regs4 (gif-reg-id st) + :regs5 (gif-reg-id rgbaq) + :regs6 (gif-reg-id xyzf2) + :regs7 (gif-reg-id st) + :regs8 (gif-reg-id rgbaq) + :regs9 (gif-reg-id xyzf2) + :regs10 (gif-reg-id st) + :regs11 (gif-reg-id rgbaq) + :regs12 (gif-reg-id xyzf2) + )) + ) + :tex1-tmpl (new 'static 'array uint64 2 #x60 #x14) + :small-font-lo-tmpl (new 'static 'array uint64 2 #x0 #x6) + :small-font-hi-tmpl (new 'static 'array uint64 2 #x0 #x6) + :large-font-lo-tmpl (new 'static 'array uint64 2 #x0 #x6) + :large-font-hi-tmpl (new 'static 'array uint64 2 #x0 #x6) + :size1-small (new 'static 'vector :x 12.0 :y 0.0 :w 0.5) + :size2-small (new 'static 'vector :x 0.0 :y 8.0 :w 8.0) + :size3-small (new 'static 'vector :x 12.0 :y 8.0 :w 8.0) + :size1-large (new 'static 'vector :x 24.0 :y 0.0 :w 1.0) + :size2-large (new 'static 'vector :x 0.0 :y 16.0 :w 16.0) + :size3-large (new 'static 'vector :x 24.0 :y 16.0 :w 16.0) + :size-st1 (new 'static 'vector :x 0.08985 :y 0.0 :w 0.5) + :size-st2 (new 'static 'vector :x 0.0 :y 0.06153846 :w 0.5) + :size-st3 (new 'static 'vector :x 0.08985 :y 0.06153846 :w 0.5) + :current-verts (new 'static 'char-verts + :pos (new 'static 'inline-array vector 4 + (new 'static 'vector :w 1.0) + (new 'static 'vector :w 1.0) + (new 'static 'vector :w 1.0) + (new 'static 'vector :w 1.0) + ) + :tex-st (new 'static 'inline-array vector 4 + (new 'static 'vector :z 1.0) + (new 'static 'vector :z 1.0) + (new 'static 'vector :z 1.0) + (new 'static 'vector :z 1.0) + ) + ) + :src-verts (new 'static 'char-verts + :pos (new 'static 'inline-array vector 4 + (new 'static 'vector :w 1.0) + (new 'static 'vector :w 1.0) + (new 'static 'vector :w 1.0) + (new 'static 'vector :w 1.0) + ) + :tex-st (new 'static 'inline-array vector 4 + (new 'static 'vector :z 1.0) + (new 'static 'vector :z 1.0) + (new 'static 'vector :z 1.0) + (new 'static 'vector :z 1.0) + ) + ) + :dest-verts (new 'static 'char-verts + :pos (new 'static 'inline-array vector 4 + (new 'static 'vector :w 1.0) + (new 'static 'vector :w 1.0) + (new 'static 'vector :w 1.0) + (new 'static 'vector :w 1.0) + ) + :tex-st (new 'static 'inline-array vector 4 + (new 'static 'vector :z 1.0) + (new 'static 'vector :z 1.0) + (new 'static 'vector :z 1.0) + (new 'static 'vector :z 1.0) + ) + ) + :color-shadow (new 'static 'vector4w :x #x00 :y #x00 :z #x00 :w #x80) + ;; TODO - make enum for this + :color-table (new 'static 'inline-array char-color 64 + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x70 #x78 #x70 #x80) + (new-rgba #x70 #x78 #x70 #x80) + (new-rgba #x30 #x38 #x30 #x80) + (new-rgba #x30 #x38 #x30 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x80 #x80 #x80 #x80) + (new-rgba #x80 #x80 #x80 #x80) + (new-rgba #x60 #x60 #x60 #x80) + (new-rgba #x60 #x60 #x60 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x80 #x80 #x80 #x40) + (new-rgba #x80 #x80 #x80 #x40) + (new-rgba #x60 #x60 #x60 #x40) + (new-rgba #x60 #x60 #x60 #x40) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x80 #x60 #x20 #x80) + (new-rgba #x80 #x60 #x20 #x80) + (new-rgba #x60 #x00 #x00 #x80) + (new-rgba #x60 #x00 #x00 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x80 #x64 #x00 #x80) + (new-rgba #x80 #x64 #x00 #x80) + (new-rgba #x80 #x00 #x00 #x80) + (new-rgba #x80 #x00 #x00 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x80 #x80 #x00 #x80) + (new-rgba #x80 #x80 #x00 #x80) + (new-rgba #x28 #x28 #x00 #x80) + (new-rgba #x28 #x28 #x00 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x20 #x80 #x20 #x80) + (new-rgba #x20 #x80 #x20 #x80) + (new-rgba #x00 #x30 #x00 #x80) + (new-rgba #x00 #x30 #x00 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x40 #x40 #x80 #x80) + (new-rgba #x40 #x40 #x80 #x80) + (new-rgba #x00 #x00 #x60 #x80) + (new-rgba #x00 #x00 #x60 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x00 #x80 #x80 #x80) + (new-rgba #x00 #x80 #x80 #x80) + (new-rgba #x00 #x20 #x50 #x80) + (new-rgba #x00 #x20 #x50 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x80 #x40 #x80 #x80) + (new-rgba #x80 #x40 #x80 #x80) + (new-rgba #x30 #x00 #x30 #x80) + (new-rgba #x30 #x00 #x30 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x60 #x80 #x80 #x80) + (new-rgba #x60 #x80 #x80 #x80) + (new-rgba #x00 #x40 #x60 #x80) + (new-rgba #x00 #x40 #x60 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x40 #x60 #x60 #x80) + (new-rgba #x40 #x60 #x60 #x80) + (new-rgba #x00 #x20 #x40 #x80) + (new-rgba #x00 #x20 #x40 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x80 #x80 #x80 #x80) + (new-rgba #x80 #x80 #x80 #x80) + (new-rgba #x50 #x50 #x50 #x80) + (new-rgba #x50 #x50 #x50 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x50 #x50 #x50 #x80) + (new-rgba #x50 #x50 #x50 #x80) + (new-rgba #x28 #x28 #x28 #x80) + (new-rgba #x28 #x28 #x28 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x80 #x54 #x00 #x80) + (new-rgba #x80 #x54 #x00 #x80) + (new-rgba #x60 #x00 #x00 #x80) + (new-rgba #x60 #x00 #x00 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x70 #x80 #x30 #x80) + (new-rgba #x70 #x80 #x30 #x80) + (new-rgba #x00 #x60 #x00 #x80) + (new-rgba #x00 #x60 #x00 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x48 #x58 #x8 #x80) + (new-rgba #x48 #x58 #x10 #x80) + (new-rgba #x00 #x38 #x00 #x80) + (new-rgba #x00 #x38 #x00 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x58 #x60 #x58 #x80) + (new-rgba #x58 #x60 #x58 #x80) + (new-rgba #x30 #x40 #x30 #x80) + (new-rgba #x30 #x40 #x30 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x40 #x48 #x40 #x80) + (new-rgba #x40 #x48 #x40 #x80) + (new-rgba #x18 #x28 #x18 #x80) + (new-rgba #x18 #x28 #x18 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x30 #x20 #x30 #x80) + (new-rgba #x30 #x20 #x30 #x80) + (new-rgba #x30 #x20 #x30 #x80) + (new-rgba #x30 #x20 #x30 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x80 #x79 #x48 #x80) + (new-rgba #x80 #x79 #x48 #x80) + (new-rgba #x80 #x79 #x48 #x80) + (new-rgba #x80 #x79 #x48 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x20 #x5e #x78 #x80) + (new-rgba #x20 #x5e #x78 #x80) + (new-rgba #x80 #x7d #x4f #x80) + (new-rgba #x80 #x7d #x4f #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x1d #x1d #x1d #x80) + (new-rgba #x1d #x1d #x1d #x80) + (new-rgba #x1d #x1d #x1d #x80) + (new-rgba #x1d #x1d #x1d #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x40 #x40 #x40 #x80) + (new-rgba #x40 #x40 #x40 #x80) + (new-rgba #x40 #x40 #x40 #x80) + (new-rgba #x40 #x40 #x40 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x7a #x4d #x65 #x80) + (new-rgba #x7a #x4d #x65 #x80) + (new-rgba #x7a #x4d #x65 #x80) + (new-rgba #x7a #x4d #x65 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x7a #x34 #x34 #x80) + (new-rgba #x7a #x34 #x34 #x80) + (new-rgba #x7a #x34 #x34 #x80) + (new-rgba #x7a #x34 #x34 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x10 #x65 #x4c #x80) + (new-rgba #x10 #x65 #x4c #x80) + (new-rgba #x10 #x65 #x4c #x80) + (new-rgba #x10 #x65 #x4c #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x46 #x4a #x78 #x80) + (new-rgba #x46 #x4a #x78 #x80) + (new-rgba #x46 #x4a #x78 #x80) + (new-rgba #x46 #x4a #x78 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x57 #x7e #x80 #x80) + (new-rgba #x57 #x7e #x80 #x80) + (new-rgba #x29 #x63 #x79 #x80) + (new-rgba #x29 #x63 #x70 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x7f #x7b #x33 #x80) + (new-rgba #x7f #x7b #x33 #x80) + (new-rgba #x76 #x40 #x14 #x80) + (new-rgba #x76 #x40 #x14 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x79 #x79 #x2 #x80) + (new-rgba #x79 #x79 #x2 #x80) + (new-rgba #x1b #x51 #x20 #x80) + (new-rgba #x1b #x51 #x20 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x47 #x68 #x7a #x80) + (new-rgba #x47 #x68 #x7a #x80) + (new-rgba #x00 #x3c #x4f #x80) + (new-rgba #x00 #x3c #x4f #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x70 #x78 #x70 #x80) + (new-rgba #x70 #x78 #x70 #x80) + (new-rgba #x30 #x38 #x30 #x80) + (new-rgba #x30 #x38 #x30 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x60 #x00 #x00 #x80) + (new-rgba #x60 #x00 #x00 #x80) + (new-rgba #x80 #x60 #x20 #x80) + (new-rgba #x80 #x60 #x20 #x80) + ) + ) + (new 'static 'char-color + :color + (new 'static 'array rgba 4 + (new-rgba #x80 #x60 #x20 #x80) + (new-rgba #x80 #x60 #x20 #x80) + (new-rgba #x60 #x00 #x00 #x80) + (new-rgba #x60 #x00 #x00 #x80) + ) + ) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + (new 'static 'char-color) + ) + ) + ) + +(defun font-set-tex0 ((ptr-tex0 (pointer gs-tex0)) (tex texture) (tex-addr uint) (psm uint) (clut-addr uint)) + "Write the TEX0 parameters for a font" + + (set! (-> ptr-tex0) (new 'static 'gs-tex0 + :tcc #x1 + :cld #x1 + :cbp clut-addr + :th (log2 (-> tex h)) + :tw (log2 (-> tex w)) + :tbw (-> tex width 0) + :tbp0 (sar tex-addr 6) + :psm psm + )) + (none) + ) + + diff --git a/goal_src/engine/gfx/hw/display-h.gc b/goal_src/engine/gfx/hw/display-h.gc index 2f57759508..4b1d6a595a 100644 --- a/goal_src/engine/gfx/hw/display-h.gc +++ b/goal_src/engine/gfx/hw/display-h.gc @@ -218,7 +218,7 @@ :flag-assert #xa0000039c (:methods (new (symbol type int int int int int) _type_ 0) - (set-video-time-params (_type_ float) float 9) + (set-time-ratios (_type_ float) float 9) ) ) diff --git a/goal_src/engine/gfx/hw/display.gc b/goal_src/engine/gfx/hw/display.gc index d66cc090ba..26f2cb9919 100644 --- a/goal_src/engine/gfx/hw/display.gc +++ b/goal_src/engine/gfx/hw/display.gc @@ -25,8 +25,8 @@ ) -(defmethod set-video-time-params display ((obj display) (slowdown float)) - "Set timing parameters for the current game speed. For example, set slowdown = 1.0 if the game +(defmethod set-time-ratios display ((obj display) (slowdown float)) + "Set the time ratios for the current game speed. For example, set slowdown = 1.0 if the game is running at full speed or slowdown = 2.0 if the game is running at half speed." ;; don't allow slowdowns of more than 4x. This prevents the dt's in the physics @@ -216,7 +216,7 @@ (let ((v1-0 (-> disp gif-tag0))) ;; 8x registers, data in a+d format. (set! (-> v1-0 tag) (new 'static 'gif-tag64 :nloop #x8 :eop #x1 :nreg #x1)) - (set! (-> v1-0 regs) (new 'static 'gif-tag-regs :regs0 (gs-reg-id a+d))) + (set! (-> v1-0 regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))) ) ;; copy to the other envs. @@ -281,11 +281,10 @@ arg0 ) -;; need font-h. -#| -(define *font-context* (new 'global 'font-context *font-default-matrix* 0 24 0.0 0 3)) -(define *pause-context* (new 'global 'font-context *font-default-matrix* 256 170 0.0 3 3)) -|# + +(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))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -392,10 +391,10 @@ ;; each block gets a prim, color, and two vertices. (set! (-> start-gif-tag regs) (new 'static 'gif-tag-regs - :regs0 (gs-reg-id prim) - :regs1 (gs-reg-id rgbaq) - :regs2 (gs-reg-id xyzf2) - :regs3 (gs-reg-id xyzf2) + :regs0 (gif-reg-id prim) + :regs1 (gif-reg-id rgbaq) + :regs2 (gif-reg-id xyzf2) + :regs3 (gif-reg-id xyzf2) ) ) (set! (-> t1-1 base) (&+ (the-as pointer start-gif-tag) 16)) @@ -554,10 +553,10 @@ (set! (-> gif tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :flg #x1 :nreg #x4)) (set! (-> gif regs) (new 'static 'gif-tag-regs - :regs0 (gs-reg-id prim) - :regs1 (gs-reg-id rgbaq) - :regs2 (gs-reg-id xyzf2) - :regs3 (gs-reg-id xyzf2) + :regs0 (gif-reg-id prim) + :regs1 (gif-reg-id rgbaq) + :regs2 (gif-reg-id xyzf2) + :regs3 (gif-reg-id xyzf2) ) ) (set! (-> a2-3 base) (&+ (the-as pointer gif) 16)) @@ -644,14 +643,14 @@ ) (set! (-> gif regs) (new 'static 'gif-tag-regs - :regs1 (gs-reg-id rgbaq) - :regs2 (gs-reg-id xyzf2) - :regs3 (gs-reg-id rgbaq) - :regs4 (gs-reg-id xyzf2) - :regs5 (gs-reg-id rgbaq) - :regs6 (gs-reg-id xyzf2) - :regs7 (gs-reg-id rgbaq) - :regs8 (gs-reg-id xyzf2) + :regs1 (gif-reg-id rgbaq) + :regs2 (gif-reg-id xyzf2) + :regs3 (gif-reg-id rgbaq) + :regs4 (gif-reg-id xyzf2) + :regs5 (gif-reg-id rgbaq) + :regs6 (gif-reg-id xyzf2) + :regs7 (gif-reg-id rgbaq) + :regs8 (gif-reg-id xyzf2) ) ) (set! (-> t0-1 base) (&+ (the-as pointer gif) 16)) @@ -778,22 +777,22 @@ (set! (-> gif tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x7)) (set! (-> gif regs) (new 'static 'gif-tag-regs - :regs0 (gs-reg-id a+d) - :regs1 (gs-reg-id a+d) - :regs2 (gs-reg-id a+d) - :regs3 (gs-reg-id a+d) - :regs4 (gs-reg-id a+d) - :regs5 (gs-reg-id a+d) - :regs6 (gs-reg-id a+d) - :regs7 (gs-reg-id a+d) - :regs8 (gs-reg-id a+d) - :regs9 (gs-reg-id a+d) - :regs10 (gs-reg-id a+d) - :regs11 (gs-reg-id a+d) - :regs12 (gs-reg-id a+d) - :regs13 (gs-reg-id a+d) - :regs14 (gs-reg-id a+d) - :regs15 (gs-reg-id a+d) + :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-2 base) (&+ (the-as pointer gif) 16)) @@ -859,22 +858,22 @@ (set! (-> gif tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x7)) (set! (-> gif regs) (new 'static 'gif-tag-regs - :regs0 (gs-reg-id a+d) - :regs1 (gs-reg-id a+d) - :regs2 (gs-reg-id a+d) - :regs3 (gs-reg-id a+d) - :regs4 (gs-reg-id a+d) - :regs5 (gs-reg-id a+d) - :regs6 (gs-reg-id a+d) - :regs7 (gs-reg-id a+d) - :regs8 (gs-reg-id a+d) - :regs9 (gs-reg-id a+d) - :regs10 (gs-reg-id a+d) - :regs11 (gs-reg-id a+d) - :regs12 (gs-reg-id a+d) - :regs13 (gs-reg-id a+d) - :regs14 (gs-reg-id a+d) - :regs15 (gs-reg-id a+d) + :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-2 base) (&+ (the-as pointer gif) 16)) @@ -941,22 +940,22 @@ (set! (-> gif regs) (new 'static 'gif-tag-regs - :regs0 (gs-reg-id a+d) - :regs1 (gs-reg-id a+d) - :regs2 (gs-reg-id a+d) - :regs3 (gs-reg-id a+d) - :regs4 (gs-reg-id a+d) - :regs5 (gs-reg-id a+d) - :regs6 (gs-reg-id a+d) - :regs7 (gs-reg-id a+d) - :regs8 (gs-reg-id a+d) - :regs9 (gs-reg-id a+d) - :regs10 (gs-reg-id a+d) - :regs11 (gs-reg-id a+d) - :regs12 (gs-reg-id a+d) - :regs13 (gs-reg-id a+d) - :regs14 (gs-reg-id a+d) - :regs15 (gs-reg-id a+d) + :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! (-> a3-2 base) (&+ (the-as pointer gif) 16)) diff --git a/goal_src/engine/gfx/hw/gs.gc b/goal_src/engine/gfx/hw/gs.gc index a2f43ff9bb..e730b41e51 100644 --- a/goal_src/engine/gfx/hw/gs.gc +++ b/goal_src/engine/gfx/hw/gs.gc @@ -534,13 +534,13 @@ :flag-assert #x900000004 ) (deftype gif-tag64 (uint64) - ((nloop uint16 :offset 0 :size 15) - (eop uint8 :offset 15 :size 1) - (id uint16 :offset 32 :size 14) - (pre uint8 :offset 46 :size 1) - (prim uint16 :offset 47 :size 11) - (flg uint8 :offset 58 :size 2) - (nreg uint8 :offset 60 :size 4)) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim gs-prim :offset 47 :size 11) + (flg uint8 :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4)) :flag-assert #x900000008 ) (deftype gif-tag (uint128) @@ -571,7 +571,7 @@ :flag-assert #x900000010 ) -(defenum gs-reg-id +(defenum gif-reg-id :bitfield #f :type uint8 (prim 0) @@ -592,25 +592,32 @@ ) (deftype gif-tag-regs (uint64) - ((regs0 gs-reg-id :offset 0 :size 4) - (regs1 gs-reg-id :offset 4 :size 4) - (regs2 gs-reg-id :offset 8 :size 4) - (regs3 gs-reg-id :offset 12 :size 4) - (regs4 gs-reg-id :offset 16 :size 4) - (regs5 gs-reg-id :offset 20 :size 4) - (regs6 gs-reg-id :offset 24 :size 4) - (regs7 gs-reg-id :offset 28 :size 4) - (regs8 gs-reg-id :offset 32 :size 4) - (regs9 gs-reg-id :offset 36 :size 4) - (regs10 gs-reg-id :offset 40 :size 4) - (regs11 gs-reg-id :offset 44 :size 4) - (regs12 gs-reg-id :offset 48 :size 4) - (regs13 gs-reg-id :offset 52 :size 4) - (regs14 gs-reg-id :offset 56 :size 4) - (regs15 gs-reg-id :offset 60 :size 4) + ((regs0 gif-reg-id :offset 0 :size 4) + (regs1 gif-reg-id :offset 4 :size 4) + (regs2 gif-reg-id :offset 8 :size 4) + (regs3 gif-reg-id :offset 12 :size 4) + (regs4 gif-reg-id :offset 16 :size 4) + (regs5 gif-reg-id :offset 20 :size 4) + (regs6 gif-reg-id :offset 24 :size 4) + (regs7 gif-reg-id :offset 28 :size 4) + (regs8 gif-reg-id :offset 32 :size 4) + (regs9 gif-reg-id :offset 36 :size 4) + (regs10 gif-reg-id :offset 40 :size 4) + (regs11 gif-reg-id :offset 44 :size 4) + (regs12 gif-reg-id :offset 48 :size 4) + (regs13 gif-reg-id :offset 52 :size 4) + (regs14 gif-reg-id :offset 56 :size 4) + (regs15 gif-reg-id :offset 60 :size 4) ) ) +;; we unfortunately kind of need this +(defmacro gif-tag->static-array (tag regs) + "Allocates a new static array of two uint64's making up the gif-tag and the tag registers" + + `(new 'static 'array uint64 2 ,tag ,regs) + ) + (deftype gs-gif-tag (structure) ((qword uint128 :offset-assert 0) ;; is "qword" and inline? in game (tag gif-tag64 :offset 0) @@ -673,22 +680,22 @@ ;; this sets all the regs to a+d, but the ones after 9 are ignored. (set! (-> gif-tag regs) (new 'static 'gif-tag-regs - :regs0 (gs-reg-id a+d) - :regs1 (gs-reg-id a+d) - :regs2 (gs-reg-id a+d) - :regs3 (gs-reg-id a+d) - :regs4 (gs-reg-id a+d) - :regs5 (gs-reg-id a+d) - :regs6 (gs-reg-id a+d) - :regs7 (gs-reg-id a+d) - :regs8 (gs-reg-id a+d) - :regs9 (gs-reg-id a+d) - :regs10 (gs-reg-id a+d) - :regs11 (gs-reg-id a+d) - :regs12 (gs-reg-id a+d) - :regs13 (gs-reg-id a+d) - :regs14 (gs-reg-id a+d) - :regs15 (gs-reg-id a+d) + :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! (-> buff-ptr5 base) (&+ (the-as pointer gif-tag) 16)) diff --git a/goal_src/engine/math/vector-h.gc b/goal_src/engine/math/vector-h.gc index a30df4f3d9..6630bc2622 100644 --- a/goal_src/engine/math/vector-h.gc +++ b/goal_src/engine/math/vector-h.gc @@ -198,7 +198,7 @@ ;; Vector of 4 signed words (deftype vector4w (structure) - ((data int32 4 :offset-assert 0) + ((data int32 4 :do-not-decompile :offset-assert 0) (x int32 :offset 0) (y int32 :offset 4) (z int32 :offset 8) diff --git a/goalc/compiler/compilation/Static.cpp b/goalc/compiler/compilation/Static.cpp index 10dc5b9e5d..45df536f5b 100644 --- a/goalc/compiler/compilation/Static.cpp +++ b/goalc/compiler/compilation/Static.cpp @@ -69,6 +69,7 @@ void Compiler::compile_static_structure_inline(const goos::Object& form, field_defs = &pair_cdr(*field_defs); auto field_value = pair_car(*field_defs); + field_value = expand_macro_completely(field_value, env); field_defs = &pair_cdr(*field_defs); if (field_name_def.at(0) != ':') { @@ -838,4 +839,4 @@ Val* Compiler::compile_new_static_structure_or_basic(const goos::Object& form, auto sr = compile_new_static_structure(form, type, field_defs, env); auto result = fe->alloc_val(sr.reference(), type); return result; -} \ No newline at end of file +} diff --git a/scripts/batch/gc.bat b/scripts/batch/gc.bat index b7f3e90fe6..1ae4ba22db 100644 --- a/scripts/batch/gc.bat +++ b/scripts/batch/gc.bat @@ -1,3 +1,3 @@ @echo off cd ..\.. -out\build\Release\bin\goalc -v +out\build\Release\bin\goalc -v -auto-lt diff --git a/test/decompiler/reference/all_forward_declarations.gc b/test/decompiler/reference/all_forward_declarations.gc index a3ee27000c..e45547c391 100644 --- a/test/decompiler/reference/all_forward_declarations.gc +++ b/test/decompiler/reference/all_forward_declarations.gc @@ -242,7 +242,7 @@ (sprite 6) ) -(defenum gs-reg-id +(defenum gif-reg-id :bitfield #f :type uint8 (prim 0) @@ -263,22 +263,22 @@ ) (deftype gif-tag-regs (uint64) - ((regs0 gs-reg-id :offset 0 :size 4) - (regs1 gs-reg-id :offset 4 :size 4) - (regs2 gs-reg-id :offset 8 :size 4) - (regs3 gs-reg-id :offset 12 :size 4) - (regs4 gs-reg-id :offset 16 :size 4) - (regs5 gs-reg-id :offset 20 :size 4) - (regs6 gs-reg-id :offset 24 :size 4) - (regs7 gs-reg-id :offset 28 :size 4) - (regs8 gs-reg-id :offset 32 :size 4) - (regs9 gs-reg-id :offset 36 :size 4) - (regs10 gs-reg-id :offset 40 :size 4) - (regs11 gs-reg-id :offset 44 :size 4) - (regs12 gs-reg-id :offset 48 :size 4) - (regs13 gs-reg-id :offset 52 :size 4) - (regs14 gs-reg-id :offset 56 :size 4) - (regs15 gs-reg-id :offset 60 :size 4) + ((regs0 gif-reg-id :offset 0 :size 4) + (regs1 gif-reg-id :offset 4 :size 4) + (regs2 gif-reg-id :offset 8 :size 4) + (regs3 gif-reg-id :offset 12 :size 4) + (regs4 gif-reg-id :offset 16 :size 4) + (regs5 gif-reg-id :offset 20 :size 4) + (regs6 gif-reg-id :offset 24 :size 4) + (regs7 gif-reg-id :offset 28 :size 4) + (regs8 gif-reg-id :offset 32 :size 4) + (regs9 gif-reg-id :offset 36 :size 4) + (regs10 gif-reg-id :offset 40 :size 4) + (regs11 gif-reg-id :offset 44 :size 4) + (regs12 gif-reg-id :offset 48 :size 4) + (regs13 gif-reg-id :offset 52 :size 4) + (regs14 gif-reg-id :offset 56 :size 4) + (regs15 gif-reg-id :offset 60 :size 4) ) ) diff --git a/test/decompiler/reference/bounding-box_REF.gc b/test/decompiler/reference/bounding-box_REF.gc index 14be2171c8..732f3c3aaf 100644 --- a/test/decompiler/reference/bounding-box_REF.gc +++ b/test/decompiler/reference/bounding-box_REF.gc @@ -4,24 +4,24 @@ ;; definition for function box-vector-enside? (defun box-vector-enside? ((box bounding-box) (pt vector)) (and - (< (-> box min data 0) (-> pt data 0)) - (< (-> box min data 1) (-> pt data 1)) - (< (-> box min data 2) (-> pt data 2)) - (< (-> pt data 0) (-> box max data 0)) - (< (-> pt data 1) (-> box max data 1)) - (< (-> pt data 2) (-> box max data 2)) + (< (-> box min x) (-> pt x)) + (< (-> box min y) (-> pt y)) + (< (-> box min z) (-> pt z)) + (< (-> pt x) (-> box max x)) + (< (-> pt y) (-> box max y)) + (< (-> pt z) (-> box max z)) ) ) ;; definition for function box-vector-inside? (defun box-vector-inside? ((box bounding-box) (pt vector)) (and - (>= (-> pt data 0) (-> box min data 0)) - (>= (-> pt data 1) (-> box min data 1)) - (>= (-> pt data 2) (-> box min data 2)) - (>= (-> box max data 0) (-> pt data 0)) - (>= (-> box max data 1) (-> pt data 1)) - (>= (-> box max data 2) (-> pt data 2)) + (>= (-> pt x) (-> box min x)) + (>= (-> pt y) (-> box min y)) + (>= (-> pt z) (-> box min z)) + (>= (-> box max x) (-> pt x)) + (>= (-> box max y) (-> pt y)) + (>= (-> box max z) (-> pt z)) ) ) @@ -142,3 +142,6 @@ ;; definition for method 9 of type bounding-box ;; ERROR: function was not converted to expressions. Cannot decompile. + + + diff --git a/test/decompiler/reference/decomp-h_REF.gc b/test/decompiler/reference/decomp-h_REF.gc new file mode 100644 index 0000000000..ce04804d85 --- /dev/null +++ b/test/decompiler/reference/decomp-h_REF.gc @@ -0,0 +1,32 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type decomp-work +(deftype decomp-work (structure) + ((buffer0 uint8 2048 :offset-assert 0) + (buffer1 uint8 2048 :offset-assert 2048) + (indices uint16 2048 :offset-assert 4096) + (temp-indices uint16 2048 :offset-assert 8192) + ) + :method-count-assert 9 + :size-assert #x3000 + :flag-assert #x900003000 + ) + +;; definition for method 3 of type decomp-work +(defmethod inspect decomp-work ((obj decomp-work)) + (format #t "[~8x] ~A~%" obj 'decomp-work) + (format #t "~Tbuffer0[2048] @ #x~X~%" (-> obj buffer0)) + (format #t "~Tbuffer1[2048] @ #x~X~%" (-> obj buffer1)) + (format #t "~Tindices[2048] @ #x~X~%" (-> obj indices)) + (format #t "~Ttemp-indices[2048] @ #x~X~%" (-> obj temp-indices)) + obj + ) + +;; failed to figure out what this is: +(let ((v0-1 0)) + ) + + + + diff --git a/test/decompiler/reference/display-h_REF.gc b/test/decompiler/reference/display-h_REF.gc index 8f30daed12..1008657922 100644 --- a/test/decompiler/reference/display-h_REF.gc +++ b/test/decompiler/reference/display-h_REF.gc @@ -200,7 +200,7 @@ :flag-assert #xa0000039c (:methods (new (symbol type int int int int int) _type_ 0) - (set-video-time-params (_type_ float) float 9) + (set-time-ratios (_type_ float) float 9) ) ) @@ -348,3 +348,6 @@ (let ((v0-5 0)) ) + + + diff --git a/test/decompiler/reference/display_REF.gc b/test/decompiler/reference/display_REF.gc index 54d1f5a92d..9237fa35d3 100644 --- a/test/decompiler/reference/display_REF.gc +++ b/test/decompiler/reference/display_REF.gc @@ -12,7 +12,7 @@ ) ;; definition for method 9 of type display -(defmethod set-video-time-params display ((obj display) (slowdown float)) +(defmethod set-time-ratios display ((obj display) (slowdown float)) (let ((ratio (fmin 4.0 slowdown))) (set! (-> obj time-ratio) ratio) (let ((v1-0 (get-video-mode))) @@ -165,7 +165,7 @@ ((disp display) (psm int) (w int) (h int) (ztest int) (zpsm int)) (let ((v1-0 (-> disp gif-tag0))) (set! (-> v1-0 tag) (new 'static 'gif-tag64 :nloop #x8 :eop #x1 :nreg #x1)) - (set! (-> v1-0 regs) (new 'static 'gif-tag-regs :regs0 (gs-reg-id a+d))) + (set! (-> v1-0 regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))) ) (set! (-> disp gif-tag1 qword) (-> disp gif-tag0 qword)) (set! (-> disp gif-tag2 qword) (-> disp gif-tag0 qword)) @@ -263,13 +263,22 @@ ;; definition for symbol *font-context*, type font-context (define *font-context* - (new 'global 'font-context *font-default-matrix* 0 24 0.0 0 3) + (new 'global 'font-context *font-default-matrix* 0 24 0.0 0 (the-as uint 3)) ) ;; definition for symbol *pause-context*, type font-context (define *pause-context* - (new 'global 'font-context *font-default-matrix* 256 170 0.0 3 3) + (new + 'global + 'font-context + *font-default-matrix* + 256 + 170 + 0.0 + 3 + (the-as uint 3) + ) ) ;; definition for method 11 of type profile-bar @@ -377,9 +386,9 @@ (set! (-> start-gif-tag regs) (new 'static 'gif-tag-regs - :regs1 (gs-reg-id rgbaq) - :regs2 (gs-reg-id xyzf2) - :regs3 (gs-reg-id xyzf2) + :regs1 (gif-reg-id rgbaq) + :regs2 (gif-reg-id xyzf2) + :regs3 (gif-reg-id xyzf2) ) ) (set! (-> t1-1 base) (&+ (the-as pointer start-gif-tag) 16)) @@ -544,9 +553,9 @@ (set! (-> gif regs) (new 'static 'gif-tag-regs - :regs1 (gs-reg-id rgbaq) - :regs2 (gs-reg-id xyzf2) - :regs3 (gs-reg-id xyzf2) + :regs1 (gif-reg-id rgbaq) + :regs2 (gif-reg-id xyzf2) + :regs3 (gif-reg-id xyzf2) ) ) (set! (-> a2-3 base) (&+ (the-as pointer gif) 16)) @@ -642,14 +651,14 @@ (set! (-> gif regs) (new 'static 'gif-tag-regs - :regs1 (gs-reg-id rgbaq) - :regs2 (gs-reg-id xyzf2) - :regs3 (gs-reg-id rgbaq) - :regs4 (gs-reg-id xyzf2) - :regs5 (gs-reg-id rgbaq) - :regs6 (gs-reg-id xyzf2) - :regs7 (gs-reg-id rgbaq) - :regs8 (gs-reg-id xyzf2) + :regs1 (gif-reg-id rgbaq) + :regs2 (gif-reg-id xyzf2) + :regs3 (gif-reg-id rgbaq) + :regs4 (gif-reg-id xyzf2) + :regs5 (gif-reg-id rgbaq) + :regs6 (gif-reg-id xyzf2) + :regs7 (gif-reg-id rgbaq) + :regs8 (gif-reg-id xyzf2) ) ) (set! (-> t0-1 base) (&+ (the-as pointer gif) 16)) @@ -804,22 +813,22 @@ (set! (-> gif regs) (new 'static 'gif-tag-regs - :regs0 (gs-reg-id a+d) - :regs1 (gs-reg-id a+d) - :regs2 (gs-reg-id a+d) - :regs3 (gs-reg-id a+d) - :regs4 (gs-reg-id a+d) - :regs5 (gs-reg-id a+d) - :regs6 (gs-reg-id a+d) - :regs7 (gs-reg-id a+d) - :regs8 (gs-reg-id a+d) - :regs9 (gs-reg-id a+d) - :regs10 (gs-reg-id a+d) - :regs11 (gs-reg-id a+d) - :regs12 (gs-reg-id a+d) - :regs13 (gs-reg-id a+d) - :regs14 (gs-reg-id a+d) - :regs15 (gs-reg-id a+d) + :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-2 base) (&+ (the-as pointer gif) 16)) @@ -896,22 +905,22 @@ (set! (-> gif regs) (new 'static 'gif-tag-regs - :regs0 (gs-reg-id a+d) - :regs1 (gs-reg-id a+d) - :regs2 (gs-reg-id a+d) - :regs3 (gs-reg-id a+d) - :regs4 (gs-reg-id a+d) - :regs5 (gs-reg-id a+d) - :regs6 (gs-reg-id a+d) - :regs7 (gs-reg-id a+d) - :regs8 (gs-reg-id a+d) - :regs9 (gs-reg-id a+d) - :regs10 (gs-reg-id a+d) - :regs11 (gs-reg-id a+d) - :regs12 (gs-reg-id a+d) - :regs13 (gs-reg-id a+d) - :regs14 (gs-reg-id a+d) - :regs15 (gs-reg-id a+d) + :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-2 base) (&+ (the-as pointer gif) 16)) @@ -982,22 +991,22 @@ (set! (-> gif regs) (new 'static 'gif-tag-regs - :regs0 (gs-reg-id a+d) - :regs1 (gs-reg-id a+d) - :regs2 (gs-reg-id a+d) - :regs3 (gs-reg-id a+d) - :regs4 (gs-reg-id a+d) - :regs5 (gs-reg-id a+d) - :regs6 (gs-reg-id a+d) - :regs7 (gs-reg-id a+d) - :regs8 (gs-reg-id a+d) - :regs9 (gs-reg-id a+d) - :regs10 (gs-reg-id a+d) - :regs11 (gs-reg-id a+d) - :regs12 (gs-reg-id a+d) - :regs13 (gs-reg-id a+d) - :regs14 (gs-reg-id a+d) - :regs15 (gs-reg-id a+d) + :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! (-> a3-2 base) (&+ (the-as pointer gif) 16)) @@ -1057,3 +1066,5 @@ (allocate-dma-buffers *display*) + + diff --git a/test/decompiler/reference/euler-h_REF.gc b/test/decompiler/reference/euler-h_REF.gc index 984ddaa548..4c371f2ad0 100644 --- a/test/decompiler/reference/euler-h_REF.gc +++ b/test/decompiler/reference/euler-h_REF.gc @@ -25,11 +25,11 @@ ;; Used lq/sq (defmethod inspect euler-angles ((obj euler-angles)) (format #t "[~8x] ~A~%" obj 'euler-angles) - (format #t "~Tdata[4] @ #x~X~%" (-> obj data)) - (format #t "~Tx: ~f~%" (-> obj data 0)) - (format #t "~Ty: ~f~%" (-> obj data 1)) - (format #t "~Tz: ~f~%" (-> obj data 2)) - (format #t "~Tw: ~f~%" (-> obj data 3)) + (format #t "~Tdata[4] @ #x~X~%" (&-> obj x)) + (format #t "~Tx: ~f~%" (-> obj x)) + (format #t "~Ty: ~f~%" (-> obj y)) + (format #t "~Tz: ~f~%" (-> obj z)) + (format #t "~Tw: ~f~%" (-> obj w)) (format #t "~Tquad: ~D~%" (-> obj quad)) obj ) @@ -40,3 +40,4 @@ + diff --git a/test/decompiler/reference/euler_REF.gc b/test/decompiler/reference/euler_REF.gc index d1fe51932a..98f13a7f44 100644 --- a/test/decompiler/reference/euler_REF.gc +++ b/test/decompiler/reference/euler_REF.gc @@ -5,10 +5,10 @@ (defun set-eul! ((arg0 euler-angles) (arg1 float) (arg2 float) (arg3 float) (arg4 int)) - (set! (-> arg0 data 0) arg1) - (set! (-> arg0 data 1) arg2) - (set! (-> arg0 data 2) arg3) - (set! (-> arg0 data 3) (the float arg4)) + (set! (-> arg0 x) arg1) + (set! (-> arg0 y) arg2) + (set! (-> arg0 z) arg3) + (set! (-> arg0 w) (the float arg4)) arg0 ) @@ -18,23 +18,23 @@ (matrix-identity! arg0) (let ((s5-0 (new 'stack-no-clear 'vector))) (set! (-> s5-0 quad) (-> arg1 quad)) - (if (= (logand (the int (-> s5-0 data 3)) 1) 1) - (let ((f0-2 (-> s5-0 data 0))) - (set! (-> s5-0 data 0) (-> s5-0 data 2)) - (set! (-> s5-0 data 2) f0-2) + (if (= (logand (the int (-> s5-0 w)) 1) 1) + (let ((f0-2 (-> s5-0 x))) + (set! (-> s5-0 x) (-> s5-0 z)) + (set! (-> s5-0 z) f0-2) ) ) - (when (= (logand (sar (the int (-> s5-0 data 3)) 2) 1) 1) - (set! (-> s5-0 data 0) (- (-> s5-0 data 0))) - (set! (-> s5-0 data 1) (- (-> s5-0 data 1))) - (set! (-> s5-0 data 2) (- (-> s5-0 data 2))) + (when (= (logand (sar (the int (-> s5-0 w)) 2) 1) 1) + (set! (-> s5-0 x) (- (-> s5-0 x))) + (set! (-> s5-0 y) (- (-> s5-0 y))) + (set! (-> s5-0 z) (- (-> s5-0 z))) ) - (let* ((f26-0 (cos (-> s5-0 data 0))) - (f30-0 (cos (-> s5-0 data 1))) - (f22-0 (cos (-> s5-0 data 2))) - (f24-0 (sin (-> s5-0 data 0))) - (f28-0 (sin (-> s5-0 data 1))) - (f4-0 (sin (-> s5-0 data 2))) + (let* ((f26-0 (cos (-> s5-0 x))) + (f30-0 (cos (-> s5-0 y))) + (f22-0 (cos (-> s5-0 z))) + (f24-0 (sin (-> s5-0 x))) + (f28-0 (sin (-> s5-0 y))) + (f4-0 (sin (-> s5-0 z))) (f0-17 (* f26-0 f22-0)) (f1-1 (* f26-0 f4-0)) (f2-0 (* f24-0 f22-0)) @@ -46,13 +46,13 @@ ) (let ((v1-9 0)) ) - (let* ((v1-12 (logand (sar (the int (-> s5-0 data 3)) 2) 1)) - (a1-2 (-> EulSafe (logand (sar (the int (-> s5-0 data 3)) 3) 3))) + (let* ((v1-12 (logand (sar (the int (-> s5-0 w)) 2) 1)) + (a1-2 (-> EulSafe (logand (sar (the int (-> s5-0 w)) 3) 3))) (a0-21 (-> EulNext (+ a1-2 v1-12))) (v1-17 (-> EulNext (+ (- 1 v1-12) a1-2))) ) (cond - ((= (logand (sar (the int (-> s5-0 data 3)) 1) 1) 1) + ((= (logand (sar (the int (-> s5-0 w)) 1) 1) 1) (set! (-> (the-as @@ -262,7 +262,7 @@ (cond ((< 0.00001 f30-0) (set! - (-> arg0 data 0) + (-> arg0 x) (atan (-> (the-as @@ -279,7 +279,7 @@ ) ) (set! - (-> arg0 data 1) + (-> arg0 y) (atan f30-0 (-> @@ -291,7 +291,7 @@ ) ) (set! - (-> arg0 data 2) + (-> arg0 z) (atan (-> (the-as @@ -312,7 +312,7 @@ ) (else (set! - (-> arg0 data 0) + (-> arg0 x) (atan (- (-> @@ -331,7 +331,7 @@ ) ) (set! - (-> arg0 data 1) + (-> arg0 y) (atan f30-0 (-> @@ -342,7 +342,7 @@ ) ) ) - (set! (-> arg0 data 2) 0.0) + (set! (-> arg0 z) 0.0) ) ) ) @@ -369,7 +369,7 @@ (cond ((< 0.00001 f30-1) (set! - (-> arg0 data 0) + (-> arg0 x) (atan (-> (the-as @@ -386,7 +386,7 @@ ) ) (set! - (-> arg0 data 1) + (-> arg0 y) (atan (- (-> @@ -400,7 +400,7 @@ ) ) (set! - (-> arg0 data 2) + (-> arg0 z) (atan (-> (the-as @@ -419,7 +419,7 @@ ) (else (set! - (-> arg0 data 0) + (-> arg0 x) (atan (- (-> @@ -438,7 +438,7 @@ ) ) (set! - (-> arg0 data 1) + (-> arg0 y) (atan (- (-> @@ -451,24 +451,24 @@ f30-1 ) ) - (set! (-> arg0 data 2) 0.0) + (set! (-> arg0 z) 0.0) ) ) ) ) ) (when (= (logand (sar arg2 2) 1) 1) - (set! (-> arg0 data 0) (- (-> arg0 data 0))) - (set! (-> arg0 data 1) (- (-> arg0 data 1))) - (set! (-> arg0 data 2) (- (-> arg0 data 2))) + (set! (-> arg0 x) (- (-> arg0 x))) + (set! (-> arg0 y) (- (-> arg0 y))) + (set! (-> arg0 z) (- (-> arg0 z))) ) (if (= (logand arg2 1) 1) - (let ((f0-49 (-> arg0 data 0))) - (set! (-> arg0 data 0) (-> arg0 data 2)) - (set! (-> arg0 data 2) f0-49) + (let ((f0-49 (-> arg0 x))) + (set! (-> arg0 x) (-> arg0 z)) + (set! (-> arg0 z) f0-49) ) ) - (set! (-> arg0 data 3) (the float arg2)) + (set! (-> arg0 w) (the float arg2)) arg0 ) diff --git a/test/decompiler/reference/gs_REF.gc b/test/decompiler/reference/gs_REF.gc index 8139b45b48..098c7c9edf 100644 --- a/test/decompiler/reference/gs_REF.gc +++ b/test/decompiler/reference/gs_REF.gc @@ -697,13 +697,13 @@ ;; definition of type gif-tag64 (deftype gif-tag64 (uint64) - ((nloop uint16 :offset 0 :size 15) - (eop uint8 :offset 15 :size 1) - (id uint16 :offset 32 :size 14) - (pre uint8 :offset 46 :size 1) - (prim uint16 :offset 47 :size 11) - (flg uint8 :offset 58 :size 2) - (nreg uint8 :offset 60 :size 4) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim gs-prim :offset 47 :size 11) + (flg uint8 :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) ) :method-count-assert 9 :size-assert #x8 @@ -966,22 +966,22 @@ (set! (-> gif-tag regs) (new 'static 'gif-tag-regs - :regs0 (gs-reg-id a+d) - :regs1 (gs-reg-id a+d) - :regs2 (gs-reg-id a+d) - :regs3 (gs-reg-id a+d) - :regs4 (gs-reg-id a+d) - :regs5 (gs-reg-id a+d) - :regs6 (gs-reg-id a+d) - :regs7 (gs-reg-id a+d) - :regs8 (gs-reg-id a+d) - :regs9 (gs-reg-id a+d) - :regs10 (gs-reg-id a+d) - :regs11 (gs-reg-id a+d) - :regs12 (gs-reg-id a+d) - :regs13 (gs-reg-id a+d) - :regs14 (gs-reg-id a+d) - :regs15 (gs-reg-id a+d) + :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! (-> buff-ptr5 base) (&+ (the-as pointer gif-tag) 16)) @@ -1169,3 +1169,5 @@ ) + + diff --git a/test/decompiler/reference/matrix_REF.gc b/test/decompiler/reference/matrix_REF.gc index b2a24d2313..77ab7f8382 100644 --- a/test/decompiler/reference/matrix_REF.gc +++ b/test/decompiler/reference/matrix_REF.gc @@ -228,15 +228,15 @@ (let ((temp-vec3 (new 'stack-no-clear 'vector))) (set! (-> temp-vec3 quad) (the-as uint128 0)) (let ((v1-0 temp-vec3)) - (set! (-> v1-0 data 0) (-> vec data 0)) - (set! (-> v1-0 data 1) (-> vec data 1)) - (set! (-> v1-0 data 2) (-> vec data 2)) - (set! (-> v1-0 data 3) 1.0) + (set! (-> v1-0 x) (-> vec data 0)) + (set! (-> v1-0 y) (-> vec data 1)) + (set! (-> v1-0 z) (-> vec data 2)) + (set! (-> v1-0 w) 1.0) ) (vector-matrix*! temp-vec3 temp-vec3 mat) - (set! (-> dst data 0) (-> temp-vec3 data 0)) - (set! (-> dst data 1) (-> temp-vec3 data 1)) - (set! (-> dst data 2) (-> temp-vec3 data 2)) + (set! (-> dst data 0) (-> temp-vec3 x)) + (set! (-> dst data 1) (-> temp-vec3 y)) + (set! (-> dst data 2) (-> temp-vec3 z)) ) dst ) @@ -247,15 +247,15 @@ (let ((temp-vec3 (new 'stack-no-clear 'vector))) (set! (-> temp-vec3 quad) (the-as uint128 0)) (let ((v1-0 temp-vec3)) - (set! (-> v1-0 data 0) (-> vec data 0)) - (set! (-> v1-0 data 1) (-> vec data 1)) - (set! (-> v1-0 data 2) (-> vec data 2)) - (set! (-> v1-0 data 3) 1.0) + (set! (-> v1-0 x) (-> vec data 0)) + (set! (-> v1-0 y) (-> vec data 1)) + (set! (-> v1-0 z) (-> vec data 2)) + (set! (-> v1-0 w) 1.0) ) (vector-rotate*! temp-vec3 temp-vec3 mat) - (set! (-> dst data 0) (-> temp-vec3 data 0)) - (set! (-> dst data 1) (-> temp-vec3 data 1)) - (set! (-> dst data 2) (-> temp-vec3 data 2)) + (set! (-> dst data 0) (-> temp-vec3 x)) + (set! (-> dst data 1) (-> temp-vec3 y)) + (set! (-> dst data 2) (-> temp-vec3 z)) ) dst ) @@ -499,18 +499,18 @@ ;; definition for function matrix-translate! (defun matrix-translate! ((dst matrix) (trans vector)) (matrix-identity! dst) - (set! (-> dst data 12) (-> trans data 0)) - (set! (-> dst data 13) (-> trans data 1)) - (set! (-> dst data 14) (-> trans data 2)) + (set! (-> dst data 12) (-> trans x)) + (set! (-> dst data 13) (-> trans y)) + (set! (-> dst data 14) (-> trans z)) dst ) ;; definition for function matrix-translate+! ;; Used lq/sq (defun matrix-translate+! ((dst matrix) (src matrix) (trans vector)) - (set! (-> dst data 12) (+ (-> src data 12) (-> trans data 0))) - (set! (-> dst data 13) (+ (-> src data 13) (-> trans data 1))) - (set! (-> dst data 14) (+ (-> src data 14) (-> trans data 2))) + (set! (-> dst data 12) (+ (-> src data 12) (-> trans x))) + (set! (-> dst data 13) (+ (-> src data 13) (-> trans y))) + (set! (-> dst data 14) (+ (-> src data 14) (-> trans z))) (when (!= dst src) (set! (-> dst vector 0 quad) (-> src vector 0 quad)) (set! (-> dst vector 1 quad) (-> src vector 1 quad)) @@ -526,9 +526,9 @@ (set! (-> dst vector 1 quad) (the-as uint128 0)) (set! (-> dst vector 2 quad) (the-as uint128 0)) (set! (-> dst vector 3 quad) (the-as uint128 0)) - (set! (-> dst data 0) (-> scale data 0)) - (set! (-> dst data 5) (-> scale data 1)) - (set! (-> dst data 10) (-> scale data 2)) + (set! (-> dst data 0) (-> scale x)) + (set! (-> dst data 5) (-> scale y)) + (set! (-> dst data 10) (-> scale z)) (set! (-> dst data 15) 1.0) dst ) @@ -565,9 +565,9 @@ (set! (-> dst vector 1 quad) (the-as uint128 0)) (set! (-> dst vector 2 quad) (the-as uint128 0)) (set! (-> dst vector 3 quad) (the-as uint128 0)) - (set! (-> dst data 0) (/ 1.0 (-> scale data 0))) - (set! (-> dst data 5) (/ 1.0 (-> scale data 1))) - (set! (-> dst data 10) (/ 1.0 (-> scale data 2))) + (set! (-> dst data 0) (/ 1.0 (-> scale x))) + (set! (-> dst data 5) (/ 1.0 (-> scale y))) + (set! (-> dst data 10) (/ 1.0 (-> scale z))) (set! (-> dst data 15) 1.0) dst ) @@ -670,10 +670,10 @@ (set! (-> rot-mat vector 1 quad) (the-as uint128 0)) (set! (-> rot-mat vector 2 quad) (the-as uint128 0)) (set! (-> rot-mat vector 3 quad) (the-as uint128 0)) - (matrix-rotate-x! dst (-> rot-xyz-deg data 0)) - (matrix-rotate-y! temp-mat (-> rot-xyz-deg data 1)) + (matrix-rotate-x! dst (-> rot-xyz-deg x)) + (matrix-rotate-y! temp-mat (-> rot-xyz-deg y)) (matrix*! rot-mat temp-mat dst) - (matrix-rotate-z! temp-mat (-> rot-xyz-deg data 2)) + (matrix-rotate-z! temp-mat (-> rot-xyz-deg z)) (matrix*! dst temp-mat rot-mat) ) ) @@ -693,10 +693,10 @@ (set! (-> rot-mat vector 1 quad) (the-as uint128 0)) (set! (-> rot-mat vector 2 quad) (the-as uint128 0)) (set! (-> rot-mat vector 3 quad) (the-as uint128 0)) - (matrix-rotate-z! dst (-> rot-xyz-deg data 2)) - (matrix-rotate-y! temp-mat (-> rot-xyz-deg data 1)) + (matrix-rotate-z! dst (-> rot-xyz-deg z)) + (matrix-rotate-y! temp-mat (-> rot-xyz-deg y)) (matrix*! rot-mat temp-mat dst) - (matrix-rotate-x! temp-mat (-> rot-xyz-deg data 0)) + (matrix-rotate-x! temp-mat (-> rot-xyz-deg x)) (matrix*! dst temp-mat rot-mat) ) ) @@ -716,10 +716,10 @@ (set! (-> rot-mat vector 1 quad) (the-as uint128 0)) (set! (-> rot-mat vector 2 quad) (the-as uint128 0)) (set! (-> rot-mat vector 3 quad) (the-as uint128 0)) - (matrix-rotate-y! dst (-> rot-xyz-deg data 1)) - (matrix-rotate-x! temp-mat (-> rot-xyz-deg data 0)) + (matrix-rotate-y! dst (-> rot-xyz-deg y)) + (matrix-rotate-x! temp-mat (-> rot-xyz-deg x)) (matrix*! rot-mat temp-mat dst) - (matrix-rotate-z! temp-mat (-> rot-xyz-deg data 2)) + (matrix-rotate-z! temp-mat (-> rot-xyz-deg z)) (matrix*! dst temp-mat rot-mat) ) ) @@ -739,10 +739,10 @@ (set! (-> rot-mat vector 1 quad) (the-as uint128 0)) (set! (-> rot-mat vector 2 quad) (the-as uint128 0)) (set! (-> rot-mat vector 3 quad) (the-as uint128 0)) - (matrix-rotate-z! dst (-> rot-xyz-deg data 2)) - (matrix-rotate-x! temp-mat (-> rot-xyz-deg data 0)) + (matrix-rotate-z! dst (-> rot-xyz-deg z)) + (matrix-rotate-x! temp-mat (-> rot-xyz-deg x)) (matrix*! rot-mat temp-mat dst) - (matrix-rotate-y! temp-mat (-> rot-xyz-deg data 1)) + (matrix-rotate-y! temp-mat (-> rot-xyz-deg y)) (matrix*! dst temp-mat rot-mat) ) ) @@ -762,10 +762,10 @@ (set! (-> rot-mat vector 1 quad) (the-as uint128 0)) (set! (-> rot-mat vector 2 quad) (the-as uint128 0)) (set! (-> rot-mat vector 3 quad) (the-as uint128 0)) - (matrix-rotate-z! dst (-> rot-xyz-deg data 0)) - (matrix-rotate-x! temp-mat (-> rot-xyz-deg data 2)) + (matrix-rotate-z! dst (-> rot-xyz-deg x)) + (matrix-rotate-x! temp-mat (-> rot-xyz-deg z)) (matrix*! rot-mat temp-mat dst) - (matrix-rotate-y! temp-mat (-> rot-xyz-deg data 1)) + (matrix-rotate-y! temp-mat (-> rot-xyz-deg y)) (matrix*! dst temp-mat rot-mat) ) ) @@ -779,18 +779,18 @@ (cos-vec (new 'stack-no-clear 'vector)) ) (let ((v1-0 sincos-input)) - (set! (-> v1-0 data 0) (-> rots-deg data 0)) - (set! (-> v1-0 data 1) (- (-> rots-deg data 1) (-> rots-deg data 2))) - (set! (-> v1-0 data 2) (-> rots-deg data 2)) - (set! (-> v1-0 data 3) 1.0) + (set! (-> v1-0 x) (-> rots-deg x)) + (set! (-> v1-0 y) (- (-> rots-deg y) (-> rots-deg z))) + (set! (-> v1-0 z) (-> rots-deg z)) + (set! (-> v1-0 w) 1.0) ) (vector-sincos! sin-vec cos-vec sincos-input) - (let ((cos-y (-> cos-vec data 1)) - (sin-y (-> sin-vec data 1)) - (cos-x (-> cos-vec data 0)) - (sin-x (-> sin-vec data 0)) - (cos-z (-> cos-vec data 2)) - (sin-z (-> sin-vec data 2)) + (let ((cos-y (-> cos-vec y)) + (sin-y (-> sin-vec y)) + (cos-x (-> cos-vec x)) + (sin-x (-> sin-vec x)) + (cos-z (-> cos-vec z)) + (sin-z (-> sin-vec z)) ) (set! (-> dst data 0) (- (* cos-y cos-z) (* (* sin-y cos-x) sin-z))) (set! (-> dst data 1) (* sin-y sin-x)) @@ -1690,3 +1690,5 @@ ;; ERROR: function was not converted to expressions. Cannot decompile. + + diff --git a/test/decompiler/reference/quaternion_REF.gc b/test/decompiler/reference/quaternion_REF.gc index ce4894ead2..bc89a255ff 100644 --- a/test/decompiler/reference/quaternion_REF.gc +++ b/test/decompiler/reference/quaternion_REF.gc @@ -62,9 +62,9 @@ (f30-0 (sin f28-0)) (f0-1 (cos f28-0)) ) - (set! (-> quat x) (* (-> axis data 0) f30-0)) - (set! (-> quat y) (* (-> axis data 1) f30-0)) - (set! (-> quat z) (* (-> axis data 2) f30-0)) + (set! (-> quat x) (* (-> axis x) f30-0)) + (set! (-> quat y) (* (-> axis y) f30-0)) + (set! (-> quat z) (* (-> axis z) f30-0)) (set! (-> quat w) f0-1) ) quat @@ -78,10 +78,10 @@ (f30-0 (/ f0-0 (sqrtf (- f1-0 (* f2-0 f2-0))))) (f0-3 (* 2.0 (acos-rad (-> arg1 w)))) ) - (set! (-> arg0 data 0) (* (-> arg1 x) f30-0)) - (set! (-> arg0 data 1) (* (-> arg1 y) f30-0)) - (set! (-> arg0 data 2) (* (-> arg1 z) f30-0)) - (set! (-> arg0 data 3) f0-3) + (set! (-> arg0 x) (* (-> arg1 x) f30-0)) + (set! (-> arg0 y) (* (-> arg1 y) f30-0)) + (set! (-> arg0 z) (* (-> arg1 z) f30-0)) + (set! (-> arg0 w) f0-3) ) arg0 ) @@ -518,7 +518,10 @@ ) ) ) - (set! (-> arg0 data a2-0) (* 0.5 f0-12)) + (set! + (-> (the-as (pointer float) (+ (shl a2-0 2) (the-as int arg0)))) + (* 0.5 f0-12) + ) (if (!= f0-12 0.0) (set! f0-12 (/ 0.5 f0-12)) ) @@ -543,7 +546,7 @@ ) ) (set! - (-> arg0 data a3-0) + (-> (the-as (pointer float) (+ (shl a3-0 2) (the-as int arg0)))) (* (+ (-> @@ -563,7 +566,7 @@ ) ) (set! - (-> arg0 data v1-1) + (-> (the-as (pointer float) (+ (shl v1-1 2) (the-as int arg0)))) (* (+ (-> @@ -733,12 +736,12 @@ (else (let ((s5-0 (new 'stack-no-clear 'vector))) (sincos-rad! (the-as (pointer float) s5-0) f30-0) - (let ((f0-6 (/ (-> s5-0 data 0) f30-0))) + (let ((f0-6 (/ (-> s5-0 x) f30-0))) (set! (-> arg0 x) (* (-> arg1 x) f0-6)) (set! (-> arg0 y) (* (-> arg1 y) f0-6)) (set! (-> arg0 z) (* (-> arg1 z) f0-6)) ) - (set! (-> arg0 w) (-> s5-0 data 1)) + (set! (-> arg0 w) (-> s5-0 y)) ) ) ) @@ -789,8 +792,8 @@ (let ((f0-7 (atan-series-rad f0-6)) (s2-0 (new 'stack-no-clear 'vector)) ) - (set! (-> s2-0 data 0) (* (- 1.0 arg3) f0-7)) - (set! (-> s2-0 data 1) (* (* arg3 f0-7) f30-0)) + (set! (-> s2-0 x) (* (- 1.0 arg3) f0-7)) + (set! (-> s2-0 y) (* (* arg3 f0-7) f30-0)) (vector-sin-rad! s2-0 s2-0) (.lvf vf1 (&-> s2-0 quad)) ) @@ -930,14 +933,14 @@ ;; definition for function quaternion-y-angle (defun quaternion-y-angle ((arg0 quaternion)) (let ((v1-1 (vector-z-quaternion! (new 'stack-no-clear 'vector) arg0))) - (atan (-> v1-1 data 0) (-> v1-1 data 2)) + (atan (-> v1-1 x) (-> v1-1 z)) ) ) ;; definition for function quaternion-vector-y-angle (defun quaternion-vector-y-angle ((arg0 quaternion) (arg1 vector)) (let ((f30-0 (quaternion-y-angle arg0)) - (f0-2 (atan (-> arg1 data 0) (-> arg1 data 2))) + (f0-2 (atan (-> arg1 x) (-> arg1 z))) ) (deg-diff f30-0 f0-2) ) @@ -1046,12 +1049,12 @@ (let ((gp-0 acos)) (let* ((s5-0 (vector-z-quaternion! (new 'stack-no-clear 'vector) arg0)) (v1-1 (vector-z-quaternion! (new 'stack-no-clear 'vector) arg1)) - (f0-0 (-> s5-0 data 0)) - (f1-0 (-> s5-0 data 1)) - (f2-0 (-> s5-0 data 2)) - (f3-0 (-> v1-1 data 0)) - (f4-0 (-> v1-1 data 1)) - (f5-0 (-> v1-1 data 2)) + (f0-0 (-> s5-0 x)) + (f1-0 (-> s5-0 y)) + (f2-0 (-> s5-0 z)) + (f3-0 (-> v1-1 x)) + (f4-0 (-> v1-1 y)) + (f5-0 (-> v1-1 z)) ) (.mula.s f0-0 f3-0) (.madda.s f1-0 f4-0) @@ -1069,10 +1072,10 @@ (let ((t9-0 vector-xz-normalize!) (a0-1 (new 'stack-no-clear 'vector)) ) - (set! (-> a0-1 data 0) (-> arg2 x)) - (set! (-> a0-1 data 1) 0.0) - (set! (-> a0-1 data 2) (-> arg2 z)) - (set! (-> a0-1 data 3) 1.0) + (set! (-> a0-1 x) (-> arg2 x)) + (set! (-> a0-1 y) 0.0) + (set! (-> a0-1 z) (-> arg2 z)) + (set! (-> a0-1 w) 1.0) (let ((s0-0 (t9-0 a0-1 1.0))) (quaternion-from-two-vectors-max-angle! s5-0 @@ -1108,12 +1111,12 @@ ;; definition for function vector-y-angle (defun vector-y-angle ((arg0 vector)) - (atan (-> arg0 data 0) (-> arg0 data 2)) + (atan (-> arg0 x) (-> arg0 z)) ) ;; definition for function vector-x-angle (defun vector-x-angle ((arg0 vector)) - (atan (-> arg0 data 1) (vector-xz-length arg0)) + (atan (-> arg0 y) (vector-xz-length arg0)) ) ;; definition for function quaterion<-rotate-y-vector @@ -1150,13 +1153,16 @@ ) (quaternion->matrix gp-0 arg0) (let ((v1-1 s5-0)) - (set! (-> v1-1 data 0) 0.0) - (set! (-> v1-1 data 1) 0.0) - (set! (-> v1-1 data 2) 1.0) - (set! (-> v1-1 data 3) 1.0) + (set! (-> v1-1 x) 0.0) + (set! (-> v1-1 y) 0.0) + (set! (-> v1-1 z) 1.0) + (set! (-> v1-1 w) 1.0) ) (vector-matrix*! s5-0 s5-0 gp-0) (vector-y-angle s5-0) ) ) + + + diff --git a/test/decompiler/reference/sync-info_REF.gc b/test/decompiler/reference/sync-info_REF.gc index 0cba439e36..875567ce6c 100644 --- a/test/decompiler/reference/sync-info_REF.gc +++ b/test/decompiler/reference/sync-info_REF.gc @@ -491,15 +491,15 @@ (set! (-> obj start-time) (-> *display* base-frame-counter)) (set! (-> obj timer) (rand-vu-int-range (-> obj min-time) (-> obj max-time))) (set! - (-> obj value data 0) + (-> obj value x) (rand-vu-float-range (- (-> obj xz-max)) (-> obj xz-max)) ) (set! - (-> obj value data 1) + (-> obj value y) (rand-vu-float-range (- (-> obj y-max)) (-> obj y-max)) ) (set! - (-> obj value data 2) + (-> obj value z) (rand-vu-float-range (- (-> obj xz-max)) (-> obj xz-max)) ) (-> obj value) @@ -706,3 +706,5 @@ ) + + diff --git a/test/decompiler/reference/texture-h_REF.gc b/test/decompiler/reference/texture-h_REF.gc new file mode 100644 index 0000000000..0cee59ae15 --- /dev/null +++ b/test/decompiler/reference/texture-h_REF.gc @@ -0,0 +1,410 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *texture-enable-user-menu*, type int +(define *texture-enable-user-menu* 31) + +;; definition for symbol *texture-enable-user*, type int +(define *texture-enable-user* 0) + +;; definition of type texture-id +(deftype texture-id (uint32) + ((index uint16 :offset 8 :size 12) + (page uint16 :offset 20 :size 12) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +;; definition for method 3 of type texture-id +(defmethod inspect texture-id ((obj texture-id)) + (format #t "[~8x] ~A~%" obj 'texture-id) + (format #t "~Tindex: ~D~%" (-> obj index)) + (format #t "~Tpage: ~D~%" (-> obj page)) + obj + ) + +;; definition of type texture-pool-segment +(deftype texture-pool-segment (structure) + ((dest uint32 :offset-assert 0) + (size uint32 :offset-assert 4) + ) + :pack-me + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +;; definition for method 3 of type texture-pool-segment +(defmethod inspect texture-pool-segment ((obj texture-pool-segment)) + (format #t "[~8x] ~A~%" obj 'texture-pool-segment) + (format #t "~Tdest: #x~X~%" (-> obj dest)) + (format #t "~Tsize: #x~X~%" (-> obj size)) + obj + ) + +;; definition of type texture-pool +(deftype texture-pool (basic) + ((top int32 :offset-assert 4) + (cur int32 :offset-assert 8) + (allocate-func basic :offset-assert 12) + (font-palette int32 :offset-assert 16) + (segment texture-pool-segment 4 :inline :offset-assert 20) + (segment-near texture-pool-segment :inline :offset 20) + (segment-common texture-pool-segment :inline :offset 28) + (common-page int32 32 :offset-assert 52) + (common-page-mask int32 :offset-assert 180) + (ids int32 126 :offset-assert 184) + ) + :method-count-assert 23 + :size-assert #x2b0 + :flag-assert #x17000002b0 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 () none 13) + (dummy-14 () none 14) + (dummy-15 () none 15) + (dummy-16 () none 16) + (dummy-17 () none 17) + (dummy-18 () none 18) + (dummy-19 () none 19) + (dummy-20 () none 20) + (dummy-21 () none 21) + (dummy-22 () none 22) + ) + ) + +;; definition for method 3 of type texture-pool +(defmethod inspect texture-pool ((obj texture-pool)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Ttop: #x~X~%" (-> obj top)) + (format #t "~Tcur: #x~X~%" (-> obj cur)) + (format #t "~Tallocate-func: ~A~%" (-> obj allocate-func)) + (format #t "~Tfont-palette: ~D~%" (-> obj font-palette)) + (format #t "~Tsegment[4] @ #x~X~%" (-> obj segment)) + (format + #t + "~Tsegment-near: #~%" + (-> obj segment) + ) + (format + #t + "~Tsegment-common: #~%" + (-> obj segment 1) + ) + (format #t "~Tcommon-page[32] @ #x~X~%" (-> obj common-page)) + (format #t "~Tcommon-page-mask: ~D~%" (-> obj common-page-mask)) + (format #t "~Tids[126] @ #x~X~%" (-> obj ids)) + obj + ) + +;; definition of type texture +(deftype texture (basic) + ((w int16 :offset-assert 4) + (h int16 :offset-assert 6) + (num-mips uint8 :offset-assert 8) + (tex1-control uint8 :offset-assert 9) + (psm uint8 :offset-assert 10) + (mip-shift uint8 :offset-assert 11) + (clutpsm uint16 :offset-assert 12) + (dest uint16 7 :offset-assert 14) + (clutdest uint16 :offset-assert 28) + (width uint8 7 :offset-assert 30) + (name basic :offset-assert 40) + (size uint32 :offset-assert 44) + (uv-dist float :offset-assert 48) + (masks uint32 3 :offset-assert 52) + ) + :method-count-assert 9 + :size-assert #x40 + :flag-assert #x900000040 + ) + +;; definition for method 3 of type texture +(defmethod inspect texture ((obj texture)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tw: ~D~%" (-> obj w)) + (format #t "~Th: ~D~%" (-> obj h)) + (format #t "~Tnum-mips: ~D~%" (-> obj num-mips)) + (format #t "~Ttex1-control: ~D~%" (-> obj tex1-control)) + (format #t "~Tpsm: ~D~%" (-> obj psm)) + (format #t "~Tmip-shift: ~D~%" (-> obj mip-shift)) + (format #t "~Tclutpsm: ~D~%" (-> obj clutpsm)) + (format #t "~Tdest[7] @ #x~X~%" (-> obj dest)) + (format #t "~Tclutdest: ~D~%" (-> obj clutdest)) + (format #t "~Twidth[7] @ #x~X~%" (-> obj width)) + (format #t "~Tname: ~A~%" (-> obj name)) + (format #t "~Tsize: #x~X~%" (-> obj size)) + (format #t "~Tuv-dist: ~f~%" (-> obj uv-dist)) + (format #t "~Tmasks[3] @ #x~X~%" (-> obj masks)) + obj + ) + +;; definition of type texture-page-segment +(deftype texture-page-segment (structure) + ((block-data pointer :offset-assert 0) + (size uint32 :offset-assert 4) + (dest uint32 :offset-assert 8) + ) + :pack-me + :method-count-assert 9 + :size-assert #xc + :flag-assert #x90000000c + ) + +;; definition for method 3 of type texture-page-segment +(defmethod inspect texture-page-segment ((obj texture-page-segment)) + (format #t "[~8x] ~A~%" obj 'texture-page-segment) + (format #t "~Tblock-data: #x~X~%" (-> obj block-data)) + (format #t "~Tsize: #x~X~%" (-> obj size)) + (format #t "~Tdest: #x~X~%" (-> obj dest)) + obj + ) + +;; definition for function texture-mip->segment +(defun texture-mip->segment ((arg0 int) (arg1 int)) + (if (>= 2 arg1) + (+ (- -1 arg0) arg1) + (max 0 (- 2 arg0)) + ) + ) + +;; definition of type texture-page +(deftype texture-page (basic) + ((info basic :offset-assert 4) + (name basic :offset-assert 8) + (id uint32 :offset-assert 12) + (length int32 :offset-assert 16) + (mip0-size uint32 :offset-assert 20) + (size uint32 :offset-assert 24) + (segment texture-page-segment 3 :inline :offset-assert 28) + (pad uint32 16 :offset-assert 64) + (data uint8 :dynamic :offset-assert 128) + ) + :method-count-assert 15 + :size-assert #x80 + :flag-assert #xf00000080 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 () none 13) + (dummy-14 () none 14) + ) + ) + +;; definition for method 3 of type texture-page +(defmethod inspect texture-page ((obj texture-page)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tinfo: ~A~%" (-> obj info)) + (format #t "~Tname: ~A~%" (-> obj name)) + (format #t "~Tid: ~D~%" (-> obj id)) + (format #t "~Tlength: ~D~%" (-> obj length)) + (format #t "~Tmip0-size: ~D~%" (-> obj mip0-size)) + (format #t "~Tsize: #x~X~%" (-> obj size)) + (format #t "~Tsegment[3] @ #x~X~%" (-> obj segment)) + (format #t "~Tpad[16] @ #x~X~%" (-> obj pad)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj data)) + obj + ) + +;; definition of type shader-ptr +(deftype shader-ptr (uint32) + () + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +;; definition of type texture-link +(deftype texture-link (structure) + ((next uint32 :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +;; definition for method 3 of type texture-link +(defmethod inspect texture-link ((obj texture-link)) + (format #t "[~8x] ~A~%" obj 'texture-link) + (format #t "~Tnext: #x~X~%" (-> obj next)) + obj + ) + +;; definition of type texture-page-dir-entry +(deftype texture-page-dir-entry (structure) + ((length int16 :offset-assert 0) + (status uint16 :offset-assert 2) + (page basic :offset-assert 4) + (link uint32 :offset-assert 8) + ) + :method-count-assert 9 + :size-assert #xc + :flag-assert #x90000000c + ) + +;; definition for method 3 of type texture-page-dir-entry +(defmethod inspect texture-page-dir-entry ((obj texture-page-dir-entry)) + (format #t "[~8x] ~A~%" obj 'texture-page-dir-entry) + (format #t "~Tlength: ~D~%" (-> obj length)) + (format #t "~Tstatus: ~D~%" (-> obj status)) + (format #t "~Tpage: ~A~%" (-> obj page)) + (format #t "~Tlink: #x~X~%" (-> obj link)) + obj + ) + +;; definition of type texture-page-dir +(deftype texture-page-dir (basic) + ((pad uint8 16 :offset-assert 4) + ) + :method-count-assert 10 + :size-assert #x14 + :flag-assert #xa00000014 + (:methods + (dummy-9 () none 9) + ) + ) + +;; definition of type texture-relocate-later +(deftype texture-relocate-later (basic) + ((memcpy basic :offset-assert 4) + (dest uint32 :offset-assert 8) + (source uint32 :offset-assert 12) + (move uint32 :offset-assert 16) + (entry texture-page-dir-entry :offset-assert 20) + (page basic :offset-assert 24) + ) + :method-count-assert 9 + :size-assert #x1c + :flag-assert #x90000001c + ) + +;; definition for method 3 of type texture-relocate-later +(defmethod inspect texture-relocate-later ((obj texture-relocate-later)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tmemcpy: ~A~%" (-> obj memcpy)) + (format #t "~Tdest: ~D~%" (-> obj dest)) + (format #t "~Tsource: ~D~%" (-> obj source)) + (format #t "~Tmove: ~D~%" (-> obj move)) + (format #t "~Tentry: #~%" (-> obj entry)) + (format #t "~Tpage: ~A~%" (-> obj page)) + obj + ) + +;; definition for symbol *texture-relocate-later*, type texture-relocate-later +(define + *texture-relocate-later* + (the-as texture-relocate-later (new 'global 'texture-relocate-later)) + ) + +;; failed to figure out what this is: +(set! (-> *texture-relocate-later* memcpy) #f) + +;; definition for symbol *texture-page-dir*, type texture-page-dir +(define *texture-page-dir* (the-as texture-page-dir #f)) + +;; definition of type adgif-shader +(deftype adgif-shader (structure) + ((quad uint128 5 :offset 0) + (prims uint64 10 :offset 0) + (tex0 uint64 :offset 0) + (tex1 uint64 :offset 16) + (miptbp1 uint64 :offset 32) + (clamp uint64 :offset 48) + (clamp-reg uint64 :offset 56) + (alpha uint64 :offset 64) + (link-test uint32 :offset 8) + (texture-id uint32 :offset 24) + (next uint32 :offset 40) + ) + :method-count-assert 9 + :size-assert #x50 + :flag-assert #x900000050 + ) + +;; definition for method 3 of type adgif-shader +(defmethod inspect adgif-shader ((obj adgif-shader)) + (format #t "[~8x] ~A~%" obj 'adgif-shader) + (format #t "~Tquad[5] @ #x~X~%" (-> obj quad)) + (format #t "~Tprims[10] @ #x~X~%" (-> obj quad)) + (format #t "~Ttex0: #x~X~%" (-> obj prims 0)) + (format #t "~Ttex1: #x~X~%" (-> obj prims 2)) + (format #t "~Tmiptbp1: #x~X~%" (-> obj prims 4)) + (format #t "~Tclamp: #x~X~%" (-> obj prims 6)) + (format #t "~Tclamp-reg: ~D~%" (-> obj prims 7)) + (format #t "~Talpha: #x~X~%" (-> obj prims 8)) + (format #t "~Tlink-test: ~D~%" (-> obj link-test)) + (format #t "~Ttexture-id: ~D~%" (-> obj texture-id)) + (format #t "~Tnext: #x~X~%" (-> obj next)) + obj + ) + +;; definition of type adgif-shader-array +(deftype adgif-shader-array (inline-array-class) + () + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +;; definition for method 3 of type adgif-shader-array +(defmethod inspect adgif-shader-array ((obj adgif-shader-array)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tlength: ~D~%" (-> obj length)) + (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) + (format #t "~Tdata[0] @ #x~X~%" (&-> obj data 4)) + obj + ) + +;; failed to figure out what this is: +(set! (-> adgif-shader-array heap-base) (the-as uint 80)) + +;; definition for symbol *sky-base-vram-word*, type int +(define *sky-base-vram-word* 0) + +;; definition for symbol *sky-base-block*, type int +(define *sky-base-block* 0) + +;; definition for symbol *sky-base-page*, type int +(define *sky-base-page* 0) + +;; definition for symbol *depth-cue-base-vram-word*, type int +(define *depth-cue-base-vram-word* 0) + +;; definition for symbol *depth-cue-base-block*, type int +(define *depth-cue-base-block* 0) + +;; definition for symbol *depth-cue-base-page*, type int +(define *depth-cue-base-page* 0) + +;; definition for symbol *eyes-base-vram-word*, type int +(define *eyes-base-vram-word* 0) + +;; definition for symbol *eyes-base-block*, type int +(define *eyes-base-block* 0) + +;; definition for symbol *eyes-base-page*, type int +(define *eyes-base-page* 0) + +;; definition for symbol *ocean-base-vram-word*, type int +(define *ocean-base-vram-word* 0) + +;; definition for symbol *ocean-base-block*, type int +(define *ocean-base-block* 0) + +;; definition for symbol *ocean-base-page*, type int +(define *ocean-base-page* 0) + +;; failed to figure out what this is: +(let ((v0-14 0)) + ) + + + + diff --git a/test/decompiler/reference/transform_REF.gc b/test/decompiler/reference/transform_REF.gc index be8757d876..4261398e69 100644 --- a/test/decompiler/reference/transform_REF.gc +++ b/test/decompiler/reference/transform_REF.gc @@ -7,26 +7,26 @@ (format #t "~T~Ttrans:~F ~F ~F ~F ~%" - (-> obj trans data 0) - (-> obj trans data 1) - (-> obj trans data 2) - (-> obj trans data 3) + (-> obj trans x) + (-> obj trans y) + (-> obj trans z) + (-> obj trans w) ) (format #t "~T~Trot: ~F ~F ~F ~F ~%" - (-> obj rot data 0) - (-> obj rot data 1) - (-> obj rot data 2) - (-> obj rot data 3) + (-> obj rot x) + (-> obj rot y) + (-> obj rot z) + (-> obj rot w) ) (format #t "~T~Tscale:~F ~F ~F ~F>" - (-> obj scale data 0) - (-> obj scale data 1) - (-> obj scale data 2) - (-> obj scale data 3) + (-> obj scale x) + (-> obj scale y) + (-> obj scale z) + (-> obj scale w) ) obj ) @@ -38,8 +38,8 @@ (object-new allocation type-to-make (the-as int (-> type-to-make size))) ) ) - (set! (-> obj trans data 3) 1.0) - (set! (-> obj rot data 3) 1.0) + (set! (-> obj trans w) 1.0) + (set! (-> obj rot w) 1.0) (vector-identity! (-> obj scale)) obj ) @@ -60,11 +60,11 @@ (set! (-> s3-0 vector 3 quad) (the-as uint128 0)) (matrix-identity! dst-mat) (matrix-translate! dst-mat (-> tf trans)) - (matrix-rotate-y! s4-0 (-> tf rot data 1)) + (matrix-rotate-y! s4-0 (-> tf rot y)) (matrix*! s3-0 s4-0 dst-mat) - (matrix-rotate-x! s4-0 (-> tf rot data 0)) + (matrix-rotate-x! s4-0 (-> tf rot x)) (matrix*! dst-mat s4-0 s3-0) - (matrix-rotate-z! s4-0 (-> tf rot data 2)) + (matrix-rotate-z! s4-0 (-> tf rot z)) (matrix*! s3-0 s4-0 dst-mat) (matrix-scale! s4-0 (-> tf scale)) (matrix*! dst-mat s4-0 s3-0) @@ -91,11 +91,11 @@ (matrix-translate! s3-0 (-> tf trans)) (matrix-inv-scale! s4-0 inv-scale) (matrix*! dst-mat s4-0 s3-0) - (matrix-rotate-y! s4-0 (-> tf rot data 1)) + (matrix-rotate-y! s4-0 (-> tf rot y)) (matrix*! s3-0 s4-0 dst-mat) - (matrix-rotate-x! s4-0 (-> tf rot data 0)) + (matrix-rotate-x! s4-0 (-> tf rot x)) (matrix*! dst-mat s4-0 s3-0) - (matrix-rotate-z! s4-0 (-> tf rot data 2)) + (matrix-rotate-z! s4-0 (-> tf rot z)) (matrix*! s3-0 s4-0 dst-mat) (matrix-scale! s4-0 (-> tf scale)) (matrix*! dst-mat s4-0 s3-0) @@ -109,3 +109,5 @@ ) + + diff --git a/test/decompiler/reference/vector-h_REF.gc b/test/decompiler/reference/vector-h_REF.gc index 670899aa6d..ff7026baa1 100644 --- a/test/decompiler/reference/vector-h_REF.gc +++ b/test/decompiler/reference/vector-h_REF.gc @@ -285,12 +285,12 @@ ;; Used lq/sq (defmethod inspect vector4w ((obj vector4w)) (format #t "[~8x] ~A~%" obj 'vector4w) - (format #t "~Tdata[4] @ #x~X~%" (-> obj data)) - (format #t "~Tx: ~D~%" (-> obj data 0)) - (format #t "~Ty: ~D~%" (-> obj data 1)) - (format #t "~Tz: ~D~%" (-> obj data 2)) - (format #t "~Tw: ~D~%" (-> obj data 3)) - (format #t "~Tdword[2] @ #x~X~%" (-> obj data)) + (format #t "~Tdata[4] @ #x~X~%" (&-> obj x)) + (format #t "~Tx: ~D~%" (-> obj x)) + (format #t "~Ty: ~D~%" (-> obj y)) + (format #t "~Tz: ~D~%" (-> obj z)) + (format #t "~Tw: ~D~%" (-> obj w)) + (format #t "~Tdword[2] @ #x~X~%" (&-> obj x)) (format #t "~Tquad: ~D~%" (-> obj quad)) obj ) @@ -300,10 +300,10 @@ (format #t "#" - (-> obj data 0) - (-> obj data 1) - (-> obj data 2) - (-> obj data 3) + (-> obj x) + (-> obj y) + (-> obj z) + (-> obj w) obj ) obj @@ -453,11 +453,11 @@ ;; Used lq/sq (defmethod inspect vector ((obj vector)) (format #t "[~8x] ~A~%" obj 'vector) - (format #t "~Tdata[4] @ #x~X~%" (-> obj data)) - (format #t "~Tx: ~f~%" (-> obj data 0)) - (format #t "~Ty: ~f~%" (-> obj data 1)) - (format #t "~Tz: ~f~%" (-> obj data 2)) - (format #t "~Tw: ~f~%" (-> obj data 3)) + (format #t "~Tdata[4] @ #x~X~%" (&-> obj x)) + (format #t "~Tx: ~f~%" (-> obj x)) + (format #t "~Ty: ~f~%" (-> obj y)) + (format #t "~Tz: ~f~%" (-> obj z)) + (format #t "~Tw: ~f~%" (-> obj w)) (format #t "~Tquad: ~D~%" (-> obj quad)) obj ) @@ -469,10 +469,10 @@ (format #t "~T[~F] [~F] [~F] [~F]~%" - (-> obj data 0) - (-> obj data 1) - (-> obj data 2) - (-> obj data 3) + (-> obj x) + (-> obj y) + (-> obj z) + (-> obj w) ) obj ) @@ -482,10 +482,10 @@ (format #t "#" - (-> obj data 0) - (-> obj data 1) - (-> obj data 2) - (-> obj data 3) + (-> obj x) + (-> obj y) + (-> obj z) + (-> obj w) obj ) obj @@ -565,16 +565,16 @@ ;; Used lq/sq (defmethod inspect rgbaf ((obj rgbaf)) (format #t "[~8x] ~A~%" obj 'rgbaf) - (format #t "~Tdata[4] @ #x~X~%" (-> obj data)) - (format #t "~Tx: ~f~%" (-> obj data 0)) - (format #t "~Ty: ~f~%" (-> obj data 1)) - (format #t "~Tz: ~f~%" (-> obj data 2)) - (format #t "~Tw: ~f~%" (-> obj data 3)) + (format #t "~Tdata[4] @ #x~X~%" (&-> obj x)) + (format #t "~Tx: ~f~%" (-> obj x)) + (format #t "~Ty: ~f~%" (-> obj y)) + (format #t "~Tz: ~f~%" (-> obj z)) + (format #t "~Tw: ~f~%" (-> obj w)) (format #t "~Tquad: ~D~%" (-> obj quad)) - (format #t "~Tr: ~f~%" (-> obj data 0)) - (format #t "~Tg: ~f~%" (-> obj data 1)) - (format #t "~Tb: ~f~%" (-> obj data 2)) - (format #t "~Ta: ~f~%" (-> obj data 3)) + (format #t "~Tr: ~f~%" (-> obj x)) + (format #t "~Tg: ~f~%" (-> obj y)) + (format #t "~Tb: ~f~%" (-> obj z)) + (format #t "~Ta: ~f~%" (-> obj w)) obj ) @@ -594,16 +594,16 @@ ;; Used lq/sq (defmethod inspect plane ((obj plane)) (format #t "[~8x] ~A~%" obj 'plane) - (format #t "~Tdata[4] @ #x~X~%" (-> obj data)) - (format #t "~Tx: ~f~%" (-> obj data 0)) - (format #t "~Ty: ~f~%" (-> obj data 1)) - (format #t "~Tz: ~f~%" (-> obj data 2)) - (format #t "~Tw: ~f~%" (-> obj data 3)) + (format #t "~Tdata[4] @ #x~X~%" (&-> obj x)) + (format #t "~Tx: ~f~%" (-> obj x)) + (format #t "~Ty: ~f~%" (-> obj y)) + (format #t "~Tz: ~f~%" (-> obj z)) + (format #t "~Tw: ~f~%" (-> obj w)) (format #t "~Tquad: ~D~%" (-> obj quad)) - (format #t "~Ta: ~f~%" (-> obj data 0)) - (format #t "~Tb: ~f~%" (-> obj data 1)) - (format #t "~Tc: ~f~%" (-> obj data 2)) - (format #t "~Td: ~f~%" (-> obj data 3)) + (format #t "~Ta: ~f~%" (-> obj x)) + (format #t "~Tb: ~f~%" (-> obj y)) + (format #t "~Tc: ~f~%" (-> obj z)) + (format #t "~Td: ~f~%" (-> obj w)) obj ) @@ -620,13 +620,13 @@ ;; Used lq/sq (defmethod inspect sphere ((obj sphere)) (format #t "[~8x] ~A~%" obj 'sphere) - (format #t "~Tdata[4] @ #x~X~%" (-> obj data)) - (format #t "~Tx: ~f~%" (-> obj data 0)) - (format #t "~Ty: ~f~%" (-> obj data 1)) - (format #t "~Tz: ~f~%" (-> obj data 2)) - (format #t "~Tw: ~f~%" (-> obj data 3)) + (format #t "~Tdata[4] @ #x~X~%" (&-> obj x)) + (format #t "~Tx: ~f~%" (-> obj x)) + (format #t "~Ty: ~f~%" (-> obj y)) + (format #t "~Tz: ~f~%" (-> obj z)) + (format #t "~Tw: ~f~%" (-> obj w)) (format #t "~Tquad: ~D~%" (-> obj quad)) - (format #t "~Tr: ~f~%" (-> obj data 3)) + (format #t "~Tr: ~f~%" (-> obj w)) obj ) @@ -827,12 +827,12 @@ ;; WARN: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] (defun vector-dot ((arg0 vector) (arg1 vector)) (local-vars (f0-1 float)) - (let ((f0-0 (-> arg0 data 0)) - (f1-0 (-> arg0 data 1)) - (f2-0 (-> arg0 data 2)) - (f3-0 (-> arg1 data 0)) - (f4-0 (-> arg1 data 1)) - (f5-0 (-> arg1 data 2)) + (let ((f0-0 (-> arg0 x)) + (f1-0 (-> arg0 y)) + (f2-0 (-> arg0 z)) + (f3-0 (-> arg1 x)) + (f4-0 (-> arg1 y)) + (f5-0 (-> arg1 z)) ) (.mula.s f0-0 f3-0) (.madda.s f1-0 f4-0) @@ -864,14 +864,14 @@ ;; WARN: Unsupported inline assembly instruction kind - [madd.s f0, f3, f7] (defun vector4-dot ((arg0 vector) (arg1 vector)) (local-vars (f0-1 float)) - (let ((f0-0 (-> arg0 data 0)) - (f1-0 (-> arg0 data 1)) - (f2-0 (-> arg0 data 2)) - (f3-0 (-> arg0 data 3)) - (f4-0 (-> arg1 data 0)) - (f5-0 (-> arg1 data 1)) - (f6-0 (-> arg1 data 2)) - (f7-0 (-> arg1 data 3)) + (let ((f0-0 (-> arg0 x)) + (f1-0 (-> arg0 y)) + (f2-0 (-> arg0 z)) + (f3-0 (-> arg0 w)) + (f4-0 (-> arg1 x)) + (f5-0 (-> arg1 y)) + (f6-0 (-> arg1 z)) + (f7-0 (-> arg1 w)) ) (.mula.s f0-0 f4-0) (.madda.s f1-0 f5-0) @@ -964,3 +964,6 @@ ;; definition for symbol *zero-vector*, type vector (define *zero-vector* (new 'static 'vector)) + + + diff --git a/test/decompiler/reference/vector_REF.gc b/test/decompiler/reference/vector_REF.gc index defcdf0897..d801bf8292 100644 --- a/test/decompiler/reference/vector_REF.gc +++ b/test/decompiler/reference/vector_REF.gc @@ -106,7 +106,7 @@ (.div.vf Q vf0 vf5 :fsf #b11 :ftf #b1) (.add.x.vf vf6 vf0 vf0 :mask #b1000) (.lvf vf4 (&-> arg1 quad)) - (let ((v1-0 (/ (-> arg1 data 0) (-> arg2 data 0)))) + (let ((v1-0 (/ (-> arg1 x) (-> arg2 x)))) (.wait.vf) (.mul.vf vf6 vf4 Q :mask #b10) (.nop.vf) @@ -309,8 +309,8 @@ (defun vector-seek-2d-xz-smooth! ((vec vector) (target vector) (max-step float) (alpha float)) - (let ((x-diff (- (-> target data 0) (-> vec data 0))) - (z-diff (- (-> target data 2) (-> vec data 2))) + (let ((x-diff (- (-> target x) (-> vec x))) + (z-diff (- (-> target z) (-> vec z))) ) (if (or (!= x-diff 0.0) (!= z-diff 0.0)) (let* ((x-step (* x-diff alpha)) @@ -319,13 +319,13 @@ ) (cond ((>= max-step step-len) - (set! (-> vec data 0) (+ (-> vec data 0) x-step)) - (set! (-> vec data 2) (+ (-> vec data 2) z-step)) + (set! (-> vec x) (+ (-> vec x) x-step)) + (set! (-> vec z) (+ (-> vec z) z-step)) ) (else (let ((f2-6 (/ max-step step-len))) - (set! (-> vec data 0) (+ (-> vec data 0) (* f2-6 x-step))) - (set! (-> vec data 2) (+ (-> vec data 2) (* f2-6 z-step))) + (set! (-> vec x) (+ (-> vec x) (* f2-6 x-step))) + (set! (-> vec z) (+ (-> vec z) (* f2-6 z-step))) ) ) ) @@ -339,8 +339,8 @@ (defun vector-seek-2d-yz-smooth! ((vec vector) (target vector) (max-step float) (alpha float)) - (let ((y-diff (- (-> target data 1) (-> vec data 1))) - (z-diff (- (-> target data 2) (-> vec data 2))) + (let ((y-diff (- (-> target y) (-> vec y))) + (z-diff (- (-> target z) (-> vec z))) ) (if (or (!= y-diff 0.0) (!= z-diff 0.0)) (let* ((y-step (* y-diff alpha)) @@ -349,13 +349,13 @@ ) (cond ((>= max-step step-len) - (set! (-> vec data 1) (+ (-> vec data 1) y-step)) - (set! (-> vec data 2) (+ (-> vec data 2) z-step)) + (set! (-> vec y) (+ (-> vec y) y-step)) + (set! (-> vec z) (+ (-> vec z) z-step)) ) (else (let ((step-scale (/ max-step step-len))) - (set! (-> vec data 1) (+ (-> vec data 1) (* step-scale y-step))) - (set! (-> vec data 2) (+ (-> vec data 2) (* step-scale z-step))) + (set! (-> vec y) (+ (-> vec y) (* step-scale y-step))) + (set! (-> vec z) (+ (-> vec z) (* step-scale z-step))) ) ) ) @@ -369,9 +369,9 @@ (defun vector-seek-3d-smooth! ((vec vector) (target vector) (max-step float) (alpha float)) - (let ((x-diff (- (-> target data 0) (-> vec data 0))) - (y-diff (- (-> target data 1) (-> vec data 1))) - (z-diff (- (-> target data 2) (-> vec data 2))) + (let ((x-diff (- (-> target x) (-> vec x))) + (y-diff (- (-> target y) (-> vec y))) + (z-diff (- (-> target z) (-> vec z))) ) (if (or (!= x-diff 0.0) (!= y-diff 0.0) (!= z-diff 0.0)) (let* ((x-step (* x-diff alpha)) @@ -385,15 +385,15 @@ ) (cond ((>= max-step step-len) - (set! (-> vec data 0) (+ (-> vec data 0) x-step)) - (set! (-> vec data 1) (+ (-> vec data 1) y-step)) - (set! (-> vec data 2) (+ (-> vec data 2) z-step)) + (set! (-> vec x) (+ (-> vec x) x-step)) + (set! (-> vec y) (+ (-> vec y) y-step)) + (set! (-> vec z) (+ (-> vec z) z-step)) ) (else (let ((step-scale (/ max-step step-len))) - (set! (-> vec data 0) (+ (-> vec data 0) (* step-scale x-step))) - (set! (-> vec data 1) (+ (-> vec data 1) (* step-scale y-step))) - (set! (-> vec data 2) (+ (-> vec data 2) (* step-scale z-step))) + (set! (-> vec x) (+ (-> vec x) (* step-scale x-step))) + (set! (-> vec y) (+ (-> vec y) (* step-scale y-step))) + (set! (-> vec z) (+ (-> vec z) (* step-scale z-step))) ) ) ) @@ -429,26 +429,26 @@ ;; definition for function vector-identity! (defun vector-identity! ((arg0 vector)) - (set! (-> arg0 data 0) 1.0) - (set! (-> arg0 data 1) 1.0) - (set! (-> arg0 data 2) 1.0) - (set! (-> arg0 data 3) 1.0) + (set! (-> arg0 x) 1.0) + (set! (-> arg0 y) 1.0) + (set! (-> arg0 z) 1.0) + (set! (-> arg0 w) 1.0) arg0 ) ;; definition for function vector-seconds (defun vector-seconds ((arg0 vector) (arg1 vector)) - (set! (-> arg0 data 0) (* 300.0 (-> arg1 data 0))) - (set! (-> arg0 data 1) (* 300.0 (-> arg1 data 1))) - (set! (-> arg0 data 2) (* 300.0 (-> arg1 data 2))) + (set! (-> arg0 x) (* 300.0 (-> arg1 x))) + (set! (-> arg0 y) (* 300.0 (-> arg1 y))) + (set! (-> arg0 z) (* 300.0 (-> arg1 z))) arg0 ) ;; definition for function vector-seconds! (defun vector-seconds! ((arg0 vector)) - (set! (-> arg0 data 0) (* 300.0 (-> arg0 data 0))) - (set! (-> arg0 data 1) (* 300.0 (-> arg0 data 1))) - (set! (-> arg0 data 2) (* 300.0 (-> arg0 data 2))) + (set! (-> arg0 x) (* 300.0 (-> arg0 x))) + (set! (-> arg0 y) (* 300.0 (-> arg0 y))) + (set! (-> arg0 z) (* 300.0 (-> arg0 z))) arg0 ) @@ -623,20 +623,12 @@ ;; definition for function vector-xz-length-squared (defun vector-xz-length-squared ((arg0 vector)) - (+ - (* (-> arg0 data 0) (-> arg0 data 0)) - (* (-> arg0 data 2) (-> arg0 data 2)) - ) + (+ (* (-> arg0 x) (-> arg0 x)) (* (-> arg0 z) (-> arg0 z))) ) ;; definition for function vector-xz-length (defun vector-xz-length ((arg0 vector)) - (sqrtf - (+ - (* (-> arg0 data 0) (-> arg0 data 0)) - (* (-> arg0 data 2) (-> arg0 data 2)) - ) - ) + (sqrtf (+ (* (-> arg0 x) (-> arg0 x)) (* (-> arg0 z) (-> arg0 z)))) ) ;; definition for function vector-vector-distance @@ -801,13 +793,13 @@ (if (= f0-0 0.0) (set! (-> arg0 quad) (-> arg1 quad)) (let ((v1-1 (/ arg2 f0-0))) - (set! (-> arg0 data 0) (* (-> arg1 data 0) v1-1)) - (set! (-> arg0 data 1) (* (-> arg1 data 1) v1-1)) - (set! (-> arg0 data 2) (* (-> arg1 data 2) v1-1)) + (set! (-> arg0 x) (* (-> arg1 x) v1-1)) + (set! (-> arg0 y) (* (-> arg1 y) v1-1)) + (set! (-> arg0 z) (* (-> arg1 z) v1-1)) ) ) ) - (set! (-> arg0 data 3) 1.0) + (set! (-> arg0 w) 1.0) arg0 ) @@ -816,8 +808,8 @@ (let ((f0-0 (vector-xz-length arg0))) (if (!= f0-0 0.0) (let ((v1-1 (/ arg1 f0-0))) - (set! (-> arg0 data 0) (* (-> arg0 data 0) v1-1)) - (set! (-> arg0 data 2) (* (-> arg0 data 2) v1-1)) + (set! (-> arg0 x) (* (-> arg0 x) v1-1)) + (set! (-> arg0 z) (* (-> arg0 z) v1-1)) ) ) ) @@ -830,9 +822,9 @@ (when (not (or (= f0-0 0.0) (< f0-0 arg1))) (set! f0-0 (/ f0-0 arg1)) (when (!= f0-0 0.0) - (set! (-> arg0 data 0) (/ (-> arg0 data 0) f0-0)) - (set! (-> arg0 data 1) (/ (-> arg0 data 1) f0-0)) - (set! (-> arg0 data 2) (/ (-> arg0 data 2) f0-0)) + (set! (-> arg0 x) (/ (-> arg0 x) f0-0)) + (set! (-> arg0 y) (/ (-> arg0 y) f0-0)) + (set! (-> arg0 z) (/ (-> arg0 z) f0-0)) ) ) ) @@ -845,8 +837,8 @@ (when (not (or (= f0-0 0.0) (< f0-0 arg1))) (set! f0-0 (/ f0-0 arg1)) (when (!= f0-0 0.0) - (set! (-> arg0 data 0) (/ (-> arg0 data 0) f0-0)) - (set! (-> arg0 data 2) (/ (-> arg0 data 2) f0-0)) + (set! (-> arg0 x) (/ (-> arg0 x) f0-0)) + (set! (-> arg0 z) (/ (-> arg0 z) f0-0)) ) ) ) @@ -856,24 +848,21 @@ ;; definition for function vector-rotate-around-y! ;; Used lq/sq (defun vector-rotate-around-y! ((arg0 vector) (arg1 vector) (arg2 float)) - (let ((f26-0 (-> arg1 data 2)) - (f30-0 (-> arg1 data 0)) + (let ((f26-0 (-> arg1 z)) + (f30-0 (-> arg1 x)) (f28-0 (cos arg2)) (f0-0 (sin arg2)) ) (set! (-> arg0 quad) (-> arg1 quad)) - (set! (-> arg0 data 2) (- (* f26-0 f28-0) (* f30-0 f0-0))) - (set! (-> arg0 data 0) (+ (* f26-0 f0-0) (* f30-0 f28-0))) + (set! (-> arg0 z) (- (* f26-0 f28-0) (* f30-0 f0-0))) + (set! (-> arg0 x) (+ (* f26-0 f0-0) (* f30-0 f28-0))) ) arg0 ) ;; definition for function rotate-y<-vector+vector (defun rotate-y<-vector+vector ((arg0 vector) (arg1 vector)) - (atan - (- (-> arg1 data 0) (-> arg0 data 0)) - (- (-> arg1 data 2) (-> arg0 data 2)) - ) + (atan (- (-> arg1 x) (-> arg0 x)) (- (-> arg1 z) (-> arg0 z))) ) ;; definition for function vector-cvt.w.s! @@ -898,35 +887,35 @@ ;; definition for function rot-zxy-from-vector! (defun rot-zxy-from-vector! ((arg0 vector) (arg1 vector)) - (let* ((f28-0 (-> arg1 data 2)) - (f30-0 (-> arg1 data 0)) + (let* ((f28-0 (-> arg1 z)) + (f30-0 (-> arg1 x)) (f0-0 (atan f30-0 f28-0)) ) - (set! (-> arg0 data 1) f0-0) + (set! (-> arg0 y) f0-0) (let* ((f26-0 (- f0-0)) (f0-4 (- (* f28-0 (cos f26-0)) (* f30-0 (sin f26-0)))) ) - (set! (-> arg0 data 0) (atan (- (-> arg1 data 1)) f0-4)) + (set! (-> arg0 x) (atan (- (-> arg1 y)) f0-4)) ) ) - (set! (-> arg0 data 2) 0.0) + (set! (-> arg0 z) 0.0) arg0 ) ;; definition for function rot-zyx-from-vector! (defun rot-zyx-from-vector! ((arg0 vector) (arg1 vector)) - (let* ((f28-0 (-> arg1 data 2)) - (f30-0 (- (-> arg1 data 1))) + (let* ((f28-0 (-> arg1 z)) + (f30-0 (- (-> arg1 y))) (f0-1 (atan f30-0 f28-0)) ) - (set! (-> arg0 data 0) f0-1) + (set! (-> arg0 x) f0-1) (let* ((f26-0 (- f0-1)) (f0-5 (- (* f28-0 (cos f26-0)) (* f30-0 (sin f26-0)))) ) - (set! (-> arg0 data 1) (atan (-> arg1 data 0) f0-5)) + (set! (-> arg0 y) (atan (-> arg1 x) f0-5)) ) ) - (set! (-> arg0 data 2) 0.0) + (set! (-> arg0 z) 0.0) arg0 ) @@ -1137,19 +1126,10 @@ ) ) (else - (set! - (-> out data 0) - (deg-lerp-clamp (-> min-val data 0) (-> max-val data 0) in) - ) - (set! - (-> out data 1) - (deg-lerp-clamp (-> min-val data 1) (-> max-val data 1) in) - ) - (set! - (-> out data 2) - (deg-lerp-clamp (-> min-val data 2) (-> max-val data 2) in) - ) - (set! (-> out data 3) 1.0) + (set! (-> out x) (deg-lerp-clamp (-> min-val x) (-> max-val x) in)) + (set! (-> out y) (deg-lerp-clamp (-> min-val y) (-> max-val y) in)) + (set! (-> out z) (deg-lerp-clamp (-> min-val z) (-> max-val z) in)) + (set! (-> out w) 1.0) ) ) out @@ -1159,9 +1139,9 @@ (defun vector3s-copy! ((arg0 vector) (arg1 vector)) (let ((v1-0 "Copy a vector3s")) ) - (set! (-> arg0 data 0) (-> arg1 data 0)) - (set! (-> arg0 data 1) (-> arg1 data 1)) - (set! (-> arg0 data 2) (-> arg1 data 2)) + (set! (-> arg0 x) (-> arg1 x)) + (set! (-> arg0 y) (-> arg1 y)) + (set! (-> arg0 z) (-> arg1 z)) arg0 ) @@ -1169,9 +1149,9 @@ (defun vector3s+! ((arg0 vector) (arg1 vector) (arg2 vector)) (let ((v1-0 "Add 2 vectors3.")) ) - (set! (-> arg0 data 0) (+ (-> arg1 data 0) (-> arg2 data 0))) - (set! (-> arg0 data 1) (+ (-> arg1 data 1) (-> arg2 data 1))) - (set! (-> arg0 data 2) (+ (-> arg1 data 2) (-> arg2 data 2))) + (set! (-> arg0 x) (+ (-> arg1 x) (-> arg2 x))) + (set! (-> arg0 y) (+ (-> arg1 y) (-> arg2 y))) + (set! (-> arg0 z) (+ (-> arg1 z) (-> arg2 z))) arg0 ) @@ -1179,9 +1159,9 @@ (defun vector3s*float! ((arg0 vector) (arg1 vector) (arg2 float)) (let ((v1-0 "mult vectors3 by float")) ) - (set! (-> arg0 data 0) (* (-> arg1 data 0) arg2)) - (set! (-> arg0 data 1) (* (-> arg1 data 1) arg2)) - (set! (-> arg0 data 2) (* (-> arg1 data 2) arg2)) + (set! (-> arg0 x) (* (-> arg1 x) arg2)) + (set! (-> arg0 y) (* (-> arg1 y) arg2)) + (set! (-> arg0 z) (* (-> arg1 z) arg2)) arg0 ) @@ -1189,9 +1169,9 @@ (defun vector3s-! ((arg0 vector) (arg1 vector) (arg2 vector)) (let ((v1-0 "Subtract 2 vectors3: c = (a - b).")) ) - (set! (-> arg0 data 0) (- (-> arg1 data 0) (-> arg2 data 0))) - (set! (-> arg0 data 1) (- (-> arg1 data 1) (-> arg2 data 1))) - (set! (-> arg0 data 2) (- (-> arg1 data 2) (-> arg2 data 2))) + (set! (-> arg0 x) (- (-> arg1 x) (-> arg2 x))) + (set! (-> arg0 y) (- (-> arg1 y) (-> arg2 y))) + (set! (-> arg0 z) (- (-> arg1 z) (-> arg2 z))) arg0 ) @@ -1223,9 +1203,9 @@ ;; definition for function sphere<-vector! ;; Used lq/sq (defun sphere<-vector! ((arg0 sphere) (arg1 vector)) - (let ((f0-0 (-> arg0 data 3))) + (let ((f0-0 (-> arg0 w))) (set! (-> arg0 quad) (-> arg1 quad)) - (set! (-> arg0 data 3) f0-0) + (set! (-> arg0 w) f0-0) ) arg0 ) @@ -1234,17 +1214,17 @@ ;; Used lq/sq (defun sphere<-vector+r! ((arg0 sphere) (arg1 vector) (arg2 float)) (set! (-> arg0 quad) (-> arg1 quad)) - (set! (-> arg0 data 3) arg2) + (set! (-> arg0 w) arg2) arg0 ) ;; definition for function rand-vu-sphere-point! (defun rand-vu-sphere-point! ((arg0 vector) (arg1 float)) (let ((s4-0 arg0)) - (set! (-> s4-0 data 0) (rand-vu-float-range -1.0 1.0)) - (set! (-> s4-0 data 1) (rand-vu-float-range -1.0 1.0)) - (set! (-> s4-0 data 2) (rand-vu-float-range -1.0 1.0)) - (set! (-> s4-0 data 3) 1.0) + (set! (-> s4-0 x) (rand-vu-float-range -1.0 1.0)) + (set! (-> s4-0 y) (rand-vu-float-range -1.0 1.0)) + (set! (-> s4-0 z) (rand-vu-float-range -1.0 1.0)) + (set! (-> s4-0 w) 1.0) ) (vector-normalize! arg0 (rand-vu-float-range 0.0 arg1)) ) diff --git a/test/offline/offline_test_main.cpp b/test/offline/offline_test_main.cpp index fb4b0c9616..75867e9e32 100644 --- a/test/offline/offline_test_main.cpp +++ b/test/offline/offline_test_main.cpp @@ -418,6 +418,8 @@ TEST_F(OfflineDecompilation, Reference) { fmt::print("{}\n", src); }*/ + lg::info("Comparing {}...", file); + auto reference = file_util::read_text_file(file_util::get_file_path( {"test", "decompiler", "reference", fmt::format("{}_REF.gc", file)})); diff --git a/third-party/mman/mman.c b/third-party/mman/mman.c index 486ed94d88..3de4d8b55b 100644 --- a/third-party/mman/mman.c +++ b/third-party/mman/mman.c @@ -22,7 +22,7 @@ static DWORD __map_mmap_prot_page(const int prot) DWORD protect = 0; if (prot == PROT_NONE) - return protect; + return PAGE_NOACCESS; if ((prot & PROT_EXEC) != 0) {