blob: b472d315a7950c243d95f79925acd0a43bbd33b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
|