11 void set_vga_base(unsigned char* base);
12 void *vga_shm_get(void);
13 void vga_shm_free(void* addr);
14 void release_bus(void);
17 unsigned int ce :1; /*chip enable*/
18 unsigned int rw :1; /*assert on write.*/
19 unsigned int vblank :1; /*connected to nmi*/
23 unsigned int rd :1; /*read*/
24 unsigned int wr :1; /*write.*/
27 static struct ppu_cpu_pin ppu_pin;
28 static struct ppu_cart_pin cart_pin;
30 static unsigned short ppu_addr;
31 static unsigned char ppu_data;
33 static unsigned char* vga_shared_buf;
37 * ppucore r/w func ptr.
39 typedef void (ppu_write_t)(unsigned char);
40 typedef unsigned char (ppu_read_t)(void);
42 static void null_write(unsigned char);
43 static unsigned char null_read(void);
45 static ppu_write_t *ppucore_write_func[8] = {
56 static ppu_read_t *ppucore_read_func[8] = {
68 * JAPAN/US uses NTSC standard.
71 * ---------------------------------------------------------
72 * Frames per second 60
73 * Time per frame (milliseconds) 16.67
74 * Scanlines per frame (of which is V-Blank) 262 (20)
75 * CPU cycles per scanline 113.33
76 * Resolution 256 x 224
82 void set_ppu_addr(unsigned short addr) {
86 unsigned char get_ppu_data(void) {
90 void set_ppu_data(unsigned char data) {
98 void set_ppu_rw_pin(int rw) {
102 void set_ppu_ce_pin(int ce) {
104 //let ram i/o on the bus.
108 ppucore_write_func[ppu_addr](ppu_data);
112 ppu_data = ppucore_read_func[ppu_addr]();
119 static void null_write(unsigned char d){}
120 static unsigned char null_read(void){return 0;}
133 /* get vga shared memory */
134 if((vga_shared_buf = (unsigned char*)vga_shm_get()) == NULL)
136 fprintf(stderr, "error attaching shared memory.\n");
140 memset(vga_shared_buf, 0, VGA_SHM_SIZE);
141 set_vga_base((unsigned char*)vga_shared_buf);
143 ret = ppucore_init();
151 void clean_ppu(void) {
153 vga_shm_free(vga_shared_buf);