mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-10 23:04:04 +09:00
fix for the sigmoid functions
This commit is contained in:
@@ -37,7 +37,7 @@ public class AppLoader {
|
|||||||
|
|
||||||
EmulInstance reference = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.ReferenceGraphicsAdapter", "assets/disk0");
|
EmulInstance reference = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.ReferenceGraphicsAdapter", "assets/disk0");
|
||||||
EmulInstance reference2 = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.ReferenceLikeLCD", "assets/disk0");
|
EmulInstance reference2 = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.ReferenceLikeLCD", "assets/disk0");
|
||||||
EmulInstance term = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.TexticsAdapter", "assets/disk0");
|
EmulInstance term = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.Term", "assets/disk0");
|
||||||
EmulInstance portable = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.CharacterLCDdisplay", "assets/disk0");
|
EmulInstance portable = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.CharacterLCDdisplay", "assets/disk0");
|
||||||
|
|
||||||
EmulInstance wp = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.WpTerm", "assets/wpdisk");
|
EmulInstance wp = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.WpTerm", "assets/wpdisk");
|
||||||
|
|||||||
@@ -916,20 +916,23 @@ int getTileFromColor(vec4 color) {
|
|||||||
return _colToInt(color) & 0xFFFFF;
|
return _colToInt(color) & 0xFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uniform float sgmp = 4.3;
|
||||||
|
float sgmcomp = 2.0 / (1.0 + exp(-sgmp)) - 1.001; // making sure everything sits within [0..1)
|
||||||
|
|
||||||
float sigmoid(float x) {
|
float sigmoid(float x) {
|
||||||
return 2.0 / (1.0 + exp(-6.333 * x)) - 1.0;
|
return (2.0 / (1.0 + exp(-sgmp * x)) - 1.0) / sgmcomp;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 sigmoid(vec4 x) {
|
vec4 sigmoid(vec4 x) {
|
||||||
return 2.0 / (1.0 + exp(-6.333 * x)) - 1.0;
|
return (2.0 / (1.0 + exp(-sgmp * x)) - 1.0) / sgmcomp;
|
||||||
}
|
}
|
||||||
|
|
||||||
float invsigmoid(float x) {
|
float invsigmoid(float x) {
|
||||||
return (1.0 / 6.333) * log((1.0 + x) / (1.0 - x));
|
return (1.0 / sgmp) * log((1.0 + sgmcomp * x) / (1.0 - sgmcomp * x));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 invsigmoid(vec4 x) {
|
vec4 invsigmoid(vec4 x) {
|
||||||
return (1.0 / 6.333) * log((1.0 + x) / (1.0 - x));
|
return (1.0 / sgmp) * log((1.0 + sgmcomp * x) / (1.0 - sgmcomp * x));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 sigmoidmix(vec4 a, vec4 b, float x) {
|
vec4 sigmoidmix(vec4 a, vec4 b, float x) {
|
||||||
@@ -1023,20 +1026,23 @@ vec4 grey(vec4 color) {
|
|||||||
return vec4(lum, lum, lum, color.a);
|
return vec4(lum, lum, lum, color.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uniform float sgmp = 4.3;
|
||||||
|
float sgmcomp = 2.0 / (1.0 + exp(-sgmp)) - 1.001; // making sure everything sits within [0..1)
|
||||||
|
|
||||||
float sigmoid(float x) {
|
float sigmoid(float x) {
|
||||||
return 2.0 / (1.0 + exp(-6.333 * x)) - 1.0;
|
return (2.0 / (1.0 + exp(-sgmp * x)) - 1.0) / sgmcomp;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 sigmoid(vec4 x) {
|
vec4 sigmoid(vec4 x) {
|
||||||
return 2.0 / (1.0 + exp(-6.333 * x)) - 1.0;
|
return (2.0 / (1.0 + exp(-sgmp * x)) - 1.0) / sgmcomp;
|
||||||
}
|
}
|
||||||
|
|
||||||
float invsigmoid(float x) {
|
float invsigmoid(float x) {
|
||||||
return (1.0 / 6.333) * log((1.0 + x) / (1.0 - x));
|
return (1.0 / sgmp) * log((1.0 + sgmcomp * x) / (1.0 - sgmcomp * x));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 invsigmoid(vec4 x) {
|
vec4 invsigmoid(vec4 x) {
|
||||||
return (1.0 / 6.333) * log((1.0 + x) / (1.0 - x));
|
return (1.0 / sgmp) * log((1.0 + sgmcomp * x) / (1.0 - sgmcomp * x));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 sigmoidmix(vec4 a, vec4 b, float x) {
|
vec4 sigmoidmix(vec4 a, vec4 b, float x) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.torvald.tsvm.peripheral
|
package net.torvald.tsvm.peripheral
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Camera
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.GL20
|
import com.badlogic.gdx.graphics.GL20
|
||||||
import com.badlogic.gdx.graphics.Texture
|
import com.badlogic.gdx.graphics.Texture
|
||||||
@@ -9,19 +8,7 @@ import net.torvald.tsvm.VM
|
|||||||
import net.torvald.tsvm.kB
|
import net.torvald.tsvm.kB
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
|
|
||||||
open class TexticsAdapter(vm: VM, config: AdapterConfig = AdapterConfig(
|
open class TexticsAdapterBase(vm: VM, config: AdapterConfig) : GraphicsAdapter(vm, config) {
|
||||||
"crt_white",
|
|
||||||
720,
|
|
||||||
480,
|
|
||||||
80,
|
|
||||||
32,
|
|
||||||
254,
|
|
||||||
0,
|
|
||||||
256.kB(),
|
|
||||||
"./hp2640.png",
|
|
||||||
0.32f,
|
|
||||||
GraphicsAdapter.TEXT_TILING_SHADER_MONOCHROME
|
|
||||||
)) : GraphicsAdapter(vm, config) {
|
|
||||||
|
|
||||||
private val crtGradTex = Texture("./assets/crt_grad.png")
|
private val crtGradTex = Texture("./assets/crt_grad.png")
|
||||||
|
|
||||||
@@ -77,7 +64,21 @@ open class TexticsAdapter(vm: VM, config: AdapterConfig = AdapterConfig(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WpTerm(vm: VM) : TexticsAdapter(vm = vm, AdapterConfig(
|
class Term(vm: VM) : TexticsAdapterBase(vm, AdapterConfig(
|
||||||
|
"crt_white",
|
||||||
|
720,
|
||||||
|
480,
|
||||||
|
80,
|
||||||
|
32,
|
||||||
|
254,
|
||||||
|
0,
|
||||||
|
256.kB(),
|
||||||
|
"./hp2640.png",
|
||||||
|
0.32f,
|
||||||
|
GraphicsAdapter.TEXT_TILING_SHADER_MONOCHROME
|
||||||
|
))
|
||||||
|
|
||||||
|
class WpTerm(vm: VM) : TexticsAdapterBase(vm, AdapterConfig(
|
||||||
"crt_amber",
|
"crt_amber",
|
||||||
810,
|
810,
|
||||||
300,
|
300,
|
||||||
|
|||||||
Reference in New Issue
Block a user