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

;; name: minimap-h.gc
;; name in dgo: minimap-h
;; dgos: GAME

(defenum minimap-flag
  :type uint32
  :bitfield #t
  (active 0)
  (fade-in 1)
  (fade-out 2)
  (clamp 3)
  (trail 4)
  (task-graph 5)
  (flash 6)
  (minimap 7)
  (background 8)
  (task 9)
  (enemy 10)
  (frustum 11)
  (racer 12)
  (bigmap 13)
  (bigmap-only 14)
  (goal 15)
  (local-only 16)
  (transport 17)
  (ctywide 18)
  (wasall 19)
  (waswide 20)
  (desert 21)
  )

(defenum minimap-class
  :type uint16
  (none 0)
  (onintent 1)
  (vinroom 2)
  (sewer-kg 3)
  (sewer-genb 4)
  (sewer-slumb 5)
  (hiphog 6)
  (gungame 7)
  (gun-yellow 8)
  (desert-nest-entrance 9)
  (guard 10)
  (parking-spot 11)
  (goal 12)
  (goal-no-trail 13)
  (goal-no-trail-bigmap 14)
  (cty-sniper-vicinity 15)
  (forest 16)
  (wascity-gungame 17)
  (city-transport 18)
  (wascity-leaper-race 19)
  (wascity-pre-game 20)
  (desert-transport 21)
  (waspal 22)
  (stadium 23)
  (wasteland-arena 24)
  (guard-frustum 25)
  (wasdoors 26)
  (gun-dark 27)
  (spargus-city 28)
  (racer 29)
  (racer-target 30)
  (racer-errol 31)
  (monk-temple 32)
  (bbush-desd 33)
  (bbush-desc 34)
  (bbush-desa 35)
  (bbush-desg 36)
  (bbush-desh 37)
  (bbush-desc-2 38)
  (bbush-dese 39)
  (bbush-desb 40)
  (bbush-desa-2 41)
  (bbush-desc-3 42)
  (bbush-desg-2 43)
  (bbush-desd-2 44)
  (bbush-desg-3 45)
  (bbush-dese-2 46)
  (bbush-dese-3 47)
  (bbush-desd-3 48)
  (bbush-desb-2 49)
  (bbush-wasa-1 50)
  (bbush-wasa-2 51)
  (bbush-wasa-3 52)
  (bbush-wasa-4 53)
  (bbush-wasb-2 54)
  (bbush-wasb-1 55)
  (bbush-wasb-4 56)
  (bbush-wasb-3 57)
  (bbush-desg-4 58)
  (bbush-wasb-5 59)
  (bbush-wasb-6 60)
  (bbush-desa-3 61)
  (bbush-wasa-5 62)
  (bbush-desd-4 63)
  (bbush-desd-5 64)
  (bbush-sluma-1 65)
  (bbush-genb-1 66)
  (bbush-slumb-1 67)
  (bbush-slumb-3 68)
  (bbush-desc-4 69)
  (bbush-inda-1 70)
  (bbush-dese-4 71)
  (bbush-desc-5 72)
  (bbush-desb-3 73)
  (bbush-wasa-6 74)
  (bbush-wasb-7 75)
  (bbush-indb-1 76)
  (bbush-desf 77)
  (bbush-port-1 78)
  (bbush-genb-2 79)
  (bbush-genb-3 80)
  (bbush-genb-4 81)
  (bbush-slumb-4 82)
  (bbush-slumc-1 83)
  (bbush-dese-5 84)
  (bbush-post-game 85)
  (bbush-slumc-2 86)
  (bbush-sluma-2 87)
  (bbush-sluma-3 88)
  (bbush-indb-2 89)
  (bbush-indb-3 90)
  (bbush-inda-2 91)
  (bbush-inda-3 92)
  (bbush-inda-4 93)
  (bbush-inda-5 94)
  (bbush-port-4 95)
  (bbush-port-5 96)
  (bbush-port-6 97)
  (bbush-port-7 98)
  (bbush-port-8 99)
  (bbush-desb-4 100)
  (atoll-valve 101)
  (atoll-ashelin 102)
  (mountain-lens 103)
  (mountain-shard 104)
  (mountain-gear 105)
  (ruins-hut 106)
  (forest-samos 107)
  (metalhead 108)
  (kleever-arena 109)
  (seem-wascitya 110)
  (seem-wascityb 111)
  (kleever-wasdoors 112)
  (damus-wasdoors 113)
  (damus-waspal 114)
  (damus-arena 115)
  (kleever-wascityb 116)
  (red-clamped-dot 117)
  (tiny-red-dot 118)
  (desert-temple 119)
  (desert-oasis 120)
  (desert-corral 121)
  (sig-wasdoors 122)
  (freehq 123)
  (green-clamped-dot 124)
  (nest-cocoon 125)
  (nest-bridge 126)
  (factory 127)
  (big-orange-flashing-clamped-dot 128)
  (big-red-flashing-clamped-dot 129)
  (big-green-flashing-clamped-dot 130)
  (big-purple-flashing-clamped-dot 131)
  (medium-purple-dot 132)
  (parked-vehicle 133)
  (samos-genb 134)
  (projectile 135)
  (desertb-race 136)
  (big-red-flashing-trail-dot 137)
  (big-green-flashing-trail-dot 138)
  (robot-frustum 139)
  (desert-marauder-village 140)
  (gray-clamped-dot 141)
  (volcano-monk 142)
  (volcano-collapsing-rock 143)
  (volcano-stone-lid 144)
  (volcano-dark-maker-idol 145)
  (medium-green-dot 146)
  (big-red-flashing-dot 147)
  (factory-clamped-target 148)
  (factory-clamped-tower 149)
  (desglide-ring-dot 150)
  (desglide-thermal-dot 151)
  (mine-elevator 152)
  (mine-armor 153)
  (mine-sign-up 154)
  (mine-sign-down 155)
  (mine-door 156)
  (ruins-elec-gate 157)
  (ruins-goal 158)
  (dp-bipedal 159)
  (neo-wasp 160)
  (dark-maker 161)
  (templea-door 162)
  (templeb-watchers 163)
  (templeb-regen 164)
  (templeb-warpgate 165)
  (templex-darkmaker 166)
  (temple-tests-door 167)
  (templeb-freeze 168)
  (temple-elev 169)
  (factoryc-vehicle 170)
  (templeb-defend 171)
  (templeb-seem 172)
  (temple-defend-door-1 173)
  (temple-defend-door-2 174)
  (temple-defend-door-3 175)
  (palace-ruins 176)
  )

