| @@ -222,12 +222,7 @@ static inline int f6502_write(nes_Memory* mem, | |||||
| // Copy to render reference | // Copy to render reference | ||||
| addr &= 0x1FU; | addr &= 0x1FU; | ||||
| uint8_t* pal = mem->ppu.palette; | uint8_t* pal = mem->ppu.palette; | ||||
| if (0 == (addr & 0x3)) { | |||||
| // TODO: Just initialize this | |||||
| pal[0] = pal[4] = pal[8] = pal[12] = | |||||
| pal[16] = pal[20] = pal[24] = | |||||
| pal[28] = 0xFFU; | |||||
| } else { | |||||
| if (0 != (addr & 0x3)) { | |||||
| pal[addr] = val & 0x3FU; | pal[addr] = val & 0x3FU; | ||||
| } | } | ||||
| @@ -42,11 +42,5 @@ static inline uint8_t* prg_rom_page(nes_Memory* mem, int page) { | |||||
| return &mem->rom[page * NES_PRG_ROM_PAGE_SIZE]; | return &mem->rom[page * NES_PRG_ROM_PAGE_SIZE]; | ||||
| } | } | ||||
| static inline uint8_t* prg_rom_last_page(nes_Memory* mem, int page) { | |||||
| // TODO: Where's 0x2000U from? | |||||
| return &mem->rom[ (mem->n_rom_banks * NES_PRG_ROM_PAGE_SIZE) - | |||||
| ((page + 1) * 0x2000U)]; | |||||
| } | |||||
| #endif // NESE_MEMORY_H_ | #endif // NESE_MEMORY_H_ | ||||
| @@ -9,7 +9,7 @@ | |||||
| void nes_init(nes* sys) { | void nes_init(nes* sys) { | ||||
| f6502_init(&sys->core); | f6502_init(&sys->core); | ||||
| // TODO: Init PPU | |||||
| nes_ppu_init(&sys->ppu, &sys->core.memory.ppu); | |||||
| // TODO: Init APU | // TODO: Init APU | ||||
| } | } | ||||
| @@ -107,6 +107,7 @@ static int nes_hsync(nes* sys, void* plat) { | |||||
| } | } | ||||
| #define mapper_hsync_dot (300U) | #define mapper_hsync_dot (300U) | ||||
| #define render_dot (256U) | |||||
| int nes_loop(nes* sys, void* plat) { | int nes_loop(nes* sys, void* plat) { | ||||
| int status = 0; | int status = 0; | ||||
| @@ -11,7 +11,6 @@ typedef struct { | |||||
| const ines_Header* cart_header; | const ines_Header* cart_header; | ||||
| f6502_Core core; | f6502_Core core; | ||||
| nes_PPU ppu; | nes_PPU ppu; | ||||
| // TODO: PPU | |||||
| // TODO: APU | // TODO: APU | ||||
| } nes; | } nes; | ||||
| @@ -6,6 +6,14 @@ | |||||
| #include "log.h" | #include "log.h" | ||||
| void nes_ppu_init(nes_PPU* ppu, nes_PPU_Memory* mem) { | |||||
| uint8_t* pal = mem->palette; | |||||
| pal[0] = pal[4] = pal[8] = pal[12] = | |||||
| pal[16] = pal[20] = pal[24] = | |||||
| pal[28] = 0xFFU; | |||||
| } | |||||
| static const uint8_t mirror_schemes[][4] = { | static const uint8_t mirror_schemes[][4] = { | ||||
| [nes_Mirror_Horizontal] = {0, 0, 1, 1}, | [nes_Mirror_Horizontal] = {0, 0, 1, 1}, | ||||
| [nes_Mirror_Vertical] = {0, 1, 0, 1}, | [nes_Mirror_Vertical] = {0, 1, 0, 1}, | ||||
| @@ -136,6 +136,8 @@ typedef struct { | |||||
| uint8_t screen_data[nes_ppu_render_w * nes_ppu_render_h]; | uint8_t screen_data[nes_ppu_render_w * nes_ppu_render_h]; | ||||
| } nes_PPU; | } nes_PPU; | ||||
| void nes_ppu_init(nes_PPU*, nes_PPU_Memory*); | |||||
| void nes_ppu_find_hit_line(nes_PPU*, nes_PPU_Memory*); | void nes_ppu_find_hit_line(nes_PPU*, nes_PPU_Memory*); | ||||
| void nes_ppu_render_line(nes_PPU*, nes_PPU_Memory*); | void nes_ppu_render_line(nes_PPU*, nes_PPU_Memory*); | ||||