jak-project/goal_src/jak1/pc/pckernel-impl.gc
Tyler Wilding c162c66118
g/j1: Cleanup all main issues in the formatter and format all of goal_src/jak1 (#3535)
This PR does two main things:
1. Work through the main low-hanging fruit issues in the formatter
keeping it from feeling mature and usable
2. Iterate and prove that point by formatting all of the Jak 1 code
base. **This has removed around 100K lines in total.**
- The decompiler will now format it's results for jak 1 to keep things
from drifting back to where they were. This is controlled by a new
config flag `format_code`.

How am I confident this hasn't broken anything?:
- I compiled the entire project and stored it's `out/jak1/obj` files
separately
- I then recompiled the project after formatting and wrote a script that
md5's each file and compares it (`compare-compilation-outputs.py`
- The results (eventually) were the same:

![Screenshot 2024-05-25
132900](https://github.com/open-goal/jak-project/assets/13153231/015e6f20-8d19-49b7-9951-97fa88ddc6c2)
> This proves that the only difference before and after is non-critical
whitespace for all code/macros that is actually in use.

I'm still aware of improvements that could be made to the formatter, as
well as general optimization of it's performance. But in general these
are for rare or non-critical situations in my opinion and I'll work
through them before doing Jak 2. The vast majority looks great and is
working properly at this point. Those known issues are the following if
you are curious:

![image](https://github.com/open-goal/jak-project/assets/13153231/0edfaba1-6d36-40f5-ab23-0642209867c4)
2024-06-05 22:17:31 -04:00

173 lines
5.3 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
(require "pc/pckernel-h.gc")
#| This file has the game-specific implementation of the pckernel (see pckernel-h.gc and pckernel.gc). |#
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; version: 1.10.4.0
(defconstant PC_KERNEL_VERSION (static-pckernel-version 1 10 4 0))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; types and enums
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; pc enum for languages. this is the game's languages + custom ones.
(defenum pc-language
:type uint16
(english 0)
(french 1)
(german 2)
(spanish 3)
(italian 4)
(japanese 5)
(uk-english 6)
;; custom
(portuguese 7)
(finnish 8)
(swedish 9)
(danish 10)
(norwegian 11)
(dutch 12)
(br-portuguese 13)
(hungarian 14)
(catalan 15)
(icelandic 16)
(korean 17)
(russian 18)
(polish 19)
(lithuanian 20)
(custom 999) ;; temp
)
;; concept arts
(defenum pc-jak1-concept-art
:bitfield #t
:type uint64
(test))
;; secrets and goodies
(deftype pc-game-secrets (structure)
((art pc-jak1-concept-art) ;; concept art unlocked
(music pc-music-log-entry PC_MUSIC_LOG_LENGTH :inline)
(hard-fish-hiscore int32)
(hard-rats? symbol) ;; enable this crap
(hard-rats-hiscore int32)
(hard-rats-hiwave int32)
(hero-mode? symbol) ;; unsure how this should work
(hud-map? symbol) ;; enable map in HUD/progress?
(hud-counters? symbol) ;; enable level orb counter/global buzzer counter?
(hud-watch? symbol) ;; a watch that tells the time of day!
(watch-12hr? symbol) ;; 12-hour clock toggle
)
:pack-me)
;; The Jak 1 version of the pc-settings object.
(deftype pc-settings-jak1 (pc-settings)
((cheats pc-cheats)
(cheats-known pc-cheats)
(skip-movies? symbol) ;; if on, enable cutscene skipping
(subtitles? symbol) ;; if on, cutscene subtitles will show up
(text-language pc-language) ;; language for game text
(subtitle-language pc-language) ;; language for subtitles
(money-starburst? symbol) ;; add a starburst to the money
(extra-hud? symbol) ;; extra hud elements.
(secrets pc-game-secrets :inline) ;; hidden goodies and additional secrets!
(scenes-seen uint8 PC_SPOOL_LOG_LENGTH) ;; cutscenes that have been seen, by spool-anim (maybe use 8-char name or bits instead?)
))
(define *pc-settings* (the pc-settings-jak1 #f))
;; jak 1 discord rpc structure
(deftype discord-info (structure)
((fuel (pointer float))
(money-total (pointer float))
(buzzer-total (pointer float))
(deaths (pointer int32))
(status string)
(level string)
(cutscene? symbol)
(ogreboss? symbol)
(plant-boss? symbol)
(racer? symbol)
(flutflut? symbol)
(time-of-day (pointer float))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; debug settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define *fallback-text-lookup?* #t)
(define *display-bug-report* #f)
(define *mood-override-debug* #f)
(define *mood-override-table* (new 'global 'inline-array 'float 8))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; resets
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmethod reset-misc ((obj pc-settings-jak1) (call-handlers symbol))
"Set the default misc settings"
((method-of-type pc-settings reset-misc) obj call-handlers)
(set! (-> obj text-language) (the pc-language (scf-get-language)))
(set! (-> obj subtitle-language) (the pc-language (scf-get-language)))
(set! (-> obj skip-movies?) #t)
(set! (-> obj subtitles?) *debug-segment*)
(cond
((and (= *default-territory* GAME_TERRITORY_SCEE) (= (-> obj text-language) (pc-language english)))
(set! (-> obj text-language) (pc-language uk-english))
;(set! (-> obj subtitle-language) (pc-language uk-english))
)
((= *default-territory* GAME_TERRITORY_SCEI)
(set! (-> obj text-language) (pc-language japanese))
;(set! (-> obj subtitle-language) (pc-language japanese))
)
(else))
(set! (-> obj money-starburst?) #f)
(set! (-> obj extra-hud?) #f)
0)
(defmethod reset-extra ((obj pc-settings-jak1) (call-handlers symbol))
"Set the default goodies settings"
((method-of-type pc-settings reset-extra) obj call-handlers)
(set! (-> obj cheats) (pc-cheats))
(set! (-> obj cheats-known) (pc-cheats))
(dotimes (i PC_SPOOL_LOG_LENGTH)
(set! (-> obj scenes-seen i) 0))
(dotimes (i PC_MUSIC_LOG_LENGTH)
(set! (-> obj secrets music i name) #f)
(set! (-> obj secrets music i flava-mask) 0))
(set! (-> obj secrets art) (pc-jak1-concept-art))
(set! (-> obj secrets hard-fish-hiscore) 0)
(set! (-> obj secrets hard-rats-hiscore) 0)
(set! (-> obj secrets hard-rats-hiwave) 0)
(set! (-> obj secrets hard-rats?) #f)
(set! (-> obj secrets hero-mode?) #f)
(set! (-> obj secrets hud-map?) #t)
(set! (-> obj secrets hud-counters?) #t)
(set! (-> obj secrets hud-watch?) #f)
(set! (-> obj secrets watch-12hr?) #f)
0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; other
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun get-video-params ()
*video-parms*)
;; for debugging
(defenum pc-pat-skip-hack
:bitfield #t
(noentity 0)
(nocamera 1)
(noedge 2)
(nolineofsight 12)
(unknowncamera 13))