mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
better crt shader
This commit is contained in:
@@ -267,6 +267,7 @@ class AudioAdapter(val vm: VM) : PeriBase(VM.PERITYPE_SOUND) {
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
System.err.println("Dispose AudioAdapter")
|
||||
renderRunnables.forEach { it.stop() }
|
||||
writeQueueingRunnables.forEach { it.stop() }
|
||||
playheads.forEach { it.dispose() }
|
||||
@@ -430,8 +431,9 @@ class AudioAdapter(val vm: VM) : PeriBase(VM.PERITYPE_SOUND) {
|
||||
fun getPcmQueueCapacity() = QUEUE_SIZE[pcmQueueSizeIndex]
|
||||
|
||||
fun dispose() {
|
||||
println("AudioDevice dispose ${parent.renderThreads[index]}")
|
||||
try { audioDevice.dispose() } catch (e: GdxRuntimeException) { println(" "+ e.message) }
|
||||
// audioDevice.dispose() is called by RenderRunnable.stop()
|
||||
// System.err.println("AudioDevice dispose ${parent.renderThreads[index]}")
|
||||
// try { audioDevice.dispose() } catch (e: GdxRuntimeException) { println(" "+ e.message) }
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.toUint
|
||||
import org.lwjgl.BufferUtils
|
||||
import org.lwjgl.openal.AL10
|
||||
import org.lwjgl.openal.AL11
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import java.nio.Buffer
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.IntBuffer
|
||||
@@ -118,9 +119,12 @@ class OpenALBufferedAudioDevice(
|
||||
return obtainSourceMethod.invoke(audio, isMusic) as Int
|
||||
}
|
||||
private fun audioFreeSource(sourceID: Int) {
|
||||
val freeSourceMethod = OpenALLwjgl3Audio::class.java.getDeclaredMethod("freeSource", java.lang.Integer.TYPE)
|
||||
freeSourceMethod.isAccessible = true
|
||||
freeSourceMethod.invoke(audio, sourceID)
|
||||
try {
|
||||
val freeSourceMethod = OpenALLwjgl3Audio::class.java.getDeclaredMethod("freeSource", java.lang.Integer.TYPE)
|
||||
freeSourceMethod.isAccessible = true
|
||||
freeSourceMethod.invoke(audio, sourceID)
|
||||
}
|
||||
catch (_: InvocationTargetException) {}
|
||||
}
|
||||
|
||||
private val alErrors = hashMapOf(
|
||||
|
||||
@@ -42,8 +42,8 @@ public class AppLoader {
|
||||
// VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{OEMBios.INSTANCE, BasicRom.INSTANCE});
|
||||
// VM vm = new VM("./assets", 64 << 10, new TheRealWorld(), new VMProgramRom[]{TandemBios.INSTANCE, BasicRom.INSTANCE}, 2, watchdogs);
|
||||
// VM vm = new VM("./assets", 128 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, WPBios.INSTANCE}, 2, watchdogs);
|
||||
// VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{TsvmBios.INSTANCE}, 8, watchdogs);
|
||||
VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{OpenBios.INSTANCE}, 8, watchdogs);
|
||||
VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{TsvmBios.INSTANCE}, 8, watchdogs);
|
||||
// VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{OpenBios.INSTANCE}, 8, watchdogs);
|
||||
// VM pipvm = new VM("./assets", 4096, new TheRealWorld(), new VMProgramRom[]{PipBios.INSTANCE, PipROM.INSTANCE}, 8, watchdogs);
|
||||
|
||||
vm.getIO().getBlockTransferPorts()[0].attachDevice(new TestDiskDrive(vm, 0, diskPath));
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.torvald.tsvm.peripheral.*
|
||||
import net.torvald.tsvm.peripheral.GraphicsAdapter.Companion.DRAW_SHADER_VERT
|
||||
import java.util.*
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
import kotlin.coroutines.*
|
||||
|
||||
|
||||
@@ -162,13 +163,13 @@ class VMGUI(val loaderInfo: EmulInstance, val viewportWidth: Int, val viewportHe
|
||||
}, "VmRunner:${vm.id}")
|
||||
coroutineJob.start()
|
||||
|
||||
vmKilled.set(false)
|
||||
vmKilled.set(0)
|
||||
}
|
||||
|
||||
private val vmKilled = AtomicBoolean(false)
|
||||
private val vmKilled = AtomicLong(0)
|
||||
|
||||
private fun killVMenv() {
|
||||
if (vmKilled.compareAndSet(false, true)) {
|
||||
if (vmKilled.compareAndSet(0, System.currentTimeMillis())) {
|
||||
System.err.println("VMGUI is killing VM environment...")
|
||||
vm.park()
|
||||
vm.poke(-90L, -128)
|
||||
@@ -403,7 +404,10 @@ const mat4 yuv_to_rgb = mat4(
|
||||
);
|
||||
|
||||
const float gamma = 2.4;
|
||||
const float blur = 0.8;
|
||||
const float blurH = 0.8;
|
||||
const float blurV = 0.4;
|
||||
|
||||
const vec4 gradingarg = vec4(1.4, 1.1, 1.1, 1.0);
|
||||
|
||||
vec4 toYUV(vec4 rgb) { return rgb_to_yuv * rgb; }
|
||||
vec4 toRGB(vec4 ycc) { return yuv_to_rgb * ycc; }
|
||||
@@ -417,11 +421,30 @@ vec4 avr(vec4 a, vec4 b, float gam) {
|
||||
);
|
||||
}
|
||||
|
||||
vec4 grading(vec4 col, vec4 args) {
|
||||
vec4 vel = vec4(1.0, 1.0 / args.y, 1.0 / args.z, 1.0);
|
||||
vec4 power = vec4(args.x, args.x, args.x, 1.0);
|
||||
|
||||
vec4 sgn = sign(col);
|
||||
vec4 absval = abs(col);
|
||||
vec4 raised = pow(absval, vel);
|
||||
|
||||
vec4 rgb = toRGB(sgn * raised);
|
||||
|
||||
return pow(rgb, power);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 rgbColourIn = v_color * texture(u_texture, v_texCoords);
|
||||
vec4 rgbColourL = v_color * texture(u_texture, v_texCoords + (vec2(-blur, 0.0) / resolution));
|
||||
vec4 rgbColourR = v_color * texture(u_texture, v_texCoords + (vec2(+blur, 0.0) / resolution));
|
||||
|
||||
vec4 rgbColourL = v_color * mix(
|
||||
texture(u_texture, v_texCoords + (vec2(-blurH, -blurV) / resolution)),
|
||||
texture(u_texture, v_texCoords + (vec2(-blurH, +blurV) / resolution)),
|
||||
0.5);
|
||||
vec4 rgbColourR = v_color * mix(
|
||||
texture(u_texture, v_texCoords + (vec2(+blurH, -blurV) / resolution)),
|
||||
texture(u_texture, v_texCoords + (vec2(+blurH, +blurV) / resolution)),
|
||||
0.5);
|
||||
|
||||
vec4 colourIn = toYUV(rgbColourIn);
|
||||
vec4 colourL = toYUV(rgbColourL);
|
||||
vec4 colourR = toYUV(rgbColourR);
|
||||
@@ -431,7 +454,7 @@ void main() {
|
||||
|
||||
vec4 outCol = wgtavr * ((mod(gl_FragCoord.y, 2.0) >= 1.0) ? scanline : one);
|
||||
|
||||
fragColor = toRGB(outCol);
|
||||
fragColor = grading(outCol, gradingarg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user