From 8c82be43720d9e221a9e2541c9ff6151015838bb Mon Sep 17 00:00:00 2001 From: Peter Fors Date: Fri, 4 Apr 2025 01:03:19 +0200 Subject: move read/write prg/chr/cirom data to mapper --- mknes.h | 46 ++++++++-------------------------------------- 1 file changed, 8 insertions(+), 38 deletions(-) (limited to 'mknes.h') diff --git a/mknes.h b/mknes.h index be2d946..ed22652 100644 --- a/mknes.h +++ b/mknes.h @@ -1,33 +1,16 @@ - -// #define PPU_CTRL_NMI_ENABLE 0x80 -// #define PPU_CTRL_MASTER_SLAVE 0x40 -// #define PPU_CTRL_SPRITE_HEIGHT 0x20 -// #define PPU_CTRL_BG_TILE_SELECT 0x10 -// #define PPU_CTRL_SPRITE_TILE_SELECT 0x08 -// #define PPU_CTRL_NT_SELECT_Y 0x04 -// #define PPU_CTRL_NT_SELECT_X 0x02 -// #define PPU_CTRL_VRAM_INCREMENT 0x01 - -// #define PPU_MASK_SHOW_BG 0x08 -// #define PPU_MASK_SHOW_SPRITES 0x10 - -// #define PPU_STATUS_VBLANK 0x80 -// #define PPU_STATUS_SPRITE0_HIT 0x40 -// #define PPU_STATUS_OVERFLOW 0x20 - +#define PPU_CTRL_NMI 0x80 #define PPU_CTRL_BG_TILE_SELECT 0x10 #define PPU_CTRL_SPRITE_TILE_SELECT 0x08 -#define PPU_CTRL_NMI 0x80 #define PPU_CTRL_VRAM_INCREMENT 0x04 // Define constants for PPU control and mask bits #define PPU_CTRL_NMI 0x80 -#define PPU_CTRL_VRAM_INCREMENT 0x04 #define PPU_CTRL_SPRITE_HEIGHT 0x20 #define PPU_CTRL_SPRITE_TILE 0x08 +#define PPU_CTRL_VRAM_INCREMENT 0x04 #define PPU_MASK_SHOW_BG 0x08 #define PPU_MASK_SHOW_SPRITES 0x10 @@ -37,11 +20,6 @@ #define MIRROR_VERTICAL 1 #define MIRROR_FOURSCREEN 2 - -struct nes_state; - - - struct ppu_state { uint8_t pixels[256 * 240]; @@ -64,6 +42,8 @@ struct ppu_state { uint8_t vram_read_buffer; uint8_t write_latch; + uint8_t open_bus; + uint8_t palette[0x20]; uint32_t scanline; @@ -118,17 +98,6 @@ struct ines_state { uint32_t chr_size; }; -struct mapper { - void (*init)(struct nes_state *state); - uint8_t (*read)(struct nes_state *state, uint32_t addr); - void (*write)(struct nes_state *state, uint32_t addr, uint8_t value); - void (*tick)(struct nes_state *state); -}; - -union mapper_data { - struct mapper_066 m066; -}; - struct nes_state { struct ines_state ines; struct cpu_state cpu; @@ -141,11 +110,12 @@ struct nes_state { uint8_t ram[0x800]; uint8_t sram[0x2000]; uint8_t ciram[0x1000]; // NOTE(peter): Originally 0x800 bytes, but extended as it should work for up to fourway, this is optimization, reality is 2kb, but there is no side-effects, so this is fine! - uint8_t rom[4 * 1024 * 1024]; - uint8_t chrrom[4 * 1024 * 1024]; + uint8_t prg_rom[4 * 1024 * 1024]; + uint8_t chr_rom[4 * 1024 * 1024]; }; -static uint32_t nes_palette[64] = { + +__attribute__((aligned(4096))) static uint32_t nes_palette[64] = { 0x585858ff, 0x00237cff, 0x0d1099ff, 0x300092ff, 0x4f006cff, 0x600035ff, 0x5c0500ff, 0x461800ff, 0x272d00ff, 0x093e00ff, 0x004500ff, 0x004106ff, 0x003545ff, 0x000000ff, 0x000000ff, 0x000000ff, 0xa1a1a1ff, 0x0b53d7ff, 0x3337feff, 0x6621f7ff, 0x9515beff, 0xac166eff, 0xa62721ff, 0x864300ff, -- cgit v1.2.3