decomp: hint-control | menu | default-menu (as much as possible) (#632)

* decomp: mostly done `hint-control`

* decomp: Started and decent chunk of `menu` done

* temp stash

* decomp: escape from `menu` hell

* decomp: starting on `default-menu`

* decomp: As much as i can do in `default-menu` at this time

* decomp: clean up `hint-control`

* decomp: fix reference tests

* temp stash

* decomp: finalize `menu`

* decomp: add `menu` to goal_src

* decomp: finalize `hint-control`

* decomp: Resolve TypeConsistency issues

* and fix reference tests

* address feedback

* format and lint

* fix tests
This commit is contained in:
Tyler Wilding
2021-07-04 18:25:08 -04:00
committed by GitHub
parent a6eb51999b
commit 17aedd894d
34 changed files with 5617 additions and 366 deletions
@@ -40,7 +40,8 @@
;; definition of type control-info
(deftype control-info (collide-shape-moving)
((unknown-vector00 vector :inline :offset 576)
((some-quaternion quaternion :offset 496)
(unknown-vector00 vector :inline :offset 576)
(unknown-surface surface :offset 660)
(unknown-symbol symbol :offset 664)
(unknown-qword uint128 :offset 1136)
File diff suppressed because it is too large Load Diff
@@ -74,7 +74,7 @@
:flag-assert #x10004000a8
(:methods
(dummy-14 () none 14)
(dummy-15 () none 15)
(dummy-15 (_type_) symbol 15)
)
)
@@ -161,50 +161,50 @@
;; definition of type game-info
(deftype game-info (basic)
((mode symbol :offset-assert 4)
(save-name basic :offset-assert 8)
(life float :offset-assert 12)
(life-max float :offset-assert 16)
(money float :offset-assert 20)
(money-total float :offset-assert 24)
(money-per-level uint8 32 :offset-assert 28)
(deaths-per-level uint8 32 :offset-assert 60)
(buzzer-total float :offset-assert 92)
(fuel float :offset-assert 96)
(perm-list entity-perm-array :offset-assert 100)
(task-perm-list entity-perm-array :offset-assert 104)
(current-continue continue-point :offset-assert 108)
(text-ids-seen bit-array :offset-assert 112)
(level-opened uint8 32 :offset-assert 116)
(hint-control (array level-hint-control) :offset-assert 148)
(task-hint-control array :offset-assert 152)
(total-deaths int32 :offset-assert 156)
(continue-deaths int32 :offset-assert 160)
(fuel-cell-deaths int32 :offset-assert 164)
(game-start-time uint64 :offset-assert 168)
(continue-time uint64 :offset-assert 176)
(death-time uint64 :offset-assert 184)
(hit-time uint64 :offset-assert 192)
(fuel-cell-pickup-time uint64 :offset-assert 200)
(fuel-cell-time (array uint64) :offset-assert 208)
(enter-level-time (array uint64) :offset-assert 212)
(in-level-time (array uint64) :offset-assert 216)
(blackout-time uint64 :offset-assert 224)
(letterbox-time uint64 :offset-assert 232)
(hint-play-time uint64 :offset-assert 240)
(display-text-time uint64 :offset-assert 248)
(display-text-handle uint64 :offset-assert 256)
(death-movie-tick int32 :offset-assert 264)
(want-auto-save symbol :offset-assert 268)
(auto-save-proc handle :offset-assert 272)
(auto-save-status uint32 :offset-assert 280)
(auto-save-card int32 :offset-assert 284)
(auto-save-which int32 :offset-assert 288)
(pov-camera-handle uint64 :offset-assert 296)
(other-camera-handle uint64 :offset-assert 304)
(death-pos vector-array :offset-assert 312)
(dummy basic :offset-assert 316)
(auto-save-count int32 :offset-assert 320)
((mode symbol :offset-assert 4)
(save-name basic :offset-assert 8)
(life float :offset-assert 12)
(life-max float :offset-assert 16)
(money float :offset-assert 20)
(money-total float :offset-assert 24)
(money-per-level uint8 32 :offset-assert 28)
(deaths-per-level uint8 32 :offset-assert 60)
(buzzer-total float :offset-assert 92)
(fuel float :offset-assert 96)
(perm-list entity-perm-array :offset-assert 100)
(task-perm-list entity-perm-array :offset-assert 104)
(current-continue continue-point :offset-assert 108)
(text-ids-seen bit-array :offset-assert 112)
(level-opened uint8 32 :offset-assert 116)
(hint-control (array level-hint-control) :offset-assert 148)
(task-hint-control (array task-hint-control-group) :offset-assert 152)
(total-deaths int32 :offset-assert 156)
(continue-deaths int32 :offset-assert 160)
(fuel-cell-deaths int32 :offset-assert 164)
(game-start-time uint64 :offset-assert 168)
(continue-time uint64 :offset-assert 176)
(death-time uint64 :offset-assert 184)
(hit-time uint64 :offset-assert 192)
(fuel-cell-pickup-time uint64 :offset-assert 200)
(fuel-cell-time (array uint64) :offset-assert 208)
(enter-level-time (array uint64) :offset-assert 212)
(in-level-time (array uint64) :offset-assert 216)
(blackout-time uint64 :offset-assert 224)
(letterbox-time uint64 :offset-assert 232)
(hint-play-time uint64 :offset-assert 240)
(display-text-time uint64 :offset-assert 248)
(display-text-handle uint64 :offset-assert 256)
(death-movie-tick int32 :offset-assert 264)
(want-auto-save symbol :offset-assert 268)
(auto-save-proc handle :offset-assert 272)
(auto-save-status uint32 :offset-assert 280)
(auto-save-card int32 :offset-assert 284)
(auto-save-which int32 :offset-assert 288)
(pov-camera-handle uint64 :offset-assert 296)
(other-camera-handle uint64 :offset-assert 304)
(death-pos vector-array :offset-assert 312)
(dummy basic :offset-assert 316)
(auto-save-count int32 :offset-assert 320)
)
:method-count-assert 29
:size-assert #x144
@@ -274,8 +274,8 @@
;; definition for symbol *debug-hook*, type (function none)
(define *debug-hook* nothing)
;; definition for symbol *menu-hook*, type (function none)
(define *menu-hook* nothing)
;; definition for symbol *menu-hook*, type (function debug-menu-context)
(define *menu-hook* (the-as (function debug-menu-context) nothing))
;; definition for symbol *progress-hook*, type (function none)
(define *progress-hook* nothing)
@@ -59,7 +59,7 @@
;; definition of type task-hint-control-group
(deftype task-hint-control-group (structure)
((tasks basic :offset-assert 0)
((tasks (array task-hint-control) :offset-assert 0)
)
:method-count-assert 9
:size-assert #x4
@@ -0,0 +1,525 @@
;;-*-Lisp-*-
(in-package goal)
;; failed to figure out what this is:
(set!
(-> *game-info* hint-control)
(the-as
(array level-hint-control)
(new
'static
'boxed-array
:type level-hint-control :length 25 :allocated-length 25
(new 'static 'level-hint-control
:id #x917
:num-attempts-before-playing 1
:num-success-before-killing 3
)
(new 'static 'level-hint-control
:id #x90a
:num-attempts-before-playing 3
:num-success-before-killing -1
)
(new 'static 'level-hint-control
:id #x284
:num-attempts-before-playing 3
:num-success-before-killing 3
)
(new 'static 'level-hint-control
:id #x285
:num-attempts-before-playing 1
:num-success-before-killing 1
)
(new 'static 'level-hint-control
:id #x251
:num-attempts-before-playing 1
:num-success-before-killing 1
)
(new 'static 'level-hint-control
:id #x2af
:num-attempts-before-playing 1
:num-success-before-killing 1
)
(new 'static 'level-hint-control
:delay-before-playing #x384
:id #x239
:num-attempts-before-playing 1
:num-success-before-killing 1
)
(new 'static 'level-hint-control
:delay-before-playing #x5dc
:id #x29d
:num-attempts-before-playing 1
:num-success-before-killing -1
)
(new 'static 'level-hint-control
:delay-before-playing #x384
:id #x25b
:num-attempts-before-playing 1
:num-success-before-killing -1
)
(new 'static 'level-hint-control
:id #x2a4
:num-attempts-before-playing 3
:num-success-before-killing 1
)
(new 'static 'level-hint-control
:delay-before-playing #x384
:id #x2aa
:num-attempts-before-playing 1
:num-success-before-killing 1
)
(new 'static 'level-hint-control
:delay-before-playing #x5dc
:id #x33a
:num-attempts-before-playing 1
:num-success-before-killing 1
)
(new 'static 'level-hint-control
:delay-before-playing #x1194
:id #x34b
:num-attempts-before-playing 3
:num-success-before-killing 2
)
(new 'static 'level-hint-control
:delay-before-playing #x4650
:id #x34a
:num-attempts-before-playing 3
:num-success-before-killing -1
)
(new 'static 'level-hint-control
:id #x34d
:num-attempts-before-playing 3
:num-success-before-killing -1
)
(new 'static 'level-hint-control
:id #x345
:num-attempts-before-playing 3
:num-success-before-killing 2
)
(new 'static 'level-hint-control
:id #x352
:num-attempts-before-playing 1
:num-success-before-killing 1
)
(new 'static 'level-hint-control
:delay-before-playing #x2328
:id #x347
:num-attempts-before-playing 3
:num-success-before-killing 1
)
(new 'static 'level-hint-control
:id #x34e
:num-attempts-before-playing 3
:num-success-before-killing -1
)
(new 'static 'level-hint-control
:id #x444
:num-attempts-before-playing 5
:num-success-before-killing -1
)
(new 'static 'level-hint-control
:delay-before-playing #x384
:id #x438
:num-attempts-before-playing 1
:num-success-before-killing -1
)
(new 'static 'level-hint-control
:id #x433
:num-attempts-before-playing 4
:num-success-before-killing -1
)
(new 'static 'level-hint-control
:id #x70d
:num-attempts-before-playing 1
:num-success-before-killing 2
)
(new 'static 'level-hint-control
:delay-before-playing #x5dc
:id #x806
:num-attempts-before-playing 1
:num-success-before-killing 1
)
(new 'static 'level-hint-control
:delay-before-playing #x5dc
:id #x809
:num-attempts-before-playing 1
:num-success-before-killing 1
)
)
)
)
;; failed to figure out what this is:
(set!
(-> *game-info* task-hint-control)
(the-as
(array task-hint-control-group)
(new
'static
'boxed-array
:type task-hint-control-group :length 16 :allocated-length 16
(new 'static 'task-hint-control-group
:tasks
(new
'static
'boxed-array
:type task-hint-control :length 3 :allocated-length 3
(new 'static 'task-hint-control :task #x5c :delay #x2bf20)
(new 'static 'task-hint-control :task #x5d :delay #x57e40)
(new 'static 'task-hint-control :task #x5e :delay #x83d60)
)
)
(new 'static 'task-hint-control-group)
(new 'static 'task-hint-control-group
:tasks
(new
'static
'boxed-array
:type task-hint-control :length 3 :allocated-length 3
(new 'static 'task-hint-control :task #x15 :delay #x41eb0)
(new 'static 'task-hint-control :task #x16 :delay #x83d60)
(new 'static 'task-hint-control :task #x13 :delay #xc5c10)
)
)
(new 'static 'task-hint-control-group
:tasks
(new
'static
'boxed-array
:type task-hint-control :length 2 :allocated-length 2
(new 'static 'task-hint-control :task #x6 :delay #x57e40)
(new 'static 'task-hint-control :task #x8 :delay #xafc80)
)
)
(new 'static 'task-hint-control-group
:tasks
(new
'static
'boxed-array
:type task-hint-control :length 4 :allocated-length 4
(new 'static 'task-hint-control :task #x18 :delay #x57e40)
(new 'static 'task-hint-control :task #x19 :delay #x83d60)
(new 'static 'task-hint-control :task #x1d :delay #xafc80)
(new 'static 'task-hint-control :task #x1e :delay #xdbba0)
)
)
(new 'static 'task-hint-control-group)
(new 'static 'task-hint-control-group)
(new 'static 'task-hint-control-group
:tasks
(new
'static
'boxed-array
:type task-hint-control :length 3 :allocated-length 3
(new 'static 'task-hint-control :task #x33 :delay #x57e40)
(new 'static 'task-hint-control :task #x30 :delay #x83d60)
(new 'static 'task-hint-control :task #x2e :delay #xafc80)
)
)
(new 'static 'task-hint-control-group
:tasks
(new
'static
'boxed-array
:type task-hint-control :length 1 :allocated-length 1
(new 'static 'task-hint-control :task #x26 :delay #xafc80)
)
)
(new 'static 'task-hint-control-group
:tasks
(new
'static
'boxed-array
:type task-hint-control :length 1 :allocated-length 1
(new 'static 'task-hint-control :task #x38 :delay #xafc80)
)
)
(new 'static 'task-hint-control-group
:tasks
(new
'static
'boxed-array
:type task-hint-control :length 1 :allocated-length 1
(new 'static 'task-hint-control :task #x6e :delay #x107ac0)
)
)
(new 'static 'task-hint-control-group
:tasks
(new
'static
'boxed-array
:type task-hint-control :length 1 :allocated-length 1
(new 'static 'task-hint-control :task #x4a :delay #x107ac0)
)
)
(new 'static 'task-hint-control-group
:tasks
(new
'static
'boxed-array
:type task-hint-control :length 4 :allocated-length 4
(new 'static 'task-hint-control :task #x42 :delay #x57e40)
(new 'static 'task-hint-control :task #x43 :delay #x83d60)
(new 'static 'task-hint-control :task #x3f :delay #xafc80)
(new 'static 'task-hint-control :task #x40 :delay #xdbba0)
)
)
(new 'static 'task-hint-control-group
:tasks
(new
'static
'boxed-array
:type task-hint-control :length 4 :allocated-length 4
(new 'static 'task-hint-control :task #x50 :delay #x57e40)
(new 'static 'task-hint-control :task #x51 :delay #x83d60)
(new 'static 'task-hint-control :task #x52 :delay #xafc80)
(new 'static 'task-hint-control :task #x54 :delay #xdbba0)
)
)
(new 'static 'task-hint-control-group)
(new 'static 'task-hint-control-group)
)
)
)
;; definition for function find-hint-control-index
(defun find-hint-control-index ((arg0 level-hint-control))
(let ((gp-0 -1))
(let ((v1-2 (length (-> *game-info* hint-control))))
(dotimes (a0-2 v1-2)
(when (= (-> *game-info* hint-control a0-2 id) arg0)
(set! gp-0 a0-2)
(set! a0-2 v1-2)
)
)
)
gp-0
)
)
;; definition for function start-hint-timer
;; INFO: Return type mismatch int vs none.
(defun start-hint-timer ((arg0 level-hint-control))
(let ((v1-0 (find-hint-control-index arg0)))
(when
(and
(>= v1-0 0)
(zero? (-> *game-info* hint-control v1-0 start-time))
(!= (-> *game-info* hint-control v1-0 num-attempts-before-playing) 1)
)
(set!
(-> *game-info* hint-control v1-0 start-time)
(-> *display* base-frame-counter)
)
0
)
)
0
(none)
)
;; definition for function increment-success-for-hint
;; INFO: Return type mismatch int vs none.
(defun increment-success-for-hint ((arg0 level-hint-control))
(let ((gp-0 (find-hint-control-index arg0)))
(when (>= gp-0 0)
(set!
(-> *game-info* hint-control gp-0 num-success)
(seekl (-> *game-info* hint-control gp-0 num-success) 127 1)
)
0
)
)
0
(none)
)
;; definition for function can-hint-be-played?
;; WARN: disable def twice: 139. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare.
(defun can-hint-be-played? ((arg0 int))
(let ((v1-0 (not (str-is-playing?))))
(if (and v1-0 (nonzero? arg0))
(set! v1-0 (not (seen-text? *game-info* (the-as game-text-id arg0))))
)
(when v1-0
(when *hint-semaphore*
(let ((v1-3 *hint-semaphore*))
(set! v1-0 (dummy-15 (the-as level-hint (if v1-3
(-> v1-3 0 self)
)
)
)
)
)
0
)
(when
(and
v1-0
(<
(the-as
int
(- (-> *display* base-frame-counter) (-> *game-info* hint-play-time))
)
30
)
)
(set! v1-0 #f)
0
)
(set!
v1-0
(and
v1-0
(not (-> *setting-control* current talking))
(not (-> *setting-control* current spooling))
(not (-> *setting-control* current hint))
(not (-> *setting-control* current ambient))
(>=
(the-as int (-> *display* base-frame-counter))
(the-as int (-> *game-info* blackout-time))
)
)
)
0
)
(cond
(v1-0
(let ((v1-16 (find-hint-control-index (the-as level-hint-control arg0))))
(cond
((< v1-16 0)
#t
)
(else
(let ((gp-1 (-> *game-info* hint-control v1-16))
(a0-24
(-
(-> *display* base-frame-counter)
(-> *game-info* hint-control v1-16 last-time-called)
)
)
(v1-21 #t)
)
(if
(and
(= (-> gp-1 num-attempts-before-playing) 1)
(< (the-as int a0-24) 30)
)
(set! (-> gp-1 start-time) (+ (-> gp-1 start-time) a0-24))
)
(cond
((and
(!= (-> gp-1 num-attempts-before-playing) 1)
(nonzero? (-> gp-1 last-time-called))
(<
(the-as
int
(- (-> *display* base-frame-counter) (-> gp-1 last-time-called))
)
150
)
)
(set! (-> gp-1 last-time-called) (-> *display* base-frame-counter))
#f
)
(else
(set! (-> gp-1 last-time-called) (-> *display* base-frame-counter))
(when (nonzero? (-> gp-1 delay-before-playing))
(if
(<
(the-as int (-> gp-1 start-time))
(the-as int (-> gp-1 delay-before-playing))
)
(set! v1-21 #f)
)
0
)
(cond
(v1-21
(set! (-> gp-1 num-attempts) (seekl (-> gp-1 num-attempts) 127 1))
(and
(>= (-> gp-1 num-attempts) (-> gp-1 num-attempts-before-playing))
(or
(= (-> gp-1 num-success-before-killing) -1)
(< (-> gp-1 num-success) (-> gp-1 num-success-before-killing))
)
)
)
(else
#f
)
)
)
)
)
)
)
)
)
(else
#f
)
)
)
)
;; definition for function reset-all-hint-controls
;; INFO: Return type mismatch int vs none.
(defun reset-all-hint-controls ()
(let ((v1-2 (length (-> *game-info* hint-control))))
(dotimes (a0-1 v1-2)
(let ((a1-2 (-> *game-info* hint-control a0-1)))
(set! (-> a1-2 start-time) (the-as uint 0))
(set! (-> a1-2 last-time-called) (the-as uint 0))
(set! (-> a1-2 num-attempts) 0)
(set! (-> a1-2 num-success) 0)
)
0
)
)
0
(none)
)
;; definition for function update-task-hints
;; INFO: Return type mismatch int vs none.
(defun update-task-hints ()
(when *target*
(let ((a0-0 (+ (-> *target* current-level info index) -1))
(v1-7 (-> *game-info* task-hint-control))
)
(when (and (>= a0-0 0) (< a0-0 (-> *level-task-data-remap* length)))
(let ((a0-3 (-> *level-task-data-remap* a0-0)))
(when (< a0-3 (-> v1-7 length))
(let ((gp-0 (-> v1-7 a0-3 tasks)))
(when (and (!= gp-0 0) (nonzero? (-> gp-0 length)))
(let ((s5-0 (-> *game-info* in-level-time a0-3)))
(dotimes (s4-0 (-> gp-0 length))
(let
((v1-17 (get-task-status (the-as game-task (-> gp-0 s4-0 task)))))
(when
(or
(= v1-17 (task-status need-hint))
(= v1-17 (task-status unknown))
)
(if (< (-> gp-0 s4-0 delay) s5-0)
(close-specific-task!
(the-as game-task (-> gp-0 s4-0 task))
(task-status need-hint)
)
)
)
)
)
)
)
)
)
)
)
)
)
0
(none)
)
@@ -114,7 +114,7 @@
(format #t "~Twind-index: ~D~%" (-> obj wind-index))
(format #t "~Tflat-normal: #<vector @ #x~X>~%" (-> obj flat-normal))
(format #t "~Tflat-hwidth: ~f~%" (-> obj flat-normal w))
(format #t "~Tcolor: ~D~%" (-> obj color))
(format #t "~Tcolor: ~D~%" (-> obj unknown))
obj
)
@@ -245,6 +245,7 @@
;; definition of type instance
(deftype instance (drawable)
((bucket-index uint16 :offset 6)
(unknown uint32 :offset 8)
(origin matrix4h :inline :offset-assert 32)
(wind-index uint16 :offset 62)
)
@@ -67,7 +67,7 @@
(format #t "~Tbucket-index: ~D~%" (-> obj bucket-index))
(format #t "~Torigin: #<matrix4h @ #x~X>~%" (-> obj origin))
(format #t "~Twind-index: ~D~%" (-> obj wind-index))
(format #t "~Tcolor-indices: #x~X~%" (-> obj color-indices))
(format #t "~Tcolor-indices: #x~X~%" (-> obj unknown))
(format #t "~Tbucket-ptr: ~A~%" (-> obj bucket-ptr))
(format #t "~Tmax-scale: ~D~%" (-> obj max-scale))
(format #t "~Tflags: ~D~%" (-> obj flags))
+9 -18
View File
@@ -46,35 +46,24 @@ const std::unordered_set<std::string> g_functions_expected_to_reject = {
"(method 9 bounding-box)", // handwritten asm loop
"(method 14 bounding-box)", // handwritten asm loop
// trig
"exp",
"atan0",
"sincos!",
"sincos-rad!",
"exp", "atan0", "sincos!", "sincos-rad!",
// matrix
"(method 9 matrix)", // handwritten asm loop
"matrix-axis-sin-cos!",
"matrix-axis-sin-cos-vu!",
"matrix-axis-sin-cos!", "matrix-axis-sin-cos-vu!",
// dma-h
"dma-count-until-done", // dma asm loop
"dma-sync-with-count",
"dma-send-no-scratch",
"dma-sync-fast",
"dma-sync-with-count", "dma-send-no-scratch", "dma-sync-fast",
// dma
"symlink2",
"symlink3",
"symlink2", "symlink3",
"dma-sync-hang", // handwritten asm
"vector=", // asm branching
// display
"vblank-handler", // asm
"vif1-handler",
"vif1-handler-debug",
"vif1-handler", "vif1-handler-debug",
// stats-h
"(method 11 perf-stat)",
"(method 12 perf-stat)",
"(method 11 perf-stat)", "(method 12 perf-stat)",
// ripple - asm
"ripple-execute-init",
"ripple-create-wave-table",
"ripple-apply-wave-table",
"ripple-execute-init", "ripple-create-wave-table", "ripple-apply-wave-table",
"ripple-matrix-scale",
// ripple - calls an asm function
"ripple-execute",
@@ -90,6 +79,8 @@ const std::unordered_set<std::string> g_functions_expected_to_reject = {
// actor-link-h
"(method 21 actor-link-info)", // BUG: sc cfg / cfg-ir bug
"(method 20 actor-link-info)",
"debug-menu-item-var-render" // asm
};
const std::unordered_set<std::string> g_functions_to_skip_compiling = {