diff options
| author | Eugene Sandulenko | 2004-05-03 23:06:57 +0000 | 
|---|---|---|
| committer | Eugene Sandulenko | 2004-05-03 23:06:57 +0000 | 
| commit | 51801dc503f045dd6a79211db7696202fe978e7e (patch) | |
| tree | c443e62a4e2e175a7bb81dc54fd389798d1311d5 | |
| parent | ce03b7635fe70dc58587dd46b83191d4a334f2d3 (diff) | |
| download | scummvm-rg350-51801dc503f045dd6a79211db7696202fe978e7e.tar.gz scummvm-rg350-51801dc503f045dd6a79211db7696202fe978e7e.tar.bz2 scummvm-rg350-51801dc503f045dd6a79211db7696202fe978e7e.zip | |
Started work on moving from ys_read/write to MemoryReadStream
svn-id: r13769
| -rw-r--r-- | saga/actionmap.cpp | 23 | ||||
| -rw-r--r-- | saga/actor.cpp | 8 | ||||
| -rw-r--r-- | saga/saga.h | 3 | 
3 files changed, 17 insertions, 17 deletions
| diff --git a/saga/actionmap.cpp b/saga/actionmap.cpp index 506cf78a2b..9bdab9fa21 100644 --- a/saga/actionmap.cpp +++ b/saga/actionmap.cpp @@ -22,7 +22,7 @@   */  /* Action map module */ - +#include "saga.h"  #include "reinherit.h"  #include "yslib.h" @@ -57,16 +57,13 @@ namespace Saga {  		int exit_ct;  		int i, pt; -		const byte *read_p = exmap_res; -		size_t read_len = exmap_res_len; -  		assert(ActmapModule.init);  		assert(exmap_res != NULL); -		(void)read_len; +		MemoryReadStream *exmapStream = new MemoryReadStream(exmap_res, exmap_res_len);  		// Load exits -		exit_ct = ys_read_s16_le(read_p, &read_p); +		exit_ct = exmapStream->readSint16LE();  		if (exit_ct < 0) {  			return R_FAILURE;  		} @@ -78,12 +75,12 @@ namespace Saga {  		}  		for (i = 0; i < exit_ct; i++) { -			exmap_entry[i].unknown00 = ys_read_s16_le(read_p, &read_p); -			exmap_entry[i].unknown02 = ys_read_s16_le(read_p, &read_p); -			exmap_entry[i].exit_scene = ys_read_s16_le(read_p, &read_p); -			exmap_entry[i].unknown06 = ys_read_s16_le(read_p, &read_p); +			exmap_entry[i].unknown00 = exmapStream->readSint16LE(); +			exmap_entry[i].unknown02 = exmapStream->readSint16LE(); +			exmap_entry[i].exit_scene = exmapStream->readSint16LE(); +			exmap_entry[i].unknown06 = exmapStream->readSint16LE(); -			exmap_entry[i].pt_count = ys_read_s16_le(read_p, &read_p); +			exmap_entry[i].pt_count = exmapStream->readSint16LE();  			if (exmap_entry[i].pt_count < 0) {  				free(exmap_entry);  				return R_FAILURE; @@ -96,8 +93,8 @@ namespace Saga {  			}  			for (pt = 0; pt < exmap_entry[i].pt_count; pt++) { -				exmap_pt_tbl[pt].x = ys_read_s16_le(read_p, &read_p); -				exmap_pt_tbl[pt].y = ys_read_s16_le(read_p, &read_p); +				exmap_pt_tbl[pt].x = exmapStream->readSint16LE(); +				exmap_pt_tbl[pt].y = exmapStream->readSint16LE();  			}  			exmap_entry[i].pt_tbl = exmap_pt_tbl; diff --git a/saga/actor.cpp b/saga/actor.cpp index 688bd2f8f9..d9793e5d03 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -654,7 +654,6 @@ R_ACTOR *LookupActor(int index) {  int LoadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p) {  	byte *res_p;  	size_t res_len; -	const byte *read_p;  	int s_action_ct;  	R_ACTORACTION *action_p;  	int last_frame; @@ -667,11 +666,12 @@ int LoadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p) {  		return R_FAILURE;  	} -	read_p = res_p;  	s_action_ct = res_len / 16;  	R_printf(R_STDOUT, "Sprite resource contains %d sprite actions.\n", s_action_ct);  	action_p = (R_ACTORACTION *)malloc(sizeof(R_ACTORACTION) * s_action_ct); +	MemoryReadStream *resStream = new MemoryReadStream(res_p, res_len); +  	if (action_p == NULL) {  		R_printf(R_STDERR, "Couldn't allocate memory for sprite actions.\n");  		RSC_FreeResource(res_p); @@ -683,8 +683,8 @@ int LoadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p) {  	for (i = 0; i < s_action_ct; i++) {  		for (orient = 0; orient < 4; orient++) {  			// Load all four orientations -			action_p[i].dir[orient].frame_index = ys_read_u16_le(read_p, &read_p); -			action_p[i].dir[orient].frame_count = ys_read_u16_le(read_p, &read_p); +			action_p[i].dir[orient].frame_index = resStream->readUint16LE(); +			action_p[i].dir[orient].frame_count = resStream->readUint16LE();  			if (action_p[i].dir[orient].frame_index > last_frame) {  				last_frame = action_p[i].dir[orient].frame_index;  			} diff --git a/saga/saga.h b/saga/saga.h index a049d120c2..f792e63c29 100644 --- a/saga/saga.h +++ b/saga/saga.h @@ -29,6 +29,7 @@  #include "base/engine.h"  #include "base/gameDetector.h"  #include "common/util.h" +#include "common/stream.h"  #include <limits.h>  #include <stddef.h> @@ -41,6 +42,8 @@ class SndRes;  class Sound;  class Music; +typedef Common::MemoryReadStream MemoryReadStream; +  #define R_PBOUNDS(n,max) (((n)>=(0))&&((n)<(max)))  enum SAGAGameId { | 
