mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
adding flipY option on display draw
This commit is contained in:
@@ -29,13 +29,16 @@ class CharacterLCDdisplay(vm: VM) : GraphicsAdapter(vm, AdapterConfig(
|
||||
}
|
||||
}*/
|
||||
|
||||
override fun render(delta: Float, batch: SpriteBatch, xoff: Float, yoff: Float) {
|
||||
override fun render(delta: Float, batch: SpriteBatch, xoff: Float, yoff: Float, flipY: Boolean) {
|
||||
batch.shader = null
|
||||
batch.inUse {
|
||||
batch.color = Color.WHITE
|
||||
batch.draw(machine, xoff, yoff)
|
||||
}
|
||||
super.render(delta, batch, xoff+74, yoff+102)
|
||||
if (!flipY)
|
||||
super.render(delta, batch, xoff+74, yoff+102, flipY)
|
||||
else
|
||||
super.render(delta, batch, xoff+74, yoff+72, flipY)
|
||||
|
||||
// draw BMS and RTC
|
||||
val batPerc = "89"
|
||||
@@ -51,21 +54,23 @@ class CharacterLCDdisplay(vm: VM) : GraphicsAdapter(vm, AdapterConfig(
|
||||
batch.shader = null
|
||||
batch.inUse {
|
||||
batch.color = Color.WHITE
|
||||
val y = yoff + 102 + config.height * config.drawScale
|
||||
val y = if (!flipY) yoff + 102 + config.height * config.drawScale else yoff + 56
|
||||
val sx = lcdFont.tileW.toFloat()
|
||||
val sy = lcdFont.tileH * (if (flipY) -1f else 1f)
|
||||
for (x in 0 until config.textCols) {
|
||||
batch.draw(lcdFont.get(0,0), xoff+74 + x * lcdFont.tileW, y)
|
||||
batch.draw(lcdFont.get(0,0), xoff+74 + x * lcdFont.tileW, y, sx, sy)
|
||||
}
|
||||
for (x in clock.indices) {
|
||||
val ccode = clock[x].toInt()
|
||||
batch.draw(lcdFont.get(ccode % 16, ccode / 16), xoff+74 + x * lcdFont.tileW, y)
|
||||
batch.draw(lcdFont.get(ccode % 16, ccode / 16), xoff+74 + x * lcdFont.tileW, y, sx, sy)
|
||||
}
|
||||
for (x in msg.indices) {
|
||||
val ccode = msg[x]
|
||||
batch.draw(lcdFont.get(ccode % 16, ccode / 16), xoff+74 + (x + 6) * lcdFont.tileW, y)
|
||||
batch.draw(lcdFont.get(ccode % 16, ccode / 16), xoff+74 + (x + 6) * lcdFont.tileW, y, sx, sy)
|
||||
}
|
||||
for (x in batText.indices) {
|
||||
val ccode = batText[x].toInt()
|
||||
batch.draw(lcdFont.get(ccode % 16, ccode / 16), xoff+74 + (config.textCols - batText.length + x) * lcdFont.tileW, y)
|
||||
batch.draw(lcdFont.get(ccode % 16, ccode / 16), xoff+74 + (config.textCols - batText.length + x) * lcdFont.tileW, y, sx, sy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class ExtDisp(val vm: VM, val width: Int, val height: Int) : PeriBase {
|
||||
|
||||
private lateinit var tex: Texture
|
||||
|
||||
open fun render(uiBatch: SpriteBatch, xoff: Float, yoff: Float) {
|
||||
open fun render(uiBatch: SpriteBatch, xoff: Float, yoff: Float, flipY: Boolean = false) {
|
||||
framebuffer.pixels.position(0)
|
||||
|
||||
tex = Texture(framebuffer)
|
||||
@@ -51,7 +51,10 @@ class ExtDisp(val vm: VM, val width: Int, val height: Int) : PeriBase {
|
||||
uiBatch.inUse {
|
||||
uiBatch.color = Color.WHITE
|
||||
uiBatch.shader = drawShader
|
||||
uiBatch.draw(tex, xoff, yoff)
|
||||
if (!flipY)
|
||||
uiBatch.draw(tex, xoff, yoff)
|
||||
else
|
||||
uiBatch.draw(tex, xoff, yoff + tex.height, tex.width.toFloat(), -tex.height.toFloat())
|
||||
}
|
||||
|
||||
tex.dispose()
|
||||
|
||||
@@ -710,7 +710,7 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig, val sgr: Super
|
||||
unusedArea[1].toInt().and(15).toFloat() / 15f,
|
||||
unusedArea[2].toInt().and(15).toFloat() / 15f, 1f)
|
||||
|
||||
open fun render(delta: Float, uiBatch: SpriteBatch, xoff: Float, yoff: Float) {
|
||||
open fun render(delta: Float, uiBatch: SpriteBatch, xoff: Float, yoff: Float, flipY: Boolean = false) {
|
||||
// must reset positions as pixmaps expect them to be zero
|
||||
framebuffer.pixels.position(0)
|
||||
chrrom.pixels.position(0)
|
||||
@@ -892,7 +892,12 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig, val sgr: Super
|
||||
if (config.scaleFiltered) Texture.TextureFilter.Linear else Texture.TextureFilter.Nearest,
|
||||
if (config.scaleFiltered) Texture.TextureFilter.Linear else Texture.TextureFilter.Nearest
|
||||
)
|
||||
uiBatch.draw(outFBOregion[1], xoff, HEIGHT * config.drawScale + yoff, WIDTH * config.drawScale, -HEIGHT * config.drawScale)
|
||||
|
||||
if (!flipY)
|
||||
uiBatch.draw(outFBOregion[1], xoff, HEIGHT * config.drawScale + yoff, WIDTH * config.drawScale, -HEIGHT * config.drawScale)
|
||||
else
|
||||
uiBatch.draw(outFBOregion[1], xoff, yoff, WIDTH * config.drawScale, HEIGHT * config.drawScale)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,9 +38,9 @@ open class TexticsAdapterBase(vm: VM, config: AdapterConfig) : GraphicsAdapter(v
|
||||
private val ALIGN = (HEIGHT - TEX_HEIGHT).absoluteValue / 2f
|
||||
private val phosphorCol = crtColor[theme.substring(4)] ?: crtColor["white"]
|
||||
|
||||
override fun render(delta: Float, batch: SpriteBatch, xoff: Float, yoff: Float) {
|
||||
override fun render(delta: Float, batch: SpriteBatch, xoff: Float, yoff: Float, flipY: Boolean) {
|
||||
|
||||
super.render(delta, batch, xoff, yoff)
|
||||
super.render(delta, batch, xoff, yoff, flipY)
|
||||
|
||||
batch.inUse {
|
||||
batch.enableBlending()
|
||||
|
||||
Reference in New Issue
Block a user