mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-14 06:56:05 +09:00
basic: most basic and working INPUT
This commit is contained in:
@@ -4,10 +4,7 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||
import net.torvald.tsvm.peripheral.BasicBios;
|
||||
import net.torvald.tsvm.peripheral.BasicRom;
|
||||
import net.torvald.tsvm.peripheral.GenericBios;
|
||||
import net.torvald.tsvm.peripheral.VMProgramRom;
|
||||
import net.torvald.tsvm.peripheral.*;
|
||||
|
||||
public class AppLoader {
|
||||
|
||||
@@ -31,7 +28,8 @@ public class AppLoader {
|
||||
|
||||
// val vm = VM(64.kB(), TheRealWorld(), arrayOf(GenericBios))
|
||||
//VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{GenericBios.INSTANCE});
|
||||
VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, BasicRom.INSTANCE});
|
||||
//VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, BasicRom.INSTANCE});
|
||||
VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{OEMBios.INSTANCE, BasicRom.INSTANCE});
|
||||
new LwjglApplication(new VMGUI(vm, appConfig), appConfig);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class VMJSR223Delegate(val vm: VM) {
|
||||
vm.romMapping = slot.and(255)
|
||||
}
|
||||
fun romReadAll(): String {
|
||||
if (vm.romMapping == 255) return ""
|
||||
if (vm.romMapping == 255 || vm.romMapping !in vm.roms.indices || vm.roms[vm.romMapping] == null) return ""
|
||||
return vm.roms[vm.romMapping]!!.readAll()
|
||||
}
|
||||
|
||||
|
||||
28
src/net/torvald/tsvm/peripheral/OEMBios.kt
Normal file
28
src/net/torvald/tsvm/peripheral/OEMBios.kt
Normal file
@@ -0,0 +1,28 @@
|
||||
package net.torvald.tsvm.peripheral
|
||||
|
||||
import net.torvald.tsvm.CompressorDelegate
|
||||
import net.torvald.tsvm.CompressorDelegate.GZIP_HEADER
|
||||
import net.torvald.tsvm.VM
|
||||
import net.torvald.tsvm.startsWith
|
||||
import java.io.File
|
||||
|
||||
object OEMBios : VMProgramRom {
|
||||
|
||||
private val contents: ByteArray
|
||||
|
||||
init {
|
||||
val bytes = File("./assets/bios/TBMBIOS.js").readBytes()
|
||||
contents = bytes.sliceArray(0 until minOf(65536, bytes.size))
|
||||
}
|
||||
|
||||
override fun readAll(): String {
|
||||
// check if bios is compressed in gzip
|
||||
return if (contents.startsWith(GZIP_HEADER))
|
||||
CompressorDelegate.decomp(contents).toString(VM.CHARSET)
|
||||
else
|
||||
contents.toString(VM.CHARSET)
|
||||
}
|
||||
|
||||
override fun get(addr: Int): Byte = contents[addr]
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user