mirror of
https://github.com/open-goal/jak-project
synced 2026-08-14 20:43:54 -04:00
memory cards (in progress) (#868)
* c++ memory card stuff * saving kinda works * load working * more progress * clean up
This commit is contained in:
@@ -939,7 +939,8 @@
|
||||
|
||||
(defmacro birth-log (str &rest args)
|
||||
"Debug print to stdout of runtime for debugging actor inits."
|
||||
`(format 0 ,(string-append "[BIRTH] " str) ,@args)
|
||||
;;`(format 0 ,(string-append "[BIRTH] " str) ,@args)
|
||||
`(empty)
|
||||
)
|
||||
|
||||
(defun init-entity ((proc process) (ent entity))
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
(declare-type eco-collectable process-drawable)
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
;; definition for function eco-fadeout
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
(defun eco-fadeout ((arg0 sparticle-system) (arg1 sparticle-cpuinfo))
|
||||
(if
|
||||
(zero?
|
||||
@@ -23,6 +24,8 @@
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for function eco-track-root-prim-fadeout
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
(defun
|
||||
eco-track-root-prim-fadeout
|
||||
((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
|
||||
@@ -44,6 +47,8 @@
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for function part-tracker-track-root
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
(defun
|
||||
part-tracker-track-root
|
||||
((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
|
||||
@@ -56,6 +61,7 @@
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for function part-tracker-move-to-target
|
||||
(defun part-tracker-move-to-target ((arg0 part-tracker))
|
||||
(let* ((v1-0 *target*)
|
||||
(a2-0 (if (not v1-0)
|
||||
@@ -82,6 +88,8 @@
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function part-tracker-track-target
|
||||
;; Used lq/sq
|
||||
(defun part-tracker-track-target ((arg0 part-tracker))
|
||||
(set! (-> arg0 linger-callback) (-> arg0 callback))
|
||||
(let* ((v1-1 *target*)
|
||||
@@ -2707,6 +2715,8 @@
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function sparticle-track-root-money
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
(defun
|
||||
sparticle-track-root-money
|
||||
((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
|
||||
@@ -2873,7 +2883,7 @@
|
||||
(sp-tex spt-texture (new 'static 'texture-id :index #x1a :page #x2))
|
||||
(sp-flt spt-num 2.0)
|
||||
(sp-rnd-flt spt-scale-x (meters 1.3) (meters 0.2) 1.0)
|
||||
(sp-int spt-rot-x 0)
|
||||
(sp-rnd-flt spt-rot-x 0.0 12743.111 1.0)
|
||||
(sp-flt spt-rot-y (degrees 0.0))
|
||||
(sp-copy-from-other spt-scale-y -4)
|
||||
(sp-flt spt-r 128.0)
|
||||
@@ -2898,7 +2908,7 @@
|
||||
(sp-tex spt-texture (new 'static 'texture-id :index #x1a :page #x2))
|
||||
(sp-flt spt-num 2.0)
|
||||
(sp-rnd-flt spt-scale-x (meters 1.3) (meters 0.2) 1.0)
|
||||
(sp-int spt-rot-x 1184657863)
|
||||
(sp-rnd-flt spt-rot-x 20024.889 12743.111 1.0)
|
||||
(sp-flt spt-rot-y (degrees 0.0))
|
||||
(sp-copy-from-other spt-scale-y -4)
|
||||
(sp-flt spt-r 128.0)
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
(let ((tag (the-as game-save-tag (-> obj tag)))
|
||||
(tag-idx 0)
|
||||
)
|
||||
(while (< (the-as int tag) (the-as int (-> obj tag)))
|
||||
(while (< (the-as int tag) (the-as int (-> obj tag (-> obj length))))
|
||||
(format #t "~T [~3D] ~-32S [~3D/~3D] ~12D ~8f "
|
||||
tag-idx
|
||||
(game-save-elt->string (-> tag elt-type))
|
||||
@@ -1705,57 +1705,30 @@
|
||||
)
|
||||
|
||||
(defbehavior auto-save-post auto-save ()
|
||||
(when
|
||||
(and
|
||||
(= *cheat-mode* 'debug)
|
||||
(logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons l3))
|
||||
)
|
||||
(let
|
||||
((gp-0
|
||||
(new
|
||||
'stack
|
||||
'font-context
|
||||
*font-default-matrix*
|
||||
32
|
||||
160
|
||||
0.0
|
||||
(font-color default)
|
||||
(font-flags shadow kerning)
|
||||
)
|
||||
;; debug text
|
||||
(when (and (= *cheat-mode* 'debug)
|
||||
(logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons l3))
|
||||
)
|
||||
(let ((gp-0 (new 'stack 'font-context *font-default-matrix* 32 160 0.0 (font-color default) (font-flags shadow kerning))))
|
||||
(let ((v1-5 gp-0))
|
||||
(set! (-> v1-5 width) (the float 440))
|
||||
)
|
||||
(let ((v1-6 gp-0))
|
||||
(set! (-> v1-6 height) (the float 80))
|
||||
)
|
||||
(set! (-> gp-0 flags) (font-flags shadow kerning))
|
||||
(format (clear *temp-string*) "~S / ~S ~D~%"
|
||||
(-> self mode)
|
||||
(-> self state name)
|
||||
(-> self which)
|
||||
)
|
||||
(print-game-text *temp-string* gp-0 #f 128 22)
|
||||
)
|
||||
)
|
||||
(let ((v1-5 gp-0))
|
||||
(set! (-> v1-5 width) (the float 440))
|
||||
)
|
||||
(let ((v1-6 gp-0))
|
||||
(set! (-> v1-6 height) (the float 80))
|
||||
)
|
||||
(set! (-> gp-0 flags) (font-flags shadow kerning))
|
||||
(format
|
||||
(clear *temp-string*)
|
||||
"~S / ~S ~D~%"
|
||||
(-> self mode)
|
||||
(-> self state name)
|
||||
(-> self which)
|
||||
)
|
||||
(print-game-text *temp-string* gp-0 #f 128 22)
|
||||
)
|
||||
)
|
||||
|
||||
;; auto-save drawing
|
||||
(when (and (= (-> self mode) 'auto-save) (!= (-> self next-state name) 'done))
|
||||
(let
|
||||
((gp-1
|
||||
(new
|
||||
'stack
|
||||
'font-context
|
||||
*font-default-matrix*
|
||||
20
|
||||
40
|
||||
0.0
|
||||
(font-color default)
|
||||
(font-flags shadow kerning)
|
||||
)
|
||||
)
|
||||
)
|
||||
(let ((gp-1 (new 'stack 'font-context *font-default-matrix* 20 40 0.0 (font-color default) (font-flags shadow kerning))))
|
||||
(let ((v1-15 gp-1))
|
||||
(set! (-> v1-15 scale) 0.8)
|
||||
)
|
||||
@@ -1766,14 +1739,10 @@
|
||||
(set! (-> v1-17 height) (the float 20))
|
||||
)
|
||||
(set! (-> gp-1 flags) (font-flags shadow kerning middle left large))
|
||||
|
||||
;; if this is the first time saving, display a warning.
|
||||
(when (zero? (-> *game-info* auto-save-count))
|
||||
(print-game-text
|
||||
(lookup-text! *common-text* (game-text-id saving-data) #f)
|
||||
gp-1
|
||||
#f
|
||||
128
|
||||
22
|
||||
)
|
||||
(print-game-text (lookup-text! *common-text* (game-text-id saving-data) #f) gp-1 #f 128 22)
|
||||
(set! (-> gp-1 origin x) 20.0)
|
||||
(set! (-> gp-1 origin y) 130.0)
|
||||
(let ((v1-23 gp-1))
|
||||
@@ -1792,51 +1761,48 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; flash the icon.
|
||||
(when (< (mod (-> *display* real-frame-counter) 300) 270)
|
||||
(when (> (-> self part matrix) 0)
|
||||
(let ((gp-2 (sprite-get-user-hvdf (-> self part matrix))))
|
||||
(set! (-> gp-2 vector4w x) (the-as int 1842.0))
|
||||
(set!
|
||||
(-> gp-2 vector4w y)
|
||||
(the-as
|
||||
int
|
||||
(the
|
||||
float
|
||||
(+ (the int (* 0.5 (- (* (if (= (get-aspect-ratio) 'aspect16x9)
|
||||
370.0
|
||||
360.0
|
||||
)
|
||||
(-> *video-parms* relative-y-scale)
|
||||
)
|
||||
(the float (-> *video-parms* screen-sy))
|
||||
)
|
||||
)
|
||||
)
|
||||
2048
|
||||
)
|
||||
(when (> (-> self part matrix) 0)
|
||||
(let ((gp-2 (sprite-get-user-hvdf (-> self part matrix))))
|
||||
(set! (-> gp-2 vector4w x) (the-as int 1842.0))
|
||||
(set! (-> gp-2 vector4w y) (the-as int
|
||||
(the float (+ (the int (* 0.5 (- (* (if (= (get-aspect-ratio) 'aspect16x9)
|
||||
370.0
|
||||
360.0
|
||||
)
|
||||
(-> *video-parms* relative-y-scale)
|
||||
)
|
||||
(the float (-> *video-parms* screen-sy))
|
||||
)
|
||||
)
|
||||
)
|
||||
2048
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set!
|
||||
(-> gp-2 vector4w z)
|
||||
(the-as int (+ -1024.0 (-> *math-camera* hvdf-off z)))
|
||||
)
|
||||
(set! (-> gp-2 vector4w w) (the-as int (-> *math-camera* hvdf-off w)))
|
||||
)
|
||||
)
|
||||
)
|
||||
(set!
|
||||
(-> gp-2 vector4w z)
|
||||
(the-as int (+ -1024.0 (-> *math-camera* hvdf-off z)))
|
||||
)
|
||||
(set! (-> gp-2 vector4w w) (the-as int (-> *math-camera* hvdf-off w)))
|
||||
)
|
||||
(spawn (-> self part) *zero-vector*)
|
||||
)
|
||||
(spawn (-> self part) *zero-vector*)
|
||||
)
|
||||
)
|
||||
(none)
|
||||
)
|
||||
|
||||
(defstatehandler auto-save :post auto-save-post)
|
||||
|
||||
(defbehavior auto-save-init-by-other auto-save ((desired-mode symbol) (notify-proc process-tree) (card-idx int) (file-idx int))
|
||||
|
||||
;; stubbing for now.
|
||||
(return #f)
|
||||
|
||||
|
||||
(defbehavior auto-save-init-by-other auto-save ((desired-mode symbol) (notify-proc process-tree) (card-idx int) (file-idx int))
|
||||
(format 0 "auto-save-init!~%")
|
||||
;; trying to create multiple auto save procs, bad idea.
|
||||
(when (handle->process (-> *game-info* auto-save-proc))
|
||||
(let ((a1-2 (new 'stack-no-clear 'event-message-block)))
|
||||
(set! (-> a1-2 from) self)
|
||||
@@ -1844,14 +1810,19 @@
|
||||
(set! (-> a1-2 message) 'notify)
|
||||
(set! (-> a1-2 param 0) (the-as uint 'error))
|
||||
(set! (-> a1-2 param 1) (the-as uint 16))
|
||||
(format 0 "auto save proc error~%")
|
||||
(send-event-function (the-as process notify-proc) a1-2)
|
||||
)
|
||||
(return #f)
|
||||
)
|
||||
|
||||
;; set us as the auto save proc
|
||||
(set! (-> *game-info* auto-save-proc) (process->handle self))
|
||||
(set! (-> *game-info* auto-save-status) (mc-status-code ok))
|
||||
(stack-size-set! (-> self main-thread) 512)
|
||||
(logclear! (-> self mask) (process-mask pause menu progress))
|
||||
|
||||
;; setup ourself
|
||||
(set! (-> self card) card-idx)
|
||||
(set! (-> self which) file-idx)
|
||||
(set! (-> self buffer) #f)
|
||||
@@ -1877,11 +1848,565 @@
|
||||
)
|
||||
)
|
||||
(set! (-> *setting-control* default auto-save) #f)
|
||||
(format 0 "going to get-heap!~%")
|
||||
(go-virtual get-heap)
|
||||
(none)
|
||||
)
|
||||
|
||||
;; Get heap memory.
|
||||
(defstate get-heap (auto-save)
|
||||
:virtual #t
|
||||
:code
|
||||
(behavior ()
|
||||
(set! (-> self state-time) (-> *display* real-frame-counter))
|
||||
(let ((a0-1 (reserve-alloc *art-control*)))
|
||||
(while (not a0-1)
|
||||
(if (>= (- (-> *display* real-frame-counter) (-> self state-time)) #x4650)
|
||||
(go-virtual error (mc-status-code no-memory))
|
||||
)
|
||||
(suspend)
|
||||
(set! a0-1 (reserve-alloc *art-control*))
|
||||
)
|
||||
(set! (-> self buffer) a0-1)
|
||||
)
|
||||
(go-virtual get-card)
|
||||
(none)
|
||||
)
|
||||
:post
|
||||
auto-save-post
|
||||
)
|
||||
|
||||
(defstate get-card (auto-save)
|
||||
:virtual #t
|
||||
:code
|
||||
(behavior ()
|
||||
(label cfg-0)
|
||||
(mc-get-slot-info (-> self slot) (-> self info))
|
||||
(when (zero? (-> self info known))
|
||||
(suspend)
|
||||
(goto cfg-0)
|
||||
)
|
||||
(cond
|
||||
((zero? (-> self info handle))
|
||||
(go-virtual error (mc-status-code no-card))
|
||||
)
|
||||
((zero? (-> self card))
|
||||
(set! (-> self card) (-> self info handle))
|
||||
)
|
||||
((!= (-> self info handle) (-> self card))
|
||||
(go-virtual error (mc-status-code bad-handle))
|
||||
)
|
||||
)
|
||||
(case (-> self mode)
|
||||
(('save 'auto-save)
|
||||
(go-virtual save)
|
||||
)
|
||||
(('save-last)
|
||||
(set! (-> self which) (-> self info last-file))
|
||||
(if (= (-> self which) -1)
|
||||
(go-virtual error (mc-status-code no-last))
|
||||
(go-virtual save)
|
||||
)
|
||||
)
|
||||
(('restore)
|
||||
(go-virtual restore)
|
||||
)
|
||||
(('format-card)
|
||||
(go-virtual format-card)
|
||||
)
|
||||
(('unformat-card)
|
||||
(go-virtual unformat-card)
|
||||
)
|
||||
(('create-file)
|
||||
(go-virtual create-file)
|
||||
)
|
||||
(else
|
||||
(go-virtual done)
|
||||
)
|
||||
)
|
||||
(none)
|
||||
)
|
||||
:post
|
||||
auto-save-post
|
||||
)
|
||||
|
||||
(defstate format-card (auto-save)
|
||||
:virtual #t
|
||||
:code
|
||||
(behavior ()
|
||||
(when (zero? (-> self info formatted))
|
||||
(label cfg-1)
|
||||
(set! (-> self result) (mc-format (-> self card)))
|
||||
(when (!= (-> self result) (mc-status-code ok))
|
||||
(suspend)
|
||||
(goto cfg-1)
|
||||
)
|
||||
(label cfg-3)
|
||||
(set! (-> self result) (the-as mc-status-code (mc-check-result)))
|
||||
(let ((v1-4 (-> self result)))
|
||||
(b! (nonzero? v1-4) cfg-5 :delay (nop!))
|
||||
(b! #t cfg-10 :delay (nop!))
|
||||
(label cfg-5)
|
||||
(b! (= v1-4 (mc-status-code format-failed)) cfg-1 :delay (nop!))
|
||||
(nop!)
|
||||
(b! (!= v1-4 (mc-status-code ok)) cfg-9 :delay (nop!))
|
||||
)
|
||||
(b! #t cfg-12 :delay (nop!))
|
||||
(the-as none 0)
|
||||
(b! #t cfg-10 :delay (nop!))
|
||||
(label cfg-9)
|
||||
(go-virtual error (-> self result))
|
||||
(label cfg-10)
|
||||
(suspend)
|
||||
(goto cfg-3)
|
||||
;;(break ((empty)) ((empty-form)))
|
||||
|
||||
)
|
||||
(label cfg-12)
|
||||
(case (-> self mode)
|
||||
(('create-file 'save 'save-last 'auto-save 'restore)
|
||||
(go-virtual create-file)
|
||||
)
|
||||
)
|
||||
(go-virtual done)
|
||||
(none)
|
||||
)
|
||||
:post
|
||||
auto-save-post
|
||||
)
|
||||
|
||||
(defstate unformat-card (auto-save)
|
||||
:virtual #t
|
||||
:code
|
||||
(behavior ()
|
||||
(when (nonzero? (-> self info formatted))
|
||||
(label cfg-1)
|
||||
(set! (-> self result) (mc-unformat (-> self card)))
|
||||
(when (!= (-> self result) (mc-status-code ok))
|
||||
(suspend)
|
||||
(goto cfg-1)
|
||||
)
|
||||
(while #t
|
||||
(set! (-> self result) (the-as mc-status-code (mc-check-result)))
|
||||
(case (-> self result)
|
||||
(((mc-status-code busy))
|
||||
)
|
||||
(((mc-status-code ok))
|
||||
(goto cfg-11)
|
||||
)
|
||||
(else
|
||||
(go-virtual error (-> self result))
|
||||
)
|
||||
)
|
||||
(suspend)
|
||||
)
|
||||
)
|
||||
(label cfg-11)
|
||||
(go-virtual done)
|
||||
(none)
|
||||
)
|
||||
:post
|
||||
auto-save-post
|
||||
)
|
||||
|
||||
(defstate create-file (auto-save)
|
||||
:virtual #t
|
||||
:code
|
||||
(behavior ()
|
||||
(cond
|
||||
((zero? (-> self info formatted))
|
||||
(go-virtual error (mc-status-code no-format))
|
||||
)
|
||||
((zero? (-> self info inited))
|
||||
(if (< (-> self info mem-actual) (-> self info mem-required))
|
||||
(go-virtual error (mc-status-code no-space))
|
||||
)
|
||||
(let ((v1-12 (-> self buffer)))
|
||||
(set! (-> v1-12 current) (-> v1-12 base))
|
||||
)
|
||||
(label cfg-6)
|
||||
(set!
|
||||
(-> self result)
|
||||
(mc-create-file (-> self card) (the-as uint (-> self buffer base)))
|
||||
)
|
||||
(when (!= (-> self result) (mc-status-code ok))
|
||||
(suspend)
|
||||
(goto cfg-6)
|
||||
)
|
||||
(while #t
|
||||
(set! (-> self result) (the-as mc-status-code (mc-check-result)))
|
||||
(case (-> self result)
|
||||
(((mc-status-code busy))
|
||||
)
|
||||
(((mc-status-code ok))
|
||||
(goto cfg-16)
|
||||
)
|
||||
(else
|
||||
(go-virtual error (-> self result))
|
||||
)
|
||||
)
|
||||
(suspend)
|
||||
)
|
||||
)
|
||||
)
|
||||
(label cfg-16)
|
||||
(case (-> self mode)
|
||||
(('restore)
|
||||
(go-virtual restore)
|
||||
)
|
||||
(('save 'save-last 'auto-save)
|
||||
(go-virtual save)
|
||||
)
|
||||
)
|
||||
(go-virtual done)
|
||||
(none)
|
||||
)
|
||||
:post
|
||||
auto-save-post
|
||||
)
|
||||
|
||||
(defstate save (auto-save)
|
||||
:virtual #t
|
||||
:code
|
||||
(behavior ()
|
||||
(cond
|
||||
((zero? (-> self info formatted))
|
||||
(go-virtual error (mc-status-code no-format))
|
||||
)
|
||||
((zero? (-> self info inited))
|
||||
(go-virtual error (mc-status-code no-file))
|
||||
)
|
||||
)
|
||||
(case (-> self mode)
|
||||
(('auto-save)
|
||||
(+! (-> *game-info* auto-save-count) 1)
|
||||
)
|
||||
)
|
||||
(let ((v1-14 (-> self buffer)))
|
||||
(set! (-> v1-14 current) (-> v1-14 base))
|
||||
)
|
||||
(let ((gp-0 loading-level))
|
||||
(set! loading-level (-> self buffer))
|
||||
(set! (-> self save) (new 'loading-level 'game-save #x10000))
|
||||
(save-game! *game-info* (-> self save) "save")
|
||||
(set! loading-level (the-as kheap gp-0))
|
||||
0
|
||||
(label cfg-7)
|
||||
(set!
|
||||
(-> self result)
|
||||
(mc-save
|
||||
(-> self card)
|
||||
(-> self which)
|
||||
(&-> (-> self save) type)
|
||||
(the-as int (-> self save info-int32))
|
||||
)
|
||||
)
|
||||
(when (!= (-> self result) (mc-status-code ok))
|
||||
(suspend)
|
||||
(goto cfg-7)
|
||||
)
|
||||
(while #t
|
||||
(set! (-> self result) (the-as mc-status-code (mc-check-result)))
|
||||
(let ((v1-24 (-> self result)))
|
||||
(cond
|
||||
((= v1-24 (mc-status-code busy))
|
||||
#f
|
||||
)
|
||||
((= v1-24 (mc-status-code ok))
|
||||
(goto cfg-21)
|
||||
gp-0
|
||||
)
|
||||
((= v1-24 (mc-status-code write-error))
|
||||
(suspend)
|
||||
gp-0
|
||||
)
|
||||
(else
|
||||
(case (-> self mode)
|
||||
(('auto-save)
|
||||
(set!
|
||||
(-> *game-info* auto-save-count)
|
||||
(seekl (-> *game-info* auto-save-count) 0 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(go-virtual error (-> self result))
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
(suspend)
|
||||
)
|
||||
)
|
||||
(label cfg-21)
|
||||
(go-virtual done)
|
||||
(none)
|
||||
)
|
||||
:post
|
||||
auto-save-post
|
||||
)
|
||||
|
||||
(defstate restore (auto-save)
|
||||
:virtual #t
|
||||
:code
|
||||
(behavior ()
|
||||
(local-vars (gp-0 none))
|
||||
(cond
|
||||
((zero? (-> self info formatted))
|
||||
(go-virtual error (mc-status-code no-format))
|
||||
)
|
||||
((zero? (-> self info inited))
|
||||
(go-virtual error (mc-status-code no-file))
|
||||
)
|
||||
)
|
||||
(let ((v1-10 (-> self buffer)))
|
||||
(set! (-> v1-10 current) (-> v1-10 base))
|
||||
)
|
||||
(if (zero? (-> self info file (-> self which) present))
|
||||
(go-virtual error (mc-status-code no-save))
|
||||
)
|
||||
(label cfg-6)
|
||||
(set!
|
||||
(-> self result)
|
||||
(mc-load (-> self card) (-> self which) (-> self buffer base))
|
||||
)
|
||||
(when (!= (-> self result) (mc-status-code ok))
|
||||
(suspend)
|
||||
(goto cfg-6)
|
||||
)
|
||||
(while #t
|
||||
(set! (-> self result) (the-as mc-status-code (mc-check-result)))
|
||||
(let ((v1-22 (-> self result)))
|
||||
(cond
|
||||
((= v1-22 (mc-status-code busy))
|
||||
#f
|
||||
)
|
||||
((= v1-22 (mc-status-code ok))
|
||||
(goto cfg-20)
|
||||
gp-0
|
||||
)
|
||||
((= v1-22 (mc-status-code read-error))
|
||||
(suspend)
|
||||
gp-0
|
||||
)
|
||||
((= v1-22 (mc-status-code new-game))
|
||||
(go-virtual error (mc-status-code no-save))
|
||||
)
|
||||
(else
|
||||
(go-virtual error (-> self result))
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
(suspend)
|
||||
)
|
||||
(label cfg-20)
|
||||
(set! (-> self save) (the-as game-save (&+ (-> self buffer base) 4)))
|
||||
(let ((v1-34 (-> self save)))
|
||||
(set! (-> v1-34 type) game-save)
|
||||
(if (!= (-> v1-34 version) 1)
|
||||
(go-virtual error (mc-status-code bad-version))
|
||||
)
|
||||
)
|
||||
(set-setting! *setting-control* self 'music-volume 'abs 0.0 0)
|
||||
(set-setting! *setting-control* self 'sfx-volume 'abs 0.0 0)
|
||||
(set! (-> *game-info* mode) 'play)
|
||||
(initialize! *game-info* 'game (-> self save) (the-as string #f))
|
||||
(set-master-mode 'game)
|
||||
(push-setting!
|
||||
*setting-control*
|
||||
self
|
||||
(the-as (function object object object object object) 'process-mask)
|
||||
'set
|
||||
0.0
|
||||
16
|
||||
)
|
||||
(copy-settings-from-target! *setting-control*)
|
||||
(dotimes (gp-1 15)
|
||||
(suspend)
|
||||
)
|
||||
(go-virtual done)
|
||||
(none)
|
||||
)
|
||||
:post
|
||||
auto-save-post
|
||||
)
|
||||
|
||||
(defstate error (auto-save)
|
||||
:virtual #t
|
||||
:event
|
||||
(behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
|
||||
(let ((v1-0 arg2))
|
||||
(the-as object (cond
|
||||
((= v1-0 'progress-allowed?)
|
||||
#t
|
||||
)
|
||||
((= v1-0 'die)
|
||||
(deactivate self)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
:code
|
||||
(behavior ((arg0 mc-status-code))
|
||||
(if (-> self buffer)
|
||||
(reserve-free *art-control* (-> self buffer))
|
||||
)
|
||||
(set! (-> self result) arg0)
|
||||
(let ((s5-0 *auto-save-info*))
|
||||
(mem-copy! (the-as pointer s5-0) (the-as pointer (-> self info)) 300)
|
||||
(let ((a1-2 (new 'stack-no-clear 'event-message-block)))
|
||||
(set! (-> a1-2 from) self)
|
||||
(set! (-> a1-2 num-params) 3)
|
||||
(set! (-> a1-2 message) 'notify)
|
||||
(set! (-> a1-2 param 0) (the-as uint 'error))
|
||||
(set! (-> a1-2 param 1) (the-as uint (-> self result)))
|
||||
(set! (-> a1-2 param 2) (the-as uint s5-0))
|
||||
(send-event-function (handle->process (-> self notify)) a1-2)
|
||||
)
|
||||
)
|
||||
(let ((t9-3 format)
|
||||
(a0-7 #t)
|
||||
(a1-3 "SAVE ERROR: ~A~%")
|
||||
(v1-12 (-> self result))
|
||||
)
|
||||
(t9-3 a0-7 a1-3 (cond
|
||||
((= v1-12 (mc-status-code no-auto-save))
|
||||
"no-auto-save"
|
||||
)
|
||||
((= v1-12 (mc-status-code no-process))
|
||||
"no-process"
|
||||
)
|
||||
((= v1-12 (mc-status-code bad-version))
|
||||
"bad-version"
|
||||
)
|
||||
((= v1-12 (mc-status-code no-space))
|
||||
"no-space"
|
||||
)
|
||||
((= v1-12 (mc-status-code no-save))
|
||||
"no-save"
|
||||
)
|
||||
((= v1-12 (mc-status-code no-file))
|
||||
"no-file"
|
||||
)
|
||||
((= v1-12 (mc-status-code no-format))
|
||||
"no-format"
|
||||
)
|
||||
((= v1-12 (mc-status-code no-last))
|
||||
"no-last"
|
||||
)
|
||||
((= v1-12 (mc-status-code no-card))
|
||||
"no-card"
|
||||
)
|
||||
((= v1-12 (mc-status-code no-memory))
|
||||
"no-memory"
|
||||
)
|
||||
((= v1-12 (mc-status-code new-game))
|
||||
"new-game"
|
||||
)
|
||||
((= v1-12 (mc-status-code read-error))
|
||||
"read-error"
|
||||
)
|
||||
((= v1-12 (mc-status-code write-error))
|
||||
"write-error"
|
||||
)
|
||||
((= v1-12 (mc-status-code internal-error))
|
||||
"internal-error"
|
||||
)
|
||||
((= v1-12 (mc-status-code format-failed))
|
||||
"format-failed"
|
||||
)
|
||||
((= v1-12 (mc-status-code bad-handle))
|
||||
"bad-handle"
|
||||
)
|
||||
((= v1-12 (mc-status-code ok))
|
||||
"ok"
|
||||
)
|
||||
((= v1-12 (mc-status-code busy))
|
||||
"busy"
|
||||
)
|
||||
(else
|
||||
"*unknown*"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if (= (-> self result) (mc-status-code no-auto-save))
|
||||
(return #f)
|
||||
)
|
||||
(case (-> self mode)
|
||||
(('auto-save 'error)
|
||||
(set! (-> self state-time) (-> *display* real-frame-counter))
|
||||
(set! (-> *game-info* auto-save-status) arg0)
|
||||
(while (< (- (-> *display* real-frame-counter) (-> self state-time)) 60)
|
||||
(if (not (progress-allowed?))
|
||||
(set! (-> self state-time) (-> *display* real-frame-counter))
|
||||
)
|
||||
(suspend)
|
||||
)
|
||||
(if (= arg0 (mc-status-code no-card))
|
||||
(activate-progress *dproc* (progress-screen memcard-removed))
|
||||
(activate-progress *dproc* (progress-screen memcard-auto-save-error))
|
||||
)
|
||||
)
|
||||
)
|
||||
(none)
|
||||
)
|
||||
:post
|
||||
auto-save-post
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(defstate done (auto-save)
|
||||
:virtual #t
|
||||
:code
|
||||
(behavior ()
|
||||
(if (and (-> self buffer) (-> *art-control* reserve-buffer))
|
||||
(reserve-free *art-control* (-> self buffer))
|
||||
)
|
||||
(set! (-> *game-info* auto-save-status) (mc-status-code ok))
|
||||
(case (-> self mode)
|
||||
(('save 'save-last 'auto-save 'restore)
|
||||
(set! (-> *setting-control* default auto-save) #t)
|
||||
(set! (-> *game-info* auto-save-card) (-> self card))
|
||||
(set! (-> *game-info* auto-save-which) (-> self which))
|
||||
)
|
||||
)
|
||||
(let ((gp-0 *auto-save-info*))
|
||||
(mem-copy! (the-as pointer gp-0) (the-as pointer (-> self info)) 300)
|
||||
(let ((a1-5 (new 'stack-no-clear 'event-message-block)))
|
||||
(set! (-> a1-5 from) self)
|
||||
(set! (-> a1-5 num-params) 3)
|
||||
(set! (-> a1-5 message) 'notify)
|
||||
(set! (-> a1-5 param 0) (the-as uint 'done))
|
||||
(set! (-> a1-5 param 1) (the-as uint 1))
|
||||
(set! (-> a1-5 param 2) (the-as uint gp-0))
|
||||
(send-event-function (handle->process (-> self notify)) a1-5)
|
||||
)
|
||||
)
|
||||
(case (-> self mode)
|
||||
(('auto-save)
|
||||
(when (= (-> *game-info* auto-save-count) 1)
|
||||
(set! (-> self event-hook) (-> (method-of-object self error) event))
|
||||
(set! (-> self state-time) (-> *display* real-frame-counter))
|
||||
(while (< (- (-> *display* real-frame-counter) (-> self state-time)) 60)
|
||||
(if (not (progress-allowed?))
|
||||
(set! (-> self state-time) (-> *display* real-frame-counter))
|
||||
)
|
||||
(suspend)
|
||||
)
|
||||
(activate-progress *dproc* (progress-screen auto-save))
|
||||
)
|
||||
)
|
||||
)
|
||||
(none)
|
||||
)
|
||||
:post
|
||||
auto-save-post
|
||||
)
|
||||
|
||||
(defun auto-save-command ((arg0 symbol) (arg1 int) (arg2 int) (arg3 process-tree))
|
||||
(format #t "auto-save cmd: ~A from ~A~%" arg0 arg3)
|
||||
(make-init-process auto-save auto-save-init-by-other arg0 arg3 arg1 arg2)
|
||||
(none)
|
||||
)
|
||||
|
||||
@@ -695,12 +695,11 @@
|
||||
(process-particles)
|
||||
|
||||
|
||||
;; particles
|
||||
;; vif0 collid
|
||||
;; vif0 collide
|
||||
;; swap sound
|
||||
;; str play
|
||||
(level-update *level*) ;; also updates settings.
|
||||
;; run mc
|
||||
(mc-run)
|
||||
;; auto save check
|
||||
;; suspend
|
||||
|
||||
|
||||
@@ -1552,6 +1552,8 @@
|
||||
(defmethod level-update level-group ((obj level-group))
|
||||
;; todo lots of stuff
|
||||
(update-per-frame-settings! *setting-control*)
|
||||
(update *art-control* #t)
|
||||
(clear-rec *art-control*)
|
||||
0
|
||||
)
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
;; This is not well-understood yet, but it is definitely related to streaming animation loading,
|
||||
;; and possibly art-group stuff.
|
||||
|
||||
|
||||
;; note: lower values are more important.
|
||||
;; negative values will preload.
|
||||
(defconstant SPOOL_PRIORITY_LOWEST 100000000.0)
|
||||
(defconstant SPOOL_PRIORITY_RECALC -99.0)
|
||||
(defconstant SPOOL_PRIORITY_HIGHEST -20.0)
|
||||
@@ -23,7 +24,9 @@
|
||||
(string-array (array string) :offset-assert 8) ;; these are the names
|
||||
(data-array (array basic) :offset-assert 12) ;; this is the file data.
|
||||
)
|
||||
:flag-assert #xb00000010
|
||||
:method-count-assert 11
|
||||
:size-assert #x10
|
||||
:flag-assert #xb00000010
|
||||
(:methods
|
||||
(new (symbol type int basic) _type_ 0)
|
||||
(load-to-heap-by-name (_type_ string symbol kheap int) art-group 9)
|
||||
@@ -35,7 +38,9 @@
|
||||
(deftype load-dir-art-group (load-dir)
|
||||
((art-group-array (array art-group) :offset 12)
|
||||
)
|
||||
:flag-assert #xb00000010
|
||||
:method-count-assert 11
|
||||
:size-assert #x10
|
||||
:flag-assert #xb00000010
|
||||
(:methods
|
||||
(new (symbol type int basic) _type_ 0)
|
||||
)
|
||||
@@ -74,31 +79,42 @@
|
||||
)
|
||||
)
|
||||
|
||||
;; An external-art-buffer owns some memory for loading files.
|
||||
;; status:
|
||||
;; - 'active: file is loaded and art group is linked to level's art group.
|
||||
;; - 'reserved: buffer is reserved for other purpose
|
||||
;; - 'error: load has encountered an error, goes to 'inactive
|
||||
;; - 'inactive: not in use
|
||||
;; - 'loading: loading is in progress
|
||||
;; - 'loaded: loading has finished, goes to 'locked or 'active
|
||||
;; - 'locked: loaded, but another buffer is active and blocks this one.
|
||||
;; Note: a locked buffer has loaded/linked the file, but hasn't linked the file
|
||||
;; to the "master" art group, located in the level.
|
||||
(deftype external-art-buffer (basic)
|
||||
((index int32 :offset-assert 4)
|
||||
(other external-art-buffer :offset-assert 8)
|
||||
(status symbol :offset-assert 12)
|
||||
(locked? symbol :offset-assert 16)
|
||||
(frame-lock symbol :offset-assert 20)
|
||||
(heap kheap :inline :offset-assert 32)
|
||||
(pending-load-file string :offset-assert 48)
|
||||
(pending-load-file-part int32 :offset-assert 52)
|
||||
(pending-load-file-owner handle :offset-assert 56)
|
||||
(pending-load-file-priority float :offset-assert 64)
|
||||
(load-file string :offset-assert 68)
|
||||
(load-file-part int32 :offset-assert 72)
|
||||
(load-file-owner handle :offset-assert 80)
|
||||
(load-file-priority float :offset-assert 88)
|
||||
(buf pointer :offset-assert 92)
|
||||
(len int32 :offset-assert 96)
|
||||
(art-group art-group :offset-assert 100)
|
||||
((index int32 :offset-assert 4)
|
||||
(other external-art-buffer :offset-assert 8)
|
||||
(status symbol :offset-assert 12)
|
||||
(locked? symbol :offset-assert 16)
|
||||
(frame-lock symbol :offset-assert 20)
|
||||
(heap kheap :inline :offset-assert 32)
|
||||
(pending-load-file string :offset-assert 48)
|
||||
(pending-load-file-part int32 :offset-assert 52)
|
||||
(pending-load-file-owner handle :offset-assert 56)
|
||||
(pending-load-file-priority float :offset-assert 64)
|
||||
(load-file string :offset-assert 68)
|
||||
(load-file-part int32 :offset-assert 72)
|
||||
(load-file-owner handle :offset-assert 80)
|
||||
(load-file-priority float :offset-assert 88)
|
||||
(buf pointer :offset-assert 92)
|
||||
(len int32 :offset-assert 96)
|
||||
(art-group art-group :offset-assert 100)
|
||||
)
|
||||
:method-count-assert 16
|
||||
:size-assert #x68
|
||||
:flag-assert #x1000000068
|
||||
(:methods
|
||||
(new (symbol type int) _type_ 0)
|
||||
(want-file (_type_ string int handle float) int 9)
|
||||
(set-pending-file (_type_ string int handle float) int 9)
|
||||
(update (_type_) int 10)
|
||||
(inactive? (_type_) symbol 11)
|
||||
(file-status (_type_ string int) symbol 12)
|
||||
@@ -128,11 +144,14 @@
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;; A spool-anim tracks the buffers for spooled animations.
|
||||
;; ?? what are the bufs here.
|
||||
(deftype spool-anim (basic)
|
||||
((name string :offset 16) ;; why?
|
||||
(buf1 external-art-buffer :offset 16) ;; custom
|
||||
(index int32 :score 100 :offset 20)
|
||||
(buf2 external-art-buffer :offset 20) ;; custom (also what?)
|
||||
(buf2 external-art-buffer :offset 20) ;; custom the old buffer
|
||||
(parts int32 :offset-assert 24)
|
||||
(priority float :offset-assert 28)
|
||||
(owner handle :offset-assert 32)
|
||||
@@ -144,12 +163,13 @@
|
||||
:flag-assert #x90000002c
|
||||
)
|
||||
|
||||
;; This is the main controller for the loader.
|
||||
(deftype external-art-control (basic)
|
||||
((buffer external-art-buffer 2 :offset-assert 4)
|
||||
(rec spool-anim 3 :inline :offset-assert 16)
|
||||
((buffer external-art-buffer 2 :offset-assert 4) ;; actual data buffers
|
||||
(rec spool-anim 3 :inline :offset-assert 16) ;; things we would consider loading
|
||||
(spool-lock handle :offset-assert 160)
|
||||
(reserve-buffer external-art-buffer :offset-assert 168)
|
||||
(reserve-buffer-count int32 :offset-assert 172)
|
||||
(reserve-buffer external-art-buffer :offset-assert 168) ;; ??
|
||||
(reserve-buffer-count int32 :offset-assert 172) ;; ??
|
||||
(active-stream string :offset-assert 176)
|
||||
(preload-stream spool-anim :inline :offset-assert 184)
|
||||
(last-preload-stream spool-anim :inline :offset-assert 232)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
|
||||
(defmethod inspect load-dir ((obj load-dir))
|
||||
"Print all the stuff in a load-dir"
|
||||
(format #t "[~8x] ~A~%" obj (-> obj type))
|
||||
(format #t "~Tlevel: ~A~%" (-> obj unknown))
|
||||
(format #t "~Tallocated-length: ~D~%" (-> obj string-array allocated-length))
|
||||
@@ -179,7 +180,7 @@
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod want-file external-art-buffer ((obj external-art-buffer) (arg0 string) (arg1 int) (arg2 handle) (arg3 float))
|
||||
(defmethod set-pending-file external-art-buffer ((obj external-art-buffer) (arg0 string) (arg1 int) (arg2 handle) (arg3 float))
|
||||
"Request a new file to be loaded into this buffer."
|
||||
|
||||
(set! (-> obj pending-load-file) arg0)
|
||||
@@ -212,14 +213,16 @@
|
||||
)
|
||||
;; the file is at least wanting to load
|
||||
(if (and (name= (-> obj load-file) name) (= (-> obj load-file-part) part))
|
||||
(-> obj status) ;; file is loaded
|
||||
'pending ;; file is not loaded yet?
|
||||
(-> obj status) ;; file is loaded or loading
|
||||
'pending ;; file has not started loading yet.
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod link-art! art-group ((obj art-group))
|
||||
"Links the elements of this art-group."
|
||||
"Links the elements of this art-group.
|
||||
This will put a reference to this joint animation in the level art group.
|
||||
Level art groups have slots for temporarily loaded joint animations."
|
||||
|
||||
(when obj
|
||||
(countdown (s5-0 (-> obj length))
|
||||
@@ -236,19 +239,23 @@
|
||||
(label cfg-22)
|
||||
(nonzero? s3-1)
|
||||
)
|
||||
;; loop over levels, looking for the master art group for this joint animation.
|
||||
(+! s3-1 -1)
|
||||
(let ((janim-group (art-group-get-by-name (-> *level* level s3-1) (-> janim master-art-group-name))))
|
||||
(when janim-group
|
||||
(cond
|
||||
((and (< (-> janim master-art-group-index) (-> janim-group length))
|
||||
(not (-> janim-group data (-> janim master-art-group-index)))
|
||||
((and (< (-> janim master-art-group-index) (-> janim-group length)) ;; index is valid
|
||||
(not (-> janim-group data (-> janim master-art-group-index))) ;; doesn't already have it loaded
|
||||
)
|
||||
;; link!
|
||||
(set! (-> janim-group data (-> janim master-art-group-index)) janim)
|
||||
(set! success #t)
|
||||
)
|
||||
(else
|
||||
;; if the specified index is no good, just try looking for somewhere else.
|
||||
(countdown (a0-14 (-> janim-group length))
|
||||
(when (not (-> janim-group data a0-14))
|
||||
;; found an empty one!
|
||||
(set! (-> janim-group data a0-14) janim)
|
||||
(set! success #t)
|
||||
(goto cfg-22)
|
||||
@@ -271,7 +278,7 @@
|
||||
)
|
||||
|
||||
(defmethod unlink-art! art-group ((obj art-group))
|
||||
"Unlinks the elements of this art-group."
|
||||
"Unlinks the elements of this art-group. This will undo the link-art! function."
|
||||
|
||||
(when obj
|
||||
(countdown (s5-0 (-> obj length))
|
||||
@@ -348,6 +355,8 @@
|
||||
(when (= (-> obj status) 'initialize)
|
||||
;; we need to initialize the heap
|
||||
(let ((v1-11 (-> obj heap)))
|
||||
;; Scary: this is a hard coded address that points to the kernel memory.
|
||||
;; it turns out the kernel doesn't need this. So we can use it!
|
||||
(set! (-> v1-11 base) (the-as pointer (+ #x84000 (* #x3dc00 (-> obj index)))))
|
||||
(set! (-> v1-11 current) (-> v1-11 base))
|
||||
(set! (-> v1-11 top-base) (&+ (-> v1-11 base) #x3dc00))
|
||||
@@ -368,9 +377,11 @@
|
||||
(set! (-> obj load-file-part) -1)
|
||||
(set! (-> obj load-file-owner) (the-as handle #f))
|
||||
(set! (-> obj load-file-priority) SPOOL_PRIORITY_LOWEST)
|
||||
;; on the next time through, we will set the actual load file.
|
||||
)
|
||||
(else
|
||||
;; we have officially chosen to load this file
|
||||
|
||||
(set! (-> obj load-file) (-> obj pending-load-file))
|
||||
(set! (-> obj load-file-part) (-> obj pending-load-file-part))
|
||||
(set! (-> obj load-file-owner) (-> obj pending-load-file-owner))
|
||||
@@ -378,6 +389,8 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(label cfg-18)
|
||||
(cond
|
||||
((-> obj load-file)
|
||||
@@ -406,7 +419,7 @@
|
||||
(set! (-> v1-28 current) (-> v1-28 base))
|
||||
)
|
||||
(cond
|
||||
((string= (-> obj load-file) "reserved") ;; we want to reserve something
|
||||
((string= (-> obj load-file) "reserved") ;; we want to reserve this buffer for something (not loading an str file)
|
||||
(cond
|
||||
((-> *art-control* reserve-buffer)
|
||||
(format 0 "ERROR: trying double reserve ~A when ~A is reserved~%" obj (-> *art-control* reserve-buffer))
|
||||
@@ -422,7 +435,8 @@
|
||||
)
|
||||
;; unused cond
|
||||
)
|
||||
((str-load (-> obj load-file) (-> obj load-file-part) (the pointer (align64 (-> obj heap current))) #x3fc00)
|
||||
((str-load (-> obj load-file) (-> obj load-file-part) (the pointer (align64 (-> obj heap current))) #x3fc00) ;; try to start load
|
||||
;; load has started!!
|
||||
(set! (-> obj status) 'loading)
|
||||
)
|
||||
)
|
||||
@@ -476,10 +490,11 @@
|
||||
)
|
||||
(('locked)
|
||||
;; this buffer is locked and needs to be unlocked before it can be used.
|
||||
;; only one buffer can be active at a time. The other buffer is locked to prevent it from activating.
|
||||
(when (and (not (-> obj locked?)) (handle->process (-> obj load-file-owner)))
|
||||
;; we want to be used, unlock this buffer and lock the other just in case.
|
||||
(link-file obj (-> obj art-group))
|
||||
(set! (-> obj other locked?) #t)
|
||||
(set! (-> obj other locked?) #t) ;; prevent it from becoming active
|
||||
(set! (-> obj status) 'active)
|
||||
(goto cfg-18)
|
||||
)
|
||||
@@ -512,6 +527,7 @@
|
||||
)
|
||||
(set! (-> obj art-group) #f)
|
||||
(set! (-> obj status) 'inactive)
|
||||
;; if the other is locked due to us, unlock it, then update it so it activates.
|
||||
(when (-> obj other locked?)
|
||||
(unlock! (-> obj other))
|
||||
(update (-> obj other))
|
||||
@@ -551,27 +567,38 @@
|
||||
"Update this external-art-control. This validates the spool buffers, sorts the spools, advances str-play-queue, and does some other things.
|
||||
If debug-print, also prints some text to the display console"
|
||||
|
||||
;; if somebody wants a reserve buffer, they will set this to 1.
|
||||
(if (nonzero? (-> obj reserve-buffer-count))
|
||||
(spool-push obj "reserved" 0 *dproc* (if (-> obj reserve-buffer)
|
||||
-110.0
|
||||
-0.5)
|
||||
)
|
||||
)
|
||||
|
||||
;; frame-lock will get set to #t if something is assigned to this buffer in this update.
|
||||
(dotimes (v1-5 2)
|
||||
(set! (-> obj buffer v1-5 frame-lock) #f) ;; I don't know what this is
|
||||
(set! (-> obj buffer v1-5 frame-lock) #f)
|
||||
)
|
||||
|
||||
;; buffers assigned from this call to update
|
||||
(dotimes (v1-8 3)
|
||||
(set! (-> obj rec v1-8 buf2) #f)
|
||||
)
|
||||
|
||||
;; update existing buffers from their recs
|
||||
(dotimes (s4-0 2)
|
||||
(let ((s3-0 (-> obj rec s4-0)))
|
||||
(when (-> s3-0 name)
|
||||
;; iterate over the two buffers
|
||||
(dotimes (s2-0 2)
|
||||
(when (and (file-status (-> obj buffer s2-0) (-> s3-0 name) (-> s3-0 parts))
|
||||
(not (-> obj buffer s2-0 frame-lock))
|
||||
(when (and (file-status (-> obj buffer s2-0) (-> s3-0 name) (-> s3-0 parts)) ;; this buffer holds the file for the rec
|
||||
(not (-> obj buffer s2-0 frame-lock)) ;; and nothing has frame-locked this buffer
|
||||
)
|
||||
;; so we frame lock it to prevent it from being kicked out
|
||||
(set! (-> obj buffer s2-0 frame-lock) #t)
|
||||
;; remember what buffer
|
||||
(set! (-> s3-0 buf2) (-> obj buffer s2-0))
|
||||
;; update owner and priority.
|
||||
(set! (-> obj buffer s2-0 pending-load-file-owner) (-> s3-0 owner))
|
||||
(set! (-> obj buffer s2-0 load-file-owner) (-> s3-0 owner))
|
||||
(set! (-> obj buffer s2-0 pending-load-file-priority) (-> s3-0 priority))
|
||||
@@ -584,18 +611,25 @@
|
||||
(label cfg-24)
|
||||
)
|
||||
|
||||
;; preload recs
|
||||
;; iterate over recs
|
||||
(dotimes (s4-1 2)
|
||||
(let ((s3-1 (-> obj rec s4-1)))
|
||||
;; rec wants to load something, but doesn't have a buffer already
|
||||
(when (and (-> s3-1 name) (not (-> s3-1 buf2)))
|
||||
;; skip if we aren't preloading, or have a positive priority.
|
||||
(if (and (not *preload-spool-anims*) (>= (-> s3-1 priority) 0.0))
|
||||
;; not in use, move on
|
||||
(goto cfg-46)
|
||||
)
|
||||
;; search for a buffer for preloading
|
||||
(dotimes (s2-1 2)
|
||||
;; can't steal one that's already assigned
|
||||
(when (not (-> obj buffer s2-1 frame-lock))
|
||||
;; do the assignment!
|
||||
(set! (-> obj buffer s2-1 frame-lock) #t)
|
||||
(want-file (-> obj buffer s2-1) (-> s3-1 name) (-> s3-1 parts) (-> s3-1 owner) (-> s3-1 priority))
|
||||
(set! (-> s3-1 index) (the-as int (-> obj buffer s2-1)))
|
||||
(set-pending-file (-> obj buffer s2-1) (-> s3-1 name) (-> s3-1 parts) (-> s3-1 owner) (-> s3-1 priority))
|
||||
(set! (-> s3-1 buf2) (-> obj buffer s2-1))
|
||||
(goto cfg-46)
|
||||
)
|
||||
)
|
||||
@@ -604,18 +638,20 @@
|
||||
(label cfg-46)
|
||||
)
|
||||
|
||||
;; this part is a bit confusing, but I think it basically kicks out the lowest priority thing.
|
||||
(when (not (-> obj reserve-buffer))
|
||||
(let ((s4-2 (-> obj rec 0 buf1)))
|
||||
(let ((s4-2 (-> obj rec 0 buf2))) ;; top priority buffer
|
||||
(if (and s4-2
|
||||
(-> s4-2 locked?)
|
||||
(not (string= (-> s4-2 pending-load-file) "reserved"))
|
||||
(not (string= (-> s4-2 other pending-load-file) "reserved"))
|
||||
)
|
||||
(want-file (-> s4-2 other) (the-as string #f) -1 (the-as handle #f) SPOOL_PRIORITY_LOWEST)
|
||||
(set-pending-file (-> s4-2 other) (the-as string #f) -1 (the-as handle #f) SPOOL_PRIORITY_LOWEST)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; update the buffers
|
||||
(dotimes (s4-3 2)
|
||||
(update (-> obj buffer s4-3))
|
||||
)
|
||||
@@ -686,7 +722,7 @@
|
||||
(set! (-> obj reserve-buffer-count) 0)
|
||||
)
|
||||
((= (-> obj reserve-buffer heap) arg0)
|
||||
(want-file (-> obj reserve-buffer) (the-as string #f) -1 (the-as handle #f) SPOOL_PRIORITY_LOWEST)
|
||||
(set-pending-file (-> obj reserve-buffer) (the-as string #f) -1 (the-as handle #f) SPOOL_PRIORITY_LOWEST)
|
||||
(update (-> obj reserve-buffer))
|
||||
(set! (-> obj reserve-buffer-count) 0)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user