summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraven <citrons@mondecitronne.com>2026-04-11 19:41:05 -0500
committerraven <citrons@mondecitronne.com>2026-04-11 19:41:05 -0500
commitc62bef0fc853750fb23d1a610b26fed48bbcd1f0 (patch)
tree507d6a3ba1e9e1428e045dc63a8d7285e9fb4f9e
parentf6c30f0acf44969646b2c895bd2672c0ebc85d66 (diff)
transpose bytes
-rw-r--r--src/memory.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/memory.c b/src/memory.c
index 373ca27..23c6350 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -16,8 +16,7 @@ uintptr_t to_addr(int x, int y) {
memcpy(&ux, &x, sizeof(unsigned int));
memcpy(&uy, &y, sizeof(unsigned int));
uintptr_t page = zorder(ux / PAGE_WIDTH, uy / PAGE_HEIGHT);
- int offset =
- x % PAGE_WIDTH / CHAR_BIT + y % PAGE_HEIGHT * PAGE_WIDTH / CHAR_BIT;
+ int offset = x % PAGE_WIDTH / CHAR_BIT * PAGE_HEIGHT + y % PAGE_HEIGHT;
return page * PAGE_SIZE + offset;
}
@@ -102,9 +101,16 @@ SDL_Texture *get_texture(page *p) {
}
uint32_t hash = fnv(data, PAGE_SIZE);
if (p->hash != hash) {
+ static char pixels[PAGE_SIZE];
+ for (int col = 0; col < PAGE_WIDTH / 8; col++) {
+ for (int row = 0; row < PAGE_HEIGHT; row++) {
+ pixels[row * PAGE_WIDTH / 8 + col] =
+ data[col * PAGE_HEIGHT + row];
+ }
+ }
if (p->tex) SDL_DestroyTexture(p->tex);
SDL_Surface *surface = must(SDL_CreateSurfaceFrom(
- PAGE_WIDTH, PAGE_HEIGHT, SDL_PIXELFORMAT_INDEX1LSB, data,
+ PAGE_WIDTH, PAGE_HEIGHT, SDL_PIXELFORMAT_INDEX1LSB, pixels,
PAGE_WIDTH / 8
));
p->tex = must(SDL_CreateTextureFromSurface(renderer, surface));