;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/ui/progress/progress-static.gc")
(require "engine/game/main.gc")
(require "engine/ui/hud-classes.gc")

;; DECOMP BEGINS

(defun adjust-pos ((arg0 int) (arg1 int))
  (if (< arg0 arg1) 0 (- arg0 arg1)))

(defmethod draw-fuel-cell-screen ((this progress) (arg0 int))
  (local-vars
    (sv-112 int)
    (sv-128 int)
    (sv-144 int)
    (sv-160 (function trsqv float quaternion))
    (sv-176 trsqv)
    (sv-192 int)
    (sv-208 int)
    (sv-224 (function string float font-context int none)))
  (hide-progress-icons)
  (let ((s5-0 (-> *level-task-data* arg0)))
    (if (and (= *cheat-mode* 'debug) (cpad-hold? 0 l3)) (format *stdcon* "fcd:~d~%" (-> *game-info* fuel-cell-deaths)))
    (set! (-> *progress-process* 0 particles 14 init-pos x) -320.0)
    (set! (-> *progress-process* 0 particles 15 init-pos x) -320.0)
    (set! (-> *progress-process* 0 icons 4 icon-x) -320)
    (when (and (!= s5-0 #f) (= (-> *game-info* level-opened arg0) 1))
      (set! sv-112 (- (-> *task-egg-starting-x* (-> s5-0 nb-of-tasks)) (-> this left-x-offset)))
      (set! sv-128 (the int (* 47.0 (-> this transition-percentage-invert))))
      0
      (let ((s0-0 6)
            (s2-0 0)
            (s4-1 (if (= (-> this level-transition) 1) (- (-> this transition-offset)) (-> this transition-offset)))
            (f30-0 (-> this transition-percentage-invert))
            (s1-0 0)
            (s3-0 #f))
        (when (-> this stat-transition)
          (set! sv-128 47)
          (set! s2-0
                (if (!= (-> this display-state) (-> this next-display-state)) (- (-> this transition-offset)) (-> this transition-offset)))
          (set! s4-1 0)
          (set! f30-0 1.0))
        (set! sv-144 0)
        (while (< sv-144 4)
          (let ((a0-18 (-> this icons sv-144 icon 0 root)))
            (set! sv-176 a0-18)
            (set! sv-160 (method-of-object sv-176 set-yaw-angle-clear-roll-pitch!))
            (let ((a1-2 (+ (y-angle a0-18) (* 182.04445 (/ (-> *display* time-adjust-ratio) 2))))) (sv-160 sv-176 a1-2)))
          (set! sv-144 (+ sv-144 1)))
        (set! sv-192 (+ sv-112 (/ (- (* 47 (-> s5-0 nb-of-tasks)) (* sv-128 (-> s5-0 nb-of-tasks))) 2)))
        (set! sv-208 0)
        (while (< sv-208 (-> s5-0 nb-of-tasks))
          (let ((v0-4 (get-task-status (-> s5-0 task-info sv-208 task-id)))
                (v1-59 -1)
                (a0-25 #f))
            (set! (-> this particle-state s0-0) 2)
            (cond
              ((or (= v0-4 (task-status need-hint)) (= v0-4 (task-status unknown)))
               (if (= *kernel-boot-message* 'play) (set! (-> this particle-state s0-0) 1)))
              ((= v0-4 (task-status invalid))
               (set! v1-59 (-> s5-0 task-info sv-208 text-index-when-resolved))
               (set! (-> this particle-state s0-0) 3)
               (set! a0-25 #t))
              ((= v0-4 (task-status need-introduction)) (set! v1-59 0))
              ((= v0-4 (task-status need-reminder-a)) (set! v1-59 0))
              ((= v0-4 (task-status need-reminder)) (set! v1-59 1))
              ((= v0-4 (task-status need-reward-speech)) (set! v1-59 2))
              ((= v0-4 (task-status need-resolution)) (set! v1-59 2)))
            (if (and (!= *kernel-boot-message* 'play) (= v1-59 -1)) (set! v1-59 0))
            (set! (-> this particles s0-0 init-pos x) (the float (+ sv-192 s2-0)))
            (set! (-> this particles s0-0 init-pos y) (the float (+ s4-1 204)))
            (+! s0-0 1)
            (when (= sv-208 (-> this task-index))
              (set! s1-0 v1-59)
              (set! s3-0 a0-25)
              (set! (-> this particles 5 init-pos x) (the float (+ sv-192 s2-0)))
              (set! (-> this particles 5 init-pos y) (the float (+ s4-1 204)))))
          (set! sv-192 (+ sv-192 sv-128))
          (set! sv-208 (+ sv-208 1)))
        (dotimes (v1-77 (- 8 (-> s5-0 nb-of-tasks)))
          (set! (-> *progress-process* 0 particles s0-0 init-pos x) (the float (+ s2-0 -320)))
          (set! (-> this particles s0-0 init-pos y) (the float (+ s4-1 194)))
          (+! s0-0 1))
        (when *common-text*
          (when (and (!= s1-0 -1)
                     (> (-> s5-0 nb-of-tasks) 0)
                     (>= (-> this task-index) 0)
                     (< (-> this task-index) (-> s5-0 nb-of-tasks)))
            (let ((s0-1 (new 'stack
                             'font-context
                             *font-default-matrix*
                             (- (+ s2-0 32) (-> this left-x-offset))
                             (+ (/ s4-1 2) 125)
                             8325000.0
                             (font-color progress-yellow)
                             (font-flags shadow kerning))))
              (let ((v1-91 s0-1)) (set! (-> v1-91 width) (the float 328)))
              (let ((v1-92 s0-1)) (set! (-> v1-92 height) (the float 50)))
              (let ((v1-93 s0-1)) (set! (-> v1-93 scale) 0.7))
              (set! (-> s0-1 flags) (font-flags shadow kerning middle middle-vert large))
              (set! sv-224 print-game-text-scaled)
              (let ((a0-47 (lookup-text! *common-text* (-> s5-0 task-info (-> this task-index) task-name s1-0) #f))
                    (a1-57 f30-0)
                    (a2-15 s0-1)
                    (a3-2 (the int (* 128.0 f30-0))))
                (sv-224 a0-47 a1-57 a2-15 a3-2))
              (when s3-0
                (set! (-> s0-1 origin x) (the float (- (+ s2-0 32) (-> this left-x-offset))))
                (set! (-> s0-1 origin y) (the float (+ (/ s4-1 2) 175)))
                (let ((a0-49 s0-1)) (set! (-> a0-49 color) (font-color progress-blue)))
                (let ((v1-104 s0-1)) (set! (-> v1-104 height) (the float 15)))
                (let ((v1-105 s0-1)) (set! (-> v1-105 scale) 0.5))
                (print-game-text-scaled (lookup-text! *common-text* (text-id task-completed) #f) f30-0 s0-1 (the int (* 128.0 f30-0))))))))))
  0
  (none))

(defmethod draw-money-screen ((this progress) (arg0 int))
  (hide-progress-icons)
  (let* ((v1-1 (/ (-> this transition-offset) 16))
         (s4-0 (if (= (-> this level-transition) 1) (- (-> this transition-offset)) (-> this transition-offset)))
         (f30-0 (-> this transition-percentage-invert))
         (s3-0 (- v1-1)))
    (when (-> this stat-transition)
      (set! v1-1
            (if (!= (-> this display-state) (-> this next-display-state)) (- (-> this transition-offset)) (-> this transition-offset)))
      (set! s3-0 v1-1)
      (set! s4-0 0)
      (set! f30-0 1.0))
    (set! (-> this particles 15 init-pos x) (the float (- (+ v1-1 150) (-> this left-x-offset))))
    (set! (-> this particles 15 init-pos y) (the float (+ s4-0 214)))
    (set! (-> this icons 4 icon-x) (- (+ v1-1 148) (-> this left-x-offset)))
    (set! (-> this icons 4 icon-y) (+ (-> this big-orb-y-offset) s4-0))
    (let ((a0-15 (-> this icons 4 icon 0 root)))
      (set-yaw-angle-clear-roll-pitch! a0-15 (- (y-angle a0-15) (* 182.04445 (* 4.0 (-> *display* time-adjust-ratio))))))
    (let ((s4-1 (new 'stack
                     'font-context
                     *font-default-matrix*
                     (- (+ s3-0 200) (-> this left-x-offset))
                     (+ (/ s4-0 2) 96)
                     8325000.0
                     (font-color default)
                     (font-flags shadow kerning))))
      (let ((v1-19 s4-1)) (set! (-> v1-19 width) (the float 328)))
      (let ((v1-20 s4-1)) (set! (-> v1-20 height) (the float 70)))
      (set! (-> s4-1 flags) (font-flags shadow kerning large))
      (let ((s3-1 print-game-text-scaled))
        (format (clear *temp-string*) "~D/~D" (-> *game-info* money-per-level arg0) (-> *game-counts* data arg0 money-count))
        (s3-1 *temp-string* f30-0 s4-1 (the int (* 128.0 f30-0))))
      (let ((v1-26 s4-1)) (set! (-> v1-26 width) (the float 428)))
      (+! (-> s4-1 origin x) -220.0)
      (+! (-> s4-1 origin y) 40.0)
      (set! (-> s4-1 flags) (font-flags shadow kerning middle large))
      (print-game-text-scaled (lookup-text! *common-text* (text-id total-collected) #f)
                              (* 0.7 f30-0)
                              s4-1
                              (the int (* 128.0 f30-0)))
      (+! (-> s4-1 origin y) 15.0)
      (let ((s5-2 print-game-text-scaled))
        (format (clear *temp-string*) "~D/~D" (the int (-> *game-info* money-total)) (-> this total-nb-of-orbs))
        (s5-2 *temp-string* f30-0 s4-1 (the int (* 128.0 f30-0))))))
  0
  (none))

(defmethod draw-buzzer-screen ((this progress) (arg0 int))
  (hide-progress-icons)
  (let* ((v1-2 (-> *level-task-data* arg0))
         (a0-3 (/ (-> this transition-offset) 16))
         (s4-0 (if (= (-> this level-transition) 1) (- (-> this transition-offset)) (-> this transition-offset)))
         (f30-0 (-> this transition-percentage-invert))
         (s3-0 (- a0-3)))
    (when (-> this stat-transition)
      (set! a0-3
            (if (!= (-> this display-state) (-> this next-display-state)) (- (-> this transition-offset)) (-> this transition-offset)))
      (set! s3-0 a0-3)
      (set! s4-0 0)
      (set! f30-0 1.0))
    (set! (-> this particles 14 init-pos x) (the float (- (+ a0-3 150) (-> this left-x-offset))))
    (set! (-> this particles 14 init-pos y) (the float (+ s4-0 214)))
    (let ((s2-0 0))
      (let ((a1-8 (-> v1-2 buzzer-task-index)))
        (if (!= a1-8 -1) (set! s2-0 (buzzer-count *game-info* (-> v1-2 task-info a1-8 task-id)))))
      (let ((s4-1 (new 'stack
                       'font-context
                       *font-default-matrix*
                       (- (+ s3-0 200) (-> this left-x-offset))
                       (+ (/ s4-0 2) 96)
                       8325000.0
                       (font-color default)
                       (font-flags shadow kerning))))
        (let ((v1-9 s4-1)) (set! (-> v1-9 width) (the float 328)))
        (let ((v1-10 s4-1)) (set! (-> v1-10 height) (the float 70)))
        (set! (-> s4-1 flags) (font-flags shadow kerning large))
        (let ((s3-1 print-game-text-scaled))
          (format (clear *temp-string*) "~D/~D" s2-0 (-> *game-counts* data arg0 buzzer-count))
          (s3-1 *temp-string* f30-0 s4-1 (the int (* 128.0 f30-0))))
        (let ((v1-14 s4-1)) (set! (-> v1-14 width) (the float 428)))
        (+! (-> s4-1 origin x) -220.0)
        (+! (-> s4-1 origin y) 40.0)
        (set! (-> s4-1 flags) (font-flags shadow kerning middle large))
        (print-game-text-scaled (lookup-text! *common-text* (text-id total-collected) #f)
                                (* 0.7 f30-0)
                                s4-1
                                (the int (* 128.0 f30-0)))
        (+! (-> s4-1 origin y) 15.0)
        (let ((s5-2 print-game-text-scaled))
          (format (clear *temp-string*) "~D/~D" (the int (-> *game-info* buzzer-total)) (-> this total-nb-of-buzzers))
          (s5-2 *temp-string* f30-0 s4-1 (the int (* 128.0 f30-0)))))))
  0
  (none))

(defmethod draw-memcard-storage-error ((this progress) (arg0 font-context))
  (let ((v1-0 arg0)) (set! (-> v1-0 scale) 0.55))
  (let ((v1-1 arg0)) (set! (-> v1-1 width) (the float 265)))
  (let ((v1-2 arg0)) (set! (-> v1-2 height) (the float 55)))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (let ((s4-0 (text-id memcard-not-formatted-title)))
    (case (-> this display-state)
      (((progress-screen memcard-no-space)) (set! s4-0 (text-id memcard-no-space)))
      (((progress-screen memcard-not-inserted)) (set! s4-0 (text-id memcard-not-inserted))))
    (let ((s3-0 print-game-text-scaled))
      (format (clear *temp-string*) (lookup-text! *common-text* s4-0 #f) 1)
      (s3-0 *temp-string* (-> this transition-percentage-invert) arg0 128)))
  (set! (-> arg0 origin x) (the float (- 20 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 70.0)
  (let ((v1-12 arg0)) (set! (-> v1-12 width) (the float 350)))
  (let ((v1-13 arg0)) (set! (-> v1-13 height) (the float 40)))
  (let ((s4-1 print-game-text-scaled))
    (format (clear *temp-string*)
            (lookup-text! *common-text* (text-id memcard-space-requirement1) #f)
            (if (-> this card-info) (-> this card-info mem-required) 0))
    (s4-1 *temp-string* (-> this transition-percentage-invert) arg0 128))
  (set! (-> arg0 origin y) 115.0)
  (let ((v1-17 arg0)) (set! (-> v1-17 height) (the float 60)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id memcard-space-requirement2) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (let ((v1-19 arg0)) (set! (-> v1-19 scale) 0.65))
  (set! (-> arg0 origin y) 160.0)
  (print-game-text-scaled (lookup-text! *common-text* (text-id continue?) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  0
  (none))

(defmethod draw-memcard-format ((this progress) (arg0 font-context))
  (set! (-> arg0 origin y) 35.0)
  (let ((v1-0 arg0)) (set! (-> v1-0 scale) 0.55))
  (let ((v1-1 arg0)) (set! (-> v1-1 width) (the float 265)))
  (let ((v1-2 arg0)) (set! (-> v1-2 height) (the float 55)))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (let ((s4-0 print-game-text-scaled))
    (format (clear *temp-string*) (lookup-text! *common-text* (text-id memcard-not-formatted-title) #f) 1)
    (s4-0 *temp-string* (-> this transition-percentage-invert) arg0 128))
  (set! (-> arg0 origin x) (the float (- 20 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 105.0)
  (let ((v1-7 arg0)) (set! (-> v1-7 width) (the float 360)))
  (let ((v1-8 arg0)) (set! (-> v1-8 height) (the float 40)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id memcard-not-formatted-msg) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (let ((v1-10 arg0)) (set! (-> v1-10 scale) 0.65))
  (set! (-> arg0 origin y) 138.0)
  (let ((v1-11 arg0)) (set! (-> v1-11 height) (the float 60)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id format?) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  0
  (none))

(defmethod draw-memcard-data-exists ((this progress) (arg0 font-context))
  (let ((v1-0 arg0)) (set! (-> v1-0 scale) 0.65))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (set! (-> arg0 origin x) (the float (- 20 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 55.0)
  (let ((v1-4 arg0)) (set! (-> v1-4 width) (the float 365)))
  (let ((v1-5 arg0)) (set! (-> v1-5 height) (the float 75)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id save-data-already-exists) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (set! (-> arg0 origin y) 140.0)
  (let ((v1-7 arg0)) (set! (-> v1-7 width) (the float 360)))
  (let ((v1-8 arg0)) (set! (-> v1-8 height) (the float 40)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id overwrite?) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  0
  (none))

(defmethod draw-memcard-no-data ((this progress) (arg0 font-context))
  (let ((v1-0 arg0)) (set! (-> v1-0 scale) 0.65))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (set! (-> arg0 origin x) (the float (- 20 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 40.0)
  (let ((v1-4 arg0)) (set! (-> v1-4 width) (the float 365)))
  (let ((v1-5 arg0)) (set! (-> v1-5 height) (the float 75)))
  (let ((s4-0 print-game-text-scaled))
    (format (clear *temp-string*) (lookup-text! *common-text* (text-id no-save-data) #f) 1)
    (s4-0 *temp-string* (-> this transition-percentage-invert) arg0 128))
  (set! (-> arg0 origin y) 130.0)
  (let ((v1-7 arg0)) (set! (-> v1-7 width) (the float 360)))
  (let ((v1-8 arg0)) (set! (-> v1-8 height) (the float 40)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id create-save-data?) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  0
  (none))

(defmethod draw-memcard-accessing ((this progress) (arg0 font-context))
  (let ((v1-0 arg0)) (set! (-> v1-0 scale) 1.0))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (set! (-> arg0 origin x) (the float (- 20 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 35.0)
  (let ((v1-4 arg0)) (set! (-> v1-4 width) (the float 365)))
  (let ((v1-5 arg0)) (set! (-> v1-5 height) (the float 75)))
  (when (or (< (mod (-> *display* real-frame-counter) 300) 150) (!= (-> this transition-percentage-invert) 1.0))
    (let ((a1-1 (text-id loading-data)))
      (case (-> this display-state)
        (((progress-screen memcard-saving)) (set! a1-1 (text-id saving-data)))
        (((progress-screen memcard-formatting)) (set! a1-1 (text-id formatting)))
        (((progress-screen memcard-creating)) (set! a1-1 (text-id creating-save-data))))
      (print-game-text-scaled (lookup-text! *common-text* a1-1 #f) (-> this transition-percentage-invert) arg0 128)))
  (let ((v1-18 arg0)) (set! (-> v1-18 scale) 0.65))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (set! (-> arg0 origin x) (the float (- 15 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 100.0)
  (let ((v1-22 arg0)) (set! (-> v1-22 width) (the float 370)))
  (let ((v1-23 arg0)) (set! (-> v1-23 height) (the float 75)))
  (let ((s4-1 print-game-text-scaled))
    (format (clear *temp-string*) (lookup-text! *common-text* (text-id memcard-do-not-remove) #f) 1)
    (s4-1 *temp-string* (-> this transition-percentage-invert) arg0 128))
  0
  (none))

(defmethod draw-memcard-insert ((this progress) (arg0 font-context))
  (let ((v1-0 arg0)) (set! (-> v1-0 scale) 0.65))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (set! (-> arg0 origin x) (the float (- 50 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 35.0)
  (let ((v1-4 arg0)) (set! (-> v1-4 width) (the float 310)))
  (let ((v1-5 arg0)) (set! (-> v1-5 height) (the float 110)))
  ;; og:preserve-this PAL patch here
  (let ((v1-6 (-> this card-info)))
    (when (and (= (-> *setting-control* default language) (language-enum japanese)) v1-6 (zero? (-> v1-6 handle)))
      (set! (-> arg0 origin y) -15.0)
      (let ((s4-0 print-game-text-scaled))
        (format (clear *temp-string*) (lookup-text! *common-text* (text-id memcard-not-inserted) #f) 1)
        (s4-0 *temp-string* (-> this transition-percentage-invert) arg0 128))
      (set! (-> arg0 origin y) 53.0)))
  (let ((s4-1 print-game-text-scaled))
    (format (clear *temp-string*) (lookup-text! *common-text* (text-id insert-memcard) #f) 1)
    (s4-1 *temp-string* (-> this transition-percentage-invert) arg0 128))
  (let ((v1-12 arg0)) (set! (-> v1-12 scale) 0.65))
  (set! (-> arg0 origin y) 130.0)
  (let ((v1-13 arg0)) (set! (-> v1-13 height) (the float 60)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id back?) #f) (-> this transition-percentage-invert) arg0 128)
  0
  (none))

(defmethod draw-memcard-file-select ((this progress) (arg0 font-context))
  (local-vars
    (sv-16 (function _varargs_ object))
    (sv-32 (function _varargs_ object))
    (sv-48 (function _varargs_ object))
    (sv-64 (function _varargs_ object))
    (sv-80 (function _varargs_ object))
    (sv-96 (function _varargs_ object))
    (sv-112 (function _varargs_ object))
    (sv-128 (function _varargs_ object))
    (sv-144 (function _varargs_ object)))
  (let ((s4-0 (* (+ (-> this transition-offset) -256) 2)))
    (if (< s4-0 0) (set! s4-0 0))
    (if (< 500 s4-0) (set! s4-0 700))
    (set! (-> this particles 19 init-pos x) (the float (- (- 202 (adjust-pos s4-0 150)) (-> this left-x-offset))))
    (set! (-> this particles 20 init-pos x) (the float (- (+ (adjust-pos s4-0 100) 202) (-> this left-x-offset))))
    (set! (-> this particles 21 init-pos x) (the float (- (- 202 (adjust-pos s4-0 50)) (-> this left-x-offset))))
    (set! (-> this particles 22 init-pos x) (the float (- (+ s4-0 202) (-> this left-x-offset)))))
  (cond
    ((= (-> *setting-control* current video-mode) 'pal)
     (set! (-> this particles 21 init-pos y) 256.0)
     (set! (-> this particles 22 init-pos y) 338.0))
    (else (set! (-> this particles 21 init-pos y) 255.0) (set! (-> this particles 22 init-pos y) 336.0)))
  (let ((f0-13 (* 2.0 (+ -0.5 (-> this transition-percentage-invert)))))
    128
    (if (< f0-13 0.0) (set! f0-13 0.0))
    (let ((s4-1 (the int (* 128.0 f0-13))))
      (let ((v1-29 arg0)) (set! (-> v1-29 scale) 0.5))
      (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
      (set! (-> arg0 origin x) (the float (- 102 (-> this left-x-offset))))
      (set! (-> arg0 origin y) 5.0)
      (let ((v1-33 arg0)) (set! (-> v1-33 width) (the float 200)))
      (let ((v1-34 arg0)) (set! (-> v1-34 height) (the float 20)))
      (print-game-text (lookup-text! *common-text*
                                     (if (= (-> this display-state) (progress-screen load-game)) (text-id select-file-to-load) (text-id select-file-to-save))
                                     #f)
                       arg0
                       #f
                       s4-1
                       22)
      (set! (-> arg0 origin y) 26.0)
      (let ((v1-37 arg0)) (set! (-> v1-37 height) (the float 20)))
      (let ((s3-3 (-> this card-info))
            (s2-0 23))
        (dotimes (s1-0 4)
          (set! (-> arg0 origin x) (the float (- 41 (-> this left-x-offset))))
          (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
          (let ((a0-17 arg0)) (set! (-> a0-17 color) (font-color default)))
          (let ((v1-42 arg0)) (set! (-> v1-42 width) (the float 320)))
          (cond
            ((and s3-3 (= (-> s3-3 formatted) 1) (= (-> s3-3 inited) 1) (= (-> s3-3 file s1-0 present) 1))
             (set! (-> this particles s2-0 init-pos x) (the float (- 66 (-> this left-x-offset))))
             (let ((v1-57 arg0)) (set! (-> v1-57 scale) 0.6))
             (if (and (< (-> s3-3 file s1-0 level-index) (length *level-task-data-remap*)) (> (-> s3-3 file s1-0 level-index) 0))
               (print-game-text (lookup-text! *common-text*
                                              (-> *level-task-data* (-> *level-task-data-remap* (+ (-> s3-3 file s1-0 level-index) -1)) level-name-id)
                                              #f)
                                arg0
                                #f
                                s4-1
                                22)
               (print-game-text "OLD SAVE GAME" arg0 #f s4-1 22))
             (let ((a0-28 arg0)) (set! (-> a0-28 color) (font-color progress-memcard)))
             (cond
               ((or (>= (seconds 2) (- (-> *display* real-frame-counter) (-> this last-option-index-change)))
                    (or (< (mod (- (-> *display* real-frame-counter) (-> this last-option-index-change)) 1200) 600)
                        (!= (-> this option-index) s1-0)
                        (-> this in-transition)))
                (let ((v1-87 arg0)) (set! (-> v1-87 scale) 0.5))
                (+! (-> arg0 origin y) 16.0)
                (set! (-> arg0 flags) (font-flags shadow kerning middle large))
                (set! (-> arg0 origin x) (the float (- -73 (-> this left-x-offset))))
                (let ((v1-91 arg0)) (set! (-> v1-91 width) (the float 350)))
                (let ((s0-2 print-game-text))
                  (set! sv-16 format)
                  (let ((a0-40 (clear *temp-string*))
                        (a1-13 "~D")
                        (a2-5 (the int (-> s3-3 file s1-0 fuel-cell-count))))
                    (sv-16 a0-40 a1-13 a2-5))
                  (s0-2 *temp-string* arg0 #f s4-1 22))
                (set! (-> arg0 origin x) (the float (- 1 (-> this left-x-offset))))
                (let ((s0-3 print-game-text))
                  (set! sv-32 format)
                  (let ((a0-44 (clear *temp-string*))
                        (a1-15 "~D")
                        (a2-7 (the int (-> s3-3 file s1-0 money-count))))
                    (sv-32 a0-44 a1-15 a2-7))
                  (s0-3 *temp-string* arg0 #f s4-1 22))
                (set! (-> arg0 origin x) (the float (- 79 (-> this left-x-offset))))
                (let ((s0-4 print-game-text))
                  (set! sv-48 format)
                  (let ((a0-48 (clear *temp-string*))
                        (a1-17 "~D")
                        (a2-9 (the int (-> s3-3 file s1-0 buzzer-count))))
                    (sv-48 a0-48 a1-17 a2-9))
                  (s0-4 *temp-string* arg0 #f s4-1 22))
                (+! (-> arg0 origin y) 1.0)
                (let ((v1-108 arg0)) (set! (-> v1-108 scale) 1.0))
                (set! (-> arg0 flags) (font-flags shadow kerning right large))
                (set! (-> arg0 origin x) (the float (- 352 (-> this left-x-offset))))
                (let ((s0-5 print-game-text))
                  (set! sv-64 format)
                  (let ((a0-52 (clear *temp-string*))
                        (a1-19 "~D%")
                        (a2-11 (the int (-> s3-3 file s1-0 completion-percentage))))
                    (sv-64 a0-52 a1-19 a2-11))
                  (s0-5 *temp-string* arg0 #f s4-1 22))
                (let ((v1-116 arg0)) (set! (-> v1-116 scale) 0.5))
                (+! (-> arg0 origin y) 9.0)
                (set! (-> arg0 flags) (font-flags shadow kerning large))
                (set! (-> arg0 origin x) (the float (- 85 (-> this left-x-offset))))
                (let ((s0-6 print-game-text))
                  (set! sv-80 format)
                  (let ((a0-56 (clear *temp-string*))
                        (a1-21 "/~D")
                        (a2-17 (if (< 100 (the int (-> s3-3 file s1-0 fuel-cell-count))) (-> this total-nb-of-power-cells) 100)))
                    (sv-80 a0-56 a1-21 a2-17))
                  (s0-6 *temp-string* arg0 #f s4-1 22))
                (set! (-> arg0 origin x) (the float (- 150 (-> this left-x-offset))))
                (let ((s0-7 print-game-text))
                  (set! sv-96 format)
                  (let ((a0-60 (clear *temp-string*))
                        (a1-23 "/~D")
                        (a2-19 (-> this total-nb-of-orbs)))
                    (sv-96 a0-60 a1-23 a2-19))
                  (s0-7 *temp-string* arg0 #f s4-1 22))
                (set! (-> arg0 origin x) (the float (- 238 (-> this left-x-offset))))
                (let ((s0-8 print-game-text))
                  (set! sv-112 format)
                  (let ((a0-64 (clear *temp-string*))
                        (a1-25 "/~D")
                        (a2-21 (-> this total-nb-of-buzzers)))
                    (sv-112 a0-64 a1-25 a2-21))
                  (s0-8 *temp-string* arg0 #f s4-1 22))
                (+! (-> arg0 origin y) 15.0))
               (else
                (+! (-> arg0 origin y) 18.0)
                (set! (-> arg0 origin x) (the float (- 28 (-> this left-x-offset))))
                (let ((v1-131 arg0)) (set! (-> v1-131 scale) 0.8))
                (set! (-> arg0 flags) (font-flags shadow kerning middle large))
                (let ((v1-133 arg0)) (set! (-> v1-133 width) (the float 350)))
                ;; og:preserve-this pc port stuff here, added YMD
                (case (scf-get-territory)
                  ((GAME_TERRITORY_SCEA)
                   (print-game-text (string-format "~X/~X/20~2X   ~2X:~2X"
                                                   (-> s3-3 file s1-0 month)
                                                   (-> s3-3 file s1-0 day)
                                                   (-> s3-3 file s1-0 year)
                                                   (-> s3-3 file s1-0 hour)
                                                   (-> s3-3 file s1-0 minute))
                                    arg0
                                    #f
                                    s4-1
                                    22))
                  ((GAME_TERRITORY_SCEI)
                   (print-game-text (string-format "20~2X/~X/~X   ~2X:~2X"
                                                   (-> s3-3 file s1-0 year)
                                                   (-> s3-3 file s1-0 month)
                                                   (-> s3-3 file s1-0 day)
                                                   (-> s3-3 file s1-0 hour)
                                                   (-> s3-3 file s1-0 minute))
                                    arg0
                                    #f
                                    s4-1
                                    22))
                  (else
                   (print-game-text (string-format "~X/~X/20~2X   ~2X:~2X"
                                                   (-> s3-3 file s1-0 day)
                                                   (-> s3-3 file s1-0 month)
                                                   (-> s3-3 file s1-0 year)
                                                   (-> s3-3 file s1-0 hour)
                                                   (-> s3-3 file s1-0 minute))
                                    arg0
                                    #f
                                    s4-1
                                    22)))
                (set! (-> this particles s2-0 init-pos x) -320.0)
                (+! (-> arg0 origin y) 23.0))))
            (else
             (set! (-> this particles s2-0 init-pos x) -320.0)
             (+! (-> arg0 origin y) 12.0)
             (let ((v1-173 arg0)) (set! (-> v1-173 scale) 0.7))
             (print-game-text (lookup-text! *common-text* (text-id empty) #f) arg0 #f s4-1 22)
             (+! (-> arg0 origin y) 29.0)))
          (+! s2-0 1)))))
  0
  (none))

(defmethod draw-memcard-auto-save-error ((this progress) (arg0 font-context))
  (let ((v1-0 arg0)) (set! (-> v1-0 scale) 0.6))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (set! (-> arg0 origin x) (the float (- 70 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 5.0)
  (let ((v1-4 arg0)) (set! (-> v1-4 width) (the float 265)))
  (let ((v1-5 arg0)) (set! (-> v1-5 height) (the float 35)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id error-saving) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (set! (-> arg0 origin x) (the float (- 20 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 34.0)
  (let ((v1-9 arg0)) (set! (-> v1-9 width) (the float 360)))
  (let ((v1-10 arg0)) (set! (-> v1-10 height) (the float 50)))
  (let ((s4-1 print-game-text-scaled))
    (format (clear *temp-string*) (lookup-text! *common-text* (text-id check-memcard) #f) 1)
    (s4-1 *temp-string* (-> this transition-percentage-invert) arg0 128))
  (set! (-> arg0 origin y) 89.0)
  (let ((v1-12 arg0)) (set! (-> v1-12 width) (the float 360)))
  (let ((v1-13 arg0)) (set! (-> v1-13 height) (the float 20)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id autosave-disabled-title) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (set! (-> arg0 origin y) 118.0)
  (let ((v1-15 arg0)) (set! (-> v1-15 width) (the float 360)))
  (let ((v1-16 arg0)) (set! (-> v1-16 height) (the float 60)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id autosave-disabled-msg) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (let ((v1-18 arg0)) (set! (-> v1-18 scale) 0.65))
  (set! (-> arg0 origin y) 160.0)
  (let ((v1-19 arg0)) (set! (-> v1-19 height) (the float 60)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id continue?) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  0
  (none))

(defmethod draw-memcard-removed ((this progress) (arg0 font-context))
  (let ((v1-0 arg0)) (set! (-> v1-0 scale) 0.6))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (set! (-> arg0 origin x) (the float (- 70 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 10.0)
  (let ((v1-4 arg0)) (set! (-> v1-4 width) (the float 265)))
  (let ((v1-5 arg0)) (set! (-> v1-5 height) (the float 55)))
  (let ((s4-0 print-game-text-scaled))
    (format (clear *temp-string*) (lookup-text! *common-text* (text-id memcard-removed) #f) 1)
    (s4-0 *temp-string* (-> this transition-percentage-invert) arg0 128))
  (set! (-> arg0 origin x) (the float (- 20 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 78.0)
  (let ((v1-9 arg0)) (set! (-> v1-9 width) (the float 360)))
  (let ((v1-10 arg0)) (set! (-> v1-10 height) (the float 20)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id autosave-disabled-title) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (set! (-> arg0 origin y) 112.0)
  (let ((v1-12 arg0)) (set! (-> v1-12 width) (the float 360)))
  (let ((v1-13 arg0)) (set! (-> v1-13 height) (the float 60)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id autosave-disabled-msg) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (let ((v1-15 arg0)) (set! (-> v1-15 scale) 0.65))
  (set! (-> arg0 origin y) 160.0)
  (let ((v1-16 arg0)) (set! (-> v1-16 height) (the float 60)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id continue?) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  0
  (none))

(defmethod draw-memcard-error ((this progress) (arg0 font-context))
  (set! (-> arg0 origin y) 15.0)
  (let ((v1-0 arg0)) (set! (-> v1-0 scale) 0.7))
  (let ((v1-1 arg0)) (set! (-> v1-1 width) (the float 265)))
  (let ((v1-2 arg0)) (set! (-> v1-2 height) (the float 55)))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (let ((s4-0 (text-id error-loading)))
    (case (-> this display-state)
      (((progress-screen memcard-error-saving)) (set! s4-0 (text-id error-saving)))
      (((progress-screen memcard-error-formatting)) (set! s4-0 (text-id error-formatting)))
      (((progress-screen memcard-error-creating)) (set! s4-0 (text-id error-creating-data))))
    (let ((s3-0 print-game-text-scaled))
      (format (clear *temp-string*) (lookup-text! *common-text* s4-0 #f) 1)
      (s3-0 *temp-string* (-> this transition-percentage-invert) arg0 128)))
  (set! (-> arg0 origin x) (the float (- 20 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 80.0)
  (let ((v1-13 arg0)) (set! (-> v1-13 width) (the float 360)))
  (let ((v1-14 arg0)) (set! (-> v1-14 height) (the float 70)))
  (let ((s4-1 print-game-text-scaled))
    (format (clear *temp-string*) (lookup-text! *common-text* (text-id check-memcard-and-retry) #f) 1)
    (s4-1 *temp-string* (-> this transition-percentage-invert) arg0 128))
  (let ((v1-16 arg0)) (set! (-> v1-16 scale) 0.65))
  (set! (-> arg0 origin y) 155.0)
  (let ((v1-17 arg0)) (set! (-> v1-17 height) (the float 60)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id continue?) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  0
  (none))

(defmethod draw-auto-save ((this progress) (arg0 font-context))
  (set! (-> arg0 origin x) (the float (- 35 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 18.0)
  (let ((v1-2 arg0)) (set! (-> v1-2 scale) 0.6))
  (let ((v1-3 arg0)) (set! (-> v1-3 width) (the float 330)))
  (let ((v1-4 arg0)) (set! (-> v1-4 height) (the float 60)))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (print-game-text-scaled (lookup-text! *common-text* (text-id autosave-warn-title) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (set! (-> arg0 origin x) (the float (- 15 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 110.0)
  (let ((v1-9 arg0)) (set! (-> v1-9 width) (the float 370)))
  (let ((v1-10 arg0)) (set! (-> v1-10 height) (the float 60)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id autosave-warn-msg) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (let ((v1-12 arg0)) (set! (-> v1-12 scale) 0.65))
  (set! (-> arg0 origin y) 175.0)
  (let ((v1-13 arg0)) (set! (-> v1-13 height) (the float 20)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id continue?) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (set! (-> *progress-process* 0 particles 31 init-pos y) (the float (if (= (get-aspect-ratio) 'aspect16x9) 170 180)))
  (set! (-> *progress-process* 0 particles 31 init-pos x)
        (the float
             (- (if (or (< (mod (-> *display* real-frame-counter) 300) 270) (!= (-> this transition-percentage-invert) 1.0)) 205 -320)
                (-> this left-x-offset))))
  0
  (none))

(defmethod draw-pal-change-to-60hz ((this progress) (arg0 font-context))
  (set! (-> arg0 origin x) (the float (- 50 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 20.0)
  (let ((v1-2 arg0)) (set! (-> v1-2 scale) 0.6))
  (let ((v1-3 arg0)) (set! (-> v1-3 width) (the float 300)))
  (let ((v1-4 arg0)) (set! (-> v1-4 height) (the float 40)))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (print-game-text-scaled (lookup-text! *common-text* (text-id screen-change-to-60hz) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (set! (-> arg0 origin x) (the float (- 15 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 60.0)
  (let ((v1-9 arg0)) (set! (-> v1-9 width) (the float 370)))
  (let ((v1-10 arg0)) (set! (-> v1-10 height) (the float 60)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id screen-60hz-warn-support) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (set! (-> arg0 origin y) 120.0)
  (let ((v1-12 arg0)) (set! (-> v1-12 height) (the float 50)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id screen-60hz-warn-timer) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (let ((v1-14 arg0)) (set! (-> v1-14 scale) 0.65))
  (set! (-> arg0 origin y) 175.0)
  (let ((v1-15 arg0)) (set! (-> v1-15 height) (the float 20)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id continue?) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  0
  (none))

(defmethod draw-no-disc ((this progress) (arg0 font-context))
  (set! (-> arg0 origin x) (the float (- 50 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 50.0)
  (let ((v1-2 arg0)) (set! (-> v1-2 scale) 0.6))
  (let ((v1-3 arg0)) (set! (-> v1-3 width) (the float 300)))
  (let ((v1-4 arg0)) (set! (-> v1-4 height) (the float 40)))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (print-game-text-scaled (lookup-text! *common-text* (text-id no-disc-title) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (set! (-> arg0 origin x) (the float (- 20 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 90.0)
  (let ((v1-9 arg0)) (set! (-> v1-9 width) (the float 360)))
  (let ((v1-10 arg0)) (set! (-> v1-10 height) (the float 60)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id no-disc-msg) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (when (is-cd-in?)
    (let ((v1-13 arg0)) (set! (-> v1-13 scale) 0.65))
    (set! (-> arg0 origin y) 155.0)
    (let ((v1-14 arg0)) (set! (-> v1-14 height) (the float 20)))
    (print-game-text-scaled (lookup-text! *common-text* (text-id continue?) #f)
                            (-> this transition-percentage-invert)
                            arg0
                            128))
  0
  (none))

(defmethod draw-bad-disc ((this progress) (arg0 font-context))
  (set! (-> arg0 origin x) (the float (- 50 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 50.0)
  (let ((v1-2 arg0)) (set! (-> v1-2 scale) 0.6))
  (let ((v1-3 arg0)) (set! (-> v1-3 width) (the float 300)))
  (let ((v1-4 arg0)) (set! (-> v1-4 height) (the float 40)))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (print-game-text-scaled (lookup-text! *common-text* (text-id bad-disc-title) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (set! (-> arg0 origin x) (the float (- 20 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 90.0)
  (let ((v1-9 arg0)) (set! (-> v1-9 width) (the float 360)))
  (let ((v1-10 arg0)) (set! (-> v1-10 height) (the float 60)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id bad-disc-msg) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (let ((v1-12 arg0)) (set! (-> v1-12 scale) 0.65))
  (set! (-> arg0 origin y) 155.0)
  (let ((v1-13 arg0)) (set! (-> v1-13 height) (the float 20)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id continue?) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  0
  (none))

(defmethod draw-quit ((this progress) (arg0 font-context))
  (set! (-> arg0 origin x) (the float (- 50 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 70.0)
  (let ((v1-2 arg0)) (set! (-> v1-2 scale) 0.6))
  (let ((v1-3 arg0)) (set! (-> v1-3 width) (the float 300)))
  (let ((v1-4 arg0)) (set! (-> v1-4 height) (the float 40)))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (print-game-text-scaled (lookup-text! *common-text* (text-id quit?) #f) (-> this transition-percentage-invert) arg0 128)
  0
  (none))

(defmethod draw-pal-now-60hz ((this progress) (arg0 font-context))
  (set! (-> arg0 origin x) (the float (- 50 (-> this left-x-offset))))
  (set! (-> arg0 origin y) 45.0)
  (let ((v1-2 arg0)) (set! (-> v1-2 scale) 0.6))
  (let ((v1-3 arg0)) (set! (-> v1-3 width) (the float 300)))
  (let ((v1-4 arg0)) (set! (-> v1-4 height) (the float 50)))
  (set! (-> arg0 flags) (font-flags shadow kerning middle middle-vert large))
  (print-game-text-scaled (lookup-text! *common-text* (text-id screen-now-60hz) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  (set! (-> arg0 origin y) 95.0)
  (let ((v1-7 arg0)) (set! (-> v1-7 height) (the float 50)))
  (print-game-text-scaled (lookup-text! *common-text* (text-id screen-60hz-keep?) #f)
                          (-> this transition-percentage-invert)
                          arg0
                          128)
  0
  (none))

(defmethod draw-notice-screen ((this progress))
  (hide-progress-icons)
  (when *common-text*
    (let ((a1-1 (new 'stack
                     'font-context
                     *font-default-matrix*
                     (- 70 (-> this left-x-offset))
                     10
                     0.0
                     (font-color default)
                     (font-flags shadow kerning))))
      (case (-> this display-state)
        (((progress-screen memcard-format)) (draw-memcard-format this a1-1))
        (((progress-screen memcard-no-space) (progress-screen memcard-not-inserted) (progress-screen memcard-not-formatted))
         (draw-memcard-storage-error this a1-1))
        (((progress-screen memcard-data-exists)) (draw-memcard-data-exists this a1-1))
        (((progress-screen memcard-no-data)) (draw-memcard-no-data this a1-1))
        (((progress-screen memcard-loading)
          (progress-screen memcard-saving)
          (progress-screen memcard-formatting)
          (progress-screen memcard-creating))
         (draw-memcard-accessing this a1-1))
        (((progress-screen memcard-insert)) (draw-memcard-insert this a1-1))
        (((progress-screen load-game) (progress-screen save-game) (progress-screen save-game-title))
         (draw-memcard-file-select this a1-1))
        (((progress-screen memcard-auto-save-error)) (draw-memcard-auto-save-error this a1-1))
        (((progress-screen memcard-removed)) (draw-memcard-removed this a1-1))
        (((progress-screen memcard-error-loading)
          (progress-screen memcard-error-saving)
          (progress-screen memcard-error-formatting)
          (progress-screen memcard-error-creating))
         (draw-memcard-error this a1-1))
        (((progress-screen auto-save)) (draw-auto-save this a1-1))
        (((progress-screen pal-change-to-60hz)) (draw-pal-change-to-60hz this a1-1))
        (((progress-screen pal-now-60hz)) (draw-pal-now-60hz this a1-1))
        (((progress-screen no-disc)) (draw-no-disc this a1-1))
        (((progress-screen bad-disc)) (draw-bad-disc this a1-1))
        (((progress-screen quit)) (draw-quit this a1-1)))))
  0
  (none))

(defun draw-percent-bar ((arg0 int) (arg1 int) (arg2 float) (arg3 rgba))
  (with-dma-buffer-add-bucket ((s2-0 (-> (current-frame) global-buf)) (bucket-id sprite))
    (draw-sprite2d-xy s2-0 arg0 arg1 255 14 (new 'static 'rgba :a #x60))
    (draw-sprite2d-xy s2-0 arg0 (+ arg1 2) (the int (* 255.0 arg2)) 10 arg3))
  0
  (none))

(defun print-language-name ((arg0 int) (arg1 font-context) (arg2 int) (arg3 symbol))
  (let ((s5-0 (if arg3 arg2 (- arg2))))
    (+! (-> arg1 origin x) (the float s5-0))
    (let ((f30-0 (- 1.0 (* 0.0033333334 (the float arg2)))))
      (print-game-text-scaled (lookup-text! *common-text* (-> *language-name-remap* arg0) #f)
                              f30-0
                              arg1
                              (the int (* 128.0 f30-0))))
    (set! (-> arg1 origin x) (- (-> arg1 origin x) (the float s5-0))))
  (set! (-> arg1 color) (font-color default))
  arg1)

(defmethod draw-options ((this progress) (arg0 int) (arg1 int) (arg2 float))
  (let ((s3-0 (-> *options-remap* (-> this display-state))))
    (when s3-0
      (let ((s2-1 (- arg0 (/ (* arg1 (length s3-0)) 2)))
            (s1-0 0)
            (unkx 27)
            (unk2 0)
            (font (new 'stack 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (font-flags shadow kerning))))
        (set-width! font 350)
        (set-height! font 25)
        (set! (-> font flags) (font-flags shadow kerning middle middle-vert large))
        (dotimes (s0-0 (length s3-0))
          (let ((option-str (the string #f))
                (x-off 27)
                (y-off s2-1))
            (let ((v1-18 (-> s3-0 s0-0 option-type)))
              (cond
                ((= v1-18 (game-option-type yes-no))
                 (if (-> (the-as (pointer uint32) (-> s3-0 s0-0 value-to-modify)))
                   (set! option-str
                         (string-format "~30L~S~0L ~S"
                                        (lookup-text! *common-text* (text-id yes) #f)
                                        (lookup-text! *common-text* (text-id no) #f)))
                   (set! option-str
                         (string-format "~0L~S ~30L~S~1L"
                                        (lookup-text! *common-text* (text-id yes) #f)
                                        (lookup-text! *common-text* (text-id no) #f)))))
                ((or (= v1-18 (game-option-type menu)) (= v1-18 (game-option-type button)))
                 (cond
                   ((nonzero? (-> s3-0 s0-0 name)) (set! option-str (lookup-text! *common-text* (-> s3-0 s0-0 name) #f)))
                   (else (set! option-str (the-as string #f)))))
                ((and (-> this selected-option) (= (-> this option-index) s0-0))
                 (set-color! font (font-color default))
                 (set! (-> font origin x) (the float (- x-off (-> this left-x-offset))))
                 (case (-> s3-0 s0-0 option-type)
                   (((game-option-type center-screen)) (set! (-> font origin y) (the float (+ s2-1 -20))))
                   (else (set! (-> font origin y) (the float (+ s2-1 -8)))))
                 (set-scale! font 0.6)
                 (print-game-text (lookup-text! *common-text* (-> s3-0 s0-0 name) #f) font #f 128 22)
                 (case (-> s3-0 s0-0 option-type)
                   (((game-option-type center-screen)) (set! y-off (+ s2-1 3)))
                   (else (set! y-off (+ s2-1 7))))
                 (case (-> s3-0 s0-0 option-type)
                   (((game-option-type slider))
                    (let* ((v1-82 (the-as uint #x8000ffff))
                           (f0-12 (* 0.01 (-> (the-as (pointer float) (-> s3-0 s0-0 value-to-modify)))))
                           (a0-34 (logior (logand v1-82 -256) (shr (shl (the int (+ 64.0 (* 191.0 f0-12))) 56) 56)))
                           (a3-5 (logior (logand a0-34 -65281) (shr (shl (shr (shl a0-34 56) 56) 56) 48))))
                      (draw-percent-bar (- 75 (-> this left-x-offset)) (+ s2-1 8) f0-12 (the-as rgba a3-5)))
                    (set! option-str (string-format "~D" (the int (-> (the-as (pointer float) (-> s3-0 s0-0 value-to-modify))))))
                    (set! x-off (+ (the int (* 2.5 (-> (the-as (pointer float) (-> s3-0 s0-0 value-to-modify))))) -100))
                    x-off)
                   (((game-option-type on-off))
                    (if (-> (the-as (pointer uint32) (-> s3-0 s0-0 value-to-modify)))
                      (set! option-str
                            (string-format "~30L~S~0L ~S"
                                           (lookup-text! *common-text* (text-id on) #f)
                                           (lookup-text! *common-text* (text-id off) #f)))
                      (set! option-str
                            (string-format "~0L~S ~30L~S~1L"
                                           (lookup-text! *common-text* (text-id on) #f)
                                           (lookup-text! *common-text* (text-id off) #f)))))
                   (((game-option-type language))
                    (let ((old-lang (-> this language-selection))
                          (new-lang (-> (the-as (pointer language-enum) (-> s3-0 s0-0 value-to-modify))))
                          (max-lang (if (and (= (scf-get-territory) GAME_TERRITORY_SCEA)
                                             (not (and (= *progress-cheat* 'language) (cpad-hold? 0 l2) (cpad-hold? 0 r2))))
                                      5
                                      6)))
                      (if (-> this language-transition)
                        (seekl! (-> this language-x-offset) 200 (the int (* 10.0 (-> *display* time-adjust-ratio)))))
                      (when (>= (-> this language-x-offset) 100)
                        (set! (-> this language-selection) new-lang)
                        (set! old-lang new-lang)
                        (set! (-> this language-transition) #f)
                        (set! (-> this language-x-offset) 0))
                      (set! (-> font origin y) (the float (+ s2-1 3)))
                      (set-color! font (font-color progress-blue))
                      0
                      (let ((next-lang (mod (+ old-lang 1) max-lang))
                            (a0-66 (mod (+ max-lang -1 old-lang) max-lang))
                            (v1-153 (mod (+ old-lang 2) max-lang))
                            (prev-lang (mod (+ max-lang -2 old-lang) max-lang)))
                        (cond
                          ((-> this language-direction)
                           (let ((a2-22 (- 200 (+ (-> this language-x-offset) 100)))) (print-language-name a0-66 font a2-22 #f))
                           (let ((a2-23 (+ (-> this language-x-offset) 100)))
                             (cond
                               ((< a2-23 150) (print-language-name (the int next-lang) font a2-23 #t))
                               (else (let ((a2-24 (- 200 (-> this language-x-offset)))) (print-language-name prev-lang font a2-24 #f))))))
                          (else
                           (let ((a2-25 (+ (-> this language-x-offset) 100)))
                             (cond
                               ((< a2-25 150) (print-language-name a0-66 font a2-25 #f))
                               (else (let ((a2-26 (- 200 (-> this language-x-offset)))) (print-language-name (the int v1-153) font a2-26 #t)))))
                           (let ((a2-27 (- 200 (+ (-> this language-x-offset) 100)))) (print-language-name (the int next-lang) font a2-27 #t)))))
                      (if (not (-> this language-transition)) (set-color! font (font-color progress-selected)))
                      (print-language-name (the-as int old-lang) font (-> this language-x-offset) (-> this language-direction))))
                   (((game-option-type center-screen)) (set! option-str (lookup-text! *common-text* (text-id move-dpad) #f)))
                   (((game-option-type aspect-ratio))
                    (if (= (-> (the-as (pointer uint32) (-> s3-0 s0-0 value-to-modify))) 'aspect4x3)
                      (set! option-str
                            (string-format "~30L~S~0L ~S"
                                           (lookup-text! *common-text* (text-id 4x3) #f)
                                           (lookup-text! *common-text* (text-id 16x9) #f)))
                      (set! option-str
                            (string-format "~0L~S ~30L~S~1L"
                                           (lookup-text! *common-text* (text-id 4x3) #f)
                                           (lookup-text! *common-text* (text-id 16x9) #f)))))
                   (((game-option-type video-mode))
                    (if (= (-> (the-as (pointer uint32) (-> s3-0 s0-0 value-to-modify))) 'ntsc)
                      (set! option-str
                            (string-format "~0L~S ~30L~S~1L"
                                           (lookup-text! *common-text* (text-id 50hz) #f)
                                           (lookup-text! *common-text* (text-id 60hz) #f)))
                      (set! option-str
                            (string-format "~30L~S~0L ~S"
                                           (lookup-text! *common-text* (text-id 50hz) #f)
                                           (lookup-text! *common-text* (text-id 60hz) #f)))))))
                (else
                 (case (-> s3-0 s0-0 option-type)
                   (((game-option-type slider)
                     (game-option-type center-screen)
                     (game-option-type aspect-ratio)
                     (game-option-type video-mode))
                    (set! option-str (lookup-text! *common-text* (-> s3-0 s0-0 name) #f)))
                   (((game-option-type on-off))
                    (set! option-str
                          (string-format "~S: ~S"
                                         (lookup-text! *common-text* (-> s3-0 s0-0 name) #f)
                                         (if (-> (the-as (pointer uint32) (-> s3-0 s0-0 value-to-modify)))
                                           (lookup-text! *common-text* (text-id on) #f)
                                           (lookup-text! *common-text* (text-id off) #f)))))
                   (((game-option-type language))
                    (set! option-str
                          (string-format "~S: ~S"
                                         (lookup-text! *common-text* (-> s3-0 s0-0 name) #f)
                                         (lookup-text! *common-text* (-> *language-name-remap* (-> (the-as (pointer uint64) (-> s3-0 s0-0 value-to-modify)))) #f))))))))
            (when option-str
              (let ((f0-23 (-> this transition-percentage-invert)))
                (set-color! font
                            (if (and (= s0-0 (-> this option-index)) (not (-> this in-transition))) (font-color progress-selected) (font-color default)))
                (set! (-> font origin x) (the float (- x-off (-> this left-x-offset))))
                (set! (-> font origin y) (the float (the int (* (the float y-off) (if (-> s3-0 s0-0 scale) f0-23 1.0)))))
                (set-scale! font (* arg2 f0-23))
                (print-game-text option-str font #f (the int (* 128.0 f0-23)) 22)))
            (+! s2-1 arg1)
            (+! s1-0 1))))))
  0
  (none))

(defmethod draw-progress ((this progress))
  (let ((f30-0 (+ -409.0 (-> this particles 2 init-pos x) (* 0.8 (the float (-> this left-x-offset)))))
        (s5-0 (if (or (-> this stat-transition) (nonzero? (-> this level-transition))) 0 (-> this transition-offset))))
    (let ((f28-0 (if (or (-> this stat-transition) (nonzero? (-> this level-transition))) 1.0 (-> this transition-percentage-invert))))
      (let* ((s3-0 (-> *display* frames (-> *display* on-screen) frame global-buf))
             (s4-0 (-> s3-0 base)))
        (let ((s2-0 draw-string-xy))
          (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* game money))))
          (s2-0 *temp-string*
                s3-0
                (the int (+ 428.0 (the float s5-0) f30-0))
                (- 12 (the int (/ f30-0 6)))
                (font-color default)
                (font-flags shadow kerning large)))
        (let ((s2-1 draw-string-xy))
          (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* game fuel))))
          (s2-1 *temp-string*
                s3-0
                (the int (+ 456.0 (the float (adjust-pos s5-0 50)) f30-0))
                (- 48 (the int (/ f30-0 8)))
                (font-color default)
                (font-flags shadow kerning large)))
        (let ((s2-2 draw-string-xy))
          (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* fact buzzer))))
          (s2-2 *temp-string*
                s3-0
                (the int (+ 469.0 (the float (adjust-pos s5-0 100)) f30-0))
                89
                (font-color default)
                (font-flags shadow kerning large)))
        (let ((a3-4 (-> s3-0 base)))
          (let ((v1-20 (the-as object (-> s3-0 base))))
            (set! (-> (the-as dma-packet v1-20) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
            (set! (-> (the-as dma-packet v1-20) vif0) (new 'static 'vif-tag))
            (set! (-> (the-as dma-packet v1-20) vif1) (new 'static 'vif-tag))
            (set! (-> s3-0 base) (&+ (the-as pointer v1-20) 16)))
          (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group)
                                 (bucket-id debug)
                                 s4-0
                                 (the-as (pointer dma-tag) a3-4))))
      (let ((s4-2 (new 'stack
                       'font-context
                       *font-default-matrix*
                       (the int (+ (- 423.0 (the float (/ (-> this left-x-offset) 2))) f30-0 (the float (adjust-pos s5-0 150))))
                       131
                       0.0
                       (font-color default)
                       (font-flags shadow kerning))))
        (let ((v1-29 s4-2)) (set! (-> v1-29 width) (the float 100)))
        (let ((v1-30 s4-2)) (set! (-> v1-30 height) (the float 15)))
        (let ((v1-31 s4-2)) (set! (-> v1-31 scale) 0.5))
        (set! (-> s4-2 flags) (font-flags shadow kerning large))
        (print-game-text (lookup-text! *common-text* (text-id options) #f) s4-2 #f 128 22)
        (let ((v1-34 s4-2)) (set! (-> v1-34 width) (the float 160)))
        (let ((v1-35 s4-2)) (set! (-> v1-35 height) (the float 22)))
        (let ((v1-36 s4-2)) (set! (-> v1-36 scale) 1.3))
        (let ((a0-31 s4-2)) (set! (-> a0-31 color) (font-color progress-percent)))
        (set! (-> s4-2 origin x)
              (+ (- 435.0 (the float (if (< (-> *progress-process* 0 completion-percentage) 10.0) 93 80))) f30-0))
        (set! (-> s4-2 origin y) 180.0)
        (set! (-> s4-2 flags) (font-flags shadow kerning middle middle-vert large))
        (let ((s3-3 print-game-text))
          (format (clear *temp-string*) "~2D%" (the int (-> *progress-process* 0 completion-percentage)))
          (s3-3 *temp-string* s4-2 #f (the int (* 128.0 f28-0)) 22))))
    0.0
    (let ((f28-1 (+ -94.0 (-> this particles 2 init-pos x)))
          (s3-4 90)
          (s4-3 224)
          (s2-5 (/ s5-0 5))
          (f26-3 (-> this button-scale)))
      (let ((f24-0 (* 182.04445 (- (/ -36.0 f26-3) (the float s2-5)))))
        (set! (-> this particles 27 init-pos x) (the float (+ s3-4 (the int (* f28-1 (cos f24-0))))))
        (set! (-> this particles 27 init-pos y) (the float (+ s4-3 (the int (* f28-1 (sin f24-0)))))))
      (let ((f24-2 (* 182.04445 (- (/ -21.0 f26-3) (the float (adjust-pos s2-5 10))))))
        (set! (-> this particles 28 init-pos x) (the float (+ s3-4 (the int (* f28-1 (cos f24-2))))))
        (set! (-> this particles 28 init-pos y) (the float (+ s4-3 (the int (* f28-1 (sin f24-2)))))))
      (let ((f24-4 (* 182.04445 (- (/ -6.0 f26-3) (the float (adjust-pos s2-5 15))))))
        (set! (-> this particles 29 init-pos x) (the float (+ s3-4 (the int (* f28-1 (cos f24-4))))))
        (set! (-> this particles 29 init-pos y) (the float (+ s4-3 (the int (* f28-1 (sin f24-4)))))))
      (let ((f26-5 (* 182.04445 (- (/ 9.0 f26-3) (the float (adjust-pos s2-5 20))))))
        (set! (-> this particles 30 init-pos x) (the float (+ s3-4 (the int (* f28-1 (cos f26-5))))))
        (set! (-> this particles 30 init-pos y) (the float (+ s4-3 (the int (* f28-1 (sin f26-5))))))))
    (when *cheat-mode*
      (let ((a0-46 "AUTO SAVE OFF"))
        (if (-> *setting-control* current auto-save) (set! a0-46 "AUTO SAVE ON"))
        (let* ((s3-5 (-> *display* frames (-> *display* on-screen) frame global-buf))
               (s4-4 (-> s3-5 base)))
          (draw-string-xy a0-46
                          s3-5
                          (the int (+ 430.0 f30-0))
                          200
                          (font-color progress-memcard)
                          (font-flags shadow kerning middle))
          (let ((a3-9 (-> s3-5 base)))
            (let ((v1-81 (the-as object (-> s3-5 base))))
              (set! (-> (the-as dma-packet v1-81) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
              (set! (-> (the-as dma-packet v1-81) vif0) (new 'static 'vif-tag))
              (set! (-> (the-as dma-packet v1-81) vif1) (new 'static 'vif-tag))
              (set! (-> s3-5 base) (&+ (the-as pointer v1-81) 16)))
            (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group)
                                   (bucket-id debug)
                                   s4-4
                                   (the-as (pointer dma-tag) a3-9))))))
    (let ((a0-52 (-> this icons 5 icon 0 root)))
      (set-yaw-angle-clear-roll-pitch! a0-52 (- (y-angle a0-52) (* 182.04445 (* 4.0 (-> *display* time-adjust-ratio))))))
    (let* ((f28-2 (* 0.00024414062 (the float (-> *progress-process* 0 in-out-position))))
           (f30-1 (* 300.0 f28-2)))
      (set! (-> this particles 18 init-pos x)
            (the float (+ (the int (the float (adjust-pos s5-0 50))) 394 (the int f30-1) (-> this right-x-offset))))
      (set! (-> this particles 18 init-pos y) (the float (- 40 (the int (* 80.0 f28-2)))))
      (set! (-> this icons 5 icon-x)
            (+ (the int (the float (adjust-pos s5-0 50))) 393 (the int f30-1) (-> this right-x-offset)))
      (set! (-> this icons 5 icon-y) (- (-> this small-orb-y-offset) (the int (* 80.0 f28-2))))
      (set! (-> this particles 16 init-pos x)
            (the float (+ (the int (the float (adjust-pos s5-0 100))) 425 (the int f30-1) (-> this right-x-offset))))
      (set! (-> this particles 16 init-pos y) (the float (- 112 (the int (* 60.0 f28-2)))))
      (set! (-> this particles 17 init-pos x)
            (the float
                 (+ (the int (the float (adjust-pos s5-0 150)))
                    442
                    (the int f30-1)
                    (the int (* 0.7 (the float (-> this right-x-offset)))))))))
  (set! (-> this particles 17 init-pos y) 193.0)
  0
  (none))
