int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){ ChangeWindowMode(TRUE);//ウィンドウモード if(DxLib_Init() == -1 || SetDrawScreen( DX_SCREEN_BACK )!=0) return -1;//初期化と裏画面化 while(ProcessLoop()==0){//メインループ switch(func_state){ case 0://初回のみ入る処理 load(); //データロード first_ini();//初回の初期化 func_state=99; break; case 99://STGを始める前に行う初期化 ini(); func_state=100; break; case 100://通常処理 calc_ch(); //キャラクタ計算 ch_move(); //キャラクタの移動制御 enemy_main();//敵処理メイン graph_main();//描画メイン stage_count++; break; default: printfDx("不明なfunc_state\n"); break; } if(CheckStateKey(KEY_INPUT_ESCAPE)==1)break;//エスケープが入力されたらブレイク ScreenFlip();//裏画面反映 } DxLib_End();//DXライブラリ終了処理 return 0; }
void ch_main(){ calc_ch(); calc_percent(); calc_grade(); ch_move(); }
static int chioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l) { struct ch_softc *sc = device_lookup_private(&ch_cd, CHUNIT(dev)); int error = 0; /* * If this command can change the device's state, we must * have the device open for writing. */ switch (cmd) { case CHIOGPICKER: case CHIOGPARAMS: case OCHIOGSTATUS: break; default: if ((flags & FWRITE) == 0) return (EBADF); } switch (cmd) { case CHIOMOVE: error = ch_move(sc, (struct changer_move_request *)data); break; case CHIOEXCHANGE: error = ch_exchange(sc, (struct changer_exchange_request *)data); break; case CHIOPOSITION: error = ch_position(sc, (struct changer_position_request *)data); break; case CHIOGPICKER: *(int *)data = sc->sc_picker - sc->sc_firsts[CHET_MT]; break; case CHIOSPICKER: { int new_picker = *(int *)data; if (new_picker > (sc->sc_counts[CHET_MT] - 1)) return (EINVAL); sc->sc_picker = sc->sc_firsts[CHET_MT] + new_picker; break; } case CHIOGPARAMS: { struct changer_params *cp = (struct changer_params *)data; cp->cp_curpicker = sc->sc_picker - sc->sc_firsts[CHET_MT]; cp->cp_npickers = sc->sc_counts[CHET_MT]; cp->cp_nslots = sc->sc_counts[CHET_ST]; cp->cp_nportals = sc->sc_counts[CHET_IE]; cp->cp_ndrives = sc->sc_counts[CHET_DT]; break; } case CHIOIELEM: error = ch_ielem(sc); if (error == 0) { sc->sc_periph->periph_flags |= PERIPH_MEDIA_LOADED; } break; case OCHIOGSTATUS: { struct ochanger_element_status_request *cesr = (struct ochanger_element_status_request *)data; error = ch_ousergetelemstatus(sc, cesr->cesr_type, cesr->cesr_data); break; } case CHIOGSTATUS: error = ch_usergetelemstatus(sc, (struct changer_element_status_request *)data); break; case CHIOSVOLTAG: error = ch_setvoltag(sc, (struct changer_set_voltag_request *)data); break; /* Implement prevent/allow? */ default: error = scsipi_do_ioctl(sc->sc_periph, dev, cmd, data, flags, l); break; } return (error); }
int chioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { struct ch_softc *sc = ch_cd.cd_devs[CHUNIT(dev)]; int error = 0; /* * If this command can change the device's state, we must * have the device open for writing. */ switch (cmd) { case CHIOGPICKER: case CHIOGPARAMS: case CHIOGSTATUS: break; default: if ((flags & FWRITE) == 0) return (EBADF); } switch (cmd) { case CHIOMOVE: error = ch_move(sc, (struct changer_move *)data); break; case CHIOEXCHANGE: error = ch_exchange(sc, (struct changer_exchange *)data); break; case CHIOPOSITION: error = ch_position(sc, (struct changer_position *)data); break; case CHIOGPICKER: *(int *)data = sc->sc_picker - sc->sc_firsts[CHET_MT]; break; case CHIOSPICKER: { int new_picker = *(int *)data; if (new_picker > (sc->sc_counts[CHET_MT] - 1)) return (EINVAL); sc->sc_picker = sc->sc_firsts[CHET_MT] + new_picker; break; } case CHIOGPARAMS: { struct changer_params *cp = (struct changer_params *)data; cp->cp_curpicker = sc->sc_picker - sc->sc_firsts[CHET_MT]; cp->cp_npickers = sc->sc_counts[CHET_MT]; cp->cp_nslots = sc->sc_counts[CHET_ST]; cp->cp_nportals = sc->sc_counts[CHET_IE]; cp->cp_ndrives = sc->sc_counts[CHET_DT]; break; } case CHIOGSTATUS: { struct changer_element_status_request *cesr = (struct changer_element_status_request *)data; error = ch_usergetelemstatus(sc, cesr); break; } /* Implement prevent/allow? */ default: error = scsi_do_ioctl(sc->sc_link, cmd, data, flags); break; } return (error); }