feat: add micro mem view

This commit is contained in:
shokre 2021-09-16 17:27:22 +02:00
parent 91828eaa3e
commit 286222b681

19
orao/micro_mem_view.py Normal file
View file

@ -0,0 +1,19 @@
import pygame
import numpy
palette = []
# below chars
palette += [(i * 8, 0, 0) for i in range(32)]
# text chars
palette += [(i * 2, 255, 0) for i in range(128 - 32)]
# other
palette += [(i * 2, 0, 255) for i in range(128)]
micro_mem_view_dims = (32, 192)
micro_mem_view = pygame.Surface(micro_mem_view_dims, depth=8)
micro_mem_view.set_palette(palette)
def store_mem_view(memory):
w, h = micro_mem_view_dims
arr = numpy.reshape(memory[0:(w * h)], (h, w))
pygame.surfarray.blit_array(micro_mem_view, numpy.transpose(arr))