[Scummvm-cvs-logs] SF.net SVN: scummvm: [29035] scummvm/trunk/engines/agi
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Sun Sep 23 02:12:07 CEST 2007
Revision: 29035
http://scummvm.svn.sourceforge.net/scummvm/?rev=29035&view=rev
Author: mthreepwood
Date: 2007-09-22 17:12:07 -0700 (Sat, 22 Sep 2007)
Log Message:
-----------
readRoom is now Endian-safe
Modified Paths:
--------------
scummvm/trunk/engines/agi/preagi_winnie.cpp
scummvm/trunk/engines/agi/preagi_winnie.h
Modified: scummvm/trunk/engines/agi/preagi_winnie.cpp
===================================================================
--- scummvm/trunk/engines/agi/preagi_winnie.cpp 2007-09-22 23:56:08 UTC (rev 29034)
+++ scummvm/trunk/engines/agi/preagi_winnie.cpp 2007-09-23 00:12:07 UTC (rev 29035)
@@ -57,7 +57,7 @@
winnie_event = false;
}
-uint32 Winnie::readRoom(int iRoom, uint8 *buffer) {
+uint32 Winnie::readRoom(int iRoom, uint8 *buffer, WTP_ROOM_HDR &roomHdr) {
char szFile[256] = {0};
if (_vm->getPlatform() == Common::kPlatformPC)
sprintf(szFile, IDS_WTP_ROOM_DOS, iRoom);
@@ -72,6 +72,38 @@
memset(buffer, 0, sizeof(buffer));
file.read(buffer, filelen);
file.close();
+
+ memcpy(&roomHdr, buffer, sizeof(WTP_ROOM_HDR));
+ if (_vm->getPlatform() == Common::kPlatformPC) {
+ roomHdr.ofsPic = TO_LE_16(roomHdr.ofsPic);
+ roomHdr.fileLen = TO_LE_16(roomHdr.fileLen);
+ roomHdr.reserved0 = TO_LE_16(roomHdr.reserved0);
+ roomHdr.reserved1 = TO_LE_16(roomHdr.reserved1);
+ for (byte i = 0; i < IDI_WTP_MAX_BLOCK; i++) {
+ roomHdr.ofsDesc[i] = TO_LE_16(roomHdr.ofsDesc[i]);
+ roomHdr.ofsBlock[i] = TO_LE_16(roomHdr.ofsBlock[i]);
+ for (byte j = 0; j < IDI_WTP_MAX_BLOCK; j++)
+ roomHdr.opt[i].ofsOpt[j] = TO_LE_16(roomHdr.opt[i].ofsOpt[j]);
+ }
+ for (byte i = 0; i < IDI_WTP_MAX_STR; i++)
+ roomHdr.ofsStr[i] = TO_LE_16(roomHdr.ofsStr[i]);
+ roomHdr.reserved2 = TO_LE_32(roomHdr.reserved2);
+ } else if (_vm->getPlatform() == Common::kPlatformAmiga) {
+ roomHdr.ofsPic = TO_BE_16(roomHdr.ofsPic);
+ roomHdr.fileLen = TO_BE_16(roomHdr.fileLen);
+ roomHdr.reserved0 = TO_BE_16(roomHdr.reserved0);
+ roomHdr.reserved1 = TO_BE_16(roomHdr.reserved1);
+ for (byte i = 0; i < IDI_WTP_MAX_BLOCK; i++) {
+ roomHdr.ofsDesc[i] = TO_BE_16(roomHdr.ofsDesc[i]);
+ roomHdr.ofsBlock[i] = TO_BE_16(roomHdr.ofsBlock[i]);
+ for (byte j = 0; j < IDI_WTP_MAX_BLOCK; j++)
+ roomHdr.opt[i].ofsOpt[j] = TO_BE_16(roomHdr.opt[i].ofsOpt[j]);
+ }
+ for (byte i = 0; i < IDI_WTP_MAX_STR; i++)
+ roomHdr.ofsStr[i] = TO_BE_16(roomHdr.ofsStr[i]);
+ roomHdr.reserved2 = TO_BE_32(roomHdr.reserved2);
+ }
+
return filelen;
}
@@ -437,8 +469,7 @@
uint8 *roomdata = (uint8 *)malloc(4096);
uint8 *objdata = (uint8 *)malloc(2048);
- readRoom(iRoom, roomdata);
- memcpy(&roomhdr, roomdata, sizeof(WTP_ROOM_HDR));
+ readRoom(iRoom, roomdata, roomhdr);
readObj(iObj, objdata);
memcpy(&objhdr, objdata, sizeof(WTP_OBJ_HDR));
@@ -942,8 +973,7 @@
phase0:
if (!game.nObjMiss && (room == IDI_WTP_ROOM_PICNIC))
room = IDI_WTP_ROOM_PARTY;
- readRoom(room, roomdata);
- memcpy(&hdr, roomdata, sizeof(WTP_ROOM_HDR));
+ readRoom(room, roomdata, hdr);
drawRoomPic();
_vm->_gfx->doUpdate();
_vm->_system->updateScreen();
@@ -1025,12 +1055,9 @@
_vm->_gfx->clearScreen(0);
// read room picture
- readRoom(room, buffer);
- memcpy(&roomhdr, buffer, sizeof(WTP_ROOM_HDR));
+ readRoom(room, buffer, roomhdr);
- if (_vm->getPlatform() == Common::kPlatformAmiga)
- roomhdr.ofsPic = TO_BE_16(roomhdr.ofsPic);
- else if (_vm->getPlatform() == Common::kPlatformPC)
+ if (_vm->getPlatform() == Common::kPlatformPC)
roomhdr.ofsPic = roomhdr.ofsPic - IDI_WTP_OFS_ROOM;
// draw room picture
@@ -1061,8 +1088,7 @@
WTP_ROOM_HDR hdr;
uint8 *buffer = (uint8 *)malloc(4096);
- readRoom(iRoom, buffer);
- memcpy(&hdr, buffer, sizeof(hdr));
+ readRoom(iRoom, buffer, hdr);
_vm->printStrXOR((char *)(buffer + hdr.ofsStr[iStr - 1] - IDI_WTP_OFS_ROOM));
free(buffer);
Modified: scummvm/trunk/engines/agi/preagi_winnie.h
===================================================================
--- scummvm/trunk/engines/agi/preagi_winnie.h 2007-09-22 23:56:08 UTC (rev 29034)
+++ scummvm/trunk/engines/agi/preagi_winnie.h 2007-09-23 00:12:07 UTC (rev 29035)
@@ -317,7 +317,7 @@
void intro();
void drawPic(const char*);
void gameLoop();
- uint32 readRoom(int, uint8*);
+ uint32 readRoom(int, uint8*, WTP_ROOM_HDR&);
void drawRoomPic();
int parser(int, int, uint8*);
int getObjInRoom(int);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list