feat: add micro mem view
This commit is contained in:
parent
91828eaa3e
commit
286222b681
1 changed files with 19 additions and 0 deletions
19
orao/micro_mem_view.py
Normal file
19
orao/micro_mem_view.py
Normal 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))
|
Loading…
Reference in a new issue