Credits.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429
  1. #ifdef PRECOMPILEDHEADERS
  2. #include "JA2 All.h"
  3. #include "Credits.h"
  4. #include "Encrypted File.h"
  5. #else
  6. #include "Types.h"
  7. #include "Credits.h"
  8. #endif
  9. //externals
  10. extern HVSURFACE ghFrameBuffer;
  11. //local Defines
  12. enum
  13. {
  14. CRDT_RENDER_NONE,
  15. CRDT_RENDER_ALL,
  16. };
  17. //nnn
  18. typedef struct _CRDT_NODE
  19. {
  20. UINT32 uiType; //the type of node
  21. CHAR16 *pString; //string for the node if the node contains a string
  22. UINT32 uiFlags; //various flags
  23. INT16 sPosX; //position of the node on the screen if the node is displaying stuff
  24. INT16 sPosY;
  25. INT16 sOldPosX; //position of the node on the screen if the node is displaying stuff
  26. INT16 sOldPosY;
  27. INT16 sHeightOfString; //The height of the displayed string
  28. BOOLEAN fDelete; //Delete this loop
  29. UINT32 uiLastTime; // The last time the node was udated
  30. UINT32 uiVideoSurfaceImage;
  31. struct _CRDT_NODE *pPrev;
  32. struct _CRDT_NODE *pNext;
  33. } CRDT_NODE;
  34. //type of credits
  35. enum
  36. {
  37. CRDT_NODE_NONE,
  38. CRDT_NODE_DEFAULT, // scrolls up and off the screen
  39. };
  40. //flags for the credits
  41. //Flags:
  42. #define CRDT_FLAG__TITLE 0x00000001
  43. #define CRDT_FLAG__START_SECTION 0x00000002
  44. #define CRDT_FLAG__END_SECTION 0x00000004
  45. //#define CRDT_NAME_OF_CREDIT_FILE "BINARYDATA\\Credits.txt"
  46. #define CRDT_NAME_OF_CREDIT_FILE "BINARYDATA\\Credits.edt"
  47. #define CREDITS_LINESIZE 80 * 2
  48. //
  49. // Code tokens
  50. //
  51. //new codes:
  52. #define CRDT_START_CODE '@'
  53. #define CRDT_SEPARATION_CODE L","
  54. #define CRDT_END_CODE L";"
  55. #define CRDT_DELAY_BN_STRINGS_CODE 'D'
  56. #define CRDT_DELAY_BN_SECTIONS_CODE 'B'
  57. #define CRDT_SCROLL_SPEED 'S'
  58. #define CRDT_FONT_JUSTIFICATION 'J'
  59. #define CRDT_TITLE_FONT_COLOR 'C'
  60. #define CRDT_ACTIVE_FONT_COLOR 'R'
  61. //Flags:
  62. #define CRDT_TITLE 'T'
  63. #define CRDT_START_OF_SECTION '{'
  64. #define CRDT_END_OF_SECTION '}'
  65. #define CRDT_NAME_LOC_X 375
  66. #define CRDT_NAME_LOC_Y 420
  67. #define CRDT_NAME_TITLE_LOC_Y 435
  68. #define CRDT_NAME_FUNNY_LOC_Y 450
  69. #define CRDT_NAME_LOC_WIDTH 260
  70. #define CRDT_NAME_LOC_HEIGHT ( CRDT_NAME_FUNNY_LOC_Y - CRDT_NAME_LOC_Y + GetFontHeight( CRDT_NAME_FONT ) )
  71. #define CRDT_NAME_FONT FONT12ARIAL
  72. #define CRDT_LINE_NODE_DISAPPEARS_AT 0//20
  73. /*
  74. //new codes:
  75. enum
  76. {
  77. CRDT_ERROR,
  78. CRDT_CODE_DELAY_BN_STRINGS,
  79. CRDT_CODE_SCROLL_SPEED,
  80. CRDT_CODE_FONT_JUSIFICATION,
  81. CRDT_CODE_FONT_COLOR,
  82. CRDT_NUM_CODES,
  83. };
  84. */
  85. #define CRDT_WIDTH_OF_TEXT_AREA 210
  86. #define CRDT_TEXT_START_LOC 10
  87. #define CRDT_SCROLL_PIXEL_AMOUNT 1
  88. #define CRDT_NODE_DELAY_AMOUNT 25
  89. #define CRDT_DELAY_BN_NODES 750
  90. #define CRDT_DELAY_BN_SECTIONS 2500
  91. #define CRDT_SPACE_BN_SECTIONS 50
  92. #define CRDT_SPACE_BN_NODES 12
  93. #define CRDT_START_POS_Y 479
  94. #define CRDT_EYE_WIDTH 30
  95. #define CRDT_EYE_HEIGHT 12
  96. #define CRDT_EYES_CLOSED_TIME 150
  97. //ddd
  98. typedef struct
  99. {
  100. INT16 sX;
  101. INT16 sY;
  102. INT16 sWidth;
  103. INT16 sHeight;
  104. INT16 sEyeX;
  105. INT16 sEyeY;
  106. INT16 sMouthX;
  107. INT16 sMouthY;
  108. INT16 sBlinkFreq;
  109. UINT32 uiLastBlinkTime;
  110. UINT32 uiEyesClosedTime;
  111. } CDRT_FACE;
  112. CDRT_FACE gCreditFaces[] =
  113. {
  114. // x y w h
  115. 298, 137, 37, 49, 310, 157, 304, 170, 2500, 0, 0, //Camfield
  116. 348, 137, 43, 47, 354, 153, 354, 153, 3700, 0, 0, //Shawn
  117. 407, 132, 30, 50, 408, 151, 410, 164, 3000, 0, 0, //Kris
  118. 443, 131, 30, 50, 447, 151, 446, 161, 4000, 0, 0, //Ian
  119. 487, 136, 43, 50, 493, 155, 493, 155, 3500, 0, 0, //Linda
  120. 529, 145, 43, 50, 536, 164, 536, 164, 4000, 0, 0, //Eric
  121. 581, 132, 43, 48, 584, 150, 583, 161, 3500, 0, 0, //Lynn
  122. 278, 211, 36, 51, 283, 232, 283, 241, 3700, 0, 0, //Norm
  123. 319, 210, 34, 49, 323, 227, 320, 339, 4000, 0, 0, //George
  124. 358, 211, 38, 49, 364, 226, 361, 239, 3600, 0, 0, //Andrew Stacey
  125. 396, 200, 42, 50, 406, 220, 403, 230, 4600, 0, 0, //Scott
  126. 444, 202, 43, 51, 452, 220, 452, 231, 2800, 0, 0, //Emmons
  127. 493, 188, 36, 51, 501, 207, 499, 217, 4500, 0, 0, //Dave
  128. 531, 199, 47, 56, 541, 221, 540, 232, 4000, 0, 0, //Alex
  129. 585, 196, 39, 49, 593, 218, 593, 228, 3500, 0, 0, //Joey
  130. };
  131. /*
  132. enum
  133. {
  134. CRDT_CAMFIELD,
  135. CRDT_SHAWN,
  136. CRDT_KRIS,
  137. CRDT_IAN,
  138. CRDT_LINDA,
  139. CRDT_ERIC,
  140. CRDT_LYNN,
  141. CRDT_NORM,
  142. CRDT_GEORGE,
  143. CRDT_STACEY,
  144. CRDT_SCOTT,
  145. CRDT_EMMONS,
  146. CRDT_DAVE,
  147. CRDT_ALEX,
  148. CRDT_JOEY,
  149. NUM_PEOPLE_IN_CREDITS,
  150. };
  151. STR16 gzCreditNames[]=
  152. {
  153. L"Chris Camfield",
  154. L"Shaun Lyng",
  155. L"Kris Märnes",
  156. L"Ian Currie",
  157. L"Linda Currie",
  158. L"Eric \"WTF\" Cheng",
  159. L"Lynn Holowka",
  160. L"Norman \"NRG\" Olsen",
  161. L"George Brooks",
  162. L"Andrew Stacey",
  163. L"Scot Loving",
  164. L"Andrew \"Big Cheese\" Emmons",
  165. L"Dave \"The Feral\" French",
  166. L"Alex Meduna",
  167. L"Joey \"Joeker\" Whelan",
  168. };
  169. STR16 gzCreditNameTitle[]=
  170. {
  171. L"Game Internals Programmer", // Chris Camfield
  172. L"Co-designer/Writer", // Shaun Lyng
  173. L"Strategic Systems & Editor Programmer", //Kris \"The Cow Rape Man\" Marnes
  174. L"Producer/Co-designer", // Ian Currie
  175. L"Co-designer/Map Designer", // Linda Currie
  176. L"Artist", // Eric \"WTF\" Cheng
  177. L"Beta Coordinator, Support", // Lynn Holowka
  178. L"Artist Extraordinaire", // Norman \"NRG\" Olsen
  179. L"Sound Guru", // George Brooks
  180. L"Screen Designer/Artist", // Andrew Stacey
  181. L"Lead Artist/Animator", // Scot Loving
  182. L"Lead Programmer", // Andrew \"Big Cheese Doddle\" Emmons
  183. L"Programmer", // Dave French
  184. L"Strategic Systems & Game Balance Programmer", // Alex Meduna
  185. L"Portraits Artist", // Joey \"Joeker\" Whelan",
  186. };
  187. STR16 gzCreditNameFunny[]=
  188. {
  189. L"", // Chris Camfield
  190. L"(still learning punctuation)", // Shaun Lyng
  191. L"(\"It's done. I'm just fixing it\")", //Kris \"The Cow Rape Man\" Marnes
  192. L"(getting much too old for this)", // Ian Currie
  193. L"(and working on Wizardry 8)", // Linda Currie
  194. L"(forced at gunpoint to also do QA)", // Eric \"WTF\" Cheng
  195. L"(Left us for the CFSA - go figure...)", // Lynn Holowka
  196. L"", // Norman \"NRG\" Olsen
  197. L"", // George Brooks
  198. L"(Dead Head and jazz lover)", // Andrew Stacey
  199. L"(his real name is Robert)", // Scot Loving
  200. L"(the only responsible person)", // Andrew \"Big Cheese Doddle\" Emmons
  201. L"(can now get back to motocrossing)", // Dave French
  202. L"(stolen from Wizardry 8)", // Alex Meduna
  203. L"(did items and loading screens too!)", // Joey \"Joeker\" Whelan",
  204. };
  205. */
  206. //Global Variables
  207. MOUSE_REGION gCrdtMouseRegions[ NUM_PEOPLE_IN_CREDITS ];
  208. void SelectCreditFaceRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason );
  209. void SelectCreditFaceMovementRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason );
  210. UINT32 guiCreditBackGroundImage;
  211. UINT32 guiCreditFaces;
  212. BOOLEAN gfCreditsScreenEntry = TRUE;
  213. BOOLEAN gfCreditsScreenExit = FALSE;
  214. UINT32 guiCreditsExitScreen;
  215. UINT8 gubCreditScreenRenderFlags = CRDT_RENDER_ALL;
  216. CRDT_NODE *gCrdtRootNode=NULL;
  217. CRDT_NODE *gCrdtLastAddedNode=NULL;
  218. BOOLEAN gfCrdtHaveRenderedFirstFrameToSaveBuffer; // need to render background image to save buffer once
  219. INT32 giCurrentlySelectedFace = -1;
  220. //
  221. //VAriables needed for processing of the nodes:
  222. //
  223. UINT32 guiCreditScreenActiveFont; // the font that is used
  224. UINT32 guiCreditScreenTitleFont; // the font that is used
  225. UINT8 gubCreditScreenActiveColor; // color of the font
  226. UINT8 gubCreditScreenTitleColor; // color of a Title node
  227. //UINT32 guiCreditScreenActiveDisplayFlags; //
  228. UINT32 guiCrdtNodeScrollSpeed = CRDT_NODE_DELAY_AMOUNT; //speed credits go up at
  229. //UINT32 guiCrdtTimeTillReadNextCredit = CRDT_DELAY_BN_SECTIONS; //the delay before reading the next credit ( normall = guiCrdtDelayBetweenCreditSection or guiCrdtDelayBetweenNodes )
  230. //UINT32 guiCrdtDelayBetweenCreditSection = CRDT_DELAY_BN_SECTIONS; //delay between major credits sections ( programming and art ) appearing on the screen
  231. //UINT32 guiCrdtDelayBetweenNodes = CRDT_DELAY_BN_NODES; //delay between credits appearing on the screen
  232. UINT32 guiCrdtLastTimeUpdatingNode=0; // the last time a node was read from the file
  233. UINT8 gubCrdtJustification = CENTER_JUSTIFIED; // the current justification
  234. UINT32 guiGapBetweenCreditSections = CRDT_SPACE_BN_SECTIONS;
  235. UINT32 guiGapBetweenCreditNodes = CRDT_SPACE_BN_NODES;
  236. UINT32 guiGapTillReadNextCredit = CRDT_SPACE_BN_NODES;
  237. UINT32 guiCurrentCreditRecord = 0;
  238. BOOLEAN gfPauseCreditScreen = FALSE;
  239. HWFILE ghFile;
  240. //ggg
  241. //Function Prototypes
  242. BOOLEAN EnterCreditsScreen();
  243. BOOLEAN ExitCreditScreen();
  244. void HandleCreditScreen();
  245. BOOLEAN RenderCreditScreen();
  246. void GetCreditScreenUserInput();
  247. void SetCreditsExitScreen( UINT32 uiScreenToGoTo );
  248. BOOLEAN ShutDownCreditList();
  249. BOOLEAN AddCreditNode( UINT32 uiType, UINT32 uiFlags, STR16 pString );
  250. BOOLEAN InitCreditNode( );
  251. BOOLEAN DisplayCreditNode( CRDT_NODE *pCurrent );
  252. void HandleCreditNodes();
  253. void HandleNode_Default( CRDT_NODE *pCurrent );
  254. void HandleCurrentCreditNode( CRDT_NODE *pCurrent );
  255. BOOLEAN DeleteNode( CRDT_NODE *pNodeToDelete );
  256. UINT32 GetAndHandleCreditCodeFromCodeString( STR16 pzCode );
  257. BOOLEAN GetNextCreditFromTextFile();
  258. UINT32 CountNumberOfCreditNodes();
  259. STR16 GetNextCreditCode( STR16 pString, UINT32 *pSizeOfCode );
  260. void HandleCreditFlags( UINT32 uiFlags );
  261. void HandleCreditEyeBlinking();
  262. void InitCreditEyeBlinking();
  263. //ppp
  264. // VSURFACE_DESC vs_desc;
  265. // HVSURFACE hVSurface;
  266. UINT32 CreditScreenInit( void )
  267. {
  268. gfCreditsScreenEntry = TRUE;
  269. return( 1 );
  270. }
  271. UINT32 CreditScreenHandle( void )
  272. {
  273. StartFrameBufferRender();
  274. if( gfCreditsScreenEntry )
  275. {
  276. if( !EnterCreditsScreen() )
  277. {
  278. gfCreditsScreenEntry = FALSE;
  279. gfCreditsScreenExit = TRUE;
  280. }
  281. else
  282. {
  283. gfCreditsScreenEntry = FALSE;
  284. gfCreditsScreenExit = FALSE;
  285. }
  286. gubCreditScreenRenderFlags = CRDT_RENDER_ALL;
  287. }
  288. GetCreditScreenUserInput();
  289. HandleCreditScreen();
  290. // render buttons marked dirty
  291. // MarkButtonsDirty( );
  292. // RenderButtons( );
  293. // render help
  294. // RenderFastHelp( );
  295. // RenderButtonsFastHelp( );
  296. ExecuteBaseDirtyRectQueue();
  297. EndFrameBufferRender();
  298. if( gfCreditsScreenExit )
  299. {
  300. ExitCreditScreen();
  301. gfCreditsScreenEntry = TRUE;
  302. gfCreditsScreenExit = FALSE;
  303. }
  304. return( guiCreditsExitScreen );
  305. }
  306. UINT32 CreditScreenShutdown( void )
  307. {
  308. return( 1 );
  309. }
  310. //eee
  311. BOOLEAN EnterCreditsScreen()
  312. {
  313. UINT32 uiCnt;
  314. VOBJECT_DESC VObjectDesc;
  315. /*
  316. VSURFACE_DESC vs_desc;
  317. vs_desc.fCreateFlags = VSURFACE_CREATE_FROMFILE | VSURFACE_SYSTEM_MEM_USAGE;
  318. strcpy(vs_desc.ImageFile, "INTERFACE\\Credits.sti");
  319. if( !AddVideoSurface( &vs_desc, &guiCreditBackGroundImage ) )
  320. {
  321. return( FALSE );
  322. }
  323. */
  324. VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
  325. FilenameForBPP("INTERFACE\\Credits.sti", VObjectDesc.ImageFile);
  326. CHECKF(AddVideoObject(&VObjectDesc, &guiCreditBackGroundImage ));
  327. VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
  328. FilenameForBPP("INTERFACE\\Credit Faces.sti", VObjectDesc.ImageFile);
  329. CHECKF(AddVideoObject(&VObjectDesc, &guiCreditFaces ));
  330. //Initialize the root credit node
  331. InitCreditNode( );
  332. guiCreditsExitScreen = CREDIT_SCREEN;
  333. gfCrdtHaveRenderedFirstFrameToSaveBuffer = FALSE;
  334. guiCreditScreenActiveFont = FONT12ARIAL;
  335. gubCreditScreenActiveColor = FONT_MCOLOR_DKWHITE;
  336. guiCreditScreenTitleFont = FONT14ARIAL;
  337. gubCreditScreenTitleColor = FONT_MCOLOR_RED;
  338. // guiCreditScreenActiveDisplayFlags = LEFT_JUSTIFIED;
  339. guiCrdtNodeScrollSpeed = CRDT_NODE_DELAY_AMOUNT;
  340. gubCrdtJustification = CENTER_JUSTIFIED;
  341. guiCurrentCreditRecord = 0;
  342. // guiCrdtTimeTillReadNextCredit = CRDT_DELAY_BN_SECTIONS;
  343. // guiCrdtDelayBetweenCreditSection = CRDT_DELAY_BN_SECTIONS;
  344. // guiCrdtDelayBetweenNodes = CRDT_DELAY_BN_NODES;
  345. guiCrdtLastTimeUpdatingNode = GetJA2Clock();
  346. guiGapBetweenCreditSections = CRDT_SPACE_BN_SECTIONS;
  347. guiGapBetweenCreditNodes = CRDT_SPACE_BN_NODES;
  348. guiGapTillReadNextCredit = CRDT_SPACE_BN_NODES;
  349. for( uiCnt=0; uiCnt < NUM_PEOPLE_IN_CREDITS; uiCnt++)
  350. {
  351. // Make a mouse region
  352. MSYS_DefineRegion( &gCrdtMouseRegions[uiCnt], gCreditFaces[uiCnt].sX, gCreditFaces[uiCnt].sY, (INT16)(gCreditFaces[uiCnt].sX + gCreditFaces[uiCnt].sWidth), (INT16)(gCreditFaces[uiCnt].sY + gCreditFaces[uiCnt].sHeight), MSYS_PRIORITY_NORMAL,
  353. CURSOR_WWW, SelectCreditFaceMovementRegionCallBack, SelectCreditFaceRegionCallBack );
  354. // Add region
  355. MSYS_AddRegion( &gCrdtMouseRegions[uiCnt] );
  356. MSYS_SetRegionUserData( &gCrdtMouseRegions[uiCnt], 0, uiCnt );
  357. }
  358. //Test Node
  359. {
  360. // AddCreditNode( CRDT_NODE_DEFAULT, L"This is a test" );
  361. }
  362. /*
  363. //open the credit text file
  364. ghFile = FileOpen( CRDT_NAME_OF_CREDIT_FILE, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
  365. if( !ghFile )
  366. {
  367. return( FALSE );
  368. }
  369. */
  370. giCurrentlySelectedFace = -1;
  371. gfPauseCreditScreen = FALSE;
  372. InitCreditEyeBlinking();
  373. return( TRUE );
  374. }
  375. BOOLEAN ExitCreditScreen()
  376. {
  377. UINT32 uiCnt;
  378. //Blit the background image
  379. // DeleteVideoSurfaceFromIndex( guiCreditBackGroundImage );
  380. DeleteVideoObjectFromIndex( guiCreditBackGroundImage );
  381. DeleteVideoObjectFromIndex( guiCreditFaces );
  382. //ShutDown Credit link list
  383. ShutDownCreditList();
  384. for( uiCnt=0; uiCnt < NUM_PEOPLE_IN_CREDITS; uiCnt++)
  385. {
  386. MSYS_RemoveRegion( &gCrdtMouseRegions[uiCnt] );
  387. }
  388. /*
  389. //close the text file
  390. FileClose( ghFile );
  391. ghFile = 0;
  392. */
  393. return( TRUE );
  394. }
  395. //hhh
  396. void HandleCreditScreen()
  397. {
  398. // UINT32 uiTime = GetJA2Clock();
  399. if( gubCreditScreenRenderFlags == CRDT_RENDER_ALL )
  400. {
  401. RenderCreditScreen();
  402. gubCreditScreenRenderFlags = CRDT_RENDER_NONE;
  403. }
  404. //Handle the Credit linked list
  405. HandleCreditNodes();
  406. //Handle the blinkng eyes
  407. HandleCreditEyeBlinking();
  408. //is it time to get a new node
  409. if( gCrdtLastAddedNode == NULL || ( CRDT_START_POS_Y - ( gCrdtLastAddedNode->sPosY + gCrdtLastAddedNode->sHeightOfString - 16 ) ) >= (INT16)guiGapTillReadNextCredit )
  410. {
  411. //if there are no more credits in the file
  412. if( !GetNextCreditFromTextFile() && gCrdtLastAddedNode == NULL )
  413. {
  414. SetCreditsExitScreen( MAINMENU_SCREEN );
  415. }
  416. }
  417. RestoreExternBackgroundRect( CRDT_NAME_LOC_X, CRDT_NAME_LOC_Y, CRDT_NAME_LOC_WIDTH, (INT16)CRDT_NAME_LOC_HEIGHT );
  418. if( giCurrentlySelectedFace != -1 )
  419. {
  420. DrawTextToScreen( gzCreditNames[giCurrentlySelectedFace], CRDT_NAME_LOC_X, CRDT_NAME_LOC_Y, CRDT_NAME_LOC_WIDTH, CRDT_NAME_FONT, FONT_MCOLOR_WHITE, 0, FALSE, INVALIDATE_TEXT | CENTER_JUSTIFIED );
  421. DrawTextToScreen( gzCreditNameTitle[giCurrentlySelectedFace], CRDT_NAME_LOC_X, CRDT_NAME_TITLE_LOC_Y, CRDT_NAME_LOC_WIDTH, CRDT_NAME_FONT, FONT_MCOLOR_WHITE, 0, FALSE, INVALIDATE_TEXT | CENTER_JUSTIFIED );
  422. DrawTextToScreen( gzCreditNameFunny[giCurrentlySelectedFace], CRDT_NAME_LOC_X, CRDT_NAME_FUNNY_LOC_Y, CRDT_NAME_LOC_WIDTH, CRDT_NAME_FONT, FONT_MCOLOR_WHITE, 0, FALSE, INVALIDATE_TEXT | CENTER_JUSTIFIED );
  423. }
  424. }
  425. //rrr
  426. BOOLEAN RenderCreditScreen()
  427. {
  428. HVOBJECT hPixHandle;
  429. GetVideoObject(&hPixHandle, guiCreditBackGroundImage );
  430. BltVideoObject( FRAME_BUFFER, hPixHandle, 0, 0, 0, VO_BLT_SRCTRANSPARENCY, NULL);
  431. /*
  432. HVSURFACE hVSurface;
  433. GetVideoSurface( &hVSurface, guiCreditBackGroundImage );
  434. BltVideoSurfaceToVideoSurface( ghFrameBuffer, hVSurface, 0, 0, 0, 0, NULL );
  435. */
  436. if( !gfCrdtHaveRenderedFirstFrameToSaveBuffer )
  437. {
  438. gfCrdtHaveRenderedFirstFrameToSaveBuffer = TRUE;
  439. //blit everything to the save buffer ( cause the save buffer can bleed through )
  440. BlitBufferToBuffer(guiRENDERBUFFER, guiSAVEBUFFER, 0, 0, 640, 480 );
  441. UnmarkButtonsDirty( );
  442. }
  443. InvalidateScreen( );
  444. return( TRUE );
  445. }
  446. void GetCreditScreenUserInput()
  447. {
  448. InputAtom Event;
  449. while( DequeueEvent( &Event ) )
  450. {
  451. if( Event.usEvent == KEY_DOWN )
  452. {
  453. switch( Event.usParam )
  454. {
  455. case ESC:
  456. //Exit out of the screen
  457. SetCreditsExitScreen( MAINMENU_SCREEN );
  458. break;
  459. #ifdef JA2TESTVERSION
  460. case 'r':
  461. gubCreditScreenRenderFlags = CRDT_RENDER_ALL;
  462. break;
  463. case 'i':
  464. InvalidateRegion( 0, 0, 640, 480 );
  465. break;
  466. case UPARROW:
  467. guiCrdtNodeScrollSpeed+=5;
  468. break;
  469. case DNARROW:
  470. if( guiCrdtNodeScrollSpeed > 5 )
  471. guiCrdtNodeScrollSpeed-=5;
  472. break;
  473. case PAUSE:
  474. case SPACE:
  475. if( gfPauseCreditScreen )
  476. gfPauseCreditScreen = FALSE;
  477. else
  478. gfPauseCreditScreen = TRUE;
  479. break;
  480. #endif
  481. }
  482. }
  483. }
  484. }
  485. void SetCreditsExitScreen( UINT32 uiScreenToGoTo )
  486. {
  487. gfCreditsScreenExit = TRUE;
  488. guiCreditsExitScreen = uiScreenToGoTo;
  489. }
  490. BOOLEAN InitCreditNode( )
  491. {
  492. if( gCrdtRootNode != NULL )
  493. Assert( 0 );
  494. gCrdtRootNode = NULL;
  495. return( TRUE );
  496. }
  497. BOOLEAN ShutDownCreditList()
  498. {
  499. CRDT_NODE *pNodeToDelete=NULL;
  500. CRDT_NODE *pTemp=NULL;
  501. pNodeToDelete = gCrdtRootNode;
  502. while( pNodeToDelete!= NULL )
  503. {
  504. pTemp = pNodeToDelete;
  505. pNodeToDelete = pNodeToDelete->pNext;
  506. //Delete the current node
  507. DeleteNode( pTemp );
  508. }
  509. return( TRUE );
  510. }
  511. BOOLEAN DeleteNode( CRDT_NODE *pNodeToDelete )
  512. {
  513. CRDT_NODE *pTempNode;
  514. pTempNode = pNodeToDelete;
  515. if( gCrdtLastAddedNode == pNodeToDelete )
  516. {
  517. gCrdtLastAddedNode = NULL;
  518. }
  519. //if its Not the first node
  520. if( pNodeToDelete->pPrev != NULL )
  521. pNodeToDelete->pPrev = pNodeToDelete->pNext;
  522. else
  523. {
  524. if( gCrdtRootNode->pNext != NULL )
  525. {
  526. gCrdtRootNode = gCrdtRootNode->pNext;
  527. gCrdtRootNode->pPrev = NULL;
  528. }
  529. }
  530. //if its the last node in the list
  531. if( pNodeToDelete->pNext == NULL && pNodeToDelete->pPrev != NULL )
  532. pNodeToDelete->pPrev->pNext = NULL;
  533. //iof the node that is being deleted is the first node
  534. if( pTempNode == gCrdtRootNode )
  535. gCrdtRootNode = NULL;
  536. //Free the string
  537. if( pTempNode->pString != NULL )
  538. {
  539. MemFree( pTempNode->pString );
  540. pTempNode->pString = NULL;
  541. }
  542. //if the node had something to display, delete a surface for it
  543. if( pTempNode->uiType == CRDT_NODE_DEFAULT )
  544. {
  545. DeleteVideoSurfaceFromIndex( pTempNode->uiVideoSurfaceImage );
  546. pTempNode->uiVideoSurfaceImage = 0;
  547. }
  548. //Free the node
  549. MemFree( pTempNode );
  550. pTempNode = NULL;
  551. return( TRUE );
  552. }
  553. //aaa
  554. BOOLEAN AddCreditNode( UINT32 uiType, UINT32 uiFlags, STR16 pString )
  555. {
  556. CRDT_NODE *pNodeToAdd=NULL;
  557. CRDT_NODE *pTemp=NULL;
  558. UINT32 uiSizeOfString = ( wcslen( pString ) + 2 ) * 2;
  559. UINT32 uiFontToUse;
  560. UINT8 uiColorToUse;
  561. //if
  562. if( uiType == CRDT_NODE_NONE)
  563. {
  564. //Assert( 0 );
  565. return( TRUE );
  566. }
  567. pNodeToAdd = MemAlloc( sizeof( CRDT_NODE) );
  568. if( pNodeToAdd == NULL )
  569. {
  570. return( FALSE );
  571. }
  572. memset( pNodeToAdd, 0, sizeof( CRDT_NODE) );
  573. //Determine the font and the color to use
  574. if( uiFlags & CRDT_FLAG__TITLE )
  575. {
  576. uiFontToUse = guiCreditScreenTitleFont;
  577. uiColorToUse = gubCreditScreenTitleColor;
  578. }
  579. /*
  580. else if ( uiFlags & CRDT_FLAG__START_SECTION )
  581. {
  582. uiFontToUse = ;
  583. uiColorToUse = ;
  584. }
  585. else if ( uiFlags & CRDT_FLAG__END_SECTION )
  586. {
  587. uiFontToUse = ;
  588. uiColorToUse = ;
  589. }
  590. */
  591. else
  592. {
  593. uiFontToUse = guiCreditScreenActiveFont;
  594. uiColorToUse = gubCreditScreenActiveColor;
  595. }
  596. //
  597. // Set some default data
  598. //
  599. //the type of the node
  600. pNodeToAdd->uiType = uiType;
  601. //any flags that are added
  602. pNodeToAdd->uiFlags = uiFlags;
  603. //the starting left position for the it
  604. pNodeToAdd->sPosX = CRDT_TEXT_START_LOC;
  605. //Allocate memory for the string
  606. pNodeToAdd->pString = MemAlloc( uiSizeOfString );
  607. if( pNodeToAdd->pString == NULL )
  608. return( FALSE );
  609. //copy the string into the node
  610. wcscpy( pNodeToAdd->pString, pString );
  611. //Calculate the height of the string
  612. pNodeToAdd->sHeightOfString = DisplayWrappedString( 0, 0, CRDT_WIDTH_OF_TEXT_AREA, 2, uiFontToUse, uiColorToUse, pNodeToAdd->pString, 0, FALSE, DONT_DISPLAY_TEXT ) + 1;
  613. //starting y position on the screen
  614. pNodeToAdd->sPosY = CRDT_START_POS_Y;
  615. // pNodeToAdd->uiLastTime = GetJA2Clock();
  616. //if the node can have something to display, Create a surface for it
  617. if( pNodeToAdd->uiType == CRDT_NODE_DEFAULT )
  618. {
  619. VSURFACE_DESC vs_desc;
  620. // Create a background video surface to blt the face onto
  621. vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
  622. vs_desc.usWidth = CRDT_WIDTH_OF_TEXT_AREA;
  623. vs_desc.usHeight = pNodeToAdd->sHeightOfString;
  624. vs_desc.ubBitDepth = 16;
  625. if( AddVideoSurface( &vs_desc, &pNodeToAdd->uiVideoSurfaceImage) == 0 )
  626. {
  627. return( FALSE );
  628. }
  629. //Set transparency
  630. SetVideoSurfaceTransparency( pNodeToAdd->uiVideoSurfaceImage, 0 );
  631. //fill the surface with a transparent color
  632. ColorFillVideoSurfaceArea(pNodeToAdd->uiVideoSurfaceImage, 0, 0, CRDT_WIDTH_OF_TEXT_AREA, pNodeToAdd->sHeightOfString, 0 );
  633. //set the font dest buffer to be the surface
  634. SetFontDestBuffer( pNodeToAdd->uiVideoSurfaceImage, 0, 0, CRDT_WIDTH_OF_TEXT_AREA, pNodeToAdd->sHeightOfString, FALSE );
  635. //write the string onto the surface
  636. DisplayWrappedString( 0, 1, CRDT_WIDTH_OF_TEXT_AREA, 2, uiFontToUse, uiColorToUse, pNodeToAdd->pString, 0, FALSE, gubCrdtJustification );
  637. //reset the font dest buffer
  638. SetFontDestBuffer(FRAME_BUFFER, 0,0,640,480, FALSE);
  639. }
  640. //
  641. // Insert the node into the list
  642. //
  643. //if its the first node to add
  644. if( gCrdtRootNode == NULL )
  645. {
  646. //make the new node the root node
  647. gCrdtRootNode = pNodeToAdd;
  648. gCrdtRootNode->pNext = NULL;
  649. gCrdtRootNode->pPrev = NULL;
  650. }
  651. else
  652. {
  653. pTemp = gCrdtRootNode;
  654. while( pTemp->pNext != NULL )
  655. {
  656. pTemp = pTemp->pNext;
  657. }
  658. //Add the new node to the list
  659. pTemp->pNext = pNodeToAdd;
  660. //Assign the prev node
  661. pNodeToAdd->pPrev = pTemp;
  662. }
  663. gCrdtLastAddedNode = pNodeToAdd;
  664. return( TRUE );
  665. }
  666. void HandleCreditNodes()
  667. {
  668. UINT32 uiCurrentTime =GetJA2Clock();
  669. CRDT_NODE *pCurrent=NULL;
  670. CRDT_NODE *pTemp=NULL;
  671. if( gCrdtRootNode == NULL )
  672. return;
  673. //if the screen is paused, exit
  674. if( gfPauseCreditScreen )
  675. return;
  676. pCurrent = gCrdtRootNode;
  677. if( !( GetJA2Clock() - guiCrdtLastTimeUpdatingNode > guiCrdtNodeScrollSpeed ) )
  678. return;
  679. //loop through all the nodes
  680. while( pCurrent != NULL )
  681. {
  682. pTemp = pCurrent;
  683. pCurrent = pCurrent->pNext;
  684. //Handle the current node
  685. HandleCurrentCreditNode( pTemp );
  686. //if the node is to be deleted
  687. if( pTemp->fDelete )
  688. {
  689. //delete the node
  690. DeleteNode( pTemp );
  691. }
  692. }
  693. // RestoreExternBackgroundRect( CRDT_TEXT_START_LOC, 0, CRDT_WIDTH_OF_TEXT_AREA, CRDT_LINE_NODE_DISAPPEARS_AT );
  694. guiCrdtLastTimeUpdatingNode = GetJA2Clock();
  695. }
  696. void HandleCurrentCreditNode( CRDT_NODE *pCurrent )
  697. {
  698. //switch on the type of node
  699. switch( pCurrent->uiType )
  700. {
  701. //new codes:
  702. case CRDT_NODE_DEFAULT:
  703. HandleNode_Default( pCurrent );
  704. break;
  705. default:
  706. Assert( 0 );
  707. break;
  708. }
  709. }
  710. void HandleNode_Default( CRDT_NODE *pCurrent )
  711. {
  712. UINT32 uiCurrentTime =GetJA2Clock();
  713. //if it is time to update the current node
  714. // if( ( uiCurrentTime - pCurrent->uiLastTime ) > guiCrdtNodeScrollSpeed )
  715. {
  716. //Display the Current Node
  717. DisplayCreditNode( pCurrent );
  718. //Save the old position
  719. pCurrent->sOldPosX = pCurrent->sPosX;
  720. pCurrent->sOldPosY = pCurrent->sPosY;
  721. //Move the current node up
  722. pCurrent->sPosY -= CRDT_SCROLL_PIXEL_AMOUNT;
  723. //if the node is entirely off the screen
  724. if( ( pCurrent->sPosY + pCurrent->sHeightOfString ) < CRDT_LINE_NODE_DISAPPEARS_AT )
  725. {
  726. //mark the node to be deleted this frame
  727. pCurrent->fDelete = TRUE;
  728. }
  729. //Update the last time to be the current time
  730. // pCurrent->uiLastTime = uiCurrentTime + ( uiCurrentTime - ( pCurrent->uiLastTime + guiCrdtNodeScrollSpeed ) );
  731. // pCurrent->uiLastTime = ( uiCurrentTime - ( uiCurrentTime - pCurrent->uiLastTime - guiCrdtNodeScrollSpeed) );
  732. pCurrent->uiLastTime = GetJA2Clock();
  733. }
  734. }
  735. BOOLEAN DisplayCreditNode( CRDT_NODE *pCurrent )
  736. {
  737. HVSURFACE hVSurface;
  738. //Currently, we have no need to display a node that doesnt have a string
  739. if( pCurrent->pString == NULL )
  740. return( FALSE );
  741. //if the node is new and we havent displayed it yet
  742. if( pCurrent->uiLastTime == 0 )
  743. {
  744. }
  745. //else we have to restore were the string was
  746. else
  747. {
  748. //
  749. //Restore the background before blitting the text back on
  750. //
  751. //if the surface is at the bottom of the screen
  752. if( pCurrent->sOldPosY + pCurrent->sHeightOfString > CRDT_START_POS_Y )
  753. {
  754. INT16 sHeight = 480 - pCurrent->sOldPosY;
  755. RestoreExternBackgroundRect( pCurrent->sOldPosX, pCurrent->sOldPosY, CRDT_WIDTH_OF_TEXT_AREA, sHeight );
  756. }
  757. else if( pCurrent->sOldPosY > CRDT_LINE_NODE_DISAPPEARS_AT )
  758. {
  759. RestoreExternBackgroundRect( pCurrent->sOldPosX, pCurrent->sOldPosY, CRDT_WIDTH_OF_TEXT_AREA, pCurrent->sHeightOfString );
  760. }
  761. //if the surface is at the top of the screen
  762. else
  763. {
  764. INT16 sHeight = pCurrent->sOldPosY + pCurrent->sHeightOfString;
  765. RestoreExternBackgroundRect( pCurrent->sOldPosX, CRDT_LINE_NODE_DISAPPEARS_AT, CRDT_WIDTH_OF_TEXT_AREA, sHeight );
  766. }
  767. }
  768. GetVideoSurface( &hVSurface, pCurrent->uiVideoSurfaceImage );
  769. BltVideoSurfaceToVideoSurface( ghFrameBuffer, hVSurface, 0, pCurrent->sPosX, pCurrent->sPosY, VS_BLT_CLIPPED | VS_BLT_USECOLORKEY, NULL );
  770. return( TRUE );
  771. }
  772. //return false from this function when there are no more items in the text file
  773. BOOLEAN GetNextCreditFromTextFile()
  774. {
  775. BOOLEAN fDone = FALSE;
  776. UINT32 uiStringWidth = 20;
  777. CHAR16 zOriginalString[512];
  778. CHAR16 zString[512];
  779. CHAR16 zCodes[512];
  780. STR16 pzNewCode=NULL;
  781. UINT32 uiCodeType = 0;
  782. UINT32 uiNodeType = 0;
  783. UINT32 uiStartLoc = 0;
  784. UINT32 uiFlags=0;
  785. //Get the current Credit record
  786. uiStartLoc = CREDITS_LINESIZE * guiCurrentCreditRecord;
  787. if( !LoadEncryptedDataFromFile( CRDT_NAME_OF_CREDIT_FILE, zOriginalString, uiStartLoc, CREDITS_LINESIZE ) )
  788. {
  789. //there are no more credits
  790. return( FALSE );
  791. }
  792. //Increment to the next crdit record
  793. guiCurrentCreditRecord++;
  794. //if there are no codes in the string
  795. if( zOriginalString[0] != CRDT_START_CODE )
  796. {
  797. //copy the string
  798. wcscpy( zString, zOriginalString );
  799. uiNodeType = CRDT_NODE_DEFAULT;
  800. }
  801. else
  802. {
  803. UINT32 uiSizeOfCodes = 0;
  804. UINT32 uiSizeOfSubCode = 0;
  805. STR16 pzEndCode = NULL;
  806. UINT32 uiDistanceIntoCodes = 0;
  807. //Retrive all the codes from the string
  808. pzEndCode = wcsstr( zOriginalString, CRDT_END_CODE );
  809. //Make a string for the codes
  810. wcscpy( zCodes, zOriginalString );
  811. //end the setence after the codes
  812. zCodes[ pzEndCode - zOriginalString + 1 ] = '\0';
  813. //Get the size of the codes
  814. uiSizeOfCodes = pzEndCode - zOriginalString + 1;
  815. //
  816. //check to see if there is a string, or just codes
  817. //
  818. //if the string is the same size as the codes
  819. if( wcslen( zOriginalString ) == uiSizeOfCodes )
  820. {
  821. //there is no string, just codes
  822. uiNodeType = CRDT_NODE_NONE;
  823. }
  824. //else there is a string aswell
  825. else
  826. {
  827. //copy the main string
  828. wcscpy( zString, &zOriginalString[ uiSizeOfCodes ] );
  829. uiNodeType = CRDT_NODE_DEFAULT;
  830. }
  831. //get rid of the start code delimeter
  832. uiDistanceIntoCodes = 1;
  833. uiFlags = 0;
  834. //loop through the string of codes to get all the control codes out
  835. while( uiDistanceIntoCodes < uiSizeOfCodes )
  836. {
  837. //Determine what kind of code it is, and handle it
  838. uiFlags |= GetAndHandleCreditCodeFromCodeString( &zCodes[ uiDistanceIntoCodes ] );
  839. //get the next code from the string of codes, returns NULL when done
  840. pzNewCode = GetNextCreditCode( &zCodes[ uiDistanceIntoCodes ], &uiSizeOfSubCode );
  841. //if we are done getting the sub codes
  842. if( pzNewCode == NULL )
  843. {
  844. uiDistanceIntoCodes = uiSizeOfCodes;
  845. }
  846. else
  847. {
  848. //else increment by the size of the code
  849. uiDistanceIntoCodes += uiSizeOfSubCode;
  850. }
  851. }
  852. }
  853. if( uiNodeType != CRDT_NODE_NONE )
  854. {
  855. //add the node to the list
  856. AddCreditNode( uiNodeType, uiFlags, zString );
  857. }
  858. //if any processing of the flags need to be done
  859. HandleCreditFlags( uiFlags );
  860. return( TRUE );
  861. }
  862. //return any flags that need to be set in the node
  863. UINT32 GetAndHandleCreditCodeFromCodeString( STR16 pzCode )
  864. {
  865. //new codes:
  866. //if the code is to change the delay between strings
  867. if( pzCode[0] == CRDT_DELAY_BN_STRINGS_CODE )
  868. {
  869. UINT32 uiNewDelay=0;
  870. //Get the delay from the string
  871. swscanf( &pzCode[1], L"%d%*s", &uiNewDelay );
  872. // guiCrdtDelayBetweenNodes = uiNewDelay;
  873. guiGapBetweenCreditNodes = uiNewDelay;
  874. return( CRDT_NODE_NONE );
  875. }
  876. //if the code is to change the delay between sections strings
  877. else if( pzCode[0] == CRDT_DELAY_BN_SECTIONS_CODE )
  878. {
  879. UINT32 uiNewDelay=0;
  880. //Get the delay from the string
  881. swscanf( &pzCode[1], L"%d%*s", &uiNewDelay );
  882. // guiCrdtDelayBetweenCreditSection = uiNewDelay;
  883. guiGapBetweenCreditSections = uiNewDelay;
  884. return( CRDT_NODE_NONE );
  885. }
  886. else if( pzCode[0] == CRDT_SCROLL_SPEED )
  887. {
  888. UINT32 uiScrollSpeed=0;
  889. //Get the delay from the string
  890. swscanf( &pzCode[1], L"%d%*s", &uiScrollSpeed );
  891. guiCrdtNodeScrollSpeed = uiScrollSpeed;
  892. return( CRDT_NODE_NONE );
  893. }
  894. else if( pzCode[0] == CRDT_FONT_JUSTIFICATION )
  895. {
  896. UINT32 uiJustification=0;
  897. //Get the delay from the string
  898. swscanf( &pzCode[1], L"%d%*s", &uiJustification );
  899. //get the justification
  900. switch( uiJustification )
  901. {
  902. case 0:
  903. gubCrdtJustification = LEFT_JUSTIFIED;
  904. break;
  905. case 1:
  906. gubCrdtJustification = CENTER_JUSTIFIED;
  907. break;
  908. case 2:
  909. gubCrdtJustification = RIGHT_JUSTIFIED;
  910. break;
  911. default:
  912. Assert( 0 );
  913. }
  914. return( CRDT_NODE_NONE );
  915. }
  916. else if( pzCode[0] == CRDT_TITLE_FONT_COLOR )
  917. {
  918. //Get the new color for the title
  919. swscanf( &pzCode[1], L"%d%*s", &gubCreditScreenTitleColor );
  920. return( CRDT_NODE_NONE );
  921. }
  922. else if( pzCode[0] == CRDT_ACTIVE_FONT_COLOR )
  923. {
  924. //Get the new color for the active text
  925. swscanf( &pzCode[1], L"%d%*s", &gubCreditScreenActiveColor );
  926. return( CRDT_NODE_NONE );
  927. }
  928. //else its the title code
  929. else if( pzCode[0] == CRDT_TITLE )
  930. {
  931. return( CRDT_FLAG__TITLE );
  932. }
  933. //else its the title code
  934. else if( pzCode[0] == CRDT_START_OF_SECTION )
  935. {
  936. return( CRDT_FLAG__START_SECTION );
  937. }
  938. //else its the title code
  939. else if( pzCode[0] == CRDT_END_OF_SECTION )
  940. {
  941. return( CRDT_FLAG__END_SECTION );
  942. }
  943. //else its an error
  944. else
  945. {
  946. Assert( 0 );
  947. }
  948. return( CRDT_NODE_NONE );
  949. }
  950. UINT32 CountNumberOfCreditNodes()
  951. {
  952. UINT32 uiNumNodes = 0;
  953. CRDT_NODE *pTempNode = gCrdtRootNode;
  954. while( pTempNode )
  955. {
  956. uiNumNodes++;
  957. pTempNode = pTempNode->pNext;
  958. }
  959. return( uiNumNodes );
  960. }
  961. STR16 GetNextCreditCode( STR16 pString, UINT32 *pSizeOfCode )
  962. {
  963. STR16 pzNewCode=NULL;
  964. UINT32 uiSizeOfCode = 0;
  965. //get the new subcode out
  966. pzNewCode = wcsstr( pString, CRDT_SEPARATION_CODE );
  967. //if there is no separation code, then there must be an end code
  968. if( pzNewCode == NULL )
  969. {
  970. //pzNewCode = wcsstr( pString, CRDT_END_CODE );
  971. //we are done
  972. pzNewCode = NULL;
  973. }
  974. else
  975. {
  976. //get rid of separeation code
  977. pzNewCode++;
  978. //calc size of sub string
  979. uiSizeOfCode = pzNewCode - pString;
  980. }
  981. *pSizeOfCode = uiSizeOfCode;
  982. return( pzNewCode );
  983. }
  984. //Flags:
  985. void HandleCreditFlags( UINT32 uiFlags )
  986. {
  987. if( uiFlags & CRDT_FLAG__TITLE )
  988. {
  989. }
  990. if( uiFlags & CRDT_FLAG__START_SECTION )
  991. {
  992. // guiCrdtTimeTillReadNextCredit = guiCrdtDelayBetweenNodes;
  993. guiGapTillReadNextCredit = guiGapBetweenCreditNodes;
  994. }
  995. if( uiFlags & CRDT_FLAG__END_SECTION )
  996. {
  997. // guiCrdtTimeTillReadNextCredit = guiCrdtDelayBetweenCreditSection;
  998. guiGapTillReadNextCredit = guiGapBetweenCreditSections;
  999. }
  1000. }
  1001. void SelectCreditFaceRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason )
  1002. {
  1003. if (iReason & MSYS_CALLBACK_REASON_INIT)
  1004. {
  1005. }
  1006. else if(iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
  1007. {
  1008. }
  1009. else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
  1010. {
  1011. }
  1012. }
  1013. void SelectCreditFaceMovementRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason )
  1014. {
  1015. if( iReason & MSYS_CALLBACK_REASON_LOST_MOUSE )
  1016. {
  1017. giCurrentlySelectedFace = -1;
  1018. }
  1019. else if( iReason & MSYS_CALLBACK_REASON_GAIN_MOUSE )
  1020. {
  1021. giCurrentlySelectedFace = MSYS_GetRegionUserData( pRegion,0 );
  1022. }
  1023. else if( iReason & MSYS_CALLBACK_REASON_MOVE )
  1024. {
  1025. }
  1026. }
  1027. void InitCreditEyeBlinking()
  1028. {
  1029. UINT8 ubCnt;
  1030. for( ubCnt=0; ubCnt<NUM_PEOPLE_IN_CREDITS; ubCnt++ )
  1031. {
  1032. gCreditFaces[ubCnt].uiLastBlinkTime = GetJA2Clock() + Random( gCreditFaces[ubCnt].sBlinkFreq * 2 );
  1033. }
  1034. }
  1035. void HandleCreditEyeBlinking()
  1036. {
  1037. HVOBJECT hPixHandle;
  1038. UINT8 ubCnt;
  1039. GetVideoObject(&hPixHandle, guiCreditFaces );
  1040. for( ubCnt=0; ubCnt<NUM_PEOPLE_IN_CREDITS; ubCnt++ )
  1041. {
  1042. if( ( GetJA2Clock() - gCreditFaces[ubCnt].uiLastBlinkTime ) > (UINT32)gCreditFaces[ubCnt].sBlinkFreq )
  1043. {
  1044. BltVideoObject( FRAME_BUFFER, hPixHandle, (UINT8)(ubCnt*3), gCreditFaces[ubCnt].sEyeX, gCreditFaces[ubCnt].sEyeY, VO_BLT_SRCTRANSPARENCY, NULL);
  1045. InvalidateRegion( gCreditFaces[ubCnt].sEyeX, gCreditFaces[ubCnt].sEyeY, gCreditFaces[ubCnt].sEyeX + CRDT_EYE_WIDTH, gCreditFaces[ubCnt].sEyeY + CRDT_EYE_HEIGHT );
  1046. gCreditFaces[ubCnt].uiLastBlinkTime = GetJA2Clock();
  1047. gCreditFaces[ubCnt].uiEyesClosedTime = GetJA2Clock() + CRDT_EYES_CLOSED_TIME + Random( CRDT_EYES_CLOSED_TIME );
  1048. }
  1049. else if( GetJA2Clock() > gCreditFaces[ubCnt].uiEyesClosedTime )
  1050. {
  1051. gCreditFaces[ubCnt].uiEyesClosedTime = 0;
  1052. RestoreExternBackgroundRect( gCreditFaces[ubCnt].sEyeX, gCreditFaces[ubCnt].sEyeY, CRDT_EYE_WIDTH, CRDT_EYE_HEIGHT );
  1053. }
  1054. }
  1055. }