(declare-type minimap-class-node structure)
(define-extern *minimap-class-list* (inline-array minimap-class-node))

;; DECOMP BEGINS

(deftype minimap-table-entry (structure)
  ((corner            vector  :inline)
   (level-name        symbol)
   (tex-name          string)
   (meters-per-texel  float)
   (pos-scale         float)
   (min-inv-scale     float)
   (max-inv-scale     float)
   (switch-immediate  symbol)
   )
  )


(deftype minimap-class-node (structure)
  ((default-position  vector     :inline)
   (flags             minimap-flag)
   (name              string)
   (icon-xy           vector2ub  :inline)
   (class             minimap-class)
   (scale             float)
   (color             rgba)
   )
  (:methods
    (minimap-class-node-method-9 (_type_) symbol)
    )
  )


(deftype connection-minimap (connection-pers)
  ((next               connection-minimap :override)
   (handle             handle              :overlay-at update-time)
   (position           vector              :overlay-at (-> param 0))
   (alpha              float               :overlay-at (-> param 1))
   (flags              minimap-flag        :overlay-at (-> param 2))
   (class              minimap-class-node  :overlay-at (-> param 3))
   (node               uint16)
   (edge-ry            int16)
   (last-world-pos     vector              :inline)
   (last-relative-pos  vector              :inline)
   )
  )


(deftype engine-minimap (engine-pers)
  ((alive-list  connection-minimap :override)
   (dead-list   connection-minimap :override)
   )
  )


(deftype minimap-trail (structure)
  ((used-by         connection-minimap)
   (search-id       uint32)
   (node-count      int16)
   (goal-node-id    int32)
   (node-path-dist  float)
   (last-updated    uint64)
   (cached-info     trail-cached-search-info  :inline)
   (node-id         uint16                    64)
   )
  (:methods
    (get-distance-with-path (_type_ vector vector) float)
    (reset (_type_) none)
    )
  )


(deftype minimap-draw-work (structure)
  ((buf            dma-buffer)
   (justify-right  symbol)
   (global-flags   uint32)
   (draw-pos       vector4w  :inline)
   (mat            matrix    :inline)
   (corner         vector    4 :inline)
   )
  )


(deftype minimap (structure)
  ((draw-tmpl         dma-gif-packet  :inline)
   (draw2-tmpl        dma-gif-packet  :inline)
   (draw3-tmpl        dma-gif-packet  :inline)
   (draw4-tmpl        dma-gif-packet  :inline)
   (sprite-tmpl       dma-gif-packet  :inline)
   (adgif-tmpl        dma-gif-packet  :inline)
   (color             vector4w        :inline)
   (offset            vector          :inline)
   (minimap-corner    vector          :inline)
   (last-name         string)
   (last-tex          basic)
   (target-inv-scale  float)
   (map-bits          uint64)
   (level             level)
   (ctywide           level)
   (meters-per-texel  float)
   (pos-scale         float)
   (min-inv-scale     float)
   (max-inv-scale     float)
   (inv-scale         float           :overlay-at (-> offset data 1))
   (map-inv-scale     float)
   (icon-inv-scale    float)
   (fade              float           :overlay-at (-> offset data 3))
   (engine            engine-minimap)
   (engine-key        uint32)
   (trail             minimap-trail   6 :inline)
   (race-tex          texture)
   (race-scale        float)
   (race-level        level)
   (sprite2-tmpl      dma-gif-packet  :inline)
   (race-corner       vector          :inline)
   (goal-time         float)
   (frustum-alpha     float)
   )
  (:methods
    (debug-draw (_type_) none)
    (get-trail-for-connection (_type_ connection-minimap symbol) minimap-trail)
    (get-icon-draw-pos (_type_ connection-minimap minimap-trail vector float vector) symbol)
    (add-icon! (_type_ process uint int vector int) connection-minimap)
    (free-trail-by-connection (_type_ connection-minimap) none)
    (update-trails (_type_) none)
    (draw-1 (_type_ dma-buffer vector4w symbol) none)
    (draw-connection (_type_ minimap-draw-work connection-minimap) none)
    (draw-frustum-1 (_type_ minimap-draw-work connection-minimap) none)
    (draw-frustum-2 (_type_ minimap-draw-work connection-minimap) none)
    (sub-draw-1-2 (_type_ minimap-draw-work) none)
    (update! (_type_) symbol)
    (sub-draw-1-1 (_type_ minimap-draw-work) none)
    (set-color (_type_ vector) none)
    (draw-racer-2 (_type_ minimap-draw-work connection-minimap) none)
    (draw-sprite2 (_type_ dma-buffer vector4w symbol) none)
    (set-race-texture (_type_ texture float level) none)
    (draw-racer-1 (_type_ minimap-draw-work connection-minimap float float float) none)
    (set-race-corner (_type_ float float) none)
    )
  )

(define-extern *minimap* minimap)