comparison clojure/com/aurellem/gb/hxc.clj @ 347:ff65ee0944fe

more progess: now rom.org tangles into hxc.clj; i'll be subdividing the code blocks as I write more.
author Dylan Holmes <ocsenave@gmail.com>
date Sun, 08 Apr 2012 06:13:39 -0500
parents 5639312a393f
children 497ca041f5af
comparison
equal deleted inserted replaced
346:5639312a393f 347:ff65ee0944fe
1
1 (ns com.aurellem.gb.hxc 2 (ns com.aurellem.gb.hxc
2 (:use (com.aurellem.gb assembly characters gb-driver util mem-util 3 (:use (com.aurellem.gb assembly characters gb-driver util mem-util
3 constants species)) 4 constants species))
4 (:import [com.aurellem.gb.gb_driver SaveState])) 5 (:import [com.aurellem.gb.gb_driver SaveState]))
5 6
6 7
7 8
8 9
9 ; ************* HANDWRITTEN CONSTANTS 10 ; ************* HANDWRITTEN CONSTANTS
10
11
12 11
13 (def pkmn-types 12 (def pkmn-types
14 [:normal ;;0 13 [:normal ;;0
15 :fighting ;;1 14 :fighting ;;1
16 :flying ;;2 15 :flying ;;2
136 "(leech seed)" 135 "(leech seed)"
137 "does nothing (splash)" 136 "does nothing (splash)"
138 "(disable)" 137 "(disable)"
139 ]) 138 ])
140 139
141
142 ;; ************** HARDCODED DATA 140 ;; ************** HARDCODED DATA
143 141
144 (defn hxc-thunk 142 (defn hxc-thunk
145 "Creates a thunk (nullary fn) that grabs data in a certain region of rom and 143 "Creates a thunk (nullary fn) that grabs data in a certain region of rom and
146 splits it into a collection by 0x50. If rom is not supplied, uses the 144 splits it into a collection by 0x50. If rom is not supplied, uses the
159 "Same as hxc-thunk, except it interprets the rom data as characters, 157 "Same as hxc-thunk, except it interprets the rom data as characters,
160 returning a collection of strings." 158 returning a collection of strings."
161 (comp 159 (comp
162 (partial comp (partial map character-codes->str)) 160 (partial comp (partial map character-codes->str))
163 hxc-thunk)) 161 hxc-thunk))
164
165 162
166 ;; -------------------------------------------------- 163 ;; --------------------------------------------------
167 164
168 165
169 166
508 (drop 0x3E62D rom)))))) 505 (drop 0x3E62D rom))))))
509 506
510 507
511 508
512 (defn format-evo 509 (defn format-evo
510 "Parse a sequence of evolution data, returning a map. First is the
511 method: 0 = end-evolution-data. 1 = level-up, 2 = item, 3 = trade. Next is an item id, if the
512 method of evolution is by item (only stones will actually make pokemon
513 evolve, for some auxillary reason.) Finally, the minimum level for
514 evolution to occur (level 1 means no limit, which is used for trade
515 and item evolutions), followed by the internal id of the pokemon
516 into which to evolve. Hence, level up and trade evolutions are
517 described with 3
518 bytes; item evolutions with four."
513 [coll] 519 [coll]
514 (let [method (first coll)] 520 (let [method (first coll)]
515 (cond (empty? coll) [] 521 (cond (empty? coll) []
516 (= 0 method) [] ;; just in case 522 (= 0 method) [] ;; just in case
517 (= 1 method) ;; level-up evolution 523 (= 1 method) ;; level-up evolution
553 559
554 560
555 (defn hxc-learnsets 561 (defn hxc-learnsets
556 "Hardcoded map associating pokemon names to lists of pairs [lvl 562 "Hardcoded map associating pokemon names to lists of pairs [lvl
557 move] of abilities they learn as they level up. The data 563 move] of abilities they learn as they level up. The data
558 exists at ROM@3400, sorted by internal order. Pointers to the data 564 exists at ROM@34000, sorted by internal order. Pointers to the data
559 exist at ROM@3B1E5; see also, hxc-ptrs-evolve" 565 exist at ROM@3B1E5; see also, hxc-ptrs-evolve"
560 ([] (hxc-learnsets com.aurellem.gb.gb-driver/original-rom)) 566 ([] (hxc-learnsets com.aurellem.gb.gb-driver/original-rom))
561 ([rom] 567 ([rom]
562 (apply assoc 568 (apply assoc
563 {} 569 {}
930 ;; note: DD4D spells out pokemon vital stat names ("speed", etc.) 936 ;; note: DD4D spells out pokemon vital stat names ("speed", etc.)
931 937
932 ;; note: 1195C-6A says ABLE#NOT ABLE#, but so does 119C0-119CE. 938 ;; note: 1195C-6A says ABLE#NOT ABLE#, but so does 119C0-119CE.
933 ;; The first instance is for Machines; the second, for stones. 939 ;; The first instance is for Machines; the second, for stones.
934 940
941 ;; 0x251A (in indexable mem): image decompression routine seems to begin here.
942
943
935 (comment 944 (comment
936 945
937 (def hxc-later 946 (def hxc-later
938 "Running this code produces, e.g. hardcoded names NPCs give 947 "Running this code produces, e.g. hardcoded names NPCs give
939 their pokemon. Will sort through it later." 948 their pokemon. Will sort through it later."
949 (def dex dex) 958 (def dex dex)
950 (def hxc-species 959 (def hxc-species
951 (map character-codes->str 960 (map character-codes->str
952 (take-nth 4 dex)))) 961 (take-nth 4 dex))))
953 ) 962 )
954
955
956
957
958
959