mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-09 14:44:05 +09:00
half-working text-only lcd
This commit is contained in:
BIN
8025_textonly.png
Normal file
BIN
8025_textonly.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
@@ -22,8 +22,8 @@ public class AppLoader {
|
|||||||
appConfig.resizable = false;
|
appConfig.resizable = false;
|
||||||
appConfig.title = appTitle;
|
appConfig.title = appTitle;
|
||||||
appConfig.forceExit = true;
|
appConfig.forceExit = true;
|
||||||
appConfig.width = 560;
|
appConfig.width = 960;//560;
|
||||||
appConfig.height = 448;
|
appConfig.height = 400;//448;
|
||||||
|
|
||||||
|
|
||||||
// val vm = VM(64.kB(), TheRealWorld(), arrayOf(GenericBios))
|
// val vm = VM(64.kB(), TheRealWorld(), arrayOf(GenericBios))
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.OrthographicCamera
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import net.torvald.tsvm.CompressorDelegate.GZIP_HEADER
|
import net.torvald.tsvm.CompressorDelegate.GZIP_HEADER
|
||||||
|
import net.torvald.tsvm.peripheral.CharacterLCDdisplay
|
||||||
import net.torvald.tsvm.peripheral.GenericBios
|
import net.torvald.tsvm.peripheral.GenericBios
|
||||||
import net.torvald.tsvm.peripheral.GraphicsAdapter
|
import net.torvald.tsvm.peripheral.GraphicsAdapter
|
||||||
import net.torvald.tsvm.peripheral.TexticsAdapter
|
import net.torvald.tsvm.peripheral.TexticsAdapter
|
||||||
@@ -33,7 +34,8 @@ class VMGUI(val vm: VM, val appConfig: LwjglApplicationConfiguration) : Applicat
|
|||||||
super.create()
|
super.create()
|
||||||
|
|
||||||
//gpu = TexticsAdapter(vm, theme = GraphicsAdapter.THEME_COLORCRT)
|
//gpu = TexticsAdapter(vm, theme = GraphicsAdapter.THEME_COLORCRT)
|
||||||
gpu = GraphicsAdapter(vm, GraphicsAdapter.DEFAULT_CONFIG_COLOR_CRT)
|
//gpu = GraphicsAdapter(vm, GraphicsAdapter.DEFAULT_CONFIG_COLOR_CRT)
|
||||||
|
gpu = CharacterLCDdisplay(vm)
|
||||||
|
|
||||||
vm.peripheralTable[1] = PeripheralEntry(
|
vm.peripheralTable[1] = PeripheralEntry(
|
||||||
VM.PERITYPE_GPU_AND_TERM,
|
VM.PERITYPE_GPU_AND_TERM,
|
||||||
|
|||||||
44
src/net/torvald/tsvm/peripheral/CharacterLCDdisplay.kt
Normal file
44
src/net/torvald/tsvm/peripheral/CharacterLCDdisplay.kt
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package net.torvald.tsvm.peripheral
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.graphics.Texture
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import net.torvald.tsvm.VM
|
||||||
|
|
||||||
|
class CharacterLCDdisplay(vm: VM) : GraphicsAdapter(vm, AdapterConfig(
|
||||||
|
"pmlcd_inverted", 960, 400, 80, 25, 249, 255, 262144L, "./lcd.png", 0.7f
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
|
||||||
|
private val machine = Texture("./8025_textonly.png")
|
||||||
|
|
||||||
|
override fun peek(addr: Long): Byte? {
|
||||||
|
return when (addr) {
|
||||||
|
in 0 until 250880 -> (-1).toByte()
|
||||||
|
else -> super.peek(addr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun poke(addr: Long, byte: Byte) {
|
||||||
|
when (addr) {
|
||||||
|
in 0 until 250880 -> { /*do nothing*/ }
|
||||||
|
else -> super.poke(addr, byte)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(delta: Float, batch: SpriteBatch, xoff: Float, yoff: Float) {
|
||||||
|
/*batch.shader = null
|
||||||
|
batch.inUse {
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
batch.draw(machine, xoff, yoff)
|
||||||
|
}
|
||||||
|
super.render(delta, batch, xoff+200, yoff-200)
|
||||||
|
*/
|
||||||
|
super.render(delta, batch, xoff, yoff)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
machine.dispose()
|
||||||
|
super.dispose()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -569,7 +569,7 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig) :
|
|||||||
private var glowDecay = config.decay
|
private var glowDecay = config.decay
|
||||||
private var decayColor = Color(1f, 1f, 1f, 1f - glowDecay)
|
private var decayColor = Color(1f, 1f, 1f, 1f - glowDecay)
|
||||||
|
|
||||||
fun render(delta: Float, batch: SpriteBatch, x: Float, y: Float) {
|
open fun render(delta: Float, batch: SpriteBatch, xoff: Float, yoff: Float) {
|
||||||
rendertex.dispose()
|
rendertex.dispose()
|
||||||
rendertex = Texture(framebuffer, Pixmap.Format.RGBA8888, false)
|
rendertex = Texture(framebuffer, Pixmap.Format.RGBA8888, false)
|
||||||
|
|
||||||
@@ -608,7 +608,7 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig) :
|
|||||||
if (theme.startsWith("pmlcd")) batch.shader.setUniformf("lcdBaseCol", LCD_BASE_COL)
|
if (theme.startsWith("pmlcd")) batch.shader.setUniformf("lcdBaseCol", LCD_BASE_COL)
|
||||||
|
|
||||||
// draw framebuffer
|
// draw framebuffer
|
||||||
batch.draw(rendertex, x, y)
|
batch.draw(rendertex, 0f, 0f)
|
||||||
|
|
||||||
// draw texts or sprites
|
// draw texts or sprites
|
||||||
|
|
||||||
@@ -712,7 +712,7 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig) :
|
|||||||
batch.shader = null
|
batch.shader = null
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
batch.draw(outFBOs[1].colorBufferTexture, 0f, HEIGHT.toFloat(), WIDTH.toFloat(), -HEIGHT.toFloat())
|
batch.draw(outFBOs[1].colorBufferTexture, xoff, HEIGHT.toFloat() - yoff, WIDTH.toFloat(), -HEIGHT.toFloat())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1483,16 +1483,16 @@ void main() {
|
|||||||
0
|
0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun FrameBuffer.inUse(action: () -> Unit) {
|
fun FrameBuffer.inUse(action: () -> Unit) {
|
||||||
this.begin()
|
this.begin()
|
||||||
action()
|
action()
|
||||||
this.end()
|
this.end()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SpriteBatch.inUse(action: () -> Unit) {
|
fun SpriteBatch.inUse(action: () -> Unit) {
|
||||||
this.begin()
|
this.begin()
|
||||||
action()
|
action()
|
||||||
this.end()
|
this.end()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user