Skip to content

Instantly share code, notes, and snippets.

@oupo
Last active August 27, 2017 06:43
Show Gist options
  • Save oupo/6339a9b430c6af61b6ad366883fdbe80 to your computer and use it in GitHub Desktop.
Save oupo/6339a9b430c6af61b6ad366883fdbe80 to your computer and use it in GitHub Desktop.
# 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