making room for larger tile ID to accomodate subtiling

This commit is contained in:
minjaesong
2024-08-19 02:52:32 +09:00
parent e18f6512bc
commit 88680fb0fc
3 changed files with 89 additions and 78 deletions

View File

@@ -3,17 +3,17 @@ package net.torvald.unsafe
/**
* Created by minjaesong on 2024-07-22.
*/
class UnsafeInt2D(width: Int, height: Int) {
class UnsafeLong2D(width: Int, height: Int) {
val width = width.toLong()
val height = height.toLong()
private val ptr = UnsafeHelper.allocate(4L * width * height)
private val ptr = UnsafeHelper.allocate(8L * width * height)
private inline fun toIndex(y: Int, x: Int) = width * y + x
operator fun set(y: Int, x: Int, value: Int) = ptr.setInt(toIndex(y, x), value)
operator fun get(y: Int, x: Int) = ptr.getInt(toIndex(y, x))
operator fun set(y: Int, x: Int, value: Long) = ptr.setLong(toIndex(y, x), value)
operator fun get(y: Int, x: Int) = ptr.getLong(toIndex(y, x))
fun destroy() = ptr.destroy()
val destroyed: Boolean