-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbit.cpp
1358 lines (1084 loc) · 25.6 KB
/
bit.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
#include "export.h"
#include "bit.h"
#include "mem.h"
#include <cstring>
#include <cstdlib>
#include "validate.h"
#include "spool.h"
#include "utils.h"
#include "ps2lowsfx.h"
CVector gGlobalNormal;
SAnimFrame* gAnimTable[0x1D];
EXPORT CChunkBit* ChunkBitList;
EXPORT CGlow* GlowList;
CTextBox* TextBoxList = 0;
EXPORT volatile i32 BitCount = 0;
EXPORT i32 TotalBitUsage = 0;
EXPORT CFlatBit *FlatBitList;
EXPORT CSpecialDisplay *SpecialDisplayList;
EXPORT CPixel* PixelList;
u32 SparkSize = 1;
i32 gTimerRelated;
EXPORT CBit* NonRenderedBitList;
EXPORT CBit* Linked2EndedBitListLeftover;
EXPORT CBit* PolyLineList;
CBit* GPolyLineList;
EXPORT CBit* QuadBitList;
EXPORT CBit* GenPolyList;
EXPORT CBit* GlassList;
EXPORT CBit* GLineList;
EXPORT CBitServer* gBitServer = 0;
vector3d::vector3d(f32 a1, f32 a2, f32 a3)
{
this->field_0[0] = a1;
this->field_0[1] = a2;
this->field_0[2] = a3;
}
// @Ok
INLINE vector4d::vector4d(const vector3d& a1, f32 a2)
{
this->field_0[0] = a1.field_0[0];
this->field_0[1] = a1.field_0[1];
this->field_0[2] = a1.field_0[2];
this->field_0[3] = a2;
}
// @SMALLTODO
void Bit_DeleteAll(void)
{
printf("void Bit_DeleteAll(void)");
}
// @MEDIUMTODO
void DisplayGLineList(void**)
{
}
// @MEDIUMTODO
void DisplaySpecialDisplayList(void**)
{
}
// @MEDIUMTODO
void DisplayGlassList(void**)
{
}
// @MEDIUMTODO
void DisplayGlowList(void**)
{
}
// @MEDIUMTODO
void DisplayChunkBitList(void**)
{
}
// @MEDIUMTODO
void DisplayQuadBitList(void**)
{
}
// @MEDIUMTODO
void DisplayTextBoxList(void**)
{
}
// @MEDIUMTODO
void DisplayFlatBitList(void**)
{
}
// @MEDIUMTODO
void DisplayLinked2EndedBitListLeftover(void**)
{
}
// @MEDIUMTODO
void DisplayPixelList(void**)
{
}
// @MEDIUMTODO
void DisplayPolyLineList(void**)
{
}
// @MEDIUMTODO
void DisplayGPolyLineList(void**)
{
}
// @Ok
void Bit_Init(void)
{
BitCount = 0;
NonRenderedBitList = 0;
TextBoxList = 0;
FlatBitList = 0;
Linked2EndedBitListLeftover = 0;
PixelList = 0;
PolyLineList = 0;
GPolyLineList = 0;
QuadBitList = 0;
GenPolyList = 0;
ChunkBitList = 0;
GlowList = 0;
GlassList = 0;
GLineList = 0;
SpecialDisplayList = 0;
if (gBitServer)
{
gBitServer = new CBitServer();
gBitServer->RegisterSlot(reinterpret_cast<void**>(&TextBoxList), DisplayTextBoxList);
gBitServer->RegisterSlot(reinterpret_cast<void**>(&FlatBitList), DisplayFlatBitList);
gBitServer->RegisterSlot(reinterpret_cast<void**>(&Linked2EndedBitListLeftover), DisplayLinked2EndedBitListLeftover);
gBitServer->RegisterSlot(reinterpret_cast<void**>(&PixelList), DisplayPixelList);
gBitServer->RegisterSlot(reinterpret_cast<void**>(&PolyLineList), DisplayPolyLineList);
gBitServer->RegisterSlot(reinterpret_cast<void**>(&GPolyLineList), DisplayGPolyLineList);
gBitServer->RegisterSlot(reinterpret_cast<void**>(&QuadBitList), DisplayQuadBitList);
gBitServer->RegisterSlot(reinterpret_cast<void**>(&ChunkBitList), DisplayChunkBitList);
gBitServer->RegisterSlot(reinterpret_cast<void**>(&GlowList), DisplayGlowList);
gBitServer->RegisterSlot(reinterpret_cast<void**>(&GlassList), DisplayGlassList);
gBitServer->RegisterSlot(reinterpret_cast<void**>(&GLineList), DisplayGLineList);
gBitServer->RegisterSlot(reinterpret_cast<void**>(&SpecialDisplayList), DisplaySpecialDisplayList);
}
setDrawTPage();
memset(gAnimTable, 0, sizeof(gAnimTable));
}
// @Ok
void Bit_SetSparkSize(u32 size)
{
print_if_false(size < 0x10, "Daft spark size");
SparkSize = size | (size << 16);
}
// @MEDIUMTODO
CWibbly::CWibbly(u8,u8,u8,i32,i32 a6,i32,i32,i32,i32,i32,i32,i32,i32)
: CGouraudRibbon(a6 + 1, 0)
{
printf("CWibbly::CWibbly(u8,u8,u8,i32,i32,i32,i32,i32,i32,i32,i32,i32,i32)");
}
// @MEDIUMTODO
void CWibbly::Move(void)
{
printf("CWibbly::Move(void)");
}
// @Ok
void CWibbly::SetCore(
u8 a2,
u8 a3,
u8 a4,
i32 a5)
{
delete this->field_48;
this->field_48 = new CGouraudRibbon(this->mNumPoints, 0);
this->field_48->mProtected = 1;
this->field_48->SetRGB(a2, a3, a4);
this->field_48->SetWidth(a5);
}
// @Ok
void CWibbly::SetEndPoints(
CVector* a2,
CVector* a3)
{
this->field_4C = *a2;
this->field_58 = (*a3 - *a2) / (this->mNumPoints - 1);
CSVector v12;
v12.vx = 0;
v12.vy = 0;
v12.vz = 0;
Utils_CalcAim(&v12, a2, a3);
v12.vy = (v12.vy + 1024) & 0xFFF;
Utils_GetVecFromMagDir(&this->field_64, this->field_7C, &v12);
v12.vy = (v12.vy - 1024) & 0xFFF;
v12.vx = (v12.vx + 1024) & 0xFFF;
Utils_GetVecFromMagDir(&this->field_70, this->field_88, &v12);
}
// @Ok
CWibbly::~CWibbly(void)
{
delete this->field_48;
}
// @Ok
CFireyExplosion::CFireyExplosion(CVector* pPos)
{
this->mPos = *pPos;
this->field_E = 50;
SFX_PlayPos(1, &this->mPos, 0);
}
// @Ok
CFireyExplosion::~CFireyExplosion(void)
{
}
// @Ok
CCombatImpactRing::~CCombatImpactRing(void)
{
}
// @Ok
CTextBox::CTextBox(
i32 a2,
i32 a3,
i32 a4,
i32 a5,
u32 a6,
CFriction* pFric)
{
this->AttachTo(reinterpret_cast<CBit**>(&TextBoxList));
this->mPos.vx = a2;
this->mPos.vy = a3;
this->mVel.vx = a4;
this->mVel.vy = a5;
this->mFric.vx = pFric->vx;
this->mFric.vy = pFric->vy;
this->mFric.vz = pFric->vz;
this->field_E = a6;
this->field_3C = gTimerRelated;
}
// @Ok
CTextBox::~CTextBox(void)
{
this->DeleteFrom(reinterpret_cast<CBit**>(&TextBoxList));
}
// @SMALLTODO
CChunkBit::CChunkBit(CSVector*, CSVector*, CSVector*)
{
printf("CChunkBit::CChunkBit(CSVector*, CSVector*, CSVector*)");
}
// @Ok
CChunkBit::~CChunkBit(void)
{
this->DeleteFrom(reinterpret_cast<CBit**>(&ChunkBitList));
}
// @Ok
CBitServer::CBitServer(void)
{
this->mNumEntries = 0;
}
// @Ok
CBitServer::~CBitServer(void)
{
}
// @Ok
// so close but that while loop is hard to match, prob because they didn't create a type
INLINE u32 CBitServer::RegisterSlot(void** bitList, void (*drawFunc)(void**))
{
u32 usedSlot = this->mNumEntries;
if (usedSlot < 0x20)
{
this->mEntry[usedSlot].field_0 = bitList;
this->mEntry[usedSlot].field_4 = drawFunc;
usedSlot = this->mNumEntries;
this->mNumEntries = usedSlot + 1;
u32 curSlot = this->mNumEntries;
while (curSlot < 0x20)
{
if (this->mEntry[curSlot++].field_0 == 0)
return usedSlot;
this->mNumEntries = curSlot;
}
this->mNumEntries = 666;
}
return this->mNumEntries;
}
// @Ok
void CBitServer::DisplayRegisteredSlots(void)
{
for (i32 i = 0; i < 0x20; i++)
{
if (this->mEntry[i].field_0)
this->mEntry[i].field_4(this->mEntry[i].field_0);
}
}
// @Ok
CPixel::~CPixel(void)
{
this->DeleteFrom(reinterpret_cast<CBit**>(&PixelList));
}
// @Ok
CPixel::CPixel(void)
{
this->AttachTo(reinterpret_cast<CBit**>(&PixelList));
}
// @SMALLTODO
CFrag::CFrag(CVector*, u8, u8, u8, i32, u16, i32, i32, i32, i32)
{
printf("CFrag::CFrag(CVector*, u8, u8, u8, i32, u16, i32, i32, i32, i32);");
}
// @Ok
// @Matching
void CGlow::SetFringeWidth(u32 Fringe, u32 Width)
{
print_if_false(Fringe < this->mNumFringes, "Bad Fringe sent to SetFringeWidth");
SFringeQuad* pFringe = &this->mpFringes[Fringe * this->mNumSections];
for (u32 i = 0; i < this->mNumSections; i++)
{
pFringe[i].Width = Width;
}
}
// @Ok
// @CloseMatching - bruh lea vs add
void CGlow::SetFringeRGB(
u32 Fringe,
u8 r,
u8 g,
u8 b)
{
print_if_false(Fringe < this->mNumFringes, "Bad Fringe sent to SetFringeRGB");
u32 val = (((((0x3A << 8) | b) << 8) | g ) << 8) | r;
SFringeQuad* pFringe = &this->mpFringes[Fringe * this->mNumFringes];
for (u32 i = 0; i < this->mNumSections; i++)
{
pFringe[i].CodeBGR = val;
}
}
// @SMALLTODO
CCombatImpactRing::CCombatImpactRing(CVector*, u8, u8, u8, i32, i32, i32)
{
printf("CCombatImpactRing::CCombatImpactRing(CVector*, u8, u8, u8, i32, i32, i32)");
}
// @SMALLTODO
CSimpleAnim::CSimpleAnim(CVector*, i32, u16, i32, i32, i32)
{
printf("CSimpleAnim::CSimpleAnim(CVector*, i32, u16, i32, i32, i32)");
}
// @SMALLTODO
void CRibbon::SetScale(i32)
{
printf("void CRibbon:SetScale(i32)");
}
// @SMALLTODO
CRibbon::CRibbon(CVector*, i32, i32, i32, i32, i32, i32)
{
printf("CRibbon::CRibbon(CVector*, i32, i32, i32, i32, i32, i32)");
}
// @SMALLTODO
CSmokeTrail::CSmokeTrail(
CVector* a2,
i32 a3,
i32, i32, i32)
: CRibbon(a2, a3, 2, 2, 2, 400, 1)
{
printf("CSmokeTrail::CSmokeTrail(CVector*, i32, i32, i32, i32)");
}
// @Ok
// @Note: code works because sizeof(SFringeQuad) == sizeof(SSection), weird shit
CGlow::CGlow(u32 NumPoints, u32 NumFringes)
{
print_if_false(NumPoints != 0, "Bad NumPoints sent to CGlow");
this->mNumSections = 2 * NumPoints;
this->mStepAngle = 0x1000u / (2 * NumPoints);
this->mNumFringes = NumFringes;
// This shit weird
this->mpSections = static_cast<SSection*>(DCMem_New(sizeof(SSection) * (this->mNumSections + this->mNumSections * this->mNumFringes), 0, 1, 0, 1));
this->mpFringes = reinterpret_cast<SFringeQuad*>(&this->mpSections[this->mNumSections]);
for (u32 i = 0; i < this->mNumSections * this->mNumFringes; i++)
{
this->mpFringes[i].CodeBGR = 0x3A000000;
}
this->mCentreCodeBGR = 0x32000000;
this->mMask = -1;
this->AttachTo(reinterpret_cast<CBit**>(&GlowList));
}
// @Ok
CGlow::~CGlow(void)
{
Mem_Delete(static_cast<void*>(this->mpSections));
this->DeleteFrom(reinterpret_cast<CBit**>(&GlowList));
}
// @MEDIUMTODO
void CQuadBit::OrientUsing(CVector *, SVECTOR *, i32, i32, i32)
{
printf("CQuadBit::OrientUsing(CVector *, SVECTOR *, i32, i32, i32)");
}
// @NotOk
// @Test
// remove reinterpret cast, understand whta devs did
void CQuadBit::SetTexture(u32 checksum)
{
Texture *pTexture = Spool_FindTextureEntry(checksum);
this->mpTexture = pTexture;
if (pTexture)
{
if (pTexture->field_12 & 0xF0)
this->mCodeBGR |= 0x20;
// @FIXME
u32* arr = reinterpret_cast<u32*>(pTexture);
this->field_74 = arr[0];
this->field_74 = arr[1];
this->field_74 = arr[2];
this->field_80 = pTexture->TexWin;
}
}
// @MEDIUMTODO
CGlow::CGlow(
CVector* pVector,
i32 a3,
i32 a4,
u8 a5,
u8 a6,
u8 a7,
u8 a8,
u8 a9,
u8 a10)
{
printf("CGlow::CGlow");
}
// @Ok
CFlatBit::~CFlatBit(void)
{
this->DeleteFrom(reinterpret_cast<CBit**>(&FlatBitList));
}
// @Ok
// @Test
void CMotionBlur::Move(void)
{
this->mPos.vx += this->mVel.vx;
this->mPos.vy += this->mVel.vy;
this->mPos.vz += this->mVel.vz;
this->mScale -= this->field_3E;
if (this->mScale < 0)
{
this->mScale = 0;
this->Die();
return;
}
u8 mCodeBGR = this->mCodeBGR;
i16 mTransDecay = this->mTransDecay;
u32 v10 = this->mCodeBGR >> 8;
u32 mCodeBGR_high = (this->mCodeBGR >> 16);
u8 v18;
if ( mTransDecay > mCodeBGR )
v18 = 0;
else
v18 = mCodeBGR - (this->mTransDecay & 0xFF);
u8 v12;
if ( mTransDecay > (u8)v10 )
v12 = 0;
else
v12 = v10 - (this->mTransDecay & 0xFF);
u8 v13;
if ( mTransDecay > (u8)mCodeBGR_high )
v13 = 0;
else
v13 = mCodeBGR_high - (this->mTransDecay & 0xFF);
u16 v14 = (v13 << 8) | v12;
this->mCodeBGR = v18 | this->mCodeBGR & 0xFF000000 | (v14 << 8);
if (!(this->mCodeBGR & 0xFFFFFF))
{
this->Die();
return;
}
if ( ++this->field_C & 1)
{
if ( ++this->field_52 >= this->field_51 )
this->field_52 = 0;
}
this->field_4C = &this->mPSXAnim[this->field_52];
}
// @Ok
CMotionBlur::CMotionBlur(
CVector* a2,
CVector* a3,
i32 a4,
i32 a5,
i32 a6,
i32 a7)
{
this->mPos = *a2;
this->mVel = *a3;
this->SetAnim(a4);
this->SetSemiTransparent();
this->mScale = a5;
this->field_3E = a6;
this->mTransDecay = a7;
}
// @Ok
CBit::CBit() {
this->mPos.vx = 0;
this->mPos.vy = 0;
this->mPos.vz = 0;
this->mVel.vx = 0;
this->mVel.vy = 0;
this->mVel.vz = 0;
this->mAcc.vx = 0;
this->mAcc.vy = 0;
this->mAcc.vz = 0;
//mFric is inited to 0 here but removed
this->mFric.vx = 1;
this->mFric.vy = 1;
this->mFric.vz = 1;
BitCount++;
}
/*
* With optimizations the >>=2 expression is removed
* taking a look at THPS2 it shows it's due
* to it storing the result in a global variable. For some reason
* both PC and MAC remove the store
*/
void* CBit::operator new(size_t size) {
void *result;
if (TotalBitUsage == 0)
result = DCMem_New(size, 0, 1, 0, 1);
else
result = DCMem_New(size, 0, 1, 0, 1);
unsigned int quarter = size + 3;
quarter &= 0xFFFFFFFC;
/*
TotalBitUsage += 4 + quarter;
*/
quarter >>= 2; // optimized out
if (quarter)
memset(result, 0, 4 * quarter);
return result;
}
// @Ok
void CBit::operator delete(void* ptr)
{
Mem_Delete(ptr);
}
// @NotOk
// revisit, there's a weird mem_delete
CBit::~CBit()
{
}
// @Ok
void CBit::Die(void){
print_if_false(this->mProtected == 0, "A protected bit die");
this->mDead = 1;
}
// @Ok
CBit* CBit::AttachTo(CBit** to){
CBit* tmp;
CBit* result;
tmp = *to;
this->mPrevious = NULL;
this->mNext = tmp;
*to = this;
result = this->mNext;
if (result)
result->mPrevious = this;
return result;
}
// @Ok
void CBit::SetPos(const CVector &pos){
this->mPos = pos;
}
// @Ok
INLINE void CBit::DeleteFrom(CBit **lst){
CBit* next = this->mNext;
if(next != NULL){
next->mPrevious = this->mPrevious;
}
CBit* prev = this->mPrevious;
if(prev != NULL){
prev->mNext = this->mNext;
}
if(*lst == this){
*lst = this->mNext;
}
}
// @Ok
void CQuadBit::SetTint(unsigned char a2, unsigned char a3, unsigned char a4)
{
this->mTint = a2 | ((a4 << 16) & 0xFF0000 | (a3 << 8) & 0xFF00) & 0xFFFFFF00;
}
// @Ok
void CQuadBit::SetSemiTransparent()
{
this->mCodeBGR = (this->mCodeBGR & 0xFFFFFFFE) | 0x2C0;
}
// @Ok
void CQuadBit::SetOpaque(){
this->mCodeBGR = (this->mCodeBGR & 0xFFFFFDBF) | 0x80;
}
// @Ok
void CQuadBit::SetSubtractiveTransparency(){
this->mCodeBGR = (this->mCodeBGR & 0xFFFFFF7F) | 0x340;
}
// @Ok
void CQuadBit::SetCorners(const CVector &a2, const CVector &a3, const CVector &a4, const CVector &a5)
{
this->mPos = a2;
this->mPosB = a3;
this->mPosC = a4;
this->mPosD = a5;
}
// @Ok
void CQuadBit::SetTransparency(unsigned char a2){
this->mTint = a2 | ((a2 | (a2 << 8)) << 8);
}
// @MEDIUMTODO
void CQuadBit::OrientUsing(CVector *a2, SVECTOR *a3, int a4, int a5)
{
}
// @MEDIUMTODO
void CQuadBit::SetTexture(int a, int b){
}
// @SMALLTODO
void CQuadBit::SetTexture(Texture*)
{
printf("void CQuadBit::SetTexture(Texture*)");
}
// @Ok
CFT4Bit::~CFT4Bit()
{
if (this->mDeleteAnimOnDestruction)
Mem_Delete(reinterpret_cast<void*>(this->mPSXAnim));
}
// @Ok
void CFT4Bit::SetAnimSpeed(short s){
this->mAnimSpeed = s;
}
// @Ok
void CFT4Bit::SetScale(unsigned short s){
this->mScale = s;
}
// @Ok
void CFT4Bit::SetSemiTransparent(){
this->mCodeBGR |= 0x2000000;
}
// @Ok
void CFT4Bit::SetTransparency(unsigned char t){
this->mCodeBGR = t | this->mCodeBGR & 0xFF000000 | ((t | (t << 8)) << 8);
}
static const unsigned int maxANimTableEntry = 0x1D;
// @Ok
void CFT4Bit::SetAnim(int a2){
char v5; // cl
print_if_false(a2 >= 0 && !((unsigned int)a2 >= maxANimTableEntry), "Bad lookup value sent to SetAnim");
print_if_false(this->mDeleteAnimOnDestruction == 0, "mDeleteAnimOnDestruction set?");
// @FIXME
int v4 = reinterpret_cast<i32>(gAnimTable[a2]);
this->mPSXAnim = reinterpret_cast<SCFT4BitTexture*>(v4);
v5 = *(char *)(v4 - 4);
this->field_53 = 0;
this->field_51 = v5;
this->field_52 = 0;
this->field_4C = this->mPSXAnim;
}
// @Ok
void CFT4Bit::SetTint(unsigned char a2, unsigned char a3, unsigned char a4)
{
int tmp = this->mCodeBGR & 0xFF000000;
this->mCodeBGR = a2 | tmp | (((a4 << 8) | a3) << 8);
}
// @Ok
void CFT4Bit::SetTexture(Texture* pTexture)
{
int v4; // ecx
int v5; // eax
int v6; // edx
int v7; // ecx
print_if_false(this->mPSXAnim == 0, "mpPSXAnim already set?");
print_if_false(pTexture != 0, "No Texture for SetTexture");
this->mPSXAnim = (SCFT4BitTexture *)DCMem_New(8, 0, 1, 0, 1);
this->mDeleteAnimOnDestruction = 1;
v4 = (unsigned __int8)pTexture->v2;
v5 = (unsigned __int8)pTexture->u1 - (unsigned __int8)pTexture->u0;
v6 = (unsigned __int8)pTexture->v0;
this->mPSXAnim->field_2 = v5;
v7 = v4 - v6;
this->mPSXAnim->field_3 = v7;
this->mPSXAnim->field_0 = v5 / -2;
this->mPSXAnim->field_1 = v7 / -2;
this->mPSXAnim->field_4 = pTexture;
this->field_4C = this->mPSXAnim;
this->field_51 = 1;
}
// @Ok
void CFT4Bit::SetTexture(unsigned int Checksum)
{
int v4; // ecx
int v5; // eax
int v6; // edx
int v7; // ecx
print_if_false(this->mPSXAnim == 0, "mpPSXAnim already set?");
Texture *pTexture = Spool_FindTextureEntry(Checksum);
print_if_false(pTexture != 0, "Bad checksum sent to SetTexture");
this->mPSXAnim = (SCFT4BitTexture *)DCMem_New(8, 0, 1, 0, 1);
this->mDeleteAnimOnDestruction = 1;
v4 = (unsigned __int8)pTexture->v2;
v5 = (unsigned __int8)pTexture->u1 - (unsigned __int8)pTexture->u0;
v6 = (unsigned __int8)pTexture->v0;
this->mPSXAnim->field_2 = v5;
v7 = v4 - v6;
this->mPSXAnim->field_3 = v7;
this->mPSXAnim->field_0 = v5 / -2;
this->mPSXAnim->field_1 = v7 / -2;
this->mPSXAnim->field_4 = pTexture;
this->field_4C = this->mPSXAnim;
this->field_51 = 1;
}
// @Ok
// not matching becausae they assign all mCodeBGR at beggining
int CFT4Bit::Fade(int a2)
{
int mCodeBGR = this->mCodeBGR;
if (!(mCodeBGR & 0xFFFFFF))
{
this->Die();
return 1;
}
unsigned __int16 v6 = this->mTransDecay;
unsigned char v10;
if (v6 > (unsigned __int16)(this->mCodeBGR & 0xFF))
v10 = 0;
else
v10 = (this->mCodeBGR & 0xFF) - (this->mTransDecay & 0xFF);
unsigned char v7;
if (v6 > (unsigned __int16)((this->mCodeBGR & 0xFF00) >> 8))
v7 = 0;
else
v7 = ((this->mCodeBGR & 0xFF00) >> 8) - (this->mTransDecay & 0xFF);
unsigned char v8;
if (v6 > (unsigned __int16)((this->mCodeBGR & 0xFF0000) >> 16))
v8 = 0;
else
v8 = ((this->mCodeBGR & 0xFFFF00) >> 16) - (this->mTransDecay & 0xFF);
this->mCodeBGR = (mCodeBGR & 0xFF000000) | (((v8 << 8) | v7) << 8) | v10;
return 0;
}
// @MEDIUMTODO
int Bit_MakeSpriteRing(CVector*, int, int, int, int, int, int, int)
{
return 0x420690;
}
// @Ok
void CBit::Move(void)
{
}
// @Ok
void MoveList(CBit *pBit)
{
for (CBit *p = pBit; p; p = p->mNext)
{
if (!p->mDead)
p->Move();
}
}
static unsigned char gSparkR;
static unsigned char gSparkG;
static unsigned char gSparkB;
// @NotOk
// Globals
void Bit_SetSparkRGB(unsigned char r, unsigned char g, unsigned char b)
{
gSparkR = r;
gSparkG = g;
gSparkB = b;
}
static unsigned char gSparkFadeR;
static unsigned char gSparkFadeG;
static unsigned char gSparkFadeB;
// @NotOk
// Globals
void Bit_SetSparkFadeRGB(unsigned char r, unsigned char g, unsigned char b)
{
gSparkFadeR = r;
gSparkFadeG = g;
gSparkFadeB = b;
}
// @Ok
CSpecialDisplay::CSpecialDisplay(void)
{
this->AttachTo(reinterpret_cast<CBit**>(SpecialDisplayList));
}
// @Ok
void CGlow::SetCentreRGB(unsigned char a2, unsigned char a3, unsigned char a4)
{
this->mCentreCodeBGR = 0x32000000 | (((a4 << 8) | a3) << 8) | a2;
}
static CSVector gSparkTrajectory;
// @NotOk
// global
void Bit_SetSparkTrajectory(const CSVector *pVec)
{
gSparkTrajectory = *pVec;
}
static CSVector gSparkTrajectoryCone;
// @NotOk
// global
void Bit_SetSparkTrajectoryCone(const CSVector *pVec)
{
gSparkTrajectoryCone = *pVec;
}
// @Ok
CFT4Bit::CFT4Bit(void)
{
this->mAnimSpeed = 0x80;
this->mScale = 400;
this->mCodeBGR = 0x2C808080;
}
// @NotOk
// globals
CLinked2EndedBit::CLinked2EndedBit(void)