changeset 294:9f466a332448

merge
author Robert McIntyre <rlm@mit.edu>
date Fri, 30 Mar 2012 18:15:28 -0500
parents 4a0dbaed7078 (current diff) c31cb3043087 (diff)
children d35683bfc15f
files
diffstat 3 files changed, 172 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/hxc.clj	Fri Mar 30 18:14:14 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/hxc.clj	Fri Mar 30 18:15:28 2012 -0500
     1.3 @@ -449,8 +449,12 @@
     1.4  
     1.5  
     1.6  (defn hxc-advantage
     1.7 -  "The hardcoded type advantages in memory, returned as tuples of atk-type def-type multiplier. By default (i.e. if not listed here),
     1.8 -the multiplier is 1."
     1.9 +  ;; in-game multipliers are stored as 10x their effective value
    1.10 +  ;; to allow for fractional multipliers like 1/2
    1.11 +  
    1.12 +  "The hardcoded type advantages in memory, returned as tuples of
    1.13 +  atk-type def-type multiplier. By default (i.e. if not listed here),
    1.14 +the multiplier is 1. List begins at 0x3E62D."
    1.15    ([] (hxc-advantage com.aurellem.gb.gb-driver/original-rom))
    1.16    ([rom]
    1.17       (map
    1.18 @@ -750,6 +754,52 @@
    1.19  
    1.20  
    1.21  
    1.22 +
    1.23 +
    1.24 +(defn hxc-ptrs-wild
    1.25 +  "A list of the hardcoded wild encounter data in memory. Pointers
    1.26 +  begin at ROM@0CB95; data begins at ROM@0x04D89" 
    1.27 +  ([] (hxc-ptrs-wild com.aurellem.gb.gb-driver/original-rom))
    1.28 +  ([rom]
    1.29 +     (let [ptrs
    1.30 +           (map (fn [[a b]] (+ a (* 0x100 b)))
    1.31 +            (take-while (partial not= (list 0xFF 0xFF))
    1.32 +                            (partition 2 (drop 0xCB95 rom))))]
    1.33 +       ptrs)))
    1.34 +
    1.35 +
    1.36 +
    1.37 +(defn hxc-wilds
    1.38 +  "A list of the hardcoded wild encounter data in memory. Pointers
    1.39 +  begin at ROM@0CB95; data begins at ROM@0x04D89" 
    1.40 +  ([] (hxc-wilds com.aurellem.gb.gb-driver/original-rom))
    1.41 +  ([rom]
    1.42 +     (let [pokenames (zipmap (range) (hxc-pokenames rom))]
    1.43 +       (map
    1.44 +        (partial map (fn [[a b]] {:species (pokenames (dec b)) :level
    1.45 +                                  a}))
    1.46 +        (partition 10
    1.47 +                     
    1.48 +                      (take-while (comp (partial not= 1)
    1.49 +                                        first) 
    1.50 +                                 (partition 2
    1.51 +                                            (drop 0xCD8C rom))
    1.52 +                   
    1.53 +                   ))))))
    1.54 +
    1.55 +
    1.56 +
    1.57 +
    1.58 +
    1.59 +
    1.60 +
    1.61 +
    1.62 +
    1.63 +
    1.64 +
    1.65 +
    1.66 +
    1.67 +
    1.68  ;; ********************** MANIPULATION FNS
    1.69  
    1.70  
     2.1 --- a/clojure/com/aurellem/gb/types.clj	Fri Mar 30 18:14:14 2012 -0500
     2.2 +++ b/clojure/com/aurellem/gb/types.clj	Fri Mar 30 18:15:28 2012 -0500
     2.3 @@ -6,7 +6,7 @@
     2.4    {0x00 :normal
     2.5     0x01 :fighting
     2.6     0x02 :flying
     2.7 -   0x03 :poision
     2.8 +   0x03 :poison
     2.9     0x04 :ground
    2.10     0x05 :rock
    2.11     0x07 :bug
     3.1 --- a/clojure/com/aurellem/world/new_types.clj	Fri Mar 30 18:14:14 2012 -0500
     3.2 +++ b/clojure/com/aurellem/world/new_types.clj	Fri Mar 30 18:15:28 2012 -0500
     3.3 @@ -1,5 +1,121 @@
     3.4  (ns com.aurellem.world.new-types
     3.5 -  (:import (com.aurelem.gb.gb_driver))
     3.6 -  (:use (com.aurellem.gb hxc))
     3.7 -  )
     3.8 +  (:use (com.aurellem.gb gb-driver util hxc characters util assembly))
     3.9 +  (:use (com.aurellem.world practice))
    3.10 +  (:import [com.aurellem.gb.gb_driver SaveState]))
    3.11    
    3.12 +
    3.13 +;; GEN II type differences
    3.14 +;; bug against poison: 2x -> 1/2
    3.15 +;; poison against bug: 2x -> 1x
    3.16 +;; !! our article is wrong. bug against ghost 1x -X-> 2x
    3.17 +;; ghost against psychic: 0x -> 2x
    3.18 +;; ice against fire: 1x -> 1/2
    3.19 +
    3.20 +;; steel against rock: 2x
    3.21 +;; steel against steel: 1/2
    3.22 +;; steel against fire : 1/2
    3.23 +;; steel against water: 1/2
    3.24 +;; steel against electric: 1/2
    3.25 +;; steel against ice: 2x
    3.26 +
    3.27 +;; normal against steel: 1/2
    3.28 +;; fighting against steel: 2x
    3.29 +;; flying against steel: 1/2
    3.30 +;; poison against steel: 0
    3.31 +;; ground against steel: 2
    3.32 +;; rock against steel: 1/2
    3.33 +;; bug against steel: 1/2
    3.34 +;; ghost against steel: 1/2
    3.35 +;; fire against steel: 2
    3.36 +;; grass against steel: 1/2
    3.37 +;; psychic against steel: 1/2
    3.38 +;; ice against steel: 1/2
    3.39 +;; dragon against steel: 1/2
    3.40 +;; dark against steel: 1/2
    3.41 +
    3.42 +;; dark against fighting 1/2
    3.43 +;; dark against ghost 2x
    3.44 +;; dark against steel 1/2
    3.45 +;; dark against psychic 2x
    3.46 +;; dark against dark 1/2
    3.47 +
    3.48 +;; fighting against dark 1/2
    3.49 +;; bug against dark 2x
    3.50 +;; ghost against dark 1/2
    3.51 +;; psychic against dark 0
    3.52 +
    3.53 +
    3.54 +;; #BIRD -> #DARK at 27DE8
    3.55 +
    3.56 +(defn hack-encounter
    3.57 +  "(BROKEN) Change the wild encounter pokemon of the given area in the current state. Volatile ---
    3.58 +only changes the current area, and then only as long as you remain in
    3.59 +  the area."
    3.60 +  ([pokemon]
    3.61 +     (hack-encounter pokemon 11))
    3.62 +  ([pokemon level]
    3.63 +     (let [id ((zipmap (hxc-pokenames) (range)) pokemon)]
    3.64 +       (rewrite-memory (vec(memory))
    3.65 +                       0xD888
    3.66 +                       (cons level
    3.67 +                             (interleave
    3.68 +                              (repeat 5 level)
    3.69 +                              (repeat (inc id)))
    3.70 +                              )))))
    3.71 +  
    3.72 +  
    3.73 +(defn hack-encounter*
    3.74 +  "Certainly Encounter a certain pokemon in the grass outside celadon. You must
    3.75 +walk out of the wild and back to load the data into RAM." 
    3.76 +  ([mem pkmn] (encounter mem pkmn 11))
    3.77 +  ([mem pkmn lvl]
    3.78 +  (let [pkmn-id ((zipmap (hxc-pokenames) (range)) pkmn)
    3.79 +        pkmn-id (if (nil? pkmn-id) 76 (inc pkmn-id))
    3.80 +        ] 
    3.81 +    (rewrite-memory
    3.82 +     mem
    3.83 +     0xCF6C
    3.84 +     (interleave (repeat lvl 10) (repeat pkmn-id))))))
    3.85 +
    3.86 +
    3.87 +(defn hack-gen-2-types
    3.88 +  []
    3.89 +  (->
    3.90 +   (vec (rom))
    3.91 +   (rewrite-memory 0x3E6DD [20]) ;; ghost is 2x effective against psychic
    3.92 +   (rewrite-memory 0x3E6C5 [5])  ;; bug is half-effective against poison
    3.93 +   
    3.94 +   ;; ice is half-effective against fire.
    3.95 +   ;; since this overwrites "poison is 2x against bug",
    3.96 +   ;; poison is now, by default, 1x effective against bug.
    3.97 +   (rewrite-memory 0x3E681 [25 20 5])
    3.98 +   
    3.99 +   
   3.100 +   (rewrite-memory 0x27DE9 ["DARK"]) ;; replace BIRD with DARK
   3.101 +   (rewrite-memory 0x38105 [6]) ;; BITE is a dark-type attack
   3.102 +
   3.103 +   ;; the following commands write into risky unknown memory.
   3.104 +
   3.105 +   (rewrite-memory 0x27DFF
   3.106 +                   ["STEEL" 0x50])
   3.107 +   
   3.108 +   (rewrite-memory 0x3E6f0
   3.109 +                   [6 1 5   ;; dark fighting 1/2
   3.110 +                    6 24 20 ;; dark psychic 2
   3.111 +                    6 8 20  ;; dark ghost 2
   3.112 +                    6 6 5  ;; dark dark 1/2
   3.113 +
   3.114 +                    1 6 20  ;; fighting dark 2
   3.115 +                    24 6 0  ;; psychic dark 0
   3.116 +                    7 6 20  ;; bug dark 2
   3.117 +                    8 6 5   ;; ghost dark 1/2
   3.118 +                    
   3.119 +                    0xff
   3.120 +                    ])
   3.121 +   ;;(rewrite-rom _ 
   3.122 +   ;;(write-rom!)
   3.123 + 
   3.124 +   ))
   3.125 +  
   3.126 +
   3.127 +