mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-12 22:16:05 +09:00
graphics: fixed pixels not plotting on non crt_color
This commit is contained in:
@@ -38,7 +38,7 @@ public class AppLoader {
|
||||
EmulInstance term = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.TexticsAdapter", "assets/disk0");
|
||||
EmulInstance portable = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.CharacterLCDdisplay", "assets/disk0");
|
||||
|
||||
new LwjglApplication(new VMGUI(reference), appConfig);
|
||||
new LwjglApplication(new VMGUI(portable), appConfig);
|
||||
}
|
||||
|
||||
public static ShaderProgram loadShaderFromFile(String vert, String frag) {
|
||||
|
||||
@@ -28,15 +28,11 @@ class GraphicsJSR223Delegate(val vm: VM) {
|
||||
}
|
||||
|
||||
fun loadBulk(fromAddr: Int, toAddr: Int, length: Int) {
|
||||
getFirstGPU()?.let {
|
||||
it._loadbulk(fromAddr, toAddr, length)
|
||||
}
|
||||
getFirstGPU()?._loadbulk(fromAddr, toAddr, length)
|
||||
}
|
||||
|
||||
fun storeBulk(fromAddr: Int, toAddr: Int, length: Int) {
|
||||
getFirstGPU()?.let {
|
||||
it._storebulk(fromAddr, toAddr, length)
|
||||
}
|
||||
getFirstGPU()?._storebulk(fromAddr, toAddr, length)
|
||||
}
|
||||
|
||||
fun plotPixel(x: Int, y: Int, color: Int) {
|
||||
@@ -74,9 +70,7 @@ class GraphicsJSR223Delegate(val vm: VM) {
|
||||
}
|
||||
|
||||
fun clearText() {
|
||||
getFirstGPU()?.let {
|
||||
it.eraseInDisp(2)
|
||||
}
|
||||
getFirstGPU()?.eraseInDisp(2)
|
||||
}
|
||||
|
||||
fun clearPixels(col: Int) {
|
||||
|
||||
@@ -620,8 +620,8 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig, val sgr: Super
|
||||
// feed palette data
|
||||
// must be done every time the shader is "actually loaded"
|
||||
// try this: if above line precedes 'batch.shader = paletteShader', it won't work
|
||||
outFBObatch.shader.setUniform4fv("pal", paletteOfFloats, 0, paletteOfFloats.size)
|
||||
if (theme.startsWith("pmlcd")) outFBObatch.shader.setUniformf("lcdBaseCol", LCD_BASE_COL)
|
||||
paletteShader.setUniform4fv("pal", paletteOfFloats, 0, paletteOfFloats.size)
|
||||
paletteShader.setUniformf("lcdBaseCol", LCD_BASE_COL)
|
||||
|
||||
// draw framebuffer
|
||||
outFBObatch.draw(rendertex, 0f, 0f)
|
||||
@@ -648,11 +648,6 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig, val sgr: Super
|
||||
if (drawCursor) ttyFore else spriteAndTextArea[memTextForeOffset + addr].toInt()
|
||||
.and(255)
|
||||
|
||||
if (!theme.contains("color")) {
|
||||
if (back == 255) back = 0
|
||||
if (fore == 255) fore = 0
|
||||
}
|
||||
|
||||
textPixmap.setColor(Color(0f, 0f, char / 255f, 1f))
|
||||
textPixmap.drawPixel(x, y)
|
||||
textBackPixmap.setColor(
|
||||
@@ -700,7 +695,7 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig, val sgr: Super
|
||||
textShader.setUniformf("screenDimension", WIDTH.toFloat(), HEIGHT.toFloat())
|
||||
textShader.setUniformf("tilesInAtlas", 16f, 16f)
|
||||
textShader.setUniformf("atlasTexSize", chrrom0.width.toFloat(), chrrom0.height.toFloat())
|
||||
if (theme.startsWith("pmlcd")) outFBObatch.shader.setUniformf("lcdBaseCol", LCD_BASE_COL)
|
||||
textShader.setUniformf("lcdBaseCol", LCD_BASE_COL)
|
||||
|
||||
outFBObatch.draw(faketex, 0f, 0f, WIDTH.toFloat(), HEIGHT.toFloat())
|
||||
|
||||
@@ -830,7 +825,7 @@ uniform vec4 lcdBaseCol;
|
||||
|
||||
void main(void) {
|
||||
vec4 palCol = pal[int(texture2D(u_texture, v_texCoords).a * 255.0)];
|
||||
float lum = floor((3.0 * palCol.r + 4.0 * palCol.g + palCol.b) / 8.0 * intensitySteps) / intensitySteps;
|
||||
float lum = ceil((3.0 * palCol.r + 4.0 * palCol.g + palCol.b) / 8.0 * intensitySteps) / intensitySteps;
|
||||
vec4 outIntensity = vec4(vec3(1.0 - lum), palCol.a);
|
||||
|
||||
// LCD output will invert the luminosity. That is, normally white colour will be black on PM-LCD.
|
||||
|
||||
@@ -47,14 +47,14 @@ class TexticsAdapter(vm: VM) : GraphicsAdapter(vm, AdapterConfig(
|
||||
|
||||
override fun peek(addr: Long): Byte? {
|
||||
return when (addr) {
|
||||
in 0 until 250880 -> (-1).toByte()
|
||||
in 0 until 250972 -> (-1).toByte()
|
||||
else -> super.peek(addr)
|
||||
}
|
||||
}
|
||||
|
||||
override fun poke(addr: Long, byte: Byte) {
|
||||
when (addr) {
|
||||
in 0 until 250880 -> { /*do nothing*/ }
|
||||
in 0 until 250972 -> { /*do nothing*/ }
|
||||
else -> super.poke(addr, byte)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user