diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index ba5364e06..0afb6c775 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -222,6 +222,77 @@ object Terrarum : StateBasedGame(GAME_NAME) { } } + @Throws(SlickException::class) + override fun initStatesList(gc: GameContainer) { + gc.input.enableKeyRepeat() + + + // get locale from config + val gameLocaleFromConfig = gameConfig.getAsString("language") ?: sysLang + + // if bad game locale were set, use system locale + if (gameLocaleFromConfig.length < 2) + gameLocale = sysLang + else + gameLocale = gameLocaleFromConfig + + println("[Terrarum] Locale: " + gameLocale) + + + fontGame = GameFontImpl() + fontSmallNumbers = TinyAlphNum() + + + // search for real controller + // exclude controllers with name "Mouse", "keyboard" + val notControllerRegex = Regex("mouse|keyboard") + try { + // gc.input.controllerCount is unreliable + for (i in 0..255) { + val controllerInQuo = Controllers.getController(i) + + println("Controller $i: ${controllerInQuo.name}") + + // check the name + if (!controllerInQuo.name.toLowerCase().contains(notControllerRegex)) { + controller = controllerInQuo + println("Controller $i selected: ${controller!!.name}") + break + } + } + } + catch (e: IndexOutOfBoundsException) { + } + + if (controller != null) { + for (c in 0..controller!!.axisCount - 1) { + controller!!.setDeadZone(c, CONTROLLER_DEADZONE) + } + } + + gc.graphics.clear() // clean up any 'dust' in the buffer + + //addState(StateVTTest()) + //addState(StateGraphicComputerTest()) + //addState(StateTestingLightning()) + //addState(StateSplash()) + //addState(StateMonitorCheck()) + //addState(StateFontTester()) + //addState(StateNoiseTexGen()) + //addState(StateBlurTest()) + //addState(StateShaderTest()) + //addState(StateNoiseTester()) + + ingame = StateInGame() + addState(ingame) + + + // foolproof + if (stateCount < 1) { + throw Error("Please add or un-comment addState statements") + } + } + private fun getDefaultDirectory() { val OS = System.getProperty("os.name").toUpperCase() if (OS.contains("WIN")) { @@ -373,77 +444,6 @@ object Terrarum : StateBasedGame(GAME_NAME) { return file // TODO TEST CODE } - - @Throws(SlickException::class) - override fun initStatesList(gc: GameContainer) { - gc.input.enableKeyRepeat() - - - // get locale from config - val gameLocaleFromConfig = gameConfig.getAsString("language") ?: sysLang - - // if bad game locale were set, use system locale - if (gameLocaleFromConfig.length < 2) - gameLocale = sysLang - else - gameLocale = gameLocaleFromConfig - - println("[Terrarum] Locale: " + gameLocale) - - - fontGame = GameFontImpl() - fontSmallNumbers = TinyAlphNum() - - - // search for real controller - // exclude controllers with name "Mouse", "keyboard" - val notControllerRegex = Regex("mouse|keyboard") - try { - // gc.input.controllerCount is unreliable - for (i in 0..255) { - val controllerInQuo = Controllers.getController(i) - - println("Controller $i: ${controllerInQuo.name}") - - // check the name - if (!controllerInQuo.name.toLowerCase().contains(notControllerRegex)) { - controller = controllerInQuo - println("Controller $i selected: ${controller!!.name}") - break - } - } - } - catch (e: IndexOutOfBoundsException) { - } - - if (controller != null) { - for (c in 0..controller!!.axisCount - 1) { - controller!!.setDeadZone(c, CONTROLLER_DEADZONE) - } - } - - gc.graphics.clear() // clean up any 'dust' in the buffer - - //addState(StateVTTest()) - addState(StateGraphicComputerTest()) - //addState(StateTestingLightning()) - //addState(StateSplash()) - //addState(StateMonitorCheck()) - //addState(StateFontTester()) - //addState(StateNoiseTexGen()) - //addState(StateBlurTest()) - //addState(StateShaderTest()) - //addState(StateNoiseTester()) - - ingame = StateInGame() - addState(ingame) - - - // foolproof - if (stateCount < 1) { - throw Error("Please add or un-comment addState statements") - } - } } fun main(args: Array) { diff --git a/src/net/torvald/terrarum/virtualcomputer/luaapi/Term.kt b/src/net/torvald/terrarum/virtualcomputer/luaapi/Term.kt index 90d986564..d1c6cb878 100644 --- a/src/net/torvald/terrarum/virtualcomputer/luaapi/Term.kt +++ b/src/net/torvald/terrarum/virtualcomputer/luaapi/Term.kt @@ -71,7 +71,7 @@ internal class Term(globals: Globals, term: Teletype) { class WriteString(val tty: Teletype) : LuaFunction() { override fun call(p0: LuaValue): LuaValue { if (tty is Terminal) - tty.writeString(p0.checkIBM437()) + tty.writeString(p0.checkIBM437(), tty.cursorX, tty.cursorY) else tty.writeChars(p0.checkIBM437()) return LuaValue.NONE @@ -89,7 +89,7 @@ internal class Term(globals: Globals, term: Teletype) { class PrintString(val tty: Teletype) : LuaFunction() { override fun call(p0: LuaValue): LuaValue { if (tty is Terminal) - tty.printString(p0.checkIBM437()) + tty.printString(p0.checkIBM437(), tty.cursorX, tty.cursorY) else tty.printChars(p0.checkIBM437()) return LuaValue.NONE diff --git a/src/net/torvald/terrarum/virtualcomputer/terminal/GraphicsTerminal.kt b/src/net/torvald/terrarum/virtualcomputer/terminal/GraphicsTerminal.kt index 318e68982..196107754 100644 --- a/src/net/torvald/terrarum/virtualcomputer/terminal/GraphicsTerminal.kt +++ b/src/net/torvald/terrarum/virtualcomputer/terminal/GraphicsTerminal.kt @@ -106,34 +106,35 @@ class GraphicsTerminal(private val host: TerrarumComputer) : Terminal { override fun emitChar(c: Char, xx: Int, yy: Int) { wrap() // needed - var x = xx - var y = yy + var nx = xx + var ny = yy // wrap argument cursor if (xx < 0 && yy <= 0) { - x = 0 - y = 0 + nx = 0 + ny = 0 } else if (cursorX >= width) { println("arstenioarstoneirastneo") - x = 0 - y += 1 + nx = 0 + ny += 1 } else if (cursorX < 0) { - x = width - 1 - y -= 1 + nx = width - 1 + ny -= 1 } // auto scroll up if (cursorY >= height) { scroll() - y -= 1 + ny -= 1 } println("xx: $xx, yy: $yy") + println("nx: $nx, ny: $ny") videoCard.drawChar( c, - x * PeripheralVideoCard.blockW, - y * PeripheralVideoCard.blockH, + nx * PeripheralVideoCard.blockW, + ny * PeripheralVideoCard.blockH, CLUT16_TO_64[foreColour] ) } diff --git a/src/net/torvald/terrarum/virtualcomputer/terminal/SimpleTextTerminal.kt b/src/net/torvald/terrarum/virtualcomputer/terminal/SimpleTextTerminal.kt index aa9e23e7d..d6e32d293 100644 --- a/src/net/torvald/terrarum/virtualcomputer/terminal/SimpleTextTerminal.kt +++ b/src/net/torvald/terrarum/virtualcomputer/terminal/SimpleTextTerminal.kt @@ -195,7 +195,7 @@ open class SimpleTextTerminal( override fun printChar(c: Char) { wrap() if (c >= ' ' && c.toInt() != 127) { - emitChar(c) + emitChar(c, cursorX, cursorY) cursorX += 1 } else { @@ -206,7 +206,7 @@ open class SimpleTextTerminal( ASCII_LF -> newLine() ASCII_FF -> clear() ASCII_CR -> { cursorX = 0 } - ASCII_DEL -> { cursorX -= 1; wrap(); emitChar(colourKey.shl(8)) } + ASCII_DEL -> { cursorX -= 1; wrap(); emitChar(colourKey.shl(8), cursorX, cursorY) } ASCII_DC1, ASCII_DC2, ASCII_DC3, ASCII_DC4 -> { foreColour = c - ASCII_DC1 } ASCII_DLE -> { foreColour = errorColour } } diff --git a/work_files/UI/vital_metres_2_annotation.png b/work_files/UI/vital_metres_2_annotation.png new file mode 100644 index 000000000..1a66eabcf Binary files /dev/null and b/work_files/UI/vital_metres_2_annotation.png differ diff --git a/work_files/UI/vital_metres_2_mockup.png b/work_files/UI/vital_metres_2_mockup.png new file mode 100644 index 000000000..94a1483a3 Binary files /dev/null and b/work_files/UI/vital_metres_2_mockup.png differ