null argument to support print w/o newline|new EMIT fn for BASIC

This commit is contained in:
minjaesong
2020-06-16 10:02:04 +09:00
parent 4e9dcf71e0
commit 8b9a16bbd1
4 changed files with 41 additions and 22 deletions

View File

@@ -71,6 +71,8 @@ class GraphicsJSR223Delegate(val vm: VM) {
fun putSymbol(char: Byte) {
getFirstGPU()?.let {
val (cx, cy) = it.getCursorPos()
it.putChar(cx, cy, char)
it.setCursorPos(cx + 1, cy)
}

View File

@@ -34,13 +34,7 @@ abstract class GlassTty(val TEXT_ROWS: Int, val TEXT_COLS: Int) {
abstract fun putChar(x: Int, y: Int, text: Byte, foreColour: Byte = ttyFore.toByte(), backColour: Byte = ttyBack.toByte())
fun writeOut(char: Byte) {
// deal with y-axis out-of-bounds
var (cx, cy) = getCursorPos()
if (cy >= TEXT_ROWS) {
scrollUp(cy - TEXT_ROWS + 1)
setCursorPos(cx, TEXT_ROWS - 1)
cy = TEXT_ROWS - 1
}
val (cx, cy) = getCursorPos()
val printable = acceptChar(char) // this function processes the escape codes and CRLFs

View File

@@ -69,11 +69,7 @@ class GraphicsAdapter(val vm: VM, val lcdMode: Boolean = false, lcdInvert: Boole
set(value) { spriteAndTextArea.setShort(memTextCursorPosOffset, value.toShort()) }
override fun getCursorPos() = rawCursorPos % TEXT_COLS to rawCursorPos / TEXT_COLS
/**
* Think of it as a real paper tty;
* setCursorPos must "wrap" the cursor properly when x-value goes out of screen bound.
* For y-value, only when y < 0, set y to zero and don't care about the y-value goes out of bound.
*/
override fun setCursorPos(x: Int, y: Int) {
var newx = x
var newy = y
@@ -89,6 +85,11 @@ class GraphicsAdapter(val vm: VM, val lcdMode: Boolean = false, lcdInvert: Boole
if (newy < 0) {
newy = 0 // DON'T SCROLL when cursor goes ABOVE the screen
}
else if (newy >= TEXT_ROWS) {
scrollUp(newy - TEXT_ROWS + 1)
setCursorPos(newy, TEXT_ROWS - 1)
newy = TEXT_ROWS - 1
}
rawCursorPos = toTtyTextOffset(newx, newy)
}