-
Notifications
You must be signed in to change notification settings - Fork 0
/
Credits.cpp
1475 lines (1171 loc) · 34.9 KB
/
Credits.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifdef PRECOMPILEDHEADERS
#include "JA2 All.h"
#include "Credits.h"
#include "Encrypted File.h"
#include "Language Defines.h"
#else
#include "Types.h"
#include "Credits.h"
#include "Language Defines.h"
#include "vsurface.h"
#include "mousesystem.h"
#include "Text.h"
#include "wordwrap.h"
#include "Video.h"
#include "render dirty.h"
#include "local.h"
#include "utilities.h"
#include "WCheck.h"
#include "screenids.h"
#include "Font Control.h"
#include "cursors.h"
#include "font.h"
#include "wordwrap.h"
#include "sysutil.h"
#include "Input.h"
#include "english.h"
#include "encrypted file.h"
#include "Random.h"
#endif
//externals
extern HVSURFACE ghFrameBuffer;
//local Defines
enum
{
CRDT_RENDER_NONE,
CRDT_RENDER_ALL,
};
//nnn
typedef struct _CRDT_NODE
{
UINT32 uiType; //the type of node
CHAR16 *pString; //string for the node if the node contains a string
UINT32 uiFlags; //various flags
INT16 sPosX; //position of the node on the screen if the node is displaying stuff
INT16 sPosY;
INT16 sOldPosX; //position of the node on the screen if the node is displaying stuff
INT16 sOldPosY;
INT16 sHeightOfString; //The height of the displayed string
BOOLEAN fDelete; //Delete this loop
UINT32 uiLastTime; // The last time the node was udated
UINT32 uiVideoSurfaceImage;
struct _CRDT_NODE *pPrev;
struct _CRDT_NODE *pNext;
} CRDT_NODE;
//type of credits
enum
{
CRDT_NODE_NONE,
CRDT_NODE_DEFAULT, // scrolls up and off the screen
};
//flags for the credits
//Flags:
#define CRDT_FLAG__TITLE 0x00000001
#define CRDT_FLAG__START_SECTION 0x00000002
#define CRDT_FLAG__END_SECTION 0x00000004
#define CRDT_NAME_OF_CREDIT_FILE "BINARYDATA\\Credits.edt"
#define CRDT_NAME_OF_MOD_CREDIT_FILE "BINARYDATA\\Credits_Mod.edt"
#define CREDITS_LINESIZE (80 * 2)
//
// Code tokens
//
//new codes:
#define CRDT_START_CODE '@'
#define CRDT_SEPARATION_CODE L","
#define CRDT_END_CODE L";"
#define CRDT_DELAY_BN_STRINGS_CODE 'D'
#define CRDT_DELAY_BN_SECTIONS_CODE 'B'
#define CRDT_SCROLL_SPEED 'S'
#define CRDT_FONT_JUSTIFICATION 'J'
#define CRDT_TITLE_FONT_COLOR 'C'
#define CRDT_ACTIVE_FONT_COLOR 'R'
//Flags:
#define CRDT_TITLE 'T'
#define CRDT_START_OF_SECTION '{'
#define CRDT_END_OF_SECTION '}'
#define CRDT_NAME_FONT FONT12ARIAL
#define CRDT_LINE_NODE_DISAPPEARS_AT 0
#define CRDT_WIDTH_OF_TEXT_AREA 210
#define CRDT_SCROLL_PIXEL_AMOUNT 1
#define CRDT_NODE_DELAY_AMOUNT 25
#define CRDT_DELAY_BN_NODES 750
#define CRDT_DELAY_BN_SECTIONS 2500
#define CRDT_SPACE_BN_SECTIONS 50
#define CRDT_SPACE_BN_NODES 12
#define CRDT_START_POS_Y (SCREEN_HEIGHT - 1)
#define CRDT_EYE_WIDTH 30
#define CRDT_EYE_HEIGHT 12
#define CRDT_EYES_CLOSED_TIME 150
//ddd
typedef struct
{
INT16 sX;
INT16 sY;
INT16 sWidth;
INT16 sHeight;
INT16 sEyeX;
INT16 sEyeY;
INT16 sMouthX;
INT16 sMouthY;
INT16 sBlinkFreq;
UINT32 uiLastBlinkTime;
UINT32 uiEyesClosedTime;
} CDRT_FACE;
CDRT_FACE gCreditFaces[] =
{
// x y w h
298, 137, 37, 49, 310, 157, 304, 170, 2500, 0, 0, //Camfield
348, 137, 43, 47, 354, 153, 354, 153, 3700, 0, 0, //Shawn
407, 132, 30, 50, 408, 151, 410, 164, 3000, 0, 0, //Kris
443, 131, 30, 50, 447, 151, 446, 161, 4000, 0, 0, //Ian
487, 136, 43, 50, 493, 155, 493, 155, 3500, 0, 0, //Linda
529, 145, 43, 50, 536, 164, 536, 164, 4000, 0, 0, //Eric
581, 132, 43, 48, 584, 150, 583, 161, 3500, 0, 0, //Lynn
278, 211, 36, 51, 283, 232, 283, 241, 3700, 0, 0, //Norm
319, 210, 34, 49, 323, 227, 320, 339, 4000, 0, 0, //George
358, 211, 38, 49, 364, 226, 361, 239, 3600, 0, 0, //Andrew Stacey
396, 200, 42, 50, 406, 220, 403, 230, 4600, 0, 0, //Scott
444, 202, 43, 51, 452, 220, 452, 231, 2800, 0, 0, //Emmons
493, 188, 36, 51, 501, 207, 499, 217, 4500, 0, 0, //Dave
531, 199, 47, 56, 541, 221, 540, 232, 4000, 0, 0, //Alex
585, 196, 39, 49, 593, 218, 593, 228, 3500, 0, 0, //Joey
};
//Global Variables
MOUSE_REGION gCrdtMouseRegions[ NUM_PEOPLE_IN_CREDITS ];
void SelectCreditFaceRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason );
void SelectCreditFaceMovementRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason );
UINT32 guiCreditBackGroundImage;
UINT32 guiCreditFaces;
BOOLEAN gfCreditsScreenEntry = TRUE;
BOOLEAN gfCreditsScreenExit = FALSE;
UINT32 guiCreditsExitScreen;
UINT8 gubCreditScreenRenderFlags = CRDT_RENDER_ALL;
CRDT_NODE *gCrdtRootNode=NULL;
CRDT_NODE *gCrdtLastAddedNode=NULL;
BOOLEAN gfCrdtHaveRenderedFirstFrameToSaveBuffer; // need to render background image to save buffer once
INT32 giCurrentlySelectedFace = -1;
//
//VAriables needed for processing of the nodes:
//
UINT32 guiCreditScreenActiveFont; // the font that is used
UINT32 guiCreditScreenTitleFont; // the font that is used
UINT8 gubCreditScreenActiveColor; // color of the font
UINT8 gubCreditScreenTitleColor; // color of a Title node
UINT32 guiCrdtNodeScrollSpeed = CRDT_NODE_DELAY_AMOUNT; //speed credits go up at
UINT32 guiCrdtLastTimeUpdatingNode=0; // the last time a node was read from the file
UINT8 gubCrdtJustification = CENTER_JUSTIFIED; // the current justification
UINT32 guiGapBetweenCreditSections = CRDT_SPACE_BN_SECTIONS;
UINT32 guiGapBetweenCreditNodes = CRDT_SPACE_BN_NODES;
UINT32 guiGapTillReadNextCredit = CRDT_SPACE_BN_NODES;
UINT32 guiCurrentCreditRecord = 0;
BOOLEAN gfPauseCreditScreen = FALSE;
BOOLEAN gfModCredits = TRUE;
HWFILE ghFile;
//Function Prototypes
BOOLEAN EnterCreditsScreen();
BOOLEAN ExitCreditScreen();
void HandleCreditScreen();
BOOLEAN RenderCreditScreen();
void GetCreditScreenUserInput();
void SetCreditsExitScreen( UINT32 uiScreenToGoTo );
BOOLEAN ShutDownCreditList();
BOOLEAN AddCreditNode( UINT32 uiType, UINT32 uiFlags, STR16 pString );
BOOLEAN InitCreditNode( );
BOOLEAN DisplayCreditNode( CRDT_NODE *pCurrent );
void HandleCreditNodes();
void HandleNode_Default( CRDT_NODE *pCurrent );
void HandleCurrentCreditNode( CRDT_NODE *pCurrent );
BOOLEAN DeleteNode( CRDT_NODE *pNodeToDelete );
UINT32 GetAndHandleCreditCodeFromCodeString( STR16 pzCode );
BOOLEAN GetNextCreditFromTextFile();
UINT32 CountNumberOfCreditNodes();
STR16 GetNextCreditCode( STR16 pString, UINT32 *pSizeOfCode );
void HandleCreditFlags( UINT32 uiFlags );
void HandleCreditEyeBlinking();
void InitCreditEyeBlinking();
UINT32 CreditScreenInit( void )
{
gfCreditsScreenEntry = TRUE;
return( 1 );
}
UINT32 CreditScreenHandle( void )
{
StartFrameBufferRender();
if( gfCreditsScreenEntry )
{
if( !EnterCreditsScreen() )
{
gfCreditsScreenEntry = FALSE;
gfCreditsScreenExit = TRUE;
}
else
{
gfCreditsScreenEntry = FALSE;
gfCreditsScreenExit = FALSE;
}
gubCreditScreenRenderFlags = CRDT_RENDER_ALL;
}
GetCreditScreenUserInput();
HandleCreditScreen();
ExecuteBaseDirtyRectQueue();
EndFrameBufferRender();
if( gfCreditsScreenExit )
{
ExitCreditScreen();
gfCreditsScreenEntry = TRUE;
gfCreditsScreenExit = FALSE;
}
return( guiCreditsExitScreen );
}
UINT32 CreditScreenShutdown( void )
{
return( 1 );
}
BOOLEAN EnterCreditsScreen()
{
UINT32 uiCnt;
VOBJECT_DESC VObjectDesc;
gfModCredits = TRUE;
ColorFillVideoSurfaceArea( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0 );
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
if (iResolution >= _640x480 && iResolution < _800x600)
{
FilenameForBPP("INTERFACE\\Credits.sti", VObjectDesc.ImageFile);
}
else if (iResolution < _1024x768)
{
FilenameForBPP("INTERFACE\\Credits_800x600.sti", VObjectDesc.ImageFile);
}
else
{
FilenameForBPP("INTERFACE\\Credits_1024x768.sti", VObjectDesc.ImageFile);
}
CHECKF(AddVideoObject(&VObjectDesc, &guiCreditBackGroundImage ));
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\Credit Faces.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiCreditFaces ));
//Initialize the root credit node
InitCreditNode( );
guiCreditsExitScreen = CREDIT_SCREEN;
gfCrdtHaveRenderedFirstFrameToSaveBuffer = FALSE;
guiCreditScreenActiveFont = FONT12ARIAL;
gubCreditScreenActiveColor = FONT_MCOLOR_DKWHITE;
guiCreditScreenTitleFont = FONT14ARIAL;
gubCreditScreenTitleColor = FONT_MCOLOR_RED;
guiCrdtNodeScrollSpeed = CRDT_NODE_DELAY_AMOUNT;
gubCrdtJustification = CENTER_JUSTIFIED;
guiCurrentCreditRecord = 0;
guiCrdtLastTimeUpdatingNode = GetJA2Clock();
guiGapBetweenCreditSections = CRDT_SPACE_BN_SECTIONS;
guiGapBetweenCreditNodes = CRDT_SPACE_BN_NODES;
guiGapTillReadNextCredit = CRDT_SPACE_BN_NODES;
for( uiCnt=0; uiCnt < NUM_PEOPLE_IN_CREDITS; uiCnt++)
{
// Make a mouse region
MSYS_DefineRegion( &gCrdtMouseRegions[uiCnt], gCreditFaces[uiCnt].sX + xResOffset, gCreditFaces[uiCnt].sY + yResOffset, (INT16)(gCreditFaces[uiCnt].sX + gCreditFaces[uiCnt].sWidth + xResOffset), (INT16)(gCreditFaces[uiCnt].sY + gCreditFaces[uiCnt].sHeight + yResOffset), MSYS_PRIORITY_NORMAL,
CURSOR_WWW, SelectCreditFaceMovementRegionCallBack, SelectCreditFaceRegionCallBack );
// Add region
MSYS_AddRegion( &gCrdtMouseRegions[uiCnt] );
MSYS_SetRegionUserData( &gCrdtMouseRegions[uiCnt], 0, uiCnt );
}
giCurrentlySelectedFace = -1;
gfPauseCreditScreen = FALSE;
InitCreditEyeBlinking();
return( TRUE );
}
BOOLEAN ExitCreditScreen()
{
UINT32 uiCnt;
DeleteVideoObjectFromIndex( guiCreditBackGroundImage );
DeleteVideoObjectFromIndex( guiCreditFaces );
//ShutDown Credit link list
ShutDownCreditList();
for( uiCnt=0; uiCnt < NUM_PEOPLE_IN_CREDITS; uiCnt++)
{
MSYS_RemoveRegion( &gCrdtMouseRegions[uiCnt] );
}
return( TRUE );
}
//hhh
void HandleCreditScreen()
{
UINT16 CRDT_NAME_LOC_X = 375 + xResOffset;
UINT16 CRDT_NAME_LOC_Y = 420 + yResOffset;
UINT16 CRDT_NAME_TITLE_LOC_Y = 435 + yResOffset;
UINT16 CRDT_NAME_FUNNY_LOC_Y = 450 + yResOffset;
UINT16 CRDT_NAME_LOC_WIDTH = 260;
UINT16 CRDT_NAME_LOC_HEIGHT = ( CRDT_NAME_FUNNY_LOC_Y - CRDT_NAME_LOC_Y + GetFontHeight( CRDT_NAME_FONT ) );
if( gubCreditScreenRenderFlags == CRDT_RENDER_ALL )
{
RenderCreditScreen();
gubCreditScreenRenderFlags = CRDT_RENDER_NONE;
}
//Handle the Credit linked list
HandleCreditNodes();
//Handle the blinkng eyes
HandleCreditEyeBlinking();
//is it time to get a new node
if( gCrdtLastAddedNode == NULL || ( CRDT_START_POS_Y - ( gCrdtLastAddedNode->sPosY + gCrdtLastAddedNode->sHeightOfString - 16 ) ) >= (INT16)guiGapTillReadNextCredit )
{
//if there are no more credits in the file
if( !GetNextCreditFromTextFile() && gCrdtLastAddedNode == NULL )
{
SetCreditsExitScreen( MAINMENU_SCREEN );
}
}
RestoreExternBackgroundRect( CRDT_NAME_LOC_X, CRDT_NAME_LOC_Y, CRDT_NAME_LOC_WIDTH, (INT16)CRDT_NAME_LOC_HEIGHT );
if( giCurrentlySelectedFace != -1 )
{
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 );
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 );
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 );
}
}
//rrr
BOOLEAN RenderCreditScreen()
{
HVOBJECT hPixHandle;
GetVideoObject(&hPixHandle, guiCreditBackGroundImage );
BltVideoObject( FRAME_BUFFER, hPixHandle, 0, xResOffset, yResOffset, VO_BLT_SRCTRANSPARENCY, NULL);
if( !gfCrdtHaveRenderedFirstFrameToSaveBuffer )
{
gfCrdtHaveRenderedFirstFrameToSaveBuffer = TRUE;
//blit everything to the save buffer ( cause the save buffer can bleed through )
BlitBufferToBuffer(guiRENDERBUFFER, guiSAVEBUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
UnmarkButtonsDirty( );
}
InvalidateScreen( );
return( TRUE );
}
void GetCreditScreenUserInput()
{
InputAtom Event;
while (DequeueSpecificEvent(&Event, KEY_DOWN|KEY_UP|KEY_REPEAT))
{
if( Event.usEvent == KEY_DOWN )
{
switch( Event.usParam )
{
case ESC:
//Exit out of the screen
SetCreditsExitScreen( MAINMENU_SCREEN );
break;
case 'r':
gubCreditScreenRenderFlags = CRDT_RENDER_ALL;
break;
case 'i':
InvalidateRegion( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
break;
case UPARROW:
guiCrdtNodeScrollSpeed+=5;
break;
case DNARROW:
if( guiCrdtNodeScrollSpeed > 5 )
guiCrdtNodeScrollSpeed-=5;
break;
case PAUSE:
case SPACE:
if( gfPauseCreditScreen )
gfPauseCreditScreen = FALSE;
else
gfPauseCreditScreen = TRUE;
break;
}
}
}
}
void SetCreditsExitScreen( UINT32 uiScreenToGoTo )
{
gfCreditsScreenExit = TRUE;
guiCreditsExitScreen = uiScreenToGoTo;
}
BOOLEAN InitCreditNode( )
{
if( gCrdtRootNode != NULL )
Assert( 0 );
gCrdtRootNode = NULL;
return( TRUE );
}
BOOLEAN ShutDownCreditList()
{
CRDT_NODE *pNodeToDelete=NULL;
CRDT_NODE *pTemp=NULL;
pNodeToDelete = gCrdtRootNode;
while( pNodeToDelete!= NULL )
{
pTemp = pNodeToDelete;
pNodeToDelete = pNodeToDelete->pNext;
//Delete the current node
DeleteNode( pTemp );
}
return( TRUE );
}
BOOLEAN DeleteNode( CRDT_NODE *pNodeToDelete )
{
CRDT_NODE *pTempNode;
pTempNode = pNodeToDelete;
if( gCrdtLastAddedNode == pNodeToDelete )
{
gCrdtLastAddedNode = NULL;
}
//if its Not the first node
if( pNodeToDelete->pPrev != NULL )
pNodeToDelete->pPrev = pNodeToDelete->pNext;
else
{
if( gCrdtRootNode->pNext != NULL )
{
gCrdtRootNode = gCrdtRootNode->pNext;
gCrdtRootNode->pPrev = NULL;
}
}
//if its the last node in the list
if( pNodeToDelete->pNext == NULL && pNodeToDelete->pPrev != NULL )
pNodeToDelete->pPrev->pNext = NULL;
//iof the node that is being deleted is the first node
if( pTempNode == gCrdtRootNode )
gCrdtRootNode = NULL;
//Free the string
if( pTempNode->pString != NULL )
{
MemFree( pTempNode->pString );
pTempNode->pString = NULL;
}
//if the node had something to display, delete a surface for it
if( pTempNode->uiType == CRDT_NODE_DEFAULT )
{
DeleteVideoSurfaceFromIndex( pTempNode->uiVideoSurfaceImage );
pTempNode->uiVideoSurfaceImage = 0;
}
//Free the node
MemFree( pTempNode );
pTempNode = NULL;
return( TRUE );
}
//aaa
BOOLEAN AddCreditNode( UINT32 uiType, UINT32 uiFlags, STR16 pString )
{
CRDT_NODE *pNodeToAdd=NULL;
CRDT_NODE *pTemp=NULL;
UINT32 uiSizeOfString = ( wcslen( pString ) + 2 ) * 2;
UINT32 uiFontToUse;
UINT8 uiColorToUse;
UINT16 CRDT_TEXT_START_LOC = xResOffset + 10;
//if
if( uiType == CRDT_NODE_NONE)
{
Assert( 0 );
return( TRUE );
}
pNodeToAdd = (CRDT_NODE *) MemAlloc( sizeof( CRDT_NODE) );
if( pNodeToAdd == NULL )
{
return( FALSE );
}
memset( pNodeToAdd, 0, sizeof( CRDT_NODE) );
//Determine the font and the color to use
if( uiFlags & CRDT_FLAG__TITLE )
{
uiFontToUse = guiCreditScreenTitleFont;
uiColorToUse = gubCreditScreenTitleColor;
}
else
{
uiFontToUse = guiCreditScreenActiveFont;
uiColorToUse = gubCreditScreenActiveColor;
}
//
// Set some default data
//
//the type of the node
pNodeToAdd->uiType = uiType;
//any flags that are added
pNodeToAdd->uiFlags = uiFlags;
//the starting left position for the it
pNodeToAdd->sPosX = CRDT_TEXT_START_LOC;
//Allocate memory for the string
pNodeToAdd->pString = (CHAR16 *) MemAlloc( uiSizeOfString );
if( pNodeToAdd->pString == NULL )
return( FALSE );
//copy the string into the node
wcscpy( pNodeToAdd->pString, pString );
//Calculate the height of the string
pNodeToAdd->sHeightOfString = DisplayWrappedString( 0, 0, CRDT_WIDTH_OF_TEXT_AREA, 2, uiFontToUse, uiColorToUse, pNodeToAdd->pString, 0, FALSE, DONT_DISPLAY_TEXT ) + 1;
//starting y position on the screen
pNodeToAdd->sPosY = CRDT_START_POS_Y;
// pNodeToAdd->uiLastTime = GetJA2Clock();
//if the node can have something to display, Create a surface for it
if( pNodeToAdd->uiType == CRDT_NODE_DEFAULT )
{
VSURFACE_DESC vs_desc;
// Create a background video surface to blt the face onto
vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
vs_desc.usWidth = CRDT_WIDTH_OF_TEXT_AREA;
vs_desc.usHeight = pNodeToAdd->sHeightOfString;
vs_desc.ubBitDepth = 16;
if( AddVideoSurface( &vs_desc, &pNodeToAdd->uiVideoSurfaceImage) == 0 )
{
return( FALSE );
}
//Set transparency
SetVideoSurfaceTransparency( pNodeToAdd->uiVideoSurfaceImage, 0 );
//fill the surface with a transparent color
ColorFillVideoSurfaceArea(pNodeToAdd->uiVideoSurfaceImage, 0, 0, CRDT_WIDTH_OF_TEXT_AREA, pNodeToAdd->sHeightOfString, 0 );
//set the font dest buffer to be the surface
SetFontDestBuffer( pNodeToAdd->uiVideoSurfaceImage, 0, 0, CRDT_WIDTH_OF_TEXT_AREA, pNodeToAdd->sHeightOfString, FALSE );
//write the string onto the surface
DisplayWrappedString( 0, 1, CRDT_WIDTH_OF_TEXT_AREA, 2, uiFontToUse, uiColorToUse, pNodeToAdd->pString, 0, FALSE, gubCrdtJustification );
//reset the font dest buffer
SetFontDestBuffer(FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE);
}
//
// Insert the node into the list
//
//if its the first node to add
if( gCrdtRootNode == NULL )
{
//make the new node the root node
gCrdtRootNode = pNodeToAdd;
gCrdtRootNode->pNext = NULL;
gCrdtRootNode->pPrev = NULL;
}
else
{
pTemp = gCrdtRootNode;
while( pTemp->pNext != NULL )
{
pTemp = pTemp->pNext;
}
//Add the new node to the list
pTemp->pNext = pNodeToAdd;
//Assign the prev node
pNodeToAdd->pPrev = pTemp;
}
gCrdtLastAddedNode = pNodeToAdd;
return( TRUE );
}
void HandleCreditNodes()
{
CRDT_NODE *pCurrent=NULL;
CRDT_NODE *pTemp=NULL;
if( gCrdtRootNode == NULL )
return;
//if the screen is paused, exit
if( gfPauseCreditScreen )
return;
pCurrent = gCrdtRootNode;
if( !( GetJA2Clock() - guiCrdtLastTimeUpdatingNode > guiCrdtNodeScrollSpeed ) )
return;
//loop through all the nodes
while( pCurrent != NULL )
{
pTemp = pCurrent;
pCurrent = pCurrent->pNext;
//Handle the current node
HandleCurrentCreditNode( pTemp );
//if the node is to be deleted
if( pTemp->fDelete )
{
//delete the node
DeleteNode( pTemp );
}
}
guiCrdtLastTimeUpdatingNode = GetJA2Clock();
}
void HandleCurrentCreditNode( CRDT_NODE *pCurrent )
{
//switch on the type of node
switch( pCurrent->uiType )
{
case CRDT_NODE_DEFAULT:
HandleNode_Default( pCurrent );
break;
default:
Assert( 0 );
break;
}
}
void HandleNode_Default( CRDT_NODE *pCurrent )
{
//Display the Current Node
DisplayCreditNode( pCurrent );
//Save the old position
pCurrent->sOldPosX = pCurrent->sPosX;
pCurrent->sOldPosY = pCurrent->sPosY;
//Move the current node up
pCurrent->sPosY -= CRDT_SCROLL_PIXEL_AMOUNT;
//if the node is entirely off the screen
if( ( pCurrent->sPosY + pCurrent->sHeightOfString ) < CRDT_LINE_NODE_DISAPPEARS_AT )
{
//mark the node to be deleted this frame
pCurrent->fDelete = TRUE;
}
pCurrent->uiLastTime = GetJA2Clock();
}
BOOLEAN DisplayCreditNode( CRDT_NODE *pCurrent )
{
HVSURFACE hVSurface;
//Currently, we have no need to display a node that doesnt have a string
if( pCurrent->pString == NULL )
return( FALSE );
//if the node is new and we havent displayed it yet
if( pCurrent->uiLastTime == 0 )
{
}
//else we have to restore were the string was
else
{
//
//Restore the background before blitting the text back on
//
//if the surface is at the bottom of the screen
if( pCurrent->sOldPosY + pCurrent->sHeightOfString > CRDT_START_POS_Y )
{
INT16 sHeight = SCREEN_HEIGHT - pCurrent->sOldPosY;
//INT16 sHeight = 480 - pCurrent->sOldPosY;
RestoreExternBackgroundRect( pCurrent->sOldPosX, pCurrent->sOldPosY, CRDT_WIDTH_OF_TEXT_AREA, sHeight );
}
else if( pCurrent->sOldPosY > CRDT_LINE_NODE_DISAPPEARS_AT )
{
RestoreExternBackgroundRect( pCurrent->sOldPosX, pCurrent->sOldPosY, CRDT_WIDTH_OF_TEXT_AREA, pCurrent->sHeightOfString );
}
//if the surface is at the top of the screen
else
{
INT16 sHeight = pCurrent->sOldPosY + pCurrent->sHeightOfString;
RestoreExternBackgroundRect( pCurrent->sOldPosX, CRDT_LINE_NODE_DISAPPEARS_AT, CRDT_WIDTH_OF_TEXT_AREA, sHeight );
}
}
GetVideoSurface( &hVSurface, pCurrent->uiVideoSurfaceImage );
BltVideoSurfaceToVideoSurface( ghFrameBuffer, hVSurface, 0, pCurrent->sPosX, pCurrent->sPosY, VS_BLT_CLIPPED | VS_BLT_USECOLORKEY, NULL );
return( TRUE );
}
//return false from this function when there are no more items in the text file
BOOLEAN GetNextCreditFromTextFile()
{
CHAR16 zOriginalString[512];
CHAR16 zString[512];
CHAR16 zCodes[512];
STR16 pzNewCode=NULL;
UINT32 uiNodeType = 0;
UINT32 uiStartLoc = 0;
UINT32 uiFlags=0;
// 1.) MOD Credits
if (gfModCredits == TRUE)
{
if (FileExists(CRDT_NAME_OF_MOD_CREDIT_FILE))
{
uiStartLoc = CREDITS_LINESIZE * (guiCurrentCreditRecord);
if( !LoadEncryptedDataFromFile( CRDT_NAME_OF_MOD_CREDIT_FILE, zOriginalString, uiStartLoc, CREDITS_LINESIZE ) )
{
//there are no more credits
gfModCredits = FALSE;
guiCurrentCreditRecord = 0;
}
// We have ended the mod credits list
if (strcmp((char *)zOriginalString, "") == 0)
{
gfModCredits = FALSE;
guiCurrentCreditRecord = 0;
}
}
else
{
gfModCredits = FALSE;
guiCurrentCreditRecord = 0;
}
}
if (gfModCredits == FALSE)
{
switch(guiCurrentCreditRecord)
{
// 2.) 1.13 Credits
case 0:
wcscpy(zOriginalString, L"@T,C208,R134,D16,B40,S10,J1,};");
break;
case 1:
wcscpy(zOriginalString, pCreditsJA2113[0]);
break;
case 2:
wcscpy(zOriginalString, L"@};");
break;
case 3:
wcscpy(zOriginalString, pCreditsJA2113[1]);
break;
case 4:
wcscpy(zOriginalString, L"anv");
break;
case 5:
wcscpy(zOriginalString, L"BirdFlu");
break;
case 6:
wcscpy(zOriginalString, L"Buggler");
break;
case 7:
wcscpy(zOriginalString, L"Bugmonster");
break;
case 8:
wcscpy(zOriginalString, L"ChrisL");
break;
case 9:
wcscpy(zOriginalString, L"Flugente");
break;
case 10:
wcscpy(zOriginalString, L"haydent");
break;
case 11:
wcscpy(zOriginalString, L"Jazz");
break;
case 12:
wcscpy(zOriginalString, L"Kaiden");
break;
case 13:
wcscpy(zOriginalString, L"Kriplo");
break;
case 14:
wcscpy(zOriginalString, L"Lesh");
break;
case 15:
wcscpy(zOriginalString, L"Little Alien");
break;
case 16:
wcscpy(zOriginalString, L"Madd Mugsy");
break;
case 17:
wcscpy(zOriginalString, L"Overhaul");
break;
case 18:
wcscpy(zOriginalString, L"RoWa21 aka Wanne");
break;
case 19:
wcscpy(zOriginalString, L"Sandro");
break;
case 20:
wcscpy(zOriginalString, L"silversurfer");
break;
case 21:
wcscpy(zOriginalString, L"Space Viking");
break;
case 22:
wcscpy(zOriginalString, L"@};Zathras");
break;
case 23:
wcscpy(zOriginalString, pCreditsJA2113[2]);
break;
case 24:
wcscpy(zOriginalString, L"BulletSix");
break;
case 25:
wcscpy(zOriginalString, L"coolberg");
break;
case 26:
wcscpy(zOriginalString, L"Corpse");
break;
case 27:
wcscpy(zOriginalString, L"John Wright");
break;
case 28:
wcscpy(zOriginalString, L"Kaerar");
break;
case 29:
wcscpy(zOriginalString, L"Kazuya");
break;
case 30:
wcscpy(zOriginalString, L"Khor");
break;
case 31:
wcscpy(zOriginalString, L"Lisac");
break;
case 32:
wcscpy(zOriginalString, L"Madd Mugsy");
break;
case 33:
wcscpy(zOriginalString, L"Marlboro Man");
break;
case 34:
wcscpy(zOriginalString, L"PasHancock");
break;
case 35:
wcscpy(zOriginalString, L"Scorpion");
break;
case 36: