void wsReset() { // Reset I/O ioReset(); // Reset GPU gpuReset(); // Reset CPU emulator nec_reset(0); }
// Destroy IO state structure. void ioDestroy(struct s_io_state *iostate) { ioReset(iostate); free(iostate->handle); free(iostate->mem); iostate->bufsize = 0; iostate->max = 0; iostate->count = 0; #ifdef IO_WINDOWS WSACleanup(); #endif }
// Create IO state structure. Returns 1 on success. int ioCreate(struct s_io_state *iostate, const int io_bufsize, const int io_max) { #ifdef IO_WINDOWS WSADATA wsadata; if(WSAStartup(MAKEWORD(2,2), &wsadata) != 0) { return 0; } #endif if((io_bufsize > 0) && (io_max > 0)) { // check parameters if((iostate->mem = (malloc(io_bufsize * io_max))) != NULL) { if((iostate->handle = (malloc(sizeof(struct s_io_handle) * io_max))) != NULL) { iostate->bufsize = io_bufsize; iostate->max = io_max; iostate->count = 0; memset(iostate->mem, 0, (io_bufsize * io_max)); memset(iostate->handle, 0, (sizeof(struct s_io_handle) * io_max)); ioReset(iostate); return 1; } free(iostate->mem); } } return 0; }