From 26accb8714b4441f786a7f3c542229790441051b Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Thu, 22 Apr 2021 23:31:54 +0100 Subject: [PATCH] Fix `+1` macros to `1+` and update some timer types (#375) * Correct `+1` macros to `1+` * update some `timer-h` types --- decompiler/config/all-types.gc | 16 +++++++++------- goal_src/engine/ps2/timer-h.gc | 20 +++++++++++--------- goal_src/goal-lib.gc | 6 +++--- test/decompiler/reference/timer-h_REF.gc | 2 +- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 0415d3c36..8fb6a44e1 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -2047,13 +2047,15 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; +(defenum timer-clock-selection + :type uint8 + (busclk 0) + (busclk/16 1) + (busclk/256 2) + (hblank 3) + ) (deftype timer-mode (uint32) - (;; clock selection: - ;; 0: BUSCLK - ;; 1: BUSCLK/16 - ;; 2: BUSCLK/256 - ;; 3: hblank - (clks uint8 :offset 0 :size 2) + ((clks timer-clock-selection :offset 0 :size 2) (gate uint8 :offset 2 :size 1) ;; gate function enable (gats uint8 :offset 3 :size 1) ;; gate selection: 0 = hblank, 1 = vblank ;; gate mode: @@ -2106,7 +2108,7 @@ (define-extern timer-init (function timer-bank timer-mode int)) (deftype profile-frame (structure) - ((name basic :offset-assert 0) + ((name symbol :offset-assert 0) (time-stamp uint32 :offset-assert 4) (color rgba :offset-assert 8) ) diff --git a/goal_src/engine/ps2/timer-h.gc b/goal_src/engine/ps2/timer-h.gc index fcbb40fed..08979f766 100644 --- a/goal_src/engine/ps2/timer-h.gc +++ b/goal_src/engine/ps2/timer-h.gc @@ -12,15 +12,17 @@ (defconstant TIMER2_BANK #x10001000) ;; does NOT have HOLD register! (defconstant TIMER3_BANK #x10001800) ;; does NOT have HOLD register! +(defenum timer-clock-selection + :type uint8 + (busclk 0) + (busclk/16 1) + (busclk/256 2) + (hblank 3) + ) ;; 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 (deftype timer-mode (uint32) - (;; clock selection: - ;; 0: BUSCLK - ;; 1: BUSCLK/16 - ;; 2: BUSCLK/256 - ;; 3: hblank - (clks uint8 :offset 0 :size 2) + ((clks timer-clock-selection :offset 0 :size 2) (gate uint8 :offset 2 :size 1) ;; gate function enable (gats uint8 :offset 3 :size 1) ;; gate selection: 0 = hblank, 1 = vblank ;; gate mode: @@ -83,14 +85,14 @@ (set! (-> timer count) 0) ) -;; segfaults OpenGOAL as it does not support ps2 EE timers +;; needs PS2 TIMER porting (#unless PC_PORT - (timer-init (the-as timer-bank TIMER1_BANK) (the-as timer-mode #x82)) + (timer-init (the-as timer-bank TIMER1_BANK) (new 'static 'timer-mode :clks (timer-clock-selection busclk/16) :cue 1)) ) (deftype profile-frame (structure) - ((name basic :offset-assert 0) + ((name symbol :offset-assert 0) (time-stamp uint32 :offset-assert 4) (color rgba :offset-assert 8) ) diff --git a/goal_src/goal-lib.gc b/goal_src/goal-lib.gc index a838e182f..8067a9477 100644 --- a/goal_src/goal-lib.gc +++ b/goal_src/goal-lib.gc @@ -279,7 +279,7 @@ `(let (( ,(first var) 0)) (while (< ,(first var) ,(second var)) ,@body - (+1! ,(first var)) + (1+! ,(first var)) ) ,@(cddr var) ) @@ -371,7 +371,7 @@ ;; Math Macros ;;;;;;;;;;;;;;;;;;; -(defmacro +1 (var) +(defmacro 1+ (var) `(+ ,var 1) ) @@ -379,7 +379,7 @@ `(set! ,place (+ ,place ,amount)) ) -(defmacro +1! (place) +(defmacro 1+! (place) `(set! ,place (+ 1 ,place)) ) diff --git a/test/decompiler/reference/timer-h_REF.gc b/test/decompiler/reference/timer-h_REF.gc index 2f674438d..6aca9d5a5 100644 --- a/test/decompiler/reference/timer-h_REF.gc +++ b/test/decompiler/reference/timer-h_REF.gc @@ -93,7 +93,7 @@ ;; definition of type profile-frame (deftype profile-frame (structure) - ((name basic :offset-assert 0) + ((name symbol :offset-assert 0) (time-stamp uint32 :offset-assert 4) (color rgba :offset-assert 8) )