game: add real-time time of day cheat code (#1595)

This commit is contained in:
Hat Kid
2022-07-03 23:28:29 +02:00
committed by GitHub
parent 87d24dd291
commit 6c595355b6
2 changed files with 19 additions and 1 deletions
+1
View File
@@ -123,6 +123,7 @@
(invinc)
(sidekick-blue)
(tunes)
(sky)
)
(defmacro pc-cheats? (obj &rest cheats)
+18 -1
View File
@@ -224,7 +224,7 @@
(none))
(define *pc-cheat-temp* (the-as (pointer int32) (malloc 'global (* 4 7))))
(define *pc-cheat-temp* (the-as (pointer int32) (malloc 'global (* 4 8))))
(defmacro pc-cheat-toggle-and-tune (obj cheat)
`(begin
(cpad-clear! 0 r1)
@@ -233,6 +233,11 @@
)
)
(defun bcd->dec ((bcd uint))
"Convert a number encoded in BCD to its decimal equivalent"
(+ (* (shr (logand bcd #xf0) 4) 10) (logand bcd #x0f))
)
(defmethod update pc-settings ((obj pc-settings))
"Update settings to/from PC kernel. Call this at the start of every frame.
This will update things like the aspect-ratio, which will be used for graphics code later."
@@ -365,6 +370,9 @@
(pc-check-cheat-code (-> *pc-cheat-temp* 6) 0 (t u n e s)
(pc-cheat-toggle-and-tune obj tunes))
(pc-check-cheat-code (-> *pc-cheat-temp* 7) 0 (s k y)
(pc-cheat-toggle-and-tune obj sky))
)
(when *target*
@@ -421,6 +429,15 @@
(set! (-> obj flava-hack) 0)
)
(if (pc-cheats? obj sky)
(let ((date (new 'stack 'scf-time)))
(scf-get-time date)
(when (zero? (-> date stat))
(set-time-of-day (+ (the float (bcd->dec (-> date hour))) (/ (the float (bcd->dec (-> date minute))) 60)))
)
)
)
(logior! (-> obj cheats-known) (-> obj cheats))
0)