From db4308d60bce90cec92139fa1fe469c9464dccf6 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 11 Oct 2005 14:03:36 +0000 Subject: Rewrote some code that didn't look alignment safe to me. svn-id: r19020 --- saga/sthread.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'saga') 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 -- cgit v1.2.3