Example #1
0
static bool
flow (struct anim *g)
{
  if (g->oaction != guard_die) {
    /* place_frame (&g->f, &g->f, guard_die_frameset[0].frame, */
    /*              &g->p, (g->f.dir == LEFT) */
    /*              ? +13 : +21, (g->type == SHADOW) ? +18 : +17); */
    g->i = -1, g->j = 0;
    if (g->type == SKELETON)
      play_audio (&skeleton_audio, NULL, g->id);

    if (! g->glory_sample) {
      play_audio (&glory_audio, NULL, g->id);
      g->glory_sample = true;
    }

    g->xf.b = NULL;
  }

  g->current_lives = 0;

  g->i = g->i < 5 ? g->i + 1 : 5;

  struct frameset *frameset = get_guard_die_frameset (g->type);
  select_frame (g, frameset, g->i);

  if (g->j >= 1) g->fo.dx = g->fo.dy = 0;
  if (g->i == 5) g->j = 1;
  if (g->j == 1) g->j++;

  return true;
}
Example #2
0
void
guard_die_spiked (struct anim *g)
{
  if (fg (&g->p) != SPIKES_FLOOR) {
    guard_die_properly (g);
    return;
  }

  g->oaction = g->action;
  g->action = guard_die_spiked;
  g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  assert (fg (&g->p) == SPIKES_FLOOR);
  struct spikes_floor *s = spikes_floor_at_pos (&g->p);

  if (s->i != 4 || s->state != 5 || ! s->inactive) {
    s->i = 4;
    s->state = 5;
    s->inactive = true;
    register_changed_pos (&g->p);
  }

  if (g->oaction != guard_die_spiked) {
    g->splash = true;
    g->death_reason = SPIKES_DEATH;

    if (g->type == SKELETON)
      play_audio (&skeleton_audio, NULL, g->id);
    else play_audio (&spiked_audio, NULL, g->id);

    if (! g->glory_sample) {
      play_audio (&glory_audio, NULL, g->id);
      g->glory_sample = true;
    }
  }

  g->current_lives = 0;

  int dy;
  if (g->type == SKELETON) dy = +45;
  else dy = (g->f.dir == LEFT) ? +32 : +31;

  ALLEGRO_BITMAP *bitmap = get_guard_die_spiked_bitmap (g->type);
  place_frame (&g->f, &g->f, bitmap,
               &g->p, (g->f.dir == LEFT) ? +8 : +9, dy);

  g->xf.b = NULL;
}
Example #3
0
void
guard_die_chopped (struct anim *g)
{
  if (fg (&g->p) != CHOPPER) {
    guard_die_properly (g);
    return;
  }

  g->oaction = g->action;
  g->action = guard_die_chopped;
  g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  int dx, dy;

  if (g->type == SHADOW) {
    dx = (g->f.dir == LEFT) ? -8 : -7;
    dy = +47;
  } else {
    dx = (g->f.dir == LEFT) ? -10 : -13;
    dy = (g->type == SKELETON) ? +45 : +43;
  }

  ALLEGRO_BITMAP *bitmap = get_guard_die_chopped_bitmap (g->type);
  place_frame (&g->f, &g->f, bitmap, &g->p, dx, dy);

  if (g->oaction != guard_die_chopped
      && ! g->glory_sample) {
    play_audio (&glory_audio, NULL, g->id);
    g->glory_sample = true;
  }

  g->current_lives = 0;
  g->xf.b = NULL;
}
int _tmain(int argc, _TCHAR* argv[])
{
	FILE * fp;

//	if((fp=fopen("mine.pcm","rb"))==NULL)//打开你的PCM 文件mine.spx
	if((fp=fopen("mine.spx","rb"))==NULL)//打开你的PCM 文件mine.spx
	{
		printf("cannot open this file\n");
	}
	char pcm_data[320];

	dsound_union_t * dsound_union_handle = (dsound_union_t *)malloc(sizeof(dsound_union_t));
	if(dsound_union_handle == NULL){
		printf("malloc failed .\n");
		exit(1);
	}

	init_audio(dsound_union_handle, 1, 16, 8000, 0);
	while(1){
		//fread((BYTE*)pcm_data,320,1,fp);
		if(feof(fp)){
			printf("over ....\n");
			destory_audio(dsound_union_handle);
			while(1);
			break;
		}
		/*fread((BYTE*)pcm_data,38,1,fp);
		play_audio(dsound_union_handle ,pcm_data, 38);*/
		fread((BYTE*)pcm_data,50,1,fp);
		play_audio(dsound_union_handle ,pcm_data, 50);
	}
	return 0;
}
Example #5
0
void
compute_opener_floors (void)
{
    size_t i;

    for (i = 0; i < opener_floor_nmemb;) {
        struct opener_floor *o = &opener_floor[i];
        if (fg (&o->p) == OPENER_FLOOR) {
            i++;
            continue;
        }
        remove_opener_floor (o);
    }

    for (i = 0; i < opener_floor_nmemb; i++) {
        struct opener_floor *o = &opener_floor[i];
        if (o->pressed && ! o->broken) {
            if (! o->noise) {
                alert_guards (&o->p);
                play_audio (&opener_floor_audio, &o->p, -1);
                o->noise = true;
            }
            open_door (o->p.l, o->event, o->priority, false);
        } else o->noise = false;
    }
}
Example #6
0
void playPortalSong(void) {
    if (sSdFileBoard[FILE_ID_STILL_ALIVE].loaded) {
        play_audio(sSdFileBoard[FILE_ID_STILL_ALIVE].baseAddr,
                sSdFileBoard[FILE_ID_STILL_ALIVE].length);
    } else {
        xil_printf("Portal song not loaded yet!\r\n");
    }
}
Example #7
0
void playGunSound(void) {
    if (sSdFileBoard[FILE_ID_MACHINE_GUN].loaded) {
        play_audio(sSdFileBoard[FILE_ID_MACHINE_GUN].baseAddr,
                sSdFileBoard[FILE_ID_MACHINE_GUN].length);
    } else {
        xil_printf("Gun sound not loaded yet!\r\n");
    }
}
Example #8
0
void playPortalGunSound(void) {
    if (sSdFileBoard[FILE_ID_PORTAL_GUN].loaded) {
        play_audio(sSdFileBoard[FILE_ID_PORTAL_GUN].baseAddr,
                sSdFileBoard[FILE_ID_PORTAL_GUN].length);
    } else {
        xil_printf("Portal gun sound not loaded yet!\r\n");
    }
}
Example #9
0
void playTargetAcquired(void) {
    if (sSdFileBoard[FILE_ID_TARGET_ACQUIRED].loaded) {
        play_audio(sSdFileBoard[FILE_ID_TARGET_ACQUIRED].baseAddr,
                sSdFileBoard[FILE_ID_TARGET_ACQUIRED].length);
    } else {
        xil_printf("Target Acquired not loaded yet!\r\n");
    }
}
Example #10
0
void playPos(void) {
    if (sSdFileBoard[FILE_ID_BUTTON_POSITIVE].loaded) {
        play_audio(sSdFileBoard[FILE_ID_BUTTON_POSITIVE].baseAddr,
                sSdFileBoard[FILE_ID_BUTTON_POSITIVE].length);
    } else {
        xil_printf("pos button not loaded yet!\r\n");
    }
}
Example #11
0
void playNeg(void) {
    if (sSdFileBoard[FILE_ID_BUTTON_NEGATIVE].loaded) {
        play_audio(sSdFileBoard[FILE_ID_BUTTON_NEGATIVE].baseAddr,
                sSdFileBoard[FILE_ID_BUTTON_NEGATIVE].length);
    } else {
        xil_printf("neg button not loaded yet!\r\n");
    }
}
Example #12
0
/*********************** Main program **********************/
int main(int argc, char **argv)
{
    register int		err;

    // No wave data loaded yet
    WavePtr = 0;

    if (argc < 2)
    {
        printf("You must supply the name of a 16-bit mono WAVE file to play\n");
        return 0;
    }

    // Load the wave file
    if (waveLoad(argv[1]))
    {
        printf("Could not load wave file\n");
        return 0;
    }

    if(WaveBits != 16)
    {
        printf("16 bit PCM audio only!!!\n");
        return 0;
    }

    printf("Sample total %d\n", WaveSize);
    printf("Sample rate  %d\n", WaveRate);
    printf("Sample bits  %d\n", WaveBits);
    add_effect(fuzz_init, fuzz_run, fuzz_end, "Fuzz");
    printf("Finished effect line\n");

    // Open audio card we wish to use for playback
    if ((err = snd_pcm_open(&PlaybackHandle, &SoundCardPortName[0], SND_PCM_STREAM_PLAYBACK, 0)) < 0)
    {
        printf("Can't open audio %s: %s\n", &SoundCardPortName[0], snd_strerror(err));
        return 0;
    }

    // Set the audio card's hardware parameters (sample rate, bit resolution, etc)
    if ((err = snd_pcm_set_params(PlaybackHandle, SND_PCM_FORMAT_S16, SND_PCM_ACCESS_RW_INTERLEAVED, WaveChannels, WaveRate, 1, 10000)) < 0)
    {
        printf("Can't set sound parameters: %s\n", snd_strerror(err));
        return 0;
    }

    // Play the waveform
    play_audio();

    // Close sound card
    snd_pcm_close(PlaybackHandle);

    // Free the WAVE data
    free_wave_data();

    return 0;
}
Example #13
0
static void
physics_out (struct anim *k)
{
  /* depressible floors */
  if (k->i > 4) clear_depressible_floor (k);
  else keep_depressible_floor (k);

  /* sound */
  if (k->j % 4 == 0) play_audio (&step_audio, NULL, k->id);
}
void scene_gestalt()
{
    float time = 0.0;
    float offset = 1.0;
    object p1 = GetObjectByTag("intro_p1_start");
    object p2 = GetObjectByTag("intro_p2_start");
    object p2e = GetObjectByTag("intro_p2_end");
    object p3 = GetObjectByTag("intro_p3");

    /* Initialize */
    GestaltStartCutscene(pc);
    GestaltCameraFade(time, pc, FADE_CROSS, FADE_SPEED_MEDIUM, fade_duration);
    ghost();

    /* Setup */
    time = 2*delay;
    GestaltInvisibility(time, pc);
    GestaltCameraFacing(time, 63.0, 10.0, 85.0, pc);
    play_audio(time);

    /* Pass 1 */
    GestaltJump(time, pc, p1);
    GestaltActionMove(time + offset, pc, p2, FALSE, 0.0, 5*delay);

    /* Pass 2 */
    time = 7*delay;
    GestaltCameraFade(time - offset, pc, FADE_CROSS, FADE_SPEED_MEDIUM, fade_duration);
    GestaltCameraFacing(time + offset, 293.0, 10.0, 85.0, pc);
    GestaltJump(time, pc, p2);
    GestaltActionMove(time + offset, pc, p2e, FALSE, 0.0, 5*delay);


    /* Pass 3 (zoom into shadow) */
    time = 12*delay;
    GestaltCameraFade(time - offset, pc, FADE_CROSS, FADE_SPEED_MEDIUM, fade_duration);
    GestaltJump(time + offset, pc, p3);
    GestaltCameraMove(time + offset, 260.0, 20.0, 85.0, 280.0, 10.0, 85.0, 5*delay, 60.0, pc);

    /* Clean up and end cutscene */
    time = 16 * delay;
    DelayCommand(time, FadeToBlack(pc));
    //GestaltCameraFade(time - offset, pc, FADE_CROSS, FADE_SPEED_MEDIUM, fade_duration);

    /* Trigger ScriptEase */
    time = 18 * delay;
    GestaltClearEffect(time, pc);
    GestaltStopCutscene(time, pc, "intro_end");

    time = time + offset;
    // GestaltCameraFacing(time, 270.0, 10.0, 75.0, pc);
    AssignCommand(pc, SetCameraFacing(270.0, 10.0));
    DelayCommand(time, AssignCommand(pc, SetFacing(270.0)));
    DelayCommand(time, SetLocked(GetObjectByTag("activate_easel_trigger"), FALSE));
    DelayCommand(time, FadeFromBlack(pc));
}
Example #15
0
void
fight_hit (struct anim *k, struct anim *ke)
{
  if (k->immortal || k->sword_immune) return;
  if (k->current_lives <= 0) return;
  if (is_anim_fall (&k->f) || is_kid_stairs (&k->f))
    return;

  place_on_the_ground (&k->f, &k->f.c);
  k->xf.b = NULL;

  if (! is_in_fight_mode (k)) k->current_lives = 0;
  else k->current_lives--;

  if (! is_guard (ke))
    upgrade_skill (&ke->skill, &k->skill, k->total_lives);

  int d = (k->f.dir == LEFT) ? +1 : -1;
  struct pos pb;
  survey (_m, pos, &k->f, NULL, &k->p, NULL);
  prel (&k->p, &pb, 0, d);

  if (k->current_lives <= 0 && ! is_strictly_traversable (&pb)) {
    k->current_lives = 0;
    k->death_reason = FIGHT_DEATH;
    ke->alert_cycle = anim_cycle;
    anim_die (k);
  } else anim_sword_hit (k);

  if (is_in_fight_mode (k)) {
    backoff_from_range (ke, k, ATTACK_RANGE - 20, true, false);
    get_in_range (ke, k, ATTACK_RANGE - 10, false, false);
  }

  k->splash = true;

  if (k->id == current_kid_id) {
    mr.flicker = 2;
    mr.color = get_flicker_blood_color ();
    play_audio (&harm_audio, NULL, k->id);
  } else play_audio (&guard_hit_audio, NULL, k->id);
}
Example #16
0
static void
physics_out (struct anim *g)
{
  /* sound */
  if (g->i == 4) play_audio (&sword_attack_audio, NULL, g->id);

  /* depressible floors */
  if (g->i == 3) update_depressible_floor (g, -4, -41);
  else if (g->i == 4) update_depressible_floor (g, -9, -48);
  else if (g->i == 6) update_depressible_floor (g, -3, -33);
  else if (g->i == 7) update_depressible_floor (g, -1, -24);
  else keep_depressible_floor (g);
}
Example #17
0
static void
physics_out (struct anim *k)
{
  struct pos pmbo;

  /* depressible floors */
  keep_depressible_floor (k);

  /* loose floor shaking */
  survey (_mbo, pos, &k->f, NULL, &pmbo, NULL);
  if (k->i == 8) shake_loose_floor_row (&pmbo);

  /* sound */
  if (k->i == 7) play_audio (&step_audio, NULL, k->id);
}
Example #18
0
static void
physics_out (struct anim *k)
{
  struct pos hanged_pos;

  /* depressible floors */
  clear_depressible_floor (k);
  get_hanged_pos (&k->hang_pos, k->f.dir, &hanged_pos);
  press_depressible_floor (&hanged_pos);

  /* sound */
  if (! k->reverse && k->i == 4 && k->key.shift && ! k->key.up
      && ! k->hang_limit)
    play_audio (&hit_wall_audio, NULL, k->id);
}
Example #19
0
void
guard_die_suddenly (struct anim *g)
{
  enum confg f = fg (&g->p);
  if ( f == SPIKES_FLOOR || f == CHOPPER) {
    guard_die_properly (g);
    return;
  }

  g->oaction = g->action;
  g->action = guard_die_suddenly;
  g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  struct frameset *frameset = get_guard_die_frameset (g->type);

  int dy = (g->type == SKELETON) ? +44 : +47;

  place_frame (&g->f, &g->f, frameset[5].frame,
               &g->p, (g->f.dir == LEFT)
               ? +9 : +4, dy);

  if (g->oaction != guard_die_suddenly
      && ! g->glory_sample) {
    play_audio (&glory_audio, NULL, g->id);
    g->glory_sample = true;
  }

  g->current_lives = 0;
  g->xf.b = NULL;

  g->hit_by_loose_floor = false;

  /* fall */
  struct pos pm;
  survey (_m, pos, &g->f, NULL, &pm, NULL);
  if (is_strictly_traversable (&pm)) {
    guard_fall (g);
    return;
  }

  /* depressible floors */
  update_depressible_floor (g, -12, -28);
}
Example #20
0
void
put_at_defense_frame (struct anim *k)
{
  struct frameset *frameset;
  play_audio (&sword_defense_audio, NULL, k->id);

  switch (k->type) {
  case NO_ANIM: default: break;
  case KID:
    select_frame (k, kid_sword_defense_frameset, 0);
    next_frame (&k->f, &k->f, &k->fo);

    select_frame (k, kid_sword_defense_frameset, 1);

    struct anim *ke = get_anim_by_id (k->enemy_id);
    if (ke->type == KID) {
      select_xframe (&k->xf, sword_frameset, 11);
      k->xf.dx = -13;
      k->xf.dy = +5;
    } else select_xframe (&k->xf, sword_frameset, 14);

    k->action = kid_sword_defense;
    uncollide_back_fight (k);
    next_frame (&k->f, &k->f, &k->fo);
    break;
  case GUARD:
  case FAT_GUARD:
  case VIZIER:
  case SKELETON:
  case SHADOW:
    frameset = get_guard_defense_frameset (k->type);
    select_frame (k, frameset, 0);
    select_xframe (&k->xf, sword_frameset, 11);
    k->action = guard_defense;
    uncollide_back_fight (k);
    next_frame (&k->f, &k->f, &k->fo);
    break;
  }

  /* if (k->id == 0) */
  /*   printf ("%s: k->i = %i, k->fo.dx = %i\n", */
  /*           __func__, k->i, k->fo.dx); */
}
Example #21
0
int main(int argc, char** argv) {	
	setup(argc, argv);
	
	float xmbuffer[period_size];
	float alsabuffer[period_size];
	
	while(!glfwWindowShouldClose(window)) {
		play_audio(xmbuffer, alsabuffer);
		render();

		glfwSwapBuffers(window);
		glfwPollEvents();

		if(glfwGetKey(window, GLFW_KEY_ESCAPE) || loop > 0) {
			glfwSetWindowShouldClose(window, GL_TRUE);
		}
	}

	teardown();
	return 0;
}
Example #22
0
 */void sound()
{
	short int handle;
	//printf("SDCARD CONNECTION CHECK\n");
	alt_up_sd_card_dev *device_reference=alt_up_sd_card_open_dev("/dev/Altera_UP_SD_Card_Avalon_Interface_0");
	alt_up_audio_dev *audio;
	sdcardcheck(device_reference);

	//printf("AV CONFIG SETUP\n");
	av_config_setup();

	//printf("AUDIO OPEN\n");
	audio=alt_up_audio_open_dev("/dev/audio");
	unsigned int buffer[COIN_SIZE];
	char *filename="coin.wav";

	readCoin(buffer, filename, handle);
	play_audio(audio, buffer, handle);

	alt_up_sd_card_fclose(filename);

}
Example #23
0
/* DDS????: Display Error */
void display_error(enum error err)
{
	unsigned int language;
	struct image *bgimage;

	language = get_language();

	/* Draw background if we can, otherwise clear screen */
	bgimage = get_message_mayfail(language, MSG_BACKGROUND);
	if (bgimage) paste_image(0, 0, bgimage);
	else clear_screen();

	/* Message to tell them */
	play_audio(true, get_audio("error.raw"));

	/* Use electorate "1" here for the numbers. */
	draw_error(get_message_mayfail(language, MSG_ERROR),
		   get_preference_image_mayfail(1, (unsigned int)err),
		   err);

	/* Loop until reset. */
	wait_for_reset();
}
Example #24
0
void
raise_skeleton (struct anim *s)
{
  s->oaction = s->action;
  s->action = raise_skeleton;
  s->f.flip = (s->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  if (s->oaction != raise_skeleton) {
    play_audio (&skeleton_audio, NULL, s->id);
    place_frame (&s->f, &s->f, skeleton_die_frameset[2].frame,
                 &s->p, (s->f.dir == LEFT) ? +12 : +0, +43);
    s->i = 2;
  }

  if (s->i-- == 0) {
    guard_normal (s);
    return;
  }

  s->fo.b = skeleton_die_frameset[s->i].frame;
  s->fo.dx = -skeleton_die_frameset[s->i + 1].dx;
  s->fo.dy = -skeleton_die_frameset[s->i + 1].dy;
  next_frame (&s->f, &s->f, &s->fo);
}
Example #25
0
JNIEXPORT jint JNICALL Java_com_frank_ffmpeg_VideoPlayer_filter
        (JNIEnv * env, jclass clazz, jstring filePath, jobject surface, jstring filterDescr){

    int ret;
    const char * file_name = (*env)->GetStringUTFChars(env, filePath, JNI_FALSE);
    const char *filter_descr = (*env)->GetStringUTFChars(env, filterDescr, JNI_FALSE);
    //打开输入文件
    if(!is_playing){
        LOGI("open_input...");
        if((ret = open_input(env, file_name, surface)) < 0){
            LOGE("Couldn't allocate video frame.");
            goto end;
        }
        //注册滤波器
        avfilter_register_all();
        filter_frame = av_frame_alloc();
        if(filter_frame == NULL) {
            LOGE("Couldn't allocate filter frame.");
            ret = -1;
            goto end;
        }
        //初始化音频解码器
        if ((ret = init_audio(env, clazz)) < 0){
            LOGE("Couldn't init_audio.");
            goto end;
        }

    }

    //初始化滤波器
    if ((ret = init_filters(filter_descr)) < 0){
        LOGE("init_filter error, ret=%d\n", ret);
        goto end;
    }

    is_playing = 1;
    int frameFinished;
    AVPacket packet;

    while(av_read_frame(pFormatCtx, &packet)>=0 && !release) {
        //切换滤波器,退出当初播放
        if(again){
            goto again;
        }
        //判断是否为视频流
        if(packet.stream_index == video_stream_index) {
            //对该帧进行解码
            avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);

            if (frameFinished) {
                //把解码后视频帧添加到filter_graph
                if (av_buffersrc_add_frame_flags(buffersrc_ctx, pFrame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) {
                    LOGE("Error while feeding the filter_graph\n");
                    break;
                }
                //把滤波后的视频帧从filter graph取出来
                ret = av_buffersink_get_frame(buffersink_ctx, filter_frame);
                if (ret >= 0){
                    // lock native window
                    ANativeWindow_lock(nativeWindow, &windowBuffer, 0);
                    // 格式转换
                    sws_scale(sws_ctx, (uint8_t const * const *)filter_frame->data,
                              filter_frame->linesize, 0, pCodecCtx->height,
                              pFrameRGBA->data, pFrameRGBA->linesize);
                    // 获取stride
                    uint8_t * dst = windowBuffer.bits;
                    int dstStride = windowBuffer.stride * 4;
                    uint8_t * src = pFrameRGBA->data[0];
                    int srcStride = pFrameRGBA->linesize[0];
                    // 由于window的stride和帧的stride不同,因此需要逐行复制
                    int h;
                    for (h = 0; h < pCodecCtx->height; h++) {
                        memcpy(dst + h * dstStride, src + h * srcStride, (size_t) srcStride);
                    }
                    ANativeWindow_unlockAndPost(nativeWindow);
                }
                av_frame_unref(filter_frame);
            }
            //延迟等待
            if (!playAudio){
                usleep((unsigned long) (1000 * 40));//1000 * 40
            }
        } else if(packet.stream_index == audio_stream_index){//音频帧
            if (playAudio){
                play_audio(env, &packet, pFrame);
            }
        }
        av_packet_unref(&packet);
    }
    end:
    is_playing = 0;
    //释放内存以及关闭文件
    av_free(buffer);
    av_free(pFrameRGBA);
    av_free(filter_frame);
    av_free(pFrame);
    avcodec_close(pCodecCtx);
    avformat_close_input(&pFormatCtx);
    avfilter_free(buffersrc_ctx);
    avfilter_free(buffersink_ctx);
    avfilter_graph_free(&filter_graph);
    avcodec_close(audioCodecCtx);
    free(buffer);
    free(sws_ctx);
    free(&windowBuffer);
    free(out_buffer);
    free(audio_swr_ctx);
    free(audio_track);
    free(audio_track_write_mid);
    ANativeWindow_release(nativeWindow);
    (*env)->ReleaseStringUTFChars(env, filePath, file_name);
    (*env)->ReleaseStringUTFChars(env, filterDescr, filter_descr);
    LOGE("do release...");
    again:
    again = 0;
    LOGE("play again...");
    return ret;
}
Example #26
0
void uart_play_audio(void) {
    play_audio( (u32 *) AUDIO_BASE_ADDR, RECORD_LENGTH);
}
Example #27
0
static bool
flow (struct anim *k)
{
  struct pos np;

  if (k->oaction != kid_hang_free)
    k->i = 5, k->j = -1, k->wait = 3, k->reverse = true;

  bool hang_back = ((k->f.dir == LEFT) ? k->key.right : k->key.left)
    && ! k->key.up && k->key.shift;

  int back_dir = (k->f.dir == LEFT) ? RIGHT : LEFT;

    /* hang back */
  if (k->i >= 7
      && hang_back && is_hangable_pos (&k->hang_pos, back_dir)) {
    play_audio (&hang_on_fall_audio, NULL, k->id);
    kid_turn (k);
    return false;
  }

  /* climb */
  if ((k->i < 5 || k->j > -1
       || k->hang_caller != kid_unclimb)
      && k->key.up
      && ! ((k->key.left || k->key.right)
            && k->hang_caller == kid_unclimb)
      && ! k->hang_limit) {
    kid_climb (k);
    return false;
  }

  /* release */
  if ((! k->key.shift || k->hang_limit
       || get_hanged_con (&k->hang_pos, k->f.dir) == NO_FLOOR)
      && (k->i < 5 || k->j > -1)) {
    int dir = (k->f.dir == LEFT) ? -1 : +1;
    k->hang_limit = false;
    if (! is_strictly_traversable (&k->hang_pos)
        && k->i >= 4) {
      place_frame (&k->f, &k->f, kid_vjump_frameset[13].frame,
                   &k->hang_pos, (k->f.dir == LEFT) ? +7 : PLACE_WIDTH + 9, -8);
      kid_vjump (k);
      return false;
    }
    if (! is_strictly_traversable (prel (&k->hang_pos, &np, +0, dir))
        && k->i <= 4) {
      place_frame (&k->f, &k->f, kid_vjump_frameset[13].frame,
                   &k->hang_pos, (k->f.dir == LEFT) ? +7 : PLACE_WIDTH + 5, -8);
      kid_vjump (k);
      return false;
    }
    if (is_strictly_traversable (&k->hang_pos)
        && k->i >= 4) {
      place_frame (&k->f, &k->f, kid_fall_frameset[0].frame,
                   &k->hang_pos, (k->f.dir == LEFT) ? +10 : +22, +4);
      kid_fall (k);
      return false;
    }
    if (is_strictly_traversable (prel (&k->hang_pos, &np, +0, dir))
        && k->i <= 4) {
      place_frame (&k->f, &k->f, kid_fall_frameset[0].frame,
                   &k->hang_pos, (k->f.dir == LEFT)
                   ? -10 : PLACE_WIDTH + 10, +12);
      kid_fall (k);
      return false;
    }
  }

  if (k->reverse && k->i > 0) {
    if (k->i == 4  && k->j++ > 0) k->hang_limit = true;
    k->i--;
  } else if (k->reverse && k->i == 0) {
    if (k->wait == 0) {
      k->reverse = false; k->i++;
    } else k->wait--;
  } else if (! k->reverse
             && ((k->j == 0 && k->i < 12)
                 || (k->j > 0 && k->i < 9))) k->i++;
  else if (! k->reverse
           && ((k->j == 0 && k->i == 12)
               || (k->j > 0 && k->i == 9))) {
    k->reverse = true; k->i--;
  }

  k->fo.b = kid_hang_frameset[k->i].frame;
  k->fo.dx = (k->reverse) ? -kid_hang_frameset[k->i + 1].dx
    : kid_hang_frameset[k->i].dx;
  k->fo.dy = (k->reverse) ? -kid_hang_frameset[k->i + 1].dy
    : kid_hang_frameset[k->i].dy;

  if (k->f.b == kid_hang_13) k->fo.dx = +0, k->fo.dy = +1;

  if (k->reverse && k->j == 0 && k->i == 0
      && k->wait < 3) k->fo.dy = 0;

  return true;
}
Example #28
0
static bool
flow (struct anim *k)
{
  if (k->oaction != kid_hang_wall)
    k->i = 3, k->wait = 0, k->reverse = false;

  bool hang_back = ((k->f.dir == LEFT) ? k->key.right : k->key.left)
    && ! k->key.up && k->key.shift;

  int back_dir = (k->f.dir == LEFT) ? RIGHT : LEFT;

  /* hang back */
  if (k->i == 4 && k->reverse
      && hang_back && is_hangable_pos (&k->hang_pos, back_dir)) {
    play_audio (&hang_on_fall_audio, NULL, k->id);
    kid_turn (k);
    return false;
  }

  if ((! k->key.shift && (k->reverse || k->i > 3))
      || k->hang_limit
      || get_hanged_con (&k->hang_pos, k->f.dir) == NO_FLOOR) {
    if (is_strictly_traversable (&k->hang_pos)) {
      place_frame (&k->f, &k->f, kid_fall_frameset[0].frame,
                   &k->hang_pos,
                   (k->f.dir == LEFT) ? +10 : +22, +4);
      kid_fall (k);
      k->hang_limit = false;
      return false;
    }
    place_frame (&k->f, &k->f, kid_vjump_frameset[13].frame,
                 &k->hang_pos, (k->f.dir == LEFT)
                 ? +12 : PLACE_WIDTH + 2, -8);
    kid_vjump (k);
    k->hang_limit = false;
    return false;
  } if (k->key.up
        && ! ((k->key.left || k->key.right)
              && k->hang_caller == kid_unclimb)
        && ! k->hang_limit) {
    kid_climb (k);
    return false;
  }

  if (! k->reverse && k->i < 6) k->i++;
  else if (! k->reverse && k->i == 6) k->reverse = true;
  else if (k->reverse && k->i > 4 && k->wait == 0)
    k->i--, k->wait = 1;
  else if (k->reverse && k->i >= 4 && k->wait > 0) k->wait--;

  k->fo.b = kid_hang_frameset[k->i].frame;
  k->fo.dx = (k->reverse) ? -kid_hang_frameset[k->i + 1].dx
    : kid_hang_frameset[k->i].dx;
  k->fo.dy = (k->reverse) ? -kid_hang_frameset[k->i + 1].dy
    : kid_hang_frameset[k->i].dy;

  if (k->f.b == kid_hang_13) k->fo.dx = +0, k->fo.dy = +1;

  if (k->reverse && k->wait == 0) {
    k->fo.dx = 0;
    k->fo.dy = 0;
  }

  return true;
}