summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthe lemons <citrons@mondecitronne.com>2023-02-06 23:48:23 -0600
committerthe lemons <citrons@mondecitronne.com>2023-02-06 23:48:23 -0600
commit2f4f1462488a867dddae15802ba7dff94279fb9f (patch)
treec01fdd366cd1b79ff365fba0fcf58f4fcc60da70
parent0116b00e0334b692d662c065ec5d77df636b1bc5 (diff)
render checkerboard in unmapped areas
-rw-r--r--memview.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/memview.c b/memview.c
index 9acdd22..4491f05 100644
--- a/memview.c
+++ b/memview.c
@@ -16,12 +16,6 @@ struct viewer {
uint8_t page_buffer[PAGE_SIZE];
};
-enum color {
- BLACK = 0x00000000,
- WHITE = 0xFFFFFFFF,
- GREY = 0xFF303030,
-};
-
#define BIT_OF(X, I) (((X) >> (I)) & 1ULL)
static uintptr_t zorder(int x, int y) {
@@ -83,12 +77,13 @@ static void render_page(SDL_Texture *tex, uint8_t *data) {
for (int i = 0; i < PAGE_SIZE; i++) {
for (int j = 0; j < CHAR_BIT; j++) {
uint8_t bit = (data[i] >> j) & 1;
- pixels[i * CHAR_BIT + j] = bit ? WHITE : BLACK;
+ pixels[i * CHAR_BIT + j] = bit ? 0xFFFFFFFF : 0xFF000000;
}
}
} else {
for (int i = 0; i < PAGE_WIDTH * PAGE_HEIGHT; i++)
- pixels[i] = GREY;
+ pixels[i] =
+ ((i / 16) + i / PAGE_WIDTH / 16) % 2 ? 0xFF111111 : 0xFF333333;
}
SDL_UnlockTexture(tex);
}