1
0

creditsrend.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  1. #include "main.h"
  2. #define LAND_SIZE 500
  3. #define LAND_DIV 12
  4. extern void plTextPutStrW(pl_Cam* cam, pl_sInt x, pl_sInt y, pl_Float z, pl_uChar color, const wchar_t* string);
  5. static void setup_materials(pl_Mat **mat, unsigned char *pal);
  6. static pl_Obj *setup_landscape(float size, int div, pl_Mat *m);
  7. static pl_Mat *mat[7];
  8. static pl_Cam *cam;
  9. static pl_Obj *land,*object[8], *lightobject,*lightobject2, *billboard, *teamobject;
  10. static pl_Spline spline;
  11. static pl_Float splineTime;
  12. static pl_Light *light;
  13. static unsigned int prevtime;
  14. static pl_Texture *grndtex, *watex, *walogotex, *teamtex;
  15. static char *teamtexbase;
  16. static int displaycredits=1;
  17. static float keys1[8*5];
  18. static void initspline(int i)
  19. {
  20. spline.keys[i*5+0] = (pl_Float)(warand()%320)-160;
  21. spline.keys[i*5+1] = (pl_Float)(warand()%110)+15;
  22. spline.keys[i*5+2] = (pl_Float)(warand()%320)-160;
  23. spline.keys[i*5+3] = (pl_Float)(warand()%32)/32.0f;
  24. spline.keys[i*5+4] = (pl_Float)(warand()%32)/32.0f;
  25. }
  26. static unsigned int m_creditspos;
  27. static int m_creditspos_frames;
  28. static int m_lastpos;
  29. static int rpoo=1;
  30. void render_togglecredits()
  31. {
  32. displaycredits=!displaycredits;
  33. }
  34. void render_init(int w, int h, char *pal)
  35. {
  36. int i;
  37. float wd;
  38. int ishigh=!!(GetAsyncKeyState(VK_SHIFT)&GetAsyncKeyState(VK_MENU)&0x8000);
  39. rpoo=1;
  40. splineTime=0.0;
  41. spline.tens = (pl_Float)-0.6;
  42. spline.keyWidth = 5;
  43. spline.numKeys = 8;
  44. spline.keys = keys1;
  45. for (i = 0; i < spline.numKeys; i ++)
  46. {
  47. initspline(i);
  48. }
  49. cam = plCamCreate(w,h,1.0,120.0,NULL,NULL);
  50. cam->ScreenWidth=w;
  51. cam->ScreenHeight=h;
  52. cam->ClipTop = 1;
  53. cam->ClipLeft = 1;
  54. cam->ClipBottom = h-1;
  55. cam->ClipRight = w-1;
  56. cam->AspectRatio=1.0;
  57. cam->CenterX=w/2;
  58. cam->CenterY=h/2;
  59. cam->Sort = 1;
  60. cam->Z = -60;
  61. light = plLightCreate();
  62. setup_materials(mat,(unsigned char*)pal);
  63. land = setup_landscape(LAND_SIZE,ishigh?LAND_DIV*2:LAND_DIV,mat[0]);
  64. teamobject = plMakeBox(32,32,32,mat[5]);
  65. teamobject->Yp=75;
  66. teamobject->Xp=-LAND_SIZE/3;
  67. teamobject->Za=-90;
  68. teamobject->Ya=90;
  69. teamobject->BackfaceCull=0;
  70. billboard = plMakePlane(LAND_SIZE/3,90,1,mat[4]);
  71. billboard->Yp=75;
  72. billboard->Xp=LAND_SIZE/3;
  73. billboard->Za=-90;
  74. billboard->Ya=90;
  75. billboard->BackfaceCull=0;
  76. wd=9.8f;
  77. for (i = 0; i < sizeof(object)/sizeof(object[0]); i++)
  78. {
  79. object[i]=plObjCreate(0,0);
  80. object[i]->Xp=0;
  81. object[i]->Yp=90;
  82. object[i]->Zp=0;
  83. object[i]->Children[0]=plMakeTorus(wd,wd+4.0f,ishigh?(64+i*4):(12+i*2),ishigh?12:6,mat[1+(i&1)]);
  84. wd+=5.8f;
  85. }
  86. lightobject=plMakeSphere(17.0,ishigh?16:6,ishigh?24:8,mat[3]);
  87. lightobject2=plMakeSphere(17.0,ishigh?16:6,ishigh?24:8,mat[3]);
  88. m_creditspos=GetTickCount64();
  89. m_creditspos_frames=0;
  90. m_lastpos=-1;
  91. prevtime=GetTickCount64();
  92. }
  93. // 128 frames:
  94. // 0-15, silence
  95. // 16-31, fadein
  96. // 32-111, display
  97. // 112-127, fadeout
  98. void render_quit(void)
  99. {
  100. int x;
  101. m_lastpos=-1;
  102. m_creditspos=0;
  103. m_creditspos_frames=0;
  104. plObjDelete(land); land=0;
  105. plObjDelete(billboard); billboard=0;
  106. plObjDelete(teamobject); teamobject=0;
  107. for (x = 0; x < sizeof(object)/sizeof(object[0]); x ++)
  108. {
  109. plObjDelete(object[x]); object[x]=0;
  110. }
  111. plObjDelete(lightobject);
  112. plObjDelete(lightobject2);
  113. for (x = 0; x < sizeof(mat)/sizeof(mat[0])-1; x ++)
  114. {
  115. plMatDelete(mat[x]); mat[x]=0;
  116. }
  117. plCamDelete(cam); cam=0;
  118. plLightDelete(light); light=0;
  119. plTexDelete(grndtex); grndtex=0;
  120. plTexDelete(watex); watex = 0;
  121. if (teamtex && teamtexbase) teamtex->Data = teamtexbase; teamtexbase=0;
  122. plTexDelete(teamtex); teamtex=0;
  123. plTexDelete(walogotex); walogotex=0;
  124. }
  125. #define WIDEN2(x) L ## x
  126. #define WIDEN(x) WIDEN2(x)
  127. static wchar_t *creditslist[]=
  128. {
  129. L"Winamp v" WIDEN(APP_VERSION) L"\n"
  130. L" The Credits"
  131. ,
  132. L"Winamp v" WIDEN(APP_VERSION) L" Development:\n"
  133. L" Quentin Hebette\n"
  134. L" Thierry Honore\n"
  135. L" Lionel Peeters\n"
  136. L" Hakan Danisik\n"
  137. L" Eddy Richman\n"
  138. L" Jef Mauguit\n"
  139. // L" Mher Didaryan\n"
  140. // L" Siarhei Herasiuta\n"
  141. // L" Ben Allison\n"
  142. ,
  143. L"QA, Engineering & Support:\n"
  144. L" DJ Egg\n"
  145. ,
  146. L"Freeform Skin Engine Updates:\n"
  147. L" Linus Brolin"
  148. ,
  149. L"Bento Skin:\n"
  150. L" Martin Pohlmann\n"
  151. L" Taber Buhl\n"
  152. L" Ben Allison\n"
  153. L" Victor Brocaz\n"
  154. ,
  155. L"Language Packs:\n"
  156. // L" Dutch: Paul van Garderen\n"
  157. L" French: Julien Victor, Benoit Hervier\n"
  158. L" German: Christoph Grether\n"
  159. // L" Italian: Flocksoft, Riccardo Vianello\n"
  160. L" Polish: Pawel Porwisz"
  161. ,
  162. L"Language Packs:\n"
  163. L" Spanish: Manuel Fernando Gutierrez, Joel Almeida,\n"
  164. L" Darwin Toledo Caceres aka Niwrad\n"
  165. // L" Swedish: Kenneth Chen, Amir Tehrani,\n"
  166. // L" Björn-Ole Antonsen\n"
  167. L" Russian: Nureev Aleksandr, Eduard Galkin\n"
  168. L" Turkish: Ali Sarioglu"
  169. ,
  170. L"Language Packs:\n"
  171. L" Portuguese (Brazil): Anderson Silva\n"
  172. // L" Romanian: Catalin, Sebastian Alexandru\n"
  173. L" Japanese: Toshiya Matsuo\n"
  174. L" Hungarian: Laszlo Gardonyi\n"
  175. // L" Indonesian: Antony Kurniawan"
  176. ,
  177. L"Winamp Hall-of-Fame:\n"
  178. L" Justin Frankel\n"
  179. L" Christophe Thibault\n"
  180. L" Francis Gastellu\n"
  181. L" Brennan Underwood\n"
  182. L" Peter Pawlowski\n"
  183. L" Tom Pepper\n"
  184. L" Ryan Geiss\n"
  185. L" Will Fisher\n"
  186. L" Maksim Tyrtyshny\n"
  187. L" Darren Owen\n"
  188. L" Ben Allison"
  189. ,
  190. L"Installer packaged with NSIS:\n"
  191. L" http://nsis.sourceforge.net/\n"
  192. L" thanklessly maintained by\n"
  193. L" Amir Szekely\n"
  194. L" Anders Kjersem\n"
  195. L"Unicode NSIS port\n"
  196. L" by Jim Park\n"
  197. L" http://www.scratchpaper.com"
  198. ,
  199. L"Modern Skin:\n"
  200. L" Sven Kistner\n"
  201. L" http://www.metrix.de"
  202. ,
  203. /*L"Online Help: Jatin Billimoria\n"
  204. L" with updates from DJ Egg"
  205. ,*/
  206. L"PCM EQ magic:\n"
  207. L" 4Front Technologies/George Yohng\n"
  208. L" http://www.yohng.com/\n"
  209. L"\n"
  210. L"EQ presets: Lars Holmberg"
  211. /*
  212. ,
  213. L"MikMod plug-in:\n"
  214. L" Jake Stine\n"
  215. L" ...testing:\n"
  216. L" Mathew Valente"
  217. */
  218. ,
  219. L"Intro sound: JJ McKay"
  220. ,
  221. /*
  222. L"Nullsoft Alumni (aka fun-haters):\n"
  223. L" Rob Lord, Ian Rogers, Ryan Melcher\n"
  224. L" Patrick Goddard, Jason Crawford\n"
  225. L" Daniel Ruben, Kyle Yamamoto\n"
  226. L" Susan Becker, Bill Thompson\n"
  227. L" Josh Gerrish, Steven Blumenfeld\n"
  228. L" Bonnie Burton, Rolf Hanson"
  229. ,
  230. L"Nullsoft Alumni (continued):\n"
  231. L" Chris Amen, Keith Peters\n"
  232. L" Konstantin Martynenko\n"
  233. L" Justin Frankel, Christophe Thibault\n"
  234. L" Steve Gedikian, David Biderman\n"
  235. L" Tom Pepper, Ghislain 'Aus' Lacroix\n"
  236. L" Jonathan Ward, Michael 'Mig' Gerard\n"
  237. L" ...and DENNY!"
  238. ,
  239. L"Nullsoft Alumni (continued):\n"
  240. L" Lloyd Given, Scott Brown\n"
  241. L" Ben Sutherland, Wen Huang\n"
  242. L" Ben Pontius, Brenda Chung\n"
  243. L" Lauren Axelrod, Shaun Montgomery\n"
  244. L" Chris Edwards, Matt Callaway\n"
  245. L" Stephen 'Tag' Loomis, Jason Herskowitz"
  246. ,
  247. L"Nullsoft Alumni (continued):\n"
  248. L" Ben London, Ying Chen, Rob Gould, Marcian Lytwyn\n"
  249. L" Shawn Lavelle, Alex Petty, Chad Tempest\n"
  250. L" Vanaja Nataraj, Ashok Bania, Venkatraman L\n"
  251. L" Smita Roul, Shiva Virupaksha, Gautam Dayanidhi\n"
  252. L" John Niranjan, Krishna Chaitanya, Chitra A, Rakesh G A\n"
  253. L" Sumit Kumar, Vinay Sharma, Sudhindra Aithal\n"
  254. L" Venkatesh Arya, Manoj Chourasia, Basavana Gowda\n"
  255. L" Niharika Patro, Prasanna Revan, Mohan Balaji, Sasikumar R"
  256. ,
  257. L"Nullsoft Alumni (continued):\n"
  258. L" Geno Yoham, Tarik Dahir, Tejas Mistry, Billy White, Bill Hicks\n"
  259. L" Jonathan Chester, Gergo Spolarics, Maksim Tyrtyshny\n"
  260. L" Taber Buhl, Shashikiran Reddy, Ryan Flynn, James Cready\n"
  261. */
  262. L"Credits rendered with Plush:\n"
  263. L" http://www.cockos.com/wdl/\n"
  264. L" (8bpp foreva)"
  265. ,
  266. L"Thanks:\n"
  267. L" NS Beta Team & Craig Freer\n"
  268. L" Our lowly forum moderators\n"
  269. L" Our precious skin reviewers\n"
  270. L" EFnet #mpeg3\n"
  271. L" 4Front Technologies"
  272. ,
  273. /*
  274. L"So long and ...\n"
  275. L" thanks for all the fish"
  276. ,
  277. L"We really whipped the llama's ass!"
  278. ,
  279. L"Much <3 to all who have helped\n"
  280. L"both directly and indirectly with\n"
  281. L"Winamp over the many years!"
  282. ,
  283. L"At the going down of the sun\n"
  284. L"and in the morning ...\n\n"
  285. L"we will remember Winamp <3"
  286. ,
  287. */
  288. L" Copyright © 1997-2023\n"
  289. L" Winamp SA\n"
  290. L" www.winamp.com"
  291. ,
  292. L""
  293. ,
  294. L"(you can double left click to toggle the credits\n"
  295. L" for your viewing pleasure)"
  296. ,
  297. L"(you can also double right click to go into\n"
  298. L" crappy fullscreen mode)"
  299. ,
  300. L""
  301. };
  302. static int creditslist_l=(sizeof(creditslist)/sizeof(creditslist[0]))*128;
  303. static unsigned int start_time;
  304. static int text_hW(const wchar_t *str)
  305. {
  306. int nc=1;
  307. while (str && *str)
  308. {
  309. if (*str==L'\n') nc++;
  310. str++;
  311. }
  312. return ScaleY(nc*17);
  313. }
  314. static int text_hA(const char* str)
  315. {
  316. int nc = 1;
  317. while (str && *str)
  318. {
  319. if (*str == '\n') nc++;
  320. str++;
  321. }
  322. return ScaleY(nc * 17);
  323. }
  324. static int text_w(const wchar_t *str)
  325. {
  326. int maxc=0,nc=0;
  327. while (str && *str)
  328. {
  329. if (*str==L'\n') nc=0;
  330. else nc++;
  331. str++;
  332. if (nc > maxc) maxc=nc;
  333. }
  334. return ScaleX(maxc*9);
  335. }
  336. #ifndef STATICBALLTEXTURE
  337. #define FIRE_BITMAP_W 64
  338. #define FIRE_BITMAP_H 64
  339. void makeBallTexture(char *tx)
  340. {
  341. int y;
  342. unsigned char *p=(unsigned char *)tx;
  343. int x;
  344. unsigned char *t=p + FIRE_BITMAP_W*FIRE_BITMAP_H;
  345. for (x = 0; x < FIRE_BITMAP_W; x ++)
  346. {
  347. int a=*t - 10;
  348. if ((warand()&0x7) == 7) a+=130;
  349. if (a < 0) a=0;
  350. else if (a > 150) a=150;
  351. *t++=a;//warand()&0xf0;
  352. }
  353. for (y = 0; y < FIRE_BITMAP_H; y ++)
  354. {
  355. *p++=p[0]/4 + p[FIRE_BITMAP_W]/2 + p[FIRE_BITMAP_W+1]/4;
  356. for (x = 1; x < FIRE_BITMAP_W-1; x ++)
  357. *p++=p[0]/4 + p[FIRE_BITMAP_W]/4 + p[FIRE_BITMAP_W-1]/4 + p[FIRE_BITMAP_W+1]/4;
  358. *p++=p[0]/4 + p[FIRE_BITMAP_W]/2 + p[FIRE_BITMAP_W-1]/4;
  359. }
  360. }
  361. void makeBallTextPal(char *pal)
  362. {
  363. unsigned char *t=(unsigned char *)pal;
  364. int x=255;
  365. t[0]=t[1]=t[2]=0;
  366. t+=3;
  367. while (x)
  368. {
  369. if (x > 128)
  370. {
  371. int a=256-x;
  372. a*=3;
  373. if (a>255)a=255;
  374. t[2]=0;
  375. t[1]=a/2;
  376. t[0]=a;
  377. }
  378. else
  379. {
  380. t[2]=256-x*2;
  381. t[1]=255/3 + ((256-x)*2)/3;
  382. t[0]=255;
  383. }
  384. t+=3;
  385. x--;
  386. }
  387. }
  388. #endif
  389. void render_render(unsigned char *framebuffer, HDC hdc)
  390. {
  391. static float light_sc=0.2f+2*0.3f;
  392. pl_Float curpos[5];
  393. int i;
  394. cam->frameBuffer=framebuffer;
  395. {
  396. unsigned int now = GetTickCount64();
  397. unsigned int t = now - prevtime;
  398. if (t < 0) t=0;
  399. splineTime += (pl_Float)(t*(0.01/33.0));
  400. prevtime=now;
  401. }
  402. if (splineTime > spline.numKeys)
  403. {
  404. for (i = 2; i < spline.numKeys-2; i ++)
  405. {
  406. initspline(i);
  407. }
  408. rpoo=0;
  409. splineTime -= spline.numKeys;
  410. }
  411. if (!rpoo&&splineTime>3.0)
  412. {
  413. rpoo=1;
  414. initspline(0);
  415. initspline(1);
  416. initspline(spline.numKeys-2);
  417. initspline(spline.numKeys-1);
  418. }
  419. plSplineGetPoint(&spline,splineTime,curpos);
  420. {
  421. for (i = sizeof(object)/sizeof(object[0])-1; i > 0; i --)
  422. {
  423. object[i]->Xa=object[i-1]->Xa;
  424. object[i]->Ya=object[i-1]->Ya;
  425. object[i]->Za=object[i-1]->Za;
  426. }
  427. object[0]->Xa+=5*curpos[3];
  428. object[0]->Ya+=5*curpos[4];
  429. object[0]->Za-=5*(curpos[4]*curpos[3]);
  430. }
  431. cam->X = curpos[0];
  432. cam->Y = curpos[1];
  433. cam->Z = curpos[2];
  434. teamobject->Xp=(pl_Float)(100.0*sin((splineTime-0.1)*3.14159));
  435. teamobject->Yp=(pl_Float)(75+40.0*cos((splineTime-0.1)*3.14159));
  436. teamobject->Zp=(pl_Float)(100.0*cos((splineTime-0.1)*3.14159*1.5));
  437. teamobject->Ya+=1.1f;
  438. lightobject->Xp=(pl_Float)(100.0*sin(splineTime*3.14159));
  439. lightobject->Yp=(pl_Float)(75+40.0*cos(splineTime*3.14159));
  440. lightobject->Zp=(pl_Float)(100.0*cos(splineTime*3.14159*1.5));
  441. lightobject->Ya+=1.1f;
  442. plLightSet(light,PL_LIGHT_POINT,lightobject->Xp,lightobject->Yp,lightobject->Zp,0.7f-0.2f/2+light_sc/2,LAND_SIZE/2);//(warand()%LAND_SIZE)-LAND_SIZE/2,12,(warand()%LAND_SIZE)-LAND_SIZE/2,1.0,LAND_SIZE/4);
  443. plCamSetTarget(cam,lightobject->Xp/4,lightobject->Yp/4.0f+90*0.75f,lightobject->Zp/4);
  444. cam->ClipBack = 1500.0;
  445. #ifndef STATICBALLTEXTURE
  446. if (watex && watex->Data) { makeBallTexture(watex->Data); makeBallTexture(watex->Data);}
  447. #endif
  448. plRenderBegin(cam);
  449. plRenderLight(light);
  450. plRenderObj(land);
  451. plRenderEnd();
  452. plRenderBegin(cam);
  453. plRenderLight(light);
  454. billboard->Za+=1.0;
  455. billboard->Ya+=1.0;
  456. {
  457. light_sc=0.2f+2*0.3f;
  458. plRenderObj(lightobject);
  459. }
  460. if (sa_curmode && playing)
  461. {
  462. char sadata[75*2+8] = {0};
  463. unsigned char *data=(unsigned char *)sa_get(in_getouttime(),sa_curmode, sadata);
  464. if (data)
  465. {
  466. if (sa_curmode == 2) data+=75;
  467. for (i = 0; i < sizeof(object)/sizeof(object[0]); i ++)
  468. {
  469. int t=data[(7-i)*3];
  470. int t2=data[(7-i)*3+1];
  471. int t3=data[(7-i)*3+2];
  472. float val;
  473. if (t2 > t) t=t2;
  474. if (t3 > t) t=t3;
  475. if (sa_curmode==2) { t-=128; t/=4;}
  476. val=t*1.3f;
  477. if (object[i]->Children[0]->Yp < val) object[i]->Children[0]->Yp=val;
  478. else object[i]->Children[0]->Yp=object[i]->Children[0]->Yp*0.9f;
  479. if (i)
  480. {
  481. object[i]->Xa=object[0]->Xa;
  482. object[i]->Ya=object[0]->Ya;
  483. object[i]->Za=object[0]->Za;
  484. }
  485. }
  486. }
  487. }
  488. else
  489. {
  490. for (i = 0; i < sizeof(object)/sizeof(object[0]); i ++)
  491. {
  492. object[i]->Children[0]->Yp=object[i]->Children[0]->Yp*0.9f;
  493. }
  494. }
  495. for (i = 0; i < sizeof(object)/sizeof(object[0]); i ++) plRenderObj(object[i]);
  496. plRenderObj(billboard);
  497. plRenderObj(teamobject);
  498. plRenderEnd();
  499. if (displaycredits)
  500. {
  501. int alpha=0;
  502. int creditspos=((GetTickCount64()-m_creditspos)/30)%creditslist_l;
  503. int pos=creditspos&127;
  504. const wchar_t *str=creditslist[creditspos/128];
  505. static int g_ypos;
  506. static int g_xpos;
  507. if (creditspos/128 != m_lastpos)
  508. {
  509. m_lastpos=creditspos/128;
  510. if (creditspos<128)
  511. {
  512. m_creditspos_frames=0;
  513. start_time=GetTickCount64();
  514. }
  515. g_ypos=cam->ScreenHeight/4+(warand()%(cam->ScreenHeight/2-text_hW(str)/2));
  516. g_xpos=10+(warand()%(cam->ClipRight-text_w(str)-20));
  517. }
  518. else if (pos>=112) alpha=(127-pos);
  519. else if (pos >= 32) alpha=15;
  520. else if (pos >= 16) alpha=(pos-16);
  521. if (alpha&&str[0]) plTextPutStrW(cam,g_xpos,g_ypos,0, 1, str);
  522. }
  523. {
  524. int t=(GetTickCount64()-start_time)/1000;
  525. char nbuf[32] = {0};
  526. StringCchPrintfA(nbuf, 32, "%dfps",t?(m_creditspos_frames/t):0);
  527. plTextPutStr(cam,3,cam->ScreenHeight+1-text_hA(nbuf),0,1, nbuf);
  528. }
  529. m_creditspos_frames++;
  530. #define TEAM_IMG_W 32
  531. #define TEAM_IMG_H 32 //416
  532. if (teamtex && (!(m_creditspos_frames & 127)))
  533. {
  534. int g_regver=2;
  535. teamtex->Data += 32*32;
  536. if (g_regver < 1 && teamtex->Data-teamtexbase >= TEAM_IMG_W*(TEAM_IMG_H-32))
  537. teamtex->Data=teamtexbase;
  538. else if (teamtex->Data-teamtexbase >= TEAM_IMG_W*TEAM_IMG_H)
  539. teamtex->Data=teamtexbase;
  540. }
  541. }
  542. #define SPLASH_IMG_W 400
  543. #define SPLASH_IMG_H 189
  544. static pl_Texture *mkWALogoTex(int which)
  545. {
  546. //pl_Texture *p=(pl_Texture*)GlobalAlloc(GPTR,sizeof(pl_Texture));
  547. pl_Texture* p = (pl_Texture*)malloc(sizeof(pl_Texture));
  548. if (p)
  549. {
  550. //char *temp=(char *)GlobalAlloc(GPTR,SPLASH_IMG_W*SPLASH_IMG_H);
  551. char* temp = (char*)malloc(SPLASH_IMG_W * SPLASH_IMG_H);
  552. //p->Data=GlobalAlloc(GPTR,which ? TEAM_IMG_H*TEAM_IMG_W : 256*256);
  553. p->Data = malloc(which ? TEAM_IMG_H * TEAM_IMG_W : 256 * 256);
  554. //p->PaletteData=GlobalAlloc(GPTR,3*256);
  555. p->PaletteData = malloc(3 * 256);
  556. if (p->Data && p->PaletteData && temp)
  557. {
  558. HBITMAP m_imgbm, m_imgoldbm;
  559. HDC m_imgdc;
  560. struct
  561. {
  562. BITMAPINFO bmi;
  563. RGBQUAD more_bmiColors[256];
  564. LPVOID data;
  565. } m_bitmap;
  566. int c;
  567. char *out=p->Data;
  568. memset(&m_bitmap, 0, sizeof(m_bitmap));
  569. m_imgdc = CreateCompatibleDC(NULL);
  570. // TODO (load from PNG)
  571. m_imgbm = LoadImage(hMainInstance,MAKEINTRESOURCE(which ? IDB_TEAM : IDB_SPLASH), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
  572. //m_imgbm = WALoadImage(hMainInstance, L"PNG", MAKEINTRESOURCEW(which ? IDR_TEAM : IDR_SPLASH), FALSE);
  573. m_imgoldbm=SelectObject(m_imgdc,m_imgbm);
  574. m_bitmap.bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  575. m_bitmap.bmi.bmiHeader.biPlanes = 1;
  576. m_bitmap.bmi.bmiHeader.biBitCount = 8;
  577. m_bitmap.bmi.bmiHeader.biCompression = BI_RGB;
  578. m_bitmap.bmi.bmiHeader.biSizeImage = 0;
  579. m_bitmap.bmi.bmiHeader.biClrUsed = 256;
  580. m_bitmap.bmi.bmiHeader.biClrImportant = 256;
  581. m_bitmap.bmi.bmiHeader.biWidth = which ? TEAM_IMG_W : SPLASH_IMG_W;
  582. m_bitmap.bmi.bmiHeader.biHeight = which ? -TEAM_IMG_H : -SPLASH_IMG_H;
  583. m_bitmap.bmi.bmiHeader.biSizeImage = which ? TEAM_IMG_H * TEAM_IMG_W : SPLASH_IMG_W*SPLASH_IMG_H;
  584. GetDIBits(m_imgdc,m_imgbm,0,which ? TEAM_IMG_H : SPLASH_IMG_H,temp,(BITMAPINFO *)&m_bitmap,DIB_RGB_COLORS);
  585. GetDIBColorTable(m_imgdc,0,which ? 64 : 256,m_bitmap.bmi.bmiColors);
  586. SelectObject(m_imgdc, m_imgoldbm);
  587. DeleteDC(m_imgdc);
  588. DeleteObject(m_imgbm);
  589. for (c = 0; c < (which ? 64 : 256); c ++)
  590. {
  591. p->PaletteData[c*3] = m_bitmap.bmi.bmiColors[c].rgbRed;
  592. p->PaletteData[c*3+1] = m_bitmap.bmi.bmiColors[c].rgbGreen;
  593. p->PaletteData[c*3+2] = m_bitmap.bmi.bmiColors[c].rgbBlue;
  594. }
  595. if (which)
  596. {
  597. memcpy(out,temp,TEAM_IMG_W*TEAM_IMG_H);
  598. p->Width=5;
  599. p->Height=5;
  600. p->iWidth=32;
  601. p->iHeight=32;
  602. p->uScale=-32;
  603. p->vScale=32;
  604. p->NumColors=64;
  605. }
  606. else
  607. {
  608. int dxp=(SPLASH_IMG_W<<16)/256;
  609. int dyp=(SPLASH_IMG_H<<16)/256;
  610. int y, yp = 0;
  611. for (y = 0; y < 256; y ++)
  612. {
  613. char *in=temp+(yp>>16)*SPLASH_IMG_W;
  614. int x, xp = 0;
  615. for (x = 0; x < 256; x ++)
  616. {
  617. *out++=in[xp>>16];
  618. xp+=dxp;
  619. }
  620. yp+=dyp;
  621. }
  622. p->Width=8;
  623. p->Height=8;
  624. p->iWidth=256;
  625. p->iHeight=256;
  626. p->uScale=-256;
  627. p->vScale=256;
  628. p->NumColors=256;
  629. }
  630. //GlobalFree(temp);
  631. free(temp);
  632. }
  633. //else { if (p->Data) GlobalFree(p->Data); if (p->PaletteData) GlobalFree(p->PaletteData); GlobalFree(p); p=NULL; if (temp) GlobalFree(temp); }
  634. else { if (p->Data) free(p->Data); if (p->PaletteData) free(p->PaletteData); free(p); p = NULL; if (temp) free(temp); }
  635. }
  636. return p;
  637. }
  638. static pl_Texture *mkWATex()
  639. {
  640. //pl_Texture *p=(pl_Texture*)GlobalAlloc(GPTR,sizeof(pl_Texture));
  641. pl_Texture* p = (pl_Texture*)malloc(sizeof(pl_Texture));
  642. if (p)
  643. {
  644. //p->Data=GlobalAlloc(GPTR,64*65+2);
  645. p->Data = malloc(64 * 65 + 2);
  646. //p->PaletteData=GlobalAlloc(GPTR,3*256);
  647. p->PaletteData = malloc(3 * 256);
  648. if (p->Data && p->PaletteData)
  649. {
  650. makeBallTextPal(p->PaletteData);
  651. p->Width=6;
  652. p->Height=6;
  653. p->iWidth=64;
  654. p->iHeight=64;
  655. p->uScale=128;
  656. p->vScale=64;
  657. p->NumColors=150;
  658. }
  659. //else { if (p->Data) GlobalFree(p->Data); if (p->PaletteData) GlobalFree(p->PaletteData); GlobalFree(p); p=NULL; }
  660. else { if (p->Data) free(p->Data); if (p->PaletteData) free(p->PaletteData); free(p); p = NULL; }
  661. }
  662. return p;
  663. }
  664. static pl_Texture *mkGroundTex()
  665. {
  666. //pl_Texture *p=(pl_Texture*)GlobalAlloc(GPTR,sizeof(pl_Texture));
  667. pl_Texture* p = (pl_Texture*)malloc(sizeof(pl_Texture));
  668. if (p)
  669. {
  670. //p->Data=GlobalAlloc(GPTR,16*16);
  671. p->Data = malloc(16 * 16);
  672. //p->PaletteData=GlobalAlloc(GPTR,3*16);
  673. p->PaletteData = malloc(3 * 16);
  674. if (p->Data && p->PaletteData)
  675. {
  676. int x,y;
  677. p->Width=4;
  678. p->Height=4;
  679. p->iWidth=16;
  680. p->iHeight=16;
  681. p->uScale=16*3;
  682. p->vScale=16*3;
  683. p->NumColors=16;
  684. for (y = 0; y < 16; y ++) for (x = 0; x < 16; x ++) p->Data[y*16+x]=x^y;
  685. for (x = 0; x < 16; x ++)
  686. {
  687. p->PaletteData[x*3+0]=43+((93-43)*x)/16;
  688. p->PaletteData[x*3+1]=25+((52-25)*x)/16;
  689. p->PaletteData[x*3+2]=9+((23-9)*x)/16;
  690. }
  691. }
  692. //else { if (p->Data) GlobalFree(p->Data); if (p->PaletteData) GlobalFree(p->PaletteData); GlobalFree(p); p=NULL; }
  693. else { if (p->Data) free(p->Data); if (p->PaletteData) free(p->PaletteData); free(p); p = NULL; }
  694. }
  695. return p;
  696. }
  697. static void setup_materials(pl_Mat **mat, unsigned char *pal)
  698. {
  699. int fuckomode=!(GetAsyncKeyState(VK_CONTROL) & GetAsyncKeyState(VK_SHIFT) & 0x8000 );
  700. mat[0] = plMatCreate();
  701. mat[1] = plMatCreate();
  702. mat[2] = plMatCreate();
  703. mat[3] = plMatCreate();
  704. mat[4] = plMatCreate();
  705. mat[5] = plMatCreate();
  706. mat[6]=0;
  707. watex = mkWATex();
  708. grndtex=mkGroundTex();
  709. mat[0]->ShadeType = PL_SHADE_GOURAUD;
  710. mat[0]->Shininess = 16;
  711. mat[0]->NumGradients = 1500;
  712. mat[0]->Ambient[0] = -128;
  713. mat[0]->Ambient[1] = -128;
  714. mat[0]->Ambient[2] = -128;
  715. mat[0]->Diffuse[0] = 170;
  716. mat[0]->Diffuse[1] = 140;
  717. mat[0]->Diffuse[2] = 140;
  718. mat[0]->Specular[0] = 140;
  719. mat[0]->Specular[1] = 90;
  720. mat[0]->Specular[2] = 0;
  721. mat[0]->FadeDist = 5000.0;
  722. mat[0]->Texture = fuckomode ? watex : grndtex;
  723. mat[0]->TexScaling = 8.0;
  724. mat[0]->PerspectiveCorrect = 16;
  725. mat[1]->ShadeType = PL_SHADE_GOURAUD;
  726. mat[1]->Shininess = 8;
  727. mat[1]->NumGradients = 150;
  728. mat[1]->Ambient[0] = 0;
  729. mat[1]->Ambient[1] = 0;
  730. mat[1]->Ambient[2] = 0;
  731. mat[1]->Diffuse[0] = 0;
  732. mat[1]->Diffuse[1] = 0;
  733. mat[1]->Diffuse[2] = 0;
  734. mat[1]->Specular[0] = 450;
  735. mat[1]->Specular[1] = 264;
  736. mat[1]->Specular[2] = 150;
  737. mat[2]->ShadeType = PL_SHADE_GOURAUD;
  738. mat[2]->Shininess = 8;
  739. mat[2]->NumGradients = 150;
  740. mat[2]->Ambient[0] = 32;
  741. mat[2]->Ambient[1] = 32;
  742. mat[2]->Ambient[2] = 64;
  743. mat[2]->Diffuse[0] = 120;
  744. mat[2]->Diffuse[1] = 60;
  745. mat[2]->Diffuse[2] = 60;
  746. mat[2]->Specular[0] = 200;
  747. mat[2]->Specular[1] = 80;
  748. mat[2]->Specular[2] = 80;
  749. mat[3]->ShadeType = PL_SHADE_GOURAUD;
  750. mat[3]->Shininess = 1;
  751. mat[3]->NumGradients = 1;
  752. mat[3]->Ambient[0] = 0;
  753. mat[3]->Ambient[1] = 0;
  754. mat[3]->Ambient[2] = 0;
  755. mat[3]->Diffuse[0] = 0;
  756. mat[3]->Diffuse[1] = 0;
  757. mat[3]->Diffuse[2] = 0;
  758. mat[3]->Specular[0] = 0;
  759. mat[3]->Specular[1] = 0;
  760. mat[3]->Specular[2] = 0;
  761. mat[3]->Texture = fuckomode ? grndtex : watex;
  762. mat[3]->TexScaling = 1.4f;
  763. mat[3]->PerspectiveCorrect = 16;
  764. mat[4]->ShadeType = PL_SHADE_GOURAUD;
  765. mat[4]->Shininess = 1;
  766. mat[4]->NumGradients = 1;
  767. mat[4]->Ambient[0] = 0;
  768. mat[4]->Ambient[1] = 0;
  769. mat[4]->Ambient[2] = 0;
  770. mat[4]->Diffuse[0] = 0;
  771. mat[4]->Diffuse[1] = 0;
  772. mat[4]->Diffuse[2] = 0;
  773. mat[4]->Specular[0] = 0;
  774. mat[4]->Specular[1] = 0;
  775. mat[4]->Specular[2] = 0;
  776. mat[4]->Texture = walogotex = mkWALogoTex(0);
  777. mat[4]->TexScaling = 1.0;
  778. mat[4]->PerspectiveCorrect = 16;
  779. mat[5]->ShadeType = PL_SHADE_GOURAUD;
  780. mat[5]->Shininess = 1;
  781. mat[5]->NumGradients = 1;
  782. mat[5]->Ambient[0] = 0;
  783. mat[5]->Ambient[1] = 0;
  784. mat[5]->Ambient[2] = 0;
  785. mat[5]->Diffuse[0] = 0;
  786. mat[5]->Diffuse[1] = 0;
  787. mat[5]->Diffuse[2] = 0;
  788. mat[5]->Specular[0] = 0;
  789. mat[5]->Specular[1] = 0;
  790. mat[5]->Specular[2] = 0;
  791. mat[5]->Texture = teamtex = mkWALogoTex(1);
  792. mat[5]->TexScaling = 1.0;
  793. mat[5]->PerspectiveCorrect = 16;
  794. if (teamtex) teamtexbase=teamtex->Data;
  795. plMatInit(mat[0]);
  796. plMatInit(mat[1]);
  797. plMatInit(mat[2]);
  798. plMatInit(mat[3]);
  799. plMatInit(mat[4]);
  800. plMatInit(mat[5]);
  801. memset(pal,0,768);
  802. plMatMakeOptPal(pal,2,255,mat,1);
  803. pal[0] = pal[1] = pal[2] = 0;
  804. pal[3] = pal[4] = pal[5] = 255;
  805. plMatMapToPal(mat[0],pal,0,255);
  806. plMatMapToPal(mat[1],pal,0,255);
  807. plMatMapToPal(mat[2],pal,0,255);
  808. plMatMapToPal(mat[3],pal,0,255);
  809. plMatMapToPal(mat[4],pal,0,255);
  810. plMatMapToPal(mat[5],pal,0,255);
  811. }
  812. static void adjustmapping(pl_Obj *obj)
  813. {
  814. int nf=obj->NumFaces;
  815. int x;
  816. pl_Face *f=obj->Faces;
  817. for (x = 0; x < nf; x ++)
  818. {
  819. f->MappingV[0]=MulDiv(f->MappingV[0],(150<<16)/500,(1<<16));
  820. f->MappingV[1]=MulDiv(f->MappingV[1],(150<<16)/500,(1<<16));
  821. f->MappingV[2]=MulDiv(f->MappingV[2],(150<<16)/500,(1<<16));
  822. f++;
  823. }
  824. }
  825. static pl_Obj *setup_landscape(float size, int div, pl_Mat *m)
  826. {
  827. pl_Obj *o = plMakePlane(size,size,div,m);
  828. o->Children[0]= plMakePlane(size,size,div,m);
  829. o->Children[0]->Yp=150;
  830. o->Children[0]->Xa=-180;
  831. div/=3;
  832. o->Children[1]= plMakePlane(size,150,div,m);
  833. o->Children[1]->Yp=75;
  834. o->Children[1]->Zp=size/2;
  835. o->Children[1]->Xa=90;
  836. adjustmapping(o->Children[1]);
  837. o->Children[2]= plMakePlane(size,150,div,m);
  838. o->Children[2]->Yp=75;
  839. o->Children[2]->Zp=-size/2;
  840. o->Children[2]->Xa=-90;
  841. adjustmapping(o->Children[2]);
  842. o->Children[3]= plMakePlane(size,150,div,m);
  843. o->Children[3]->Yp=75;
  844. o->Children[3]->Xp=size/2;
  845. o->Children[3]->Za=-90;
  846. o->Children[3]->Ya=90;
  847. adjustmapping(o->Children[3]);
  848. o->Children[4]= plMakePlane(size,150,div,m);
  849. o->Children[4]->Yp=75;
  850. o->Children[4]->Xp=-size/2;
  851. o->Children[4]->Za=90;
  852. o->Children[4]->Ya=90;
  853. adjustmapping(o->Children[4]);
  854. o->Yp = 0;
  855. return (o);
  856. }