# HG changeset patch # User Robert McIntyre # Date 1332749366 18000 # Node ID e94d20ad853e767c29b8990f820a1d8161a39a82 # Parent 22f58fa47c3caef3c1da722c1f3ad8faa1e73acd# Parent 921d2277bb5722e176a3cc0128bd419cd173a9d2 mrege. diff -r 22f58fa47c3c -r e94d20ad853e clojure/com/aurellem/gb/hxc.clj --- a/clojure/com/aurellem/gb/hxc.clj Mon Mar 26 03:08:54 2012 -0500 +++ b/clojure/com/aurellem/gb/hxc.clj Mon Mar 26 03:09:26 2012 -0500 @@ -5,18 +5,141 @@ (:import [com.aurellem.gb.gb_driver SaveState])) -(def hxc-pokenames - "The hardcoded names of the 190 species in memory. List begins at ROM@E8000." - (let [count-species 190 - name-length 10] - (map character-codes->str - (partition name-length - (take (* count-species name-length) - (drop 0xE8000 - (rom(root)))))))) + +(def pkmn-types + [:normal + :fighting + :flying + :poison + :ground + :rock + :bird + :bug + :ghost + :A + :B + :C + :D + :E + :F + :G + :H + :I + :J + :K + :fire + :water + :grass + :electric + :psychic + :ice + :dragon + ]) + + +;; question: when status effects claim to take +;; their accuracy from the move accuracy, does +;; this mean that the move always "hits" but the +;; status effect may not? + +(def move-effects + ["normal damage" + "no damage, just opponent sleep" ;; how many turns? is atk power ignored? + "0x4C chance of poison" + "leech half of inflicted damage" + "0x19 chance of burn" + "0x19 chance of freeze" + "0x19 chance of paralyze" + "user faints; opponent defense halved." + "leech half of inflicted damage ONLY if sleeping opponent." + "imitate last attack" + "user atk +1" + "user def +1" + "user spd +1" + "user spc +1" + "user acr +1" ;; unused?! + "user evd +1" + "get post-battle $ = 2*level*uses" + "0xFE acr, no matter what." + "opponent atk -1" ;; acr taken from move acr? + "opponent def -1" ;; + "opponent spd -1" ;; + "opponent spc -1" ;; + "opponent acr -1";; + "opponent evd -1" + "converts user's type to opponent's." + "(haze)" + "(bide)" + "(thrash)" + "(teleport)" + "(fury swipes)" + "attacks 2-5 turns" ;; unused? like rollout? + "0x19 chance of flinch" + "opponent sleep for 1-7 turns" + "0x66 chance of poison" + "0x4D chance of burn" + "0x4D chance of freeze" + "0x4D chance of paralyze" + "0x4D chance of flinch" + "one-hit KO" + "charge one turn, atk next." + "fixed damage, leaves 1HP." ;; how is dmg determined? + "fixed damage." ;; cf seismic toss, dragon rage, psywave. + "atk 2-5 turns; opponent can't attack" ;; unnormalized? (0 0x60 0x60 0x20 0x20) + "charge one turn, atk next. (can't be hit when charging)" + "atk hits twice." + "user takes 1 damage if misses." + "evade status-lowering effects" ;;caused by you or also your opponent? + "(broken) if user is slower than opponent, makes critical hit impossible, otherwise has no effect" + "atk causes recoil dmg = 1/4 dmg dealt" + "confuses opponent" ;; acr taken from move acr + "user atk +2" + "user def +2" + "user spd +2" + "user spc +2" + "user acr +2" ;; unused! + "user evd +2" ;; unused! + "restores up to half of user's max hp." ;; broken: fails if the difference + ;; b/w max and current hp is one less than a multiple of 256. + "(transform)" + "opponent atk -2" + "opponent def -2" + "opponent spd -2" + "opponent spc -2" + "opponent acr -2" + "opponent evd -2" + "doubles user spc when attacked" + "doubles user def when attacked" + "poisons opponent" ;;acr taken from move acr + "paralyzes opponent" ;; + "0x19 chance opponent atk -1" + "0x19 chance opponent def -1" + "0x19 chance opponent spd -1" + "0x4C chance opponent spc -1" ;; context suggest chance is 0x19 + "0x19 chance opponent acr -1" + "0x19 chance opponent evd -1" + "???" ;; unused? no effect? + "???" ;; unused? no effect? + "0x19 chance opponent confused" + "atk hits twice. 0x33 chance opponent poisioned." + "broken. crash the game after attack." + "(substitute)" + "unless opponent faints, user must recharge after atk. some + exceptions apply." + "(rage)" + "(mimic)" + "(metronome)" + "(leech seed)" + "does nothing (splash)" + "(disable)" + ]) + + + + (def hxc-items - "The hardcoded names of the items in memory. List begins at ROM@45B7 " + "The hardcoded names of the items in memory. List begins at ROM@045B7 " (map character-codes->str (take-nth 2 (partition-by #(= % 0x50) @@ -44,26 +167,6 @@ (rom (root)))))))) -(def hxc-pokedex - "The hardcoded pokedex entries in memory. List begins at -ROM@B8000, shortly before move names." - (map character-codes->str - (take-nth 2 - (partition-by #(= % 0x50) - (take 14754 - (drop 0xB8000 - (rom (root)))))))) -(def hxc-moves - "The hardcoded move names in memory. List begins at ROM@BC000" - (map character-codes->str - (take-nth 2 - (partition-by #(= % 0x50) - (take 1551 - (drop 0xBC000 - (rom (root)))))))) - - - (def hxc-places "The hardcoded place names in memory. List begins at ROM@71500. Cinnabar Mansion is dynamically calculated." @@ -81,40 +184,73 @@ (drop (+ 0x98000) (rom (root)))))) +(def hxc-pokedex + "The hardcoded pokedex entries in memory. List begins at +ROM@B8000, shortly before move names." + (map character-codes->str + (take-nth 2 + (partition-by #(= % 0x50) + (take 14754 + (drop 0xB8000 + (rom (root)))))))) +(def hxc-move-names + "The hardcoded move names in memory. List begins at ROM@BC000" + (map character-codes->str + (take-nth 2 + (partition-by #(= % 0x50) + (take 1551 + (drop 0xBC000 + (rom (root)))))))) +(def hxc-move-data + "The hardcoded (basic (move effects)) in memory. List begins at +0x38000. Effect descriptions were handwritten and aren't hardcoded." + (let [names (vec hxc-move-names) + move-count (count names) + move-size 6 + format-name (fn [s] + (keyword (.toLowerCase + (apply str + (map #(if (= % \space) "-" %) s))))) + ] + (zipmap (map format-name names) + (map + (fn [[idx effect power type accuracy pp]] + {:name (names (dec idx)) + :power power + :accuracy (hex accuracy) + :pp pp + :fx-id (hex effect) + :fx-txt (get move-effects effect) + } + ) + + (partition move-size + (take (* move-size move-count) + (drop 0x38000 (rom(root))))))))) + -(def pkmn-types - [:normal - :fighting - :flying - :poison - :ground - :rock - :bug - :ghost - :A - :B - :C - :D - :E - :F - :G - :H - :I - :J - :K - :fire - :water - :grass - :electric - :psychic - :ice - :dragon - ]) +(def hxc-pokenames + "The hardcoded names of the 190 species in memory. List begins at ROM@E8000." + (let [count-species 190 + name-length 10] + (map character-codes->str + (partition name-length + (take (* count-species name-length) + (drop 0xE8000 + (rom(root)))))))) + + + + + + + (def hxc-advantage + "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." (map (fn [[atk def mult]] [(get pkmn-types atk (hex atk)) (get pkmn-types def (hex def)) @@ -137,11 +273,11 @@ +;; note for later: credits start at F1290 - - +(comment (def hxc-later "Running this code produces, e.g. hardcoded names NPCs give @@ -159,3 +295,4 @@ (def hxc-species (map character-codes->str (take-nth 4 dex)))) +) \ No newline at end of file