Browse Source

Sound FX support

master
Alec Murphy 2 years ago
parent
commit
e503d99523
  1. 74
      Actor_Collision.HC
  2. 100
      Actor_WorkType.HC
  3. 14
      Dialog.HC
  4. 4
      Effects.HC
  5. 4
      Game.HC
  6. 1
      Main.HC
  7. 8
      Music.HC
  8. 2
      Palette.HC
  9. 58
      Player.HC
  10. 1
      Run.HC
  11. 213
      Sfx.HC

74
Actor_Collision.HC

@ -15,11 +15,11 @@ U0 actor_explode_container(ActorData *actor)
explode_effect_add_sprite(actor->data_2, 3, actor->x + 1 + 1, actor->y + 2);
if((sub_1106F() & 1) == 0)
{
//play_sfx(0x3d);
play_sfx(0x3d);
}
else
{
//play_sfx(12);
play_sfx(12);
}
actor_toss_add_new(actor->data_1, actor->x + 1, actor->y);
@ -71,7 +71,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
{
if (actor->count_down_timer == 0 && player_bounce_in_the_air(0x28) != 0)
{
//play_sfx(6);
play_sfx(6);
if (word_2E246 == 0)
{
word_2E246 = 1;
@ -86,7 +86,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
case 16: //47 OBJECT: Blue Mobile Trampoline Car
if (actor->count_down_timer == 0 && player_bounce_in_the_air(0x14) != 0)
{
//play_sfx(0x2b);
play_sfx(0x2b);
actor->data_1 = 3;
}
return 0;
@ -95,7 +95,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0)
{
actor->count_down_timer = 5;
//play_sfx(6);
play_sfx(6);
actor_tile_display_func_index = 2;
actor->data_1 = actor->data_1 - 1;
@ -135,7 +135,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0)
{
actor->count_down_timer = 3;
//play_sfx(6);
play_sfx(6);
actor->data_5 = actor->data_5 - 1;
actor_tile_display_func_index = 2;
@ -168,7 +168,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
case 187: // 218 ENEMY: Blue Bird
if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0)
{
//play_sfx(6);
play_sfx(6);
actor->is_deactivated_flag_maybe = 1;
exploding_balls_effect(actor->x, actor->y);
@ -195,7 +195,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
{
return 0;
}
//play_sfx(0x21);
play_sfx(0x21);
if (actor->data_2 != 0)
{
@ -210,7 +210,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
case 86: // 117 ENEMY: Blue Ball
if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0)
{
//play_sfx(6);
play_sfx(6);
actor->data_3 = 0;
actor->count_down_timer = 3;
@ -267,7 +267,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
case 101: // 132 ENEMY: Big Red Jumper FIXME might need new logic from COSMO2 or 3 EXEs
if (actor->count_down_timer == 0 && player_bounce_in_the_air(15) != 0)
{
//play_sfx(6);
play_sfx(6);
actor->count_down_timer = 6;
actor->data_5 = actor->data_5 - 1;
@ -300,7 +300,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0)
{
actor->count_down_timer = 3;
//play_sfx(6);
play_sfx(6);
actor_tile_display_func_index = 2;
if (actorInfoIndex != 0x76)
{
@ -330,7 +330,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0)
{
player_add_score_for_actor(0x7c);
//play_sfx(6);
play_sfx(6);
exploding_balls_effect(actor->x, actor->y);
@ -345,7 +345,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
actor->count_down_timer == 0 && player_bounce_in_the_air(15) != 0)
{
actor->count_down_timer = 3;
//play_sfx(6);
play_sfx(6);
if (actor->data_1 == 0)
{
@ -371,7 +371,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0)
{
num_hits_since_touching_ground = 0;
//play_sfx(6);
play_sfx(6);
actor->count_down_timer = 5;
}
else
@ -387,7 +387,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
case 188: // 219 OBJECT: Rocket
if (actor->x == player_x_pos && actor->count_down_timer == 0 && player_bounce_in_the_air(5) != 0)
{
//play_sfx(6);
play_sfx(6);
}
return 0;
@ -405,7 +405,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
if (actor->count_down_timer != 0 || player_bounce_in_the_air(0x14) == 0)
{//FIXME is this correct?
}
//play_sfx(6);
play_sfx(6);
byte_2E17C = 0;
hide_player_sprite = 0;
word_2E180 = 0;
@ -450,7 +450,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
actor->has_moved_left_flag = 1;
actor->data_2 = 0;
actor->data_1 = 1;
//play_sfx(0x3e);
play_sfx(0x3e);
}
return 0;
@ -467,7 +467,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
}
if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0)
{
//play_sfx(6);
play_sfx(6);
actor->data_5 = actor->data_5 + 1;
actor->has_moved_left_flag = 10;
@ -485,7 +485,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
if (actor->data_5 == 4)
{
explode_effect_add_sprite(0x66, 1, actor->x, actor->y - 4);
//play_sfx(0x37);
play_sfx(0x37);
}
effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 1);
@ -603,7 +603,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
case 27: // 59 BONUS: Power Up (health/12800)
actor->is_deactivated_flag_maybe = 1;
//play_sfx(1);
play_sfx(1);
effect_add_sprite(15, 4, actor->x, actor->y, 0, 3);
if (knows_about_powerups_flag == 0)
@ -658,7 +658,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
actor_add_new(0xb4, x_pos, y_pos);
}
effect_add_sprite(15, 4, actor->x, actor->y, 0, 3);
//play_sfx(13);
play_sfx(13);
return 1;
case 56: // 88: bonus bomb
@ -673,7 +673,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
display_num_bombs_left();
effect_add_sprite(15, 4, actor->x, actor->y, 0, 3);
//play_sfx(13);
play_sfx(13);
return 1;
}
return 0;
@ -691,11 +691,11 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
}
else
{
//play_sfx(6);
play_sfx(6);
}
actor_toss_add_new(green_roamer_worm_tbl[sub_1106F() & 3], actor->x, actor->y + 1);
//play_sfx(0x11);
play_sfx(0x11);
actor_tile_display_func_index = 2;
actor->data_2 = actor->data_2 - 1;
@ -730,7 +730,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
break;
}
//play_sfx(0x16);
play_sfx(0x16);
return 1;
case 104: // 136: pneumatic pipe entrance
@ -804,7 +804,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
return 0;
}
player_hoverboard_counter = 4;
//play_sfx(3);
play_sfx(3);
player_reset_push_variables();
byte_2E2E4 = 0;
word_2E180 = 0;
@ -852,7 +852,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
actor->data_4 = 5;
hide_player_sprite = 1;
byte_2E17C = 1;
//play_sfx(0x27);
play_sfx(0x27);
}
return 1;
@ -899,7 +899,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
byte_2E17C = 1;
hide_player_sprite = 1;
actor->frame_num = 1;
//play_sfx(0x27);
play_sfx(0x27);
}
return 0;
@ -907,7 +907,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
effect_add_sprite(0x17, 8, x_pos, y_pos, 0, 1);
num_stars_collected++;
actor->is_deactivated_flag_maybe = 1;
//play_sfx(1);
play_sfx(1);
player_add_score_for_actor(actorInfoIndex);
actor_add_new(0xb2, x_pos, y_pos);
display_num_stars_collected();
@ -919,7 +919,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
actor_add_new(0xb8, x_pos, y_pos);
effect_add_sprite(15, 4, actor->x, actor->y, 0, 3);
//play_sfx(13);
play_sfx(13);
if (num_health_bars < 5)
{
num_health_bars++;
@ -941,7 +941,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
actor_add_new(0xb2, x_pos, y_pos);
effect_add_sprite(15, 4, actor->x, actor->y, 0, 3);
//play_sfx(13);
play_sfx(13);
return 1;
case 188: // 220 BONUS: Invincibility Cube
@ -949,7 +949,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
actor_add_new(0xc9, player_x_pos - 1, player_y_pos + 1);
effect_add_sprite(0x17, 8, x_pos, y_pos, 0, 1);
actor_add_new(0xb8, x_pos, y_pos);
//play_sfx(1);
play_sfx(1);
return 1;
case 152: // 184 unknown
@ -959,7 +959,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
effect_add_sprite(15, 4, actor->x, actor->y, 0, 3);
player_add_to_score(0xc80);
actor_add_new(0xb6, x_pos, y_pos);
//play_sfx(13);
play_sfx(13);
return 1;
case 153: // 185 BONUS: Blue Crystal (on ground)
@ -968,7 +968,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
effect_add_sprite(15, 4, actor->x, actor->y, 0, 3);
player_add_to_score(0x640);
actor_add_new(0xb5, x_pos, y_pos);
//play_sfx(13);
play_sfx(13);
return 1;
case 193: // 225 BONUS: Diamond 2 (falling)
@ -980,7 +980,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
effect_add_sprite(15, 4, actor->x, actor->y, 0, 3);
player_add_to_score(0x320);
actor_add_new(0xb4, x_pos, y_pos);
//play_sfx(13);
play_sfx(13);
return 1;
case 1: // 33: floor spring
@ -988,7 +988,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
(byte_2E2E4 == 0 || player_bounce_flag_maybe != 0))
{
actor->count_down_timer = 2;
//play_sfx(6);
play_sfx(6);
actor->data_1 = 3;
player_bounce_height_counter = 0;
player_bounce_flag_maybe = 0;
@ -1043,7 +1043,7 @@ I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x
{
push_player_around(7, 5, 2, 0x28, 0, 1);
}
//play_sfx(0x14);
play_sfx(0x14);
return 0;
case 62:

100
Actor_WorkType.HC

@ -47,7 +47,7 @@ U0 actor_wt_133_boss_purple_15411(ActorData *actor)
{
effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 1);
effect_add_sprite(0x61, 6, actor->x + 3, actor->y, 2, 1);
//play_sfx(0x38);
play_sfx(0x38);
}
}
@ -137,7 +137,7 @@ U0 actor_wt_133_boss_purple_15411(ActorData *actor)
actor->data_3 = actor->data_3 + 1;
if(actor->data_3 % 14 == 1)
{
//play_sfx(0x38);
play_sfx(0x38);
}
actor->data_2 = actor->data_2 + 1;
@ -148,7 +148,7 @@ U0 actor_wt_133_boss_purple_15411(ActorData *actor)
if(sprite_blocking_check(2, 0x66, 0, actor->x - 1, actor->y) != NOT_BLOCKED)
{
actor->data_4 = 1;
//play_sfx(0x25);
play_sfx(0x25);
effect_add_sprite(0x61, 6, actor->x, actor->y - 2, 5, 1);
}
@ -166,7 +166,7 @@ U0 actor_wt_133_boss_purple_15411(ActorData *actor)
else
{
actor->data_4 = 0;
//play_sfx(0x25);
play_sfx(0x25);
effect_add_sprite(0x61, 6, actor->x + 3, actor->y - 2, 5, 1);
}
@ -218,7 +218,7 @@ U0 actor_wt_133_boss_purple_15411(ActorData *actor)
actor->data_3 = 0;
actor->can_fall_down_flag = 0;
actor->falling_counter = 0;
//play_sfx(0x32);
play_sfx(0x32);
effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 1);
effect_add_sprite(0x61, 6, actor->x + 3, actor->y, 2, 1);
@ -233,7 +233,7 @@ U0 actor_wt_133_boss_purple_15411(ActorData *actor)
actor->data_3 = 0;
actor->can_fall_down_flag = 0;
actor->falling_counter = 0;
//play_sfx(0x25);
play_sfx(0x25);
effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 1);
effect_add_sprite(0x61, 6, actor->x + 3, actor->y, 2, 1);
@ -354,7 +354,7 @@ U0 actor_wt_acid(ActorData *actor)
actor->frame_num = 4;
if(is_sprite_on_screen(0x2b, 6, actor->x, actor->data_2) != 0)
{
//play_sfx(0x15);
play_sfx(0x15);
}
return;
}
@ -481,7 +481,7 @@ U0 actor_wt_big_red_jumper(ActorData *actor)
}
else
{
//play_sfx(0x1f);
play_sfx(0x1f);
}
}
else
@ -613,7 +613,7 @@ U0 actor_wt_big_red_jumper(ActorData *actor)
actor->data_2 = 0;
if(is_sprite_on_screen(0x65, 0, actor->x, actor->y) != 0)
{
//play_sfx(0x20);
play_sfx(0x20);
}
return;
}
@ -631,7 +631,7 @@ U0 actor_wt_big_red_jumper(ActorData *actor)
actor->data_2 = 0;
if(is_sprite_on_screen(0x65, 0, actor->x, actor->y) != 0)
{
//play_sfx(0x20);
play_sfx(0x20);
}
}
else
@ -691,7 +691,7 @@ U0 actor_wt_big_red_plant(ActorData *actor)
if(actor->data_1 == 2 && actor->has_moved_left_flag == 0)
{
actor_toss_add_new(0x56, actor->x + 2, actor->y - 5);
//play_sfx(0x2f);
play_sfx(0x2f);
}
if(actor->data_1 == 5)
@ -730,7 +730,7 @@ U0 actor_wt_big_red_plant(ActorData *actor)
if(actor->data_1 == 2 && actor->has_moved_left_flag == 0)
{
actor_toss_add_new(0x56, actor->x + 2, actor->y - 5);
//play_sfx(0x2f);
play_sfx(0x2f);
}
if(actor->data_1 == 5)
@ -750,7 +750,7 @@ U0 actor_wt_big_saw_blade(ActorData *actor)
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
if(is_sprite_on_screen(actor->actorInfoIndex, 0, actor->x, actor->y) != 0)
{
//play_sfx(0x23);
play_sfx(0x23);
}
if(actor->data_1 != 0)
@ -787,7 +787,7 @@ U0 actor_wt_big_yellow_spike(ActorData *actor)
{
actor->is_deactivated_flag_maybe = 1;
effect_add_sprite(0x61, 6, actor->x, actor->y, 1, 3);
//play_sfx(0x1b);
play_sfx(0x1b);
actor_tile_display_func_index = 1;
}
}
@ -1211,7 +1211,7 @@ U0 actor_wt_blue_cube_platform(ActorData *actor)
explode_effect_add_sprite(0xa3, 1, actor->x, actor->y);
explode_effect_add_sprite(0xa3, 2, actor->x, actor->y);
//play_sfx(0x19);
play_sfx(0x19);
actor_tile_display_func_index = 2;
return;
}
@ -1587,7 +1587,7 @@ U0 actor_wt_clam_trap(ActorData *actor)
{
if(actor->data_3 == 1)
{
//play_sfx(0x28);
play_sfx(0x28);
}
actor->frame_num = clam_trap_frame_num_tbl[actor->data_3];
actor->data_3++;
@ -1696,7 +1696,7 @@ U0 actor_wt_crate_bomb_box(ActorData *actor)
explode_effect_add_sprite(0x83, 5, actor->x, actor->y);
explode_effect_add_sprite(0x83, 6, actor->x + 5, actor->y + 5);
//play_sfx(0x19);
play_sfx(0x19);
}
U0 actor_wt_cyan_spitting_plant(ActorData *actor)
@ -1859,7 +1859,7 @@ U0 actor_wt_egg_head(ActorData *actor)
{
actor->data_1 = 1;
actor->data_2 = 0x14;
//play_sfx(0x21);
play_sfx(0x21);
}
}
}
@ -1881,7 +1881,7 @@ U0 actor_wt_egg_head(ActorData *actor)
effect_add_sprite(0x4d, 1, actor->x + 1, actor->y - 1, 2, 5);
effect_add_sprite(0x84, 1, actor->x, actor->y, 3, 5);
effect_add_sprite(0x85, 1, actor->x + 1, actor->y, 7, 5);
//play_sfx(0x22);
play_sfx(0x22);
}
}
@ -1971,7 +1971,7 @@ U0 actor_wt_extending_arrow(ActorData *actor)
{
if(is_sprite_on_screen(actor->actorInfoIndex, 0, actor->x, actor->y) != 0)
{
//play_sfx(9);
play_sfx(9);
}
}
@ -2152,7 +2152,7 @@ U0 actor_wt_green_plant(ActorData *actor)
{
if(actor->data_4 == 7)
{
//play_sfx(0x35);
play_sfx(0x35);
}
actor->data_4 = actor->data_4 - 1;
@ -2375,7 +2375,7 @@ U0 actor_wt_hint_dialog(ActorData *actor)
}
if((up_key_pressed != 0 && player_hoverboard_counter == 0) || byte_2E21C == 0)
{
//play_sfx(0x1e);
play_sfx(0x1e);
ingame_hint_dialogs(actor->data_5);
}
byte_2E21C = 1;
@ -2399,7 +2399,7 @@ U0 actor_wt_horizontal_flame(ActorData *actor)
if(actor->frame_num == 2)
{
effect_add_sprite(0x61, 6, actor->x - actor->data_5, actor->y - 3, 1, 1);
//play_sfx(0x36);
play_sfx(0x36);
}
actor->data_2++;
if(actor->data_2 == 0x10)
@ -2468,7 +2468,7 @@ U0 actor_wt_jaws_and_tongue(ActorData *actor)
actor->data_2 = 11;
actor->frame_num = 1;
actor->data_5 = 1;
//play_sfx(0x26);
play_sfx(0x26);
}
if(actor->frame_num != 0)
@ -2516,7 +2516,7 @@ U0 actor_wt_jumping_bullet_head(ActorData *actor)
actor->data_2 = Cond(actor->data_2, -1, 0) + 1;
if(is_sprite_on_screen(0x2e, 0, actor->x, actor->y) != 0)
{
//play_sfx(0x25);
play_sfx(0x25);
}
actor->data_3 = 0;
}
@ -2542,7 +2542,7 @@ U0 actor_wt_mini_ghost(ActorData *actor)
actor->data_3 = 1;
if(is_sprite_on_screen(0x41, 0, actor->x, actor->y) != 0)
{
//play_sfx(0x3b);
play_sfx(0x3b);
}
return;
}
@ -2572,7 +2572,7 @@ U0 actor_wt_mini_ghost(ActorData *actor)
{
if(is_sprite_on_screen(0x41, 0, actor->x, actor->y) != 0)
{
//play_sfx(0x3a);
play_sfx(0x3a);
}
}
@ -2746,7 +2746,7 @@ U0 actor_wt_plasma_fireball(ActorData *actor)
{
if(actor->data_1 == 0x1d)
{
//play_sfx(0x24);
play_sfx(0x24);
}
if(actor->data_1 >= 0x1e)
@ -2765,7 +2765,7 @@ U0 actor_wt_plasma_fireball(ActorData *actor)
actor->x = actor->data_2;
actor->y = actor->data_3;
//play_sfx(0x1b);
play_sfx(0x1b);
}
}
else
@ -2780,7 +2780,7 @@ U0 actor_wt_plasma_fireball(ActorData *actor)
actor->x = actor->data_2;
actor->y = actor->data_3;
//play_sfx(0x1b);
play_sfx(0x1b);
}
}
}
@ -2839,7 +2839,7 @@ U0 actor_wt_projectile_flashing_ball(ActorData *actor)
if(actor->data_1 == 0)
{
actor->data_1 = 1;
//play_sfx(0x1a);
play_sfx(0x1a);
}
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
@ -2925,7 +2925,7 @@ U0 actor_wt_red_blue_plant(ActorData *actor)
actor->frame_num = actor->frame_num + 1;
if(actor->frame_num == 1)
{
//play_sfx(0x3f);
play_sfx(0x3f);
}
if(actor->frame_num == 4)
@ -3115,14 +3115,14 @@ U0 actor_wt_retracting_spikes(ActorData *actor)
else
{
actor->data_1 = 1;
//play_sfx(9);
play_sfx(9);
actor_tile_display_func_index = 1;
}
}
else
{
actor->data_1 = 0;
//play_sfx(9);
play_sfx(9);
}
if(actor->frame_num == 2)
{
@ -3276,7 +3276,7 @@ U0 actor_wt_robotic_spike_ground(ActorData *actor)
actor->data_3 = 1;
if(is_sprite_on_screen(actor->actorInfoIndex, 0, actor->x, actor->y) != 0)
{
//play_sfx(0x23);
play_sfx(0x23);
}
}
@ -3351,7 +3351,7 @@ U0 actor_wt_rocket(ActorData *actor)
effect_add_sprite(0x61, 6, actor->x - 1, actor->y + 1, 7, 1);
effect_add_sprite(0x61, 6, actor->x + 1, actor->y + 1, 3, 1);
//play_sfx(0x31);
play_sfx(0x31);
}
if(actor->data_2 > 1)
@ -3372,7 +3372,7 @@ U0 actor_wt_rocket(ActorData *actor)
if(is_sprite_on_screen(actor->actorInfoIndex, 0, actor->x, actor->y) != 0)
{
//play_sfx(0x31);
play_sfx(0x31);
}
}
@ -3480,7 +3480,7 @@ U0 actor_wt_rubber_wall(ActorData *actor)
actor_add_new(0xb8, actor->x - 2, actor->y - 9);
actor_add_new(0xb8, actor->x + 1 + 1, actor->y - 9);
//play_sfx(0x19);
play_sfx(0x19);
return;
}
@ -3552,7 +3552,7 @@ U0 actor_wt_satellite(ActorData *actor)
actor->is_deactivated_flag_maybe = 1;
actor_tile_display_func_index = 2;
//play_sfx(0x12);
play_sfx(0x12);
actor->data_1 = 1;
for(; actor->data_1 < 9; actor->data_1++)
@ -3724,7 +3724,7 @@ U0 actor_wt_silver_robot(ActorData *actor)
actor->frame_num = 2;
actor->data_2 = 8;
push_player_around(7, 5, 2, 0x28, 0, 1);
//play_sfx(0x14);
play_sfx(0x14);
player_direction = 0x17;
actor->data_4 = 3;
actor_tile_display_func_index = 0;
@ -3764,7 +3764,7 @@ U0 actor_wt_silver_robot(ActorData *actor)
actor->frame_num = 5;
actor->data_2 = 8;
push_player_around(3, 5, 2, 0x11, 0, 1);
//play_sfx(0x14);
play_sfx(0x14);
player_direction = 0;
actor->data_4 = 3;
actor_tile_display_func_index = 0;
@ -3835,7 +3835,7 @@ U0 actor_wt_small_red_plant(ActorData *actor)
if(actor->frame_num == 1)
{
actor->x = actor->x - 1;
//play_sfx(0x3f);
play_sfx(0x3f);
}
if(actor->frame_num == 2)
@ -4025,7 +4025,7 @@ U0 actor_wt_stone_head(ActorData *actor)
actor->data_1 = 2;
if(is_sprite_on_screen(0x2f, 0, actor->x, actor->y) != 0)
{
//play_sfx(0x25);
play_sfx(0x25);
effect_add_sprite(0x61, 6, actor->x + 1, actor->y, 2, 1);
effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 1);
@ -4042,7 +4042,7 @@ U0 actor_wt_stone_head(ActorData *actor)
if(sprite_blocking_check(1, 0x2f, 0, actor->x, actor->y) != NOT_BLOCKED)
{
actor->data_1 = 2;
//play_sfx(0x25);
play_sfx(0x25);
effect_add_sprite(0x61, 6, actor->x + 1, actor->y, 2, 1);
@ -4440,7 +4440,7 @@ U0 activate_switch_maybe(I64 actorInfoIndex, ActorData *switch_actor)
else
{
actor->is_deactivated_flag_maybe = 1;
//play_sfx(8);
play_sfx(8);
effect_add_sprite(actorInfoIndex, 1, actor->x, actor->y, 5, 5);
}
activate_switch_maybe_cont:
@ -4479,7 +4479,7 @@ U0 actor_wt_switch_multi_use(ActorData *actor)
write_tile_row_to_tilemap(0x3d88, 0x3d90, 0x3d98, 0x3da0, actor->x, actor->y);
if(actor->data_1 == 4)
{
//play_sfx(0x10);
play_sfx(0x10);
switch (actor->data_5)
{
case 59:
@ -4506,7 +4506,7 @@ U0 actor_wt_switch_multi_use(ActorData *actor)
}
else
{
//play_sfx(15);
play_sfx(15);
}
}
@ -4553,7 +4553,7 @@ U0 actor_wt_teleporter(ActorData *actor)
effect_add_sprite(15, 4, player_x_pos - 1, player_y_pos - 3, 0, 2);
effect_add_sprite(15, 4, player_x_pos, player_y_pos - 2, 0, 3);
effect_add_sprite(15, 4, player_x_pos + 1, player_y_pos - 3, 0, 3);
//play_sfx(0x17);
play_sfx(0x17);
}
if(teleporter_counter > 1)
{
@ -4637,7 +4637,7 @@ U0 actor_wt_two_tons(ActorData *actor)
actor->data_2 = 2;
if(is_sprite_on_screen(0x2d, 4, actor->x - 1, actor->y + 3) != 0)
{
//play_sfx(0x25);
play_sfx(0x25);
}
}
else
@ -4745,7 +4745,7 @@ U0 actor_wt_speech_bubble(ActorData *actor)
actor_tile_display_func_index = 1;
if(actor->data_1 == 0)
{
//play_sfx(0x39);
play_sfx(0x39);
if(actor->actorInfoIndex == 0xf6)
{
player_add_to_score(0xc350);

14
Dialog.HC

@ -118,7 +118,7 @@ U0 display_dialog_text_with_color(U16 x_pos, U16 y_pos, U8 *text, U8 text_color)
typewriter_keys_count = typewriter_delay_counter;
if (c != 0x20)
{
//play_sfx(0x2c);
play_sfx(0x2c);
}
video_update();
display_char(x_pos + x, y_pos, c, text_color);
@ -512,7 +512,7 @@ U0 now_entering_level_n_dialog(U16 level_number)
{
U16 x = create_text_dialog_box(7, 3, 0x18, " Now entering level ", "");
cosmo_wait(0x14);
//play_sfx(0x40);
play_sfx(0x40);
if(level_numbers_tbl[level_number] != 10)
{
display_number(x + 0x14, 8, level_numbers_tbl[level_number]);
@ -578,7 +578,7 @@ I64 main_menu() {
stop_music();
show_one_moment_screen_flag = 1;
show_monster_attack_hint = 0;
//play_sfx(0x30);
play_sfx(0x30);
return PLAY_GAME;
}
@ -708,7 +708,7 @@ I64 main_menu() {
U0 no_bombs_dialog() {
if(game_play_mode == PLAY_GAME)
{
//play_sfx(0x1e);
play_sfx(0x1e);
U16 x = create_text_dialog_box(2, 4, 0x1c, "", "");
x++;
display_dialog_text(x, 3, "You haven't found any");
@ -722,7 +722,7 @@ U0 power_up_module_dialog()
{
if(game_play_mode == PLAY_GAME)
{
//play_sfx(0x1e);
play_sfx(0x1e);
I64 si = create_text_dialog_box(2, 5, 0x16, "", "");
display_dialog_text(si, 3, " Power Up modules");
display_dialog_text(si, 4, " increase Cosmo's");
@ -737,7 +737,7 @@ U0 monster_attack_hint_dialog()
{
if(game_play_mode == PLAY_GAME)
{
//play_sfx(0x1e);
play_sfx(0x1e);
U16 si = create_text_dialog_box(2, 5, 0x16, "REMINDER: Jump on", "defend yourself. ");
display_dialog_text(si, 4, " top of creatures to");
cosmo_wait(0x3c);
@ -789,7 +789,7 @@ U0 display_score_from_level()
{
display_clear_tile_to_gray(0x17 + j, 0xc);
}
//play_sfx(1);
play_sfx(1);
display_number(0x1d, 0xc, score);
if (star_counter / 6 < 13)

4
Effects.HC

@ -307,7 +307,7 @@ U0 struct6_add_sprite(I64 x_pos, I64 y_pos)
sprite->counter = 1;
sprite->x = x_pos;
sprite->y = y_pos + 2;
//play_sfx(0xa);
play_sfx(0xa);
return;
}
}
@ -440,7 +440,7 @@ U0 explode_effect_update_sprites()
}
sprite->counter = 3;
sprite->fall_through_floor = 1;
//play_sfx(0x2e);
play_sfx(0x2e);
explode_while_cont1:
}
explode_while_cont2:

4
Game.HC

@ -222,7 +222,7 @@ U0 select_next_level()
{
fade_to_black(0);
display_fullscreen_image(3);
//play_sfx(0x2d);
play_sfx(0x2d);
if(tmp_num_stars_collected > 49)
{
current_level++;
@ -326,7 +326,7 @@ Bool executeTick() {
if (finished_level_flag_maybe)
{
finished_level_flag_maybe = 0;
//play_sfx(11);
play_sfx(11);
select_next_level();
load_level(current_level);
}

1
Main.HC

@ -18,6 +18,7 @@ I64 main(...)
game_init();
//audio_init();
music_init();
load_sfx();
video_fill_screen_with_black();

8
Music.HC

@ -67,16 +67,22 @@ U0 music_callback(SND_OUT_CONTAINER *buf,I64)
{
delay_counter -= i;
adlib_getsample(stream, i, is_stereo);
//mix_sfx(stream, i);
mix_sfx(buf);
return;
}
if(delay_counter <= i)
{
i -= delay_counter;
adlib_getsample(stream, delay_counter, is_stereo);
//mix_sfx(stream, delay_counter);
stream += delay_counter * SND_OCHANNELS * SND_SAMPLE_BITS/8;
delay_counter = 0;
}
}
mix_sfx(buf);
}
U0 play_music()
@ -86,7 +92,7 @@ U0 play_music()
U0 stop_music()
{
fp_snd_fill_buf=&HDFillBuf;
fp_snd_fill_buf=&sfx_callback;
}
U0 load_music(U16 new_music_index)

2
Palette.HC

@ -113,7 +113,7 @@ U0 update_palette_anim()
else
{
set_palette_color(5, 0x17);
//play_sfx(0x3c);
play_sfx(0x3c);
next_pal_colour = 1;
}
break;

58
Player.HC

@ -225,7 +225,7 @@ U0 player_decrease_health()
{
update_health_bar_display();
player_invincibility_counter = 0x2c;
//play_sfx(14);
play_sfx(14);
}
else
{
@ -682,26 +682,26 @@ U0 handle_player_input_maybe()
{
if(top_bomb_check_flag != 0)
{
//play_sfx(0x1c);
play_sfx(0x1c);
}
else
{
if(bottom_bomb_check_flag != 0)
{
//play_sfx(0x1c);
play_sfx(0x1c);
}
else
{
if(num_bombs <= 0)
{
//play_sfx(0x1c);
play_sfx(0x1c);
}
else
{
actor_add_new(0x18, player_x_pos - 2, player_y_pos - 2);
num_bombs = num_bombs - 1;
display_num_bombs_left();
//play_sfx(0x1d);
play_sfx(0x1d);
}
}
}
@ -726,7 +726,7 @@ U0 handle_player_input_maybe()
}
if(top_bomb_check_flag != 0)
{
//play_sfx(0x1c);
play_sfx(0x1c);
}
else
{
@ -737,16 +737,16 @@ U0 handle_player_input_maybe()
actor_add_new(0x18, player_x_pos + 3, player_y_pos - 2);
num_bombs = num_bombs - 1;
display_num_bombs_left();
//play_sfx(0x1d);
play_sfx(0x1d);
}
else
{
//play_sfx(0x1c);
play_sfx(0x1c);
}
}
else
{
//play_sfx(0x1c);
play_sfx(0x1c);
}
}
}
@ -831,7 +831,7 @@ U0 handle_player_input_maybe()
player_hanging_on_wall_direction = 2;
player_bounce_flag_maybe = 0;
player_bounce_height_counter = 0;
//play_sfx(4);
play_sfx(4);
byte_2E2E4 = 0;
byte_2E182 = 0;
word_2E180 = 0;
@ -890,7 +890,7 @@ U0 handle_player_input_maybe()
player_hanging_on_wall_direction = 3;
player_bounce_flag_maybe = 0;
player_bounce_height_counter = 0;
//play_sfx(4);
play_sfx(4);
byte_2E182 = 0;
byte_2E2E4 = 0;
word_2E180 = 0;
@ -1014,7 +1014,7 @@ U0 handle_player_input_maybe()
{
if(var_4 != 0 && byte_2E182 == 0)
{
//play_sfx(2);
play_sfx(2);
}
}
else
@ -1022,7 +1022,7 @@ U0 handle_player_input_maybe()
if(byte_2E182 > 0 || player_bounce_flag_maybe != 0)
{
//loc_1E420:
//play_sfx(5);
play_sfx(5);
}
player_bounce_height_counter = 0;
player_bounce_flag_maybe = 0;
@ -1072,7 +1072,7 @@ U0 handle_player_input_maybe()
{
if(word_2E180 != 0)
{
//play_sfx(3);
play_sfx(3);
}
byte_2E2E4 = 0;
player_y_pos = player_y_pos - 1;
@ -1093,7 +1093,7 @@ U0 handle_player_input_maybe()
mapwindow_y_offset = mapwindow_y_offset + 1;
if(player_check_movement(1, player_x_pos, player_y_pos) != NOT_BLOCKED)
{
//play_sfx(3);
play_sfx(3);
byte_2E2E4 = 0;
player_y_pos = player_y_pos - 1;
mapwindow_y_offset = mapwindow_y_offset - 1;
@ -1294,7 +1294,7 @@ U0 handle_player_input_maybe()
{
if((player_sprite_dir_frame_offset & 1) != 0)
{
//play_sfx(0x13);
play_sfx(0x13);
}
player_sprite_dir_frame_offset = player_sprite_dir_frame_offset + 1;
}
@ -1525,7 +1525,7 @@ U0 player_hoverboard_update()
word_2E1E8 = 1;
player_bounce_in_the_air(9);
player_bounce_height_counter -= 2;
//play_sfx(2);
play_sfx(2);
return;
}
}
@ -1558,7 +1558,7 @@ U0 player_hoverboard_update()
if ((player_x_pos & 1) != 0)
{
effect_add_sprite(0x13, 4, player_x_pos + 3, player_y_pos + 1, 3, 1);
//play_sfx(0x18);
play_sfx(0x18);
}
}
@ -1584,7 +1584,7 @@ U0 player_hoverboard_update()
if ((player_x_pos & 1) != 0)
{
effect_add_sprite(0x13, 4, player_x_pos - 1, player_y_pos + 1, 7, 1);
//play_sfx(0x18);
play_sfx(0x18);
}
}
@ -1621,7 +1621,7 @@ U0 player_hoverboard_update()
if ((player_y_pos & 1) != 0)
{
effect_add_sprite(0x13, 4, player_x_pos + 1, player_y_pos + 1, 5, 1);
//play_sfx(0x18);
play_sfx(0x18);
}
}
@ -1653,11 +1653,11 @@ U0 player_hoverboard_update()
actor_add_new(0x18, player_x_pos - 2, player_y_pos - 2);
num_bombs = num_bombs - 1;
display_num_bombs_left();
//play_sfx(0x1d);
play_sfx(0x1d);
}
else
{
//play_sfx(0x1c);
play_sfx(0x1c);
}
}
else
@ -1669,11 +1669,11 @@ U0 player_hoverboard_update()
actor_add_new(0x18, player_x_pos + 3, player_y_pos - 2);
num_bombs = num_bombs - 1;
display_num_bombs_left();
//play_sfx(0x1d);
play_sfx(0x1d);
}
else
{
//play_sfx(0x1c);
play_sfx(0x1c);
}
}
}
@ -1725,7 +1725,7 @@ U0 player_update_walk_anim()
{
word_32EB2 = 0;
player_walk_anim_index = 8;
//play_sfx(3);
play_sfx(3);
}
if(player_walk_anim_index != 0)
{
@ -1766,7 +1766,7 @@ I64 player_update_sprite()
player_fall_off_map_bottom_counter = player_fall_off_map_bottom_counter + 1;
if (player_fall_off_map_bottom_counter == 2)
{
//play_sfx(14);
play_sfx(14);
}
while (player_fall_off_map_bottom_counter < 12)
@ -1777,7 +1777,7 @@ I64 player_update_sprite()
if (player_fall_off_map_bottom_counter == 13)
{
//play_sfx(7);
play_sfx(7);
}
if (player_fall_off_map_bottom_counter > 12 && player_fall_off_map_bottom_counter < 0x13)
{
@ -1840,7 +1840,7 @@ I64 player_update_sprite()
}
if (player_death_counter == 10)
{
//play_sfx(7);
play_sfx(7);
}
player_y_pos = player_y_pos - 1;
player_death_counter = player_death_counter + 1;
@ -1858,7 +1858,7 @@ I64 player_update_sprite()
{
if (player_death_counter == 1)
{
//play_sfx(14);
play_sfx(14);
}
player_death_counter = player_death_counter + 1;

1
Run.HC

@ -9,6 +9,7 @@
#include "HDAudio";
#include "Opl";
#include "Sfx";
#include "Music";
#include "Font";

213
Sfx.HC

@ -0,0 +1,213 @@
#define MAX_SAMPLES_PER_FILE 23 //the game only reads the first 23 sfx in each file.
#define SFX_SAMPLE_RATE 140
#define PC_PIT_RATE 1193181
#define WAVE_AMPLITUDE_VALUE 3500
class Mix_Chunk {
I64 allocated;
U8 *abuf;
U32 alen;
U8 volume; /* Per-sample volume, 0-128 */
};
class Sfx {
U8 priority;
Mix_Chunk *sample;
};
Sfx *sfxs;
I64 num_sfx = 0;
I64 currently_playing_priority=0;
U8 sfx_on_flag = 1;
U32 sfx_pos = 0;
I64 sfx_num = -1;
U0 mix_sfx(U32 *buf)
{
I64 i;
I64 j;
Mix_Chunk *sample;
U32 *raw;
if (sfx_num < 0) return;
sample = sfxs[sfx_num-1].sample;
j = Min(SND_BUF_LEN * 4, sample->alen - sfx_pos);
j /= 4;
raw = sample->abuf + sfx_pos;
for (i=0;i<j;i++)
{
buf[i] += raw[i];
}
sfx_pos += j * 4;
if (sfx_pos >= sample->alen)
{
sfx_pos = 0;
sfx_num = -1;
}
}
U0 sfx_callback(SND_OUT_CONTAINER *buf,I64)
{
I64 i;
for (i=0;i<SND_BUF_LEN;i++)
{
buf[i]=0;
}
mix_sfx(buf);
}
I64 get_num_sfx(U8 *filename)
{
File file;
open_file(filename, &file);
file_seek(&file, 6);
I64 count = file_read2(&file);
file_close(&file);
return count;
}
I64 get_num_samples(File *file, I64 offset, I64 index, I64 total)
{
if(index < total - 1)
{
file_seek(file, (index+2)*16);
I64 next_offset = file_read2(file);
return ((next_offset - offset) / 2) - 1;
}
return ((file_get_filesize(file) - offset) / 2) - 1;
}
U0 writeSample(U8 *buf, U16 index, I16 sample) {
(buf + index * SND_OCHANNELS * SND_SAMPLE_BITS/8)(U16*)[0] = sample;
if (SND_OCHANNELS == 2) {
(buf + index * SND_OCHANNELS * SND_SAMPLE_BITS/8 + SND_SAMPLE_BITS/8)(U16*)[0] = sample;
}
}
Mix_Chunk *convert_sfx_to_wave(File *file, I64 offset, I64 num_samples)
{
I64 sample_length = (SND_SAMPLE_RATE / SFX_SAMPLE_RATE);
Mix_Chunk *chunk = MAlloc(sizeof(Mix_Chunk));
chunk->alen = (num_samples * sample_length * SND_OCHANNELS * SND_SAMPLE_BITS/8);
chunk->abuf = MAlloc(chunk->alen);
chunk->allocated = 0;
chunk->volume = 128;
I64 i;
I64 sampleCounter;
file_seek(file, offset);
I16 *wave_data = chunk->abuf;
I16 beepWaveVal = WAVE_AMPLITUDE_VALUE;
// sint16 velocity = -4;
// sint16 desiredAmplitude = -WAVE_AMPLITUDE_VALUE;
U16 beepHalfCycleCounter = 0;
for(i=0; i < num_samples; i++)
{
U16 sample = file_read2(file);
if (sample)
{
F64 freq = PC_PIT_RATE / ToF64(sample);
I64 half_cycle_length = (SND_SAMPLE_RATE / (freq * 2));
//printf("sample %d, freq=%f, half_cycle_len = %d\n", i, freq, half_cycle_length);
for (sampleCounter = 0; sampleCounter < sample_length; sampleCounter++) {
writeSample(chunk->abuf, i*sample_length+sampleCounter, beepWaveVal);
// beepWaveVal += velocity;
// if((velocity < 0 && beepWaveVal < desiredAmplitude) || (velocity > 0 && beepWaveVal > desiredAmplitude))
// {
// beepWaveVal = desiredAmplitude;
// velocity = 0;
// }
// velocity *= 2;
beepHalfCycleCounter++;
if (beepHalfCycleCounter >= half_cycle_length) {
beepHalfCycleCounter = Cond(half_cycle_length != 0, (beepHalfCycleCounter % half_cycle_length), 0);
beepWaveVal = -beepWaveVal;
// desiredAmplitude = -desiredAmplitude;
// if(desiredAmplitude < 0)
// {
// velocity = -4;
// }
// else
// {
// velocity = 4;
// }
}
}
}
else
{
MemSet(&wave_data[i*sample_length*SND_OCHANNELS], 0, sample_length * SND_OCHANNELS * SND_SAMPLE_BITS/8); //silence
}
}
return chunk;
}
I64 load_sfx_file(U8 *filename, I64 sfx_offset)
{
File file;
open_file(filename, &file);
file_seek(&file, 6);
I64 count = file_read2(&file);
I64 i;
I64 num_samples;
I64 offset;
Sfx *sfx;
"%s, %d, %d\n", filename, count, sfx_offset;
for(i=0; i < MAX_SAMPLES_PER_FILE; i++)
{
file_seek(&file, (i+1) * 16); //+1 to skip header.
offset = file_read2(&file);
sfx = &sfxs[sfx_offset + i];
sfx->priority = file_read1(&file);
num_samples = get_num_samples(&file, offset, i, count);
// printf("sfx[%d] samples = %d\n", i+sfx_offset, num_samples);
sfx->sample = convert_sfx_to_wave(&file, offset, num_samples);
}
return MAX_SAMPLES_PER_FILE;
}
U0 load_sfx()
{
num_sfx = 0;
num_sfx += get_num_sfx("SOUNDS.MNI");
num_sfx += get_num_sfx("SOUNDS2.MNI");
num_sfx += get_num_sfx("SOUNDS3.MNI");
"Total Sfx %d\n", num_sfx;
sfxs = MAlloc(sizeof(Sfx) * num_sfx);
I64 sfx_offset = load_sfx_file("SOUNDS.MNI", 0);
sfx_offset += load_sfx_file("SOUNDS2.MNI", sfx_offset);
load_sfx_file("SOUNDS3.MNI", sfx_offset);
}
U0 play_sfx(I64 sfx_number)
{
sfx_pos = 0;
sfx_num = sfx_number;
/*
if(sfx_on_flag)
{
sfx_number--;
if(Mix_Playing(0))
{
if(sfxs[sfx_number].priority < currently_playing_priority)
return;
}
currently_playing_priority = sfxs[sfx_number].priority;
Mix_PlayChannel(0, sfxs[sfx_number].sample, 0);
}
*/
}
Loading…
Cancel
Save