rlm@145: (ns com.aurellem.exp.pokemon rlm@145: "Here I find out how pokemon are stored in memory." rlm@145: (:use (com.aurellem.gb gb-driver items assembly util rlm@145: characters)) rlm@145: (:import [com.aurellem.gb.gb_driver SaveState])) rlm@145: rlm@145: rlm@145: (def pidgeot-lvl-36 (mid-game)) rlm@145: rlm@145: rlm@145: (def pidgeot-lvl-37 (read-state "pidgeot-lvl-37")) rlm@145: rlm@145: rlm@145: (def pidgeot-lvl-38 (read-state "pidgeot-lvl-38")) rlm@145: rlm@145: rlm@145: (def pidgeot-lvl-39 (read-state "pidgeot-lvl-39")) rlm@145: rlm@145: rlm@145: (def pidgeot-lvl-40 (read-state "pidgeot-lvl-40")) rlm@145: rlm@145: rlm@145: (defn level-analysis [] rlm@145: (apply common-differences rlm@145: (map (comp vec memory) rlm@145: [pidgeot-lvl-36 rlm@145: pidgeot-lvl-37 rlm@145: pidgeot-lvl-38 rlm@145: pidgeot-lvl-39 rlm@145: pidgeot-lvl-40]))) rlm@145: rlm@145: ;; inconclusive -- implies that level is calculated from rlm@145: ;; some other values. rlm@145: rlm@145: rlm@145: (def name-pidgeotto (read-state "name-pidgeotto")) rlm@145: (def named-A (read-state "named-A")) rlm@145: (def named-B (read-state "named-B")) rlm@145: (def named-C (read-state "named-C")) rlm@145: (def named-D (read-state "named-D")) rlm@145: (def named-E (read-state "named-E")) rlm@145: (def named-F (read-state "named-F")) rlm@145: rlm@145: (defn name-analysis [] rlm@145: (apply common-differences rlm@145: (map (comp vec memory) rlm@145: [named-A rlm@145: named-B rlm@145: named-C rlm@145: named-D rlm@145: named-E rlm@145: named-F]))) rlm@145: rlm@145: ;; resluted in 3 separate locations that could rlm@145: ;; possibly hold the first letter of the pokemon's name rlm@145: rlm@145: 0xCF4A rlm@145: 0xD2EB rlm@145: 0xCEED rlm@145: rlm@145: ;; try changing each of them rlm@145: rlm@145: rlm@145: (defn test-cf4a [] rlm@145: (continue! rlm@145: (set-memory named-A 0xCF4A (character->character-code "Z")))) rlm@145: ;; result -- pidgeotto named "A" rlm@145: rlm@145: (defn test-d2eb [] rlm@145: (continue! rlm@145: (set-memory named-A 0xD2EB (character->character-code "Z")))) rlm@145: ;; result -- pidgeotto named "Z" rlm@145: rlm@145: (defn test-ceed [] rlm@145: (continue! rlm@145: (set-memory named-A 0xCEED (character->character-code "Z")))) rlm@145: ;; result -- pidgeotto named "A" rlm@145: rlm@145: (def sixth-pokemon-name-start 0xD2EB) rlm@145: rlm@145: rlm@145: (defn set-sixth-pokemon-name-first-character rlm@145: ([state character] rlm@145: (set-memory state sixth-pokemon-name-start rlm@145: (character->character-code character))) rlm@145: ([character] rlm@145: (set-sixth-pokemon-name-first-character @current-state rlm@145: character))) rlm@145: rlm@145: rlm@146: (def end-of-name-marker 0x50) rlm@146: (def max-name-length 11) rlm@145: rlm@146: (defn sixth-pokemon-name [^SaveState state] rlm@146: (character-codes->str rlm@146: (take-while rlm@146: (partial not= 0x50) rlm@146: (subvec (vec (memory state)) rlm@146: sixth-pokemon-name-start rlm@146: (+ (inc max-name-length) rlm@146: sixth-pokemon-name-start))))) rlm@146: rlm@145: