Skip to content

Commit

Permalink
Merge pull request #12 from CebolaBros64/loop
Browse files Browse the repository at this point in the history
Add support for editing and extracting the loop value in tempo files
  • Loading branch information
chrislo27 authored Dec 23, 2021
2 parents d364260 + 7b34f78 commit 32bccf7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class GameExtractor(val allSubs: Boolean) {
val beats = buffer.getFloat(addr - 0x100000)
val seconds = buffer.getInt(addr - 0x100000 + 4) / 32000.0 // will not work with unsigned but not important
val bpm = 60 * beats / seconds
s += "${correctlyRoundDouble(bpm, DECIMALS)} ${correctlyRoundDouble(beats.toDouble(), DECIMALS)}\n"
val loop = buffer.getInt(addr - 0x100000 + 8)
s += "${correctlyRoundDouble(bpm, DECIMALS)} ${correctlyRoundDouble(beats.toDouble(), DECIMALS)} ${loop}\n"
if (buffer.getIntAdj(addr + 8) != 0)
break
addr += 12
Expand Down
15 changes: 10 additions & 5 deletions src/main/kotlin/rhmodding/tickompiler/gameputter/GamePutter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,20 @@ object GamePutter {
tempo.drop(1).forEachIndexed { index, list ->
val bpm = list[0].toFloat()
val beats = list[1].toFloat()
val loop = if (list.size > 2){ // Check for loop value
list[2].toInt()
} else { // Special case for tempo files lacking loop value, behaves exactly as older Tickompiler versions
if (index == tempo.size - 2) {
0x8000
} else {
0
}
}
val time = 60*beats/bpm
val timeInt = (time * 32000).roundToInt()
result.add(java.lang.Float.floatToIntBits(beats))
result.add(timeInt)
if (index == tempo.size - 2) {
result.add(0x8000)
} else {
result.add(0)
}
result.add(loop)
}
for (i in 0 until 0x1DD) {
val one = base.getInt(16*i + 0x1588)
Expand Down

0 comments on commit 32bccf7

Please sign in to comment.