summaryrefslogtreecommitdiff
path: root/mknes.h
diff options
context:
space:
mode:
authorPeter Fors <peter.fors@mindkiller.com>2025-05-24 15:45:54 +0200
committerPeter Fors <peter.fors@mindkiller.com>2025-05-24 15:45:54 +0200
commita8e0c141b0184d629504b9f0ee8dbc4fefb90934 (patch)
treecff0f7e64ce58dc8f1e4ff4501743d9b94449c94 /mknes.h
parente28ad1546509de31b706f0fd300a906e5bc55199 (diff)
3011fps
Diffstat (limited to 'mknes.h')
-rw-r--r--mknes.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/mknes.h b/mknes.h
index fba1406..c169140 100644
--- a/mknes.h
+++ b/mknes.h
@@ -1,10 +1,8 @@
-#define PPU_CTRL_NMI 0x80
#define PPU_CTRL_BG_TILE_SELECT 0x10
#define PPU_CTRL_SPRITE_TILE_SELECT 0x08
-#define PPU_CTRL_VRAM_INCREMENT 0x04
// Define constants for PPU control and mask bits
#define PPU_CTRL_NMI 0x80
@@ -44,12 +42,9 @@ struct ppu_state {
uint8_t reg_status;
uint8_t write_latch;
-
uint8_t vram_read_buffer;
-
uint8_t open_bus;
-
uint8_t sprite_zero_hit_possible;
uint8_t sprite_count;
uint8_t palette[32];
@@ -82,7 +77,7 @@ struct apu_state {
struct cpu_state {
size_t cycles;
- uint32_t pc; // Program Counter
+ uint16_t pc; // Program Counter
uint8_t sp; // Stack Pointer
uint8_t a; // Accumulator
uint8_t x; // X Register
@@ -112,9 +107,10 @@ struct ines_state {
struct nes_state {
struct ppu_state ppu;
struct mapper_functions mapper;
- union mapper_data map;
- struct ines_state ines;
+ // union mapper_data map;
+ char map[sizeof(union mapper_data)] __attribute__((aligned(64))); // NOTE(peter): Only way due to aliasing rules in the C standard.
struct cpu_state cpu;
+ struct ines_state ines;
// struct apu_state apu;
uint8_t ram[RAM_SIZE] __attribute__((aligned(4096)));
@@ -134,5 +130,6 @@ __attribute__((aligned(4096))) static uint32_t nes_palette[65] = {
0xffffffff, 0x51a5feff, 0x8084feff, 0xbc6afeff, 0xf15bfeff, 0xfe5ec4ff, 0xfe7269ff, 0xe19321ff,
0xadb600ff, 0x79d300ff, 0x51df21ff, 0x3ad974ff, 0x39c3dfff, 0x424242ff, 0x000000ff, 0x000000ff,
0xffffffff, 0xb5d9feff, 0xcacafeff, 0xe3befeff, 0xf9b8feff, 0xfebae7ff, 0xfec3bcff, 0xf4d199ff,
- 0xdee086ff, 0xc6ec87ff, 0xb2f29dff, 0xa7f0c3ff, 0xa8e7f0ff, 0xacacacff, 0x000000ff, 0x000000ff, 0xffffffff
+ 0xdee086ff, 0xc6ec87ff, 0xb2f29dff, 0xa7f0c3ff, 0xa8e7f0ff, 0xacacacff, 0x000000ff, 0x000000ff,
+ 0xffffffff // one extra for debug-coloring...
};