int main() { // Create the main window // Start the game loop arc_add_dat("th105a.dat"); arc_add_dat("th105b.dat"); arc_add_dat("th105c.dat"); arc_add_dat("th123a.dat"); arc_add_dat("th123b.dat"); arc_add_dat("th123c.dat"); gr_init(640,480,"OpenSoku"); sfx_init(); scene_load_sounds(); char_c *marisa = new char_marisa(inp_createinput(INP_TYPE_KB)); char_c *alice = new char_alice(inp_createinput(INP_TYPE_NONE),1); // uint32_t i = 0; // inp_kb kb; marisa->set_seq(0); alice->set_seq(0); background *bkg = new background_11; c_scene *scn = new c_scene(bkg,marisa,alice); while(!kb.rawPressed(kC_Escape)) { kb.update(); gr_clear(); scn->players_input(); //scn.players_collisions(); scn->update(); scn->draw_scene(); scn->update_char_anims(); gr_flip(); } return EXIT_SUCCESS; }
int main(int argc, char** argv) { resource_mgr_t *resmgr; sfx_state_t sound; int res_version = SCI_VERSION_AUTODETECT; int sound_nr; song_handle_t dummy1; int dummy2; int arg; int it_type = SCI_SONG_ITERATOR_TYPE_SCI0; song_iterator_t *base, *ff; printf("FreeSCI %s music player Copyright (C) 1999-2007\n", VERSION); printf(" Dmitry Jemerov, Christopher T. Lansdown, Sergey Lapin, Rickard Lind,\n" " Carl Muckenhoupt, Christoph Reichenbach, Magnus Reftel, Lars Skovlund,\n" " Rink Springer, Petr Vyhnak, Solomon Peachy, Matt Hargett, Alex Angas\n" " Walter van Niftrik, Rainer Canavan, Ruediger Hanke, Hugues Valois\n" "This program is free software. You can copy and/or modify it freely\n" "according to the terms of the GNU general public license, v2.0\n" "or any later version, at your option.\n" "It comes with ABSOLUTELY NO WARRANTY.\n"); if (argc < 3) { fprintf(stderr, "Syntax: %s <resource dir> <sound number> [<sound number> ...]\n", argv[0]); return 1; } if (!(resmgr = scir_new_resource_manager(argv[1], res_version, 0, 1024 * 128))) { fprintf(stderr, "Could not find any resources; quitting.\n"); return 2; } if (resmgr->sci_version >= SCI_VERSION_01) it_type = SCI_SONG_ITERATOR_TYPE_SCI1; sfx_init(&sound, resmgr, 0); sfx_set_volume(&sound, 127); arg = 2 - 1; while (++arg < argc) { sound_nr = atoi(argv[arg]); base = ff = build_iterator(resmgr, sound_nr, it_type, DUMMY_SOUND_HANDLE); printf("Playing resource %d...\n", sound_nr); if (sfx_add_song(&sound, ff, 0, DUMMY_SOUND_HANDLE, sound_nr)) { fprintf(stderr, "Could not start sound resource. Does it exist?\n"); return 2; } sfx_song_set_status(&sound, DUMMY_SOUND_HANDLE, SOUND_STATUS_PLAYING); while (sfx_poll(&sound, &dummy1, &dummy2) != SI_FINISHED) {}; } sfx_exit(&sound); scir_free_resource_manager(resmgr); return 0; }
int main(int argc, char **argv) { SDL_Window *window = NULL; Rock_Screen screen_data; bool done = false, full_screen = true; int8_t selected; atexit(rock_exit); set_text(); sfx_init(); full_screen = !(argc > 1 && !strcmp(argv[1], "-w")); screen_data.screen = screen_init(window, full_screen); screen_data.buffer_surface = screen_make_surface(SCREEN_WIDTH, SCREEN_HEIGHT); // Surface para la pantalla principal screen_data.buffer_texture = screen_make_buffers(screen_data.screen, SCREEN_WIDTH, SCREEN_HEIGHT); screen_data.dump_texture = screen_make_buffers(screen_data.screen, SCREEN_WIDTH, SCREEN_HEIGHT); screen_data.blit_surface = false; // Se indica si se usarán texturas en GPU o surfaces en CPU sprites_load_textures(&screen_data); SDL_ShowCursor(SDL_DISABLE); while (!done) { selected = rockpush_menu(&screen_data); switch (selected) { case 1: rockpush_init_game(&screen_data); break; case 2: rockpush_credits(screen_data.screen); break; case 0: case 3: done = true; break; } } SDL_DestroyTexture(screen_data.dump_texture); SDL_DestroyTexture(screen_data.buffer_texture); SDL_FreeSurface(screen_data.buffer_surface); sprites_free_textures(&screen_data); SDL_DestroyRenderer(screen_data.screen); SDL_DestroyWindow(window); //Mix_FreeMusic(music); SDL_ShowCursor(SDL_ENABLE); exit(EXIT_SUCCESS); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void init(void) { play_led_en(); play_led_off(); dbg_led_en(); dbg_led_on(); // initialize effects sfx_init(); // initialize SPI EEPROM support spie_init(); // initialize USART uart_init(); // setup the UART receive interrupt handler uartBeginReceive(&receiveCallback); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // establish event timer & handler // timer1, event timer // Set CTC mode (Clear Timer on Compare Match) (p.133) // Have to set OCR1A *before anything else*, otherwise it gets reset to 0! PRR &= ~(1<<PRTIM1); OCR1A = (F_CPU / SAMPLE_RATE); TCCR1A = 0; TCCR1B = (1<<WGM12) | // CTC (1<<CS10); TIMSK1 = (1<<OCIE1A); setTimeBase(SAMPLE_RATE); // setup sleep mode set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); // setup switch input SWITCH_DDR &= ~(1<<SWITCH_PIN); SWITCH_PINS |= (1<<SWITCH_PIN); SWITCH_PCMSK |= (1<<SWITCH_PCINT); PCICR |= (1<<SWITCH_PCICR); registerHighPriorityEvent(fadeStatusLed, 0, EVENT_STATE_NONE); registerEvent(readNextStatusVal, 500, EVENT_STATE_NONE); // enable all interrupts sei(); }
// plays an sfx sample void sfx(int index,int pan,bool loop, bool restart) { if(!sfx_init(index)) return; voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY); voice_set_pan(sfx_voice[index],pan); int pos = voice_get_position(sfx_voice[index]); if(restart) voice_set_position(sfx_voice[index],0); if(pos<=0) voice_start(sfx_voice[index]); }
// start it (in loop mode) if it's not already playing, // otherwise adjust it to play in loop mode -DD void cont_sfx(int index) { if(!sfx_init(index)) { return; } if(voice_get_position(sfx_voice[index])<=0) { voice_set_position(sfx_voice[index],0); voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP); voice_start(sfx_voice[index]); } else { adjust_sfx(index, 128, true); } }