mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-10 21:21:51 +09:00
fix: mp2 384k would cause stack overflow error
This commit is contained in:
@@ -9,7 +9,7 @@ let PATHFUN = (i) => `/ddol2/${(''+i).padStart(5,'0')}.bmp` // how can be the im
|
||||
let AUDIOTRACK = 'ddol.mp2'
|
||||
let AUDIOFORMAT = 'MP2fr' // PCMu8 or MP2fr
|
||||
// to export video to its frames:
|
||||
// ffmpeg -i file.mp4 file/%05d.bmp
|
||||
// ffmpeg -i file.mp4 file/%05d.png
|
||||
// the input frames must be resized (and cropped) beforehand, using ImageMagick is recommended, like so:
|
||||
// mogrify -path ./path/to/write/results/ -resize 560x448^ -gravity Center -extent 560x448 ./path/to/source/files/*
|
||||
//
|
||||
|
||||
@@ -621,6 +621,7 @@ Sound Adapter MMIO
|
||||
|
||||
64..2367 RW: MP2 Decoded Samples (unsigned 8-bit stereo)
|
||||
2368..4095 RW: MP2 Frame to be decoded
|
||||
4096..4097 RO: MP2 Frame guard bytes; always return 0 on read
|
||||
|
||||
Sound Hardware Info
|
||||
- Sampling rate: 32000 Hz
|
||||
|
||||
@@ -233,11 +233,15 @@ class AudioAdapter(val vm: VM) : PeriBase(VM.PERITYPE_SOUND) {
|
||||
41 -> mp2Busy.toInt().toByte()
|
||||
in 64..2367 -> mediaDecodedBin[addr - 64]
|
||||
in 2368..4095 -> mediaFrameBin[addr - 2368]
|
||||
in 4096..4097 -> 0
|
||||
in 32768..65535 -> (adi - 32768).let {
|
||||
cueSheet[it / 16].read(it % 15)
|
||||
}
|
||||
in 65536..131071 -> pcmBin[addr - 65536]
|
||||
else -> mmio_read(addr % 131072)
|
||||
else -> {
|
||||
println("[AudioAdapter] Bus mirroring on mmio_reading while trying to read address $addr")
|
||||
mmio_read(addr % 131072)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +338,13 @@ class MP2Env(val vm: VM) {
|
||||
samplesR[pushSizeR++] = sampleR
|
||||
}
|
||||
|
||||
val ret = _decodeFrame(mp2, framePtr, pcm, pushL, pushR)
|
||||
val ret = try {
|
||||
_decodeFrame(mp2, framePtr, pcm, pushL, pushR)
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
intArrayOf(0, 0)
|
||||
}
|
||||
|
||||
// dither samples and store them to the given "out" pointer
|
||||
var outPos = out
|
||||
|
||||
@@ -39,18 +39,26 @@ class AudioMenu(parent: VMEmuExecutable, x: Int, y: Int, w: Int, h: Int) : EmuMe
|
||||
val adev = parent.currentlyPersistentVM?.vm?.peripheralTable?.getOrNull(cardIndex ?: -1)?.peripheral as? AudioAdapter
|
||||
|
||||
if (adev != null) {
|
||||
|
||||
// draw status LCD
|
||||
batch.inUse {
|
||||
// draw backgrounds
|
||||
batch.color = COL_WELL
|
||||
for (i in 0..3) { batch.fillRect(7, 5 + 115*i, 102, 8*FONT.H + 4) }
|
||||
batch.color = COL_SOUNDSCOPE_BACK
|
||||
for (i in 0..3) { batch.fillRect(117, 5 + 115*i, 512, 8*FONT.H + 4) }
|
||||
}
|
||||
|
||||
|
||||
for (i in 0..3) {
|
||||
val ahead = (adev.extortField("playheads") as Array<AudioAdapter.Playhead>)[i]
|
||||
drawStatusLCD(adev, ahead, batch, i, 9f + 7, 7f + 7 + 115 * i)
|
||||
}
|
||||
|
||||
// draw Soundscope like this so that the overflown queue sparkline would not be overlaid on top of the envelopes
|
||||
batch.inUse {
|
||||
// draw backgrounds
|
||||
batch.color = COL_SOUNDSCOPE_BACK
|
||||
for (i in 0..3) { batch.fillRect(117, 5 + 115*i, 512, 8*FONT.H + 4) }
|
||||
}
|
||||
for (i in 0..3) {
|
||||
val ahead = (adev.extortField("playheads") as Array<AudioAdapter.Playhead>)[i]
|
||||
drawSoundscope(adev, ahead, batch, i, 117f, 5f + 115 * i)
|
||||
}
|
||||
}
|
||||
@@ -64,6 +72,8 @@ class AudioMenu(parent: VMEmuExecutable, x: Int, y: Int, w: Int, h: Int) : EmuMe
|
||||
}
|
||||
|
||||
private fun drawStatusLCD(audio: AudioAdapter, ahead: AudioAdapter.Playhead, batch: SpriteBatch, index: Int, x: Float, y: Float) {
|
||||
// NOTE: Samples count for PCM mode is drawn by drawSoundscope() function, not this one!
|
||||
|
||||
batch.inUse {
|
||||
batch.color = Color.WHITE
|
||||
// PLAY icon
|
||||
@@ -156,6 +166,12 @@ class AudioMenu(parent: VMEmuExecutable, x: Int, y: Int, w: Int, h: Int) : EmuMe
|
||||
batch.fillRect(x + s, y + 27, 1, smpLHi)
|
||||
batch.fillRect(x + s, y + 81, 1, smpRHi)
|
||||
}
|
||||
|
||||
batch.color = Color.WHITE
|
||||
FONT.draw(batch, "Samples", x - 101, y + 5*FONT.H + 9)
|
||||
batch.color = COL_ACTIVE3
|
||||
FONT.drawRalign(batch, "${smpCnt+1}", x - 17, y + 5*FONT.H + 9)
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user