diff options
| author | Peter Fors <peter.fors@mindkiller.com> | 2025-05-02 23:15:47 +0200 |
|---|---|---|
| committer | Peter Fors <peter.fors@mindkiller.com> | 2025-05-02 23:15:47 +0200 |
| commit | 5808f00555c48e1cc1cc110af6a5cd73ddf13010 (patch) | |
| tree | dff942b61441bafe297e7a99f0e799f32ae978b1 /mknes.h | |
| parent | 9463faa436e1b981ef72000568445a83682f2658 (diff) | |
cleanup and rewrite of ppu_registers.c
Diffstat (limited to 'mknes.h')
| -rw-r--r-- | mknes.h | 38 |
1 files changed, 18 insertions, 20 deletions
@@ -64,6 +64,10 @@ struct ppu_state { uint8_t secondary_oam[32]; uint8_t oam[256]; + uint8_t input[2]; // Controller 1 & 2 + uint8_t input_latch[2]; // Latched inputs after strobe + uint8_t input_bit[2]; // Current bit position being shifted out + uint8_t input_strobe; // Control bit (0 or 1) uint8_t frame_ready; } __attribute__((packed, aligned(64))); @@ -74,9 +78,10 @@ struct apu_state { uint8_t irq_pending; uint8_t dmc_dma_enabled; uint32_t dmc_sample_timer; -}; +} __attribute__((packed, aligned(64))); struct cpu_state { + size_t cycles; uint32_t pc; // Program Counter uint8_t sp; // Stack Pointer uint8_t a; // Accumulator @@ -91,42 +96,35 @@ struct cpu_state { uint8_t z; // Zero Flag uint8_t c; // Carry Flag // -- - uint8_t die; // KIL instruction found! -};// __attribute__((aligned(64))); + uint8_t irq_pending; + uint8_t nmi_pending; +} __attribute__((packed, aligned(64))); struct ines_state { - uint32_t mapper; - uint32_t submapper; + uint8_t mapper; + uint8_t submapper; uint8_t mirroring; // 0 = H, 1 = V, 2 = 4-screen uint32_t prg_size; uint32_t chr_size; -}; +} __attribute__((packed, aligned(64))); struct nes_state { - size_t cycles; - struct cpu_state cpu; - uint8_t irq_pending; - uint8_t nmi_pending; - uint8_t input[2]; // Controller 1 & 2 - uint8_t input_latch[2]; // Latched inputs after strobe - uint8_t input_bit[2]; // Current bit position being shifted out - uint8_t input_strobe; // Control bit (0 or 1) - // struct apu_state apu; struct ppu_state ppu; - - struct mapper_entry mapper; + struct mapper_functions mapper; union mapper_data map; struct ines_state ines; + struct cpu_state cpu; + // struct apu_state apu; - uint8_t *pixels; uint8_t *ram; uint8_t *ciram; - uint8_t *chr_ram; uint8_t *prg_rom; uint8_t *chr_rom; + uint8_t *chr_ram; + uint8_t *pixels; uint8_t *sram; -}; +} __attribute__((packed, aligned(64))); __attribute__((aligned(4096))) static uint32_t nes_palette[65] = { |
