gdx and java update

This commit is contained in:
minjaesong
2024-08-11 20:45:12 +09:00
parent 1a1d49fbe5
commit 456426cafe
151 changed files with 182 additions and 255 deletions

View File

@@ -23,6 +23,7 @@ import java.io.InputStream
import java.io.OutputStream
import java.lang.IllegalArgumentException
import kotlin.experimental.and
import kotlin.math.floor
data class AdapterConfig(
val theme: String,
@@ -39,7 +40,7 @@ data class AdapterConfig(
val paletteShader: String = DRAW_SHADER_FRAG,
val drawScale: Float = 1f,
val scaleFiltered: Boolean = false,
val baudRate: Double = 57600.0,
val baudRate: Double = 20_480_000.0,//57600.0,
val bitsPerChar: Int = 10 // start bit + 8 data bits + stop bit
)
@@ -243,6 +244,31 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
}
}
protected val sleepMillis = if (config.baudRate == 0.0 || config.baudRate >= 1000000000.0) // sleep time of 1ns or less is considered as instant
0L
else
floor((1.0 / (config.baudRate / config.bitsPerChar)) * 1000).toLong()
protected val sleepNanos = if (config.baudRate == 0.0 || config.baudRate >= 1000000000.0) // sleep time of 1ns or less is considered as instant
0
else
(((1.0 / (config.baudRate / config.bitsPerChar)) * 1000 * 1000000) % 1000000).toInt()
protected var slpcnt = 0L
@SuppressWarnings()
protected fun applyDelay() {
slpcnt += sleepMillis * 1000000L + sleepNanos
val millis = slpcnt / 1000000L
if (slpcnt >= 1000000L) {
Thread.sleep(millis, 0)
slpcnt -= millis * 1000000L
}
}
override fun poke(addr: Long, byte: Byte) {
val adi = addr.toInt()
val bi = byte.toInt().and(255)
@@ -272,6 +298,7 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
poke(addr % VRAM_SIZE, byte)
} // HW mirroring
}
applyDelay()
}
private fun getTextmodeAttirbutes(): Byte = (currentChrRom.and(15).shl(4) or

View File

@@ -389,4 +389,7 @@ class IOSpace(val vm: VM) : PeriBase("io"), InputProcessor {
return false
}
override fun touchCancelled(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
return false
}
}

View File

@@ -12,33 +12,10 @@ import kotlin.math.floor
open class TexticsAdapterBase(assetsRoot: String, vm: VM, config: AdapterConfig) : GraphicsAdapter(assetsRoot, vm, config) {
protected val sleepMillis = if (config.baudRate == 0.0 || config.baudRate >= 10000000.0) // sleep time of 100ns or less is considered as instant
0L
else
floor((1.0 / (config.baudRate / config.bitsPerChar)) * 1000).toLong()
protected val sleepNanos = if (config.baudRate == 0.0 || config.baudRate >= 10000000.0) // sleep time of 100ns or less is considered as instant
0
else
(((1.0 / (config.baudRate / config.bitsPerChar)) * 1000 * 1000000) % 1000000).toInt()
protected var slpcnt = 0L
init {
println("Baud: $sleepMillis ms $sleepNanos ns")
}
@SuppressWarnings()
protected inline fun applyDelay() {
slpcnt += sleepMillis * 1000000L + sleepNanos
val millis = slpcnt / 1000000L
if (slpcnt >= 1000000L) {
Thread.sleep(millis, 0)
slpcnt -= millis * 1000000L
}
}
// private val crtGradTex = Texture("$assetsRoot/crt_grad.png")
companion object {
@@ -120,7 +97,7 @@ class Term(assetsRoot: String, vm: VM) : TexticsAdapterBase(assetsRoot, vm, Adap
"./hp2640.png",
0.32f,
GraphicsAdapter.TEXT_TILING_SHADER_MONOCHROME,
baudRate = 57600.0
baudRate = 9600.0
))
class WpTerm(assetsRoot: String, vm: VM) : TexticsAdapterBase(assetsRoot, vm, AdapterConfig(