diff options
| author | Peter Fors <peter.fors@mindkiller.com> | 2025-06-08 17:32:05 +0200 |
|---|---|---|
| committer | Peter Fors <peter.fors@mindkiller.com> | 2025-06-08 17:32:05 +0200 |
| commit | 412b2ef851516c1de8ba5006ddd284192cbcaf9b (patch) | |
| tree | e8b68d60125bf89e375ec9acc4e7833825abbfaa /mknes.c | |
| parent | 6dd73982c514445c4d2a4787c37666d0812a3dad (diff) | |
tests
Diffstat (limited to 'mknes.c')
| -rw-r--r-- | mknes.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -7,6 +7,9 @@ #include <math.h> #include <string.h> #include <immintrin.h> +#include <sys/mman.h> +#include <sys/stat.h> /* For mode constants */ +#include <fcntl.h> /* For O_* constants */ #define BUFFER_WIDTH 256 #define BUFFER_HEIGHT 240 @@ -67,7 +70,7 @@ struct main_state { uint8_t toggle_crt_emulation; }; -struct main_state state; +struct main_state state __attribute__((aligned(64))); uint32_t buffer[BUFFER_WIDTH * BUFFER_HEIGHT] __attribute__((section(".bss"), aligned(4096))); uint32_t display_buffer[BUFFER_WIDTH * BUFFER_HEIGHT] __attribute__((section(".bss"), aligned(4096))); @@ -116,7 +119,16 @@ int main(int argc, char **argv) { init_opcode_ud_lut(); // protect_opcode_lut(); +#if DEBUG_SHARED_MEM + // int fd = shm_open("/mknes_dbg", O_CREAT | O_RDWR, 0666); + // ftruncate(fd, sizeof(struct nes_state)); + // struct nes_state *nstate = mmap(0, sizeof(struct nes_state), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + // close(fd); +#else + // struct nes_state *nstate = mmap(0, sizeof(struct nes_state), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); struct nes_state *nstate = aligned_alloc(4096, (sizeof(struct nes_state) + 4095) & ~4095); + memset(nstate, 0, sizeof(struct nes_state)); +#endif ppu_reset(nstate); // ines2_load(nstate, "data/0000/10-Yard Fight (USA, Europe).nes"); @@ -142,7 +154,7 @@ int main(int argc, char **argv) { // ines2_load(nstate, "data/0000/raster_demos/RasterTest3e.NES"); // ines2_load(nstate, "data/0000/NEStress.NES"); // ines2_load(nstate, "data/0000/Super Mario Bros. (World) (HVC-SM).zip"); - ines2_load(nstate, "data/0042/Super Mario Bros. + Duck Hunt (USA).zip"); + // ines2_load(nstate, "data/0042/Super Mario Bros. + Duck Hunt (USA).zip"); // ines2_load(nstate, "data/0000/Xevious - The Avenger (USA).zip"); // ines2_load(nstate, "data/tv.nes"); |
