diff --git a/Actor.HC b/Actor.HC new file mode 100644 index 0000000..25343b8 --- /dev/null +++ b/Actor.HC @@ -0,0 +1,1554 @@ +extern U0 video_draw_tile_flipped(Tile *tile, uint16 x, uint16 y); +extern U0 video_draw_tile_mode3(Tile *tile, uint16 x, uint16 y); +extern I64 finished_game_flag_maybe; +extern I64 finished_level_flag_maybe; +extern U8 get_episode_number(); + +#define MAX_ACTORS 410 + +class ActorData +{ + I64 actorInfoIndex; + I64 frame_num; + I64 x; + I64 y; + I64 update_while_off_screen_flag; + I64 can_update_if_goes_off_screen_flag; + I64 non_blocking_flag_maybe; + I64 can_fall_down_flag; + I64 has_moved_left_flag; + I64 has_moved_right_flag; + uint16 data_1; + uint16 data_2; + uint16 data_3; + uint16 data_4; + uint16 data_5; + I64 is_deactivated_flag_maybe; + I64 falling_counter; + I64 count_down_timer; + U0 (*update_function)(ActorData *); +}; + +//Data +ActorData actors[MAX_ACTORS]; +I64 total_num_actors = 0; + +uint16 word_2E17E = 0; +uint16 word_2E22A = 0; +uint16 word_2E236 = 0; +uint16 word_2E228 = 0; +uint16 word_2E220 = 0; +uint16 word_2E238 = 0; +uint16 word_2E21E = 0; +uint16 word_2E24C = 0; +uint16 word_2E23C = 0; +uint16 word_2E232 = 0; +uint16 word_2E234 = 0; +uint16 word_2E246 = 0; + +uint8 byte_32EB8 = 0; + +uint16 word_32EC2 = 0; //range 0 - 35 + +uint8 energy_beam_enabled_flag = 0; + +uint16 word_2E1E4 = 0; //seems to be related to number of actors in play. + +uint16 word_2E1E2 = 0; + +uint16 num_moving_platforms = 0; + +uint16 brightness_effect_enabled_flag = 0; +uint16 obj_switch_151_flag = 0; + +uint8 move_platform_flag = 0; +uint16 actor_tile_display_func_index = 0; + +Tile *actor_tiles; +Sprite *actor_sprites; + +uint16 word_28D9C[36] = { + 31, 12, 17, 233, + 99, 8, 64, 12, + 199, 49, 5, 6, + 143, 1, 35, 46, + 52, 5, 8, 21, + 44, 8, 3, 77, + 2, 103, 34, 23, + 78, 2, 67, 2, + 79, 46, 1, 98 +}; + +ActorData *get_actor(uint16 actor_num) { + //assert(actor_num < MAX_ACTORS); + return &actors[actor_num]; +} + +TileInfo *actor_get_tile_info(I64 actorInfoIndex, I64 frame_num) { + return &actor_sprites[actorInfoIndex].frames[frame_num]; +} + +I64 sprite_blocking_check(I64 blocking_dir, I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos) +{ + uint16 sprite_height = actor_sprites[actorInfoIndex].frames[frame_num].height; + uint16 sprite_width = actor_sprites[actorInfoIndex].frames[frame_num].width; + I64 i; + uint16 tile_attr; + + switch (blocking_dir) + { + case 0: + for (i = 0; i < sprite_width; i++) + { + if(tileattr_mni_data[map_get_tile_cell(x_pos + i, y_pos - sprite_height + 1)/8] & TILE_ATTR_BLOCK_UP) + { + return BLOCKED; + } + } + break; + + case 1: + for (i = 0; i < sprite_width; i++) + { + tile_attr = tileattr_mni_data[map_get_tile_cell(x_pos + i, y_pos)/8]; + if(tile_attr & TILE_ATTR_SLOPED) + { + return SLOPE; + } + if(tile_attr & TILE_ATTR_BLOCK_DOWN) + { + return BLOCKED; + } + } + break; + + case 2: + if(x_pos == 0) + { + return BLOCKED; + } + + for(i=0;i x_pos || mapwindow_x_offset + 0x26 <= x_pos) && (mapwindow_x_offset < x_pos || x_pos + sprite_width <= mapwindow_x_offset)) || + ((mapwindow_y_offset + 0x12 <= y_pos - sprite_height + 1 || mapwindow_y_offset + 0x12 > y_pos) && (y_pos < mapwindow_y_offset || mapwindow_y_offset + 0x12 <= y_pos))) + { + return FALSE; + } + + return TRUE; +} + +U0 display_actor_sprite_flipped(TileInfo *info, I64 x_pos, I64 y_pos) +{ + I64 x, y; + Tile *tile = &actor_tiles[info->tile_num]; + for(y=0;y < info->height;y++) + { + for (x = 0; x < info->width; x++) + { + uint16 screen_x = (x_pos - mapwindow_x_offset + x + 1) * 8; + uint16 screen_y = (y_pos - info->height + 1 - mapwindow_y_offset + (info->height-y-1) + 1) * 8; + uint16 tile_attr = tileattr_mni_data[map_get_tile_cell(x_pos+x,y_pos - info->height + 1 + (info->height-y-1))/8]; + if(screen_x >= 8 && screen_x <= 304 && //FIXME need a better way of making sure we draw in the borders. + screen_y >= 8 && screen_y < 152 && + !(tile_attr & TILE_ATTR_IN_FRONT)) + { + video_draw_tile_flipped(tile, screen_x, screen_y); + } + tile++; + } + } +} + +U0 display_actor_sprite_maybe(I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos, I64 tile_display_func_index) +{ + //FIXME + + if(actor_sprites[actorInfoIndex].num_frames==0) + { + //printf("WARN: actorInfoIndex %d has no frames!. Wanted frame_num: %d\n", actorInfoIndex, frame_num); + return; + } + + I64 x, y; + + TileInfo *info = &actor_sprites[actorInfoIndex].frames[frame_num]; + Tile *tile = &actor_tiles[info->tile_num]; + + if(tile_display_func_index == 4) + { + display_actor_sprite_flipped(info, x_pos, y_pos); + return; + } + + for(y=0;y < info->height;y++) + { + for(x=0;x < info->width; x++) + { + uint16 screen_x = (x_pos - mapwindow_x_offset + x + 1) * 8; + uint16 screen_y = (y_pos - info->height + 1 - mapwindow_y_offset + y + 1) * 8; + uint16 tile_attr = tileattr_mni_data[map_get_tile_cell(x_pos+x,y_pos - info->height + y + 1)/8]; + if(tile_display_func_index == 6) //FIXME + { + screen_x = (x_pos + x + 1) * 8; + screen_y = (y_pos - info->height + y + 1) * 8; + video_draw_tile(tile, screen_x, screen_y); + } + else + { + if(screen_x >= 8 && screen_x <= 304 && //FIXME need a better way of making sure we draw in the borders. + screen_y >= 8 && screen_y < 152 && + (!(tile_attr & TILE_ATTR_IN_FRONT) || tile_display_func_index == 5 || tile_display_func_index == 6)) + { + if (tile_display_func_index == 2) + { + video_draw_tile_white(tile, screen_x, screen_y); + } + else if(tile_display_func_index == 3) + { + video_draw_tile_mode3(tile, screen_x, screen_y); + } + else + { + video_draw_tile(tile, screen_x, screen_y); + } + } + } + tile++; + } + } +} + +//TODO work out what this should be called. +uint16 sub_1106F() +{ + word_32EC2++; + if(word_32EC2 > 0x23) + { + word_32EC2 = 0; + } + return word_28D9C[word_32EC2] + mapwindow_x_offset + mapwindow_y_offset + word_32EC2 + player_x_pos + player_y_pos; +} + +U0 actor_init_struct(I64 actor_init_cur_actor_num, + I64 actorInfoIndex, + I64 x, + I64 y, + I64 update_while_offscreen, + I64 can_update_if_goes_offscreen, + I64 can_fall_down, + I64 is_non_blocking, + U0 (*update_function)(ActorData *), + I64 data_1, + I64 data_2, + I64 data_3, + I64 data_4, + I64 data_5) +{ + if(data_2 == 0x1e || data_2 == 0xb9) + { + word_2E1E4++; + } + + ActorData *actor = &actors[actor_init_cur_actor_num]; + + actor->actorInfoIndex = actorInfoIndex; + actor->frame_num = 0; + actor->x = x; + actor->y = y; + actor->update_while_off_screen_flag = update_while_offscreen; + actor->can_update_if_goes_off_screen_flag = can_update_if_goes_offscreen; + actor->can_fall_down_flag = can_fall_down; + actor->non_blocking_flag_maybe = is_non_blocking; + actor->is_deactivated_flag_maybe = 0; + actor->update_function = update_function; + actor->has_moved_left_flag = 0; + actor->has_moved_right_flag = 0; + actor->falling_counter = 0; + actor->data_1 = data_1; + actor->data_2 = data_2; + actor->data_3 = data_3; + actor->data_4 = data_4; + actor->data_5 = data_5; + actor->count_down_timer = 0; + + return; +} + +#include "Actor_Toss"; +#include "Actor_Collision"; +#include "Actor_WorkType"; + +I64 actor_init(I64 actor_num, I64 image_index, I64 x_pos, I64 y_pos) +{ + switch (image_index) + { + case 0: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0, 0xb9, 0, 0, 0); + break; + + case 1: + actor_init_struct(actor_num, 1, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_bonus_item, 0, 0, 0, 0, 4); + break; + + case 2: + actor_init_struct(actor_num, 2, x_pos, y_pos, 0, 1, 1, 0, &actor_wt_spring, 0, 0, 0, 0, 0); + break; + + case 3: + actor_init_struct(actor_num, 3, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_extending_arrow, 0, 0, 0, 0, 0); + break; + + case 4: + actor_init_struct(actor_num, 4, x_pos - 4, y_pos, 0, 1, 0, 0, &actor_wt_extending_arrow, 0, 0, 0, 0, 1); + break; + + case 5: + actor_init_struct(actor_num, 5, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_plasma_fireball, 0, x_pos, y_pos, 0, 0); + break; + + case 6: + actor_init_struct(actor_num, 5, x_pos - 1, y_pos, 1, 0, 0, 0, &actor_wt_plasma_fireball, 0, x_pos - 1, y_pos, 0, 1); + break; + + case 7: + actor_init_struct(actor_num, 7, x_pos, y_pos + 1, 0, 0, 0, 0, &actor_wt_switch, 0, 0, 0, 0, 11); + break; + + case 11: + actor_init_struct(actor_num, 11, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_door, 0, 0, 0, 0, 0); + break; + + case 8: + actor_init_struct(actor_num, 8, x_pos, y_pos + 1, 0, 0, 0, 0, &actor_wt_switch, 0, 0, 0, 0, 12); + break; + + case 12: + actor_init_struct(actor_num, 12, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_door, 0, 0, 0, 0, 0); + break; + + case 9: + actor_init_struct(actor_num, 9, x_pos, y_pos + 1, 0, 0, 0, 0, &actor_wt_switch, 0, 0, 0, 0, 13); + break; + + case 13: + actor_init_struct(actor_num, 13, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_door, 0, 0, 0, 0, 0); + break; + + case 10: + actor_init_struct(actor_num, 10, x_pos, y_pos + 1, 0, 0, 0, 0, &actor_wt_switch, 0, 0, 0, 0, 14); + break; + + case 14: + actor_init_struct(actor_num, 14, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_door, 0, 0, 0, 0, 0); + break; + + case 16: + actor_init_struct(actor_num, 0x10, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_blue_mobile_trampoline_car, 0, 0, 0, 0, 0); + break; + + case 17: + actor_init_struct(actor_num, 0x11, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 18: + actor_init_struct(actor_num, 0x12, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_retracting_spikes, 1, 0, 0, 0, 0); + break; + + case 20: + actor_init_struct(actor_num, 0x14, x_pos, y_pos, 0, 1, 0, 1, &actor_wt_big_saw_blade, 0, 0, 0, 0, 0); + break; + + case 22: + actor_init_struct(actor_num, 0x14, x_pos, y_pos, 1, 0, 0, 1, &actor_wt_robotic_spike_ground, 0, 0, 0, 0, 1); + break; + + case 24: + actor_init_struct(actor_num, 0x18, x_pos, y_pos, 1, 0, 1, 1, &actor_wt_bomb, 0, 0, 0, 0, 0); + break; + + case 25: + actor_init_struct(actor_num, 0x19, x_pos, y_pos, 0, 1, 1, 1, &actor_wt_green_pruny_cabbage_ball, 1, 0, 0, 0, 0); + break; + + case 28: + actor_init_struct(actor_num, 0x1c, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_bonus_item, 0, 0, 0, 1, 6); + break; + + case 29: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x1c, 0x1e, 0, 0, 0); + break; + + case 31: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x20, 0xb9, 0, 0, 0); + break; + + case 33: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x22, 0xb9, 0, 0, 0); + break; + + case 35: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x24, 0x1e, 0, 0, 0); + break; + + case 37: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x26, 0x1e, 0, 0, 0); + break; + + case 58: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 1, &actor_wt_container, 2, 0x1e, 0, 0, 0); + break; + + case 32: + actor_init_struct(actor_num, 0x20, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 34: + actor_init_struct(actor_num, 0x22, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 36: + actor_init_struct(actor_num, 0x24, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 38: + actor_init_struct(actor_num, 0x26, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 39: + actor_init_struct(actor_num, 0x27, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 40: + actor_init_struct(actor_num, 0x29, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 41: + actor_init_struct(actor_num, 0x29, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_spear_vertical, 0, 0, 0, 0, 0); + break; + + case 42: + actor_init_struct(actor_num, 0x2b, x_pos, y_pos + 1, 0, 0, 0, 0, &actor_wt_acid, 0, 0, 0, 0, 0); + break; + + case 43: + actor_init_struct(actor_num, 0x2b, x_pos, y_pos + 1, 0, 1, 0, 0, &actor_wt_acid, x_pos, y_pos + 1, 0, 0, 1); + break; + + case 44: + actor_init_struct(actor_num, 0x2c, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_plasma_energy_blue_sprite, 0, 0, 0, 0, 0); + break; + + case 45: + actor_init_struct(actor_num, 0x2d, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_two_tons, 0, 0, 0, 0, 0); + break; + + case 46: + actor_init_struct(actor_num, 0x2e, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_jumping_bullet_head, 0, 0, 0, 0, 0); + break; + + case 47: + actor_init_struct(actor_num, 0x2f, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_stone_head, 0, 0, 0, 0, 0); + break; + + case 48: + actor_init_struct(actor_num, 0x31, x_pos, y_pos + 1, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 49: + actor_init_struct(actor_num, 0x31, x_pos, y_pos + 1, 0, 1, 0, 1, &actor_wt_big_yellow_spike, 0, 0, 0, 0, 0); + break; + + case 50: + actor_init_struct(actor_num, 0x31, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_big_yellow_spike, 0, 0, 0, 0, 1); + break; + + case 51: + actor_init_struct(actor_num, 0x33, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_ghost, 0, 0, 0, 0, 4); + break; + + case 54: + actor_init_struct(actor_num, 0x36, x_pos, y_pos, 0, 0, 0, 1, &actor_wt_angry_moon, 0, 0, 0, 0, 4); + break; + + case 55: + actor_init_struct(actor_num, 0x37, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_small_red_plant, 0, 0, 0, 0, 0); + break; + + case 56: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x39, 0x1e, 0, 0, 0); + break; + + case 57: + actor_init_struct(actor_num, 0x39, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_bonus_bomb, 0, 0, 0, 0, 0); + break; + + case 59: + actor_init_struct(actor_num, 0x3c, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0x3b); + move_platform_flag = 0; + break; + + case 61: + actor_init_struct(actor_num, 0x3c, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0x3d); + break; + + case 62: + actor_init_struct(actor_num, 0x3e, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_question_mark_block, 0, 0, 0, 0, 0); + word_2E17E = 0; + break; + + case 65: + actor_init_struct(actor_num, 0x41, x_pos, y_pos, 0, 1, 1, 0, &actor_wt_mini_ghost, 0, 0, 0, 0, 0); + break; + + case 66: + actor_init_struct(actor_num, 0x44, x_pos, y_pos, 1, 0, 0, 1, &actor_wt_projectile_flashing_ball, 0, 0, 0, 0, 1); + break; + + case 67: + actor_init_struct(actor_num, 0x44, x_pos, y_pos, 1, 0, 0, 1, &actor_wt_projectile_flashing_ball, 0, 0, 0, 0, 3); + break; + + case 68: + actor_init_struct(actor_num, 0x44, x_pos, y_pos, 1, 0, 0, 1, &actor_wt_projectile_flashing_ball, 0, 0, 0, 0, 2); + break; + + case 69: + actor_init_struct(actor_num, 0x45, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_green_roamer_worm, 0, 3, 0, 0, 0); + break; + + case 70: + actor_init_struct(actor_num, 0x46, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_pipe_transit_direction, 0, 0, 0, 0, 0); + break; + + case 71: + actor_init_struct(actor_num, 0x47, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_pipe_transit_direction, 0, 0, 0, 0, 0); + break; + + case 72: + actor_init_struct(actor_num, 0x48, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_pipe_transit_direction, 0, 0, 0, 0, 0); + break; + + case 73: + actor_init_struct(actor_num, 0x49, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_pipe_transit_direction, 0, 0, 0, 0, 0); + break; + + case 74: + actor_init_struct(actor_num, 0x4b, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_egg_head, 0, 0, 0, 0, 0); + break; + + case 75: + actor_init_struct(actor_num, 0x4b, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_egg_head, 0, 0, 0, 0, 1); + break; + + case 78: + actor_init_struct(actor_num, 0x4e, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_robotic_spike_ground, 8, 0, 0, 0, 1); + break; + + case 80: + actor_init_struct(actor_num, 0x50, x_pos, y_pos + 1 + 1, 0, 1, 0, 0, &actor_wt_robotic_spike_ceiling, 0, 0, 0, 0, 0); + break; + + case 81: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x52, 0xb9, 0, 0, 0); + break; + + case 82: + actor_init_struct(actor_num, 0x52, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 83: + actor_init_struct(actor_num, 0x53, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_red_blue_plant, 0, 0, 0, 0, 0); + break; + + case 84: + actor_init_struct(actor_num, 0x53, x_pos, y_pos + 1 + 1, 0, 0, 0, 0, &actor_wt_red_blue_plant, 0, 0, 0, 0, 4); + break; + + case 85: + actor_init_struct(actor_num, 0x55, x_pos, y_pos + 1 + 1, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 86: + actor_init_struct(actor_num, 0x56, x_pos, y_pos, 0, 1, 1, 1, &actor_wt_blue_ball, 0, 0x14, 0, 0, 2); + break; + + case 87: + actor_init_struct(actor_num, 0x57, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 88: + actor_init_struct(actor_num, 0x58, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_retracting_spikes, 1, 0, 0, 0, 0); + break; + + case 89: + actor_init_struct(actor_num, 0x59, x_pos - 3, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 90: + actor_init_struct(actor_num, 0x5a, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_robot_with_blue_arc, 0, 0, 0, 0, 0); + break; + + case 91: + actor_init_struct(actor_num, 0x5b, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_blue_platform, 0, 0, 0, 0, 0); + break; + + case 92: + actor_init_struct(actor_num, 0x5c, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_spark, 0, 0, 0, 0, 0); + break; + + case 93: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x5e, 0xb9, 0, 0, 0); + break; + + case 94: + actor_init_struct(actor_num, 0x5e, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_bonus_item, 0, 0, 0, 1, 2); + break; + + case 95: + actor_init_struct(actor_num, 0x5f, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_pink_eye_plant, 0, 0, 0, 0, 0); + if(word_2E1E2 < 15) + { + word_2E1E2 = word_2E1E2 + 1; + } + break; + + case 96: + actor_init_struct(actor_num, 0x5f, x_pos, y_pos + 1, 0, 0, 0, 0, &actor_wt_pink_eye_plant, 0, 0, 0, 0, 4); + break; + + case 100: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xfb, 0x1e, 0, 0, 0); + break; + + case 101: + actor_init_struct(actor_num, 0x65, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_big_red_jumper, 0, 0, 0, 0, 7); + break; + + case 102: + actor_init_struct(actor_num, 0x66, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_133_boss_purple_15411, 0, 0, 0, 0, 0); + break; + + case 104: + actor_init_struct(actor_num, 0x69, x_pos - 1, y_pos + 1 + 1, 1, 0, 0, 0, &actor_wt_pneumatic_pipe, 0, 0, 0, 0, 0); + break; + + case 105: + actor_init_struct(actor_num, 0x69, x_pos - 1, y_pos + 1 + 1, 0, 1, 0, 0, &actor_wt_pneumatic_pipe, 0, 1, 0, 0, 0); + break; + + case 106: + actor_init_struct(actor_num, 0x6a, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_suction_cup_alien_enemy, 0, 0, 0, 0, 0); + break; + + case 107: + actor_init_struct(actor_num, 0x6c, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_teleporter, 0, 0, 0, 0, 2); + break; + + case 108: + actor_init_struct(actor_num, 0x6c, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_teleporter, 0, 0, 0, 0, 1); + break; + + case 109: + actor_init_struct(actor_num, 0x44, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_projectile_flashing_ball, 0, 0, 0, 0, 0); + break; + + case 110: + actor_init_struct(actor_num, 0x44, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_projectile_flashing_ball, 0, 0, 0, 0, 4); + break; + + case 112: + actor_init_struct(actor_num, 0x70, x_pos - 3, y_pos, 0, 0, 0, 0, &actor_wt_cyan_spitting_plant, 0, 0, 0, 0, 2); + break; + + case 111: + actor_init_struct(actor_num, 0x6f, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_cyan_spitting_plant, 0, 0, 0, 0, 3); + break; + + case 113: + actor_init_struct(actor_num, 0x71, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_blue_turret_alien, 0, 10, x_pos, 0, 3); + break; + + case 114: + actor_init_struct(actor_num, 0x72, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_hoverboard, 0, 0, 0, 0, 0); + break; + + case 118: + actor_init_struct(actor_num, 0x76, x_pos, y_pos, 0, 1, 1, 0, &actor_wt_red_chomper_alien, 0, 0, 0, 0, 0); + break; + + case 120: + actor_init_struct(actor_num, 0x3c, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0x78); + brightness_effect_enabled_flag = 0; + obj_switch_151_flag = 1; + break; + + case 121: + actor_init_struct(actor_num, 0x3c, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0x79); + break; + + case 122: + actor_init_struct(actor_num, 0x7a, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_energy_beam, 0, 0, 0, 0, 0); + break; + + case 123: + actor_init_struct(actor_num, 0x7b, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_energy_beam, 0, 0, 0, 0, 1); + break; + + case 124: + actor_init_struct(actor_num, 0x7c, x_pos, y_pos, 0, 1, 1, 0, &actor_wt_pink_slug, 0, 0, 0, 0, 0); + break; + + case 125: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 0); + break; + + case 126: + actor_init_struct(actor_num, 0x7e, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_silver_robot, 0, 0, 0, 0, 4); + break; + + case 127: + actor_init_struct(actor_num, 0x7f, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_security_robot, 0, 0, 0, 0, 4); + break; + + case 128: + actor_init_struct(actor_num, 0x80, x_pos, y_pos, 0, 0, 1, 0, &actor_wt_159_unknown, 0, 0, 0, 0, 3); + break; + + case 129: + actor_init_struct(actor_num, 0x81, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_dragonfly, 0, 0, 0, 0, 0); + break; + + case 130: + actor_init_struct(actor_num, 0x82, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_crate_bomb_box, 0, 0, 0, 0, (sub_1106F() % 0x14) * 5 + 0x32); + break; + + case 134: + actor_init_struct(actor_num, 0x86, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 135: + actor_init_struct(actor_num, 0x87, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 136: + actor_init_struct(actor_num, 0x88, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 137: + actor_init_struct(actor_num, 0x89, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 138: + actor_init_struct(actor_num, 0x8a, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 139: + actor_init_struct(actor_num, 0x8b, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 140: + actor_init_struct(actor_num, 0x8c, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 141: + actor_init_struct(actor_num, 0x8d, x_pos, y_pos + 1 + 1, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 142: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x86, 0x1e, 0, 0, 0); + break; + + case 52: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x87, 0xb9, 0, 0, 0); + break; + + case 53: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x88, 0xb9, 0, 0, 0); + break; + + case 119: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x89, 0xb9, 0, 0, 0); + break; + + case 115: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x8a, 0xb9, 0, 0, 0); + break; + + case 116: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_container, 0x8b, 0xb9, 0, 0, 0); + break; + + case 117: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x8c, 0x1e, 0, 0, 0); + break; + + case 143: + actor_init_struct(actor_num, 0x8f, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_satellite, 0, 0, 0, 0, 0); + break; + + case 145: + actor_init_struct(actor_num, 0x91, x_pos, y_pos + 7, 0, 1, 0, 0, &actor_wt_green_plant, 5, 0, 0, 7, 0); + break; + + case 146: + actor_init_struct(actor_num, 0x92, x_pos, y_pos + 1 + 1, 1, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 147: + actor_init_struct(actor_num, 0x93, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 148: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x93, 0xb9, 0, 0, 0); + break; + + case 149: + actor_init_struct(actor_num, 0x95, x_pos - 4, y_pos, 0, 1, 0, 0, &actor_wt_jaws_and_tongue, 0, 0, 0, 0, 0); + break; + + case 150: + actor_init_struct(actor_num, 0x96, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_invisible_exit_marker_right, 0, 0, 0, 0, 0); + break; + + case 151: + actor_init_struct(actor_num, 0x97, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_small_flame, 0, 0, 0, 0, 0); + break; + + case 153: + actor_init_struct(actor_num, 0x99, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_bonus_item, 0, 0, 0, 0, 4); + break; + + case 154: + actor_init_struct(actor_num, 0x9a, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_bonus_item, 0, 0, 0, 0, 5); + break; + + case 155: + actor_init_struct(actor_num, 0x9b, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_bonus_item, 0, 0, 0, 0, 6); + break; + + case 156: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x99, 0x1e, 0, 0, 0); + break; + + case 157: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x9a, 0x1e, 0, 0, 0); + break; + + case 158: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0x9b, 0x1e, 0, 0, 0); + break; + + case 159: + actor_init_struct(actor_num, 0x20, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 160: + actor_init_struct(actor_num, 0x22, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 161: + actor_init_struct(actor_num, 0x24, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 162: + actor_init_struct(actor_num, 0xa2, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_clam_trap, 0, 0, 0, 0, 0); + break; + + case 163: + actor_init_struct(actor_num, 0xa3, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_blue_cube_platform, 0, 0, 0, 0, 0); + break; + + case 164: + case 165: + case 166: + actor_init_struct(actor_num, 0xa4, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_short_dialog, image_index, 0, 0, 0, 0); + break; + + case 168: + actor_init_struct(actor_num, 0xa8, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 167: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xa8, 0xb9, 0, 0, 0); + break; + + case 170: + actor_init_struct(actor_num, 0xaa, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 169: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xaa, 0xb9, 0, 0, 0); + break; + + case 172: + actor_init_struct(actor_num, 0xac, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 171: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xac, 0xb9, 0, 0, 0); + break; + + case 174: + actor_init_struct(actor_num, 0xae, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_bonus_item, 0, 0, 0, 0, 5); + break; + + case 173: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xae, 0x1e, 0, 0, 0); + break; + + case 176: + actor_init_struct(actor_num, 0xb0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_bonus_item, 0, 0, 0, 0, 4); + break; + + case 175: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xb0, 0x1e, 0, 0, 0); + break; + + case 177: + actor_init_struct(actor_num, 0xb1, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_floating_score_effect, 0, 0, 0, 0, 0); + break; + + case 178: + actor_init_struct(actor_num, 0xb2, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_floating_score_effect, 0, 0, 0, 0, 0); + break; + + case 179: + actor_init_struct(actor_num, 0xb3, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_floating_score_effect, 0, 0, 0, 0, 0); + break; + + case 180: + actor_init_struct(actor_num, 0xb4, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_floating_score_effect, 0, 0, 0, 0, 0); + break; + + case 181: + actor_init_struct(actor_num, 0xb5, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_floating_score_effect, 0, 0, 0, 0, 0); + break; + + case 182: + actor_init_struct(actor_num, 0xb6, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_floating_score_effect, 0, 0, 0, 0, 0); + break; + + case 183: + actor_init_struct(actor_num, 0xb7, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_floating_score_effect, 0, 0, 0, 0, 0); + break; + + case 184: + actor_init_struct(actor_num, 0xb8, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_floating_score_effect, 0, 0, 0, 0, 0); + break; + + case 186: + actor_init_struct(actor_num, 0xba, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_alien_eating_space_plant, 0, 0, 0x1e, 0, 0); + break; + + case 187: + actor_init_struct(actor_num, 0xbb, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_blue_bird, 0, 0, 0, 0, 0); + break; + + case 188: + actor_init_struct(actor_num, 0xbc, x_pos, y_pos, 0, 1, 0, 0, &actor_wt_rocket, 0x3c, 10, 0, 0, 0); + break; + + case 189: + actor_init_struct(actor_num, 0xbd, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_bonus_item, 0, 0, 0, 0, 4); + break; + + case 190: + actor_init_struct(actor_num, 0xc0, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_destructable_pedestal, 13, 0, 0, 0, 0); + break; + + case 191: + actor_init_struct(actor_num, 0xc0, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_destructable_pedestal, 0x13, 0, 0, 0, 0); + break; + + case 192: + actor_init_struct(actor_num, 0xc0, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_destructable_pedestal, 0x19, 0, 0, 0, 0); + break; + + case 201: + actor_init_struct(actor_num, 0xc9, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_unknown_232, 0, 0, 0, 0, 0); + break; + + case 193: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xc2, 0x1e, 0, 0, 0); + break; + + case 194: + actor_init_struct(actor_num, 0xc2, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_bonus_item, 3, 2, 0, 0, 1); + break; + + case 195: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xc4, 0x1e, 0, 0, 0); + break; + + case 196: + actor_init_struct(actor_num, 0xc4, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_bonus_item, 2, 2, 0, 0, 1); + break; + + case 197: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xc6, 0x1e, 0, 0, 0); + break; + + case 198: + actor_init_struct(actor_num, 0xc6, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_bonus_item, 2, 2, 0, 0, 1); + break; + + case 199: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xc8, 0x1e, 0, 0, 0); + break; + + case 200: + actor_init_struct(actor_num, 0xc8, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_bonus_item, 2, 2, 0, 0, 1); + break; + + case 202: + actor_init_struct(actor_num, 0xca, x_pos, y_pos + 1 + 1, 0, 0, 0, 0, &actor_wt_bonus_item, 0, 0, 0, 0, 4); + break; + + case 203: + actor_init_struct(actor_num, 0x6c, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_teleporter, 0, 0, 0, 0, 3); + break; + + case 204: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 1); + break; + + case 205: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 2); + break; + + case 206: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 3); + break; + + case 207: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 4); + break; + + case 208: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 5); + break; + + case 209: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 6); + break; + + case 210: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 7); + break; + + case 211: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 8); + break; + + case 212: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 9); + break; + + case 63: + actor_init_struct(actor_num, 0x3f, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 64: + actor_init_struct(actor_num, 0x40, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_rubber_wall, 0, 0, 0, 0, 0); + break; + + case 213: + actor_init_struct(actor_num, 0xc2, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_bonus_item, 3, 2, 0, 0, 1); + break; + + case 214: + actor_init_struct(actor_num, 0xc4, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_bonus_item, 2, 2, 0, 0, 1); + break; + + case 215: + actor_init_struct(actor_num, 0xc6, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_bonus_item, 2, 2, 0, 0, 1); + break; + + case 216: + actor_init_struct(actor_num, 0xc8, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_bonus_item, 2, 2, 0, 0, 1); + break; + + case 152: + actor_init_struct(actor_num, 0x98, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_big_red_plant, 0, 0x1e, 0, 0, 0); + break; + + case 217: + actor_init_struct(actor_num, 2, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_spring, 0, 0, y_pos + 1, y_pos + 3, 1); + break; + + case 218: + actor_init_struct(actor_num, 0x1d, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xdc, 0x1e, 0, 0, 0); + break; + + case 219: + actor_init_struct(actor_num, 0xdc, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 220: + actor_init_struct(actor_num, 0xdc, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 221: + actor_init_struct(actor_num, 0xdd, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_frozen_duke_nukum, 0, 0, 0, 0, 0); + break; + + case 223: + actor_init_struct(actor_num, 0xdf, x_pos, y_pos + 1, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 224: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xe2, 0xb9, 0, 0, 0); + break; + + case 225: + actor_init_struct(actor_num, 0xe2, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 226: + actor_init_struct(actor_num, 0xe2, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 227: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xe5, 0xb9, 0, 0, 0); + break; + + case 228: + actor_init_struct(actor_num, 0xe5, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 229: + actor_init_struct(actor_num, 0xe5, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 230: + actor_init_struct(actor_num, 0, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_container, 0xe8, 0xb9, 0, 0, 0); + break; + + case 231: + actor_init_struct(actor_num, 0xe8, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 232: + actor_init_struct(actor_num, 0xe8, x_pos, y_pos, 1, 0, 1, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 233: + actor_init_struct(actor_num, 0xe9, x_pos - 1, y_pos, 0, 0, 0, 0, &actor_wt_horizontal_flame, 0, 0, 0, 0, 1); + break; + + case 234: + actor_init_struct(actor_num, 0xea, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_horizontal_flame, 0, 0, 0, 0, 0); + break; + + case 236: + actor_init_struct(actor_num, 0xed, x_pos, y_pos + 1, 0, 0, 0, 0, &actor_wt_acid, 0, 0, 0, 0, 0); + break; + + case 237: + actor_init_struct(actor_num, 0xed, x_pos, y_pos + 1, 0, 1, 0, 0, &actor_wt_acid, x_pos, y_pos + 1, 0, 0, 1); + break; + + case 238: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 10); + break; + + case 239: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 11); + break; + + case 240: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 12); + break; + + case 241: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 13); + break; + + case 242: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 14); + break; + + case 243: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 15); + break; + + case 235:actor_init_struct(actor_num, 0xeb, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_speech_bubble, 0, 0, 0, 0, 0); + break; + + case 244:actor_init_struct(actor_num, 0xf4, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_speech_bubble, 0, 0, 0, 0, 0); + break; + + case 245:actor_init_struct(actor_num, 0xf5, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_speech_bubble, 0, 0, 0, 0, 0); + break; + + case 246:actor_init_struct(actor_num, 0xf6, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_speech_bubble, 0, 0, 0, 0, 0); + break; + + case 247: + actor_init_struct(actor_num, 0xf7, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_switch_multi_use, 0, 0, 0, 0, 0); + break; + + case 248: + actor_init_struct(actor_num, 0xf8, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_smoke_rising, 0, 0, 0, 0, 1); + break; + + case 249: + actor_init_struct(actor_num, 0xf9, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_smoke_rising, 1, 0, 0, 0, 0); + break; + + case 250: + actor_init_struct(actor_num, 0xfa, x_pos, y_pos, 1, 0, 0, 0, &actor_wt_end_of_level_marker, 0, 0, 0, 0, 0); + break; + + case 251: + actor_init_struct(actor_num, 0x19, x_pos, y_pos, 1, 0, 1, 1, &actor_wt_green_pruny_cabbage_ball, 2, 0, 0, 0, 0); + break; + + case 252: + actor_init_struct(actor_num, 0x9b, x_pos, y_pos + 1, 0, 0, 0, 0, &actor_wt_bonus_item, 1, 0, 0, 0, 6); + break; + + case 253: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 0x10); + break; + + case 254: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 0x11); + break; + + case 255: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 0x12); + break; + + case 256: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 0x13); + break; + + case 257: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 0x14); + break; + + case 258: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 0x15); + break; + + case 259: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 0x16); + break; + + case 260: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 0x17); + break; + + case 261: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 0x18); + break; + + case 262: + actor_init_struct(actor_num, 0x7d, x_pos, y_pos, 0, 0, 0, 0, &actor_wt_hint_dialog, 0, 0, 0, 0, 0x19); + break; + + case 263: + actor_init_struct(actor_num, 0x1c, x_pos, y_pos, 0, 1, 1, 0, &actor_wt_bonus_item, 0, 0, 0, 1, 6); + break; + + case 264: + actor_init_struct(actor_num, 1, x_pos, y_pos, 0, 1, 1, 0, &actor_wt_bonus_item, 0, 0, 0, 0, 4); + break; + + case 265: + actor_init_struct(actor_num, 0x109, x_pos, y_pos + 3, 1, 0, 0, 0, &actor_wt_end_of_level_marker, 1, 0, 0, 0, 0); + break; + + default : + return 0; + } + + return 1; +} + +U0 actor_add_new(I64 image_index, I64 x_pos, I64 y_pos) +{ + I64 i; + ActorData *actor; + for (i = 0; i < total_num_actors; i++) + { + actor = &actors[i]; + if (actor->is_deactivated_flag_maybe != 0) + { + actor_init(i, image_index, x_pos, y_pos); + if (image_index == 0x56) + { + actor->update_while_off_screen_flag = 1; + } + return; + } + } + + if (total_num_actors < MAX_ACTORS) + { + actor = &actors[total_num_actors]; + actor_init(total_num_actors, image_index, x_pos, y_pos); + if (image_index == 0x56) + { + actor->update_while_off_screen_flag = 1; + } + total_num_actors = total_num_actors + 1; + } + + return; +} + +U0 load_actor(I64 actor_num, I64 actorType, I64 x_pos, I64 y_pos) +{ + //printf("Loading Actor: %d, (%d,%d)\n", actorType, x_pos, y_pos); + if (actorType < 0x20) + { + switch (actorType) + { + case 0: + if (map_width_in_tiles - 15 >= x_pos) + { + if (map_stride_bit_shift_amt <= 5 || x_pos - 15 < 0) + { + mapwindow_x_offset = 0; + } + else + { + mapwindow_x_offset = x_pos - 15; + } + } + else + { + mapwindow_x_offset = map_width_in_tiles - 38; + } + + if (y_pos - 10 < 0) + { + mapwindow_y_offset = 0; + } + else + { + mapwindow_y_offset = y_pos - 10; + } + + player_x_pos = x_pos; + player_y_pos = y_pos; + break; + + case 1: + moving_platform_tbl[num_moving_platforms].x = x_pos; + moving_platform_tbl[num_moving_platforms].y = y_pos; + num_moving_platforms++; + break; + + case 2: + case 3: + case 4: + case 5: + mud_fountain_tbl[num_mud_fountains].x = x_pos - 1; + mud_fountain_tbl[num_mud_fountains].y = y_pos - 1; + mud_fountain_tbl[num_mud_fountains].direction = 0; + mud_fountain_tbl[num_mud_fountains].length_counter = 0; + mud_fountain_tbl[num_mud_fountains].current_height = 0; + mud_fountain_tbl[num_mud_fountains].max_height = actorType * 3; + mud_fountain_tbl[num_mud_fountains].pause_counter = 0; + num_mud_fountains++; + break; + + case 6: + case 7: + case 8: + add_brightness_obj(actorType - 6, x_pos, y_pos); + break; + default: break; + } + } + + if (actorType >= 0x1f) + { + if (actor_init(actor_num, actorType - 31, x_pos, y_pos) != 0) + { + total_num_actors = total_num_actors + 1; + } + } + return; +} + +U0 actor_update(ActorData *actor) +{ + if (actor->is_deactivated_flag_maybe != 0) + { + return; + } + + if (actor->y > map_max_y_offset + 0x15) + { + actor->is_deactivated_flag_maybe = 1; + return; + } + + actor_tile_display_func_index = 0; + if (actor->count_down_timer != 0) + { + actor->count_down_timer = actor->count_down_timer - 1; + } + + if (is_sprite_on_screen(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) == 0) + { + if (actor->update_while_off_screen_flag == 0) + { + return; + } + actor_tile_display_func_index = 1; + } + else + { + + if (actor->can_update_if_goes_off_screen_flag != 0) + { + actor->update_while_off_screen_flag = 1; + } + } + + if (actor->can_fall_down_flag != 0) + { + if (sprite_blocking_check(1, actor->actorInfoIndex, 0, actor->x, actor->y) != 0) + { + + actor->y = actor->y - 1; + actor->falling_counter = 0; + } + + if (sprite_blocking_check(1, actor->actorInfoIndex, 0, actor->x, actor->y + 1) != 0) + { + actor->falling_counter = 0; + } + else + { + + if (actor->falling_counter < 5) + { + actor->falling_counter = actor->falling_counter + 1; + } + + if (actor->falling_counter > 1 && actor->falling_counter < 6) + { + actor->y = actor->y + 1; + } + + if (actor->falling_counter == 5) + { + if (sprite_blocking_check(1, actor->actorInfoIndex, 0, actor->x, actor->y + 1) != 0) + { + actor->falling_counter = 0; + } + else + { + actor->y = actor->y + 1; + } + } + } + } + + if (is_sprite_on_screen(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0) + { + actor_tile_display_func_index = 0; + } + + actor->update_function(actor); + + if (struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0 && + blow_up_actor_with_bomb(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0) + { + actor->is_deactivated_flag_maybe = 1; + return; + } + + if (actor_update_impl(actor, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) == 0 && actor_tile_display_func_index != 1) + { + + display_actor_sprite_maybe(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y, actor_tile_display_func_index); + } + + return; +} + +U0 actor_update_all() +{ + I64 i; + word_32EAC = 0; + + for(i=0;iis_deactivated_flag_maybe = 1; + explode_effect_add_sprite(actor->data_2, 0, actor->x - 1, actor->y); + + explode_effect_add_sprite(actor->data_2, 1, actor->x + 1, actor->y - 1); + + explode_effect_add_sprite(actor->data_2, 2, actor->x + 3, actor->y); + + explode_effect_add_sprite(actor->data_2, 3, actor->x + 1 + 1, actor->y + 2); + if((sub_1106F() & 1) == 0) + { + //play_sfx(0x3d); + } + else + { + //play_sfx(12); + } + + actor_toss_add_new(actor->data_1, actor->x + 1, actor->y); + if(word_2E1E4 == 1) + { + actor_add_new(0xf6, player_x_pos - 1, player_y_pos - 5); + } + word_2E1E4--; + return ; +} + +I64 actor_update_impl(ActorData *actor, I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos) +{ + if (is_sprite_on_screen(actorInfoIndex, frame_num, x_pos, y_pos) == 0) + { + return 1; + } + + I64 ax; + + uint16 sprite_height = actor_get_tile_info(actorInfoIndex, frame_num)->height; + uint16 sprite_width = actor_get_tile_info(actorInfoIndex, frame_num)->width; + + word_2E1E8 = 0; + if (actorInfoIndex != 0x66) + { + ax = Cond(word_2E180 <= 3, 0, 1); + + if (ax + y_pos - sprite_height + 1 >= player_y_pos && y_pos - sprite_height <= player_y_pos && + player_x_pos + 1 + 1 >= x_pos && x_pos + sprite_width - 1 >= player_x_pos && player_hoverboard_counter == 0) + { + word_2E1E8 = 1; + } + } + else + { + sprite_height = 7; + if (y_pos - sprite_height + 5 >= player_y_pos && y_pos - sprite_height <= player_y_pos && + player_x_pos + 1 + 1 >= x_pos && x_pos + sprite_width - 1 >= player_x_pos) + { + word_2E1E8 = 1; + } + } + + switch (actorInfoIndex) + { + case 2: //33 PLAT: Floor Spring + if (actor->data_5 == 0) + { + if (actor->count_down_timer == 0 && player_bounce_in_the_air(0x28) != 0) + { + //play_sfx(6); + if (word_2E246 == 0) + { + word_2E246 = 1; + actor_add_new(0xf4, player_x_pos - 1, player_y_pos - 5); + } + actor->data_1 = 3; + } + return 0; + } + break; + + case 16: //47 OBJECT: Blue Mobile Trampoline Car + if (actor->count_down_timer == 0 && player_bounce_in_the_air(0x14) != 0) + { + //play_sfx(0x2b); + actor->data_1 = 3; + } + return 0; + + case 25: //56 HAZARD: Green Pruny Cabbage Ball + if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0) + { + actor->count_down_timer = 5; + //play_sfx(6); + actor_tile_display_func_index = 2; + + actor->data_1 = actor->data_1 - 1; + if (actor->data_1 == 0) + { + actor->is_deactivated_flag_maybe = 1; + player_add_score_for_actor(0x19); + + exploding_balls_effect(actor->x, actor->y); + return 1; + } + } + else + { + if (actor->count_down_timer == 0 && + player_check_collision_with_actor(actorInfoIndex, frame_num, x_pos, y_pos) != 0) + { + player_decrease_health(); + } + } + return 0; + + case 0: //31 Unknown. + case 29: //60 BARREL: Power Up (health/12800) + if (actor->count_down_timer == 0 && player_bounce_in_the_air(5) != 0) + { + actor_explode_container(actor); + player_add_to_score(0x64); + + actor_add_new(0xb1, actor->x, actor->y); + return 1; + } + return 0; + + case 51: // 82 ENEMY: Ghost + case 54: // 85 ENEMY: Angry Moon (blue floating characters) + if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0) + { + actor->count_down_timer = 3; + //play_sfx(6); + + actor->data_5 = actor->data_5 - 1; + actor_tile_display_func_index = 2; + if (actor->data_5 != 0) + { + return 0; + } + actor->is_deactivated_flag_maybe = 1; + if (actorInfoIndex == 0x33) + { + actor_add_new(0x41, actor->x, actor->y); + } + + exploding_balls_effect(actor->x - 1, actor->y + 1); + player_add_score_for_actor(0x33); + return 1; + } + else + { + if (actor->count_down_timer == 0 && + player_check_collision_with_actor(actorInfoIndex, frame_num, x_pos, y_pos) != 0) + { + player_decrease_health(); + } + } + return 0; + + case 65: // 96 ENEMY: Mini Ghost (jumps) + case 106: // 137 ENEMY: Suction-Cup-Legged Alien + case 187: // 218 ENEMY: Blue Bird + if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0) + { + //play_sfx(6); + + actor->is_deactivated_flag_maybe = 1; + exploding_balls_effect(actor->x, actor->y); + player_add_score_for_actor(actor->actorInfoIndex); + return 1; + } + else + { + if (actor->count_down_timer == 0 && + player_check_collision_with_actor(actorInfoIndex, frame_num, x_pos, y_pos) != 0) + { + player_decrease_health(); + } + } + return 0; + + case 74: // 105 ENEMY: Egg Head (special?) -- only 1x: in B2.MNI + case 75: // 106 ENEMY: Egg Head + if (actor->count_down_timer != 0) + { + return 0; + } + if (player_bounce_in_the_air(7) == 0) + { + return 0; + } + //play_sfx(0x21); + + if (actor->data_2 != 0) + { + actor->data_2 = 1; + } + else + { + actor->data_2 = 10; + } + return 0; + + case 86: // 117 ENEMY: Blue Ball + if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0) + { + //play_sfx(6); + + actor->data_3 = 0; + actor->count_down_timer = 3; + actor->data_5 = actor->data_5 - 1; + if (actor->data_1 != 0 || actor->falling_counter != 0) + { + actor->data_5 = 0; + } + + if (actor->data_5 == 0) + { + exploding_balls_effect(actor->x, actor->y); + + actor->is_deactivated_flag_maybe = 1; + if (actor->data_1 > 0) + { + player_add_to_score(0xc80); + + actor_add_new(0xb6, actor->x, actor->y); + return 0; + } + if (actor->falling_counter == 0) + { + player_add_to_score(0x320); + } + else + { + player_add_to_score(0x3200); + + actor_add_new(0xb8, actor->x, actor->y); + } + } + else + { + actor_tile_display_func_index = 2; + + if (actor->data_1 == 0) + { + actor->data_2 = 0; + actor->data_1 = (sub_1106F() & 1) + 1; + } + } + } + else + { + if (actor->count_down_timer == 0 && + player_check_collision_with_actor(actorInfoIndex, frame_num, x_pos, y_pos) != 0) + { + player_decrease_health(); + } + } + return 0; + + 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); + + actor->count_down_timer = 6; + actor->data_5 = actor->data_5 - 1; + if (actor->data_5 != 0) + { + actor_tile_display_func_index = 2; + } + else + { + actor_add_new(1, actor->x, actor->y); + + exploding_balls_effect(actor->x, actor->y); + actor->is_deactivated_flag_maybe = 1; + return 1; + } + } + else + { + if (actor->count_down_timer == 0 && + player_check_collision_with_actor(actorInfoIndex, frame_num, x_pos, y_pos) != 0) + { + player_decrease_health(); + } + } + return 0; + + case 113: // 144 ENEMY: Blue Turret Alien + case 118: // 149 ENEMY: Red Chomper Alien + case 126: // 157 ENEMY: Silver Robot (pushes player around) + if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0) + { + actor->count_down_timer = 3; + //play_sfx(6); + actor_tile_display_func_index = 2; + if (actorInfoIndex != 0x76) + { + actor->data_5 = actor->data_5 - 1; + } + if (actor->data_5 == 0 || actorInfoIndex == 0x76) + { + + actor->is_deactivated_flag_maybe = 1; + player_add_score_for_actor(actor->actorInfoIndex); + + exploding_balls_effect(actor->x, actor->y); + return 1; + } + } + else + { + if (actor->count_down_timer == 0 && + player_check_collision_with_actor(actorInfoIndex, frame_num, x_pos, y_pos) != 0) + { + player_decrease_health(); + } + } + return 0; + + case 124: // 155 CREATURE/HAZARD: Pink slug/Worm + if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0) + { + player_add_score_for_actor(0x7c); + //play_sfx(6); + + exploding_balls_effect(actor->x, actor->y); + + actor->is_deactivated_flag_maybe = 1; + actor_add_new(0x80, actor->x, actor->y); + return 1; + } + return 0; + + case 127: // 158 ENEMY: Security Robot (shoots flashing bullet, can act as moving floor spring) + if (((brightness_effect_enabled_flag == 0 && obj_switch_151_flag != 0) || (brightness_effect_enabled_flag != 0 && obj_switch_151_flag == 0)) && + actor->count_down_timer == 0 && player_bounce_in_the_air(15) != 0) + { + actor->count_down_timer = 3; + //play_sfx(6); + + if (actor->data_1 == 0) + { + actor->frame_num = 8; + } + else + { + actor->frame_num = 7; + } + } + else + { + if (actor->count_down_timer == 0 && + player_check_collision_with_actor(actorInfoIndex, frame_num, x_pos, y_pos) != 0) + { + player_decrease_health(); + } + } + return 0; + + case 129: // 160 PLAT/HAZARD: Dragonfly + case 145: // 176 ENEMY: Green Plant + if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0) + { + num_hits_since_touching_ground = 0; + //play_sfx(6); + actor->count_down_timer = 5; + } + else + { + if (actor->count_down_timer == 0 && + player_check_collision_with_actor(actorInfoIndex, frame_num, x_pos, y_pos) != 0) + { + player_decrease_health(); + } + } + return 0; + + 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); + } + return 0; + + case 152: // 183 ENEMY: Big Red Plant (spitting Blue Balls/catapult) + + if (actor->has_moved_right_flag != 0) + { + actor->has_moved_right_flag = actor->has_moved_right_flag - 1; + if (actor->has_moved_right_flag != 0) + { + return 0; + } + byte_2E2E4 = 1; + word_2E1E8 = 1; + if (actor->count_down_timer != 0 || player_bounce_in_the_air(0x14) == 0) + {//FIXME is this correct? + } + //play_sfx(6); + byte_2E17C = 0; + hide_player_sprite = 0; + word_2E180 = 0; + + actor->has_moved_left_flag = 1; + actor->data_2 = 0; + actor->data_1 = 1; + player_y_pos = player_y_pos - 2; + if (word_2E236 == 0) + { + word_2E236 = 1; + actor_add_new(0xf4, player_x_pos - 1, player_y_pos - 5); + } + return 0; + } + + if (actor->has_moved_left_flag != 0) + { + return 0; + } + if (actor->x + 1 > player_x_pos) + { + return 0; + } + if (actor->x + 5 < player_x_pos + 1 + 1) + { + return 0; + } + if (actor->y - 1 != player_y_pos && actor->y - 2 != player_y_pos) + { + return 0; + } + if (byte_2E2E4 != 0) + { + + actor->has_moved_right_flag = 0x14; + word_2E1E8 = 0; + player_bounce_height_counter = 0; + byte_2E2E4 = 0; + byte_2E17C = 1; + hide_player_sprite = 1; + actor->has_moved_left_flag = 1; + actor->data_2 = 0; + actor->data_1 = 1; + //play_sfx(0x3e); + } + return 0; + + + case 102: // 133 ENEMY: BOSS (Purple Alien in Spike-bottomed ship) + + if (actor->has_moved_right_flag != 0) + { + return 1; + } + if (actor->data_5 == 12) + { + return 1; + } + if (actor->count_down_timer == 0 && player_bounce_in_the_air(7) != 0) + { + //play_sfx(6); + + actor->data_5 = actor->data_5 + 1; + actor->has_moved_left_flag = 10; + actor->count_down_timer = 7; + if (actor->data_1 != 2) + { + actor->data_1 = 2; + actor->data_2 = 0x1f; + actor->data_3 = 0; + actor->data_4 = 1; + actor->can_fall_down_flag = 0; + actor->falling_counter = 0; + } + + if (actor->data_5 == 4) + { + explode_effect_add_sprite(0x66, 1, actor->x, actor->y - 4); + //play_sfx(0x37); + } + + 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 (actor->count_down_timer == 0 && + player_check_collision_with_actor(actorInfoIndex, frame_num, x_pos, y_pos) != 0) + { + player_decrease_health(); + } + } + return 1; + } + + + if (player_check_collision_with_actor(actorInfoIndex, frame_num, x_pos, y_pos) == 0) + { + return 0; + } + + + switch (actorInfoIndex - 1) + { + case 2: + case 3: + case 4: + case 5: + case 19: + case 40: + case 43: + case 44: + case 45: + case 46: + case 47: + case 48: + case 49: + case 67: + case 77: + case 79: + case 91: + case 150:player_decrease_health(); + + if (actor->actorInfoIndex == 0x44) + { + actor->is_deactivated_flag_maybe = 1; + + } + return 0; + + + case 232: // 264 DANGER: Flame (<-) + case 233: // 265 DANGER: Flame (->) + if (actor->frame_num > 1) + { + player_decrease_health(); + } + return 0; + + + case 42: // 74 HAZARD: Dripping Green Acid + case 236:// 268 HAZARD: Dripping Red Acid + + if (actor->data_5 != 0) + { + actor->y = actor->data_2; + actor->data_4 = 0; + if (actor->y > player_y_pos - 4 || actor->frame_num == 6) + { + player_decrease_health(); + } + + actor->frame_num = 0; + return 0; + } + if (actor->y > player_y_pos - 4) + { + player_decrease_health(); + } + return 0; + + case 82: // 114 ENEMY: Blue/Red plant + case 83: // 115 Unknown + if (actor->frame_num != 0) + { + player_decrease_health(); + } + return 0; + + case 6: // 38 Blue Switch (on ceiling + case 7: // 39 Red Switch (on ceiling) + case 8: // 40 Green Switch + case 9: // 41 Yellow Switch + + if (actor->frame_num == 0) + { + actor->y = actor->y - 1; + actor->frame_num = 1; + } + return 0; + + case 16: // 48 HAZARD: Non-Retracting Spikes + case 17: // 49 HAZARD: Retracting Spikes + case 86: // 118 ENEMY: Spikes (on left wall) + case 87: // 119 ENEMY: Retracting Spikes (on left wall) + case 88: // 120 ENEMY: Spikes (on right wall) + if (actor->frame_num <= 1) + { + player_decrease_health(); + return 0; + } + return 1; + + case 27: // 59 BONUS: Power Up (health/12800) + actor->is_deactivated_flag_maybe = 1; + //play_sfx(1); + + effect_add_sprite(15, 4, actor->x, actor->y, 0, 3); + if (knows_about_powerups_flag == 0) + { + knows_about_powerups_flag = 1; + power_up_module_dialog(); + } + if (health > num_health_bars) + { + player_add_to_score(0x3200); + + actor_add_new(0xb8, actor->x, actor->y); + } + else + { + health = health + 1; + update_health_bar_display(); + + player_add_to_score(0x64); + + actor_add_new(0xb1, actor->x, actor->y); + } + return 1; + + case 84: + case 93: + case 133: + case 134: + case 135: + case 136: + case 137: + case 138: + case 139: + case 140: + case 145: + case 146: + case 167: + case 169: + case 171: + case 222: + case 225: + case 228: + case 231:actor->is_deactivated_flag_maybe = 1; + if (actorInfoIndex != 0x92 && actorInfoIndex != 0xdf && actorInfoIndex != 0x55 && actorInfoIndex != 0x8d) + { + player_add_to_score(0x190); + actor_add_new(0xb3, x_pos, y_pos); + } + else + { + player_add_to_score(0x320); + actor_add_new(0xb4, x_pos, y_pos); + } + effect_add_sprite(15, 4, actor->x, actor->y, 0, 3); + //play_sfx(13); + return 1; + + case 56: // 88: bonus bomb + if (num_bombs <= 8) + { + actor->is_deactivated_flag_maybe = 1; + num_bombs++; + has_had_bomb_flag = 1; + player_add_to_score(0x64); + + actor_add_new(0xb1, actor->x, actor->y); + display_num_bombs_left(); + + effect_add_sprite(15, 4, actor->x, actor->y, 0, 3); + //play_sfx(13); + return 1; + } + return 0; + + case 68: // 100 CREATURE: Green Roamer Worm + if (actor->count_down_timer != 0) + { + return 0; + } + + actor->count_down_timer = 10; + if (player_bounce_in_the_air(7) == 0) + { + player_hanging_on_wall_direction = 0; + } + else + { + //play_sfx(6); + } + + actor_toss_add_new(green_roamer_worm_tbl[sub_1106F() & 3], actor->x, actor->y + 1); + //play_sfx(0x11); + actor_tile_display_func_index = 2; + + actor->data_2 = actor->data_2 - 1; + if (actor->data_2 == 0) + { + actor->is_deactivated_flag_maybe = 1; + exploding_balls_effect(actor->x - 1, actor->y + 1); + } + return 0; + + case 69: // 101 PIPE TRANSIT DIRECTION: Arrow Up + case 70: // 102 PIPE TRANSIT DIRECTION: Arrow Down + case 71: // 103 PIPE TRANSIT DIRECTION: Arrow Left + case 72: // 104 PIPE TRANSIT DIRECTION: Arrow Right + if (player_in_pneumatic_tube_flag == 0) + { + return 1; + } + + switch (actorInfoIndex - 0x46) + { + case 0:push_player_around(1, 0x64, 2, 0xff, 0, 0); + break; + + case 1:push_player_around(5, 0x64, 2, 0xff, 0, 0); + break; + + case 2:push_player_around(7, 0x64, 2, 0xff, 0, 0); + break; + + case 3:push_player_around(3, 0x64, 2, 0xff, 0, 0); + break; + } + + //play_sfx(0x16); + return 1; + + case 104: // 136: pneumatic pipe entrance + + if (actor->data_2 == 0 && (actor->y + 3 == player_y_pos || actor->y + 2 == player_y_pos)) + { + if (player_is_being_pushed_flag == 0) + { + return 0; + } + player_x_pos = actor->x; + word_32EB2 = 1; + player_in_pneumatic_tube_flag = 0; + player_reset_push_variables(); + if (word_2E24C == 0) + { + word_2E24C = 1; + actor_add_new(0xf4, player_x_pos - 1, player_y_pos - 5); + } + return 0; + } + if (byte_2E2E4 != 0 && player_bounce_flag_maybe == 0) + { + return 0; + } + if (jump_key_pressed == 0 && player_bounce_flag_maybe == 0) + { + return 0; + } + + if (actor->x != player_x_pos) + { + return 0; + } + if (actor->y + 3 == player_y_pos || actor->y + 2 == player_y_pos) + { + player_in_pneumatic_tube_flag = 1; + } + return 0; + + case 107: // 139 OBJECT: Teleporter B + if (teleporter_counter != 0) + { + return 1; + } + + if (actor->x > player_x_pos || actor->x + 4 < player_x_pos + 1 + 1 || actor->y != player_y_pos) + { + player_is_teleporting_flag = 0; + } + else + { + if (up_key_pressed != 0) + { + teleporter_state_maybe = actor->data_5; + teleporter_counter = 15; + byte_2E2E4 = 0; + } + player_is_teleporting_flag = 1; + } + return 1; + + case 113: // 145 PLAT: Hoverboard + if (byte_2E2E4 == 0) + { + return 0; + } + + if (actor->y != player_y_pos && actor->y + 1 != player_y_pos) + { + return 0; + } + player_hoverboard_counter = 4; + //play_sfx(3); + player_reset_push_variables(); + byte_2E2E4 = 0; + word_2E180 = 0; + player_bounce_flag_maybe = 0; + word_2E1E8 = 0; + player_bounce_height_counter = 0; + num_hits_since_touching_ground = 0; + if (word_2E232 == 0) + { + word_2E232 = 1; + actor_add_new(0xf4, player_x_pos - 1, player_y_pos - 5); + } + return 0; + + case 148: // 180 DECO: Jaws & Tongue + + if (actor->data_4 != 0) + { + actor->data_4 = actor->data_4 - 1; + if (actor->data_4 != 0) + { + actor->frame_num = 0; + return 1; + } + else + { + finished_level_flag_maybe = 1; + actor->frame_num = 0; + } + return 0; + } + + if (actor->data_1 == 0) + { + return 1; + } + if (actor->y != player_y_pos) + { + return 1; + } + if (actor->x <= player_x_pos) + { + actor->frame_num = 0; + actor->data_5 = 0; + actor->data_4 = 5; + hide_player_sprite = 1; + byte_2E17C = 1; + //play_sfx(0x27); + } + return 1; + + case 161: // 193 HAZARD: Clamp Trap + + if (actor->data_2 == 0 && actor->x == player_x_pos && actor->y == player_y_pos) + { + actor->data_2 = 1; + byte_2E17C = 1; + if (word_2E220 == 0) + { + word_2E220 = 1; + actor_add_new(0xf5, player_x_pos - 1, player_y_pos - 5); + } + return 0; + } + //NOTE deliberate fall through here. :) + + case 185: // 217 ENEMY: Alien-Eating Space Plant (Exits the current level) + + if (actor->frame_num != 0) + { + return 0; + } + if (actor->x >= player_x_pos) + { + return 0; + } + if (actor->x + 5 <= player_x_pos) + { + return 0; + } + if (actor->y - 2 <= player_y_pos) + { + return 0; + } + if (actor->y - 5 >= player_y_pos) + { + return 0; + } + if (byte_2E2E4 != 0) + { + actor->data_5 = 1; + byte_2E17C = 1; + hide_player_sprite = 1; + actor->frame_num = 1; + //play_sfx(0x27); + } + return 0; + + case 0: // 32: bonus star + effect_add_sprite(0x17, 8, x_pos, y_pos, 0, 1); + num_stars_collected++; + actor->is_deactivated_flag_maybe = 1; + //play_sfx(1); + player_add_score_for_actor(actorInfoIndex); + actor_add_new(0xb2, x_pos, y_pos); + display_num_stars_collected(); + return 1; + + case 81: // 113 Hamburger + actor->is_deactivated_flag_maybe = 1; + player_add_to_score(0x3200); + actor_add_new(0xb8, x_pos, y_pos); + + effect_add_sprite(15, 4, actor->x, actor->y, 0, 3); + //play_sfx(13); + if (num_health_bars < 5) + { + num_health_bars++; + } + if (word_2E22A == 0) + { + actor_add_new(0xf4, player_x_pos - 1, player_y_pos - 5); + word_2E22A = 1; + } + update_health_bar_display(); + return 1; + + case 31: // 63 BONUS: Green Tomato (falling) + case 33: // 65 BONUS: Tomato (falling) + case 35: // 67 BONUS: Yellow/Cyan Fruit (falling) + case 37: // 69 Unknown + actor->is_deactivated_flag_maybe = 1; + player_add_to_score(0xc8); + actor_add_new(0xb2, x_pos, y_pos); + + effect_add_sprite(15, 4, actor->x, actor->y, 0, 3); + //play_sfx(13); + return 1; + + case 188: // 220 BONUS: Invincibility Cube + actor->is_deactivated_flag_maybe = 1; + 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); + return 1; + + case 152: // 184 unknown + case 173: // 205 BONUS: Green Gem + case 175: // 207 BONUS: Diamond + actor->is_deactivated_flag_maybe = 1; + 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); + return 1; + + case 153: // 185 BONUS: Blue Crystal (on ground) + case 154: // 186 BONUS: Red Crystal (on ground) + actor->is_deactivated_flag_maybe = 1; + 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); + return 1; + + case 193: // 225 BONUS: Diamond 2 (falling) + case 195: // 227 BONUS: Red Berry (falling) + case 197: // 229 BONUS: Crystal (falling) + case 199: // 231 BONUS: Blue Gem (falling) + case 219: // 251 BONUS: Headphones (falling) + actor->is_deactivated_flag_maybe = 1; + 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); + return 1; + + case 1: // 33: floor spring + if (actor->data_5 != 0 && actor->count_down_timer == 0 && player_hoverboard_counter == 0 && + (byte_2E2E4 == 0 || player_bounce_flag_maybe != 0)) + { + actor->count_down_timer = 2; + //play_sfx(6); + actor->data_1 = 3; + player_bounce_height_counter = 0; + player_bounce_flag_maybe = 0; + byte_2E2E4 = 1; + word_2E180 = 4; + byte_2E182 = 0; + } + return 0; + + case 38: // 70 OBJECT: Exit Sign (ends level on touch) + finished_level_flag_maybe = 1; + return 0; + + case 59: // 91 unknown. + + if (actor->data_1 >= 4 || actor->data_4 != 0) + { + return 0; + } + byte_2E2E4 = 1; + sub_11062(); + player_bounce_in_the_air(3); + + actor->data_1 = actor->data_1 + 1; + if (actor->data_2 != 0) + { + actor->data_3 = 0; + } + else + { + actor->data_3 = 0x40; + actor->data_2 = 1; + } + actor->data_4 = 1; + return 0; + + case 63: // 95 OBJECT: Rubber Wall (can blow it up, throws Cosmo backwards when touched) + if (word_2E234 == 0) + { + word_2E234 = 1; + actor_add_new(0xf5, player_x_pos - 1, player_y_pos - 5); + } + if (actor->x != player_x_pos + 2) + { + if (actor->x + 2 != player_x_pos) + { + return 0; + } + push_player_around(3, 5, 2, 0x11, 0, 1); + } + else + { + push_player_around(7, 5, 2, 0x28, 0, 1); + } + //play_sfx(0x14); + return 0; + + case 62: + case 110: + case 111: + case 127: + case 201:player_decrease_health(); + return 0; + + case 54: // 86 ENEMY: Small Red Plant + actor->data_1 = 1; + player_decrease_health(); + return 0; + + case 246: + if (get_episode_number() != 1) //FIXME is this ok to leave in EP1 + { + hide_player_sprite = 1; + byte_2E17C = 1; + actor->data_1++; + if (actor->frame_num == 0) + { + if (actor->data_1 == 3) + { + actor->frame_num++; + } + } + else + { + finished_level_flag_maybe = 1; + } + if (actor->data_1 > 1) + { + player_y_pos = actor->y; + byte_2E2E4 = 0; + } + return 0; + } + break; + + default :break; + } + + return 0; +} \ No newline at end of file diff --git a/Actor_Toss.HC b/Actor_Toss.HC new file mode 100644 index 0000000..de1fd87 --- /dev/null +++ b/Actor_Toss.HC @@ -0,0 +1,76 @@ +#define MAX_TOSSED_ACTORS 6 + +class ActorToss +{ +I64 actorInfoIndex; +I64 x; +I64 y; +I64 counter; +}; + +ActorToss actorToss[MAX_TOSSED_ACTORS]; + +U0 actor_toss_add_new(I64 actorInfoIndex, I64 x_pos, I64 y_pos) { + I64 i; + for(i=0;iactorInfoIndex == 0) + goto actor_toss_update_cont; + + at->counter = at->counter + 1; + at->y--; + if (sprite_blocking_check(0, at->actorInfoIndex, 0, at->x, at->y) == NOT_BLOCKED) + { + if (at->counter >= 9 || sprite_blocking_check(0, at->actorInfoIndex, 0, at->x, --at->y) == NOT_BLOCKED) + { + if(at->counter != 11) + { + display_actor_sprite_maybe(at->actorInfoIndex, 0, at->x, at->y, 4); + } + else + { + actor_add_new(at->actorInfoIndex, at->x, at->y); + display_actor_sprite_maybe(at->actorInfoIndex, 0, at->x, at->y, 4); + at->actorInfoIndex = 0; + } + } + else + { + actor_add_new(at->actorInfoIndex, at->x, at->y + 1); + display_actor_sprite_maybe(at->actorInfoIndex, 0, at->x, at->y + 1, 0); + at->actorInfoIndex = 0; + } + } + else + { + actor_add_new(at->actorInfoIndex, at->x, at->y + 1); + display_actor_sprite_maybe(at->actorInfoIndex, 0, at->x, at->y + 1, 0); + at->actorInfoIndex = 0; + } +actor_toss_update_cont: + } +} + +U0 actor_toss_clear_all() { + I64 i; + for(i=0;ihas_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); + //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) + { + //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; + //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; + //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; + //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; + //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; +} + +uint8 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) + { + //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; +} + +uint8 alien_eating_space_plant_f_num_tbl[4] = {5, 6, 7, 8}; +uint8 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; +} + +sint8 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 + { + //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); + sint8 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) + { + //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) + { + //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 */ +} + +uint8 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); + //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); + //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) + { + //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); + //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; +} + +uint8 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 +}; + +uint8 blue_ball_moving_left_frame_num_tbl[4] = {7, 6, 5, 4}; +uint8 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) +{ + uint16 sprite_width = actor_get_tile_info(actor->actorInfoIndex, actor->frame_num)->width; + I64 block_status; + uint8 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; +} + +sint8 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) + { + if((actor->data_3 & 1) != 0 && actor->data_3 < 10) + { + actor->y = actor->y - 1; + } + } + else + { + actor->data_3 = 0; + actor->data_1 = 2; + if(actor->x + 1 <= player_x_pos) + { + actor->data_4 = 1; + } + else + { + actor->data_4 = 0; + } + } + + if(actor->x + 1 <= player_x_pos) + { + actor->frame_num = (actor->data_3 & 1) + 6; + } + else + { + actor->frame_num = (actor->data_3 & 1) + 2; + } + } + else + { + + if(actor->data_1 == 2) + { + actor->data_3 = actor->data_3 + 1; + if(actor->data_4 != 0) + { + actor->frame_num = (actor->data_3 & 1) + 6; + actor->x = actor->x + 1; + } + else + { + actor->frame_num = (actor->data_3 & 1) + 1 + 1; + actor->x = actor->x - 1; + } + actor->y = actor->y + bird_swoop_y_offset_tbl[actor->data_3 - 1]; + if(actor->data_3 == 15) + { + actor->data_1 = 1; + actor->data_3 = 10; + } + } + } + } + return; +} + +U0 actor_wt_blue_cube_platform(ActorData *actor) +{ + if(sprite_blocking_check(1, 0xa3, 0, actor->x, actor->y + 1) != NOT_BLOCKED) + { + actor->is_deactivated_flag_maybe = 1; + explode_effect_add_sprite(0xa3, 1, actor->x, actor->y); + + explode_effect_add_sprite(0xa3, 2, actor->x, actor->y); + //play_sfx(0x19); + actor_tile_display_func_index = 2; + return; + } + + if(actor->data_1 == 0) + { + actor->has_moved_left_flag = map_get_tile_cell(actor->x, actor->y - 1); + actor->has_moved_right_flag = map_get_tile_cell(actor->x + 1, actor->y - 1); + map_write_tile_cell(0x50, actor->x, actor->y - 1); + map_write_tile_cell(0x50, actor->x + 1, actor->y - 1); + actor->data_1 = 1; + } + + if(actor->y - 2 == player_y_pos) + { + if(actor->x <= player_x_pos + 1 + 1) + { + if(actor->x + 1 >= player_x_pos) + { + actor->data_2 = 7; + } + } + } + + if(actor->data_2 != 0) + { + actor->data_2--; + if(actor->data_2 == 0) + { + actor->can_fall_down_flag = 1; + map_write_tile_cell(actor->has_moved_left_flag, actor->x, actor->y - 1); + map_write_tile_cell(actor->has_moved_right_flag, actor->x + 1, actor->y - 1); + } + } + return; +} + +U0 actor_wt_blue_mobile_trampoline_car(ActorData *actor) +{ + if(actor->data_1 <= 0) + { + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + if(actor->data_2 == 0) + { + actor->x = actor->x - 1; + check_actor_move_left_or_right(actor, LEFT); + + if(actor->has_moved_left_flag == 0) + { + actor->data_2 = 1; + } + } + else + { + actor->x = actor->x + 1; + check_actor_move_left_or_right(actor, RIGHT); + + if(actor->has_moved_right_flag == 0) + { + actor->data_2 = 0; + } + } + } + else + { + actor->frame_num = 2; + actor->data_1--; + } + + if(is_sprite_on_screen(0x10, 2, actor->x, actor->y) == 0) + { + actor->frame_num = 0; + return; + } + return; +} + +U0 actor_wt_blue_platform(ActorData *actor) +{ + actor->has_moved_left_flag = actor->has_moved_left_flag + 1; + if(actor->data_1 == 0) + { + actor->data_1 = 1; + map_write_row_of_tiles(0x3dd0, 4, actor->x, actor->y - 1); + } + else + { + if (actor->data_1 != 1 || actor->y - 2 != player_y_pos) + { + if (actor->data_1 == 2) + { + if ((actor->has_moved_left_flag & 1) != 0) + { + actor->data_2 = actor->data_2 + 1; + } + + if (actor->data_2 == 5) + { + map_write_row_of_tiles(0, 4, actor->x, actor->y - 1); + } + + if (actor->data_2 >= 5 && actor->data_2 < 8) + { + actor_tile_display_func_index = 1; + display_actor_sprite_maybe(0x5b, 1, actor->x - (actor->data_2 - 5), actor->y, 0); + + display_actor_sprite_maybe(0x5b, 2, actor->x + actor->data_2 - 3, actor->y, 0); + } + + if (actor->data_2 == 7) + { + actor->data_1 = 3; + actor->data_2 = 0; + } + } + } + else + { + if (actor->x > player_x_pos || actor->x + 3 < player_x_pos) + { + if (actor->x <= player_x_pos + 2) + { + if (actor->x + 3 >= player_x_pos + 2) + { + actor->data_1 = 2; + actor->data_2 = 0; + sub_11062(); + } + } + } + else + { + actor->data_1 = 2; + actor->data_2 = 0; + sub_11062(); + } + } + } + + if(actor->data_1 != 3) + { + return; + } + actor_tile_display_func_index = 1; + display_actor_sprite_maybe(0x5b, 1, actor->x + actor->data_2 - 2, actor->y, 0); + + display_actor_sprite_maybe(0x5b, 2, actor->x + 4 - actor->data_2, actor->y, 0); + + if((actor->has_moved_left_flag & 1) != 0) + { + actor->data_2 = actor->data_2 + 1; + } + + if(actor->data_2 == 3) + { + actor_tile_display_func_index = 0; + map_write_row_of_tiles(0, 4, actor->x, actor->y - 1); + actor->data_1 = 0; + } +} + +U0 actor_wt_blue_turret_alien(ActorData *actor) +{ + actor->data_2--; + if(actor->data_2 == 0) + { + actor->data_1++; + actor->data_2 = 3; + if(actor->data_1 != 3) + { + actor->frame_num++; + switch (actor->frame_num - 2) + { + case 0: + actor_add_new(0x6d, actor->x - 1, actor->y - 1); + break; + + case 3: + actor_add_new(0x42, actor->x - 1, actor->y + 1); + break; + + case 6: + actor_add_new(0x44, actor->x + 1, actor->y + 1); + break; + + case 9: + actor_add_new(0x43, actor->x + 5, actor->y + 1); + break; + + case 12: + actor_add_new(0x6e, actor->x + 5, actor->y - 1); + break; + + default : break; + } + } + } + + if(actor->data_1 == 0) + { + if(actor->y < player_y_pos - 2) + { + if(actor->y < player_y_pos - 2) + { + if(actor->x - 2 <= player_x_pos) + { + if(actor->x + 3 >= player_x_pos) + { + if(actor->x - 2 < player_x_pos && actor->x + 3 >= player_x_pos) + { + actor->frame_num = 6; + actor->x = actor->data_3 + 1; + } + } + else + { + actor->frame_num = 9; + actor->x = actor->data_3 + 1; + } + } + else + { + actor->frame_num = 3; + actor->x = actor->data_3; + } + + if(actor->x - 2 == player_x_pos) + { + actor->frame_num = 6; + actor->x = actor->data_3 + 1; + } + } + } + else + { + if(actor->x + 1 <= player_x_pos) + { + if(actor->x + 2 <= player_x_pos) + { + actor->frame_num = 12; + actor->x = actor->data_3 + 1; + } + } + else + { + actor->frame_num = 0; + actor->x = actor->data_3; + } + } + } + + if(actor->data_1 == 3) + { + actor->data_2 = 0x1b; + actor->data_1 = 0; + } + + if(actor->frame_num > 14) + { + actor->frame_num = 14; + } + + return; +} + +U0 actor_wt_bomb(ActorData *actor) +{ + if(actor->frame_num == 3) + { + actor->data_2 = actor->data_2 + 1; + actor->data_1 = actor->data_1 + 1; + if((actor->data_1 & 1) != 0 && actor->frame_num == 3) + { + actor_tile_display_func_index = 2; + } + + if(actor->data_2 == 10) + { + actor->is_deactivated_flag_maybe = 1; + exploding_balls_effect(actor->x - 2, actor->y + 1 + 1); + actor_tile_display_func_index = 1; + + struct6_add_sprite(actor->x - 2, actor->y); + + if((actor->data_1 & 1) != 0 && actor->frame_num == 3) + { + display_actor_sprite_maybe(0x18, actor->frame_num, actor->x, actor->y, 2); + } + } + } + else + { + actor->data_1 = actor->data_1 + 1; + if(actor->data_1 == 5) + { + actor->data_1 = 0; + actor->frame_num++; + } + } + + if(sprite_blocking_check(1, 0x18, 0, actor->x, actor->y) != NOT_BLOCKED) + { + actor->y--; + } + return; + +} + +U0 actor_wt_bonus_bomb(ActorData *actor) +{ + if(actor->data_1 == 2) + { + struct6_add_sprite(actor->x - 2, actor->y); + actor->is_deactivated_flag_maybe = 1; + return; + } + + if(actor->data_1 != 0) + { + actor->data_1 = actor->data_1 + 1; + } + + if(actor->data_1 == 0) + { + if(struct6_1B4FC(0x39, 0, actor->x, actor->y) != 0) + { + actor->data_1 = 1; + } + } +} + +U0 actor_wt_bonus_item(ActorData *actor) +{ + if(actor->data_1 != 0) + { + actor_tile_display_func_index = 4; + } + + if (actor->data_4 == 0) + { + actor->frame_num = actor->frame_num + 1; + } + else + { + actor->data_3 = Cond(actor->data_3, -1, 0) + 1; + if (actor->data_3 != 0) + { + actor->frame_num = actor->frame_num + 1; + } + } + + if(actor->frame_num == actor->data_5) + { + actor->frame_num = 0; + } + + if(actor->data_5 == 1 && actor->actorInfoIndex != 0xca && actor->data_4 == 0) + { + if((cosmo_rand() & 0x3f) == 0) + { + effect_add_sprite(0x17, 8, cosmo_rand() % actor->data_1 + actor->x, cosmo_rand() % actor->data_2 + actor->y, 0, 1); + } + } +} + +uint8 clam_trap_frame_num_tbl[27] = { + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 0 +}; + +U0 actor_wt_clam_trap(ActorData *actor) +{ + if(actor->data_2 != 0) + { + if(actor->data_3 == 1) + { + //play_sfx(0x28); + } + actor->frame_num = clam_trap_frame_num_tbl[actor->data_3]; + actor->data_3++; + if(actor->data_3 >= 0x18) + { + byte_2E17C = 0; + } + + if(actor->data_3 == 0x1b) + { + actor->data_3 = 0; + actor->data_2 = 0; + byte_2E17C = 0; + } + + if(struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0) + { + player_add_to_score(0xfa); + + explode_effect_add_sprite(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y); + actor->is_deactivated_flag_maybe = 1; + byte_2E17C = 0; + } + } + else + { + if(struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0) + { + player_add_to_score(0xfa); + + explode_effect_add_sprite(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y); + actor->is_deactivated_flag_maybe = 1; + } + } +} + +U0 actor_wt_container(ActorData *actor) +{ + if(struct6_1B4FC(0x1d, 0, actor->x, actor->y) != 0) + { + actor_explode_container(actor); + player_add_to_score(0x640); + + actor_add_new(0xb5, actor->x, actor->y); + } +} + +U0 actor_wt_crate_bomb_box(ActorData *actor) +{ + if(actor->data_4 == 0) + { + map_write_row_of_tiles(0x50, 4, actor->x, actor->y - 2); + actor->data_4 = 1; + return; + } + + if(sprite_blocking_check(1, 0x82, 0, actor->x, actor->y + 1) == 0) + { + + map_write_row_of_tiles(0, 4, actor->x, actor->y - 2); + + actor->y = actor->y + 1; + if(sprite_blocking_check(1, 0x82, 0, actor->x, actor->y + 1) != NOT_BLOCKED) + { + + map_write_row_of_tiles(0x50, 4, actor->x, actor->y - 2); + } + return; + } + + if(is_sprite_on_screen(0x82, 0, actor->x, actor->y) == 0) + { + return; + } + + if(struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0) + { + + actor->data_5 = 1; + actor->has_moved_right_flag = 0xf1f1; + } + + if(actor->data_5 != 0) + { + actor->data_5--; + return; + } + + actor->is_deactivated_flag_maybe = 1; + if(actor->has_moved_right_flag == 0xf1f1) + { + struct6_add_sprite(actor->x - 1, actor->y - 1); + return; + } + + map_write_row_of_tiles(0, 4, actor->x, actor->y - 2); + + actor_add_new(0x7c, actor->x, actor->y); + actor_tile_display_func_index = 2; + + explode_effect_add_sprite(0x83, 0, actor->x - 1, actor->y + 3); + explode_effect_add_sprite(0x83, 1, actor->x, actor->y - 1); + explode_effect_add_sprite(0x83, 2, actor->x + 1, actor->y); + explode_effect_add_sprite(0x83, 3, actor->x, actor->y); + explode_effect_add_sprite(0x83, 4, actor->x + 3, actor->y + 1 + 1); + 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); +} + +U0 actor_wt_cyan_spitting_plant(ActorData *actor) +{ + actor->data_4++; + if(actor->data_4 == 0x32) + { + actor->data_4 = 0; + actor->frame_num = 0; + } + + if(actor->data_4 == 0x2a) + { + actor->frame_num = 1; + } + + if(actor->data_4 == 0x2d) + { + actor->frame_num = 2; + if(actor->data_5 != 2) + { + actor_add_new(0x6e, actor->x + 4, actor->y - 1); + } + else + { + actor_add_new(0x6d, actor->x - 1, actor->y - 1); + } + } +} + +U0 actor_wt_destructable_pedestal(ActorData *actor) +{ + actor_tile_display_func_index = 1; + I64 i=0; + for(; i < actor->data_1;i++) + { + display_actor_sprite_maybe(0xc0, 1, actor->x, actor->y - i, 0); + } + + display_actor_sprite_maybe(0xc0, 0, actor->x - 2, actor->y - i, 0); + + map_write_row_of_tiles(0x48, 5, actor->x - 2, actor->y - i); + + if(actor->data_2 == 0) + { + if(struct6_1B4FC(0xc0, 1, actor->x, actor->y) != 0) + { + actor->data_2 = 3; + } + } + + if(actor->data_2 > 1) + { + actor->data_2--; + } + + if(actor->data_2 != 1) + { + return; + } + actor->data_2 = 3; + map_write_row_of_tiles(0, 5, actor->x - 2, actor->y - i); + + actor->data_1--; + if(actor->data_1 != 1) + { + explode_effect_add_sprite(0xc0, 1, actor->x, actor->y); + effect_add_sprite(0x61, 6, actor->x - 1, actor->y + 1, 1, 1); + } + else + { + actor->is_deactivated_flag_maybe = 1; + explode_effect_add_sprite(0xc0, 0, actor->x, actor->y); + } +} + +U0 actor_wt_door(ActorData *actor) +{ + I64 si; + if (actor->has_moved_left_flag != 0) + { + return; + } + + actor->has_moved_left_flag = 1; + + actor->data_1 = map_get_tile_cell(actor->x + 1, actor->y); + actor->data_2 = map_get_tile_cell(actor->x + 1, actor->y - 1); + actor->data_3 = map_get_tile_cell(actor->x + 1, actor->y - 2); + actor->data_4 = map_get_tile_cell(actor->x + 1, actor->y - 3); + actor->data_5 = map_get_tile_cell(actor->x + 1, actor->y - 4); + + for(si=0; si < 5; si++) + { + map_write_tile_cell(0x3dc8, actor->x + 1, actor->y - si); + } + + return; +} + +U0 actor_wt_dragonfly(ActorData *actor) +{ + if(actor->data_1 != 0) + { + if(sprite_blocking_check(3, 0x81, 0, actor->x + 1, actor->y) == NOT_BLOCKED) + { + actor->x = actor->x + 1; + actor->data_2 = Cond(actor->data_2, -1, 0) + 1; + actor->frame_num = actor->data_2 + 2; + } + else + { + actor->data_1 = 0; + } + return; + } + + if(sprite_blocking_check(2, 0x81, 0, actor->x - 1, actor->y) == NOT_BLOCKED) + { + actor->x = actor->x - 1; + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + } + else + { + actor->data_1 = 1; + } +} + +U0 actor_wt_egg_head(ActorData *actor) +{ + if(actor->data_2 == 0) + { + if(sub_1106F() % 0x46 == 0 && actor->data_3 == 0) + { + actor->data_3 = 2; + } + else + { + actor->frame_num = 0; + } + } + else + { + actor->frame_num = 2; + } + + if(actor->data_3 != 0) + { + actor->data_3--; + actor->frame_num = 1; + } + + if(actor->data_5 == 0 && actor->data_1 == 0) + { + if(actor->y <= player_y_pos) + { + if(actor->x - 6 < player_x_pos) + { + if(actor->x + 4 > player_x_pos) + { + actor->data_1 = 1; + actor->data_2 = 0x14; + //play_sfx(0x21); + } + } + } + } + + if(actor->data_2 > 1) + { + actor->data_2--; + return; + } + + if(actor->data_2 == 1) + { + actor->is_deactivated_flag_maybe = 1; + actor_tile_display_func_index = 1; + actor_add_new(0x41, actor->x, actor->y); + + effect_add_sprite(0x4c, 1, actor->x, actor->y - 1, 8, 5); + 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); + } +} + +U0 actor_wt_end_of_level_marker(ActorData *actor) +{ + if(actor->y <= player_y_pos && actor->data_1 == 0) + { + finished_level_flag_maybe = 1; + } + else + { + if(actor->y >= player_y_pos && actor->data_1 != 0) + { + finished_game_flag_maybe = 1; + } + } + + actor_tile_display_func_index = 1; + return; +} + +U0 actor_wt_energy_beam(ActorData *actor) +{ + I64 i; + actor->data_1 = 0; + actor->data_4++; + if(actor->data_4 == 3) + { + actor->data_4 = 0; + } + actor_tile_display_func_index = 1; + if(energy_beam_enabled_flag == 0) + { + actor->is_deactivated_flag_maybe = 1; + return; + } + if (actor->data_5 != 0) + { + for(i=1;i==i;actor->data_1++) + { + if(player_check_collision_with_actor(actor->actorInfoIndex, 0, actor->x + actor->data_1, actor->y) != 0) + { + player_decrease_health(); + break; + } + + if((tileattr_mni_data[map_get_tile_cell(actor->x + actor->data_1, actor->y)/8] & TILE_ATTR_BLOCK_RIGHT) != 0) + { + break; + } + + display_actor_sprite_maybe(actor->actorInfoIndex, actor->data_4, actor->x + actor->data_1, actor->y, 0); + } + } + else + { + for(i=1;i==i;actor->data_1++) + { + if (player_check_collision_with_actor(actor->actorInfoIndex, 0, actor->x, actor->y - actor->data_1) != 0) + { + player_decrease_health(); + break; + } + + if((tileattr_mni_data[map_get_tile_cell(actor->x, actor->y - actor->data_1)/8] & TILE_ATTR_BLOCK_UP) != 0) + { + break; + } + + display_actor_sprite_maybe(actor->actorInfoIndex, actor->data_4, actor->x, actor->y - actor->data_1, 0); + } + } +} + +U0 actor_wt_extending_arrow(ActorData *actor) +{ + if(actor->data_1 >= 0x1f) + { + actor->data_1 = 0; + } + else + { + actor->data_1++; + } + + if(actor->data_1 == 0x1d || actor->data_1 == 0x1a) + { + if(is_sprite_on_screen(actor->actorInfoIndex, 0, actor->x, actor->y) != 0) + { + //play_sfx(9); + } + } + + if(actor->data_5 == 0) + { + if(actor->data_1 > 0x1c) + { + actor->x = actor->x + 1; + } + else + { + if(actor->data_1 > 0x19) + { + actor->x = actor->x - 1; + return; + } + } + return; + } + if(actor->data_1 > 0x1c) + { + actor->x = actor->x - 1; + return; + } + if(actor->data_1 > 0x19) + { + actor->x = actor->x + 1; + return; + } + return; +} + +U0 actor_wt_frozen_duke_nukum(ActorData *actor) +{ + //TODO +} + +U0 actor_wt_ghost(ActorData *actor) +{ + actor->data_4++; + if(actor->data_4 % 3 == 0) + { + actor->data_1++; + } + + if(actor->data_1 == 4) + { + actor->data_1 = 0; + } + if (player_direction == 0) + { + if (actor->x <= player_x_pos + 1 + 1 || player_hanging_on_wall_direction != 2 || right_key_pressed == 0) + { + if (actor->x <= player_x_pos) + { + if(cosmo_rand() % 0x23 != 0) + { + actor->frame_num = 5; + } + else + { + actor->frame_num = 7; + } + return; + } + else + { + actor->frame_num = actor->data_1 & 1; + if(actor->data_1 != 0) + { + return; + } + actor->x = actor->x - 1; + if(actor->y < player_y_pos) + { + actor->y = actor->y + 1; + return; + } + + if(actor->y > player_y_pos) + { + actor->y = actor->y - 1; + } + return; + } + } + else + { + if(cosmo_rand() % 0x23 != 0) + { + actor->frame_num = 2; + } + else + { + actor->frame_num = 6; + } + return; + } + } + else + { + if (actor->x >= player_x_pos || player_hanging_on_wall_direction != 3 || left_key_pressed == 0) + { + if (actor->x >= player_x_pos) + { + if(cosmo_rand() % 0x23 != 0) + { + actor->frame_num = 2; + } + else + { + actor->frame_num = 6; + } + } + else + { + actor->frame_num = (actor->data_1 & 1) + 3; + if (actor->data_1 == 0) + { + actor->x = actor->x + 1; + if(actor->y < player_y_pos) + { + actor->y = actor->y + 1; + return; + } + + if(actor->y > player_y_pos) + { + actor->y = actor->y - 1; + } + } + return; + } + } + else + { + if(cosmo_rand() % 0x23 != 0) + { + actor->frame_num = 5; + } + else + { + actor->frame_num = 7; + } + } + } +} + +U0 actor_wt_green_plant(ActorData *actor) +{ + if(actor->data_2 != 0) + { + actor->y = actor->y + 1; + actor->data_4 = actor->data_4 + 1; + if(actor->data_4 == 7) + { + actor->data_2 = 0; + actor->data_3 = 0; + actor->data_1 = 12; + } + return; + } + + if(actor->data_3 < actor->data_1) + { + actor->data_3 = actor->data_3 + 1; + return; + } + + actor->data_5 = Cond(actor->data_5, -1, 0) + 1; + actor->frame_num = actor->frame_num + 1; + if(actor->frame_num == 4) + { + actor->frame_num = 0; + } + + if(actor->data_4 != 0) + { + if(actor->data_4 == 7) + { + //play_sfx(0x35); + } + + actor->data_4 = actor->data_4 - 1; + actor->y = actor->y - 1; + } + + if(struct6_1B4FC(0x91, 0, actor->x, actor->y) != 0) + { + actor->data_2 = 1; + } +} + +sint8 cabbage_ball_y_tbl[4] = {-1, -1, 0, 0}; + +U0 actor_wt_green_pruny_cabbage_ball(ActorData *actor) +{ + if(actor->data_2 == 10 && actor->data_3 == 3) + { + if(sprite_blocking_check(1, 0x19, 0, actor->x, actor->y + 1) == NOT_BLOCKED) + { + if(actor->data_4 == 0) + { + actor->frame_num = 1; + } + else + { + actor->frame_num = 3; + } + return; + } + } + + if(actor->data_2 < 10) + { + if(sprite_blocking_check(1, 0x19, 0, actor->x, actor->y + 1) != NOT_BLOCKED) + { + + actor->data_2 = actor->data_2 + 1; + if(actor->x <= player_x_pos) + { + actor->frame_num = 2; + actor->data_4 = 2; + } + else + { + actor->frame_num = 0; + actor->data_4 = 0; + } + return; + } + } + + if(actor->data_3 < 3) + { + actor->y = actor->y + cabbage_ball_y_tbl[actor->data_3]; + if(actor->data_4 == 0) + { + actor->x = actor->x - 1; + check_actor_move_left_or_right(actor, 2); + } + else + { + actor->x = actor->x + 1; + check_actor_move_left_or_right(actor, 3); + } + + actor->data_3++; + if(actor->data_4 == 0) + { + actor->frame_num = 1; + } + else + { + actor->frame_num = 3; + } + return; + } + + actor->data_2 = 0; + actor->data_3 = 0; + if(actor->x <= player_x_pos) + { + actor->frame_num = 2; + actor->data_4 = 2; + } + else + { + actor->frame_num = 0; + actor->data_4 = 0; + } +} + +U0 actor_wt_green_roamer_worm(ActorData *actor) +{ + if(actor->data_5 != 0) + { + I64 si = sub_1106F() & 3; + if(si == 0) + { + if(sprite_blocking_check(0, 0x45, 0, actor->x, actor->y - 1) == 0) + { + actor->data_5 = 0; + actor->data_1 = 0; + } + } + if(si == 1) + { + if(sprite_blocking_check(1, 0x45, 0, actor->x, actor->y + 1) == 0) + { + actor->data_5 = 0; + actor->data_1 = 1; + } + } + if(si == 2) + { + if(sprite_blocking_check(2, 0x45, 0, actor->x - 1, actor->y) == 0) + { + actor->data_5 = 0; + actor->data_1 = 2; + } + } + if(si == 3) + { + if(sprite_blocking_check(3, 0x45, 0, actor->x + 1, actor->y) == 0) + { + actor->data_5 = 0; + actor->data_1 = 3; + } + } + } + else + { + switch (actor->data_1) + { + case 0: + + if(sprite_blocking_check(0, 0x45, 0, actor->x, actor->y - 1) == NOT_BLOCKED) + { + actor->y = actor->y - 1; + } + else + { + actor->data_5 = 1; + } + actor->data_3 = 0; + break; + + case 1: + + if(sprite_blocking_check(1, 0x45, 0, actor->x, actor->y + 1) == 0) + { + actor->y = actor->y + 1; + } + else + { + actor->data_5 = 1; + } + actor->data_3 = 4; + break; + + case 2: + + if(sprite_blocking_check(2, 0x45, 0, actor->x - 1, actor->y) == 0) + { + actor->x = actor->x - 1; + } + else + { + actor->data_5 = 1; + } + actor->data_3 = 6; + break; + + case 3: + + if(sprite_blocking_check(3, 0x45, 0, actor->x + 1, actor->y) == 0) + { + actor->x = actor->x + 1; + } + else + { + actor->data_5 = 1; + } + actor->data_3 = 2; + break; + } + } + + actor->data_4 = Cond(actor->data_4, -1, 0) + 1; + actor->frame_num = actor->data_3 + actor->data_4; +} + +uint8 byte_28EFE[6] = { 0, 4, 5, 6, 5, 4}; + +U0 actor_wt_hint_dialog(ActorData *actor) +{ + actor->data_4 = Cond(actor->data_4, -1, 0) + 1; + if(actor->data_4 != 0) + { + actor->data_3 = actor->data_3 + 1; + } + + display_actor_sprite_maybe(0x7d, byte_28EFE[actor->data_3 % 6], actor->x, actor->y - 2, 0); + + actor->data_2 = actor->data_2 + 1; + if(actor->data_2 == 4) + { + actor->data_2 = 1; + } + + display_actor_sprite_maybe(0x7d, actor->data_2, actor->x, actor->y, 0); + actor_tile_display_func_index = 1; + + if(player_check_collision_with_actor(0x7d, 0, actor->x, actor->y - 2) != 0) + { + word_32EAC = 1; + if(game_play_mode != 0) + { + byte_2E21C = 1; + } + if((up_key_pressed != 0 && player_hoverboard_counter == 0) || byte_2E21C == 0) + { + //play_sfx(0x1e); + ingame_hint_dialogs(actor->data_5); + } + byte_2E21C = 1; + } + return; +} + +uint8 flame_frame_num_tbl[17] = { + 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 1, 0, 0 +}; +U0 actor_wt_horizontal_flame(ActorData *actor) +{ + if(actor->data_1 != 0) + { + actor->data_1--; + actor_tile_display_func_index = 1; + } + else + { + actor->frame_num = flame_frame_num_tbl[actor->data_2]; + if(actor->frame_num == 2) + { + effect_add_sprite(0x61, 6, actor->x - actor->data_5, actor->y - 3, 1, 1); + //play_sfx(0x36); + } + actor->data_2++; + if(actor->data_2 == 0x10) + { + actor->data_1 = 0x1e; + actor->data_2 = 0; + } + } + return; +} + +U0 actor_wt_hoverboard(ActorData *actor) +{ + actor->frame_num = actor->frame_num + 1; + actor->frame_num = actor->frame_num & 3; + if(player_hoverboard_counter != 0) + { + actor->x = player_x_pos; + actor->y = player_y_pos + 1; + return; + } + + actor->data_2++; + if(actor->data_2 % 10 == 0) + { + if(sprite_blocking_check(1, 0x72, 0, actor->x, actor->y + 1) != NOT_BLOCKED) + { + actor->y = actor->y - 1; + } + else + { + actor->y = actor->y + 1; + if(sprite_blocking_check(1, 0x72, 0, actor->x, actor->y + 1) != NOT_BLOCKED) + { + actor->y = actor->y - 1; + return; + } + } + return; + } + return; +} + +U0 actor_wt_invisible_exit_marker_right(ActorData *actor) +{ + if(actor->x <= player_x_pos + 3) + { + finished_level_flag_maybe = 1; + return; + } + actor_tile_display_func_index = 1; + return; +} + +uint8 jaws_and_tongue_frame_num_tbl[4] = {2, 3, 4, 3}; +U0 actor_wt_jaws_and_tongue(ActorData *actor) +{ + if(actor->data_1 == 0) + { + actor->data_2++; + } + + if(actor->data_2 == 10) + { + actor->data_1 = 1; + actor->data_2 = 11; + actor->frame_num = 1; + actor->data_5 = 1; + //play_sfx(0x26); + } + + if(actor->frame_num != 0) + { + display_actor_sprite_maybe(0x95, jaws_and_tongue_frame_num_tbl[actor->data_3 & 3], actor->x + 6 - actor->data_5, actor->y - 3, 0); + actor->data_3++; + } + + if(is_sprite_on_screen(0x95, 1, actor->x, actor->y) == 0) + { + + actor->frame_num = 0; + actor->data_2 = 0; + actor->data_1 = 0; + actor->data_5 = 0; + } + actor_tile_display_func_index = 1; + + display_actor_sprite_maybe(actor->actorInfoIndex, 1, actor->x, actor->y, 0); + + if(actor->data_5 != 0 && actor->data_5 < 4) + { + actor->data_5++; + return; + } + + display_actor_sprite_maybe(actor->actorInfoIndex, 0, actor->x, actor->y - 1 - actor->data_5, 0); + return; +} +sint16 bullet_head_y_tbl[16] = {-2, -2, -2, -2, -1, -1, -1, 0, 0, 1, 1, 1, 2, 2, 2, 2}; +U0 actor_wt_jumping_bullet_head(ActorData *actor) +{ + if(actor->data_2 != 0) + { + actor->x = actor->x + 1; + } + else + { + actor->x = actor->x - 1; + } + actor->y = actor->y + bullet_head_y_tbl[actor->data_3]; + actor->data_3++; + if(actor->data_3 == 0x10) + { + 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); + } + actor->data_3 = 0; + } +} + +U0 actor_wt_mini_ghost(ActorData *actor) +{ + if(actor->data_4 != 0) + { + actor->data_4--; + return; + } + + if(actor->data_1 == 0) + { + if(sprite_blocking_check(1, 0x41, 0, actor->x, actor->y + 1) != NOT_BLOCKED) + { + actor->can_fall_down_flag = 0; + actor->data_1 = 1; + actor->data_4 = 3; + actor->data_2 = 4; + actor->frame_num = 1; + actor->data_3 = 1; + if(is_sprite_on_screen(0x41, 0, actor->x, actor->y) != 0) + { + //play_sfx(0x3b); + } + return; + } + + if(actor->data_5 != 0) + { + actor->data_5--; + } + else + { + actor->frame_num = 1; + if(actor->data_3 == 0) + { + actor->data_4++; + return; + } + } + } + else + { + + if(actor->data_1 == 1) + { + actor->y = actor->y - 1; + actor->frame_num = 0; + if(actor->data_2 == 4) + { + if(is_sprite_on_screen(0x41, 0, actor->x, actor->y) != 0) + { + //play_sfx(0x3a); + } + } + + actor->data_2--; + if(actor->data_2 == 0) + { + actor->data_1 = 0; + actor->data_5 = 3; + actor->can_fall_down_flag = 1; + } + } + } + return; +} + +U0 actor_wt_pink_eye_plant(ActorData *actor) +{ + actor_tile_display_func_index = actor->data_5; + actor->data_2 = cosmo_rand() % 0x28; + if(actor->data_2 <= 0x25) + { + actor->data_2 = 0; + } + else + { + actor->data_2 = 3; + } + + if(actor->x - 2 > player_x_pos) + { + actor->frame_num = actor->data_2; + return; + } + + if(actor->x + 1 >= player_x_pos) + { + actor->frame_num = actor->data_2 + 1; + } + else + { + actor->frame_num = actor->data_2 + 2; + } + + return; +} + +U0 actor_wt_pink_slug(ActorData *actor) +{ + if(actor->data_5 == 0) + { + actor->data_4 = Cond(actor->data_4, -1, 0) + 1; + if(actor->data_4 != 0) + { + return; + } + } + if(cosmo_rand() % 0x28 > 0x25) + { + + if(actor->data_3 == 0 && actor->data_2 == 0) + { + actor->data_3 = 4; + } + } + + if(actor->data_3 != 0) + { + actor->data_3--; + if(actor->data_3 == 2) + { + if(actor->data_1 == 0) + { + actor->frame_num = 2; + return; + } + + if(actor->data_2 == 0) + { + actor->frame_num = 5; + } + return; + } + + if(actor->data_1 != 0) + { + actor->frame_num = 3; + } + else + { + actor->frame_num = 0; + } + return; + } + + if(actor->data_1 == 0) + { + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + if(actor->frame_num != 0) + { + actor->x--; + check_actor_move_left_or_right(actor, 2); + + if(actor->has_moved_left_flag == 0) + { + actor->data_1 = 1; + } + } + return; + } + + actor->data_2 = Cond(actor->data_2, -1, 0) + 1; + if(actor->data_2 == 0) + { + actor->x = actor->x + 1; + actor->frame_num = 1; + check_actor_move_left_or_right(actor, 3); + + if(actor->has_moved_right_flag == 0) + { + actor->data_1 = 0; + } + return; + } + + actor->frame_num = actor->data_2 + 3; +} + +U0 actor_wt_pipe_transit_direction(ActorData *actor) +{ + actor_tile_display_func_index = 1; +} + +U0 actor_wt_plasma_energy_blue_sprite(ActorData *actor) +{ + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + if(actor->data_1 >= 0x3f) + { + actor->data_1 = 0; + } + else + { + actor->data_1++; + } + + if(actor->data_1 > 0x32) + { + actor->y = actor->y + 2; + if(actor->data_1 < 0x37) + { + actor->y = actor->y - 1; + } + actor_tile_display_func_index = 4; + return; + } + + if(actor->data_1 > 0x22) + { + if(actor->data_1 < 0x2f) + { + actor->y = actor->y - 1; + } + + if(actor->data_1 < 0x2d) + { + actor->y = actor->y - 1; + } + } +} + +U0 actor_wt_plasma_fireball(ActorData *actor) +{ + if(actor->data_1 == 0x1d) + { + //play_sfx(0x24); + } + + if(actor->data_1 >= 0x1e) + { + + if(actor->data_5 != 0) + { + + actor->x = actor->x + 1; + + actor->has_moved_right_flag = Cond(sprite_blocking_check(3, actor->actorInfoIndex, 0, actor->x, actor->y) != NOT_BLOCKED, -1, 0) + 1; + if(actor->has_moved_right_flag == 0) + { + actor->data_1 = 0; + effect_add_sprite(0x61, 6, actor->x - 2, actor->y, 1, 1); + + actor->x = actor->data_2; + actor->y = actor->data_3; + //play_sfx(0x1b); + } + } + else + { + actor->x = actor->x - 1; + + actor->has_moved_left_flag = Cond(sprite_blocking_check(2, actor->actorInfoIndex, 0, actor->x, actor->y) != NOT_BLOCKED, -1, 0) + 1; + if(actor->has_moved_left_flag == 0) + { + actor->data_1 = 0; + effect_add_sprite(0x61, 6, actor->x + 1, actor->y, 1, 1); + + actor->x = actor->data_2; + actor->y = actor->data_3; + //play_sfx(0x1b); + } + } + } + else + { + actor->data_1++; + } + + if(is_sprite_on_screen(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) == 0) + { + + actor->data_1 = 0; + actor->x = actor->data_2; + actor->y = actor->data_3; + return; + } + + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + return; +} + +U0 actor_wt_pneumatic_pipe(ActorData *actor) +{ + if(actor->data_2 != 0) + { + actor->data_1++; + actor->data_3++; + if((actor->data_3 & 1) == 0) + { + actor->frame_num = 0; + } + else + { + actor->frame_num = 4; + } + + if(actor->data_1 == 4) + { + actor->data_1 = 1; + } + + display_actor_sprite_maybe(0x69, actor->data_1, actor->x, actor->y + 3, 0); + return; + } + return; +} + +U0 actor_wt_projectile_flashing_ball(ActorData *actor) +{ + if(is_sprite_on_screen(0x44, 0, actor->x, actor->y) == 0) + { + actor->is_deactivated_flag_maybe = 1; + return; + } + + if(actor->data_1 == 0) + { + actor->data_1 = 1; + //play_sfx(0x1a); + } + + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + + switch (actor->data_5) + { + case 0: + actor->x = actor->x - 1; + break; + + case 1: + actor->x = actor->x - 1; + actor->y = actor->y + 1; + break; + + case 2: + actor->y = actor->y + 1; + break; + + case 3: + actor->x = actor->x + 1; + actor->y = actor->y + 1; + break; + + case 4: + actor->x = actor->x + 1; + break; + + default : break; + } +} + +U0 actor_wt_question_mark_block(ActorData *actor) +{ + if(word_2E17E != 0) + { + actor->data_1 = 1; + actor->update_while_off_screen_flag = 1; + } + + if(actor->data_1 == 0) + { + return; + } + if((actor->data_1 & 1) != 0) + { + map_write_tile_cell(0x3df8, actor->x, actor->y - 1); + + map_write_tile_cell(0x3e00, actor->x + 1, actor->y - 1); + + map_write_tile_cell(0x3e08, actor->x, actor->y); + + map_write_tile_cell(0x3e10, actor->x + 1, actor->y); + } + + if(sprite_blocking_check(0, actor->actorInfoIndex, 0, actor->x, actor->y - 1) != NOT_BLOCKED) + { + + if((actor->data_1 & 1) == 0) + { + map_write_tile_cell(0x3e08, actor->x, actor->y - 1); + map_write_tile_cell(0x3e10, actor->x + 1, actor->y - 1); + } + actor->is_deactivated_flag_maybe = 1; + } + else + { + if((actor->data_1 & 1) == 0) + { + effect_add_sprite(15, 4, actor->x - 1, actor->y - 1, 0, 1); + } + + actor->data_1++; + actor->y--; + } +} + +U0 actor_wt_red_blue_plant(ActorData *actor) +{ + actor_tile_display_func_index = actor->data_5; + if(actor->data_2 == 1) + { + actor->frame_num = actor->frame_num + 1; + if(actor->frame_num == 1) + { + //play_sfx(0x3f); + } + + if(actor->frame_num == 4) + { + actor->data_2 = 2; + } + return; + } + + if(actor->data_2 == 2) + { + actor->frame_num = actor->frame_num - 1; + if(actor->frame_num == 1) + { + actor->data_2 = 0; + actor->data_1 = 1; + } + return; + } + + if(actor->data_1 >= 0x10) + { + actor->data_1 = 0; + } + else + { + actor->data_1++; + } + + if(actor->data_1 != 0) + { + actor->frame_num = 0; + } + else + { + actor->data_2 = 1; + } + return; +} + +uint8 word_28EE6[6] = { 8, 9, 10, 10, 9, 8}; +uint8 word_28EF2[6] = { 10, 9, 8, 8, 9, 10}; + +U0 actor_wt_red_chomper_alien(ActorData *actor) +{ + actor->data_4 = Cond(actor->data_4, -1, 0) + 1; + + if(sub_1106F() % 0x5f != 0) + { + if(sub_1106F() % 0x64 == 0) + { + actor->data_5 = 11; + } + } + else + { + actor->data_5 = 10; + } + + if(actor->data_5 < 11 && actor->data_5 != 0) + { + actor->data_5--; + if(actor->data_5 <= 8) + { + + if(actor->data_5 != 8) + { + + actor->data_2 = Cond(actor->data_2, -1, 0) + 1; + + actor->frame_num = actor->data_2 + 6; + } + else + { + actor->frame_num = 5; + } + } + else + { + actor->frame_num = 6; + } + if(actor->data_5 != 0) + { + return; + } + + if((sub_1106F() & 1) == 0) + { + return; + } + + if(actor->x < player_x_pos) + { + actor->data_1 = 1; + } + else + { + actor->data_1 = 0; + } + } + else + { + + if(actor->data_5 > 10) + { + if(actor->data_1 != 0) + { + actor->frame_num = word_28EF2[actor->data_5 - 11]; + } + else + { + actor->frame_num = word_28EE6[actor->data_5 - 11]; + } + + actor->data_5++; + if(actor->data_5 == 0x11) + { + actor->data_5 = 0; + } + return; + } + + if(actor->data_1 == 0) + { + if(actor->data_4 != 0) + { + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + actor->x = actor->x - 1; + check_actor_move_left_or_right(actor, LEFT); + + if(actor->has_moved_left_flag == 0) + { + actor->data_1 = 1; + actor->frame_num = 4; + } + } + return; + } + + if(actor->data_4 != 0) + { + actor->data_3 = Cond(actor->data_3, -1, 0) + 1; + actor->frame_num = actor->data_3 + 2; + actor->x++; + check_actor_move_left_or_right(actor, RIGHT); + + if(actor->has_moved_right_flag == 0) + { + actor->data_1 = 0; + actor->frame_num = 4; + } + } + } + return; +} + +U0 actor_wt_retracting_spikes(ActorData *actor) +{ + actor->data_2++; + if(actor->data_2 == 0x14) + { + actor->data_2 = 0; + } + + if(actor->frame_num != 0 || actor->data_2 != 0) + { + + if(actor->frame_num != 2 || actor->data_2 != 0) + { + + if(actor->data_1 == 0) + { + + if(actor->frame_num < 2) + { + actor->frame_num = actor->frame_num + 1; + } + } + else + { + if(actor->frame_num > 0) + { + actor->frame_num = actor->frame_num - 1; + } + } + } + else + { + actor->data_1 = 1; + //play_sfx(9); + actor_tile_display_func_index = 1; + } + } + else + { + actor->data_1 = 0; + //play_sfx(9); + } + if(actor->frame_num == 2) + { + actor_tile_display_func_index = 1; + return; + } + return; +} + +U0 actor_wt_robot_with_blue_arc(ActorData *actor) +{ + static uint16 spark_frame_num = 0; + I64 si; + + actor_tile_display_func_index = 1; + if (actor->data_2 == 0) + { + actor->data_5 = Cond(actor->data_5, -1, 0) + 1; + actor->data_4++; + if(actor->data_1 == 0) + { + + if((actor->data_4 & 1) != 0) + { + actor->x++; + } + check_actor_move_left_or_right(actor, RIGHT); + + if(actor->has_moved_right_flag == 0) + { + actor->data_1 = 1; + } + } + else + { + if((actor->data_4 & 1) != 0) + { + actor->x--; + } + check_actor_move_left_or_right(actor, LEFT); + + if(actor->has_moved_left_flag == 0) + { + actor->data_1 = 0; + } + } + + display_actor_sprite_maybe(0x5a, actor->data_5, actor->x, actor->y, 0); + + if(player_check_collision_with_actor(0x5a, 0, actor->x, actor->y) != 0) + { + player_decrease_health(); + } + spark_frame_num++; + + for(si=2; si < 21 && sprite_blocking_check(0, 0x5a, 2, actor->x + 1, actor->y - si) == NOT_BLOCKED; si++) + { + display_actor_sprite_maybe(0x5a, (spark_frame_num & 3) + 4, actor->x + 1, actor->y - si, 0); + + if(player_check_collision_with_actor(0x5a, 4, actor->x + 1, actor->y - si) != 0) + { + player_decrease_health(); + } + } + display_actor_sprite_maybe(0x5a, actor->data_5 + 1 + 1, actor->x + 1, actor->y - si + 1, 0); + + if(player_check_collision_with_actor(0x5a, 0, actor->x, actor->y + 1) != 0) + { + player_decrease_health(); + } + + if(struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0) + { + actor->data_2 = si; + } + } + else + { + for(si = 0; si < actor->data_2; si += 4) + { + struct6_add_sprite(actor->x, actor->y - si); + actor_add_new(1, actor->x, actor->y - si); + } + + actor->is_deactivated_flag_maybe = 1; + } +} + +U0 actor_wt_robotic_spike_ceiling(ActorData *actor) +{ + actor->data_3 = Cond(actor->data_3, -1, 0) + 1; + if(actor->data_3 == 0) + { + return; + } + if(actor->data_4 != 0) + { + actor->data_4--; + return; + } + + if(actor->data_2 == 1) + { + if(sprite_blocking_check(3, 0x50, 0, actor->x + 1, actor->y) != 0) + { + actor->data_4 = 4; + actor->data_2 = 0; + } + else + { + if(sprite_blocking_check(3, 0x50, 0, actor->x + 1, actor->y - 1) != 0) + { + actor->x = actor->x + 1; + } + else + { + actor->data_4 = 4; + actor->data_2 = 0; + } + } + return; + } + + if(sprite_blocking_check(2, 0x50, 0, actor->x - 1, actor->y) != 0) + { + actor->data_4 = 4; + actor->data_2 = 1; + } + else + { + if(sprite_blocking_check(2, 0x50, 0, actor->x - 1, actor->y - 1) != 0) + { + actor->x = actor->x - 1; + } + else + { + actor->data_4 = 4; + actor->data_2 = 1; + } + } + + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + return; +} + +U0 actor_wt_robotic_spike_ground(ActorData *actor) +{ + actor->data_3 = Cond(actor->data_3, -1, 0) + 1; + if(actor->actorInfoIndex == 0x14) + { + actor->data_3 = 1; + if(is_sprite_on_screen(actor->actorInfoIndex, 0, actor->x, actor->y) != 0) + { + //play_sfx(0x23); + } + } + + if(actor->data_4 != 0) + { + actor->data_4--; + } + + if(actor->data_3 == 0) + { + return; + } + if(actor->data_4 == 0) + { + if(actor->data_2 == 0) + { + actor->x = actor->x - 1; + check_actor_move_left_or_right(actor, LEFT); + + if(actor->has_moved_left_flag == 0) + { + actor->data_2 = 1; + actor->data_4 = actor->data_1; + } + } + else + { + actor->x = actor->x + 1; + check_actor_move_left_or_right(actor, RIGHT); + + if(actor->has_moved_right_flag == 0) + { + actor->data_2 = 0; + actor->data_4 = actor->data_1; + } + } + } + + actor->frame_num++; + if(actor->frame_num > actor->data_5) + { + actor->frame_num = 0; + } + return; +} + +U0 actor_wt_rocket(ActorData *actor) +{ + if(actor->data_1 != 0) + { + actor->data_1--; + if(actor->data_1 >= 0x1e) + { + return; + } + if((actor->data_1 & 1) == 0) + { + + effect_add_sprite(0x61, 6, actor->x + 1, actor->y + 1, 2, 1); + } + else + { + effect_add_sprite(0x61, 6, actor->x - 1, actor->y + 1, 8, 1); + } + return; + } + + if(actor->data_2 != 0) + { + if(actor->data_2 > 7) + { + 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); + } + + if(actor->data_2 > 1) + { + actor->data_2--; + } + + if(actor->data_2 < 10) + { + if(sprite_blocking_check(0, 0xbc, 0, actor->x, actor->y - 1) != 0) + { + actor->data_5 = 1; + } + else + { + actor->y = actor->y - 1; + } + + if(is_sprite_on_screen(actor->actorInfoIndex, 0, actor->x, actor->y) != 0) + { + //play_sfx(0x31); + } + } + + if(actor->data_2 < 5) + { + if(sprite_blocking_check(0, 0xbc, 0, actor->x, actor->y - 1) != 0) + { + actor->data_5 = 1; + } + else + { + actor->y = actor->y - 1; + } + + actor->data_4 = Cond(actor->data_4, -1, 0) + 1; + display_actor_sprite_maybe(0xbc, actor->data_4 + 4, actor->x, actor->y + 6, 0); + + if(player_check_collision_with_actor(0xbc, 4, actor->x, actor->y + 6) != 0) + { + player_decrease_health(); + } + + if(actor->data_4 != 0) + { + effect_add_sprite(0x61, 6, actor->x, actor->y + 6, 5, 1); + } + } + + if(actor->x == player_x_pos) + { + if(actor->y - 7 <= player_y_pos) + { + if(actor->y - 4 >= player_y_pos) + { + player_bounce_height_counter = 0x10; + player_bounce_flag_maybe = 1; + sub_11062(); + word_2E1DE = 0; + if(actor->y - 7 == player_y_pos) + { + player_y_pos = player_y_pos + 1; + } + if(actor->y - 6 == player_y_pos) + { + player_y_pos = player_y_pos + 1; + } + if(actor->y - 4 == player_y_pos) + { + player_y_pos = player_y_pos - 1; + } + } + } + } + + if(actor->data_2 > 4 && (actor->data_2 & 1) != 0) + { + effect_add_sprite(0x61, 6, actor->x, actor->y + 1 + 1, 5, 1); + } + } + + if(actor->data_5 != 0) + { + actor->is_deactivated_flag_maybe = 1; + explode_effect_add_sprite(0xbc, 1, actor->x, actor->y); + + explode_effect_add_sprite(0xbc, 2, actor->x + 1, actor->y); + + explode_effect_add_sprite(0xbc, 3, actor->x + 1 + 1, actor->y); + + struct6_add_sprite(actor->x - 4, actor->y); + + struct6_add_sprite(actor->x + 1, actor->y); + actor_tile_display_func_index = 2; + } + return; +} + +U0 actor_wt_rubber_wall(ActorData *actor) +{ + if (actor->data_2 != 0) + { + actor->is_deactivated_flag_maybe = 1; + actor_tile_display_func_index = 1; + explode_effect_add_sprite(0x40, 3, actor->x, actor->y - 8); + + explode_effect_add_sprite(0x40, 3, actor->x, actor->y - 7); + + explode_effect_add_sprite(0x40, 3, actor->x, actor->y - 6); + + explode_effect_add_sprite(0x40, 3, actor->x, actor->y); + + explode_effect_add_sprite(0x40, 3, actor->x + 1, actor->y); + + explode_effect_add_sprite(0x40, 3, actor->x + 1 + 1, actor->y); + + effect_add_sprite(0x61, 6, actor->x, actor->y, 1, 2); + + effect_add_sprite(0x61, 6, actor->x, actor->y, 2, 2); + + effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 2); + + effect_add_sprite(0x61, 6, actor->x, actor->y - 4, 1, 3); + player_add_to_score(0x6400); + + actor_add_new(0xb8, actor->x - 2, actor->y - 9); + + actor_add_new(0xb8, actor->x + 1 + 1, actor->y - 9); + //play_sfx(0x19); + return; + } + + I64 i; + + if (actor->has_moved_left_flag == 0) + { + actor->has_moved_left_flag = 1; + for(i=0; i < 9; i++) + { + map_write_tile_cell(0x3d88, actor->x + 1, actor->y - i); + } + } + + if(actor->data_1 != 0) + { + actor->data_1--; + if((actor->data_1 & 1) != 0) + { + actor_tile_display_func_index = 2; + } + } + + if (struct6_1B4FC(0x40, 0, actor->x, actor->y) != 0 && actor->data_1 == 0) + { + actor->data_1 = 10; + actor->frame_num++; + + if (actor->frame_num == 3) + { + actor->frame_num = 2; + actor->data_2 = 1; + for(i=0; i < 9; i ++) + { + map_write_tile_cell(0, actor->x + 1, actor->y - i); + } + } + } + + return; +} + +U0 actor_wt_satellite(ActorData *actor) +{ + if(actor->data_2 != 0) + { + actor->data_2--; + if(actor->data_2 != 0) + { + if((actor->data_2 & 1) != 0) + { + actor_tile_display_func_index = 2; + } + return; + } + } + + if(struct6_1B4FC(0x8f, 0, actor->x, actor->y) == 0) + { + return; + } + + if(actor->data_1 == 0) + { + actor->data_1 = 1; + actor->data_2 = 15; + return; + } + + actor->is_deactivated_flag_maybe = 1; + actor_tile_display_func_index = 2; + //play_sfx(0x12); + actor->data_1 = 1; + + for(; actor->data_1 < 9; actor->data_1++) + { + effect_add_sprite(0x61, 6, actor->x + 3, actor->y - 3, actor->data_1, 3); + } + + exploding_balls_effect(actor->x, actor->y + 5); + explode_effect_add_sprite(0x90, 0, actor->x, actor->y - 2); + explode_effect_add_sprite(0x90, 1, actor->x + 1, actor->y - 2); + explode_effect_add_sprite(0x90, 2, actor->x + 7, actor->y + 1 + 1); + explode_effect_add_sprite(0x90, 3, actor->x + 3, actor->y - 2); + explode_effect_add_sprite(0x90, 4, actor->x - 1, actor->y - 8); + explode_effect_add_sprite(0x90, 5, actor->x + 1 + 1, actor->y + 3); + explode_effect_add_sprite(0x90, 6, actor->x + 6, actor->y - 2); + explode_effect_add_sprite(0x90, 7, actor->x - 4, actor->y + 1); + + actor_toss_add_new(0x52, actor->x + 4, actor->y); +} + +U0 actor_wt_security_robot(ActorData *actor) +{ + if(actor->count_down_timer != 0) + { + return; + } + actor->data_3 = Cond(actor->data_3, -1, 0) + 1; + if(actor->data_3 != 0) + { + return; + } + if(brightness_effect_enabled_flag != 0) + { + if(sub_1106F() % 0x32 > 0x30) + { + if(actor->data_4 == 0) + { + actor->data_4 = 10; + } + } + } + + if(actor->data_4 != 0) + { + actor->data_2 = Cond(actor->data_2, -1, 0) + 1; + actor->data_4--; + if(actor->data_4 == 1) + { + if(actor->x + 1 <= player_x_pos) + { + actor->data_1 = 1; + } + else + { + actor->data_1 = 0; + } + + if(actor->data_1 == 0) + { + actor_add_new(0x6d, actor->x - 1, actor->y - 1); + } + else + { + actor_add_new(0x6e, actor->x + 3, actor->y - 1); + } + } + + if(actor->data_1 != 0) + { + if(actor->data_2 == 0) + { + actor->frame_num = 0; + } + else + { + actor->frame_num = 5; + } + return; + } + + if(actor->data_2 == 0) + { + actor->frame_num = 2; + } + else + { + actor->frame_num = 6; + } + } + else + { + + if(actor->data_1 == 0) + { + actor->x = actor->x - 1; + check_actor_move_left_or_right(actor, LEFT); + + if(actor->has_moved_left_flag != 0) + { + + actor->data_2 = Cond(actor->data_2, -1, 0) + 1; + actor->frame_num = actor->data_2 + 2; + } + else + { + actor->data_1 = 1; + actor->frame_num = 4; + } + return; + } + actor->x = actor->x + 1; + check_actor_move_left_or_right(actor, RIGHT); + + if(actor->has_moved_right_flag != 0) + { + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + } + else + { + actor->data_1 = 0; + actor->frame_num = 4; + } + } +} + +U0 actor_wt_short_dialog(ActorData *actor) +{ + actor_tile_display_func_index = 1; + if(actor->data_2 == 0) + { + if(actor->y <= player_y_pos) + { + if(actor->y >= player_y_pos - 4) + { + end_game_dialog(actor->data_1); + actor->data_2 = 1; + } + } + } +} + +U0 actor_wt_silver_robot(ActorData *actor) +{ + actor_tile_display_func_index = 3; + if(actor->data_5 == 1) + { + actor_tile_display_func_index = 0; + } + + if(actor->data_2 != 0) + { + actor->data_2--; + actor_tile_display_func_index = 0; + return; + } + + if(actor->data_4 != 0) + { + actor->data_4--; + } + + actor->data_3 = Cond(actor->data_3, -1, 0) + 1; + if(actor->data_1 == 0) + { + if(actor->y == player_y_pos) + { + if(actor->x - 3 == player_x_pos && actor->data_4 == 0) + { + actor->frame_num = 2; + actor->data_2 = 8; + push_player_around(7, 5, 2, 0x28, 0, 1); + //play_sfx(0x14); + player_direction = 0x17; + actor->data_4 = 3; + actor_tile_display_func_index = 0; + if(word_2E238 == 0) + { + word_2E238 = 1; + actor_add_new(0xf5, player_x_pos - 1, player_y_pos - 5); + } + return; + } + } + + if(actor->data_3 == 0) + { + return; + } + actor->x = actor->x - 1; + check_actor_move_left_or_right(actor, LEFT); + + if(actor->has_moved_left_flag != 0) + { + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + } + else + { + actor->data_1 = 1; + actor->frame_num = (actor->x & 1) + 3; + } + } + else + { + + if(actor->y == player_y_pos) + { + if(actor->x + 4 == player_x_pos && actor->data_4 == 0) + { + actor->frame_num = 5; + actor->data_2 = 8; + push_player_around(3, 5, 2, 0x11, 0, 1); + //play_sfx(0x14); + player_direction = 0; + actor->data_4 = 3; + actor_tile_display_func_index = 0; + if(word_2E238 == 0) + { + word_2E238 = 1; + actor_add_new(0xf5, player_x_pos - 1, player_y_pos - 5); + } + return; + } + } + + if(actor->data_3 != 0) + { + actor->x++; + check_actor_move_left_or_right(actor, RIGHT); + + if(actor->has_moved_right_flag != 0) + { + actor->frame_num = (actor->x & 1) + 3; + } + else + { + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + actor->data_1 = 0; + } + } + } + return; +} + +U0 actor_wt_small_flame(ActorData *actor) +{ + actor->frame_num = actor->frame_num + 1; + if(actor->frame_num == 6) + { + actor->frame_num = 0; + } + return; +} + +U0 actor_wt_small_red_plant(ActorData *actor) +{ + if(actor->data_1 == 0) + { + if(actor->y > player_y_pos) + { + if(actor->x == player_x_pos) + { + actor->data_1 = 1; + } + } + } + + if(actor->data_1 == 1) + { + actor->data_2++; + if(actor->data_2 == 2) + { + actor->data_2 = 0; + actor->frame_num = actor->frame_num + 1; + if(actor->frame_num == 3) + { + actor->data_1 = 0; + actor->frame_num = 0; + } + + if(actor->frame_num == 1) + { + actor->x = actor->x - 1; + //play_sfx(0x3f); + } + + if(actor->frame_num == 2) + { + actor->x = actor->x + 1; + } + } + } + return; +} + +U0 actor_wt_smoke_rising(ActorData *actor) +{ + actor_tile_display_func_index = 1; + + actor->data_1 = (sub_1106F() & 0x1f); + if(actor->data_1 == 0) + { + if(actor->data_5 == 0) + { + + effect_add_sprite(0x62, 6, actor->x - 2, actor->y, 1, 1); + } + else + { + effect_add_sprite(0x61, 6, actor->x - 1, actor->y, 1, 1); + } + } + return; +} + +U0 actor_wt_spark(ActorData *actor) +{ + actor->data_5++; + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + if((actor->data_5 & 1) != 0) + { + return; + } + if(actor->data_1 == 0) + { + actor->x = actor->x - 1; + if(sprite_blocking_check(2, actor->actorInfoIndex, 0, actor->x - 1, actor->y) != NOT_BLOCKED) + { + actor->data_1 = 2; + return; + } + + if(sprite_blocking_check(1, actor->actorInfoIndex, 0, actor->x, actor->y + 1) == NOT_BLOCKED) + { + actor->data_1 = 3; + } + return; + } + + if (actor->data_1 != 1) + { + if(actor->data_1 == 2) + { + actor->y = actor->y - 1; + if(sprite_blocking_check(0, actor->actorInfoIndex, 0, actor->x, actor->y - 1) != NOT_BLOCKED) + { + actor->data_1 = 1; + return; + } + + if(sprite_blocking_check(2, actor->actorInfoIndex, 0, actor->x - 1, actor->y) == NOT_BLOCKED) + { + actor->data_1 = 0; + return; + } + return; + } + + if(actor->data_1 == 3) + { + actor->y = actor->y + 1; + if(sprite_blocking_check(1, actor->actorInfoIndex, 0, actor->x, actor->y + 1) != NOT_BLOCKED) + { + actor->data_1 = 0; + return; + } + + if(sprite_blocking_check(3, actor->actorInfoIndex, 0, actor->x + 1, actor->y) == NOT_BLOCKED) + { + actor->data_1 = 1; + } + return; + } + } + else + { + actor->x = actor->x + 1; + if(sprite_blocking_check(3, actor->actorInfoIndex, 0, actor->x + 1, actor->y) != NOT_BLOCKED) + { + actor->data_1 = 3; + return; + } + + if(sprite_blocking_check(0, actor->actorInfoIndex, 0, actor->x, actor->y - 1) == NOT_BLOCKED) + { + actor->data_1 = 2; + } + } +} + +U0 actor_wt_spear_vertical(ActorData *actor) +{ + if(actor->data_1 >= 0x1e) + { + actor->data_1 = 0; + } + else + { + actor->data_1++; + } + + if(actor->data_1 > 0x16) + { + actor->y = actor->y - 1; + return; + } + + if(actor->data_1 > 14) + { + actor->y = actor->y + 1; + return; + } + return; +} + +U0 actor_wt_spring(ActorData *actor) +{ + if(actor->data_1 <= 0) + { + actor->frame_num = 0; + } + else + { + actor->frame_num = 1; + actor->data_1--; + } + + if(actor->data_5 != 0) + { + actor_tile_display_func_index = 4; + if(actor->frame_num != 0) + { + actor->y = actor->data_4; + } + else + { + actor->y = actor->data_3; + } + } + return; +} + +U0 actor_wt_stone_head(ActorData *actor) +{ + actor->data_4 = Cond(actor->data_4, -1, 0) + 1; + if(actor->data_1 == 0) + { + if(actor->y < player_y_pos) + { + if(actor->x <= player_x_pos + 6) + { + if(actor->x + 7 > player_x_pos) + { + actor->data_1 = 1; + actor->data_2 = actor->y; + actor->frame_num = 1; + return; + } + } + } + actor->frame_num = 0; + return; + } + + if(actor->data_1 == 1) + { + actor->frame_num = 1; + actor->y = actor->y + 1; + if(sprite_blocking_check(1, 0x2f, 0, actor->x, actor->y) != 0) + { + actor->data_1 = 2; + if(is_sprite_on_screen(0x2f, 0, actor->x, actor->y) != 0) + { + //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); + actor->y = actor->y - 1; + } + else + { + actor->y = actor->y - 1; + } + return; + } + + actor->y = actor->y + 1; + if(sprite_blocking_check(1, 0x2f, 0, actor->x, actor->y) != NOT_BLOCKED) + { + actor->data_1 = 2; + //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); + actor->y = actor->y - 1; + return; + } + } + else + { + + if(actor->data_1 == 2) + { + actor->frame_num = 0; + if(actor->y == actor->data_2) + { + actor->data_1 = 0; + } + else if(actor->data_4 != 0) + { + actor->y = actor->y - 1; + } + } + } + return; +} + +uint8 suction_cup_enemy_check_if_blocked(ActorData *actor, uint8 blocking_check) +{ + if ((sub_1106F() & 1) == 0) + { + return 0; + } + + I64 si; + + if (blocking_check == 0) + { + for(si=0;si < 15; si++) + { + if ((tileattr_mni_data[map_get_tile_cell(actor->x, actor->y - si - 4)/8] & TILE_ATTR_BLOCK_LEFT) != 0 && + (tileattr_mni_data[map_get_tile_cell(actor->x + 1 + 1, actor->y - si - 4)/8] & TILE_ATTR_BLOCK_LEFT) != 0) + { + return 1; + } + } + } + else if(blocking_check == 1) + { + for(si=0; si < 15; si++) + { + if((tileattr_mni_data[map_get_tile_cell(actor->x, actor->y + si)/8] & TILE_ATTR_BLOCK_DOWN) != 0 && + (tileattr_mni_data[map_get_tile_cell(actor->x + 1 + 1, actor->y + si)/8] & TILE_ATTR_BLOCK_DOWN) != 0) + { + return 1; + } + } + } + + return 0; +} + +U0 actor_wt_suction_cup_alien_enemy(ActorData *actor) +{ + I64 blocking_check; + uint8 tile_attr; + actor->data_4 = Cond(actor->data_4, -1, 0) + 1; + if (actor->data_1 == 0) + { + if (actor->data_2 == 0) + { + if(actor->data_4 != 0) + { + actor->data_3 = Cond(actor->data_3, -1, 0) + 1; + actor->frame_num = actor->data_3; + } + + tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x - 1, actor->y + 1)/8]; + if (sprite_blocking_check(2, 0x6a, 0, actor->x - 1, actor->y) != NOT_BLOCKED || Cond(tile_attr & 1, -1, 0) + 1 != 0) + { + if (suction_cup_enemy_check_if_blocked(actor, 0) == 0) + { + actor->data_1 = 1; + actor->data_2 = 0; + } + else + { + actor->data_2 = 2; + actor->frame_num = 9; + } + return; + } + else + { + if (sub_1106F() % 0x32 == 0) + { + if (suction_cup_enemy_check_if_blocked(actor, 0) == 0) + { + actor->data_1 = 1; + actor->data_2 = 0; + } + else + { + actor->data_2 = 2; + actor->frame_num = 9; + } + } + else + { + if(actor->data_4 != 0) + { + actor->x = actor->x - 1; + } + } + return; + } + } + else + { + if(actor->data_2 != 1) + { + if(actor->data_2 == 2) + { + if(sprite_blocking_check(0, 0x6a, 0, actor->x, actor->y - 1) == 0) + { + actor->y = actor->y - 1; + } + else + { + actor->data_2 = 1; + } + + if(sprite_blocking_check(0, 0x6a, 0, actor->x, actor->y - 1) != NOT_BLOCKED) + { + actor->data_2 = 1; + } + else + { + actor->y = actor->y - 1; + } + return; + } + + if(actor->data_2 != 3) + { + return; + } + if(sprite_blocking_check(1, 0x6a, 0, actor->x, actor->y + 1) == 0) + { + actor->y = actor->y + 1; + } + else + { + actor->data_2 = 0; + } + + if(sprite_blocking_check(1, 0x6a, 0, actor->x, actor->y + 1) != NOT_BLOCKED) + { + actor->data_2 = 0; + } + else + { + actor->y = actor->y + 1; + } + return; + } + if(actor->data_4 != 0) + { + actor->data_3 = Cond(actor->data_3, -1, 0) + 1; + actor->frame_num = actor->data_3 + 4; + } + + blocking_check = sprite_blocking_check(2, 0x6a, 0, actor->x - 1, actor->y); + tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x - 1, actor->y - 4)/8]; + + if(blocking_check == SLOPE) + { + + if(actor->data_4 != 0) + { + actor->y = actor->y - 1; + actor->x = actor->x - 1; + return; + } + } + if (blocking_check != NOT_BLOCKED || Cond(tile_attr & 4, -1, 0) + 1 != 0) + { + if (suction_cup_enemy_check_if_blocked(actor, 1) == 0) + { + actor->data_1 = 1; + actor->data_2 = 1; + } + else + { + actor->data_2 = 3; + actor->frame_num = 9; + } + } + else + { + if (sub_1106F() % 0x32 != 0) + { + if(actor->data_4 != 0) + { + actor->x = actor->x - 1; + } + } + else + { + if (suction_cup_enemy_check_if_blocked(actor, 1) == 0) + { + actor->data_1 = 1; + actor->data_2 = 1; + } + else + { + actor->data_2 = 3; + actor->frame_num = 9; + } + } + } + } + } + else + { + if(actor->data_1 != 1) + { + return; + } + if (actor->data_2 == 0) + { + if(actor->data_4 != 0) + { + actor->data_3 = Cond(actor->data_3, -1, 0) + 1; + actor->frame_num = actor->data_3 + 1 + 1; + } + + tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x + 3, actor->y + 1)/8]; + if (sprite_blocking_check(3, 0x6a, 0, actor->x + 1, actor->y) != NOT_BLOCKED || Cond(tile_attr & 1, -1, 0) + 1 != 0) + { + if(suction_cup_enemy_check_if_blocked(actor, 0) == 0) + { + actor->data_1 = 0; + actor->data_2 = 0; + } + else + { + actor->data_2 = 2; + actor->frame_num = 8; + } + } + else + { + if (sub_1106F() % 0x32 != 0) + { + if(actor->data_4 != 0) + { + actor->x = actor->x + 1; + } + } + else + { + if(suction_cup_enemy_check_if_blocked(actor, 0) == 0) + { + actor->data_1 = 0; + actor->data_2 = 0; + } + else + { + actor->data_2 = 2; + actor->frame_num = 8; + } + } + } + } + else + { + if(actor->data_2 != 1) + { + if(actor->data_2 == 2) + { + if(sprite_blocking_check(0, 0x6a, 0, actor->x, actor->y - 1) == NOT_BLOCKED) + { + actor->y = actor->y - 1; + } + else + { + actor->data_2 = 1; + } + + if(sprite_blocking_check(0, 0x6a, 0, actor->x, actor->y - 1) != NOT_BLOCKED) + { + actor->data_2 = 1; + } + else + { + actor->y = actor->y - 1; + } + return; + } + + if(actor->data_2 == 3) + { + if(sprite_blocking_check(1, 0x6a, 0, actor->x, actor->y + 1) == NOT_BLOCKED) + { + actor->y = actor->y + 1; + } + else + { + actor->data_2 = 0; + } + + if(sprite_blocking_check(1, 0x6a, 0, actor->x, actor->y + 1) == NOT_BLOCKED) + { + actor->y = actor->y + 1; + } + else + { + actor->data_2 = 0; + } + } + return; + } + if(actor->data_4 != 0) + { + actor->data_3 = Cond(actor->data_3, -1, 0) + 1; + actor->frame_num = actor->data_3 + 6; + } + + tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x + 3, actor->y - 4)/8]; + if (sprite_blocking_check(3, 0x6a, 0, actor->x + 1, actor->y) != NOT_BLOCKED || Cond(tile_attr & 4, -1, 0) + 1 != 0) + { + if(suction_cup_enemy_check_if_blocked(actor, 1) == 0) + { + actor->data_1 = 0; + actor->data_2 = 1; + } + else + { + actor->data_2 = 3; + actor->frame_num = 8; + } + } + else + { + if (sub_1106F() % 0x32 == 0) + { + if(suction_cup_enemy_check_if_blocked(actor, 1) == 0) + { + actor->data_1 = 0; + actor->data_2 = 1; + } + else + { + actor->data_2 = 3; + actor->frame_num = 8; + } + } + else + { + if(actor->data_4 != 0) + { + actor->x = actor->x + 1; + } + } + } + } + } +} + +U0 activate_switch_maybe(I64 actorInfoIndex, ActorData *switch_actor) +{ + I64 di; + for(di=0; di < total_num_actors; di++) + { + ActorData *actor = get_actor(di); + if (actor->actorInfoIndex != actorInfoIndex) + { + goto activate_switch_maybe_cont; + } + + if (switch_actor->data_1 != 2) + { + if (switch_actor->data_1 != 1) + { + break; + } + + map_write_tile_cell(actor->data_1, actor->x + 1, actor->y - 0); + map_write_tile_cell(actor->data_2, actor->x + 1, actor->y - 1); + map_write_tile_cell(actor->data_3, actor->x + 1, actor->y - 2); + map_write_tile_cell(actor->data_4, actor->x + 1, actor->y - 3); + map_write_tile_cell(actor->data_5, actor->x + 1, actor->y - 4); + } + else + { + actor->is_deactivated_flag_maybe = 1; + //play_sfx(8); + effect_add_sprite(actorInfoIndex, 1, actor->x, actor->y, 5, 5); + } +activate_switch_maybe_cont: + } +} +U0 actor_wt_switch(ActorData *actor) +{ + if(actor->frame_num == 1) + { + if(actor->data_1 < 3) + { + actor->data_1++; + } + activate_switch_maybe(actor->data_5, actor); + } +} + +U0 actor_wt_switch_multi_use(ActorData *actor) +{ + if(actor->actorInfoIndex != 0x3c) + { + return; + } + if(actor->has_moved_left_flag == 0) + { + actor->has_moved_left_flag = 1; + write_tile_row_to_tilemap(0x3d88, 0x3d90, 0x3d98, 0x3da0, actor->x, actor->y); + } + + if(actor->data_4 != 0) + { + actor->data_4 = 0; + write_tile_row_to_tilemap(0x3da8 - actor->data_3, 0x3da8 - actor->data_3 + 8, 0x3da8 - actor->data_3 + 0x10, 0x3da8 - actor->data_3 + 0x18, actor->x, actor->y); + + actor->y = actor->y + 1; + write_tile_row_to_tilemap(0x3d88, 0x3d90, 0x3d98, 0x3da0, actor->x, actor->y); + if(actor->data_1 == 4) + { + //play_sfx(0x10); + switch (actor->data_5) + { + case 59: + move_platform_flag = 1; + break; + + case 61: + word_2E17E = 4; + if(word_2E228 == 0) + { + word_2E228 = 1; + actor_add_new(0xf4, player_x_pos - 1, player_y_pos - 5); + } + break; + + case 120: + brightness_effect_enabled_flag = 1; + break; + + case 121: + energy_beam_enabled_flag = 0; + break; + } + } + else + { + //play_sfx(15); + } + } + + if(actor->data_1 < 4 && actor->data_4 == 0) + { + if(struct6_1B4FC(0x3c, 0, actor->x, actor->y) != 0) + { + actor->data_1 = actor->data_1 + 1; + if(actor->data_2 != 0) + { + actor->data_3 = 0; + } + else + { + actor->data_3 = 0x40; + actor->data_2 = 1; + } + actor->data_4 = 1; + } + } +} + +U0 actor_wt_teleporter(ActorData *actor) +{ + actor_tile_display_func_index = 1; + if(teleporter_counter == 0 || (cosmo_rand() & 1) == 0) + { + + display_actor_sprite_maybe(0x6b, 0, actor->x, actor->y, 0); + } + else + { + + display_actor_sprite_maybe(0x6b, 0, actor->x, actor->y, 2); + } + if((sub_1106F() & 1) != 0) + { + display_actor_sprite_maybe(0x6b, (cosmo_rand() & 1) + 1, actor->x, actor->y, 0); + } + if(teleporter_counter == 15) + { + effect_add_sprite(15, 4, player_x_pos - 1, player_y_pos, 0, 1); + effect_add_sprite(15, 4, player_x_pos + 1, player_y_pos, 0, 1); + 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); + } + if(teleporter_counter > 1) + { + teleporter_counter = teleporter_counter - 1; + return; + } + if(teleporter_state_maybe == 3) + { + finished_level_flag_maybe = 1; + return; + } + if(teleporter_state_maybe == 0) + { + return; + } + + if(actor->data_5 == teleporter_state_maybe || actor->data_5 == 3) + { + return; + } + player_x_pos = actor->x + 1; + player_y_pos = actor->y; + if(player_x_pos - 14 >= 0) + { + if(player_x_pos - 14 <= map_width_in_tiles - 38) + { + mapwindow_x_offset = player_x_pos - 14; + } + else + { + mapwindow_x_offset = map_width_in_tiles - 38; + } + } + else + { + mapwindow_x_offset = 0; + } + if(player_y_pos - 12 >= 0) + { + if(player_y_pos - 12 <= map_max_y_offset) + { + mapwindow_y_offset = player_y_pos - 12; + } + else + { + mapwindow_y_offset = map_max_y_offset; + } + } + else + { + mapwindow_y_offset = 0; + } + teleporter_state_maybe = 0; + teleporter_counter = 0; + player_bounce_flag_maybe = 0; + if(word_2E23C == 0) + { + word_2E23C = 1; + actor_add_new(0xf4, player_x_pos - 1, player_y_pos - 5); + } + return; +} + +U0 actor_wt_two_tons(ActorData *actor) +{ + if(actor->data_1 < 0x14) + { + actor->data_1++; + } + + if(actor->data_1 == 0x13) + { + actor->data_2 = 1; + } + + if(actor->data_2 == 1) + { + if(actor->frame_num >= 3) + { + + actor->data_2 = 2; + if(is_sprite_on_screen(0x2d, 4, actor->x - 1, actor->y + 3) != 0) + { + //play_sfx(0x25); + } + } + else + { + actor->frame_num = actor->frame_num + 1; + if(actor->frame_num == 1) + { + actor->data_3 = 1; + } + else + { + if(actor->frame_num == 2) + { + actor->data_3 = 2; + } + else + { + if(actor->frame_num == 3) + { + actor->data_3 = 4; + } + } + } + + actor->y = actor->y + actor->data_3; + } + } + + if(actor->data_2 == 2) + { + if(actor->frame_num <= 0) + { + + actor->data_2 = 0; + actor->data_1 = 0; + actor->data_3 = 0; + } + else + { + actor->frame_num--; + if(actor->frame_num == 0) + { + actor->data_3 = 1; + } + else + { + if(actor->frame_num == 1) + { + actor->data_3 = 2; + } + else + { + if(actor->frame_num == 2) + { + actor->data_3 = 4; + } + } + } + + actor->y = actor->y - actor->data_3; + } + } + + if(player_check_collision_with_actor(0x2d, 4, actor->x - 1, actor->y + 3) != 0) + { + player_decrease_health(); + return; + } + + display_actor_sprite_maybe(0x2d, 4, actor->x - 1, actor->y + 3, 0); + return; +} + +sint8 score_effect_x_tbl[10] = { + -2, -1, 0, 1, 2, 2, 1, 0, -1, -2 +}; +U0 actor_wt_floating_score_effect(ActorData *actor) +{ + actor_tile_display_func_index = 1; + actor->data_1++; + actor->frame_num = Cond(actor->frame_num, -1, 0) + 1; + if(actor->data_1 > 0x1f) + { + actor->y = actor->y - 1; + actor->x = actor->x + score_effect_x_tbl[(actor->data_1 - 32) % 10]; + } + + if(actor->data_1 < 4) + { + actor->y = actor->y - 1; + } + + if(actor->data_1 == 0x64 || is_sprite_on_screen(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) == 0) + { + actor->is_deactivated_flag_maybe = 1; + actor_tile_display_func_index = 1; + } + + display_actor_sprite_maybe(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y, 5); + return; +} + +U0 actor_wt_speech_bubble(ActorData *actor) +{ + actor_tile_display_func_index = 1; + if(actor->data_1 == 0) + { + //play_sfx(0x39); + if(actor->actorInfoIndex == 0xf6) + { + player_add_to_score(0xc350); + } + } + + actor->data_1++; + if(actor->data_1 != 0x14) + { + display_actor_sprite_maybe(actor->actorInfoIndex, 0, player_x_pos - 1, player_y_pos - 5, 5); + } + else + { + actor->is_deactivated_flag_maybe = 1; + } + + return; +} + +uint8 unk_232_frame_num_tbl[4] = {0, 1, 2, 1}; +U0 actor_wt_unknown_232(ActorData *actor) +{ + byte_32EB8 = 1; + + actor->data_1++; + actor->frame_num = unk_232_frame_num_tbl[actor->data_1 & 3]; + if(actor->data_1 > 0xc8 && (actor->data_1 & 1) != 0) + { + actor_tile_display_func_index = 1; + } + + if(actor->data_1 != 0xf0) + { + + actor->x = player_x_pos - 1; + actor->y = player_y_pos + 1; + } + else + { + actor->is_deactivated_flag_maybe = 1; + actor_tile_display_func_index = 1; + byte_32EB8 = 0; + } +} diff --git a/Backdrop.HC b/Backdrop.HC new file mode 100644 index 0000000..b9ee814 --- /dev/null +++ b/Backdrop.HC @@ -0,0 +1,98 @@ +extern U0 video_draw_tile_with_clip_rect(Tile *tile, uint16 x, uint16 y, uint16 clip_x, uint16 clip_y, uint16 clip_w, uint16 clip_h); + +#define BACKGROUND_WIDTH 40 +#define BACKGROUND_HEIGHT 18 + +//Data +uint16 backdrop_index = 0xff; +uint8 background_x_scroll_flag = 0; +uint8 background_y_scroll_flag = 0; + +U8 backdrop_filename_tbl[26][13] = { + "BDBLANK.MNI", + "BDPIPE.MNI", + "BDREDSKY.MNI", + "BDROCKTK.MNI", + "BDJUNGLE.MNI", + "BDSTAR.MNI", + "BDWIERD.MNI", + "BDCAVE.MNI", + "BDICE.MNI", + "BDSHRUM.MNI", + "BDTECHMS.MNI", + "BDNEWSKY.MNI", + "BDSTAR2.MNI", + "BDSTAR3.MNI", + "BDFOREST.MNI", + "BDMOUNTN.MNI", + "BDGUTS.MNI", + "BDBRKTEC.MNI", + "BDCLOUDS.MNI", + "BDFUTCTY.MNI", + "BDICE2.MNI", + "BDCLIFF.MNI", + "BDSPOOKY.MNI", + "BDCRYSTL.MNI", + "BDCIRCUT.MNI", + "BDCIRCPC.MNI" +}; + +Tile *bg_tiles; + +U0 load_backdrop_image(U8 *filename) +{ + uint16 num_tiles; + bg_tiles = load_tiles(filename, SOLID, &num_tiles); + "Loading %d background tiles.\n", num_tiles; +} + +Bool set_backdrop(uint16 new_backdrop_index) +{ + uint8 cur_background_x_scroll_flag = 0; + uint8 cur_background_y_scroll_flag = 0; + + if (new_backdrop_index != backdrop_index || + cur_background_x_scroll_flag != background_x_scroll_flag || + cur_background_y_scroll_flag != background_y_scroll_flag) + { + backdrop_index = new_backdrop_index; + cur_background_x_scroll_flag = background_x_scroll_flag; + cur_background_y_scroll_flag = background_y_scroll_flag; + + load_backdrop_image(backdrop_filename_tbl[backdrop_index]); + } + + return TRUE; +} + +U0 backdrop_display() +{ + I64 x_offset = 0; + I64 y_offset = 0; + I64 sub_tile_x = 0; + I64 sub_tile_y = 0; + I64 x, y; + + //background scrolls in 4 pixel increments. + if(background_x_scroll_flag) + { + x_offset = mapwindow_x_offset % (BACKGROUND_WIDTH*2); + x_offset /= 2; + sub_tile_x = Cond(mapwindow_x_offset & 1, 4, 0); + } + + if(background_y_scroll_flag) + { + y_offset = mapwindow_y_offset % (BACKGROUND_HEIGHT*2); + y_offset /= 2; + sub_tile_y = Cond(mapwindow_y_offset & 1, 4, 0); + } + + for(y=0; y < MAP_WINDOW_HEIGHT + 1; y++) + { + for(x=0; x < MAP_WINDOW_WIDTH + 1; x++) + { + video_draw_tile_with_clip_rect(&bg_tiles[((x+x_offset) % BACKGROUND_WIDTH) + ((y+y_offset) % BACKGROUND_HEIGHT) * BACKGROUND_WIDTH], (x+1)*8 - sub_tile_x, (y+1)*8 - sub_tile_y, 8, 8, 8*MAP_WINDOW_WIDTH, 8*MAP_WINDOW_HEIGHT); + } + } +} \ No newline at end of file diff --git a/Cartoon.HC b/Cartoon.HC new file mode 100644 index 0000000..f449d59 --- /dev/null +++ b/Cartoon.HC @@ -0,0 +1,29 @@ +Tile *cartoon_tiles; +Sprite *sprites; + +U0 load_cartoon_images() +{ + uint16 num_tile_info_records; + uint16 num_tiles; + cartoon_tiles = load_tiles("CARTOON.MNI", TRANSPARENT, &num_tiles); + "Loading %d cartoon tiles.\n", num_tiles; + + sprites = load_tile_info("CARTINFO.MNI", &num_tile_info_records); + "Loading %d, cartoon tile info records.\n", num_tile_info_records; +} + +U0 display_cartoon_sequence(uint16 frame_num, uint16 x_pos, uint16 y_pos) +{ + TileInfo *info = &sprites[0].frames[frame_num]; + Tile *tile = &cartoon_tiles[info->tile_num]; + I64 x, y; + + for(y=0; y < info->height; y++) + { + for(x=0; x < info->width; x++) + { + video_draw_tile(tile, (x_pos + x) * 8, (y_pos + y - info->height + 1) * 8); + tile++; + } + } +} \ No newline at end of file diff --git a/Config.HC b/Config.HC new file mode 100644 index 0000000..e69de29 diff --git a/Define.HC b/Define.HC new file mode 100644 index 0000000..016813a --- /dev/null +++ b/Define.HC @@ -0,0 +1,20 @@ +#define uint8 U8 +#define uint16 U16 +#define uint32 U32 + +#define sint8 I8 +#define sint16 I16 +#define sint32 I32 + +// BlockingType +#define NOT_BLOCKED 0 +#define BLOCKED 1 +#define SLOPE 2 + +// Direction +#define UP 0 +#define DOWN 1 +#define LEFT 2 +#define RIGHT 3 + +#define WB_SIZE 1048576 diff --git a/Dialog.HC b/Dialog.HC new file mode 100644 index 0000000..5b15400 --- /dev/null +++ b/Dialog.HC @@ -0,0 +1,850 @@ +extern U0 video_update(); +extern Tile *map_get_bg_tile(uint16 tile_num); +extern U8 get_episode_number(); +extern U0 set_initial_game_state(); +extern U0 display_fullscreen_image(uint8 image_number); +extern U0 fade_to_black_speed_3(); +extern U0 video_fill_screen_with_black(); +extern U0 fade_in_from_black_with_delay_3(); +extern U0 fade_to_white(uint16 wait_time); +extern U0 fade_in_from_black(uint16 wait_time); + + +#define SDLK_UP 1 +#define SDLK_DOWN 2 +#define SDLK_LEFT 3 +#define SDLK_RIGHT 4 + +#define PLAY_GAME 0 +#define PLAY_DEMO 1 +#define RECORD_DEMO 2 +#define QUIT_GAME 3 + + +class MenuItem { + uint16 x_pos; + uint16 y_pos; + U8 *text; + I64 action_key; +}; + + +//Data +uint8 show_one_moment_screen_flag = 0; +uint8 byte_28BE3 = 0; +uint8 byte_2E21C = 0; +I64 cur_selected_item = 0; + +//HintDialogInput +#define FAST_FORWARD 0 +#define EXIT 1 +#define NO_INPUT 2 + +I64 hint_dialog_get_input(I64 input) +{ + if (Bt(kbd.down_bitmap, Char2ScanCode(' '))) + { + return FAST_FORWARD; + } + if (Bt(kbd.down_bitmap, SC_ESC)) + { + return EXIT; + } + return NO_INPUT; + //return input; +} + +U8 score_text_tbl[13][17] = { + " Not Bad! ", + " Way Cool ", + " Groovy ", + " Radical! ", + " Insane ", + " Gnarly ", + " Outrageous ", + " Incredible ", + " Awesome! ", + " Brilliant! ", + " Profound ", + " Towering ", + "Rocket Scientist" +}; + + +U16 dialog_text_extract_num(U8 *text) +{ + U8 buf[4]; + + buf[0] = text[0]; + buf[1] = text[1]; + buf[2] = text[2]; + buf[3] = 0; + + return Str2I64(&buf) & 0xFFFF; +} + +U0 display_dialog_text_with_color(uint16 x_pos, uint16 y_pos, U8 *text, uint8 text_color) +{ + I64 input = NO_INPUT; + uint16 typewriter_keys_count = 0; + uint16 typewriter_delay_counter = 0; + I64 len = StrLen(text); + I64 x=0; + I64 i; + for(i=0; i < len; i++) + { + U8 c = text[i]; + if(c == '\n') + { + x = 0; + y_pos++; + goto display_dialog_text_with_color_cont; + } + + if(c < 123) + { + if (typewriter_delay_counter > 0) + { + input = hint_dialog_get_input(input); + + if(input == FAST_FORWARD) + { + cosmo_wait(1); + } + else + { + if(input == NO_INPUT) + { + for(; typewriter_keys_count > 0; typewriter_keys_count--) + { + cosmo_wait(3); + } + } + } + + typewriter_keys_count = typewriter_delay_counter; + if (c != 0x20) + { + //play_sfx(0x2c); + } + video_update(); + display_char(x_pos + x, y_pos, c, text_color); + } + else + { + display_char(x_pos + x, y_pos, c, text_color); + } + x++; + } + if(c >= 0xfb && c < 0xff) + { + uint16 frame_num = dialog_text_extract_num(&text[i+1]); + switch(c) + { + case 0xfb : display_cartoon_sequence(frame_num, x_pos + x, y_pos); break; + case 0xfc : + typewriter_keys_count = frame_num; + typewriter_delay_counter = frame_num; + break; + case 0xfd : display_player_sprite(frame_num, x_pos + x, y_pos, 6); break; + case 0xfe : + display_actor_sprite_maybe(frame_num, dialog_text_extract_num(&text[i+4]), x_pos + x - 1, y_pos, 6); + i += 3; + break; + } + i += 3; + } +display_dialog_text_with_color_cont: + } + video_update(); +} + +U0 display_dialog_text(uint16 x_pos, uint16 y_pos, U8 *text) +{ + display_dialog_text_with_color(x_pos, y_pos, text, FONT_WHITE); +} + +uint16 draw_dialog_frame(uint16 x_pos, uint16 y_pos, uint16 height, uint16 width, U8 *top_text, U8 *bottom_text, uint8 display_text) +{ + video_draw_tile(map_get_bg_tile(1991), x_pos * TILE_WIDTH, y_pos * TILE_HEIGHT); + video_draw_tile(map_get_bg_tile(1992), (x_pos + width-1) * TILE_WIDTH, y_pos * TILE_HEIGHT); + I64 x, y, x1; + + for(x=1;x < width-1;x++) + { + video_draw_tile(map_get_bg_tile(1995), (x_pos + x) * TILE_WIDTH, y_pos * TILE_HEIGHT); + video_draw_tile(map_get_bg_tile(1996), (x_pos + x) * TILE_WIDTH, (y_pos + height-1) * TILE_HEIGHT); + + for(y=1;y < height-1;y++) + { + video_draw_tile(map_get_bg_tile(1997), x_pos * TILE_WIDTH, (y_pos + y) * TILE_HEIGHT); + video_draw_tile(map_get_bg_tile(1998), (x_pos + width-1) * TILE_WIDTH, (y_pos + y) * TILE_HEIGHT); + + for(x1=1;x1 < width-1;x1++) + { + video_draw_tile(map_get_bg_tile(1999), (x_pos + x1) * TILE_WIDTH, (y_pos + y) * TILE_HEIGHT); + } + } + } + + video_draw_tile(map_get_bg_tile(1993), x_pos * TILE_WIDTH, (y_pos + height-1) * TILE_HEIGHT); + video_draw_tile(map_get_bg_tile(1994), (x_pos + width-1) * TILE_WIDTH, (y_pos + height-1) * TILE_HEIGHT); + + if(display_text) + { + display_dialog_text(0x14 - (StrLen(top_text)/2), y_pos + 1, top_text); + display_dialog_text(0x14 - (StrLen(bottom_text)/2), y_pos + height - 2, bottom_text); + } + + video_update(); + return x_pos + 1; +} + +uint16 create_text_dialog_box(uint16 y_offset, uint16 height, uint16 width, U8 *top_message, U8 *bottom_message) +{ + I64 dialog_x = 0x14 - (width / 2); + I64 var_4 = (height / 2) + y_offset; + I64 cur_width = 1; + I64 cur_x, cur_y; + for(cur_x = 0x13; cur_x > dialog_x; cur_x--) + { + cur_width = cur_width + 2; + draw_dialog_frame(cur_x, var_4, 2, cur_width, "", "", 0); + cosmo_wait(1); + } + + I64 cur_height = 0; + for(cur_y = var_4;cur_y >= Cond((height & 1), 1, 2) + y_offset; cur_y--) + { + cur_height += 2; + draw_dialog_frame(dialog_x, cur_y, cur_height, width, "", "", 0); + cosmo_wait(1); + } + + return draw_dialog_frame(dialog_x, y_offset, height, width, top_message, bottom_message, 1); +} + +U0 display_clear_tile_to_gray(uint16 x, uint16 y) +{ + video_draw_tile(map_get_bg_tile(1999), x * TILE_WIDTH, y * TILE_HEIGHT); +} + +I64 wait_for_input_with_repeat(I64 spinner_x, I64 spinner_y, Bool allow_key_repeat) +{ + video_update(); + reset_player_control_inputs(); + flush_input(); + + uint16 spinner_idx = 0; + I64 keycode = poll_for_key_press(allow_key_repeat); + while(keycode == SDLK_UNKNOWN && !Bt(kbd.down_bitmap, SC_ESC)) + { + //Draw spinning cursor + video_draw_tile(map_get_bg_tile(1987+spinner_idx), spinner_x * TILE_WIDTH, spinner_y * TILE_HEIGHT); + video_update(); + if(spinner_idx == 3) + spinner_idx = 0; + else + spinner_idx++; + cosmo_wait(5); + keycode = poll_for_key_press(allow_key_repeat); + } + display_clear_tile_to_gray(spinner_x, spinner_y); + return keycode; +} + +I64 wait_for_input(I64 spinner_x, I64 spinner_y) +{ + return wait_for_input_with_repeat(spinner_x, spinner_y, FALSE); +} + + +MenuItem main_menu_items[14] = { + {0, 5, " B)egin New Game", Char2ScanCode('b')}, + {0, 6, " R)estore A Game", Char2ScanCode('r')}, + {0, 7, " S)tory", Char2ScanCode('s')}, + {0, 8, " I)nstructions", Char2ScanCode('i')}, + {0, 9, " H)igh Scores", Char2ScanCode('h')}, + {0, 10, " G)ame Redefine", Char2ScanCode('g')}, + {0, 12, " O)rdering Info.", Char2ScanCode('o')}, + {0, 14, " F)oreign Orders", Char2ScanCode('f')}, + {0, 15, " A)pogee's BBS", Char2ScanCode('a')}, + {0, 0x10, " D)emo", Char2ScanCode('d')}, + {0, 0x11, " C)redits", Char2ScanCode('c')}, + {0, 0x12, " T)itle Screen", Char2ScanCode('t')}, + {0, 0x14, " Q)uit Game", Char2ScanCode('q')}, + {0, 0, NULL, 0} +}; + + +U0 ingame_hint_dialogs(uint16 hint_number) { + cosmo_wait(0x1e); + flush_input(); + uint16 x; + if(hint_number != 0 && hint_number < 15) + { + x = create_text_dialog_box(2, 9, 0x1c, "COSMIC HINT!", "Press any key to exit."); + display_dialog_text(x, 8, " Press SPACE to hurry or"); + } + + switch (hint_number) + { + case 0: + x = create_text_dialog_box(2, 11, 0x1c, "COSMIC HINT!", "Press any key to exit."); + display_dialog_text(x, 10, " Press SPACE to hurry or"); + display_dialog_text(x, 5, " These hint globes will\n" + " help you along your\n" + " journey. Press the up\n" + " key to reread them"); + + wait_for_input(x + 0x19, 11); + break; + + case 1: + display_dialog_text(x, 5, " Bump head into switch\n above!"); + break; + + case 2: + display_dialog_text(x, 5, " The ice in this cave is\n very, very slippery."); + break; + + case 3: + display_dialog_text(x, 5, " Use this shield for\n temporary invincibility."); + break; + + case 4: + display_dialog_text(x, 5, " You found a secret\n area!!! Good job!"); + break; + + case 5: + display_dialog_text(x, 5, " In high places look up\n to find bonus objects."); + break; + + case 6: + display_dialog_text(x, 5, " Out of Order..."); + break; + + case 7: + display_dialog_text(x, 5, " This might be a good\n time to save your game!"); + break; + + case 8: + display_dialog_text(x, 5, " Press your up key to\n use the transporter."); + break; + + case 9: + display_dialog_text(x, 5, " (1) FOR..."); + break; + + case 10: + display_dialog_text(x, 5, " (2) EXTRA..."); + break; + + case 11: + display_dialog_text(x, 5, " (3) POINTS,..."); + break; + + case 12: + display_dialog_text(x, 5, " (4) DESTROY..."); + break; + + case 13: + display_dialog_text(x, 5, " (5) HINT..."); + break; + + case 14: + display_dialog_text(x, 5, " (6) GLOBES!!!"); + break; + + case 15: + x = create_text_dialog_box(2, 11, 0x1c, "COSMIC HINT!", "Press any key to exit."); + display_dialog_text(x + 0x16, 8, ""); + display_dialog_text(x, 10, " Press SPACE to hurry or"); + display_dialog_text(x, 5, " The Clam Plants won't\n hurt you if their\n mouths are closed."); + wait_for_input(x + 0x19, 11); + break; + + case 16: + x = create_text_dialog_box(2, 10, 0x1c, "COSMIC HINT!", "Press any key to exit."); + display_dialog_text(x, 9, " Press SPACE to hurry or"); + display_dialog_text(x + 0x17, 7, "\n Collect the STARS to\n advance to BONUS\n STAGES."); + wait_for_input(x + 0x19, 10); + break; + + case 17: + x = create_text_dialog_box(2, 10, 0x1c, "COSMIC HINT!", "Press any key to exit."); + display_dialog_text(x, 9, " Press SPACE to hurry or"); + display_dialog_text(x, 5, " Some creatures require\n more than one pounce\n to defeat!"); + wait_for_input(x + 0x19, 10); + break; + + case 18: + x = create_text_dialog_box(2, 9, 0x1e, "COSMIC HINT!", "Press any key to exit."); + display_dialog_text(x + 0x19, 8, "\xfd""032"); + display_dialog_text(x, 8, " Press SPACE to hurry or"); + display_dialog_text(x, 5, " Cosmo can climb wall's\n with his suction hands."); + wait_for_input(x + 0x1b, 9); + break; + } + + if(hint_number != 0 && hint_number < 15) + { + wait_for_input(x + 0x19, 9); + } +} + +/* + uint16 x = create_text_dialog_box(4, 13, 0x1a, "A game by", "Copyright (c) 1992"); + display_dialog_text(x, 7, " Todd J Replogle"); + display_dialog_text(x + 11, 9, "and"); + display_dialog_text(x, 11, "\xfd""027 Stephen A Hornback""\xfd""004"); + display_dialog_text(x, 13, " Version 1.20"); + wait_for_time_or_key(0x2bc); + fade_to_black_speed_3(); +} +*/ + + +U0 end_game_dialog(uint16 dialog_number) { + if(get_episode_number() != 1) + { + return; + } + + flush_input(); + reset_player_control_inputs(); + if(dialog_number == 0xa6) + { + finished_game_flag_maybe = 1; + return; + } + if(dialog_number == 0xa4 || dialog_number == 0xa5) + { + uint16 x = create_text_dialog_box(2, 8, 0x1c, "", "Press any key to exit."); + if(dialog_number == 0xa4) + { + display_dialog_text(x, 4, "\xfc003 What's happening? Is\n Cosmo falling to his\n Doom?"); + } + else + { + display_dialog_text(x, 4, "\xfc003 Is there no end to this\n pit? And what danger\n awaits below?!"); + } + wait_for_input(x + 0x19, 8); + } +} + +U0 display_menu_items(I64 x_offset, MenuItem *menu_items) +{ + MenuItem *item = menu_items; + I64 i; + for(i=0; item->text != NULL; item++, i++) + { + display_dialog_text_with_color(x_offset + item->x_pos, item->y_pos, item->text, Cond(i == cur_selected_item, 2, FONT_WHITE)); + } +} + +U0 menu_handle_arrow_key(I64 key, MenuItem *items) { + I64 num_items = 0; + MenuItem *item; + for(item = items; item->text != NULL; item++) + { + num_items++; + } + + if(key == SDLK_DOWN) + { + cur_selected_item = (cur_selected_item + 1) % num_items; + } + if(key == SDLK_UP) + { + cur_selected_item = cur_selected_item - 1; + if(cur_selected_item < 0) + cur_selected_item = num_items - 1; + } + +} + +I64 display_menu_items_in_dialog(I64 x_offset, + MenuItem *menu_items, + I64 spinner_x, I64 spinner_y) +{ + cur_selected_item = 0; + I64 key = 0; + do { + display_menu_items(x_offset, menu_items); + key = wait_for_input_with_repeat(spinner_x, spinner_y, TRUE); + if (Bt(kbd.down_bitmap, SC_CURSOR_UP)) + key = SDLK_UP; + if (Bt(kbd.down_bitmap, SC_CURSOR_DOWN)) + key = SDLK_DOWN; + if(key == SDLK_UP || key == SDLK_DOWN) + { + menu_handle_arrow_key(key, menu_items); + } + } while(key == SDLK_UP || key == SDLK_DOWN); + + //if(is_return_key(key)) + if (Bt(kbd.down_bitmap, SC_ENTER)) + { + key = menu_items[cur_selected_item].action_key; + } + + return key; +} + +I64 quit_game_dialog() +{ + uint16 x = create_text_dialog_box(11, 4, 0x12, "Are you sure you", "want to quit? "); + I64 key = wait_for_input(x + 14, 13); + //if (key == SDLK_y || is_return_key(key)) + if (Bt(kbd.down_bitmap, Char2ScanCode('y')) || Bt(kbd.down_bitmap, SC_ENTER)) + { + return 1; + } + + return 0; +} + +U0 main_menu_dialog() +{ + cur_selected_item = 0; + I64 x = create_text_dialog_box(2, 0x15, 0x14, "MAIN MENU", ""); + display_menu_items(x, main_menu_items); +} + +U8 level_numbers_tbl[18] ={ 1, 2, 0, 0, 3, 4, 0, 0, 5, 6, 0, 0, 7, 8, 0, 0, 9, 10 }; +U0 now_entering_level_n_dialog(uint16 level_number) +{ + if(game_play_mode == 0) + { + uint16 x = create_text_dialog_box(7, 3, 0x18, " Now entering level ", ""); + cosmo_wait(0x14); + //play_sfx(0x40); + if(level_numbers_tbl[level_number] != 10) + { + display_number(x + 0x14, 8, level_numbers_tbl[level_number]); + } + else + { + display_number(x + 0x15, 8, level_numbers_tbl[level_number]); + } + video_update(); + } +} + +I64 main_menu() { + set_initial_game_state(); + show_one_moment_screen_flag = 0; + //load_music(0x12); + display_fullscreen_image(1); + flush_input(); + I64 i, return_to_title; + Bool key_handled = FALSE; + I64 key; + + for(i=0;i=i;i+=3) + { + if (Bt(kbd.down_bitmap, Char2ScanCode('q')) || Bt(kbd.down_bitmap, SC_ESC)) + { + if (quit_game_dialog()) + { + return QUIT_GAME; + } + } + uint16 restore_status = 0; + for(return_to_title=0;!return_to_title;) + { + main_menu_dialog(); + //key_handled = TRUE; + while(!key_handled && !return_to_title) + { + key = display_menu_items_in_dialog(11, main_menu_items, 0x1c, 0x15); + //switch(key) + //{ + //case SDLK_ESCAPE : + //case SDLK_q : + if (Bt(kbd.down_bitmap, Char2ScanCode('q')) || + Bt(kbd.down_bitmap, SC_ESC)) + { + if(quit_game_dialog()) + { + return QUIT_GAME; + } + return_to_title = 1; + i = 0; + } + + //case SDLK_b : + //case SDLK_SPACE : + if (Bt(kbd.down_bitmap, Char2ScanCode('b')) || + Bt(kbd.down_bitmap, Char2ScanCode(' '))) + { + + //stop_music(); + show_one_moment_screen_flag = 1; + show_monster_attack_hint = 0; + //play_sfx(0x30); + return PLAY_GAME; + } + + //case SDLK_r : + if (Bt(kbd.down_bitmap, Char2ScanCode('r'))) + { + //restore_status = restore_savegame_dialog(); + if(restore_status == 1) + { + //stop_music(); + return PLAY_GAME; + } + + if(restore_status == 0) + { + //missing_savegame_dialog(); + } + //break; + } + + //case SDLK_i : + if (Bt(kbd.down_bitmap, Char2ScanCode('i'))) + { + //instructions_dialog(); + } + //break; + + //case SDLK_s : + if (Bt(kbd.down_bitmap, Char2ScanCode('s'))) + { + //story_dialog(); + } + //break; + + //case SDLK_g : + if (Bt(kbd.down_bitmap, Char2ScanCode('g'))) + { + //game_redefine(); + } + //break; + + //case SDLK_F11 : + if (Bt(kbd.down_bitmap, SC_F11)) + { + //if (cheat_mode_flag) + //{ + // return RECORD_DEMO; + //} + } + //break; + + //case SDLK_o : + if (Bt(kbd.down_bitmap, Char2ScanCode('o'))) + { + //ordering_info_dialog(); + } + //break; + + //case SDLK_f : + if (Bt(kbd.down_bitmap, Char2ScanCode('f'))) + { + //foreign_orders_dialog(); + } + //break; + + //case SDLK_a : + if (Bt(kbd.down_bitmap, Char2ScanCode('a'))) + { + //apogee_bbs_dialog(); + } + //break; + + //case SDLK_d : + if (Bt(kbd.down_bitmap, Char2ScanCode('d'))) + { + return PLAY_DEMO; + } + + //case SDLK_h : + if (Bt(kbd.down_bitmap, Char2ScanCode('h'))) + { + fade_to_black_speed_3(); + video_fill_screen_with_black(); + //display_high_score_dialog(TRUE); + } + //break; + + //case SDLK_c : + if (Bt(kbd.down_bitmap, Char2ScanCode('c'))) + { + display_fullscreen_image(2); + while(poll_for_key_press(FALSE)==SDLK_UNKNOWN) + {} + } + //break; + + //case SDLK_t : + if (Bt(kbd.down_bitmap, Char2ScanCode('t'))) + { + return_to_title = 1; + i = 0; + } + //break; + + //default : + // key_handled = FALSE; + // break; + } + + if (i<600) display_fullscreen_image(1); + + } + if(i==600) + { + display_fullscreen_image(2); + } + if(i == 1200) + { + return PLAY_DEMO; + } + cosmo_wait(3); + } +} + +U0 no_bombs_dialog() { + if(game_play_mode == PLAY_GAME) + { + //play_sfx(0x1e); + uint16 x = create_text_dialog_box(2, 4, 0x1c, "", ""); + x++; + display_dialog_text(x, 3, "You haven't found any"); + display_dialog_text(x, 4, "bombs to use yet! "); + cosmo_wait(0x3c); + wait_for_input(x-1 + 0x19, 4); + } +} + +U0 power_up_module_dialog() +{ + if(game_play_mode == PLAY_GAME) + { + //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"); + display_dialog_text(si, 5, " health. "); + cosmo_wait(0x3c); + flush_input(); + wait_for_input(si + 8, 5); + } +} + +U0 monster_attack_hint_dialog() +{ + if(game_play_mode == PLAY_GAME) + { + //play_sfx(0x1e); + uint16 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); + wait_for_input(si + 0x13, 5); + si = create_text_dialog_box(2, 13, 0x14, "Like this...", "Press ANY key."); + display_dialog_text(si + 5, 9, " "); + display_dialog_text(si + 5, 11, " "); + cosmo_wait(0x3c); + wait_for_input(si + 0x11, 13); + } +} + +U0 display_score_from_level() +{ + //stop_music(); + + if(num_stars_collected == 0) + { + fade_in_from_black_with_delay_3(); + return; + } + + fade_to_white(3); + video_fill_screen_with_black(); + create_text_dialog_box(2, 0xe, 0x1e, "Super Star Bonus!!!!", ""); + + display_actor_sprite_maybe(1, 2, 8, 8, 6); + + display_dialog_text(0xe, 7, "X 1000 ="); + + display_number(0x1b, 7, num_stars_collected * 1000); + + cosmo_wait(0x32); + display_dialog_text(0xa, 0xc, "YOUR SCORE = "); + display_number(0x1d, 0xc, score); + + fade_in_from_black_with_delay_3(); + + cosmo_wait(0x64); + + I64 star_counter = 0; + I64 i, j; + for(i=num_stars_collected; i > 0; i--) + { + score += 1000; + cosmo_wait(0xf); + + for(j=0; j < 7; j++) + { + display_clear_tile_to_gray(0x17 + j, 0xc); + } + //play_sfx(1); + display_number(0x1d, 0xc, score); + + if (star_counter / 6 < 13) + { + star_counter++; + } + + for(j=0; j < 16; j++) + { + if(j < 7) + { + display_clear_tile_to_gray(0x16 + j, 7); + } + + if((star_counter & 7) == 1) + { + display_clear_tile_to_gray(0xd + j, 0xe); + + } + } + + display_number(0x1b, 7, i * 1000); + + video_update(); + + if((star_counter & 7) == 1) + { + uint8 score_text_idx = (star_counter/6); + if(score_text_idx > 12) + { + score_text_idx = 12; + } + + display_dialog_text(0xd, 0xe, score_text_tbl[score_text_idx]); + } + + video_update(); + } + + cosmo_wait(0x190); + num_stars_collected = 0; +} + +U0 display_end_of_level_score_dialog(U8 *header_text, U8 *footer_text) +{ + fade_to_black_speed_3(); + video_fill_screen_with_black(); + uint16 x = create_text_dialog_box(6, 4, 0x1e, header_text, footer_text); + fade_in_from_black_with_delay_3(); + wait_for_input(x + 0x1b, 8); + display_score_from_level(); + fade_to_black_speed_3(); + video_fill_screen_with_black(); +} + diff --git a/Effects.HC b/Effects.HC new file mode 100644 index 0000000..d4b6a00 --- /dev/null +++ b/Effects.HC @@ -0,0 +1,562 @@ +extern U8 rain_flag; +extern U0 actor_add_new(I64 image_index, I64 x_pos, I64 y_pos); +extern U0 actor_toss_add_new(I64 actorInfoIndex, I64 x_pos, I64 y_pos); +extern U16 word_2E1E2; +extern TileInfo *actor_get_tile_info(I64 actorInfoIndex, I64 frame_num); +extern I64 sprite_blocking_check(I64 blocking_dir, I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos); +extern I64 is_sprite_on_screen(I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos); +extern uint16 brightness_effect_enabled_flag; +extern U0 video_draw_highlight_effect(uint16 x, uint16 y, uint8 type); + +#define MAX_EFFECT_SPRITES 10 +#define MAX_EXPLODE_EFFECT_SPRITES 16 +#define MAX_STRUCT6_SPRITES 7 +#define MAX_BRIGHTNESS_OBJS 0xc7 + +class effect_sprite +{ + I64 is_active_flag; + I64 actorInfoIndex; + I64 frame_num; + I64 x; + I64 y; + I64 field_A; + I64 counter; +}; + +class explode_effect_sprite +{ + I64 actorInfoIndex; + I64 x; + I64 y; + I64 frame_num; + I64 counter; + I64 direction; + I64 fall_through_floor; +}; + +class struc_6 +{ + I64 counter; + I64 x; + I64 y; +}; + +class Brightness +{ + I64 type; + I64 x; + I64 y; +}; + +uint16 num_brightness_objs = 0; +Brightness brightness_tbl[MAX_BRIGHTNESS_OBJS + 1]; + +effect_sprite static_effect_sprites[MAX_EFFECT_SPRITES]; +uint16 effect_frame_num_tbl[MAX_EFFECT_SPRITES]; + +explode_effect_sprite explode_effect_sprites[MAX_EXPLODE_EFFECT_SPRITES]; + +struc_6 struc6_sprites[MAX_STRUCT6_SPRITES]; + +U0 effect_add_sprite(I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos, I64 arg_8, I64 counter) +{ + I64 i; + for(i=0;iis_active_flag) + { + sprite->is_active_flag = 1; + sprite->actorInfoIndex = actorInfoIndex; + sprite->frame_num = frame_num; + sprite->x = x_pos; + sprite->y = y_pos; + sprite->field_A = arg_8; + sprite->counter = counter; + effect_frame_num_tbl[i] = 0; + return; + } + } +} + +U0 effect_clear_sprites() +{ + I64 i; + for(i=0; i < MAX_EFFECT_SPRITES; i++) + { + static_effect_sprites[i].is_active_flag = 0; + } +} + +U0 explode_effect_add_sprite(I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos) +{ + uint8 explode_direction = 0; + I64 i; + + explode_direction++; + if(explode_direction == 5) + { + explode_direction = 0; + } + + for(i=0;i < MAX_EXPLODE_EFFECT_SPRITES; i++) + { + explode_effect_sprite *sprite = &explode_effect_sprites[i]; + + if(sprite->counter == 0) + { + sprite->actorInfoIndex = actorInfoIndex; + sprite->x = x_pos; + sprite->y = y_pos; + sprite->frame_num = frame_num; + sprite->counter = 1; + sprite->direction = explode_direction; + sprite->fall_through_floor = 0; + return; + } + } + + return ; +} + +U0 explode_effect_clear_sprites() +{ + I64 i; + for(i=0;i < MAX_EXPLODE_EFFECT_SPRITES; i++) + { + explode_effect_sprites[i].counter = 0; + } +} + +U0 update_rain_effect() //FIXME this rain doesn't look quite right. The lightning palette anim might need tweaking. +{ + + I64 x = (cosmo_rand % 38) + mapwindow_x_offset; + I64 y = (cosmo_rand % 18) + mapwindow_y_offset; + I64 map_tile_cell = map_get_tile_cell(x, y); + + if((cosmo_rand & 1) != 0) + { + if((tileattr_mni_data[map_tile_cell / 8] & TILE_ATTR_SLIPPERY) != 0) + { + effect_add_sprite(0x63, 5, x, y, 0, 1); + } + } + if(rain_flag != 0) + { + y = mapwindow_y_offset + 1; + + if(map_get_tile_cell(x, y) == 0) + { + effect_add_sprite(0x1b, 1, x, y, 6, 0x14); + } + } + return; +} + +U0 exploding_balls_effect(I64 x_pos, I64 y_pos) +{ + effect_add_sprite(0x15, 6, x_pos + 1, y_pos, 6, 2); + effect_add_sprite(0x15, 6, x_pos + 3, y_pos, 4, 2); + effect_add_sprite(0x15, 6, x_pos + 4, y_pos - 2, 3, 2); + effect_add_sprite(0x15, 6, x_pos + 3, y_pos - 4, 2, 2); + effect_add_sprite(0x15, 6, x_pos + 1, y_pos - 4, 8, 2); + effect_add_sprite(0x15, 6, x_pos, y_pos - 2, 7, 2); +} + + + +I64 blow_up_actor_with_bomb(I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos) +{ + switch (actorInfoIndex) + { + case 3: + case 4: + case 17: + case 18: + case 20: + case 25: + case 41: + case 46: + case 47: + case 51: + case 54: + case 55: + case 65: + case 69: + case 74: + case 75: + case 78: + case 80: + case 83: + case 84: + case 86: + case 87: + case 88: + case 89: + case 92: + case 95: + case 96: + case 101: + case 106: + case 111: + case 112: + case 113: + case 118: + case 124: + case 125: + case 126: + case 127: + case 128: + case 129: + case 187: + case 188: + if(actorInfoIndex == 0x7d) + { + actor_add_new(0xb8, x_pos, y_pos); + } + if((actorInfoIndex == 0x12 || actorInfoIndex == 0x58) && frame_num == 2) + { + return 0; + } + else + { + explode_effect_add_sprite(actorInfoIndex, frame_num, x_pos, y_pos); + player_add_score_for_actor(actorInfoIndex); + if(actorInfoIndex == 0x5f) + { + if(word_2E1E2 == 1) + { + actor_add_new(0xf6, player_x_pos - 1, player_y_pos - 5); + } + effect_add_sprite(0x17, 8, x_pos, y_pos, 0, 1); + actor_toss_add_new(0x39, x_pos, y_pos); + word_2E1E2--; + } + } + return 1; + + default : break; + } + + return 0; +} + +Bool struct6_collision_check_maybe(I64 actorInfoIndex1, I64 actor_frame_num1, I64 actor1_x, I64 actor1_y, I64 actorInfoIndex2, I64 actor_frame_num2, I64 actor2_x, I64 actor2_y) +{ + TileInfo *actor1_info = actor_get_tile_info(actorInfoIndex1, actor_frame_num1); + uint16 sprite1_width = actor1_info->width; + uint16 si = actor1_info->height; + + TileInfo *actor2_info = actor_get_tile_info(actorInfoIndex2, actor_frame_num2); + uint16 sprite2_width = actor2_info->width; + uint16 di = actor2_info->height; + + if(actor1_x > map_width_in_tiles && actor1_x <= -1) + { + sprite1_width = actor1_x + sprite1_width; + actor1_x = 0; + } + + if(((actor2_x > actor1_x || actor2_x + sprite2_width <= actor1_x) && (actor2_x < actor1_x || actor1_x + sprite1_width <= actor2_x)) || + ((actor1_y - si >= actor2_y || actor2_y > actor1_y) && (actor2_y - di >= actor1_y || actor1_y > actor2_y))) + { + return 0; + } + + return 1; +} + +I64 struct6_1B4FC(I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos) +{ + I64 i; + for(i=0; i < MAX_STRUCT6_SPRITES; i++) + { + struc_6 *sprite = &struc6_sprites[i]; + + if(sprite->counter != 0) + { + if(struct6_collision_check_maybe(0x1a, 0, sprite->x, sprite->y, actorInfoIndex, frame_num, x_pos, y_pos) != 0) + { + return 1; + } + } + } + + return 0; +} + +U0 struct6_clear_sprites() +{ + I64 i; + for(i=0; i < MAX_STRUCT6_SPRITES; i++) + { + struc6_sprites[i].counter = 0; + } +} + +U0 struct6_add_sprite(I64 x_pos, I64 y_pos) +{ + I64 i; + for(i=0; i < MAX_STRUCT6_SPRITES; i++) + { + struc_6 *sprite = &struc6_sprites[i]; + if (sprite->counter == 0) + { + sprite->counter = 1; + sprite->x = x_pos; + sprite->y = y_pos + 2; + //play_sfx(0xa); + return; + } + } +} + +U0 add_brightness_obj(uint8 type, I64 x_pos, I64 y_pos) +{ + if (num_brightness_objs != MAX_BRIGHTNESS_OBJS) + { + brightness_tbl[num_brightness_objs].type = type; + brightness_tbl[num_brightness_objs].x = x_pos; + brightness_tbl[num_brightness_objs].y = y_pos; + num_brightness_objs++; + } +} + +U0 clear_brightness_objs() +{ + num_brightness_objs = 0; +} + +U0 explode_effect_update_sprites() +{ + I64 i; + for(i=0;i < MAX_EXPLODE_EFFECT_SPRITES; i++) + { + explode_effect_sprite *sprite = &explode_effect_sprites[i]; + if (sprite->counter == 0) + { + goto explode_while_cont2; + } + + if(sprite->direction == 0 || sprite->direction == 3) + { + if(sprite_blocking_check(RIGHT, sprite->actorInfoIndex, sprite->frame_num, sprite->x + 1, sprite->y + 1) == NOT_BLOCKED) + { + sprite->x++; + if(sprite->direction == 3) + { + sprite->x++; + } + } + } + else + { + if(sprite->direction == 1 || sprite->direction == 4) + { + if(sprite_blocking_check(LEFT, sprite->actorInfoIndex, sprite->frame_num, sprite->x - 1, sprite->y + 1) == NOT_BLOCKED) + { + sprite->x--; + if(sprite->direction == 4) + { + sprite->x--; + } + } + } + } + + //for(;;) + while(1) + { + if(sprite->counter < 5) + { + sprite->y -= 2; + } + + if(sprite->counter == 5) + { + sprite->y--; + } + else if(sprite->counter == 8) + { + if (sprite_blocking_check(DOWN, sprite->actorInfoIndex, sprite->frame_num, sprite->x, sprite->y + 1) == + NOT_BLOCKED) + { + sprite->y++; + } + else + { + sprite->counter = 3; + sprite->y += 2; + goto explode_while_cont1; + } + } + + if(sprite->counter < 9) + { + if(sprite->counter == 1) + { + display_actor_sprite_maybe(sprite->actorInfoIndex, sprite->frame_num, sprite->x, sprite->y, 2); + } + else + { + display_actor_sprite_maybe(sprite->actorInfoIndex, sprite->frame_num, sprite->x, sprite->y, 4); + } + sprite->counter++; + if(sprite->counter > 40) + { + sprite->counter = 0; + } + break; + } + + if(sprite->counter > 16 && is_sprite_on_screen(sprite->actorInfoIndex, sprite->frame_num, sprite->x, sprite->y) == 0) + { + sprite->counter = 0; + break; + } + + if(sprite->fall_through_floor != 0 || sprite_blocking_check(DOWN, sprite->actorInfoIndex, sprite->frame_num, sprite->x, sprite->y + 1) == NOT_BLOCKED) + { + sprite->y++; + if(sprite->fall_through_floor != 0 || sprite_blocking_check(DOWN, sprite->actorInfoIndex, sprite->frame_num, sprite->x, sprite->y + 1) == NOT_BLOCKED) + { + if(sprite->counter == 1) + { + display_actor_sprite_maybe(sprite->actorInfoIndex, sprite->frame_num, sprite->x, sprite->y, 2); + } + else + { + display_actor_sprite_maybe(sprite->actorInfoIndex, sprite->frame_num, sprite->x, sprite->y, 4); + } + sprite->counter++; + if(sprite->counter > 40) + { + sprite->counter = 0; + } + break; + } + } + sprite->counter = 3; + sprite->fall_through_floor = 1; + //play_sfx(0x2e); +explode_while_cont1: + } +explode_while_cont2: + } +} + +U0 struct6_update_sprites() +{ + I64 i; + for(i=0; i < MAX_STRUCT6_SPRITES; i++) + { + struc_6 *sprite = &struc6_sprites[i]; + if(sprite->counter != 0) + { + if(sprite->counter == 1) + { + effect_add_sprite(0x17, 8, sprite->x + 1 + 1, sprite->y - 2, 0, 1); + } + + display_actor_sprite_maybe(0x1a, sprite->counter - 1 & 3, sprite->x, sprite->y, 0); + + if(player_check_collision_with_actor(0x1a, sprite->counter - 1 & 3, sprite->x, sprite->y) != 0) + { + player_decrease_health(); + } + + sprite->counter++; + if(sprite->counter == 9) + { + sprite->counter = 0; + effect_add_sprite(0x62, 6, sprite->x + 1, sprite->y - 1, 1, 1); + } + } + } +} + +U0 effect_update_sprites() +{ + I64 i; + for(i=0; i < MAX_EFFECT_SPRITES; i++) + { + effect_sprite *sprite = &static_effect_sprites[i]; + + if(sprite->is_active_flag) + { + if(is_sprite_on_screen(sprite->actorInfoIndex, sprite->frame_num, sprite->x, sprite->y)) + { + + if(sprite->actorInfoIndex == 0x63) + { + + display_actor_sprite_maybe(sprite->actorInfoIndex, effect_frame_num_tbl[i], sprite->x, sprite->y, 5); + } + else + { + display_actor_sprite_maybe(sprite->actorInfoIndex, effect_frame_num_tbl[i], sprite->x, sprite->y, 0); + } + + if(sprite->actorInfoIndex == 0x1b) + { + sprite->x--; + sprite->y = sprite->y + (cosmo_rand() % 3); + } + sprite->x = sprite->x + player_x_offset_tbl[sprite->field_A]; + sprite->y = sprite->y + player_y_offset_tbl[sprite->field_A]; + effect_frame_num_tbl[i]++; + if(effect_frame_num_tbl[i] == sprite->frame_num) + { + effect_frame_num_tbl[i] = 0; + if(sprite->counter != 0) + { + sprite->counter--; + if(sprite->counter == 0) + { + sprite->is_active_flag = 0; + } + } + } + } + else + { + sprite->is_active_flag = 0; + } + } + } + + return; +} + +U0 update_brightness_objs() +{ + if(brightness_effect_enabled_flag == 0) + return; + + I64 i, j; + for(i=0;ix >= mapwindow_x_offset && brightness->x < mapwindow_x_offset + MAP_WINDOW_WIDTH && + brightness->y >= mapwindow_y_offset && brightness->y < mapwindow_y_offset + MAP_WINDOW_HEIGHT) + { + video_draw_highlight_effect((brightness->x - mapwindow_x_offset + 1) * TILE_WIDTH, (brightness->y - mapwindow_y_offset + 1) * TILE_HEIGHT, brightness->type); + + uint16 tile_attr = tileattr_mni_data[map_get_tile_cell(brightness->x,brightness->y + 1)/8]; + for(j = 1; !(tile_attr & TILE_ATTR_BLOCK_DOWN);) + { + if(brightness->x >= mapwindow_x_offset && brightness->x < mapwindow_x_offset + MAP_WINDOW_WIDTH && + brightness->y + j >= mapwindow_y_offset && brightness->y + j < mapwindow_y_offset + MAP_WINDOW_HEIGHT) + { + video_draw_highlight_effect((brightness->x - mapwindow_x_offset + 1) * TILE_WIDTH, + (brightness->y + j - mapwindow_y_offset + 1) * TILE_HEIGHT, 1); + } + j++; + tile_attr = tileattr_mni_data[map_get_tile_cell(brightness->x,brightness->y + j)/8]; + } + } + } +} + diff --git a/File.HC b/File.HC new file mode 100644 index 0000000..5b6eabb --- /dev/null +++ b/File.HC @@ -0,0 +1,169 @@ +class File { + U8 *filename; + U8 *data; + U8 *idata; + U8 *mode; + U32 size; + U32 pos; + U32 initial_offset; +}; + +U0 file_close(File *file) { + if (!StrCmp("wb", file->mode)) + { + if(file->data) + { + FileWrite(file->filename, file->data, file->size); + } + } + if(file->idata) + { + Free(file->idata); + return; + } + if(file->data) + { + Free(file->data); + } +} + +U32 file_get_current_position(File *file) +{ + if (file) + return file->pos; + return 0; +} + +U32 file_get_filesize(File *file) +{ + if (file) + return file->size; + return 0; +} + +Bool file_open(U8 *filename, U8 *mode, File *file) { + if (!StrCmp("rb", mode)) + { + if (!FileFind(filename)) + { + "Failed opening '%s'\n", filename; + return FALSE; + } + file->filename = StrNew(filename); + file->data = FileRead(filename, &file->size); + file->idata = NULL; + file->mode = StrNew(mode); + file->pos = 0; + file->initial_offset = 0; + return TRUE; + } + + // FIXME: add "wb" mode + if (!StrCmp("wb", mode)) + { + file->filename = StrNew(filename); + file->data = CAlloc(WB_SIZE); + file->idata = NULL; + file->mode = StrNew(mode); + file->pos = 0; + file->size = 0; + file->initial_offset = 0; + return TRUE; + } + + return FALSE; +} + +Bool file_open_at_offset(U8 *filename, U8 *mode, File *file, uint32 offset, uint32 size) +{ + if (!file_open(filename, mode, file)) + { + "Failed opening '%s'\n", filename; + return FALSE; + } + + if(offset + size >= file->size) + { + "Failed opening '%s' offset + size >= actual_size\n", filename; + file_close(file); + return FALSE; + } + + file->idata = file->data; + file->data = file->idata + offset; + file->size = size; + file->pos = 0; + //file->pos = offset; + return TRUE; +} + +U0 file_seek(File *file, uint32 new_position) { + if(file->data && new_position <= file->size) + { + file->pos = new_position; + } + + return; +} + +U32 file_read_to_buffer(File *file, U8 *buf, uint32 num_bytes) { + if(file->pos + num_bytes > file->size) + num_bytes = file->size - file->pos; + + MemCpy(buf, file->data + file->pos, num_bytes); + file->pos += num_bytes; + + return num_bytes; +} + +U8 file_read1(File *file) { + if(!file->data || file->pos >= file->size) + return 0; + + U64 b0 = file->data[file->pos++]; + return b0; +} + +U16 file_read2(File *file) { + if(!file->data || file->pos >= file->size) + return 0; + + U64 b0 = file->data[file->pos++]; + U64 b1 = file->data[file->pos++]; + return (b0 + (b1<<8)); +} + +U32 file_read4(File *file) { + if(!file->data || file->pos >= file->size) + return 0; + + U64 b0 = file->data[file->pos++]; + U64 b1 = file->data[file->pos++]; + U64 b2 = file->data[file->pos++]; + U64 b3 = file->data[file->pos++]; + return (b0 + (b1<<8) + (b2<<16) + (b3<<24)); +} + +U0 file_write1(U8 byte, File *file) { + file->data[file->pos++] = byte; + if(file->pos > file->size) + file->size = file->pos; +} + +U0 file_write2(U16 word, File *file) +{ + file->data[file->pos++] = word & 0xff; + file->data[file->pos++] = (word >> 8) & 0xff; + if(file->pos > file->size) + file->size = file->pos; +} + +U0 file_write4(U32 double_word, File *file) +{ + file->data[file->pos++] = double_word & 0xff; + file->data[file->pos++] = (double_word >> 8) & 0xff; + file->data[file->pos++] = (double_word >> 16) & 0xff; + file->data[file->pos++] = (double_word >> 24) & 0xff; + if(file->pos > file->size) + file->size = file->pos; +} \ No newline at end of file diff --git a/Font.HC b/Font.HC new file mode 100644 index 0000000..db7914e --- /dev/null +++ b/Font.HC @@ -0,0 +1,57 @@ +extern U0 video_draw_font_tile(Tile *tile, uint16 x, uint16 y, uint8 font_color); + +#define FONT_WHITE 0xf + +Tile *font_tiles; + +U0 font_load_tiles() +{ + uint16 num_tiles; + font_tiles = load_tiles("FONTS.MNI", FONT, &num_tiles); + "Loading %d font tiles.\n", num_tiles; +} + +U0 display_number(I64 x_pos, I64 y_pos, uint32 number) +{ + uint8 font_color = FONT_WHITE; + I64 i; + U8 buf[32]; + StrPrint(buf, "%d", number); + for(i=0;i < StrLen(buf); i++) + { + video_draw_font_tile(&font_tiles[buf[i]-48+26], (x_pos - StrLen(buf) + i + 1) * 8, y_pos * 8, font_color); + } +} + +U0 display_char(I64 x_pos, I64 y_pos, U8 c, uint8 font_color) +{ + if(c == 0x18 || c == 0x19 || c == 0x1b || c == 0x1c) //FIXME hack to get arrow key font to render. + { + video_draw_font_tile(&font_tiles[c-25 + 3], x_pos * 8, y_pos * 8, font_color); + return; + } + + if(c >= 32 && c < 91) + { + video_draw_font_tile(&font_tiles[c-48+26], x_pos * 8, y_pos * 8, font_color); + } + else + { + video_draw_font_tile(&font_tiles[c-97+69], x_pos * 8, y_pos * 8, font_color); + } +} + +U0 display_text_with_color(I64 x_pos, I64 y_pos, U8 *text, uint8 color) +{ + I64 len = StrLen(text); + I64 i; + for(i=0; i < len; i++) + { + display_char(x_pos + i, y_pos, text[i], color); + } +} + +U0 display_text(I64 x_pos, I64 y_pos, U8 *text) +{ + display_text_with_color(x_pos, y_pos, text, 0xf); +} diff --git a/Fullscreen_Image.HC b/Fullscreen_Image.HC new file mode 100644 index 0000000..f276f42 --- /dev/null +++ b/Fullscreen_Image.HC @@ -0,0 +1,90 @@ +extern U0 video_draw_fullscreen_image(uint8 *pixels); + +U8 filename_ep1_tbl[6][13] = { + "PRETITLE.MNI", + "TITLE1.MNI", + "CREDIT.MNI", + "BONUS.MNI", + "END1.MNI", + "ONEMOMNT.MNI" +}; +U8 filename_ep2_tbl[6][13] = { + "PRETITLE.MNI", + "TITLE2.MNI", + "CREDIT.MNI", + "BONUS.MNI", + "END2.MNI", + "ONEMOMNT.MNI" +}; +U8 filename_ep3_tbl[6][13] = { + "PRETITLE.MNI", + "TITLE3.MNI", + "CREDIT.MNI", + "BONUS.MNI", + "END3.MNI", + "ONEMOMNT.MNI" +}; + +#define NUM_PIXELS (320 * 200) + +U8 *get_filename(uint8 image_number) +{ + switch(get_episode_number()) + { + case 1 : return filename_ep1_tbl[image_number]; + case 2 : return filename_ep2_tbl[image_number]; + case 3 : return filename_ep3_tbl[image_number]; + default : break; + } + return NULL; +} + +U8 *load_image(U8 *filename) +{ + uint8 *pixels = MAlloc(320*200); + I64 c, i, j; + + File image; + if(!open_file(filename, &image)) { + "failed to open %s\n", filename; + } + + for(c=0;c<4;c++) { + + for (i = 0; i < NUM_PIXELS / 8; i++) { + uint8 data = file_read1(&image); + for (j = 0; j < 8; j++) { + if(c==0) + { + pixels[i * 8 + j] = (data >> (7 - j)) & 1; + } + else + { + pixels[i * 8 + j] |= ((data >> (7 - j)) & 1) << c; + } + } + } + } + file_close(&image); + + return pixels; +} + +U0 display_fullscreen_image(uint8 image_number) +{ + //assert(image_number < 6); + + if(image_number != 1 && image_number != 2) + { + //stop_music(); + } + + fade_to_black_speed_3(); + + uint8 *image = load_image(get_filename(image_number)); + video_draw_fullscreen_image(image); + Free(image); + + fade_in_from_black_with_delay_3(); + +} diff --git a/Game.HC b/Game.HC new file mode 100644 index 0000000..44ce2c8 --- /dev/null +++ b/Game.HC @@ -0,0 +1,356 @@ +extern I64 palette_index; +extern I64 palette_2E1EE; +extern U0 update_palette_anim(); +extern U0 fade_to_black(uint16 wait_time); + +#define COSMO_INTERVAL 100 + +//Data +I64 game_play_mode = PLAY_GAME; +uint32 score; +uint32 num_stars_collected; +I64 cheats_used_flag = 0; +I64 knows_about_powerups_flag; +I64 finished_game_flag_maybe = 0; +I64 finished_level_flag_maybe; +I64 cheat_mode_flag = 0; + +uint8 episode_number = 1; +Bool quick_start_mode = FALSE; + +U8 get_episode_number() +{ + return episode_number; +} + +Bool is_quick_start() +{ + return quick_start_mode; +} + +U0 set_initial_game_state() +{ + score = 0; + health = 4; + num_health_bars = 3; + current_level = 0; + num_bombs = 0; + num_stars_collected = 0; + cheats_used_flag = 0; + has_had_bomb_flag = 0; + knows_about_powerups_flag = 0; + return; +} + +U0 reset_game_state() +{ + finished_game_flag_maybe = 0; + player_hanging_on_wall_direction = 0; + byte_2E2E4 = 1; + player_input_jump_related_flag = 1; + byte_2E182 = 0; + word_2E180 = 1; + player_bounce_flag_maybe = 0; + player_bounce_height_counter = 0; + player_direction_related_32E98 = 3; + player_sprite_dir_frame_offset = 0; + player_direction = 0x17; + player_death_counter = 0; + finished_level_flag_maybe = 0; + player_invincibility_counter = 0x28; + teleporter_counter = 0; + teleporter_state_maybe = 0; + player_in_pneumatic_tube_flag = 0; + player_hoverboard_counter = 0; + player_is_teleporting_flag = 0; + word_32EAC = 0; + energy_beam_enabled_flag = 1; + byte_2E17C = 0; + + sub_11062(); + + hide_player_sprite = 0; + move_platform_flag = 1; + byte_32EB8 = 0; + palette_2E1EE = 0; + palette_index = 0; + word_32EC2 = 0; + player_fall_off_map_bottom_counter = 0; + word_28BEA = 0; + byte_2E21C = 0; + word_2E1E4 = 0; + word_2E1E2 = 0; + num_hits_since_touching_ground = 0; + + //Actor values + word_2E22A = 0; + word_2E236 = 0; + word_2E228 = 0; + word_2E220 = 0; + word_2E238 = 0; + word_2E21E = 0; + word_2E24C = 0; + word_2E23C = 0; + word_2E232 = 0; + word_2E234 = 0; + word_2E246 = 0; + return; +} + +U0 game_init() +{ + if(!is_quick_start()) + { + display_fullscreen_image(0); + wait_for_time_or_key(0xc8); + } + + //load_config_file(); + + status_load_tiles(); + tile_attr_load(); + player_load_tiles(); + actor_load_tiles(); + map_load_tiles(); + load_cartoon_images(); + font_load_tiles(); + //load_sfx(); +} + +U8 *get_game_vol_filename() +{ + switch(get_episode_number()) + { + case 1 : return "COSMO1.VOL"; + case 2 : return "COSMO2.VOL"; + case 3 : return "COSMO3.VOL"; + default : break; + } + + return NULL; +} + +U8 *get_game_stn_filename() +{ + switch(get_episode_number()) + { + case 1 : return "COSMO1.STN"; + case 2 : return "COSMO2.STN"; + case 3 : return "COSMO3.STN"; + default : break; + } + + return NULL; +} + +Bool open_file(U8 *filename, File *file) +{ + if(vol_file_open(get_game_vol_filename(), filename, file)) + { + return TRUE; + } + + return vol_file_open(get_game_stn_filename(), filename, file); +} + +U8 *load_file(U8 *filename, U8 *buf, uint32 buf_size) +{ + uint32 bytes_read; + if(vol_file_load(get_game_vol_filename(), filename, buf, buf_size, &bytes_read)) + { + return buf; + } + + return vol_file_load(get_game_stn_filename(), filename, buf, buf_size, &bytes_read); +} + +U0 select_next_level() +{ + uint32 tmp_num_stars_collected = num_stars_collected; + if (game_play_mode == PLAY_GAME) + { + switch (current_level) + { + case 2: + case 6: + case 10: + case 14: + case 18: + case 22: + case 26: + display_end_of_level_score_dialog("Bonus Level Completed!!", "Press ANY key."); + current_level += 2; + break; + + case 3: + case 7: + case 11: + case 15: + case 19: + case 23: + case 27: + display_end_of_level_score_dialog("Bonus Level Completed!!", "Press ANY key."); + current_level++; + break; + + case 0: + case 4: + case 8: + case 12: + case 16: + case 20: + case 24: + current_level++; + break; + + case 1: + case 5: + case 9: + case 13: + case 17: + case 21: + case 25: + display_end_of_level_score_dialog("Section Completed!", "Press ANY key."); + if(tmp_num_stars_collected <= 24) + { + current_level += 3; + } + else + { + fade_to_black(0); + display_fullscreen_image(3); + //play_sfx(0x2d); + if(tmp_num_stars_collected > 49) + { + current_level++; + } + current_level++; + cosmo_wait(0x96); + } + break; + + default: break; + } + } + else //DEMO Mode + { + switch (current_level) + { + case 0: + current_level = 13; + break; + + case 13: + current_level = 5; + break; + + case 5: + current_level = 9; + break; + + case 9: + current_level = 0x10; + break; + } + } +} + + +Bool executeTick() { + I64 input_state = 0; + + update_palette_anim(); + + input_state = read_input(); + //if (input_state == QUIT) { + // return FALSE; + //} + + //if (input_state == PAUSED) { + // return TRUE; + //} + + + handle_player_input_maybe(); + if (player_hoverboard_counter != 0) + { + player_hoverboard_update(); + } + + if (word_32EB2 != 0 || player_walk_anim_index != 0) + { + player_update_walk_anim(); //TODO check name I think this might be fall anim + } + + update_moving_platforms(); + + update_mud_fountains(); + + map_display(); + + //player_update_sprite(); + + if (player_update_sprite() != 0) { + return TRUE; + } + + display_mud_fountains(); + + actor_update_all(); + + explode_effect_update_sprites(); + + actor_toss_update(); + + update_rain_effect(); + + struct6_update_sprites(); + + effect_update_sprites(); + + update_brightness_objs(); + + if (game_play_mode != PLAY_GAME) + { + display_actor_sprite_maybe(0x10a, 0, 17, 4, 6); //DEMO sign. + } + + if (show_monster_attack_hint == 1) + { + show_monster_attack_hint = 2; + monster_attack_hint_dialog(); + } + + video_update(); + + if (finished_level_flag_maybe) + { + finished_level_flag_maybe = 0; + //play_sfx(11); + select_next_level(); + load_level(current_level); + } + + if (finished_game_flag_maybe) + { + //end_sequence(); + return FALSE; + } + + return TRUE; +} + +U0 game_wait() +{ + Sleep(100); +} + +U0 game_loop() +{ + while (1) + { + executeTick(); + game_wait(); + } +} + diff --git a/Input.HC b/Input.HC new file mode 100644 index 0000000..cc3b89f --- /dev/null +++ b/Input.HC @@ -0,0 +1,115 @@ +//input_state_enum +#define QUIT 0 +#define PAUSED 1 +#define CONTINUE 2 + +//InputCommand +#define CMD_KEY_UP 0 +#define CMD_KEY_DOWN 1 +#define CMD_KEY_LEFT 2 +#define CMD_KEY_RIGHT 3 +#define CMD_KEY_JUMP 4 +#define CMD_KEY_BOMB 5 +#define CMD_KEY_OTHER 6 + +#define SDLK_UNKNOWN 0 + +uint8 bomb_key_pressed = 0; +uint8 jump_key_pressed = 0; +uint8 up_key_pressed = 0; +uint8 down_key_pressed = 0; +uint8 left_key_pressed = 0; +uint8 right_key_pressed = 0; + +//This is needed because the game manipulates up_key_pressed as part of the hover board logic. This is the actual +//key pressed state. +uint8 input_up_key_pressed = 0; + +uint8 byte_2E17C; //modifies the left, right and jump key presses + +U0 cosmo_wait(I64 delay) +{ + Sleep(8 * delay); +} + +U0 flush_input() +{ + FifoI64Flush(kbd.scan_code_fifo); +} + +U0 reset_player_control_inputs() +{ + up_key_pressed = 0; + input_up_key_pressed = 0; + down_key_pressed = 0; + left_key_pressed = 0; + right_key_pressed = 0; + bomb_key_pressed = 0; + jump_key_pressed = 0; +} + +I64 poll_for_key_press(I64 keycode) +{ + //FIXME: implementation + return SDLK_UNKNOWN; +} + +U0 wait_for_time_or_key(I64 delay_in_game_cycles) +{ + //FIXME: implementation wait for key + cosmo_wait(delay_in_game_cycles); +} + +I64 read_input() +{ + if (Bt(kbd.down_bitmap, SC_CURSOR_UP)) + { + up_key_pressed = 1; + } + else + { + up_key_pressed = 0; + } + if (Bt(kbd.down_bitmap, SC_CURSOR_DOWN)) + { + down_key_pressed = 1; + } + else + { + down_key_pressed = 0; + } + if (Bt(kbd.down_bitmap, SC_CURSOR_LEFT)) + { + left_key_pressed = 1; + } + else + { + left_key_pressed = 0; + } + if (Bt(kbd.down_bitmap, SC_CURSOR_RIGHT)) + { + right_key_pressed = 1; + } + else + { + right_key_pressed = 0; + } + if (Bt(kbd.down_bitmap, SC_ALT)) + { + jump_key_pressed = 1; + } + else + { + jump_key_pressed = 0; + } + if (Bt(kbd.down_bitmap, Char2ScanCode(' '))) + { + bomb_key_pressed = 1; + } + else + { + bomb_key_pressed = 0; + } + + return CONTINUE; +} \ No newline at end of file diff --git a/Main.HC b/Main.HC new file mode 100644 index 0000000..cd24b41 --- /dev/null +++ b/Main.HC @@ -0,0 +1,93 @@ +I64 cleanup_and_exit() +{ + //write_config_file(); + //video_shutdown(); + //audio_shutdown(); + //SDL_Quit(); + + Fs->draw_it = NULL; + DCFill(gr.dc, TRANSPARENT); + return 0; +} + +I64 main(...) +{ + + //load_config_from_command_line(argc, argv); + video_init(); + Fs->draw_it = &video_draw_it; + game_init(); + + + //audio_init(); + + video_fill_screen_with_black(); + + //a_game_by_dialog(); + uint16 x = create_text_dialog_box(4, 13, 0x1a, "A game by", "Copyright (c) 1992"); + display_dialog_text(x, 7, " Todd J Replogle"); + display_dialog_text(x + 11, 9, "and"); + display_dialog_text(x, 11, " Stephen A Hornback"); + display_dialog_text(x, 13, " Version 1.20"); + //wait_for_time_or_key(0x2bc); + + + + //game_play_mode = main_menu(); + + show_one_moment_screen_flag = 1; + show_monster_attack_hint = 0; + //play_sfx(0x30); + set_initial_game_state(); + game_play_mode = PLAY_GAME; + + video_update; + wait_for_time_or_key(0x2bc); + //fade_to_black_speed_3(); + + /* + if(!is_quick_start()) + { + + + // + } + else + { + game_play_mode = PLAY_GAME; + } + */ + + while(game_play_mode != QUIT_GAME) + { + load_level(current_level); + //if(game_play_mode == PLAY_DEMO) + //{ + // load_demo(); + //} + + //Spawn(&game_loop,,,2); + //while (1) { Sleep(1); }; + game_loop(); + //stop_music(); + /* + if(game_play_mode == PLAY_GAME) + { + //show_high_scores(); + } + game_play_mode = main_menu(); + */ + } + + //stop_music(); + //display_exit_text(); + + return cleanup_and_exit(); + + + + + +} + +main; \ No newline at end of file diff --git a/Map.HC b/Map.HC new file mode 100644 index 0000000..881a7e3 --- /dev/null +++ b/Map.HC @@ -0,0 +1,362 @@ +extern U0 video_draw_tile(Tile *tile, uint16 x, uint16 y); +extern U8 palette_anim_type; +extern U0 reset_game_state(); + +#define MAX_MAP_TILES 32768 +//Data +uint16 current_level; + +I64 map_width_in_tiles = 0; +I64 map_stride_bit_shift_amt; +I64 mapwindow_x_offset = 0; +I64 mapwindow_y_offset = 0; +I64 map_max_y_offset = 0; + +uint8 rain_flag = 0; + +uint16 map_data[MAX_MAP_TILES]; + +Tile *map_bg_tiles; +Tile *map_fg_tiles; + +uint16 map_get_tile_cell(I64 x, I64 y) { + if (x + y * map_width_in_tiles >= MAX_MAP_TILES) + { + return 0; + } + + return map_data[x + y * map_width_in_tiles]; +} + +U8 level_filename_ep1_tbl[30][13] = { + "A1.MNI", + "A2.MNI", + "BONUS1.MNI", + "BONUS2.MNI", + "A3.MNI", + "A4.MNI", + "BONUS1.MNI", + "BONUS2.MNI", + "A5.MNI", + "A6.MNI", + "BONUS1.MNI", + "BONUS2.MNI", + "A7.MNI", + "A8.MNI", + "BONUS1.MNI", + "BONUS2.MNI", + "A9.MNI", + "A10.MNI", + "BONUS1.MNI", + "BONUS2.MNI", + "A11.MNI", + "A12.MNI", + "BONUS1.MNI", + "BONUS2.MNI", + "A13.MNI", + "A14.MNI", + "BONUS1.MNI", + "BONUS2.MNI", + "A15.MNI", + "A16.MNI" +}; + +U8 level_filename_ep2_tbl[30][13] = { + "B1.MNI", + "B2.MNI", + "BONUS3.MNI", + "BONUS4.MNI", + "B3.MNI", + "B4.MNI", + "BONUS3.MNI", + "BONUS4.MNI", + "B5.MNI", + "B6.MNI", + "BONUS3.MNI", + "BONUS4.MNI", + "B7.MNI", + "B8.MNI", + "BONUS3.MNI", + "BONUS4.MNI", + "B9.MNI", + "B10.MNI", + "BONUS3.MNI", + "BONUS4.MNI", + "B11.MNI", + "B12.MNI", + "BONUS3.MNI", + "BONUS4.MNI", + "B13.MNI", + "B14.MNI", + "BONUS3.MNI", + "BONUS4.MNI", + "B15.MNI", + "B16.MNI" +}; + +U8 level_filename_ep3_tbl[30][13] = { + "C1.MNI", + "C2.MNI", + "BONUS5.MNI", + "BONUS6.MNI", + "C3.MNI", + "C4.MNI", + "BONUS5.MNI", + "BONUS6.MNI", + "C5.MNI", + "C6.MNI", + "BONUS5.MNI", + "BONUS6.MNI", + "C7.MNI", + "C8.MNI", + "BONUS5.MNI", + "BONUS6.MNI", + "C9.MNI", + "C10.MNI", + "BONUS5.MNI", + "BONUS6.MNI", + "C11.MNI", + "C12.MNI", + "BONUS5.MNI", + "BONUS6.MNI", + "C13.MNI", + "C14.MNI", + "BONUS5.MNI", + "BONUS6.MNI", + "C15.MNI", + "C16.MNI" +}; + +U8 *get_level_filename(I64 level_number) +{ + switch(get_episode_number) + { + case 1 : return level_filename_ep1_tbl[level_number]; + case 2 : return level_filename_ep2_tbl[level_number]; + case 3 : return level_filename_ep3_tbl[level_number]; + default : break; + } + return NULL; +} + +U0 map_load_tiles() +{ + uint16 num_tiles; + map_bg_tiles = load_tiles("TILES.MNI", SOLID, &num_tiles); + "Loading %d map bg tiles.\n", num_tiles; + map_fg_tiles = load_tiles("MASKTILE.MNI", TRANSPARENT, &num_tiles); + "Loading %d map fg tiles.\n", num_tiles; +} + +U0 map_write_tile_cell(uint16 map_tile_cell, I64 x, I64 y) +{ + map_data[x + y * map_width_in_tiles] = map_tile_cell; +} + +U0 map_write_row_of_tiles(uint16 map_tile_cell, uint16 length_in_tiles, I64 x, I64 y) { + //assert(x + length_in_tiles < map_width_in_tiles); + I64 i; + for(i = 0; i < length_in_tiles; i++) + { + map_write_tile_cell(map_tile_cell, x + i, y); + } +} + +U0 write_tile_row_to_tilemap(uint16 map_tile_cell, + uint16 map_tile_cell2, + uint16 map_tile_cell3, + uint16 map_tile_cell4, + I64 x, + I64 y) +{ + map_write_tile_cell(map_tile_cell, x, y); + map_write_tile_cell(map_tile_cell2, x + 1, y); + map_write_tile_cell(map_tile_cell3, x + 2, y); + map_write_tile_cell(map_tile_cell4, x + 3, y); +} + +Tile *map_get_bg_tile(uint16 tile_num) { + return &map_bg_tiles[tile_num]; +} + +U0 map_display() { + if(mapwindow_y_offset > map_max_y_offset) + mapwindow_y_offset = map_max_y_offset; + + I64 x, y; + uint16 tile; + + backdrop_display(); + for(y=0; y < MAP_WINDOW_HEIGHT; y++) + { + for(x=0; x < MAP_WINDOW_WIDTH; x++) + { + uint16 map_cell = map_data[(x+mapwindow_x_offset) + (y+mapwindow_y_offset) * map_width_in_tiles]; + if(map_cell < 16000) + { + tile = map_cell/8; + if(tile > 9) // The first 10 tiles aren't shown. They are arrows for moving platform debug. + { + video_draw_tile(&map_bg_tiles[tile], (x+1)*8, (y+1)*8); + } + } + else + { + tile = ((map_cell/8) - 2000) / 5; + video_draw_tile(&map_fg_tiles[tile], (x+1)*8, (y+1)*8); + } + } + } +} + +U0 load_level_data(I64 level_number) +{ + byte_28BE3 = 0; + File map_file; + I64 i, j; + if(!open_file(get_level_filename(level_number), &map_file)) + { + "Error: loading level data. %s\n", get_level_filename(level_number); + return; + } + + file_seek(&map_file, 2); + map_width_in_tiles = file_read2(&map_file); + + "map width (in tiles): %d\n", map_width_in_tiles; + + switch(map_width_in_tiles) + { + case 32: map_stride_bit_shift_amt = 5; break; + case 64: map_stride_bit_shift_amt = 6; break; + case 128: map_stride_bit_shift_amt = 7; break; + case 256: map_stride_bit_shift_amt = 8; break; + case 512: map_stride_bit_shift_amt = 9; break; + case 1024: map_stride_bit_shift_amt = 10; break; + case 2048: map_stride_bit_shift_amt = 11; break; + default: break; + } + + + uint16 actor_data_size_in_words = file_read2(&map_file); + + total_num_actors = 0; + num_moving_platforms = 0; + num_mud_fountains = 0; + clear_brightness_objs(); + brightness_effect_enabled_flag = 1; + obj_switch_151_flag = 0; + + for(i=0;i< actor_data_size_in_words/3;i++) + { + uint16 actor_type = file_read2(&map_file); + uint16 x = file_read2(&map_file); + uint16 y = file_read2(&map_file); + if(total_num_actors < MAX_ACTORS) + { + load_actor(total_num_actors, actor_type, x, y); + } + } + + for(i=0;i < MAX_MAP_TILES - 4; i++) + { + map_data[i] = file_read2(&map_file); + } + + for(i=0;i> 8 & 7); + uint16 music_index = ((level_flags >> 11) & 0x1f); + + "Level %d: rain=%d, backdrop_index=%d, bg_x_scroll=%d, bg_y_scroll=%d, pal_anim_type=%d, music_index=%d\n", current_level, rain_flag, backdrop_index, background_x_scroll_flag, background_y_scroll_flag, palette_anim_type, music_index; + reset_game_state(); + + set_backdrop(backdrop_index); + + load_level_data(level_number); + + if (level_number == 0 && show_one_moment_screen_flag != 0) { + fade_to_black_speed_3(); + show_one_moment_screen_flag = 0; + } + if (game_play_mode == 0) { + switch (level_number) { + case 0: + case 1: + case 4: + case 5: + case 8: + case 9: + case 12: + case 13: + case 16: + case 17: + video_fill_screen_with_black(); + fade_in_from_black_with_delay_3(); + now_entering_level_n_dialog(level_number); + wait_for_time_or_key(0x96); + fade_to_black_speed_3(); + break; + default: + break; + } + } + explode_effect_clear_sprites(); + struct6_clear_sprites(); + effect_clear_sprites(); + player_reset_push_variables(); + actor_toss_clear_all(); + status_panel_init(); + + //write_savegame_file('T'); + //load_music(music_index); + + //I Don't think this will be needed. + +// if (byte_32FEA == 0) { +// gvar_32D12 = REGISTER_29; +// tileattr_mni_data = &ptr + 0x1388; +// word_28BE4 = 0x1111; +// load_tileattr_mni("TILEATTR.MNI", REGISTER_32); +// } + + fade_in_from_black_with_delay_3(); +} \ No newline at end of file diff --git a/Palette.HC b/Palette.HC new file mode 100644 index 0000000..c2277cd --- /dev/null +++ b/Palette.HC @@ -0,0 +1,139 @@ +CBGR48 orig_palette; +//GrPaletteGet(&orig_palette); + +I64 next_pal_colour = 0; +U8 palette_anim_type = 0; +I64 palette_index = 0; +I64 palette_2E1EE = 0; + +U8 ega_palette[64][3]= +{ + {0x00,0x00,0x00}, {0x00,0x00,0xaa}, {0x00,0xaa,0x00}, {0x00,0xaa,0xaa}, {0xaa,0x00,0x00}, {0xaa,0x00,0xaa}, {0xaa,0x55,0x00}, {0xaa,0xaa,0xaa}, + {0x00,0x00,0x00}, {0x00,0x00,0xaa}, {0x00,0xaa,0x00}, {0x00,0xaa,0xaa}, {0xaa,0x00,0x00}, {0xaa,0x00,0xaa}, {0xaa,0x55,0x00}, {0xaa,0xaa,0xaa}, + {0x55,0x55,0x55}, {0x55,0x55,0xff}, {0x55,0xff,0x55}, {0x55,0xff,0xff}, {0xff,0x55,0x55}, {0xff,0x55,0xff}, {0xff,0xff,0x55}, {0xff,0xff,0xff}, + {0x55,0x55,0x55}, {0x55,0x55,0xff}, {0x55,0xff,0x55}, {0x55,0xff,0xff}, {0xff,0x55,0x55}, {0xff,0x55,0xff}, {0xff,0xff,0x55}, {0xff,0xff,0xff}, + {0x00,0x00,0x00}, {0x00,0x00,0xaa}, {0x00,0xaa,0x00}, {0x00,0xaa,0xaa}, {0xaa,0x00,0x00}, {0xaa,0x00,0xaa}, {0xaa,0x55,0x00}, {0xaa,0xaa,0xaa}, + {0x00,0x00,0x00}, {0x00,0x00,0xaa}, {0x00,0xaa,0x00}, {0x00,0xaa,0xaa}, {0xaa,0x00,0x00}, {0xaa,0x00,0xaa}, {0xaa,0x55,0x00}, {0xaa,0xaa,0xaa}, + {0x55,0x55,0x55}, {0x55,0x55,0xff}, {0x55,0xff,0x55}, {0x55,0xff,0xff}, {0xff,0x55,0x55}, {0xff,0x55,0xff}, {0xff,0xff,0x55}, {0xff,0xff,0xff}, + {0x55,0x55,0x55}, {0x55,0x55,0xff}, {0x55,0xff,0x55}, {0x55,0xff,0xff}, {0xff,0x55,0x55}, {0xff,0x55,0xff}, {0xff,0xff,0x55}, {0xff,0xff,0xff} +}; + +U8 palette_anim_type_1_tbl[52] = +{ + 0x04, 0x04, 0x0C, 0x0C, 0x0E, 0x0E, 0x0F, 0x0F, 0x0E, 0x0E, + 0x0C, 0x0C, 0xFF, 0x00, 0x00, 0x04, 0x04, 0x0C, 0x04, 0x04, + 0x00, 0x00, 0x02, 0x02, 0x0A, 0x02, 0x02, 0x00, 0x00, 0x01, + 0x01, 0x09, 0x01, 0x01, 0xFF, 0x00, 0x00, 0x08, 0x07, 0x0F, + 0x07, 0x08, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x04, + 0x0D, 0xFF +}; + +U8 palette_anim_type_2_tbl[22] = +{ + 0x00, 0x00, 0x04, 0x04, 0x0C, 0x04, 0x04, 0x00, 0x00, 0x02, + 0x02, 0x0A, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x09, 0x01, + 0x01, 0xFF +}; + +U8 palette_anim_type_3_tbl[8] = +{ + 0x00, 0x00, 0x08, 0x07, 0x0F, 0x07, 0x08, 0xFF +}; + +U8 palette_anim_type_4_tbl[9] = +{ + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x04, 0x0D, 0xFF +}; + +CBGR48 get_ega_color(U8 ega) +{ + CBGR48 c; +// c.r = 85 * (((ega >> 1) & 2) + ((ega >> 5) & 1)); +// c.g = 85 * (( ega & 2) + ((ega >> 4) & 1)); +// c.b = 85 * (((ega << 1) & 2) + ((ega >> 3) & 1)); + + c.b.u8[0] = ega_palette[ega][2]; + c.b.u8[1] = ega_palette[ega][2]; + c.g.u8[0] = ega_palette[ega][1]; + c.g.u8[1] = ega_palette[ega][1]; + c.r.u8[0] = ega_palette[ega][0]; + c.r.u8[1] = ega_palette[ega][0]; + return c; +} + +U0 set_palette_color(I64 pal_reg, I64 ega) +{ + GrPaletteColorSet(pal_reg, get_ega_color(ega)); +} + +U0 palette_cycle_reg_5_from_tbl(U8 *palette_cycle_tbl_ptr) +{ + palette_index++; + //FIXME need to hook up palette_2E1EE into this logic. + + if (palette_cycle_tbl_ptr[palette_index] == 0xff) + { + palette_index = 0; + } + + if (palette_cycle_tbl_ptr[palette_index] >= 8) + { + set_palette_color(5, (palette_cycle_tbl_ptr[palette_index] + 8)); + } + else + { + set_palette_color(5, palette_cycle_tbl_ptr[palette_index]); + } + + return; +} + +U0 update_palette_anim() +{ + switch (palette_anim_type - 1) + { + case 0: + if (next_pal_colour == 2) + { + next_pal_colour = 0; + set_palette_color(5, 0x10); + return; + } + if (next_pal_colour == 1) + { + next_pal_colour = 2; + set_palette_color(5, 7); + return; + } + if (cosmo_rand() >= 0x5dc) + { + set_palette_color(5, 0); + next_pal_colour = 0; + } + else + { + set_palette_color(5, 0x17); + //play_sfx(0x3c); + next_pal_colour = 1; + } + break; + + case 1: + palette_cycle_reg_5_from_tbl(palette_anim_type_1_tbl); + break; + + case 2: + palette_cycle_reg_5_from_tbl(palette_anim_type_2_tbl); + break; + + case 3: + palette_cycle_reg_5_from_tbl(palette_anim_type_3_tbl); + break; + + case 4: + palette_cycle_reg_5_from_tbl(palette_anim_type_4_tbl); + break; + } + + return; +} \ No newline at end of file diff --git a/Platforms.HC b/Platforms.HC new file mode 100644 index 0000000..18b507a --- /dev/null +++ b/Platforms.HC @@ -0,0 +1,144 @@ +extern U0 map_write_tile_cell(uint16 map_tile_cell, I64 x, I64 y); +extern U0 display_actor_sprite_maybe(I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos, I64 tile_display_func_index); +extern U16 num_moving_platforms; +extern U8 move_platform_flag; + +class MovingPlatform +{ + uint16 x; + uint16 y; + uint16 map_tiles[5]; +}; + +class MudFountain +{ + uint16 x; + uint16 y; + uint16 direction; + uint16 length_counter; + uint16 current_height; + uint16 max_height; + uint16 pause_counter; +}; + +uint16 num_mud_fountains = 0; +MovingPlatform moving_platform_tbl[10]; +MudFountain mud_fountain_tbl[10]; + +U0 update_mud_fountains() +{ + I64 si; + for(si=0;si < num_mud_fountains; si++) + { + MudFountain *mud_fountain = &mud_fountain_tbl[si]; + if(mud_fountain->pause_counter == 0) + { + mud_fountain->length_counter++; + if(mud_fountain->length_counter != mud_fountain->max_height) + { + map_write_tile_cell(0, mud_fountain->x, mud_fountain->y); + map_write_tile_cell(0, mud_fountain->x + 1 + 1, mud_fountain->y); + if(player_death_counter == 0) + { + if(mud_fountain->y - 1 == player_y_pos) + { + if(mud_fountain->direction == 0) + { + player_move_on_platform(mud_fountain->x, mud_fountain->x + 2, 0, 1); + } + else + { + player_move_on_platform(mud_fountain->x, mud_fountain->x + 2, 0, 5); + } + } + } + + if(mud_fountain->direction == 0) + { + mud_fountain->y--; + mud_fountain->current_height++; + } + else + { + mud_fountain->y++; + mud_fountain->current_height--; + } + + map_write_tile_cell(0x48, mud_fountain->x, mud_fountain->y); + map_write_tile_cell(0x48, mud_fountain->x + 2, mud_fountain->y); + } + else + { + mud_fountain->length_counter = 0; + mud_fountain->direction = (Cond(mud_fountain->direction, -1, 0) + 1); + mud_fountain->pause_counter = 10; + } + } + else + { + mud_fountain->pause_counter--; + } + } + + + return; +} + +U0 display_mud_fountains() +{ + uint16 frame_counter = 0; + uint16 frame_num = 0; + I64 i, j; + frame_counter++; + if ((frame_counter & 1) != 0) + { + frame_num++; + } + for (i = 0; i < num_mud_fountains; i++) + { + MudFountain *mud_fountain = &mud_fountain_tbl[i]; + display_actor_sprite_maybe(0x4f, frame_num & 1, mud_fountain->x, mud_fountain->y + 1, 0); + + for (j = 0; j < mud_fountain->current_height + 1; j++) + { + display_actor_sprite_maybe(0x4f, (frame_num & 1) + 1 + 1, mud_fountain->x + 1, mud_fountain->y + j + 1, 0); + + if (player_check_collision_with_actor(0x4f, 2, mud_fountain->x + 1, mud_fountain->y + j + 1) != 0) + { + player_decrease_health(); + } + } + } + + return; +} + +U0 update_moving_platforms() { + I64 i, si; + for(i =0;i < num_moving_platforms; i++) { + MovingPlatform *platform = &moving_platform_tbl[i]; + for (si = 2; si < 7; si++) { + map_write_tile_cell(platform->map_tiles[si - 2], platform->x + si - 4, platform->y); + } + + uint16 map_tile_num = (map_get_tile_cell(platform->x, platform->y) / 8); + if (player_death_counter == 0) { + if (platform->y - 1 == player_y_pos && move_platform_flag != 0) { + player_move_on_platform(platform->x - 2, platform->x + 2, map_tile_num, map_tile_num); + } + } + if (move_platform_flag != 0) { + platform->x += player_x_offset_tbl[map_tile_num]; + platform->y += player_y_offset_tbl[map_tile_num]; + } + + for (si = 2; si < 7; si++) { + platform->map_tiles[si - 2] = map_get_tile_cell(platform->x + si - 4, platform->y); + } + + for (si = 2; si < 7; si++) { + map_write_tile_cell(((si - 2) / 8) + 0x3dd0, platform->x + si - 4, platform->y); + } + } + return; +} diff --git a/Player.HC b/Player.HC new file mode 100644 index 0000000..1cdad40 --- /dev/null +++ b/Player.HC @@ -0,0 +1,1872 @@ +extern TileInfo *actor_get_tile_info(I64 actorInfoIndex, I64 frame_num); +extern I64 map_width_in_tiles; +extern U8 byte_32EB8; +extern U0 actor_add_new(I64 image_index, I64 x_pos, I64 y_pos); +extern uint16 map_get_tile_cell(I64 x, I64 y); +extern I64 map_max_y_offset; +extern I64 mapwindow_x_offset; +extern I64 mapwindow_y_offset; +extern U0 video_draw_tile_white(Tile *tile, uint16 x, uint16 y); +extern U0 no_bombs_dialog(); +extern I64 map_stride_bit_shift_amt; +extern U0 effect_add_sprite(I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos, I64 arg_8, I64 counter); +extern U0 display_actor_sprite_maybe(I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos, I64 tile_display_func_index); +extern U0 load_level(I64 level_number); +extern uint16 current_level; + +sint16 player_x_offset_tbl[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 }; +sint16 player_y_offset_tbl[9] = { 0, -1, -1, 0, 1, 1, 1, 0, -1 }; + +I64 player_is_grabbing_wall_flag = 0; +I64 player_death_counter = 0; +I64 player_walk_anim_index = 0; +I64 player_is_being_pushed_flag = 0; +I64 player_hanging_on_wall_direction = 0; + +I64 player_y_pos = 0; +I64 player_x_pos = 0; +I64 player_direction = 0; +I64 player_direction_related_32E98 = 0; + +I64 player_sprite_dir_frame_offset = 0; +I64 player_input_jump_related_flag = 0; + +I64 player_bounce_height_counter = 0; +I64 player_bounce_flag_maybe = 0; + +I64 is_standing_slipry_slope_left_flg = 0; +I64 is_standing_slipry_slope_right_flg = 0; + +uint8 health = 0; +uint8 num_health_bars = 0; + +uint16 num_bombs = 0; +uint16 has_had_bomb_flag = 0; + +I64 teleporter_state_maybe = 0; +I64 player_is_teleporting_flag = 0; +I64 teleporter_counter = 0; + +uint8 player_in_pneumatic_tube_flag = 0; + +I64 player_invincibility_counter = 0; + +I64 player_fall_off_map_bottom_counter = 0; +I64 num_hits_since_touching_ground = 0; + +uint16 player_push_direction = 0; +uint16 player_push_anim_duration_maybe = 0; +uint16 player_push_anim_counter = 0; +uint16 player_push_duration = 0; +uint16 player_push_frame_num = 0; +uint8 player_dont_push_while_jumping_flag = 0; +uint16 player_push_check_blocking_flag = 0; + +uint8 word_28BEA; +I64 word_28F7E; +I64 word_28F94; +I64 word_2E180; +I64 word_2E1E8; +I64 hide_player_sprite; +I64 word_2E1DE; +I64 word_2E214; +I64 player_hoverboard_counter; +I64 word_32EAC; +I64 word_32EB2; + +U8 byte_2E182; +U8 byte_2E2E4; + +uint8 god_mode_flag = 0; +uint8 show_monster_attack_hint = 0; + +Tile *player_tiles; +Sprite *player_sprites; + +U0 sub_11062() +{ + word_32EB2 = 0; + player_walk_anim_index = 0; + return; +} + +U0 player_add_to_score(uint32 amount_to_add_low) +{ + add_to_score_update_on_display(amount_to_add_low, 9, 0x16); +} + +U0 player_add_score_for_actor(I64 actorInfoIndex) +{ + switch (actorInfoIndex) + { + case 46: + player_add_to_score(0x320); + break; + + case 51: + case 54: + case 78: + case 80: + player_add_to_score(0x190); + break; + + case 20: + player_add_to_score(0xc80); + break; + + case 41: + case 47: + case 86: + player_add_to_score(0x640); + break; + + case 92: + case 101: + player_add_to_score(0x1900); + break; + + case 17: + case 18: + case 87: + case 89: + player_add_to_score(0xfa); + break; + + case 106: + case 113: + player_add_to_score(0x3e8); + break; + + case 69: + case 125: + player_add_to_score(0x3200); + break; + + case 126: + player_add_to_score(0x7d0); + break; + + case 3: + case 4: + case 88: + case 111: + case 112: + case 118: + case 127: + player_add_to_score(0x1f4); + break; + + case 129: + player_add_to_score(0xc350); + break; + + case 74: + case 75: + case 95: + case 96: + case 128: + case 187: + player_add_to_score(0x64); + break; + + case 1: + case 25: + case 55: + case 65: + case 83: + case 84: + case 124: + case 188: + player_add_to_score(0xc8); + break; + + default: break; + } + return ; +} + +I64 player_check_collision_with_actor(I64 actorInfoIndex, I64 frame_num, I64 x_pos, I64 y_pos) { + if(player_death_counter == 0) + { + TileInfo *tileInfo = actor_get_tile_info(actorInfoIndex, frame_num); + uint16 di = tileInfo->height; + uint16 si = tileInfo->width; + + if(x_pos > map_width_in_tiles && x_pos <= -1 && actorInfoIndex == 0x1a) + { + si += x_pos; + x_pos = 0; + } + if(((player_x_pos <= x_pos && player_x_pos + 3 > x_pos) || (player_x_pos >= x_pos && x_pos + si > player_x_pos)) && + ((y_pos - di < player_y_pos && player_y_pos <= y_pos) || (player_y_pos - 4 <= y_pos && y_pos <= player_y_pos))) + { + return 1; + } + } + return 0; + +} + +U0 player_decrease_health() +{ + if(player_death_counter == 0 && god_mode_flag == 0 && hide_player_sprite == 0 && teleporter_state_maybe == 0 && byte_32EB8 == 0 && player_in_pneumatic_tube_flag == 0 && player_invincibility_counter == 0) + { + player_hanging_on_wall_direction = 0; + if(word_28BEA == 0) + { + word_28BEA = 1; + actor_add_new(0xeb, player_x_pos - 1, player_y_pos - 5); + if(show_monster_attack_hint == 0) + { + show_monster_attack_hint = 1; + } + } + health--; + if(health != 0) + { + update_health_bar_display(); + player_invincibility_counter = 0x2c; + //play_sfx(14); + } + else + { + player_death_counter = 1; + player_hoverboard_counter = 0; + } + } + + return; +} + +U0 push_player_around(I64 push_direction, I64 push_anim_duration, I64 push_duration, I64 player_frame_num, + uint8 dont_push_while_jumping_flag, I64 check_for_blocking_flag) +{ + player_push_direction = push_direction; + player_push_anim_duration_maybe = push_anim_duration; + player_push_anim_counter = 0; + player_push_duration = push_duration; + player_push_frame_num = player_frame_num; + player_dont_push_while_jumping_flag = dont_push_while_jumping_flag; + player_is_being_pushed_flag = 1; + player_hoverboard_counter = 0; + player_push_check_blocking_flag = check_for_blocking_flag; + player_bounce_flag_maybe = 0; + player_bounce_height_counter = 0; + sub_11062(); + return ; +} + +I64 player_check_movement(I64 direction, I64 x_pos, I64 y_pos) +{ + is_standing_slipry_slope_left_flg = 0; + is_standing_slipry_slope_right_flg = 0; + uint8 tile_attr; + I64 i; + switch (direction) + { + case 0: //UP + if (player_y_pos - 3 == 0 || player_y_pos - 2 == 0) + { + return BLOCKED; + } + + for (i = 0; i < 3; i++) + { + if (tileattr_mni_data[map_get_tile_cell(x_pos + i, y_pos - 4) / 8] & TILE_ATTR_BLOCK_UP) + { + return BLOCKED; + } + } + break; + + case 1: //DOWN + if (map_max_y_offset + 0x12 == player_y_pos) + { + return NOT_BLOCKED; + } + + tile_attr = tileattr_mni_data[map_get_tile_cell(x_pos, y_pos) / 8]; + if ((tile_attr & TILE_ATTR_BLOCK_DOWN) == 0 && (tile_attr & TILE_ATTR_SLOPED) != 0 && + (tile_attr & TILE_ATTR_SLIPPERY) != 0) + { + is_standing_slipry_slope_left_flg = 1; + } + + tile_attr = tileattr_mni_data[map_get_tile_cell(x_pos + 2, y_pos) / 8]; + if ((tile_attr & TILE_ATTR_BLOCK_DOWN) == 0 && + (tile_attr & TILE_ATTR_SLOPED) != 0 && + (tile_attr & TILE_ATTR_SLIPPERY) != 0) + { + is_standing_slipry_slope_right_flg = 1; + } + + for (i = 0; i < 3; i++) + { + tile_attr = tileattr_mni_data[map_get_tile_cell(x_pos + i, y_pos) / 8]; + if (tile_attr & TILE_ATTR_SLOPED) + { + num_hits_since_touching_ground = 0; + return SLOPE; + } + if (tile_attr & TILE_ATTR_BLOCK_DOWN) + { + num_hits_since_touching_ground = 0; + return BLOCKED; + } + } + break; + + case 2: // LEFT + tile_attr = tileattr_mni_data[map_get_tile_cell(x_pos, y_pos - 2) / 8]; + player_is_grabbing_wall_flag = tile_attr & TILE_ATTR_CAN_GRAB_WALL; + + for (i = 0; i < 5; i++) + { + tile_attr = tileattr_mni_data[map_get_tile_cell(x_pos, y_pos - i) / 8]; + if (tile_attr & TILE_ATTR_BLOCK_LEFT) + { + return BLOCKED; + } + + if (i == 0) + { + if (tileattr_mni_data[map_get_tile_cell(x_pos, y_pos) / 8] & TILE_ATTR_SLOPED && + (tileattr_mni_data[map_get_tile_cell(x_pos, y_pos - 1) / 8] & TILE_ATTR_BLOCK_LEFT) == 0) + { + return SLOPE; + } + } + } + break; + + case 3: // RIGHT + tile_attr = tileattr_mni_data[map_get_tile_cell(x_pos + 2, y_pos - 2) / 8]; + player_is_grabbing_wall_flag = tile_attr & TILE_ATTR_CAN_GRAB_WALL; + + for (i = 0; i < 5; i++) + { + tile_attr = tileattr_mni_data[map_get_tile_cell(x_pos + 2, y_pos - i) / 8]; + if (tile_attr & TILE_ATTR_BLOCK_RIGHT) + { + return BLOCKED; + } + + if (i == 0) + { + if (tileattr_mni_data[map_get_tile_cell(x_pos + 2, y_pos) / 8] & TILE_ATTR_SLOPED && + (tileattr_mni_data[map_get_tile_cell(x_pos + 2, y_pos - 1) / 8] & TILE_ATTR_BLOCK_RIGHT) == 0) + { + return SLOPE; + } + } + } + break; + + default : break; + } + + return NOT_BLOCKED; +} + +U0 player_move_on_platform(I64 platform_x_left, I64 platform_x_right, I64 x_offset_tbl_index, I64 y_offset_tbl_index) +{ + if(player_hoverboard_counter != 0) + { + return; + } + + I64 player_right_x_pos = player_sprites[0].frames[0].width + player_x_pos - 1; + + if(player_hanging_on_wall_direction != 0 && player_check_movement(DOWN, player_x_pos, player_y_pos + 1) != 0) + { + player_hanging_on_wall_direction = 0; + } + + if((player_x_pos < platform_x_left || player_x_pos > platform_x_right) && (player_right_x_pos < platform_x_left || player_right_x_pos > platform_x_right)) + { + return; + } + + player_x_pos = player_x_pos + player_x_offset_tbl[x_offset_tbl_index]; + player_y_pos = player_y_pos + player_y_offset_tbl[y_offset_tbl_index]; + + if((up_key_pressed != 0 || down_key_pressed != 0) && left_key_pressed == 0 && right_key_pressed == 0) + { + if(up_key_pressed != 0 && mapwindow_y_offset > 0 && player_y_pos - mapwindow_y_offset < 0x11) + { + mapwindow_y_offset = mapwindow_y_offset - 1; + } + if(down_key_pressed != 0 && (mapwindow_y_offset + 4 < player_y_pos || (player_y_offset_tbl[y_offset_tbl_index] == 1 && mapwindow_y_offset + 3 < player_y_pos))) + { + mapwindow_y_offset = mapwindow_y_offset + 1; + } + } + + if(player_y_pos - mapwindow_y_offset <= 0x11) + { + if(player_y_pos - mapwindow_y_offset < 3) + { + mapwindow_y_offset = mapwindow_y_offset - 1; + } + } + else + { + mapwindow_y_offset = mapwindow_y_offset + 1; + } + + if(player_x_pos - mapwindow_x_offset <= 0x17 || map_width_in_tiles - 38 <= mapwindow_x_offset) + { + if(player_x_pos - mapwindow_x_offset < 12 && mapwindow_x_offset > 0) + { + mapwindow_x_offset = mapwindow_x_offset - 1; + } + } + else + { + mapwindow_x_offset = mapwindow_x_offset + 1; + } + + if(player_y_offset_tbl[y_offset_tbl_index] == 1 && player_y_pos - mapwindow_y_offset > 14) + { + mapwindow_y_offset = mapwindow_y_offset + 1; + } + + if(player_y_offset_tbl[y_offset_tbl_index] == -1 && player_y_pos - mapwindow_y_offset < 3) + { + mapwindow_y_offset = mapwindow_y_offset - 1; + } + + return; +} + +U0 player_load_tiles() +{ + uint16 num_tile_info_records; + uint16 num_tiles; + player_tiles = load_tiles("PLAYERS.MNI", TRANSPARENT, &num_tiles); + "Loading %d player tiles.\n", num_tiles; + + player_sprites = load_tile_info("PLYRINFO.MNI", &num_tile_info_records); + "Loading %d, player tile info records.\n", num_tile_info_records; +} + +U0 display_player_sprite_mode_6(uint8 frame_num, I64 x_pos, I64 y_pos) +{ + TileInfo *info = &player_sprites[0].frames[frame_num]; + Tile *tile = &player_tiles[info->tile_num]; + I64 x, y; + + for(y=0;y < info->height;y++) + { + for (x = 0; x < info->width; x++) + { + video_draw_tile(tile, (x_pos + x) * 8, (y_pos + y - (info->height - 1)) * 8); + tile++; + } + } +} + +U0 display_player_sprite(uint8 frame_num, I64 x_pos, I64 y_pos, I64 tile_display_func_index) +{ + if(tile_display_func_index == 6) + { + display_player_sprite_mode_6(frame_num, x_pos, y_pos); + return; + } + + if(player_push_frame_num == 0xff || teleporter_state_maybe || (player_invincibility_counter & 1) || hide_player_sprite) + { + return; + } + + TileInfo *info = &player_sprites[0].frames[frame_num]; + Tile *tile = &player_tiles[info->tile_num]; + I64 x, y; + + for(y=0;y < info->height;y++) + { + for(x=0;x < info->width; x++) + { + uint16 screen_x = (x_pos - mapwindow_x_offset + x + 1) * 8; + uint16 screen_y = (y_pos - info->height + 1 - mapwindow_y_offset + y + 1) * 8; + + if(screen_x >= 8 && screen_x <= 304 && //FIXME need a better way of making sure we draw in the borders. + screen_y >= 8 && screen_y < 152 && + !(tileattr_mni_data[map_get_tile_cell(x_pos+x,y_pos - info->height + y + 1)/8] & TILE_ATTR_IN_FRONT)) + { + if(tile_display_func_index == 2) + { + video_draw_tile_white(tile, screen_x, screen_y); + } + else + { + video_draw_tile(tile, screen_x, screen_y); + } + } + tile++; + } + } +} + +U0 player_reset_push_variables() +{ + player_is_being_pushed_flag = 0; + player_push_direction = 0; + player_push_anim_duration_maybe = 0; + player_push_anim_counter = 0; + player_push_duration = 0; + player_push_frame_num = 0; + player_dont_push_while_jumping_flag = 0; + player_bounce_flag_maybe = 0; + player_bounce_height_counter = 0; + byte_2E2E4 = 1; + word_2E180 = 0; + return; +} + +sint16 word_28F80[10] = {-2, -1, -1, -1, -1, -1, -1, 0, 0, 0}; + +U0 push_player() +{ + I64 di = 0; + I64 i; + if(player_is_being_pushed_flag == di) + { + return; + } + if(jump_key_pressed != 0 && player_dont_push_while_jumping_flag != 0) + { + player_is_being_pushed_flag = di; + return; + } + + for(i=0; i < player_push_duration; i++) + { + if(player_x_offset_tbl[player_push_direction] + player_x_pos > 0 && + player_x_offset_tbl[player_push_direction] + player_x_pos + 2 < map_width_in_tiles) + { + player_x_pos += player_x_offset_tbl[player_push_direction]; + } + + player_y_pos += player_y_offset_tbl[player_push_direction]; + + if(player_x_offset_tbl[player_push_direction] + mapwindow_x_offset > 0 && + player_x_offset_tbl[player_push_direction] + mapwindow_x_offset < map_width_in_tiles - 37) + { + mapwindow_x_offset = mapwindow_x_offset + player_x_offset_tbl[player_push_direction]; + } + if(player_y_offset_tbl[player_push_direction] + mapwindow_y_offset > 2) + { + mapwindow_y_offset = mapwindow_y_offset + player_y_offset_tbl[player_push_direction]; + } + if(player_push_check_blocking_flag != 0 && (player_check_movement(2, player_x_pos, player_y_pos) != NOT_BLOCKED || player_check_movement(3, player_x_pos, player_y_pos) != NOT_BLOCKED || player_check_movement(0, player_x_pos, player_y_pos) != NOT_BLOCKED || player_check_movement(1, player_x_pos, player_y_pos) != NOT_BLOCKED)) + { + di = 1; + break; + } + } + + if(di != 0) + { + player_x_pos = player_x_pos - player_x_offset_tbl[player_push_direction]; + player_y_pos = player_y_pos - player_y_offset_tbl[player_push_direction]; + mapwindow_x_offset = mapwindow_x_offset - player_x_offset_tbl[player_push_direction]; + mapwindow_y_offset = mapwindow_y_offset - player_y_offset_tbl[player_push_direction]; + player_reset_push_variables(); + return; + } + player_push_anim_counter++; + if(player_push_anim_counter >= player_push_anim_duration_maybe) + { + player_reset_push_variables(); + } + return; +} + +U0 handle_player_input_maybe() +{ + I64 local_bomb_key_counter = 0; + I64 var_4=0; + I64 top_bomb_check_flag = 0; + I64 tile_cell; + I64 player_movement_status = NOT_BLOCKED; + I64 bottom_bomb_check_flag; + I64 di; + I64 blockingCheck; + uint8 tile_attr; + + I64 si = 0; + player_is_grabbing_wall_flag = 0; + if(player_death_counter != 0 || teleporter_state_maybe != 0 || player_hoverboard_counter != 0 || player_walk_anim_index != 0 || hide_player_sprite != 0) + { + return; + } + word_28F94 = word_28F94 + 1; + push_player(); + if(player_is_being_pushed_flag != 0) + { + player_hanging_on_wall_direction = 0; + return; + } + if(player_hanging_on_wall_direction != 0) + { + tile_cell = 0; + if(player_hanging_on_wall_direction != 2) + { + tile_cell = map_get_tile_cell(player_x_pos + 3, player_y_pos - 2); + } + else + { + tile_cell = map_get_tile_cell(player_x_pos - 1, player_y_pos - 2); + } + if((tileattr_mni_data[tile_cell >> 3] & TILE_ATTR_SLIPPERY) != 0 && (tileattr_mni_data[tile_cell >> 3] & TILE_ATTR_CAN_GRAB_WALL) != 0) + { + if(player_check_movement(1, player_x_pos, player_y_pos + 1) == NOT_BLOCKED) + { + player_y_pos = player_y_pos + 1; + si = 1; + if(player_hanging_on_wall_direction != 2) + { + tile_cell = map_get_tile_cell(player_x_pos + 3, player_y_pos - 2); + } + else + { + tile_cell = map_get_tile_cell(player_x_pos - 1, player_y_pos - 2); + } + + if((tileattr_mni_data[tile_cell >> 3] & TILE_ATTR_SLIPPERY) == 0) + { + if((tileattr_mni_data[tile_cell >> 3] & TILE_ATTR_CAN_GRAB_WALL) == 0) + { + player_hanging_on_wall_direction = 0; + si = 0; + //goto loc_1DD63; + } + } + } + else + { + player_hanging_on_wall_direction = 0; + } + } + else + { + if((tileattr_mni_data[tile_cell >> 3] & TILE_ATTR_CAN_GRAB_WALL) == 0) + { + player_hanging_on_wall_direction = 0; + } + } + } + if(player_hanging_on_wall_direction == 0) + { + if(bomb_key_pressed == 0) + { + local_bomb_key_counter = 0; + } + if(bomb_key_pressed != 0 && local_bomb_key_counter == 0) + { + local_bomb_key_counter = 2; + } + if(local_bomb_key_counter != 0 && local_bomb_key_counter != 1) + { + local_bomb_key_counter = local_bomb_key_counter - 1; + if(local_bomb_key_counter == 1) + { + if(player_direction == 0) + { + tile_attr = tileattr_mni_data[map_get_tile_cell(player_x_pos - 1, player_y_pos - 2) >> 3]; + top_bomb_check_flag = tile_attr & TILE_ATTR_BLOCK_LEFT; + tile_attr = tileattr_mni_data[map_get_tile_cell(player_x_pos - 2, player_y_pos - 2) >> 3]; + bottom_bomb_check_flag = tile_attr & TILE_ATTR_BLOCK_LEFT; + + if(num_bombs != 0 || has_had_bomb_flag != 0) + { + if(top_bomb_check_flag != 0) + { + //play_sfx(0x1c); + } + else + { + if(bottom_bomb_check_flag != 0) + { + //play_sfx(0x1c); + } + else + { + if(num_bombs <= 0) + { + //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); + } + } + } + } + else + { + has_had_bomb_flag = 1; + no_bombs_dialog(); + } + } + else + { + tile_attr = tileattr_mni_data[map_get_tile_cell(player_x_pos + 3, player_y_pos - 2) >> 3]; + top_bomb_check_flag = tile_attr & TILE_ATTR_BLOCK_RIGHT; + tile_attr = tileattr_mni_data[map_get_tile_cell(player_x_pos + 4, player_y_pos - 2) >> 3]; + bottom_bomb_check_flag = tile_attr & TILE_ATTR_BLOCK_RIGHT; + + if(num_bombs == 0 && has_had_bomb_flag == 0) + { + has_had_bomb_flag = 1; + no_bombs_dialog(); + } + if(top_bomb_check_flag != 0) + { + //play_sfx(0x1c); + } + else + { + if(bottom_bomb_check_flag == 0) + { + if(num_bombs > 0) + { + actor_add_new(0x18, player_x_pos + 3, player_y_pos - 2); + num_bombs = num_bombs - 1; + display_num_bombs_left(); + //play_sfx(0x1d); + } + else + { + //play_sfx(0x1c); + } + } + else + { + //play_sfx(0x1c); + } + } + } + } + } + else + { + bomb_key_pressed = 0; + } + } + if(byte_2E182 != 0 || bomb_key_pressed == 0 || byte_2E2E4 != 0 || player_hanging_on_wall_direction != 0 || (jump_key_pressed != 0 && player_input_jump_related_flag == 0)) + { + word_2E214 = 0; + //ax = player_check_movement(1, player_x_pos, player_y_pos + 1); + if(is_standing_slipry_slope_left_flg == 0 || is_standing_slipry_slope_right_flg == 0) + { + if(is_standing_slipry_slope_right_flg != 0) + { + if(player_hanging_on_wall_direction == 0) + { + player_x_pos = player_x_pos - 1; + } + if(player_check_movement(1, player_x_pos, player_y_pos + 1) == 0 && player_hanging_on_wall_direction == 0) + { + player_y_pos = player_y_pos + 1; + } + if(player_y_pos - mapwindow_y_offset > 14) + { + mapwindow_y_offset = mapwindow_y_offset + 1; + } + if(player_x_pos - mapwindow_x_offset < 12 && mapwindow_x_offset > 0) + { + mapwindow_x_offset = mapwindow_x_offset - 1; + } + player_hanging_on_wall_direction = 0; + } + if(is_standing_slipry_slope_left_flg != 0) + { + if(player_hanging_on_wall_direction == 0) + { + player_x_pos = player_x_pos + 1; + } + if(player_check_movement(1, player_x_pos, player_y_pos + 1) == 0 && player_hanging_on_wall_direction == 0) + { + player_y_pos = player_y_pos + 1; + } + if(player_y_pos - mapwindow_y_offset > 14) + { + mapwindow_y_offset = mapwindow_y_offset + 1; + } + if(player_x_pos - mapwindow_x_offset > 0x17) + { + if(map_width_in_tiles - 38 > mapwindow_x_offset) + { + mapwindow_x_offset = mapwindow_x_offset + 1; + } + } + player_hanging_on_wall_direction = 0; + } + } + if(left_key_pressed != 0 && player_hanging_on_wall_direction == 0 && right_key_pressed == 0) + { + di = player_check_movement(1, player_x_pos, player_y_pos + 1); + + if(player_direction_related_32E98 != 2) + { + player_direction_related_32E98 = 2; + } + else + { + player_x_pos = player_x_pos - 1; + } + player_direction = 0; + if(player_x_pos >= 1) + { + player_movement_status = player_check_movement(2, player_x_pos, player_y_pos); + if(player_movement_status == BLOCKED) + { + player_x_pos = player_x_pos + 1; + if(player_check_movement(1, player_x_pos, player_y_pos + 1) == NOT_BLOCKED && player_is_grabbing_wall_flag != 0) + { + player_hanging_on_wall_direction = 2; + player_bounce_flag_maybe = 0; + player_bounce_height_counter = 0; + //play_sfx(4); + byte_2E2E4 = 0; + byte_2E182 = 0; + word_2E180 = 0; + if(jump_key_pressed == 0) + { + player_input_jump_related_flag = 0; + } + else + { + player_input_jump_related_flag = 1; + } + } + } + } + else + { + player_x_pos = player_x_pos + 1; + } + if(player_movement_status != 2) + { + if(di == SLOPE) + { + if(player_check_movement(1, player_x_pos, player_y_pos + 1) == NOT_BLOCKED) + { + byte_2E2E4 = 0; + byte_2E182 = 0; + player_y_pos = player_y_pos + 1; + } + } + } + else + { + player_y_pos = player_y_pos - 1; + } + } + if(right_key_pressed != 0 && player_hanging_on_wall_direction == 0 && left_key_pressed == 0) + { + di = player_check_movement(1, player_x_pos, player_y_pos + 1); + if(player_direction_related_32E98 != 3) + { + player_direction_related_32E98 = 3; + } + else + { + player_x_pos = player_x_pos + 1; + } + player_direction = 0x17; + if(map_width_in_tiles - 4 >= player_x_pos) + { + player_movement_status = player_check_movement(3, player_x_pos, player_y_pos); + if(player_movement_status == BLOCKED) + { + player_x_pos = player_x_pos - 1; + if(player_check_movement(1, player_x_pos, player_y_pos + 1) == NOT_BLOCKED && player_is_grabbing_wall_flag != 0) + { + player_hanging_on_wall_direction = 3; + player_bounce_flag_maybe = 0; + player_bounce_height_counter = 0; + //play_sfx(4); + byte_2E182 = 0; + byte_2E2E4 = 0; + word_2E180 = 0; + if(jump_key_pressed == 0) + { + player_input_jump_related_flag = 0; + } + else + { + player_input_jump_related_flag = 1; + } + } + } + } + else + { + player_x_pos = player_x_pos - 1; + } + if(player_movement_status != 2) + { + if(di == SLOPE) + { + if(player_check_movement(1, player_x_pos, player_y_pos + 1) == NOT_BLOCKED) + { + byte_2E2E4 = 0; + word_2E180 = 0; + player_y_pos = player_y_pos + 1; + } + } + } + else + { + player_y_pos = player_y_pos - 1; + } + } + if(player_hanging_on_wall_direction != 0 && player_input_jump_related_flag != 0 && jump_key_pressed == 0) + { + player_input_jump_related_flag = 0; + } + if(player_bounce_height_counter != 0 || + (jump_key_pressed != 0 && byte_2E2E4 == 0 && player_input_jump_related_flag == 0) || + (player_hanging_on_wall_direction != 0 && jump_key_pressed != 0 && player_input_jump_related_flag == 0)) + { + if(player_bounce_flag_maybe != 0 && player_bounce_height_counter > 0) + { + player_bounce_height_counter = player_bounce_height_counter - 1; + if(player_bounce_height_counter < 10) + { + word_2E1DE = 0; + } + if(player_bounce_height_counter > 1) + { + player_y_pos = player_y_pos - 1; + } + if(player_bounce_height_counter > 13) + { + player_bounce_height_counter = player_bounce_height_counter - 1; + if(player_check_movement(0, player_x_pos, player_y_pos) != 0) + { + word_2E1DE = 0; + } + else + { + player_y_pos = player_y_pos - 1; + } + } + var_4 = 0; + if(player_bounce_height_counter == 0) + { + byte_2E182 = 0; + player_bounce_flag_maybe = 0; + word_2E180 = 0; + word_2E1DE = 0; + player_input_jump_related_flag = 1; + } + } + else + { + if(player_hanging_on_wall_direction == 2) + { + if(left_key_pressed == 0) + { + if(right_key_pressed != 0) + { + player_direction = 0x17; + } + } + else + { + player_hanging_on_wall_direction = 0; + } + } + if(player_hanging_on_wall_direction == 3) + { + if(right_key_pressed == 0) + { + if(left_key_pressed != 0) + { + player_direction = 0; + } + } + else + { + player_hanging_on_wall_direction = 0; + } + } + if(player_hanging_on_wall_direction == 0) + { + player_y_pos = player_y_pos + word_28F80[byte_2E182]; + } + if(byte_2E182 == 0 && player_check_movement(0, player_x_pos, player_y_pos + 1) != 0) + { + player_y_pos = player_y_pos + 1; + } + player_bounce_flag_maybe = 0; + var_4 = 1; + } + player_hanging_on_wall_direction = 0; + blockingCheck = player_check_movement(0, player_x_pos, player_y_pos); + if(blockingCheck == NOT_BLOCKED) + { + if(var_4 != 0 && byte_2E182 == 0) + { + //play_sfx(2); + } + } + else + { + if(byte_2E182 > 0 || player_bounce_flag_maybe != 0) + { + //loc_1E420: + //play_sfx(5); + } + player_bounce_height_counter = 0; + player_bounce_flag_maybe = 0; + blockingCheck = player_check_movement(0, player_x_pos, player_y_pos + 1); + if(blockingCheck != NOT_BLOCKED) + { + player_y_pos = player_y_pos + 1; + } + player_y_pos = player_y_pos + 1; + byte_2E2E4 = 1; + if(jump_key_pressed != 0) + { + player_input_jump_related_flag = 1; + } + word_2E180 = 0; + word_2E1DE = 0; + } + if(player_bounce_flag_maybe == 0) + { + if(byte_2E182 > 6) + { + byte_2E2E4 = 1; + if(jump_key_pressed != 0) + { + player_input_jump_related_flag = 1; + } + word_2E180 = 0; + } + byte_2E182++; + } + } + if(player_hanging_on_wall_direction == 0) + { + if(byte_2E2E4 != 0 && jump_key_pressed != 0) + { + player_input_jump_related_flag = 1; + } + if((jump_key_pressed == 0 || player_input_jump_related_flag != 0) && byte_2E2E4 == 0) + { + byte_2E2E4 = 1; + word_2E180 = 0; + } + if(byte_2E2E4 != 0 && player_bounce_flag_maybe == 0) + { + player_y_pos = player_y_pos + 1; + if(player_check_movement(1, player_x_pos, player_y_pos) != NOT_BLOCKED) + { + if(word_2E180 != 0) + { + //play_sfx(3); + } + byte_2E2E4 = 0; + player_y_pos = player_y_pos - 1; + byte_2E182 = 0; + if(jump_key_pressed == 0) + { + player_input_jump_related_flag = 0; + } + else + { + player_input_jump_related_flag = 1; + } + word_2E180 = 0; + } + if(word_2E180 > 3) + { + player_y_pos = player_y_pos + 1; + mapwindow_y_offset = mapwindow_y_offset + 1; + if(player_check_movement(1, player_x_pos, player_y_pos) != NOT_BLOCKED) + { + //play_sfx(3); + byte_2E2E4 = 0; + player_y_pos = player_y_pos - 1; + mapwindow_y_offset = mapwindow_y_offset - 1; + byte_2E182 = 0; + if(jump_key_pressed == 0) + { + player_input_jump_related_flag = 0; + } + else + { + player_input_jump_related_flag = 1; + } + word_2E180 = 0; + } + } + if(word_2E180 < 0x19) + { + word_2E180 = word_2E180 + 1; + } + } + if(byte_2E2E4 != 0 && word_2E180 == 1 && player_bounce_flag_maybe == 0) + { + player_y_pos = player_y_pos - 1; + } + } + } + else + { + if(left_key_pressed == 0) + { + if(right_key_pressed == 0) + { + if(player_direction_related_32E98 != 2) + { + if(player_direction_related_32E98 == 3) + { + word_2E214 = 3; + } + } + else + { + word_2E214 = 2; + } + } + else + { + player_direction_related_32E98 = 3; + word_2E214 = 3; + player_direction = 0x17; + } + } + else + { + player_direction_related_32E98 = 2; + word_2E214 = 2; + player_direction = 0; + } + } + if (word_2E214 == 0) //goto loc_1E5DC; + { +// node 0001e5dc-0001e5e1 #insn=2 use={} def={} in={ax, si, al, dl} out={ax, si, al, dl} pred={ 1DC0F} CONDJUMP target=0001e615 follow=0001e6bd + //loc_1E5DC: + if ((up_key_pressed != 0 || down_key_pressed != 0) && left_key_pressed == 0 && right_key_pressed == 0 && + byte_2E2E4 == 0 && jump_key_pressed == 0) + { +// node 0001e615-0001e6a9 #insn=6 use={} def={} in={} out={} pred={ 1E5DC} FALLTHROUGH follow=0001e96f + //loc_1E615: + word_28F7E = 0; + if (up_key_pressed != 0 && player_is_teleporting_flag == 0 && word_32EAC == 0) + { + if (mapwindow_y_offset > 0 && player_y_pos - mapwindow_y_offset < 0x11) + { + mapwindow_y_offset = mapwindow_y_offset - 1; + } + if (si != 0) + { + mapwindow_y_offset = mapwindow_y_offset + 1; + } + if (player_hanging_on_wall_direction == 0) + { + player_sprite_dir_frame_offset = 5; + } + else + { + player_sprite_dir_frame_offset = 11; + } + return; + } + if (down_key_pressed == 0) + { + return; + } + if (mapwindow_y_offset + 3 < player_y_pos) + { + mapwindow_y_offset = mapwindow_y_offset + 1; + if ((si != 0 || is_standing_slipry_slope_left_flg != 0 || is_standing_slipry_slope_right_flg != 0) && + mapwindow_y_offset + 3 < player_y_pos) + { + mapwindow_y_offset = mapwindow_y_offset + 1; + } + } + if (player_hanging_on_wall_direction == 0) + { + player_sprite_dir_frame_offset = 6; + } + else + { + player_sprite_dir_frame_offset = 12; + } + return; + } + + // node 0001e6bd-0001e6c2 #insn=2 use={} def={} in={} out={} pred={ 1E5DC} FALLTHROUGH follow=0001e8d8 + //loc_1E6BD: + if(player_hanging_on_wall_direction != 2) + { + if(player_hanging_on_wall_direction != 3) + { + if((byte_2E2E4 == 0 || player_bounce_flag_maybe != 0) && (byte_2E182 <= 6 || byte_2E2E4 != 0)) + { + if((jump_key_pressed == 0 || player_input_jump_related_flag != 0) && player_bounce_flag_maybe == 0) + { + if(left_key_pressed == right_key_pressed) + { + uint8 rvalue = (cosmo_rand() % 0x32); + + player_sprite_dir_frame_offset = 4; + if(left_key_pressed == 0 && right_key_pressed == 0 && byte_2E2E4 == 0) + { + word_28F7E = word_28F7E + 1; + if(word_28F7E <= 0x64 || word_28F7E >= 0x6e) + { + if(word_28F7E <= 0x8b || word_28F7E >= 0x96) + { + if(word_28F7E == 0xb4) + { + player_sprite_dir_frame_offset = 0x13; + } + else + { + if(word_28F7E == 0xb5) + { + player_sprite_dir_frame_offset = 0x14; + } + else + { + if(word_28F7E != 0xb6) + { + if(word_28F7E != 0xb7) + { + if(word_28F7E != 0xb8) + { + if(word_28F7E == 0xb9) + { + word_28F7E = 0; + } + } + else + { + player_sprite_dir_frame_offset = 0x13; + } + } + else + { + player_sprite_dir_frame_offset = 0x14; + } + } + else + { + player_sprite_dir_frame_offset = 0x15; + } + } + } + } + else + { + player_sprite_dir_frame_offset = 6; + } + } + else + { + player_sprite_dir_frame_offset = 5; + } + } + if(player_sprite_dir_frame_offset != 5 && player_sprite_dir_frame_offset != 6 && (rvalue == 0 || rvalue == 0x1f)) + { + //loc_1E89B: + player_sprite_dir_frame_offset = 0x12; + //goto loc_1E8D8; + } + } + else + { + if(byte_2E2E4 == 0) + { + word_28F7E = 0; + if((word_28F94 & 1) != 0) + { + if((player_sprite_dir_frame_offset & 1) != 0) + { + //play_sfx(0x13); + } + player_sprite_dir_frame_offset = player_sprite_dir_frame_offset + 1; + } + if(player_sprite_dir_frame_offset > 3) + { + player_sprite_dir_frame_offset = 0; + } + } + } + } + else + { + word_28F7E = 0; + player_sprite_dir_frame_offset = 7; + if(player_bounce_flag_maybe != 0 && word_2E1DE != 0) + { + player_sprite_dir_frame_offset = 0x16; + } + if(player_bounce_height_counter < 3 && player_bounce_flag_maybe != 0) + { + player_sprite_dir_frame_offset = 8; + } + } + } + else + { + word_28F7E = 0; + if(player_bounce_flag_maybe != 0 || byte_2E2E4 != 0 || byte_2E182 <= 6) + { + if(word_2E180 < 10 || word_2E180 >= 0x19) + { + if(word_2E180 != 0x19) + { + if(byte_2E2E4 != 0) + { + player_sprite_dir_frame_offset = 8; + } + else + { + player_sprite_dir_frame_offset = 7; + } + } + else + { + player_sprite_dir_frame_offset = 0x10; + word_32EB2 = 1; + } + } + else + { + player_sprite_dir_frame_offset = 13; + } + } + else + { + player_sprite_dir_frame_offset = 8; + } + } + } + else + { + word_28F7E = 0; + if(left_key_pressed == 0) + { + player_sprite_dir_frame_offset = 9; + } + else + { + player_sprite_dir_frame_offset = 10; + } + } + } + else + { + word_28F7E = 0; + if(right_key_pressed != 0) + { + player_sprite_dir_frame_offset = 10; + } + else + { + player_sprite_dir_frame_offset = 9; + } + } + } + else + { + // node 0001e5cd-0001e5d9 #insn=3 use={} def={} in={si} out={si} pred={ 1DC0F} JUMP target=0001e8d8 + word_28F7E = 0; + player_sprite_dir_frame_offset = 14; + //goto loc_1E8D8; + } + + + +// node 0001e8d8-0001e962 #insn=5 use={} def={} in={} out={} pred={ 1E5CD 1E6BD} FALLTHROUGH follow=0001e96f + //loc_1E8D8: + if(player_y_pos - mapwindow_y_offset > 14) + { + mapwindow_y_offset = mapwindow_y_offset + 1; + } + if(si == 0 || player_y_pos - mapwindow_y_offset <= 14) + { + if(player_bounce_height_counter > 10 && player_y_pos - mapwindow_y_offset < 7 && mapwindow_y_offset > 0) + { + mapwindow_y_offset = mapwindow_y_offset - 1; + } + if(player_y_pos - mapwindow_y_offset < 7 && mapwindow_y_offset > 0) + { + mapwindow_y_offset = mapwindow_y_offset - 1; + } + } + else + { + mapwindow_y_offset = mapwindow_y_offset + 1; + } + if(player_x_pos - mapwindow_x_offset > 0x17 && map_width_in_tiles - 38 > mapwindow_x_offset && map_stride_bit_shift_amt > 5) + { + mapwindow_x_offset = mapwindow_x_offset + 1; + return; + } + if(player_x_pos - mapwindow_x_offset < 12 && mapwindow_x_offset > 0) + { + mapwindow_x_offset = mapwindow_x_offset - 1; + } +} + +I64 player_bounce_in_the_air(I64 bounce_height) +{ + I64 word_2CAF6 = 0; + + if(player_death_counter != 0 || player_walk_anim_index != 0) + { + return 0; + } + + if((player_bounce_flag_maybe == 0 || (player_bounce_flag_maybe != 0 && player_bounce_height_counter < 2)) && + ((byte_2E2E4 != 0 && word_2E180 >= 0) || byte_2E182 > 6) && + word_2E1E8 != 0) + { + player_bounce_height_counter = bounce_height + 1; + word_2CAF6 = bounce_height + 1; + player_bounce_flag_maybe = 1; + sub_11062(); + if(bounce_height <= 0x12) + { + word_2E1DE = 0; + } + else + { + word_2E1DE = 1; + } + show_monster_attack_hint = 2; + if(bounce_height != 7) + { + num_hits_since_touching_ground = 0; + } + else + { + num_hits_since_touching_ground = num_hits_since_touching_ground + 1; + if(num_hits_since_touching_ground == 10) + { + num_hits_since_touching_ground = 0; + actor_add_new(0xf6, player_x_pos - 1, player_y_pos - 5); + } + } + return 1; + } + + if(word_2CAF6 - 2 >= player_bounce_height_counter) + { + return 0; + } + else + { + if(word_2E1E8 == 0) + { + return 0; + } + else + { + if(player_bounce_flag_maybe == 0) + { + return 0; + } + else + { + sub_11062(); + if(player_bounce_height_counter <= 0x12) + { + word_2E1DE = 0; + } + else + { + word_2E1DE = 1; + } + show_monster_attack_hint = 2; + //return 1; + } + } + } + return 1; +} + +U0 player_hoverboard_update() +{ + uint16 drop_bomb_state = 0; + + sub_11062(); + word_2E1E8 = 0; + player_bounce_height_counter = 0; + byte_2E2E4 = 0; + uint8 tr1, tr2; + if (player_death_counter != 0) + { + return; + } + + if (player_hoverboard_counter <= 1) + { + if (jump_key_pressed != 0) + { + player_input_jump_related_flag = 1; + player_hoverboard_counter = 0; + byte_2E2E4 = 1; + word_2E180 = 1; + player_bounce_flag_maybe = 0; + word_2E1E8 = 1; + player_bounce_in_the_air(9); + player_bounce_height_counter -= 2; + //play_sfx(2); + return; + } + } + else + { + up_key_pressed = 1; + player_hoverboard_counter--; + } + + if (left_key_pressed != 0 && right_key_pressed == 0) + { + if (player_direction == 0) + { + player_x_pos--; + } + + player_direction = 0; + player_sprite_dir_frame_offset = 4; + if (player_x_pos < 1) + { + player_x_pos++; + } + + if (player_check_movement(2, player_x_pos, player_y_pos) != 0 || + player_check_movement(2, player_x_pos, player_y_pos + 1) != 0) + { + player_x_pos++; + } + + if ((player_x_pos & 1) != 0) + { + effect_add_sprite(0x13, 4, player_x_pos + 3, player_y_pos + 1, 3, 1); + //play_sfx(0x18); + } + } + + if (right_key_pressed != 0 && left_key_pressed == 0) + { + if (player_direction != 0) + { + player_x_pos++; + } + + player_direction = 0x17; + player_sprite_dir_frame_offset = 4; + if (map_width_in_tiles - 4 < player_x_pos) + { + player_x_pos--; + } + + if (player_check_movement(3, player_x_pos, player_y_pos) != 0 || + player_check_movement(3, player_x_pos, player_y_pos + 1) != 0) + { + player_x_pos--; + } + if ((player_x_pos & 1) != 0) + { + effect_add_sprite(0x13, 4, player_x_pos - 1, player_y_pos + 1, 7, 1); + //play_sfx(0x18); + } + } + + if (up_key_pressed == 0 || down_key_pressed != 0) + { + if (down_key_pressed == 0 || up_key_pressed != 0) + { + player_sprite_dir_frame_offset = 4; + } + else + { + player_sprite_dir_frame_offset = 6; + if (map_max_y_offset + 0x11 > player_y_pos) + { + player_y_pos++; + } + if (player_check_movement(1, player_x_pos, player_y_pos + 1) != 0) + { + player_y_pos--; + } + } + } + else + { + player_sprite_dir_frame_offset = 5; + if (player_y_pos > 4) + { + player_y_pos--; + } + if (player_check_movement(0, player_x_pos, player_y_pos) != 0) + { + player_y_pos++; + } + if ((player_y_pos & 1) != 0) + { + effect_add_sprite(0x13, 4, player_x_pos + 1, player_y_pos + 1, 5, 1); + //play_sfx(0x18); + } + } + + if (bomb_key_pressed == 0) + { + drop_bomb_state = 0; + } + if (bomb_key_pressed != 0 && drop_bomb_state == 0) + { + drop_bomb_state = 1; + player_sprite_dir_frame_offset = 14; + } + if (drop_bomb_state == 0 || drop_bomb_state == 2) + { + bomb_key_pressed = 0; + } + else + { + player_sprite_dir_frame_offset = 14; + if (drop_bomb_state != 0) + { + drop_bomb_state = 2; + if (player_direction == 0) + { + tr1 = tileattr_mni_data[map_get_tile_cell(player_x_pos - 1, player_y_pos - 2) / 8]; + tr2 = tileattr_mni_data[map_get_tile_cell(player_x_pos - 2, player_y_pos - 2) / 8]; + if ((tr1 & TILE_ATTR_BLOCK_LEFT) == 0 && (tr2 & TILE_ATTR_BLOCK_LEFT) == 0 && num_bombs > 0) + { + actor_add_new(0x18, player_x_pos - 2, player_y_pos - 2); + num_bombs = num_bombs - 1; + display_num_bombs_left(); + //play_sfx(0x1d); + } + else + { + //play_sfx(0x1c); + } + } + else + { + tr1 = tileattr_mni_data[map_get_tile_cell(player_x_pos + 3, player_y_pos - 2) / 8]; + tr2 = tileattr_mni_data[map_get_tile_cell(player_x_pos + 4, player_y_pos - 2) / 8]; + if ((tr1 & TILE_ATTR_BLOCK_RIGHT) == 0 && (tr2 & TILE_ATTR_BLOCK_RIGHT) == 0 && num_bombs > 0) + { + actor_add_new(0x18, player_x_pos + 3, player_y_pos - 2); + num_bombs = num_bombs - 1; + display_num_bombs_left(); + //play_sfx(0x1d); + } + else + { + //play_sfx(0x1c); + } + } + } + } + + if (player_y_pos - mapwindow_y_offset <= 14) + { + if (player_bounce_height_counter > 10 && player_y_pos - mapwindow_y_offset < 7 && mapwindow_y_offset > 0) + { + mapwindow_y_offset = mapwindow_y_offset - 1; + } + if (player_y_pos - mapwindow_y_offset < 7 && mapwindow_y_offset > 0) + { + mapwindow_y_offset = mapwindow_y_offset - 1; + } + } + else + { + mapwindow_y_offset = mapwindow_y_offset + 1; + } + + if (player_x_pos - mapwindow_x_offset > 0x17 && map_width_in_tiles - 38 > mapwindow_x_offset) + { + mapwindow_x_offset = mapwindow_x_offset + 1; + } + else + { + if (player_x_pos - mapwindow_x_offset < 12 && mapwindow_x_offset > 0) + { + mapwindow_x_offset = mapwindow_x_offset - 1; + } + } + return; +} +uint8 player_walk_frame_tbl_maybe[9] = { + 0x13, 0x14, 0x15, + 0x14, 0x13, 0x14, + 0x15, 0x14, 0x13 +}; + +U0 player_update_walk_anim() +{ + if(player_hanging_on_wall_direction != 0) + { + word_32EB2 = 0; + player_walk_anim_index = 0; + } + if(word_32EB2 != 0 && player_check_movement(1, player_x_pos, player_y_pos + 1) != 0) + { + word_32EB2 = 0; + player_walk_anim_index = 8; + //play_sfx(3); + } + if(player_walk_anim_index != 0) + { + player_sprite_dir_frame_offset = player_walk_frame_tbl_maybe[player_walk_anim_index];// * ((player_walk_anim_index << 1) + player_walk_frame_tbl_maybe); + player_walk_anim_index = player_walk_anim_index - 1; + byte_2E2E4 = 0; + if(player_walk_anim_index > 8) + { + sub_11062(); + } + } + + return; +} + + +I64 player_update_sprite() +{ + uint8 byte_28FAC = 0; + + if (map_max_y_offset + 0x15 < player_y_pos && player_death_counter == 0) + { + player_fall_off_map_bottom_counter = 1; + player_death_counter = 1; + + if (map_max_y_offset + 0x16 == player_y_pos) + { + player_y_pos = player_y_pos + 1; + } + byte_28FAC++; + if (byte_28FAC == 5) + { + byte_28FAC = 0; + } + } + if (player_fall_off_map_bottom_counter != 0) + { + player_fall_off_map_bottom_counter = player_fall_off_map_bottom_counter + 1; + if (player_fall_off_map_bottom_counter == 2) + { + //play_sfx(14); + } + + while (player_fall_off_map_bottom_counter < 12) + { + cosmo_wait(2); + player_fall_off_map_bottom_counter++; + } + + if (player_fall_off_map_bottom_counter == 13) + { + //play_sfx(7); + } + if (player_fall_off_map_bottom_counter > 12 && player_fall_off_map_bottom_counter < 0x13) + { + display_actor_sprite_maybe(0xde, byte_28FAC, player_x_pos - 1, + player_y_pos - player_fall_off_map_bottom_counter + 13, 5); + } + if (player_fall_off_map_bottom_counter > 0x12) + { + display_actor_sprite_maybe(0xde, byte_28FAC, player_x_pos - 1, player_y_pos - 6, 5); + } + if (player_fall_off_map_bottom_counter > 0x1e) + { + //load_savegame_file('T'); + load_level(current_level); + player_fall_off_map_bottom_counter = 0; + return 1; + } + } + else + { + if (player_death_counter == 0) + { + if (player_invincibility_counter != 0x2c) + { + if (player_invincibility_counter > 0x28) + { + display_player_sprite(player_direction + 15, player_x_pos, player_y_pos, 0); + } + } + else + { + display_player_sprite(player_direction + 15, player_x_pos, player_y_pos, 2); + } + if (player_invincibility_counter != 0) + { + player_invincibility_counter = player_invincibility_counter - 1; + } + if (player_invincibility_counter < 0x29) + { + if (player_is_being_pushed_flag != 0) + { + display_player_sprite(player_push_frame_num, player_x_pos, player_y_pos, 0); + } + else + { + display_player_sprite(player_direction + player_sprite_dir_frame_offset, player_x_pos, player_y_pos, + 0); + } + } + } + else + { + if (player_death_counter >= 10) + { + if (player_death_counter > 9) + { + if (mapwindow_y_offset > 0 && player_death_counter < 12) + { + mapwindow_y_offset = mapwindow_y_offset - 1; + } + if (player_death_counter == 10) + { + //play_sfx(7); + } + player_y_pos = player_y_pos - 1; + player_death_counter = player_death_counter + 1; + + display_player_sprite((player_death_counter & 1) + 0x2e, player_x_pos - 1, player_y_pos, 5); + if (player_death_counter > 0x24) + { + //load_savegame_file('T'); + load_level(current_level); + return 1; + } + } + } + else + { + if (player_death_counter == 1) + { + //play_sfx(14); + } + player_death_counter = player_death_counter + 1; + + display_player_sprite((player_death_counter & 1) + 0x2e, player_x_pos - 1, player_y_pos, 5); + } + } + } + + return 0; +} \ No newline at end of file diff --git a/Run.HC b/Run.HC new file mode 100644 index 0000000..e40c678 --- /dev/null +++ b/Run.HC @@ -0,0 +1,33 @@ +#include "Define"; + +#include "File"; +#include "Vol"; + +#include "Util"; +#include "Input"; +#include "Tile"; + +#include "Font"; +#include "Status"; + +#include "Player"; +#include "Backdrop"; +#include "Effects"; +#include "Platforms"; +#include "Actor"; +#include "Cartoon"; +#include "Dialog"; +#include "Map"; + + +#include "Fullscreen_Image"; +#include "Config"; + +#include "Game"; + +#include "Palette"; +#include "Video"; + +#include "Main"; + +"Hello, world!\n"; \ No newline at end of file diff --git a/Status.HC b/Status.HC new file mode 100644 index 0000000..d2bcf80 --- /dev/null +++ b/Status.HC @@ -0,0 +1,80 @@ +#define MAP_WINDOW_WIDTH 38 +#define MAP_WINDOW_HEIGHT 18 + +extern uint32 score; +extern U8 num_health_bars; +extern U8 health; +extern U32 num_stars_collected; +extern U16 num_bombs; +extern CDC *game_surface; +extern U0 video_draw_tile(Tile *tile, uint16 x, uint16 y); + +#define STATUS_BAR_HEIGHT 6 +#define STATUS_BAR_WIDTH 38 + +Tile *status_tiles; + +U0 status_load_tiles() { + uint16 num_tiles; + status_tiles = load_tiles("STATUS.MNI", SOLID, &num_tiles); + "Loading %d status tiles.\n", num_tiles; +} + +U0 status_display() +{ + I64 x, y; + for(y=0; y < STATUS_BAR_HEIGHT; y++) + { + for (x = 0; x < STATUS_BAR_WIDTH; x++) + { + video_draw_tile(&status_tiles[x + y * STATUS_BAR_WIDTH], (x + 1) * TILE_WIDTH, (y+MAP_WINDOW_HEIGHT+1) * TILE_HEIGHT); + } + } +} + +U0 add_to_score_update_on_display(uint32 amount_to_add_low, I64 x_pos, I64 y_pos) +{ + score += amount_to_add_low; + display_number(x_pos, y_pos, score); +} + +U0 update_health_bar_display() +{ + I64 x = 0x11; + I64 y = 0x16; + I64 i; + for(i=0;i< num_health_bars;i++) + { + if(health - 1 > i) + { + video_draw_tile(&font_tiles[95], (x - i) * TILE_WIDTH, y * TILE_HEIGHT); + video_draw_tile(&font_tiles[96], (x - i) * TILE_WIDTH, (y+1) * TILE_HEIGHT); + } + else + { + video_draw_tile(&font_tiles[9], (x - i) * TILE_WIDTH, y * TILE_HEIGHT); + video_draw_tile(&font_tiles[8], (x - i) * TILE_WIDTH, (y+1) * TILE_HEIGHT); + } + } +} + +U0 display_num_stars_collected() +{ + display_number(0x23,0x16,num_stars_collected); +} + +U0 display_num_bombs_left() +{ + video_draw_tile(&font_tiles[97], 0x18 * TILE_WIDTH, 0x17 * TILE_HEIGHT); + display_number(0x18, 0x17, num_bombs); +} + +U0 status_panel_init() +{ + DCFill(game_surface, BLACK); + status_display; + add_to_score_update_on_display(0, 9, 0x16); + update_health_bar_display; + display_num_stars_collected; + display_num_bombs_left; +} diff --git a/Tile.HC b/Tile.HC new file mode 100644 index 0000000..23e4a68 --- /dev/null +++ b/Tile.HC @@ -0,0 +1,210 @@ +extern U8 *load_file(U8 *filename, U8 *buf, uint32 buf_size); +extern Bool open_file(U8 *filename, File *file); + +// Tiletype +#define SOLID 0 +#define TRANSPARENT 1 +#define FONT 2 + +// TileAttr +#define BLOCK_DOWN 0x1 +#define BLOCK_UP 0x2 +#define BLOCK_LEFT 0x4 +#define BLOCK_RIGHT 0x8 +#define SLIPPERY 0x10 +#define IN_FRONT 0x20 +#define SLOPED 0x40 +#define CAN_GRAB_WALL 0x80 + +class Tile { + I64 type; + uint8 pixels[64]; +}; + +class TileInfo { + uint16 height; + uint16 width; + uint16 tile_num; +}; + +class Sprite { + uint16 num_frames; + TileInfo *frames; +}; + +#define TILE_ATTR_BLOCK_DOWN 0x1 +#define TILE_ATTR_BLOCK_UP 0x2 +#define TILE_ATTR_BLOCK_LEFT 0x4 +#define TILE_ATTR_BLOCK_RIGHT 0x8 +#define TILE_ATTR_SLIPPERY 0x10 +#define TILE_ATTR_IN_FRONT 0x20 +#define TILE_ATTR_SLOPED 0x40 +#define TILE_ATTR_CAN_GRAB_WALL 0x80 + +#define TILE_HEIGHT 8 +#define TILE_WIDTH 8 + +#define TRANSPARENT_COLOR 255 + +uint8 tileattr_mni_data[7000]; + +U0 tile_attr_load() +{ + load_file("TILEATTR.MNI", &tileattr_mni_data, 7000); +} +uint8 get_tile_size(I64 type) +{ + return Cond(type == SOLID, 32, 40); +} +uint16 get_number_of_tiles(File *file, I64 type) +{ + uint8 tile_size = get_tile_size(type); + + uint16 num_tiles = 0; + uint32 filesize = file->size; + while(filesize > 0xffff) + { + num_tiles += 0xffff / tile_size; + filesize -= 0xffff; + } + + if(filesize > 0) + { + num_tiles += filesize / tile_size; + } + + return num_tiles; +} + +uint8 getPixelAtColumnPosition(uint8 *rowPtr, uint8 column, I64 tileType) +{ + uint8 color = 0; + + if (tileType == TRANSPARENT) { + if (*rowPtr & (1 << (7 - column))) { + return TRANSPARENT_COLOR; + } + rowPtr++; + } + + if (tileType == FONT) //Font tiles have an inverted mask layer. + { + if ((*rowPtr & (1 << (7 - column))) == 0) { + return TRANSPARENT_COLOR; + } + rowPtr++; + } + + I64 i; + for (i = 0; i < 4; i++, rowPtr++) { + + color |= (((*rowPtr >> (7 - column)) & 1) << (i)); + } + + return color; +} + +U0 load_tile(uint8 *planarData, I64 type, Tile *tile) +{ + tile->type = type; + uint8 *pixelPtr = tile->pixels; + U8 x,y; + for(y=0;ysize / 2); + if(current_frame_num < num_total_sprites - 1) + { + next_offset = file_read2(file); + } + + return ((next_offset - offset) / 4); +} + +Sprite *load_tile_info(U8 *filename, uint16 *num_records_loaded) +{ + File file; + if(!open_file(filename, &file)) + { + "Error: opening tileinfo file %s\n", filename; + return NULL; + } + + *num_records_loaded = file_read2(&file); + Sprite *sprites = MAlloc(*num_records_loaded * sizeof(Sprite)); + + uint16 sprite_index; + I64 j, frame_num; + + for(sprite_index=0;sprite_index < *num_records_loaded; sprite_index++) + { + sprites[sprite_index].num_frames = 0; + for(j=sprite_index; sprites[sprite_index].num_frames == 0 && j < *num_records_loaded; j++) //advance through the sprite info offsets until we find some frames + { + file_seek(&file, j * 2); + sprites[sprite_index].num_frames = 0; + + uint16 offset = file_read2(&file); + sprites[sprite_index].num_frames = get_number_of_sprite_frames(j, offset, *num_records_loaded, &file); + + if (sprites[sprite_index].num_frames != 0) + { + file_seek(&file, offset * 2); + + sprites[sprite_index].frames = MAlloc(sprites[sprite_index].num_frames * sizeof(TileInfo)); + + for (frame_num = 0; frame_num < sprites[sprite_index].num_frames; frame_num++) + { + sprites[sprite_index].frames[frame_num].height = file_read2(&file); + sprites[sprite_index].frames[frame_num].width = file_read2(&file); + uint32 frameOffset = file_read4(&file); + sprites[sprite_index].frames[frame_num].tile_num = ((frameOffset >> 16) * 1638 + (frameOffset & 0xffff) / 40); + } + } + } + } + + file_close(&file); + + return sprites; +} diff --git a/Util.HC b/Util.HC new file mode 100644 index 0000000..b23a2fb --- /dev/null +++ b/Util.HC @@ -0,0 +1,12 @@ +I64 cosmo_rand() +{ + //FIXME + return RandU64 % 0xffff; +} + +I64 Cond(Bool cond, I64 true, I64 false) +{ + if (cond) + return true; + return false; +} diff --git a/Video.HC b/Video.HC new file mode 100644 index 0000000..f3ad205 --- /dev/null +++ b/Video.HC @@ -0,0 +1,335 @@ +#define SCREEN_WIDTH 320 +#define SCREEN_HEIGHT 200 + +#define DEFAULT_SCALE_FACTOR 2 + +Bool is_game_mode = TRUE; +Bool is_fullscreen = FALSE; +Bool video_has_initialised = FALSE; +I64 video_scale_factor = DEFAULT_SCALE_FACTOR; + +CDC *game_surface = NULL; +CDC *text_surface = NULL; + +CDC *game_dc = NULL; +CDC *game_dc0 = NULL; + +U0 video_draw_it(CDC *) +{ + gr.dc->color = BLACK; + GrRect(gr.dc, 0, 8, 640, 32); + GrRect(gr.dc, 0, 480-40, 640, 40); + GrBlot(gr.dc, (gr.dc->width/2) - (game_dc->width/2), + (gr.dc->height/2) - (game_dc->height/2), game_dc); +} + + +U0 set_game_mode() +{ + if (is_game_mode) + return; + is_game_mode = TRUE; +} + +U0 set_text_mode() +{ + if (!is_game_mode) + return; + is_game_mode = FALSE; +} + +Bool video_init() +{ + game_surface = DCNew(SCREEN_WIDTH, SCREEN_HEIGHT); + text_surface = DCNew(SCREEN_WIDTH*2, SCREEN_HEIGHT*2); + game_dc = DCNew(SCREEN_WIDTH*2, SCREEN_HEIGHT*2); + game_dc0 = DCNew(SCREEN_WIDTH*2, SCREEN_HEIGHT*2); + DCFill(game_surface, BLACK); + DCFill(text_surface, BLACK); + + set_game_mode; + + video_has_initialised = TRUE; + return TRUE; +} + +U0 video_shutdown() +{ + DCDel(game_surface); + DCDel(text_surface); +} + +U0 video_draw_tile(Tile *tile, uint16 x, uint16 y) +{ + uint8 *pixel = game_surface->body + x + (y * SCREEN_WIDTH); + uint8 *tile_pixel = tile->pixels; + I64 i, j; + if(tile->type == SOLID) + { + for(i=0;ibody + x + y * SCREEN_WIDTH; + uint8 *tile_pixel = tile->pixels; + I64 i, j; + + for(i=0;i clip_x + clip_w || + y > clip_y + clip_h) + { + return; + } + + if (x < clip_x) + { + tx = (clip_x - x); + w = TILE_WIDTH - tx; + x = clip_x; + } + + if (x + w > clip_x + clip_w) + { + w -= ((x + w) - (clip_x + clip_w)); + } + + if (y < clip_y) + { + ty = (clip_y - y); + h = TILE_HEIGHT - ty; + y = clip_y; + } + + if (y + h > clip_y + clip_h) + { + h -= ((y + h) - (clip_y + clip_h)); + } + + uint8 *pixel = game_surface->body + x + (y * SCREEN_WIDTH); + uint8 *tile_pixel = &tile->pixels[tx + (ty * TILE_WIDTH)]; + for(i=0;ibody + x + ((y+TILE_HEIGHT-1) * SCREEN_WIDTH); + uint8 *tile_pixel = tile->pixels; + I64 i, j; + for(i=0;ibody + x + (y * SCREEN_WIDTH); + uint8 *tile_pixel = tile->pixels; + I64 i, j; + if(tile->type == SOLID) + { + for(i=0;ibody + x + (y * SCREEN_WIDTH); + uint8 *tile_pixel = tile->pixels; + I64 i, j; + if(tile->type == TRANSPARENT) + { + for(i=0;ibody, game_surface->body, SCREEN_WIDTH*SCREEN_HEIGHT); + I64 x, y, c; + for (y=0;ycolor = c; + GrRect(game_dc0, x*2, y*2, 2, 2); + } + } + MemCpy(game_dc->body, game_dc0->body, (SCREEN_WIDTH*2) * (SCREEN_HEIGHT*2)); +} + +U0 fade_to_black(uint16 wait_time) +{ + I64 i; + for(i=0;i < 16; i++) + { + cosmo_wait(wait_time); + set_palette_color(i, 0); + video_update(); + } +} + +U0 fade_to_white(uint16 wait_time) +{ + I64 i; + for(i=0;i < 16; i++) + { + cosmo_wait(wait_time); + set_palette_color(i, 23); + video_update(); + } +} + +U0 fade_in_from_black(uint16 wait_time) +{ + I64 i, j=0; + for(i=0;i < 16; i++) + { + if(i == 8) + { + j = 8; + } + set_palette_color(i, i + j); + video_update(); + cosmo_wait(wait_time); + } +} + +U0 fade_to_black_speed_3() +{ + fade_to_black(3); +} + +U0 fade_in_from_black_with_delay_3() +{ + fade_in_from_black(3); +} + +U0 video_draw_fullscreen_image(uint8 *pixels) { + MemCpy(game_surface->body, pixels, 320 * 200); +} + +U0 video_draw_highlight_effect(uint16 x, uint16 y, uint8 type) +{ + I64 i, j; + uint8 *pixel = game_surface->body + x + y * SCREEN_WIDTH; + for(i=0;i= 7) || + type == 1 || + (type == 2 && i >= j)) + { + *pixel |= 8; //set intensity bit + } + pixel++; + } + pixel += SCREEN_WIDTH - TILE_WIDTH; + } +} diff --git a/Vol.HC b/Vol.HC new file mode 100644 index 0000000..9e33445 --- /dev/null +++ b/Vol.HC @@ -0,0 +1,123 @@ +#define MAX_FILES 200 +#define FILENAME_LEN 12 + +U8 *extract(File *vol_file, uint16 index, U8 *buf, uint32 buf_size, uint32 *bytesRead) +{ + file_seek(vol_file, index * 20 + FILENAME_LEN); + uint32 offset = file_read4(vol_file); + uint32 size = file_read4(vol_file); + file_seek(vol_file, offset); + + if (buf == NULL) + { + buf = MAlloc(size); + } else + { + if (buf_size < size) { + size = buf_size; + } + } + + file_read_to_buffer(vol_file, buf, size); + + *bytesRead = size; + + return buf; +} + +uint16 get_index_of_file(File *vol_file, U8 *filename) +{ + U8 volFilenameBuf[FILENAME_LEN+1]; + + uint16 i=0; + for(;i