-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFONT.C
1159 lines (836 loc) · 22.7 KB
/
FONT.C
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
/********************************************************************
* *
* *
* Font draw functions *
* *
* *
********************************************************************/
/********************************************************************
* *
* Includes *
* *
********************************************************************/
#include "incs.h"
#ifdef PSX
#include "..\..\striker\src\anim.def"
#include "main.h"
#include "datafile.h"
#include "sprite.h"
#include "frontend.h"
#include "gadget.h"
#include "shell.h"
#include "hardware.h"
#include "font.h"
#endif
/********************************************************************
* *
* Defines *
* *
********************************************************************/
#define MAX_TEXT_STRINGS_ACTIVE 32 // in a single group
#define TEXT_STRING_GROUPS 8
// special font chars
#define FONT_Y_SPACE 254
#define FONT_CR 253
#define FONT_ENDSTRING 252
/********************************************************************
* *
* Prototypes *
* *
********************************************************************/
void add_font ( Font_data *font_data, UWORD font_num );
void init_fonts();
void spawn_text_string ( Textman_struct *textman );
void unspawn_text_string( Sprite *sprite );
void unspawn_all_text_strings();
void apply_to_sprite_string( Sprite *sprite );
void get_group_sprite ( WORD group );
void apply_seqnum_to_sprite_string( Sprite *sprite );
void milford_font_logic ( Sprite *sprite );
void start_text_manager( WORD text_strings );
void adjust_text_string_pos ( Sprite *sprite, WORD xamount, WORD yamount );
/********************************************************************
* *
* Vars *
* *
********************************************************************/
typedef struct
{
WORD current_spawned_string;
Sprite *spawned_strings_list[ MAX_TEXT_STRINGS_ACTIVE ];
}Text_group;
Text_group text_group [ TEXT_STRING_GROUPS ];
Sprite *head_sprite;
WORD tslot_poses[ TEXTMAN_TSLOTS ];
Font *resident_fonts[ MAX_FONTS ];
Font_data milford_font_data = {
MILFT,// graphic type
26, // start of alpha lower
0, // start of alpha upper
52, // start of numeric
65, // comma
64, // stop
62, // exclamation
68, // double quote
137, // apostrophe
73, // dollar
0, // pound
0, // hat
71, // ampersand
74, // asterisk
66, // open bracket
67, // close bracket
69, // plus
70, // minus
72, // hash
63, // question mark
134, // colon
136, // <
135, // >
79, // return
78, // backspace
77, // space
133, // dummy space
2, // x space between characters was 2
46, // y space between characters
75, // slash
// 11,18,// set frame n to width x
134, 6,
0,0,
};
Font_data tiny_font_data = {
TYFNT,// graphic type
0, // start of alpha lower
0, // start of alpha upper
41, // start of numeric
29, // comma
28, // stop
26, // exclamation
32, // double quote
52, // single quote
37, // dollar
0, // pound
0, // hat
0, // ampersand
38, // asterisk
30, // open bracket
31, // close bracket
33, // plus
34, // minus
36, // hash
27, // question mark
53, // colon
0, // <
0, // >
0, // return
0, // backspace
0, // space
51, // dummy space
2, // x space between characters
32, // y space between characters
0, // slash
// 11,18,// set frame n to width x
// 15,24,
0,0,
};
Font_data title_font_data = {
TITFT,// graphic type
26, // start of alpha lower
0, // start of alpha upper
52, // start of numeric
65, // comma
64, // stop
62, // exclamation
68, // double quote
137, //137, // apostrophe
73, // dollar
0, // pound
0, // hat
71, // ampersand
74, // asterisk
66, // open bracket
67, // close bracket
69, // plus
70, // minus
72, // hash
63, // question mark
134, // colon
0, //136, // <
0, //135, // >
79, // return
78, // backspace
77, // space
133, // dummy space
2, // x space between characters was 2
46, // y space between characters
0, // slash
// 11,18,// set frame n to width x
// 134, 6,
0,0,
};
/********************************************************************
* *
* Prototypes *
* *
********************************************************************/
void setup_font_lookup_list ( Font *font );
void init_text_spawner();
void update_text_manager();
void init_fonts()
{
WORD cnt;
for ( cnt=0;cnt < MAX_FONTS; cnt++ )
{
resident_fonts[cnt] = (Font *)0;
}
init_text_spawner();
add_font ( &tiny_font_data, TINY_FONT );
add_font ( &title_font_data, TITLE_FONT );
add_font ( &milford_font_data, MILFORD_FONT );
}
void add_font ( Font_data *font_data, UWORD font_num )
{
Font *font;
resident_fonts[font_num] = allocate_mem ( 0, sizeof ( Font ) );
font = resident_fonts[font_num];
font->font_data = font_data;
setup_font_lookup_list ( font );
// printf("fontdata=%x\n",font->font_data);
}
void setup_font_lookup_list ( Font *font )
{
WORD cnt;
Spr_anim_frame_san *frame;
for ( cnt=0;cnt<255;cnt++ )
font->lookup_list[cnt] = 255;
for ( cnt=0;cnt<26;cnt++ )
{
font->lookup_list[ 'A' + cnt ] = font->font_data->alpha_upper + cnt;
font->lookup_list[ 'a' + cnt ] = font->font_data->alpha_lower + cnt;
}
for ( cnt=0;cnt<10;cnt++ )
{
font->lookup_list[ '0' + cnt ] = font->font_data->numeric + cnt;
}
font->lookup_list[ ',' ] = font->font_data->comma;
font->lookup_list[ '.' ] = font->font_data->stop;
font->lookup_list[ '!' ] = font->font_data->exclamation;
font->lookup_list[ '"' ] = font->font_data->double_quote;
font->lookup_list[ 39 ] = font->font_data->single_quote;
font->lookup_list[ '$' ] = font->font_data->dollar;
font->lookup_list[ 'œ' ] = font->font_data->pound;
font->lookup_list[ '^' ] = font->font_data->hat;
font->lookup_list[ '&' ] = font->font_data->ampersand;
font->lookup_list[ '*' ] = font->font_data->asterisk;
font->lookup_list[ '(' ] = font->font_data->open_bracket;
font->lookup_list[ ')' ] = font->font_data->close_bracket;
font->lookup_list[ '+' ] = font->font_data->plus;
font->lookup_list[ '-' ] = font->font_data->minus;
font->lookup_list[ '#' ] = font->font_data->hash;
font->lookup_list[ '?' ] = font->font_data->question_mark;
font->lookup_list[ ':' ] = font->font_data->colon;
font->lookup_list[ '' ] = font->font_data->backspace; //ascii 27
font->lookup_list[ 'Ù' ] = font->font_data->ret; //ascii 217
font->lookup_list[ 'ð' ] = font->font_data->space; //ascii 240
font->lookup_list[ ' ' ] = font->font_data->dummy_space;
font->lookup_list[ '<' ] = font->font_data->less_than;
font->lookup_list[ '>' ] = font->font_data->greater_than;
font->lookup_list[ '/' ] = font->font_data->slash;
font->lookup_list[ 10 ] = FONT_CR;
font->lookup_list[ 0 ] = FONT_ENDSTRING;
//adjust widths of any chars
cnt=0;
while(1)
{
if ( font->font_data->adjust[ cnt ].wd )
{
frame = get_sprite_frame_addr ( font->font_data->graphic_type );
frame += font->font_data->adjust[cnt].fr;
frame->real_w = font->font_data->adjust[cnt].wd;
// frame->w = 26; //font->font_data->adjust[cnt].wd;
// printf("fr=%d wd=%d\n",font->font_data->adjust[cnt].fr,frame->real_w);
cnt++;
}
else
break;
}
}
//WORD temp_frame_offs[]={ 0,-12,0,-14,-2,-12,0 };
WORD temp_frame_offs[]={ -1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0 };
void init_text_spawner()
{
WORD gr,str;
Text_group *tg;
tg = text_group;
for ( gr=0;gr < TEXT_STRING_GROUPS; gr++ )
{
tg->current_spawned_string = 0;
for ( str=0;str < MAX_TEXT_STRINGS_ACTIVE; str++ )
tg->spawned_strings_list[ str ] = 0;
tg++;
}
}
/*************************************
* *
* Spawn a text string *
* *
* 0,0 = centre of screen *
* *
*************************************/
void spawn_text_string ( Textman_struct *textman )
{
Font *font = resident_fonts[ textman->font_type ];
Spr_anim_frame_san *frame;
UBYTE fr;
WORD base_x;
WORD start_x;
WORD total_sprite_cnt; // total number of sprites spawned
WORD line_sprite_cnt; // sprites spawned on a line
Sprite *sprite_store;
Text_group *tg = &text_group[ textman->spawn_group];
WORD temp;
WORD head_sprite_xoffs,head_sprite_yoffs;
WORD y_adj;
WORD space_chr;
Sprite *new_sprite;
WORD cnt=0;
WORD line_wd;
WORD x = 0; //textman->x;
WORD y = textman->y;
WORD wd;
BYTE *string = &textman->string[0];
// printf("going to spawn '%s'\n",string );
// tlxy , brxy = boxed area occupied by font
// x += SCREEN_UNIT_WD/2;
// y += SCREEN_UNIT_HT/2;
head_sprite_xoffs=0;
head_sprite_yoffs=0;
textman->x1 = 32767;
textman->x2 = -32767;
textman->y1 = 32767;
textman->y2 = -32767;
textman->max_brightness = 120;
textman->depth = NEAREST_DEPTH;
base_x = textman->x;
total_sprite_cnt=0;
line_sprite_cnt=0;
sprite = 0;
while ( 1 )
{
fr = font->lookup_list [ *string ];
if ( fr < 242 )
{
#if DEBUG
if ( sprite->frame == 255 )
display_error ( "unknown font character\n");
#endif
if ( total_sprite_cnt == 0 )
{
spawn_sprite ( font->font_data->graphic_type );
head_sprite = sprite;
sprite->prev = 0; // no sprites before this one , therefore this is the head sprite
frame = sprite->spr_anim_frame_san + fr;
head_sprite_xoffs = frame->xoffs;
head_sprite_yoffs = frame->yoffs;
}
else
{
sprite = spawn_sprite_after ( font->font_data->graphic_type ); // store addr of last sprite spawned in this sprite struct.
frame = sprite->spr_anim_frame_san + fr;
}
sprite->frame = fr;
if ( fr == font->font_data->dummy_space )
{
sprite->display=NO;
}
sprite->gadget = textman->gadget;
if ( textman->font_logic )
sprite->upd_rtn = textman->font_logic;
sprite->x.w.hi = x;
sprite->y.w.hi = y + (frame->yoffs*SCREEN_UNIT_HT)/screen_yres;
sprite->depth = NEAREST_DEPTH;
sprite->transp_rate = -1;
sprite->group_num = textman->spawn_group;
sprite->textman = textman;
x += ((frame->real_w*SCREEN_UNIT_WD)/screen_xres ) + font->font_data->x_gap_size;
temp = sprite->y.w.hi + ((frame->h*SCREEN_UNIT_HT)/screen_yres);
if ( textman->y2 < temp )
textman->y2 = temp;
if ( textman->y1 > sprite->y.w.hi )
textman->y1 = sprite->y.w.hi;
total_sprite_cnt++;
line_sprite_cnt++;
//tail_font_sprite = sprite;
}
else
{
line_wd = x;
if ( (fr == FONT_CR ) || (fr == FONT_ENDSTRING) )
{
if ( textman->justify_type & FONT_XC )
{
//** x = width of line of text **
// adjust every sprite from this one to the beginning
sprite_store = sprite;
// this is the rightmost sprite in the text string
while( line_sprite_cnt )
{
sprite->x.w.hi += base_x - (line_wd/2);
frame = sprite->spr_anim_frame_san + sprite->frame;
temp = sprite->x.w.hi + ((frame->real_w*SCREEN_UNIT_WD)/screen_xres );
if ( textman->x1 >= sprite->x.w.hi )
textman->x1 = sprite->x.w.hi;
if ( temp >= textman->x2 )
textman->x2 = temp;
sprite = sprite->prev;
line_sprite_cnt--;
}
// this is the leftmost sprite in the text string
sprite = sprite_store;
}
if ( textman->justify_type & FONT_RJUST )
{
sprite_store = sprite;
// this is the rightmost sprite in the text string
while( line_sprite_cnt )
{
sprite->x.w.hi += base_x + (SCREEN_UNIT_WD/2) - line_wd;
frame = sprite->spr_anim_frame_san + sprite->frame;
temp = sprite->x.w.hi + ((frame->real_w*SCREEN_UNIT_WD)/screen_xres );
if ( textman->x1 >= sprite->x.w.hi )
textman->x1 = sprite->x.w.hi;
if ( temp >= textman->x2 )
textman->x2 = temp;
sprite = sprite->prev;
line_sprite_cnt--;
}
// this is the leftmost sprite in the text string
sprite = sprite_store;
}
if ( textman->justify_type & FONT_NORMAL )
{
sprite_store = sprite;
// this is the rightmost sprite in the text string
while( line_sprite_cnt )
{
sprite->x.w.hi += base_x;
frame = sprite->spr_anim_frame_san + sprite->frame;
temp = sprite->x.w.hi + ((frame->real_w*SCREEN_UNIT_WD)/screen_xres );
if ( textman->x1 >= sprite->x.w.hi )
textman->x1 = sprite->x.w.hi;
if ( temp >= textman->x2 )
textman->x2 = temp;
sprite = sprite->prev;
line_sprite_cnt--;
}
// this is the leftmost sprite in the text string
sprite = sprite_store;
}
line_sprite_cnt=0;
y += font->font_data->y_gap_size;
x=0;
}
}
string++;
if ( fr == FONT_ENDSTRING )
{
break;
}
cnt++;
}
if ( textman->justify_type & FONT_YC )
{
sprite_store = sprite;
y_adj = (textman->y2-textman->y1)/2;
textman->y1 -= y_adj;
textman->y2 -= y_adj;
while( sprite )
{
sprite->y.w.hi -= y_adj;
sprite = sprite->prev;
}
sprite = sprite_store;
}
}
void unspawn_text_string( Sprite *sprite_ptr )
{
WORD cnt;
POLY_GT4 *poly;
// unspawn all sprites from this sprite to all it's previous sprites
cnt=0;
while(1)
{
sprite_ptr->active = NO;
cnt++;
if ( sprite_ptr->prev == 0)
break;
sprite_ptr = sprite_ptr->prev;
}
}
void unspawn_text_group( WORD spawn_group )
{
Sprite *sprite;
WORD gr;
Text_group *tg = &text_group[spawn_group];
display_error ( "illegal call to unspawn text group" );
while ( tg-> current_spawned_string )
{
tg->current_spawned_string--;
unspawn_text_string ( tg->spawned_strings_list[ tg->current_spawned_string ] );
}
}
void adjust_text_string_pos ( Sprite *sprite, WORD xamount, WORD yamount )
{
while ( 1 )
{
sprite->x.w.hi += xamount;
sprite->y.w.hi += yamount;
if ( (sprite = sprite->prev) == 0 )
break;
}
}
#if 0
void apply_to_sprite_string( Sprite *sprite )
{
Sprite *prev;
prev = sprite;
while ( 1 )
{
prev->upd_rtn = sprite->upd_rtn;
prev->xvel1.l = sprite->xvel1.l;
prev->yvel1.l = sprite->yvel1.l;
prev->timer1 = sprite->timer1;
prev->timer2 = sprite->timer2;
prev->transp_rate = sprite->transp_rate;
prev->tint = sprite->tint;
prev->sequence_num = sprite->sequence_num;
prev->depth = sprite->depth;
prev = sprite->prev;
if ( prev == 0 )
break;
}
}
#endif
void apply_seqnum_to_sprite_string( Sprite *sprite )
{
//Sprite *prev;
WORD num;
num = sprite->sequence_num;
// printf("sprite=%x\n",sprite );
while ( 1 )
{
sprite->sequence_num = num;
sprite = sprite->prev;
if ( sprite == 0 )
break;
}
}
void get_group_sprite ( WORD group )
{
// set SPRITE to first sprite in the chosen group
sprite = text_group [ group ].spawned_strings_list[0];
}
/******************************************************************
*
* Text string manager
*
******************************************************************/
Textman_header textman_header;
void start_text_manager( WORD text_strings )
{
WORD cnt;
add_process ( update_text_manager );
textman_header.max_text_strings = text_strings;
textman_header.text_string_list =
allocate_mem ( 0, sizeof ( Textman_struct ) * text_strings );
for ( cnt=0; cnt< text_strings; cnt++ )
{
textman_header.text_string_list[ cnt ].active = 0;
textman_header.text_string_list[ cnt ].string[0] = 0;
textman_header.text_string_list[ cnt ].tail_sprite = 0;
}
textman_header.slot_cnt=0;
}
void update_text_manager()
{
Textman_struct *text;
WORD cnt = textman_header.max_text_strings;
text = textman_header.text_string_list;
while ( cnt )
{
if ( (text->active) && (text->to_die) )
{
text->active = NO;
sprite = text->tail_sprite;
sprite->sequence_num = FONT_DYING;
apply_seqnum_to_sprite_string ( sprite );
}
text->to_die = YES; // set all strings to_die
cnt--;
text++;
}
}
void set_textman_slot( WORD slot_pos, WORD num_slots )
{
tslot_poses[ slot_pos ] = textman_header.slot_cnt;
textman_header.slot_cnt += num_slots; // reserve this num slots at [slot_pos]
}
void milford_font_logic ( Sprite *sprite )
{
WORD die_speed,spd;
WORD hilite;
Textman_struct *ts = sprite->textman;
WORD dim,hilite_on;
WORD tint, cnt;
/******************
*
* Additive font
*
*******************/
if ( sprite->sequence_num == FONT_DYING )
{
//*** Once a char has been triggered to die, it should no longer be dependant on the textmanager struct that spawned it. ***
if ( sprite->die_speed == 0 )
{
// If die_speed set to 0, font disappears instantly
sprite->display = sprite->active = NO;
return;
}
else
{
sprite->brightness -= sprite->die_speed;
if ( sprite->brightness < 0 )
{
sprite->brightness = 0;
sprite->display = sprite->active = NO;
return;
}
}
}
hilite_on=NO;
sprite->group_num = ts->spawn_group;
if ( sprite->sequence_num == FONT_INIT )
{
sprite->brightness = 0;
sprite->transp_rate = 1;
sprite->sequence_num = FONT_STAGE1;
sprite->xscale = 256;
sprite->timer1 = shell->master_option_active?ts->delay_until_fade_up:0;
sprite->depth = ts->depth;
sprite->die_speed = ts->die_speed;
}
if ( sprite->sequence_num == FONT_STAGE1 )
{
//**** Character is fading up *****
if ( sprite->timer1 )
{
sprite->timer1--;
sprite->brightness=0;
}
else
{
if ( (ts->fade_up_speed == 0) || (shell->master_option_active==NO) )
sprite->brightness = ts->max_brightness;
else
sprite->brightness += ts->fade_up_speed;
if ( sprite->brightness >= ts->max_brightness )
{
sprite->brightness = ts->max_brightness;
sprite->sequence_num++;
}
}
}
if ( sprite->sequence_num == FONT_STAGE2 )
{
//**** Character is at maximum brightness ****
// if ( (flash_counter/6)&1 )
// {
hilite_on=NO;
// }
// else
// {
if ( (sprite->group_num == shell->current_item) || ts->flash_text )
{
hilite_on=YES;
}
// }
if ( hilite_on==YES )
sprite->brightness = ts->max_brightness;
else
sprite->brightness = ts->max_brightness;
}
sprite->tint.r = ( ts->text_color.r * sprite->brightness ) >> 7;
sprite->tint.g = ( ts->text_color.g * sprite->brightness ) >> 7;
sprite->tint.b = ( ts->text_color.b * sprite->brightness ) >> 7;
/** Add a bluey tint to text **/
if ( hilite_on==YES )
{
cnt=14-(flash_counter%14);
if ( cnt>7 ) cnt = 14-cnt;
sprite->tint.r -= 40+(cnt*8);
sprite->tint.g -= 40+(cnt*8);
}
}
void milford_font_logic_sub ( Sprite *sprite )
{
WORD die_speed,spd;
Textman_struct *ts = sprite->textman;
/******************
*
* Additive font
*
*******************/
// check for character deactivated
if ( sprite->sequence_num == FONT_DYING )
{
if ( sprite->textman->die_speed == 0 )
{
// If die_speed set to 0, font disappears instantly
sprite->tint.r = 221;
}
else
{
sprite->tint.g-=sprite->textman->die_speed;
sprite->tint.b-=sprite->textman->die_speed;
sprite->tint.r-=sprite->textman->die_speed;
}
if ( sprite->tint.r > 220 )
{
sprite->tint.r = sprite->tint.g = sprite->tint.b = 0;
sprite->active=NO;
}
}
// character drawn for first time
if ( sprite->sequence_num == FONT_INIT )
{
sprite->tint.r = sprite->tint.g = sprite->tint.b = 16;
sprite->transp_rate = 2;
sprite->sequence_num = FONT_STAGE1;
sprite->xscale = 256;
sprite->timer1=make_random_number(8);
sprite->depth = ts->depth;
}
//** Character fading up **
if ( sprite->sequence_num == FONT_STAGE1 )
{
sprite->tint.r += (6 * frame_update)/2;
if ( sprite->tint.r > sprite->textman->max_brightness )
{
sprite->tint.r = sprite->textman->max_brightness;
sprite->sequence_num = FONT_STAGE2;
}
}
sprite->tint.g = sprite->tint.b = sprite->tint.r;
}