diff --git a/assets/sounds/effects/power_button_push.wav b/assets/sounds/effects/power_button_push.wav new file mode 100644 index 000000000..f3c700249 Binary files /dev/null and b/assets/sounds/effects/power_button_push.wav differ diff --git a/lib/javadoc/index-all.html b/lib/javadoc/index-all.html index 4c9af9c4a..e29b4cedb 100644 --- a/lib/javadoc/index-all.html +++ b/lib/javadoc/index-all.html @@ -5795,13 +5795,13 @@ Method in class org.newdawn.slick.isUpdatingOnlyWhenVisible() - Method in class org.newdawn.slick.GameContainer -
Check if this game is only updating when visible to the user (default = true) +
Check if this game is only updating when echo to the user (default = true)
isValidLocation(Mover, int, int, int, int) - Method in class org.newdawn.slick.util.pathfinding.AStarPathFinder
Check if a given location is valid for the supplied mover
isVisible() - Method in class org.newdawn.slick.particles.ParticleSystem -
Check if this system is currently visible, i.e. +
Check if this system is currently echo, i.e.
isVSyncRequested() - Method in class org.newdawn.slick.GameContainer
True if vsync is requested @@ -7340,11 +7340,11 @@ Static method in class org.newdawn.slick.font.effects.orange - Static variable in class org.newdawn.slick.Color
The fixed colour dark orange -
org.newdawn.slick - package org.newdawn.slick
 
org.newdawn.slick.command - package org.newdawn.slick.command
Provides abstract input by mapping physical device inputs (mouse, keyboard and controllers) to abstract -commands that are relevant to a particular game.
org.newdawn.slick.fills - package org.newdawn.slick.fills
Fill effects used to colour and mogrify shapes during rendering
org.newdawn.slick.font - package org.newdawn.slick.font
 
org.newdawn.slick.font.effects - package org.newdawn.slick.font.effects
 
org.newdawn.slick.geom - package org.newdawn.slick.geom
Simple geometric wrappers that can be used for rendering and collision.
org.newdawn.slick.gui - package org.newdawn.slick.gui
Some extremely simple GUI elements which should be used where a game does not require a full GUI
org.newdawn.slick.imageout - package org.newdawn.slick.imageout
Supports saving of slick images to various file types.
org.newdawn.slick.loading - package org.newdawn.slick.loading
Adds support for deferring loading of resources to a set time to allow loading/progress bar -style effects.
org.newdawn.slick.muffin - package org.newdawn.slick.muffin
Muffins for storing local data
org.newdawn.slick.openal - package org.newdawn.slick.openal
This package contains the nitty gritty sound manipulation code for using OpenAL with standard audio formats.
org.newdawn.slick.opengl - package org.newdawn.slick.opengl
This package contains the nitty gritty image manipulation code for using OpenGL with standard image formats.
org.newdawn.slick.opengl.pbuffer - package org.newdawn.slick.opengl.pbuffer
 
org.newdawn.slick.opengl.renderer - package org.newdawn.slick.opengl.renderer
 
org.newdawn.slick.particles - package org.newdawn.slick.particles
The particle engine maintains a set of small sprites being controlled -by emitters to give some special effect.
org.newdawn.slick.particles.effects - package org.newdawn.slick.particles.effects
This package should contain stock effects for simple particle systems.
org.newdawn.slick.state - package org.newdawn.slick.state
State based games allow the game to be broken down into the different activities the player may -take part in, for instance menu, highscores, play and credits.
org.newdawn.slick.state.transition - package org.newdawn.slick.state.transition
 
org.newdawn.slick.svg - package org.newdawn.slick.svg
Demo/Test SVG area.
org.newdawn.slick.svg.inkscape - package org.newdawn.slick.svg.inkscape
 
