;;-*-Lisp-*-
(in-package goal)

;; name: minimap.gc
;; name in dgo: minimap
;; dgos: ENGINE, GAME

;; TODO - for gungame-obs
(define-extern *minimap-class-list* (inline-array minimap-class-node))

;; DECOMP BEGINS

(deftype minimap-texture-name-array (structure)
  ((data  string  35)
   )
  )


(deftype minimap-corner-array (structure)
  ((data  vector  35 :inline)
   )
  )


(define *minimap-texture-name-array*
  (new 'static 'minimap-texture-name-array :data (new 'static 'array string 35
                                                   #f
                                                   #f
                                                   "map-stadium"
                                                   "map-ctyslumc"
                                                   #f
                                                   #f
                                                   "map-ctygena"
                                                   "map-ctygenb"
                                                   "map-ctyslumb"
                                                   #f
                                                   #f
                                                   "map-ctyfarma"
                                                   "map-ctygenc"
                                                   #f
                                                   "map-ctysluma"
                                                   #f
                                                   "map-ctymarka"
                                                   "map-ctypala"
                                                   "map-ctymarkb"
                                                   "map-ctyindb"
                                                   #f
                                                   "map-ctyfarmb"
                                                   "map-ctypalb"
                                                   #f
                                                   "map-ctyinda"
                                                   #f
                                                   "map-ctyporta"
                                                   "map-ctyportb"
                                                   "map-ctyportc"
                                                   #f
                                                   #f
                                                   "map-ctyportd"
                                                   "map-ctyporte"
                                                   "map-ctyportf"
                                                   #f
                                                   )
                                           )
  )

(define *minimap-corner-array*
  (new 'static 'minimap-corner-array :data (new 'static 'inline-array vector 35
                                             (new 'static 'vector :x -4456448.0 :z -4456448.0 :w 1.0)
                                             (new 'static 'vector :x -2883584.0 :z -4456448.0 :w 1.0)
                                             (new 'static 'vector :x -1310720.0 :z -4456448.0 :w 1.0)
                                             (new 'static 'vector :x 262144.0 :z -4456448.0 :w 1.0)
                                             (new 'static 'vector :x 1835008.0 :z -4456448.0 :w 1.0)
                                             (new 'static 'vector :x -4456448.0 :z -2883584.0 :w 1.0)
                                             (new 'static 'vector :x -2883584.0 :z -2883584.0 :w 1.0)
                                             (new 'static 'vector :x -1310720.0 :z -2883584.0 :w 1.0)
                                             (new 'static 'vector :x 262144.0 :z -2883584.0 :w 1.0)
                                             (new 'static 'vector :x 1835008.0 :z -2883584.0 :w 1.0)
                                             (new 'static 'vector :x -4456448.0 :z -1310720.0 :w 1.0)
                                             (new 'static 'vector :x -2883584.0 :z -1310720.0 :w 1.0)
                                             (new 'static 'vector :x -1310720.0 :z -1310720.0 :w 1.0)
                                             (new 'static 'vector :x 262144.0 :z -1310720.0 :w 1.0)
                                             (new 'static 'vector :x 1835008.0 :z -1310720.0 :w 1.0)
                                             (new 'static 'vector :x -4456448.0 :z 262144.0 :w 1.0)
                                             (new 'static 'vector :x -2883584.0 :z 262144.0 :w 1.0)
                                             (new 'static 'vector :x -1310720.0 :z 262144.0 :w 1.0)
                                             (new 'static 'vector :x 262144.0 :z 262144.0 :w 1.0)
                                             (new 'static 'vector :x 1835008.0 :z 262144.0 :w 1.0)
                                             (new 'static 'vector :x -4456448.0 :z 1835008.0 :w 1.0)
                                             (new 'static 'vector :x -2883584.0 :z 1835008.0 :w 1.0)
                                             (new 'static 'vector :x -1310720.0 :z 1835008.0 :w 1.0)
                                             (new 'static 'vector :x 262144.0 :z 1835008.0 :w 1.0)
                                             (new 'static 'vector :x 1835008.0 :z 1835008.0 :w 1.0)
                                             (new 'static 'vector :x -4456448.0 :z 3407872.0 :w 1.0)
                                             (new 'static 'vector :x -2883584.0 :z 3407872.0 :w 1.0)
                                             (new 'static 'vector :x -1310720.0 :z 3407872.0 :w 1.0)
                                             (new 'static 'vector :x 262144.0 :z 3407872.0 :w 1.0)
                                             (new 'static 'vector :x 1835008.0 :z 3407872.0 :w 1.0)
                                             (new 'static 'vector :x -4456448.0 :z 4980736.0 :w 1.0)
                                             (new 'static 'vector :x -2883584.0 :z 4980736.0 :w 1.0)
                                             (new 'static 'vector :x -1310720.0 :z 4980736.0 :w 1.0)
                                             (new 'static 'vector :x 262144.0 :z 4980736.0 :w 1.0)
                                             (new 'static 'vector :x 1835008.0 :z 4980736.0 :w 1.0)
                                             )
                                     )
  )

