changeset 248:e94d20ad853e

mrege.
author Robert McIntyre <rlm@mit.edu>
date Mon, 26 Mar 2012 03:09:26 -0500
parents 22f58fa47c3c (current diff) 921d2277bb57 (diff)
children 99227bec1123 b7f682bb3090
files
diffstat 1 files changed, 197 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/hxc.clj	Mon Mar 26 03:08:54 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/hxc.clj	Mon Mar 26 03:09:26 2012 -0500
     1.3 @@ -5,18 +5,141 @@
     1.4    (:import [com.aurellem.gb.gb_driver SaveState]))
     1.5  
     1.6  
     1.7 -(def hxc-pokenames
     1.8 -  "The hardcoded names of the 190 species in memory. List begins at ROM@E8000."
     1.9 -  (let [count-species 190
    1.10 -        name-length 10]
    1.11 -    (map character-codes->str
    1.12 -         (partition name-length
    1.13 -                    (take (* count-species name-length)
    1.14 -                          (drop 0xE8000
    1.15 -                                (rom(root))))))))
    1.16 +
    1.17 +(def pkmn-types
    1.18 +  [:normal
    1.19 +   :fighting
    1.20 +   :flying
    1.21 +   :poison
    1.22 +   :ground
    1.23 +   :rock
    1.24 +   :bird
    1.25 +   :bug
    1.26 +   :ghost
    1.27 +   :A
    1.28 +   :B
    1.29 +   :C
    1.30 +   :D
    1.31 +   :E
    1.32 +   :F
    1.33 +   :G
    1.34 +   :H
    1.35 +   :I
    1.36 +   :J
    1.37 +   :K
    1.38 +   :fire
    1.39 +   :water
    1.40 +   :grass
    1.41 +   :electric
    1.42 +   :psychic
    1.43 +   :ice
    1.44 +   :dragon
    1.45 +   ])
    1.46 +
    1.47 +
    1.48 +;; question: when status effects claim to take
    1.49 +;; their accuracy from the move accuracy, does
    1.50 +;; this mean that the move always "hits" but the
    1.51 +;; status effect may not?
    1.52 +
    1.53 +(def move-effects
    1.54 +  ["normal damage"
    1.55 +   "no damage, just opponent sleep" ;; how many turns? is atk power ignored?
    1.56 +   "0x4C chance of poison"
    1.57 +   "leech half of inflicted damage"
    1.58 +   "0x19 chance of burn"
    1.59 +   "0x19 chance of freeze"
    1.60 +   "0x19 chance of paralyze"
    1.61 +   "user faints; opponent defense halved."
    1.62 +   "leech half of inflicted damage ONLY if sleeping opponent."
    1.63 +   "imitate last attack"
    1.64 +   "user atk +1"
    1.65 +   "user def +1"
    1.66 +   "user spd +1"
    1.67 +   "user spc +1"
    1.68 +   "user acr +1" ;; unused?!
    1.69 +   "user evd +1"
    1.70 +   "get post-battle $ = 2*level*uses"
    1.71 +   "0xFE acr, no matter what."
    1.72 +   "opponent atk -1"     ;; acr taken from move acr?
    1.73 +   "opponent def -1"     ;;
    1.74 +   "opponent spd -1"   ;;
    1.75 +   "opponent spc -1" ;;
    1.76 +   "opponent acr -1";;
    1.77 +   "opponent evd -1"
    1.78 +   "converts user's type to opponent's."
    1.79 +   "(haze)"
    1.80 +   "(bide)"
    1.81 +   "(thrash)"
    1.82 +   "(teleport)"
    1.83 +   "(fury swipes)"
    1.84 +   "attacks 2-5 turns" ;; unused? like rollout?
    1.85 +   "0x19 chance of flinch"
    1.86 +   "opponent sleep for 1-7 turns"
    1.87 +   "0x66 chance of poison"
    1.88 +   "0x4D chance of burn"
    1.89 +   "0x4D chance of freeze"
    1.90 +   "0x4D chance of paralyze"
    1.91 +   "0x4D chance of flinch"
    1.92 +   "one-hit KO"
    1.93 +   "charge one turn, atk next."
    1.94 +   "fixed damage, leaves 1HP." ;; how is dmg determined?
    1.95 +   "fixed damage."             ;; cf seismic toss, dragon rage, psywave.
    1.96 +   "atk 2-5 turns; opponent can't attack" ;; unnormalized? (0 0x60 0x60 0x20 0x20)
    1.97 +   "charge one turn, atk next. (can't be hit when charging)"
    1.98 +   "atk hits twice."
    1.99 +   "user takes 1 damage if misses."
   1.100 +   "evade status-lowering effects" ;;caused by you or also your opponent?
   1.101 +   "(broken) if user is slower than opponent, makes critical hit impossible, otherwise has no effect"
   1.102 +   "atk causes recoil dmg = 1/4 dmg dealt"
   1.103 +   "confuses opponent" ;; acr taken from move acr
   1.104 +   "user atk +2"
   1.105 +   "user def +2"
   1.106 +   "user spd +2"
   1.107 +   "user spc +2"
   1.108 +   "user acr +2" ;; unused!
   1.109 +   "user evd +2" ;; unused!
   1.110 +   "restores up to half of user's max hp." ;; broken: fails if the difference
   1.111 +   ;; b/w max and current hp is one less than a multiple of 256.
   1.112 +   "(transform)"
   1.113 +   "opponent atk -2"
   1.114 +   "opponent def -2"
   1.115 +   "opponent spd -2"
   1.116 +   "opponent spc -2"
   1.117 +   "opponent acr -2"
   1.118 +   "opponent evd -2"
   1.119 +   "doubles user spc when attacked"
   1.120 +   "doubles user def when attacked"
   1.121 +   "poisons opponent"   ;;acr taken from move acr
   1.122 +   "paralyzes opponent" ;;
   1.123 +   "0x19 chance opponent atk -1"
   1.124 +   "0x19 chance opponent def -1"
   1.125 +   "0x19 chance opponent spd -1"
   1.126 +   "0x4C chance opponent spc -1" ;; context suggest chance is 0x19
   1.127 +   "0x19 chance opponent acr -1"
   1.128 +   "0x19 chance opponent evd -1"
   1.129 +   "???" ;; unused? no effect?
   1.130 +   "???" ;; unused? no effect?
   1.131 +   "0x19 chance opponent confused"
   1.132 +   "atk hits twice. 0x33 chance opponent poisioned."
   1.133 +   "broken. crash the game after attack."
   1.134 +   "(substitute)"
   1.135 +   "unless opponent faints, user must recharge after atk. some
   1.136 +  exceptions apply."
   1.137 +   "(rage)"
   1.138 +   "(mimic)"
   1.139 +   "(metronome)"
   1.140 +   "(leech seed)"
   1.141 +   "does nothing (splash)"
   1.142 +   "(disable)"
   1.143 +   ])
   1.144 +
   1.145 +
   1.146 +
   1.147 +
   1.148  
   1.149  (def hxc-items
   1.150 -  "The hardcoded names of the items in memory. List begins at ROM@45B7 "
   1.151 +  "The hardcoded names of the items in memory. List begins at ROM@045B7 "
   1.152    (map character-codes->str
   1.153         (take-nth 2
   1.154                   (partition-by #(= % 0x50)
   1.155 @@ -44,26 +167,6 @@
   1.156                                             (rom (root))))))))
   1.157  
   1.158  
   1.159 -(def hxc-pokedex
   1.160 -  "The hardcoded pokedex entries in memory. List begins at
   1.161 -ROM@B8000, shortly before move names."
   1.162 -  (map character-codes->str
   1.163 -       (take-nth 2
   1.164 -                 (partition-by #(= % 0x50)
   1.165 -                               (take 14754
   1.166 -                                     (drop 0xB8000
   1.167 -                                           (rom (root))))))))
   1.168 -(def hxc-moves
   1.169 -  "The hardcoded move names in memory. List begins at ROM@BC000"
   1.170 -  (map character-codes->str
   1.171 -       (take-nth 2
   1.172 -                 (partition-by #(= % 0x50)
   1.173 -                               (take 1551
   1.174 -                                     (drop 0xBC000
   1.175 -                                           (rom (root))))))))   
   1.176 -
   1.177 -
   1.178 -
   1.179  (def hxc-places
   1.180    "The hardcoded place names in memory. List begins at
   1.181  ROM@71500. Cinnabar Mansion is dynamically calculated."
   1.182 @@ -81,40 +184,73 @@
   1.183                            (drop (+ 0x98000)
   1.184                                  (rom (root))))))
   1.185  
   1.186 +(def hxc-pokedex
   1.187 +  "The hardcoded pokedex entries in memory. List begins at
   1.188 +ROM@B8000, shortly before move names."
   1.189 +  (map character-codes->str
   1.190 +       (take-nth 2
   1.191 +                 (partition-by #(= % 0x50)
   1.192 +                               (take 14754
   1.193 +                                     (drop 0xB8000
   1.194 +                                           (rom (root))))))))
   1.195 +(def hxc-move-names
   1.196 +  "The hardcoded move names in memory. List begins at ROM@BC000"
   1.197 +  (map character-codes->str
   1.198 +       (take-nth 2
   1.199 +                 (partition-by #(= % 0x50)
   1.200 +                               (take 1551
   1.201 +                                     (drop 0xBC000
   1.202 +                                           (rom (root))))))))   
   1.203  
   1.204 +(def hxc-move-data
   1.205 +  "The hardcoded (basic (move effects)) in memory. List begins at
   1.206 +0x38000. Effect descriptions were handwritten and aren't hardcoded."
   1.207 +  (let [names (vec hxc-move-names)
   1.208 +        move-count (count names)
   1.209 +        move-size 6
   1.210 +        format-name (fn [s]
   1.211 +                      (keyword (.toLowerCase
   1.212 +                       (apply str
   1.213 +                              (map #(if (= % \space) "-" %) s)))))
   1.214 +        ]
   1.215 +    (zipmap (map format-name names)
   1.216 +            (map
   1.217 +             (fn [[idx effect power type accuracy pp]]
   1.218 +               {:name (names (dec idx))
   1.219 +                :power power
   1.220 +                :accuracy (hex accuracy)
   1.221 +                :pp pp
   1.222 +                :fx-id (hex effect)
   1.223 +                :fx-txt (get move-effects effect) 
   1.224 +                }
   1.225 +               )
   1.226 +    
   1.227 +             (partition move-size
   1.228 +                        (take (* move-size move-count)
   1.229 +                              (drop 0x38000 (rom(root)))))))))
   1.230 +  
   1.231  
   1.232  
   1.233 -(def pkmn-types
   1.234 -  [:normal
   1.235 -   :fighting
   1.236 -   :flying
   1.237 -   :poison
   1.238 -   :ground
   1.239 -   :rock
   1.240 -   :bug
   1.241 -   :ghost
   1.242 -   :A
   1.243 -   :B
   1.244 -   :C
   1.245 -   :D
   1.246 -   :E
   1.247 -   :F
   1.248 -   :G
   1.249 -   :H
   1.250 -   :I
   1.251 -   :J
   1.252 -   :K
   1.253 -   :fire
   1.254 -   :water
   1.255 -   :grass
   1.256 -   :electric
   1.257 -   :psychic
   1.258 -   :ice
   1.259 -   :dragon
   1.260 -   ])
   1.261 +(def hxc-pokenames
   1.262 +  "The hardcoded names of the 190 species in memory. List begins at ROM@E8000."
   1.263 +  (let [count-species 190
   1.264 +        name-length 10]
   1.265 +    (map character-codes->str
   1.266 +         (partition name-length
   1.267 +                    (take (* count-species name-length)
   1.268 +                          (drop 0xE8000
   1.269 +                                (rom(root))))))))
   1.270 +
   1.271 +
   1.272 +
   1.273 +
   1.274 +
   1.275 +
   1.276 +
   1.277  
   1.278  
   1.279  (def hxc-advantage
   1.280 +  "The hardcoded type advantages in memory, returned as tuples of [atk-type def-type multiplier]. By default (i.e. if not listed here), the multiplier is 1."
   1.281    (map
   1.282     (fn [[atk def mult]] [(get pkmn-types atk (hex atk))
   1.283                           (get pkmn-types def (hex def))
   1.284 @@ -137,11 +273,11 @@
   1.285  
   1.286  
   1.287  
   1.288 +;; note for later: credits start at F1290
   1.289  
   1.290  
   1.291  
   1.292 -
   1.293 -
   1.294 +(comment 
   1.295  
   1.296  (def hxc-later
   1.297    "Running this code produces, e.g. hardcoded names NPCs give
   1.298 @@ -159,3 +295,4 @@
   1.299    (def hxc-species
   1.300      (map character-codes->str
   1.301           (take-nth 4 dex))))
   1.302 +)
   1.303 \ No newline at end of file