Refactor rewind functionality with circular buffer, update BufferedImageData handling in DisplayView, enhance ConsoleView rendering updates, and integrate SnakeCode data.

This commit is contained in:
2025-08-17 20:32:12 +02:00
parent f169dce339
commit 37691dc7fa
15 changed files with 4916 additions and 4854 deletions

View File

@@ -3,7 +3,7 @@ package mtmc.emulator
import kotlin.math.min
class MTMCDisplay(private val computer: MonTanaMiniComputer) {
private val buffer: BufferedImage? = null
val buffer: BufferedImage = createCanvasImage(COLS, ROWS)
private var currentColor: DisplayColor? = null
private var graphics: Array<BufferedImage> = arrayOf()
private var byteArray: ByteArray = ByteArray(0)
@@ -107,11 +107,11 @@ class MTMCDisplay(private val computer: MonTanaMiniComputer) {
}
fun setPixel(col: Int, row: Int, color: DisplayColor) {
buffer?.setRGB(col, row, color.intVal)
buffer.setRGB(col, row, color.intVal)
}
fun getPixel(col: Int, row: Int): Short {
val rgb = buffer?.getRGB(col, row) ?: 0
val rgb = buffer.getRGB(col, row)
return DisplayColor.indexFromInt(rgb)
}
@@ -123,10 +123,11 @@ class MTMCDisplay(private val computer: MonTanaMiniComputer) {
}
fun drawRectangle(startCol: Short, startRow: Short, width: Short, height: Short) {
// val graphics = buffer.getGraphics()
// graphics.setColor(currentColor!!.javaColor)
// graphics.fillRect(startCol.toInt(), startRow.toInt(), width.toInt(), height.toInt())
// graphics.dispose()
for (x in startCol..<startCol + width) {
for (y in startRow..<startRow + height) {
setPixel(x, y, currentColor!!)
}
}
}
fun drawImage(image: Int, x: Int, y: Int) {