[Scummvm-git-logs] scummvm master -> 0eafc5808a7e8c08d7e8a9c70622331d2d3a81c3

aquadran aquadran at gmail.com
Sat Mar 6 14:15:52 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
0eafc5808a ICB: Remove async anim loading


Commit: 0eafc5808a7e8c08d7e8a9c70622331d2d3a81c3
    https://github.com/scummvm/scummvm/commit/0eafc5808a7e8c08d7e8a9c70622331d2d3a81c3
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2021-03-06T15:15:48+01:00

Commit Message:
ICB: Remove async anim loading

Changed paths:
    engines/icb/async_generic.cpp
    engines/icb/camera.cpp
    engines/icb/fn_animation.cpp
    engines/icb/fn_interact.cpp
    engines/icb/icon_menu.cpp
    engines/icb/mission.cpp
    engines/icb/p4_pc.cpp
    engines/icb/res_man.cpp
    engines/icb/res_man.h
    engines/icb/res_man_pc.cpp
    engines/icb/res_man_pc.h
    engines/icb/route_manager.cpp
    engines/icb/session.cpp
    engines/icb/speech.cpp


diff --git a/engines/icb/async_generic.cpp b/engines/icb/async_generic.cpp
index 9b64cb305c..e8a2685eb3 100644
--- a/engines/icb/async_generic.cpp
+++ b/engines/icb/async_generic.cpp
@@ -34,138 +34,6 @@
 
 namespace ICB {
 
-#define MAX_async_anims_per_state 24
-#define MAX_mega_async_anims_per_state 24
-__mega_set_names player_generic_anim_async_table[__TOTAL_PLAYER_MODES][MAX_async_anims_per_state] = {
-    // STOOD,   1
-    {__STAND, __BEING_SHOT, __BEING_SHOT_DEAD, __STAND_TO_WALK, __TURN_ON_THE_SPOT_CLOCKWISE, __WALK, __PULL_OUT_WEAPON, __STAND_AND_SHOOT, __STEP_BACKWARD, __SIDESTEP_LEFT,
-     __STRIKE, __WALK_TO_STAND, __LOAD_GUN, __LOAD_GUN_2,
-
-     __WALK_TO_PULL_OUT_WEAPON,
-
-     __CLIMB_DOWN_LADDER_LEFT, __CLIMB_DOWN_LADDER_RIGHT, __SLIDE_DOWN_LADDER, __CLIMB_UP_LADDER_LEFT, __CLIMB_UP_LADDER_RIGHT, __CLIMB_UP_LADDER_RIGHT_TO_STAND,
-     __SLIDE_DOWN_LADDER_TO_STAND, __CLIMB_DOWN_LADDER_RIGHT_TO_STAND,
-
-     __NO_ANIM},
-
-    // WALKING, 2
-    {__WALK_TO_PULL_OUT_WEAPON, __WALK_TO_STAND, __WALK_TO_OTHER_STAND_LEFT_LEG, __RUN, __BEING_SHOT, __BEING_SHOT_DEAD, __HIT_FROM_BEHIND, __STRIKE,
-     __CORD_STAND_TO_CLIMB_UP_LADDER, __STAND_TO_CLIMB_DOWN_LADDER_RIGHT,
-
-     __WALK_UPSTAIRS_LEFT, __WALK_UPSTAIRS_RIGHT, __WALK_DOWNSTAIRS_LEFT, __WALK_DOWNSTAIRS_RIGHT, __WALK_UPSTAIRS_RIGHT_TO_STOOD_ON_STAIRS_FACING_UP,
-
-     __CLIMB_DOWN_LADDER_LEFT, __CLIMB_DOWN_LADDER_RIGHT, __SLIDE_DOWN_LADDER, __CLIMB_UP_LADDER_LEFT, __CLIMB_UP_LADDER_RIGHT, __CLIMB_UP_LADDER_RIGHT_TO_STAND,
-     __SLIDE_DOWN_LADDER_TO_STAND, __CLIMB_DOWN_LADDER_RIGHT_TO_STAND,
-
-     __NO_ANIM},
-
-    // CROUCH_WALK, 3
-    {__STAND_CROUCHED_TO_STAND, __NO_ANIM},
-    // RUNNING,     4
-    {__RUN_TO_STAND, __WALK, __CORD_STAND_TO_CLIMB_UP_LADDER, __STAND_TO_CLIMB_DOWN_LADDER_RIGHT, __RUN_UPSTAIRS_LEFT, __RUN_UPSTAIRS_RIGHT, __RUN_DOWNSTAIRS_LEFT,
-     __RUN_DOWNSTAIRS_RIGHT, __STRIKE, __BEING_SHOT, __BEING_SHOT_DEAD,
-
-     __CLIMB_DOWN_LADDER_LEFT, __CLIMB_DOWN_LADDER_RIGHT, __SLIDE_DOWN_LADDER, __CLIMB_UP_LADDER_LEFT, __CLIMB_UP_LADDER_RIGHT, __CLIMB_UP_LADDER_RIGHT_TO_STAND,
-     __SLIDE_DOWN_LADDER_TO_STAND, __CLIMB_DOWN_LADDER_RIGHT_TO_STAND,
-
-     __NO_ANIM},
-    // crouch to punch 5
-    {__NO_ANIM},
-
-    // CROUCH_TO_STAND_UNARMED, 6
-    {__NO_ANIM},
-    // CROUCH_TO_STAND_ARMED,       7
-    {__NO_ANIM},
-
-    // CROUCHING,       8
-    {__STAND_CROUCHED_TO_STAND, __TURN_ON_THE_SPOT_CLOCKWISE, __NO_ANIM},
-
-    // NEW_AIM, 9
-    {__TURN_ON_THE_SPOT_CLOCKWISE, __STEP_BACKWARD, __STEP_FORWARD, __SIDESTEP_LEFT, __PULL_OUT_WEAPON, __BEING_SHOT, __BEING_SHOT_DEAD, __LOAD_GUN, __LOAD_GUN_2, __NO_ANIM},
-
-    // CROUCH_AIM,  10
-    {__STAND_CROUCHED_TO_STAND, __TURN_ON_THE_SPOT_CLOCKWISE, __STEP_BACKWARD, __SIDESTEP_LEFT, __PULL_OUT_WEAPON, __LOAD_GUN, __LOAD_GUN_CROUCH_2, __NO_ANIM},
-
-    // PUTTING_AWAY_GUN,    11
-    {__NO_ANIM},
-    // PUTTING_AWAY_CROUCH_GUN, 12
-    {__NO_ANIM},
-
-    // LINKING, 13
-    {__NO_ANIM},
-    // GUN LINKING, 14
-    {__NO_ANIM},
-
-    // FAST_LINKING,    15
-    {__NO_ANIM},
-    // EASY_LINKING,    16
-    {__NO_ANIM},
-    // REVERSE_LINKING, 17
-    {__NO_ANIM},
-    // FAST_REVERSE_LINKING,    18
-    {__NO_ANIM},
-    // STILL_LINKING,   19
-    {__NO_ANIM},
-    // INVENTORY,   20
-    {__NO_ANIM},
-    // REMORA,  21
-    {__NO_ANIM},
-
-    // STRIKING,    22
-    {__STAND, __NO_ANIM},
-
-    // ON_STAIRS,   23
-    {__WALK_UPSTAIRS_LEFT, __WALK_UPSTAIRS_RIGHT, __WALK_DOWNSTAIRS_LEFT, __WALK_DOWNSTAIRS_RIGHT,
-
-     __WALK_UPSTAIRS_RIGHT_TO_WALK_DOWNSTAIRS_LEFT, __WALK_UPSTAIRS_LEFT_TO_WALK_DOWNSTAIRS_RIGHT, __WALK_UPSTAIRS_LEFT_TO_STOOD_ON_STAIRS_FACING_UP,
-     __WALK_UPSTAIRS_RIGHT_TO_STOOD_ON_STAIRS_FACING_UP, __WALK_DOWNSTAIRS_RIGHT_TO_WALK_UPSTAIRS_LEFT, __WALK_DOWNSTAIRS_LEFT_TO_WALK_UPSTAIRS_RIGHT,
-     __WALK_DOWNSTAIRS_LEFT_TO_STOOD_ON_STAIRS_FACING_DOWN, __WALK_DOWNSTAIRS_RIGHT_TO_STOOD_ON_STAIRS_FACING_DOWN,
-
-     __NO_ANIM},
-
-    // RUNNING_ON_STAIRS,   24
-    {__RUN_UPSTAIRS_LEFT, __RUN_UPSTAIRS_RIGHT, __RUN_DOWNSTAIRS_LEFT, __RUN_DOWNSTAIRS_RIGHT,
-
-     __WALK_UPSTAIRS_RIGHT_TO_WALK_DOWNSTAIRS_LEFT, __WALK_UPSTAIRS_LEFT_TO_WALK_DOWNSTAIRS_RIGHT, __WALK_UPSTAIRS_LEFT_TO_STOOD_ON_STAIRS_FACING_UP,
-     __WALK_UPSTAIRS_RIGHT_TO_STOOD_ON_STAIRS_FACING_UP, __WALK_DOWNSTAIRS_RIGHT_TO_WALK_UPSTAIRS_LEFT, __WALK_DOWNSTAIRS_LEFT_TO_WALK_UPSTAIRS_RIGHT,
-     __WALK_DOWNSTAIRS_LEFT_TO_STOOD_ON_STAIRS_FACING_DOWN, __WALK_DOWNSTAIRS_RIGHT_TO_STOOD_ON_STAIRS_FACING_DOWN,
-
-     __NO_ANIM},
-
-    // STOOD_ON_STAIRS, 25
-    {__WALK_UPSTAIRS_LEFT, __WALK_UPSTAIRS_RIGHT, __WALK_DOWNSTAIRS_LEFT, __WALK_DOWNSTAIRS_RIGHT,
-
-     __WALK_UPSTAIRS_RIGHT_TO_WALK_DOWNSTAIRS_LEFT, __WALK_UPSTAIRS_LEFT_TO_WALK_DOWNSTAIRS_RIGHT, __WALK_DOWNSTAIRS_RIGHT_TO_WALK_UPSTAIRS_LEFT,
-     __WALK_DOWNSTAIRS_LEFT_TO_WALK_UPSTAIRS_RIGHT, __NO_ANIM},
-
-    // REVERSE_ON_STAIRS,   26
-    {__NO_ANIM},
-
-    // ON_LADDER,   27
-    {__CLIMB_UP_LADDER_LEFT, __CLIMB_UP_LADDER_RIGHT, __CLIMB_DOWN_LADDER_LEFT, __CLIMB_DOWN_LADDER_RIGHT, __CLIMB_UP_LADDER_RIGHT_TO_STAND, __SLIDE_DOWN_LADDER,
-     __SLIDE_DOWN_LADDER_TO_STAND, __CLIMB_DOWN_LADDER_RIGHT_TO_STAND, __NO_ANIM},
-
-    // BEGIN_DOWN_LADDER,   28
-    {__CLIMB_DOWN_LADDER_LEFT, __CLIMB_DOWN_LADDER_RIGHT, __SLIDE_DOWN_LADDER, __CLIMB_UP_LADDER_LEFT, __CLIMB_UP_LADDER_RIGHT, __CLIMB_UP_LADDER_RIGHT_TO_STAND,
-     __SLIDE_DOWN_LADDER_TO_STAND, __CLIMB_DOWN_LADDER_RIGHT_TO_STAND, __NO_ANIM},
-
-    // LEAVE_LADDER,    29
-    {__STAND, __TURN_ON_THE_SPOT_CLOCKWISE, __STAND_TO_WALK, __NO_ANIM},
-
-    // LEAVE_LADDER_BOTTOM, 30
-    {__STAND, __TURN_ON_THE_SPOT_CLOCKWISE, __STAND_TO_WALK, __NO_ANIM},
-
-    // SLIP_SLIDIN_AWAY,    31
-    {__SLIDE_DOWN_LADDER_TO_STAND, __NO_ANIM},
-    // finish reloading 32
-    {__NO_ANIM},
-
-    // fin-normal-reload 33
-    {__NO_ANIM},
-
-    // fin-normal-crouch-reload
-    {__NO_ANIM}};
-
 mcodeFunctionReturnCodes fn_preload_basics(int32 &result, int32 *params) { return (MS->fn_preload_basics(result, params)); }
 
 	// function loads some standard anim and marker files in, designed to be used at session
@@ -181,379 +49,5 @@ mcodeFunctionReturnCodes _game_session::fn_preload_basics(int32 &, int32 *) {
 	return (IR_CONT);
 }
 
-__mega_set_names evil_mega_always_in_memory[] = {__BEING_SHOT, __BEING_SHOT_DEAD, __HIT_FROM_BEHIND, __NO_ANIM};
-
-__mega_set_names good_mega_always_in_memory[] = {__STAND, __NO_ANIM};
-
-__mega_set_names mega_generic_anim_async_table[__TOTAL_WEAPONS][MAX_mega_async_anims_per_state] = {
-    // stood unarmed
-    {__STAND, __TURN_ON_THE_SPOT_CLOCKWISE, __WALK, __WALK_TO_STAND, __WALK_TO_OTHER_STAND_LEFT_LEG, __RUN, __BEING_SHOT, __BEING_SHOT_DEAD,
-
-     __COWER, __COWER_TO_STAND, __HAND_HAIR,
-
-     __STAND_TO_WALK_DOWN_STAIRS_RIGHT, __STAND_TO_WALK_UP_STAIRS_RIGHT, __WALK_UPSTAIRS_RIGHT, __WALK_UPSTAIRS_LEFT, __WALK_DOWNSTAIRS_RIGHT, __WALK_DOWNSTAIRS_LEFT,
-     __STAND_TO_CLIMB_DOWN_LADDER_RIGHT, __STAND_TO_CLIMB_UP_LADDER_RIGHT, __CLIMB_UP_LADDER_LEFT, __CLIMB_UP_LADDER_RIGHT, __CLIMB_DOWN_LADDER_LEFT, __CLIMB_DOWN_LADDER_RIGHT,
-
-     __NO_ANIM},
-    // stood gun
-    {__STAND, __TURN_ON_THE_SPOT_CLOCKWISE, __STAND_AND_AIM, __PULL_OUT_WEAPON, __STAND_AND_SHOOT, __BEING_SHOT, __BEING_SHOT_DEAD,
-
-     // guard idle anims
-     __LOOK_AT_WATCH, __STRETCH, __SCRATCH,
-
-     __STAND_TO_WALK_DOWN_STAIRS_RIGHT, __STAND_TO_WALK_UP_STAIRS_RIGHT, __WALK_UPSTAIRS_RIGHT, __WALK_UPSTAIRS_LEFT, __WALK_DOWNSTAIRS_RIGHT, __WALK_DOWNSTAIRS_LEFT,
-
-     __NO_ANIM},
-    // crouched unarmed
-    {__NO_ANIM},
-    // crouched gun
-    {__STAND, __STAND_CROUCHED_TO_STAND, __BEING_SHOT, __BEING_SHOT_DEAD,
-
-     __NO_ANIM}};
-
-bool8 Check_preload(__mega_set_names anim, int on_screen, _vox_image *I) {
-	// anim exists so will need preloading
-	if (I->IsAnimTable(anim)) {
-		// check info file, otherwise return false
-		if (rs_anims->Res_async_open(I->get_info_name(anim), I->info_name_hash[anim], I->base_path, I->base_path_hash) == 0)
-			return FALSE8;
-
-		// if onscreen we'll also need the anim file so check it's in...
-		if ((on_screen) && (rs_anims->Res_async_open(I->get_anim_name(anim), I->anim_name_hash[anim], I->base_path, I->base_path_hash) == 0))
-			return FALSE8;
-	}
-
-	// anim doesn't exist so we are okay since we won't be using it...
-	// or all anims in memory so we're okay...
-	return TRUE8;
-}
-
-#define ASYNC_GAME_CYCLES 3           // 1/4 second
-#define TOO_MANY_DEFRAGS 2            // 2/3 per cycle
-#define ENOUGH_OLD_MEMORY (10 * 1024) // 20k
-#define AMOUNT_TO_GRAB (50 * 1024)    // 50k
-
-// helps out the asyncer by perhaps turning it off on ocasion or something
-void _game_session::Async_helper() {
-	async_counter++;
-
-	// triggered each second
-	if (async_counter >= ASYNC_GAME_CYCLES) {
-
-		// turn async on by default every second..
-		async_off = 0;
-
-		// too many defrags in last second
-		if (rs_anims->amount_of_defrags >= TOO_MANY_DEFRAGS) {
-			// enough old memory to make it worth doing a big flush, on the basis that the resources flushed out will probabily
-			// not be used...
-			if (rs_anims->Fetch_old_memory(ASYNC_GAME_CYCLES) > ENOUGH_OLD_MEMORY) {
-				const char *flush_cluster = "mem";
-				uint32 flush_cluster_hash = HashString(flush_cluster);
-				uint32 flush_file_hash = 0xbabe;
-
-				// grab the memory
-				rs_anims->Res_alloc(flush_file_hash, flush_cluster, flush_cluster_hash, AMOUNT_TO_GRAB);
-
-				// now purge it out...
-				rs_anims->Res_purge(NULL, flush_file_hash, flush_cluster, flush_cluster_hash);
-
-				rs_anims->Defrag();
-			} else {
-				// all the memory is being used so just switch ther asyncer off for this second...
-				async_off = 1;
-			}
-		}
-
-		// reset
-
-		rs_anims->amount_of_defrags = 0;
-		async_counter = 0;
-	}
-}
-
-void _game_session::Service_generic_async() {
-	// called for each mega servicing their generic cache ahead needs
-	// done after each mega is processes as this is nearest to the initial 'time of need' yet allows some space to be bought between
-	// megas; maybe
-	// there are 2 groups - the player who works from state and megas that work from __weapon
-
-	// ultimately, this is PSX only
-	_player_stat prev;
-	static uint32 list_pos = 0;
-	static uint32 depth_pos = 0;
-
-#define PLAYER_FILE player_generic_anim_async_table[player_stat_use][M->async_list_pos]
-#define MEGA_FILE mega_generic_anim_async_table[M->weapon][M->async_list_pos]
-
-	// someone is talking, don't async
-	if (speech_info[CONV_ID].total_subscribers > 0)
-		return;
-
-	// has been turned off dont async
-
-	if (async_off)
-		return;
-
-	if (cur_id == player.Fetch_player_id()) {
-		// its the player
-
-		// check the icons are loaded in
-
-#define SPECIAL_PLAYER_FILE player_generic_anim_async_table[list_pos][depth_pos]
-		// now service the other sets
-		if (!init_asyncs) {
-			// prime the players 4 async vox-images
-			// this system will ensure the first 3 anims in each player state for each weapon set will be nearby
-			init_asyncs = TRUE8;
-
-			sync_set[0].___init(M->chr_name, M->anim_set, __NOT_ARMED);
-			sync_set[1].___init(M->chr_name, M->anim_set, __GUN);
-			sync_set[2].___init(M->chr_name, M->anim_set, __CROUCH_NOT_ARMED);
-			sync_set[3].___init(M->chr_name, M->anim_set, __CROUCH_GUN);
-
-			list_pos = 0;
-			depth_pos = 0;
-
-			cur_sync_set = 0; // start in set 0
-			caching = FALSE8;
-
-			Tdebug("special_async.txt", "reseting %s %s", M->chr_name, M->anim_set);
-		}
-
-		// check that current sync set is not the current set - which will be covered by other async code
-		if (cur_sync_set == (uint32)M->Fetch_pose()) {
-			cur_sync_set++;
-			if (cur_sync_set == 4) {
-				cur_sync_set = 0;
-			}
-
-			// make sure we're not caching (because the anim might not exist in this set...
-			caching = 0;
-
-			Tdebug("special_async.txt", "\nskipping to set %d", cur_sync_set);
-		}
-
-		if ((!caching) && (sync_set[cur_sync_set].IsAnimTable(SPECIAL_PLAYER_FILE))) { // if exists - build filename too
-			caching = TRUE8;
-			Tdebug("special_async.txt", "going to load list %d, depth %d", list_pos, depth_pos);
-			//  has current pending loaded
-		}
-
-		if ((caching) && (rs_anims->Res_async_open(sync_set[cur_sync_set].get_info_name(SPECIAL_PLAYER_FILE), sync_set[cur_sync_set].info_name_hash[SPECIAL_PLAYER_FILE],
-		                                           sync_set[cur_sync_set].base_path, sync_set[cur_sync_set].base_path_hash))) {
-			if (rs_anims->Res_async_open(sync_set[cur_sync_set].get_anim_name(SPECIAL_PLAYER_FILE), sync_set[cur_sync_set].anim_name_hash[SPECIAL_PLAYER_FILE],
-			                             sync_set[cur_sync_set].base_path, sync_set[cur_sync_set].base_path_hash)) {
-				caching = FALSE8; // loaded it
-			}
-		}
-
-		if (!caching) {
-			// move the state on one too - we do all the states then go deeper on each... etc.
-			do {
-				// next set
-				cur_sync_set++;
-
-				// we've done all the ones here for all sets
-				if (cur_sync_set == 4) {
-					// reset set
-					cur_sync_set = 0;
-
-					// next anim
-					list_pos++;
-
-					// we've done all the anims in all the sets...
-					if (list_pos == 12) {
-						// reset...
-						list_pos = 0;
-
-						//  next depth level
-						depth_pos++; // point to 1 deeper in this set
-						if (depth_pos == 3)
-							depth_pos = 0; // cant go too deep
-					}
-				}
-			} while (SPECIAL_PLAYER_FILE == __NO_ANIM);
-
-			Tdebug("special_async.txt", " moving to list %d, depth %d", list_pos, depth_pos);
-		}
-
-		// check for change of status
-		if (player_stat_was != player.player_status) {
-			prev = player_stat_use; // record old
-
-			if ((player.player_status == LINKING) || (player.player_status == FAST_LINKING) || (player.player_status == EASY_LINKING) ||
-			    (player.player_status == REVERSE_LINKING) || (player.player_status == FAST_REVERSE_LINKING) || (player.player_status == STILL_LINKING)) {
-				player_stat_use = player.stat_after_link; // look ahead and start asycing from players next mode
-			} else {
-				player_stat_use = player.player_status; // use current real mode
-			}
-
-			if (prev != player_stat_use) { // dont reset when link finished and changes to real mode
-				// player has changed status so we must reset the cache list and start loading new stuff
-				M->async_list_pos = 0; // reset list position
-				M->asyncing = 0;       // cancel 'wait' for file to load - change instantly to new list
-			}
-		}
-
-		// record current status ready for check-for-change next time
-		player_stat_was = player.player_status;
-
-		// are we waiting for current file to load?
-		if (M->asyncing) {
-			// has current pending loaded
-			if (rs_anims->Res_async_open(I->get_info_name(PLAYER_FILE), I->info_name_hash[PLAYER_FILE], I->base_path, I->base_path_hash)) {
-				// Always async the players anims
-				if (rs_anims->Res_async_open(I->get_anim_name(PLAYER_FILE), I->anim_name_hash[PLAYER_FILE], I->base_path, I->base_path_hash)) {
-					M->async_list_pos++;  // next
-					M->asyncing = FALSE8; // not currently loading
-					return;               // try to even out the processor load as res-open itself is very slow
-				} else {
-					M->async_list_pos++;  // next
-					M->asyncing = FALSE8; // not currently loading
-					return;               // try to even out the processor load as res-open itself is very slow
-				}
-			} else
-				return; // not loaded yet
-		}
-
-		// not waiting for file to load so start on the next
-		if (PLAYER_FILE == __NO_ANIM) {
-			M->asyncing = FALSE8; // not currently loading so dont check if loaded
-			return;               // done the list for this state
-		}
-
-		// set file loading
-
-		if (I->IsAnimTable(PLAYER_FILE)) {
-			M->asyncing = TRUE8;
-		} else {
-			M->async_list_pos++;  // next
-			M->asyncing = FALSE8; // not currently loading
-		}
-
-	} else { // normal    M E G A
-
-		// Always async the player animations
-		// but only async the mega animations if on the screen
-		int on_screen = Object_visible_to_camera(cur_id);
-
-		// first ensure we have being_shot,being_shot_dead and hit_from_behind in memory at all times
-
-		int ani = 0;
-
-		if (M->is_evil) {
-			while (evil_mega_always_in_memory[ani] != __NO_ANIM) {
-				Check_preload(evil_mega_always_in_memory[ani], on_screen, I);
-				ani++;
-			}
-		} else {
-			while (good_mega_always_in_memory[ani] != __NO_ANIM) {
-				Check_preload(good_mega_always_in_memory[ani], on_screen, I);
-				ani++;
-			}
-		}
-		// index by M->weapon
-
-		if (M->async_weapon != M->weapon) {
-			// changed weapon/pose
-			M->async_weapon = M->weapon;
-			M->async_list_pos = 0; // reset list position
-			M->asyncing = 0;       // cancel 'wait' for file to load - change instantly to new list
-		}
-
-		// are we waiting for current file to load?
-		if (M->asyncing) {
-			// has current pending loaded
-			if (rs_anims->Res_async_open(I->get_info_name(MEGA_FILE), I->info_name_hash[MEGA_FILE], I->base_path, I->base_path_hash)) {
-				// Async the mega animations if on the screen
-				if (on_screen) {
-					if (rs_anims->Res_async_open(I->get_anim_name(MEGA_FILE), I->anim_name_hash[MEGA_FILE], I->base_path, I->base_path_hash)) {
-						M->async_list_pos++;  // next
-						M->asyncing = FALSE8; // not currently loading
-						return;               // try to even out the processor load as res-open itself is very slow
-					}
-				} else {
-					M->async_list_pos++;  // next
-					M->asyncing = FALSE8; // not currently loading
-					return;               // try to even out the processor load as res-open itself is very slow
-				}
-			} else
-				return; // not loaded yet
-		}
-
-		// not waiting for file to load so start on the next
-		if (MEGA_FILE == __NO_ANIM) {
-			M->asyncing = FALSE8; // not currently loading so dont check if loaded
-			return;               // done the list for this state
-		}
-
-		// set file loading
-
-		if (I->IsAnimTable(MEGA_FILE)) {
-			M->asyncing = TRUE8;
-		} else {
-			M->async_list_pos++;  // next
-			M->asyncing = FALSE8; // not currently loading
-		}
-	}
-}
-
-bool8 _game_session::Route_async_ready(bool8 run, bool8 turn) {
-	// special pre-route code to ensure all required anims are in memory before we start routing
-
-	// Always async the player animations
-	// but only async the mega animations if on the screen
-
-	int on_screen;
-
-	// default not visable...
-	on_screen = 0;
-
-	// more complex version of visible code
-	if (Object_visible_to_camera(cur_id)) {
-		bool8 result = TRUE8;
-		PXvector filmPosition;
-		PXWorldToFilm(M->actor_xyz, set.GetCamera(), result, filmPosition);
-
-		if (filmPosition.z < -g_actor_hither_plane) {
-			VECTOR v;
-			v.vx = (int32)M->actor_xyz.x;
-			v.vy = (int32)M->actor_xyz.y;
-			v.vz = (int32)M->actor_xyz.z;
-
-			SVECTOR orient;
-			orient.vx = 0;
-			orient.vy = 0;
-			orient.vz = 0;
-
-			// finally if this is true then we are okay so on_screen is true
-			if (QuickActorCull((psxCamera *)&(set.GetCamera()), &v, &orient) != 1)
-				on_screen = 1;
-		}
-	}
-
-	L->looping = 1;
-
-	if ((run) && (!Check_preload(__RUN, on_screen, I)))
-		return FALSE8;
-	if ((run) && (!Check_preload(__STAND_TO_RUN, on_screen, I)))
-		return FALSE8;
-	if ((run) && (!Check_preload(__RUN_TO_STAND, on_screen, I)))
-		return FALSE8;
-	else if ((!run) && (!Check_preload(__WALK, on_screen, I)))
-		return FALSE8;
-	else if ((!run) && (!Check_preload(__WALK_TO_STAND, on_screen, I)))
-		return FALSE8;
-	else if ((!run) && (!Check_preload(__WALK_TO_OTHER_STAND_LEFT_LEG, on_screen, I)))
-		return FALSE8;
-	else if ((!run) && (!Check_preload(__STAND_TO_WALK, on_screen, I)))
-		return FALSE8;
-	else if ((turn) && (!Check_preload(__TURN_ON_THE_SPOT_CLOCKWISE, on_screen, I)))
-		return FALSE8;
-
-	// all in
-	return TRUE8;
-}
 
 } // End of namespace ICB
