void system_reset(void) { sms_reset(); pio_reset(); vdp_reset(); render_reset(); sound_reset(); system_manage_sram(cart.sram, SLOT_CART, SRAM_LOAD); }
void system_reset(void) { SoftResetCount = 0; Cart_Reset(); sms_reset(); pio_reset(); vdp_reset(); render_reset(); SMS_SoundReset(); }
void system_reset(void) { cpu_reset(); vdp_reset(); sms_reset(); render_reset(); system_load_sram(); if(snd.enabled) { OPLL_reset(opll) ; OPLL_reset_patch(opll,0) ; /* if use default voice data. */ } }
int main(int argc, char** argv) { auint j; auint t; auint cdi = 0U; auint auc = 0U; uint16* lpt; uint16* rpt; uint16 edt; /* Event data (just one) */ auint mid; /* Mouse device id */ SDL_Event event; /* The event got from the queue */ rrpge_object_t* emu = NULL; /* Init message */ printf("\n"); printf("%s", main_appname); printf("\n\n"); printf("%s", main_appauth); printf("%s", main_copyrig); printf("\n"); /* Check arguments: need an application */ if (argc <= 1){ printf("Error: need an application to run as parameter!\n"); exit(1); }else{ printf("Opening %s...\n", argv[1]); main_app = fopen(argv[1], "rb"); if (main_app == NULL){ perror("Failed to open file"); exit(1); } } /* Initialize emulator library */ rrpge_init_lib(&main_malloc, &free); /* Attempt to initialize the emulator. Note that the app. binary load ** callback is blocking, so no need to implement any waiting here using ** rrpge_init_run(). */ emu = rrpge_new_emu(&main_cbpack); if (emu == NULL){ printf("Failed to allocate emulator state\n"); goto loadfault; } t = rrpge_init_run(emu, RRPGE_INI_RESET); if (t != RRPGE_ERR_OK){ printf("Failed to initialize emulator\n"); main_printrerr(t); goto loadfault; } mid = rrpge_dev_add(emu, RRPGE_DEV_POINT); /* Add mouse (pointing device) */ /* Initialize renderer */ render_reset(emu); /* Initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)!=0) return -1; /* Try to set up the screen */ if (screen_set()!=0) return -1; SDL_WM_SetCaption(main_appname, main_appicon); /* Set up audio */ if (audio_set(2048U) != 0U) return -1; /* OK, let's go! */ printf("Entering emulation\n"); /* The main loop: It is more straightforward to exit from it with a suitable ** break at the proper place */ while(1){ /* Wait for some event... */ if (SDL_WaitEvent(&event)==0) return -1; /*Error?*/ /* An event is here: do something about it! */ if (event.type==SDL_USEREVENT){ if (event.user.code==AUDIO_EVENT){ t = 0U; /* No halt */ while (audio_needservice()){ /* Waiting for audio data from emulator */ do{ j = rrpge_run(emu, RRPGE_RUN_FREE); t = rrpge_gethaltcause(emu); if (t & RRPGE_HLT_AUDIO){ cdi++; } if (cdi >= 10){ cdi = 0U; printf("Audio events: %08d\n", auc); printf("Cycles: %08d\n", j); main_printstats(emu); main_printhalt(t); } /* Need proper exit point... */ }while ((t & (RRPGE_HLT_AUDIO | RRPGE_HLT_EXIT | RRPGE_HLT_STACK | RRPGE_HLT_INVKCALL | RRPGE_HLT_INVOP | RRPGE_HLT_FAULT | RRPGE_HLT_DETACHED | RRPGE_HLT_WAIT)) == 0U); if ((t & RRPGE_HLT_AUDIO) != 0U){ /* Audio data produced by emulator */ audio_getbufptrs(&lpt, &rpt); rrpge_getaudio(emu, lpt, rpt); auc++; } if ((t & (RRPGE_HLT_EXIT | RRPGE_HLT_STACK | RRPGE_HLT_INVKCALL | RRPGE_HLT_INVOP | RRPGE_HLT_FAULT | RRPGE_HLT_DETACHED | RRPGE_HLT_WAIT)) != 0U){ /* Errors & Exit */ break; } } /* End of audio wait loop */ if ((t & RRPGE_HLT_EXIT) != 0U){ break; } /* Exit program */ if ((t & (RRPGE_HLT_STACK | RRPGE_HLT_INVKCALL | RRPGE_HLT_INVOP | RRPGE_HLT_FAULT | RRPGE_HLT_DETACHED | RRPGE_HLT_WAIT)) != 0U){ main_errexit(t, emu); break; /* Also exit, with error */ } } }else if (event.type==SDL_KEYDOWN){ /* Some key was pressed. Which? */ if (event.key.keysym.sym==SDLK_ESCAPE) break; /* Exit program */ }else if (event.type==SDL_KEYUP){ }else if (event.type==SDL_QUIT){ /* Exit program */ break; }else if (event.type==SDL_MOUSEBUTTONDOWN){ edt = (uint16)(event.button.x); rrpge_dev_push(emu, mid, 2U, 1U, &edt); edt = (uint16)(event.button.y); rrpge_dev_push(emu, mid, 3U, 1U, &edt); if (event.button.button == SDL_BUTTON_LEFT){ edt = 1U; rrpge_dev_push(emu, mid, 0U, 1U, &edt); } else if (event.button.button == SDL_BUTTON_RIGHT){ edt = 2U; rrpge_dev_push(emu, mid, 0U, 1U, &edt); } else if (event.button.button == SDL_BUTTON_MIDDLE){ edt = 3U; rrpge_dev_push(emu, mid, 0U, 1U, &edt); } else {} }else if (event.type==SDL_MOUSEBUTTONUP){ edt = (uint16)(event.button.x); rrpge_dev_push(emu, mid, 2U, 1U, &edt); edt = (uint16)(event.button.y); rrpge_dev_push(emu, mid, 3U, 1U, &edt); if (event.button.button == SDL_BUTTON_LEFT){ edt = 1U; rrpge_dev_push(emu, mid, 1U, 1U, &edt); } else if (event.button.button == SDL_BUTTON_RIGHT){ edt = 2U; rrpge_dev_push(emu, mid, 1U, 1U, &edt); } else if (event.button.button == SDL_BUTTON_MIDDLE){ edt = 3U; rrpge_dev_push(emu, mid, 1U, 1U, &edt); } else {} }else if (event.type==SDL_MOUSEMOTION){ edt = (uint16)(event.motion.x); rrpge_dev_push(emu, mid, 2U, 1U, &edt); edt = (uint16)(event.motion.y); rrpge_dev_push(emu, mid, 3U, 1U, &edt); } } printf("Trying to exit\n"); rrpge_delete(emu); audio_free(); screen_free(); SDL_Quit(); fclose(main_app); exit(0); loadfault: if (emu != NULL) free(emu); fclose(main_app); exit(1); }