This commit is contained in:
minjaesong
2021-04-05 16:40:08 +09:00
parent 5a81655dfa
commit 3b11cf60c1
4 changed files with 19 additions and 27 deletions

View File

@@ -45,6 +45,7 @@ class VMGUI(val vm: VM, val appConfig: LwjglApplicationConfiguration) : Applicat
//gpu = GraphicsAdapter(vm, GraphicsAdapter.DEFAULT_CONFIG_COLOR_CRT)
//gpu = GraphicsAdapter(vm, GraphicsAdapter.DEFAULT_CONFIG_PMLCD)
//gpu = TexticsAdapter(vm)
gpu = CharacterLCDdisplay(vm)

View File

@@ -8,14 +8,14 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import net.torvald.tsvm.VM
class CharacterLCDdisplay(vm: VM) : GraphicsAdapter(vm, AdapterConfig(
"pmlcd_inverted", 240, 64, 40, 8, 249, 255, 262144L, "lcd2.png", 0.7f, TEXT_TILING_SHADER_LCD, DRAW_SHADER_FRAG_LCD, 2f
"pmlcd_inverted", 240, 64, 40, 8, 254, 255, 262144L, "lcd2.png", 0.7f, TEXT_TILING_SHADER_LCD, DRAW_SHADER_FRAG_LCD, 2f
)
) {
private val machine = Texture("./assets/4008_portable_full.png")
private val lcdFont = TextureRegionPack(Texture("./assets/lcd.png"), 12, 16)
override fun peek(addr: Long): Byte? {
/*override fun peek(addr: Long): Byte? {
return when (addr) {
in 0 until 250880 -> (-1).toByte()
else -> super.peek(addr)
@@ -27,7 +27,7 @@ class CharacterLCDdisplay(vm: VM) : GraphicsAdapter(vm, AdapterConfig(
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

View File

@@ -66,26 +66,8 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig, val sgr: Super
internal val spriteAndTextArea = UnsafeHelper.allocate(10660L)
protected val unusedArea = ByteArray(92)
protected val paletteShader = AppLoader.loadShaderInline(DRAW_SHADER_VERT,
config.paletteShader
/*if (theme.startsWith("pmlcd") && !theme.endsWith("_inverted"))
DRAW_SHADER_FRAG_LCD_NOINV
else if (theme.startsWith("pmlcd"))
DRAW_SHADER_FRAG_LCD
else
DRAW_SHADER_FRAG*/
)
protected val textShader = AppLoader.loadShaderInline(DRAW_SHADER_VERT,
config.fragShader
/*if (theme.startsWith("crt_") && !theme.endsWith("color"))
TEXT_TILING_SHADER_MONOCHROME
else if (theme.startsWith("pmlcd") && !theme.endsWith("_inverted"))
TEXT_TILING_SHADER_LCD_NOINV
else if (theme.startsWith("pmlcd"))
TEXT_TILING_SHADER_LCD
else
TEXT_TILING_SHADER_COLOUR*/
)
protected val paletteShader = AppLoader.loadShaderInline(DRAW_SHADER_VERT, config.paletteShader)
protected val textShader = AppLoader.loadShaderInline(DRAW_SHADER_VERT, config.fragShader)
override var blinkCursor = true
override var ttyRawMode = false
@@ -833,10 +815,6 @@ varying vec2 v_texCoords;
uniform sampler2D u_texture;
uniform vec4 pal[256];
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
void main(void) {
gl_FragColor = pal[int(texture2D(u_texture, v_texCoords).a * 255.0)];
}

View File

@@ -84,6 +84,19 @@ MMIO
88 RW: Rom mapping
89 RO: BMS flags
0b b000 00ca
a: 1 if charging (accepting power from the AC adapter)
c: 1 if battery is detected
b: 1 if the device is battery-operated
if the device is battery-operated but currently running off of an AC adapter and there is no battery inserted,
the flag would be 1000 0001
90 RO: BMS calculated battery percentage where 255 is 100%
91 RO: BMS battery voltage multiplied by 10 (127 = "12.7 V")
4076..4079 RW: 8-bit status code for the port
4080..4083 RO: 8-bit status code for connected device