jak-project/goal_src/jak2/engine/game/game-info-h.gc
ManDude cd68cb671e
deftype and defmethod syntax major changes (#3094)
Major change to how `deftype` shows up in our code:
- the decompiler will no longer emit the `offset-assert`,
`method-count-assert`, `size-assert` and `flag-assert` parameters. There
are extremely few cases where having this in the decompiled code is
helpful, as the types there come from `all-types` which already has
those parameters. This also doesn't break type consistency because:
  - the asserts aren't compared.
- the first step of the test uses `all-types`, which has the asserts,
which will throw an error if they're bad.
- the decompiler won't emit the `heap-base` parameter unless necessary
now.
- the decompiler will try its hardest to turn a fixed-offset field into
an `overlay-at` field. It falls back to the old offset if all else
fails.
- `overlay-at` now supports field "dereferencing" to specify the offset
that's within a field that's a structure, e.g.:
```lisp
(deftype foobar (structure)
  ((vec    vector  :inline)
   (flags  int32   :overlay-at (-> vec w))
   )
  )
```
in this structure, the offset of `flags` will be 12 because that is the
final offset of `vec`'s `w` field within this structure.
- **removed ID from all method declarations.** IDs are only ever
automatically assigned now. Fixes #3068.
- added an `:overlay` parameter to method declarations, in order to
declare a new method that goes on top of a previously-defined method.
Syntax is `:overlay <method-name>`. Please do not ever use this.
- added `state-methods` list parameter. This lets you quickly specify a
list of states to be put in the method table. Same syntax as the
`states` list parameter. The decompiler will try to put as many states
in this as it can without messing with the method ID order.

Also changes `defmethod` to make the first type definition (before the
arguments) optional. The type can now be inferred from the first
argument. Fixes #3093.

---------

Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
2023-10-30 03:20:02 +00:00

394 lines
11 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: game-info-h.gc
;; name in dgo: game-info-h
;; dgos: ENGINE, GAME
(declare-type entity-perm-array inline-array-class)
(declare-type continue-point basic)
(declare-type game-save basic)
(defenum pickup-type
:bitfield #f
:type int32
(none 0)
(eco-yellow 1)
(eco-red 2)
(eco-blue 3)
(eco-dark 4)
(eco-green 5)
(eco-pill-green 6)
(eco-pill-dark 7)
(eco-pill-random 8)
(money 9)
(fuel-cell 10)
(buzzer 11)
(darkjak 12)
(ammo-yellow 13)
(ammo-red 14)
(ammo-blue 15)
(ammo-dark 16)
(shield 17)
(health 18)
(trick-point 19)
(trick-judge 20)
(gem 21)
(skill 22)
(karma 23)
(gun-red 24)
(gun-yellow 25)
(gun-blue 26)
(gun-dark 27)
(board 28)
(pass-red 29)
(pass-green 30)
(pass-yellow 31)
(pass-blue 32)
(ammo-random 33)
)
(defenum continue-flags
:type uint32
:bitfield #t
;(continue-flag-0 0)
(scene-wait 1)
(change-continue 2)
(no-auto 3)
(no-blackout 4)
(game-start 5)
(demo-end 6)
(warp-gate 7)
(demo 8)
(intro 9)
(hero-mode 10)
(demo-movie 11)
(title 12)
(title-movie 13)
(continue-flag-14 14)
(continue-flag-15 15)
(continue-flag-16 16)
(test 17)
(record-path 18)
(pilot 19)
(pilot-dax 20)
(record-sig 21)
(indax 22)
)
;; +++game-secrets
(defenum game-secrets
:type uint32
:bitfield #t
(toggle-beard)
(hflip-screen)
(endless-ammo)
(invulnerable)
(endless-dark)
(scene-player-1)
(scene-player-2)
(scene-player-3)
(level-select)
(scrap-book-1)
(scrap-book-2)
(scrap-book-3)
(gungame-blue)
(gungame-dark)
(reverse-races)
(hero-mode)
(big-head)
(little-head)
(game-secret-unknown))
;; ---game-secrets
(defenum game-score
(none)
(race-1)
(race-2)
(race-3)
(gungame-red)
(gungame-yellow)
(gungame-blue)
(gungame-dark)
(onin-game)
(whack)
(judge-skatea)
(bush-race-1)
(bush-race-2)
(bush-race-3)
(bush-port)
(bush-errol)
(reverse-race-1)
(reverse-race-2)
(reverse-race-3)
)
(defenum highscore-flags
:bitfield #t
:type uint8
(time)
)
(declare-type game-info basic)
(define-extern *game-info* game-info)
(declare-type process-drawable process)
(define-extern process-drawable-art-error (state string process-drawable))
(define-extern part-group-pointer? (function pointer symbol))
;; NOTE - for default-menu
(define-extern bug-report-display (function symbol int))
(define-extern trsq->continue-point (function trsq int))
;; NOTE - for progress
(declare-type highscore-info structure)
(define-extern *highscore-info-array* (array highscore-info))
(declare-type entity-perm structure)
(define-extern *task-level* (array symbol))
;; DECOMP BEGINS
(local-vars (gp-0 game-info))
(deftype game-bank (basic)
((life-max-default float)
(life-start-default float)
(life-single-inc float)
(money-task-inc float)
(money-oracle-inc float)
)
)
(define *GAME-bank* (new 'static 'game-bank
:life-max-default 99.0
:life-start-default 5.0
:life-single-inc 1.0
:money-task-inc 90.0
:money-oracle-inc 120.0
)
)
(deftype actor-id (uint32)
()
)
(deftype highscore-info (structure)
((flags highscore-flags)
(award-scores float 3)
(bronze-score float :overlay-at (-> award-scores 0))
(silver-score float :overlay-at (-> award-scores 1))
(gold-score float :overlay-at (-> award-scores 2))
)
(:methods
(get-rank (_type_ float) int)
)
)
(deftype level-buffer-state (structure)
((name symbol)
(display? symbol)
(force-vis? symbol)
(force-inside? symbol)
)
:pack-me
)
(deftype load-state (basic)
((want level-buffer-state 6 :inline)
(want-sound symbol 3)
(vis-nick symbol)
(command-list pair)
(object-name string 256)
(object-status basic 256)
)
(:methods
(new (symbol type) _type_)
(reset! (_type_) _type_)
(update! (_type_) int)
(want-levels (_type_ (pointer symbol)) int)
(want-sound-banks (_type_ (pointer symbol)) none)
(want-display-level (_type_ symbol symbol) int)
(want-vis-level (_type_ symbol) none)
(want-force-vis (_type_ symbol symbol) int)
(want-force-inside (_type_ symbol symbol) none)
(execute-commands-up-to (_type_ float) none)
(backup-load-state-and-set-cmds (_type_ pair) int)
(restore-load-state-and-cleanup (_type_) int)
(restore-load-state (_type_) int)
(add-borrow-levels (_type_) none)
)
)
(defmethod new load-state ((allocation symbol) (type-to-make type))
(reset! (object-new allocation type-to-make (the-as int (-> type-to-make size))))
)
(deftype continue-point (basic)
((name string)
(level symbol)
(flags continue-flags)
(trans vector :inline)
(quat vector :inline)
(camera-trans vector :inline)
(camera-rot vector3s 3 :inline)
(on-goto pair)
(vis-nick symbol)
(want level-buffer-state 6 :inline)
(want-sound symbol 3)
)
(:methods
(debug-draw (_type_) int)
(continue-point-method-10 (_type_ load-state) continue-point)
(move-camera! (_type_) none)
)
)
(deftype game-info (basic)
((mode symbol)
(save-name string)
(life float)
(life-max float)
(money float)
(money-total float)
(money-per-level uint8 32)
(deaths-per-level uint8 32)
(buzzer-total float)
(fuel float)
(gem float)
(gem-total float)
(skill float)
(skill-total float)
(karma float)
(eco-pill-dark float)
(eco-pill-dark-total float)
(features game-feature)
(debug-features game-feature)
(secrets game-secrets)
(unknown-pad1 uint32)
(purchase-secrets game-secrets)
(unknown-pad2 uint32)
(gun-type pickup-type)
(gun-ammo float 4)
(shield float)
(score float)
(score-owner handle)
(timer time-frame)
(timer-owner handle)
(timer-flash symbol)
(counter float)
(counter-flash basic)
(attack-id uint32)
(perm-list entity-perm-array)
(task-perm-list entity-perm-array)
(current-continue continue-point)
(last-continue continue-point)
(play-list (array game-task-info))
(sub-task-list (array game-task-node-info))
(mission-list (array game-task-node-info))
(task-counter uint32)
(unknown-pad6 (array uint16))
(level-opened uint8 32)
(total-deaths int32)
(continue-deaths int32)
(task-deaths int32)
(total-trys int32)
(game-start-time time-frame)
(continue-time time-frame)
(death-time time-frame)
(hit-time time-frame)
(task-pickup-time time-frame)
(unknown-array1 (array time-frame))
(task-enter-times (array time-frame))
(task-in-times (array time-frame))
(death-pos vector-array :offset 372)
(stop-watch-start uint64)
(stop-watch-stop uint64)
(blackout-time time-frame)
(letterbox-time time-frame)
(hint-play-time time-frame)
(display-text-time time-frame)
(display-text-handle handle)
(death-movie-tick int32)
(want-auto-save symbol)
(auto-save-proc handle)
(auto-save-status mc-status-code)
(auto-save-card int32)
(auto-save-which int32)
(auto-save-count int32)
(pov-camera-handle handle)
(other-camera-handle handle)
(controller handle 2)
(race-timer uint64)
(race-current-lap-count int32)
(race-total-lap-count int32)
(race-position int32)
(race-number-turbos int32)
(bot-health float 3)
(demo-state uint32)
(wanted-flash symbol)
(distance float)
(kiosk-timeout uint64)
(pause-start-time time-frame)
(game-score (array float))
(goal float)
(miss float)
(miss-max float)
(task-close-times (array time-frame))
(live-eco-pill-count int32)
(live-gem-count int32)
(air-supply float)
(homing-beacon int32)
(dark-eco-pickup int32)
(green-eco-pickup int32)
)
(:methods
(initialize! (_type_ symbol game-save string) _type_)
(give (_type_ symbol float handle) float)
(task-complete? (_type_ game-task) symbol)
(subtask-index-by-name (_type_ string) int)
(set-subtask-hook! (_type_ game-task-node int function) function)
(actor-perm (_type_ actor-id) entity-perm)
(task-perm-by-index (_type_ int) entity-perm)
(copy-perms-from-level! (_type_ level) int)
(copy-perms-to-level! (_type_ level) int)
(debug-inspect (_type_ symbol) _type_)
(get-current-continue-forced (_type_) continue-point)
(get-continue-by-name (_type_ string) continue-point)
(set-continue! (_type_ basic symbol) continue-point)
(game-info-method-22 (_type_) int)
(save-game (_type_ game-save string) game-save)
(load-game (_type_ game-save) game-save)
(you-suck-stage (_type_ symbol) int)
(you-suck-scale (_type_ object) float)
(get-next-attack-id (_type_) uint)
(game-info-method-28 (_type_ game-score float) int)
(get-game-score-ref (_type_ int) (pointer float))
(calculate-percentage (_type_) float)
)
)
(defmethod get-next-attack-id ((this game-info))
(let ((v0-0 (+ (-> this attack-id) 1)))
(set! (-> this attack-id) v0-0)
v0-0
)
)
(set! gp-0
(when (or (not *game-info*) (zero? *game-info*))
(set! gp-0 (new 'static 'game-info :mode 'debug :current-continue #f :last-continue #f))
(set! (-> gp-0 unknown-array1) (the-as (array time-frame) (new 'global 'boxed-array uint64 110)))
(set! (-> gp-0 task-close-times) (the-as (array time-frame) (new 'global 'boxed-array uint64 110)))
(set! (-> gp-0 task-enter-times) (the-as (array time-frame) (new 'global 'boxed-array uint64 32)))
(set! (-> gp-0 task-in-times) (the-as (array time-frame) (new 'global 'boxed-array uint64 32)))
(set! *game-info* gp-0)
gp-0
)
)