view clojure/com/aurellem/exp/pokemon.clj @ 146:c5914665012d

made function to get the sixth pokemon's full name
author Robert McIntyre <rlm@mit.edu>
date Mon, 19 Mar 2012 21:35:43 -0500
parents 412ca096a9ba
children 279e9ee6fccb
line wrap: on
line source
1 (ns com.aurellem.exp.pokemon
2 "Here I find out how pokemon are stored in memory."
3 (:use (com.aurellem.gb gb-driver items assembly util
4 characters))
5 (:import [com.aurellem.gb.gb_driver SaveState]))
8 (def pidgeot-lvl-36 (mid-game))
11 (def pidgeot-lvl-37 (read-state "pidgeot-lvl-37"))
14 (def pidgeot-lvl-38 (read-state "pidgeot-lvl-38"))
17 (def pidgeot-lvl-39 (read-state "pidgeot-lvl-39"))
20 (def pidgeot-lvl-40 (read-state "pidgeot-lvl-40"))
23 (defn level-analysis []
24 (apply common-differences
25 (map (comp vec memory)
26 [pidgeot-lvl-36
27 pidgeot-lvl-37
28 pidgeot-lvl-38
29 pidgeot-lvl-39
30 pidgeot-lvl-40])))
32 ;; inconclusive -- implies that level is calculated from
33 ;; some other values.
36 (def name-pidgeotto (read-state "name-pidgeotto"))
37 (def named-A (read-state "named-A"))
38 (def named-B (read-state "named-B"))
39 (def named-C (read-state "named-C"))
40 (def named-D (read-state "named-D"))
41 (def named-E (read-state "named-E"))
42 (def named-F (read-state "named-F"))
44 (defn name-analysis []
45 (apply common-differences
46 (map (comp vec memory)
47 [named-A
48 named-B
49 named-C
50 named-D
51 named-E
52 named-F])))
54 ;; resluted in 3 separate locations that could
55 ;; possibly hold the first letter of the pokemon's name
57 0xCF4A
58 0xD2EB
59 0xCEED
61 ;; try changing each of them
64 (defn test-cf4a []
65 (continue!
66 (set-memory named-A 0xCF4A (character->character-code "Z"))))
67 ;; result -- pidgeotto named "A"
69 (defn test-d2eb []
70 (continue!
71 (set-memory named-A 0xD2EB (character->character-code "Z"))))
72 ;; result -- pidgeotto named "Z"
74 (defn test-ceed []
75 (continue!
76 (set-memory named-A 0xCEED (character->character-code "Z"))))
77 ;; result -- pidgeotto named "A"
79 (def sixth-pokemon-name-start 0xD2EB)
82 (defn set-sixth-pokemon-name-first-character
83 ([state character]
84 (set-memory state sixth-pokemon-name-start
85 (character->character-code character)))
86 ([character]
87 (set-sixth-pokemon-name-first-character @current-state
88 character)))
91 (def end-of-name-marker 0x50)
92 (def max-name-length 11)
94 (defn sixth-pokemon-name [^SaveState state]
95 (character-codes->str
96 (take-while
97 (partial not= 0x50)
98 (subvec (vec (memory state))
99 sixth-pokemon-name-start
100 (+ (inc max-name-length)
101 sixth-pokemon-name-start)))))