diff --git a/engines/icb/camera.cpp b/engines/icb/camera.cpp
index c5a04effda..6d6b7a8e55 100644
--- a/engines/icb/camera.cpp
+++ b/engines/icb/camera.cpp
@@ -384,7 +384,6 @@ void _game_session::Camera_director() {
 
 				// force in the anims of megas not playing stand - techs and the like
 				MS->One_logic_cycle();
-				rs_anims->async_flush();
 			}
 		}
 	}
diff --git a/engines/icb/fn_animation.cpp b/engines/icb/fn_animation.cpp
index 11481954a7..9902d4f4a7 100644
--- a/engines/icb/fn_animation.cpp
+++ b/engines/icb/fn_animation.cpp
@@ -621,11 +621,11 @@ mcodeFunctionReturnCodes _game_session::fn_reverse_generic_anim(int32 &, int32 *
 	if (L->looping == 100) {
 		// setup
 		// psx async loading check - is file in memory
-		if (!rs_anims->Res_async_open(I->get_info_name(M->next_anim_type), I->info_name_hash[M->next_anim_type], I->base_path, I->base_path_hash))
+		if (!rs_anims->Res_open(I->get_info_name(M->next_anim_type), I->info_name_hash[M->next_anim_type], I->base_path, I->base_path_hash))
 			return IR_REPEAT;
 
 		if ((Object_visible_to_camera(cur_id)) &&
-		    (!rs_anims->Res_async_open(I->get_anim_name(M->next_anim_type), I->anim_name_hash[M->next_anim_type], I->base_path, I->base_path_hash)))
+		    (!rs_anims->Res_open(I->get_anim_name(M->next_anim_type), I->anim_name_hash[M->next_anim_type], I->base_path, I->base_path_hash)))
 			return IR_REPEAT;
 
 		L->cur_anim_type = M->next_anim_type; // anim now in memory
@@ -680,11 +680,11 @@ mcodeFunctionReturnCodes _game_session::fn_play_generic_anim(int32 &, int32 *par
 
 	if (L->looping == 100) {
 		// psx async loading check - is file in memory
-		if (!rs_anims->Res_async_open(I->get_info_name(M->next_anim_type), I->info_name_hash[M->next_anim_type], I->base_path, I->base_path_hash))
+		if (!rs_anims->Res_open(I->get_info_name(M->next_anim_type), I->info_name_hash[M->next_anim_type], I->base_path, I->base_path_hash))
 			return IR_REPEAT;
 
 		if ((Object_visible_to_camera(cur_id)) &&
-		    (!rs_anims->Res_async_open(I->get_anim_name(M->next_anim_type), I->anim_name_hash[M->next_anim_type], I->base_path, I->base_path_hash)))
+		    (!rs_anims->Res_open(I->get_anim_name(M->next_anim_type), I->anim_name_hash[M->next_anim_type], I->base_path, I->base_path_hash)))
 			return IR_REPEAT;
 
 		// anim found and started ok
@@ -752,11 +752,11 @@ mcodeFunctionReturnCodes _game_session::fn_easy_play_generic_anim(int32 &, int32
 	if (L->looping == 100) {
 		// setup
 		// psx async loading check - is file in memory
-		if (!rs_anims->Res_async_open(I->get_info_name(M->next_anim_type), I->info_name_hash[M->next_anim_type], I->base_path, I->base_path_hash))
+		if (!rs_anims->Res_open(I->get_info_name(M->next_anim_type), I->info_name_hash[M->next_anim_type], I->base_path, I->base_path_hash))
 			return IR_REPEAT;
 
 		if ((Object_visible_to_camera(cur_id)) &&
-		    (!rs_anims->Res_async_open(I->get_anim_name(M->next_anim_type), I->anim_name_hash[M->next_anim_type], I->base_path, I->base_path_hash)))
+		    (!rs_anims->Res_open(I->get_anim_name(M->next_anim_type), I->anim_name_hash[M->next_anim_type], I->base_path, I->base_path_hash)))
 			return IR_REPEAT;
 
 		L->cur_anim_type = M->next_anim_type; // anim now in memory
@@ -818,11 +818,11 @@ mcodeFunctionReturnCodes _game_session::fn_easy_play_generic_anim_with_pan(int32
 		// setup
 
 		// psx async loading check - is file in memory
-		if (!rs_anims->Res_async_open(I->get_info_name(M->next_anim_type), I->info_name_hash[M->next_anim_type], I->base_path, I->base_path_hash))
+		if (!rs_anims->Res_open(I->get_info_name(M->next_anim_type), I->info_name_hash[M->next_anim_type], I->base_path, I->base_path_hash))
 			return IR_REPEAT;
 
 		if ((Object_visible_to_camera(cur_id)) &&
-		    (!rs_anims->Res_async_open(I->get_anim_name(M->next_anim_type), I->anim_name_hash[M->next_anim_type], I->base_path, I->base_path_hash)))
+		    (!rs_anims->Res_open(I->get_anim_name(M->next_anim_type), I->anim_name_hash[M->next_anim_type], I->base_path, I->base_path_hash)))
 			return IR_REPEAT;
 
 		L->cur_anim_type = M->next_anim_type; // anim now in memory
@@ -889,11 +889,11 @@ mcodeFunctionReturnCodes _game_session::fn_easy_play_custom_anim_with_pan(int32
 	// anim is in memory so do first frame then pass on to normal logic path
 	if (L->looping == 100) {
 		// psx async loading check - is file in memory
-		if (!rs_anims->Res_async_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
+		if (!rs_anims->Res_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
 			return IR_REPEAT;
 
 		if ((Object_visible_to_camera(cur_id)) &&
-		    (!rs_anims->Res_async_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
+		    (!rs_anims->Res_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
 			return IR_REPEAT;
 
 		I->Promote_non_generic(); // swap out the _NON_GENERIC to safe place
@@ -938,11 +938,11 @@ mcodeFunctionReturnCodes _game_session::fn_set_to_last_frame_generic_anim(int32
 	}
 
 	// psx async loading check - is file in memory
-	if (!rs_anims->Res_async_open(I->get_info_name(M->next_anim_type), I->info_name_hash[M->next_anim_type], I->base_path, I->base_path_hash))
+	if (!rs_anims->Res_open(I->get_info_name(M->next_anim_type), I->info_name_hash[M->next_anim_type], I->base_path, I->base_path_hash))
 		return IR_REPEAT;
 
 	if ((Object_visible_to_camera(cur_id)) &&
-	    (!rs_anims->Res_async_open(I->get_anim_name(M->next_anim_type), I->anim_name_hash[M->next_anim_type], I->base_path, I->base_path_hash)))
+	    (!rs_anims->Res_open(I->get_anim_name(M->next_anim_type), I->anim_name_hash[M->next_anim_type], I->base_path, I->base_path_hash)))
 		return IR_REPEAT;
 
 	L->cur_anim_type = M->next_anim_type; // anim now in memory
@@ -974,11 +974,11 @@ mcodeFunctionReturnCodes _game_session::fn_set_to_first_frame_generic_anim(int32
 	}
 
 	// psx async loading check - is file in memory
-	if (!rs_anims->Res_async_open(I->get_info_name(M->next_anim_type), I->info_name_hash[M->next_anim_type], I->base_path, I->base_path_hash))
+	if (!rs_anims->Res_open(I->get_info_name(M->next_anim_type), I->info_name_hash[M->next_anim_type], I->base_path, I->base_path_hash))
 		return IR_REPEAT;
 
 	if ((Object_visible_to_camera(cur_id)) &&
-	    (!rs_anims->Res_async_open(I->get_anim_name(M->next_anim_type), I->anim_name_hash[M->next_anim_type], I->base_path, I->base_path_hash)))
+	    (!rs_anims->Res_open(I->get_anim_name(M->next_anim_type), I->anim_name_hash[M->next_anim_type], I->base_path, I->base_path_hash)))
 		return IR_REPEAT;
 
 	L->cur_anim_type = M->next_anim_type; // anim now in memory
@@ -1005,10 +1005,10 @@ mcodeFunctionReturnCodes _game_session::fn_set_to_first_frame_custom_anim(int32
 	}
 
 	// psx async loading check - is file in memory
-	if (!rs_anims->Res_async_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
+	if (!rs_anims->Res_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
 		return IR_REPEAT;
 
-	if ((Object_visible_to_camera(cur_id)) && (!rs_anims->Res_async_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
+	if ((Object_visible_to_camera(cur_id)) && (!rs_anims->Res_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
 		return IR_REPEAT;
 
 	I->Promote_non_generic(); // swap out the _NON_GENERIC to safe place
@@ -1035,10 +1035,10 @@ mcodeFunctionReturnCodes _game_session::fn_set_to_last_frame_custom_anim(int32 &
 	}
 
 	// psx async loading check - is file in memory
-	if (!rs_anims->Res_async_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
+	if (!rs_anims->Res_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
 		return IR_REPEAT;
 
-	if ((Object_visible_to_camera(cur_id)) && (!rs_anims->Res_async_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
+	if ((Object_visible_to_camera(cur_id)) && (!rs_anims->Res_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
 		return IR_REPEAT;
 
 	I->Promote_non_generic(); // swap out the _NON_GENERIC to safe place
@@ -1110,11 +1110,11 @@ mcodeFunctionReturnCodes _game_session::fn_prime_custom_anim(int32 &, int32 *par
 	// anim is in memory so do first frame then pass on to normal logic path
 	if (L->looping == 100) {
 		// psx async loading check - is file in memory
-		if (!rs_anims->Res_async_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
+		if (!rs_anims->Res_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
 			return IR_REPEAT;
 
 		if ((Object_visible_to_camera(cur_id)) &&
-		    (!rs_anims->Res_async_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
+		    (!rs_anims->Res_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
 			return IR_REPEAT;
 	}
 
@@ -1143,11 +1143,11 @@ mcodeFunctionReturnCodes _game_session::fn_play_custom_anim(int32 &result, int32
 	// anim is in memory so do first frame then pass on to normal logic path
 	if (L->looping == 100) {
 		// psx async loading check - is file in memory
-		if (!rs_anims->Res_async_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
+		if (!rs_anims->Res_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
 			return IR_REPEAT;
 
 		if ((Object_visible_to_camera(cur_id)) &&
-		    (!rs_anims->Res_async_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
+		    (!rs_anims->Res_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
 			return IR_REPEAT;
 
 		I->Promote_non_generic(); // swap out the _NON_GENERIC to safe place
@@ -1184,11 +1184,11 @@ mcodeFunctionReturnCodes _game_session::fn_reverse_custom_anim(int32 &, int32 *p
 	// anim is in memory so do first frame then pass on to normal logic path
 	if (L->looping == 100) {
 		// psx async loading check - is file in memory
-		if (!rs_anims->Res_async_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
+		if (!rs_anims->Res_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
 			return IR_REPEAT;
 
 		if ((Object_visible_to_camera(cur_id)) &&
-		    (!rs_anims->Res_async_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
+		    (!rs_anims->Res_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
 			return IR_REPEAT;
 
 		I->Promote_non_generic(); // swap out the _NON_GENERIC to safe place
@@ -1236,11 +1236,11 @@ mcodeFunctionReturnCodes _game_session::fn_easy_play_custom_anim(int32 &result,
 	// anim is in memory so do first frame then pass on to normal logic path
 	if (L->looping == 100) {
 		// psx async loading check - is file in memory
-		if (!rs_anims->Res_async_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
+		if (!rs_anims->Res_open(I->get_info_name(__NON_GENERIC), I->info_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash))
 			return IR_REPEAT;
 
 		if ((Object_visible_to_camera(cur_id)) &&
-		    (!rs_anims->Res_async_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
+		    (!rs_anims->Res_open(I->get_anim_name(__NON_GENERIC), I->anim_name_hash[__NON_GENERIC], I->base_path, I->base_path_hash)))
 			return IR_REPEAT;
 
 		I->Promote_non_generic(); // swap out the _NON_GENERIC to safe place
diff --git a/engines/icb/fn_interact.cpp b/engines/icb/fn_interact.cpp
index 68510ac37f..03d549f844 100644
--- a/engines/icb/fn_interact.cpp
+++ b/engines/icb/fn_interact.cpp
@@ -290,7 +290,7 @@ mcodeFunctionReturnCodes _game_session::Core_prop_interact(int32 & /*result*/, i
 		}
 
 		// start psx asyncing the anim - may already be doing so if scripts are written properly!
-		if (rs_anims->Res_async_open(I->get_info_name(anim), I->info_name_hash[anim], I->base_path, I->base_path_hash) == 0)
+		if (rs_anims->Res_open(I->get_info_name(anim), I->info_name_hash[anim], I->base_path, I->base_path_hash) == 0)
 			return IR_REPEAT;
 
 		// we are now looping, having done the init
@@ -431,7 +431,7 @@ mcodeFunctionReturnCodes _game_session::Core_prop_interact(int32 & /*result*/, i
 			anim = Fetch_generic_anim_from_ascii(anim_name);
 
 		// in memory yet?
-		if (rs_anims->Res_async_open(I->get_info_name(anim), I->info_name_hash[anim], I->base_path, I->base_path_hash)) {
+		if (rs_anims->Res_open(I->get_info_name(anim), I->info_name_hash[anim], I->base_path, I->base_path_hash)) {
 			L->cur_anim_type = anim;
 			L->anim_pc = 0;
 			L->looping = 4; // go straight to play anim
diff --git a/engines/icb/icon_menu.cpp b/engines/icb/icon_menu.cpp
index e05cc47a4c..a3b5248b1b 100644
--- a/engines/icb/icon_menu.cpp
+++ b/engines/icb/icon_menu.cpp
@@ -309,13 +309,9 @@ void _icon_menu::PreloadIcon(const char *pcIconPath, const char *pcIconName) {
 	char pcFullIconName[MAXLEN_URL];
 	sprintf(pcFullIconName, "%s%s.%s", pcIconPath, pcIconName, PX_BITMAP_EXT);
 
-#if defined(_PSX)
-	const char *pcFullIconName = pcIconName;
-#endif // #if defined(_PSX)
-
 	// Open the icon resource.
 	nFullIconNameHash = NULL_HASH;
-	rs_icons->Res_async_open(pcFullIconName, nFullIconNameHash, m_pcIconCluster, m_nIconClusterHash);
+	rs_icons->Res_open(pcFullIconName, nFullIconNameHash, m_pcIconCluster, m_nIconClusterHash);
 }
 
 const char *_icon_menu::GetLastSelection() {
diff --git a/engines/icb/mission.cpp b/engines/icb/mission.cpp
index 86652382ad..ba700074a3 100644
--- a/engines/icb/mission.cpp
+++ b/engines/icb/mission.cpp
@@ -361,9 +361,6 @@ uint32 _mission::Game_cycle() {
 
 	rs_anims->Garbage_removal();
 
-	// check async
-	rs1->async_checkArray();
-
 	// update the sound engine
 	UpdateHearableSounds();
 
@@ -1137,10 +1134,8 @@ __load_result Load_game(const char *filename) {
 
 	// run a logic cycle to get those anims caching!
 	MS->One_logic_cycle();
-	rs_anims->async_flush();
 	MS->Camera_director();
 	MS->One_logic_cycle();
-	rs_anims->async_flush();
 
 	return __LOAD_OK;
 }
diff --git a/engines/icb/p4_pc.cpp b/engines/icb/p4_pc.cpp
index f558782ade..9f649e6012 100644
--- a/engines/icb/p4_pc.cpp
+++ b/engines/icb/p4_pc.cpp
@@ -203,24 +203,24 @@ void InitEngine(const char *lpCmdLine) {
 	Memory_stats();
 
 	// Animations
-	rs1 = new res_man(ANIMATION_BUFFER_SIZE, false); // TODO: Should be true, but threads are broken atm.
+	rs1 = new res_man(ANIMATION_BUFFER_SIZE);
 	rs1->Set_auto_timeframe_advance();
 	rs_anims = rs1;
 
 	// Icons, Fonts and Remora
-	rs3 = new res_man(BITMAP_BUFFER_SIZE, false);
+	rs3 = new res_man(BITMAP_BUFFER_SIZE);
 	rs3->Set_auto_timeframe_advance();
 	rs_icons = rs3;
 	rs_remora = rs3;
 	rs_font = rs3;
 
 	// Stage
-	rs2 = new res_man(BACKGROUND_BUFFER_SIZE, false);
+	rs2 = new res_man(BACKGROUND_BUFFER_SIZE);
 	rs2->Set_auto_timeframe_advance();
 	rs_bg = rs2;
 
 	// Privates
-	private_session_resman = new res_man(PRIVATE_RESMAN_SIZE, false); // size, no ASYNC
+	private_session_resman = new res_man(PRIVATE_RESMAN_SIZE);
 
 	// Initalize the Revolution Render Device
 	InitRevRenderDevice();
diff --git a/engines/icb/res_man.cpp b/engines/icb/res_man.cpp
index e77a2aa86e..50b2178cc1 100644
--- a/engines/icb/res_man.cpp
+++ b/engines/icb/res_man.cpp
@@ -154,8 +154,6 @@ void res_man::Defrag() {
 
 	// just to be on the safe side, finish all async stuff, we can't risk any async going to addresses we are moving about...
 
-	async_flush();
-
 	do {
 
 		Tdebug("defrag.txt", "\nlooking at bloc %d", cur_block);
@@ -242,7 +240,7 @@ void res_man::Defrag() {
 	// finished - should be done.
 }
 
-void res_man::Initialise(uint32 memory_tot, uint32 threadFlag) {
+void res_man::Initialise(uint32 memory_tot) {
 	total_free_memory = memory_tot;
 	total_pool = memory_tot; // kept for error referencing and so on
 
@@ -254,12 +252,6 @@ void res_man::Initialise(uint32 memory_tot, uint32 threadFlag) {
 
 	Reset();
 
-	// start async thread etc..
-	if (threadFlag)
-		OpenAsync();
-	else
-		hasThread = 0;
-
 	amount_of_defrags = 0;
 
 	Tdebug("resman.txt", "made resman - %d", total_pool);
@@ -298,9 +290,6 @@ res_man::~res_man() {
 
 	delete[] memory_base;
 	delete[] mem_list;
-
-	// close async thread.
-	CloseAsync();
 }
 
 uint32 res_man::Fetch_old_memory(int number_of_cycles) {
@@ -364,46 +353,6 @@ uint8 *res_man::Res_open(const char *url, uint32 &url_hash, const char *cluster,
 	return (ret);
 }
 
-// If hash or cluster_hash == NULL_HASH then the hash of url/cluster_url
-// is computed and stored in hash/cluster_hash
-uint8 *res_man::Res_async_open(const char *url, uint32 &url_hash, const char *cluster, uint32 &cluster_hash, int compressed) {
-	// pc does not have async for now (well i know it does but i'm switching it off)
-	return Res_open(url, url_hash, cluster, cluster_hash, compressed);
-
-	// if this is a cluster then fatal error (cant res_async_open a cluster directly like you can open one)
-	if ((url_hash == NULL_HASH) && (url == NULL)) {
-		warning("cant res_async_open a cluster directly. loading");
-		return Res_open(url, url_hash, cluster, cluster_hash, compressed);
-	}
-
-	// make the hash names if we need to
-	MakeHash(url, url_hash);
-	MakeHash(cluster, cluster_hash);
-
-	RMParams params;
-	uint32 time = 0;
-
-	params.url_hash = url_hash;
-	params.cluster = cluster;
-	params.cluster_hash = cluster_hash;
-	params.mode = RM_ASYNCLOAD;
-	params.compressed = compressed;
-	params.not_ready_yet = 0;
-
-	if ((px.logic_timing) && (px.mega_timer)) {
-		time = GetMicroTimer();
-	}
-
-	uint8 *ret = this->Internal_open(&params, NULL);
-
-	if ((px.logic_timing) && (px.mega_timer)) {
-		time = GetMicroTimer() - time;
-		g_mission->resman_logic_time += time;
-	}
-
-	return (ret);
-}
-
 void res_man::Advance_time_stamp() {
 	// add one to the time frame
 	// user modules must decide when appropriate to increase
@@ -417,11 +366,9 @@ res_man::res_man() {
 	memory_base = NULL;
 	max_mem_blocks = 0;
 	mem_list = NULL;
-	hResManMutex = NULL;
-	hRunMutex = NULL;
 }
 
-res_man::res_man(uint32 memory_tot, uint32 threadFlag) {
+res_man::res_man(uint32 memory_tot) {
 	// object constructor - allocaes the memory pool for this manager
 
 	memory_base = AllocMemory(memory_tot);
@@ -430,11 +377,9 @@ res_man::res_man(uint32 memory_tot, uint32 threadFlag) {
 	mem_list = new mem[max_mem_blocks];
 	mem_offset_list = new mem_offset[max_mem_blocks];
 	num_mem_offsets = 0;
-	hResManMutex = NULL;
-	hRunMutex = NULL;
 
 	// Setup everything up correctly
-	Initialise(memory_tot, threadFlag);
+	Initialise(memory_tot);
 }
 
 void res_man::Construct(uint8 *base, uint32 size, mem *memList, mem_offset *offsetList, uint32 nMemBlocks) {
@@ -450,7 +395,7 @@ void res_man::Construct(uint8 *base, uint32 size, mem *memList, mem_offset *offs
 	max_mem_blocks = nMemBlocks;
 
 	// Setup everything up correctly
-	Initialise(size, 0);
+	Initialise(size);
 }
 
 void res_man::Res_purge(const char *url, uint32 url_hash, const char *cluster, uint32 cluster_hash, uint32 fatal) {
@@ -862,8 +807,6 @@ uint32 res_man::FindMemBlock(uint32 adj_len, RMParams *params) {
 			bool8 debug_state = zdebug;
 			zdebug = TRUE8;
 
-			async_flush();
-
 			uint16 *age_table = new uint16[MAX_MEM_BLOCKS];
 			uint32 total_age = 0;
 			uint32 cur_age = 0; // index in trash loop to current age to remove
diff --git a/engines/icb/res_man.h b/engines/icb/res_man.h
index 2643e641f5..85b162f374 100644
--- a/engines/icb/res_man.h
+++ b/engines/icb/res_man.h
@@ -117,21 +117,11 @@ class res_man {
 
 	uint16 current_time_frame; // inc's each time Res_open is called and is given to resource as its age cannot be allowed to start at 0!
 
-	uint32 hasThread;
-
-	rcActArray<async_PacketType> async_fnArray;
-
 public:
 	int amount_of_defrags;
 
-	async_PacketType async_data;
-	int32 async_loading;
-	int32 async_done;
-	//SDL_Thread *hThread; // TODO: Fix threading
-	Common::Mutex *hResManMutex;
-	Common::Mutex *hRunMutex;
 	res_man();
-	res_man(uint32 memory_tot, uint32 threadFlag);
+	res_man(uint32 memory_tot);
 	res_man(uint8 *base, uint32 size);
 	void Construct(uint8 *base, uint32 size, mem *memList, mem_offset *memOffsets, uint32 nMemBlocks);
 	~res_man();
@@ -150,11 +140,6 @@ public:
 	void Set_auto_timeframe_advance();
 	void Set_to_no_defrag();
 
-	int32 async_checkArray();
-	void async_flush();
-	void async_addFile(const int8 *fn, uint8 *p, int32 size, int32 zipped, int32 memListNo);
-	void RegisterAsync(const int32 n);
-
 	int16 find_oldest_file();
 	void Garbage_removal();
 
@@ -169,11 +154,6 @@ public:
 	uint8 *Res_open(const char *url, uint32 &url_hash, const char *cluster_url, uint32 &cluster_hash,
 	                int compressed = 0, // non zero if the resource is compressed
 	                int32 *ret_len = NULL);
-	// If hash or cluster_hash == NULL_HASH then the hash of url/cluster_url
-	// is computed and stored in hash/cluster_hash
-	uint8 *Res_async_open(const char *url,
-	                      uint32 &url_hash, const char *cluster_url, uint32 &cluster_hash,
-	                      int compressed = 0); // non zero if the resource is compressed
 	// new function to just allocate some memory for use
 	// by code which wants temporary memory but not files
 	// e.g. stream player, image decompressor
@@ -205,7 +185,7 @@ public:
 	inline void Id(int newId);
 	inline int Id();
 
-      private:
+private:
 	inline void MakeHash(const char *s, uint32 &h);
 	inline int32 CheckHash(const char *s, const uint32 h, uint32 &h2);
 
@@ -228,7 +208,7 @@ public:
 	uint32 FindMemBlock(uint32 adj_len, RMParams *params);
 	uint8 *AllocMemory(uint32 &memory_tot);
 
-	void Initialise(uint32 memory_tot, uint32 threadFlag);
+	void Initialise(uint32 memory_tot);
 
 	uint8 *Internal_open(RMParams *params, int32 *ret_len = NULL);
 
@@ -236,12 +216,6 @@ public:
 
 	int16 Find_space(uint32 len);
 	uint16 Fetch_spawn(uint16 parent);
-	void OpenAsync();
-	void CloseAsync();
-
-	//              async
-	async_PacketType async_shiftArray();
-	void async_setLoading(async_PacketType s);
 
 	bool8 auto_time_advance; // if true then time stamp is automatically imcremented as a file is opened
 	bool8 no_defrag; // this manager is a static one so resources cannot be purged, shuffled or aged out
diff --git a/engines/icb/res_man_pc.cpp b/engines/icb/res_man_pc.cpp
index c9cf9d92f9..b17dc6a152 100644
--- a/engines/icb/res_man_pc.cpp
+++ b/engines/icb/res_man_pc.cpp
@@ -81,220 +81,6 @@ bool checkFileExists(const char *fullpath) {
 	return file.exists(fullpath);
 }
 
-#if 0
-
-FILE *openDiskFileForBinaryWrite(const char *filename) {
-	pxString path = filename;
-	path.ConvertPath();
-	warning("openDiskFileForBinaryWrite(%s)", path.c_str());
-	FILE *result = fopen(path, "wb");
-	if (result != NULL) {
-		warning(" - SUCCESS");
-		return result;
-	} else {
-		warning(" - FAILED");
-		return NULL;
-	}
-}
-
-#endif
-
-// Thread procedure take files and load them
-int async_loadThread(void *v) {
-	Common::File *in;
-	res_man *rm = (res_man *)v;
-
-	int8 *fn = NULL;
-	uint8 *p;
-	int32 z;
-	int32 size;
-	int32 newSize;
-
-	Zdebug(100, "ASYNC: Thread active...\n");
-	for (;;) {
-		g_system->delayMillis(10); // Sleep(10);
-		rm->hResManMutex->lock(); // if ( WaitForSingleObject(rm->hResManMutex,INFINITE)!=WAIT_TIMEOUT )
-		{
-			if (rm->async_loading == 1) {
-				z = rm->async_data.zipped;
-				fn = new int8[1 + strlen(rm->async_data.fn)];
-				strcpy((char *)fn, rm->async_data.fn);
-				p = rm->async_data.p;
-				size = rm->async_data.size;
-
-				rm->hResManMutex->unlock(); // ReleaseMutex(rm->hResManMutex);
-
-				if (z)
-					memUncompress(p, (const char *)fn); // TODO: Use wrapCompressedStream to solve?
-				else {
-					uint32 timer = g_system->getMillis();
-					in = openDiskFileForBinaryRead((char *)fn);
-					newSize = size;
-					while (newSize != 0) {
-						if (newSize > 1024) {
-							in->read(p, 1024);
-							p += 1024;
-							newSize -= 1024;
-						} else {
-							in->read(p, newSize);
-							p += newSize;
-							newSize = 0;
-						}
-					}
-					in->close();
-					delete in;
-
-					timer = g_system->getMillis() - timer;
-					Zdebug(100, "%d", timer);
-				}
-
-				rm->hResManMutex->lock(); // WaitForSingleObject(rm->hResManMutex,INFINITE);
-				rm->async_loading = 0;
-				rm->async_done = 1;
-				rm->hResManMutex->unlock(); // ReleaseMutex(rm->hResManMutex);
-
-			} else {
-				rm->hResManMutex->unlock(); // ReleaseMutex(rm->hResManMutex);
-
-				//				if (SDL_TryLockMutex(rm->hRunMutex) != SDL_MUTEX_TIMEDOUT) { //if ( WaitForSingleObject(rm->hRunMutex,0)!=WAIT_TIMEOUT
-				//)
-				rm->hRunMutex->lock(); // TODO: Fix this.
-				{
-					if (fn)
-						delete[] fn;
-
-					Zdebug("ASYNC: thread ending...\n");
-					return 0;
-				}
-			}
-		}
-	}
-
-	return 0;
-}
-
-void res_man::OpenAsync() {
-	Zdebug("starting ASYNC");
-	hasThread = 1;
-	// hRunMutex=CreateMutex(NULL,TRUE,NULL);
-	hRunMutex = new Common::Mutex();
-	hRunMutex->lock();
-
-	// hResManMutex=CreateMutex(NULL,FALSE,NULL);
-	hResManMutex = new Common::Mutex();
-
-	//_beginthread(async_loadThread,0,this);
-	warning("TODO: Fix threading");
-#if 0
-	hThread = NULL;
-	//hThread = SDL_CreateThread(async_loadThread, "async_loadThread", (void *)this);
-	if (!hThread) {
-		printf("ERROR: res_man::OpenAsync() Couldn't create thread");
-	}
-#endif
-	async_loading = 0;
-	async_done = 0;
-}
-
-void res_man::CloseAsync() {
-	// close async thread.
-	if (hasThread) {
-		Zdebug("ASYNC: shutting down\n");
-
-		hRunMutex->unlock(); // ReleaseMutex(hRunMutex);
-		// SDL_Delay(50);    //Sleep(50);
-
-		warning("TODO: Fix threading");
-#if 0
-		//wait for thread to finish
-		SDL_WaitThread(hThread, NULL);
-		hThread = NULL;
-#endif
-		delete hRunMutex; // CloseHandle(hRunMutex);
-		delete hResManMutex; // CloseHandle(hResManMutex);
-	}
-}
-
-// Shift array (might not be needed soon)
-async_PacketType res_man::async_shiftArray() {
-	async_PacketType top;
-	rcActArray<async_PacketType> newArray;
-
-	if (async_fnArray.GetNoItems() == 0)
-		return top;
-
-	top = async_fnArray[0];
-
-	uint i;
-
-	for (i = 1; i < async_fnArray.GetNoItems(); i++) {
-		newArray.Add(async_fnArray[i]);
-	}
-
-	async_fnArray.Reset();
-
-	for (i = 0; i < newArray.GetNoItems(); i++) {
-		async_fnArray.Add(newArray[i]);
-	}
-
-	return top;
-}
-
-// Add item to list
-void res_man::async_addFile(const int8 *fn, uint8 *p, int32 size, int32 zipped, int32 memListNo) {
-	async_PacketType a;
-	a.fn = (char *)const_cast<int8 *>(fn);
-	a.p = p;
-	a.size = size;
-	a.zipped = zipped;
-	a.memListNo = memListNo;
-	async_fnArray.Add(a);
-}
-
-// Pass information to thread to start loading
-void res_man::async_setLoading(async_PacketType s) {
-	hResManMutex->lock(); // WaitForSingleObject(hResManMutex,INFINITE);
-	async_loading = 1;
-	async_data = s;
-	hResManMutex->unlock(); // ReleaseMutex(hResManMutex);
-}
-
-// Check for new files
-int32 res_man::async_checkArray() {
-	int32 i;
-
-	i = async_fnArray.GetNoItems();
-
-	if (i == 0)
-		return i;
-
-	//if (SDL_TryLockMutex(hResManMutex) != SDL_MUTEX_TIMEDOUT) { //if ( WaitForSingleObject(hResManMutex,0)!=WAIT_TIMEOUT )
-	// TODO: Fix this
-	hResManMutex->lock();
-	{
-		if (async_done == 1) {
-			async_done = 0;
-			hResManMutex->unlock(); // ReleaseMutex(hResManMutex);
-			async_shiftArray();
-			i--;
-			RegisterAsync(async_data.memListNo);
-			return i;
-		} else if ((i > 0) && (async_loading == 0)) {
-			hResManMutex->unlock(); // ReleaseMutex(hResManMutex);
-			async_setLoading(async_fnArray[0]);
-		} else
-			hResManMutex->unlock(); // ReleaseMutex(hResManMutex);
-	}
-	return i;
-}
-
-// Flush out everything
-void res_man::async_flush() {
-	Zdebug("ASYNC: flushing (%d items)\n", async_fnArray.GetNoItems());
-	while (async_checkArray() != 0)
-		;
-}
-
 void Memory_stats() {
 	uint32 one_meg = 1024 * 1024;
 
@@ -363,9 +149,6 @@ uint8 *res_man::AllocMemory(uint32 &memory_tot) {
 	return memory_b;
 }
 
-void res_man::RegisterAsync(const int32) {
-}
-
 uint32 res_man::Fetch_size(const char * /*url*/, uint32 url_hash, const char *cluster, uint32 cluster_hash) {
 	// try to find the cluster file
 	RMParams params;
diff --git a/engines/icb/res_man_pc.h b/engines/icb/res_man_pc.h
index 92e438186c..bd4f53dc1e 100644
--- a/engines/icb/res_man_pc.h
+++ b/engines/icb/res_man_pc.h
@@ -36,14 +36,6 @@
 
 namespace ICB {
 
-typedef struct async_PacketType {
-	pxString fn;
-	uint8 *p;
-	int32 size;
-	int32 zipped;
-	int32 memListNo;
-} async_PacketType;
-
 bool checkFileExists(const char *fullpath);
 
 Common::SeekableReadStream *openDiskFileForBinaryStreamRead(const Common::String &filename);
diff --git a/engines/icb/route_manager.cpp b/engines/icb/route_manager.cpp
index 41be94d8b9..a6b0682fb1 100644
--- a/engines/icb/route_manager.cpp
+++ b/engines/icb/route_manager.cpp
@@ -306,10 +306,6 @@ mcodeFunctionReturnCodes _game_session::fn_tiny_route(int32 &result, int32 *para
 
 		Tdebug("route_async.txt", "%s tiny", object->GetName());
 
-		// dont continue until all route related anims have asynced into memory
-		if (!Route_async_ready((bool8)params[2], (bool8)params[3]))
-			return IR_REPEAT;
-
 		// check for free router
 		if (Is_router_busy())
 			return IR_REPEAT;
@@ -365,10 +361,6 @@ mcodeFunctionReturnCodes _game_session::fn_room_route(int32 &result, int32 *para
 	//			IR_REPEAT
 
 	if (L->looping < 2) {
-		//		dont continue until all route related anims have asynced into memory
-		if (!Route_async_ready((bool8)params[2], (bool8)params[3]))
-			return IR_REPEAT;
-
 		// check for free router
 		if (Is_router_busy()) {
 			return IR_REPEAT;
@@ -409,10 +401,6 @@ mcodeFunctionReturnCodes _game_session::fn_sharp_route(int32 &result, int32 *par
 	bool8 route_res;
 
 	if (L->looping < 2) {
-		// dont continue until all route related anims have asynced into memory
-		if (!Route_async_ready((bool8)params[2], (bool8)params[3]))
-			return IR_REPEAT;
-
 		// check for free router
 		if (Is_router_busy()) {
 			return IR_REPEAT;
@@ -469,10 +457,6 @@ mcodeFunctionReturnCodes _game_session::fn_laser_route(int32 &result, int32 *par
 	//			IR_REPEAT
 
 	if (L->looping < 2) {
-		// dont continue until all route related anims have asynced into memory
-		if (!Route_async_ready((bool8)params[2], (bool8)params[3]))
-			return IR_REPEAT;
-
 		// check for free router
 		if (Is_router_busy()) {
 			return IR_REPEAT;
@@ -516,10 +500,6 @@ mcodeFunctionReturnCodes _game_session::fn_route_to_nico(int32 &result, int32 *p
 	}
 
 	if (L->looping < 2) {
-		// dont continue until all route related anims have asynced into memory
-		if (!Route_async_ready((bool8)params[1], (bool8)params[2]))
-			return IR_REPEAT;
-
 		// check for free router
 		if (Is_router_busy()) {
 			return IR_REPEAT;
@@ -575,10 +555,6 @@ mcodeFunctionReturnCodes _game_session::fn_interact_near_mega(int32 &result, int
 	len = (PXreal)((sub1 * sub1) + (sub2 * sub2));
 
 	if (L->looping < 2) {
-		// dont continue until all route related anims have asynced into memory
-		if (!Route_async_ready((bool8)params[2], (bool8)params[3]))
-			return IR_REPEAT;
-
 		// check for free router
 		if (Is_router_busy()) {
 			return IR_REPEAT;
@@ -834,10 +810,6 @@ mcodeFunctionReturnCodes _game_session::Route_to_near_mega_core(const char *name
 	len = (int32)((sub1 * sub1) + (sub2 * sub2));
 
 	if (L->looping < 2) {
-		// dont continue until all route related anims have asynced into memory
-		if (!Route_async_ready((bool8)run, (bool8)initial_turn))
-			return IR_REPEAT;
-
 		// check for free router
 		if (Is_router_busy())
 			return IR_REPEAT;
@@ -916,10 +888,6 @@ mcodeFunctionReturnCodes _game_session::fn_route_to_marker(int32 &result, int32
 	const char *marker_name = (const char *)MemoryUtil::resolvePtr(params[0]);
 
 	if (L->looping < 2) {
-		// dont continue until all route related anims have asynced into memory
-		if (!Route_async_ready((bool8)params[2], (bool8)params[3]))
-			return IR_REPEAT;
-
 		// check for free router
 		if (Is_router_busy()) {
 			return IR_REPEAT;
diff --git a/engines/icb/session.cpp b/engines/icb/session.cpp
index 08e5466f6d..bae41b2227 100644
--- a/engines/icb/session.cpp
+++ b/engines/icb/session.cpp
@@ -880,10 +880,6 @@ void _game_session::One_logic_cycle() {
 				if (!first_session_cycle)
 					Process_player_floor_status(); // sends events when object gains same floor as player
 
-				// async
-				if (!M->dead)
-					Service_generic_async(); // servive live megas
-
 				// process hold mode options
 				// has on-camera-only mode and is not on screen - then sleep again
 				if ((L->hold_mode == mega_player_floor_hold) && (!M->on_players_floor))
diff --git a/engines/icb/speech.cpp b/engines/icb/speech.cpp
index 4199695e1a..d18b0a2ed9 100644
--- a/engines/icb/speech.cpp
+++ b/engines/icb/speech.cpp
@@ -897,7 +897,7 @@ mcodeFunctionReturnCodes _game_session::speak_preload_custom_anim(int32 &, int32
 	II->has_custom_path_built = FALSE8;
 
 	// start preloading
-	rs_anims->Res_async_open(II->get_anim_name(__NON_GENERIC), II->anim_name_hash[__NON_GENERIC], II->base_path, II->base_path_hash); //
+	rs_anims->Res_open(II->get_anim_name(__NON_GENERIC), II->anim_name_hash[__NON_GENERIC], II->base_path, II->base_path_hash); //
 
 	MM->custom = FALSE8;
 




More information about the Scummvm-git-logs mailing list