-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheditor.c
3088 lines (2704 loc) · 89.1 KB
/
editor.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 "editor.h"
#include "skills.h"
#include "render.h"
#include "camera.h"
#include "sound.h"
#include "items.h"
#include "stdlib.h"//forgive myself?
#include "video.h"
#include "zdialogs.h"
#include "globalvar.h"
#include "zmath.h"
#define FPMUL(x,y) ((((x)>>6)*((y)>>6))>>4)
#define FPDIV(x,y) ((((x)<<6)/((y)>>6))>>4)
Uint8 curlayer,layer_spec_mode=0,node_axis=0;
Uint32 editorcount;
Uint8 color,colorbuf[3],levelmode,selaxis,selstep=1,curmovie,curtrigger,lastlmode;
Uint8 aiedit;
Uint8 ex,ey,tile,tileedit[16][16],grid,tiledatcur=0,MapTag,objcur;
Uint8 CurrentTile,TileSelector,SoundPlayer,TilePlace,twosidedtile;
Uint8 cam0,cam1,cam2,cam3,camfollowmode;
Sint32 editorcamera_speed=3400;
Sint8 cursorx,cursory,cursorz,cursortarget,relativecursor,solidcursor;//My precioss
Sint32 cursori;
Sint16 starx[100],stary[100];
Sint16 starix[100],stariy[100];
Uint8 inTrigEdit=0;
const char *st_ch[2]=
{
"Off","On"
};
const char c_hex[16]=
{
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
};
const char ai_text[13][20]=
{
"Normal AI",
"Walk East",
"Walk North",
"Walk West",
"Walk South",
"Run East",
"Run North",
"Run West",
"Run South",
"Panic East",
"Panic North",
"Panic West",
"Panic South"
};
const char *MapTaginfo[]=
{
"Empty(Unassigned)","Block Player","Floor Damage Low","Unknown 1","Unknown 2",
"Trigger 1",
"Trigger 2",
"Trigger 3",
"Trigger 4",
"Trigger 5",
"Trigger 6",
"Trigger 7",
"Trigger 8",
"Trigger 9",
"Trigger 10",
"Trigger 11",
"Trigger 12",
"Trigger 13",
"Trigger 14",
"Trigger 15",
"Climb East",
"Climb North",
"Climb West",
"Climb South",
"SHOP TIME!"
};
const Uint8 MapTaginfo_num=25;
Uint8 currentnode,currentconnode;
//con movie node
void GetCurrentConNode(void)
{
currentconnode=0;
if (movie_control_nodes[curmovie])
{
while
(
(movie_control_node_pos[curmovie][currentconnode]<c_movie_step)
&
(currentconnode<movie_control_nodes[curmovie])
)
{currentconnode++;}
}
}
//anim_movie node
void GetCurrentNode(void)
{
currentnode=0;
if (movie_layer_nodes[curmovie][curlayer])
{
while
(
(movie_node_pos[curmovie][currentnode][curlayer]<c_movie_step)
&
(currentnode<movie_layer_nodes[curmovie][curlayer])
)
{currentnode++;}
}
// c_movie_step=movie_node_pos[curmovie][currentnode][curlayer];
}
Uint8 ccon[3],cconi;
Uint8 CCON_SI=11;
char ccon_s[11][20]=
{
"NOP",
"SETMODEL_L_I",
"SETFRAME_L_I",
"SETANIM_L_I",
"PLAYMUS_I",
"PLAYSND_I",
"ENDLEVEL",
"ACTTRIG",
"_DIALOG",
"S_FIELD",
"_RENAME"
};
void MInsert_ConNode(void)
{
//currentnode=curmovie*64;
if (movie_control_nodes[curmovie]<128)
{
GetCurrentNode();
for (Uint8 i=movie_control_nodes[curmovie];i>currentconnode;i--)
{
movie_control_node_pos[curmovie][i]=movie_control_node_pos[curmovie][i-1];
movie_control_node[curmovie][i][0]=movie_control_node[curmovie][i-1][0];
movie_control_node[curmovie][i][1]=movie_control_node[curmovie][i-1][1];
movie_control_node[curmovie][i][2]=movie_control_node[curmovie][i-1][2];
}
movie_control_node_pos[curmovie][currentconnode]=c_movie_step;
movie_control_node[curmovie][currentconnode][0]=ccon[0];
movie_control_node[curmovie][currentconnode][1]=ccon[1];
movie_control_node[curmovie][currentconnode][2]=ccon[2];
movie_control_nodes[curmovie]++;
}
}
void MDelete_ConNode(void)
{
//currentnode=curmovie*64;
if (movie_control_nodes[curmovie]>0)
{
GetCurrentConNode();
for (Uint8 i=currentconnode;i<movie_control_nodes[curmovie]-1;i++)
{
movie_control_node_pos[curmovie][i]=movie_control_node_pos[curmovie][i+1];
movie_control_node[curmovie][i][0]=movie_control_node[curmovie][i+1][0];
movie_control_node[curmovie][i][1]=movie_control_node[curmovie][i+1][1];
movie_control_node[curmovie][i][2]=movie_control_node[curmovie][i+1][2];
}
movie_control_nodes[curmovie]--;
}
}
void MInsert_Node(void)
{
//currentnode=curmovie*64;
if (movie_layer_nodes[curmovie][curlayer]<64)
{
GetCurrentNode();
for (Uint8 i=movie_layer_nodes[curmovie][curlayer];i>currentnode;i--)
{
movie_node_pos[curmovie][i][curlayer]=movie_node_pos[curmovie][i-1][curlayer];
movie_node[curmovie][i][curlayer][0]=movie_node[curmovie][i-1][curlayer][0];
movie_node[curmovie][i][curlayer][1]=movie_node[curmovie][i-1][curlayer][1];
movie_node[curmovie][i][curlayer][2]=movie_node[curmovie][i-1][curlayer][2];
movie_node[curmovie][i][curlayer][3]=movie_node[curmovie][i-1][curlayer][3];
movie_node[curmovie][i][curlayer][4]=movie_node[curmovie][i-1][curlayer][4];
movie_node[curmovie][i][curlayer][5]=movie_node[curmovie][i-1][curlayer][5];
}
movie_node_pos[curmovie][currentnode][curlayer]=c_movie_step;
movie_node[curmovie][currentnode][curlayer][0]=rcamera[0];
movie_node[curmovie][currentnode][curlayer][1]=rcamera[1];
movie_node[curmovie][currentnode][curlayer][2]=rcamera[2];
movie_node[curmovie][currentnode][curlayer][3]=rcamera[3];
movie_node[curmovie][currentnode][curlayer][4]=rcamera[4];
movie_node[curmovie][currentnode][curlayer][5]=rcamera[5];
movie_layer_nodes[curmovie][curlayer]++;
}
}
void MDelete_Node(void)
{
//currentnode=curmovie*64;
if (movie_layer_nodes[curmovie][curlayer]>0)
{
GetCurrentNode();
for (Uint8 i=currentnode;i<movie_layer_nodes[curmovie][curlayer]-1;i++)
{
movie_node_pos[curmovie][i][curlayer]=movie_node_pos[curmovie][i+1][curlayer];
movie_node[curmovie][i][curlayer][0]=movie_node[curmovie][i+1][curlayer][0];
movie_node[curmovie][i][curlayer][1]=movie_node[curmovie][i+1][curlayer][1];
movie_node[curmovie][i][curlayer][2]=movie_node[curmovie][i+1][curlayer][2];
movie_node[curmovie][i][curlayer][3]=movie_node[curmovie][i+1][curlayer][3];
movie_node[curmovie][i][curlayer][4]=movie_node[curmovie][i+1][curlayer][4];
movie_node[curmovie][i][curlayer][5]=movie_node[curmovie][i+1][curlayer][5];
}
movie_layer_nodes[curmovie][curlayer]--;
}
}
void ClearLEditor()
{
cursorx=0;
cursory=0;
cursorz=0;
camera[0]=0;
camera[1]=0;
camera[2]=0;
camera[3]=0;
camera[4]=0;
camera[5]=0;
camfollowmode=0;cursortarget=0;objcur=0;
twosidedtile=0;
relativecursor=1;
solidcursor=0;
cam0=0;
cam1=0x88;
cam2=0x88;
cam3=0x88;
curmovie=0;
curtrigger=0;
}
void savetiledata(void)
{
Uint8 c;
FILE *fp;
fp=fopen("data/tiledata.ggc","wb");
for (int i=0;i<=255;i++)
{
c=0;
if (tiledata_alpha[i]) c=c | 1;
if (tiledata_animated[i]) c=c | 2;
if (tiledata_block[i]) c=c | 4;
if (tiledata_breakable[i]) c=c | 8;
if (tiledata_finalbreak[i]) c=c | 16;
c=c+tiledata_sound[i]*32;
fputc(c,fp);
}
fclose(fp);
}
void RenderEditorCursor(void)
{
Sint32 t=cursorx+cursory*128+cursorz*16384;
if (controlpad.button[PAD_Y])
{
zlcolor=39;
zlline(meshx[t],meshz[t],meshy[t],meshx[t]+1000,meshz[t]+2000,meshy[t]+1000);
}
if (controlpad.button[PAD_Y])
zlcolor=22; else zlcolor=19;
zlline(meshx[t],meshz[t],meshy[t],meshx[t+1],meshz[t+1],meshy[t+1]);
zlline(meshx[t],meshz[t],meshy[t],meshx[t+128],meshz[t+128],meshy[t+128]);
zlline(meshx[t+1],meshz[t+1],meshy[t+1],meshx[t+129],meshz[t+129],meshy[t+129]);
zlline(meshx[t+128],meshz[t+128],meshy[t+128],meshx[t+129],meshz[t+129],meshy[t+129]);
zlcolor=19;
zlline(meshx[t],meshz[t],meshy[t],meshx[t+16384],meshz[t+16384],meshy[t+16384]);
zlline(meshx[t+1],meshz[t+1],meshy[t+1],meshx[t+16385],meshz[t+16385],meshy[t+16385]);
zlline(meshx[t+128],meshz[t+128],meshy[t+128],meshx[t+16512],meshz[t+16512],meshy[t+16512]);
zlline(meshx[t+129],meshz[t+129],meshy[t+129],meshx[t+16513],meshz[t+16513],meshy[t+16513]);
t=t+16384;
if (controlpad.button[PAD_Y])
zlcolor=24;
zlline(meshx[t],meshz[t],meshy[t],meshx[t+1],meshz[t+1],meshy[t+1]);
zlline(meshx[t],meshz[t],meshy[t],meshx[t+128],meshz[t+128],meshy[t+128]);
zlline(meshx[t+1],meshz[t+1],meshy[t+1],meshx[t+129],meshz[t+129],meshy[t+129]);
zlline(meshx[t+128],meshz[t+128],meshy[t+128],meshx[t+129],meshz[t+129],meshy[t+129]);
if ((!camfollowmode)&cursortarget)
{
camera[4]=1024-arctan(cursorx*65536+32666-camera[0],cursory*65536+32666-camera[2]);
camera[3]=arctan(srange(cursorx*65536+32666-camera[0],cursory*65536+32666-camera[2]),cursorz*65536+32666-camera[1]);
}
if (controlpad.button[PAD_Y])
{
l_textstring=sprintf(s_textstring,"Cursor Control");
s_drawtext(246,203,16);
s_drawtext(245,202,14);
}
}
void SaveLevel(Uint8 num)
{
FILE *fp;
Uint8 c,c1,ext,k,n,j;
Uint8 x,y,z;
Uint32 t;
Uint16 i;
char spath[25];
sprintf(spath,"data/Level%i%i.zgz",num/10,num%10);
fp=fopen(spath,"wb");
if (fp)
{
ext=0;
fputc(fogcolor,fp);
fputc(levelx,fp);
fputc(levely,fp);
fputc(levelz,fp);
fputc(levelsight,fp);
fputc(maxmonsters,fp);
fputc(levelmusictrack,fp);
fputc(level_tag,fp);
for (z=0;z<=levelz;z++)
for (y=0;y<=levely;y++)
for (x=0;x<=levelx;x++)
{
t=x+y*128+z*16384;
//FLAG0
c=0;
if (map[t]) c=c | 1;
if (mapt0[t]) c=c | 2;
if (mapt1[t]) c=c | 4;
if (mapt2[t]) c=c | 8;
if (mapt3[t]) c=c | 16;
if (mapt4[t]) c=c | 32;
if (mapt5[t]) c=c | 64;
c1=0;
if (meshxdisplace[t]) c1=c1 | 1;
if (meshydisplace[t]) c1=c1 | 2;
if (meshzdisplace[t]) c1=c1 | 4;
if (mapcam0[t]) c1=c1 | 8;
if (mapobj[t]) c1=c1 | 16;
if (mapai[t]) c1=c1 | 32;
//we got freespace descent III here
if (c1) c=c | 128;
fputc(c,fp);
if (map[t]) fputc(map[t],fp);
if (mapt0[t]) fputc(mapt0[t],fp);
if (mapt1[t]) fputc(mapt1[t],fp);
if (mapt2[t]) fputc(mapt2[t],fp);
if (mapt3[t]) fputc(mapt3[t],fp);
if (mapt4[t]) fputc(mapt4[t],fp);
if (mapt5[t]) fputc(mapt5[t],fp);
if (c1) fputc(c1,fp);
if (c1)
{
//FLAG1
// if (mapt4[t]) c=c | 32;
// if (mapt5[t]) c=c | 64;
// if (mapai[t]) c=c | 128;
// fputc(c1,fp);
if (meshxdisplace[t]) fputc(meshxdisplace[t],fp);
if (meshydisplace[t]) fputc(meshydisplace[t],fp);
if (meshzdisplace[t]) fputc(meshzdisplace[t],fp);
if (mapcam0[t])
{
fputc(mapcam0[t],fp);
if (mapcam0[t] & 128)
{
fputc(mapcam1[t],fp);
fputc(mapcam2[t],fp);
fputc(mapcam3[t],fp);
}
}
if (mapobj[t]) fputc(mapobj[t],fp);
if (mapai[t]) fputc(mapai[t],fp);
}///c1
}
fputc(staticcams,fp);//Static Cameras
if (staticcams)
for (i=0;i<staticcams;i++)
{
for (k=0;k<6;k++)
{
// staticcam[i][k]=camera[k];//he-eh=hehe
c=staticcam[i][k]/65536 %256;
fputc(c,fp);
c=staticcam[i][k]/256 %256;
fputc(c,fp);
c=staticcam[i][k]%256;
fputc(c,fp);
}
// I should listen you more, my love
}
for (i=0;i<512;i++)
{
fputc(trig[i],fp);
}
//movie
for (i=0;i<16;i++)
{
c=movie_length[i]/256;
fputc(c,fp);
c=movie_length[i]%256;
fputc(c,fp);
if (movie_length[i])
{
fputc(movie_type[i],fp);
fputc(movie_num_layers[i],fp);
//layers 0-7
for (Uint8 k=0;k<=movie_num_layers[i];k++)
{
fputc(movie_layer_nodes[i][k],fp);
if (movie_layer_nodes[i][k])
{
for (Uint8 n=0;n<movie_layer_nodes[i][k];n++)
{
for (j=0;j<3;j++)
{
c=movie_node[i][n][k][j]/65536;
fputc(c,fp);
c=movie_node[i][n][k][j]/256;
fputc(c,fp);
c=movie_node[i][n][k][j];
fputc(c,fp);
}
for (j=3;j<6;j++)
{
c=movie_node[i][n][k][j]/256;
fputc(c,fp);
c=movie_node[i][n][k][j];
fputc(c,fp);
}
c=movie_node_pos[i][n][k]/256;
fputc(c,fp);
c=movie_node_pos[i][n][k];
fputc(c,fp);
}
}
}
//control layer 8(eight - not a smile with no teeth)
fputc(movie_control_nodes[i],fp);
if (movie_control_nodes[i])
{
for (Uint8 n=0;n<movie_control_nodes[i];n++)
{
for (j=0;j<3;j++)
{
c=movie_control_node[i][n][j];
fputc(c,fp);
}
c=movie_control_node_pos[i][n]/256;
fputc(c,fp);
c=movie_control_node_pos[i][n];
fputc(c,fp);
}
}
}
}
//Close Level File
fclose(fp);
}
}
void RenderETileSelector(void)
{
int ix,iy;
int c,a,d,n;
c=CurrentTile/32*32;
for (int a=0;a<32;a++)
{
ix=10+((a%8)*38);
iy=20+((a/8)*38);
for (int x=0;x<16;x++)
for (int y=0;y<16;y++)
{
n=ix+x*2+(iy+y*2)*320;
d=Tile[Tile_offset[CurrentTile/32*32+a]+x+y*16];
scrbuf[n]=d;
scrbuf[n+1]=d;
scrbuf[n+320]=d;
scrbuf[n+321]=d;
}
}
ix=9+(((CurrentTile%32)%8)*38);
iy=19+(((CurrentTile%32)/8)*38);
d=13+count/5%3;
for (c=0;c<34;c++)
{
scrbuf[ix+c+(iy)*320]=d;
scrbuf[ix+c+(iy+33)*320]=d;
scrbuf[ix+(iy+c)*320]=d;
scrbuf[ix+33+(iy+c)*320]=d;
}
if (GameMode==EDITOR_TEXTURE)
{
for (int x=0;x<16;x++)
for (int y=0;y<16;y++)
{
n=20+x*2+(180+y*2)*320;
d=tileedit[x][y];
scrbuf[n]=d;
scrbuf[n+1]=d;
scrbuf[n+320]=d;
scrbuf[n+321]=d;
}
l_textstring=sprintf(s_textstring,"X:Read Y:Write");
s_drawtext(20,226,14);
}
if (editorcount>10)
{
l_textstring=sprintf(s_textstring,"Select: Save");
s_drawtext(130,226,15);
}
l_textstring=sprintf(s_textstring,"Tile Element N:%i",CurrentTile);
s_drawtext(220,2,14);
if (editorcount>10)
{
l_textstring=sprintf(s_textstring,"Tile Selector");
s_drawtext(10,2,14);
}
l_textstring=sprintf(s_textstring,"L: Previous Page");
s_drawtext(230,192,14);
l_textstring=sprintf(s_textstring,"R: Next Page");
s_drawtext(230,204,14);
l_textstring=sprintf(s_textstring,"Start: Return");
s_drawtext(230,226,15);
}
void RenderETexture(void)
{//R_TEXTURE EDITOR
if (editorcount>10)
{
l_textstring=sprintf(s_textstring,"Texture editor");
s_drawtext(10,10,14);
}
l_textstring=sprintf(s_textstring,"Start: Exit");
s_drawtext(230,226,15);
if (!controlpad.button[PAD_L1])
{
l_textstring=sprintf(s_textstring,"Vol-:Tiles Vol+:Grid");
s_drawtext(20,226,14);
}
if (controlpad.button[PAD_L1])
{
l_textstring=sprintf(s_textstring,"Tiledata %i",CurrentTile);
s_drawtext(240,20,14);
s_drawtext(239,19,15);
l_textstring=sprintf(s_textstring,"b_AlphaChannel %i",tiledata_alpha[CurrentTile]);
if (tiledatcur==0)
s_drawtext(230,32,13);else s_drawtext(230,32,14);
l_textstring=sprintf(s_textstring,"b_Animated %i",tiledata_animated[CurrentTile]);
if (tiledatcur==1)
s_drawtext(230,44,13);else s_drawtext(230,44,14);
l_textstring=sprintf(s_textstring,"b_Blocking %i",tiledata_block[CurrentTile]);
if (tiledatcur==2)
s_drawtext(230,56,13);else s_drawtext(230,56,14);
l_textstring=sprintf(s_textstring,"b_Breakable %i",tiledata_breakable[CurrentTile]);
if (tiledatcur==3)
s_drawtext(230,68,13);else s_drawtext(230,68,14);
l_textstring=sprintf(s_textstring,"b_FinalDamage %i",tiledata_finalbreak[CurrentTile]);
if (tiledatcur==4)
s_drawtext(230,80,13);else s_drawtext(230,80,14);
l_textstring=sprintf(s_textstring,"i_Sound %i=5+2*%i",5+tiledata_sound[CurrentTile]*2,tiledata_sound[CurrentTile]);
if (tiledatcur==5)
s_drawtext(230,92,13);else s_drawtext(230,92,14);
if (editorcount>10)
{
l_textstring=sprintf(s_textstring,"Select: Save TileData");
s_drawtext(205,104,15);
}
}
else
if (controlpad.button[PAD_R1])
{
l_textstring=sprintf(s_textstring,"Palette");
s_drawtext(240,126,14);
for (int y=0;y<12;y++)
for (int x=0;x<12;x++)
{
scrbuf[277+x+(y+126)*320]=color;
}
}
//else
//{
//l_textstring=sprintf(s_textstring,"Tile N%i",CurrentTile);
//s_drawtext(40,202,14);
//}
for (int y=0;y<16;y++)
for (int x=0;x<16;x++)
{
scrbuf[13010+x+y*320]=tileedit[x][y];
}
scrbuf[12690+ex]=15;
scrbuf[18130+ex]=15;
scrbuf[13009+ey*320]=15;
scrbuf[13026+ey*320]=15;
for (int y=40;y<200;y++)
for (int x=40;x<200;x++)
{
scrbuf[x+320*y]=tileedit[(x-40)/10][(y-40)/10];
}
for (int y=140;y<204;y++)
for (int x=240;x<304;x++)
{
scrbuf[x+320*y]=(x-240)/4+(y-140)/4*16;
}
Uint8 c,i;i=16+count/13%4*3;
int ix,iy;
ix=240+color%16*4;iy=140+color/16*4;
for (c=0;c<4;c++)
{
scrbuf[ix+c+(iy)*320]=i;
scrbuf[ix+c+(iy+4)*320]=i;
scrbuf[ix+(iy+c)*320]=i;
scrbuf[ix+4+(iy+c)*320]=i;
}
if (grid)
{
c=15+grid*4;
for (int y=40;y<201;y++)
for (int x=40;x<201;x++)
{
if ((x%10==0)||(y%10==0))
scrbuf[x+320*y]=c;
}
}
if (controlpad.button[PAD_R1]==0)
{
ix=40+ex*10;iy=40+ey*10;
for (c=0;c<10;c++)
{
scrbuf[ix+c+(iy)*320]=color;
scrbuf[ix+c+(iy+10)*320]=color;
scrbuf[ix+(iy+c)*320]=color;
scrbuf[ix+10+(iy+c)*320]=color;
}
}
}//R_TEXTURE EDITOR END;
void SavePalette(void)
{
FILE *fp;char c;
fp=fopen("data/palette.ggg","wb");
for (int i=0;i<256;i++)
{
#ifdef GP2X
fputc(screen->format->palette->colors[i].r,fp);
fputc(screen->format->palette->colors[i].g,fp);
fputc(screen->format->palette->colors[i].b,fp);
#endif
#ifdef PC
fputc(ipal[i][0],fp);
fputc(ipal[i][1],fp);
fputc(ipal[i][2],fp);
#endif
}
fclose(fp);
}
void SaveTiles(void)
{
FILE *fp;
fp=fopen("data/tileset.ggg","wb");
for (int i=0;i<65536;i++)
{
fputc(Tile[i],fp);
}
fclose(fp);
}
void RenderEPalette(void)
{
if (editorcount>10)
{
l_textstring=sprintf(s_textstring,"Palette editor");
s_drawtext(10,10,14);
}
for (int y=0;y<16;y++)
for (int x=0;x<16;x++)
{
scrbuf[13010+x+y*320]=x+y*16;
}
scrbuf[12690+color%16]=15;
scrbuf[18130+color%16]=15;
scrbuf[13009+color/16*320]=15;
scrbuf[13026+color/16*320]=15;
for (int y=40;y<200;y++)
for (int x=40;x<200;x++)
{
scrbuf[x+320*y]=(x-40)/10+(y-40)/10*16;
}
scrbuf[12840+color%16*10+color/16*3200]=15;
scrbuf[15720+color%16*10+color/16*3200]=15;
scrbuf[12849+color%16*10+color/16*3200]=15;
scrbuf[15729+color%16*10+color/16*3200]=15;
l_textstring=sprintf(s_textstring,"index: %i",color);
s_drawtext(210,60,13);
#ifdef GP2X
l_textstring=sprintf(s_textstring,"R: %i",screen->format->palette->colors[color].r);
s_drawtext(230,72,13);
l_textstring=sprintf(s_textstring,"G: %i",screen->format->palette->colors[color].g);
s_drawtext(230,84,13);
l_textstring=sprintf(s_textstring,"B: %i",screen->format->palette->colors[color].b);
s_drawtext(230,96,13);
#endif
#ifdef PC
l_textstring=sprintf(s_textstring,"R: %i",ipal[color][0]);
s_drawtext(230,72,13);
l_textstring=sprintf(s_textstring,"G: %i",ipal[color][1]);
s_drawtext(230,84,13);
l_textstring=sprintf(s_textstring,"B: %i",ipal[color][2]);
s_drawtext(230,96,13);
#endif
l_textstring=sprintf(s_textstring,"X/Y: Copy/Paste");
s_drawtext(230,190,13);
l_textstring=sprintf(s_textstring,"Select: Save");
s_drawtext(150,226,15);
l_textstring=sprintf(s_textstring,"Start: Exit");
s_drawtext(230,226,15);
}
void RenderEMenu(void)
{
Uint8 i;
for (i=0;i<100;i++)
{
if ((starx[i]>0)&(stary[i]>0)&(starx[i]<319)&(stary[i]<239))
{
scrbuf[starx[i]+stary[i]*320]=18+i%12;
starx[i]+=starix[i];
stary[i]+=stariy[i];
}
else
{
starx[i]=150+rand()%21;
stary[i]=110+rand()%21;
starix[i]=-7+rand()%15;
if (starix[i]==0) starix[i]=-1;
stariy[i]=-7+rand()%15;
if (stariy[i]==0) stariy[i]=-1;
}
}
l_textstring=sprintf(s_textstring,"Editor Main Menu");
s_drawtext2(20,10,19);
int c;
l_textstring=sprintf(s_textstring,"0. Level Editor %i",CurrentLevel);
if (menupos==0) c=13; else c=14;
s_drawtext(20,34,c);
l_textstring=sprintf(s_textstring,"1. Model Viewer");
if (menupos==1) c=13; else c=14;
s_drawtext(20,46,c);
l_textstring=sprintf(s_textstring,"2. Texture Editor");
if (menupos==2) c=13; else c=14;
s_drawtext(20,58,c);
l_textstring=sprintf(s_textstring,"3. Palette Editor");
if (menupos==3) c=13; else c=14;
s_drawtext(20,70,c);
l_textstring=sprintf(s_textstring,"4. Music Player %i",Next_Music_Track);
if (menupos==4) c=13; else c=14;
s_drawtext(20,82,c);
if (d_sound_count)
l_textstring=sprintf(s_textstring,"5. Sound Player %i",SoundPlayer);
else
l_textstring=sprintf(s_textstring,"5. No Sounds To Hear",SoundPlayer);
if (menupos==5) c=13; else c=14;
s_drawtext(20,94,c);
l_textstring=sprintf(s_textstring,"6. AI Editor");
if (menupos==6) c=13; else c=14;
s_drawtext(20,106,c);
l_textstring=sprintf(s_textstring,"7. Disable EE Runtime");
if (menupos==7) c=13; else c=14;
s_drawtext(20,118,c);
l_textstring=sprintf(s_textstring,"8. Exit");
if (menupos==8) c=13; else c=14;
s_drawtext(20,130,c);
if (menupos==5)
{
switch (SoundMode)
{
case 0:l_textstring=sprintf(s_textstring,"<SELECT>Stereo Sound Mode");break;
case 1:l_textstring=sprintf(s_textstring,"<SELECT>Reversed Stereo Mode");break;
case 2:l_textstring=sprintf(s_textstring,"<SELECT>Monoral Sound Mode");break;
}
s_drawtext(160,94,14);
}
switch (menupos)
{
case 0:l_textstring=sprintf(s_textstring,"A-Return X-Load B-New (loaded:%i)",LoadedLevel);break;
case 1:l_textstring=sprintf(s_textstring,"View Models");break;
case 2:l_textstring=sprintf(s_textstring,"Built-in texture drawing tool");break;
case 3:l_textstring=sprintf(s_textstring,"Change Color Set");break;
case 4:l_textstring=sprintf(s_textstring,"Enjoy ingame music while developing other content");break;
case 5:
if (d_sound_count)
l_textstring=sprintf(s_textstring,"Channel: A-left X=center B-right");
else
l_textstring=sprintf(s_textstring,"You promised to not leave all that silent!");
break;
case 6:l_textstring=sprintf(s_textstring,"AI table managment");break;
case 7:l_textstring=sprintf(s_textstring,"Begin testing :)");break;
#ifdef PC
case 8:l_textstring=sprintf(s_textstring,"Return to WINDOWS (actualy you are inside already!)");break;
#endif
#ifdef GP2X
case 8:l_textstring=sprintf(s_textstring,"Return to GP2X OS menu");break;
#endif
}
s_drawtext(300-l_textstring*5,182,14);
l_textstring=sprintf(s_textstring,"Genocide Generation Gaming engine 0.64f");
s_drawtext(320-l_textstring*5,228,15);
}
void renderLeditor(void)
{
renderscene();
Uint8 t;
if (controlpad.button[PAD_L1] && controlpad.button[PAD_R1])
{
l_textstring=sprintf(s_textstring,"Level %i",CurrentLevel);
s_drawtext(36,22,16);
s_drawtext(35,21,15);
int c;
c=36+12*levelmode;
c=c*320;
for (int x=16;x<200;x+=2)
{
scrbuf[x+c]=16;
scrbuf[x+c+321]=16;
scrbuf[x+c+640]=16;
scrbuf[x+c+961]=16;
scrbuf[x+c+1280]=16;
scrbuf[x+c+1601]=16;
scrbuf[x+c+1920]=16;
scrbuf[x+c+2241]=16;
scrbuf[x+c+2560]=16;
scrbuf[x+c+2881]=16;
}
l_textstring=sprintf(s_textstring,"Description Header");
if (levelmode==0) c=13; else c=14;
s_drawtext(36,36,16);
s_drawtext(35,35,c);
l_textstring=sprintf(s_textstring,"Mesh Editor");
if (levelmode==1) c=13; else c=14;
s_drawtext(36,48,16);
s_drawtext(35,47,c);
if (levelmode!=2)
l_textstring=sprintf(s_textstring,"Tile Wrapper");
else
if (twosidedtile)
l_textstring=sprintf(s_textstring,"Tile Wrapper two sided");
else
l_textstring=sprintf(s_textstring,"Tile Wrapper one sided");
if (levelmode==2) c=13; else c=14;
s_drawtext(36,60,16);
s_drawtext(35,59,c);
l_textstring=sprintf(s_textstring,"Edit Map Tags");
if (levelmode==3) c=13; else c=14;
s_drawtext(36,72,16);
s_drawtext(35,71,c);
if (levelmode!=4)
l_textstring=sprintf(s_textstring,"Camera Tool");
else
l_textstring=sprintf(s_textstring,"Camera Tool FollowMode %s",st_ch[camfollowmode]);
if (levelmode==4) c=13; else c=14;
s_drawtext(36,84,16);
s_drawtext(35,83,c);
l_textstring=sprintf(s_textstring,"Object Placer");
if (levelmode==5) c=13; else c=14;
s_drawtext(36,96,16);
s_drawtext(35,95,c);
l_textstring=sprintf(s_textstring,"AI Nodes");
if (levelmode==6) c=13; else c=14;
s_drawtext(36,108,16);
s_drawtext(35,107,c);
l_textstring=sprintf(s_textstring,"Trigger Scripts");
if (levelmode==7) c=13; else c=14;
s_drawtext(36,120,16);
s_drawtext(35,119,c);
l_textstring=sprintf(s_textstring,"Movie Editor %i/%i l:%i type:%i lrs:%i",curmovie,movies,movie_length[curmovie],movie_type[curmovie],movie_num_layers[curmovie]);
if (levelmode==8) c=13; else c=14;
s_drawtext(36,132,16);
s_drawtext(35,131,c);
l_textstring=sprintf(s_textstring,"Camera Speed : %i",editorcamera_speed/100-9);
if (levelmode==11) c=13; else c=14;
s_drawtext(36,168,16);
s_drawtext(35,167,c);
l_textstring=sprintf(s_textstring,"Camera follow cursor : %s",st_ch[cursortarget]);
if (levelmode==12) c=13; else c=14;
s_drawtext(36,180,16);
s_drawtext(35,179,c);
l_textstring=sprintf(s_textstring,"Relative cursor : %s",st_ch[relativecursor]);
if (levelmode==13) c=13; else c=14;
s_drawtext(36,192,16);
s_drawtext(35,191,c);
l_textstring=sprintf(s_textstring,"Solid cursor : %s",st_ch[solidcursor]);
if (levelmode==14) c=13; else c=14;
s_drawtext(36,204,16);
s_drawtext(35,203,c);
}
else