@@ -4,7 +4,7 @@ import com.emerjbl.ultra8.util.LockGuarded
4
4
import java.util.concurrent.locks.ReentrantLock
5
5
6
6
7
- class SimpleGraphics : Chip8Graphics , Chip8Render < SimpleGraphics . Frame > {
7
+ class SimpleGraphics {
8
8
class Frame private constructor(
9
9
val width : Int ,
10
10
val height : Int ,
@@ -17,7 +17,7 @@ class SimpleGraphics : Chip8Graphics, Chip8Render<SimpleGraphics.Frame> {
17
17
18
18
private var frame: LockGuarded <Frame > = LockGuarded (ReentrantLock (), lowRes())
19
19
20
- override var hires: Boolean = false
20
+ var hires: Boolean = false
21
21
set(value) {
22
22
field = value
23
23
frame.update(if (value) hiRes() else lowRes())
@@ -26,11 +26,11 @@ class SimpleGraphics : Chip8Graphics, Chip8Render<SimpleGraphics.Frame> {
26
26
private fun lowRes () = Frame (64 , 32 )
27
27
private fun hiRes () = Frame (128 , 64 )
28
28
29
- override fun clear () {
29
+ fun clear () {
30
30
frame.withLock { it.data.fill(0 ) }
31
31
}
32
32
33
- override fun scrollRight () = frame.withLock { frame ->
33
+ fun scrollRight () = frame.withLock { frame ->
34
34
for (row in 0 until frame.width) {
35
35
val rowStart = row * frame.width
36
36
val startIndex = rowStart
@@ -41,7 +41,7 @@ class SimpleGraphics : Chip8Graphics, Chip8Render<SimpleGraphics.Frame> {
41
41
}
42
42
}
43
43
44
- override fun scrollLeft () = frame.withLock { frame ->
44
+ fun scrollLeft () = frame.withLock { frame ->
45
45
for (row in 0 until frame.height) {
46
46
val rowStart = row * frame.width
47
47
val startIndex = rowStart + 4
@@ -52,23 +52,23 @@ class SimpleGraphics : Chip8Graphics, Chip8Render<SimpleGraphics.Frame> {
52
52
}
53
53
}
54
54
55
- override fun scrollDown (n : Int ) = frame.withLock { frame ->
55
+ fun scrollDown (n : Int ) = frame.withLock { frame ->
56
56
val destinationOffset = n * frame.width
57
57
val startIndex = 0
58
58
val endIndex = (frame.height - n) * frame.width
59
59
frame.data.copyInto(frame.data, destinationOffset, startIndex, endIndex)
60
60
frame.data.fill(0 , 0 , n * frame.width)
61
61
}
62
62
63
- override fun scrollUp (n : Int ) = frame.withLock { frame ->
63
+ fun scrollUp (n : Int ) = frame.withLock { frame ->
64
64
val destinationOffset = 0
65
65
val startIndex = n * frame.width
66
66
val endIndex = frame.width * frame.height
67
67
frame.data.copyInto(frame.data, destinationOffset, startIndex, endIndex)
68
68
frame.data.fill(0 , 0 , n * frame.width)
69
69
}
70
70
71
- override fun putSprite (
71
+ fun putSprite (
72
72
xBase : Int ,
73
73
yBase : Int ,
74
74
data : ByteArray ,
@@ -119,7 +119,7 @@ class SimpleGraphics : Chip8Graphics, Chip8Render<SimpleGraphics.Frame> {
119
119
return unset
120
120
}
121
121
122
- override fun nextFrame (lastFrame : Frame ? ): Frame = frame.withLock { frame ->
122
+ fun nextFrame (lastFrame : Frame ? ): Frame = frame.withLock { frame ->
123
123
if (lastFrame?.height == frame.height && lastFrame.width == frame.width) {
124
124
frame.data.copyInto(lastFrame.data)
125
125
lastFrame
0 commit comments