(define *minimap*
  (new 'static 'minimap
    :draw-tmpl (new 'static 'dma-gif-packet
      :dma-vif (new 'static 'dma-packet
        :dma (new 'static 'dma-tag :qwc #xa :id (dma-tag-id cnt))
        :vif1 (new 'static 'vif-tag :imm #xa :cmd (vif-cmd direct) :msk #x1)
        )
      :gif0 (new 'static 'gif-tag64
        :nloop #x1
        :eop #x1
        :pre #x1
        :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :tme #x1 :fst #x1)
        :nreg #x9
        )
      :gif1 (new 'static 'gif-tag-regs
        :regs0 (gif-reg-id rgbaq)
        :regs1 (gif-reg-id uv)
        :regs2 (gif-reg-id xyz2)
        :regs3 (gif-reg-id uv)
        :regs4 (gif-reg-id xyz2)
        :regs5 (gif-reg-id uv)
        :regs6 (gif-reg-id xyz2)
        :regs7 (gif-reg-id uv)
        :regs8 (gif-reg-id xyz2)
        )
      )
    :draw2-tmpl (new 'static 'dma-gif-packet
      :dma-vif (new 'static 'dma-packet
        :dma (new 'static 'dma-tag :qwc #xa :id (dma-tag-id cnt))
        :vif1 (new 'static 'vif-tag :imm #xa :cmd (vif-cmd direct) :msk #x1)
        )
      :gif0 (new 'static 'gif-tag64
        :nloop #x1
        :eop #x1
        :pre #x1
        :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :tme #x1)
        :nreg #x9
        )
      :gif1 (new 'static 'gif-tag-regs
        :regs0 (gif-reg-id rgbaq)
        :regs1 (gif-reg-id st)
        :regs2 (gif-reg-id xyz2)
        :regs3 (gif-reg-id st)
        :regs4 (gif-reg-id xyz2)
        :regs5 (gif-reg-id st)
        :regs6 (gif-reg-id xyz2)
        :regs7 (gif-reg-id st)
        :regs8 (gif-reg-id xyz2)
        )
      )
    :draw3-tmpl (new 'static 'dma-gif-packet
      :dma-vif (new 'static 'dma-packet
        :dma (new 'static 'dma-tag :qwc #xa :id (dma-tag-id cnt))
        :vif1 (new 'static 'vif-tag :imm #xa :cmd (vif-cmd direct) :msk #x1)
        )
      :gif0 (new 'static 'gif-tag64
        :nloop #x1
        :eop #x1
        :pre #x1
        :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :tme #x1 :abe #x1 :fst #x1)
        :nreg #x9
        )
      :gif1 (new 'static 'gif-tag-regs
        :regs0 (gif-reg-id rgbaq)
        :regs1 (gif-reg-id uv)
        :regs2 (gif-reg-id xyz2)
        :regs3 (gif-reg-id uv)
        :regs4 (gif-reg-id xyz2)
        :regs5 (gif-reg-id uv)
        :regs6 (gif-reg-id xyz2)
        :regs7 (gif-reg-id uv)
        :regs8 (gif-reg-id xyz2)
        )
      )
    :draw4-tmpl (new 'static 'dma-gif-packet
      :dma-vif (new 'static 'dma-packet
        :dma (new 'static 'dma-tag :qwc #xa :id (dma-tag-id cnt))
        :vif1 (new 'static 'vif-tag :imm #xa :cmd (vif-cmd direct) :msk #x1)
        )
      :gif0 (new 'static 'gif-tag64
        :nloop #x1
        :eop #x1
        :pre #x1
        :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :tme #x1 :abe #x1)
        :nreg #x9
        )
      :gif1 (new 'static 'gif-tag-regs
        :regs0 (gif-reg-id rgbaq)
        :regs1 (gif-reg-id st)
        :regs2 (gif-reg-id xyz2)
        :regs3 (gif-reg-id st)
        :regs4 (gif-reg-id xyz2)
        :regs5 (gif-reg-id st)
        :regs6 (gif-reg-id xyz2)
        :regs7 (gif-reg-id st)
        :regs8 (gif-reg-id xyz2)
        )
      )
    :sprite-tmpl (new 'static 'dma-gif-packet
      :dma-vif (new 'static 'dma-packet
        :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt))
        :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1)
        )
      :gif0 (new 'static 'gif-tag64
        :nloop #x1
        :eop #x1
        :pre #x1
        :prim (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :abe #x1 :fst #x1)
        :nreg #x5
        )
      :gif1 (new 'static 'gif-tag-regs
        :regs0 (gif-reg-id rgbaq)
        :regs1 (gif-reg-id uv)
        :regs2 (gif-reg-id xyz2)
        :regs3 (gif-reg-id uv)
        :regs4 (gif-reg-id xyz2)
        )
      )
    :adgif-tmpl (new 'static 'dma-gif-packet
      :dma-vif (new 'static 'dma-packet
        :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt))
        :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1)
        )
      :gif0 (new 'static 'gif-tag64 :nloop #x5 :eop #x1 :nreg #x1)
      :gif1 (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))
      )
    :color (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80)
    :offset (new 'static 'vector :x 1.0 :y 1.0 :z 1.0)
    :last-name #f
    :last-tex #f
    :engine #f
    :engine-key #x800
    :race-tex #f
    :race-scale 16384.0
    :race-level #f
    :sprite2-tmpl (new 'static 'dma-gif-packet
      :dma-vif (new 'static 'dma-packet
        :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt))
        :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1)
        )
      :gif0 (new 'static 'gif-tag64
        :nloop #x1
        :eop #x1
        :pre #x1
        :prim (new 'static 'gs-prim :prim (gs-prim-type sprite) :tme #x1 :abe #x1)
        :nreg #x5
        )
      :gif1 (new 'static 'gif-tag-regs
        :regs0 (gif-reg-id rgbaq)
        :regs1 (gif-reg-id st)
        :regs2 (gif-reg-id xyz2)
        :regs3 (gif-reg-id st)
        :regs4 (gif-reg-id xyz2)
        )
      )
    :frustum-alpha 1.0
    )
  )

(define *minimap-class-list* (new 'static 'inline-array minimap-class-node 71
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :w 1.0)
                                 :flags (minimap-flag trail bigmap)
                                 :name "none"
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 2920448.0 :y 32768.0 :z 3080192.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "onintent"
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 3346432.0 :y 32768.0 :z -1384448.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "ruins"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x1 #x0))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 4505600.0 :z 4505600.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "vinroom"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x0))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -1761280.0 :z 856064.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "mountain"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x3 #x0))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 4751360.0 :y 32768.0 :z 241664.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "hideout"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x4 #x0))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 4378624.0 :y -34734.08 :z 2097152.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "sewer"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x1 #x1))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 2285568.0 :y 32768.0 :z -3252224.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "atoll"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x1))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -282624.0 :y 45056.0 :z 5464064.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "hiphog"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x3 #x1))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 3084288.0 :z 929792.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "fortress"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x4 #x1))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1757184.0 :z 5386240.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "gungame"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x5 #x1))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1843200.0 :y 34816.0 :z 5275648.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "gun-yellow"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x1 #x2))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :b #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 442368.0 :z -1843200.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "garage"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x2))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 835584.0 :z -712704.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "palace-cable"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x4 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :w 1.0)
                                 :name "guard"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x1))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :w 1.0)
                                 :flags (minimap-flag trail bigmap goal)
                                 :name "goal"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x4))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :w 1.0)
                                 :flags (minimap-flag clamp bigmap goal)
                                 :name "goal-no-trail"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x4))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :w 1.0)
                                 :name "parking-spot"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x1))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #x7f :g #x7f :b #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -1761280.0 :z 856064.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "forest"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x3 #x0))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -450560.0 :z 1982464.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap)
                                 :name "kiosk"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x3 #x2))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1523712.0 :z 7372800.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "dig"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x2))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -1761280.0 :z 856064.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "canyon"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x3 #x0))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 839680.0 :z 3756032.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "tomb"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x4 #x2))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1904640.0 :z 1753088.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "tanker"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x5 #x0))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :w 1.0)
                                 :flags (minimap-flag trail flash bigmap)
                                 :name "kid"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x1))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :b #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 3121152.0 :z 3551232.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "consite"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x5 #x2))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 786432.0 :z 3014656.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "palace"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x5 #x0))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1523712.0 :z 7372800.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "castle"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x2))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 86016.0 :z 7151616.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "underport"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1126400.0 :z -2863104.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "stadium"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x2))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 2408448.0 :z 7798784.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap)
                                 :name "port-turret"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x5 #x1))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 2895872.0 :z -1855488.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "oracle"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x1 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :w 1.0)
                                 :flags (minimap-flag frustum)
                                 :name "guard-frustum"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x1))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "burning-bush"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1843200.0 :y 34816.0 :z 5275648.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "gun-dark"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x1 #x2))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :b #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 3137536.0 :y 34324.48 :z -2962923.5 :w 1.0)
                                 :flags (minimap-flag trail bigmap city-only)
                                 :name "slumc-seal"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x3 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :w 1.0)
                                 :flags (minimap-flag racer)
                                 :name "racer"
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :w 1.0)
                                 :flags (minimap-flag racer)
                                 :name "racer-target"
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :w 1.0)
                                 :flags (minimap-flag racer)
                                 :name "racer-errol"
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 166871.05 :y 49192.96 :z -2900009.0 :w 1.0)
                                 :flags (minimap-flag trail bigmap)
                                 :name "flag"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x5 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -258048.0 :y 32768.0 :z -96256.0 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-gena"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -1567539.2 :y 32768.0 :z -805683.2 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-gena-2"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 683663.4 :y 32768.0 :z -1237483.5 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-genb"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1126400.0 :y 32768.0 :z -270336.0 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-genb-2"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 884736.0 :y 32768.0 :z 9445.376 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-genc"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 159744.0 :y 32768.0 :z 1081344.0 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-genc-2"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 3391774.8 :y 33341.44 :z 984637.44 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-sluma"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 2891899.0 :y 32768.0 :z -306487.28 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-slumb"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1738997.8 :y 32768.0 :z -280698.88 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-slumb-2"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 2180219.0 :y 32768.0 :z -2407219.2 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-slumc"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 2602066.0 :y 31662.08 :z 6453739.5 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-port-3"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1839267.9 :y 31662.08 :z 5443010.5 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-port-2"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -423485.44 :y 31744.0 :z 5558599.5 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-port"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -224952.31 :y 32768.0 :z 362332.16 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-farma"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -1280532.5 :y 32768.0 :z 4410286.0 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-farmb"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 3178741.8 :y 32768.0 :z 3331031.0 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-inda"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 3182592.0 :y 32768.0 :z 2916352.0 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-indb"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -733184.0 :y 32768.0 :z 3481600.0 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-marka"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 2985451.5 :y 34406.4 :z 2185216.0 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-markb"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 2576916.5 :y 34406.4 :z 3131310.0 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-markb-2"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 378306.56 :y 65536.0 :z 1866915.9 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-pal"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1256243.2 :y 32768.0 :z 3622092.8 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-pal-2"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1392926.8 :y 32768.0 :z -3109273.5 :w 1.0)
                                 :flags (minimap-flag bigmap city-only)
                                 :name "bbush-stadium"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x2 #x3))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 1542847.2 :y 196168.9 :z -4314233.0 :w 1.0)
                                 :flags (minimap-flag bigmap goal)
                                 :name "atoll-valve"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x4))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 2277804.5 :y 217672.9 :z -4571725.5 :w 1.0)
                                 :flags (minimap-flag bigmap goal)
                                 :name "atoll-ashelin"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x4))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -3100565.5 :y 547275.56 :z 1190112.5 :w 1.0)
                                 :flags (minimap-flag bigmap goal)
                                 :name "mountain-lens"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x4))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -2833539.0 :y 496445.44 :z 11345.101 :w 1.0)
                                 :flags (minimap-flag bigmap goal)
                                 :name "mountain-shard"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x4))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -3448408.5 :y 567047.8 :z 1029759.4 :w 1.0)
                                 :flags (minimap-flag bigmap goal)
                                 :name "mountain-gear"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x4))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x 4357507.5 :y 205120.72 :z -2286701.2 :w 1.0)
                                 :flags (minimap-flag bigmap goal)
                                 :name "ruins-hut"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x4))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :x -2575550.8 :y 156067.02 :z 3728844.8 :w 1.0)
                                 :flags (minimap-flag bigmap goal)
                                 :name "forest-samos"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x4))
                                 :scale 1.0
                                 :color (new 'static 'rgba :g #x7f :a #x80)
                                 )
                               (new 'static 'minimap-class-node
                                 :default-position (new 'static 'vector :w 1.0)
                                 :name "metalhead"
                                 :icon-xy (new 'static 'vector2ub :data (new 'static 'array uint8 2 #x0 #x1))
                                 :scale 1.0
                                 :color (new 'static 'rgba :r #x7f :b #x7f :a #x80)
                                 )
                               )
        )

(#when PC_PORT
;; og:preserve-this fix icon colors
(set! (-> *minimap-class-list* (minimap-class consite) color) (static-rgba #xff #xff #xff #x80))
(set! (-> *minimap-class-list* (minimap-class underport) color) (static-rgba #xff #xff #xff #x80))
)

(let ((gp-0 *minimap*))
  ;; og:preserve-this minimap engine connections raised for pc port
  (set! (-> gp-0 engine) (new 'global 'engine-minimap '*minimap* (#if PC_PORT 256 64) connection-minimap))
  (countdown (v1-7 6)
    (set! (-> gp-0 trail v1-7 used-by) #f)
    )
  )

(defmethod debug-draw ((this minimap))
  (when *trail-graph*
    (dotimes (s5-0 6)
      (let ((s4-0 (-> this trail s5-0)))
        (when (and (-> s4-0 used-by)
                   (>= (-> s4-0 node-count) 0)
                   (not (time-elapsed? (the-as int (-> s4-0 last-updated)) (seconds 5)))
                   )
          (let* ((a3-0 (target-pos 0))
                 (v1-12 s5-0)
                 (t1-0 (cond
                         ((zero? v1-12)
                          *color-green*
                          )
                         ((= v1-12 1)
                          *color-blue*
                          )
                         ((= v1-12 2)
                          *color-white*
                          )
                         ((= v1-12 3)
                          *color-red*
                          )
                         (else
                           *color-magenta*
                           )
                         )
                       )
                 )
            (debug-draw-path
              *trail-graph*
              (-> s4-0 node-count)
              (-> s4-0 node-id)
              a3-0
              (-> s4-0 cached-info orig-goal-pos)
              t1-0
              (* 1024.0 (the float s5-0))
              )
            )
          )
        )
      )
    )
  0
  (none)
  )

;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v1, Count]
(defmethod update-trails ((this minimap))
  "Main function to do trail search per-frame"
  (let ((s5-0 *trail-graph*))
    (when s5-0
      (.mtc0 Count 0)
      (let ((v1-1 0))
        (while (< (the-as uint v1-1) (the-as uint #x605a))
          (let ((v1-2 (-> s5-0 mode)))
            (cond
              ((= v1-2 1)
               (run-until-done-or-timeout s5-0 #x605a)
               )
              ((zero? v1-2)
               (let ((v1-5 -1))
                 (let ((a0-5 0))
                   (countdown (a1-1 6)
                     (let* ((a2-3 (-> this trail a1-1))
                            (a3-0 (-> a2-3 used-by))
                            )
                       (when (and a3-0 (and (< 0.0 (-> a3-0 alpha)) (or (< v1-5 0) (< (the-as int (-> a2-3 last-updated)) a0-5))))
                         (set! v1-5 a1-1)
                         (set! a0-5 (the-as int (-> a2-3 last-updated)))
                         )
                       )
                     )
                   (let ((a1-5 (current-time)))
                     (if (or (< v1-5 0) (= a0-5 a1-5))
                         (goto cfg-68)
                         )
                     )
                   )
                 (let ((s4-0 (-> this trail v1-5))
                       (s3-0 (the-as object #f))
                       )
                   (let* ((v1-9 (-> s4-0 used-by))
                          (s2-0 (-> v1-9 position))
                          )
                     (set! s3-0 (cond
                                  ((= s2-0 #t)
                                   (let* ((s2-1 (handle->process (-> v1-9 handle)))
                                          (v1-13 (if (type? s2-1 process-drawable)
                                                     s2-1
                                                     )
                                                 )
                                          )
                                     (if v1-13
                                         (set! s3-0 (-> (the-as process-drawable v1-13) root trans))
                                         )
                                     )
                                   s3-0
                                   )
                                  ((and (= (logand (the-as int s2-0) 7) 4) (= (-> (the-as basic s2-0) type) entity-actor))
                                   (let* ((v1-19 s2-0)
                                          (s3-1 (if v1-19
                                                    (-> (the-as entity-actor v1-19) extra process)
                                                    )
                                                )
                                          (v1-21 (if (type? s3-1 process-drawable)
                                                     s3-1
                                                     )
                                                 )
                                          )
                                     (if v1-21
                                         (set! s3-0 (-> (the-as process-drawable v1-21) root trans))
                                         (set! s3-0 (-> (the-as entity-actor s2-0) extra trans))
                                         )
                                     )
                                   s3-0
                                   )
                                  (else
                                    s2-0
                                    )
                                  )
                           )
                     )
                   (when s3-0
                     (do-search! s5-0 (target-pos 0) (the-as vector s3-0) (-> s4-0 cached-info))
                     (set! (-> s4-0 search-id) (-> s5-0 search-id))
                     )
                   )
                 )
               )
              ((or (= v1-2 3) (= v1-2 2))
               (countdown (v1-33 6)
                 (let ((s4-1 (-> this trail v1-33)))
                   (when (and (= (-> s4-1 search-id) (-> s5-0 search-id)) (-> s4-1 used-by))
                     (set! (-> s4-1 node-count)
                           (get-path-to-root s5-0 (-> s4-1 node-id) 64 (&-> s4-1 goal-node-id) (&-> s4-1 node-path-dist))
                           )
                     (set! (-> s4-1 last-updated) (the-as uint (current-time)))
                     (goto cfg-64)
                     )
                   )
                 )
               (label cfg-64)
               (reset-search-state s5-0)
               )
              )
            )
            ;; og:preserve-this added in PC port: they timed stuff, we just allow it to run a fixed number of iterations.
            (+! v1-1 100)
            (.mfc0 v1-1 Count)
          )
        )
      (label cfg-68)
      0
      )
    )
  0
  (none)
  )

(defmethod get-trail-for-connection ((this minimap) (arg0 connection-minimap) (arg1 symbol))
  "Get a trail for connection. If arg1 is set, allow allocating a new one."
  (local-vars (gp-0 minimap-trail))
  (countdown (v1-0 6)
    (let ((a3-3 (-> this trail v1-0)))
      (when (= (-> a3-3 used-by) arg0)
        (set! gp-0 a3-3)
        (goto cfg-14)
        )
      )
    )
  (when arg1
    (dotimes (v1-4 6)
      (let ((a3-7 (-> this trail v1-4)))
        (when (not (-> a3-7 used-by))
          (set! (-> a3-7 used-by) arg0)
          (set! gp-0 a3-7)
          (goto cfg-14)
          )
        )
      )
    )
  (set! gp-0 (the-as minimap-trail #f))
  (label cfg-14)
  (if (and gp-0 arg1)
      (reset gp-0)
      )
  gp-0
  )

;; WARN: Function (method 13 minimap) has a return type of none, but the expression builder found a return statement.
(defmethod free-trail-by-connection ((this minimap) (arg0 connection-minimap))
  "Free the trail associated with this connection."
  (countdown (v1-0 6)
    (let ((a2-3 (-> this trail v1-0)))
      (when (= (-> a2-3 used-by) arg0)
        (set! (-> a2-3 used-by) #f)
        (reset a2-3)
        (return #f)
        )
      )
    )
  0
  (none)
  )

(defmethod reset ((this minimap-trail))
  (set! (-> this node-count) -1)
  (set! (-> this search-id) (the-as uint 0))
  (set! (-> this last-updated) (the-as uint 0))
  (set! (-> this cached-info goal-conn-id) -1)
  (none)
  )

(defmethod get-icon-draw-pos ((this minimap) (arg0 connection-minimap) (arg1 minimap-trail) (arg2 vector) (arg3 float) (arg4 vector))
  "Follow the path from the start until it reaches the border of the map, then get this position."
  (let ((s5-0 (new 'stack-no-clear 'inline-array 'vector 4)))
    (vector-reset! (-> s5-0 2))
    (vector-reset! (-> s5-0 1))
    (let ((s1-0 0))
      (while (>= (-> arg1 node-count) s1-0)
        (set! (-> s5-0 0 quad) (-> s5-0 1 quad))
        (cond
          ((< s1-0 (-> arg1 node-count))
           (get-node-location-by-id *trail-graph* (-> arg1 node-id s1-0) (-> s5-0 1))
           (+! s1-0 1)
           (vector-! (-> s5-0 1) (-> s5-0 1) arg2)
           (set! (-> s5-0 1 x) (* (-> s5-0 1 x) arg3))
           (set! (-> s5-0 1 z) (* (-> s5-0 1 z) arg3))
           (set! (-> s5-0 1 y) 0.0)
           (set! (-> s5-0 1 w) 1.0)
           )
          (else
            (vector-negate! (-> s5-0 1) arg4)
            (+! s1-0 1)
            )
          )
        (let ((v1-12 (-> s5-0 1)))
          (when (>= (sqrtf (+ (* (-> v1-12 x) (-> v1-12 x)) (* (-> v1-12 z) (-> v1-12 z)))) 50.0)
            (vector-! (-> s5-0 3) (-> s5-0 0) (-> s5-0 1))
            (let* ((f1-6 (ray-sphere-intersect (-> s5-0 1) (-> s5-0 3) (-> s5-0 2) 50.0))
                   (f0-12 (fmax 0.0 (fmin 1.0 f1-6)))
                   )
              (vector-float*! arg4 (-> s5-0 3) f0-12)
              )
            (vector+! arg4 arg4 (-> s5-0 1))
            (vector-negate! arg4 arg4)
            (return #t)
            )
          )
        )
      )
    )
  #f
  )

(defmethod get-distance-with-path ((this minimap-trail) (arg0 vector) (arg1 vector))
  "Assuming we go from a to b, using this path in the middle, how long is it?"
  0.0
  (let ((s4-0 *trail-graph*))
    (cond
      ((and s4-0 (> (-> this node-count) 0))
       (let ((f30-0 (-> this node-path-dist))
             (s2-0 (new 'stack-no-clear 'vector))
             )
         (get-node-location-by-id s4-0 (-> this node-id 0) s2-0)
         (let ((f30-1 (+ f30-0 (vector-vector-xz-distance arg0 s2-0))))
           (get-node-location-by-id s4-0 (the-as uint (-> this goal-node-id)) s2-0)
           (+ f30-1 (vector-vector-xz-distance arg1 s2-0))
           )
         )
       )
      (else
        (vector-vector-xz-distance arg0 arg1)
        )
      )
    )
  )

(defmethod print ((this connection-minimap))
  (format
    #t
    "#<connection-minimap ~16S #x~4X ~A @ #x~X>"
    (-> this class name)
    (-> this flags)
    (handle->process (-> this handle))
    this
    )
  this
  )


(defmethod run-pending-updates! ((this engine-minimap) (arg0 time-frame))
  "Run updates if they scheduled. If something is found that has no pending update, kill it.
   Note that we won't kill things on this call if they fail to update their `update-time`.
   They will survive until the next call to `run-pending-updates`!
   (or you can modify their `update-time` before that to prevent them from being killed.)"
  (let ((s2-0 (the-as (pointer connection-pers) (&-> this alive-list)))
        (s3-0 (-> this alive-list))
        )
    (while s3-0
      (let ((s4-0 (-> s3-0 next)))
        (when (not (paused?))
          (cond
            ((logtest? (-> s3-0 flags) (minimap-flag fade-out))
             (logclear! (-> s3-0 flags) (minimap-flag fade-in))
             (seek! (-> s3-0 alpha) 0.0 (seconds-per-frame))
             )
            ((and (logtest? (-> s3-0 flags) (minimap-flag task-graph))
                  (not (logtest? (-> *setting-control* user-current minimap) 32))
                  )
             (logior! (-> s3-0 flags) (minimap-flag fade-in))
             (seek! (-> s3-0 alpha) 0.0 (seconds-per-frame))
             )
            ((logtest? (-> s3-0 flags) (minimap-flag fade-in))
             (let ((f30-0 1.0))
               (when (logtest? (-> s3-0 class flags) (minimap-flag trail))
                 (let ((v1-26 (get-trail-for-connection *minimap* s3-0 #f)))
                   (if (or (not v1-26) (time-elapsed? (the-as int (-> v1-26 last-updated)) (seconds 5)))
                       (set! f30-0 0.0001)
                       )
                   )
                 )
               (seek! (-> s3-0 alpha) f30-0 (seconds-per-frame))
               )
             (if (= (-> s3-0 alpha) 1.0)
                 (logclear! (-> s3-0 flags) (minimap-flag fade-in))
                 )
             )
            )
          )
        (cond
          ((and (logtest? (-> s3-0 flags) (minimap-flag fade-out)) (= (-> s3-0 alpha) 0.0))
           (kill-callback this s3-0)
           (set! (-> s2-0 0) (-> s3-0 next))
           (set! (-> s3-0 next) (-> this dead-list))
           (set! (-> this dead-list) s3-0)
           (+! (-> this length) -1)
           )
          ((and (handle->process (-> s3-0 handle))
                (not (and (= (logand (the-as int (-> s3-0 position)) 7) 4)
                          (= (-> (the-as basic (-> s3-0 position)) type) entity-actor)
                          (logtest? (-> (the-as entity-actor (-> s3-0 position)) extra perm status)
                                    (entity-perm-status dead subtask-complete bit-12)
                                    )
                          )
                     )
                )
           (update-callback this)
           (set! s2-0 (&-> s3-0 next))
           )
          (else
            (logior! (-> s3-0 flags) (minimap-flag fade-out))
            (update-callback this)
            (set! s2-0 (&-> s3-0 next))
            )
          )
        (set! s3-0 (the-as connection-minimap s4-0))
        )
      )
    )
  (set! (-> this execute-time) arg0)
  0
  (none)
  )

(defmethod add-icon! ((this minimap) (arg0 process) (arg1 uint) (arg2 int) (arg3 vector) (arg4 int))
  "Add an icon to the map!"
  (when (not arg2)
    (let ((v1-3 (+ (-> *minimap* engine-key) 1)))
      (set! (-> *minimap* engine-key) v1-3)
      (set! arg2 (the-as int v1-3))
      )
    )
  (let ((s3-0 (the-as connection-minimap (schedule-callback (-> this engine) arg2 0))))
    (let ((s2-1 (-> *minimap-class-list* arg1)))
      (when s3-0
        (when (not (logtest? (-> s3-0 flags) (minimap-flag active)))
          (set! (-> s3-0 class) s2-1)
          (set! (-> s3-0 last-world-pos quad) (-> s2-1 default-position quad))
          (vector-! (-> s3-0 last-relative-pos) (target-pos 0) (-> s3-0 last-world-pos))
          (set! (-> s3-0 edge-ry) -131072.0)
          )
        (set! (-> s3-0 handle) (process->handle arg0))
        (set! arg3 (cond
                     (arg3
                       (empty)
                       arg3
                       )
                     (else
                       (-> s2-1 default-position)
                       )
                     )
              )
        (set! (-> s3-0 position) arg3)
        (set! (-> s3-0 flags) (minimap-flag active fade-in))
        (set! (-> s3-0 node) (the-as uint arg4))
        )
      )
    s3-0
    )
  )

;; WARN: Function (method 10 engine-minimap) has a return type of none, but the expression builder found a return statement.
(defmethod kill-callback ((this engine-minimap) (arg0 connection-pers))
  "Called when a connection is removed."
  (if (not arg0)
      (return #f)
      )
  (if (logtest? (-> (the-as connection-minimap arg0) class flags) (minimap-flag trail))
      (free-trail-by-connection *minimap* (the-as connection-minimap arg0))
      )
  (set! (-> arg0 update-time) (the-as time-frame #f))
  ((method-of-type engine-pers kill-callback) this arg0)
  (none)
  )

(defun lookup-minimap-texture-by-name ((arg0 string) (arg1 string) (arg2 (pointer texture-page)))
  (local-vars (sv-16 texture-page))
  ;; og:preserve-this constant
  (dotimes (s3-0 LEVEL_TOTAL)
    (let ((s2-0 (-> *level* level s3-0)))
      (when (or (= (-> s2-0 status) 'active) (= (-> s2-0 status) 'reserved))
        (set! sv-16 (-> s2-0 texture-page 8))
        (when (and sv-16 (or (not arg1) (string= (-> sv-16 name) arg1)))
          (dotimes (s1-0 (-> sv-16 length))
            (let ((s0-0 (-> sv-16 data s1-0)))
              (when (and s0-0 (string= (-> s0-0 name) arg0))
                (if arg2
                    (set! (-> arg2 0) sv-16)
                    )
                (set! (-> s2-0 texture-mask 8 mask quad) (-> s0-0 masks data 0 mask quad))
                (return s0-0)
                )
              )
            )
          )
        )
      )
    )
  (the-as texture #f)
  )

(defmethod update! ((this minimap))
  (set! (-> this ctywide) (level-get *level* 'ctywide))
  (set! (-> this map-bits) (the-as uint 0))
  (dotimes (v1-2 (-> *level* length))
    (let ((a0-5 (-> *level* level v1-2)))
      (if (= (-> a0-5 status) 'active)
          (logior! (-> this map-bits) (-> a0-5 info city-map-bits))
          )
      )
    )
  (let ((s5-0 (the int (* 0.0000006357829 (+ 3145728.0 (-> (target-pos 0) x)))))
        (v1-9 (the int (* 0.0000006357829 (+ 3145728.0 (-> (target-pos 0) z)))))
        )
    (when (and (< s5-0 5) (< v1-9 7) (logtest? (-> this map-bits) (ash 1 (+ (* 5 v1-9) s5-0))))
      (let ((a0-19 (-> *minimap-texture-name-array* data (+ (* 5 v1-9) s5-0))))
        (when a0-19
          (set! (-> this last-name) a0-19)
          (set! (-> this minimap-corner quad) (-> *minimap-corner-array* data (+ (* 5 v1-9) s5-0) quad))
          (dotimes (a0-21 (-> *level* length))
            (let ((a1-23 (-> *level* level a0-21)))
              (when (= (-> a1-23 status) 'active)
                (if (logtest? (-> a1-23 info city-map-bits) (ash 1 (+ (* 5 v1-9) s5-0)))
                    (set! (-> this level) a1-23)
                    )
                )
              )
            )
          )
        )
      )
    )
  (set! (-> this last-tex)
        (lookup-minimap-texture-by-name (-> this last-name) (the-as string #f) (the-as (pointer texture-page) #f))
        )
  (let ((f30-2 (seconds-per-frame)))
    (let ((v1-12 (-> this last-tex)))
      (cond
        ((or (not (-> this level)) (zero? (-> this level)) (!= (-> this level status) 'active) (not v1-12))
         (set! (-> this offset w) 0.0)
         )
        ((not (logtest? (-> *setting-control* user-current minimap) 128))
         (seek! (-> this offset w) 0.0 f30-2)
         )
        ((and *target* (nonzero? (-> this map-bits)))
         (set! (-> this offset w) (fmin 0.5 (+ (-> this offset w) f30-2)))
         )
        (else
          (set! (-> this offset w) 0.0)
          )
        )
      )
    (cond
      ((and *target* (focus-test? *target* board pilot))
       (let ((f0-14 0.5)
             (f1-2 0.000008138021)
             (f2-0 122880.0)
             (v1-33 (-> *target* control transv))
             )
         (set! (-> this target-inv-scale)
               (fmax f0-14 (* f1-2 (fmin f2-0 (sqrtf (+ (* (-> v1-33 x) (-> v1-33 x)) (* (-> v1-33 z) (-> v1-33 z)))))))
               )
         )
       )
      (else
        (set! (-> this target-inv-scale) 0.5)
        )
      )
    (seek! (-> this offset y) (-> this target-inv-scale) (/ f30-2 2))
    )
  (run-pending-updates! (-> this engine) (-> *display* base-clock frame-counter))
  (when (and (-> this ctywide) (and (= (-> this ctywide status) 'active) (!= (-> this offset w) 0.0)))
    (update-trails this)
    (if *display-trail-graph*
        (debug-draw this)
        )
    #t
    )
  )

;; WARN: Return type mismatch pointer vs none.
(defmethod draw-racer-2 ((this minimap) (arg0 minimap-draw-work) (arg1 connection-minimap))
  (local-vars
    (sv-16 process)
    (sv-20 dma-buffer)
    (sv-208 pointer)
    (sv-212 vector)
    (sv-216 vector)
    (sv-220 matrix)
    (sv-224 matrix)
    (sv-228 matrix)
    )
  (let ((s3-0 (handle->process (-> arg1 handle))))
    (set! sv-16 (if (type? s3-0 process-drawable)
                    s3-0
                    )
          )
    )
  (set! sv-20 (-> arg0 buf))
  (when (and sv-16 (nonzero? (-> (the-as process-drawable sv-16) root)))
    (set! sv-208 (-> sv-20 base))
    (set! sv-212 (new 'stack-no-clear 'vector))
    (set! sv-216 (new 'stack-no-clear 'vector))
    (set! sv-220 (new 'stack-no-clear 'matrix))
    (set! sv-224 (new 'stack-no-clear 'matrix))
    (set! sv-228 (new 'stack-no-clear 'matrix))
    (set! (-> sv-216 quad) (-> (#if PC_PORT (if (-> *pc-settings* minimap-force-north) *matrix-minimap-north* (matrix-world->local #f #f)) (matrix-world->local #f #f)) vector 2 quad))
    (set! (-> sv-216 y) 0.0)
    (vector-normalize! sv-216 1.0)
    (vector-z-quaternion! (the-as vector sv-220) (-> (the-as process-drawable sv-16) root quat))
    (vector-xz-normalize! (the-as vector sv-220) 1.0)
    (set! (-> sv-220 vector 0 y) 0.0)
    (set! (-> sv-220 vector 0 w) 0.0)
    (vector-! sv-212 (target-pos 0) (-> (the-as process-drawable sv-16) root trans))
    (let ((f0-4 (/ (-> sv-212 x) (* 16384.0 (-> this offset y))))
          (f1-3 (/ (-> sv-212 z) (* 16384.0 (-> this offset y))))
          )
      (set-vector! (-> sv-224 vector 0) (-> sv-216 z) 0.0 (- (-> sv-216 x)) 0.0)
      (set-vector! (-> sv-224 vector 1) 0.0 1.0 0.0 0.0)
      (set-vector! (-> sv-224 vector 2) (-> sv-216 x) 0.0 (-> sv-216 z) 0.0)
      (set-vector! (-> sv-224 trans) 164.0 0.0 164.0 1.0)
      (set-vector! (-> sv-228 vector 0) (-> sv-220 vector 0 z) 0.0 (- (-> sv-220 vector 0 x)) 0.0)
      (set-vector! (-> sv-228 vector 1) 0.0 1.0 0.0 0.0)
      (set-vector! (-> sv-228 vector 2) (-> sv-220 vector 0 x) 0.0 (-> sv-220 vector 0 z) 0.0)
      (set-vector! (-> sv-228 trans) f0-4 0.0 f1-3 1.0)
      )
    (matrix*! sv-228 sv-228 sv-224)
    (let ((f0-7 7.0))
      (set-vector! (-> arg0 corner 0) 0.0 0.0 (- f0-7) 1.0)
      (set-vector! (-> arg0 corner 1) f0-7 0.0 0.0 1.0)
      (set-vector! (-> arg0 corner 2) (- f0-7) 0.0 0.0 1.0)
      (set-vector! (-> arg0 corner 3) 0.0 0.0 f0-7 1.0)
      )
    (vector-matrix*! (the-as vector (-> arg0 corner)) (the-as vector (-> arg0 corner)) sv-228)
    (vector-matrix*! (-> arg0 corner 1) (-> arg0 corner 1) sv-228)
    (vector-matrix*! (-> arg0 corner 2) (-> arg0 corner 2) sv-228)
    (vector-matrix*! (-> arg0 corner 3) (-> arg0 corner 3) sv-228)
    (let* ((a0-38 (-> arg1 class color))
           (a0-45 (copy-and-set-field a0-38 r (shr (* (-> a0-38 r) (the-as uint (-> this color x))) 7)))
           (a0-52 (copy-and-set-field a0-45 g (shr (* (-> a0-45 g) (the-as uint (-> this color y))) 7)))
           (v1-57
             (copy-and-set-field
               (copy-and-set-field a0-52 b (shr (* (-> a0-52 b) (the-as uint (-> this color z))) 7))
               a
               (the int (* 128.0 (-> arg1 alpha)))
               )
             )
           )
      (let ((a0-64 (-> this draw4-tmpl dma-vif quad)))
        (set! (-> (the-as (pointer uint128) sv-208)) a0-64)
        )
      (let ((a0-65 (-> this draw4-tmpl quad 1)))
        (set! (-> (the-as (pointer uint128) sv-208) 1) a0-65)
        )
      (set-vector!
        (-> (the-as (inline-array vector4w) sv-208) 2)
        (the-as int (-> v1-57 r))
        (the-as int (-> v1-57 g))
        (the-as int (-> v1-57 b))
        (the-as int (-> v1-57 a))
        )
      )
    (set-vector! (-> (the-as (inline-array vector) sv-208) 3) 0.0 0.0 1.0 0.0)
    (set-vector!
      (-> (the-as (inline-array vector4w) sv-208) 4)
      (the int (* 16.0 (-> arg0 corner 0 x)))
      (the int (* 16.0 (-> arg0 corner 0 z)))
      #xffffff
      0
      )
    (set-vector! (-> (the-as (inline-array vector) sv-208) 5) 1.0 0.0 1.0 0.0)
    (set-vector!
      (-> (the-as (inline-array vector4w) sv-208) 6)
      (the int (* 16.0 (-> arg0 corner 1 x)))
      (the int (* 16.0 (-> arg0 corner 1 z)))
      #xffffff
      0
      )
    (set-vector! (-> (the-as (inline-array vector) sv-208) 7) 0.0 1.0 1.0 0.0)
    (set-vector!
      (-> (the-as (inline-array vector4w) sv-208) 8)
      (the int (* 16.0 (-> arg0 corner 2 x)))
      (the int (* 16.0 (-> arg0 corner 2 z)))
      #xffffff
      0
      )
    (set-vector! (-> (the-as (inline-array vector) sv-208) 9) 1.0 1.0 1.0 0.0)
    (set-vector!
      (-> (the-as (inline-array vector4w) sv-208) 10)
      (the int (* 16.0 (-> arg0 corner 3 x)))
      (the int (* 16.0 (-> arg0 corner 3 z)))
      #xffffff
      0
      )
    (&+! (-> sv-20 base) 176)
    )
  (none)
  )

;; WARN: Return type mismatch pointer vs none.
(defmethod draw-racer-1 ((this minimap) (arg0 minimap-draw-work) (arg1 connection-minimap) (arg2 float) (arg3 float) (arg4 float))
  (local-vars
    (sv-16 process)
    (sv-20 float)
    (sv-24 dma-buffer)
    (sv-128 pointer)
    (sv-132 vector)
    (sv-136 vector)
    (sv-140 matrix)
    )
  (let ((s0-0 (handle->process (-> arg1 handle))))
    (set! sv-16 (if (type? s0-0 process-drawable)
                    s0-0
                    )
          )
    )
  (set! sv-20 (-> *video-params* relative-x-scale))
  (set! sv-24 (-> arg0 buf))
  (when (and sv-16 (nonzero? (-> (the-as process-drawable sv-16) root)))
    (set! sv-128 (-> sv-24 base))
    (set! sv-132 (new 'stack-no-clear 'vector))
    (set! sv-136 (new 'stack-no-clear 'vector))
    (set! sv-140 (new 'stack-no-clear 'matrix))
    (vector-z-quaternion! sv-136 (-> (the-as process-drawable sv-16) root quat))
    (vector-xz-normalize! sv-136 -1.0)
    (set! (-> sv-136 y) 0.0)
    (set! (-> sv-136 w) 0.0)
    (vector-! sv-132 (-> (the-as process-drawable sv-16) root trans) (-> this race-corner))
    (cond
      ((-> *blit-displays-work* horizontal-flip-flag)
       (let ((f0-4 (+ arg3 (* (- 128.0 (/ (-> sv-132 x) arg2)) sv-20)))
             (f1-4 (+ arg4 (/ (-> sv-132 z) arg2)))
             )
         (set-vector! (-> sv-140 vector 0) (-> sv-136 z) 0.0 (-> sv-136 x) 0.0)
         (set-vector! (-> sv-140 vector 1) 0.0 1.0 0.0 0.0)
         (set-vector! (-> sv-140 vector 2) (- (-> sv-136 x)) 0.0 (-> sv-136 z) 0.0)
         (set-vector! (-> sv-140 trans) f0-4 0.0 f1-4 1.0)
         )
       )
      (else
        (let ((f0-8 (+ arg3 (* (/ (-> sv-132 x) arg2) sv-20)))
              (f1-9 (+ arg4 (/ (-> sv-132 z) arg2)))
              )
          (set-vector! (-> sv-140 vector 0) (-> sv-136 z) 0.0 (- (-> sv-136 x)) 0.0)
          (set-vector! (-> sv-140 vector 1) 0.0 1.0 0.0 0.0)
          (set-vector! (-> sv-140 vector 2) (-> sv-136 x) 0.0 (-> sv-136 z) 0.0)
          (set-vector! (-> sv-140 trans) f0-8 0.0 f1-9 1.0)
          )
        )
      )
    (let ((f0-11 7.0))
      (set-vector! (-> arg0 corner 0) 0.0 0.0 (- f0-11) 1.0)
      (set-vector! (-> arg0 corner 1) f0-11 0.0 0.0 1.0)
      (set-vector! (-> arg0 corner 2) (- f0-11) 0.0 0.0 1.0)
      (set-vector! (-> arg0 corner 3) 0.0 0.0 f0-11 1.0)
      )
    (vector-matrix*! (the-as vector (-> arg0 corner)) (the-as vector (-> arg0 corner)) sv-140)
    (vector-matrix*! (-> arg0 corner 1) (-> arg0 corner 1) sv-140)
    (vector-matrix*! (-> arg0 corner 2) (-> arg0 corner 2) sv-140)
    (vector-matrix*! (-> arg0 corner 3) (-> arg0 corner 3) sv-140)
    (let* ((a0-32 (-> arg1 class color))
           (a0-39 (copy-and-set-field a0-32 r (shr (* (-> a0-32 r) (the-as uint (-> this color x))) 7)))
           (a0-46 (copy-and-set-field a0-39 g (shr (* (-> a0-39 g) (the-as uint (-> this color y))) 7)))
           (v1-59
             (copy-and-set-field
               (copy-and-set-field a0-46 b (shr (* (-> a0-46 b) (the-as uint (-> this color z))) 7))
               a
               (the int (* 128.0 (-> arg1 alpha)))
               )
             )
           )
      (let ((a0-58 (-> this draw4-tmpl dma-vif quad)))
        (set! (-> (the-as (pointer uint128) sv-128)) a0-58)
        )
      (let ((a0-59 (-> this draw4-tmpl quad 1)))
        (set! (-> (the-as (pointer uint128) sv-128) 1) a0-59)
        )
      (set-vector!
        (-> (the-as (inline-array vector4w) sv-128) 2)
        (the-as int (-> v1-59 r))
        (the-as int (-> v1-59 g))
        (the-as int (-> v1-59 b))
        (the-as int (-> v1-59 a))
        )
      )
    (set-vector! (-> (the-as (inline-array vector) sv-128) 3) 0.0 0.0 1.0 0.0)
    (set-vector!
      (-> (the-as (inline-array vector4w) sv-128) 4)
      (the int (* 16.0 (-> arg0 corner 0 x)))
      (the int (* 16.0 (-> arg0 corner 0 z)))
      #xffffff
      0
      )
    (set-vector! (-> (the-as (inline-array vector) sv-128) 5) 1.0 0.0 1.0 0.0)
    (set-vector!
      (-> (the-as (inline-array vector4w) sv-128) 6)
      (the int (* 16.0 (-> arg0 corner 1 x)))
      (the int (* 16.0 (-> arg0 corner 1 z)))
      #xffffff
      0
      )
    (set-vector! (-> (the-as (inline-array vector) sv-128) 7) 0.0 1.0 1.0 0.0)
    (set-vector!
      (-> (the-as (inline-array vector4w) sv-128) 8)
      (the int (* 16.0 (-> arg0 corner 2 x)))
      (the int (* 16.0 (-> arg0 corner 2 z)))
      #xffffff
      0
      )
    (set-vector! (-> (the-as (inline-array vector) sv-128) 9) 1.0 1.0 1.0 0.0)
    (set-vector!
      (-> (the-as (inline-array vector4w) sv-128) 10)
      (the int (* 16.0 (-> arg0 corner 3 x)))
      (the int (* 16.0 (-> arg0 corner 3 z)))
      #xffffff
      0
      )
    (&+! (-> sv-24 base) 176)
    )
  (none)
  )

;; WARN: Return type mismatch pointer vs none.
(defmethod draw-frustum-1 ((this minimap) (arg0 minimap-draw-work) (arg1 connection-minimap))
  (local-vars
    (sv-16 process)
    (sv-20 dma-buffer)
    (sv-208 pointer)
    (sv-212 texture)
    (sv-216 vector)
    (sv-220 vector)
    (sv-224 matrix)
    (sv-228 matrix)
    (sv-232 matrix)
    )
  (rlet ((vf1 :class vf)
         (vf2 :class vf)
         (vf3 :class vf)
         (vf4 :class vf)
         (vf5 :class vf)
         )
    (let ((s3-0 (handle->process (-> arg1 handle))))
      (set! sv-16 (if (type? s3-0 process-drawable)
                      s3-0
                      )
            )
      )
    (set! sv-20 (-> arg0 buf))
    (when (and sv-16 (nonzero? (-> (the-as process-drawable sv-16) root)))
      (set! sv-208 (-> sv-20 base))
      (set! sv-212 (get-texture map-guard-frustum ctywide-minimap))
      (set! sv-216 (new 'stack-no-clear 'vector))
      (set! sv-220 (new 'stack-no-clear 'vector))
      (set! sv-224 (new 'stack-no-clear 'matrix))
      (set! sv-228 (new 'stack-no-clear 'matrix))
      (set! sv-232 (new 'stack-no-clear 'matrix))
      (when sv-212
        (set! (-> sv-220 quad) (-> (#if PC_PORT (if (-> *pc-settings* minimap-force-north) *matrix-minimap-north* (matrix-world->local #f #f)) (matrix-world->local #f #f)) vector 2 quad))
        (set! (-> sv-220 y) 0.0)
        (vector-normalize! sv-220 1.0)
        (vector-z-quaternion! (the-as vector sv-224) (-> (the-as process-drawable sv-16) root quat))
        (vector-xz-normalize! (the-as vector sv-224) 1.0)
        (set! (-> sv-224 vector 0 y) 0.0)
        (set! (-> sv-224 vector 0 w) 0.0)
        (vector-! sv-216 (target-pos 0) (-> (the-as process-drawable sv-16) root trans))
        (let ((f0-4 (/ (-> sv-216 x) (* 16384.0 (-> this offset y))))
              (f1-3 (/ (-> sv-216 z) (* 16384.0 (-> this offset y))))
              )
          (set-vector! (-> sv-228 vector 0) (-> sv-220 z) 0.0 (- (-> sv-220 x)) 0.0)
          (set-vector! (-> sv-228 vector 1) 0.0 1.0 0.0 0.0)
          (set-vector! (-> sv-228 vector 2) (-> sv-220 x) 0.0 (-> sv-220 z) 0.0)
          (set-vector! (-> sv-228 trans) 164.0 0.0 164.0 1.0)
          (set-vector! (-> sv-232 vector 0) (-> sv-224 vector 0 z) 0.0 (- (-> sv-224 vector 0 x)) 0.0)
          (set-vector! (-> sv-232 vector 1) 0.0 1.0 0.0 0.0)
          (set-vector! (-> sv-232 vector 2) (-> sv-224 vector 0 x) 0.0 (-> sv-224 vector 0 z) 0.0)
          (set-vector! (-> sv-232 trans) f0-4 0.0 f1-3 1.0)
          )
        (matrix*! sv-232 sv-232 sv-228)
        (let ((f0-8 (/ -10.0 (-> this offset y))))
          (set-vector! (-> arg0 corner 0) 0.0 0.0 0.0 1.0)
          (set-vector! (-> arg0 corner 1) (- f0-8) 0.0 f0-8 1.0)
          (set-vector! (-> arg0 corner 2) f0-8 0.0 f0-8 1.0)
          (set-vector! (-> arg0 corner 3) 0.0 0.0 (* 2.0 f0-8) 1.0)
          )
        (vector-matrix*! (the-as vector (-> arg0 corner)) (the-as vector (-> arg0 corner)) sv-232)
        (vector-matrix*! (-> arg0 corner 1) (-> arg0 corner 1) sv-232)
        (vector-matrix*! (-> arg0 corner 2) (-> arg0 corner 2) sv-232)
        (vector-matrix*! (-> arg0 corner 3) (-> arg0 corner 3) sv-232)
        (let ((a0-40 (new 'stack-no-clear 'vector))
              (v1-49 (new 'stack-no-clear 'vector))
              )
          (.lvf vf1 (&-> arg0 corner 0 quad))
          (.lvf vf2 (&-> arg0 corner 1 quad))
          (.lvf vf3 (&-> arg0 corner 2 quad))
          (.lvf vf4 (&-> arg0 corner 3 quad))
          (.min.vf vf5 vf1 vf2)
          (.min.vf vf5 vf5 vf3)
          (.min.vf vf5 vf5 vf4)
          (.max.vf vf5 vf1 vf2)
          (.max.vf vf5 vf5 vf3)
          (.max.vf vf5 vf5 vf4)
          (.svf (&-> a0-40 quad) vf5)
          (.svf (&-> v1-49 quad) vf5)
          (when (and (< (-> a0-40 x) 228.0) (< (-> a0-40 z) 228.0) (< 100.0 (-> v1-49 x)) (< 100.0 (-> v1-49 z)))
            (let* ((a0-46 (-> arg1 class color))
                   (a0-53 (copy-and-set-field a0-46 r (shr (* (-> a0-46 r) (the-as uint (-> this color x))) 7)))
                   (a0-60 (copy-and-set-field a0-53 g (shr (* (-> a0-53 g) (the-as uint (-> this color y))) 7)))
                   (s4-1
                     (copy-and-set-field
                       (copy-and-set-field a0-60 b (shr (* (-> a0-60 b) (the-as uint (-> this color z))) 7))
                       a
                       (the int (* 128.0 (-> this frustum-alpha) (-> arg1 alpha)))
                       )
                     )
                   )
              (let ((v1-60 (-> this adgif-tmpl dma-vif quad)))
                (set! (-> (the-as (pointer uint128) sv-208)) v1-60)
                )
              (let ((v1-61 (-> this adgif-tmpl quad 1)))
                (set! (-> (the-as (pointer uint128) sv-208) 1) v1-61)
                )
              (adgif-shader<-texture-simple! (the-as adgif-shader (&+ sv-208 32)) sv-212)
              (let ((v1-63 (-> this draw4-tmpl dma-vif quad)))
                (set! (-> (the-as (pointer uint128) sv-208) 7) v1-63)
                )
              (let ((v1-64 (-> this draw4-tmpl quad 1)))
                (set! (-> (the-as (pointer uint128) sv-208) 8) v1-64)
                )
              (set-vector!
                (-> (the-as (inline-array vector4w) sv-208) 9)
                (the-as int (-> s4-1 r))
                (the-as int (-> s4-1 g))
                (the-as int (-> s4-1 b))
                (the-as int (-> s4-1 a))
                )
              )
            (set-vector! (-> (the-as (inline-array vector) sv-208) 10) 0.0 0.0 1.0 0.0)
            (set-vector!
              (-> (the-as (inline-array vector4w) sv-208) 11)
              (the int (* 16.0 (-> arg0 corner 0 x)))
              (the int (* 16.0 (-> arg0 corner 0 z)))
              0
              0
              )
            (set-vector! (-> (the-as (inline-array vector) sv-208) 12) 1.0 0.0 1.0 0.0)
            (set-vector!
              (-> (the-as (inline-array vector4w) sv-208) 13)
              (the int (* 16.0 (-> arg0 corner 1 x)))
              (the int (* 16.0 (-> arg0 corner 1 z)))
              0
              0
              )
            (set-vector! (-> (the-as (inline-array vector) sv-208) 14) 0.0 1.0 1.0 0.0)
            (set-vector!
              (-> (the-as (inline-array vector4w) sv-208) 15)
              (the int (* 16.0 (-> arg0 corner 2 x)))
              (the int (* 16.0 (-> arg0 corner 2 z)))
              0
              0
              )
            (set-vector! (-> (the-as (inline-array vector) sv-208) 16) 1.0 1.0 1.0 0.0)
            (set-vector!
              (-> (the-as (inline-array vector4w) sv-208) 17)
              (the int (* 16.0 (-> arg0 corner 3 x)))
              (the int (* 16.0 (-> arg0 corner 3 z)))
              0
              0
              )
            (&+! (-> sv-20 base) 288)
            )
          )
        )
      )
    (none)
    )
  )

;; WARN: Return type mismatch pointer vs none.
(defmethod draw-frustum-2 ((this minimap) (arg0 minimap-draw-work) (arg1 connection-minimap))
  (local-vars
    (sv-16 process)
    (sv-20 dma-buffer)
    (sv-208 pointer)
    (sv-212 texture)
    (sv-216 vector)
    (sv-220 vector)
    (sv-224 matrix)
    (sv-228 matrix)
    (sv-232 matrix)
    )
  (let ((s3-0 (handle->process (-> arg1 handle))))
    (set! sv-16 (if (type? s3-0 process-drawable)
                    s3-0
                    )
          )
    )
  (set! sv-20 (-> arg0 buf))
  (when (and sv-16 (nonzero? (-> (the-as process-drawable sv-16) root)))
    (set! sv-208 (-> sv-20 base))
    (set! sv-212 (get-texture map-guard-frustum ctywide-minimap))
    (set! sv-216 (new 'stack-no-clear 'vector))
    (set! sv-220 (new 'stack-no-clear 'vector))
    (set! sv-224 (new 'stack-no-clear 'matrix))
    (set! sv-228 (new 'stack-no-clear 'matrix))
    (set! sv-232 (new 'stack-no-clear 'matrix))
    (when sv-212
      (set! (-> sv-220 quad) (-> (#if PC_PORT (if (-> *pc-settings* minimap-force-north) *matrix-minimap-north* (matrix-world->local #f #f)) (matrix-world->local #f #f)) vector 2 quad))
      (set! (-> sv-220 y) 0.0)
      (vector-normalize! sv-220 1.0)
      (vector-z-quaternion! (the-as vector sv-224) (-> (the-as process-drawable sv-16) root quat))
      (vector-xz-normalize! (the-as vector sv-224) 1.0)
      (set! (-> sv-224 vector 0 y) 0.0)
      (set! (-> sv-224 vector 0 w) 0.0)
      (vector-! sv-216 (target-pos 0) (-> (the-as process-drawable sv-16) root trans))
      (let ((f0-4 (/ (-> sv-216 x) (* 16384.0 (-> this offset y))))
            (f1-3 (/ (-> sv-216 z) (* 16384.0 (-> this offset y))))
            )
        (set-vector! (-> sv-228 vector 0) (-> sv-220 z) 0.0 (- (-> sv-220 x)) 0.0)
        (set-vector! (-> sv-228 vector 1) 0.0 1.0 0.0 0.0)
        (set-vector! (-> sv-228 vector 2) (-> sv-220 x) 0.0 (-> sv-220 z) 0.0)
        (set-vector! (-> sv-228 trans) 164.0 0.0 164.0 1.0)
        (set-vector! (-> sv-232 vector 0) (-> sv-224 vector 0 z) 0.0 (- (-> sv-224 vector 0 x)) 0.0)
        (set-vector! (-> sv-232 vector 1) 0.0 1.0 0.0 0.0)
        (set-vector! (-> sv-232 vector 2) (-> sv-224 vector 0 x) 0.0 (-> sv-224 vector 0 z) 0.0)
        (set-vector! (-> sv-232 trans) f0-4 0.0 f1-3 1.0)
        )
      (matrix*! sv-232 sv-232 sv-228)
      (let ((f0-7 12.0))
        (set-vector! (-> arg0 corner 0) (- f0-7) 0.0 0.0 1.0)
        (set-vector! (-> arg0 corner 1) 0.0 0.0 f0-7 1.0)
        (set-vector! (-> arg0 corner 2) 0.0 0.0 (- f0-7) 1.0)
        (set-vector! (-> arg0 corner 3) f0-7 0.0 0.0 1.0)
        )
      (vector-matrix*! (the-as vector (-> arg0 corner)) (the-as vector (-> arg0 corner)) sv-232)
      (vector-matrix*! (-> arg0 corner 1) (-> arg0 corner 1) sv-232)
      (vector-matrix*! (-> arg0 corner 2) (-> arg0 corner 2) sv-232)
      (vector-matrix*! (-> arg0 corner 3) (-> arg0 corner 3) sv-232)
      (let* ((a3-0 (-> arg1 class color))
             (a2-6 (+ (* (the-as uint 320) (-> arg1 class icon-xy x)) 8))
             (a1-12 (+ (* (the-as uint 320) (-> arg1 class icon-xy y)) 8))
             (v1-54 (+ a2-6 304))
             (a0-43 (+ a1-12 304))
             )
        (let* ((t0-2 (copy-and-set-field a3-0 r (shr (* (-> a3-0 r) (the-as uint (-> this color x))) 7)))
               (t0-9 (copy-and-set-field t0-2 g (shr (* (-> t0-2 g) (the-as uint (-> this color y))) 7)))
               (a3-13
                 (copy-and-set-field
                   (copy-and-set-field t0-9 b (shr (* (-> t0-9 b) (the-as uint (-> this color z))) 7))
                   a
                   (the int (* 128.0 (-> arg1 alpha)))
                   )
                 )
               )
          (let ((t0-21 (-> this draw3-tmpl dma-vif quad)))
            (set! (-> (the-as (pointer uint128) sv-208)) t0-21)
            )
          (let ((t0-22 (-> this draw3-tmpl quad 1)))
            (set! (-> (the-as (pointer uint128) sv-208) 1) t0-22)
            )
          (set-vector!
            (-> (the-as (inline-array vector4w) sv-208) 2)
            (the-as int (-> a3-13 r))
            (the-as int (-> a3-13 g))
            (the-as int (-> a3-13 b))
            (the-as int (-> a3-13 a))
            )
          )
        ;; og:preserve-this cast
        (set-vector! (-> (the-as (inline-array vector4w) sv-208) 3) (the-as int a2-6) (the-as int a1-12) 0 0)
        (set-vector!
          (-> (the-as (inline-array vector4w) sv-208) 4)
          (the int (* 16.0 (-> arg0 corner 0 x)))
          (the int (* 16.0 (-> arg0 corner 0 z)))
          0
          0
          )
        ;; og:preserve-this cast
        (set-vector! (-> (the-as (inline-array vector4w) sv-208) 5) (the-as int a2-6) (the-as int a0-43) 0 0)
        (set-vector!
          (-> (the-as (inline-array vector4w) sv-208) 6)
          (the int (* 16.0 (-> arg0 corner 1 x)))
          (the int (* 16.0 (-> arg0 corner 1 z)))
          0
          0
          )
        ;; og:preserve-this cast
        (set-vector! (-> (the-as (inline-array vector4w) sv-208) 7) (the-as int v1-54) (the-as int a1-12) 0 0)
        (set-vector!
          (-> (the-as (inline-array vector4w) sv-208) 8)
          (the int (* 16.0 (-> arg0 corner 2 x)))
          (the int (* 16.0 (-> arg0 corner 2 z)))
          0
          0
          )
        ;; og:preserve-this cast
        (set-vector! (-> (the-as (inline-array vector4w) sv-208) 9) (the-as int v1-54) (the-as int a0-43) 0 0)
        )
      (set-vector!
        (-> (the-as (inline-array vector4w) sv-208) 10)
        (the int (* 16.0 (-> arg0 corner 3 x)))
        (the int (* 16.0 (-> arg0 corner 3 z)))
        0
        0
        )
      (&+! (-> sv-20 base) 176)
      )
    )
  (none)
  )

(defmethod sub-draw-1-1 ((this minimap) (arg0 minimap-draw-work))
  (let ((s5-0 (-> arg0 buf)))
    (set-display-gs-state s5-0 (the-as int (-> *map-texture-base* vram-page)) 128 128 0 0)
    (let ((s3-0 (-> s5-0 base)))
      (set! (-> (the-as (pointer uint128) s3-0)) (-> this adgif-tmpl dma-vif quad))
      (set! (-> (the-as (pointer uint128) s3-0) 1) (-> this adgif-tmpl quad 1))
      (let ((a1-2 (-> this last-tex)))
        (if (not a1-2)
            (set! a1-2 (get-texture common-white common))
            )
        (adgif-shader<-texture-simple! (the-as adgif-shader (&+ s3-0 32)) (the-as texture a1-2))
        )
      )
    (&+! (-> s5-0 base) 112)
    (dma-buffer-add-gs-set s5-0
                           (clamp-1 (new 'static 'gs-clamp))
                           (test-1 (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest always)))
                           (texa (new 'static 'gs-texa :ta1 #x80))
                           )
    (let ((s3-1 (the-as object (-> s5-0 base))))
      ;; og:preserve-this this fixes minimap stretching at non-4x3 aspeect ratio
      (let ((f30-0 (#if PC_PORT 1.0 (-> *video-params* relative-x-scale))))
        (set! (-> (the-as (pointer uint128) s3-1)) (-> this draw2-tmpl dma-vif quad))
        (set! (-> (the-as (pointer uint128) s3-1) 1) (-> this draw2-tmpl quad 1))
        (let ((s2-0 (new-stack-vector0)))
          (let ((s1-0 (new-stack-vector0)))
            (set! (-> s1-0 quad) (-> (#if PC_PORT (if (-> *pc-settings* minimap-force-north) *matrix-minimap-north* (matrix-local->world #f #f)) (matrix-local->world #f #f)) vector 2 quad))
            (set! (-> s1-0 y) 0.0)
            (vector-normalize! s1-0 1.0)
            (let ((v1-16 (-> arg0 mat)))
              (set! (-> v1-16 vector 0 x) (* (-> s1-0 z) f30-0))
              (set! (-> v1-16 vector 0 y) 0.0)
              (set! (-> v1-16 vector 0 z) (- (-> s1-0 x)))
              (set! (-> v1-16 vector 0 w) 0.0)
              )
            (set-vector! (-> arg0 mat vector 1) 0.0 1.0 0.0 0.0)
            (set-vector! (-> arg0 mat vector 2) (* (-> s1-0 x) f30-0) 0.0 (-> s1-0 z) 0.0)
            )
          (vector-! s2-0 (target-pos 0) (-> this minimap-corner))
          (set! (-> s2-0 x) (/ (-> s2-0 x) (meters 1024)))
          (set! (-> s2-0 z) (/ (-> s2-0 z) (meters 1024)))
          (vector+! (-> arg0 mat trans) s2-0 (-> this offset))
          )
        )
      (set! (-> arg0 mat trans y) 0.0)
      (set! (-> arg0 corner 0 x) (/ (-> this offset y) 4))
      (set! (-> arg0 corner 0 z) (/ (-> this offset y) 4))
      (set! (-> arg0 corner 0 w) 1.0)
      (set! (-> arg0 corner 1 x) (/ (-> this offset y) -4))
      (set! (-> arg0 corner 1 z) (/ (-> this offset y) 4))
      (set! (-> arg0 corner 1 w) 1.0)
      (set! (-> arg0 corner 2 x) (/ (-> this offset y) 4))
      (set! (-> arg0 corner 2 z) (/ (-> this offset y) -4))
      (set! (-> arg0 corner 2 w) 1.0)
      (set! (-> arg0 corner 3 x) (/ (-> this offset y) -4))
      (set! (-> arg0 corner 3 z) (/ (-> this offset y) -4))
      (set! (-> arg0 corner 3 w) 1.0)
      (vector-matrix*! (the-as vector (-> arg0 corner)) (the-as vector (-> arg0 corner)) (-> arg0 mat))
      (vector-matrix*! (-> arg0 corner 1) (-> arg0 corner 1) (-> arg0 mat))
      (vector-matrix*! (-> arg0 corner 2) (-> arg0 corner 2) (-> arg0 mat))
      (vector-matrix*! (-> arg0 corner 3) (-> arg0 corner 3) (-> arg0 mat))
      (set-vector! (-> (the-as (inline-array vector4w) s3-1) 2) 128 128 128 128)
      (set-vector! (-> (the-as (inline-array vector) s3-1) 3) (-> arg0 corner 0 x) (-> arg0 corner 0 z) 1.0 1.0)
      (set-vector! (-> (the-as (inline-array vector4w) s3-1) 4) 0 0 #xffffff 0)
      (set-vector! (-> (the-as (inline-array vector) s3-1) 5) (-> arg0 corner 1 x) (-> arg0 corner 1 z) 1.0 1.0)
      (set-vector! (-> (the-as (inline-array vector4w) s3-1) 6) 2048 0 #xffffff 0)
      (set-vector! (-> (the-as (inline-array vector) s3-1) 7) (-> arg0 corner 2 x) (-> arg0 corner 2 z) 1.0 1.0)
      (set-vector! (-> (the-as (inline-array vector4w) s3-1) 8) 0 2048 #xffffff 0)
      (set-vector! (-> (the-as (inline-array vector) s3-1) 9) (-> arg0 corner 3 x) (-> arg0 corner 3 z) 1.0 1.0)
      (set-vector! (-> (the-as (inline-array vector4w) s3-1) 10) 2048 2048 #xffffff 0)
      )
    (&+! (-> s5-0 base) 176)
    (let ((f0-57 1.0))
      (when *target*
        (if (focus-test? *target* pilot)
            (set! f0-57 0.0)
            )
        )
      (seek! (-> this frustum-alpha) f0-57 (seconds-per-frame))
      )
    (dma-buffer-add-gs-set s5-0 (xyoffset-1 (new 'static 'gs-xy-offset :ofx #x640 :ofy #x640)))
    (when (!= (-> this frustum-alpha) 0.0)
      (let ((s3-2 (the-as connection-pers (-> *minimap* engine alive-list))))
        (while s3-2
          (let ((a2-6 s3-2))
            (if (logtest? (-> (the-as connection-minimap a2-6) class flags) (minimap-flag frustum))
                (draw-frustum-1 this arg0 (the-as connection-minimap a2-6))
                )
            )
          (set! s3-2 (-> s3-2 next))
          )
        )
      )
    (let ((s2-1 (-> arg0 buf base))
          (s3-3 (get-texture mini-map-icons ctywide-minimap))
          )
      (when s3-3
        (set! (-> (the-as (pointer uint128) s2-1)) (-> this adgif-tmpl dma-vif quad))
        (set! (-> (the-as (pointer uint128) s2-1) 1) (-> this adgif-tmpl quad 1))
        (adgif-shader<-texture-simple! (the-as adgif-shader (&+ s2-1 32)) s3-3)
        (&+! (-> arg0 buf base) 112)
        )
      (if (not s3-3)
          (format *stdcon* "minimap: mini-map-icons texture is #f~%")
          )
      )
    (let ((s3-4 (the-as connection-pers (-> *minimap* engine alive-list))))
      (while s3-4
        (let ((a2-7 s3-4))
          (if (logtest? (-> (the-as connection-minimap a2-7) class flags) (minimap-flag frustum))
              (draw-frustum-2 this arg0 (the-as connection-minimap a2-7))
              )
          )
        (set! s3-4 (-> s3-4 next))
        )
      )
    (let ((s3-5 (-> arg0 buf base))
          (a1-32 (get-texture map-target-marker common))
          )
      (when a1-32
        (set! (-> (the-as (pointer uint128) s3-5)) (-> this adgif-tmpl dma-vif quad))
        (set! (-> (the-as (pointer uint128) s3-5) 1) (-> this adgif-tmpl quad 1))
        (adgif-shader<-texture-simple! (the-as adgif-shader (&+ s3-5 32)) a1-32)
        (&+! (-> arg0 buf base) 112)
        )
      )
    (let ((s3-6 (the-as connection-pers (-> *minimap* engine alive-list))))
      (while s3-6
        (let ((a2-8 s3-6))
          (if (logtest? (-> (the-as connection-minimap a2-8) class flags) (minimap-flag racer))
              (draw-racer-2 this arg0 (the-as connection-minimap a2-8))
              )
          )
        (set! s3-6 (-> s3-6 next))
        )
      )
    (dma-buffer-add-gs-set s5-0
                           (frame-1 (new 'static 'gs-frame :fbw #x2 :fbmsk #xffffff :fbp (-> *map-texture-base* vram-page)))
                           (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
                           (xyoffset-1 (new 'static 'gs-xy-offset))
                           )
    (let ((s3-7 (the-as object (-> s5-0 base))))
      (set! (-> (the-as (pointer uint128) s3-7)) (-> this adgif-tmpl dma-vif quad))
      (set! (-> (the-as (pointer uint128) s3-7) 1) (-> this adgif-tmpl quad 1))
      (adgif-shader<-texture-simple!
        (the-as adgif-shader (&-> (the-as (pointer uint128) s3-7) 2))
        (get-texture minimap-mask level-default-minimap)
        )
      (set! (-> (the-as (pointer uint128) s3-7) 7) (-> this sprite-tmpl dma-vif quad))
      (set! (-> (the-as (pointer uint128) s3-7) 8) (-> this sprite-tmpl quad 1))
      (set-vector! (-> (the-as (inline-array vector4w) s3-7) 9) 128 128 128 128)
      (set-vector! (-> (the-as (inline-array vector4w) s3-7) 10) 0 0 0 0)
      (set-vector! (-> (the-as (inline-array vector4w) s3-7) 11) 0 0 #xffffff 0)
      (set-vector! (-> (the-as (inline-array vector4w) s3-7) 12) 1024 1024 0 0)
      (set-vector! (-> (the-as (inline-array vector4w) s3-7) 13) 2048 2048 #xffffff 0)
      )
    (&+! (-> s5-0 base) 224)
    (set! (-> arg0 buf) s5-0)
    )
  0
  (none)
  )

(defmethod sub-draw-1-2 ((this minimap) (arg0 minimap-draw-work))
  (local-vars (a3-4 int) (t0-4 int) (sv-48 vector) (sv-52 matrix) (sv-56 vector))
  (let ((s5-0 (-> arg0 buf)))
    (reset-display-gs-state *display* s5-0)
    (dma-buffer-add-gs-set s5-0
                           (test-1 (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)))
                           (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1))
                           (tex0-1 (new 'static 'gs-tex0
                                     :tbw #x2
                                     :tcc #x1
                                     :th (log2 128)
                                     :tw (log2 128)
                                     :tbp0 (-> *map-texture-base* vram-block)
                                     )
                                   )
                           (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
                           (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)))
                           (texflush 0)
                           )
    (let ((f30-0 (-> *video-params* relative-x-scale)))
      (let ((v1-20 (the-as object (-> s5-0 base)))
            (t0-0 (the int (* 112.0 f30-0)))
            )
        0
        0
        (let ((a2-0 (* (+ (-> arg0 draw-pos y) 1840) 16))
              (a0-19 (* (+ (-> arg0 draw-pos y) 1952) 16))
              (a1-7 (-> arg0 draw-pos z))
              )
          (cond
            ((-> arg0 justify-right)
             (set! a3-4 (* (+ (- 1792 t0-0) (-> arg0 draw-pos x)) 16))
             (set! t0-4 (* (+ (-> arg0 draw-pos x) 1792) 16))
             )
            (else
              (set! a3-4 (* (+ (-> arg0 draw-pos x) 1792) 16))
              (set! t0-4 (* (+ t0-0 1792 (-> arg0 draw-pos x)) 16))
              )
            )
          (set! (-> (the-as (pointer uint128) v1-20)) (-> this sprite-tmpl dma-vif quad))
          (set! (-> (the-as (pointer uint128) v1-20) 1) (-> this sprite-tmpl quad 1))
          (let ((t1-5 (-> this color quad)))
            (set! (-> (the-as (pointer uint128) (&+ (the-as pointer v1-20) 32))) t1-5)
            )
          (cond
            ((-> *blit-displays-work* horizontal-flip-flag)
             (set-vector! (-> (the-as (inline-array vector4w) v1-20) 3) 0 0 0 0)
             (set-vector! (-> (the-as (inline-array vector4w) v1-20) 4) t0-4 a2-0 a1-7 0)
             (set-vector! (-> (the-as (inline-array vector4w) v1-20) 5) 2048 2048 0 0)
             (let ((v1-21 (the-as (inline-array vector4w) (-> (the-as (inline-array vector4w) v1-20) 6))))
               (set! (-> v1-21 0 x) a3-4)
               (set! (-> v1-21 0 y) a0-19)
               (set! (-> v1-21 0 z) a1-7)
               (set! (-> v1-21 0 w) 0)
               )
             )
            (else
              (set-vector! (-> (the-as (inline-array vector4w) v1-20) 3) 0 0 0 0)
              (set-vector! (-> (the-as (inline-array vector4w) v1-20) 4) a3-4 a2-0 a1-7 0)
              (set-vector! (-> (the-as (inline-array vector4w) v1-20) 5) 2048 2048 0 0)
              (set-vector! (-> (the-as (inline-array vector4w) v1-20) 6) t0-4 a0-19 a1-7 0)
              )
            )
          )
        )
      (&+! (-> s5-0 base) 112)
      (dma-buffer-add-gs-set s5-0
                             (test-1 (new 'static 'gs-test :ate #x1 :atst (gs-atest greater) :zte #x1 :ztst (gs-ztest always)))
                             )
      (set! sv-48 (new-stack-vector0))
      (let ((v1-29 (new 'stack-no-clear 'matrix)))
        (set! (-> v1-29 quad 0) (the-as uint128 0))
        (set! sv-52 v1-29)
        )
      (set! sv-56 (target-pos 0))
      (set! (-> sv-52 quad 0) (-> (#if PC_PORT (if (-> *pc-settings* minimap-force-north) *matrix-minimap-north* (matrix-world->local #f #f)) (matrix-world->local #f #f)) vector 2 quad))
      (set! (-> sv-52 vector 0 y) 0.0)
      (vector-normalize! (the-as vector sv-52) 1.0)
      (cond
        ((-> *blit-displays-work* horizontal-flip-flag)
         (let ((v1-35 (-> arg0 mat)))
           ;; og:preserve-this
           (set! (-> v1-35 vector 0 x) (* (-> sv-52 vector 0 z) (- (#if PC_PORT 1.0 f30-0))))
           (set! (-> v1-35 vector 0 y) 0.0)
           (set! (-> v1-35 vector 0 z) (- (-> sv-52 vector 0 x)))
           (set! (-> v1-35 vector 0 w) 0.0)
           )
         (set-vector! (-> arg0 mat vector 1) 0.0 1.0 0.0 0.0)
         ;; og:preserve-this
         (set-vector! (-> arg0 mat vector 2) (* (-> sv-52 vector 0 x) (- (#if PC_PORT 1.0 f30-0))) 0.0 (-> sv-52 vector 0 z) 0.0)
         (set-vector! (-> arg0 mat trans) 0.0 0.0 (the float (+ (-> arg0 draw-pos y) 1896)) 1.0)
         )
        (else
          (let ((v1-39 (-> arg0 mat)))
            ;; og:preserve-this
            (set! (-> v1-39 vector 0 x) (* (-> sv-52 vector 0 z) (#if PC_PORT 1.0 f30-0)))
            (set! (-> v1-39 vector 0 y) 0.0)
            (set! (-> v1-39 vector 0 z) (- (-> sv-52 vector 0 x)))
            (set! (-> v1-39 vector 0 w) 0.0)
            )
          (set-vector! (-> arg0 mat vector 1) 0.0 1.0 0.0 0.0)
          ;; og:preserve-this
          (set-vector! (-> arg0 mat vector 2) (* (-> sv-52 vector 0 x) (#if PC_PORT 1.0 f30-0)) 0.0 (-> sv-52 vector 0 z) 0.0)
          (set-vector! (-> arg0 mat trans) 0.0 0.0 (the float (+ (-> arg0 draw-pos y) 1896)) 1.0)
          )
        )
      (let ((v1-44 (the int (* 56.0 f30-0))))
        (if (-> arg0 justify-right)
            (set! (-> arg0 mat trans x) (the float (+ (- 1792 v1-44) (-> arg0 draw-pos x))))
            (set! (-> arg0 mat trans x) (the float (+ v1-44 1792 (-> arg0 draw-pos x))))
            )
        )
      (when *target*
        (vector-z-quaternion! (the-as vector sv-52) (-> *target* control quat))
        (vector-xz-normalize! (the-as vector sv-52) 1.0)
        (set! (-> sv-52 vector 0 y) 0.0)
        (set! (-> sv-52 vector 0 w) 0.0)
        (vector-matrix*! (the-as vector sv-52) (the-as vector sv-52) (-> arg0 mat))
        (let ((s3-2 (the-as object (-> s5-0 base)))
              (s2-1 (get-texture map-target-marker common))
              (s1-2 (new 'stack-no-clear 'matrix))
              (v1-57 (the int (* 56.0 f30-0)))
              )
          (when s2-1
            (set-vector! (-> s1-2 vector 0) (* (-> sv-52 vector 0 z) f30-0) 0.0 (- (-> sv-52 vector 0 x)) 0.0)
            (set-vector! (-> s1-2 vector 1) 0.0 1.0 0.0 0.0)
            (set-vector! (-> s1-2 vector 2) (* (-> sv-52 vector 0 x) f30-0) 0.0 (-> sv-52 vector 0 z) 1.0)
            (set-vector! (-> s1-2 trans) 0.0 0.0 (the float (+ (-> arg0 draw-pos y) 1896)) 1.0)
            (if (-> arg0 justify-right)
                (set! (-> s1-2 trans x) (the float (+ (- 1792 v1-57) (-> arg0 draw-pos x))))
                (set! (-> s1-2 trans x) (the float (+ v1-57 1792 (-> arg0 draw-pos x))))
                )
            (let ((f0-80 7.0))
              (set-vector! (-> arg0 corner 0) 0.0 0.0 (- f0-80) 1.0)
              (set-vector! (-> arg0 corner 1) f0-80 0.0 0.0 1.0)
              (set-vector! (-> arg0 corner 2) (- f0-80) 0.0 0.0 1.0)
              (set-vector! (-> arg0 corner 3) 0.0 0.0 f0-80 1.0)
              )
            (vector-matrix*! (the-as vector (-> arg0 corner)) (the-as vector (-> arg0 corner)) s1-2)
            (vector-matrix*! (-> arg0 corner 1) (-> arg0 corner 1) s1-2)
            (vector-matrix*! (-> arg0 corner 2) (-> arg0 corner 2) s1-2)
            (vector-matrix*! (-> arg0 corner 3) (-> arg0 corner 3) s1-2)
            (set! (-> (the-as (pointer uint128) s3-2)) (-> this adgif-tmpl dma-vif quad))
            (set! (-> (the-as (pointer uint128) s3-2) 1) (-> this adgif-tmpl quad 1))
            (adgif-shader<-texture-simple! (the-as adgif-shader (&-> (the-as (pointer uint128) s3-2) 2)) s2-1)
            (set! (-> (the-as (pointer uint128) s3-2) 7) (-> this draw-tmpl dma-vif quad))
            (set! (-> (the-as (pointer uint128) s3-2) 8) (-> this draw-tmpl quad 1))
            (set-vector! (-> (the-as (inline-array vector4w) s3-2) 9) 0 255 255 128)
            (set-vector! (-> (the-as (inline-array vector4w) s3-2) 10) 0 0 #xffffff 0)
            (set-vector!
              (-> (the-as (inline-array vector4w) s3-2) 11)
              (the int (* 16.0 (-> arg0 corner 0 x)))
              (the int (* 16.0 (-> arg0 corner 0 z)))
              0
              0
              )
            (set-vector! (-> (the-as (inline-array vector4w) s3-2) 12) 256 0 #xffffff 0)
            (set-vector!
              (-> (the-as (inline-array vector4w) s3-2) 13)
              (the int (* 16.0 (-> arg0 corner 1 x)))
              (the int (* 16.0 (-> arg0 corner 1 z)))
              0
              0
              )
            (set-vector! (-> (the-as (inline-array vector4w) s3-2) 14) 0 256 #xffffff 0)
            (set-vector!
              (-> (the-as (inline-array vector4w) s3-2) 15)
              (the int (* 16.0 (-> arg0 corner 2 x)))
              (the int (* 16.0 (-> arg0 corner 2 z)))
              0
              0
              )
            (set-vector! (-> (the-as (inline-array vector4w) s3-2) 16) 256 256 #xffffff 0)
            (set-vector!
              (-> (the-as (inline-array vector4w) s3-2) 17)
              (the int (* 16.0 (-> arg0 corner 3 x)))
              (the int (* 16.0 (-> arg0 corner 3 z)))
              0
              0
              )
            (&+! (-> s5-0 base) 288)
            )
          )
        )
      ;; og:preserve-this revert widescreen correction done earlier
      (#when PC_PORT
        (*! (-> arg0 mat vector 0 x) f30-0)
        (*! (-> arg0 mat vector 2 x) f30-0)
        )
      )
    (set! (-> arg0 buf) s5-0)
    )
  0
  (none)
  )

;; WARN: Return type mismatch pointer vs none.
(defmethod draw-connection ((this minimap) (arg0 minimap-draw-work) (arg1 connection-minimap))
  (let ((s1-0 (target-pos 0)))
    (cond
      ((= (-> arg1 position) #t)
       (let* ((s3-0 (handle->process (-> arg1 handle)))
              (v1-4 (if (type? s3-0 process-drawable)
                        s3-0
                        )
                    )
              )
         (when (and v1-4 (nonzero? (-> (the-as process-drawable v1-4) root)))
           (set! (-> arg1 last-world-pos quad) (-> (the-as process-drawable v1-4) root trans quad))
           (vector-! (-> arg1 last-relative-pos) s1-0 (-> arg1 last-world-pos))
           )
         )
       )
      ((and (= (logand (the-as int (-> arg1 position)) 7) 4)
            (= (-> (the-as basic (-> arg1 position)) type) entity-actor)
            )
       (let* ((v1-15 (-> arg1 position))
              (s3-1 (if v1-15
                        (-> (the-as entity-actor v1-15) extra process)
                        )
                    )
              (a0-16 (if (type? s3-1 process-drawable)
                         s3-1
                         )
                     )
              )
         (cond
           (a0-16
             (set! (-> arg1 last-world-pos quad) (-> (the-as process-drawable a0-16) root trans quad))
             (vector-! (-> arg1 last-relative-pos) s1-0 (-> arg1 last-world-pos))
             )
           (else
             (set! (-> arg1 last-world-pos quad) (-> (the-as entity-actor (-> arg1 position)) extra trans quad))
             (vector-! (-> arg1 last-relative-pos) s1-0 (-> arg1 last-world-pos))
             )
           )
         )
       )
      (else
        (set! (-> arg1 last-world-pos quad) (-> (the-as vector (-> arg1 position)) quad))
        (vector-! (-> arg1 last-relative-pos) s1-0 (-> arg1 last-world-pos))
        )
      )
    (let ((s3-2 (new 'stack-no-clear 'vector))
          (s2-0 #f)
          )
      (let ((f30-0 (/ 1.0 (* 16384.0 (-> this offset y)))))
        0.0
        (set! (-> s3-2 quad) (-> arg1 last-relative-pos quad))
        (set! (-> s3-2 x) (* (-> s3-2 x) f30-0))
        (set! (-> s3-2 z) (* (-> s3-2 z) f30-0))
        (set! (-> s3-2 y) 0.0)
        (set! (-> s3-2 w) 1.0)
        (let* ((v1-29 s3-2)
               (f28-0 (sqrtf (+ (* (-> v1-29 x) (-> v1-29 x)) (* (-> v1-29 z) (-> v1-29 z)))))
               )
          (cond
            ((logtest? (-> arg1 class flags) (minimap-flag trail))
             (cond
               (*trail-graph*
                 (let ((a2-2 (get-trail-for-connection this arg1 #f)))
                   (cond
                     ((not a2-2)
                      (when (!= (-> arg1 alpha) 0.0)
                        (when (not (get-trail-for-connection this arg1 #t))
                          (let ((s2-1 (the-as connection-pers (-> *minimap* engine alive-list))))
                            (while s2-1
                              (let ((a1-12 s2-1))
                                (if (and (= (the-as float (-> a1-12 param 1)) 0.0) (logtest? (-> arg1 class flags) (minimap-flag trail)))
                                    (free-trail-by-connection *minimap* (the-as connection-minimap a1-12))
                                    )
                                )
                              (set! s2-1 (-> s2-1 next))
                              )
                            )
                          )
                        )
                      (set! s2-0 #t)
                      (set! (-> arg1 edge-ry) -131072.0)
                      )
                     ((time-elapsed? (the-as int (-> a2-2 last-updated)) (seconds 5))
                      (set! s2-0 #t)
                      (set! (-> arg1 edge-ry) -131072.0)
                      )
                     ((< 50.0 f28-0)
                      (let ((s0-0 (new 'stack-no-clear 'vector)))
                        (set! (-> s0-0 quad) (-> s3-2 quad))
                        (let ((s1-1 (get-icon-draw-pos *minimap* arg1 a2-2 s1-0 f30-0 s3-2)))
                          (if (not s1-1)
                              (vector-normalize-copy! s3-2 s0-0 66.0)
                              )
                          (let ((f30-1 (atan (-> s3-2 x) (-> s3-2 z))))
                            (let ((f28-1 (-> arg1 edge-ry)))
                              (when (!= f28-1 -131072.0)
                                (let* ((f0-20 (deg- f30-1 f28-1))
                                       (f1-7 (fabs f0-20))
                                       (f2-3 (* 16384.0 (seconds-per-frame)))
                                       )
                                  (when (< f2-3 f1-7)
                                    (set! f30-1 (+ f28-1 (if (>= f0-20 0.0)
                                                             f2-3
                                                             (- f2-3)
                                                             )
                                                   )
                                          )
                                    (set-vector! s3-2 (sin f30-1) 0.0 (cos f30-1) 1.0)
                                    (vector-normalize! s3-2 (if s1-1
                                                                50.0
                                                                66.0
                                                                )
                                                       )
                                    )
                                  )
                                )
                              )
                            (set! (-> arg1 edge-ry) f30-1)
                            )
                          )
                        )
                      )
                     (else
                       (set! (-> arg1 edge-ry) (atan (-> s3-2 x) (-> s3-2 z)))
                       )
                     )
                   )
                 )
               (else
                 (set! s2-0 #t)
                 (set! (-> arg1 edge-ry) -131072.0)
                 )
               )
             )
            ((logtest? (-> arg1 class flags) (minimap-flag clamp))
             (cond
               ((< 50.0 f28-0)
                (let ((a1-19 (new 'stack-no-clear 'vector)))
                  (set! (-> a1-19 quad) (-> s3-2 quad))
                  (vector-normalize-copy! s3-2 a1-19 54.0)
                  )
                (let ((f30-2 (atan (-> s3-2 x) (-> s3-2 z))))
                  (let ((f28-2 (-> arg1 edge-ry)))
                    (when (!= f28-2 -131072.0)
                      (let* ((f0-35 (deg- f30-2 f28-2))
                             (f1-9 (fabs f0-35))
                             (f2-5 (* 16384.0 (seconds-per-frame)))
                             )
                        (when (< f2-5 f1-9)
                          (set! f30-2 (+ f28-2 (if (>= f0-35 0.0)
                                                   f2-5
                                                   (- f2-5)
                                                   )
                                         )
                                )
                          (set-vector! s3-2 (sin f30-2) 0.0 (cos f30-2) 1.0)
                          (vector-normalize! s3-2 54.0)
                          )
                        )
                      )
                    )
                  (set! (-> arg1 edge-ry) f30-2)
                  )
                )
               (else
                 (set! (-> arg1 edge-ry) (atan (-> s3-2 x) (-> s3-2 z)))
                 )
               )
             )
            (else
              (if (< 50.0 f28-0)
                  (set! s2-0 #t)
                  )
              )
            )
          )
        )
      (if (or (logtest? (-> arg1 class flags) (minimap-flag frustum))
              (logtest? (-> arg1 class flags) (minimap-flag racer))
              (and (logtest? (-> arg1 class flags) (minimap-flag flash))
                   ;; og:preserve-this high fps fix
                   (< (the-as int (logand (the int (* DISPLAY_FPS_RATIO (-> *display* base-clock integral-frame-counter))) 15)) 8)
                   )
              )
          (set! s2-0 #t)
          )
      (if (logtest? (-> arg1 class flags) (minimap-flag goal))
          (set! (-> arg1 class icon-xy x) (the-as uint (mod (the int (-> this goal-time)) 6)))
          )
      (when (not s2-0)
        (vector-matrix*! s3-2 s3-2 (-> arg0 mat))
        (let ((v1-115 (the-as object (-> arg0 buf base))))
          (let* ((f0-48 (-> arg1 class scale))
                 (a1-25 (-> arg1 class color))
                 (a1-32 (copy-and-set-field a1-25 r (shr (* (-> a1-25 r) (the-as uint (-> this color x))) 7)))
                 (a1-39 (copy-and-set-field a1-32 g (shr (* (-> a1-32 g) (the-as uint (-> this color y))) 7)))
                 (a0-70
                   (copy-and-set-field
                     (copy-and-set-field a1-39 b (shr (* (-> a1-39 b) (the-as uint (-> this color z))) 7))
                     a
                     (the int (* 128.0 (-> arg1 alpha)))
                     )
                   )
                 )
            (let ((f1-16 (* 20.0 (-> *video-params* relative-x-scale) f0-48))
                  (f0-49 (* 20.0 f0-48))
                  )
              (set! (-> arg0 corner 0 x) (the float (the int (- (-> s3-2 x) (* 0.5 f1-16)))))
              (set! (-> arg0 corner 0 z) (the float (the int (- (-> s3-2 z) (* 0.5 f0-49)))))
              ;; og:preserve-this
              (#when PC_PORT
                ;; pc port note : don't align icons to PS2 framebuffer positions since
                ;; it results in jagged motion on PC, since the framebuffer can be any size we want
                (when (-> *pc-settings* smooth-minimap?)
                  (set! (-> arg0 corner 0 x) (- (-> s3-2 x) (* 0.5 f1-16)))
                  (set! (-> arg0 corner 0 z) (- (-> s3-2 z) (* 0.5 f0-49)))
                  )
                )
              (set! (-> arg0 corner 1 x) (+ (-> arg0 corner 0 x) f1-16))
              (set! (-> arg0 corner 1 z) (+ (-> arg0 corner 0 z) f0-49))
              )
            (let* ((a3-1 (+ (* (the-as uint 320) (-> arg1 class icon-xy x)) 8))
                   (t0-1 (+ (* (the-as uint 320) (-> arg1 class icon-xy y)) 8))
                   (a1-61 (+ a3-1 300)) ;; og:preserve-this fix icon misalign
                   (a2-14 (+ t0-1 300)) ;; og:preserve-this fix icon misalign
                   )
              (set! (-> (the-as (pointer uint128) v1-115)) (-> this sprite-tmpl dma-vif quad))
              (set! (-> (the-as (pointer uint128) v1-115) 1) (-> this sprite-tmpl quad 1))
              (set-vector!
                (-> (the-as (inline-array vector4w) v1-115) 2)
                (the-as int (-> a0-70 r))
                (the-as int (-> a0-70 g))
                (the-as int (-> a0-70 b))
                (the-as int (-> a0-70 a))
                )
              (set-vector! (-> (the-as (inline-array vector4w) v1-115) 3) (the-as int a3-1) (the-as int t0-1) 0 0)
              (set-vector!
                (-> (the-as (inline-array vector4w) v1-115) 4)
                (the int (* 16.0 (-> arg0 corner 0 x)))
                (the int (* 16.0 (-> arg0 corner 0 z)))
                #xffffff
                0
                )
              (set-vector! (-> (the-as (inline-array vector4w) v1-115) 5) (the-as int a1-61) (the-as int a2-14) 0 0)
              )
            )
          (set-vector!
            (-> (the-as (inline-array vector4w) v1-115) 6)
            (the int (* 16.0 (-> arg0 corner 1 x)))
            (the int (* 16.0 (-> arg0 corner 1 z)))
            #xffffff
            0
            )
          )
        (&+! (-> arg0 buf base) 112)
        )
      )
    )
  (none)
  )

(defmethod draw-1 ((this minimap) (arg0 dma-buffer) (arg1 vector4w) (arg2 symbol))
  (local-vars (v1-19 uint128))
  (when (= (level-status *level* 'ctywide) 'active)
    (let ((s5-1 (new 'stack-no-clear 'minimap-draw-work)))
      (set! (-> s5-1 buf) arg0)
      (set! (-> s5-1 draw-pos quad) (-> arg1 quad))
      (set! (-> s5-1 justify-right) arg2)
      (sub-draw-1-1 this s5-1)
      (sub-draw-1-2 this s5-1)
      (set! (-> this ctywide) (level-get *level* 'ctywide))
      (let ((s2-1 (-> s5-1 buf base))
            (s4-1 (get-texture mini-map-icons ctywide-minimap))
            )
        (let ((s3-1 (-> this ctywide texture-mask 8)))
          (when s4-1
            (set! (-> (the-as (pointer uint128) s2-1)) (-> this adgif-tmpl dma-vif quad))
            (set! (-> (the-as (pointer uint128) s2-1) 1) (-> this adgif-tmpl quad 1))
            (adgif-shader<-texture-simple! (the-as adgif-shader (&+ s2-1 32)) s4-1)
            (&+! (-> s5-1 buf base) 112)
            (let ((v1-18 (-> s3-1 mask quad))
                  (a0-8 (-> s4-1 masks data 0 mask quad))
                  )
              (.por v1-19 v1-18 a0-8)
              )
            (set! (-> s3-1 mask quad) v1-19)
            )
          )
        (if (not s4-1)
            (format *stdcon* "minimap: mini-map-icons texture is #f~%")
            )
        )
      (let ((s4-2 (the-as connection-pers (-> *minimap* engine alive-list))))
        (while s4-2
          (let ((a2-1 s4-2))
            (draw-connection this s5-1 (the-as connection-minimap a2-1))
            )
          (set! s4-2 (-> s4-2 next))
          )
        )
      (if (not (paused?))
          (+! (-> this goal-time) (* 14.0 (seconds-per-frame)))
          )
      (reset-display-gs-state *display* (-> s5-1 buf))
      )
    )
  0
  (none)
  )

(defmethod draw-sprite2 ((this minimap) (arg0 dma-buffer) (arg1 vector4w) (arg2 symbol))
  (local-vars (v1-24 uint128) (a0-8 uint128) (a3-5 int) (t0-4 int))
  (when (-> this race-tex)
    (let ((s5-0 (new 'stack-no-clear 'minimap-draw-work)))
      (set! (-> s5-0 buf) arg0)
      (set! (-> s5-0 draw-pos quad) (-> arg1 quad))
      (set! (-> s5-0 justify-right) arg2)
      (let ((v1-4 (-> s5-0 buf base))
            (s3-0 (-> this race-tex))
            (s2-0 (-> this race-level texture-mask 8))
            )
        (when s3-0
          (set! (-> (the-as (pointer uint128) v1-4)) (-> this adgif-tmpl dma-vif quad))
          (set! (-> (the-as (pointer uint128) v1-4) 1) (-> this adgif-tmpl quad 1))
          (adgif-shader<-texture-simple! (the-as adgif-shader (&+ v1-4 32)) s3-0)
          (&+! (-> s5-0 buf base) 112)
          (let ((v1-8 (-> s2-0 mask quad))
                (a0-7 (-> s3-0 masks data 0 mask quad))
                )
            (.por a0-8 v1-8 a0-7)
            )
          (set! (-> s2-0 mask quad) a0-8)
          )
        )
      (let* ((f0-0 (-> *video-params* relative-x-scale))
             (v1-10 (the-as object (-> arg0 base)))
             (t0-0 (the int (* 128.0 f0-0)))
             )
        0
        0
        (let ((a2-1 (* (+ (-> s5-0 draw-pos y) 1840) 16))
              (a0-16 (* (+ (-> s5-0 draw-pos y) 1968) 16))
              (a1-2 (-> s5-0 draw-pos z))
              )
          (cond
            ((-> s5-0 justify-right)
             (set! a3-5 (* (+ (- 1792 t0-0) (-> s5-0 draw-pos x)) 16))
             (set! t0-4 (* (+ (-> s5-0 draw-pos x) 1792) 16))
             )
            (else
              (set! a3-5 (* (+ (-> s5-0 draw-pos x) 1792) 16))
              (set! t0-4 (* (+ t0-0 1792 (-> s5-0 draw-pos x)) 16))
              )
            )
          (set! (-> s5-0 draw-pos x) a3-5)
          (set! (-> s5-0 draw-pos y) a2-1)
          (set! (-> (the-as (pointer uint128) v1-10)) (-> this sprite2-tmpl dma-vif quad))
          (set! (-> (the-as (pointer uint128) v1-10) 1) (-> this sprite2-tmpl quad 1))
          (let ((t1-5 (-> this color quad)))
            (set! (-> (the-as (pointer uint128) (&+ (the-as pointer v1-10) 32))) t1-5)
            )
          (cond
            ((-> *blit-displays-work* horizontal-flip-flag)
             (set-vector! (-> (the-as (inline-array vector) v1-10) 3) 0.0 0.0 1.0 0.0)
             (set-vector! (-> (the-as (inline-array vector4w) v1-10) 4) t0-4 a2-1 a1-2 0)
             (set-vector! (-> (the-as (inline-array vector) v1-10) 5) 1.0 1.0 1.0 0.0)
             (set-vector! (-> (the-as (inline-array vector4w) v1-10) 6) a3-5 a0-16 a1-2 0)
             )
            (else
              (set-vector! (-> (the-as (inline-array vector) v1-10) 3) 0.0 0.0 1.0 0.0)
              (set-vector! (-> (the-as (inline-array vector4w) v1-10) 4) a3-5 a2-1 a1-2 0)
              (set-vector! (-> (the-as (inline-array vector) v1-10) 5) 1.0 1.0 1.0 0.0)
              (set-vector! (-> (the-as (inline-array vector4w) v1-10) 6) t0-4 a0-16 a1-2 0)
              )
            )
          )
        )
      (&+! (-> arg0 base) 112)
      (let ((s2-1 (-> s5-0 buf base))
            (s4-1 (get-texture map-target-marker common))
            (s3-1 (-> this ctywide texture-mask 8))
            )
        (when s4-1
          (set! (-> (the-as (pointer uint128) s2-1)) (-> this adgif-tmpl dma-vif quad))
          (set! (-> (the-as (pointer uint128) s2-1) 1) (-> this adgif-tmpl quad 1))
          (adgif-shader<-texture-simple! (the-as adgif-shader (&+ s2-1 32)) s4-1)
          (&+! (-> s5-0 buf base) 112)
          (let ((v1-23 (-> s3-1 mask quad))
                (a0-20 (-> s4-1 masks data 0 mask quad))
                )
            (.por v1-24 v1-23 a0-20)
            )
          (set! (-> s3-1 mask quad) v1-24)
          )
        )
      (let ((f30-0 (the float (/ (-> s5-0 draw-pos x) 16)))
            (f28-0 (the float (/ (-> s5-0 draw-pos y) 16)))
            (s4-2 (the-as connection-pers #f))
            )
        (let ((s3-2 (the-as connection-pers (-> *minimap* engine alive-list))))
          (while s3-2
            (let ((s2-2 s3-2))
              (when (logtest? (-> (the-as connection-minimap s2-2) class flags) (minimap-flag racer))
                (if (string= (the-as string (-> (the-as connection-minimap s2-2) class name)) "racer-target")
                    (set! s4-2 s2-2)
                    (draw-racer-1 this s5-0 (the-as connection-minimap s2-2) (-> this race-scale) f30-0 f28-0)
                    )
                )
              )
            (set! s3-2 (-> s3-2 next))
            )
          )
        (if s4-2
            (draw-racer-1 this s5-0 (the-as connection-minimap s4-2) (-> this race-scale) f30-0 f28-0)
            )
        )
      )
    )
  0
  (none)
  )

(defmethod set-race-texture ((this minimap) (arg0 texture) (arg1 float) (arg2 level))
  (set! (-> this race-tex) arg0)
  (set! (-> this race-scale) arg1)
  (set! (-> this race-level) arg2)
  0
  (none)
  )

(defmethod set-race-corner ((this minimap) (arg0 float) (arg1 float))
  (set! (-> this race-corner x) arg0)
  (set! (-> this race-corner z) arg1)
  0
  (none)
  )

(defmethod set-color ((this minimap) (arg0 vector))
  (set! (-> this color quad) (-> arg0 quad))
  0
  (none)
  )
