/** * Split VBO into smaller pieces, draw the pieces. */ void vbo_split_copy( struct gl_context *ctx, const struct gl_client_array *arrays[], const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, vbo_draw_func draw, const struct split_limits *limits ) { struct copy_context copy; GLuint i; memset(©, 0, sizeof(copy)); /* Require indexed primitives: */ assert(ib); copy.ctx = ctx; copy.array = arrays; copy.prim = prim; copy.nr_prims = nr_prims; copy.ib = ib; copy.draw = draw; copy.limits = limits; /* Clear the vertex cache: */ for (i = 0; i < ELT_TABLE_SIZE; i++) copy.vert_cache[i].in = ~0; replay_init(©); replay_elts(©); replay_finish(©); }
/** * Split VBO into smaller pieces, draw the pieces. */ void vbo_split_copy( struct gl_context *ctx, const struct gl_client_array *arrays[], const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, vbo_draw_func draw, const struct split_limits *limits ) { struct copy_context copy; GLuint i, this_nr_prims; for (i = 0; i < nr_prims;) { /* Our SW TNL pipeline doesn't handle basevertex yet, so bind_indices * will rebase the elements to the basevertex, and we'll only * emit strings of prims with the same basevertex in one draw call. */ for (this_nr_prims = 1; i + this_nr_prims < nr_prims; this_nr_prims++) { if (prim[i].basevertex != prim[i + this_nr_prims].basevertex) break; } memset(©, 0, sizeof(copy)); /* Require indexed primitives: */ assert(ib); copy.ctx = ctx; copy.array = arrays; copy.prim = &prim[i]; copy.nr_prims = this_nr_prims; copy.ib = ib; copy.draw = draw; copy.limits = limits; /* Clear the vertex cache: */ for (i = 0; i < ELT_TABLE_SIZE; i++) copy.vert_cache[i].in = ~0; replay_init(©); replay_elts(©); replay_finish(©); } }
// 函数实现 BOOL nes_init(NES *nes, char *file, DWORD extra) { int *mirroring = NULL; int i = 0; log_init("DEBUGER"); // log init // clear it memset(nes, 0, sizeof(NES)); // extra data nes->extra = extra; // load cartridge first if (!cartridge_load(&(nes->cart), file)) { log_printf("failed to load nes rom file !\n"); } //++ cbus mem map ++// // create cpu ram nes->cram.type = MEM_RAM; nes->cram.size = NES_CRAM_SIZE; nes->cram.data = nes->cpu.cram; // create ppu regs nes->ppuregs.type = MEM_REG; nes->ppuregs.size = NES_PPUREGS_SIZE; nes->ppuregs.data = nes->ppu.regs; nes->ppuregs.r_callback = NES_PPU_REG_RCB; nes->ppuregs.w_callback = NES_PPU_REG_WCB; // create apu regs nes->apuregs.type = MEM_REG; nes->apuregs.size = NES_APUREGS_SIZE; nes->apuregs.data = nes->apu.regs; nes->apuregs.r_callback = NES_APU_REG_RCB; nes->apuregs.w_callback = NES_APU_REG_WCB; // create expansion rom nes->erom.type = MEM_ROM; nes->erom.size = NES_EROM_SIZE; nes->erom.data = nes->buf_erom; // create sram nes->sram.type = MEM_RAM; nes->sram.size = NES_SRAM_SIZE; nes->sram.data = nes->cart.buf_sram; // create PRG-ROM 0 nes->prom0.type = MEM_ROM; nes->prom0.size = NES_PRGROM_SIZE; // create PRG-ROM 1 nes->prom1.type = MEM_ROM; nes->prom1.size = NES_PRGROM_SIZE; // init nes cbus bus_setmem(nes->cbus, 0, 0xC000, 0xFFFF, &(nes->prom1 )); bus_setmem(nes->cbus, 1, 0x8000, 0xBFFF, &(nes->prom0 )); bus_setmem(nes->cbus, 2, 0x6000, 0x7FFF, &(nes->sram )); bus_setmem(nes->cbus, 3, 0x4020, 0x5FFF, &(nes->erom )); bus_setmem(nes->cbus, 4, 0x4000, 0x401F, &(nes->apuregs)); bus_setmem(nes->cbus, 5, 0x2000, 0x3FFF, &(nes->ppuregs)); bus_setmem(nes->cbus, 6, 0x0000, 0x1FFF, &(nes->cram )); //-- cbus mem map --// //++ pbus mem map ++// // create CHR-ROM0 nes->chrrom0.type = MEM_ROM; nes->chrrom0.size = NES_CHRROM_SIZE; // create CHR-ROM1 nes->chrrom1.type = MEM_ROM; nes->chrrom1.size = NES_CHRROM_SIZE; // create vram mirroring = cartridge_get_vram_mirroring(&(nes->cart)); for (i=0; i<4; i++) { nes->vram[i].type = MEM_RAM; nes->vram[i].size = NES_VRAM_SIZE; nes->vram[i].data = nes->buf_vram[mirroring[i]]; } // create color palette nes->palette.type = MEM_RAM; nes->palette.size = NES_PALETTE_SIZE; nes->palette.data = nes->ppu.palette; // init nes pbus bus_setmir(nes->pbus, 0, 0x3F20, 0x3FFF, 0x3F1F); bus_setmem(nes->pbus, 1, 0x3F00, 0x3F1F, &(nes->palette)); bus_setmir(nes->pbus, 2, 0x3000, 0x3EFF, 0x2FFF); bus_setmem(nes->pbus, 3, 0x2C00, 0x2FFF, &(nes->vram[3])); bus_setmem(nes->pbus, 4, 0x2800, 0x2BFF, &(nes->vram[2])); bus_setmem(nes->pbus, 5, 0x2400, 0x27FF, &(nes->vram[1])); bus_setmem(nes->pbus, 6, 0x2000, 0x23FF, &(nes->vram[0])); bus_setmem(nes->pbus, 7, 0x1000, 0x1FFF, &(nes->chrrom1)); bus_setmem(nes->pbus, 8, 0x0000, 0x0FFF, &(nes->chrrom0)); //-- pbus mem map --// // init mmc before cpu & ppu & apu, due to mmc will do bank switch // this will change memory mapping on cbus & pbus mmc_init(&(nes->mmc), &(nes->cart), nes->cbus, nes->pbus); // now it's time to init cpu & ppu & apu cpu_init(&(nes->cpu), nes->cbus ); ppu_init(&(nes->ppu), nes->extra, NULL); apu_init(&(nes->apu), nes->extra, NULL); ndb_init(&(nes->ndb), nes ); // init joypad joypad_init (&(nes->pad)); joypad_setkey(&(nes->pad), 0, NES_PAD_CONNECT, 1); joypad_setkey(&(nes->pad), 1, NES_PAD_CONNECT, 1); // init replay replay_init(&(nes->replay)); // create nes event & thread pthread_create(&(nes->thread_id), NULL, nes_thread_proc, nes); return TRUE; }
int main (int argc, char *argv[]) { int fd = -1; char *log_identity = argv[0]; int log_priority = LOG_INFO; int log_options = LOG_OPT_PRIORITY; #ifndef NDEBUG log_priority = LOG_DEBUG; log_options |= LOG_OPT_TIMESTAMP; #endif /* NDEBUG */ log_open_file (stderr, log_identity, log_priority, log_options); disable_core_dumps (); conf = create_conf (); parse_cmdline (conf, argc, argv); auth_recv_init (conf->auth_server_dir, conf->auth_client_dir, conf->got_force); if (!conf->got_foreground) { fd = daemonize_init (argv[0]); if (conf->got_syslog) { log_open_file (NULL, NULL, 0, 0); log_open_syslog (log_identity, LOG_DAEMON); } else { open_logfile (conf->logfile_name, log_priority, conf->got_force); } } handle_signals (); lookup_ip_addr (conf); write_pidfile (conf->pidfile_name, conf->got_force); if (conf->got_mlockall) { lock_memory (); } crypto_init (); if (random_init (conf->seed_name) < 0) { if (conf->seed_name) { free (conf->seed_name); conf->seed_name = NULL; } } create_subkeys (conf); conf->gids = gids_create (conf->gids_update_secs, conf->got_group_stat); replay_init (); timer_init (); sock_create (conf); if (!conf->got_foreground) { daemonize_fini (fd); } log_msg (LOG_NOTICE, "Starting %s daemon (pid %d)", META_ALIAS, (int) getpid ()); job_accept (conf); sock_destroy (conf); timer_fini (); replay_fini (); gids_destroy (conf->gids); random_fini (conf->seed_name); crypto_fini (); destroy_conf (conf); log_msg (LOG_NOTICE, "Stopping %s daemon (pid %d)", META_ALIAS, (int) getpid ()); exit (EMUNGE_SUCCESS); }