Last active
August 27, 2017 06:43
-
-
Save oupo/6339a9b430c6af61b6ad366883fdbe80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HGSSのセーブデータにおいてペラップのおしゃべり音声にサインカーブを書きこむ | |
fname = ARGV[0] | |
bin = File.binread(fname).bytes.to_a | |
2.times do |j| | |
off = 0x40000 * j + 0x4e78 # hgss | |
off = 0x40000 * j + 0x64f0 # pt | |
1000.times do |i| | |
bin[off + i] = 0 | |
end | |
2000.times do |i| | |
t = 4 * i | |
h = ((Math.sin(t) * 8 + 8) % 16).to_i | |
bin[off + i / 2] += h << 4 * (i % 2) | |
end | |
end | |
File.binwrite(fname, bin.map(&:chr).join("")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment