# HG changeset patch # User Dylan Holmes # Date 1333105032 18000 # Node ID c31cb30430878d611230a5efcbf8f7eee96651c7 # Parent c8b0db518de3dd92ea1239119557f82425259981 Tinkering with types and encounters. diff -r c8b0db518de3 -r c31cb3043087 clojure/com/aurellem/gb/hxc.clj --- a/clojure/com/aurellem/gb/hxc.clj Thu Mar 29 18:23:20 2012 -0500 +++ b/clojure/com/aurellem/gb/hxc.clj Fri Mar 30 05:57:12 2012 -0500 @@ -449,8 +449,12 @@ (defn hxc-advantage - "The hardcoded type advantages in memory, returned as tuples of atk-type def-type multiplier. By default (i.e. if not listed here), -the multiplier is 1." + ;; in-game multipliers are stored as 10x their effective value + ;; to allow for fractional multipliers like 1/2 + + "The hardcoded type advantages in memory, returned as tuples of + atk-type def-type multiplier. By default (i.e. if not listed here), +the multiplier is 1. List begins at 0x3E62D." ([] (hxc-advantage com.aurellem.gb.gb-driver/original-rom)) ([rom] (map @@ -750,6 +754,52 @@ + + +(defn hxc-ptrs-wild + "A list of the hardcoded wild encounter data in memory. Pointers + begin at ROM@0CB95; data begins at ROM@0x04D89" + ([] (hxc-ptrs-wild com.aurellem.gb.gb-driver/original-rom)) + ([rom] + (let [ptrs + (map (fn [[a b]] (+ a (* 0x100 b))) + (take-while (partial not= (list 0xFF 0xFF)) + (partition 2 (drop 0xCB95 rom))))] + ptrs))) + + + +(defn hxc-wilds + "A list of the hardcoded wild encounter data in memory. Pointers + begin at ROM@0CB95; data begins at ROM@0x04D89" + ([] (hxc-wilds com.aurellem.gb.gb-driver/original-rom)) + ([rom] + (let [pokenames (zipmap (range) (hxc-pokenames rom))] + (map + (partial map (fn [[a b]] {:species (pokenames (dec b)) :level + a})) + (partition 10 + + (take-while (comp (partial not= 1) + first) + (partition 2 + (drop 0xCD8C rom)) + + )))))) + + + + + + + + + + + + + + ;; ********************** MANIPULATION FNS diff -r c8b0db518de3 -r c31cb3043087 clojure/com/aurellem/gb/types.clj --- a/clojure/com/aurellem/gb/types.clj Thu Mar 29 18:23:20 2012 -0500 +++ b/clojure/com/aurellem/gb/types.clj Fri Mar 30 05:57:12 2012 -0500 @@ -6,7 +6,7 @@ {0x00 :normal 0x01 :fighting 0x02 :flying - 0x03 :poision + 0x03 :poison 0x04 :ground 0x05 :rock 0x07 :bug diff -r c8b0db518de3 -r c31cb3043087 clojure/com/aurellem/world/new_types.clj --- a/clojure/com/aurellem/world/new_types.clj Thu Mar 29 18:23:20 2012 -0500 +++ b/clojure/com/aurellem/world/new_types.clj Fri Mar 30 05:57:12 2012 -0500 @@ -1,5 +1,121 @@ (ns com.aurellem.world.new-types - (:import (com.aurelem.gb.gb_driver)) - (:use (com.aurellem.gb hxc)) - ) + (:use (com.aurellem.gb gb-driver util hxc characters util assembly)) + (:use (com.aurellem.world practice)) + (:import [com.aurellem.gb.gb_driver SaveState])) + +;; GEN II type differences +;; bug against poison: 2x -> 1/2 +;; poison against bug: 2x -> 1x +;; !! our article is wrong. bug against ghost 1x -X-> 2x +;; ghost against psychic: 0x -> 2x +;; ice against fire: 1x -> 1/2 + +;; steel against rock: 2x +;; steel against steel: 1/2 +;; steel against fire : 1/2 +;; steel against water: 1/2 +;; steel against electric: 1/2 +;; steel against ice: 2x + +;; normal against steel: 1/2 +;; fighting against steel: 2x +;; flying against steel: 1/2 +;; poison against steel: 0 +;; ground against steel: 2 +;; rock against steel: 1/2 +;; bug against steel: 1/2 +;; ghost against steel: 1/2 +;; fire against steel: 2 +;; grass against steel: 1/2 +;; psychic against steel: 1/2 +;; ice against steel: 1/2 +;; dragon against steel: 1/2 +;; dark against steel: 1/2 + +;; dark against fighting 1/2 +;; dark against ghost 2x +;; dark against steel 1/2 +;; dark against psychic 2x +;; dark against dark 1/2 + +;; fighting against dark 1/2 +;; bug against dark 2x +;; ghost against dark 1/2 +;; psychic against dark 0 + + +;; #BIRD -> #DARK at 27DE8 + +(defn hack-encounter + "(BROKEN) Change the wild encounter pokemon of the given area in the current state. Volatile --- +only changes the current area, and then only as long as you remain in + the area." + ([pokemon] + (hack-encounter pokemon 11)) + ([pokemon level] + (let [id ((zipmap (hxc-pokenames) (range)) pokemon)] + (rewrite-memory (vec(memory)) + 0xD888 + (cons level + (interleave + (repeat 5 level) + (repeat (inc id))) + ))))) + + +(defn hack-encounter* + "Certainly Encounter a certain pokemon in the grass outside celadon. You must +walk out of the wild and back to load the data into RAM." + ([mem pkmn] (encounter mem pkmn 11)) + ([mem pkmn lvl] + (let [pkmn-id ((zipmap (hxc-pokenames) (range)) pkmn) + pkmn-id (if (nil? pkmn-id) 76 (inc pkmn-id)) + ] + (rewrite-memory + mem + 0xCF6C + (interleave (repeat lvl 10) (repeat pkmn-id)))))) + + +(defn hack-gen-2-types + [] + (-> + (vec (rom)) + (rewrite-memory 0x3E6DD [20]) ;; ghost is 2x effective against psychic + (rewrite-memory 0x3E6C5 [5]) ;; bug is half-effective against poison + + ;; ice is half-effective against fire. + ;; since this overwrites "poison is 2x against bug", + ;; poison is now, by default, 1x effective against bug. + (rewrite-memory 0x3E681 [25 20 5]) + + + (rewrite-memory 0x27DE9 ["DARK"]) ;; replace BIRD with DARK + (rewrite-memory 0x38105 [6]) ;; BITE is a dark-type attack + + ;; the following commands write into risky unknown memory. + + (rewrite-memory 0x27DFF + ["STEEL" 0x50]) + + (rewrite-memory 0x3E6f0 + [6 1 5 ;; dark fighting 1/2 + 6 24 20 ;; dark psychic 2 + 6 8 20 ;; dark ghost 2 + 6 6 5 ;; dark dark 1/2 + + 1 6 20 ;; fighting dark 2 + 24 6 0 ;; psychic dark 0 + 7 6 20 ;; bug dark 2 + 8 6 5 ;; ghost dark 1/2 + + 0xff + ]) + ;;(rewrite-rom _ + ;;(write-rom!) + + )) + + +