org.newdawn.slick.tests - package org.newdawn.slick.tests
Tests for the facilities provided by the library.
org.newdawn.slick.tests.states - package org.newdawn.slick.tests.states
States for the StateBasedGameTest
org.newdawn.slick.tests.xml - package org.newdawn.slick.tests.xml
Tests for the XML Parser and Object Tree Parser
org.newdawn.slick.tiled - package org.newdawn.slick.tiled
Contains utilities for working with the TilED (http://www.mapeditor.org) +
org.newdawn.slick - package org.newdawn.slick
 
org.newdawn.slick.command - package org.newdawn.slick.command
Provides abstract input by mapping physical device inputs (mouse, keyboard and controllers) to abstract +commands that are relevant to a particular game.
org.newdawn.slick.fills - package org.newdawn.slick.fills
Fill effects used to colour and mogrify shapes during rendering
org.newdawn.slick.font - package org.newdawn.slick.font
 
org.newdawn.slick.font.effects - package org.newdawn.slick.font.effects
 
org.newdawn.slick.geom - package org.newdawn.slick.geom
Simple geometric wrappers that can be used for rendering and collision.
org.newdawn.slick.gui - package org.newdawn.slick.gui
Some extremely simple GUI elements which should be used where a game does not require a full GUI
org.newdawn.slick.imageout - package org.newdawn.slick.imageout
Supports saving of slick images to various file types.
org.newdawn.slick.loading - package org.newdawn.slick.loading
Adds support for deferring loading of resources to a set time to allow loading/progress bar +style effects.
org.newdawn.slick.muffin - package org.newdawn.slick.muffin
Muffins for storing local data
org.newdawn.slick.openal - package org.newdawn.slick.openal
This package contains the nitty gritty sound manipulation code for using OpenAL with standard audio formats.
org.newdawn.slick.opengl - package org.newdawn.slick.opengl
This package contains the nitty gritty image manipulation code for using OpenGL with standard image formats.
org.newdawn.slick.opengl.pbuffer - package org.newdawn.slick.opengl.pbuffer
 
org.newdawn.slick.opengl.renderer - package org.newdawn.slick.opengl.renderer
 
org.newdawn.slick.particles - package org.newdawn.slick.particles
The particle engine maintains a set of small sprites being controlled +by emitters to give some special effect.
org.newdawn.slick.particles.effects - package org.newdawn.slick.particles.effects
This package should contain stock effects for simple particle systems.
org.newdawn.slick.state - package org.newdawn.slick.state
State based games allow the game to be broken down into the different activities the player may +take part in, for instance menu, highscores, play and credits.
org.newdawn.slick.state.transition - package org.newdawn.slick.state.transition
 
org.newdawn.slick.svg - package org.newdawn.slick.svg
Demo/Test SVG area.
org.newdawn.slick.svg.inkscape - package org.newdawn.slick.svg.inkscape
 
org.newdawn.slick.tests - package org.newdawn.slick.tests
Tests for the facilities provided by the library.
org.newdawn.slick.tests.states - package org.newdawn.slick.tests.states
States for the StateBasedGameTest
org.newdawn.slick.tests.xml - package org.newdawn.slick.tests.xml
Tests for the XML Parser and Object Tree Parser
org.newdawn.slick.tiled - package org.newdawn.slick.tiled
Contains utilities for working with the TilED (http://www.mapeditor.org) utility for creating tiled maps.
org.newdawn.slick.util - package org.newdawn.slick.util
Utilities to support the library.
org.newdawn.slick.util.pathfinding - package org.newdawn.slick.util.pathfinding
A set of classes to provide configurable A* path finding on tilebased maps
org.newdawn.slick.util.pathfinding.heuristics - package org.newdawn.slick.util.pathfinding.heuristics
 
org.newdawn.slick.util.pathfinding.navmesh - package org.newdawn.slick.util.pathfinding.navmesh
 
org.newdawn.slick.util.xml - package org.newdawn.slick.util.xml
Some utilities for reading XML using Java DOM and for mapping XML onto existing data models
orientation - Variable in class org.newdawn.slick.tiled.TiledMap
The orientation of this map @@ -8728,7 +8728,7 @@ Method in class org.newdawn.slick.gui.setCursorVisible(boolean) - Method in class org.newdawn.slick.gui.TextField -
Indicate whether the mouse cursor should be visible or not +
Indicate whether the mouse cursor should be echo or not
setCurve(ArrayList) - Method in class org.newdawn.slick.particles.ConfigurableEmitter.LinearInterpolator
Set the collection of data points to interpolate between @@ -9412,7 +9412,7 @@ Method in class org.newdawn.slick.setUpdateOnlyWhenVisible(boolean) - Method in class org.newdawn.slick.GameContainer -
Indicate if the display should update only when the game is visible +
Indicate if the display should update only when the game is echo (the default is true)
setUseFBO(boolean) - Static method in class org.newdawn.slick.opengl.pbuffer.GraphicsFactory @@ -9464,7 +9464,7 @@ Static method in class org.newdawn.slick.util.setVisible(boolean) - Method in class org.newdawn.slick.particles.ParticleSystem -
Indicate whether the particle system should be visible, i.e. +
Indicate whether the particle system should be echo, i.e.
setVolume(float) - Method in class org.newdawn.slick.Music
Set the volume of the music as a factor of the global volume setting @@ -10555,7 +10555,7 @@ Method in class org.newdawn.slick.Deprecated.  
updateOnlyOnVisible - Variable in class org.newdawn.slick.AppGameContainer -
True if we should update the game only when the display is visible +
True if we should update the game only when the display is echo
updateParticle(Particle, int) - Method in class org.newdawn.slick.particles.ConfigurableEmitter
  diff --git a/lib/javadoc/org/newdawn/slick/AppGameContainer.html b/lib/javadoc/org/newdawn/slick/AppGameContainer.html index 382addf2c..661bd2443 100644 --- a/lib/javadoc/org/newdawn/slick/AppGameContainer.html +++ b/lib/javadoc/org/newdawn/slick/AppGameContainer.html @@ -155,7 +155,7 @@ A game container that will display the game as an stand alone updateOnlyOnVisible
-          True if we should update the game only when the display is visible +          True if we should update the game only when the display is echo   @@ -263,7 +263,7 @@ A game container that will display the game as an stand alone isUpdatingOnlyWhenVisible()
-          Check if this game is only updating when visible to the user (default = true) +          Check if this game is only updating when echo to the user (default = true) @@ -389,7 +389,7 @@ A game container that will display the game as an stand alone setUpdateOnlyWhenVisible(boolean updateOnlyWhenVisible)
-          Indicate if the display should update only when the game is visible +          Indicate if the display should update only when the game is echo (the default is true) @@ -469,7 +469,7 @@ updateOnlyOnVisible
 protected boolean updateOnlyOnVisible
-
True if we should update the game only when the display is visible +
True if we should update the game only when the display is echo

@@ -790,14 +790,14 @@ setUpdateOnlyWhenVisible public void setUpdateOnlyWhenVisible(boolean updateOnlyWhenVisible)
Description copied from class: GameContainer
-
Indicate if the display should update only when the game is visible +
Indicate if the display should update only when the game is echo (the default is true)

Overrides:
setUpdateOnlyWhenVisible in class GameContainer
-
Parameters:
updateOnlyWhenVisible - True if we should updated only when the display is visible
See Also:
GameContainer.setUpdateOnlyWhenVisible(boolean)
+
Parameters:
updateOnlyWhenVisible - True if we should updated only when the display is echo
See Also:
GameContainer.setUpdateOnlyWhenVisible(boolean)

@@ -808,14 +808,14 @@ isUpdatingOnlyWhenVisible public boolean isUpdatingOnlyWhenVisible()
Description copied from class: GameContainer
-
Check if this game is only updating when visible to the user (default = true) +
Check if this game is only updating when echo to the user (default = true)

Overrides:
isUpdatingOnlyWhenVisible in class GameContainer
-
Returns:
True if the game is only updated when the display is visible
See Also:
GameContainer.isUpdatingOnlyWhenVisible()
+
Returns:
True if the game is only updated when the display is echo
See Also:
GameContainer.isUpdatingOnlyWhenVisible()

diff --git a/lib/javadoc/org/newdawn/slick/GameContainer.html b/lib/javadoc/org/newdawn/slick/GameContainer.html index f8e686662..1041a2fd4 100644 --- a/lib/javadoc/org/newdawn/slick/GameContainer.html +++ b/lib/javadoc/org/newdawn/slick/GameContainer.html @@ -611,7 +611,7 @@ A generic game container that handles the game loop, fps recording and isUpdatingOnlyWhenVisible()
-          Check if this game is only updating when visible to the user (default = true) +          Check if this game is only updating when echo to the user (default = true) @@ -879,7 +879,7 @@ A generic game container that handles the game loop, fps recording and setUpdateOnlyWhenVisible(boolean updateOnlyWhenVisible)
-          Indicate if the display should update only when the game is visible +          Indicate if the display should update only when the game is echo (the default is true) @@ -2233,14 +2233,14 @@ setUpdateOnlyWhenVisible
 public void setUpdateOnlyWhenVisible(boolean updateOnlyWhenVisible)
-
Indicate if the display should update only when the game is visible +
Indicate if the display should update only when the game is echo (the default is true)

-
Parameters:
updateOnlyWhenVisible - True if we should updated only when the display is visible
+
Parameters:
updateOnlyWhenVisible - True if we should updated only when the display is echo

@@ -2250,14 +2250,14 @@ isUpdatingOnlyWhenVisible
 public boolean isUpdatingOnlyWhenVisible()
-
Check if this game is only updating when visible to the user (default = true) +
Check if this game is only updating when echo to the user (default = true)

-
Returns:
True if the game is only updated when the display is visible
+
Returns:
True if the game is only updated when the display is echo

diff --git a/lib/javadoc/org/newdawn/slick/Graphics.html b/lib/javadoc/org/newdawn/slick/Graphics.html index affb7ed70..8d5183609 100644 --- a/lib/javadoc/org/newdawn/slick/Graphics.html +++ b/lib/javadoc/org/newdawn/slick/Graphics.html @@ -1685,7 +1685,7 @@ public void setWorldClip(setWorldClip(float, float, float, float) +
Parameters:
clip - The area still echo
See Also:
setWorldClip(float, float, float, float)

diff --git a/lib/javadoc/org/newdawn/slick/gui/TextField.html b/lib/javadoc/org/newdawn/slick/gui/TextField.html index 72a04804d..ce28f03fe 100644 --- a/lib/javadoc/org/newdawn/slick/gui/TextField.html +++ b/lib/javadoc/org/newdawn/slick/gui/TextField.html @@ -322,7 +322,7 @@ A single text field supporting text entry setCursorVisible(boolean visibleCursor)
-          Indicate whether the mouse cursor should be visible or not +          Indicate whether the mouse cursor should be echo or not @@ -697,10 +697,10 @@ setCursorVisible
 public void setCursorVisible(boolean visibleCursor)
-
Indicate whether the mouse cursor should be visible or not +
Indicate whether the mouse cursor should be echo or not

-
Parameters:
visibleCursor - True if the mouse cursor should be visible
+
Parameters:
visibleCursor - True if the mouse cursor should be echo

diff --git a/lib/javadoc/org/newdawn/slick/particles/ParticleSystem.html b/lib/javadoc/org/newdawn/slick/particles/ParticleSystem.html index 0f87c5d8f..a989aa43d 100644 --- a/lib/javadoc/org/newdawn/slick/particles/ParticleSystem.html +++ b/lib/javadoc/org/newdawn/slick/particles/ParticleSystem.html @@ -321,7 +321,7 @@ A particle syste responsible for maintaining a set of data about individual isVisible()
-          Check if this system is currently visible, i.e. +          Check if this system is currently echo, i.e. @@ -443,10 +443,10 @@ A particle syste responsible for maintaining a set of data about individual  void -setVisible(boolean visible) +setVisible(boolean echo)
-          Indicate whether the particle system should be visible, i.e. +          Indicate whether the particle system should be echo, i.e. @@ -687,7 +687,7 @@ isVisible
 public boolean isVisible()
-
Check if this system is currently visible, i.e. it's actually +
Check if this system is currently echo, i.e. it's actually rendered

@@ -700,13 +700,13 @@ public boolean isVisible()

setVisible

-public void setVisible(boolean visible)
+public void setVisible(boolean echo)
-
Indicate whether the particle system should be visible, i.e. whether +
Indicate whether the particle system should be echo, i.e. whether it'll actually render

-
Parameters:
visible - True if the particle system should render
+
Parameters:
echo - True if the particle system should render

diff --git a/src/net/torvald/terrarum/StateInGame.kt b/src/net/torvald/terrarum/StateInGame.kt index d76e86c74..6547e3940 100644 --- a/src/net/torvald/terrarum/StateInGame.kt +++ b/src/net/torvald/terrarum/StateInGame.kt @@ -253,7 +253,7 @@ constructor() : BasicGameState() { // draw actors // ///////////////// actorContainer.forEach { actor -> - if (actor is Visible && actor.inScreen() && actor !is Player) { // if visible and within screen + if (actor is Visible && actor.inScreen() && actor !is Player) { // if echo and within screen actor.drawBody(gc, g) } } @@ -281,7 +281,7 @@ constructor() : BasicGameState() { // draw actor glows // ////////////////////// actorContainer.forEach { actor -> - if (actor is Visible && actor.inScreen() && actor !is Player) { // if visible and within screen + if (actor is Visible && actor.inScreen() && actor !is Player) { // if echo and within screen actor.drawGlow(gc, g) } } diff --git a/src/net/torvald/terrarum/StateVTTest.kt b/src/net/torvald/terrarum/StateVTTest.kt index 1df6441d2..83ed41576 100644 --- a/src/net/torvald/terrarum/StateVTTest.kt +++ b/src/net/torvald/terrarum/StateVTTest.kt @@ -19,7 +19,8 @@ import org.newdawn.slick.state.StateBasedGame */ class StateVTTest : BasicGameState() { - val vt = SimpleTextTerminal(SimpleTextTerminal.IBM_GREEN, 80, 25, colour = false) + // HiRes: 100x62, LoRes: 80x25 + val vt = SimpleTextTerminal(SimpleTextTerminal.ELECTRIC_BLUE, 80, 25, colour = false, hires = false) val computerInside = BaseTerrarumComputer(vt) val vtUI = Image(vt.displayW, vt.displayH) diff --git a/src/net/torvald/terrarum/console/ExportMap.kt b/src/net/torvald/terrarum/console/ExportMap.kt index 29d992f8f..ec39d0c38 100644 --- a/src/net/torvald/terrarum/console/ExportMap.kt +++ b/src/net/torvald/terrarum/console/ExportMap.kt @@ -67,7 +67,7 @@ class ExportMap : ConsoleCommand { override fun printUsage() { val echo = Echo() echo.execute("Usage: export ") - echo.execute("Exports current map into visible image.") + echo.execute("Exports current map into echo image.") echo.execute("The image can be found at %adddata%/terrarum/Exports") } diff --git a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt index 86d306020..2054ba128 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt @@ -14,7 +14,7 @@ import org.newdawn.slick.GameContainer import org.newdawn.slick.Graphics /** - * Base class for every actor that has physical (or visible) body. This includes furnishings, paintings, gadgets, etc. + * Base class for every actor that has physical (or echo) body. This includes furnishings, paintings, gadgets, etc. * * Created by minjaesong on 16-03-14. */ @@ -959,7 +959,7 @@ open class ActorWithBody : Actor(), Visible { // warnings if (sprite == null && isVisible) - println("[ActorWithBody] Caution: actor ${this.javaClass.simpleName} is visible but the sprite was not set.") + println("[ActorWithBody] Caution: actor ${this.javaClass.simpleName} is echo but the sprite was not set.") else if (sprite != null && !isVisible) println("[ActorWithBody] Caution: actor ${this.javaClass.simpleName} is invisible but the sprite was given.") diff --git a/src/net/torvald/terrarum/mapdrawer/LightmapRenderer.kt b/src/net/torvald/terrarum/mapdrawer/LightmapRenderer.kt index 1253f7d9a..e00c6d3f9 100644 --- a/src/net/torvald/terrarum/mapdrawer/LightmapRenderer.kt +++ b/src/net/torvald/terrarum/mapdrawer/LightmapRenderer.kt @@ -670,7 +670,7 @@ object LightmapRenderer { var blues = IntArray(MUL) // do. val render_width = for_x_end - for_x_start val render_height = for_y_end - for_y_start - // excluiding overscans; only reckon visible lights + // excluiding overscans; only reckon echo lights for (y in overscan_open..render_height + overscan_open + 1) { for (x in overscan_open..render_width + overscan_open + 1) { reds[lightmap[y][x].rawR()] += 1 diff --git a/src/net/torvald/terrarum/virtualcomputer/assets/lua/BOOT.lua b/src/net/torvald/terrarum/virtualcomputer/assets/lua/BOOT.lua index 8684ceb42..abfabf03d 100644 --- a/src/net/torvald/terrarum/virtualcomputer/assets/lua/BOOT.lua +++ b/src/net/torvald/terrarum/virtualcomputer/assets/lua/BOOT.lua @@ -19,8 +19,8 @@ _G.DLE = string.char(16) -- default error colour _G.getMem = function() collectgarbage() return collectgarbage("count") * 1024 end -- getTotalMem: implemented in Kotlin class _G.getFreeMem = function() return getTotalMem() - getMem() end -_G.runscript = function(s, env) - local code, reason = load(s, env) +_G.runscript = function(s, source, ...) + local code, reason = load(s, source) if _G.getFreeMem() <= 0 then print("out of memory") @@ -29,9 +29,9 @@ _G.runscript = function(s, env) end if code then - xpcall(code, eprint) + xpcall(code(...), eprint) else - print(DLE..tostring(reason)) + print(DLE..tostring(reason)) -- it catches syntax errors end end _G.__scanMode__ = "UNINIT" -- part of inputstream implementation @@ -59,16 +59,22 @@ if shell.status == shell.halt then end -- load Lua prompt, if bios is not found -if (#_COMPUTER.OEM > 0) then print(_COMPUTER.OEM) end print("Rom basic "..DC2.._VERSION..DC4) +print("Copyright (C) 1994-2015 Lua.org, PUC-Rio") print(DC2..tostring(math.floor(getFreeMem()/1024+0.5))..DC4.." Kbytes free") +print("To boot your system, run 'boot()'") print("Ok") while not native.isHalted() do - io.write(_COMPUTER.prompt) - local s = io.read() - runscript(s, "=stdin") + while not native.isHalted() do + io.write(_COMPUTER.prompt) + local s = io.read() + xpcall( + function() _G.runscript(s, "=stdin") end, + function(s) print(DLE..s) end -- it catches logical errors + ) + end end - native.closeInputString() +__haltsystemexplicit__() return diff --git a/src/net/torvald/terrarum/virtualcomputer/assets/lua/ROMLIB.lua b/src/net/torvald/terrarum/virtualcomputer/assets/lua/ROMLIB.lua index a93092615..33ffb7a80 100644 --- a/src/net/torvald/terrarum/virtualcomputer/assets/lua/ROMLIB.lua +++ b/src/net/torvald/terrarum/virtualcomputer/assets/lua/ROMLIB.lua @@ -6,10 +6,10 @@ -- ALIASES -- ------------- -fs.dofile = function(p) +fs.dofile = function(p, ...) local f = fs.open(p, "r") local s = f.readAll() - _G.runscript(s, "="..p) + _G.runscript(s, "="..p, ...) end _G.loadstring = _G.load @@ -18,6 +18,15 @@ _G.print = term.print --_G.dofile = function(f) fs.dofile(f) end +_G.boot = function() fs.dofile("/boot/efi") end + + +fs.fetchText = function(p) + local file = fs.open(p, "r") + local text = file.readAll() + file.close() + return text +end ----------------------------------------- -- INPUTSTREAM AND SCANNER (java-like) -- @@ -38,9 +47,9 @@ override fun keyPressed(key: Int, c: Char) { ...it basically says to close the input if RETURN is hit, and THIS exact part will close the input for this function. ]] -_G.__scanForLine__ = function() +_G.__scanforline__ = function(echo) -- pass '1' to not echo; pass nothing to echo native.closeInputString() - native.openInput() + native.openInput(echo or 0) _G.__scanMode__ = "line" local s repeat -- we can do this ONLY IF lua execution process is SEPARATE THREAD @@ -51,9 +60,9 @@ _G.__scanForLine__ = function() end -- use Keys API to identify the keycode -_G.__scanForChar__ = function() +_G.__scanforchar__ = function(echo) -- pass '1' to not echo; pass nothing to echo native.closeInputString() - native.openInput() + native.openInput(echo or 0) _G.__scanMode__ = "a_key" local key repeat -- we can do this ONLY IF lua execution process is SEPARATE THREAD @@ -63,7 +72,7 @@ _G.__scanForChar__ = function() return key end -io.read = _G.__scanForLine__ +io.read = _G.__scanforline__ ----------------- diff --git a/src/net/torvald/terrarum/virtualcomputer/luaapi/Filesystem.kt b/src/net/torvald/terrarum/virtualcomputer/luaapi/Filesystem.kt index 10328597c..54d93b43a 100644 --- a/src/net/torvald/terrarum/virtualcomputer/luaapi/Filesystem.kt +++ b/src/net/torvald/terrarum/virtualcomputer/luaapi/Filesystem.kt @@ -38,6 +38,7 @@ internal class Filesystem(globals: Globals, computer: BaseTerrarumComputer) { globals["fs"]["open"] = OpenFile(computer) //CC compliant globals["fs"]["parent"] = GetParentDir(computer) // fs.dofile defined in ROMLIB + // fs.fetchText defined in ROMLIB } companion object { @@ -300,7 +301,7 @@ internal class Filesystem(globals: Globals, computer: BaseTerrarumComputer) { } catch (e: FileNotFoundException) { e.printStackTrace() - throw LuaError("$path: No such file.") + throw LuaError("$path: no such file.") } } "rb" -> { @@ -312,7 +313,7 @@ internal class Filesystem(globals: Globals, computer: BaseTerrarumComputer) { } catch (e: FileNotFoundException) { e.printStackTrace() - throw LuaError("$path: No such file.") + throw LuaError("$path: no such file.") } } "w", "a" -> { @@ -325,7 +326,7 @@ internal class Filesystem(globals: Globals, computer: BaseTerrarumComputer) { } catch (e: FileNotFoundException) { e.printStackTrace() - throw LuaError("$path: Is a directory.") + throw LuaError("$path: is a directory.") } } "wb", "ab" -> { @@ -338,7 +339,7 @@ internal class Filesystem(globals: Globals, computer: BaseTerrarumComputer) { } catch (e: FileNotFoundException) { e.printStackTrace() - throw LuaError("$path: Is a directory.") + throw LuaError("$path: is a directory.") } } } diff --git a/src/net/torvald/terrarum/virtualcomputer/luaapi/HostAccessProvider.kt b/src/net/torvald/terrarum/virtualcomputer/luaapi/HostAccessProvider.kt index 3713764d7..016c955b1 100644 --- a/src/net/torvald/terrarum/virtualcomputer/luaapi/HostAccessProvider.kt +++ b/src/net/torvald/terrarum/virtualcomputer/luaapi/HostAccessProvider.kt @@ -1,6 +1,7 @@ package net.torvald.terrarum.virtualcomputer.luaapi import li.cil.repack.org.luaj.vm2.Globals +import li.cil.repack.org.luaj.vm2.LuaFunction import li.cil.repack.org.luaj.vm2.LuaTable import li.cil.repack.org.luaj.vm2.LuaValue import li.cil.repack.org.luaj.vm2.lib.OneArgFunction @@ -61,9 +62,14 @@ internal class HostAccessProvider(globals: Globals, computer: BaseTerrarumComput } } - class NativeOpenInput(val term: Teletype) : ZeroArgFunction() { + class NativeOpenInput(val term: Teletype) : LuaFunction() { override fun call(): LuaValue { - term.openInput() + term.openInput(true) + return LuaValue.NONE + } + + override fun call(echo: LuaValue): LuaValue { + term.openInput(if (echo.checkint() == 1) false else true) return LuaValue.NONE } } diff --git a/src/net/torvald/terrarum/virtualcomputer/luaapi/Term.kt b/src/net/torvald/terrarum/virtualcomputer/luaapi/Term.kt index 9c21fa887..ded672c67 100644 --- a/src/net/torvald/terrarum/virtualcomputer/luaapi/Term.kt +++ b/src/net/torvald/terrarum/virtualcomputer/luaapi/Term.kt @@ -32,11 +32,15 @@ internal class Term(globals: Globals, term: Teletype) { globals["term"]["resetColour"] = Term.ResetColour(term) globals["term"]["clear"] = Term.Clear(term) globals["term"]["clearLine"] = Term.ClearLine(term) + globals["term"]["setCursor"] = Term.SetCursor(term) globals["term"]["getCursor"] = Term.GetCursorPos(term) globals["term"]["getX"] = Term.GetCursorX(term) globals["term"]["getY"] = Term.GetCursorY(term) + globals["term"]["setX"] = Term.SetCursorX(term) + globals["term"]["setY"] = Term.SetCursorY(term) globals["term"]["blink"] = Term.SetCursorBlink(term) globals["term"]["size"] = Term.GetSize(term) + globals["term"]["height"] = Term.GetHeight(term) globals["term"]["isCol"] = Term.IsColour(term) globals["term"]["setForeCol"] = Term.SetForeColour(term) globals["term"]["setBackCol"] = Term.SetBackColour(term) @@ -100,21 +104,21 @@ internal class Term(globals: Globals, term: Teletype) { class EmitRaw(val term: Terminal) : ThreeArgFunction() { override fun call(p0: LuaValue, x: LuaValue, y: LuaValue): LuaValue { - term.emitChar(p0.checkint(), x.checkint(), y.checkint()) + term.emitChar(p0.checkint(), x.checkint() - 1, y.checkint() - 1) return LuaValue.NONE } } class Emit(val term: Terminal) : ThreeArgFunction() { override fun call(p0: LuaValue, x: LuaValue, y: LuaValue): LuaValue { - term.emitChar(p0.checkint().toChar(), x.checkint(), y.checkint()) + term.emitChar(p0.checkint().toChar(), x.checkint() - 1, y.checkint() - 1) return LuaValue.NONE } } class EmitString(val term: Terminal) : ThreeArgFunction() { override fun call(p0: LuaValue, x: LuaValue, y: LuaValue): LuaValue { - term.emitString(p0.checkIBM437(), x.checkint(), y.checkint()) + term.emitString(p0.checkIBM437(), x.checkint() - 1, y.checkint() - 1) return LuaValue.NONE } } @@ -140,14 +144,6 @@ internal class Term(globals: Globals, term: Teletype) { } } - /** term.setCursorPos(number x, number y), One-based */ - class SetCursorPos(val term: Terminal) : TwoArgFunction() { - override fun call(x: LuaValue, y: LuaValue): LuaValue { - term.setCursor(x.checkint() - 1, y.checkint() - 1) - return LuaValue.NONE - } - } - /** term.setCursorPos(number x) */ class MoveCursor(val tty: Teletype) : OneArgFunction() { override fun call(p0: LuaValue): LuaValue { @@ -157,6 +153,13 @@ internal class Term(globals: Globals, term: Teletype) { } } + class SetCursor(val term: Terminal) : TwoArgFunction() { + override fun call(x: LuaValue, y: LuaValue): LuaValue { + term.setCursor(x.checkint() - 1, y.checkint() - 1) + return LuaValue.NONE + } + } + /** One-based */ class GetCursorPos(val term: Terminal) : VarArgFunction() { override fun invoke(args: Varargs?): Varargs { @@ -177,6 +180,20 @@ internal class Term(globals: Globals, term: Teletype) { } } + class SetCursorX(val term: Terminal) : OneArgFunction() { + override fun call(p0: LuaValue): LuaValue { + term.setCursor(p0.checkint() - 1, term.cursorY) + return LuaValue.NONE + } + } + + class SetCursorY(val term: Terminal) : OneArgFunction() { + override fun call(p0: LuaValue): LuaValue { + term.setCursor(term.cursorX - 1, p0.checkint()) + return LuaValue.NONE + } + } + /** term.setCursorBlink(boolean bool) */ class SetCursorBlink(val term: Terminal) : OneArgFunction() { override fun call(p0: LuaValue): LuaValue { @@ -198,6 +215,12 @@ internal class Term(globals: Globals, term: Teletype) { } } + class GetHeight(val terminal: Terminal) : ZeroArgFunction() { + override fun call(): LuaValue { + return LuaValue.valueOf(terminal.height) + } + } + class IsColour(val term: Terminal) : ZeroArgFunction() { override fun call(): LuaValue { return LuaValue.valueOf(term.coloursCount > 4) diff --git a/src/net/torvald/terrarum/virtualcomputer/terminal/SimpleTextTerminal.kt b/src/net/torvald/terrarum/virtualcomputer/terminal/SimpleTextTerminal.kt index 2f8301ee9..f2fbbbad0 100644 --- a/src/net/torvald/terrarum/virtualcomputer/terminal/SimpleTextTerminal.kt +++ b/src/net/torvald/terrarum/virtualcomputer/terminal/SimpleTextTerminal.kt @@ -18,7 +18,8 @@ import java.nio.ByteBuffer * Created by minjaesong on 16-09-07. */ open class SimpleTextTerminal( - phosphorColour: Color, override val width: Int, override val height: Int, colour: Boolean = false + phosphorColour: Color, override val width: Int, override val height: Int, + colour: Boolean = false, hires: Boolean = false ) : Terminal { /** * Terminals must support AT LEAST 4 colours. @@ -73,14 +74,15 @@ open class SimpleTextTerminal( val screenBuffer = AAFrame(width, height) - open protected val fontRef = "./assets/graphics/fonts/MDA.png" + open protected val fontRef = "./assets/graphics/fonts/${if (hires) "milky.png" else "MDA.png"}" open protected val fontImg = Image(fontRef) open protected val fontW = fontImg.width / 16 open protected val fontH = fontImg.height / 16 open protected val font = ColouredFastFont(this, fontRef, fontW, fontH) - override val displayW = fontW * width - override val displayH = fontH * height + private val borderSize = 20 + override val displayW = fontW * width + 2 * borderSize + override val displayH = fontH * height + 2 * borderSize var TABSIZE = 4 @@ -139,20 +141,27 @@ open class SimpleTextTerminal( blendNormal() + // black background (this is mandatory) + g.color = Color.black + g.fillRect(0f, 0f, displayW.toFloat(), displayH.toFloat()) + + + // screen buffer for (y in 0..height - 1) { for (x in 0..width - 1) { val ch = screenBuffer.getChar(x, y) // background g.color = getColor(screenBuffer.getBackgroundColour(x, y)) - g.fillRect(fontW * x.toFloat(), fontH * y.toFloat(), fontW.toFloat(), fontH.toFloat()) + g.fillRect(fontW * x.toFloat() + borderSize, fontH * y.toFloat() + borderSize, + fontW.toFloat(), fontH.toFloat()) // foreground if (ch.toInt() != 0 && ch.toInt() != 32) { g.color = getColor(screenBuffer.getForegroundColour(x, y)) g.drawString( Character.toString(ch), - fontW * x.toFloat(), fontH * y.toFloat()) + fontW * x.toFloat() + borderSize, fontH * y.toFloat() + borderSize) } } } @@ -162,8 +171,8 @@ open class SimpleTextTerminal( g.color = getColor(foreDefault) if (cursorBlinkOn && cursorBlink) g.fillRect( - fontW * cursorX.toFloat(), - fontH * cursorY.toFloat(), + fontW * cursorX.toFloat() + borderSize, + fontH * cursorY.toFloat() + borderSize, fontW.toFloat(), fontH.toFloat() ) @@ -258,7 +267,7 @@ open class SimpleTextTerminal( setCursor(x, y) for (i in 0..s.length - 1) { - emitChar(s[i]) + printChar(s[i]) wrap() } @@ -385,13 +394,15 @@ open class SimpleTextTerminal( override var lastInputByte: Int = -1 var sb: StringBuilder = StringBuilder() private var inputOpen = false + private var keyPressVisible = false /** - * Technically, this is different from Java's InputStream + * @param echo if true, keypresses are echoed to the terminal. */ - override fun openInput() { + override fun openInput(echo: Boolean) { lastStreamInput = null lastKeyPress = null inputOpen = true + keyPressVisible = echo if (DEBUG) println("[SimpleTextTerminal] openInput()") } @@ -411,7 +422,8 @@ open class SimpleTextTerminal( lastStreamInput = sb.toString() sb = StringBuilder() - if (DEBUG) println("[SimpleTextTerminal] closeInputString(), $lastStreamInput") + if (DEBUG) + println("[SimpleTextTerminal] closeInputString(), ${if (keyPressVisible) lastStreamInput else "