mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +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.title = appTitle;
|
||||
appConfig.forceExit = true;
|
||||
appConfig.width = 560;
|
||||
appConfig.height = 448;
|
||||
appConfig.width = 960;//560;
|
||||
appConfig.height = 400;//448;
|
||||
|
||||
|
||||
// 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 kotlinx.coroutines.*
|
||||
import net.torvald.tsvm.CompressorDelegate.GZIP_HEADER
|
||||
import net.torvald.tsvm.peripheral.CharacterLCDdisplay
|
||||
import net.torvald.tsvm.peripheral.GenericBios
|
||||
import net.torvald.tsvm.peripheral.GraphicsAdapter
|
||||
import net.torvald.tsvm.peripheral.TexticsAdapter
|
||||
@@ -33,7 +34,8 @@ class VMGUI(val vm: VM, val appConfig: LwjglApplicationConfiguration) : Applicat
|
||||
super.create()
|
||||
|
||||
//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.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 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 = 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)
|
||||
|
||||
// draw framebuffer
|
||||
batch.draw(rendertex, x, y)
|
||||
batch.draw(rendertex, 0f, 0f)
|
||||
|
||||
// draw texts or sprites
|
||||
|
||||
@@ -712,7 +712,7 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig) :
|
||||
batch.shader = null
|
||||
batch.inUse {
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun FrameBuffer.inUse(action: () -> Unit) {
|
||||
this.begin()
|
||||
action()
|
||||
this.end()
|
||||
}
|
||||
fun FrameBuffer.inUse(action: () -> Unit) {
|
||||
this.begin()
|
||||
action()
|
||||
this.end()
|
||||
}
|
||||
|
||||
private fun SpriteBatch.inUse(action: () -> Unit) {
|
||||
this.begin()
|
||||
action()
|
||||
this.end()
|
||||
}
|
||||
fun SpriteBatch.inUse(action: () -> Unit) {
|
||||
this.begin()
|
||||
action()
|
||||
this.end()
|
||||
}
|
||||
Reference in New Issue
Block a user