ChocolateBird/scripts/loaders/gba/graphics.gd

16 lines
413 B
GDScript3
Raw Normal View History

2023-07-31 23:33:05 +09:30
const INDEX_FORMAT := globals.INDEX_FORMAT
static func ByteArray(size: int) -> PoolByteArray:
var arr := PoolByteArray()
arr.resize(size)
return arr
static func _4bpp_to_tile(data: PoolByteArray) -> Image:
var tdata := ByteArray(64)
for i in range(32):
tdata[i*2] = data[i] % 16
tdata[i*2+1] = data[i] / 16
var tile := Image.new()
tile.create_from_data(8, 8, false, INDEX_FORMAT, tdata)
return tile