changeset 440:292ece432ac4

investigating the game's music.
author Robert McIntyre <rlm@mit.edu>
date Thu, 26 Apr 2012 04:35:49 -0500
parents 71878fbc277b
children e682c9ed3056
files clojure/com/aurellem/exp/music.clj save-states/no-song-1.sav save-states/no-song-2.sav save-states/no-song-3.sav save-states/rlm-viridian-forest-battle.sav save-states/rlm-viridian-forest.sav save-states/song-1.sav save-states/song-2.sav save-states/song-3.sav save-states/song-4.sav save-states/song-5.sav
diffstat 11 files changed, 92 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/clojure/com/aurellem/exp/music.clj	Thu Apr 26 04:35:49 2012 -0500
     1.3 @@ -0,0 +1,92 @@
     1.4 +(ns com.aurellem.exp.music
     1.5 +  "scratchpad namespace"
     1.6 +  (:use (com.aurellem.gb gb-driver util constants
     1.7 +                         assembly saves
     1.8 +                         items pokemon status types
     1.9 +                         characters species moves
    1.10 +                         pokedex money rival-name
    1.11 +                         text-speed badges
    1.12 +                         pokemon-presets
    1.13 +                         ))
    1.14 +  
    1.15 +  (:import java.io.File)
    1.16 +  (:import [com.aurellem.gb.gb_driver SaveState]))
    1.17 +
    1.18 +
    1.19 +
    1.20 +
    1.21 +(defn analyze-music []
    1.22 +  (clojure.pprint/pprint
    1.23 +   (map (fn [[addr nums]]
    1.24 +          [(hex addr) nums])
    1.25 +        (apply harmonic-compare
    1.26 +               (map read-state
    1.27 +                    ["song-1" "no-song-1"
    1.28 +                     "song-2" "no-song-2"
    1.29 +                     "song-3" "no-song-3"
    1.30 +                     "song-4"])))))
    1.31 +;; there are only two addresses that alternate between only
    1.32 +;; two unique values:
    1.33 +
    1.34 +0xC0DE ;; lol code :)
    1.35 +0xC0DF
    1.36 +
    1.37 +;; perhaps they are the address of the current playing sound?
    1.38 +
    1.39 +;; after watching them for a while in different environments,
    1.40 +;; I can tell that they're definately music related, but they
    1.41 +;; _don't_ seem to be the address to the current track.
    1.42 +;; they generally change whenever a substantually different
    1.43 +;; sequence is played.  maybe they control some high level
    1.44 +;; setting in the synthesizer? They are only affected by the
    1.45 +;; background music and not by pokemon cries, etc.
    1.46 +
    1.47 +0xC001 ;; seems to change along with the music, but is much
    1.48 +;; more stable than 0xC0DE and 0xC0DF. It _is_
    1.49 +;; affected by sound effects.  When a sound effect happens,
    1.50 +;; is sometimes does not return to its previous value when the sound
    1.51 +;; effect is done.
    1.52 +
    1.53 +0xC000 ;; does not seem to be affected by music
    1.54 +
    1.55 +;; maybe 0xC001 - something is loaded with the actual sounds?
    1.56 +
    1.57 +
    1.58 +;; replacing just the first 0xFF bytes starting at 0xC001 with those
    1.59 +;; found in celadon changes the music to celadon city.
    1.60 +
    1.61 +;; this can't be the actual music because it doesn't have enough
    1.62 +;; information.
    1.63 +
    1.64 +;; let's try to narrow down the bytes from the first 0xFF of celadon
    1.65 +;; starting at 0xC001
    1.66 +
    1.67 +(def celadon-song
    1.68 +  [202 0 0 255 0 178 117 40 118 158 118 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    1.69 +  0 0 0 0 0 0 0 0 0 0 0 202 202 202 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
    1.70 +  0 0 0 0 128 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    1.71 +  0 0 0 0 0 0 0 0 0 0 0 0 115 88 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    1.72 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    1.73 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 5 1 1 1 1 1
    1.74 +  1 1 1 1 1 1 1 1 12 12 12 1 1 1 1 1 128 128 128 0 0 0 0 0 5 4 4 0 4 3
    1.75 +  4 0 178 194 32 0 180 196 32 0 3 0 0 144 1 0 66 31 0 2 2 32 48 0 0 0
    1.76 +   0 0 0 0 0 0 0 0 0 0])
    1.77 +
    1.78 +(defn change-music-to-celadon
    1.79 +  ([#^SaveState state start length]
    1.80 +
    1.81 +     (set-memory-range state (+ 0xC001 start)
    1.82 +                       (take length (drop start celadon-song))))
    1.83 +  ([start length]
    1.84 +     (continue! (change-music-to-celadon (read-state "rlm-viridian-forest-battle")
    1.85 +                                         start length))))
    1.86 +   
    1.87 +  
    1.88 +
    1.89 +;;0 0x90) blend between both, with end theme as well
    1.90 +
    1.91 +;; 0x05 0xEA is the limit to completely change song to celadon from
    1.92 +;; viridian forest
    1.93 +
    1.94 +;; 0x05 0xEA is also sufficient to change music to celadon from
    1.95 +;; a battle in viridian forest
    1.96 \ No newline at end of file
     2.1 Binary file save-states/no-song-1.sav has changed
     3.1 Binary file save-states/no-song-2.sav has changed
     4.1 Binary file save-states/no-song-3.sav has changed
     5.1 Binary file save-states/rlm-viridian-forest-battle.sav has changed
     6.1 Binary file save-states/rlm-viridian-forest.sav has changed
     7.1 Binary file save-states/song-1.sav has changed
     8.1 Binary file save-states/song-2.sav has changed
     9.1 Binary file save-states/song-3.sav has changed
    10.1 Binary file save-states/song-4.sav has changed
    11.1 Binary file save-states/song-5.sav has changed