00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <stdlib.h>
00025 #include <stdio.h>
00026 #include <float.h>
00027 #include <math.h>
00028 #include <windows.h>
00029 #include <time.h>
00030 #include "struct.h"
00031 #include "..\common\postprocess\ximage.h"
00032 #include "local.h"
00033
00034 #include "snow.h"
00035
00036
00037 #if __X__MIPS__
00038 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00039 #endif
00040
00041 static HINSTANCE hDLLinstance=NULL;
00042
00043
00044
00045 #include "utils.h"
00046 #include "paint.c"
00047
00048
00049
00050 #if __WATCOMC__
00051 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00052 #elif __BC__
00053 BOOL WINAPI DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00054 #else
00055 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00056 #endif
00057 switch (dwReason) {
00058 case DLL_PROCESS_ATTACH:
00059 #if __X__MIPS__
00060 if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00061 #endif
00062
00063 hDLLinstance = hDLL;
00064 break;
00065 case DLL_PROCESS_DETACH:
00066 #if __X__MIPS__
00067 if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00068 #endif
00069
00070 break;
00071 }
00072 return (int)TRUE;
00073 }
00074
00075 #if __SC__
00076 #pragma startaddress(DllMain)
00077 #endif
00078
00079
00080
00081
00082
00083 long _RenderImageProcess(char *PrmList, XIMAGE *lpXimage){
00084
00085 long i,j, np, inp;
00086 long direct;
00087 int prob, speed;
00088 char dummy[255];
00089 fullscreenbuffer *S;
00090
00091 sscanf(PrmList,"%s %d %d %d",dummy, &prob, &direct, &speed);
00092
00093 S=lpXimage->Screen;
00094 srand(1109);
00095 np=(long)(((double)prob/2000.0)*((double)(lpXimage->Xmax)*(double)(lpXimage->Ymax)));
00096
00097 for (inp=0;inp<np/3;inp++){
00098 i=((lpXimage->Xmax-1)*(rand()))/RAND_MAX+1;
00099 j=((lpXimage->Ymax-1)*(rand()))/RAND_MAX+1;
00100 j=j+((lpXimage->this_frame)*speed);
00101 i=i+((lpXimage->this_frame)*direct);
00102 while (j>=lpXimage->Ymax){
00103 j=j-lpXimage->Ymax;
00104 }
00105 while (i>=lpXimage->Xmax){
00106 i=i-lpXimage->Xmax;
00107 }
00108 while (i<0){
00109 i=i+lpXimage->Xmax;
00110 }
00111 (S+(j*(lpXimage->Xmax))+i)->R=200;
00112 (S+(j*(lpXimage->Xmax))+i)->G=200;
00113 (S+(j*(lpXimage->Xmax))+i)->B=200;
00114
00115 if (i>0 && i<lpXimage->Xmax && j>0 && j<lpXimage->Ymax-1){
00116 (S+(j*(lpXimage->Xmax))+i+1)->R=255;
00117 (S+(j*(lpXimage->Xmax))+i+1)->G=255;
00118 (S+(j*(lpXimage->Xmax))+i+1)->B=255;
00119 (S+(j*(lpXimage->Xmax))+i-1)->R=255;
00120 (S+(j*(lpXimage->Xmax))+i-1)->G=255;
00121 (S+(j*(lpXimage->Xmax))+i-1)->B=255;
00122 (S+((j+1)*(lpXimage->Xmax))+i)->R=255;
00123 (S+((j+1)*(lpXimage->Xmax))+i)->G=255;
00124 (S+((j+1)*(lpXimage->Xmax))+i)->B=255;
00125 (S+((j-1)*(lpXimage->Xmax))+i)->R=255;
00126 (S+((j-1)*(lpXimage->Xmax))+i)->G=255;
00127 (S+((j-1)*(lpXimage->Xmax))+i)->B=255;
00128 }
00129
00130
00131
00132 }
00133 for (inp=0;inp<np/3;inp++){
00134 i=((lpXimage->Xmax-1)*(rand()))/RAND_MAX+1;
00135 j=((lpXimage->Ymax-1)*(rand()))/RAND_MAX+1;
00136 j=j+((lpXimage->this_frame)*(speed+1));
00137 i=i+((lpXimage->this_frame)*direct);
00138 while (j>=lpXimage->Ymax){
00139 j=j-lpXimage->Ymax;
00140 }
00141 while (i>=lpXimage->Xmax){
00142 i=i-lpXimage->Xmax;
00143 }
00144 while (i<0){
00145 i=i+lpXimage->Xmax;
00146 }
00147 (S+(j*(lpXimage->Xmax))+i)->R=255;
00148 (S+(j*(lpXimage->Xmax))+i)->G=255;
00149 (S+(j*(lpXimage->Xmax))+i)->B=255;
00150 }
00151
00152
00153 for (inp=0;inp<np/3;inp++){
00154 i=((lpXimage->Xmax-1)*(rand()))/RAND_MAX+1;
00155 j=((lpXimage->Ymax-1)*(rand()))/RAND_MAX+1;
00156 j=j+((lpXimage->this_frame)*(speed-1));
00157 i=i+((lpXimage->this_frame)*direct);
00158 while (j>=lpXimage->Ymax){
00159 j=j-lpXimage->Ymax;
00160 }
00161 while (i>=lpXimage->Xmax){
00162 i=i-lpXimage->Xmax;
00163 }
00164 while (i<0){
00165 i=i+lpXimage->Xmax;
00166 }
00167 (S+(j*(lpXimage->Xmax))+i)->R=255;
00168 (S+(j*(lpXimage->Xmax))+i)->G=255;
00169 (S+(j*(lpXimage->Xmax))+i)->B=255;
00170 }
00171
00172 return 1;
00173 }
00174
00175
00176
00177 long _RenderGLexternal(char *PrmList, XIMAGE *lpXimage){
00178 MessageBox(NULL,"OpenGL function called","OK",MB_OK);
00179 return 1;
00180 }
00181
00182
00183
00184
00185
00186 int prob=30;
00187 long angle=0;
00188 int speed=2;
00189
00190
00191
00192 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00193
00194 char * _SetExternalParameters(
00195 char *Op,
00196 HWND hWnd,
00197 long ruler,
00198 char *name,
00199 X__MEMORY_MANAGER *lpEVI
00200 ){
00201
00202 char buffer[256];
00203 if(Op != NULL){
00204 sscanf(Op,"%s %d %d %d",buffer, &prob, &angle, &speed);
00205 }
00206
00207
00208 if(DialogBox(hDLLinstance,MAKEINTRESOURCE(DLG_SNOW1),hWnd,
00209 (DLGPROC)DlgProc) == FALSE)return Op;
00210
00211 if(Op != NULL)CALL_FREE(Op);
00212
00213 sprintf(buffer,"%s %d %d %d",name, prob, angle, speed);
00214
00215 if((Op=(char *)CALL_MALLOC(strlen(buffer)+1)) == NULL){
00216 MessageBox (GetFocus(),"External effect: Out of memory","Error",
00217 MB_OK|MB_TASKMODAL|MB_ICONSTOP);
00218 return NULL;
00219 }
00220
00221 strcpy(Op,buffer);
00222 return Op;
00223 }
00224
00225 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00226 char str[32];
00227 switch( msg ) {
00228 case WM_INITDIALOG:
00229
00230 sprintf(str,"%d",prob);
00231 SetDlgItemText(hwnd,DLG_PROB,str);
00232 sprintf(str,"%d",angle);
00233 SetDlgItemText(hwnd,DLG_ANGLE,str);
00234 sprintf(str,"%d",speed);
00235 SetDlgItemText(hwnd,DLG_SPEED,str);
00236 CentreDialogOnScreen(hwnd);
00237 return TRUE;
00238 case WM_PAINT:
00239 PaintBackground(hwnd);
00240 break;
00241 return TRUE;
00242 case WM_COMMAND:
00243 switch(LOWORD(wparam)){
00244 case IDCANCEL:
00245 EndDialog(hwnd,FALSE);
00246 return(TRUE);
00247 case IDOK:
00248 if(GetDlgItemText(hwnd,DLG_PROB,str,12) != 0)
00249 sscanf(str,"%d",&prob);
00250 if(GetDlgItemText(hwnd,DLG_ANGLE,str,12) != 0)
00251 sscanf(str,"%d",&angle);
00252 if(GetDlgItemText(hwnd,DLG_SPEED,str,12) != 0)
00253 sscanf(str,"%d",&speed);
00254 if (speed<2){
00255 MessageBox(NULL,"The speed value must be greater than 1.",NULL,MB_OK);
00256 }
00257 else EndDialog(hwnd,TRUE);
00258 return(TRUE);
00259 default:
00260 break;
00261 }
00262 break;
00263 default: break;
00264 }
00265 return FALSE;
00266 }
00267