Esempio n. 1
0
void nes_free(NES *nes)
{
    // disable ndb debugging will make cpu keep running
    ndb_set_debug(&(nes->ndb), NDB_DEBUG_MODE_DISABLE);

    // destroy nes thread
    nes->thread_exit = TRUE;
    pthread_join(nes->thread_id, NULL);

    // free replay
    replay_free(&(nes->replay));

    // free joypad
    joypad_setkey(&(nes->pad), 0, NES_PAD_CONNECT, 0);
    joypad_setkey(&(nes->pad), 1, NES_PAD_CONNECT, 0);
    joypad_free  (&(nes->pad ));

    // free cpu & ppu & apu & mmc
    cpu_free(&(nes->cpu));
    ppu_free(&(nes->ppu));
    apu_free(&(nes->apu));
    mmc_free(&(nes->mmc));
    ndb_free(&(nes->ndb));

    // free cartridge
    cartridge_free(&(nes->cart));

    log_done(); // log done
}
Esempio n. 2
0
void nes_free(NES *nes)
{
    // destroy nes event & thread
    nes->bExitThread = TRUE;
    SetEvent(nes->hNesEvent);
    WaitForSingleObject(nes->hNesThread, -1);
    CloseHandle(nes->hNesEvent );
    CloseHandle(nes->hNesThread);

    cpu_free      (&(nes->cpu));
    ppu_free      (&(nes->ppu));
    apu_free      (&(nes->apu));
    mmc_free      (&(nes->mmc));
    joypad_setkey (&(nes->pad), 0, NES_PAD_CONNECT, 0);
    joypad_setkey (&(nes->pad), 1, NES_PAD_CONNECT, 0);
    joypad_free   (&(nes->pad )); // free joypad
    cartridge_free(&(nes->cart)); // free cartridge

    log_done();
}