diff options
author | Chris Apers | 2004-09-12 12:36:40 +0000 |
---|---|---|
committer | Chris Apers | 2004-09-12 12:36:40 +0000 |
commit | 926571bf7938244da5268853ce87798fdf9a08ce (patch) | |
tree | e053b347b9ce68e09cb75d151189dabda7309518 /backends/PalmOS/Src/arm | |
parent | a727918ba1f6a91977ad789c6196453e4c05f440 (diff) | |
download | scummvm-rg350-926571bf7938244da5268853ce87798fdf9a08ce.tar.gz scummvm-rg350-926571bf7938244da5268853ce87798fdf9a08ce.tar.bz2 scummvm-rg350-926571bf7938244da5268853ce87798fdf9a08ce.zip |
Convenient macros to ease ARM code
svn-id: r15038
Diffstat (limited to 'backends/PalmOS/Src/arm')
-rw-r--r-- | backends/PalmOS/Src/arm/macros.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/backends/PalmOS/Src/arm/macros.h b/backends/PalmOS/Src/arm/macros.h new file mode 100644 index 0000000000..7353081af5 --- /dev/null +++ b/backends/PalmOS/Src/arm/macros.h @@ -0,0 +1,75 @@ +#ifndef __MACROS_H__ +#define __MACROS_H__ + +#ifndef DISABLE_ARM + // macros for ARM calls + #define ARM_START(TYPE) \ + if (OPTIONS_TST(kOptDeviceARM)) { \ + TYPE data; + + #define ARM_CHECK_EXEC(test) if (test) { + #define ARM_CHECK_END() } + + #define ARM_ADDP(member) data.member = &member; + #define ARM_ADDM(member) data.member = member; + #define ARM_ADDV(member, var) data.member = var; + #define ARM_INIT(id) data.funcID = id; + + #define ARM_DATA() &data + #define ARM_CONTINUE() } else + #define ARM_END() return; \ + } + + #define PNO_CALL(pno, data) _PnoCall(&ARM(pno).pnoDesc, data); + #define PNO_CALL_RETURN(pno, data, var) var = _PnoCall(&ARM(pno).pnoDesc, data); + + #define PCE_CALL(pno, data) _PceCall(ARM(pno).pnoPtr, data); + #define PCE_CALL_RETURN(pno, data, var) var = _PceCall(ARM(pno).pnoPtr, data); + +#else + // no ARM = empty definition + #define ARM_START(TYPE) + + #define ARM_CHECK_EXEC(test) + #define ARM_CHECK_END() + + #define ARM_ADDP(member) + #define ARM_ADDM(member) + #define ARM_ADDV(member, var) + #define ARM_INIT(id) + + #define ARM_DATA() + #define ARM_CONTINUE() + #define ARM_END() + + #define PNO_CALL(data) + #define PNO_CALL_RETURN(data, var) + + #define PCE_CALL(data) + #define PCE_CALL_RETURN(data, var) + +#endif + + // Data access + #define _GETPTR(ptr, base, member, type) (type)ReadUnaligned32( (byte *)ptr + OffsetOf(base, member) ) + #define _SETPTR(base, member, type, var) type var = _GETPTR(userData68KP, base, member, type); + + #define _GET32 _GETPTR + #define _SET32 _SETPTR + + #define _GET16(ptr, base, member, type) (type)ByteSwap16( ((UInt16 *)((byte *)ptr + OffsetOf(base, member)))[0] ) + #define _SET16(base, member, type, var) type var = _GET16(userData68KP, base, member, type); + + #define _GET8(ptr, base, member, type) (type)((byte *)ptr + OffsetOf(base, member))[0] + #define _SET8(base, member, type, var) type var = _GET8(userData68KP, base, member, type); + + // convenient macros to ease data access + #ifdef MAIN_TYPE + # define SETPTRV(type, member, var) _SETPTR(MAIN_TYPE, member, type, var) + # define SETPTR(type, member) _SETPTR(MAIN_TYPE, member, type, member) + # define SET32(type, member) _SET32 (MAIN_TYPE, member, type, member) + # define SET16(type, member) _SET16 (MAIN_TYPE, member, type, member) + # define SET8(type, member) _SET8 (MAIN_TYPE, member, type, member) + #endif + +#endif
\ No newline at end of file |