comparison clojure/com/aurellem/exp/pokemon.clj @ 145:412ca096a9ba

major refactoring complete.
author Robert McIntyre <rlm@mit.edu>
date Mon, 19 Mar 2012 21:23:46 -0500
parents
children c5914665012d
comparison
equal deleted inserted replaced
144:ec477931f077 145:412ca096a9ba
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]))
6
7
8 (def pidgeot-lvl-36 (mid-game))
9
10
11 (def pidgeot-lvl-37 (read-state "pidgeot-lvl-37"))
12
13
14 (def pidgeot-lvl-38 (read-state "pidgeot-lvl-38"))
15
16
17 (def pidgeot-lvl-39 (read-state "pidgeot-lvl-39"))
18
19
20 (def pidgeot-lvl-40 (read-state "pidgeot-lvl-40"))
21
22
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])))
31
32 ;; inconclusive -- implies that level is calculated from
33 ;; some other values.
34
35
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"))
43
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])))
53
54 ;; resluted in 3 separate locations that could
55 ;; possibly hold the first letter of the pokemon's name
56
57 0xCF4A
58 0xD2EB
59 0xCEED
60
61 ;; try changing each of them
62
63
64 (defn test-cf4a []
65 (continue!
66 (set-memory named-A 0xCF4A (character->character-code "Z"))))
67 ;; result -- pidgeotto named "A"
68
69 (defn test-d2eb []
70 (continue!
71 (set-memory named-A 0xD2EB (character->character-code "Z"))))
72 ;; result -- pidgeotto named "Z"
73
74 (defn test-ceed []
75 (continue!
76 (set-memory named-A 0xCEED (character->character-code "Z"))))
77 ;; result -- pidgeotto named "A"
78
79 (def sixth-pokemon-name-start 0xD2EB)
80
81
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)))
89
90
91
92