ui.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. //
  2. // Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
  3. // All rights reserved.
  4. //
  5. // This file is part of SDLPAL.
  6. //
  7. // SDLPAL is free software: you can redistribute it and/or modify
  8. // it under the terms of the GNU General Public License as published by
  9. // the Free Software Foundation, either version 3 of the License, or
  10. // (at your option) any later version.
  11. //
  12. // This program is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. // GNU General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU General Public License
  18. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. //
  20. #include "main.h"
  21. LPSPRITE gpSpriteUI = NULL;
  22. INT
  23. PAL_InitUI(
  24. VOID
  25. )
  26. /*++
  27. Purpose:
  28. Initialze the UI subsystem.
  29. Parameters:
  30. None.
  31. Return value:
  32. 0 = success, -1 = fail.
  33. --*/
  34. {
  35. int iSize;
  36. //
  37. // Load the UI sprite.
  38. //
  39. iSize = PAL_MKFGetChunkSize(CHUNKNUM_SPRITEUI, gpGlobals->f.fpDATA);
  40. if (iSize < 0)
  41. {
  42. return -1;
  43. }
  44. gpSpriteUI = (LPSPRITE)calloc(1, iSize);
  45. if (gpSpriteUI == NULL)
  46. {
  47. return -1;
  48. }
  49. PAL_MKFReadChunk(gpSpriteUI, iSize, CHUNKNUM_SPRITEUI, gpGlobals->f.fpDATA);
  50. return 0;
  51. }
  52. VOID
  53. PAL_FreeUI(
  54. VOID
  55. )
  56. /*++
  57. Purpose:
  58. Shutdown the UI subsystem.
  59. Parameters:
  60. None.
  61. Return value:
  62. None.
  63. --*/
  64. {
  65. if (gpSpriteUI != NULL)
  66. {
  67. free(gpSpriteUI);
  68. gpSpriteUI = NULL;
  69. }
  70. }
  71. LPBOX
  72. PAL_CreateBox(
  73. PAL_POS pos,
  74. INT nRows,
  75. INT nColumns,
  76. INT iStyle,
  77. BOOL fSaveScreen
  78. )
  79. /*++
  80. Purpose:
  81. Create a box on the screen.
  82. Parameters:
  83. [IN] pos - position of the box.
  84. [IN] nRows - number of rows of the box.
  85. [IN] nColumns - number of columns of the box.
  86. [IN] iStyle - style of the box (0 or 1).
  87. [IN] fSaveScreen - whether save the used screen area or not.
  88. Return value:
  89. Pointer to a BOX structure. NULL if failed.
  90. If fSaveScreen is false, then always returns NULL.
  91. --*/
  92. {
  93. int i, j, x, m, n;
  94. LPCBITMAPRLE rglpBorderBitmap[3][3];
  95. LPBOX lpBox = NULL;
  96. SDL_Surface *save;
  97. SDL_Rect rect;
  98. //
  99. // Get the bitmaps
  100. //
  101. for (i = 0; i < 3; i++)
  102. {
  103. for (j = 0; j < 3; j++)
  104. {
  105. rglpBorderBitmap[i][j] = PAL_SpriteGetFrame(gpSpriteUI, i * 3 + j + iStyle * 9);
  106. }
  107. }
  108. rect.x = PAL_X(pos);
  109. rect.y = PAL_Y(pos);
  110. rect.w = 0;
  111. rect.h = 0;
  112. //
  113. // Get the total width and total height of the box
  114. //
  115. for (i = 0; i < 3; i++)
  116. {
  117. if (i == 1)
  118. {
  119. rect.w += PAL_RLEGetWidth(rglpBorderBitmap[0][i]) * nColumns;
  120. rect.h += PAL_RLEGetHeight(rglpBorderBitmap[i][0]) * nRows;
  121. }
  122. else
  123. {
  124. rect.w += PAL_RLEGetWidth(rglpBorderBitmap[0][i]);
  125. rect.h += PAL_RLEGetHeight(rglpBorderBitmap[i][0]);
  126. }
  127. }
  128. if (fSaveScreen)
  129. {
  130. //
  131. // Save the used part of the screen
  132. //
  133. save = SDL_CreateRGBSurface(gpScreen->flags, rect.w, rect.h, 8,
  134. gpScreen->format->Rmask, gpScreen->format->Gmask,
  135. gpScreen->format->Bmask, gpScreen->format->Amask);
  136. if (save == NULL)
  137. {
  138. return NULL;
  139. }
  140. lpBox = (LPBOX)calloc(1, sizeof(BOX));
  141. if (lpBox == NULL)
  142. {
  143. SDL_FreeSurface(save);
  144. return NULL;
  145. }
  146. SDL_BlitSurface(gpScreen, &rect, save, NULL);
  147. lpBox->lpSavedArea = save;
  148. lpBox->pos = pos;
  149. lpBox->wWidth = rect.w;
  150. lpBox->wHeight = rect.h;
  151. }
  152. //
  153. // Border takes 2 additional rows and columns...
  154. //
  155. nRows += 2;
  156. nColumns += 2;
  157. //
  158. // Draw the box
  159. //
  160. for (i = 0; i < nRows; i++)
  161. {
  162. x = rect.x;
  163. m = (i == 0) ? 0 : ((i == nRows - 1) ? 2 : 1);
  164. for (j = 0; j < nColumns; j++)
  165. {
  166. n = (j == 0) ? 0 : ((j == nColumns - 1) ? 2 : 1);
  167. PAL_RLEBlitToSurface(rglpBorderBitmap[m][n], gpScreen, PAL_XY(x, rect.y));
  168. x += PAL_RLEGetWidth(rglpBorderBitmap[m][n]);
  169. }
  170. rect.y += PAL_RLEGetHeight(rglpBorderBitmap[m][0]);
  171. }
  172. return lpBox;
  173. }
  174. LPBOX
  175. PAL_CreateSingleLineBox(
  176. PAL_POS pos,
  177. INT nLen,
  178. BOOL fSaveScreen
  179. )
  180. /*++
  181. Purpose:
  182. Create a single-line box on the screen.
  183. Parameters:
  184. [IN] pos - position of the box.
  185. [IN] nLen - length of the box.
  186. [IN] fSaveScreen - whether save the used screen area or not.
  187. Return value:
  188. Pointer to a BOX structure. NULL if failed.
  189. If fSaveScreen is false, then always returns NULL.
  190. --*/
  191. {
  192. static const int iNumLeftSprite = 44;
  193. static const int iNumMidSprite = 45;
  194. static const int iNumRightSprite = 46;
  195. LPCBITMAPRLE lpBitmapLeft;
  196. LPCBITMAPRLE lpBitmapMid;
  197. LPCBITMAPRLE lpBitmapRight;
  198. SDL_Surface *save;
  199. SDL_Rect rect;
  200. LPBOX lpBox = NULL;
  201. int i;
  202. //
  203. // Get the bitmaps
  204. //
  205. lpBitmapLeft = PAL_SpriteGetFrame(gpSpriteUI, iNumLeftSprite);
  206. lpBitmapMid = PAL_SpriteGetFrame(gpSpriteUI, iNumMidSprite);
  207. lpBitmapRight = PAL_SpriteGetFrame(gpSpriteUI, iNumRightSprite);
  208. rect.x = PAL_X(pos);
  209. rect.y = PAL_Y(pos);
  210. //
  211. // Get the total width and total height of the box
  212. //
  213. rect.w = PAL_RLEGetWidth(lpBitmapLeft) + PAL_RLEGetWidth(lpBitmapRight);
  214. rect.w += PAL_RLEGetWidth(lpBitmapMid) * nLen;
  215. rect.h = PAL_RLEGetHeight(lpBitmapLeft);
  216. if (fSaveScreen)
  217. {
  218. //
  219. // Save the used part of the screen
  220. //
  221. save = SDL_CreateRGBSurface(gpScreen->flags, rect.w, rect.h, 8,
  222. gpScreen->format->Rmask, gpScreen->format->Gmask,
  223. gpScreen->format->Bmask, gpScreen->format->Amask);
  224. if (save == NULL)
  225. {
  226. return NULL;
  227. }
  228. lpBox = (LPBOX)calloc(1, sizeof(BOX));
  229. if (lpBox == NULL)
  230. {
  231. SDL_FreeSurface(gpScreen);
  232. return NULL;
  233. }
  234. SDL_BlitSurface(gpScreen, &rect, save, NULL);
  235. lpBox->pos = pos;
  236. lpBox->lpSavedArea = save;
  237. lpBox->wHeight = (WORD)rect.w;
  238. lpBox->wWidth = (WORD)rect.h;
  239. }
  240. //
  241. // Draw the box
  242. //
  243. PAL_RLEBlitToSurface(lpBitmapLeft, gpScreen, pos);
  244. rect.x += PAL_RLEGetWidth(lpBitmapLeft);
  245. for (i = 0; i < nLen; i++)
  246. {
  247. PAL_RLEBlitToSurface(lpBitmapMid, gpScreen, PAL_XY(rect.x, rect.y));
  248. rect.x += PAL_RLEGetWidth(lpBitmapMid);
  249. }
  250. PAL_RLEBlitToSurface(lpBitmapRight, gpScreen, PAL_XY(rect.x, rect.y));
  251. return lpBox;
  252. }
  253. VOID
  254. PAL_DeleteBox(
  255. LPBOX lpBox
  256. )
  257. /*++
  258. Purpose:
  259. Delete a box and restore the saved part of the screen.
  260. Parameters:
  261. [IN] lpBox - pointer to the BOX struct.
  262. Return value:
  263. None.
  264. --*/
  265. {
  266. SDL_Rect rect;
  267. //
  268. // Check for NULL pointer.
  269. //
  270. if (lpBox == NULL)
  271. {
  272. return;
  273. }
  274. //
  275. // Restore the saved screen part
  276. //
  277. rect.x = PAL_X(lpBox->pos);
  278. rect.y = PAL_Y(lpBox->pos);
  279. rect.w = lpBox->wWidth;
  280. rect.h = lpBox->wHeight;
  281. SDL_BlitSurface(lpBox->lpSavedArea, NULL, gpScreen, &rect);
  282. //
  283. // Free the memory used by the box
  284. //
  285. SDL_FreeSurface(lpBox->lpSavedArea);
  286. free(lpBox);
  287. }
  288. WORD
  289. PAL_ReadMenu(
  290. LPITEMCHANGED_CALLBACK lpfnMenuItemChanged,
  291. LPMENUITEM rgMenuItem,
  292. INT nMenuItem,
  293. WORD wDefaultItem,
  294. BYTE bLabelColor
  295. )
  296. /*++
  297. Purpose:
  298. Execute a menu.
  299. Parameters:
  300. [IN] lpfnMenuItemChanged - Callback function which is called when user
  301. changed the current menu item.
  302. [IN] rgMenuItem - Array of the menu items.
  303. [IN] nMenuItem - Number of menu items.
  304. [IN] wDefaultItem - default item index.
  305. [IN] bLabelColor - color of the labels.
  306. Return value:
  307. Return value of the selected menu item. MENUITEM_VALUE_CANCELLED if cancelled.
  308. --*/
  309. {
  310. int i;
  311. WORD wCurrentItem = (wDefaultItem < nMenuItem) ? wDefaultItem : 0;
  312. //
  313. // Draw all the menu texts.
  314. //
  315. for (i = 0; i < nMenuItem; i++)
  316. {
  317. BYTE bColor = bLabelColor;
  318. if (!rgMenuItem[i].fEnabled)
  319. {
  320. if (i == wCurrentItem)
  321. {
  322. bColor = MENUITEM_COLOR_SELECTED_INACTIVE;
  323. }
  324. else
  325. {
  326. bColor = MENUITEM_COLOR_INACTIVE;
  327. }
  328. }
  329. PAL_DrawText(PAL_GetWord(rgMenuItem[i].wNumWord), rgMenuItem[i].pos,
  330. bColor, TRUE, TRUE);
  331. }
  332. if (lpfnMenuItemChanged != NULL)
  333. {
  334. (*lpfnMenuItemChanged)(rgMenuItem[wDefaultItem].wValue);
  335. }
  336. while (TRUE)
  337. {
  338. PAL_ClearKeyState();
  339. //
  340. // Redraw the selected item if needed.
  341. //
  342. if (rgMenuItem[wCurrentItem].fEnabled)
  343. {
  344. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  345. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE);
  346. }
  347. PAL_ProcessEvent();
  348. if (g_InputState.dwKeyPress & (kKeyDown | kKeyRight))
  349. {
  350. //
  351. // User pressed the down or right arrow key
  352. //
  353. if (rgMenuItem[wCurrentItem].fEnabled)
  354. {
  355. //
  356. // Dehighlight the unselected item.
  357. //
  358. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  359. rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE);
  360. }
  361. else
  362. {
  363. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  364. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE);
  365. }
  366. wCurrentItem++;
  367. if (wCurrentItem >= nMenuItem)
  368. {
  369. wCurrentItem = 0;
  370. }
  371. //
  372. // Highlight the selected item.
  373. //
  374. if (rgMenuItem[wCurrentItem].fEnabled)
  375. {
  376. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  377. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE);
  378. }
  379. else
  380. {
  381. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  382. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED_INACTIVE, FALSE, TRUE);
  383. }
  384. if (lpfnMenuItemChanged != NULL)
  385. {
  386. (*lpfnMenuItemChanged)(rgMenuItem[wCurrentItem].wValue);
  387. }
  388. }
  389. else if (g_InputState.dwKeyPress & (kKeyUp | kKeyLeft))
  390. {
  391. //
  392. // User pressed the up or left arrow key
  393. //
  394. if (rgMenuItem[wCurrentItem].fEnabled)
  395. {
  396. //
  397. // Dehighlight the unselected item.
  398. //
  399. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  400. rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE);
  401. }
  402. else
  403. {
  404. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  405. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE);
  406. }
  407. if (wCurrentItem > 0)
  408. {
  409. wCurrentItem--;
  410. }
  411. else
  412. {
  413. wCurrentItem = nMenuItem - 1;
  414. }
  415. //
  416. // Highlight the selected item.
  417. //
  418. if (rgMenuItem[wCurrentItem].fEnabled)
  419. {
  420. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  421. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED, FALSE, TRUE);
  422. }
  423. else
  424. {
  425. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  426. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_SELECTED_INACTIVE, FALSE, TRUE);
  427. }
  428. if (lpfnMenuItemChanged != NULL)
  429. {
  430. (*lpfnMenuItemChanged)(rgMenuItem[wCurrentItem].wValue);
  431. }
  432. }
  433. else if (g_InputState.dwKeyPress & kKeyMenu)
  434. {
  435. //
  436. // User cancelled
  437. //
  438. if (rgMenuItem[wCurrentItem].fEnabled)
  439. {
  440. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  441. rgMenuItem[wCurrentItem].pos, bLabelColor, FALSE, TRUE);
  442. }
  443. else
  444. {
  445. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  446. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_INACTIVE, FALSE, TRUE);
  447. }
  448. break;
  449. }
  450. else if (g_InputState.dwKeyPress & kKeySearch)
  451. {
  452. //
  453. // User pressed Enter
  454. //
  455. if (rgMenuItem[wCurrentItem].fEnabled)
  456. {
  457. PAL_DrawText(PAL_GetWord(rgMenuItem[wCurrentItem].wNumWord),
  458. rgMenuItem[wCurrentItem].pos, MENUITEM_COLOR_CONFIRMED, FALSE, TRUE);
  459. return rgMenuItem[wCurrentItem].wValue;
  460. }
  461. }
  462. //
  463. // Use delay function to avoid high CPU usage.
  464. //
  465. SDL_Delay(50);
  466. }
  467. return MENUITEM_VALUE_CANCELLED;
  468. }
  469. VOID
  470. PAL_DrawNumber(
  471. UINT iNum,
  472. UINT nLength,
  473. PAL_POS pos,
  474. NUMCOLOR color,
  475. NUMALIGN align
  476. )
  477. /*++
  478. Purpose:
  479. Draw the specified number with the bitmaps in the UI sprite.
  480. Parameters:
  481. [IN] iNum - the number to be drawn.
  482. [IN] nLength - max. length of the number.
  483. [IN] pos - position on the screen.
  484. [IN] color - color of the number (yellow or blue).
  485. [IN] align - align mode of the number.
  486. Return value:
  487. None.
  488. --*/
  489. {
  490. UINT nActualLength, i;
  491. int x, y;
  492. LPCBITMAPRLE rglpBitmap[10];
  493. //
  494. // Get the bitmaps. Blue starts from 29, Cyan from 56, Yellow from 19.
  495. //
  496. x = (color == kNumColorBlue) ? 29 : ((color == kNumColorCyan) ? 56 : 19);
  497. for (i = 0; i < 10; i++)
  498. {
  499. rglpBitmap[i] = PAL_SpriteGetFrame(gpSpriteUI, (UINT)x + i);
  500. }
  501. i = iNum;
  502. nActualLength = 0;
  503. //
  504. // Calculate the actual length of the number.
  505. //
  506. while (i > 0)
  507. {
  508. i /= 10;
  509. nActualLength++;
  510. }
  511. if (nActualLength > nLength)
  512. {
  513. nActualLength = nLength;
  514. }
  515. else if (nActualLength == 0)
  516. {
  517. nActualLength = 1;
  518. }
  519. x = PAL_X(pos) - 6;
  520. y = PAL_Y(pos);
  521. switch (align)
  522. {
  523. case kNumAlignLeft:
  524. x += 6 * nActualLength;
  525. break;
  526. case kNumAlignMid:
  527. x += 3 * (nLength + nActualLength);
  528. break;
  529. case kNumAlignRight:
  530. x += 6 * nLength;
  531. break;
  532. }
  533. //
  534. // Draw the number.
  535. //
  536. while (nActualLength-- > 0)
  537. {
  538. PAL_RLEBlitToSurface(rglpBitmap[iNum % 10], gpScreen, PAL_XY(x, y));
  539. x -= 6;
  540. iNum /= 10;
  541. }
  542. }
  543. LPOBJECTDESC
  544. PAL_LoadObjectDesc(
  545. LPCSTR lpszFileName
  546. )
  547. /*++
  548. Purpose:
  549. Load the object description strings from file.
  550. Parameters:
  551. [IN] lpszFileName - the filename to be loaded.
  552. Return value:
  553. Pointer to loaded data, in linked list form. NULL if unable to load.
  554. --*/
  555. {
  556. FILE *fp;
  557. PAL_LARGE char buf[512];
  558. char *p;
  559. LPOBJECTDESC lpDesc = NULL, pNew = NULL;
  560. unsigned int i;
  561. fp = fopen(lpszFileName, "r");
  562. if (fp == NULL)
  563. {
  564. return NULL;
  565. }
  566. //
  567. // Load the description data
  568. //
  569. while (fgets(buf, 512, fp) != NULL)
  570. {
  571. p = strchr(buf, '=');
  572. if (p == NULL)
  573. {
  574. continue;
  575. }
  576. *p = '\0';
  577. p++;
  578. pNew = UTIL_calloc(1, sizeof(OBJECTDESC));
  579. sscanf(buf, "%x", &i);
  580. pNew->wObjectID = i;
  581. pNew->lpDesc = strdup(p);
  582. pNew->next = lpDesc;
  583. lpDesc = pNew;
  584. }
  585. fclose(fp);
  586. return lpDesc;
  587. }
  588. VOID
  589. PAL_FreeObjectDesc(
  590. LPOBJECTDESC lpObjectDesc
  591. )
  592. /*++
  593. Purpose:
  594. Free the object description data.
  595. Parameters:
  596. [IN] lpObjectDesc - the description data to be freed.
  597. Return value:
  598. None.
  599. --*/
  600. {
  601. LPOBJECTDESC p;
  602. while (lpObjectDesc != NULL)
  603. {
  604. p = lpObjectDesc->next;
  605. free(lpObjectDesc->lpDesc);
  606. free(lpObjectDesc);
  607. lpObjectDesc = p;
  608. }
  609. }
  610. LPCSTR
  611. PAL_GetObjectDesc(
  612. LPOBJECTDESC lpObjectDesc,
  613. WORD wObjectID
  614. )
  615. /*++
  616. Purpose:
  617. Get the object description string from the linked list.
  618. Parameters:
  619. [IN] lpObjectDesc - the description data linked list.
  620. [IN] wObjectID - the object ID.
  621. Return value:
  622. The description string. NULL if the specified object ID
  623. is not found.
  624. --*/
  625. {
  626. while (lpObjectDesc != NULL)
  627. {
  628. if (lpObjectDesc->wObjectID == wObjectID)
  629. {
  630. return lpObjectDesc->lpDesc;
  631. }
  632. lpObjectDesc = lpObjectDesc->next;
  633. }
  634. return NULL;
  635. }