view clojure/com/aurellem/gb/hxc.clj @ 306:2873f50b7291

beginning to work on cry data
author Dylan Holmes <ocsenave@gmail.com>
date Sat, 31 Mar 2012 01:27:46 -0500
parents c31cb3043087
children 872e032949ff
line wrap: on
line source
1 (ns com.aurellem.gb.hxc
2 (:use (com.aurellem.gb assembly characters gb-driver util
3 constants species))
4 ;; (:use (com.aurellem.world practice))
5 (:import [com.aurellem.gb.gb_driver SaveState]))
10 ; ************* HANDWRITTEN CONSTANTS
14 (def pkmn-types
15 [:normal ;;0
16 :fighting ;;1
17 :flying ;;2
18 :poison ;;3
19 :ground ;;4
20 :rock ;;5
21 :bird ;;6
22 :bug ;;7
23 :ghost ;;8
24 :A
25 :B
26 :C
27 :D
28 :E
29 :F
30 :G
31 :H
32 :I
33 :J
34 :K
35 :fire ;;20 (0x14)
36 :water ;;21 (0x15)
37 :grass ;;22 (0x16)
38 :electric ;;23 (0x17)
39 :psychic ;;24 (0x18)
40 :ice ;;25 (0x19)
41 :dragon ;;26 (0x1A)
42 ])
45 ;; question: when status effects claim to take
46 ;; their accuracy from the move accuracy, does
47 ;; this mean that the move always "hits" but the
48 ;; status effect may not?
50 (def move-effects
51 ["normal damage"
52 "no damage, just opponent sleep" ;; how many turns? is atk power ignored?
53 "0x4C chance of poison"
54 "leech half of inflicted damage"
55 "0x19 chance of burn"
56 "0x19 chance of freeze"
57 "0x19 chance of paralyze"
58 "user faints; opponent defense halved during attack."
59 "leech half of inflicted damage ONLY if sleeping opponent."
60 "imitate last attack"
61 "user atk +1"
62 "user def +1"
63 "user spd +1"
64 "user spc +1"
65 "user acr +1" ;; unused?!
66 "user evd +1"
67 "get post-battle $ = 2*level*uses"
68 "0xFE acr, no matter what."
69 "opponent atk -1" ;; acr taken from move acr?
70 "opponent def -1" ;;
71 "opponent spd -1" ;;
72 "opponent spc -1" ;;
73 "opponent acr -1";;
74 "opponent evd -1"
75 "converts user's type to opponent's."
76 "(haze)"
77 "(bide)"
78 "(thrash)"
79 "(teleport)"
80 "(fury swipes)"
81 "attacks 2-5 turns" ;; unused? like rollout?
82 "0x19 chance of flinch"
83 "opponent sleep for 1-7 turns"
84 "0x66 chance of poison"
85 "0x4D chance of burn"
86 "0x4D chance of freeze"
87 "0x4D chance of paralyze"
88 "0x4D chance of flinch"
89 "one-hit KO"
90 "charge one turn, atk next."
91 "fixed damage, leaves 1HP." ;; how is dmg determined?
92 "fixed damage." ;; cf seismic toss, dragon rage, psywave.
93 "atk 2-5 turns; opponent can't attack" ;; unnormalized? (0 0x60 0x60 0x20 0x20)
94 "charge one turn, atk next. (can't be hit when charging)"
95 "atk hits twice."
96 "user takes 1 damage if misses."
97 "evade status-lowering effects" ;;caused by you or also your opponent?
98 "(broken) if user is slower than opponent, makes critical hit impossible, otherwise has no effect"
99 "atk causes recoil dmg = 1/4 dmg dealt"
100 "confuses opponent" ;; acr taken from move acr
101 "user atk +2"
102 "user def +2"
103 "user spd +2"
104 "user spc +2"
105 "user acr +2" ;; unused!
106 "user evd +2" ;; unused!
107 "restores up to half of user's max hp." ;; broken: fails if the difference
108 ;; b/w max and current hp is one less than a multiple of 256.
109 "(transform)"
110 "opponent atk -2"
111 "opponent def -2"
112 "opponent spd -2"
113 "opponent spc -2"
114 "opponent acr -2"
115 "opponent evd -2"
116 "doubles user spc when attacked"
117 "doubles user def when attacked"
118 "just poisons opponent" ;;acr taken from move acr
119 "just paralyzes opponent" ;;
120 "0x19 chance opponent atk -1"
121 "0x19 chance opponent def -1"
122 "0x19 chance opponent spd -1"
123 "0x4C chance opponent spc -1" ;; context suggest chance is 0x19
124 "0x19 chance opponent acr -1"
125 "0x19 chance opponent evd -1"
126 "???" ;; unused? no effect?
127 "???" ;; unused? no effect?
128 "0x19 chance opponent confused"
129 "atk hits twice. 0x33 chance opponent poisioned."
130 "broken. crash the game after attack."
131 "(substitute)"
132 "unless opponent faints, user must recharge after atk. some
133 exceptions apply."
134 "(rage)"
135 "(mimic)"
136 "(metronome)"
137 "(leech seed)"
138 "does nothing (splash)"
139 "(disable)"
140 ])
143 ;; ************** HARDCODED DATA
145 (defn hxc-thunk
146 "Creates a thunk (nullary fn) that grabs data in a certain region of rom and
147 splits it into a collection by 0x50. If rom is not supplied, uses the
148 original rom data."
149 [start length]
150 (fn self
151 ([rom]
152 (take-nth 2
153 (partition-by #(= % 0x50)
154 (take length
155 (drop start rom)))))
156 ([]
157 (self com.aurellem.gb.gb-driver/original-rom))))
159 (def hxc-thunk-words
160 "Same as hxc-thunk, except it interprets the rom data as characters,
161 returning a collection of strings."
162 (comp
163 (partial comp (partial map character-codes->str))
164 hxc-thunk))
167 ;; --------------------------------------------------
171 (defn hxc-pokenames-raw
172 "The hardcoded names of the 190 species in memory. List begins at
173 ROM@E8000. Although names in memory are padded with 0x50 to be 10 characters
174 long, these names are stripped of padding. See also, hxc-pokedex-names"
175 ([]
176 (hxc-pokenames-raw com.aurellem.gb.gb-driver/original-rom))
177 ([rom]
178 (let [count-species 190
179 name-length 10]
180 (map character-codes->str
181 (partition name-length
182 (map #(if (= 0x50 %) 0x00 %)
183 (take (* count-species name-length)
184 (drop 0xE8000
185 rom))))))))
186 (def hxc-pokenames
187 (comp
188 (partial map format-name)
189 hxc-pokenames-raw))
194 (defn hxc-pokedex-names
195 "The names of the pokemon in hardcoded pokedex order. List begins at
196 ROM@410B1. See also, hxc-pokenames."
197 ([] (hxc-pokedex-names
198 com.aurellem.gb.gb-driver/original-rom))
199 ([rom]
200 (let [names (hxc-pokenames rom)]
201 (#(mapv %
202 ((comp range count keys) %))
203 (zipmap
204 (take (count names)
205 (drop 0x410b1 rom))
207 names)))))
211 ;; http://hax.iimarck.us/topic/581/
212 (defn hxc-pokedex-cry
213 "The pokemon cry data in internal order. List begins at ROM@410B1
214 []
218 (def hxc-items-raw
219 "The hardcoded names of the items in memory. List begins at
220 ROM@045B7"
221 (hxc-thunk-words 0x45B7 870))
223 (def hxc-types
224 "The hardcoded type names in memory. List begins at ROM@27D99,
225 shortly before hxc-titles."
226 (hxc-thunk-words 0x27D99 102))
228 (def hxc-titles
229 "The hardcoded names of the trainer titles in memory. List begins at
230 ROM@27E77"
231 (hxc-thunk-words 0x27E77 196))
234 (def hxc-pokedex-text-raw
235 "The hardcoded pokedex entries in memory. List begins at
236 ROM@B8000, shortly before move names."
237 (hxc-thunk-words 0xB8000 14754))
241 (def hxc-items
242 "The hardcoded names of the items in memory, presented as
243 keywords. List begins at ROM@045B7. See also, hxc-items-raw."
244 (comp (partial map format-name) hxc-items-raw))
246 (defn hxc-pokedex-text
247 "The hardcoded pokedex entries in memory, presented as an
248 associative hash map. List begins at ROM@B8000."
249 ([] (hxc-pokedex-text com.aurellem.gb.gb-driver/original-rom))
250 ([rom]
251 (zipmap
252 (hxc-pokedex-names rom)
253 (cons nil ;; for missingno.
254 (hxc-pokedex-text-raw rom)))))
256 ;; In red/blue, pokedex stats are in internal order.
257 ;; In yellow, pokedex stats are in pokedex order.
259 (defn hxc-pokedex-stats
260 "The hardcoded pokedex stats (species height weight) in memory. List
261 begins at ROM@40687"
262 ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom))
263 ([rom]
264 (let [pokedex-names (zipmap (range) (hxc-pokedex-names rom))
265 pkmn-count (count pokedex-names)
266 ]
267 ((fn capture-stats
268 [n stats data]
269 (if (zero? n) stats
270 (let [[species
271 [_
272 height-ft
273 height-in
274 weight-1
275 weight-2
276 _
277 dex-ptr-1
278 dex-ptr-2
279 dex-bank
280 _
281 & data]]
282 (split-with (partial not= 0x50) data)]
283 (recur (dec n)
284 (assoc stats
285 (pokedex-names (- pkmn-count (dec n)))
286 {:species
287 (format-name (character-codes->str species))
288 :height-ft
289 height-ft
290 :height-in
291 height-in
292 :weight
293 (/ (low-high weight-1 weight-2) 10.)
295 ;; :text
296 ;; (character-codes->str
297 ;; (take-while
298 ;; (partial not= 0x50)
299 ;; (drop
300 ;; (+ 0xB8000
301 ;; -0x4000
302 ;; (low-high dex-ptr-1 dex-ptr-2))
303 ;; rom)))
304 })
306 data)
309 )))
311 pkmn-count
312 {}
313 (drop 0x40687 rom))) ))
321 (def hxc-places
322 "The hardcoded place names in memory. List begins at
323 ROM@71500. [Cinnabar] Mansion seems to be dynamically calculated."
324 (hxc-thunk-words 0x71500 560))
327 (defn hxc-dialog
328 "The hardcoded dialogue in memory, including in-game alerts. Dialog
329 seems to be separated by 0x57 instead of 0x50 (END). Begins at ROM@98000."
330 ([rom]
331 (map character-codes->str
332 (take-nth 2
333 (partition-by #(= % 0x57)
334 (take 0x0F728
335 (drop 0x98000 rom))))))
336 ([]
337 (hxc-dialog com.aurellem.gb.gb-driver/original-rom)))
340 (def hxc-move-names
341 "The hardcoded move names in memory. List begins at ROM@BC000"
342 (hxc-thunk-words 0xBC000 1551))
345 (defn hxc-move-data
346 "The hardcoded (basic (move effects)) in memory. List begins at
347 0x38000. Returns a map of {:name :power :accuracy :pp :fx-id
348 :fx-txt}. The move descriptions are handwritten, not hardcoded."
349 ([]
350 (hxc-move-data com.aurellem.gb.gb-driver/original-rom))
351 ([rom]
352 (let [names (vec (hxc-move-names rom))
353 move-count (count names)
354 move-size 6
355 types pkmn-types ;;; !! hardcoded types
356 ]
357 (zipmap (map format-name names)
358 (map
359 (fn [[idx effect power type-id accuracy pp]]
360 {:name (names (dec idx))
361 :power power
362 :accuracy accuracy
363 :pp pp
364 :type (types type-id)
365 :fx-id effect
366 :fx-txt (get move-effects effect)
367 }
368 )
370 (partition move-size
371 (take (* move-size move-count)
372 (drop 0x38000 rom))))))))
376 (defn hxc-move-data*
377 "Like hxc-move-data, but reports numbers as hexadecimal symbols instead."
378 ([]
379 (hxc-move-data* com.aurellem.gb.gb-driver/original-rom))
380 ([rom]
381 (let [names (vec (hxc-move-names rom))
382 move-count (count names)
383 move-size 6
384 format-name (fn [s]
385 (keyword (.toLowerCase
386 (apply str
387 (map #(if (= % \space) "-" %) s)))))
388 ]
389 (zipmap (map format-name names)
390 (map
391 (fn [[idx effect power type accuracy pp]]
392 {:name (names (dec idx))
393 :power power
394 :accuracy (hex accuracy)
395 :pp pp
396 :fx-id (hex effect)
397 :fx-txt (get move-effects effect)
398 }
399 )
401 (partition move-size
402 (take (* move-size move-count)
403 (drop 0x38000 rom))))))))
406 (defn hxc-machines
407 "The hardcoded moves taught by TMs and HMs. List begins at ROM@0x1232D."
408 ([] (hxc-machines
409 com.aurellem.gb.gb-driver/original-rom))
410 ([rom]
411 (let [moves (hxc-move-names rom)]
412 (zipmap
413 (range)
414 (take-while
415 (comp not nil?)
416 (map (comp
417 format-name
418 (zipmap
419 (range)
420 moves)
421 dec)
422 (take 100
423 (drop 0x1232D rom))))))))
427 (defn internal-id
428 ([rom]
429 (zipmap
430 (hxc-pokenames rom)
431 (range)))
432 ([]
433 (internal-id com.aurellem.gb.gb-driver/original-rom)))
439 ;; nidoran gender change upon levelup
440 ;; (->
441 ;; @current-state
442 ;; rom
443 ;; vec
444 ;; (rewrite-memory
445 ;; (nth (hxc-ptrs-evolve) ((internal-id) :nidoran♂))
446 ;; [1 1 15])
447 ;; (rewrite-memory
448 ;; (nth (hxc-ptrs-evolve) ((internal-id) :nidoran♀))
449 ;; [1 1 3])
450 ;; (write-rom!)
452 ;; )
457 (defn hxc-advantage
458 ;; in-game multipliers are stored as 10x their effective value
459 ;; to allow for fractional multipliers like 1/2
461 "The hardcoded type advantages in memory, returned as tuples of
462 atk-type def-type multiplier. By default (i.e. if not listed here),
463 the multiplier is 1. List begins at 0x3E62D."
464 ([] (hxc-advantage com.aurellem.gb.gb-driver/original-rom))
465 ([rom]
466 (map
467 (fn [[atk def mult]] [(get pkmn-types atk (hex atk))
468 (get pkmn-types def (hex def))
469 (/ mult 10)])
470 (partition 3
471 (take-while (partial not= 0xFF)
472 (drop 0x3E62D rom))))))
476 (defn format-evo
477 [coll]
478 (let [method (first coll)]
479 (cond (empty? coll) []
480 (= 0 method) [] ;; just in case
481 (= 1 method) ;; level-up evolution
482 (conj (format-evo (drop 3 coll))
483 {:method :level-up
484 :min-level (nth coll 1)
485 :into (dec (nth coll 2))})
487 (= 2 method) ;; item evolution
488 (conj (format-evo (drop 4 coll))
489 {:method :item
490 :item (dec (nth coll 1))
491 :min-level (nth coll 2)
492 :into (dec (nth coll 3))})
494 (= 3 method) ;; trade evolution
495 (conj (format-evo (drop 3 coll))
496 {:method :trade
497 :min-level (nth coll 1) ;; always 1 for trade.
498 :into (dec (nth coll 2))}))))
501 (defn hxc-ptrs-evolve
502 "A hardcoded collection of 190 pointers to alternating evolution/learnset data,
503 in internal order."
504 ([]
505 (hxc-ptrs-evolve com.aurellem.gb.gb-driver/original-rom))
506 ([rom]
507 (let [
508 pkmn-count (count (hxc-pokenames-raw)) ;; 190
509 ptrs
510 (map (fn [[a b]] (low-high a b))
511 (partition 2
512 (take (* 2 pkmn-count)
513 (drop 0x3b1e5 rom))))]
514 (map (partial + 0x34000) ptrs)
516 )))
519 (defn hxc-learnsets
520 "Hardcoded map associating pokemon names to lists of pairs [lvl
521 move] of abilities they learn as they level up. The data
522 exists at ROM@3400, sorted by internal order. Pointers to the data
523 exist at ROM@3B1E5; see also, hxc-ptrs-evolve"
524 ([] (hxc-learnsets com.aurellem.gb.gb-driver/original-rom))
525 ([rom]
526 (apply assoc
527 {}
528 (interleave
529 (hxc-pokenames rom)
530 (map (comp
531 (partial map
532 (fn [[lvl mv]] [lvl (dec mv)]))
533 (partial partition 2)
534 ;; keep the learnset data
535 (partial take-while (comp not zero?))
536 ;; skip the evolution data
537 rest
538 (partial drop-while (comp not zero?)))
539 (map #(drop % rom)
540 (hxc-ptrs-evolve rom)))))))
542 (defn hxc-learnsets-pretty
543 "Live hxc-learnsets except it reports the name of each move --- as
544 it appears in rom --- rather than the move index."
545 ([] (hxc-learnsets-pretty com.aurellem.gb.gb-driver/original-rom))
546 ([rom]
547 (let [moves (vec(map format-name (hxc-move-names)))]
548 (into {}
549 (map (fn [[pkmn learnset]]
550 [pkmn (map (fn [[lvl mv]] [lvl (moves mv)])
551 learnset)])
552 (hxc-learnsets rom))))))
557 (defn hxc-evolution
558 "Hardcoded evolution data in memory. The data exists at ROM@34000,
559 sorted by internal order. Pointers to the data exist at ROM@3B1E5; see also, hxc-ptrs-evolve."
560 ([] (hxc-evolution com.aurellem.gb.gb-driver/original-rom))
561 ([rom]
562 (apply assoc {}
563 (interleave
564 (hxc-pokenames rom)
565 (map
566 (comp
567 format-evo
568 (partial take-while (comp not zero?))
569 #(drop % rom))
570 (hxc-ptrs-evolve rom)
571 )))))
573 (defn hxc-evolution-pretty
574 "Like hxc-evolution, except it uses the names of items and pokemon
575 --- grabbed from ROM --- rather than their numerical identifiers."
576 ([] (hxc-evolution-pretty com.aurellem.gb.gb-driver/original-rom))
577 ([rom]
578 (let
579 [poke-names (vec (hxc-pokenames rom))
580 item-names (vec (hxc-items rom))
581 use-names
582 (fn [m]
583 (loop [ks (keys m) new-map m]
584 (let [k (first ks)]
585 (cond (nil? ks) new-map
586 (= k :into)
587 (recur
588 (next ks)
589 (assoc new-map
590 :into
591 (poke-names
592 (:into
593 new-map))))
594 (= k :item)
595 (recur
596 (next ks)
597 (assoc new-map
598 :item
599 (item-names
600 (:item new-map))))
601 :else
602 (recur
603 (next ks)
604 new-map)
605 ))))]
607 (into {}
608 (map (fn [[pkmn evo-coll]]
609 [pkmn (map use-names evo-coll)])
610 (hxc-evolution rom))))))
613 (defn hxc-pokemon-base
614 ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom))
615 ([rom]
616 (let [entry-size 28
617 pkmn-count (count (hxc-pokedex-text rom))
618 pokemon (rest (hxc-pokedex-names))
619 types (apply assoc {}
620 (interleave
621 (range)
622 pkmn-types)) ;;!! softcoded
623 moves (apply assoc {}
624 (interleave
625 (range)
626 (map format-name
627 (hxc-move-names rom))))
628 machines (hxc-machines)
629 ]
630 (zipmap
631 pokemon
632 (map
633 (fn [[n
634 rating-hp
635 rating-atk
636 rating-def
637 rating-speed
638 rating-special
639 type-1
640 type-2
641 rarity
642 rating-xp
643 pic-dimensions ;; tile_width|tile_height (8px/tile)
644 ptr-pic-obverse-1
645 ptr-pic-obverse-2
646 ptr-pic-reverse-1
647 ptr-pic-reverse-2
648 move-1
649 move-2
650 move-3
651 move-4
652 growth-rate
653 &
654 TMs|HMs]]
655 (let
656 [base-moves
657 (mapv moves
658 ((comp
659 ;; since the game uses zero as a delimiter,
660 ;; it must also increment all move indices by 1.
661 ;; heren we decrement to correct this.
662 (partial map dec)
663 (partial take-while (comp not zero?)))
664 [move-1 move-2 move-3 move-4]))
666 types
667 (set (list (types type-1)
668 (types type-2)))
669 TMs|HMs
670 (map
671 (comp
672 (partial map first)
673 (partial remove (comp zero? second)))
674 (split-at
675 50
676 (map vector
677 (rest(range))
678 (reduce concat
679 (map
680 #(take 8
681 (concat (bit-list %)
682 (repeat 0)))
684 TMs|HMs)))))
686 TMs (vec (first TMs|HMs))
687 HMs (take 5 (map (partial + -50) (vec (second TMs|HMs))))
690 ]
693 {:dex# n
694 :base-moves base-moves
695 :types types
696 :TMs TMs
697 :HMs HMs
698 :base-hp rating-hp
699 :base-atk rating-atk
700 :base-def rating-def
701 :base-speed rating-speed
702 :base-special rating-special
703 }))
705 (partition entry-size
706 (take (* entry-size pkmn-count)
707 (drop 0x383DE
708 rom))))))))
712 (defn hxc-item-prices
713 "The hardcoded list of item prices in memory. List begins at ROM@4495"
714 ([] (hxc-item-prices com.aurellem.gb.gb-driver/original-rom))
715 ([rom]
716 (let [items (hxc-items rom)
717 price-size 3]
718 (zipmap items
719 (map (comp
720 ;; zero-cost items are "priceless"
721 #(if (zero? %) :priceless %)
722 decode-bcd butlast)
723 (partition price-size
724 (take (* price-size (count items))
725 (drop 0x4495 rom))))))))
727 (defn hxc-shops
728 ([] (hxc-shops com.aurellem.gb.gb-driver/original-rom))
729 ([rom]
730 (let [items (zipmap (range) (hxc-items rom))
732 ;; temporarily softcode the TM items
733 items (into
734 items
735 (map (juxt identity
736 (comp keyword
737 (partial str "tm-")
738 (partial + 1 -200)
739 ))
740 (take 200 (drop 200 (range)))))
742 ]
744 ((fn parse-shop [coll [num-items & items-etc]]
745 (let [inventory (take-while
746 (partial not= 0xFF)
747 items-etc)
748 [separator & items-etc] (drop num-items (rest items-etc))]
749 (if (= separator 0x50)
750 (map (partial mapv (comp items dec)) (conj coll inventory))
751 (recur (conj coll inventory) items-etc)
752 )
753 ))
755 '()
756 (drop 0x233C rom))
759 )))
765 (defn hxc-ptrs-wild
766 "A list of the hardcoded wild encounter data in memory. Pointers
767 begin at ROM@0CB95; data begins at ROM@0x04D89"
768 ([] (hxc-ptrs-wild com.aurellem.gb.gb-driver/original-rom))
769 ([rom]
770 (let [ptrs
771 (map (fn [[a b]] (+ a (* 0x100 b)))
772 (take-while (partial not= (list 0xFF 0xFF))
773 (partition 2 (drop 0xCB95 rom))))]
774 ptrs)))
778 (defn hxc-wilds
779 "A list of the hardcoded wild encounter data in memory. Pointers
780 begin at ROM@0CB95; data begins at ROM@0x04D89"
781 ([] (hxc-wilds com.aurellem.gb.gb-driver/original-rom))
782 ([rom]
783 (let [pokenames (zipmap (range) (hxc-pokenames rom))]
784 (map
785 (partial map (fn [[a b]] {:species (pokenames (dec b)) :level
786 a}))
787 (partition 10
789 (take-while (comp (partial not= 1)
790 first)
791 (partition 2
792 (drop 0xCD8C rom))
794 ))))))
809 ;; ********************** MANIPULATION FNS
812 (defn same-type
813 ([pkmn move]
814 (same-type
815 com.aurellem.gb.gb-driver/original-rom pkmn move))
816 ([rom pkmn move]
817 (((comp :types (hxc-pokemon-base rom)) pkmn)
818 ((comp :type (hxc-move-data rom)) move))))
823 (defn submap?
824 "Compares the two maps. Returns true if map-big has the same associations as map-small, otherwise false."
825 [map-small map-big]
826 (cond (empty? map-small) true
827 (and
828 (contains? map-big (ffirst map-small))
829 (= (get map-big (ffirst map-small))
830 (second (first map-small))))
831 (recur (next map-small) map-big)
833 :else false))
836 (defn search-map [proto-map maps]
837 "Returns all the maps that make the same associations as proto-map."
838 (some (partial submap? proto-map) maps))
840 (defn filter-vals
841 "Returns a map consisting of all the pairs [key val] for
842 which (pred key) returns true."
843 [pred map]
844 (reduce (partial apply assoc) {}
845 (filter (fn [[k v]] (pred v)) map)))
848 (defn search-moves
849 "Returns a subcollection of all hardcoded moves with the
850 given attributes. Attributes consist of :name :power
851 :accuracy :pp :fx-id
852 (and also :fx-txt, but it contains the same information
853 as :fx-id)"
854 ([attribute-map]
855 (search-moves
856 com.aurellem.gb.gb-driver/original-rom attribute-map))
857 ([rom attribute-map]
858 (filter-vals (partial submap? attribute-map)
859 (hxc-move-data rom))))
865 ;; note: 0x2f31 contains the names "TM" "HM"?
867 ;; note for later: credits start at F1290
871 (comment
873 (def hxc-later
874 "Running this code produces, e.g. hardcoded names NPCs give
875 their pokemon. Will sort through it later."
876 (print (character-codes->str(take 10000
877 (drop 0x71597
878 (rom (root)))))))
880 (let [dex
881 (partition-by #(= 0x50 %)
882 (take 2540
883 (drop 0x40687
884 (rom (root)))))]
885 (def dex dex)
886 (def hxc-species
887 (map character-codes->str
888 (take-nth 4 dex))))
889 )