-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModelLib.cpp
1157 lines (879 loc) · 26.4 KB
/
ModelLib.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
/*
-------------------------[ LBA Story Coder Source ]--------------------------
Copyright (C) 2004
------------------------------[ ModelLib.cpp ]-------------------------------
Author: Alexandre Fontoura [alexfont]
Begin : Thu Aug 20 2004
Email : alexandrefontoura@oninetspeed.pt
Original code: Vicent Hamm [yaz0r]
-------------------------------[ GNU License ]-------------------------------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-----------------------------------------------------------------------------
*/
#include <vcl.h>
#pragma hdrstop
#include "ModelLib.h"
#include "tab.h"
#include "HQRLib.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
HDC gl_HDC;
HGLRC gl_HRC;
GLboolean should_rotate=0;
int angle=0;
int mainTab2[5000];
unsigned char* bodyPtr;
int mainTab3[5000];
GLint modele;
GLfloat zoom=-5;
GLboolean wireFrame;
int currentModel=0;
int rs1v1;
int rs1v2;
short int *tab1;
pointTab renderTab5[8000];
pointTab renderTab6[8000];
short int shadeTable[500];
unsigned char *renderV19;
int rs1s2v1;
unsigned char* rs1s2v2;
pointEntry *ptEntryPtr;
pointTab *pointPtr;
pointTab *pointPtr2;
int numOfDataBlocks;
int sizeOfBlocksHeader;
unsigned char* pri1Ptr;
short int numOfPri2;
unsigned char* pri2Ptr2;
unsigned char* pri2Ptr;
int primitiveCounter;
int renderTab2[50000];
int *renderTab3;
int *renderV21;
int numOfPri1;
int numOfPrimitives;
renderTabEntry *renderTabEntryPtr;
renderTabEntry primitiveList[5000];
unsigned char renderTab7[500000];
int numOfPoints;
int angleVert=0;
extern unsigned char palette[3*256];
extern AnsiString bodyPath;
//---------------------------------------------------------------------------
void start(TPanel *Panel1, int model)
{
currentModel = model;
// should_rotate = GL_FALSE;
// wireFrame = GL_FALSE;
tab1=tab;
mainTab2[14]=0;
mainTab2[13]=0;
mainTab2[12]=0;
mainTab2[15]=0;
mainTab2[16]=40;
mainTab2[17]=40;
mainTab2[39]=16384; // model width
mainTab2[43]=16384; // model height
mainTab2[47]=16384; // model depth
renderTab3=&renderTab2[9];
loadResource(bodyPath.c_str(),model,&bodyPtr);
if(bodyPtr)
{
loadGfxSub(bodyPtr);
}
glInit(Panel1->Width, Panel1->Height);
}
//---------------------------------------------------------------------------
void draw_screen( void )
{
int i;
int j;
GLfloat vertex[3];
GLfloat vertex1[3];
GLfloat vertex2[3];
GLfloat vertex3[3];
pointTab* currentVertex;
int eax;
int color;
int numOfVertex;
int polyRenderType;
GLubyte colorTab[4];
short int* dataPtr;
short int currentVertexNumber;
lineCoordinates *lineCoordinatesPtr;
GLfloat vertexN1;
GLfloat vertexN2;
GLfloat vertexN3;
pointTab* vertexData;
pointTabShaded* vertexDataShaded;
/* Clear the color and depth buffers. */
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
/* We don't want to modify the projection matrix. */
glMatrixMode( GL_MODELVIEW );
glLoadIdentity( );
glPushMatrix();
/* Move down the z-axis. */
glTranslatef( 0.0, -1.5, zoom );
glRotatef( 20, 1.0 , 0.0, 0.0);
/* Rotate. */
glRotatef(-40,0.0,1.0,0.0);
if(wireFrame)
{
glDisable( GL_CULL_FACE );
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
else
{
glEnable( GL_CULL_FACE );
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
for(i=0;i<numOfPrimitives;i++)
{
if(primitiveList[i].renderType==1)
{
eax=*(int*)primitiveList[i].dataPtr;
polyRenderType=eax&0xFF;
numOfVertex=(eax&0xFF00)>>8;
color=(eax&0xFF0000)>>16;
if(polyRenderType==7 || polyRenderType==8 )
{
glBegin( GL_POLYGON );
dataPtr=(short int*)(primitiveList[i].dataPtr+4);
vertexDataShaded=(pointTabShaded*)(dataPtr);
for(j=0;j<numOfVertex;j++)
{
color=vertexDataShaded->shader&0xFF;
colorTab[0]=palette[color*3];
colorTab[1]=palette[color*3+1];
colorTab[2]=palette[color*3+2];
colorTab[3]=0xFF;
glColor4ubv(colorTab);
currentVertexNumber=vertexDataShaded->number;
vertex1[0]=((float)(renderTab5[currentVertexNumber].x))/400;
vertex1[1]=((float)(renderTab5[currentVertexNumber].y))/400;
vertex1[2]=((float)(renderTab5[currentVertexNumber].z))/400;
glVertex3fv(vertex1);
vertexDataShaded++;
}
glEnd( );
}
else
if(polyRenderType==3)
{
colorTab[0]=palette[color*3];
colorTab[1]=palette[color*3+1];
colorTab[2]=palette[color*3+2];
colorTab[3]=0x50;
glColor4ubv(colorTab);
glBegin( GL_POLYGON );
dataPtr=(short int*)(primitiveList[i].dataPtr+4);
vertexDataShaded=(pointTabShaded*)(dataPtr);
for(j=0;j<numOfVertex;j++)
{
currentVertexNumber=vertexDataShaded->number;
vertex1[0]=((float)(renderTab5[currentVertexNumber].x))/400;
vertex1[1]=((float)(renderTab5[currentVertexNumber].y))/400;
vertex1[2]=((float)(renderTab5[currentVertexNumber].z))/400;
glVertex3fv(vertex1);
vertexDataShaded++;
}
glEnd( );
}
else
{
colorTab[0]=palette[color*3];
colorTab[1]=palette[color*3+1];
colorTab[2]=palette[color*3+2];
colorTab[3]=0xFF;
glColor4ubv(colorTab);
glBegin( GL_POLYGON );
dataPtr=(short int*)(primitiveList[i].dataPtr+4);
vertexDataShaded=(pointTabShaded*)(dataPtr);
for(j=0;j<numOfVertex;j++)
{
currentVertexNumber=vertexDataShaded->number;
vertex1[0]=((float)(renderTab5[currentVertexNumber].x))/400;
vertex1[1]=((float)(renderTab5[currentVertexNumber].y))/400;
vertex1[2]=((float)(renderTab5[currentVertexNumber].z))/400;
glVertex3fv(vertex1);
vertexDataShaded++;
}
glEnd( );
}
}
if(primitiveList[i].renderType==0)
{
lineCoordinatesPtr=(lineCoordinates*)primitiveList[i].dataPtr;
color=(lineCoordinatesPtr->data&0xFF00)>>8;
colorTab[0]=palette[color*3];
colorTab[1]=palette[color*3+1];
colorTab[2]=palette[color*3+2];
colorTab[3]=0xFF;
glColor4ubv(colorTab);
glBegin( GL_LINES );
currentVertexNumber=lineCoordinatesPtr->p1;
vertex[0]=((float)(renderTab5[currentVertexNumber].x))/400;
vertex[1]=((float)(renderTab5[currentVertexNumber].y))/400;
vertex[2]=((float)(renderTab5[currentVertexNumber].z))/400;
glVertex3fv(vertex);
currentVertexNumber=lineCoordinatesPtr->p2;
vertex[0]=((float)(renderTab5[currentVertexNumber].x))/400;
vertex[1]=((float)(renderTab5[currentVertexNumber].y))/400;
vertex[2]=((float)(renderTab5[currentVertexNumber].z))/400;
glVertex3fv(vertex);
glEnd();
}
if(primitiveList[i].renderType==2)
{
circleData* currentCircle;
currentCircle=(circleData*)primitiveList[i].dataPtr;
color=(currentCircle->color&0xFF00)>>8;
colorTab[0]=palette[color*3];
colorTab[1]=palette[color*3+1];
colorTab[2]=palette[color*3+2];
colorTab[3]=0xFF;
glColor4ubv(colorTab);
glPointSize(((float)currentCircle->size)/2);
currentVertexNumber=currentCircle->center;
vertex[0]=((float)(renderTab5[currentVertexNumber].x))/400;
vertex[1]=((float)(renderTab5[currentVertexNumber].y))/400;
vertex[2]=((float)(renderTab5[currentVertexNumber].z))/400;
glPushMatrix();
GLUquadric* quadric=gluNewQuadric();
glTranslatef(vertex[0], vertex[1] , vertex[2] );
gluSphere(quadric,((float)currentCircle->size)/400,10,10);
glPopMatrix();
}
}
glPopMatrix();
SwapBuffers(gl_HDC);
}
//---------------------------------------------------------------------------
void loadGfxSub(unsigned char * ptr)
{
int var1;
int var2;
int bp;
int bx;
if(!((*(short int*)ptr) & 2))
return;
var1=*(short int*)(ptr+14);
ptr=ptr+var1+16;
var1=*(short int*)ptr;
ptr+=2;
var1=var1+var1*2;
ptr=ptr+var1*2;
var2=*(short int*)ptr;
ptr+=2;
bp=36;
bx=38;
while(--var2 >= 0)
{
ptr+=38;
*(short int*)(ptr+6)=(*(short int*)(ptr+6)*bp)/bx;
};
}
//---------------------------------------------------------------------------
int setupModel(unsigned char * costumePtr)
{
unsigned int var1;
unsigned char* ptr3;
// int *ptr4;
int *ptr5;
int coX;
int coY;
int coZ;
unsigned char* ptr6;
int eax;
int ebx;
int ebp;
int edx;
int ecx;
int edi;
short int flag;
int temp;
numOfPri1=numOfDataBlocks=*(short int*)costumePtr;
costumePtr+=2;
pri1Ptr=costumePtr;
sizeOfBlocksHeader=numOfDataBlocks+numOfDataBlocks*2;
costumePtr=costumePtr+sizeOfBlocksHeader*2;
numOfPri2=*(short int*)costumePtr; // that's the number of points in the model
costumePtr+=2; // we jump to the points data
pri2Ptr2=pri2Ptr=costumePtr; // we save the point data ptr
renderV19=(unsigned char *)renderTab2;
renderS1(mainTab2[14],mainTab2[13],mainTab2[12],(pointEntry*)pri2Ptr2); // that's the process of the "base point"
pri2Ptr2+=38; // jump to the next point data
ptEntryPtr=(pointEntry*)pri2Ptr2; // that's the structure used to load the points
if(numOfPri2 -1 !=0 ) // if there is points after the base point
{
primitiveCounter=numOfPri2-1; // Since the base point is already processed, we need to load numOfPri2-1 points
renderV19=(unsigned char *)renderTab3; // the use of renderTab3 is still unknown. It's a table with 36byte long element
do // That's the loop that load and convert all the points in the model
{
ebx=ptEntryPtr->flag1; // actualy, there should be 4 flags in that order = ebx,flag,edx,ecx. So this part may be buggy. at the momment
flag=ebx;
ebx>>=16;
edx=ptEntryPtr->flag2;
ecx=(short int)edx;
edx>>=16;
if(flag == 0)
{
renderS1(edx,ecx,ebx,ptEntryPtr); // renderS1 load the points, rotate them and store them in renderTab5 (it may do other things too..)
}
else
{
if(flag == 1)
{
//renderS2 // this part seems to be rarely used...
printf("renderM1\n");
exit(1);
}
}
renderV19+=36; // next entry in renderTab3
pri2Ptr2+=38; // next point data
ptEntryPtr=(pointEntry*)pri2Ptr2; // we use the structure to load the point data
}while(--primitiveCounter);
}
primitiveCounter = numOfPri1;
numOfPoints=numOfPri1;
pointPtr2=(pointTab*)renderTab5;
pointPtr=renderTab6;
ptr5=(int*)pri2Ptr2;
eax=-1;
temp=*(short int*)ptr5;
ptr5=(int*)(((unsigned char*)ptr5)+2);
if(temp) // process shading table
{
renderV19=(unsigned char*)shadeTable;
renderV21=renderTab2;
primitiveCounter=numOfPri2;
ptr3=pri2Ptr2=pri2Ptr+18;
do // pour chaque poly ?
{
temp=*(short int*)ptr3;
if(temp)
{
rs1s2v1=temp;
mainTab2[21]=(*renderV21)*mainTab2[15];
mainTab2[22]=(*(renderV21+1))*mainTab2[15];
mainTab2[23]=(*(renderV21+2))*mainTab2[15];
mainTab2[24]=(*(renderV21+3))*mainTab2[16];
mainTab2[25]=(*(renderV21+4))*mainTab2[16];
mainTab2[26]=(*(renderV21+5))*mainTab2[16];
mainTab2[27]=(*(renderV21+6))*mainTab2[17];
mainTab2[28]=(*(renderV21+7))*mainTab2[17];
mainTab2[29]=(*(renderV21+8))*mainTab2[17];
do // pour chaque vertex ?
{
short int col1;
short int col2;
short int col3;
short int *colPtr;
colPtr=(short int*)ptr5;
col1=*(colPtr++);
col2=*(colPtr++);
col3=*(colPtr++);
eax=mainTab2[21]*col1+mainTab2[22]*col2+mainTab2[23]*col3;
eax+=mainTab2[24]*col1+mainTab2[25]*col2+mainTab2[26]*col3;
eax+=mainTab2[27]*col1+mainTab2[28]*col2+mainTab2[29]*col3;
edi=0;
if(eax>0)
{
eax>>=14;
ptr6=(unsigned char*)ptr5;
eax/=*(unsigned short int*)(ptr6+6);
edi=(unsigned short int)eax;
}
*(short int*)renderV19=edi;
renderV19+=2;
ptr5+=2;
}while(--rs1s2v1);
}
ptr3=pri2Ptr2=pri2Ptr2+38;
// ptr4=renderV21=renderV21+9;
}while(--primitiveCounter);
}
return(finishModelSetup((unsigned char*)ptr5));
}
//---------------------------------------------------------------------------
int finishModelSetup(unsigned char* esi)
{
unsigned char *edi;
unsigned char *render23;
unsigned char *render24;
short int temp;
int eax;//, ecx;
short int bp;
unsigned char temp2;
short int counter;
short int temp3;
short int type;
short int color;
float tempFloat;
int render25;
short int ax;
short int bx;
short int cx;
lineData* lineDataPtr;
lineCoordinates* lineCoordinatesPtr;
short int vertexNumber;
int point1;
int point2;
int polyRenderType;
short int bestDepth;
short int shadeValue;
short int currentDepth;
short int shadeEntry;
struct polyHeader
{
unsigned char polyRenderType;
unsigned char numOfVertex;
unsigned short int colorIndex;
};
struct polyVertexHeader
{
unsigned short int shadeEntry;
unsigned short int dataOffset;
};
struct computedVertex
{
unsigned short int shadeValue;
unsigned short int vertexNumber;
};
polyVertexHeader* currentPolyVertex;
polyHeader* currentPolyHeader;
polyHeader* destinationHeader;
computedVertex* currentComputedVertex;
pointTab* currentVertex;
pointTab* destinationVertex;
int primitiveCounter;
short int numOfPolygons;
edi=renderTab7; // coordinate buffer
numOfPrimitives=0;
renderTabEntryPtr=primitiveList;
numOfPolygons=*(short int*)esi;
esi+=2;
if(numOfPolygons)
{
primitiveCounter=numOfPolygons;
do // loop that load all the polygones
{
render23=edi;
currentPolyHeader=(polyHeader*)esi;
// ecx=*(int*)esi;
esi+=2;
polyRenderType=currentPolyHeader->polyRenderType;
if(polyRenderType>=9)
{
destinationHeader=(polyHeader*)edi;
destinationHeader->polyRenderType = currentPolyHeader->polyRenderType-2;
destinationHeader->numOfVertex = currentPolyHeader->numOfVertex;
destinationHeader->colorIndex = currentPolyHeader->colorIndex;
esi+=2;
edi+=4;
counter=destinationHeader->numOfVertex;
bestDepth=-32000;
renderV19=edi;
do
{
currentPolyVertex=(polyVertexHeader*)esi;
shadeValue=currentPolyHeader->colorIndex+shadeTable[currentPolyVertex->shadeEntry];
currentComputedVertex=(computedVertex*)edi;
currentComputedVertex->shadeValue=shadeValue;
currentComputedVertex->vertexNumber=currentPolyVertex->dataOffset/6;
edi+=4;
esi+=4;
}while(--counter);
}
else
if(polyRenderType>=7) // only 1 shade value is used
{
destinationHeader=(polyHeader*)edi;
destinationHeader->polyRenderType = currentPolyHeader->polyRenderType-7;
destinationHeader->numOfVertex = currentPolyHeader->numOfVertex;
color=currentPolyHeader->colorIndex;
shadeEntry=*(short int*)(esi+2);
esi+=4;
*(short int*)(edi+2)=color+shadeTable[shadeEntry];
edi+=4;
renderV19=edi;
bestDepth=-32000;
counter=destinationHeader->numOfVertex;
do
{
eax=*(short int*)esi;
esi+=2;
currentComputedVertex=(computedVertex*)edi;
// currentComputedVertex->shadeValue=shadeValue;
currentComputedVertex->vertexNumber=eax/6;
edi+=4;
// currentDepth=currentVertex->z;
/* if(currentDepth>bestDepth)
bestDepth=currentDepth;*/
}while(--counter);
}
else // no shade is used
{
destinationHeader=(polyHeader*)edi;
destinationHeader->polyRenderType = currentPolyHeader->polyRenderType-2;
destinationHeader->numOfVertex = currentPolyHeader->numOfVertex;
destinationHeader->colorIndex = currentPolyHeader->colorIndex;
esi+=2;
edi+=4;
bestDepth=-32000;
renderV19=edi;
eax=0;
counter=currentPolyHeader->numOfVertex;
do
{
eax=*(unsigned short int*)esi;
esi+=2;
currentComputedVertex=(computedVertex*)edi;
// currentComputedVertex->shadeValue=shadeValue;
currentComputedVertex->vertexNumber=eax/6;
edi+=4;
/* currentDepth=currentVertex->z;
if(currentDepth>bestDepth)
bestDepth=currentDepth;*/
}while(--(counter));
}
render24=edi;
// primitiveList[numOfPrimitives].depth=render25;
primitiveList[numOfPrimitives].renderType=1;
primitiveList[numOfPrimitives].dataPtr=render23;
renderTabEntryPtr++;
numOfPrimitives++;
edi=render24;
}while(--primitiveCounter);
}
temp=*(short int*)esi;
esi+=2;
if(temp) // pour les lignes (0)
{
numOfPrimitives+=temp;
do
{
lineDataPtr=(lineData*)esi;
lineCoordinatesPtr=(lineCoordinates*)edi;
if(lineDataPtr->p1%6 != 0 || lineDataPtr->p2%6 !=0)
{
printf("lineDataPtr reference is malformed !\n");
exit(1);
}
point1=lineDataPtr->p1/6;
point2=lineDataPtr->p2/6;
lineCoordinatesPtr->data=lineDataPtr->data;
lineCoordinatesPtr->p1=point1;
lineCoordinatesPtr->p2=point2;
renderTabEntryPtr->depth=bestDepth;
renderTabEntryPtr->renderType=0;
renderTabEntryPtr->dataPtr=edi;
renderTabEntryPtr++;
esi+=8;
edi+=12;
}while(--temp);
}
temp=*(short int*)esi;
esi+=2;
if(temp)
{
circleData* circleDataPtr;
circleData* circleData2Ptr;
numOfPrimitives+=temp;
do
{
circleDataPtr=(circleData*)esi;
circleData2Ptr=(circleData*)edi;
circleData2Ptr->center=circleDataPtr->center/6;
circleData2Ptr->size=circleDataPtr->size;
circleData2Ptr->color=circleDataPtr->color;
renderTabEntryPtr->renderType=2;
renderTabEntryPtr->dataPtr=edi;
renderTabEntryPtr++;
esi+=sizeof(circleData);
edi+=sizeof(circleData);
}while(--temp);
}
return(0);
}
//---------------------------------------------------------------------------
void renderS1S2(unsigned char * esi, int ecx, pointTab *dest,int* eax)
{
// int i;
short int param1;
short int param2;
short int param3;
int ebx;
int edx;
// int var;
// int var2;
int edi;
int esip;
int ebp;
short int* tempPtr;
rs1s2v1=ecx;
do
{
rs1s2v2=esi;
tempPtr=(short int*)(esi);
param1=tempPtr[0];
param2=tempPtr[1];
param3=tempPtr[2];
dest->x=((eax[0]*param1+eax[1]*param2+eax[2]*param3)>>14)+mainTab2[18];
dest->y=((eax[3]*param1+eax[4]*param2+eax[5]*param3)>>14)+mainTab2[19];
dest->z=((eax[6]*param1+eax[7]*param2+eax[8]*param3)>>14)+mainTab2[20];
dest++;
esi=rs1s2v2+6;
}while(--rs1s2v1);
}
//---------------------------------------------------------------------------
void renderS1S1(int* eax, int* ebp)
{
int i;
int edx;
int esi;
// int ecx;
int edi;
int *ptr;
int angle;
int angleVar1; //esi
int angleVar2; //ecx
int angle2;
int angle2Var1; //esi
int angle2Var2; //ecx
if(mainTab2[12]) // rotation par vers l'avant
{
angle=mainTab2[12]&0x3FF;
angleVar2=tab1[angle];
angle+=0x100;
angle&=0x3FF;
angleVar1=tab1[angle];
eax[0]=ebp[0];
eax[3]=ebp[3];
eax[6]=ebp[6];
eax[1]=(ebp[2]*angleVar2+ebp[1]*angleVar1)>>14;
eax[2]=(ebp[2]*angleVar1-ebp[1]*angleVar2)>>14;
eax[4]=(ebp[5]*angleVar2+ebp[4]*angleVar1)>>14;
eax[5]=(ebp[5]*angleVar1-ebp[4]*angleVar2)>>14;
eax[7]=(ebp[8]*angleVar2+ebp[7]*angleVar1)>>14;
eax[8]=(ebp[8]*angleVar1-ebp[7]*angleVar2)>>14;
ebp=eax;
}
if(mainTab2[14])
{
printf("renderS1S1 -> unhandled maintTab[14] rotation\n");
exit(1);
}
if(mainTab2[13]) // rotation de coté (la plus courante)
{
if(ebp==eax)
{
ebp=&mainTab2[30];
for(i=0;i<9;i++)
*(ebp++)=*(eax++);
}
angle=mainTab2[13]&0x3FF;
angleVar2=tab1[angle]; //esi
angle+=0x100;
angle&=0x3FF;
angleVar1=tab1[angle]; //ecx
eax[1]=ebp[1];
eax[4]=ebp[4];
eax[7]=ebp[7];
eax[0]=(ebp[0]*angleVar1-ebp[2]*angleVar2)>>14;
eax[2]=(ebp[0]*angleVar2+ebp[2]*angleVar1)>>14;
eax[3]=(ebp[3]*angleVar2-ebp[5]*angleVar1)>>14;
eax[5]=(ebp[5]*angleVar2+ebp[3]*angleVar1)>>14;
eax[6]=(ebp[6]*angleVar1-ebp[8]*angleVar2)>>14;
eax[8]=(ebp[6]*angleVar2+ebp[8]*angleVar1)>>14;
return;
}
else
{
if(ebp!=eax)
for(i=0;i<9;i++)
*(eax++)=*(ebp++);
return;
}
}
//---------------------------------------------------------------------------
void renderS1(int edx, int ecx, int ebx, pointEntry* ptr)
{
int *ebp;
short int var;
// int* ptr1;
mainTab2[12]=ebx;
mainTab2[13]=ecx;
mainTab2[14]=edx;
rs1v1=ptr->data1;
rs1v2=ptr->data2;
if(rs1v1%6)
{
printf("Error: rs1V1\n");
exit(1);
}
var=ptr->param;
if(var == -1) // si c'est le premier point
{
ebp=&mainTab2[39];
mainTab2[18]=0;
mainTab2[19]=0;
mainTab2[20]=0;
}
else
{
ebp=(int*)(((unsigned char*)renderTab2)+var);
mainTab2[18]=renderTab5[ptr->data3/6].x;
mainTab2[19]=renderTab5[ptr->data3/6].y;
mainTab2[20]=renderTab5[ptr->data3/6].z;
}
renderS1S1((int*)renderV19,ebp); // de renderTab2 vers renderV19
renderS1S2(pri1Ptr+rs1v1,rs1v2,&renderTab5[rs1v1/6],(int*)renderV19);
}
//---------------------------------------------------------------------------
int renderM2(unsigned char * ptr)
{
printf("renderM2\n");
exit(1);
return(-1);
}
//---------------------------------------------------------------------------