LoopScript.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2003 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 LOOPSCRIPT_H_INCLUDED
00020 #define LOOPSCRIPT_H_INCLUDED
00021 
00022 // Script Tokens
00023 #define LS_TOKEN_AND                    '&'
00024 #define LS_TOKEN_OR                             '+'
00025 #define LS_TOKEN_NOT                    '!'
00026 #define LS_TOKEN_EQUAL                  '='
00027 #define LS_TOKEN_GREATER                '>'
00028 #define LS_TOKEN_LESS                   '<'
00029 #define LS_TOKEN_GEQUAL                 ']'
00030 #define LS_TOKEN_LEQUAL                 '['
00031 
00032 #define LS_TOKEN_INT                    '%'
00033 
00034 #define LS_TOKEN_TRUE                   1
00035 #define LS_TOKEN_FALSE                  0
00036 #define LS_TOKEN_NPCNUM                 '#'
00037 #define LS_TOKEN_STATUS                 '?'
00038 #define LS_TOKEN_Q                              '*'
00039 #define LS_TOKEN_FAMILY                 ':'
00040 #define LS_TOKEN_SHAPE                  '@'
00041 #define LS_TOKEN_FRAME                  '`'
00042 
00043 #define LS_TOKEN_END                    '$'     
00044 
00045 //
00046 // Generating Loopscripts aka Abusing the C Preprocessor
00047 //
00048 
00049 //
00050 // Highlevel Function Like Scripts
00051 //
00052 // Usage:
00053 //
00054 // LOOPSCRIPT(script, LS_AND(LS_SHAPE_EQUAL(73), LS_Q_EQUAL(4)));
00055 //
00056 
00057 //
00058 // Tokenized Scripts
00059 //
00060 // Usage:
00061 //
00062 // const uint8 script[] = { 
00063 //      LS_TOKEN_SHAPE,
00064 //      LS_TOKEN_INT,
00065 //      LS_CONSTANT(73),
00066 //      LS_TOKEN_EQUAL,
00067 //      LS_TOKEN_Q,
00068 //      LS_TOKEN_INT,
00069 //      LS_CONSTANT(4),
00070 //      LS_TOKEN_EQUAL,
00071 //      LS_TOKEN_AND,
00072 //      LS_TOKEN_END
00073 // };
00074 //
00075 
00076 #define LOOPSCRIPT(name,tokens) const uint8 name[] = { tokens, LS_TOKEN_END }
00077 
00078 #define LS_CONSTANT(val)                        ((val)&0xFF), ((val>>8)&0xFF)
00079 #define LS_INT(val)                                     LS_TOKEN_INT, LS_CONSTANT(val)
00080 
00081 #define LS_OP(left, op, right)          left, right, op
00082 
00083 #define LS_NOT(left)                            left, LS_TOKEN_NOT
00084 #define LS_AND(left,right)                      left, right, LS_TOKEN_AND
00085 #define LS_OR(left,right)                       left, right, LS_TOKEN_OR
00086 
00087 #define LS_EQUAL(left,right)            left, right, LS_TOKEN_EQUAL
00088 #define LS_LEQUAL(left,right)           left, right, LS_TOKEN_LEQUAL
00089 #define LS_GEQUAL(left,right)           left, right, LS_TOKEN_GEQUAL
00090 #define LS_LESS(left,right)                     left, right, LS_TOKEN_LESS
00091 #define LS_GREATER(left,right)          left, right, LS_TOKEN_GREATER
00092 
00093 #define LS_FAMILY_EQUAL(val)            LS_EQUAL(LS_TOKEN_FAMILY,LS_INT(val))
00094 #define LS_NPCNUM_EQUAL(val)            LS_EQUAL(LS_TOKEN_NPCNUM,LS_INT(val))
00095 #define LS_STATUS_EQUAL(val)            LS_EQUAL(LS_TOKEN_STATUS,LS_INT(val))
00096 #define LS_Q_EQUAL(val)                         LS_EQUAL(LS_TOKEN_Q,LS_INT(val))
00097 
00098 #define LS_SHAPE_EQUAL(val)                     LS_EQUAL(LS_TOKEN_SHAPE,LS_INT(val))
00099 #define LS_SHAPE_EQUAL1(a)                      LS_TOKEN_SHAPE+1, LS_CONSTANT(a)
00100 #define LS_SHAPE_EQUAL2(a,b)            LS_TOKEN_SHAPE+2, LS_CONSTANT(a), LS_CONSTANT(b)
00101 #define LS_SHAPE_EQUAL3(a,b,c)          LS_TOKEN_SHAPE+3, LS_CONSTANT(a), LS_CONSTANT(b), LS_CONSTANT(c)
00102 #define LS_SHAPE_EQUAL4(a,b,c,d)        LS_TOKEN_SHAPE+4, LS_CONSTANT(a), LS_CONSTANT(b), LS_CONSTANT(c), LS_CONSTANT(d)
00103 
00104 #define LS_FRAME_EQUAL(val)                     LS_EQUAL(LS_TOKEN_FRAME,LS_INT(val))
00105 #define LS_FRAME_EQUAL1(a)                      LS_TOKEN_FRAME+1, LS_CONSTANT(a)
00106 #define LS_FRAME_EQUAL2(a,b)            LS_TOKEN_FRAME+2, LS_CONSTANT(a), LS_CONSTANT(b)
00107 #define LS_FRAME_EQUAL3(a,b,c)          LS_TOKEN_FRAME+3, LS_CONSTANT(a), LS_CONSTANT(b), LS_CONSTANT(c)
00108 #define LS_FRAME_EQUAL4(a,b,c,d)        LS_TOKEN_FRAME+4, LS_CONSTANT(a), LS_CONSTANT(b), LS_CONSTANT(c), LS_CONSTANT(d)
00109 
00110 #endif

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