Changeset 444
- Timestamp:
- Jul 18, 2009, 11:38:22 AM (15 years ago)
- Location:
- Daodan
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Daodan/src/BFW_ScriptingLanguage.h
r440 r444 27 27 } sl_arg; 28 28 29 typedef uint16_t (ONICALL *sl_func)(void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret); 29 typedef struct { 30 char* name; 31 char* calllocation; //maybe 32 } sl_callinfo; 33 34 typedef uint16_t (ONICALL *sl_func)(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret); 30 35 31 36 uint16_t ONICALL SLrScript_Command_Register_ReturnType(char* name, char* desc, char* argfmt, sl_type type, sl_func callback); -
Daodan/src/Daodan_BSL.c
r443 r444 4 4 5 5 #include "Daodan_BSL.h" 6 #include "Daodan_Utility.h" 7 #include "Daodan_Console.h" 6 8 #include "BFW_ScriptingLanguage.h" 7 9 #include "Oni.h" … … 9 11 #include "dSFMT\dSFMT.h" 10 12 11 uint16_t ONICALL bsl_int32mul( void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)13 uint16_t ONICALL bsl_int32mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) 12 14 { 13 15 if (numargs < 2) … … 18 20 } 19 21 20 uint16_t ONICALL bsl_mul( void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)22 uint16_t ONICALL bsl_mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) 21 23 { 22 24 if (numargs < 2) … … 41 43 } 42 44 43 uint16_t ONICALL bsl_int32div( void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)45 uint16_t ONICALL bsl_int32div(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) 44 46 { 45 47 if (numargs < 2) … … 50 52 } 51 53 52 uint16_t ONICALL bsl_div( void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)54 uint16_t ONICALL bsl_div(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) 53 55 { 54 56 if (numargs < 2) … … 73 75 } 74 76 75 uint16_t ONICALL bsl_int32rand( void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)77 uint16_t ONICALL bsl_int32rand(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) 76 78 { 77 79 if (numargs < 2) … … 99 101 } 100 102 101 uint16_t ONICALL bsl_getkills( void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)103 uint16_t ONICALL bsl_getkills(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) 102 104 { 103 105 int index; … … 110 112 } 111 113 112 uint16_t ONICALL bsl_getdamage( void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)114 uint16_t ONICALL bsl_getdamage(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) 113 115 { 114 116 int index; … … 120 122 return 0; 121 123 } 122 123 uint16_t ONICALL bsl_sprintf( void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)124 /* 125 uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) 124 126 { 125 127 if (numargs < 2) … … 127 129 128 130 char output[255]; 129 char temp[255]; 130 int i = 1; 131 for(i; i < numargs; i++) { 132 sprintf(output, args[0].value_str32, args[i].value_str32);/* 133 if(args[i].type == sl_int32 || args[i].type == sl_bool) { 134 sprintf(temp, "%i",args[i].value_int32); 135 sprintf(output, args[0].value_str32, temp); } 136 else if(args[i].type == sl_float) { 137 sprintf(temp, "%f",args[i].value_float); 138 sprintf(output, args[0].value_str32, temp); } 139 else*/ 131 int i; 132 for(i = 1; i < numargs; i++) { 133 sprintf(output, args[0].value_str32, args[i].value_str32); 140 134 } 141 135 … … 144 138 return 0; 145 139 } 146 /* 147 char* sprintf_return = NULL; 148 uint16_t ONICALL bsl_sprintf(void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) 149 { 150 if (!sprintf_return)151 sprintf_return = malloc(4096);140 */ 141 uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) 142 { 143 int ffi_ret; 144 char* str = NULL; 145 int size = 0; 152 146 153 147 ffi_cif cif; 154 ffi_type *ffi_args[256]; 155 void *values[256]; 156 int ffi_ret; 148 ffi_type* ffi_args[256]; 149 void* values[256]; 157 150 158 151 ffi_args[0] = &ffi_type_pointer; 159 values[0] = sprintf_return;152 values[0] = &str; 160 153 ffi_args[1] = &ffi_type_uint32; 161 values[1] = (void*)4095;154 values[1] = &size; 162 155 163 156 int i; 164 157 for(i = 2; i < numargs + 2; i ++) 165 158 { 166 ffi_args[i] = &ffi_type_pointer; 167 values[i] = args[i - 2].value; 168 } 169 170 ffi_prep_cif(&cif, FFI_DEFAULT_ABI, i, &ffi_type_sint32, ffi_args); 159 if (args[i - 2].type == sl_float) 160 { 161 float value_float = args[i - 2].value_float; 162 double* value_double = (double*)&(args[i - 2]); 163 *value_double = value_float; 164 165 ffi_args[i] = &ffi_type_double; 166 values[i] = value_double; 167 } 168 else 169 { 170 ffi_args[i] = &ffi_type_pointer; 171 values[i] = &(args[i - 2].value); 172 } 173 } 174 175 if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, i, &ffi_type_sint32, ffi_args) != FFI_OK) 176 MessageBox(0, "", "", 0); 171 177 ffi_call(&cif, (void*)snprintf, (void*)&ffi_ret, values); 172 173 ret->value_str32 = sprintf_return; 178 str = malloc(ffi_ret + 1); 179 size = ffi_ret + 1; 180 ffi_call(&cif, (void*)snprintf, (void*)&ffi_ret, values); 181 ret->value_str32 = str; 174 182 ret->type = sl_str32; 175 183 return 0; 176 184 } 177 */178 185 179 186 void SLrDaodan_Initalize() -
Daodan/src/Oni_Symbols.S
r442 r444 53 53 symbol ( @ONrGameState_GetPlayerCharacter@0 , 0x000b63a7 ) 54 54 symbol ( @ONrGetActiveCharacter@4 , 0x000f1180 ) 55 55 56 // Console 56 57 symbol ( @TSrContext_DrawText@20 , 0x0002DF00 ) 58 symbol ( @TSrContext_New@24 , 0x0002EA30 ) 59 symbol ( @TMrInstance_GetDataPtr@12 , 0x000232E0 ) 57 symbol ( @TSrContext_DrawText@20 , 0x0002DF00 ) 58 symbol ( @TSrContext_New@24 , 0x0002EA30 ) 59 symbol ( @TMrInstance_GetDataPtr@12 , 0x000232E0 ) 60 60 61 61 symbol ( @COrTextArea_Print@28 , 0x00031340 ) 62 62 63 symbol ( _COgConsoleLines , 0x001cb468 ) 63 64 symbol ( _COgFadeTimeValue , 0x00133f68 ) … … 67 68 // ScriptingLanguage 68 69 symbol ( @SLrScript_Command_Register_ReturnType@20 , 0x00077b20 ) 70 symbol ( @SLrScript_Command_Register_Void@16 , 0x00077b40 ) 71 symbol ( @SLrGlobalVariable_Register_Int32@12 , 0x00077e30 ) 72 symbol ( @SLrGlobalVariable_Register_Float@12 , 0x00077ec0 ) 69 73
Note:
See TracChangeset
for help on using the changeset viewer.