void main_loop(){ if(!taskmng_isavail()) return; taskmng_rol(); if (np2oscfg.NOWAIT) { pccore_exec(framecnt == 0); if (np2oscfg.DRAW_SKIP) { // nowait frame skip framecnt++; if (framecnt >= np2oscfg.DRAW_SKIP) { processwait(0); } } else { // nowait auto skip framecnt = 1; if (timing_getcount()) { processwait(0); } } } else if (np2oscfg.DRAW_SKIP) { // frame skip if (framecnt < np2oscfg.DRAW_SKIP) { pccore_exec(framecnt == 0); framecnt++; } else { processwait(np2oscfg.DRAW_SKIP); } } else { // auto skip if (!waitcnt) { UINT cnt; pccore_exec(framecnt == 0); framecnt++; cnt = timing_getcount(); if (framecnt > cnt) { waitcnt = framecnt; if (framemax > 1) { framemax--; } } else if (framecnt >= framemax) { if (framemax < 12) { framemax++; } if (cnt >= 12) { timing_reset(); } else { timing_setcount(cnt - framecnt); } framereset(0); } } else { processwait(waitcnt); waitcnt = framecnt; } } }
BOOL taskmng_sleep(UINT32 tick) { UINT32 base; base = GETTICK(); while (is_proc && ((GETTICK() - base) < tick)) { taskmng_rol(); usleep(20); } return is_proc; }
BOOL taskmng_sleep(UINT32 tick) { UINT32 base; base = GETTICK(); while((task_avail) && ((GETTICK() - base) < tick)) { taskmng_rol(); #if !defined(TARGET_MONA) Sleep(1); #endif } return(task_avail); }
BOOL gamecore_exec(void) { gamecore_resetvolume(); gamecore_reset(); do { if (gamecore_proc()) { break; } taskmng_rol(); } while(taskmng_isavail()); return(SUCCESS); }
BOOL taskmng_sleep(UINT32 tick) { UINT32 base; base = GETTICK(); while((is_proc) && ((GETTICK() - base) < tick)) { taskmng_rol(); #ifndef WIN32 usleep(960); #else Sleep(1); #endif } return(is_proc); }
static int mvtask(int tick) { UINT btn; if (!tick) { taskmng_rol(); if (!taskmng_isavail()) { return(0); } } else { if (!taskmng_sleep(tick)) { return(0); } } btn = inputmng_getmouse(NULL, NULL); if (btn & (LBUTTON_UPBIT | RBUTTON_UPBIT)) { inputmng_resetmouse(0); return(0); } return(1); }
void vramdraw_savebmp(int num, const char *dir, const char *name, int pos, const char *credit0, const char *credit1) { int i; char path[MAX_PATH]; char work[32]; BMPDATA inf; VRAMHDL vram; UINT tmp; UINT bmpsize; BMPFILE bf; BMPINFO bi; BYTE *dat; FILEH fh; if ((num < 0) || (num >= GAMECORE_MAXVRAM) || (name == NULL)) { goto vdsb_err1; } if (dir == NULL) { dir = ""; } for (i=0; i<100; i++) { milstr_ncpy(path, dir, sizeof(path)); milstr_ncat(path, name, sizeof(path)); sprintf(work, "%02u.bmp", i); milstr_ncat(path, work, sizeof(path)); if (file_attr(path) == -1) { break; } taskmng_rol(); } if (i >= 100) { goto vdsb_err1; } vram = vram_copy(gamecore.vram[num]); if (vram == NULL) { goto vdsb_err1; } creditmix(vram, pos, credit1, 0x000000); creditmix(vram, pos, credit0, 0xffffff); inf.width = vram->width; inf.height = vram->height; inf.bpp = 24; bmpdata_setinfo(&bi, &inf, TRUE); bmpsize = bmpdata_getdatasize(&bi); ZeroMemory(&bf, sizeof(bf)); bf.bfType[0] = 'B'; bf.bfType[1] = 'M'; tmp = sizeof(BMPFILE) + sizeof(BMPINFO); STOREINTELDWORD(bf.bfOffBits, tmp); tmp += bmpsize; STOREINTELDWORD(bf.bfSize, tmp); dat = bmpdata_bmp24cnv(&bi, vram); if (dat == NULL) { goto vdsb_err2; } fh = file_create(path); if (fh == FILEH_INVALID) { goto vdsb_err3; } file_write(fh, &bf, sizeof(bf)); file_write(fh, &bi, sizeof(bi)); file_write(fh, dat, bmpsize); file_close(fh); vdsb_err3: _MFREE(dat); vdsb_err2: vram_destroy(vram); vdsb_err1: return; }
int SDL_main(int argc, char **argv) { int pos; char *p; int id; pos = 1; while(pos < argc) { p = argv[pos++]; if ((!milstr_cmp(p, "-h")) || (!milstr_cmp(p, "--help"))) { usage(argv[0]); goto np2main_err1; } else { printf("error command: %s\n", p); goto np2main_err1; } } dosio_init(); file_setcd(datadir); initload(); TRACEINIT(); if (fontmng_init() != SUCCESS) { goto np2main_err2; } inputmng_init(); keystat_initialize(); if (sysmenu_create() != SUCCESS) { goto np2main_err3; } mousemng_initialize(); scrnmng_initialize(); if (scrnmng_create(FULLSCREEN_WIDTH, FULLSCREEN_HEIGHT) != SUCCESS) { goto np2main_err4; } sdlkbd_initialize(); // this must be after SDL_VIDEO initialized soundmng_initialize(); commng_initialize(); sysmng_initialize(); taskmng_initialize(); pccore_init(); S98_init(); mousemng_hidecursor(); scrndraw_redraw(); pccore_reset(); if (np2oscfg.resume) { id = flagload(str_sav, str_resume, FALSE); if (id == DID_CANCEL) { goto np2main_err5; } } while(taskmng_isavail()) { taskmng_rol(); if (np2oscfg.NOWAIT) { pccore_exec(framecnt == 0); if (np2oscfg.DRAW_SKIP) { // nowait frame skip framecnt++; if (framecnt >= np2oscfg.DRAW_SKIP) { processwait(0); } } else { // nowait auto skip framecnt = 1; if (timing_getcount()) { processwait(0); } } } else if (np2oscfg.DRAW_SKIP) { // frame skip if (framecnt < np2oscfg.DRAW_SKIP) { pccore_exec(framecnt == 0); framecnt++; } else { processwait(np2oscfg.DRAW_SKIP); } } else { // auto skip if (!waitcnt) { UINT cnt; pccore_exec(framecnt == 0); framecnt++; cnt = timing_getcount(); if (framecnt > cnt) { waitcnt = framecnt; if (framemax > 1) { framemax--; } } else if (framecnt >= framemax) { if (framemax < 12) { framemax++; } if (cnt >= 12) { timing_reset(); } else { timing_setcount(cnt - framecnt); } framereset(0); } } else { processwait(waitcnt); waitcnt = framecnt; } } } pccore_cfgupdate(); if (np2oscfg.resume) { flagsave(str_sav); } else { flagdelete(str_sav); } pccore_term(); S98_trash(); soundmng_deinitialize(); if (sys_updates & (SYS_UPDATECFG | SYS_UPDATEOSCFG)) { initsave(); } scrnmng_destroy(); sysmenu_destroy(); TRACETERM(); SDL_Quit(); dosio_term(); return(SUCCESS); np2main_err5: pccore_term(); S98_trash(); soundmng_deinitialize(); np2main_err4: scrnmng_destroy(); np2main_err3: sysmenu_destroy(); np2main_err2: TRACETERM(); SDL_Quit(); dosio_term(); np2main_err1: return(FAILURE); }