OSDN Git Service

[General] Convert sourcecode's CRLF format: DOS(WINDOWS) to Unix, to apply patches...
[csp-qt/common_source_project-fm7.git] / source / src / vm / familybasic / ppu.h
1 /*
2         Nintendo Family BASIC Emulator 'eFamilyBASIC'
3
4         Origin : nester
5         Author : Takeda.Toshiya
6         Date   : 2010.08.11-
7
8         [ PPU ]
9 */
10
11 #ifndef _PPU_H_
12 #define _PPU_H_
13
14 #include "../vm.h"
15 #include "../../emu.h"
16 #include "../device.h"
17
18 class PPU : public DEVICE
19 {
20 private:
21         DEVICE *d_cpu;
22         
23         scrntype palette_pc[64];
24         uint8 screen[240][256 + 16];    // 2*8 = side margin
25         uint8 solid_buf[512];
26         
27         uint8* banks[16];
28         uint8 header[16];
29         uint8 chr_rom[0x2000];
30         uint8 name_tables[0x1000];
31         uint8 spr_ram[0x100];
32         uint8 bg_pal[0x10];
33         uint8 spr_pal[0x10];
34         uint8 spr_ram_rw_ptr;
35         
36         uint8 regs[8];
37         uint16 bg_pattern_table_addr;
38         uint16 spr_pattern_table_addr;
39         uint16 ppu_addr_inc;
40         uint8 rgb_bak;
41         bool toggle_2005_2006;
42         uint8 read_2007_buffer;
43         
44         uint16 loopy_v;
45         uint16 loopy_t;
46         uint8 loopy_x;
47         
48         void render_scanline(int v);
49         void render_bg(int v);
50         void render_spr(int v);
51         void update_palette();
52         
53 public:
54         PPU(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) {}
55         ~PPU() {}
56         
57         // common functions
58         void initialize();
59         void reset();
60         void write_data8(uint32 addr, uint32 data);
61         uint32 read_data8(uint32 addr);
62         void event_vline(int v, int clock);
63         
64         // unique function
65         void set_context_cpu(DEVICE* device)
66         {
67                 d_cpu = device;
68         }
69         uint8 *get_spr_ram()
70         {
71                 return spr_ram;
72         }
73         void load_rom_image(_TCHAR *file_name);
74         void draw_screen();
75 };
76
77 #endif