annotate clojure/com/aurellem/exp/music.clj @ 440:292ece432ac4

investigating the game's music.
author Robert McIntyre <rlm@mit.edu>
date Thu, 26 Apr 2012 04:35:49 -0500
parents
children e682c9ed3056
rev   line source
rlm@440 1 (ns com.aurellem.exp.music
rlm@440 2 "scratchpad namespace"
rlm@440 3 (:use (com.aurellem.gb gb-driver util constants
rlm@440 4 assembly saves
rlm@440 5 items pokemon status types
rlm@440 6 characters species moves
rlm@440 7 pokedex money rival-name
rlm@440 8 text-speed badges
rlm@440 9 pokemon-presets
rlm@440 10 ))
rlm@440 11
rlm@440 12 (:import java.io.File)
rlm@440 13 (:import [com.aurellem.gb.gb_driver SaveState]))
rlm@440 14
rlm@440 15
rlm@440 16
rlm@440 17
rlm@440 18 (defn analyze-music []
rlm@440 19 (clojure.pprint/pprint
rlm@440 20 (map (fn [[addr nums]]
rlm@440 21 [(hex addr) nums])
rlm@440 22 (apply harmonic-compare
rlm@440 23 (map read-state
rlm@440 24 ["song-1" "no-song-1"
rlm@440 25 "song-2" "no-song-2"
rlm@440 26 "song-3" "no-song-3"
rlm@440 27 "song-4"])))))
rlm@440 28 ;; there are only two addresses that alternate between only
rlm@440 29 ;; two unique values:
rlm@440 30
rlm@440 31 0xC0DE ;; lol code :)
rlm@440 32 0xC0DF
rlm@440 33
rlm@440 34 ;; perhaps they are the address of the current playing sound?
rlm@440 35
rlm@440 36 ;; after watching them for a while in different environments,
rlm@440 37 ;; I can tell that they're definately music related, but they
rlm@440 38 ;; _don't_ seem to be the address to the current track.
rlm@440 39 ;; they generally change whenever a substantually different
rlm@440 40 ;; sequence is played. maybe they control some high level
rlm@440 41 ;; setting in the synthesizer? They are only affected by the
rlm@440 42 ;; background music and not by pokemon cries, etc.
rlm@440 43
rlm@440 44 0xC001 ;; seems to change along with the music, but is much
rlm@440 45 ;; more stable than 0xC0DE and 0xC0DF. It _is_
rlm@440 46 ;; affected by sound effects. When a sound effect happens,
rlm@440 47 ;; is sometimes does not return to its previous value when the sound
rlm@440 48 ;; effect is done.
rlm@440 49
rlm@440 50 0xC000 ;; does not seem to be affected by music
rlm@440 51
rlm@440 52 ;; maybe 0xC001 - something is loaded with the actual sounds?
rlm@440 53
rlm@440 54
rlm@440 55 ;; replacing just the first 0xFF bytes starting at 0xC001 with those
rlm@440 56 ;; found in celadon changes the music to celadon city.
rlm@440 57
rlm@440 58 ;; this can't be the actual music because it doesn't have enough
rlm@440 59 ;; information.
rlm@440 60
rlm@440 61 ;; let's try to narrow down the bytes from the first 0xFF of celadon
rlm@440 62 ;; starting at 0xC001
rlm@440 63
rlm@440 64 (def celadon-song
rlm@440 65 [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
rlm@440 66 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
rlm@440 67 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
rlm@440 68 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
rlm@440 69 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
rlm@440 70 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
rlm@440 71 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
rlm@440 72 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
rlm@440 73 0 0 0 0 0 0 0 0 0 0])
rlm@440 74
rlm@440 75 (defn change-music-to-celadon
rlm@440 76 ([#^SaveState state start length]
rlm@440 77
rlm@440 78 (set-memory-range state (+ 0xC001 start)
rlm@440 79 (take length (drop start celadon-song))))
rlm@440 80 ([start length]
rlm@440 81 (continue! (change-music-to-celadon (read-state "rlm-viridian-forest-battle")
rlm@440 82 start length))))
rlm@440 83
rlm@440 84
rlm@440 85
rlm@440 86 ;;0 0x90) blend between both, with end theme as well
rlm@440 87
rlm@440 88 ;; 0x05 0xEA is the limit to completely change song to celadon from
rlm@440 89 ;; viridian forest
rlm@440 90
rlm@440 91 ;; 0x05 0xEA is also sufficient to change music to celadon from
rlm@440 92 ;; a battle in viridian forest