fixed wrong scroll up behaviour

Former-commit-id: 07837a20ae008e1072497e25b25709a6cbe97df1
Former-commit-id: 93db3957e5e9d745c78a864eb2cddd5a80a94320
This commit is contained in:
Song Minjae
2016-10-04 01:36:45 +09:00
parent cd2bcaf5cc
commit a4a9c037a6
2 changed files with 33 additions and 12 deletions

View File

@@ -12,8 +12,10 @@ constructor(var width: Int, var height: Int) {
/**
* 0000_0000_00000000
* Upper bits: Background colour 0 black 1 dark grey 2 grey 3 white
* Middle bits: Foreground colour ditto.
* Upper bits: Background colour
*
* Middle bits: Foreground colour
*
* Lower 8 bits: CP437
*/
internal val frameBuffer: CharArray
@@ -25,7 +27,7 @@ constructor(var width: Int, var height: Int) {
}
fun drawBuffer(x: Int, y: Int, c: Char, colourKey: Int) {
if (y * width + x >= frameBuffer.size)
if (y * width + x >= frameBuffer.size || y * width + x < 0)
throw ArrayIndexOutOfBoundsException("x: $x, y; $y")
frameBuffer[y * width + x] = ((c.toInt().and(0xFF)) + colourKey.shl(8)).toChar()
}