6 int sx,sy; // Onscreen coordinates
\r
7 int dx,dy; // Device values
\r
10 struct Target Targ[2]=
\r
15 static int LightState=0;
\r
22 static struct Calib Cal={0.0f,0.0f,0.0f,0.0f};
\r
28 memset(Targ,0,sizeof(Targ));
\r
29 Targ[0].sx=MainWidth >>1;
\r
30 Targ[0].sy=MainHeight>>1;
\r
31 Targ[1].sy=Targ[0].sy-MainHeight*61/160;
\r
32 Targ[1].sx=Targ[0].sx-MainWidth *61/160;
\r
36 int LightCalUpdate()
\r
39 struct Target *pt=NULL;
\r
41 if (Inp.held[4]==1) LoopMode=3;
\r
55 // rx= a + b*x - work out a and b:
\r
56 num=Targ[0].sx-Targ[1].sx;
\r
57 den=Targ[0].dx-Targ[1].dx;
\r
58 if (den) Cal.bx=(float)num/(float)den;
\r
59 Cal.ax=(float)Targ[0].sx-Cal.bx*(float)Targ[0].dx;
\r
61 num=Targ[0].sy-Targ[1].sy;
\r
62 den=Targ[0].dy-Targ[1].dy;
\r
63 if (den) Cal.by=(float)num/(float)den;
\r
64 Cal.ay=(float)Targ[0].sy-Cal.by*(float)Targ[0].dy;
\r
73 int LightCalRender()
\r
76 struct Target *pt=NULL;
\r
77 float fx=0.0f,fy=0.0f;
\r
79 DirectClear(0xffffff);
\r
82 wsprintfW(text,L"LightGun Calibration");
\r
83 FontSetColour(0x0000ff);
\r
84 FontText(text,240,48);
\r
86 wsprintfW(text,L"Start to quit, B to call InputLightCal");
\r
87 FontSetColour(0x004000);
\r
88 FontText(text,64,120);
\r
93 FontText(L"X", pt->sx-8, pt->sy-12);
\r
95 fx=Cal.ax+Cal.bx*(float)Inp.axis[0];
\r
96 fy=Cal.ay+Cal.by*(float)Inp.axis[1];
\r
98 FontSetColour(0xff0000);
\r
99 FontText(L"+", (int)fx-8,(int)fy-12);
\r