| 1 |
struct PPU : Thread, public PPUcounter { |
| 2 |
uint8 vram[128 * 1024]; |
| 3 |
uint8 oam[544]; |
| 4 |
uint8 cgram[512]; |
| 5 |
|
| 6 |
enum : bool { Threaded = true }; |
| 7 |
alwaysinline void step(unsigned clocks); |
| 8 |
alwaysinline void synchronize_cpu(); |
| 9 |
|
| 10 |
#include "memory/memory.hpp" |
| 11 |
#include "mmio/mmio.hpp" |
| 12 |
#include "render/render.hpp" |
| 13 |
|
| 14 |
uint32* surface; |
| 15 |
uint32* output; |
| 16 |
|
| 17 |
unsigned ppu1_version = 1; |
| 18 |
unsigned ppu2_version = 3; |
| 19 |
|
| 20 |
static void Enter(); |
| 21 |
void add_clocks(unsigned clocks); |
| 22 |
|
| 23 |
uint8 region; |
| 24 |
unsigned line; |
| 25 |
|
| 26 |
enum { NTSC = 0, PAL = 1 }; |
| 27 |
enum { BG1 = 0, BG2 = 1, BG3 = 2, BG4 = 3, OAM = 4, BACK = 5, COL = 5 }; |
| 28 |
enum { SC_32x32 = 0, SC_64x32 = 1, SC_32x64 = 2, SC_64x64 = 3 }; |
| 29 |
|
| 30 |
struct { |
| 31 |
bool interlace; |
| 32 |
bool overscan; |
| 33 |
} display; |
| 34 |
|
| 35 |
struct { |
| 36 |
//$2101 |
| 37 |
uint8 oam_basesize; |
| 38 |
uint8 oam_nameselect; |
| 39 |
uint16 oam_tdaddr; |
| 40 |
|
| 41 |
//$210d-$210e |
| 42 |
uint16 m7_hofs, m7_vofs; |
| 43 |
|
| 44 |
//$211b-$2120 |
| 45 |
uint16 m7a, m7b, m7c, m7d, m7x, m7y; |
| 46 |
} cache; |
| 47 |
|
| 48 |
alwaysinline bool interlace() const { return display.interlace; } |
| 49 |
alwaysinline bool overscan() const { return display.overscan; } |
| 50 |
alwaysinline bool hires() const { return (regs.pseudo_hires || regs.bg_mode == 5 || regs.bg_mode == 6); } |
| 51 |
|
| 52 |
uint16 mosaic_table[16][4096]; |
| 53 |
void render_line(); |
| 54 |
|
| 55 |
void update_oam_status(); |
| 56 |
//required functions |
| 57 |
void scanline(); |
| 58 |
void render_scanline(); |
| 59 |
void frame(); |
| 60 |
void enter(); |
| 61 |
void enable(); |
| 62 |
void power(); |
| 63 |
void reset(); |
| 64 |
|
| 65 |
bool layer_enabled[5][4]; |
| 66 |
void layer_enable(unsigned layer, unsigned priority, bool enable); |
| 67 |
unsigned frameskip; |
| 68 |
unsigned framecounter; |
| 69 |
void set_frameskip(unsigned frameskip); |
| 70 |
|
| 71 |
void serialize(serializer&); |
| 72 |
PPU(); |
| 73 |
~PPU(); |
| 74 |
}; |
| 75 |
|
| 76 |
extern PPU ppu; |