00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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