-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
2281 lines (2247 loc) · 72.3 KB
/
main.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
#define WIN32_LEAN_AND_MEAN
#define DEBUG 0 // debug flag //#if defined(_DEBUG)
#define SHADER 1 // shader flag
#define MUSIC DEBUG?0:1 // music flag
#define PI 3.1415926535f// pi
#define PID PI/180.0f // pi ratio
#define CR 1.0f/256.0f // color ratio
#define TIME 1.92f
#include <windows.h>
#include <stdio.h>
#include <math.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include "glsl.h"
#include "resource.h"
#include "timer.h"
#if MUSIC
#include "v2mplayer.h"
#include "libv2.h"
#include "music.h"
#endif
bool done=false;
Timer *timer;
float timer_global=0;
float timer_global_previous=0;
float timer_fps=0;
float timer_fps_total=0;
float timer_fps_average=0;
float timer_fps_min=32768;
float timer_fps_max=0;
float timer_music=0;
float timer_buffer=0;
int frame_counter=0;
//char *param=GetCommandLine();
#if MUSIC
static V2MPlayer player;
#endif
bool music_play=false; // flag
int music_order=0; // pseudo protracker pattern order
int music_line=0; // pseudo protracker pattern line
int music_line_buffer=0;// keep previous variable
int screen_n=0; // screen current number
const int screen_max=21;// number of screen
int screen_i=(MUSIC==1)?0:20;// screen counter
int screen_start[]= {0,16,18,19, 1,7,12,2,3,8,10,13,14,4,15,6,20, 9,5,17,21}; // screen start
int screen_length[]={0, 1, 1, 1,24,4, 4,8,8,8, 4, 4, 2,8, 8,4, 4,16,7, 2, 8}; // screen length
float screen_timer[screen_max]; // screen timer
HDC hDC=NULL; // GDI device context
HGLRC hRC=NULL; // rendering context
HWND hWnd=NULL; // window handle
HINSTANCE hInstance; // instance application
int keys[256]; // keyboard array
int active=true; // window active flag
bool fullscreen=DEBUG?false:true; // fullscreen flag
bool pause=false; // pause flag
float nearplane=0.1f; // nearplane
float farplane=1000.0f; // farplane
bool polygon=true; // polygon mode
int polygon_fillmode=GL_FILL;// fill mode
int ratio_2d=2; // 2d ratio
/* window variable */
int base_w=800; // base width
int base_h=450; // base height
int window_w=base_w; // width
int window_h=base_h; // height
int screen_w; // screen width
int screen_h; // screen height
int window_color=32; // color depth
float screen_r; // color red
float screen_g; // color green
float screen_b; // color blue
/* object variable */
float main_angle; // main angle
float part_angle; // part angle
float fx_angle; // current angle
/* liner variable */
bool liner_flag=false; // flag
bool liner_write=true; // write flag
int car; // ascii code
int car_cursor=126; // cursor ascii code
int liner_length; // text length
int liner_line_n; // line number
int liner_line; // line increment
int liner_max; // line max length
int liner_i; // char increment
int liner_count; // counter
float liner_w; // width
float liner_h; // height
float liner_r; // color red
float liner_g; // color green
float liner_b; // color blue
float liner_x; // position x
float liner_y; // position y
float liner_z; // position z
float liner_p_x; // relative x
float liner_p_y; // relative y
float liner_p_z; // relative z
float liner_a_x; // angle x
float liner_a_y; // angle y
float liner_a_z; // angle z
float liner_angle; // angle
float liner_vtx[]={1.0f,-1.0f,1.0f,1.0f,-1.0f,1.0f,-1.0f,-1.0f}; //,-1.0f,-1.0f,-1.0f,1.0f,1.0f,1.0f,1.0f,-1.0f};
int greetings_i; // greetings value
int greetings_n=16; // greetings number
/* text variable */
char *name="Razor 1911 - The Scene Is Dead";
char const *txt_dos[]={
"\rCopyright \x05e\x031\x039\x038\x037 Commodore-Amiga, Inc.\rAll rights reserved.\rRelease 1.3\r@",
"\r\r .::::: .::::::::::. .::::: .:::::\r . . .. ............:::::.:::::..:::::...:::::...:::::........... .. . .\r _ __ ___________ __________ __________ __________ __________\r \\\\_______ ¼\\_______ ¼\\_______ ¼\\__ _ ¼\\_______ ¼\\_ __ _\r / _ ___/ _ / ______/ / / _ ___//\r / / \\/ / / / / / / / \\\r / / / / / / / / / / /\r /_____/ /_____/ /_____ /_____ /_____/ /\r /_____/ /_____/ /_____/ /_____/ /_____/kRm\r . . .. ......................................................... .. . .\r ::::: ::::: ::::: ::::: :::::\r ::::: `::::::::::: ::::: :::::\r ::::: ::::: ::::: :::::\r ::::: :::::::::::' ::::: :::::\r\r gives you \"THE SCENE IS DEAD\" A Non-AGA demo!\r Release Date 8th of April 2012\r\r If you only have 1.0 MB memory then turn off all external drives.\r If you have OS 2.x and only 1.0 MB the demo may not run!\r@",
"\r\r /\\______ /\\______ ____/\\______ __\r \\____ \\/ \\__ \\/ _ \\____ \\ __/ \\____\r / _/ _/ \\/ / / / _/ _// / / / / /\r / \\ \\ /\\ / /\\ / / \\ \\/ /\\ / / /\r \\__/\\ \\/RTX______\\___/\\__/\\ \\/ / /_/_/\r =====\\___)===\\__)============\\___)=\\/=======\r Razor 1911 - Sharpening the blade since 1985\r\r@"};
//"\r\r _____\r _ _ ___________ _\\_ /_ _______ _____ _\r .\\\\\\Y _X___ \x07fY _/ \x07fY __ \x07fY _///.\r _ ___ | | \\| | |/ | |/ | | ___ _\r \\Y /_ _ | | l | l | l | | _ _\\ Y/\r l_/// (//l___l_______l_______l_______l___|\\\\) \\\\\\_|\r \x07f . \x07f _\x07f \x07f \x07f _,\x07f! \x07f\r ! ___\\_ _____ \\__\r _____ \\__ \\_ \\__ \\_ ___/_\r \\__ \\_ \x07f/ /_ sK \x07f/ /\\\\__ \\_\r \x07f/ /\\ / _ \\ / / \\\x07f/ /\\\r / / / / /\\ / / // / \\\r / / / / / \\ / / // / /\r / / \\__ / // / // / /\r / / / / / // / // / /\r /_ /__ / /_ /__ //_ /__ //_ /__ /\r /____/\\ \\/____/\\ \\/____/\\ \\/____/\\\r \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\\r \\____\\/ \\____\\/ \\____\\/ \\____\\/\r \x07f \x07f \x07f \x07f\r : ·\r _ __ | r a z o r 1 9 1 1 | __ _\r \\Y \\ _ | | _ / Y/\r |___\\\\\\. l_______________________________| .///___|\r \x07f \x07f \x07f\r@"};
char const *txt_skull={"\r we are back@"};
char const *txt_title={"\r the\r scene\r is dead@"};
char const *txt_razor={"\r released\r by\r\r** **\r * * \r\r at\r revision\r 2012@"};
char const *txt_credits[]={"\rprogram\r rez @","\r music \rdubmood@"};
char const *txt_greetings[]={"\r greetings to elites \r fuckings to lamers!@","\r 3ln@","\r accession@","\r andromeda@","\r ate bit@","\r bomb@","\r ctrl-alt-test@","\r d-bug@","\r equinox@","\r f4cg@","\r frequency@","\r live!@","\r paradox@","\r photonstorm@","\r scenesat@","\r trsi@","\r vision factory@"};
char const *txt_end={"\r\r the scene is dead@"};
char const *txt="";
/* fs_quad variable */
float fs_quad_vtx[]={-1.0f,1.0f,0,1.0f,-1.0f,-1.0f,0,1.0f,1.0f,-1.0f,0,1.0f,1.0f,1.0f,0,1.0f};
float fs_quad_tex[]={0,1.0f,0,0,1.0f,0,1.0f,1.0f};
/* flash variable */
bool flash_flag=false; // flag
float flash_angle=0; // angle
float flash_value=0; // value
float flash_speed; // speed
/* fade variable */
bool fade_flag=false; // flag
float fade_angle=0; // angle
float fade_value=0; // value
float fade_speed; // speed
/* debug variable */
bool debug_flag=DEBUG; // flag
int debug_x; // position x
int debug_y; // position y
int debug_w; // width
int debug_h; // height
int debug_vtx[8]; // vertex array
/* sync1 variable */
bool sync1_flag=false; // flag
float sync1_angle=0; // angle
float sync1_value=0; // value
float sync1_speed; // speed
/* sync2 variable */
bool sync2_flag=false; // flag
float sync2_angle=0; // angle
float sync2_value=0; // value
float sync2_speed; // speed
/* beat variable */
bool beat_flag=false; // flag
float beat_angle=0; // angle
float beat_value=0; // value
float beat_speed; // speed
/* corner variable */
const int corner_n=10; // polygon number
int corner_w=24; // radius
int corner_vtx[corner_n*6];// vertex array
/* dos variable */
bool dos_flag=false; // flag
int dos_w; // width
int dos_h; // height
int dos_m; // margin
int dos_tab; // text tabulation
float dos_r; // red value
float dos_g; // green value
float dos_b; // blue value
int dos_vtx[8]; // vertex array
int shell_vtx[8]; // vertex array
float shell_tex[]={1.0f,0.96875f,1.0f,1.0f,0.75f,1.0f,0.75f,0.96875f};
bool cursor_flag=false; // flag
/* decrunch variable */
bool decrunch_flag=false;// flag
int decrunch_h=0; // height
int decrunch_y=0; // top
int decrunch_split=0; // bar split random
int decrunch_split_w; // bar split w
int decrunch_color=64; // base color
/* cube variable */
float cube_vtx[144]; // vertex array
/* logo variable */
bool logo_flag=false; // flag
int logo_x; // position x
int logo_y; // position y
int logo_w; // width
int logo_h; // height
int logo_vtx[16]; // vertex array
float logo_tex[]={0.1015625f,0,0,0,0,0.1796875f,0.1015625f,0.1796875f,0,0,0.1015625f,0,0.1015625f,0.1796875f,0,0.1796875f};
/* razor variable */
bool razor_flag=false; // flag
int razor_x; // position x
int razor_y; // position y
int razor_w; // width
int razor_h; // height
float razor_alpha; // color alpha
int razor_vtx[8]; // vertex array
float razor_tex[]={1.0f,0.13671875f,0.5859375f,0.13671875f,0.5859375f,0,1.0f,0};
/* bar variable */
const int bar_n=8; // bar number
int bar_i=-1; // counter
int bar_x; // position x
int bar_y; // position y
int bar_w; // width
int bar_h; // height
int bar_vtx[bar_n]; // vertex array
float bar_angle[bar_n]; // angle
float bar_speed[bar_n]; // speed
/* skull variable */
bool skull_flag=false; // flag
int skull_x; // position x
int skull_y; // position y
int skull_w; // width
int skull_h; // height
int skull_vtx[8]; // vertex array
float skull_tex[]={0.046875f,1.0f,0,1.0f,0,0.953125f,0.046875f,0.953125f};
float skull_r=0.75f; // color red
float skull_g=0.5f; // color green
float skull_b=0.0f; // color blue
/* triforce variable */
bool triforce_flag=false;// flag
float triforce_vtx[36]; // vertex array
int triforce_x; // position x
int triforce_y; // position y
/* common variable */
int i,j,k,l;
float x,y,z,w,h;
float r,g,b,c;
float value,angle,radius,scale,speed;
int tex_map;
/* shader variable */
bool shader_flag=SHADER?true:false;
bool shader_blur_flag=SHADER?true:false;
bool shader_effect_flag=SHADER?true:false;
bool shader_glow_flag=true;
bool shader_radial_flag=false;
bool shader_copper_flag=SHADER?true:false;
float copper_n; // copper amount
float copper_alpha; // color
float copper_speed; // scroll speed
float copper_limit; // y limit
bool shader_wave_flag=false;
bool shader_render_flag=false;
bool shader_cloud_flag=false;
bool shader_tunnel_flag=false;
bool shader_tube_flag=false;
bool shader_disc_flag=false;
int disc_type=0;
bool shader_title_flag=false;
bool shader_tower_flag=false;
bool shader_sphere_flag=false;
bool shader_dark_flag=false;
bool shader_land_flag=false;
bool shader_postfx_flag=SHADER?true:false;
int glow_fbo_size=3; // glow fbo size
int glow_color; // 0=color/1=alpha
float glow_smoothstep; // glow smoothstep value
float glow_mix_ratio1; // glow mixing ratio
float glow_mix_ratio2; // source mixing ratio
float radial_value1;
float radial_value2;
float radial_color; // color
bool postfx_scanline=true;
float postfx_deform; // deformation ratio
#if SHADER
GLSL glsl;
Shader* shader_simple;
Shader* shader_blur_h;
Shader* shader_blur_v;
Shader* shader_glow;
Shader* shader_radial;
Shader* shader_copper;
Shader* shader_wave;
Shader* shader_render;
Shader* shader_cloud;
Shader* shader_tunnel;
Shader* shader_tube;
Shader* shader_disc;
Shader* shader_title;
Shader* shader_tower;
Shader* shader_sphere;
Shader* shader_dark;
Shader* shader_land;
Shader* shader_postfx;
// shader variables
VARID shader_simple_texture;
VARID shader_blur_h_texture;
VARID shader_blur_h_screen_w;
VARID shader_blur_h_screen_h;
VARID shader_blur_h_time;
VARID shader_blur_h_value;
VARID shader_blur_v_texture;
VARID shader_blur_v_screen_w;
VARID shader_blur_v_screen_h;
VARID shader_blur_v_time;
VARID shader_blur_v_value;
VARID shader_glow_texture;
VARID shader_glow_texture_prv;
VARID shader_glow_screen_w;
VARID shader_glow_screen_h;
VARID shader_glow_time;
VARID shader_glow_step;
VARID shader_glow_value1;
VARID shader_glow_value2;
VARID shader_radial_texture;
VARID shader_radial_screen_w;
VARID shader_radial_screen_h;
VARID shader_radial_time;
VARID shader_radial_value1;
VARID shader_radial_value2;
VARID shader_radial_color;
VARID shader_copper_texture;
VARID shader_copper_screen_w;
VARID shader_copper_screen_h;
VARID shader_copper_time;
VARID shader_copper_n;
VARID shader_copper_alpha;
VARID shader_copper_speed;
VARID shader_copper_limit;
VARID shader_wave_texture;
VARID shader_wave_screen_w;
VARID shader_wave_screen_h;
VARID shader_wave_time;
VARID shader_wave_value;
VARID shader_render_resolution;
VARID shader_render_time;
VARID shader_render_value;
VARID shader_cloud_resolution;
VARID shader_cloud_time;
VARID shader_cloud_value;
VARID shader_tunnel_resolution;
VARID shader_tunnel_time;
VARID shader_tunnel_value;
VARID shader_tube_resolution;
VARID shader_tube_time;
VARID shader_tube_value;
VARID shader_disc_resolution;
VARID shader_disc_time;
VARID shader_disc_type;
VARID shader_disc_value;
VARID shader_disc_sync;
VARID shader_title_resolution;
VARID shader_title_time;
VARID shader_title_value;
VARID shader_tower_resolution;
VARID shader_tower_time;
VARID shader_tower_value;
VARID shader_sphere_resolution;
VARID shader_sphere_time;
VARID shader_sphere_value;
VARID shader_dark_resolution;
VARID shader_dark_time;
VARID shader_dark_value;
VARID shader_land_resolution;
VARID shader_land_time;
VARID shader_land_value1;
VARID shader_land_value2;
VARID shader_postfx_texture;
VARID shader_postfx_texture_2d;
VARID shader_postfx_screen_w;
VARID shader_postfx_screen_h;
VARID shader_postfx_time;
VARID shader_postfx_flash;
VARID shader_postfx_value;
VARID shader_postfx_deform;
VARID shader_postfx_scanline;
VARID shader_postfx_sync;
FBO* fbo_back;
FBO* fbo_front;
FBO* fbo_render;
FBO* fbo_blur_h;
FBO* fbo_blur_v;
FBO* fbo_ping;
FBO* fbo_pong;
#endif
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); // wndProc declaration
static PIXELFORMATDESCRIPTOR pfd=
{
sizeof(PIXELFORMATDESCRIPTOR),
1, // version number
PFD_DRAW_TO_WINDOW| // format must support window
PFD_SUPPORT_OPENGL| // format must support openGL
PFD_DOUBLEBUFFER, // must support double buffering
PFD_TYPE_RGBA, // request an RGBA format
window_color, // select our color depth
0,0,0,0,0,0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0,0,0,0, // accumulation bits ignored
16, // z-buffer (depth buffer)
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main drawing layer
0, // reserved
0,0,0 // layer masks ignored
};
int load_tex(WORD file,GLint clamp,GLint mipmap)
{
HBITMAP hBMP; // bitmap handle
BITMAP BMP; // bitmap structure
hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(file),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
if(!hBMP) return 0;
GetObject(hBMP,sizeof(BMP),&BMP);
glPixelStorei(GL_UNPACK_ALIGNMENT,4);
GLuint TexID;
glGenTextures(1,&TexID);
glBindTexture(GL_TEXTURE_2D,TexID);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,clamp);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,clamp);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,mipmap);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,mipmap);
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP,GL_TRUE);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,BMP.bmWidth,BMP.bmHeight,0,GL_BGR,GL_UNSIGNED_BYTE,BMP.bmBits);
DeleteObject(hBMP);
return TexID;
}
void init_viewport(int type)
{
glViewport(0,0,screen_w,screen_h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(type==0) gluPerspective(70,(float)((float)screen_w/(float)screen_h),nearplane,farplane); else gluOrtho2D(0,screen_w,screen_h,0);
glMatrixMode(GL_MODELVIEW);
}
#if SHADER
void init_shader()
{
glDisable(GL_BLEND);
glVertexPointer(4,GL_FLOAT,0,fs_quad_vtx);
glTexCoordPointer(2,GL_FLOAT,0,fs_quad_tex);
}
void fs_quad()
{
glLoadIdentity();
glDrawArrays(GL_QUADS,0,4);
}
void draw_shader_simple(FBO* fbo_output,int n)
{
shader_simple->Use();
shader_simple->SetTexture(shader_simple_texture,fbo_output->GetTextureID(),n);
fs_quad();
shader_simple->UnUse();
}
#endif
int rand()
{
static int lastrand=3489715357;
__asm
{
mov eax,[lastrand]
mov edx,eax
rcr edx,11
adc eax,17
xor ax,dx
imul eax,edx
xor eax,edx
mov [lastrand],eax
and eax,0xffff
}
return (int)lastrand;
}
void calc_txt()
{
liner_angle=main_angle;
liner_length=strlen(txt);
liner_count=0;
liner_line_n=0;
liner_max=0;
liner_i=0;
for(i=0;i<liner_length;i++)
{
if((unsigned char)txt[i]!=13)
{
liner_i++;
}
else
{
if(liner_i>liner_max) liner_max=liner_i;
liner_line_n++;
liner_i=0;
}
}
if(liner_i>liner_max) liner_max=liner_i;
}
void flash()
{
flash_flag=true;
flash_angle=main_angle;
}
void fade()
{
fade_flag=true;
fade_angle=main_angle;
}
void sync1()
{
sync1_flag=true;
sync1_angle=main_angle;
}
void sync2()
{
sync2_flag=true;
sync2_angle=main_angle;
}
void beat()
{
beat_flag=true;
beat_angle=main_angle;
}
void rectangle(int x,int y,int w,int h)
{
glLoadIdentity();
glBegin(GL_QUADS);
glVertex2i(x+w,y );
glVertex2i(x ,y );
glVertex2i(x ,y+h);
glVertex2i(x+w,y+h);
glEnd();
}
void corner()
{
float vertex[2+corner_n*2];
vertex[0]=0;
vertex[1]=0;
for(i=1;i<corner_n+1;i++)
{
j=i*2;
float a=PID*90.0f/(corner_n-1)*(i-1);
vertex[j ]=corner_w-corner_w*cosf(a);
vertex[j+1]=corner_w-corner_w*sinf(a);
}
for(i=0;i<corner_n;i++)
{
j=i*6;
k=i*2;
corner_vtx[j ]=(int)vertex[0];
corner_vtx[j+1]=(int)vertex[1];
corner_vtx[j+2]=(int)vertex[2+k];
corner_vtx[j+3]=(int)vertex[3+k];
corner_vtx[j+4]=(int)vertex[4+k];
corner_vtx[j+5]=(int)vertex[5+k];
}
}
void triforce(int radius2)
{
int radius1=radius2/2;
float x1=radius1*cosf(PID*330.0f);
float y1=radius1*sinf(PID*330.0f);
float x2=radius1*cosf(PID*210.0f);
float y2=radius1*sinf(PID*210.0f);
float x3=radius1*cosf(PID* 90.0f);
float y3=radius1*sinf(PID* 90.0f);
float x4=radius2*cosf(PID*270.0f);
float y4=radius2*sinf(PID*270.0f);
float x5=radius2*cosf(PID*150.0f);
float y5=radius2*sinf(PID*150.0f);
float x6=radius2*cosf(PID* 30.0f);
float y6=radius2*sinf(PID* 30.0f);
float vertex[]={x1,y1,x4,y4,x2,y2,x2,y2,x5,y5,x3,y3,x3,y3,x6,y6,x1,y1,x2,y2,x4,y4,x1,y1,x3,y3,x5,y5,x2,y2,x1,y1,x6,y6,x3,y3};
for(i=0;i<36;i++) triforce_vtx[i]=vertex[i];
}
void bar(float speed)
{
bar_i++;
if(bar_i>bar_n-1) bar_i=0;
bar_angle[bar_i]=main_angle;
bar_speed[bar_i]=speed;
}
void greetings()
{
greetings_i++;
if(greetings_i>greetings_n) greetings_i=0;
txt=txt_greetings[greetings_i];
calc_txt();
sync2();
}
void screen(int n)
{
screen_n=n;
screen_r=0;
screen_g=0;
screen_b=0;
flash_speed=1.5f;
fade_speed=0.2f;
sync1_flag=false;
sync1_value=1.0f;
sync1_speed=1.0f;
sync2_flag=false;
sync2_value=0;
sync2_speed=1.0f;
beat_speed=2.0f;
decrunch_flag=false;
liner_flag=false;
liner_write=false;
cursor_flag=false;
liner_w=1.6f;
liner_h=2.0f;
liner_r=1.0f;
liner_g=1.0f;
liner_b=1.0f;
liner_x=0;
liner_y=0;
liner_z=-16.0f;
liner_p_x=0;
liner_p_y=0;
liner_p_z=0;
liner_a_x=0;
liner_a_y=0;
liner_a_z=0;
dos_flag=false;
dos_tab=0;
dos_r=CR*56;
dos_g=CR*48;
dos_b=CR*64;
triforce_flag=false;
logo_flag=false;
razor_flag=false;
razor_alpha=1.0f;
skull_flag=false;
shader_effect_flag=true;
shader_glow_flag=true;
glow_color=1;
glow_smoothstep=0.025f;
glow_mix_ratio1=0.5f;
glow_mix_ratio2=0.5f;
shader_radial_flag=false;
radial_value1=2.0f;
radial_value2=0.8f;
radial_color=0;
shader_copper_flag=false;
copper_n=8.0f;
copper_alpha=0.875f;
copper_speed=0.25f;
copper_limit=1.0f;
shader_wave_flag=false;
shader_render_flag=false;
shader_cloud_flag=false;
shader_tunnel_flag=false;
shader_tube_flag=false;
shader_disc_flag=false;
disc_type=0;
shader_title_flag=false;
shader_tower_flag=false;
shader_sphere_flag=false;
shader_dark_flag=false;
shader_land_flag=false;
postfx_deform=0.5f;
switch(n)
{
case 0: // loading
break;
case 16: case 18: case 19: // loading
part_angle=main_angle;
if(n==19) decrunch_flag=true;
dos_flag=true;
if(n==16) cursor_flag=true;
txt=txt_dos[(n==16)?0:1];
dos_tab=(n==18||n==19)?screen_w/2-2*ratio_2d-dos_m-83*dos_w:0;
screen_r=dos_r;
screen_g=dos_g;
screen_b=dos_b;
if(n==16) // music
{
#if MUSIC
player.Stop();
player.Play();
while(dsGetCurSmp()<0.0f) {}
#endif
music_play=true;
timer_buffer=timer_global;
}
break;
case 1: // intro
part_angle=main_angle;
shader_copper_flag=true;
shader_wave_flag=true;
logo_flag=true;
for(i=0;i<bar_n;i++)
{
bar_angle[i]=0;
bar_speed[i]=1.0f;
}
flash();
break;
case 2: // render
part_angle=main_angle;
shader_render_flag=true;
flash();
sync1_speed=0.25f;
sync1();
break;
case 3: // cloud
part_angle=main_angle;
shader_cloud_flag=true;
flash();
sync1_speed=0.25f;
sync1();
break;
case 4: // tunnel
part_angle=main_angle;
shader_tunnel_flag=true;
flash();
sync1();
break;
case 5: case 17: // end
if(n==5) part_angle=main_angle;
shader_copper_flag=true;
copper_n=24.0f;
copper_limit=0.525f;
copper_speed=0;
shader_land_flag=true;
razor_flag=true;
razor_y=(screen_h-razor_h)/2+8*ratio_2d;
triforce_flag=true;
triforce_x=screen_w/2;
triforce_y=screen_h/2+2*ratio_2d;
liner_flag=true;
txt=txt_end;
liner_p_y=-4.575f;
liner_p_z=-7.0f;
if(n==5)
{
flash();
sync1_speed=0.25f;
sync1();
}
else
{
fade();
sync1_value=0;
sync2_speed=fade_speed;
sync2();
}
break;
case 6: case 20: // disc
if(n==6) part_angle=main_angle;
shader_disc_flag=true;
shader_radial_flag=true;
radial_value1=0.625f;
radial_value2=0.9875f;
if(n==6)
{
liner_flag=true;
txt=txt_greetings[0];
liner_p_y=4.0f;
liner_p_z=-4.0f;
liner_a_x=-45.0f;
liner_r=0.875f;
liner_g=0.625f;
liner_b=0.375f;
}
else
{
radial_color=0.0625f;
disc_type=1;
}
flash();
sync1_value=0;
//sync1_speed=1.5f;
sync1();
break;
case 7: case 12: // title
if(n==7) part_angle=main_angle;
shader_title_flag=true;
shader_copper_flag=true;
if(n==7)
{
copper_n=12.0f;
copper_speed=0.5f;
txt=txt_title;
liner_p_y=-3.0f;
liner_p_z=3.0f;
liner_a_x=-45.0f;
}
else
{
copper_n=24.0f;
copper_speed=0.5f;
triforce_flag=true;
triforce_x=screen_w/2;
triforce_y=screen_h/2-6*ratio_2d;
razor_flag=true;
razor_y=(screen_h-razor_h)/2;
txt=txt_razor;
liner_p_y=-1.0f;
liner_p_z=-14.0f;
}
liner_flag=true;
flash();
sync1_value=0;
break;
case 8: // sphere
part_angle=main_angle;
shader_sphere_flag=true;
shader_radial_flag=true;
radial_value1=0.75f;
radial_value2=1.0f;
radial_color=0.0625f;
sync1_speed=0.0625f;
sync1();
flash();
break;
case 10: case 13: case 14: // credits
if(n==8) part_angle=main_angle;
shader_tower_flag=true;
shader_radial_flag=true;
radial_value1=0.75f;
radial_value2=1.0f;//0.9875f;
if(n==10||n==13)
{
liner_flag=true;
txt=txt_credits[(n==10)?0:1];
sync1_speed=0.1275f;
sync1();
}
if(n==14) { sync2_speed=0.1f; sync2(); }
if(n!=14) flash();
break;
case 9: // dark
part_angle=main_angle;
shader_dark_flag=true;
shader_radial_flag=true;
radial_value1=0.625f;
radial_value2=0.9875f;
radial_color=0.0625f;
sync1_speed=0.01875f;
sync1();
flash();
break;
case 11: // we are back
part_angle=main_angle;
skull_flag=true;
shader_radial_flag=true;
radial_value1=0.875f;
radial_value2=0.9875f;
radial_color=0.0625f;
liner_flag=true;
txt=txt_skull;
liner_r=skull_r;
liner_g=skull_g;
liner_b=skull_b;
liner_p_y=-1.0f;
liner_p_z=-14.0f;
//flash();
break;
case 15: // greetings
part_angle=main_angle;
shader_tube_flag=true;
//shader_radial_flag=true;
radial_value1=1.0f;
radial_value2=0.9875f;
liner_flag=true;
greetings_i=0;
sync2_speed=0.75f;
txt="@";
flash();
sync1();
break;
case 21: // exit
part_angle=main_angle;
dos_flag=true;
cursor_flag=true;
txt=txt_dos[2];
screen_r=dos_r;
screen_g=dos_g;
screen_b=dos_b;
break;
}
glClearColor(screen_r,screen_g,screen_b,1.0f);
calc_txt();
}
int InitGL(void)
{
glClearDepth(1.0f); // set depth buffer
glDepthMask(GL_TRUE); // do not write z-buffer
glEnable(GL_CULL_FACE); // disable cull face
glCullFace(GL_BACK); // don't draw front face
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
// load texture
tex_map=load_tex(IDB_MAP,GL_CLAMP,GL_NEAREST);//_MIPMAP_NEAREST);
// initialize some variable
timer=new Timer();
for(i=0;i<screen_max;i++) screen_timer[i]=((i>0)?screen_timer[i-1]:0)+screen_length[i]*TIME;
screen(screen_start[screen_i]);
// initialize music
#if MUSIC
player.Init();
player.Open(music);
dsInit(player.RenderProxy,&player,GetForegroundWindow());
#endif
/*-PATACODE----------------------------------------------------------------*/
#if SHADER
if(shader_flag)
{
try
{
glsl.Init();
fbo_back=glsl.CreateFBO(screen_w,screen_h);
fbo_front=glsl.CreateFBO(screen_w,screen_h);
fbo_render=glsl.CreateFBO(screen_w/2,screen_h/2);
fbo_blur_h=glsl.CreateFBO(screen_w/glow_fbo_size,screen_h/glow_fbo_size);
fbo_blur_v=glsl.CreateFBO(screen_w/glow_fbo_size,screen_h/glow_fbo_size);
fbo_ping=glsl.CreateFBO(screen_w,screen_h);
fbo_pong=glsl.CreateFBO(screen_w,screen_h);
// shader simple
shader_simple=glsl.CreateShader(IDR_VS_SIMPLE,IDR_PS_SIMPLE,DEBUG);
shader_simple_texture=shader_simple->GetVariableID("texture");
// shader blur horizontal
shader_blur_h=glsl.CreateShader(IDR_VS_SIMPLE,IDR_PS_BLUR_H,DEBUG);
shader_blur_h_texture=shader_blur_h->GetVariableID("texture");
shader_blur_h_screen_w=shader_blur_h->GetVariableID("screen_w");
shader_blur_h_screen_h=shader_blur_h->GetVariableID("screen_h");
shader_blur_h_time=shader_blur_h->GetVariableID("time");
shader_blur_h_value=shader_blur_h->GetVariableID("value");
// shader blur vertical
shader_blur_v=glsl.CreateShader(IDR_VS_SIMPLE,IDR_PS_BLUR_V,DEBUG);
shader_blur_v_texture=shader_blur_v->GetVariableID("texture");
shader_blur_v_screen_w=shader_blur_v->GetVariableID("screen_w");
shader_blur_v_screen_h=shader_blur_v->GetVariableID("screen_h");
shader_blur_v_time=shader_blur_v->GetVariableID("time");
shader_blur_v_value=shader_blur_v->GetVariableID("value");
// shader glow
shader_glow=glsl.CreateShader(IDR_VS_SIMPLE,IDR_PS_GLOW,DEBUG);
shader_glow_texture=shader_glow->GetVariableID("texture");
shader_glow_texture_prv=shader_glow->GetVariableID("texture_prv");
shader_glow_screen_w=shader_glow->GetVariableID("screen_w");
shader_glow_screen_h=shader_glow->GetVariableID("screen_h");
shader_glow_time=shader_glow->GetVariableID("time");
shader_glow_step=shader_glow->GetVariableID("step");
shader_glow_value1=shader_glow->GetVariableID("value1");
shader_glow_value2=shader_glow->GetVariableID("value2");
// shader radial
shader_radial=glsl.CreateShader(IDR_VS_SIMPLE,IDR_PS_RADIAL,DEBUG);
shader_radial_texture=shader_radial->GetVariableID("texture");
shader_radial_screen_w=shader_radial->GetVariableID("screen_w");
shader_radial_screen_h=shader_radial->GetVariableID("screen_h");
shader_radial_time=shader_radial->GetVariableID("time");
shader_radial_value1=shader_radial->GetVariableID("value1");
shader_radial_value2=shader_radial->GetVariableID("value2");
shader_radial_color=shader_radial->GetVariableID("color");
// shader copper
shader_copper=glsl.CreateShader(IDR_VS_SIMPLE,IDR_PS_COPPER,DEBUG);
shader_copper_texture=shader_copper->GetVariableID("texture");
shader_copper_screen_w=shader_copper->GetVariableID("screen_w");
shader_copper_screen_h=shader_copper->GetVariableID("screen_h");
shader_copper_time=shader_copper->GetVariableID("time");
shader_copper_n=shader_copper->GetVariableID("number");
shader_copper_alpha=shader_copper->GetVariableID("alpha");
shader_copper_speed=shader_copper->GetVariableID("speed");
shader_copper_limit=shader_copper->GetVariableID("limit");
// shader wave
shader_wave=glsl.CreateShader(IDR_VS_SIMPLE,IDR_PS_WAVE,DEBUG);
shader_wave_texture=shader_wave->GetVariableID("texture");
shader_wave_screen_w=shader_wave->GetVariableID("screen_w");
shader_wave_screen_h=shader_wave->GetVariableID("screen_h");
shader_wave_time=shader_wave->GetVariableID("time");
shader_wave_value=shader_wave->GetVariableID("value");
// shader render
shader_render=glsl.CreateShader(IDR_VS_SIMPLE,IDR_PS_RENDER,DEBUG);
shader_render_resolution=shader_render->GetVariableID("resolution");
shader_render_time=shader_render->GetVariableID("time");
shader_render_value=shader_render->GetVariableID("value");
// shader cloud
shader_cloud=glsl.CreateShader(IDR_VS_SIMPLE,IDR_PS_CLOUD,DEBUG);
shader_cloud_resolution=shader_cloud->GetVariableID("resolution");
shader_cloud_time=shader_cloud->GetVariableID("time");
shader_cloud_value=shader_cloud->GetVariableID("value");
// shader tunnel
shader_tunnel=glsl.CreateShader(IDR_VS_SIMPLE,IDR_PS_TUNNEL,DEBUG);
shader_tunnel_resolution=shader_tunnel->GetVariableID("resolution");
shader_tunnel_time=shader_tunnel->GetVariableID("time");