static Uint8 process_input(SDL_Scancode const *s, t_menuentries *item) { t_menuentries old_item; old_item = *item; *item += (*s == get_input(UP_INP)->code && *item != START_MEN) ? -1 : 0; *item += (*s == get_input(DOWN_INP)->code && *item != SCORE_MEN) ? 1 : 0; if (*s == get_input(RETURN_INP)->code) { play_sfx(get_common_sfx(BLIPCANCEL_SFX)); set_launcher(&space_destroy); } else if (*s == get_input(START_INP)->code) { if (entries[*item].enabled) { play_sfx(get_common_sfx(BLIPOK_SFX)); set_launcher(entries[*item].callback); } } if (*item != old_item) { display_menu(); play_sfx(get_common_sfx(BLIPSEL_SFX)); return (1); } return (0); }
int SpecialUtwig(pPlayer pl) { pl->shield=SPECIAL_WAIT; // sprites[(pl->plr==1)?0:13].attribute2 = pl->SpriteStart+32 | PRIORITY(1); play_sfx(&utwig_shield,pl->plr-1); return 1; }
void next_level() { level += 1; enter_leveltitle(); play_sfx(sfx_level); // TODO small animation (like kill but happy), THEN next leveltitle ? }
int main() { unsigned int i; #if defined(TARGET_WINDOWS) && TARGET_WINDOWS == 32 && !defined(WIN386) /* As a 32-bit Windows application, we *can* talk directly to the 8254 but only if running under Windows 3.1/95/98/ME. * Windows NT would never permit us to directly talk to IO. * * However if we're a Win16 program or Watcom 386 application, Windows NT will trap and emulate the 8254 through NTVDM.EXE */ detect_windows(); if (!(windows_mode == WINDOWS_REAL || windows_mode == WINDOWS_STANDARD || windows_mode == WINDOWS_ENHANCED)) { printf("This test program is only applicable to Windows 3.x/9x\n"); return 1; } #endif printf("8254 library test program\n"); if (!probe_8254()) { printf("Chip not present. Your computer might be 2010-era hardware that dropped support for it.\n"); return 1; } printf("This program tests the ability for emulation to handle\n"); printf("rapid changes to PC speaker frequency.\n"); printf("Apogee/Duke Nukem style sound effects.\n"); #if defined(NO_PORT_43) # undef write_8254_pc_speaker #endif write_8254_system_timer(0); /* restore normal function to prevent BIOS from going crazy */ write_8254_pc_speaker(0); /* make sure the PIT timer is in mode 3 (square wave) */ printf("Rapid ramping (entry)\n"); play_sfx(duke_entry); printf("Rapid ramping (entry) alternate with extra delay\n"); play_sfx(duke_entry_alt); printf("Rapid ramping (item)\n"); for (i=0;i < 8;i++) play_sfx(duke_item); printf("Rapid ramping (item) alternate\n"); for (i=0;i < 8;i++) play_sfx(duke_item_alt); write_8254_system_timer(0); /* restore normal function to prevent BIOS from going crazy */ return 0; }
void sceneShow::show_scene(int n) { if (n < 0) { return; } if (scene_list.size() <= n) { std::cout << "ERROR: Scene List[" << n << "] invalid. List size is " << image_scenes.size() << "." << std::endl; return; } CURRENT_FILE_FORMAT::file_scene_list scene = scene_list.at(n); input.clean(); for (int i=0; i<SCENE_OBJECTS_N; i++) { input.read_input(); int scene_seek_n = scene.objects[i].seek_n; //std::cout << ">> sceneShow::show_scene - i: " << i << ", scene_seek_n: " << scene_seek_n << std::endl; if (_interrupt_scene == true || input.p1_input[BTN_START] == 1) { scene_seek_n = -1; break; } if (scene_seek_n != -1) { int scene_type = scene.objects[i].type; //std::cout << "### scene_type[" << scene_type << "]" << std::endl; if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_SHOW_TEXT) { show_text(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_CLEAR_AREA) { clear_area(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_CLEAR_SCREEN) { graphLib.clear_area(0 ,0, RES_W, RES_H, 0, 0, 0); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_MOVE_IMAGE) { show_image(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_MOVE_VIEWPOINT) { show_viewpoint(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_PLAY_MUSIC) { play_music(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_PLAY_SFX) { play_sfx(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_SHOW_ANIMATION) { show_animation(scene_seek_n, scene.objects[i].repeat_value, scene.objects[i].repeat_type); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_STOP_MUSIC) { soundManager.stop_music(); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_SUBSCENE) { show_scene(scene_seek_n); } else { std::cout << ">> sceneShow::show_scene - unknown scene_type[" << scene_type << "]" << std::endl; } std::cout << "show_scene::DELAY[" << i << "][" << scene.objects[i].delay_after << "]" << std::endl; if (input.waitScapeTime(scene.objects[i].delay_after) == 1) { _interrupt_scene = true; } } else { break; } } std::cout << "show_scene::DONE" << std::endl; }
int SpecialArilou(pPlayer pl) { play_sfx(&arilou_warp,pl->plr-1); GenerateStart(pl); return 1; }
int FireArilou(pPlayer pl) { pPlayer opp=(pPlayer)pl->opp; play_sfx(&arilou_fire,pl->plr-1); for (int b=0;b<4;b++) { pl->weapon[b].type=LASER; pl->weapon[b].object.life=2; pl->weapon[b].damage=-1; pl->weapon[b].target=pl->opp; pl->weapon[b].parent=pl; pl->weapon[b].damageparent=0; pl->weapon[b].movefunc=0; pl->weapon[b].hitfunc=0; pl->weapon[b].object.ignorecollision=0; pl->weapon[b].object.size=32;//(b==3?8:32); pl->weapon[b].object.angle = FindAngle(pl->object.xpos,pl->object.ypos,opp->object.xpos,opp->object.ypos); s32 off=(b==0?13:13+(b*32)); pl->weapon[b].object.xspeed=0; pl->weapon[b].object.yspeed=0; pl->weapon[b].object.xpos = pl->object.xpos+((off * (s32)SIN[pl->weapon[b].object.angle])>>8); pl->weapon[b].object.ypos = pl->object.ypos-((off * (s32)COS[pl->weapon[b].object.angle])>>8); drawOnScreen(&pl->weapon[b].object.xscreen,&pl->weapon[b].object.yscreen, pl->weapon[b].object.xpos,pl->weapon[b].object.ypos,screenx,screeny,pl->weapon[b].object.size); sprites[pl->weapon[b].sprite].attribute0 = COLOR_256 | SQUARE | ROTATION_FLAG |SIZE_DOUBLE | MODE_TRANSPARENT | pl->weapon[b].object.yscreen; //setup sprite info, 256 colour, shape and y-coord sprites[pl->weapon[b].sprite].attribute1 =SIZE_32 | ROTDATA(pl->weapon[b].sprite) | pl->weapon[b].object.xscreen; sprites[pl->weapon[b].sprite].attribute2 = pl->SpriteStart+64 | PRIORITY(1); } return 1; }
//adds the item in the elf's inventory void addElfItem(char type) { char count = 0; for (char i=0; i< MAX_ITEMS; i++) { if (elf.items[i] == 0) { elf.items[i] = type; break; } else { count++; } } if (count == MAX_ITEMS) { //won game elf.state = ELFSTATE_WON; } else { //otherwise, play the sound effect play_sfx(6); } }
void sceneShow::show_scene(int n) { if (scene_list.size() <= n) { std::cout << "ERROR: Scene List[" << n << "] invalid. List size is " << image_scenes.size() << "." << std::endl; exit(-1); } CURRENT_FILE_FORMAT::file_scene_list scene = scene_list.at(0); for (int i=0; i<SCENE_OBJECTS_N; i++) { int scene_seek_n = scene.objects[i].seek_n; if (scene_seek_n != -1) { int scene_type = scene.objects[i].type; if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_SHOW_TEXT) { show_text(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_CLEAR_AREA) { clear_area(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_CLEAR_SCREEN) { graphLib.clear_area(0 ,0, RES_W, RES_H, 0, 0, 0); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_MOVE_IMAGE) { show_image(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_MOVE_VIEWPOINT) { /// @TODO } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_PLAY_MUSIC) { play_music(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_PLAY_SFX) { play_sfx(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_SHOW_ANIMATION) { show_animation(scene_seek_n, scene.objects[i].repeat_value, scene.objects[i].repeat_type); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_STOP_MUSIC) { soundManager.stop_music(); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_SUBSCENE) { show_scene(scene_seek_n); } timer.delay(scene.objects[i].delay_after); } } }
RoomElement hitElf(RoomElement element) { //hit by a monster if (element.type < 50) { //check the counter, so hearts are not //removed unless the monster has not been 'hit' //already if (element.counter == 0) { element.counter = COUNTER_START; elf.hearts--; if (elf.hearts < 1) { //game over elf.state = ELFSTATE_DEAD; } } //when the elf and a monster 'bump,' move the monster //in the opposite direction switch (element.state) { case STATE_MOVE_UP: element.state = STATE_MOVE_DOWN; break; case STATE_MOVE_DOWN: element.state = STATE_MOVE_UP; break; case STATE_MOVE_LEFT: element.state = STATE_MOVE_RIGHT; break; case STATE_MOVE_RIGHT: element.state = STATE_MOVE_LEFT; break; } } else { switch (element.type) { case ITEM_HEART: if (elf.hearts < MAX_HEARTS) elf.hearts++; //handle the rest of the item hit element = hitItem(element); play_sfx(5); break; case ITEM_CRYSTAL: case ITEM_ORB: case ITEM_ARMOR: case ITEM_STAFF: addElfItem(element.type); //handle the rest of the item hit element = hitItem(element); break; case ITEM_PORTAL: //handle the rest of the item hit element = hitItem(element); if (getMapCurrentRoom() > 63) { //go to the bottom half of the map (underworld) setMapRoom(0); play_song(0); } else { //back to top half of the map (overworld) setMapRoom(64); play_song(1); } elf.x = 36; elf.y = 24; elf.facing = FACING_DOWN; showElf(); break; } } //update the display updateDisplay(elf); return element; }