mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
BasicAST: ability to distinguish two different separators
This commit is contained in:
@@ -12,6 +12,7 @@ import javax.swing.WindowConstants
|
||||
class Memvwr(val vm: VM) : JFrame() {
|
||||
|
||||
val memArea = JTextArea()
|
||||
var columns = 16
|
||||
|
||||
fun composeVwrText() {
|
||||
val sb = StringBuilder()
|
||||
@@ -67,6 +68,45 @@ class Memvwr(val vm: VM) : JFrame() {
|
||||
sb.append("== Port ${port + 1}: ${status.toString(2).padStart(8, '0')}\n")
|
||||
}
|
||||
|
||||
sb.append("\n== First 4 kbytes of User RAM ==\n")
|
||||
sb.append("ADRESS : 0 1 2 3| 4 5 6 7| 8 9 A B| C D E F\n")
|
||||
for (i in 0L..4095L) {
|
||||
if (i % columns == 0L) {
|
||||
sb.append(i.toString(16).toUpperCase().padStart(6, '0')) // mem addr
|
||||
sb.append(" : ") // separator
|
||||
}
|
||||
|
||||
|
||||
sb.append(vm.peek(i)!!.toUint().toString(16).toUpperCase().padStart(2, '0'))
|
||||
if (i % 16L in longArrayOf(3L, 7L, 11L)) {
|
||||
sb.append('|') // mem value
|
||||
}
|
||||
else {
|
||||
sb.append(' ') // mem value
|
||||
}
|
||||
|
||||
// ASCII viewer
|
||||
if (i % columns == 15L) {
|
||||
sb.append("| ")
|
||||
|
||||
for (x in -15..0) {
|
||||
val mem = vm.peek(i + x)!!.toUint()
|
||||
|
||||
if (mem < 32) {
|
||||
sb.append('.')
|
||||
}
|
||||
else {
|
||||
sb.append(mem.toChar())
|
||||
}
|
||||
|
||||
if (x + 15 in intArrayOf(3, 7, 11))
|
||||
sb.append('|')
|
||||
}
|
||||
|
||||
sb.append("|\n")
|
||||
}
|
||||
}
|
||||
|
||||
memArea.text = sb.toString()
|
||||
}
|
||||
|
||||
@@ -82,6 +122,6 @@ class Memvwr(val vm: VM) : JFrame() {
|
||||
this.isVisible = true
|
||||
this.add(javax.swing.JScrollPane(memArea), BorderLayout.CENTER)
|
||||
this.defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE
|
||||
this.size = Dimension(800, 960)
|
||||
this.size = Dimension(820, 960)
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import java.io.StringReader
|
||||
|
||||
class VMGUI(val appConfig: LwjglApplicationConfiguration) : ApplicationAdapter() {
|
||||
|
||||
val vm = VM(1024.kB())
|
||||
val vm = VM(64.kB())
|
||||
lateinit var gpu: GraphicsAdapter
|
||||
|
||||
lateinit var batch: SpriteBatch
|
||||
|
||||
Reference in New Issue
Block a user