diff --git a/decompiler/IR2/AtomicOpTypeAnalysis.cpp b/decompiler/IR2/AtomicOpTypeAnalysis.cpp index 84bcaf7cd2..3b189747e7 100644 --- a/decompiler/IR2/AtomicOpTypeAnalysis.cpp +++ b/decompiler/IR2/AtomicOpTypeAnalysis.cpp @@ -189,6 +189,7 @@ TP_Type SimpleExpression::get_type(const TypeState& input, case Kind::NEG: case Kind::LOGNOT: return get_type_int1(input, env, dts); + case Kind::DIV_UNSIGNED: case Kind::MOD_UNSIGNED: return TP_Type::make_from_ts("uint"); default: @@ -411,14 +412,14 @@ TP_Type SimpleExpression::get_type_int2(const TypeState& input, return TP_Type::make_object_plus_product(arg0_type.typespec(), arg1_type.get_multiplier()); } - if (m_kind == Kind::ADD && arg0_type.typespec().base_type() == "pointer" && - tc(dts, TypeSpec("integer"), arg1_type)) { + if ((m_kind == Kind::ADD || m_kind == Kind::SUB) && + arg0_type.typespec().base_type() == "pointer" && tc(dts, TypeSpec("integer"), arg1_type)) { // plain pointer plus integer = plain pointer return TP_Type::make_from_ts(arg0_type.typespec()); } - if (m_kind == Kind::ADD && arg1_type.typespec().base_type() == "pointer" && - tc(dts, TypeSpec("integer"), arg0_type)) { + if ((m_kind == Kind::ADD || m_kind == Kind::SUB) && + arg1_type.typespec().base_type() == "pointer" && tc(dts, TypeSpec("integer"), arg0_type)) { // plain pointer plus integer = plain pointer return TP_Type::make_from_ts(arg1_type.typespec()); } @@ -445,7 +446,7 @@ TP_Type SimpleExpression::get_type_int2(const TypeState& input, return TP_Type::make_from_ts(TypeSpec("int")); } - if (m_kind == Kind::SUB && tc(dts, TypeSpec("pointer"), arg0_type) && + if ((m_kind == Kind::ADD || m_kind == Kind::SUB) && tc(dts, TypeSpec("pointer"), arg0_type) && tc(dts, TypeSpec("pointer"), arg1_type)) { return TP_Type::make_from_ts(TypeSpec("int")); } @@ -1013,4 +1014,4 @@ TypeState AsmBranchOp::propagate_types_internal(const TypeState& input, return output; } -} // namespace decompiler \ No newline at end of file +} // namespace decompiler diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index aba133c62e..b0f519cffc 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -1175,6 +1175,10 @@ void SimpleExpressionElement::update_from_stack(const Env& env, update_from_stack_force_si_2(env, FixedOperatorKind::DIVISION, pool, stack, result, allow_side_effects, false); break; + case SimpleExpression::Kind::DIV_UNSIGNED: + update_from_stack_force_ui_2(env, FixedOperatorKind::DIVISION, pool, stack, result, + allow_side_effects); + break; case SimpleExpression::Kind::MOD_SIGNED: update_from_stack_force_si_2(env, FixedOperatorKind::MOD, pool, stack, result, allow_side_effects, false); diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 7698022e46..5db033d503 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -55,6 +55,7 @@ (define-extern *listener-function* (function object)) (define-extern *enable-method-set* int) (define-extern install-debug-handler (function int object symbol)) +(define-extern install-handler (function int (function int) none)) (define-extern file-stream-open (function file-stream basic basic file-stream)) (define-extern file-stream-length (function file-stream int)) @@ -139,9 +140,9 @@ (data uint8 :dynamic :offset-assert 12) ;; might not be here... (_pad uint8 4) ;; ??? ) - + (:methods (new (symbol type int) _type_ 0)) - + :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 @@ -220,13 +221,13 @@ (stack-top pointer :offset-assert 32) (stack-size int32 :offset-assert 36) ) - + (:methods (stack-size-set! (_type_ int) none 9) (thread-suspend (_type_) none 10) (thread-resume (_type_) none 11) ) - + :method-count-assert 12 :size-assert #x28 :flag-assert #xc00000028 @@ -242,13 +243,13 @@ (freg float 8) (stack uint8 :dynamic :offset-assert 128) ) - + (:methods (new (symbol type process symbol int pointer) _type_ 0) (thread-suspend (_type_) none 10) (thread-resume (_type_) none 11) ) - + :method-count-assert 12 :size-assert #x80 :flag-assert #xc00000080 @@ -264,7 +265,7 @@ (ppointer (pointer process-tree) :offset-assert 24) (self process-tree :offset-assert 28) ) - + (:methods (new (symbol type basic) _type_ 0) (activate (_type_ process-tree basic pointer) process-tree 9) @@ -272,8 +273,8 @@ (dummy-method-11 () none 11) (run-logic? (_type_) symbol 12) (dummy-method () none 13) - ) - + ) + :size-assert #x20 :method-count-assert 14 :no-runtime-type @@ -300,8 +301,8 @@ (connection-list connectable :inline :offset-assert #x60) (stack uint8 :dynamic :offset-assert #x70) ) - - + + (:methods (new (symbol type basic int) _type_ 0) (activate (_type_ process-tree basic pointer) process-tree 9) @@ -309,8 +310,8 @@ (dummy-method-11 () none 11) (run-logic? (process) symbol 12) (dummy-method () none 13) - ) - + ) + :size-assert #x70 :method-count-assert 14 :no-runtime-type ;; already defined by kscheme. Don't do it again. @@ -358,7 +359,7 @@ (dead-list dead-pool-heap-rec :inline :offset-assert 92) (process-list dead-pool-heap-rec :inline :dynamic :offset-assert 104) ) - + (:methods (new (symbol type basic int int) _type_ 0) (compact (dead-pool-heap int) none 16) @@ -373,7 +374,7 @@ (memory-free (dead-pool-heap) int 25) (compact-time (dead-pool-heap) uint 26) ) - + :method-count-assert 27 :size-assert #x68 :flag-assert #x1b00000068 @@ -383,7 +384,7 @@ ((name basic :offset 4) (next stack-frame :offset 8) ;; which way does this point? ) - + :size-assert #xc :method-count-assert 9 :flag-assert #x90000000c @@ -395,14 +396,14 @@ ;; changed from GOAL, see gkernel-h.gc (freg float 10 :offset-assert 20) (rreg uint128 7) - ;;(freg float 6 :offset-assert 20) - ;;(rreg uint128 8 :offset-assert 48) + ;;(freg float 6 :offset-assert 20) + ;;(rreg uint128 8 :offset-assert 48) ) - + (:methods (new (symbol type symbol function (pointer uint64)) object 0) ) - + :method-count-assert 9 :size-assert #xb0 :flag-assert #x9000000b0 @@ -414,7 +415,7 @@ (:methods (new (symbol type (function object)) protect-frame) ) - + :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 @@ -439,7 +440,7 @@ ) (:methods (new (symbol type basic function - (function object) + (function object) (function object object object object object object object) (function object) (function basic int basic event-message-block object)) _type_ 0) @@ -1606,7 +1607,7 @@ (define-extern deg-lerp-clamp (function float float float float)) (define-extern sin (function float float)) (define-extern sin-rad (function float float)) -(define-extern *sin-poly-vec* vector) +(define-extern *sin-poly-vec* vector) (define-extern *sin-poly-vec2* vector) (define-extern vector-sin-rad! (function vector vector vector)) (define-extern cos-rad (function float float)) @@ -2074,7 +2075,7 @@ ) (deftype timer-bank (structure) - ((count uint32 :offset-assert 0) + ((count uint32 :offset 0) (mode timer-mode :offset 16) (comp uint32 :offset 32) ) @@ -2084,7 +2085,7 @@ ) (deftype timer-hold-bank (timer-bank) - ((hold uint32 :offset 48) + ((hold uint32 :offset 48) ) :method-count-assert 9 :size-assert #x34 @@ -2114,6 +2115,7 @@ :flag-assert #x90000000c ) +(declare-type dma-buffer basic) (deftype profile-bar (basic) ((profile-frame-count int32 :offset-assert 4) (cache-time uint64 :offset-assert 8) @@ -2124,10 +2126,10 @@ :flag-assert #xe00004010 (:methods (get-last-frame-time-stamp (_type_) uint 9) - (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) - (dummy-13 () none 13) + (reset (_type_) _type_ 10) + (add-frame (_type_ symbol rgba) profile-frame 11) + (add-end-frame (_type_ symbol rgba) profile-frame 12) + (draw (_type_ dma-buffer int) float 13) ) ) @@ -2169,7 +2171,7 @@ (er1 uint8 :offset 13 :size 1) (fqc uint8 :offset 24 :size 4) ) - + :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -2235,7 +2237,9 @@ ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; (deftype dma-sqwc (uint32) - () + ((sqwc uint8 :offset 0 :size 8) + (tqwc uint8 :offset 16 :size 8) + ) :flag-assert #x900000004 ) @@ -2255,7 +2259,13 @@ ) (deftype dma-ctrl (uint32) - () + ((dmae uint8 :offset 0 :size 1) + (rele uint8 :offset 1 :size 1) + (mfd uint8 :offset 2 :size 2) + (sts uint8 :offset 4 :size 2) + (std uint8 :offset 6 :size 2) + (rcyc uint8 :offset 8 :size 3) + ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -2355,8 +2365,8 @@ ((imm uint16 :offset 0 :size 16) (num uint8 :offset 16 :size 8) (cmd uint8 :offset 24 :size 7) + (irq uint8 :offset 31 :size 1) (msk uint8 :offset 28 :size 1) - (irq uint8 :offset 31 :size 1) ;;? ) :method-count-assert 9 :size-assert #x4 @@ -2364,7 +2374,7 @@ ) (deftype dma-enable (uint32) - () + ((cpnd uint8 :offset 16 :size 1)) :flag-assert #x900000004 ) @@ -2375,17 +2385,38 @@ ) (deftype vif-mask (uint32) - () + ((m0 uint8 :offset 0 :size 2) + (m1 uint8 :offset 2 :size 2) + (m2 uint8 :offset 4 :size 2) + (m3 uint8 :offset 6 :size 2) + (m4 uint8 :offset 8 :size 2) + (m5 uint8 :offset 10 :size 2) + (m6 uint8 :offset 12 :size 2) + (m7 uint8 :offset 14 :size 2) + (m8 uint8 :offset 16 :size 2) + (m9 uint8 :offset 18 :size 2) + (m10 uint8 :offset 20 :size 2) + (m11 uint8 :offset 22 :size 2) + (m12 uint8 :offset 24 :size 2) + (m13 uint8 :offset 26 :size 2) + (m14 uint8 :offset 28 :size 2) + (m15 uint8 :offset 30 :size 2) + ) :flag-assert #x900000004 ) (deftype vif-stcycl-imm (uint16) - () + ((cl uint8 :offset 0 :size 8) + (wl uint8 :offset 8 :size 8) + ) :flag-assert #x900000002 ) (deftype vif-unpack-imm (uint16) - () + ((addr uint16 :offset 0 :size 10) + (usn uint8 :offset 14 :size 1) + (flg uint8 :offset 15 :size 1) + ) :flag-assert #x900000002 ) @@ -2714,9 +2745,6 @@ :flag-assert #x900000010 ) -;; display -(define-extern get-current-time (function uint)) -(define-extern get-integral-current-time (function uint)) ;; in the kernel. (define-extern cpad-open (function cpad-info int cpad-info)) (define-extern cpad-get-data (function cpad-info cpad-info)) @@ -2906,16 +2934,7 @@ ;; 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) - (;; type of primitive: - ;; - 0: point - ;; - 1: line - ;; - 2: line strip - ;; - 3: tri - ;; - 4: tri strip - ;; - 5: tri fan - ;; - 6: sprite (what?) - ;; - 7: dark magic? - (prim uint8 :offset 0 :size 3) + ((prim uint8 :offset 0 :size 3) (iip uint8 :offset 3 :size 1) (tme uint8 :offset 4 :size 1) (fge uint8 :offset 5 :size 1) @@ -3222,7 +3241,7 @@ (define-extern *fog-color* int) (define-extern default-buffer-init (function dma-buffer none)) -(define-extern *default-regs-buffer* dma-buffer) +(define-extern *default-regs-buffer* dma-buffer) (deftype gif-packet (basic) @@ -3230,7 +3249,7 @@ (gif-tag0 uint128 :offset-assert 16) (gif-tag gs-gif-tag :inline :offset 16) ;; note- added (args uint64 1 :offset-assert 32) - + ) (:methods (new (symbol type int) _type_ 0) @@ -3246,10 +3265,10 @@ (orgz int32 :offset-assert 12) (width int32 :offset-assert 16) (height int32 :offset-assert 20) - (color int32 4 :offset-assert 24) + (color rgba 4 :offset-assert 24) ) - (:methods - (new (symbol type int int int int int) _type_ 0) + (:methods + (new (symbol type int int int int rgba) _type_ 0) ) :method-count-assert 9 :size-assert #x28 @@ -3261,7 +3280,6 @@ ;;(define-extern gif-bank object) ;; unknown type ;;(define-extern gif-tag object) ;; unknown type (define-extern add-reg-gif-packet (function gif-packet int int none)) -;;(define-extern draw-context object) ;; unknown type (define-extern open-gif-packet (function gif-packet gif-packet)) ;;(define-extern gif-tag-count object) ;; unknown type ;;(define-extern gif-tag64 object) ;; unknown type @@ -3298,23 +3316,24 @@ :flag-assert #x900000028 ) +;; the "addr" fields represent GS register addresses (deftype draw-env (structure) - ((frame1 uint64 :offset-assert 0) - (frame1addr uint64 :offset-assert 8) - (zbuf1 uint64 :offset-assert 16) - (zbuf1addr uint64 :offset-assert 24) - (xyoffset1 uint64 :offset-assert 32) - (xyoffset1addr uint64 :offset-assert 40) - (scissor1 uint64 :offset-assert 48) - (scissor1addr uint64 :offset-assert 56) - (prmodecont uint64 :offset-assert 64) - (prmodecontaddr uint64 :offset-assert 72) - (colclamp uint64 :offset-assert 80) - (colclampaddr uint64 :offset-assert 88) - (dthe uint64 :offset-assert 96) - (dtheaddr uint64 :offset-assert 104) - (test1 uint64 :offset-assert 112) - (test1addr uint64 :offset-assert 120) + ((frame1 gs-frame :offset-assert 0) + (frame1addr int64 :offset-assert 8) + (zbuf1 gs-zbuf :offset-assert 16) + (zbuf1addr int64 :offset-assert 24) + (xyoffset1 gs-xy-offset :offset-assert 32) + (xyoffset1addr int64 :offset-assert 40) + (scissor1 gs-scissor :offset-assert 48) + (scissor1addr int64 :offset-assert 56) + (prmodecont gs-prmode-cont :offset-assert 64) + (prmodecontaddr int64 :offset-assert 72) + (colclamp gs-color-clamp :offset-assert 80) + (colclampaddr int64 :offset-assert 88) + (dthe gs-dthe :offset-assert 96) + (dtheaddr int64 :offset-assert 104) + (test1 gs-test :offset-assert 112) + (test1addr int64 :offset-assert 120) ) :method-count-assert 9 :size-assert #x80 @@ -3336,7 +3355,7 @@ (profile-bar basic 2 :offset 48) (run-time uint64 :offset 56) ) - (:methods + (:methods (new (symbol type) _type_ 0) ) :method-count-assert 9 @@ -3351,7 +3370,7 @@ (draw draw-env :offset-assert 12) (frame display-frame :offset-assert 16) ) - + :allow-misaligned :method-count-assert 9 :size-assert #x14 @@ -3371,7 +3390,7 @@ (on-screen int32 :offset-assert 560) (last-screen int32 :offset-assert 564) (frames virtual-frame 6 :inline :offset-assert 568) - (bg-clear-color rgba 4 :offset-assert 760) + (bg-clear-color rgba 4 :offset-assert 760) (real-frame-counter uint64 :offset-assert 776) (base-frame-counter uint64 :offset-assert 784) (game-frame-counter uint64 :offset-assert 792) @@ -3398,13 +3417,51 @@ :size-assert #x39c :flag-assert #xa0000039c (:methods - (new (symbol type int int int int int) _type_ 0) - (dummy-9 () none 9) - ) + (new (symbol type int int int int int) _type_ 0) + (set-video-time-params (_type_ float) float 9) + ) ) (define-extern *display* display) + +;;;;;;;;;;;;;;; +;; display +;;;;;;;;;;;;;;; + +(define-extern get-current-time (function uint)) +(define-extern get-integral-current-time (function uint)) +(define-extern set-display-env (function display-env int int int int int int display-env)) +(define-extern set-draw-env (function draw-env int int int int int int draw-env)) +(define-extern set-draw-env-offset (function draw-env int int int draw-env)) +(define-extern put-display-alpha-env (function draw-env none)) (define-extern set-display (function display int int int int int display)) +(define-extern set-display2 (function display int int int int int display)) +(define-extern allocate-dma-buffers (function display display)) + +(define-extern draw-sprite2d-xy (function dma-buffer int int int int rgba none)) +(define-extern draw-quad2d (function dma-buffer draw-context none)) +(define-extern screen-gradient (function dma-buffer rgba rgba rgba rgba none)) + +(define-extern vif1-handler-debug (function int)) +(define-extern vif1-handler (function int)) +(define-extern vblank-handler (function int)) + +(define-extern set-display-gs-state (function dma-buffer int int int int int dma-buffer)) +(define-extern set-display-gs-state-offset (function dma-buffer int int int int int int int dma-buffer)) +(define-extern reset-display-gs-state (function display dma-buffer int none)) + +(define-extern *profile-x* int) +(define-extern *profile-y* int) +(define-extern *profile-w* int) +(define-extern *profile-h* int) +(define-extern *profile-ticks* symbol) +(define-extern *vblank-counter* int) +(define-extern *oddeven* int) +(define-extern *vu0-dma-list* dma-buffer) + +(declare-type font-context basic) +(define-extern *font-context* font-context) +(define-extern *pause-context* font-context) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -4008,15 +4065,15 @@ (receiving-level basic :offset-assert 32) (load-commands pair :offset-assert 36) (play? basic :offset-assert 40) - ;; there's something? from 40 -> 96. + ;; there's something? from 40 -> 96. (hack-pad uint8 :offset 90) - + ;(level level 3 :inline :offset-assert 96) ;(data level 3 :inline :offset-assert 100) (level0 level :inline :offset-assert 96) ;; inline basic (level1 level :inline :offset-assert 2704) ;; inline basic (level-default level :inline :offset-assert 5312) ;; inline basic - ;; this actually went earlier, + ;; this actually went earlier, (level level 3 :inline :offset 96) (pad uint32) ) @@ -4301,7 +4358,7 @@ :method-count-assert 14 :size-assert #x20 :flag-assert #xe00000020 - ;; field param1 is a basic loaded with a signed load field param2 is a basic loaded with a signed load field param3 is a basic loaded with a signed load + ;; field param1 is a basic loaded with a signed load field param2 is a basic loaded with a signed load field param3 is a basic loaded with a signed load (:methods (print (connection) _type_ 2) (get-engine (connection) engine 9) @@ -4333,18 +4390,18 @@ :flag-assert #x1800000080 (:methods (new (symbol type basic int) _type_ 0) - (inspect-all-connections (engine) none 9) - (apply-to-connections (engine (function connectable none)) none 10) - (apply-to-connections-reverse (engine (function connectable none)) none 11) - (execute-connections (engine object) none 12) - (execute-connections-and-move-to-dead (engine object) none 13) - (execute-connections-if-needed (engine object) none 14) + (inspect-all-connections (engine) engine 9) + (apply-to-connections (engine (function connectable none)) int 10) + (apply-to-connections-reverse (engine (function connectable none)) int 11) + (execute-connections (engine object) int 12) + (execute-connections-and-move-to-dead (engine object) int 13) + (execute-connections-if-needed (engine object) int 14) (add-connection (engine process (function object object object object object) object object object) connection 15) - (remove-from-process (engine process) none 16) - (remove-matching (engine (function connection engine symbol)) none 17) - (remove-all (engine) none 18) - (remove-by-param1 (engine object) none 19) - (remove-by-param2 (engine int) none 20) + (remove-from-process (engine process) int 16) + (remove-matching (engine (function connection engine symbol)) int 17) + (remove-all (engine) int 18) + (remove-by-param1 (engine object) int 19) + (remove-by-param2 (engine int) int 20) (get-first-connectable (engine) connectable 21) (get-last-connectable (engine) connectable 22) (unknown-1 (engine (pointer uint32)) uint 23) @@ -4424,7 +4481,7 @@ (ambient-volume-movie float :offset-assert 144) (dialog-volume-hint float :offset-assert 148) (dummy uint32 11 :offset-assert 152) - + ) :method-count-assert 10 :size-assert #xc4 @@ -4476,26 +4533,25 @@ ;;;;;;;;;;;;;;;;; (deftype gs-store-image-packet (structure) - ((vifcode uint32 4 :offset-assert 0) - (giftag uint128 :offset-assert 16) - (bitbltbuf uint64 :offset-assert 32) - (bitbltbuf-addr uint64 :offset-assert 40) - (trxpos uint64 :offset-assert 48) - (trxpos-addr uint64 :offset-assert 56) - (trxreg uint64 :offset-assert 64) - (trxreg-addr uint64 :offset-assert 72) - (finish uint64 :offset-assert 80) - (finish-addr uint64 :offset-assert 88) - (trxdir uint64 :offset-assert 96) - (trxdir-addr uint64 :offset-assert 104) + ((vifcode vif-tag 4 :offset-assert 0) + (giftag gif-tag :offset-assert 16) + (bitbltbuf gs-bitbltbuf :offset-assert 32) + (bitbltbuf-addr int64 :offset-assert 40) + (trxpos gs-trxpos :offset-assert 48) + (trxpos-addr int64 :offset-assert 56) + (trxreg gs-trxreg :offset-assert 64) + (trxreg-addr int64 :offset-assert 72) + (finish int64 :offset-assert 80) ;; gs-finish + (finish-addr int64 :offset-assert 88) + (trxdir gs-trxdir :offset-assert 96) + (trxdir-addr int64 :offset-assert 104) ) :method-count-assert 9 :size-assert #x70 :flag-assert #x900000070 ) -(define-extern store-image function) -;;(define-extern gs-store-image-packet object) ;; unknown type +(define-extern store-image (function int int int int)) (define-extern gs-set-default-store-image (function gs-store-image-packet int int int int int int int int)) ;;;;;;;;;;;;;;;;;; @@ -4633,7 +4689,7 @@ :method-count-assert 10 :size-assert #x20 :flag-assert #xa00000020 - ;; field param1 is a basic loaded with a signed load field param2 is a basic loaded with a signed load + ;; field param1 is a basic loaded with a signed load field param2 is a basic loaded with a signed load (:methods (dummy-9 () none 9) ) @@ -4733,7 +4789,7 @@ :method-count-assert 18 :size-assert #x20 :flag-assert #x1200000020 - ;; field distance is a float printed as hex? + ;; field distance is a float printed as hex? (:methods (dummy-9 () none 9) (dummy-10 (_type_) int 10) @@ -5940,7 +5996,7 @@ ;; (state UNKNOWN 16 :offset-assert 1920) (num-stars float :offset 1936) ) - (:methods + (:methods (new (symbol type) _type_ 0) ) :method-count-assert 9 @@ -6603,7 +6659,7 @@ :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 - ;; field xyz-scale is a float printed as hex? + ;; field xyz-scale is a float printed as hex? ) ;; merc-h @@ -6678,7 +6734,7 @@ (send-query basic :offset-assert 32) (query basic :offset-assert 36) ) - (:methods + (:methods (new (symbol type) _type_ 0) ) :method-count-assert 9 @@ -7520,7 +7576,7 @@ :method-count-assert 29 :size-assert #x144 :flag-assert #x1d00000144 - ;; field dummy is a basic loaded with a signed load + ;; field dummy is a basic loaded with a signed load (:methods (dummy-9 () none 9) (dummy-10 () none 10) @@ -7975,7 +8031,7 @@ :method-count-assert 22 :size-assert #x20 :flag-assert #x1600000020 - ;; field extra is a basic loaded with a signed load + ;; field extra is a basic loaded with a signed load (:methods (dummy-9 () none 9) (dummy-10 () none 10) @@ -8066,7 +8122,7 @@ ;; dataw went here (mode basic :offset-assert 144) (flags uint32 :offset-assert 148) - + (data float 30 :offset 8) (hook basic 4 :offset 128) (dataw uint32 2 :offset 144) @@ -8234,12 +8290,12 @@ ;; fact-h (deftype fact-info-enemy (fact-info) ((speed float :offset-assert 40) - (idle-distance float :offset-assert 44) ; meters - (notice-top float :offset-assert 48) ; meters - (notice-bottom float :offset-assert 52) ; meters - (cam-horz float :offset-assert 56) ; meters - (cam-vert float :offset-assert 60) ; meters - (cam-notice-dist float :offset-assert 64) ; meters + (idle-distance float :offset-assert 44) ; meters + (notice-top float :offset-assert 48) ; meters + (notice-bottom float :offset-assert 52) ; meters + (cam-horz float :offset-assert 56) ; meters + (cam-vert float :offset-assert 60) ; meters + (cam-notice-dist float :offset-assert 64) ; meters ) :method-count-assert 12 :size-assert #x44 @@ -8509,7 +8565,7 @@ :method-count-assert 15 :size-assert #xe0 :flag-assert #xf007000e0 - ;; inherited inspect of processfield ~Tuserdata is a basic loaded with a signed load + ;; inherited inspect of processfield ~Tuserdata is a basic loaded with a signed load (:methods (dummy-14 () none 14) ) @@ -11585,7 +11641,7 @@ ; :method-count-assert 9 ; :size-assert #x8c ; :flag-assert #x90000008c -; ;; field key is a basic loaded with a signed load +; ;; field key is a basic loaded with a signed load ; ) ; ;; sparticle-h @@ -17772,7 +17828,7 @@ ; :method-count-assert 20 ; :size-assert #x160 ; :flag-assert #x1400f00160 -; ;; inherited inspect of process-drawablefield ~Tstate-object is a basic loaded with a signed load +; ;; inherited inspect of process-drawablefield ~Tstate-object is a basic loaded with a signed load ; (:methods ; (dummy-9 () none 9) ; (dummy-10 () none 10) @@ -32904,8 +32960,6 @@ ;;(define-extern error object) ;; unknown type ;;(define-extern details object) ;; unknown type -(define-extern get-integral-current-time (function uint)) -(define-extern get-current-time (function uint)) ;;(define-extern cpad-get-data object) ;; unknown type ;;(define-extern cpad-open object) ;; unknown type @@ -32965,33 +33019,7 @@ ;;(define-extern font-context object) ;; unknown type ;;(define-extern *font-work* object) ;; unknown type ;;(define-extern decomp-work object) ;; unknown type -;;(define-extern install-handler object) ;; unknown type -;;(define-extern *oddeven* object) ;; unknown type -;;(define-extern *profile-y* object) ;; unknown type -(define-extern vif1-handler function) -;;(define-extern *pause-context* object) ;; unknown type -;;(define-extern *profile-h* object) ;; unknown type -;;(define-extern *profile-x* object) ;; unknown type -(define-extern set-draw-env-offset function) -;;(define-extern *vblank-counter* object) ;; unknown type -;;(define-extern *vu0-dma-list* object) ;; unknown type -;;(define-extern *profile-w* object) ;; unknown type -(define-extern set-display-gs-state function) -(define-extern draw-quad2d function) -(define-extern put-display-alpha-env function) -(define-extern set-display-gs-state-offset function) -(define-extern screen-gradient function) -(define-extern draw-sprite2d-xy function) -(define-extern set-draw-env function) -(define-extern reset-display-gs-state function) -(define-extern vblank-handler function) -;;(define-extern *profile-ticks* object) ;; unknown type -;;(define-extern *font-context* object) ;; unknown type -(define-extern vif1-handler-debug function) -(define-extern set-display-env (function display-env int int int int int int display-env)) -(define-extern set-display2 function) -(define-extern allocate-dma-buffers function) -(define-extern draw-string-xy function) +(define-extern draw-string-xy (function string dma-buffer int int int none)) ;;(define-extern end-draw object) ;; unknown type (define-extern start function) ;;(define-extern pal object) ;; unknown type diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index e723b5958e..558a815dfe 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -216,11 +216,29 @@ ["L48", "float", true], ["L46", "float", true], ["L50", "float", true], - ["L49", "float", true] + ["L49", "float", true], + ["L87", "float", true], + ["L77", "float", true], + ["L78", "float", true], + ["L79", "float", true], + ["L76", "(pointer uint32)", true, 2], + ["L51", "uint64", true], + ["L52", "uint64", true], + ["L53", "uint64", true], + ["L54", "uint64", true], + ["L55", "uint64", true], + ["L56", "uint64", true], + ["L57", "uint64", true], + ["L58", "uint64", true] ], "text-h": [["L2", "_auto_", true]], + "capture": [ + ["L27", "uint64", true], + ["L12", "gs-store-image-packet", true] + ], + "ocean-trans-tables": [ ["L1", "(pointer float)", true, 16], ["L2", "(pointer float)", true, 160], diff --git a/decompiler/config/jak1_ntsc_black_label/stack_vars.jsonc b/decompiler/config/jak1_ntsc_black_label/stack_vars.jsonc index af86591691..37a940d918 100644 --- a/decompiler/config/jak1_ntsc_black_label/stack_vars.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/stack_vars.jsonc @@ -134,5 +134,8 @@ "circle-test": [[16, "sphere"], [32, "sphere"], [48, "vector"], [64, "vector"]], + "draw-sprite2d-xy": [[16, "draw-context"]], + "screen-gradient": [[16, "draw-context"]], + "(method 10 oscillating-vector)":[[16, "vector"]] } diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index e5cf129b6b..136b63fb68 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -151,5 +151,10 @@ [4, "a1", "level-load-info"], [8, "a1", "level-load-info"], [12, "a1", "level-load-info"] + ], + + // DISPLAY + "put-display-alpha-env": [ + [[0, 5], "v1", "gs-bank"] ] } diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index ad72e82a8c..eeafc6e322 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -758,12 +758,43 @@ "args": ["allocation", "type-to-make", "psm", "w", "h", "ztest", "zpsm"], "vars": { "gp-0": "obj" } }, - + + "(method 9 display)": { + "args": ["obj", "delta-seconds"], + "vars": { "gp-0": "obj", "s5-0":"delta" } + }, + + "set-draw-env-offset": { + "args": ["env", "x", "y"] + }, + + "set-display": { + "args": ["display", "psm", "w", "h", "ztest", "zpsm"] + }, + + "set-display2": { + "args": ["display", "psm", "w", "h", "ztest", "zpsm"] + }, + + "(method 11 profile-bar)": { + "args": ["obj", "name", "color"], + "vars": { "s5-0":"new-frame" } + }, + + "(method 12 profile-bar)": { + "args": ["obj", "name", "color"], + "vars": { "v0-0":"new-frame" } + }, + + "gs-set-default-store-image": { + "args": ["packet"] + }, + "(method 0 draw-context)": { "args": ["allocation", "type-to-make", "org-x", "org-y", "width", "height", "color-0"], - "vars": { "v0-0": "obj"} + "vars": { "v0-0": "obj"} }, - + "draw-context-set-xy": { "args": ["ctxt", "x", "y"] }, diff --git a/goal_src/engine/dma/dma-h.gc b/goal_src/engine/dma/dma-h.gc index 319591f516..ea9fff6c31 100644 --- a/goal_src/engine/dma/dma-h.gc +++ b/goal_src/engine/dma/dma-h.gc @@ -106,7 +106,13 @@ ;; D_CTRL, master DMA control register, shared for all channels. (deftype dma-ctrl (uint32) - () + ((dmae uint8 :offset 0 :size 1) + (rele uint8 :offset 1 :size 1) + (mfd uint8 :offset 2 :size 2) + (sts uint8 :offset 4 :size 2) + (std uint8 :offset 6 :size 2) + (rcyc uint8 :offset 8 :size 3) + ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -114,13 +120,15 @@ ;; D_ENABLEW, D_ENABLER? (deftype dma-enable (uint32) - () + ((cpnd uint8 :offset 16 :size 1)) :flag-assert #x900000004 ) ;; D_SQWC (deftype dma-sqwc (uint32) - () + ((sqwc uint8 :offset 0 :size 8) + (tqwc uint8 :offset 16 :size 8) + ) :flag-assert #x900000004 ) @@ -192,32 +200,53 @@ :flag-assert #x900000010 ) -;; ?? +;; guess - VIF_MASK register? (deftype vif-mask (uint32) - () + ((m0 uint8 :offset 0 :size 2) + (m1 uint8 :offset 2 :size 2) + (m2 uint8 :offset 4 :size 2) + (m3 uint8 :offset 6 :size 2) + (m4 uint8 :offset 8 :size 2) + (m5 uint8 :offset 10 :size 2) + (m6 uint8 :offset 12 :size 2) + (m7 uint8 :offset 14 :size 2) + (m8 uint8 :offset 16 :size 2) + (m9 uint8 :offset 18 :size 2) + (m10 uint8 :offset 20 :size 2) + (m11 uint8 :offset 22 :size 2) + (m12 uint8 :offset 24 :size 2) + (m13 uint8 :offset 26 :size 2) + (m14 uint8 :offset 28 :size 2) + (m15 uint8 :offset 30 :size 2) + ) :flag-assert #x900000004 ) -;; ?? +;; the IMM field of a VIF STCYCL instruction (deftype vif-stcycl-imm (uint16) - () + ((cl uint8 :offset 0 :size 8) + (wl uint8 :offset 8 :size 8) + ) :flag-assert #x900000002 ) -;; ?? +;; the IMM field of a VIF UNPACK instruction (deftype vif-unpack-imm (uint16) - () + ((addr uint16 :offset 0 :size 10) + (usn uint8 :offset 14 :size 1) + (flg uint8 :offset 15 :size 1) + ) :flag-assert #x900000002 ) ;; The VIF also has tags to control it. -;; Different VIF commands (called VIFCode) have different tag layouts. +;; Different VIF commands (called VIFcode) have different tag layouts. (deftype vif-tag (uint32) ((imm uint16 :offset 0 :size 16) (num uint8 :offset 16 :size 8) (cmd uint8 :offset 24 :size 7) + (irq uint8 :offset 31 :size 1) (msk uint8 :offset 28 :size 1) - (irq uint8 :offset 31 :size 1) ;;? ) :method-count-assert 9 :size-assert #x4 @@ -269,12 +298,12 @@ This function is unused." ((inline dma-sync-fast) bank) (flush-cache 0) - ;; (.sync.l) + (.sync.l) (set! (-> bank madr) madr) (set! (-> bank qwc) qwc) - ;; (.sync.l) + (.sync.l) - ;; this seems wrong, the set everything to 0, + ;; this seems wrong, they set everything to 0, ;; including dir, which is the to-memory direction (set! (-> bank chcr) (new 'static 'dma-chcr :str 1) diff --git a/goal_src/engine/engine/connect.gc b/goal_src/engine/engine/connect.gc index aaeb1d1673..11b5bc8f39 100644 --- a/goal_src/engine/engine/connect.gc +++ b/goal_src/engine/engine/connect.gc @@ -60,7 +60,7 @@ :method-count-assert 14 :size-assert #x20 :flag-assert #xe00000020 - ;; the params are loaded with a signed load, which is kinda weird... + ;; the params are loaded with a signed load, which is kinda weird... (:methods (print (connection) _type_ 2) (get-engine (connection) engine 9) @@ -100,18 +100,18 @@ :flag-assert #x1800000080 (:methods (new (symbol type basic int) _type_ 0) - (inspect-all-connections (engine) none 9) - (apply-to-connections (engine (function connectable none)) none 10) - (apply-to-connections-reverse (engine (function connectable none)) none 11) - (execute-connections (engine object) none 12) - (execute-connections-and-move-to-dead (engine object) none 13) - (execute-connections-if-needed (engine object) none 14) + (inspect-all-connections (engine) engine 9) + (apply-to-connections (engine (function connectable none)) int 10) + (apply-to-connections-reverse (engine (function connectable none)) int 11) + (execute-connections (engine object) int 12) + (execute-connections-and-move-to-dead (engine object) int 13) + (execute-connections-if-needed (engine object) int 14) (add-connection (engine process (function object object object object object) object object object) connection 15) - (remove-from-process (engine process) none 16) - (remove-matching (engine (function connection engine symbol)) none 17) - (remove-all (engine) none 18) - (remove-by-param1 (engine object) none 19) - (remove-by-param2 (engine int) none 20) + (remove-from-process (engine process) int 16) + (remove-matching (engine (function connection engine symbol)) int 17) + (remove-all (engine) int 18) + (remove-by-param1 (engine object) int 19) + (remove-by-param2 (engine int) int 20) (get-first-connectable (engine) connectable 21) (get-last-connectable (engine) connectable 22) (unknown-1 (engine (pointer uint32)) uint 23) @@ -125,7 +125,7 @@ (defmethod print connection ((obj connection)) "Print a connection and its parameters" - (format '#t "#" + (format #t "#" (-> obj param0) (-> obj param1) (-> obj param2) @@ -245,38 +245,38 @@ (defmethod print engine ((obj engine)) "Print an engine and its name" - (format '#t "#<~A ~A @ #x~X>" (-> obj type) (-> obj name) obj) + (format #t "#<~A ~A @ #x~X>" (-> obj type) (-> obj name) obj) obj ) (defmethod inspect engine ((obj engine)) (local-vars (s5-0 binteger) (s5-1 binteger) (s5-2 binteger) (s5-3 binteger)) - (format '#t "[~8x] ~A~%" obj (-> obj type)) - (format '#t "~Tname: ~A~%" (-> obj name)) - (format '#t "~Tengine-time: ~D~%" (-> obj engine-time)) - (format '#t "~Tallocated-length: ~D~%" (-> obj allocated-length)) - (format '#t "~Tlength: ~D~%" (-> obj length)) - (format '#t "~Talive-list:~%") + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tname: ~A~%" (-> obj name)) + (format #t "~Tengine-time: ~D~%" (-> obj engine-time)) + (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) + (format #t "~Tlength: ~D~%" (-> obj length)) + (format #t "~Talive-list:~%") (set! s5-0 *print-column*) (set! *print-column* (+ *print-column* 8)) ((method-of-type connectable inspect) (-> obj alive-list)) (set! *print-column* s5-0) - (format '#t "~Talive-list-end:~%") + (format #t "~Talive-list-end:~%") (set! s5-1 *print-column*) (set! *print-column* (+ *print-column* 8)) ((method-of-type connectable inspect) (-> obj alive-list-end)) (set! *print-column* s5-1) - (format '#t "~Tdead-list:~%") + (format #t "~Tdead-list:~%") (set! s5-2 *print-column*) (set! *print-column* (+ *print-column* 8)) ((method-of-type connectable inspect) (-> obj dead-list)) (set! *print-column* s5-2) - (format '#t "~Tdead-list-end:~%") + (format #t "~Tdead-list-end:~%") (set! s5-3 *print-column*) (set! *print-column* (+ *print-column* 8)) ((method-of-type connectable inspect) (-> obj dead-list-end)) (set! *print-column* s5-3) - (format '#t "~Tdata[~D]: @ #x~X~%" (-> obj allocated-length) (-> obj data)) + (format #t "~Tdata[~D]: @ #x~X~%" (-> obj allocated-length) (-> obj data)) obj ) @@ -305,18 +305,18 @@ (set! iter next) (set! next (-> next next0)) ) - (none) + 0 ) (defmethod apply-to-connections-reverse engine ((obj engine) (arg0 (function connectable none))) "Apply the given function to all the live conntables in the engine, iterating backward." - (local-vars (s4-0 connectable)) - (set! s4-0 (-> obj alive-list-end prev0)) - (while (!= s4-0 (-> obj alive-list)) + (let ((s4-0 (-> obj alive-list-end prev0))) + (while (!= s4-0 (-> obj alive-list)) (arg0 s4-0) (set! s4-0 (-> s4-0 prev0)) ) - (none) + ) + 0 ) (defmethod execute-connections engine ((obj engine) (arg0 object)) @@ -337,8 +337,7 @@ ) (set! s4-0 (-> s4-0 prev0)) ) - (none) - ) + 0) (defmethod execute-connections-and-move-to-dead engine ((obj engine) (arg0 object)) "Execute connections, but remove dead connections from the list." @@ -364,8 +363,7 @@ (move-to-dead (the-as connection (-> s4-0 next0))) ) ) - (none) - ) + 0) (defmethod execute-connections-if-needed engine ((obj engine) (arg0 object)) "Execute connections, but only if it hasn't been done on this frame." @@ -376,13 +374,13 @@ (defun connection-process-apply ((proc process) (func (function object none))) "Apply a function to all connectables of a process." - (local-vars (iter connectable)) (when proc ;; iterate with next1 to stay in the process list. - (set! iter (-> proc connection-list next1)) - (while iter - (func iter) - (set! iter (-> iter next1)) + (let ((iter (-> proc connection-list next1))) + (while iter + (func iter) + (set! iter (-> iter next1)) + ) ) #f ) @@ -393,6 +391,7 @@ "inspect all of the connections." (apply-to-connections obj (the (function connection none) (method-of-type connection inspect))) + obj ) ) @@ -493,8 +492,7 @@ (set! iter (the connection (-> iter next1))) ) ) - (none) - ) + 0) (defmethod remove-matching engine ((obj engine) (arg0 (function connection engine symbol))) "call the given function on each connection and the engine. @@ -513,8 +511,7 @@ (set! s4-0 s3-0) (set! s3-0 (-> s3-0 next0)) ) - (none) - ) + 0) (defmethod remove-all engine ((obj engine)) "Remove all connections from an engine" @@ -530,8 +527,7 @@ (set! a0-1 s5-0) (set! s5-0 (-> s5-0 next0)) ) - (none) - ) + 0) (defmethod remove-by-param1 engine ((obj engine) (arg0 object)) @@ -549,8 +545,7 @@ (set! a0-1 s4-0) (set! s4-0 (-> s4-0 next0)) ) - (none) - ) + 0) (defmethod remove-by-param2 engine ((obj engine) (arg0 int)) "Remove all connections with param2 matching arg0" @@ -567,5 +562,4 @@ (set! a0-1 s4-0) (set! s4-0 (-> s4-0 next0)) ) - (none) - ) + 0) diff --git a/goal_src/engine/gfx/hw/display-h.gc b/goal_src/engine/gfx/hw/display-h.gc index d8ccb92dcf..816428abae 100644 --- a/goal_src/engine/gfx/hw/display-h.gc +++ b/goal_src/engine/gfx/hw/display-h.gc @@ -18,23 +18,24 @@ :flag-assert #x900000028 ) +;; the "addr" fields represent GS register addresses (deftype draw-env (structure) - ((frame1 uint64 :offset-assert 0) - (frame1addr uint64 :offset-assert 8) - (zbuf1 uint64 :offset-assert 16) - (zbuf1addr uint64 :offset-assert 24) - (xyoffset1 uint64 :offset-assert 32) - (xyoffset1addr uint64 :offset-assert 40) - (scissor1 uint64 :offset-assert 48) - (scissor1addr uint64 :offset-assert 56) - (prmodecont uint64 :offset-assert 64) - (prmodecontaddr uint64 :offset-assert 72) - (colclamp uint64 :offset-assert 80) - (colclampaddr uint64 :offset-assert 88) - (dthe uint64 :offset-assert 96) - (dtheaddr uint64 :offset-assert 104) - (test1 uint64 :offset-assert 112) - (test1addr uint64 :offset-assert 120) + ((frame1 gs-frame :offset-assert 0) + (frame1addr int64 :offset-assert 8) + (zbuf1 gs-zbuf :offset-assert 16) + (zbuf1addr int64 :offset-assert 24) + (xyoffset1 gs-xy-offset :offset-assert 32) + (xyoffset1addr int64 :offset-assert 40) + (scissor1 gs-scissor :offset-assert 48) + (scissor1addr int64 :offset-assert 56) + (prmodecont gs-prmode-cont :offset-assert 64) + (prmodecontaddr int64 :offset-assert 72) + (colclamp gs-color-clamp :offset-assert 80) + (colclampaddr int64 :offset-assert 88) + (dthe gs-dthe :offset-assert 96) + (dtheaddr int64 :offset-assert 104) + (test1 gs-test :offset-assert 112) + (test1addr int64 :offset-assert 120) ) :method-count-assert 9 :size-assert #x80 @@ -135,7 +136,7 @@ :flag-assert #xa0000039c (:methods (new (symbol type int int int int int) _type_ 0) - (dummy-9 () none 9) + (set-video-time-params (_type_ float) float 9) ) ) diff --git a/goal_src/engine/gfx/hw/gs.gc b/goal_src/engine/gfx/hw/gs.gc index 565c935d67..b5e9e4a715 100644 --- a/goal_src/engine/gfx/hw/gs.gc +++ b/goal_src/engine/gfx/hw/gs.gc @@ -241,19 +241,20 @@ ) :flag-assert #x900000008 ) + +(defenum gs-prim-type :bitfield #f + (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) - (;; type of primitive: - ;; - 0: point - ;; - 1: line - ;; - 2: line strip - ;; - 3: tri - ;; - 4: tri strip - ;; - 5: tri fan - ;; - 6: sprite (what?) - ;; - 7: dark magic? - (prim uint8 :offset 0 :size 3) + ((prim uint8 :offset 0 :size 3) (iip uint8 :offset 3 :size 1) (tme uint8 :offset 4 :size 1) (fge uint8 :offset 5 :size 1) @@ -706,10 +707,10 @@ (orgz int32 :offset-assert 12) (width int32 :offset-assert 16) (height int32 :offset-assert 20) - (color int32 4 :offset-assert 24) + (color rgba 4 :offset-assert 24) ) (:methods - (new (symbol type int int int int int) _type_ 0) + (new (symbol type int int int int rgba) _type_ 0) ) :method-count-assert 9 :size-assert #x28 @@ -722,7 +723,7 @@ (org-y int) (width int) (height int) - (color-0 int) + (color-0 rgba) ) "Allocate and initialize a draw-context" (let diff --git a/goal_src/engine/ps2/timer-h.gc b/goal_src/engine/ps2/timer-h.gc index a98e9be119..fcbb40feda 100644 --- a/goal_src/engine/ps2/timer-h.gc +++ b/goal_src/engine/ps2/timer-h.gc @@ -7,10 +7,10 @@ ;; The Emotion Engine has 4 hardware timers. -(defconstant EE_TIMER0 #x10000000) ;; has HOLD register! -(defconstant EE_TIMER1 #x10000800) ;; has HOLD register! -(defconstant EE_TIMER2 #x10001000) ;; does NOT have HOLD register! -(defconstant EE_TIMER3 #x10001800) ;; does NOT have HOLD register! +(defconstant TIMER0_BANK #x10000000) ;; has HOLD register! +(defconstant TIMER1_BANK #x10000800) ;; has HOLD register! +(defconstant TIMER2_BANK #x10001000) ;; does NOT have HOLD register! +(defconstant TIMER3_BANK #x10001800) ;; does NOT have HOLD register! ;; this matches the Tn_MODE register structure of the ps2 EE timers. ;; Only the lower 32 bits of these registers are usable, and the upper 16 hardwired to zero @@ -45,7 +45,7 @@ ;; Each register is 128-bits wide, but only the lower 32-bits are usable, and the upper ;; 16-bits of that are hardwired to zero. (deftype timer-bank (structure) - ((count uint32 :offset-assert 0) + ((count uint32 :offset 0) (mode timer-mode :offset 16) (comp uint32 :offset 32) ) @@ -85,7 +85,7 @@ ;; segfaults OpenGOAL as it does not support ps2 EE timers (#unless PC_PORT - (timer-init (the-as timer-bank EE_TIMER1) (the-as timer-mode #x82)) + (timer-init (the-as timer-bank TIMER1_BANK) (the-as timer-mode #x82)) ) @@ -109,7 +109,7 @@ obj ) - +(declare-type dma-buffer basic) (deftype profile-bar (basic) ((profile-frame-count int32 :offset-assert 4) (cache-time uint64 :offset-assert 8) @@ -120,10 +120,10 @@ :flag-assert #xe00004010 (:methods (get-last-frame-time-stamp (_type_) uint 9) - (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) - (dummy-13 () none 13) + (reset (_type_) _type_ 10) + (add-frame (_type_ symbol rgba) profile-frame 11) + (add-end-frame (_type_ symbol rgba) profile-frame 12) + (draw (_type_ dma-buffer int) float 13) ) ) diff --git a/goal_src/kernel-defs.gc b/goal_src/kernel-defs.gc index 2f955a7fb0..a47978c045 100644 --- a/goal_src/kernel-defs.gc +++ b/goal_src/kernel-defs.gc @@ -126,7 +126,7 @@ (declare-type cpad-info structure) (define-extern cpad-open (function cpad-info int cpad-info)) (define-extern cpad-get-data (function cpad-info cpad-info)) -;; install-handler +(define-extern install-handler (function int (function int) none)) ;; check return val ;; install-debug-handler ;; file-stream-open (define-extern file-stream-open (function file-stream basic basic file-stream)) diff --git a/test/decompiler/reference/all_forward_declarations.gc b/test/decompiler/reference/all_forward_declarations.gc index e27ae5a2d9..bf482f438b 100644 --- a/test/decompiler/reference/all_forward_declarations.gc +++ b/test/decompiler/reference/all_forward_declarations.gc @@ -121,6 +121,9 @@ (defmacro .sync.l () `(none)) +;; timer-h +(declare-type dma-buffer basic) + ;; display-h (deftype display-env (structure) ((pmode uint64 :offset-assert 0) diff --git a/test/decompiler/reference/dma-h_REF.gc b/test/decompiler/reference/dma-h_REF.gc index 79638752c7..805c3b1f08 100644 --- a/test/decompiler/reference/dma-h_REF.gc +++ b/test/decompiler/reference/dma-h_REF.gc @@ -112,7 +112,13 @@ ;; definition of type dma-ctrl (deftype dma-ctrl (uint32) - () + ((dmae uint8 :offset 0 :size 1) + (rele uint8 :offset 1 :size 1) + (mfd uint8 :offset 2 :size 2) + (sts uint8 :offset 4 :size 2) + (std uint8 :offset 6 :size 2) + (rcyc uint8 :offset 8 :size 3) + ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -120,7 +126,8 @@ ;; definition of type dma-enable (deftype dma-enable (uint32) - () + ((cpnd uint8 :offset 16 :size 1) + ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -128,7 +135,9 @@ ;; definition of type dma-sqwc (deftype dma-sqwc (uint32) - () + ((sqwc uint8 :offset 0 :size 8) + (tqwc uint8 :offset 16 :size 8) + ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -246,7 +255,23 @@ ;; definition of type vif-mask (deftype vif-mask (uint32) - () + ((m0 uint8 :offset 0 :size 2) + (m1 uint8 :offset 2 :size 2) + (m2 uint8 :offset 4 :size 2) + (m3 uint8 :offset 6 :size 2) + (m4 uint8 :offset 8 :size 2) + (m5 uint8 :offset 10 :size 2) + (m6 uint8 :offset 12 :size 2) + (m7 uint8 :offset 14 :size 2) + (m8 uint8 :offset 16 :size 2) + (m9 uint8 :offset 18 :size 2) + (m10 uint8 :offset 20 :size 2) + (m11 uint8 :offset 22 :size 2) + (m12 uint8 :offset 24 :size 2) + (m13 uint8 :offset 26 :size 2) + (m14 uint8 :offset 28 :size 2) + (m15 uint8 :offset 30 :size 2) + ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -254,7 +279,9 @@ ;; definition of type vif-stcycl-imm (deftype vif-stcycl-imm (uint16) - () + ((cl uint8 :offset 0 :size 8) + (wl uint8 :offset 8 :size 8) + ) :method-count-assert 9 :size-assert #x2 :flag-assert #x900000002 @@ -262,7 +289,10 @@ ;; definition of type vif-unpack-imm (deftype vif-unpack-imm (uint16) - () + ((addr uint16 :offset 0 :size 10) + (usn uint8 :offset 14 :size 1) + (flg uint8 :offset 15 :size 1) + ) :method-count-assert 9 :size-assert #x2 :flag-assert #x900000002 @@ -273,8 +303,8 @@ ((imm uint16 :offset 0 :size 16) (num uint8 :offset 16 :size 8) (cmd uint8 :offset 24 :size 7) - (msk uint8 :offset 28 :size 1) (irq uint8 :offset 31 :size 1) + (msk uint8 :offset 28 :size 1) ) :method-count-assert 9 :size-assert #x4 diff --git a/test/decompiler/reference/timer-h_REF.gc b/test/decompiler/reference/timer-h_REF.gc index 4a80fac698..cf921b1323 100644 --- a/test/decompiler/reference/timer-h_REF.gc +++ b/test/decompiler/reference/timer-h_REF.gc @@ -21,7 +21,7 @@ ;; definition of type timer-bank (deftype timer-bank (structure) - ((count uint32 :offset-assert 0) + ((count uint32 :offset 0) (mode timer-mode :offset 16) (comp uint32 :offset 32) ) @@ -93,12 +93,9 @@ ;; definition of type profile-frame (deftype profile-frame (structure) - ((name basic :offset-assert 0) - (time-stamp uint32 :offset-assert 4) - (color uint32 :offset-assert 8) - (r uint8 :offset 8) - (g uint8 :offset 9) - (b uint8 :offset 10) + ((name basic :offset-assert 0) + (time-stamp uint32 :offset-assert 4) + (color rgba :offset-assert 8) ) :method-count-assert 9 :size-assert #xc @@ -124,9 +121,9 @@ (format #t "~Tcolor: ~D ~D ~D~%" - (shr (shl (-> obj color) 56) 56) - (shr (shl (-> obj color) 48) 56) - (shr (shl (-> obj color) 40) 56) + (-> (-> obj color) r) + (-> (-> obj color) g) + (-> (-> obj color) b) ) obj ) @@ -141,11 +138,11 @@ :size-assert #x4010 :flag-assert #xe00004010 (:methods - (get-last-frame-time-stamp (profile-bar) uint 9) - (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) - (dummy-13 () none 13) + (get-last-frame-time-stamp (_type_) uint 9) + (reset (_type_) _type_ 10) + (add-frame (_type_ symbol rgba) profile-frame 11) + (add-end-frame (_type_ symbol rgba) profile-frame 12) + (draw (_type_ dma-buffer int) float 13) ) )