intrinsics.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2003-2005 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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 // TODO: range checking on args
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

Generated on Fri Jul 27 22:27:19 2007 for pentagram by  doxygen 1.4.7