bunch of codes:

- Test InputStream() on VirtualComputer (blocking/unblocking using simple semaphore) -- no more dirty lua impl of io.read
- Typealias Kotlin 1.1
- Primitive box drawing on VideoCard
- Removing unnecessary fonts


Former-commit-id: cece88af3a3430678e685856eec78b4a9d598b4f
Former-commit-id: 22eed3a7beb9b4cb34636cbab2ff0e94989bdb31
This commit is contained in:
Song Minjae
2017-03-02 02:11:50 +09:00
parent bdba27d776
commit 96c6cb2cc6
33 changed files with 507 additions and 453 deletions

View File

@@ -2,7 +2,7 @@ package net.torvald.terrarum
import net.torvald.random.HQRNG
import net.torvald.terrarum.gameactors.roundInt
import net.torvald.terrarum.virtualcomputer.computer.BaseTerrarumComputer
import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer
import net.torvald.terrarum.virtualcomputer.peripheral.PeripheralVideoCard
import net.torvald.terrarum.virtualcomputer.terminal.GraphicsTerminal
import org.lwjgl.opengl.GL11
@@ -16,7 +16,7 @@ import java.util.*
* Created by SKYHi14 on 2017-02-23.
*/
class StateGraphicComputerTest : BasicGameState() {
val computer = BaseTerrarumComputer(8)
val computer = TerrarumComputer(8)
val monitor = GraphicsTerminal(computer)
init {
@@ -30,7 +30,8 @@ class StateGraphicComputerTest : BasicGameState() {
override fun init(container: GameContainer?, game: StateBasedGame?) {
val vcard = (computer.getPeripheral("ppu") as PeripheralVideoCard).vram
(0..3).forEach { vcard.sprites[it].setPaletteSet(64,33,12,62) }
// it's a-me, Mario!
/*(0..3).forEach { vcard.sprites[it].setPaletteSet(64,33,12,62) }
vcard.sprites[0].setAll(intArrayOf(
0,0,0,0,0,1,1,1,
@@ -71,46 +72,18 @@ class StateGraphicComputerTest : BasicGameState() {
0,1,1,1,0,0,0,0,
0,0,2,2,2,0,0,0,
0,0,2,2,2,2,0,0
))
))*/
}
var angle = 0.0
override fun update(container: GameContainer, game: StateBasedGame?, delta: Int) {
Terrarum.appgc.setTitle("VT — F: ${container.fps}" +
" — M: ${Terrarum.memInUse}M / ${Terrarum.memTotal}M / ${Terrarum.memXmx}M")
" — M: ${Terrarum.memInUse}M / ${Terrarum.memTotal}M / ${Terrarum.memXmx}M" +
" ${Random().nextInt(100)}")
monitor.update(container, delta)
computer.update(container, delta)
val vcard = (computer.getPeripheral("ppu") as PeripheralVideoCard)
val sprites = vcard.vram.sprites
angle += delta / 1000.0
(0..3).forEach { vcard.vram.sprites[it].setPaletteSet(64,26,12,62) }
sprites[0].posX = (Math.cos(angle) * 80 + 100).roundInt() - 8
sprites[0].posY = (Math.sin(angle) * 0 + 100).roundInt() - 8
sprites[1].posX = (Math.cos(angle) * 80 + 100).roundInt()
sprites[1].posY = (Math.sin(angle) * 0 + 100).roundInt() - 8
sprites[2].posX = (Math.cos(angle) * 80 + 100).roundInt() - 8
sprites[2].posY = (Math.sin(angle) * 0 + 100).roundInt()
sprites[3].posX = (Math.cos(angle) * 80 + 100).roundInt()
sprites[3].posY = (Math.sin(angle) * 0 + 100).roundInt()
//sprite.pal0 = (sprite.pal0 + 1) % 65
//sprite.pal1 = (sprite.pal1 + 1) % 65
//sprite.pal2 = (sprite.pal2 + 1) % 65
//sprite.pal3 = (sprite.pal3 + 1) % 65
//kotlin.repeat(256) {
//vcard.vram.setBackgroundPixel(Random().nextInt(320), Random().nextInt(200), Random().nextInt(64))
//vcard.vram.setBackgroundPixel(Random().nextInt(320), Random().nextInt(200), 15)
//}
}
override fun getID() = Terrarum.STATE_ID_TEST_TTY
@@ -118,4 +91,8 @@ class StateGraphicComputerTest : BasicGameState() {
override fun render(container: GameContainer, game: StateBasedGame?, g: Graphics) {
monitor.render(container, g)
}
override fun keyPressed(key: Int, c: Char) {
monitor.keyPressed(key, c)
}
}