Port of cosmo-engine to TempleOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4793 lines
122 KiB

extern U0 actor_add_new(I64 image_index, I64 x_pos, I64 y_pos);
extern U0 map_write_tile_cell(U16 map_tile_cell, I64 x, I64 y);
extern U0 map_write_row_of_tiles(U16 map_tile_cell, U16 length_in_tiles, I64 x, I64 y);
extern U8 byte_2E21C;
extern U0 ingame_hint_dialogs(U16 hint_number);
extern U0 end_game_dialog(U16 dialog_number);
extern U0 push_player_around(I64 push_direction, I64 push_anim_duration, I64 push_duration, I64 player_frame_num,
U8 dont_push_while_jumping_flag, I64 check_for_blocking_flag);
extern U0 write_tile_row_to_tilemap(U16 map_tile_cell,
U16 map_tile_cell2,
U16 map_tile_cell3,
U16 map_tile_cell4,
I64 x,
I64 y);
I16 purple_boss_y_offset_tbl[14] = {2, 2, 1, 0, -1, -2, -2, -2, -2, -1, 0, 1, 2, 2};
U0 actor_wt_133_boss_purple_15411(ActorData *actor)
{
actor_tile_display_func_index = 1;
if(word_2E21E == 0)
{
word_2E21E = 1;
actor_add_new(0xf4, player_x_pos - 1, player_y_pos - 5);
stop_music();
load_music(2);
}
if (actor->has_moved_right_flag > 0)
{
actor->has_moved_right_flag = actor->has_moved_right_flag - 1;
if(actor->has_moved_right_flag < 0x28)
{
actor->y = actor->y - 1;
}
actor->can_fall_down_flag = 0;
actor->falling_counter = 0;
if(actor->has_moved_right_flag == 1 || actor->y == 0 || (is_sprite_on_screen(0x66, 0, actor->x, actor->y) == 0 && actor->has_moved_right_flag < 0x1e))
{
finished_level_flag_maybe = 1;
player_add_to_score(0x186a0);
}
if(actor->has_moved_right_flag < 0x28 && actor->has_moved_right_flag != 0)
{
if(actor->has_moved_right_flag % 3 == 0)
{
effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 1);
effect_add_sprite(0x61, 6, actor->x + 3, actor->y, 2, 1);
2 years ago
play_sfx(0x38);
}
}
if((actor->has_moved_right_flag & 1) == 0)
{
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 0);
display_actor_sprite_maybe(0x66, 5, actor->x, actor->y - 4, 0);
}
else
{
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 2);
display_actor_sprite_maybe(0x66, 5, actor->x, actor->y - 4, 2);
if(actor->has_moved_right_flag > 0x27)
{
effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 1);
effect_add_sprite(0x61, 6, actor->x + 3, actor->y, 2, 1);
}
}
return;
}
if (actor->data_5 == 12)
{
if(sprite_blocking_check(1, 0x66, 0, actor->x, actor->y + 1) == 0)
{
actor->y = actor->y + 1;
if((actor->y & 1) == 0)
{
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 0);
display_actor_sprite_maybe(0x66, 5, actor->x, actor->y - 4, 0);
}
else
{
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 2);
display_actor_sprite_maybe(0x66, 5, actor->x, actor->y - 4, 2);
}
}
if(sprite_blocking_check(1, 0x66, 0, actor->x, actor->y + 1) != NOT_BLOCKED)
{
actor->has_moved_right_flag = 0x50;
}
return;
}
if(actor->has_moved_left_flag != 0)
{
I64 frame_num = Cond(actor->data_5 <= 3, 1, 5);
actor->has_moved_left_flag = actor->has_moved_left_flag - 1;
if((actor->has_moved_left_flag & 1) == 0)
{
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 0);
display_actor_sprite_maybe(0x66, frame_num, actor->x, actor->y - 4, 0);
}
else
{
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 2);
display_actor_sprite_maybe(0x66, frame_num, actor->x, actor->y - 4, 2);
}
}
if (actor->data_1 != 0)
{
if (actor->data_1 != 1)
{
if (actor->data_1 == 2)
{
if(sprite_blocking_check(1, 0x66, 0, actor->x, actor->y + purple_boss_y_offset_tbl[actor->data_3 % 14]) != NOT_BLOCKED)
{
if(purple_boss_y_offset_tbl[actor->data_3 % 14] == 2)
{
actor->y = actor->y - 2;
}
}
if (sprite_blocking_check(1, 0x66, 0, actor->x, actor->y + purple_boss_y_offset_tbl[actor->data_3 % 14]) == NOT_BLOCKED || purple_boss_y_offset_tbl[actor->data_3 % 14] != 1)
{
actor->y += purple_boss_y_offset_tbl[actor->data_3 % 14];
}
else
{
actor->y = actor->y - 1;
}
actor->data_3 = actor->data_3 + 1;
if(actor->data_3 % 14 == 1)
{
2 years ago
play_sfx(0x38);
}
actor->data_2 = actor->data_2 + 1;
if(actor->data_2 > 0x1e && actor->data_2 < 0xc9)
{
if(actor->data_4 == 0)
{
if(sprite_blocking_check(2, 0x66, 0, actor->x - 1, actor->y) != NOT_BLOCKED)
{
actor->data_4 = 1;
2 years ago
play_sfx(0x25);
effect_add_sprite(0x61, 6, actor->x, actor->y - 2, 5, 1);
}
else
{
actor->x = actor->x - 1;
}
}
else
{
if(sprite_blocking_check(3, 0x66, 0, actor->x + 1, actor->y) == NOT_BLOCKED)
{
actor->x = actor->x + 1;
}
else
{
actor->data_4 = 0;
2 years ago
play_sfx(0x25);
effect_add_sprite(0x61, 6, actor->x + 3, actor->y - 2, 5, 1);
}
}
}
else
{
if(actor->data_2 > 0xc7)
{
actor->data_1 = 3;
actor->data_2 = 0;
actor->data_3 = 8;
}
}
}
else
{
if (actor->data_1 == 3)
{
actor->data_2 = actor->data_2 + 1;
if (actor->data_3 >= 6)
{
if (actor->data_2 < 0x66)
{
actor->can_fall_down_flag = 1;
if(sprite_blocking_check(1, 0x66, 0, actor->x, actor->y + 1) == 0)
{
if(actor->x + 1 <= player_x_pos)
{
if(actor->x + 3 < player_x_pos)
{
if(sprite_blocking_check(3, 0x66, 0, actor->x + 1, actor->y) == NOT_BLOCKED)
{
actor->x = actor->x + 1;
}
}
}
else
{
if(sprite_blocking_check(2, 0x66, 0, actor->x - 1, actor->y) == NOT_BLOCKED)
{
actor->x = actor->x - 1;
}
}
}
else
{
actor->data_3 = 0;
actor->can_fall_down_flag = 0;
actor->falling_counter = 0;
2 years ago
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);
}
}
else
{
if (sprite_blocking_check(1, 0x66, 0, actor->x, actor->y + 1) != 0 || sprite_blocking_check(1, 0x66, 0, actor->x, actor->y) != 0)
{
actor->data_1 = 4;
actor->data_2 = 0;
actor->data_3 = 0;
actor->can_fall_down_flag = 0;
actor->falling_counter = 0;
2 years ago
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);
}
else
{
actor->y = actor->y + 1;
}
}
}
else
{
actor->data_3 = actor->data_3 + 1;
actor->y = actor->y - 2;
}
}
else
{
if(actor->data_1 == 4)
{
actor->can_fall_down_flag = 0;
actor->falling_counter = 0;
actor->y = actor->y - 1;
actor->data_2 = actor->data_2 + 1;
if(actor->data_2 == 6)
{
actor->data_1 = 2;
actor->data_3 = 0;
actor->data_2 = 0;
}
}
}
}
}
else
{
if(actor->data_2 == 0)
{
actor->data_1 = 2;
}
else
{
actor->data_2 = actor->data_2 - 1;
}
}
}
else
{
actor->y = actor->y - 2;
actor->data_2 = actor->data_2 + 1;
if(actor->data_2 == 6)
{
actor->data_1 = 1;
}
}
if(actor->has_moved_left_flag != 0)
{
return;
}
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 0);
if(actor->data_5 < 4)
{
display_actor_sprite_maybe(0x66, 1, actor->x, actor->y - 4, 0);
return;
}
if(actor->x + 1 > player_x_pos)
{
display_actor_sprite_maybe(0x66, 2, actor->x + 1, actor->y - 4, 0);
return;
}
if(actor->x + 1 + 1 >= player_x_pos)
{
display_actor_sprite_maybe(0x66, 3, actor->x + 1, actor->y - 4, 0);
}
else
{
display_actor_sprite_maybe(0x66, 4, actor->x + 1, actor->y - 4, 0);
}
}
U0 actor_wt_159_unknown(ActorData *actor)
{
if(actor->data_5 != 0)
{
actor->data_5--;
return;
}
if(actor->frame_num == 8)
{
actor->frame_num = 1;
return;
}
actor->frame_num++;
return;
}
U8 acid_frame_num_tbl[7] = {0, 1, 2, 3, 2, 1, 0};
U0 actor_wt_acid(ActorData *actor)
{
if(actor->data_5 != 0)
{
if(actor->data_4 == 0)
{
actor->frame_num = acid_frame_num_tbl[actor->data_3 % 6];
actor->data_3++;
if(actor->data_3 != 15)
{
return;
}
actor->data_4 = 1;
actor->data_3 = 0;
actor->frame_num = 4;
if(is_sprite_on_screen(0x2b, 6, actor->x, actor->data_2) != 0)
{
2 years ago
play_sfx(0x15);
}
return;
}
if(actor->frame_num < 6)
{
actor->frame_num = actor->frame_num + 1;
return;
}
actor->y = actor->y + 1;
if(is_sprite_on_screen(0x2b, 6, actor->x, actor->y) == 0)
{
actor->y = actor->data_2;
actor->data_4 = 0;
actor->frame_num = 0;
return;
}
}
else
{
actor->frame_num = acid_frame_num_tbl[actor->data_3];
actor->data_3++;
if(actor->data_3 == 6)
{
actor->data_3 = 0;
}
}
return;
}
U8 alien_eating_space_plant_f_num_tbl[4] = {5, 6, 7, 8};
U8 alien_eating_space_plant_f_num_2_tbl[16] = {
1, 1, 1, 1, 1, 1, 1, 2,
3, 4, 1, 1, 1, 1, 1, 1
};
U0 actor_wt_alien_eating_space_plant(ActorData *actor)
{
if(actor->data_3 != 0)
{
actor->data_3--;
actor->frame_num = 1;
if(actor->data_3 != 0)
{
return;
}
actor->frame_num = 0;
}
if(actor->frame_num == 0 && actor->data_5 == 0)
{
display_actor_sprite_maybe(0xba, alien_eating_space_plant_f_num_tbl[actor->data_1 & 3], actor->x + 1 + 1, actor->y - 3, 0);
actor->data_1++;
}
if(actor->data_5 != 0)
{
actor->frame_num = alien_eating_space_plant_f_num_2_tbl[actor->data_5 - 1];
if(actor->data_5 != 0x10)
{
actor->data_5++;
}
else
{
finished_level_flag_maybe = 1;
}
}
if(is_sprite_on_screen(0xba, 1, actor->x, actor->y) == 0)
{
actor->data_3 = 0x1e;
actor->data_5 = 0;
actor->frame_num = 1;
}
return;
}
U0 actor_wt_angry_moon(ActorData *actor)
{
actor->data_3 = Cond(actor->data_3, -1, 0) + 1;
if(actor->data_3 == 0)
{
actor->data_2++;
if(actor->x >= player_x_pos)
{
actor->frame_num = actor->data_2 & 1;
}
else
{
actor->frame_num = (actor->data_2 & 1) + 2;
}
}
return;
}
I8 red_jumper_tbl[40] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1,
0, 1, -2, 2, -2, 2, -2, 2,
-2, 2, -1, 2, -1, 2, -1, 2,
0, 2, 0, 2, 1, 1, 1, 1
};
U0 actor_wt_big_red_jumper(ActorData *actor)
{
if(actor->data_2 >= 5)
{
if(actor->data_2 != 14 || is_sprite_on_screen(0x65, 0, actor->x, actor->y) == 0)
{
if(actor->data_2 > 0x10 && actor->data_2 < 0x27)
{
if(actor->data_1 != 0 || sprite_blocking_check(2, 0x65, 0, actor->x - 1, actor->y) != NOT_BLOCKED)
{
if(actor->data_1 == 3 && sprite_blocking_check(3, 0x65, 0, actor->x + 1, actor->y) == NOT_BLOCKED)
{
actor->x = actor->x + 1;
}
}
else
{
actor->x = actor->x - 1;
}
}
}
else
{
2 years ago
play_sfx(0x1f);
}
}
else
{
if(actor->x <= player_x_pos)
{
actor->data_1 = 3;
}
else
{
actor->data_1 = 0;
}
}
if (actor->data_2 <= 0x27) //goto loc_15546;
{
// node 00015546-0001561d #insn=6 use={} def={} in={} out={} pred={ 153F7} CONDJUMP target=0001566d follow=0001561f
//loc_15546:
//si = * ((actor->data_2 << 1) + word_28356);
I8 si = red_jumper_tbl[actor->data_2];
if(si == -1)
{
if(sprite_blocking_check(0, 0x65, 0, actor->x, actor->y - 1) != 0)
{
actor->data_2 = 0x22;
}
else
{
actor->y = actor->y - 1;
}
}
if(si == -2)
{
if(sprite_blocking_check(0, 0x65, 0, actor->x, actor->y - 1) != 0)
{
actor->data_2 = 0x22;
}
else
{
actor->y = actor->y - 1;
}
if(sprite_blocking_check(0, 0x65, 0, actor->x, actor->y - 1) != 0)
{
actor->data_2 = 0x22;
}
else
{
actor->y = actor->y - 1;
}
}
if(si == 1)
{
if(sprite_blocking_check(1, 0x65, 0, actor->x, actor->y + 1) == 0)
{
actor->y = actor->y + 1;
}
}
if (si != 2) //goto loc_1566D;
{
// node 0001566d-0001568e #insn=6 use={} def={} in={} out={} pred={ 15546} FALLTHROUGH follow=00015698
//loc_1566D:
actor->frame_num = actor->data_1 + red_jumper_tbl[actor->data_2 + 1];
if(actor->data_2 < 0x27)
{
actor->data_2 = actor->data_2 + 2;
}
return;
}
else
{
//0001561f
// node 0001561f-0001563b #insn=3 use={} def={ax, bx} in={} out={ax} pred={ 15546} CONDJUMP target=00015662 follow=0001563d
if (sprite_blocking_check(1, 0x65, 0, actor->x, actor->y - 1) != NOT_BLOCKED) //goto loc_15662;
{
// node 00015662-0001566b #insn=3 use={} def={bx} in={ax} out={ax} pred={ 1561F} JUMP target=00015698
//loc_15662:
actor->data_2 = 0;
//goto loc_15698;
return;
}
else
{
// 0001563d
// node 0001563d-0001565d #insn=4 use={} def={ax, bx} in={} out={ax} pred={ 1561F} CONDJUMP target=00015662 follow=0001550f
actor->y = actor->y + 1;
if (sprite_blocking_check(1, 0x65, 0, actor->x, actor->y - 1) != NOT_BLOCKED) //goto loc_15662;
{
// node 00015662-0001566b #insn=3 use={} def={bx} in={ax} out={ax} pred={ 1563D} JUMP target=00015698
// loc_15662:
actor->data_2 = 0;
//goto loc_15698;
return;
}
else
{
// 0001550f
// node 0001550f-00015516 #insn=3 use={} def={bx} in={} out={} pred={ 154ED 1563D} JUMP target=0001566d
// loc_1550F:
actor->y = actor->y + 1;
// goto loc_1566D;
// node 0001566d-0001568e #insn=6 use={} def={} in={} out={} pred={ 1550F } FALLTHROUGH follow=00015698
// loc_1566D:
actor->frame_num = actor->data_1 + red_jumper_tbl[actor->data_2 + 1];
if(actor->data_2 < 0x27)
{
actor->data_2 = actor->data_2 + 2;
}
return;
}
}
}
}
else
{
//000154d2
// node 000154d2-000154eb #insn=1 use={bx} def={ax} in={bx} out={} pred={ 153F7} CONDJUMP target=00015519 follow=000154ed
if (sprite_blocking_check(1, 0x65, 0, actor->x, actor->y + 1) != NOT_BLOCKED) //goto loc_15519;
{
// node 00015519-00015537 #insn=5 use={} def={} in={} out={} pred={ 154ED} FALLTHROUGH follow=00015698
// loc_15519:
actor->data_2 = 0;
if(is_sprite_on_screen(0x65, 0, actor->x, actor->y) != 0)
{
2 years ago
play_sfx(0x20);
}
return;
}
else
{
// 00154ed
// node 000154ed-0001550d #insn=3 use={} def={ax, bx} in={} out={} pred={ 154D2} CONDJUMP target=00015519 follow=0001550f
actor->y = actor->y + 1;
if (sprite_blocking_check(1, 0x65, 0, actor->x, actor->y + 1) != NOT_BLOCKED) //goto loc_15519;
{
// node 00015519-00015537 #insn=5 use={} def={} in={} out={} pred={ 154ED} FALLTHROUGH follow=00015698
// loc_15519:
actor->data_2 = 0;
if(is_sprite_on_screen(0x65, 0, actor->x, actor->y) != 0)
{
2 years ago
play_sfx(0x20);
}
}
else
{
// 0001550f
// node 0001550f-00015516 #insn=3 use={} def={bx} in={} out={} pred={ 154ED } JUMP target=0001566d
// loc_1550F:
actor->y = actor->y + 1;
// goto loc_1566D;
// node 0001566d-0001568e #insn=6 use={} def={} in={} out={} pred={ 1550F } FALLTHROUGH follow=00015698
// loc_1566D:
actor->frame_num = actor->data_1 + red_jumper_tbl[actor->data_2 + 1];
if(actor->data_2 < 0x27)
{
actor->data_2 = actor->data_2 + 2;
}
return;
}
}
}
// node 00015698-0001569a #insn=3 use={ax} def={si} in={ax} out={} pred={ 15519 15662 15662 1566D} RETURN
// loc_15698:
/* pop */
}
U8 big_red_plant_frame_num_tbl[5] ={0, 2, 1, 0, 1};
U0 actor_wt_big_red_plant(ActorData *actor)
{
if(actor->has_moved_right_flag > 0 && actor->has_moved_right_flag < 7)
{
return;
}
if(actor->data_3 != 0)
{
actor->data_3--;
if((actor->data_3 & 1) != 0)
{
actor_tile_display_func_index = 2;
}
return;
}
if (struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) == 0)
{
if(actor->data_2 != 0)
{
actor->frame_num = 1;
actor->data_2--;
}
else
{
actor->frame_num = big_red_plant_frame_num_tbl[actor->data_1];
actor->data_1++;
if(actor->data_1 == 2 && actor->has_moved_left_flag == 0)
{
actor_toss_add_new(0x56, actor->x + 2, actor->y - 5);
2 years ago
play_sfx(0x2f);
}
if(actor->data_1 == 5)
{
actor->data_2 = 0x64;
actor->data_1 = 0;
actor->has_moved_left_flag = 0;
}
}
}
else
{
actor->data_3 = 15;
actor->data_5++;
if (actor->data_5 == 2)
{
actor->is_deactivated_flag_maybe = 1;
explode_effect_add_sprite(0x56, 0, actor->x + 2, actor->y - 5);
explode_effect_add_sprite(0x56, 2, actor->x + 2, actor->y - 5);
explode_effect_add_sprite(0x56, 4, actor->x + 2, actor->y - 5);
explode_effect_add_sprite(0x56, 9, actor->x + 2, actor->y - 5);
explode_effect_add_sprite(0x56, 3, actor->x + 2, actor->y - 5);
explode_effect_add_sprite(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y);
}
else
{
if(actor->data_2 != 0)
{
actor->frame_num = 1;
actor->data_2--;
}
else
{
actor->frame_num = big_red_plant_frame_num_tbl[actor->data_1];
actor->data_1++;
if(actor->data_1 == 2 && actor->has_moved_left_flag == 0)
{
actor_toss_add_new(0x56, actor->x + 2, actor->y - 5);
2 years ago
play_sfx(0x2f);
}
if(actor->data_1 == 5)
{
actor->data_2 = 0x64;
actor->data_1 = 0;
actor->has_moved_left_flag = 0;
}
}
}
}
return;
}
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)
{
2 years ago
play_sfx(0x23);
}
if(actor->data_1 != 0)
{
if(sprite_blocking_check(0, actor->actorInfoIndex, 0, actor->x, actor->y - 1) == NOT_BLOCKED)
{
actor->y = actor->y - 1;
}
else
{
actor->data_1 = 0;
}
return;
}
if(sprite_blocking_check(1, actor->actorInfoIndex, 0, actor->x, actor->y + 1) == NOT_BLOCKED)
{
actor->y = actor->y + 1;
}
else
{
actor->data_1 = 1;
}
return;
}
U0 actor_wt_big_yellow_spike(ActorData *actor)
{
if(actor->data_5 == 0)
{
if(actor->data_1 != 0)
{
if(sprite_blocking_check(1, actor->actorInfoIndex, 0, actor->x, actor->y + 1) != NOT_BLOCKED)
{
actor->is_deactivated_flag_maybe = 1;
effect_add_sprite(0x61, 6, actor->x, actor->y, 1, 3);
2 years ago
play_sfx(0x1b);
actor_tile_display_func_index = 1;
}
}
else
{
if(actor->y < player_y_pos)
{
if(actor->x <= player_x_pos + 6)
{
if(actor->x + 5 > player_x_pos)
{
actor->data_1 = 1;
actor->can_fall_down_flag = 1;
}
}
}
}
}
else
{
actor_tile_display_func_index = 4;
}
if(actor->is_deactivated_flag_maybe != 0)
{
return;
}
if(struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0)
{
actor->data_2 = 3;
}
if(actor->data_2 != 0)
{
actor->data_2--;
if(actor->data_2 == 0)
{
struct6_add_sprite(actor->x - 1, actor->y + 1);
actor->is_deactivated_flag_maybe = 1;
player_add_to_score(0xc8);
explode_effect_add_sprite(actor->actorInfoIndex, 0, actor->x, actor->y);
}
}
return;
}
U8 blue_ball_frame_num_tbl[27] = {
2, 2, 2, 0, 3, 3, 3, 0, 0, 2, 2, 0, 0, 1, 1, 0, 1, 3, 3, 3, 0, 1, 1, 0, 1, 1, 1
};
U8 blue_ball_moving_left_frame_num_tbl[4] = {7, 6, 5, 4};
U8 blue_ball_moving_right_frame_num_tbl[4] = {4, 5, 6, 7};
U0 check_actor_move_left_or_right(ActorData *actor, I64 direction_of_movement)
{
U16 sprite_width = actor_get_tile_info(actor->actorInfoIndex, actor->frame_num)->width;
I64 block_status;
U8 tile_attr;
if(direction_of_movement == LEFT)
{
block_status = sprite_blocking_check(2, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y);
actor->has_moved_left_flag = Cond(block_status != NOT_BLOCKED, -1, 0) + 1;
if(actor->has_moved_left_flag == 0 && block_status != SLOPE)
{
actor->x = actor->x + 1;
return;
}
if(block_status != SLOPE)
{
if(sprite_blocking_check(1, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y + 1) == NOT_BLOCKED)
{
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x + sprite_width, actor->y + 1) / 8];
if((tile_attr & TILE_ATTR_SLOPED) != 0)
{
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x + sprite_width - 1, actor->y + 1 + 1) / 8];
if((tile_attr & TILE_ATTR_SLOPED) != 0)
{
tile_attr = tileattr_mni_data[ map_get_tile_cell(actor->x + sprite_width - 1, actor->y + 1) / 8];
if((tile_attr & TILE_ATTR_BLOCK_DOWN) != 0)
{
return;
}
actor->has_moved_left_flag = 1;
if((tile_attr & TILE_ATTR_SLOPED) == 0)
{
actor->y = actor->y + 1;
}
return;
}
}
if(actor->has_moved_left_flag == 0)
{
actor->x = actor->x + 1;
return;
}
if(actor->non_blocking_flag_maybe != 0 || sprite_blocking_check(2, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y + 1) != 0)
{
return;
}
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x + sprite_width - 1, actor->y + 1)/ 8];
if((tile_attr & TILE_ATTR_SLOPED) == 0)
{
actor->x = actor->x + 1;
actor->has_moved_left_flag = 0;
}
}
else
{
actor->has_moved_left_flag = 1;
}
}
else
{
actor->has_moved_left_flag = 1;
actor->y = actor->y - 1;
}
}
else
{
block_status = sprite_blocking_check(3, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y);
actor->has_moved_right_flag = Cond(block_status != NOT_BLOCKED, -1, 0) + 1;
if(actor->has_moved_right_flag == 0 && block_status != SLOPE)
{
actor->x = actor->x - 1;
return;
}
if(block_status != SLOPE)
{
if(sprite_blocking_check(1, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y + 1) == NOT_BLOCKED)
{
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x - 1, actor->y + 1) /8];
if((tile_attr & TILE_ATTR_SLOPED) != 0)
{
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x, actor->y + 1 + 1) / 8];
if((tile_attr & TILE_ATTR_SLOPED) != 0)
{
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x, actor->y + 1) / 8];
if((tile_attr & TILE_ATTR_BLOCK_DOWN) != 0)
{
return;
}
actor->has_moved_right_flag = 1;
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x, actor->y + 1) / 8];
if((tile_attr & TILE_ATTR_SLOPED) == 0)
{
actor->y = actor->y + 1;
return;
}
return;
}
}
if(actor->has_moved_right_flag == 0)
{
actor->x = actor->x - 1;
return;
}
if(actor->non_blocking_flag_maybe == 0 && sprite_blocking_check(3, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y + 1) == NOT_BLOCKED)
{
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x, actor->y + 1) / 8];
if((tile_attr & TILE_ATTR_SLOPED) == 0)
{
actor->x = actor->x - 1;
actor->has_moved_right_flag = 0;
return;
}
return;
}
}
else
{
actor->has_moved_right_flag = 1;
}
}
else
{
actor->has_moved_right_flag = 1;
actor->y = actor->y - 1;
}
}
return;
}
U0 actor_wt_blue_ball(ActorData *actor)
{
if(actor->falling_counter != 0)
{
actor->data_1 = 0;
actor->data_2 = 0x14;
if(actor->falling_counter < 2)
{
actor->frame_num = 1;
actor->frame_num = 10;
return;
}
if(actor->falling_counter < 2 || actor->falling_counter > 4)
{
actor->y = actor->y - 1;
display_actor_sprite_maybe(0x56, 9, actor->x, actor->y - 2, 0);
actor->frame_num = 10;
}
else
{
display_actor_sprite_maybe(0x56, 8, actor->x, actor->y - 2, 0);
actor->frame_num = 10;
}
return;
}
if (actor->data_1 == 0)
{
actor->data_2 = actor->data_2 + 1;
actor->frame_num = blue_ball_frame_num_tbl[actor->data_2];
if (actor->data_2 == 0x1a)
{
actor->data_2 = 0;
if (actor->y == player_y_pos || (sub_1106F() & 1) == 0)
{
if(actor->x < player_x_pos + 1 + 1)
{
if(actor->x + 2 <= player_x_pos)
{
actor->data_1 = 2;
actor->data_2 = 0;
actor->frame_num = 3;
actor->data_3 = 6;
}
}
else
{
actor->data_1 = 1;
actor->data_2 = 0;
actor->frame_num = 2;
actor->data_3 = 6;
}
}
}
}
if(actor->data_3 != 0)
{
actor->data_3 = actor->data_3 - 1;
return;
}
if (actor->data_1 == 1)
{
actor->x--;
check_actor_move_left_or_right(actor, LEFT);
if(actor->has_moved_left_flag != 0)
{
actor->frame_num = blue_ball_moving_left_frame_num_tbl[actor->data_2 & 3];
actor->data_2 = actor->data_2 + 1;
if(actor->data_2 == 0x10)
{
actor->data_1 = 0;
actor->data_2 = 0;
}
return;
}
actor->data_1 = 0;
actor->data_2 = 0;
actor->frame_num = 0;
return;
}
else
{
if (actor->data_1 != 2)
{
return;
}
actor->x++;
check_actor_move_left_or_right(actor, RIGHT);
if (actor->has_moved_right_flag != 0)
{
actor->frame_num = blue_ball_moving_right_frame_num_tbl[actor->data_2 & 3];
actor->data_2 = actor->data_2 + 1;
if(actor->data_2 == 12)
{
actor->data_1 = 0;
actor->data_2 = 0;
}
}
else
{
actor->data_1 = 0;
actor->data_2 = 0;
actor->frame_num = 0;
}
}
return;
}
I8 bird_swoop_y_offset_tbl[15] = {
2, 2, 2, 1, 1, 1, 0, 0, 0, -1, -1, -1, -2, -2, -2
};
U0 actor_wt_blue_bird(ActorData *actor)
{
if(actor->data_1 == 0)
{
if(actor->x + 1 <= player_x_pos)
{
if(cosmo_rand % 10 != 0)
{
actor->data_2 = 4;
}
else
{
actor->data_2 = 5;
}
}
else
{
if(cosmo_rand() % 10 != 0)
{
actor->data_2 = 0;
}
else
{
actor->data_2 = 1;
}
}
actor->frame_num = actor->data_2;
actor->data_3 = actor->data_3 + 1;
if(actor->data_3 == 0x1e)
{
actor->data_1 = 1;
actor->data_3 = 0;
}
}
else
{
if(actor->data_1 == 1)
{
actor->data_3 = actor->data_3 + 1;
if(actor->data_3 != 0x14)