forked from pete-gordon/planet-hively
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.c
2134 lines (1817 loc) · 59.1 KB
/
render.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
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <SDL/SDL.h>
#include "types.h"
#include "shapes.h"
#include "render.h"
#include "main.h"
#include "text.h"
#include "hvl_replay.h"
extern SDL_Surface *screen;
extern int clicked, clickx, clicky;
extern struct hvl_tune *tune;
extern int ctune, paused;
extern int fontheight, starmax;
extern int tbx, tby, tbw, tbh, tbbarh, tbbrd, tbaw;
extern int dragger, enddragger, wdragger, dragx, dragy;
extern int tbpressed;
int wdxo, wdyo;
int voltimer=0;
int part=0, fader, fadeadd;
int plx, ply, plr, ptrg;
int pldx, pldy, pldr;
int sunx, suny, sundy, sunty, sunr;
float fla1, fla2, bfbnc, deaddrop;
int stalktopx, stalktopy, intropart, introdoing;
float sunang=0.0f;
int nextfpet=0;
int tbon, tbclos=0;
float tbsc, tbadd;
int notxttime=0;
float tbwob;
int pl_r, pl_rd, pl_g, pl_gd;
// irsandupoghetlvy
// 0123456789012345
Sint8 llorder[] = { 0, 1, 0, 2, -1,
3, 4, 5, -1,
6, 7, -1, 1, 8, 6, 9, 10,
7, 1, 11, 2, 11, 4, 12,
7, 13, 3, 4, 11, 12, -1,
10, 0, 14, 11, 13, 15 };
int introdat[] = { 0, 17, 0, 110,
17, 7, 0, 180,
24, 13, 0, 310,
0, 0, 0, 0 };
int introappear[17], is1, is2;
float introzoom[17], introzoomsub, introzoomtarg;
#define NUMRAYS 8
struct vtx sunrays[NUMRAYS*4];
#define MAXFPETS 32
struct floating_petal fpt[MAXFPETS];
#define NUMSTARS 32
struct star stars[NUMSTARS];
#define NUMBFLYS 2
struct butterfly bflys[NUMBFLYS];
#define NUMBBFLYS 2
struct butterfly bbflys[NUMBBFLYS];
#define NUMCLOUDS 4
struct cloud clouds[NUMCLOUDS];
struct flower flwr[2];
char *tunename[] = { "sweeties",
"forsaken",
"freeside run",
"peanuts",
"galactic emeralds",
"pantsomime",
"testing123",
"incognito crust",
"bonus track" };
char *author[] = { "syphus/up rough",
"virgill/haujobb",
"syphus/up rough",
"lavaburn/hsc",
"monk",
"joey and splif",
"breed",
"m0d",
"???" };
char *authnotes[] = { "syphus says: started ages ago, finished at the last minute "
"(4.38am on 31/01/2007;), designed for clumsy "
"dancing and star-crossed ceiling-staring. "
"much love to all...",
"virgill says: nothing!",
"syphus says: gartantuan greets to the usuals, with extra "
"hearts to xeron, spotup and exobuzz for this "
"amazing software and for their tireless feature "
"implementations^:) words to d0pefish for all the "
"hardware help and fuckings to parapete for "
"killing the scene.",
"lavaburn says: a little reggae-style piece, done in an insane hurry, "
"literally a couple of hours before the deadline! this "
"would be my first tune made in hively tracker; i am also "
"learning ahx...^:) thanks to syphus for giving me the "
"poke in the ribs necessary for me to actually do "
"some work. :) and huuuge thanks to xeron, spotup and "
"exobuzz for all their hard work in bringing us this "
"brilliant tracker! cheers!^:)",
"monk says: hey all! hivelytracker is a really wonderful tool, very "
"user-friendly and wonderful for old tracker-composers "
"like me. i seriously recommend it for anyone who has "
"enjoyed protracker, odintracker, goattracker, "
"fasttrackerii or renoise. but also for people who have "
"used to sequencing^- maybe this is the tracker that will "
"let you realize the good side about tracking also! "
"greetings to all #amigascne people, klegg, parazite, "
"my mom, zetanet, thoron, siiseli, genny and others that "
"i forgot. peace and love for all!",
"joey and splif say: joey and splif graeet al friens and even haterzx!! lol "
"pease out nubes",
"breed says: long live commodore!",
"m0d says: greetings to all the #milkytracker folks and all of my "
"dear friends at #modarchive on espernet, and thanks to "
"the folks who've been proactivly bringing freshness to "
"the scene i.e the hivelytracker folks :) i've been "
"ahx-type-tracker-composing since december 2006 (the "
"12th to be exact), at this point i've created 13 ahx "
"songs, i haven't tracked since my protracker days in "
"1996 and this ahx revival (and being part of it) is "
"really kicking some arse! although i mainly use my "
"trusty old amiga to run ahx, running hivelytracker "
"under winuae was, in a fashion, a lot of fun. "
"thanks for the experience, and thanks for reading "
"this blahness :)",
"congratulations on finding the bonus track. you must "
"now listen to it non stop for 3 days, or until your "
"head explodes :-)" };
char *top_blah[] = { "www.hivelytracker.com",
"www.irishq.dk",
"www.uprough.net",
"bbcode and unicode don't work on the oneliner",
"super special greets to abyss. thanks for ahx :-)",
"this port was done by blacky stardust",
NULL };
char *othertexts[] = { "|welcome to\n\n"
"planet hively\n"
"\n"
"{this music disk contains all the entries to the "
"first official hively tracker competition. users of "
"hively tracker were invited to submit tunes to be "
"judged by the members of iris and up rough. the "
"winner was given a c64 dtv, courtesy of ggs-data!\n\n\n"
"|the results\n"
"\n"
"{1:sweeties by syphus\n"
"}(17 points)\n\n"
"{2:forsaken by virgill\n"
"}(16 points)\n\n"
"{3:freeside run by syphus\n"
"}(13 points)\n\n"
"{4:peanuts by lavaburn\n"
"}(11 points)\n\n"
"{4:galactic emeralds by monk\n"
"}(11 points)\n\n"
"{5:pantsomime by joey and splif\n"
"}(3 points)\n\n"
"{6:testing123 by breed\n"
"}(2 points)\n\n"
"{7:incognito crust by m0d\n"
"}(0 points)\n\n"
"{thanks to all entrants and congratulations to "
"syphus! hope you've enjoyed your c64 dtv for the "
"past year or so while waiting for this musicdisk!",
"|credits\n"
"\n"
"{code, design, gfx\n"
"}xeron/iris\n\n"
"{design, gfx\n"
"}spot/up rough\n\n"
"{music\n"
"}syphus/up rough\n"
"virgill/haujobb\n"
"lavaburn/hsc\n"
"monk\n"
"joey and splif\n"
"breed\n"
"m0d\n\n"
"{this port\n"
"}blacky stardust\n\n"
"{yes, i know, this musicdisk is very, very late. "
"the original plan was to make it for 030 amigas "
"but that requires an assembler optimised "
"replayer. currently the replayer "
"only exists in fairly unoptimised c code form "
"and requires a fast 68k amiga. a couple "
"of different people offered to create an optimised "
"player, but here we are well over a year later without "
"one, so i decided to code the musicdisk in "
"plain c and sdl, so that it could be ported to "
"as many platforms as possible, and here is the "
"result. i hope you like it...\n"
"}xeron/iris",
"|greets\n"
"\n"
"apathy, dcs, depth, drifters, ephidrena, fairlight, "
"haujobb, loonies, mankind, nature, perihelion, rebels, "
"rno, scarab, software failure, tbl, triad, tulou "
"and ukscene allstars!"
"\n\n\n"
"personal greets from xeron\n"
"\n"
"bonkers: hope to see you soon...\n\n"
"britelite: arse!\n\n"
"doooooom: egallib!\n\n"
"parapete: moo!\n\n"
"spot: keep on porting :-)\n\n"
"syphus: keep on hivelying :-)\n\n",
"\n\nlike these tunes? why not download the "
"tracker they were made in? its available "
"for amiga os3, os4 and aros, and it kicks "
"ass. download it from:\n\n"
"|www.hivelytracker.com\n\n"
"{where you'll also find friendly forums, "
"the latest hively news, and a very exciting "
"full stop.\n\n\n\n\n"
"do not use hively tracker if you are pregnant, "
"stupid, or suffer from tone deafness. "
"consult your doctor if symptoms persist.",
"\n\nevening phreekz! what's up?\n"
"\n"
"spot / up rough on da keys! this disk is more "
"than a little delayed. life got in the way as "
"usual... atm my apartmen is getting a facelift "
"and i am living at my dads place in the middle "
"of the sea.... me and sabina went to strandbaren "
"to get some hangover food and to check out the "
"local fishermen types, the usual crowd of fishermen "
"and drunks was hanging in the bar, the food was "
"so-so. nothing much going on here. i hope i am "
"moving back to my apartment in a week or so.. "
"hively tracker development has been slow lately, "
"xeron has a lot of other projects going on and "
"he has also moved to a house, i think. "
"the tracks submitted to the compo was of quite "
"high quality, that's nice, my personal favourite "
"was the track by virgill. it has a genuine oldskool "
"touch to it that i like. syphus won the competition, "
"congrats not only for winning, but also for making "
"it to the top crew, welcome to up rough man!\n"
"\n"
"so what's going on in up rough then?...\n"
"\n"
"we are 10 years old! the anniversary party was a "
"blast! we packed the place with people, and they "
"all seemed to enjoy it a lot! there's lots of "
"videos and photos from the party to be found "
"on www.uprough.net. we recorded all dj sets and "
"live acts from the party too, there's many hours "
"of music waiting to be smacked into your ipods! "
"some of the compusphere organizers was present "
"at the party too, and they decided to dedicate "
"this years edition of compusphere to up rough! "
"thanx guys! we will try to deliver something fresh!\n"
"\n"
"about this disk then.. the aim was "
"for it to be multiplatform and we'll "
"do our best to get it out on as many "
"platforms as possible!\n"
"\n"
"gotta send this text to xeron now, "
"so see ya all next time!\n"
"\n"
"dipswitch on the keys. i am forced to write this "
"text else i will be toe'd by spot. greets to all "
"people who make the scene a warm place in these "
"cold days, and see you around the bonfire on "
"breakpoint!",
"|darkhawk speaks!\n"
"\n"
"{hey there sceners and welcome to "
"a new iris release, this time in "
"co-operation with up rough. we've "
"been quite silent for a while and "
"had some changes in the group, but "
"as you can see, we're not dead. "
"this production has been released "
"on several platforms, continuing "
"the small trend the last eurochart "
"started of multiplatform release. "
"in the future, you will see more "
"releases from iris on non 68k platforms, "
"demos mostly, but this doesn't mean we "
"will forget the classic amiga. perhaps "
"you will see a release from us at "
"breakpoint 2008 and perhaps our next "
"release will first see the light of day "
"later this year, but we're still here, "
"both giving to the scene and watching it.\n\n"
"keep the scene in your heart and keep "
"releasing your work, be it for amiga "
"or pc - the world needs the little "
"niche of computer art and creativity "
"here. :)",
"|some ramblings\nfrom syphus\n"
"\n"
"{well, we waited a year for this musicdisk to "
"be ready and once it finally got finished, i "
"held it up for another few weeks by being a lazy "
"bastard about writing this text... and now i don't "
"even know what to say. hivelytracker is fucking "
"amazing, first of all. since its release in 2006/7, "
"xeron has gone from being quiet, mild-mannered amiga genius "
"to the face that men and women now shut their eyes "
"and imagine while having loud sex.\n\n"
"if you're checking out this disk, you probably already "
"know why hivelytracker is so amazing - and not only "
"because of its sixteen channels of ahx-spec, "
"sid-reminiscent chipsynth sound, nor because of its "
"extra effects column, amazing ringmod capabilities, "
"tabbed module loading, the ability to load and save ahx "
"files or the 256-increment, per-instrument/per-channel "
"stereo positioning feature. no, it's not only for these "
"reasons: it also has to do with buzz/bitfellas tirelessly "
"porting it to 68k amiga and aros from os4 and with "
"spot/up rough making it look so fucking brill with a "
"selection of interface skins.\n\n"
"so while these towering bastions of manhood "
"doth bestride this narrow world like code-colossi, "
"we peons do our best to use their gift for good. "
"it's been loads of fun writing hvl tunes for the last "
"year, and it was great fun to take part in the competition "
"that led to this chipdisk. some great stuff's appeared "
"for hively, from amiga oldschoolers and tracking newcomers "
"alike. anyway, i don't need to ramble on about that, "
"since you can check that shit out for yourself.\n\n"
"spot and xeron need extra creds for this lovely, "
"multi-platform sdl musicdisk (which was well worth "
"waiting for) and of course shouts and smiles have to "
"fly to everyone who contributed. oh, and to ggs data ;)\n\n"
"p.s. - lavaburn: get off that fucking xbox 360 and "
"finish some hively tunes :d",
"|so this is it\n"
"\n"
"it is finally done\n"
"\n"
"after many delays and let downs\n"
"\n"
"we can rest.\n"
"\n"
"\n"
"until the next time..." };
char nptxt[512];
char antxt[512];
char *antxtptr = NULL;
extern int sw, sh;
int rs;
int tbtxtnum=0;
int midx, midy, se, bsw, sxe, sye, bss, bse;
int qsh;
int isqrt[32768];
int gcount;
Uint8 *layers = NULL;
Uint8 *click;
PIXEL *bg = NULL;
PIXEL skytxtpal[20];
PIXEL logopal[16];
#define PAL_ENTRIES 55
Uint8 spal[] = { 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0xff, 0xff, 0x00,
0x40, 0xff, 0x40,
0xff, 0xff, 0xff,
0xe0, 0xe0, 0xe0,
0xd0, 0xd0, 0xd0,
0xc0, 0xc0, 0xc0,
0xb0, 0xb0, 0xb0,
0xa0, 0xa0, 0xa0,
0x90, 0x90, 0x90,
0x80, 0x80, 0x80,
0x70, 0x70, 0x70,
0x60, 0x60, 0x60,
0x50, 0x50, 0x50,
0x40, 0x40, 0x40,
0x30, 0x30, 0x30,
0x20, 0x20, 0x20,
0x10, 0x10, 0x10,
0x00, 0x00, 0x00,
0x40, 0xff, 0xff,
0xff, 0x20, 0x20,
0xee, 0xbb, 0x00, // 22
0xff, 0xff, 0xbb, // 23
0xa0, 0x00, 0xa0, // 24
0x01, 0x06, 0x08, // 25
0x01, 0x06, 0x08,
0x02, 0x0c, 0x0f,
0x03, 0x12, 0x17,
0x03, 0x18, 0x1f,
0x04, 0x1e, 0x26, // 30
0x05, 0x24, 0x2e,
0x06, 0x2a, 0x36,
0x07, 0x30, 0x3d,
0x08, 0x36, 0x45,
0x09, 0x3c, 0x4d, // 35
0x0a, 0x42, 0x54,
0x0a, 0x48, 0x5c,
0x0b, 0x4e, 0x64,
0x0c, 0x54, 0x6b,
0x0d, 0x5a, 0x73, // 40
0x0e, 0x5f, 0x7b,
0x0f, 0x65, 0x82,
0x10, 0x6b, 0x8a,
0x10, 0x71, 0x92,
0x11, 0x77, 0x99, // 45
0x12, 0x7d, 0xa1,
0x13, 0x83, 0xa9,
0x14, 0x89, 0xb0,
0x15, 0x8f, 0xb8,
0x16, 0x95, 0xc0, // 50
0x17, 0x9b, 0xc7,
0x17, 0xa1, 0xcf,
0x18, 0xa7, 0xd7,
0x19, 0xad, 0xde,
0x1a, 0xb3, 0xe6 };
Uint8 *skyrgb;
PIXEL pal[PAL_ENTRIES];
static inline int edge_check1( Uint8 c, Uint8 *lb, Uint8 *pm, Uint8 *pb )
{
return (( *lb != c )||( *pm != c )||( *pb != c ));
}
static inline int edge_check2( Uint8 *lu, Uint8 c, Uint8 *lb, Uint8 *pu, Uint8 *pm, Uint8 *pb )
{
return (( *lb != c )||( *lu != c )||( *pu != c )||( *pm != c )||( *pb != c ));
}
static inline int edge_check3( Uint8 *lm, Uint8 *lb, Uint8 *pm, Uint8 *pb )
{
Uint8 c;
c = *lm;
if(( *lb != c )||( *pm != c )||( *pb != c )) return 1;
if(( *++lm != c )||( *++lb != c )) return 1;
return 0;
}
static inline int edge_check4( Uint8 *lu, Uint8 *lm, Uint8 *lb, Uint8 *pu, Uint8 *pm, Uint8 *pb )
{
Uint8 c;
c = *lm;
if(( *lb != c )||( *lm != c )||( *pu != c )||( *pm != c )||( *pb != c )) return 1;
if(( *++lu != c )||( *++lm != c )||( *++lb != c )) return 1;
return 0;
}
void render_edge_zone( struct minmax *m )
{
int x, y, xe, ty, ye;
PIXEL *p;
Uint8 *lu, *lm, *lb;
ty = m->miny;
if( ty == 0 )
{
lm = layers;
lb = &lm[sw];
p = (PIXEL *)screen->pixels;
x = m->minx;
if( x == 0 )
{
if( edge_check3( lm, lb, lm, lb ) )
*p = 0;
x++;
}
for( xe=x-1; x<=m->maxx; x++, xe++ )
if( edge_check3( &lm[x], &lb[x], &lm[xe], &lb[xe] ) )
p[x] = 0;
ty++;
}
lm = &layers[ty*sw];
lu = &lm[-sw];
lb = &lm[sw];
p = &((PIXEL *)screen->pixels)[ty*rs];
ye = m->maxy+1;
if( ye >= sye )
{
m->maxy = sye;
ye = sye-1;
}
for( y=ty; y<=ye; y++ )
{
xe = m->minx-1;
for( x=m->minx; x<=m->maxx; x++, xe++ )
{
if( edge_check4( &lu[x], &lm[x], &lb[x], &lu[xe], &lm[xe], &lb[xe] ) )
p[x] = 0;
}
lm += sw;
lu += sw;
lb += sw;
p += rs;
}
if( y > m->maxy ) return;
x = m->minx;
if( x == 0 )
{
if( edge_check3( &lm[x], &lu[x], &lm[x], &lu[x] ) )
p[x] = 0;
x++;
}
for( xe=x-1; x<=m->maxx; x++, xe++ )
if( edge_check3( &lm[x], &lu[x], &lm[xe], &lu[xe] ) )
p[x] = 0;
}
void render_edges( void )
{
int x, y, xe, yo;
PIXEL *p;
Uint8 *lu, *lm, *lb, *pu, *pm, *pb;
lu = layers;
lm = layers;
lb = &layers[sw];
pu = lu-1;
pm = lm;
pb = lb;
p = (PIXEL *)screen->pixels;
if( edge_check3( lm++, lb++, pm, pb ) )
*p = 0;
for( x=1; x<sxe; x++, lm++, lb++, pm++, pb++ )
if( edge_check3( lm, lb, pm, pb ) )
p[x] = 0;
if( edge_check1( *(lm++), lb++, pm++, pb++ ) )
p[x] = 0;
xe = rs+sxe;
for( y=1, yo=rs; y<sye; y++, yo+=rs, xe+=rs )
{
if( edge_check4( lu, lm, lb, lu, lm, lb ) )
p[yo] = 0;
lu++; lm++; lb++; pu++; pm++; pb++;
for( x=yo+1; x<xe; x++, lu++, lm++, lb++, pu++, pm++, pb++ )
if( edge_check4( lu, lm, lb, pu, pm, pb ) )
p[x] = 0;
if( edge_check2( lu++, *(lm++), lb++, pu++, pm++, pb++ ) )
p[x] = 0;
}
if( edge_check3( lm, lu, lm, lu ) )
p[yo] = 0;
lm++; lb++; pm++; pu++;
for( x=1; x<sxe; x++, lm++, lu++, pm++, pu++ )
if( edge_check3( lm, lu, pm, pu ) )
p[x+yo] = 0;
if( edge_check1( *lm, lu, pm, pu ) )
p[x+yo] = 0;
}
void create_bg( void )
{
int r, g, b, x, yt, yb, ye;
int rd, gd, bd, m;
PIXEL col;
r = g = b = 0;
rd = (85<<8) / midy;
gd = ( 8<<8) / midy;
bd = (65<<8) / midy;
for( yt=0, yb=(sh-1); yt<midy; yt++, yb-- )
{
skyrgb[yt*3 ] = (r>>8)+(rand()&3);
skyrgb[yt*3+1] = (g>>8)+(rand()&3);
skyrgb[yt*3+2] = (b>>8)+(rand()&3);
skyrgb[yb*3 ] = (r>>8)+(rand()&3);
skyrgb[yb*3+1] = (g>>8)+(rand()&3);
skyrgb[yb*3+2] = (b>>8)+(rand()&3);
r += rd; g += gd; b += bd;
}
ye = rs*sh;
yt = 0;
m = rs-sw;
for( yb=0; yb<sh; yb++ )
{
col = SDL_MapRGB( screen->format, skyrgb[yb*3], skyrgb[yb*3+1], skyrgb[yb*3+2] );
for( x=0; x<sw; x++ )
bg[yt++] = col;
yt += m;
}
}
void sunrise( int amount )
{
int r, g, b, ia;
int fr, fg, fb;
int rd, gd, bd;
int yt, yb, x, m;
PIXEL col;
r = 45<<8;
g = 225<<8;
b = 245<<8;
rd = ((255<<8)-r) / sh;
gd = ((255<<8)-g) / sh;
bd = ((255<<8)-b) / sh;
ia = 256-amount;
yt = 0;
m = rs-sw;
for( yb=0; yb<sh; yb++ )
{
fr = (skyrgb[yb*3 ]*ia)+(r>>8)*amount;
fg = (skyrgb[yb*3+1]*ia)+(g>>8)*amount;
fb = (skyrgb[yb*3+2]*ia)+(b>>8)*amount;
r += rd; g += gd; b += bd;
col = SDL_MapRGB( screen->format, fr>>8, fg>>8, fb>>8 );
for( x=0; x<sw; x++ )
bg[yt++] = col;
yt += m;
}
}
void sunset( int amount )
{
int r, g, b, ia;
int fr, fg, fb;
int rd, gd, bd;
int yt, yb, x, m;
PIXEL col;
for( r=0; r<PAL_ENTRIES; r++ )
pal[r] = SDL_MapRGB( screen->format, (spal[r*3]*amount)>>8, (spal[r*3+1]*amount)>>8, (spal[r*3+2]*amount)>>8 );
r = 45<<8;
g = 225<<8;
b = 245<<8;
rd = ((255<<8)-r) / sh;
gd = ((255<<8)-g) / sh;
bd = ((255<<8)-b) / sh;
ia = 256-amount;
yt = 0;
m = rs-sw;
for( yb=0; yb<sh; yb++ )
{
fr = (r>>8)*amount;
fg = (g>>8)*amount;
fb = (b>>8)*amount;
r += rd; g += gd; b += bd;
col = SDL_MapRGB( screen->format, fr>>8, fg>>8, fb>>8 );
for( x=0; x<sw; x++ )
bg[yt++] = col;
yt += m;
}
}
void show_now_playing( int immediate )
{
if( sw >= 320 )
{
sprintf( nptxt, "now playing: \"%s\" by %s",
tunename[ctune],
author[ctune] );
fade_in( nptxt, immediate );
antxtptr = authnotes[ctune];
} else {
sprintf( nptxt, "now playing: \"%s\"", tunename[ctune] );
sprintf( &nptxt[256], "by %s", author[ctune] );
fade_in( nptxt, immediate );
antxtptr = &nptxt[256];
return;
}
}
void reset_bbfly( int i )
{
if( rand()&1 )
{
bbflys[i].sx = ((rand()%sw)-sw)<<8;
bbflys[i].tsx = (rand()%sw)+sw;
bbflys[i].ang = 3.14159265/6.0f;
} else {
bbflys[i].sx = ((rand()%sw)+sw)<<8;
bbflys[i].tsx = (rand()%sw)-sw;
bbflys[i].ang = -3.14159265f/6.0f;
}
bbflys[i].sy = ((rand()%qsh)+midy)<<8;
bbflys[i].tsy = (rand()%qsh)+midy;
bbflys[i].dsx = ((bbflys[i].tsx<<8)-bbflys[i].sx) / (40*TARGET_FPS);
bbflys[i].dsy = ((bbflys[i].tsy<<8)-bbflys[i].sy) / (40*TARGET_FPS);
bbflys[i].dead = 0;
}
void reset_bfly( int i )
{
if( rand()&1 )
{
bflys[i].sx = ((rand()%sw)-sw)<<8;
bflys[i].tsx = (rand()%sw)+sw;
bflys[i].ang = 3.14159265/6.0f;
} else {
bflys[i].sx = ((rand()%sw)+sw)<<8;
bflys[i].tsx = (rand()%sw)-sw;
bflys[i].ang = -3.14159265f/6.0f;
}
bflys[i].sy = ((rand()%midy)+qsh)<<8;
bflys[i].tsy = (rand()%midy)+qsh;
bflys[i].dsx = ((bflys[i].tsx<<8)-bflys[i].sx) / (20*TARGET_FPS);
bflys[i].dsy = ((bflys[i].tsy<<8)-bflys[i].sy) / (20*TARGET_FPS);
bflys[i].dead = 0;
}
void reset_cloud( int i )
{
clouds[i].ang = (3.14159265f/4.0f)+(((float)(rand()%20))/40.0f);
clouds[i].r = (plr>>8) + qsh + (rand()%qsh);
clouds[i].speed = ((float)((rand()%20)+10))/(TARGET_FPS*210.0f);
}
// Shitty shitty bubble sort
// but for 4 items, who cares?
void sort_clouds_by_speed( void )
{
struct cloud c;
int sorted, i;
do
{
sorted = 1;
for( i=0; i<(NUMCLOUDS-1); i++ )
{
if( clouds[i].speed > clouds[i+1].speed )
{
c = clouds[i];
clouds[i] = clouds[i+1];
clouds[i+1] = c;
sorted = 0;
}
}
} while( sorted == 0 );
}
void start_part( int n )
{
int i, j;
float ang, anga, fi, fj;
switch( n )
{
case PART_STARFIELD:
intropart = 0;
introdoing = 0;
if( sh < 400 )
{
is1 = 10;
is2 = 17;
} else {
is1 = 20;
is2 = 34;
}
for( i=0, j=0; i<17; i++ ) j += llorder[i]<1?is1:is2;
introdat[2] = midx - j/2 + is1;
for( i=17, j=0; i<24; i++ ) j += llorder[i]<1?is1:is2;
introdat[6] = midx - j/2 + is1;
for( i=24, j=0; i<37; i++ ) j += llorder[i]<1?is1:is2;
introdat[10] = midx - j/2 + is1;
for( i=0; i<17; i++ )
{
introappear[i] = -(i+1) * TARGET_FPS / 15;
introzoom[i] = sh<400?4.0f:8.0f;
}
introzoomsub = (sh<400?10.0f:20.0f) / TARGET_FPS;
introzoomtarg = sh<400?1.0f:2.0f;
for( i=0; i<NUMSTARS; i++ )
{
stars[i].sx = (rand()%sw)<<8;
stars[i].sy = rand()%sh;
stars[i].ang = ((float)(rand()&255))/160.0f;
stars[i].speed = (((rand()%4)+1)<<9);
stars[i].scale = ((float)stars[i].speed)/3000.0f;
stars[i].speed = (stars[i].speed*sw)/(TARGET_FPS*16);
}
break;
case PART_PLANET_IN:
ptrg = midx;
plr = (sw/32)<<8;
pldr = (((sw/6)<<8)-plr) / (TARGET_FPS*2);
plx = (sw<<8)+plr*3;
ply = midy<<8;
pldx = ((ptrg<<8)-plx) / (TARGET_FPS*2);
pldy = 0;
break;
case PART_PLANET_ZOOM:
// Ugly bodge
if( (sh*5/4) == sw )
{
ptrg = sh*2+(midy*2)/3;
} else if( (sh*16/10) == sw ) {
ptrg = sh*2+(midy*4)/3;
} else if( (sh*16/9) == sw ) {
ptrg = sh*3;
} else {
ptrg = sh*2+midy;
}
pldx = ((((sw*7)/10)<<8)-plx) / (TARGET_FPS*2);
pldy = ((ptrg<<8)-ply) / (TARGET_FPS*2);
pldr = (( ((sw*4)/3) <<8)-plr) / (TARGET_FPS*2);
break;
case PART_STARS_OUT:
break;
case PART_SUNRISE:
gcount = 0;
sunr = sw/14;
sunx = sw/7;
suny = (sh+sunr)<<8;
sunty = (sh/6)+fontheight;
sundy = ((sunty<<8)-suny) / 128;
pl_r = 0;
pl_rd = (0x20<<8)/128;
pl_g = 0;
pl_gd = (0xc0<<8)/128;
ang = 0.0f;
anga = 3.14159265f/NUMRAYS;
fi = ((float)sunr)*0.9f;
fj = fi * 1.7f;
for( i=0; i<NUMRAYS; i++ )
{
sunrays[i*4 ].x = cos( ang )*fj;
sunrays[i*4 ].y = sin( ang )*fj;
sunrays[i*4+1].x = cos( ang+anga )*fj;
sunrays[i*4+1].y = sin( ang+anga )*fj;
sunrays[i*4+2].x = cos( ang+anga )*fi;
sunrays[i*4+2].y = sin( ang+anga )*fi;
sunrays[i*4+3].x = cos( ang )*fi;
sunrays[i*4+3].y = sin( ang )*fi;
ang += anga*2.0f;
}
break;
case PART_FLOWERGROW:
flwr[0].sx = (sw*8)/10;
flwr[0].sy = (sh*8)/10;
flwr[0].stkp = -20;
flwr[0].r = 0;
flwr[0].tr = sw/15;
flwr[0].dr = (flwr[0].tr<<8)/(TARGET_FPS*2/3);
flwr[0].sc = 0.0f;
flwr[1].sx = (sw*5)/10;
flwr[1].sy = (sh*13)/14;
flwr[1].stkp = 0;
flwr[1].r = 0;
flwr[1].tr = sw/19;
flwr[1].dr = (flwr[1].tr<<8)/(TARGET_FPS*2/3);
flwr[1].sc = 0.0f;
for( i=0; i<8; i++ )
{
flwr[0].p[i].attached = 1;
flwr[0].p[i].wobble = 0;
flwr[0].p[i].cangrow = 1;
flwr[0].p[i].clk = ACTION_TUNEPETAL_1+i;
flwr[0].p[i].wba = 3.14159265f;
flwr[0].p[i].wbs = 0.8f;
flwr[0].p[i].scx = -i;
flwr[0].p[i].scy = -i;
flwr[1].p[i].attached = 1;
flwr[1].p[i].wobble = 0;
flwr[1].p[i].cangrow = 1;
flwr[1].p[i].clk = ACTION_TEXTPETAL_1+i;
flwr[1].p[i].wba = 3.14159265f;
flwr[1].p[i].wbs = 0.8f;
flwr[1].p[i].scx = -i;
flwr[1].p[i].scy = -i;
}
break;
case PART_MAIN:
tbwob = 0.0f;
clicked = 0;
#ifndef __NO_MOUSE__
SDL_ShowCursor( SDL_ENABLE );
#endif
if( sw >= 320 )
fade_in( "click the petals! then the sun when you're done!", 1 );
else
fade_in( "click the petals! the sun quits", 1 );
show_now_playing( 0 );
fader = 0;
fadeadd = TARGET_FPS/45;
tbx = midx - tbw;
if( tbx < 0 ) tbx = sw/16;
tby = sh/8;
tbon = 0;
tbclos = 0;
tbadd = 1.0f / TARGET_FPS;
bfbnc = (float)sh/48;
deaddrop = (midy/TARGET_FPS)<<8;
for( i=0; i<NUMBBFLYS; i++ )
{
reset_bbfly( i );
bbflys[i].wscale = 1.0f;
bbflys[i].wscd = -2.0f / TARGET_FPS;
}
for( i=0; i<NUMBFLYS; i++ )
{