[Scummvm-cvs-logs] CVS: scummvm/simon simon.cpp,1.12,1.13

Ludvig Strigeus strigeus at users.sourceforge.net
Mon Apr 15 07:38:39 CEST 2002


Update of /cvsroot/scummvm/scummvm/simon
In directory usw-pr-cvs1:/tmp/cvs-serv21036

Modified Files:
	simon.cpp 
Log Message:
fixed a few alignment issues

Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** simon.cpp	14 Apr 2002 20:22:36 -0000	1.12
--- simon.cpp	15 Apr 2002 14:37:47 -0000	1.13
***************
*** 4811,4819 ****
  }
  
  /* FIXME: unaligned access */
  void SimonState::vc_20() {
- 	/* no idea what's going on */
  	uint16 a = vc_read_next_word();
! 	*(uint16*)_vc_ptr = a;
  	_vc_ptr += 2;
  }
--- 4811,4832 ----
  }
  
+ 
+ /* helper routines */
+ 
+ /* write unaligned 16-bit */
+ static void write_16_le(void *p, uint16 a) {
+ 	((byte*)p)[0] = (byte) (a);
+ 	((byte*)p)[1] = (byte) (a >> 8);
+ }
+ 
+ /* read unaligned 16-bit */
+ static uint16 read_16_le(void *p) {
+ 	return ((byte*)p)[0] | (((byte*)p)[1] << 8);
+ }
+ 
  /* FIXME: unaligned access */
  void SimonState::vc_20() {
  	uint16 a = vc_read_next_word();
! 	write_16_le(_vc_ptr, a);
  	_vc_ptr += 2;
  }
***************
*** 4823,4839 ****
  	if (!(_game & GAME_SIMON2)) {
  		int16 a = vc_read_next_word();
! 		uint16 *tmp = (uint16*)(_vc_ptr + a);
  
! 		if (tmp[2] != 0) {
! 			tmp[2]--;
! 			_vc_ptr = (byte*)tmp + 6;
  		}
  	} else {
  		int16 a = vc_read_next_word();
  		byte *tmp = _vc_ptr + a;
  
! 		if (*(uint16*)(tmp+3) != 0) {
! 			(*(uint16*)(tmp+3))--;
! 			_vc_ptr = (byte*)tmp + 5;
  		}
  	}
--- 4836,4854 ----
  	if (!(_game & GAME_SIMON2)) {
  		int16 a = vc_read_next_word();
! 		byte *tmp = _vc_ptr + a;
! 		uint16 val = read_16_le(tmp + 4);
  
! 		if (val != 0) {
! 			write_16_le(tmp + 4, val - 1);
! 			_vc_ptr = tmp + 6;
  		}
  	} else {
  		int16 a = vc_read_next_word();
  		byte *tmp = _vc_ptr + a;
+ 		uint16 val = read_16_le(tmp + 3);
  
! 		if (val != 0) {
! 			write_16_le(tmp + 3, val - 1);
! 			_vc_ptr = tmp + 5;
  		}
  	}
***************
*** 6204,6208 ****
  		if (!p)
  			continue;
! 		for(j=0; p[0] != 0xE703; j++,p+=2) { /* 0xE703 = byteswapped 999 */
  			x_diff = abs(READ_BE_UINT16_UNALIGNED(&p[0]) - x);
  			y_diff = abs(READ_BE_UINT16_UNALIGNED(&p[1]) - 12 - y);
--- 6219,6223 ----
  		if (!p)
  			continue;
! 		for(j=0; READ_BE_UINT16_UNALIGNED(&p[0]) != 999; j++,p+=2) { /* 0xE703 = byteswapped 999 */
  			x_diff = abs(READ_BE_UINT16_UNALIGNED(&p[0]) - x);
  			y_diff = abs(READ_BE_UINT16_UNALIGNED(&p[1]) - 12 - y);
***************
*** 6453,6457 ****
  
  		src = _icon_file_ptr;
! 		src += ((uint16*)src)[icon];
  
  		decompress_icon(dst, src, 24, 12, 0xE0,_dx_surface_pitch);
--- 6468,6472 ----
  
  		src = _icon_file_ptr;
! 		src += READ_LE_UINT16(&((uint16*)src)[icon]);
  
  		decompress_icon(dst, src, 24, 12, 0xE0,_dx_surface_pitch);
***************
*** 6468,6476 ****
  
  		src = _icon_file_ptr;
! 		src += ((uint16*)src)[icon*2+0];
  		decompress_icon(dst, src, 20, 10, 0xE0,_dx_surface_pitch);
  
  		src = _icon_file_ptr;
! 		src += ((uint16*)src)[icon*2+1];
  		decompress_icon(dst, src, 20, 10, 0xD0,_dx_surface_pitch);
  
--- 6483,6491 ----
  
  		src = _icon_file_ptr;
! 		src += READ_LE_UINT16(&((uint16*)src)[icon*2+0]);
  		decompress_icon(dst, src, 20, 10, 0xE0,_dx_surface_pitch);
  
  		src = _icon_file_ptr;
! 		src += READ_LE_UINT16(&((uint16*)src)[icon*2+1]);
  		decompress_icon(dst, src, 20, 10, 0xD0,_dx_surface_pitch);
  
***************
*** 7196,7200 ****
  			uint img_height = img_hdr[2];
  			uint img_width = img_hdr[3],i;
! 			byte *img = src + *(uint16*)img_hdr;
  			byte *cur_dst = dst;
  
--- 7211,7215 ----
  			uint img_height = img_hdr[2];
  			uint img_width = img_hdr[3],i;
! 			byte *img = src + READ_LE_UINT16(img_hdr);
  			byte *cur_dst = dst;
  
***************
*** 8597,8601 ****
  	do {
  		if (!(_game & GAME_SIMON2)) {
! 			opcode = READ_BE_UINT16_UNALIGNED((uint16*)src);
  			src+=2;
  		} else {
--- 8612,8616 ----
  	do {
  		if (!(_game & GAME_SIMON2)) {
! 			opcode = READ_BE_UINT16_UNALIGNED(src);
  			src+=2;
  		} else {
***************
*** 8620,8624 ****
  			case 'i':	fprintf(_dump_file,"%d ", (int16)READ_BE_UINT16_UNALIGNED(src)); src+=2; break;
  			case 'q': 
! 				while (*(uint16*)src != 0xE703) {
  					fprintf(_dump_file,"(%d,%d) ", READ_BE_UINT16_UNALIGNED(src), READ_BE_UINT16_UNALIGNED(src+2));
  					src += 4;
--- 8635,8639 ----
  			case 'i':	fprintf(_dump_file,"%d ", (int16)READ_BE_UINT16_UNALIGNED(src)); src+=2; break;
  			case 'q': 
! 				while (READ_BE_UINT16_UNALIGNED(src) != 999) {
  					fprintf(_dump_file,"(%d,%d) ", READ_BE_UINT16_UNALIGNED(src), READ_BE_UINT16_UNALIGNED(src+2));
  					src += 4;





More information about the Scummvm-git-logs mailing list