void cd_user_md::update_game_info_without_lock(long long uid) { auto user_ptr = get_user(uid); if(user_ptr) { std::string query = "call get_game_info(" + std::to_string(uid) + ")"; auto rs = db_md::get().execute_query(query); while(rs->next()) { auto score = rs->getInt("score"); auto win_count = rs->getInt("win_count"); auto lose_count = rs->getInt("lose_count"); auto ranking = rs->getInt("ranking"); user_ptr->set_score(score); user_ptr->set_win_count(win_count); user_ptr->set_lose_count(lose_count); user_ptr->set_ranking(ranking); json11::Json noti = json11::Json::object { { "type", "update_game_info_noti" }, { "result", true }, { "score", score }, { "win_count", win_count }, { "lose_count", lose_count }, { "ranking", ranking } }; user_ptr->send2(noti); } } }
BOOL CMFCApplication1Dlg::PreTranslateMessage(MSG* pMsg) { CWnd* temp_time = GetDlgItem(IDC_TIMER); CString t_time; switch (pMsg->message) { case WM_TIMER: //ako traje igra, svakih 0.1 sekundi provjerava da li je "duration" manji od 0, ako je poziva se "game over", ako nije da se "duration" smanji za 0.1 if (game == true) { duration -= 0.1; if (duration < 0) game_over(); t_time.Format(_T("%.1f"), duration); temp_time->SetWindowText(LPCTSTR(t_time)); return false; } case WM_KEYUP: //prepoznavanje stisnute tipke if (pMsg->wParam == VK_RETURN) { // poèetak ili reset igre new_game(); CWnd *_help = GetDlgItem(IDC_INST); _help->SetWindowText(_T("")); } else if (pMsg->wParam == VK_ESCAPE) { // izlazak iz igre EndDialog(IDCANCEL); } else if (GetAsyncKeyState(current_word[0]) && game == true) { //provjera da li je pritisnuta tipka jednaka traženom slovu if (current_word.Mid(1).IsEmpty()) { //ako nema više slova poveæava se "score" i postavlja se nova rijeè set_score(); new_word(); } else { //za svako pogoðeno slovo, to slovo se mièe iz prikaza rijeèi i svira zvuk za pogoðeno slovo sound_path.LoadString(IDS_S_WRITE); PlaySound(sound_path, GetModuleHandle(NULL), SND_ASYNC); //zvuk za dobro upisano slovo current_word = current_word.Mid(1); //mièe se prvi znak(slovo) iz rijeèi change_text(); //postavlja se tekst bez prvog znaka } } else if (GetAsyncKeyState('H') && game == false) //kada igra ne traje ako je "H" pritisnut prikazuju se instrukcije za igranje igre { CString res; CString res2; res.LoadString(IDS_M_HELP); res2.LoadString(IDS_M_HELP_T); MessageBox(res, res2); } else if (game == true) //ako igra traje i nije pogoðeno slovo, poziva se "game over" game_over(); return true; } return false; }
virtual ::grpc::Status search(::grpc::ServerContext* context, const api::SearchRequest* request, api::SearchResponse* response) { SearchRequest req; req.db = request->db(); req.raw = request->raw(); req.url = request->url(); req.content = request->content(); req.K = request->k(); req.R = request->r(); req.hint_K = request->hint_k(); req.hint_R = request->hint_r(); SearchResponse resp; server->search(req, &resp); response->set_time(resp.time); response->set_load_time(resp.load_time); response->set_filter_time(resp.filter_time); response->set_rank_time(resp.rank_time); for (auto const &hit: resp.hits) { auto ptr = response->add_hits(); ptr->set_key(hit.key); ptr->set_score(hit.score); } return grpc::Status::OK; }
static void check_game_over (void) { int cleared=1; int x,y; for(x = 0; x < STONE_COLS; x++) for(y = 0 ; y < STONE_LINES; y++) { if (!field [x][y].color) continue; cleared = 0; if(x+1 < STONE_COLS) if(field[x][y].color == field[x+1][y].color) return; if(y+1 < STONE_LINES) if(field[x][y].color == field[x][y+1].color) return; } if (cleared){ set_score (score+1000); end_of_game (_("The Same Gnome")); } else end_of_game(_("The Same Gnome")); }
static void new_game (void) { fill_board (); set_score (0); gtk_widget_draw (draw_area, NULL); }
void GameScene::spawn_tube_pair() { auto upper_tube = get_an_inactive_tube(); int upper_tube_pos_y{ std::rand() % 250 + 350 }; // dummy upper_tube->initialize_position((float)upper_tube_pos_y); upper_tube->setAnchorPoint(Vec2{ 1, 0 }); upper_tube->set_score(0); upper_tube->start_moving(); auto lower_tube = get_an_inactive_tube(); float lower_tube_pos_y{ (float)upper_tube_pos_y - TUBE_UPPER_LOWER_GAP }; lower_tube->initialize_position(lower_tube_pos_y); lower_tube->setAnchorPoint(Vec2{ 1, 1 }); lower_tube->setFlippedY(true); lower_tube->set_score(1); lower_tube->start_moving(); }
void ManagerBase::notifyDiscardFinish(const Record& res, int s, int factor) { Message m(MsgType::DiscardFinish); auto msg = m.get<DiscardFinishMsg>(); msg->set_score(s); msg->set_factor(factor); (*msg) << res.getBottom(); notify(&m); }
static void start_over(int id, int pulse) { if (id) { if (pulse) gui_pulse(id, 1.2f); if (gui_token(id) == START_LEVEL) { start_over_level(gui_value(id)); } else { gui_set_image(shot_id, set_shot(curr_set())); set_score_board(set_score(curr_set(), SCORE_COIN), -1, set_score(curr_set(), SCORE_TIME), -1, NULL, -1); } } }
void detect_lines(void) { unsigned int row_index; unsigned int count = 0; for (row_index = 0; row_index < NUMBER_OF_ROWS; row_index++) { if (is_row_completed(row_index)) { remove_row(row_index); count++; } } if (count > 0) { set_score(get_score() + 1 << (2 * (count - 1))); } }
void CMFCApplication1Dlg::new_game() { //poèetak igre srand(time(NULL)); game = false; //postavlja se indicator "game" na "false" da bi se "score" postavio na nulu set_score(); //"score" se postavlja na 0 game = true; // indicator se postavlja na "true" da kada se postavi rijeè za upisivanje, program provjerava da li je pritisnuta tipka jednaka traženom slovu new_word(); // postavlja se nova rijeè //std::async(std::launch::async, &CMFCApplication1Dlg::timer, this); timer(); //postavlja se timer }
static void kill_balls (HWND hwnd, int x, int y) { if (!field [x][y].color) return; if (tagged_count < 2) return; set_score (score + (tagged_count - 2) * (tagged_count - 2)); compress_y (); compress_x (); InvalidateRect (hwnd, &rcBoard, FALSE); check_game_over (hwnd); }
static int done_gui(void) { const char *s1 = _("New Set Record"); const char *s2 = _("Set Complete"); int id; int high = progress_set_high(); if ((id = gui_vstack(0))) { int gid; if (high) gid = gui_label(id, s1, GUI_MED, gui_grn, gui_grn); else gid = gui_label(id, s2, GUI_MED, gui_blu, gui_grn); gui_space(id); gui_score_board(id, GUI_SCORE_COIN | GUI_SCORE_TIME, 1, high); gui_space(id); gui_start(id, _("Select Level"), GUI_SML, GUI_BACK, 0); if (!resume) gui_pulse(gid, 1.2f); gui_layout(id, 0, 0); } set_score_board(set_score(curr_set(), SCORE_COIN), progress_score_rank(), set_score(curr_set(), SCORE_TIME), progress_times_rank(), NULL, -1); return id; }
static void kill_balls (int x, int y) { if (!field [x][y].color) return; if (tagged_count < 2) return; set_score (score + (tagged_count - 2) * (tagged_count - 2)); compress_y (); compress_x (); gtk_widget_draw (draw_area, NULL); check_game_over (); }
void MsgNeighbor::MergeFrom(const MsgNeighbor& from) { GOOGLE_CHECK_NE(&from, this); neighbor_.MergeFrom(from.neighbor_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from._has_bit(0)) { set_platform(from.platform()); } if (from._has_bit(1)) { set_accountid(from.accountid()); } if (from._has_bit(2)) { set_score(from.score()); } if (from._has_bit(3)) { set_xp(from.xp()); } if (from._has_bit(4)) { set_extid(from.extid()); } if (from._has_bit(5)) { set_url(from.url()); } if (from._has_bit(6)) { set_name(from.name()); } if (from._has_bit(7)) { set_isneighbor(from.isneighbor()); } } if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from._has_bit(8)) { set_levelbasedonscore(from.levelbasedonscore()); } if (from._has_bit(9)) { set_wishlist(from.wishlist()); } if (from._has_bit(10)) { set_damageprotectiontimeleft(from.damageprotectiontimeleft()); } if (from._has_bit(11)) { set_tutorialcompleted(from.tutorialcompleted()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); }
/** init_model: Used to initialize the values of a given model. * It takes a pointer to a model and changes it's values * to set values, instead of having to call all of the * functions individually. * * @param: modelPtr * A pointer to an object of the Model structure type. * * @return: none * */ void init_model(struct Model *modelPtr) { int i; set_score(modelPtr, 0); /* initialize score to 0 */ set_player_move_requested(modelPtr, 0, 0); set_player_deltaX(modelPtr, 0, 8); set_player_deltaY(modelPtr, 0, 8); set_player_cor(modelPtr, 0, 20, 160); /* set player 1's position in play area */ set_player_alive(modelPtr, 0, 0); /* set player 1's alive state to true */ for(i = 0; i < NUM_ENEMIES; i++) { generate_enemy(modelPtr, i); } }
static void check_game_over (HWND hwnd) { int cleared=1; int x,y; for(x = 0; x < STONE_COLS; x++) for(y = 0 ; y < STONE_LINES; y++) { if (!field [x][y].color) continue; cleared = 0; if(x+1 < STONE_COLS) if(field[x][y].color == field[x+1][y].color) return; if(y+1 < STONE_LINES) if(field[x][y].color == field[x][y+1].color) return; } if (cleared) set_score (score+1000); end_of_game(hwnd, _(SM_ST_SAMEGAME)); }
static void timer_callback() { if (state.buttonPushed) { state.buttonPushed = false; // Seed the random number with a time srand(time(NULL)); // Get a number between 1 and 2 state.direction = (rand() % 2) + 1; static char buf[32]; snprintf(buf, 32, "Time interval: %u", state.timeInterval); text_layer_set_text(text_layer, buf); // Set the correct label based on random number if (state.direction == 1) { layer_set_hidden((Layer*) up_label, false); layer_set_hidden((Layer*) up_image_layer, false); } else { layer_set_hidden((Layer*) down_label, false); layer_set_hidden((Layer*) down_image_layer, false); } state.timeInterval -= 10; app_timer_register(state.timeInterval, timer_callback, NULL); } else { text_layer_set_text(text_layer, "Game over. Try again."); reset_labels(); state.direction = 0; state.isRunning = false; set_score(); } }
static void process_dude_gibs(thing_t *dt) { if (view_fade_done()) { set_score(); // Pop everything (pause? fade? who cares) while (view_pop()) { }; view_fade_in((SDL_Color) { 255, 255, 255, 255 }); view_push(&view_score); view_push(&view_fade); audio_music_fade(); process_init(); } else { uint32_t since_ended = game.active_ticks - game.ended_at_ticks; if (since_ended == 60) { view_push(&view_fade); } } }
void rockpush_init_game(Rock_Screen *screen_data) { SDL_Event event; Rock_Sprite *object_rocco; Rock_Scroll_Map map; int16_t current_level; bool done = false; Uint32 init_ms; Uint32 move_ms; SDL_Joystick *joystick = NULL; Sint16 joy_event = 0; if (SDL_NumJoysticks() >= 1) { joystick = SDL_JoystickOpen(0); SDL_JoystickEventState(SDL_ENABLE); } map.view_height = VIEW_HEIGHT; map.view_width = VIEW_WIDTH; map.scroll_shift = SCROLL_SHIFT; map.diamonds = 0; map.level = 0; map.points = 0; map.lives = INIT_ROCCO_LIVE; map.update_score = false; map.refresh_rocco = false; map.rocco_death = false; current_level = map.level; screen_show_background(screen_data->screen); sprites_set_tiles_textures(); object_rocco = set_level_rocco(&map); set_score(&map, screen_data); if (sfx_get_active()) { sfx_set_level_music(&map); Mix_PlayMusic(map.level_music, -1); } SDL_GL_SetSwapInterval(0); distorsion_in(&map, screen_data); while (!done) { init_ms = SDL_GetTicks(); while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT || event.key.keysym.sym == SDLK_ESCAPE) done = true; if (SDL_JoystickGetAttached(joystick)) joy_event = SDL_JoystickGetAxis(joystick, 0) | SDL_JoystickGetAxis(joystick, 1); while (event.type == SDL_KEYDOWN || event.type == SDL_JOYBUTTONDOWN || joy_event) { move_ms = SDL_GetTicks(); if (SDL_JoystickGetAttached(joystick)) { joy_event = SDL_JoystickGetAxis(joystick, 0) | SDL_JoystickGetAxis(joystick, 1); if (SDL_JoystickGetButton(joystick, 0)) done = true; if (SDL_JoystickGetButton(joystick, 1)) map.rocco_death = true; } /*if (event.key.keysym.sym == SDLK_n) map.level ++;*/ // Reinicia el nivel if (event.key.keysym.sym == SDLK_r) map.rocco_death = true; set_position(object_rocco, event, joystick); sprites_update(&map); map_show(screen_data, &map, false); screen_dump_buffer(screen_data, map.view_width, map.view_height); SDL_PollEvent(&event); if (map.update_score) { set_score(&map, screen_data); map.update_score = false; } if (map.level > current_level && map.level < TOTAL_LEVELS) { sfx_play(SFX_LEVEL); if (sfx_get_active()) { Mix_HaltMusic(); Mix_FreeMusic(map.level_music); sfx_set_level_music(&map); Mix_PlayMusic(map.level_music, -1); } distorsion_out(&map, screen_data); free(sprites); object_rocco = set_level_rocco(&map); current_level = map.level; set_score(&map, screen_data); distorsion_in(&map, screen_data); } else if (map.level >= TOTAL_LEVELS) done = true; if (map.refresh_rocco) { object_rocco = sprite_get_object(map.rocco_index); map.refresh_rocco = false; } while ((SDL_GetTicks() - move_ms) < TICK_RATE); } if (event.type == SDL_KEYUP || !joy_event) { rocco_set_action(object_rocco, WAIT_LEFT); sprites_push_off(&map); } } sprites_update(&map); map_show(screen_data, &map, false); screen_dump_buffer(screen_data, map.view_width, map.view_height); if (map.update_score) { set_score(&map, screen_data); map.update_score = false; } // Si se añaden más elementos al mapa (realloc), hay que reasignar el puntero del personaje if (map.refresh_rocco) { object_rocco = sprite_get_object(map.rocco_index); map.refresh_rocco = false; } if (map.rocco_death) { map.lives --; if (map.lives <= 0) done = true; else { free(sprites); object_rocco = set_level_rocco(&map); current_level = map.level; set_score(&map, screen_data); map.rocco_death = false; } } while ((SDL_GetTicks() - init_ms) < TICK_RATE); } if (sfx_get_active()) { Mix_HaltMusic(); Mix_FreeMusic(map.level_music); } distorsion_out(&map, screen_data); SDL_GL_SetSwapInterval(0); if (SDL_JoystickGetAttached(joystick)) SDL_JoystickClose(joystick); }
FullTree* qsearch_make_fulltree(QSearchTree *clt, const gsl_matrix *dm) { int i,j; int node_count = clt->total_node_count; int leaf_count = (node_count + 2)/2; FullTree *tree = malloc(sizeof(FullTree)); tree->node_count = node_count; tree->data = malloc(sizeof(Misc)); ((Misc *)tree->data)->nodes = malloc(sizeof(FullNode) * node_count); ((Misc *)tree->data)->tmpA = g_array_sized_new(FALSE, FALSE, sizeof(guint32), node_count); ((Misc *)tree->data)->tmpB = g_array_sized_new(FALSE, FALSE, sizeof(guint32), node_count); FullNode *map = get_nodes(tree); GArray *todo = g_array_sized_new(FALSE, FALSE, sizeof(guint32), node_count - leaf_count); g_array_set_size(todo, node_count-leaf_count); for (i = 0; i < node_count; ++i) { FullNode *node = (map + i); for (j = 0; j < 3; ++j) { map[i].connections[j] = -1; map[i].leaf_count[j] = 0; map[i].dist[j] = 0; } guint8 *node_branch = malloc(sizeof(guint8) * node_count); node->node_branch = node_branch; if (i < leaf_count) { for (j=0; j < node_count; ++j) node_branch[j] = 0; node->leaf_count[0] = leaf_count - 1; } else { for (j = 0; j < node_count; ++j) node_branch[j] = -1; g_array_index(todo, guint32, i - leaf_count) = i; } } // set connections (construct tree) for (i = 0; i < node_count; ++i) { QSearchNeighborList *cln = g_ptr_array_index(clt->n, i); // add to connected nodes for (j = 0; j < cln->n->len; ++j) { int node = g_array_index(cln->n, guint32, j); // find unfilled branch int branch = find_branch(map[node].connections, -1); map[node].connections[branch] = i; // set connection if (i < leaf_count) { map[node].leaf_count[branch] = 1; // set leaf } map[node].node_branch[i] = branch; // leaf can be found in branch // set connection back to this node branch = find_branch(map[i].connections, -1); map[i].connections[branch] = node; map[i].node_branch[node] = branch; } } // every iteration, this loop progresses by at least finishing one node. Worst case is n^3 (for 'linear' trees) while (todo->len > 0) { for (i = 0; i < todo->len; ++i) { int this_node = g_array_index(todo, guint32, i); for (j = 0; j < 3; ++j) { int connected_node = map[this_node].connections[j]; int branch = find_branch(map[connected_node].connections, this_node); if (map[connected_node].leaf_count[branch] == 0) { int first = (3 + j-1) % 3; int second = (j + 1) % 3; if (map[this_node].leaf_count[first] != 0 && map[this_node].leaf_count[second] != 0) { map[connected_node].leaf_count[branch] = map[this_node].leaf_count[first] + map[this_node].leaf_count[second]; // set the node_branch information int k; for (k = 0; k < node_count; ++k) { // node present in one of the two branches pointing away from this int node_present = k==this_node || map[this_node].node_branch[k] == first || map[this_node].node_branch[k] == second; if (node_present) map[connected_node].node_branch[k] = branch; } } } } } for (i = 0; i < todo->len; ++i) { int this_node = g_array_index(todo, guint32, i); // we are done when all entries are set for this node, AND there are no pending assignments to neighbours // are all entries set for this node? for (j = 0; j < 3; ++j) { if (map[this_node].leaf_count[j] == 0) { break; } } // are there pending assignments? (we could do the assignments here, but that would duplicate code) int done = 1; for (j = 0; j < 3; ++j) { if (this_node < leaf_count) continue; int connected_node = map[this_node].connections[j]; // find connection int branch = find_branch(map[connected_node].connections, this_node); if (map[connected_node].leaf_count[branch] == 0) { done = 0; break; } } if (done) { //printf("Removing node %d, counts %d %d %d\n", i, map[this_node].leaf_count[0], map[this_node].leaf_count[1], map[this_node].leaf_count[2]); g_array_remove_index_fast(todo, i); --i; } } } g_array_free(todo, TRUE); int k; // now fill in the distances for (i=leaf_count; i < node_count; ++i) { for (j = 0; j < leaf_count; ++j) { for (k = j+1; k < leaf_count; ++k) { int b1 = map[i].node_branch[j]; int b2 = map[i].node_branch[k]; if (b1 == b2) continue; int b3 = 3 - b1 - b2; map[i].dist[b3] += gsl_matrix_get(dm, j, k); } } } set_score(tree); return tree; }
void handle_key(void){ if (NeedsPoll) poll_keyboard(); if (key[syskeys[0]] || key[KEY_ESC]) { do { rest(5); if (NeedsPoll) poll_keyboard(); } while (key[syskeys[0]] || key[KEY_ESC]); key_done=1; } if (key[syskeys[1]]) { do { rest(5); if (NeedsPoll) poll_keyboard(); } while (key[syskeys[1]]); mute_audio(); mute_voice(); abaut(); do { rest(5); if (NeedsPoll) poll_keyboard(); if (key[KEY_ALT] && key[KEY_ENTER]) { app_data.fullscreen = app_data.fullscreen ? 0 : 1; grmode(); abaut(); do { rest(5); if (NeedsPoll) poll_keyboard(); } while (key[KEY_ENTER]); } } while ((!key[syskeys[1]]) && (!key[KEY_ESC]) && (!key[syskeys[0]])); do { rest(5); if (NeedsPoll) poll_keyboard(); } while (key[syskeys[1]]); init_sound_stream(); } if (key[syskeys[5]]) { if (savestate(app_data.statefile)==0) { display_msg("Savefile saved.",5); } do { rest(5); if (NeedsPoll) poll_keyboard(); } while (key[syskeys[5]]); } /* LOAD STATE */ if (key[syskeys[6]]) { int stateError; if ((stateError=loadstate(app_data.statefile))==0) { display_msg("Savefile loaded.",5); } else if (stateError>=199) { if (stateError==199) display_msg("Wrong ROM-File for Savefile.",5); else if (stateError==200+ROM_O2) display_msg("Wrong BIOS for Savefile: O2ROM needed.",5); else if (stateError==200+ROM_G7400) display_msg("Wrong BIOS for Savefile: G7400 ROM needed.",5); else if (stateError==200+ROM_C52) display_msg("Wrong BIOS for Savefile: C52 ROM needed.",5); else if (stateError==200+ROM_JOPAC) display_msg("Wrong BIOS for Savefile: JOPAC ROM needed.",5); else display_msg("Wrong BIOS for Savefile: UNKNOWN ROM needed.",5); } do { rest(5); if (NeedsPoll) poll_keyboard(); } while (key[syskeys[6]]); } if (key[syskeys[2]]) key_debug=1; if (key[syskeys[3]]) { init_cpu(); init_roms(); init_vpp(); clearscr(); do { rest(5); if (NeedsPoll) poll_keyboard(); } while (key[syskeys[3]]); } /* SET HIGHSCORE */ if (key[syskeys[7]]) { set_score(app_data.scoretype, app_data.scoreaddress, app_data.default_highscore); } if (key[syskeys[4]]) { BITMAP *bmp; PALETTE pal; char *p; static char name[1024]; static int scshot_counter = 0; if (strlen(app_data.scshot)>0){ if ((p=strchr(app_data.scshot,'@'))) { *p = 0; sprintf(name, "%s%02d%s", app_data.scshot, scshot_counter++, p+1); *p = '@'; } else { strcpy(name, app_data.scshot); } get_palette(pal); bmp = create_sub_bitmap(screen, 0, 0, SCREEN_W, SCREEN_H); save_bitmap(name, bmp, pal); destroy_bitmap(bmp); do { rest(5); if (NeedsPoll) poll_keyboard(); } while (key[syskeys[4]]); } } // switch joystick if (key[syskeys[8]]) { joyswitch = joyswitch ? 0 : 1; set_defjoykeys(0,joyswitch); set_defjoykeys(1,joyswitch ? 0 : 1); int tmp = app_data.stick[0]; app_data.stick[0] = app_data.stick[1]; app_data.stick[1] = tmp; do { rest(5); if (NeedsPoll) poll_keyboard(); } while (key[syskeys[8]]); } if (key[KEY_ALT] && key[KEY_ENTER]) { app_data.fullscreen = app_data.fullscreen ? 0 : 1; grmode(); do { rest(5); if (NeedsPoll) poll_keyboard(); } while (key[KEY_ENTER]); } }
static void new_game (HWND hwnd) { fill_board (); set_score (0); InvalidateRect (hwnd, &rcBoard, FALSE); }
// Reset the player's score to 0 void reset_score() { set_score(0); }
/********************* Main*/ int omain(int argc, char *argv[]){ int i, cnt, cntt, cnttt, way; static char file[MAXC], attr[MAXC], val[MAXC], *p, *binver; #if defined(ALLEGRO_WINDOWS) binver = "Windows binary"; #elif defined(ALLEGRO_DOS) binver = "DOS binary"; #elif defined(ALLEGRO_LINUX) binver = "Linux binary"; #elif defined(ALLEGRO_BEOS) binver = "BEOS binary"; #elif defined(ALLEGRO_QNX) binver = "QNX binary"; #elif defined(ALLEGRO_UNIX) binver = "UNIX binary"; #elif defined(ALLEGRO_MPW) binver = "MacOS binary"; #else binver = "Unknown binary"; #endif printf("%s %s\n","\nO2EM v" O2EM_VERSION " " RELEASE_DATE " - ", binver); printf("Free Odyssey2 / Videopac+ Emulator - http://o2em.sourceforge.net\n"); printf("Created by Daniel Boris (c)1996/1998\n"); printf("Developed by:\n"); printf(" Andre de la Rocha since version 0.80\n"); printf(" Arlindo M. de Oliveira since version 1.16\n"); printf("\n"); app_data.debug = 0; app_data.stick[0] = app_data.stick[1] = 1; app_data.sticknumber[0] = app_data.sticknumber[1] = 0; set_defjoykeys(0,0); set_defjoykeys(1,1); set_defsystemkeys(); app_data.bank = 0; app_data.limit = 1; app_data.sound_en = 1; app_data.speed = 100; app_data.wsize = 2; #ifdef ALLEGRO_DOS app_data.fullscreen = 1; #else app_data.fullscreen = 0; #endif app_data.scanlines = 0; app_data.voice = 1; app_data.window_title = "O2EM v" O2EM_VERSION; app_data.svolume = 100; app_data.vvolume = 100; app_data.filter = 0; app_data.exrom = 0; app_data.three_k = 0; app_data.crc = 0; app_data.scshot = scshot; app_data.statefile = statefile; app_data.euro = 0; app_data.openb = 0; app_data.vpp = 0; app_data.bios = 0; app_data.scoretype = 0; app_data.scoreaddress = 0; app_data.default_highscore = 0; app_data.breakpoint = 65535; app_data.megaxrom = 0; strcpy(file,""); strcpy(file_l,""); strcpy(bios_l,""); strcpy(bios,""); strcpy(scshot,""); strcpy(statefile,""); strcpy(xrom,""); strcpy(scorefile,"highscore.txt"); read_default_config(); if (argc >= 2){ for(i=1; i<argc; i++) { if (argv[i][0] != '-') { strncat(file,argv[i],MAXC-1); file[MAXC-1]=0; strcpy(file_v,file); } else { p=strtok(argv[i],"="); if (p){ strncpy(attr,p+1,MAXC-1); attr[MAXC-1]=0; } else strcpy(attr,""); p=strtok(NULL,"="); if (p){ strncpy(val,p,MAXC-1); val[MAXC-1]=0; if (!strcmp(attr,"romdir")||!strcmp(attr,"ROMDIR")) { strcpy(romdir,val); strcat(romdir,file); strcpy(file,romdir); strcpy(romdir,val); } if (!strcmp(attr,"biosdir")||!strcmp(attr,"BIOSDIR")) { strcpy(biosdir,val); } } else strcpy(val,""); strlwr(attr); if (!parse_option(attr, val)) exit(EXIT_FAILURE); } } if (helpflag) helpus(); if (strlen(file)==0) { fprintf(stderr,"Error: file name missing\n"); exit(EXIT_FAILURE); } #ifdef __LIBRETRO__ sprintf(statefile,"%s.state\0",file); #endif printf("Starting emulation ...\n"); #ifndef __LIBRETRO__ allegro_init(); install_timer(); #endif init_audio(); #ifndef __LIBRETRO__ printf("Using Allegro %s\n",allegro_id); #endif /********************** ROMs if Launcher running... */ k = strchr(romdir, '/'); launcher_flag_r = strchr(file, '\\'); if (k != 0) { strcpy (xrom,romdir); } else if (!launcher_flag_r) { strcpy(xrom,"roms/"); strcpy(romdir,file); #ifndef __LIBRETRO__ strcpy(file,xrom); strcat(file,romdir); #endif strcpy(romdir,xrom); } else { cnt = 0; cntt = 0; cnttt = 0; way = 0; for (cnt=0; file[cnt] != '\0'; cnt=cnt+1) { if ( file[cnt] == '\\' ) { cnttt = cnt; } } for (cnt=0; cnt<=cnttt; cnt++) { file_l[cnt] = file[cnt]; } strcpy (romdir,file_l); strcpy (xrom,romdir); } #ifdef __LIBRETRO__ #ifdef AND sprintf(xrom,"%s\0","/mnt/sdcard/O2EM/roms/"); strcpy(romdir,xrom); #else sprintf(xrom,"%s\0","./roms/"); strcpy(romdir,xrom); #endif #endif file_name(xrom); if (contax < 3) { printf("\nROMs directory empty!\n"); exit(EXIT_FAILURE); } app_data.crc = crc32_file(file); crcx = app_data.crc; suck_roms(); /********************** BIOSs if Launcher running... */ launcher_flag_b = strchr(bios, '\\'); if (!launcher_flag_b){ k = strchr(biosdir, '/'); if (k != 0) { strcpy (xbios,biosdir); } else { strcpy (xbios,"bios/"); strcpy (biosdir,xbios); } #ifdef __LIBRETRO__ #ifdef AND sprintf(xbios,"%s\0","/mnt/sdcard/O2EM/bios/"); strcpy (biosdir,xbios); #else sprintf(xbios,"%s\0","./bios/"); strcpy (biosdir,xbios); #endif #endif file_name(xbios); if (contax < 3) { printf("\nBIOS directory empty!\n"); exit(EXIT_FAILURE); } suck_bios(); c_j = strcmp(bios,"jopac"); if ((rom_f!=1) && (c_j!=0)) strcpy(bios,g7400); if ((!o2flag) && (!jopflag) && (!c52flag) && (!g74flag)) { printf("\ndir '%s' without BIOS !",biosdir); exit(EXIT_FAILURE); } printf("BIOS found:\n"); if (!strcmp(bios,"g7400")){ strcpy(bios,g7400); if (g74flag != 1) { printf("\nG7400 BIOS not found !"); exit(EXIT_FAILURE); } } if (g74flag) printf(" G7400 VP+\n"); if (!strcmp(bios,"c52")){ strcpy(bios,c52); if (c52flag != 1) { printf("\nC52 BIOS not found !"); exit(EXIT_FAILURE); } } if (c52flag) printf(" C52\n"); if (!strcmp(bios,"jopac")){ strcpy(bios,jopac); if (jopflag != 1) { printf("\nJOPAC BIOS not found !"); exit(EXIT_FAILURE); } } if (jopflag) printf(" JOPAC VP+\n"); if ((!strcmp(bios,"")) || (!strcmp(bios,"o2rom"))) { strcpy(bios,odyssey2); if ((!o2flag)&&(!c52flag)&&(rom_f)){ printf("Odyssey2 BIOS not found !\n"); exit(EXIT_FAILURE); } if ((!o2flag)&&(c52flag)&&(rom_f)){ printf("\nOdyssey2 BIOS not found !\n"); printf("Loading C52 BIOS ... "); strcpy(bios,c52); } } if (o2flag) printf(" Odyssey 2\n"); } if (launcher_flag_b) { identify_bios(bios); if (rom_f!=1) { if (!((g74flag)||(jopflag))) { fprintf(stderr,"\nError: ROM only VP+ BIOS"); exit(EXIT_FAILURE); } } } if (!launcher_flag_b) { if (rom_f!=1) { if (!((g74flag)||(jopflag))) { printf("\nROM only VP+ BIOS\n"); exit(EXIT_FAILURE); } if (!(g74flag)) { printf("\nVP+ G7400 BIOS not found !"); printf("\nLoading VP+ Jopac BIOS ..."); strcpy(bios,jopac); } } } load_bios(bios); load_cart(file); if (app_data.voice) load_voice_samples(path); init_display(); init_cpu(); init_system(); set_score(app_data.scoretype, app_data.scoreaddress, app_data.default_highscore); int stateError; if ((stateError=loadstate(app_data.statefile))==0) { printf("Savefile loaded."); } else if (stateError>=199) { if (stateError==199) fprintf(stderr,"Wrong ROM-File for Savefile."); else if (stateError==200+ROM_O2) fprintf(stderr,"Wrong BIOS for Savefile: O2ROM needed."); else if (stateError==200+ROM_G7400) fprintf(stderr,"Wrong BIOS for Savefile: G7400 ROM needed."); else if (stateError==200+ROM_C52) fprintf(stderr,"Wrong BIOS for Savefile: C52 ROM needed."); else if (stateError==200+ROM_JOPAC) fprintf(stderr,"Wrong BIOS for Savefile: JOPAC ROM needed."); else fprintf(stderr,"Wrong BIOS for Savefile: UNKNOWN ROM needed."); return(0); } if (app_data.debug) key_debug=1; #ifndef _DEBUG #ifdef ALLEGRO_WINDOWS FreeConsole(); #endif #endif #ifdef __LIBRETRO__ return 1; #endif run(); if (app_data.scoretype!=0) save_highscore(get_score(app_data.scoretype, app_data.scoreaddress), scorefile); exit(EXIT_SUCCESS); } if (!strcmp(attr,"help")||!strcmp(attr,"HELP")) helpus(); printf("type o2em -help"); exit(EXIT_SUCCESS); }
int SetCustomScore(int x, int y) { MessageBoxA(NULL, "A: "+a+" B: "+y, "From Hook", MB_OK); return set_score(x,y); }
int main (int argc, char *argv []) { GtkWidget *label; GnomeClient *client; gnome_score_init("same-gnome"); bindtextdomain (PACKAGE, GNOMELOCALEDIR); textdomain (PACKAGE); gnome_init_with_popt_table ("same-gnome", VERSION, argc, argv, options, 0, NULL); gnome_window_icon_set_default_from_file (GNOME_ICONDIR"/gnome-gsame.png"); client= gnome_master_client (); gtk_signal_connect (GTK_OBJECT (client), "save_yourself", GTK_SIGNAL_FUNC (save_state), argv[0]); gtk_signal_connect (GTK_OBJECT (client), "die", GTK_SIGNAL_FUNC (client_die), NULL); if (GNOME_CLIENT_RESTARTED (client)){ gnome_config_push_prefix (gnome_client_get_config_prefix (client)); restart (); restarted = 1; gnome_config_pop_prefix (); } srand (time (NULL)); app = gnome_app_new("same-gnome", _("Same Gnome")); gtk_window_set_policy(GTK_WINDOW(app), FALSE, FALSE, TRUE); gtk_signal_connect (GTK_OBJECT(app), "delete_event", (GtkSignalFunc)game_quit_callback, NULL); appbar = gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_USER); gnome_app_set_statusbar(GNOME_APP (app), GTK_WIDGET(appbar)); gnome_appbar_set_status(GNOME_APPBAR (appbar), _("Welcome to Same Gnome!")); gnome_app_create_menus(GNOME_APP(app), mainmenu); gnome_app_install_menu_hints(GNOME_APP (app), mainmenu); vb = gtk_vbox_new (FALSE, 0); gnome_app_set_contents (GNOME_APP (app), vb); if (!fname) { fname = gnome_config_get_string ("/same-gnome/Preferences/Scenario=stones.png"); } create_same_board (fname); label = gtk_label_new (_("Score: ")); scorew = gtk_label_new (""); set_score (score); gtk_box_pack_start(GTK_BOX(appbar), label, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(appbar), scorew, FALSE, TRUE, 0); if (!restarted) new_game (); g_free (fname); gtk_widget_show (vb); gtk_widget_show (GTK_WIDGET(label)); gtk_widget_show (GTK_WIDGET(scorew)); gtk_widget_show (app); gtk_main (); return 0; }
bool retro_load_game(const struct retro_game_info *info) { char bios_file_path[256]; const char *full_path, *system_directory_c; enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { if (log_cb) log_cb(RETRO_LOG_INFO, "[O2EM]: RGB565 is not supported.\n"); return false; } struct retro_input_descriptor desc[] = { { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Left" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Up" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Down" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Right" }, { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Fire" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Left" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Up" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Down" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Right" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Action" }, { 0 }, }; environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc); full_path = info->path; system_directory_c = NULL; // BIOS is required environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_directory_c); if (!system_directory_c) { if (log_cb) log_cb(RETRO_LOG_WARN, "[O2EM]: no system directory defined, unable to look for o2rom.bin\n"); return false; } else { #ifdef _WIN32 char slash = '\\'; #else char slash = '/'; #endif snprintf(bios_file_path, sizeof(bios_file_path), "%s%c%s", system_directory_c, slash, "o2rom.bin"); if (!does_file_exist(bios_file_path)) { if (log_cb) log_cb(RETRO_LOG_WARN, "[O2EM]: o2rom.bin not found, cannot load BIOS\n"); return false; } } app_data.debug = 0; app_data.stick[0] = app_data.stick[1] = 1; app_data.sticknumber[0] = app_data.sticknumber[1] = 0; set_defjoykeys(0,0); set_defjoykeys(1,1); set_defsystemkeys(); app_data.bank = 0; app_data.limit = 1; app_data.sound_en = 1; app_data.speed = 100; app_data.wsize = 2; app_data.fullscreen = 0; app_data.scanlines = 0; app_data.voice = 1; app_data.window_title = "O2EM v" O2EM_VERSION; app_data.svolume = 100; app_data.vvolume = 100; app_data.filter = 0; app_data.exrom = 0; app_data.three_k = 0; app_data.crc = 0; app_data.scshot = scshot; app_data.statefile = statefile; app_data.euro = 0; app_data.openb = 0; app_data.vpp = 0; app_data.bios = 0; app_data.scoretype = 0; app_data.scoreaddress = 0; app_data.default_highscore = 0; app_data.breakpoint = 65535; app_data.megaxrom = 0; //strcpy(file,""); //strcpy(file_l,""); //strcpy(bios_l,""); //strcpy(bios,""); //strcpy(scshot,""); //strcpy(statefile,""); //strcpy(xrom,""); strcpy(scorefile,"highscore.txt"); //read_default_config(); init_audio(); app_data.crc = crc32_file(full_path); //suck_bios(); o2flag = 1; crcx = app_data.crc; //suck_roms(); load_bios(bios_file_path); load_cart(full_path); //if (app_data.voice) load_voice_samples(path2); init_display(); init_cpu(); init_system(); set_score(app_data.scoretype, app_data.scoreaddress, app_data.default_highscore); return true; }