rlm@180: (ns com.aurellem.gb.types rlm@180: (:use (com.aurellem.gb gb-driver util constants)) rlm@180: (:import [com.aurellem.gb.gb_driver SaveState])) rlm@180: rlm@180: (def type-code->type-name rlm@180: {0x00 :normal rlm@180: 0x01 :fighting rlm@180: 0x02 :flying ocsenave@292: 0x03 :poison rlm@180: 0x04 :ground rlm@180: 0x05 :rock rlm@180: 0x07 :bug rlm@180: 0x08 :ghost rlm@180: 0x14 :fire rlm@180: 0x15 :water rlm@180: 0x16 :grass rlm@180: 0x17 :electric rlm@180: 0x18 :psychic rlm@180: 0x19 :ice rlm@204: 0x1A :dragon }) rlm@180: rlm@180: (def type-name->type-code rlm@180: (zipmap (vals type-code->type-name) rlm@180: (keys type-code->type-name))) rlm@180: rlm@190: (def pokemon-1-type-start-address 0xD16F) rlm@180: rlm@180: (defn pokemon-type-start-address [poke-num] rlm@190: (+ pokemon-1-type-start-address rlm@180: (* pokemon-record-width poke-num))) rlm@180: rlm@180: (defn give-type rlm@180: ([^SaveState state poke-num types] rlm@180: (assert (<= 0 poke-num 5)) rlm@180: (let [types* rlm@180: (if (= (count types) 1) rlm@180: [(first types) (first types)] rlm@180: types)] rlm@180: (set-memory-range rlm@180: state rlm@180: (pokemon-type-start-address poke-num) rlm@206: (map type-name->type-code types*)))) rlm@180: ([poke-num types] rlm@180: (give-type @current-state poke-num types))) rlm@180: rlm@190: (defn read-type rlm@180: ([^SaveState state poke-num] rlm@180: (assert (<= 0 poke-num 5)) rlm@180: (let [types-start (pokemon-type-start-address poke-num) rlm@180: [type-1 type-2] rlm@180: (subvec (vec (memory state)) rlm@180: types-start (+ 2 types-start))] rlm@180: (if (= type-1 type-2) rlm@180: [(type-code->type-name type-1)] rlm@180: (mapv type-code->type-name [type-1 type-2])))) rlm@180: ([poke-num] rlm@190: (read-type @current-state poke-num))) rlm@203: rlm@205: (def pokemon->type rlm@205: {:abra [:psychic] rlm@205: :aerodactyl [:rock :flying] rlm@205: :alakazam [:psychic] rlm@205: :arbok [:poison] rlm@205: :arcanine [:fire] rlm@205: :articuno [:ice :flying] rlm@205: :beedrill [:bug :poison] rlm@205: :bellsprout [:grass :poison] rlm@205: :blastoise [:water] rlm@205: :bulbasaur [:grass :poison] rlm@205: :butterfree [:bug :flying] rlm@205: :caterpie [:bug] rlm@205: :chansey [:normal] rlm@205: :charizard [:fire :flying] rlm@205: :charmander [:fire] rlm@205: :charmeleon [:fire] rlm@205: :clefable [:normal] rlm@205: :clefairy [:normal] rlm@205: :cloyster [:water :ice] rlm@205: :cubone [:ground] rlm@205: :dewgong [:water :ice] rlm@205: :diglett [:ground] rlm@205: :ditto [:normal] rlm@205: :dodrio [:normal :flying] rlm@205: :doduo [:normal :flying] rlm@205: :dragonair [:dragon] rlm@205: :dragonite [:dragon :flying] rlm@205: :dratini [:dragon] rlm@205: :drowzee [:psychic] rlm@205: :dugtrio [:ground] rlm@205: :eevee [:normal] rlm@205: :ekans [:poison] rlm@205: :electabuzz [:electric] rlm@205: :electrode [:electric] rlm@205: :exeggcute [:grass :psychic] rlm@205: :exeggutor [:grass :psychic] rlm@205: :farfetchd [:normal :flying] rlm@205: :fearow [:normal :flying] rlm@205: :flareon [:fire] rlm@205: :gastly [:ghost :poison] rlm@205: :gengar [:ghost :poison] rlm@205: :geodude [:rock :ground] rlm@205: :gloom [:grass :poison] rlm@205: :golbat [:poison :flying] rlm@205: :goldeen [:water] rlm@205: :golduck [:water] rlm@205: :golem [:rock :ground] rlm@205: :graveler [:rock :ground] rlm@205: :grimer [:poison] rlm@205: :growlithe [:fire] rlm@205: :gyarados [:water :flying] rlm@205: :haunter [:ghost :poison] rlm@205: :hitmonchan [:fighting] rlm@205: :hitmonlee [:fighting] rlm@205: :horsea [:water] rlm@205: :hypno [:psychic] rlm@205: :ivysaur [:grass :poison] rlm@205: :jigglypuff [:normal] rlm@205: :jolteon [:electric] rlm@205: :jynx [:ice :psychic] rlm@205: :kabuto [:rock :water] rlm@205: :kabutops [:rock :water] rlm@205: :kadabra [:psychic] rlm@205: :kakuna [:bug :poison] rlm@205: :kangaskhan [:normal] rlm@205: :kingler [:water] rlm@205: :koffing [:poison] rlm@205: :krabby [:water] rlm@205: :lapras [:water :ice] rlm@205: :lickitung [:normal] rlm@205: :machamp [:fighting] rlm@205: :machoke [:fighting] rlm@205: :machop [:fighting] rlm@205: :magikarp [:water] rlm@205: :magmar [:fire] rlm@205: :magnemite [:electric] rlm@205: :magneton [:electric] rlm@205: :mankey [:fighting] rlm@205: :marowak [:ground] rlm@205: :meowth [:normal] rlm@205: :metapod [:bug] rlm@205: :mew [:psychic] rlm@205: :mewtwo [:psychic] rlm@205: :moltres [:fire :flying] rlm@205: :mr-mime [:psychic] rlm@205: :muk [:poison] rlm@205: :nidoking [:poison :ground] rlm@205: :nidoqueen [:poison :ground] rlm@205: :nidoran-female [:poison] rlm@205: :nidoran-male [:poison] rlm@205: :nidorina [:poison] rlm@205: :nidorino [:poison] rlm@205: :ninetails [:fire] rlm@205: :oddish [:grass :poison] rlm@205: :omanyte [:rock :water] rlm@205: :omastar [:rock :water] rlm@205: :onix [:rock :ground] rlm@205: :paras [:bug :grass] rlm@205: :parasect [:bug :grass] rlm@205: :persian [:normal] rlm@205: :pidgeot [:normal :flying] rlm@205: :pidgeotto [:normal :flying] rlm@205: :pidgey [:normal :flying] rlm@205: :pikachu [:electric] rlm@205: :pinsir [:bug] rlm@205: :poliwag [:water] rlm@205: :poliwhirl [:water] rlm@205: :poliwrath [:water :fighting] rlm@205: :ponyta [:fire] rlm@205: :porygon [:normal] rlm@205: :primeape [:fighting] rlm@205: :psyduck [:water] rlm@205: :raichu [:electric] rlm@205: :rapidash [:fire] rlm@205: :raticate [:normal] rlm@205: :rattata [:normal] rlm@205: :rhydon [:ground :rock] rlm@205: :rhyhorn [:ground :rock] rlm@205: :sandshrew [:ground] rlm@205: :sandslash [:ground] rlm@205: :scyther [:bug :flying] rlm@205: :seaking [:water] rlm@205: :sedra [:water] rlm@205: :seel [:water] rlm@205: :shellder [:water] rlm@205: :slowbro [:water :psychic] rlm@205: :slowpoke [:water :psychic] rlm@205: :snorlax [:normal] rlm@205: :spearow [:normal :flying] rlm@205: :squirtle [:water] rlm@205: :starmie [:water :psychic] rlm@205: :staryu [:water] rlm@205: :tangela [:grass] rlm@205: :tauros [:normal] rlm@205: :tentacool [:water :poison] rlm@205: :tentacruel [:water :poison] rlm@205: :vaporeon [:water] rlm@205: :venomoth [:bug :poison] rlm@205: :venonat [:bug :poison] rlm@205: :venusaur [:grass :poison] rlm@205: :victreebel [:grass :poison] rlm@205: :vileplume [:grass :poison] rlm@205: :voltorb [:electric] rlm@205: :vulpix [:fire] rlm@205: :wartortle [:water] rlm@205: :weedle [:bug :poison] rlm@205: :weepenbell [:grass :poison] rlm@205: :wheezing [:poison] rlm@205: :wigglytuff [:normal] rlm@205: :zapdos [:electric :flying] rlm@205: :zubat [:poison :flying]}) rlm@203: rlm@204: rlm@204: rlm@204: rlm@204: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: rlm@205: