static int init ( void ) { traceLastFunc( "init()" ); if ( g_hOrigDll == NULL ) { if ( GetModuleFileName(g_hDllModule, g_szWorkingDirectory, sizeof(g_szWorkingDirectory) - 32) != 0 ) { if ( strrchr(g_szWorkingDirectory, '\\') != NULL ) *strrchr( g_szWorkingDirectory, '\\' ) = 0; else strcpy( g_szWorkingDirectory, "." ); } else { strcpy( g_szWorkingDirectory, "." ); } // Hello World Log( "Initializing %s", NAME ); Log( "Compiled: %s CL:%d", COMPILE_DT, COMPILE_VERSION ); // log windows version for people that forget to report it WindowsInfo.osPlatform = (int) * (DWORD *)GTAvar_osPlatform; WindowsInfo.osVer = (int) * (DWORD *)GTAvar_osVer; WindowsInfo.winVer = (int) * (DWORD *)GTAvar_winVer; WindowsInfo.winMajor = (int) * (DWORD *)GTAvar_winMajor; if ( WindowsInfo.osPlatform == 2 ) Log( "OS: Windows Version %d.%d.%d", WindowsInfo.winMajor, WindowsInfo.winVer, WindowsInfo.osVer ); else Log( "OS: Not Windows (%d.%d.%d)", WindowsInfo.winMajor, WindowsInfo.winVer, WindowsInfo.osVer ); /* int D3D9UseVersion = (int)*(DWORD*)GTAvar__D3D9UseVersion; Log("D3D9UseVersion: %d", D3D9UseVersion); int DXVersion = (int)*(DWORD*)GTAvar__DXVersion; Log("DXVersion: %d", DXVersion); int windowsVersion = (int)*(DWORD*)GTAvar__windowsVersion; Log("windowsVersion: %d", windowsVersion); int CPUSupportsMMX = (int)*(DWORD*)__rwD3D9CPUSupportsMMX; int CPUSupports3DNow = (int)*(DWORD*)__rwD3D9CPUSupports3DNow; int CPUSupportsSSE = (int)*(DWORD*)__rwD3D9CPUSupportsSSE; int CPUSupportsSSE2 = (int)*(DWORD*)__rwD3D9CPUSupportsSSE2; if (!CPUSupportsMMX) Log("CPU Supports MMX: %d", CPUSupportsMMX); if (!CPUSupports3DNow) Log("CPU Supports 3DNow: %d", CPUSupports3DNow); if (!CPUSupportsSSE) Log("CPU Supports SSE: %d", CPUSupportsSSE); if (!CPUSupportsSSE2) Log("CPU Supports SSE2: %d", CPUSupportsSSE2); */ #pragma warning( disable : 4127 ) if ( sizeof(struct vehicle_info) != 2584 ) { Log( "sizeof(struct vehicle_info) == %d, aborting.", sizeof(struct vehicle_info) ); return 0; } if ( sizeof(struct actor_info) != 1988 ) { Log( "sizeof(struct actor_info) == %d, aborting.", sizeof(struct actor_info) ); return 0; } #pragma warning( default : 4127 ) ini_load(); if ( !set.i_have_edited_the_ini_file ) { MessageBox( 0, "Looks like you've not edited the .ini file like you were told to!\n""\n" "Before you can use mod_sa, you have to set \"i_have_edited_the_ini_file\" to true.\n" "We did this so you would read the INI file to see the configurability of mod_sa.\n", "You're a retard.", 0 ); ShellExecute( 0, "open", "notepad", INI_FILE, g_szWorkingDirectory, SW_SHOW ); return 0; } // get SAMP and set g_dwSAMP_Addr getSamp(); // get actual d3d9.dll and proxy original D3D9Device char filename[MAX_PATH]; GetSystemDirectory( filename, (UINT) (MAX_PATH - strlen("\\d3d9.dll") - 1) ); strlcat( filename, "\\d3d9.dll", sizeof(filename) ); g_hOrigDll = LoadLibrary( filename ); if ( g_hOrigDll == NULL ) { Log( "Failed to load %s", filename ); return 0; } orig_Direct3DCreate9 = ( D3DC9 ) GetProcAddress( g_hOrigDll, "Direct3DCreate9" ); if ( orig_Direct3DCreate9 == NULL ) { Log( "%s does not export Direct3DCreate9!?", filename ); FreeLibrary( g_hOrigDll ); return 0; } } return 1; }
static int init ( void ) { traceLastFunc( "init()" ); if ( g_hOrigDll == NULL ) { if ( GetModuleFileName(g_hDllModule, g_szWorkingDirectory, sizeof(g_szWorkingDirectory) - 32) != 0 ) { if ( strrchr(g_szWorkingDirectory, '\\') != NULL ) *strrchr( g_szWorkingDirectory, '\\' ) = 0; else strcpy( g_szWorkingDirectory, "." ); } else { strcpy( g_szWorkingDirectory, "." ); } // Hello World Log( "Initializing exe24 mod" ); Log( "Compiled: %s CL:%d", COMPILE_DT, COMPILE_VERSION ); // log windows version for people that forget to report it WindowsInfo.osPlatform = (int) * (DWORD *)GTAvar_osPlatform; WindowsInfo.osVer = (int) * (DWORD *)GTAvar_osVer; WindowsInfo.winVer = (int) * (DWORD *)GTAvar_winVer; WindowsInfo.winMajor = (int) * (DWORD *)GTAvar_winMajor; if ( WindowsInfo.osPlatform == 2 ) Log( "OS: Windows Version %d.%d.%d", WindowsInfo.winMajor, WindowsInfo.winVer, WindowsInfo.osVer ); else Log( "OS: Not Windows (%d.%d.%d)", WindowsInfo.winMajor, WindowsInfo.winVer, WindowsInfo.osVer ); #pragma warning( disable : 4127 ) if ( sizeof(struct vehicle_info) != 2584 ) { Log( "sizeof(struct vehicle_info) == %d, aborting.", sizeof(struct vehicle_info) ); return 0; } if ( sizeof(struct actor_info) != 1988 ) { Log( "sizeof(struct actor_info) == %d, aborting.", sizeof(struct actor_info) ); return 0; } #pragma warning( default : 4127 ) ini_load(); if ( !set.i_have_edited_the_ini_file ) { MessageBox( 0, "Error when starting exe24.info mod.","Error", 0 ); return 0; } // get SAMP and set g_dwSAMP_Addr getSamp(); // get actual d3d9.dll and proxy original D3D9Device char filename[MAX_PATH]; if (fileExists(".\\d3d9_exe24+.dll")) { strlcat(filename, ".\\d3d9_exe24+.dll", sizeof(filename)); } else { GetSystemDirectory(filename, (UINT)(MAX_PATH - strlen("\\d3d9.dll") - 1)); strlcat(filename, "\\d3d9.dll", sizeof(filename)); } g_hOrigDll = LoadLibrary( filename ); if ( g_hOrigDll == NULL ) { Log( "Failed to load %s", filename ); return 0; } orig_Direct3DCreate9 = ( D3DC9 ) GetProcAddress( g_hOrigDll, "Direct3DCreate9" ); if ( orig_Direct3DCreate9 == NULL ) { Log( "%s does not export Direct3DCreate9!?", filename ); FreeLibrary( g_hOrigDll ); return 0; } } return 1; }
void munger_perform64(t_munger *x, t_object *dsp64, double **ins, long numins, double **outs, long numouts, long sampleframes, long flags, void *userparam) { t_double *in = (t_double *)(ins[0]); t_double grate = x->grate_connected? *(t_double *)(ins[0]) : x->grate; t_double grate_var = x->grate_var_connected? *(t_double *)(ins[1]) : x->grate_var; t_double glen = x->glen_connected? *(t_double *)(ins[2]) : x->glen; t_double glen_var = x->glen_var_connected? *(t_double *)(ins[3]) : x->glen_var; t_double gpitch = x->gpitch_connected? *(t_double *)(ins[4]) : x->gpitch; t_double gpitch_var = x->gpitch_var_connected? *(t_double *)(ins[5]) : x->gpitch_var; t_double gpan_spread= x->gpan_spread_connected? *(t_double *)(ins[6]) : x->gpan_spread; t_double outsamp[MAXCHANNELS], samp; int newvoice, i, j; long n; t_double *out[MAXCHANNELS]; //t_double *outL = (t_double *)(w[10]); //t_double *outR = (t_double *)(w[11]); for (i=0;i<x->num_channels;i++) { out[i] = (t_double *)(outs[i]); } n = sampleframes; //make sure vars are updated if signals are connected; stupid, lazy, boob. x->grate = grate; x->grate_var = grate_var; x->glen = glen; x->glen_var = glen_var; x->gpitch = gpitch; x->gpitch_var = gpitch_var; x->gpan_spread = gpan_spread; //grate = grate + RAND01 * grate_var; //grate = grate + ((t_double)rand() - 16384.) * ONE_OVER_HALFRAND * grate_var; //gimme = x->srate_ms * grate; //grate is actually time-distance between grains if(gpan_spread > 1.) gpan_spread = 1.; if(gpan_spread < 0.) gpan_spread = 0.; if(!x->power) { while(n--) { //copy and zero out when unpowered (this is slightly less efficient than //the z_disabled approach, but some users expect it now for(i=0;i<x->num_channels;i++) { *out[i]++ = 0.; } } } else { t_buffer_obj *buffer = buffer_ref_getobject(x->l_buffer); t_float *tab = buffer_locksamples(buffer); double frames = 0; double nc = 0; if (tab) { frames = buffer_getframecount(buffer); nc = buffer_getchannelcount(buffer); } while(n--) { //outsampL = outsampR = 0.; for(i=0;i<x->num_channels;i++) outsamp[i] = 0.; //record a sample //if(x->recordOn) recordSamp(x, *in++); recordSamp(x, *in++); //grab a note if requested; works in oneshot mode or otherwise while(x->newnote > 0) { newvoice = findVoice(x); if(newvoice >= 0) { x->gvoiceCurrent[newvoice] = newNote(x, newvoice, x->newnote, frames); } x->newnote--; } //find a voice if it's time (high resolution). ignore if in "oneshot" mode if(!x->oneshot) { if(x->time >= (long)x->gimme) { x->time = 0; newvoice = findVoice(x); if(newvoice >= 0) { x->gvoiceCurrent[newvoice] = newSetup(x, newvoice, frames); } grate = grate + ((t_double)rand() - RAND_MAX * 0.5) * ONE_OVER_HALFRAND * grate_var; x->gimme = x->srate_ms * grate; //grate is actually time-distance between grains } } x->time++; //mix 'em, pan 'em for(i=0; i< x->maxvoices; i++) { //for(i=0; i<x->voices; i++) { if(x->gvoiceOn[i]) { //get a sample, envelope it if(x->externalBuffer) samp = getExternalSamp(x, x->gvoiceCurrent[i], tab, frames, nc); else samp = getSamp(x, x->gvoiceCurrent[i]); if (!x->gvoiceADSRon[i]) samp = envelope(x, i, samp) * x->gvoiceGain[i]; else samp = samp * ADSR_ADRtick(&x->gvoiceADSR[i]) * x->gvoiceGain[i]; //pan it if(x->num_channels == 2) { outsamp[0] += samp * x->gvoiceLPan[i]; outsamp[1] += samp * x->gvoiceRPan[i]; } else { //multichannel subroutine for(j=0;j<x->num_channels;j++) { outsamp[j] += samp * x->gvoiceSpat[i][j]; } } //see if grain is done after jumping to next sample point x->gvoiceCurrent[i] += (double)x->gvoiceDirection[i] * (double)x->gvoiceSpeed[i]; if (!x->gvoiceADSRon[i]) { if(++x->gvoiceDone[i] >= x->gvoiceSize[i]) x->gvoiceOn[i] = 0; } else { if(ADSR_getState(&x->gvoiceADSR[i]) == DONE) x->gvoiceOn[i] = 0; } } } for(i=0;i<x->num_channels;i++) { *out[i]++ = outsamp[i]; } } if (tab) buffer_unlocksamples(buffer); } }