00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef INTRINSICS_H
00020 #define INTRINSICS_H
00021
00022 typedef uint32 (*Intrinsic)(const uint8* args, unsigned int argsize);
00023
00024 #define INTRINSIC(x) static uint32 x (const uint8* args, unsigned int argsize)
00025
00026
00027
00028 #define ARG_UINT8(x) uint8 x = (*args++);
00029 #define ARG_UINT16(x) uint16 x = (*args++); x += ((*args++) << 8);
00030 #define ARG_UINT32(x) uint32 x = (*args++); x += ((*args++) << 8); \
00031 x+= ((*args++) << 16); x += ((*args++) << 24);
00032 #define ARG_SINT8(x) sint8 x = (*args++);
00033 #define ARG_SINT16(x) sint16 x = (*args++); x += ((*args++) << 8);
00034 #define ARG_SINT32(x) sint32 x = (*args++); x += ((*args++) << 8); \
00035 x+= ((*args++) << 16); x += ((*args++) << 24);
00036 #define ARG_UC_PTR(x) uint32 x = (*args++); x += ((*args++) << 8); \
00037 x+= ((*args++) << 16); x += ((*args++) << 24);
00038 #define ARG_OBJID(x) ObjId x = (*args++); x += ((*args++) << 8);
00039 #define ARG_PROCID(x) ProcId x = (*args++); x += ((*args++) << 8);
00040
00041 #define ARG_OBJECT_FROM_PTR(x) ARG_UC_PTR(ucptr_##x); \
00042 uint16 id_##x = UCMachine::ptrToObject(ucptr_##x); \
00043 Object* x = getObject(id_##x);
00044 #define ARG_OBJECT_FROM_ID(x) ARG_OBJID(id_##x); \
00045 Object* x = getObject(id_##x);
00046
00047 #define ARG_ITEM_FROM_PTR(x) ARG_UC_PTR(ucptr_##x); \
00048 uint16 id_##x = UCMachine::ptrToObject(ucptr_##x); \
00049 Item* x = getItem(id_##x);
00050 #define ARG_ITEM_FROM_ID(x) ARG_OBJID(id_##x); \
00051 Item* x = getItem(id_##x);
00052
00053 #define ARG_CONTAINER_FROM_PTR(x) ARG_UC_PTR(ucptr_##x); \
00054 uint16 id_##x = UCMachine::ptrToObject(ucptr_##x); \
00055 Container* x = getContainer(id_##x);
00056 #define ARG_CONTAINER_FROM_ID(x) ARG_OBJID(id_##x); \
00057 Container* x = getContainer(id_##x);
00058
00059 #define ARG_ACTOR_FROM_PTR(x) ARG_UC_PTR(ucptr_##x); \
00060 uint16 id_##x = UCMachine::ptrToObject(ucptr_##x); \
00061 Actor* x = getActor(id_##x);
00062 #define ARG_ACTOR_FROM_ID(x) ARG_OBJID(id_##x); \
00063 Actor* x = getActor(id_##x);
00064
00065 #define ARG_EGG_FROM_PTR(x) ARG_UC_PTR(ucptr_##x); \
00066 uint16 id_##x = UCMachine::ptrToObject(ucptr_##x); \
00067 Egg* x = p_dynamic_cast<Egg*>(getObject(id_##x));
00068 #define ARG_EGG_FROM_ID(x) ARG_OBJID(id_##x); \
00069 Egg* x = p_dynamic_cast<Egg*>(getObject(id_##x));
00070
00071 #define ARG_STRING(x) ARG_UC_PTR(ucptr_##x); \
00072 uint16 id_##x = UCMachine::ptrToObject(ucptr_##x); \
00073 std::string x = UCMachine::get_instance()->getString(id_##x);
00074
00075 #define ARG_LIST(x) ARG_UINT16(id_##x); \
00076 UCList* x = UCMachine::get_instance()->getList(id_##x);
00077
00078 #define ARG_WORLDPOINT(x) ARG_UC_PTR(ucptr_##x); \
00079 WorldPoint x; \
00080 UCMachine::get_instance()->dereferencePointer(ucptr_##x, x.buf, 5);
00081
00082 #define ARG_NULL8() args+=1;
00083 #define ARG_NULL16() args+=2;
00084 #define ARG_NULL32() args+=4;
00085
00086 #endif