taud: extended tempo range

This commit is contained in:
minjaesong
2026-06-20 04:00:33 +09:00
parent 1173373789
commit 6eb73355ca
11 changed files with 101 additions and 49 deletions

View File

@@ -23,7 +23,7 @@ const BEEP_P_LO = -96 // MMIO 95: pppppp_QQ
const BEEP_A = -97 // MMIO 96: A
const BEEP_B = -98 // MMIO 97: B
const BEEP_HALFCLOCK = 3579545 / 16 / 2 // f = BEEP_HALFCLOCK / divider
const BEEP_HALFCLOCK = (3579545.4545454545 / 16.0) / 2 // f = BEEP_HALFCLOCK / divider
const DIVIDER_MAX = 0x3FFF // 14-bit
const QQ_NONE = 0, QQ_TWO = 2, QQ_THREE = 3 // beeper note-effect (QQ field)
@@ -308,6 +308,10 @@ function applyTickEffects(v, t) {
const sleepUntil = (nano) => { const ms = (nano - sys.nanoTime()) / 1e6; if (ms >= 1) sys.sleep(Math.floor(ms)) }
function cmdToInt(cmd) {
return cmd[0] | (cmd[1] << 8) | (cmd[2] << 16) | (cmd[3] << 24);
}
// ---------------------------------------------------------------------------
// Render loop
// ---------------------------------------------------------------------------
@@ -322,6 +326,8 @@ const checkStop = () => {
return stopReq
}
let oldDiv = 0xFFFFFFFF
try {
let o = 0
let startRow = 0
@@ -352,12 +358,19 @@ try {
}
uploadBeeper(cmd[0], cmd[1], cmd[2], cmd[3])
println(`${String(globalTick).padStart(6, '0')} ` +
let cmdInt = cmdToInt(cmd)
if (oldDiv != cmdInt) {
println(`${String(globalTick).padStart(6, '0')} ` +
`c${String(o).padStart(2)} r${String(row).padStart(2)} t${String(t).padStart(2)} ` +
describeCommand(cmd, swInfo))
}
globalTick++
nextTick += TICK_NANO
oldDiv = cmdInt
sleepUntil(nextTick)
}

View File

@@ -158,8 +158,9 @@ function parseTaud(path, songIndex) {
const numVoices = sys.peek(ptr + entryOff + 4) & 0xFF
const numPats = (sys.peek(ptr + entryOff + 5) & 0xFF) |
((sys.peek(ptr + entryOff + 6) & 0xFF) << 8)
const bpm = (sys.peek(ptr + entryOff + 7) & 0xFF) + 25
const tickRate = sys.peek(ptr + entryOff + 8) & 0xFF
const tickPacked = sys.peek(ptr + entryOff + 8) & 0xFF
const bpm = (sys.peek(ptr + entryOff + 7) & 0xFF) + 25 + ((tickPacked & 0x80) << 1) // bit 7 = BPM high bit
const tickRate = tickPacked & 0x7F
const patCompSize = _peekU32LE(ptr, entryOff + 18)
const cueCompSize = _peekU32LE(ptr, entryOff + 22)

View File

@@ -826,8 +826,9 @@ function loadTaud(filePath, songIndex) {
const numVoices = sys.peek(ptr + entryOff + 4) & 0xFF
const numPats = (sys.peek(ptr + entryOff + 5) & 0xFF) |
((sys.peek(ptr + entryOff + 6) & 0xFF) << 8)
const bpmStored = sys.peek(ptr + entryOff + 7) & 0xFF
const tickRate = sys.peek(ptr + entryOff + 8) & 0xFF
const tickPacked = sys.peek(ptr + entryOff + 8) & 0xFF
const bpmStored = (sys.peek(ptr + entryOff + 7) & 0xFF) | ((tickPacked & 0x80) << 1) // bit 7 of byte 8 = BPM high bit
const tickRate = tickPacked & 0x7F
const patBinCompSize = _peekU32LE(ptr, entryOff + 18)
const cueSheetCompSize = _peekU32LE(ptr, entryOff + 22)
@@ -914,8 +915,8 @@ function loadTaudSongList(filePath) {
numVoices: sys.peek(ptr + entryOff + 4) & 0xFF,
numPats: (sys.peek(ptr + entryOff + 5) & 0xFF) |
((sys.peek(ptr + entryOff + 6) & 0xFF) << 8),
bpm: ((sys.peek(ptr + entryOff + 7) & 0xFF) + 25),
tickRate: sys.peek(ptr + entryOff + 8) & 0xFF,
bpm: ((sys.peek(ptr + entryOff + 7) & 0xFF) + 25 + ((sys.peek(ptr + entryOff + 8) & 0x80) << 1)), // bit 7 of byte 8 = BPM high bit
tickRate: sys.peek(ptr + entryOff + 8) & 0x7F,
mixerflags: sys.peek(ptr + entryOff + 15) & 0xFF,
songGlobalVolume: sys.peek(ptr + entryOff + 16) & 0xFF,
songMixingVolume: sys.peek(ptr + entryOff + 17) & 0xFF,
@@ -2726,8 +2727,10 @@ function simulateRowState(ptnDat, uptoRow) {
}
else if (effop === OP_T) {
const hi = (effarg >>> 8) & 0xFF
if (hi !== 0) {
bpm = Math.max(25, Math.min(280, hi + 0x19))
if (hi === 0xFF) {
bpm = Math.max(25, Math.min(535, (effarg & 0xFF) + 0x118)) // T $FFxx — extended tempo
} else if (hi !== 0) {
bpm = Math.max(25, Math.min(535, hi + 0x19))
} else {
const low = effarg & 0xFF
if ((low & 0xF0) === 0x00 || (low & 0xF0) === 0x10) memTSlide = low