changeset 346:5639312a393f

Saving progress. Cleaned up documentation a little; found more ROM stuff, including names of status ailments and amount of HP restored by potions.
author Dylan Holmes <ocsenave@gmail.com>
date Sun, 08 Apr 2012 01:28:39 -0500
parents 9366539d29b6
children ff65ee0944fe
files clojure/com/aurellem/gb/hxc.clj clojure/com/aurellem/gb/mem_util.clj org/rom.org
diffstat 3 files changed, 53 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/hxc.clj	Sun Apr 08 08:43:52 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/hxc.clj	Sun Apr 08 01:28:39 2012 -0500
     1.3 @@ -925,7 +925,12 @@
     1.4  
     1.5  ;; note for later: credits start at F1290
     1.6  
     1.7 +;; note: DADB hyper-potion-hp _ _ _ super-potion-hp _ _ _ potion-hp ??
     1.8  
     1.9 +;; note: DD4D spells out pokemon vital stat names ("speed", etc.)
    1.10 +
    1.11 +;; note: 1195C-6A says ABLE#NOT ABLE#, but so does 119C0-119CE.
    1.12 +;; The first instance is for Machines; the second, for stones.
    1.13  
    1.14  (comment 
    1.15  
     2.1 --- a/clojure/com/aurellem/gb/mem_util.clj	Sun Apr 08 08:43:52 2012 -0500
     2.2 +++ b/clojure/com/aurellem/gb/mem_util.clj	Sun Apr 08 01:28:39 2012 -0500
     2.3 @@ -190,3 +190,43 @@
     2.4  
     2.5  (defn restore-rom! [] (write-rom! original-rom))
     2.6  
     2.7 +
     2.8 +(defn endian-flip
     2.9 +  "Flip the bytes of the two-byte number."
    2.10 +  [n]
    2.11 +  (assert (< n 0xFFFF))
    2.12 +  (+ (* 0x100 (rem n 0x100))
    2.13 +        (int (/ n 0x100))))
    2.14 +
    2.15 +
    2.16 +(defn offset->ptr
    2.17 +  "Convert an offset into a little-endian pointer."
    2.18 +  [n]
    2.19 +  (->
    2.20 +   n
    2.21 +   (rem 0x10000) ;; take last four bytes
    2.22 +   (rem 0x4000)   ;; get relative offset from the start of the bank
    2.23 +   (+ 0x4000)
    2.24 +   endian-flip))
    2.25 +
    2.26 +(defn offset->bank
    2.27 +  "Get the bank of the offset."
    2.28 +  [n]
    2.29 +  (int (/ n 0x4000)))
    2.30 +
    2.31 +(defn ptr->offset
    2.32 +  "Convert a two-byte little-endian pointer into an offset."
    2.33 +  [bank ptr]
    2.34 +  (->
    2.35 +   ptr
    2.36 +   endian-flip
    2.37 +   (- 0x4000)
    2.38 +   (+ (* 0x4000 bank))
    2.39 +   ))
    2.40 +
    2.41 +(defn same-bank-offset
    2.42 +  "Convert a ptr into an absolute offset by using the bank of the reference."
    2.43 +  [reference ptr]
    2.44 +  (ptr->offset
    2.45 +   (offset->bank reference)
    2.46 +   ptr))
    2.47 \ No newline at end of file
     3.1 --- a/org/rom.org	Sun Apr 08 08:43:52 2012 -0500
     3.2 +++ b/org/rom.org	Sun Apr 08 01:28:39 2012 -0500
     3.3 @@ -7,7 +7,8 @@
     3.4  #+INCLUDE: ../../aurellem/org/level-0.org
     3.5  #+BABEL: :exports both :noweb yes :cache no :mkdirp yes
     3.6  
     3.7 -
     3.8 +# about map headers http://datacrystal.romhacking.net/wiki/Pokemon_Red/Blue:Notes
     3.9 +# map headers Yellow http://www.pokecommunity.com/archive/index.php/t-235311.html
    3.10  # pokedollar: U+20B1
    3.11  * Mapping the ROM
    3.12  
    3.13 @@ -17,12 +18,15 @@
    3.14  | 0233C-            | Shop inventories. |                 |                 |
    3.15  | 04495-            | Prices of items. | Each price is two bytes of binary-coded decimal. Prices are separated by zeroes. Priceless items[fn::Like the Pok\eacute{}dex and other unsellable items.] are given a price of zero. | The cost of lemonade is 0x03 0x50, which translates to a price of ₱350. |
    3.16  | 045B7-0491E       | Names of the items in memory. | Variable-length item names (strings of character codes). Names are separated by a single 0x80 character. | MASTER BALL#ULTRA BALL#... |
    3.17 -| 04D89-            | Lists of wild Pok\eacute{}mon to encounter in each region. | Each list contains ten Pokemon (ids) and their levels; twenty bytes in total. First, the level of the first Pokemon. Then the internal id of the first Pokemon. Next, the level of the second Pokemon, and so on. Since Pokemon cannot have level 0, the lists are separated by a pair 0 /X/, where /X/ is an apparently random Pokemon id. | The first list is (3 36 4 36 2 165 3 165 2 36 3 36 5 36 4 165 6 36 7 36 0 25), i.e. level 3 pidgey, level 4 pidgey, level 2 rattata, level 3 rattata, level 2 pidgey, level 3 pidgey, level 5 pidgey, level 4 rattata, level 6 pidgey, level 7 pidgey, level 0 end-of-list. |
    3.18 +| 04D89-            | Lists of wild Pok\eacute{}mon to encounter in each region. | Each list contains ten Pokemon (ids) and their levels; twenty bytes in total. First, the level of the first Pokemon. Then the internal id of the first Pokemon. Next, the level of the second Pokemon, and so on. Since Pokemon cannot have level 0, the lists are separated by a pair 0 /X/, where /X/ is an apparently random Pokemon id. | The first list is (3 36 4 36 2 165 3 165 2 36 3 36 5 36 4 165 6 36 7 36 0 25), i.e. level 3 pidgey, level 4 pidgey, level 2 rattata, level 3 rattata, level 2 pidgey, level 3 pidgey, level 5 pidgey, level 4 rattata, level 6 pidgey, level 7 pidgey, \ldquo{}level 0 gastly\rdquo{} (i.e., end-of-list). |
    3.19  | 05EDB.            | Which Pok\eacute{}mon to show during Prof. Oak's introduction. | A single byte, the Pok\eacute{}mon's internal id. | In Pok\eacute{}mon Yellow, it shows Pikachu during the introduction; Pikachu's internal id is 0x54. |
    3.20  | 06698-            | ? Background music. |                 |                 |
    3.21  | 0822E-082F?       | Pointers to background music, part I. |                 |                 |
    3.22  | 0CB95-            | Pointers to lists of wild pokemon to encounter in each region. These lists begin at 04D89, see above. | Each pointer is a low-byte, high-byte pair. | The first entry is 0x89 0x4D, corresponding to the address 0x4D89, the location of the first list of wild Pok\eacute{}mon (see above). |
    3.23 -| 1232D-            | Which moves are taught by the TMs and HMs |                 |                 |
    3.24 +| 0DD4D-DD72        | Names of permanent stats. | Variable-length strings separated by 0x50. | #HEALTH#ATTACK#DEFENSE#SPEED#SPECIAL# |
    3.25 +| 1195C-1196A       | The two terms for being able/unable to learn a TM/HM. | Variable-length strings separated by 0x50. | ABLE#NOT ABLE#  |
    3.26 +| 119C0-119CE       | The two terms for being able/unable to evolve using the current stone. | Variable-length strings separated by 0x50. | ABLE#NOT ABLE#  |
    3.27 +| 1232D-12364       | Which moves are taught by the TMs and HMs | A list of 55 move ids (50 TMs, plus 5 HMs). First, the move that will be taught by TM01; second, the move that will be taught by TM02; and so on. The last five entries are the moves taught by HMs 1-5. (See also, BC000 below) | The first few entries are (5 13 14 18 ...) corresponding to Mega Punch (TM01), Razor Wind (TM02), Swords Dance (TM03), Whirlwind (TM04), ... |
    3.28  | 27D99-27DFF       | Names of the Pok\eacute{}mon types. | Variable-length type names (strings of character codes). Names are separated by a single 0x80 character. | NORMAL#FIGHTING#... |
    3.29  | 27E77-            | Trainer title names. |                 | YOUNGSTER#BUG CATCHER#LASS#... |
    3.30  | 34000-            | Evolution and learnset data. |                 |                 |
    3.31 @@ -32,6 +36,7 @@
    3.32  | 3B1E5-            | Pointers to evolution/learnset data. |                 |                 |
    3.33  | 40687-            | Species data from the Pok\eacute{}dex: species name, height, weight, etc. | Fixed-length sequences of bytes. See below for specifics. |                 |
    3.34  | 410B1-            | A conversion table between internal order and Pokedex order. |                 |                 |
    3.35 +| 5DE10-5DE30       | Abbreviations for status ailments. | Fixed-length strings, probably[fn::Here's something strange: all of the status messages start with 0x7F and end with 0x4F \mdash{}except PAR, which ends with 0x50.]. The last entry is QUIT##. | [0x7F] *SLP* [0x4E][0x7F] *PSN* [0x4E][0x7F] *PAR* [0x50][0x7F]... |
    3.36  | 71500-            | Names of places. |                 |                 |
    3.37  | 7C249-7C2??       | Pointers to background music, pt II. |                 |                 |
    3.38  | 98000-            | Dialogue        |                 |                 |