aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-10-11 14:03:36 +0000
committerTorbjörn Andersson2005-10-11 14:03:36 +0000
commitdb4308d60bce90cec92139fa1fe469c9464dccf6 (patch)
tree71aadb2aebc34d510739c9c01047bbac67f9b1a8 /saga
parentaa8df56744f6de4c0879835540d0e69c617ce0f4 (diff)
downloadscummvm-rg350-db4308d60bce90cec92139fa1fe469c9464dccf6.tar.gz
scummvm-rg350-db4308d60bce90cec92139fa1fe469c9464dccf6.tar.bz2
scummvm-rg350-db4308d60bce90cec92139fa1fe469c9464dccf6.zip
Rewrote some code that didn't look alignment safe to me.
svn-id: r19020
Diffstat (limited to 'saga')
-rw-r--r--saga/sthread.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/saga/sthread.cpp b/saga/sthread.cpp
index 58db4d24ed..6c268c96d1 100644
--- a/saga/sthread.cpp
+++ b/saga/sthread.cpp
@@ -273,8 +273,8 @@ bool Script::runThread(ScriptThread *thread, uint instructionLimit) {
addr = thread->baseAddress(scriptS.readByte());
iparam1 = scriptS.readSint16LE();
addr += iparam1;
- thread->push(*((uint16*)addr));
- debug(8, "0x%X", *((uint16*)addr));
+ thread->push(READ_UINT16(addr));
+ debug(8, "0x%X", READ_UINT16(addr));
break;
CASEOP(opPutFlag)
addr = thread->baseAddress(scriptS.readByte());
@@ -291,7 +291,7 @@ bool Script::runThread(ScriptThread *thread, uint instructionLimit) {
addr = thread->baseAddress(scriptS.readByte());
iparam1 = scriptS.readSint16LE();
addr += iparam1;
- *(uint16*)addr = thread->stackTop();
+ WRITE_UINT16(addr, thread->stackTop());
break;
CASEOP(opPutFlagV)
addr = thread->baseAddress(scriptS.readByte());
@@ -308,7 +308,7 @@ bool Script::runThread(ScriptThread *thread, uint instructionLimit) {
addr = thread->baseAddress(scriptS.readByte());
iparam1 = scriptS.readSint16LE();
addr += iparam1;
- *(uint16*)addr = thread->pop();
+ WRITE_UINT16(addr, thread->pop());
break;
// FUNCTION CALL INSTRUCTIONS
@@ -468,27 +468,31 @@ bool Script::runThread(ScriptThread *thread, uint instructionLimit) {
addr = thread->baseAddress(scriptS.readByte());
iparam1 = scriptS.readSint16LE();
addr += iparam1;
- *(uint16*)addr += 1;
+ iparam1 = READ_UINT16(addr);
+ WRITE_UINT16(addr, iparam1 + 1);
break;
CASEOP(opDecV)
addr = thread->baseAddress(scriptS.readByte());
iparam1 = scriptS.readSint16LE();
addr += iparam1;
- *(uint16*)addr -= 1;
+ iparam1 = READ_UINT16(addr);
+ WRITE_UINT16(addr, iparam1 - 1);
break;
CASEOP(opPostInc)
addr = thread->baseAddress(scriptS.readByte());
iparam1 = scriptS.readSint16LE();
addr += iparam1;
- thread->push(*(int16*)addr);
- *(uint16*)addr += 1;
+ iparam1 = READ_UINT16(addr);
+ thread->push(iparam1);
+ WRITE_UINT16(addr, iparam1 + 1);
break;
CASEOP(opPostDec)
addr = thread->baseAddress(scriptS.readByte());
iparam1 = scriptS.readSint16LE();
addr += iparam1;
- thread->push(*(int16*)addr);
- *(uint16*)addr -= 1;
+ iparam1 = READ_UINT16(addr);
+ thread->push(iparam1);
+ WRITE_UINT16(addr, iparam1 - 1);
break;
// ARITHMETIC INSTRUCTIONS