Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

src/calls.c

Go to the documentation of this file.
00001 /* {{{
00002  * CalcRogue, a roguelike game for PCs, calculators and PDAs
00003  * Copyright (C) 2003 Jim Babcock
00004  * 
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  * }}} */
00019 // calls.c
00025 
00026 #include "crogue.h"
00027 
00028 //{{{
00029 void call_stepfunc(filelink f, uint x, uint y)
00030 {
00031     long args[2];
00032     
00033     if(isNull(f)) return;
00034     f = deref_file_ptr_partial(f);
00035     
00036     args[0] = x;
00037     args[1] = y;
00038     
00039     if(f.type == PTR_INTERPCALL)
00040         run_program(f.offset + w->constfileoffset, 2, (va_list)args);
00041     else
00042         ((void (*)(uint x, uint y))(w->dll_functions[f.offset]))(x, y);
00043 }
00044 //}}}
00045 //{{{
00046 void call_genericfunc(filelink f)
00047 {
00048     if(isNull(f)) return;
00049     f = deref_file_ptr_partial(f);
00050     
00051     if(f.type == PTR_INTERPCALL)
00052         run_program(f.offset + w->constfileoffset, 0, (va_list)NULL);
00053     else
00054         ((void (*)(void))(w->dll_functions[f.offset]))();
00055 }
00056 //}}}
00057 //{{{
00058 void call_throwhitfunc(filelink f, int monst)
00059 {
00060     long arg = monst;
00061     
00062     if(isNull(f)) return;
00063     f = deref_file_ptr_partial(f);
00064     
00065     if(f.type == PTR_INTERPCALL)
00066         run_program(f.offset + w->constfileoffset, 1, (va_list)&arg);
00067     else
00068         ((void (*)(int monst))(w->dll_functions[f.offset]))(monst);
00069 }
00070 //}}}
00071 //{{{
00072 int call_usefunc(filelink f, int which_item)
00073 {
00074     long arg = which_item;
00075     
00076     if(isNull(f)) return 0;
00077     f = deref_file_ptr_partial(f);
00078     
00079     if(f.type == PTR_INTERPCALL)
00080         return run_program(f.offset + w->constfileoffset, 1, (va_list)&arg);
00081     else
00082         return ((int (*)(int))(w->dll_functions[f.offset]))(which_item);
00083 }
00084 //}}}
00085 //{{{
00086 int call_attackfunc(filelink f, uint monst, uint damage, sint target)
00087 {
00088     long args[3];
00089     
00090     if(isNull(f)) return 0;
00091     f = deref_file_ptr_partial(f);
00092     
00093     args[0] = monst;
00094     args[1] = damage;
00095     args[2] = target;
00096     
00097     if(f.type == PTR_INTERPCALL)
00098         return run_program(f.offset + w->constfileoffset, 3, (va_list)args);
00099     else
00100         return ((int (*)(uint, uint, sint))
00101             (w->dll_functions[f.offset]))
00102             (monst, damage, target);
00103 }
00104 //}}}
00105 

Generated on Thu May 20 13:12:09 2004 for CalcRogue by doxygen 1.3.6