comparison clojure/com/aurellem/gb/hxc.clj @ 370:5aabbe326eb0

fixed a few blocks that were not tangling properly.
author Dylan Holmes <ocsenave@gmail.com>
date Sun, 08 Apr 2012 07:59:15 -0500
parents 497ca041f5af
children b477970d0b7a
comparison
equal deleted inserted replaced
348:497ca041f5af 370:5aabbe326eb0
480 480
481 ;; ) 481 ;; )
482 482
483 483
484 484
485 485 (defn hxc-advantage
486 ;; in-game multipliers are stored as 10x their effective value
487 ;; to allow for fractional multipliers like 1/2
488
489 "The hardcoded type advantages in memory, returned as tuples of
490 atk-type def-type multiplier. By default (i.e. if not listed here),
491 the multiplier is 1. List begins at 0x3E62D."
492 ([] (hxc-advantage com.aurellem.gb.gb-driver/original-rom))
493 ([rom]
494 (map
495 (fn [[atk def mult]] [(get pkmn-types atk (hex atk))
496 (get pkmn-types def (hex def))
497 (/ mult 10)])
498 (partition 3
499 (take-while (partial not= 0xFF)
500 (drop 0x3E62D rom))))))
486 501
487 502
488 503
489 (defn format-evo 504 (defn format-evo
490 "Parse a sequence of evolution data, returning a map. First is the 505 "Parse a sequence of evolution data, returning a map. First is the
534 (take (* 2 pkmn-count) 549 (take (* 2 pkmn-count)
535 (drop 0x3b1e5 rom))))] 550 (drop 0x3b1e5 rom))))]
536 (map (partial + 0x34000) ptrs) 551 (map (partial + 0x34000) ptrs)
537 552
538 ))) 553 )))
554
555 (defn hxc-evolution
556 "Hardcoded evolution data in memory. The data exists at ROM@34000,
557 sorted by internal order. Pointers to the data exist at ROM@3B1E5; see also, hxc-ptrs-evolve."
558 ([] (hxc-evolution com.aurellem.gb.gb-driver/original-rom))
559 ([rom]
560 (apply assoc {}
561 (interleave
562 (hxc-pokenames rom)
563 (map
564 (comp
565 format-evo
566 (partial take-while (comp not zero?))
567 #(drop % rom))
568 (hxc-ptrs-evolve rom)
569 )))))
570
571 (defn hxc-evolution-pretty
572 "Like hxc-evolution, except it uses the names of items and pokemon
573 --- grabbed from ROM --- rather than their numerical identifiers."
574 ([] (hxc-evolution-pretty com.aurellem.gb.gb-driver/original-rom))
575 ([rom]
576 (let
577 [poke-names (vec (hxc-pokenames rom))
578 item-names (vec (hxc-items rom))
579 use-names
580 (fn [m]
581 (loop [ks (keys m) new-map m]
582 (let [k (first ks)]
583 (cond (nil? ks) new-map
584 (= k :into)
585 (recur
586 (next ks)
587 (assoc new-map
588 :into
589 (poke-names
590 (:into
591 new-map))))
592 (= k :item)
593 (recur
594 (next ks)
595 (assoc new-map
596 :item
597 (item-names
598 (:item new-map))))
599 :else
600 (recur
601 (next ks)
602 new-map)
603 ))))]
604
605 (into {}
606 (map (fn [[pkmn evo-coll]]
607 [pkmn (map use-names evo-coll)])
608 (hxc-evolution rom))))))
609
610
539 611
540 612
541 (defn hxc-learnsets 613 (defn hxc-learnsets
542 "Hardcoded map associating pokemon names to lists of pairs [lvl 614 "Hardcoded map associating pokemon names to lists of pairs [lvl
543 move] of abilities they learn as they level up. The data 615 move] of abilities they learn as they level up. The data