diff options
| author | raven <citrons@mondecitronne.com> | 2026-04-08 22:51:39 -0500 |
|---|---|---|
| committer | raven <citrons@mondecitronne.com> | 2026-04-08 22:51:39 -0500 |
| commit | 18a86e1038b20cb6f8922beead08dcc24ba2a4d3 (patch) | |
| tree | 85cb74210d67d42763a4709d18af93aa60a8f400 /src/memory.h | |
| parent | 4a3429a96b5b5ea7468540349aeb4535d5738053 (diff) | |
rewrite and port to SDL3
Diffstat (limited to 'src/memory.h')
| -rw-r--r-- | src/memory.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/memory.h b/src/memory.h new file mode 100644 index 0000000..b472d31 --- /dev/null +++ b/src/memory.h @@ -0,0 +1,44 @@ +#ifndef MEMORY_H +#define MEMORY_H + +#include <stdlib.h> +#include <stdint.h> +#include <limits.h> +#include <stdbool.h> +#include <SDL3/SDL.h> + +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif + +#ifndef PAGE_WIDTH +#define PAGE_WIDTH 256 +#endif +#define PAGE_HEIGHT (PAGE_SIZE * CHAR_BIT / PAGE_WIDTH) + +typedef struct page { + struct page_list *l; + uintptr_t address; + SDL_Texture *tex; + uint64_t hash; + bool in_use; + struct page *next; +} page; + +typedef struct page_list { + int fd; + page *first; +} page_list; + +uintptr_t to_addr(int x, int y); +void to_pos(uintptr_t addr, int *x, int *y); + +int init_page_list(page_list *l, int fd); +page *get_page(page_list *l, uintptr_t addr); +void free_unused_pages(page_list *l); +SDL_Texture *get_texture(page *p); +void free_page_list(page_list *l); + +void draw_line(page_list *l, + double x1, double y1, double x2, double y2, bool bit); +#endif |
