-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGraphics.cpp
More file actions
3186 lines (3015 loc) · 75.4 KB
/
Graphics.cpp
File metadata and controls
3186 lines (3015 loc) · 75.4 KB
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 "stdafx.h"
#include "UI.h"
#include <stdio.h>
//#include "Objects.h"
#include "Dispatch.h"
#include "CSB.h"
#include "Data.h"
//extern CDC *OnDrawDC;
void info(char *, unsigned int);
void CleanupAltMonCache();
void CleanupWallDecorations();
//void CleanupFloorDecorations();
extern FILETABLE fileTable[maxFilesOpen];
extern char *helpMessage;
extern bool overlayActive;
extern TEMPORARY_FILE CSBgraphicsFile;
extern ui8 overlayPaletteRed[512];
extern ui8 overlayPaletteGreen[512];
extern ui8 overlayPaletteBlue[512];
const char *(CSBGraphicsSectionNames[]) = {
"Viewport Overlay",
"Portrait",
"Sound",
"Background Graphic",
"Viewport Palette",
"Alternate Monster Graphic",
"Wall Decorations",
"Floor Decorations",
};
#ifdef GraphicsDebug
extern FILE *GrphDbg;
#endif
class SCREEN
{
private:
ui8 *m_physScreenBase;
ui8 *m_logScreenBase;
ui8 *m_physAllocated; // The buffer we allocated
ui8 *m_logAllocated; // The buffer we allocated
public:
SCREEN();
~SCREEN();
ui8 *physbase();
ui8 *logbase();
void physbase(ui8 *newphys);
void logbase(ui8 *newlog);
};
SCREEN::SCREEN()
{
m_physAllocated = NULL;
m_logAllocated = NULL;
m_physScreenBase = NULL;
m_logScreenBase = NULL;
}
SCREEN::~SCREEN()
{
if (m_physAllocated != NULL) UI_free (m_physAllocated);
m_physScreenBase = NULL;
m_physAllocated = NULL;
if (m_logAllocated) UI_free(m_logAllocated);
m_logScreenBase = NULL;
m_logAllocated = NULL;
}
ui8 *SCREEN::physbase()
{
if (m_physScreenBase == NULL)
{
if (m_physAllocated == NULL)
m_physAllocated = (ui8 *)UI_malloc(32000, MALLOC026);
if (m_physAllocated == NULL)
{
UI_MessageBox("Cannot allocate memory",NULL,MESSAGE_OK);
die(0x5fd1);
};
m_physScreenBase = m_physAllocated;
};
return m_physScreenBase;
}
void SCREEN::physbase(ui8* newphys)
{
m_physScreenBase = newphys;
}
ui8 *SCREEN::logbase()
{
if (m_logScreenBase == NULL)
{
if (m_logAllocated == NULL)
m_logAllocated = (ui8 *)UI_malloc(32000, MALLOC027);
if (m_logAllocated == NULL)
{
UI_MessageBox("Cannot allocate memory",NULL,MESSAGE_OK);
die(0x6fd3);
};
m_logScreenBase = m_logAllocated;
};
return m_logScreenBase;
}
void SCREEN::logbase(ui8* newlog)
{
m_logScreenBase = newlog;
}
SCREEN screen;
i16 globalPalette[16] = { // RGB top-to-bottom
0x777, 0x700, 0x070, 0x007, 0x111, 0x222, 0x333, 0x444,
0x555, 0x000, 0x001, 0x010, 0x100, 0x200, 0x020, 0x002
};
void setscreen(ui8 *log,ui8 *phys,i16 /*res*/)
{
if ((i32)phys != -1) screen.physbase(phys);
if ((i32)log != -1) screen.logbase(log);
}
ui8 *physbase()
{
return screen.physbase();
}
ui8 *logbase()
{
return screen.logbase();
}
void SetDLogicalBase(ui8 *b)
{
d.LogicalScreenBase = b;
if (d.Pointer12926 == NULL) d.Pointer12926 =
(pnt)UI_malloc(768, MALLOC028);
}
/*
void VerifyGraphicFreeList()
{
ITEMQ *pCur, *pNext;
pCur = d.pgUnused;
if (pCur != NULL)
{
ASSERT(pCur->pgPrev() == NULL,"pCur");
};
while (pCur != NULL)
{
pNext=pCur->pgNext();
if (pNext != NULL)
{
ASSERT(pNext->pgPrev() == pCur,"pNext");
ASSERT(pNext->size <= pCur->size,"pNext");
ASSERT(pNext != pCur,"pNext");
};
pCur = pNext;
};
}
*/
// *********************************************************
//
// *********************************************************
void TAG0013e4(OBJ_NAME_INDEX P1, i32 xPixel, i32 yPixel)
{
RectPos rectpos;
ui8 *pnt_4;
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pnt_4 = (ui8 *)allocateMemory(128, 0);
rectpos.w.x1 = sw(xPixel);
rectpos.w.x2 = (i16)(rectpos.w.x1 + 15);
rectpos.w.y1 = sw(yPixel);
rectpos.w.y2 = (i16)(rectpos.w.y1 + 15);
GetIconGraphic(P1, pnt_4);
BLT2Screen(pnt_4, &rectpos, 8, -1);
FreeTempMemory(128);
}
// Internal function to make TextOut easier to read
// TAG0016d8
void BltOneChar(dReg& D2,
dReg& D3,
//dReg& D4,
dReg& D5,
aReg& A2,
aReg A3,
i32 A3inc,
i32 jA0,
i32 jA1)
{
dReg D0, D1, D6, D7;
i32 lineCounter;
for (lineCounter=0; lineCounter<6; lineCounter++)
{
longGear((ui8 *)A3+0) &= LE32(D2L);
longGear((ui8 *)A3+4) &= LE32(D2L);
D0L = (UI8)(*A2);
switch (D5W)
{
case 0:
D0W <<= 11-D3W;
break;
case 8:
D0UW >>= D3W-11;
break;
case 18:
D0W <<= 27-D3W;
break;
default: NotImplemented(0x16fc);
};
//D1W = D0W;
//SWAP(D1);
//D1W = D0W;
D1H2 = D0H2;
D1H1 = D0H2;
SWAP(D0);
D6L = 0;
D7L = 0;
switch (jA0&0xffff)
{
case 1: D6L = D0L; break;
case 2: D6W = D1W; break;
case 3: D6L = D1L; break;
case 4: D7L = D0L; break;
case 5: D6L = D0L; D7L = D0L; break;
case 6: D6W = D1W; D7L = D0L; break;
case 7: D6L = D1L; D7L = D0L; break;
case 8: D7W = D1W; break;
case 9: D6L = D0L; D7W = D1W; break;
case 10: D6W = D1W; D7W = D1W; break;
case 11: D6L = D1L; D7W = D1W; break;
case 12: D7L = D1L; break;
case 13: D6L = D0L; D7L = D1L; break;
case 14: D6W = D1W; D7L = D1L; break;
case 15: D6L = D1L; D7L = D1L; break;
case 0: break;
default: NotImplemented(0x1756);
};
D0L |= D2L;
D0L ^= 0xffffffff;
D0W = 0;
D1L |= D2L;
D1L ^= 0xffffffff;
switch (jA1&0xffff)
{
case 1: D6L |= D0L; break;
case 2: D6W |= D1W; break;
case 3: D6L |= D1L; break;
case 4: D7L |= D0L; break;
case 5: D6L |= D0L; D7L |= D0L; break;
case 6: D6W |= D1W; D7L |= D0L; break;
case 7: D6L |= D1L; D7L |= D0L; break;
case 8: D7W |= D1W; break;
case 9: D6L |= D0L; D7W |= D1W; break;
case 10: D6W |= D1W; D7W |= D1W; break;
case 11: D6L |= D1L; D7W |= D1W; break;
case 12: D7L |= D1L; break;
case 13: D6L |= D0L; D7L |= D1L; break;
case 14: D6W |= D1W; D7L |= D1L; break;
case 15: D6L |= D1L; D7L |= D1L; break;
case 0: break;
default: NotImplemented(0x17ae);
}
longGear((ui8 *)A3+0) |= LE32(D6L);
longGear((ui8 *)A3+4) |= LE32(D7L);
A2 += 128;
A3 += A3inc;
}
A2 -= 128;
A3 -= A3inc;
}
// TAG00154c
void TextOut_OneLine(ui8 *dest,
i32 destWidth,
i32 x,
i32 y,
i32 color,
i32 P6,
const char *text,
i32 maxLineLength,
bool translate)
{
dReg D2, D3, D4, D5, D6, D7;
i32 saveD2;
const char *A0;
aReg A2, A3, saveA2, saveA3;
i32 jA0, jA1;
i32 numCharactersDisplayed;
if (translate)
{
text = TranslateLanguage(text);
};
A2 = NULL;
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
A3 = (aReg)dest;
D7W = (i16)x;
D6W = (i16)y;
//D5W = P5;
D4W = (i16)P6;
A0 = text;
if (*A0 == 0) return;
A3 += (D6W - 4) * destWidth;
A3 += (D7UW & 0xfff0)>>1;//UWed
D3W = (i16)(D7W & 15);
jA0 = color; // 16 colors
jA1 = D4W;
numCharactersDisplayed = 0;
tag001660:
for (;;)
{
do
{
if (numCharactersDisplayed == maxLineLength) return;
numCharactersDisplayed++;
D2L = 0;
D2B = *text;
if (D2W ==0) return;
text++;
A2 = d.Pointer12926 + D2W;
if (D3W > 11) goto tag0016a0;
//D4L = 6;
D2L = 0x07ff07ff;
D2UL >>= D3W;//ULed
D2H1 = D2W;
D5L = 0;
BltOneChar(D2, D3, D5, A2, A3, destWidth, jA0, jA1);
D3W += 6;
} while (D3W < 16);
D3W &= 1;
A3 += 8;
};
tag0016a0:
//D4L = 6;
saveA3 = A3 + 8;
saveA2 = A2;
D2L = LE32(d.Long1812[D3W-12]);
//D2L = longGear((pnt)&d.Pointer1860+D3W);
//saveD2L = longGear((pnt)&d.Word1876+D3W);
saveD2 = LE32(d.Long1828[D3W-12]);
A2 = saveA2;
D5L = 8;
BltOneChar(D2, D3, D5, A2, A3, destWidth, jA0, jA1);
D2L = saveD2;
A2 = saveA2;
A3 = saveA3;;
//D4L = 6;
D5L = 18;
BltOneChar(D2, D3, D5, A2, A3, destWidth, jA0, jA1);
A3 = saveA3;
D3W -= 10;
goto tag001660;
}
//TAG008498
void ShrinkBLT(ui8 *src,
ui8 *dst,
i32 srcWidth, // in pixels
i32 srcHeight,
i32 dstWidth,
i32 dstHeight,
ui8 *pColorMap)
{ // 8 12 16 18 20 22 24
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dReg D0, D1, D2, D3, D4, D5, D7, D6;
aReg A2, A3, A4;
//i32 saveD4=D4,saveD5=D5,saveD6=D6,saveD7=D7;
//pnt saveA2=A2,saveA3=A3,saveA4=A4,saveA5=A5;
i16 LOCAL_10;
i32 LOCAL_8, LOCAL_4;
i16 pushedD3;
//A5 = P7;
//A0 = src;
// A1 = dst;
D1L = 0;
D1W = sw(srcWidth);
D0L = 15;
D0W = (i16)((D0W + D1W) & 0xfff0); //# of 16 pixel hunks in source
D0UW >>= 1;//UWed
LOCAL_10 = D0W;
D3W = sw(dstWidth);
D2L = 10;
D1L <<= D2B;
D1L = (D1UL/D3UW) & 0xffff;
D1L <<= 6;
A2 = (pnt)D1L;
D1UL >>= 1;//ULed
D1L += 0x7fff;
LOCAL_8 = D1L;
D1L = 0;
D1W = sw(srcHeight);
D1L <<= D2B;
D1L = (D1UL/(ui16)dstHeight)&0xffff;
D1L <<= 6;
LOCAL_4 = D1L;
D1UL >>= 1;//ULed
D1L += 0x7fff;
A4 = (pnt)D1L;
D1UL >>= 16;//ULed
D0L = D1UW*D0UW;
src += D0W;
pushedD3 = D3W;
tag00850a:
A3 = (pnt)-1;
D4L = LOCAL_8;
D7L = 0x80008000;
tag008518:
D2L = 0;
D3L = 0;
tag00851c:
SWAP(D4);
D6L = -16;
D6W &= D4W;
if ((ui16)D6W != LOW_I16(A3))
{
A3 = (pnt)((int)D6W);
D6UW >>= 1;//UWed
D0L = LE32(longGear(src+D6W));
D1L = LE32(longGear(src+D6W+4));
};
D6L = 15;
D6W &= D4W;
D6W = (i16)(-D6W);
D6W +=15;
D5L = 0;
if (D0L & (1<<D6B)) D5L = 2;
if (D1L & (1<<D6B)) D5W += 8;
D6W += 16;
if (D0L & (1<<D6W)) D5W +=1;
if (D1L & (1<<D6W)) D5W +=4;
D5B = *(pColorMap + D5W);
// if (D5B != 0)
// {
// i32 iii=1;
// };
switch (D5W/10)
{
case 0: break;
case 1: D2H1 |= D7W; break;
case 2: D2W |= D7W; break;
case 3: D2L |= D7L; break;
case 4: D3H1 |= D7W; break;
case 5: D2H1 |= D7W; D3H1 |= D7W; break;
case 6: D2W |= D7W; D3H1 |= D7W; break;
case 7: D2L |= D7L; D3H1 |= D7W; break;
case 8: D3W |= D7W; break;
case 9: D3W |= D7W; D2H1 |= D7W; break;
case 10: D2W |= D7W; D3W |= D7W; break;
case 11: D2L |= D7L; D3W |= D7W; break;
case 12: D3L |= D7L; break;
case 13: D2H1 |= D7W; D3L |= D7L; break;
case 14: D2W |= D7W; D3L |= D7L; break;
case 15: D2L |= D7L; D3L |= D7L; break;
default:
NotImplemented(0x85f8);
};
pushedD3--;
if (pushedD3 != 0)
{
SWAP(D4);
D4L += (i32)A2;
D7L = ((D7L>>1)&0x7fffffff)|((D7L&1)<<31);
if(D7L >= 0) goto tag00851c;
longGear(dst) = LE32(D2L); dst+=4;
longGear(dst) = LE32(D3L); dst+=4;
goto tag008518;
};
longGear(dst) = LE32(D2L); dst+=4;
longGear(dst) = LE32(D3L); dst+=4;
dstHeight--;
if (dstHeight != 0)
{
D2L = (i32)A4;
D3L = D2L;
D3L += LOCAL_4;
A4 = (pnt)D3L;
SWAP(D2);// = ((D2>>16)&0xffff)|((D2&0xffff)<<16);
SWAP(D3);// = ((D3>>16)&0xffff)|((D3&0xffff)<<16);
D3W = (i16)(D3W-D2W);
D3L = (ui16)LOCAL_10 * D3UW;
src += D3W;
pushedD3 = sw(dstWidth);
goto tag00850a;
};
//D4=saveD4;D5=saveD5;D6=saveD6;D7=saveD7;
//A2=saveA2;A3=saveA3;A4=saveA4;A5=saveA5;
}
//#define FusionDebug
#ifdef FusionDebug
extern ui8 *allocatedMemoryList;
extern i8 LScreenBase[320][210];
ui8 *FindMemoryBuffer(ui8 *addr, ui8* &end)
{
ui8 *buffer;
ui32 buffersize;
i32 chIdx;
for (buffer = allocatedMemoryList; buffer!=NULL; buffer = *(ui8 **)buffer)
{
if (addr < buffer + 12) continue;
buffersize = *((ui32 *)buffer - 4);
if (addr >= buffer + buffersize) continue;
end = buffer + buffersize;
return buffer;
};
if ((addr >= (ui8 *)LScreenBase[0]) && ( addr < (ui8 *)LScreenBase[0] +320*210))
{
end = (ui8 *)LScreenBase + 320*210;
return (ui8 *)&LScreenBase[0][0];
};
if (addr == (ui8 *)d.Byte1222)
{
end = (ui8 *)d.Byte1222 + 128;
return (ui8 *)d.Byte1222;
};
if (addr == (ui8 *)d.Byte1350)
{
end = (ui8 *)d.Byte1350 + 128;
return (ui8 *)d.Byte1350;
};
for (chIdx =0; chIdx<4; chIdx++)
{
end = (ui8 *)d.CH16482[chIdx].portrait + 464;
if (addr == (ui8 *)d.CH16482[chIdx].portrait) return (ui8 *)d.CH16482[chIdx].portrait;
};
return NULL;
}
#endif
void TAG0088b2(ui8 *src,
ui8 *dst,
RectPos *dstPos,
i32 SrcOffsetX, // pixel starting x offset
i32 SrcOffsetY, // pixel starting y offset
i32 SrcByteWidth, // #bytes per line in source
i32 DestByteWidth,// #bytes per line in destination
i32 transparentColor)
// 8 12 16 20 22 24 26 28
{
dReg D0, D1, D2, D3, D4, D5, D6, D7;
aReg A0, A1, A3, A4, A5;
bool H1Valid;
static ui16 masks[] = {
0x0000, 0x8000, 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00,
0xff00, 0xff80, 0xffc0, 0xffe0, 0xfff0, 0xfff8, 0xfffc, 0xfffe
// 0x0000, 0x0080, 0x00c0, 0x00e0, 0x00f0, 0x00f8, 0x00fc, 0x00fe,
// 0x00ff, 0x80ff, 0xc0ff, 0xe0ff, 0xf0ff, 0xf8ff, 0xfcff, 0xfeff
};
#ifdef FusionDebug
ui8 *end;
ui8 *pm;
{
pm = FindMemoryBuffer((ui8 *)src, end);
};
#endif
i16 LOCAL_2;
i16 LOCAL_4;
i16 LOCAL_6 = 0;
enum JUMP {
none = 0,
Tag008c5e,
Tag008b30,
Tag008b42,
Tag008b56,
Tag008b6a,
Tag008b7e,
Tag008b92,
Tag008ba6,
Tag008bba,
Tag008bce,
Tag008be2,
Tag008c06,
Tag008c18,
Tag008c2a,
Tag008c3c,
Tag008c4e,
Tag008bf4
};
D0L = 0;
D1L = 0;
D2L = 0;
D7L = 0;
ASSERT(verifyRectPos(dstPos),"rectpos");
JUMP ja2 = none;
//i32 saveD4=D4,saveD5=D5,saveD6=D6,saveD7=D7;
//pnt saveA2=A2,saveA3=A3,saveA4=A4,saveA5=A5;
A0 = (pnt)src;
A1 = (pnt)dst;
//D0W = (i16)transparentColor;
D1W = (i16)DestByteWidth; // Destination line width
D2W = (i16)SrcByteWidth;
D3W = (i16)SrcOffsetY;
D4W = (i16)SrcOffsetX; // SourceOffsetX
if(!A1)
A1 = (pnt)physbase();
//A2 = (pnt)P3;
A5 = (pnt)masks;
D5L = D4UW & 15; // starting source bit offset within WORD
D3L = D3UW*D2UW; // #bytes above starting source line
A0 += D3L; // address of starting line in source.
D4W = (i16)(D4W-D5W); // Starting source x offset rounded down to nearest 16.
D4UW >>= 1;//UWed // Starting source byte offset.
A0 += D4W; // Starting source byte address. D5W = bit number
D7L = 0;
D4L = 0;
if (d.UseByteCoordinates != 0)
{
D4B = dstPos->b.x1; // *(A2++);
D7B = dstPos->b.x2; // *(A2++);
}
else
{
D4W = dstPos->w.x1; //wordGear(A2); A2+=2;
D7W = dstPos->w.x2; //wordGear(A2); A2+=2;
};
// *****441020
D7W = (i16)(D7W - D4W + 1); // width of result
SWAP(D7);// = ((D7&0xffff)<<16) | ((D7>>16)&0xffff);
D3L = 0;
if (d.UseByteCoordinates != 0)
{
D3B = dstPos->b.y1; // *(A2++);
D7B = dstPos->b.y2; // *(A2);
}
else
{
D3W = dstPos->w.y1; //wordGear(A2); A2+=2;
D7W = dstPos->w.y2; //wordGear(A2);
};
// *****441078
D7W = (i16)(D7W-D3W); // height of result - 1
SWAP(D7);// = ((D7&0xffff)<<16) | ((D7>>16)&0xffff);
D6L = 15 & D4UW; // Dest start bit within word.
D3L = D1UW * D3UW; // Dest bytes above start line
A1 += D3L; // First byte in destination line
D4W = (i16)((D4UW - D6UW) >> 1);//UWed
A1 += D4W; // Starting byte in destination.
D3L = (15 + D7UW + D5UW) & 0xfff0; // src x of first full word beyond image
D3UW >>= 1;//UWed // # bytes in src line containing information
D4W = (i16)(D2W - D3W); // #source bytes to skip at end of line
A3 = (pnt)D4L; // # bytes to skip at end of source line
D7W = (i16)(D7W+D6W); // #bits in dest words including leading empty bits
LOCAL_2 = D7W; // # bits in dest incl leading empty bits
D3L = (15 + D7UW) & 0xfff0;
D3UW >>= 1;//UWed // #bytes in dest containing some part of image
D1W = (i16)(D1W-D3W); // #bytes in dest not containing any image
A4 = (pnt)D1L; // #bytes in dest not conataining any imaage
D1W = D5W; // source start bit offset
D5W = (i16)(D6W - D5W); // D5 = right shift count src->dest
if (D5W <0) D5W += 16; // if source is left of dest in current word
// *****441155
D3W = D6W; // dest bit offset
D3W = (i16)(D3W + D3W);
LOCAL_4 = wordGear(A5 + D3W); //Dest mask for starting word
D3W = (i16)(D7W + D7W);
if (D3W < 32)
{
D3W = wordGear(A5 + D3W);
D3W ^= 0xffff;
LOCAL_4 |= D3W;
if (D6W < D5W)
{
D1W = (i16)(D1W + D7W - D6W);
if (D1W < 17)
{
A3 -= 8;
};
};
}
else
{
D3W &= 31;
D3W = wordGear(A5 + D3W);
D3W ^= 0xffff;
LOCAL_6 = D3W; // mask for trailing word
};
// *****4411c6
D3W = (i16)(D5W + D5W);
A5 = (pnt)((int)wordGear(A5 + D3W));
SWAP(D5);// = ((D5&0xffff)<<16) | ((D5>>16)&0xffff);
if (transparentColor < 0)
{
ja2 = Tag008c5e;
}
else
{
// D0W += D0W;
// D3W = D0W;
// D0W += D0W;
// D0W += D3W; // 6 * D0W
switch(transparentColor)
{
case 0: ja2 = Tag008b30; break;
case 1: ja2 = Tag008b42; break;
case 2: ja2 = Tag008b56; break;
case 3: ja2 = Tag008b6a; break;
case 4: ja2 = Tag008b7e; break;
case 5: ja2 = Tag008b92; break;
case 6: ja2 = Tag008ba6; break;
case 7: ja2 = Tag008bba; break;
case 8: ja2 = Tag008bce; break;
case 9: ja2 = Tag008be2; break;
case 10: ja2 = Tag008bf4; break;
case 11: ja2 = Tag008c06; break;
case 12: ja2 = Tag008c18; break;
case 13: ja2 = Tag008c2a; break;
case 14: ja2 = Tag008c3c; break;
case 15: ja2 = Tag008c4e; break;
};
};
// *****4412bf
tag008a32:
D5H2 = D5H1;
D5H1 = LOCAL_4;
if (D5W != 0) // Shift source to destination
{
D4W = LOW_I16(A5);
if (D6W < D5W)
{
D0UH2 = D0UH1;
D1UH2 = D1UH1;
D2UH2 = D2UH1;
D3UH2 = D3UH1;
ui16 *puwA0 = (ui16 *)A0;
A0 += 8;
D1UH1 = (i16)(((LE16(*(puwA0++))*0x10001)>>D5W) & D4W);
D0UH1 = (i16)(((LE16(*(puwA0++))*0x10001)>>D5W) & D4W);
D3UH1 = (i16)(((LE16(*(puwA0++))*0x10001)>>D5W) & D4W);
#ifdef FusionDebug
if ((ui8 *)puwA0 >= end)
{
char msg[100];
sprintf(msg,"0x%08x 0x%08x", puwA0, end);
UI_MessageBox(msg,"88b0",MESSAGE_OK);
die(2);
};
#endif
D2UH1 = (i16)(((LE16(*(puwA0++))*0x10001)>>D5W) & D4W);
/*
_asm
{
LODWAP(A0,D1)
RORW(D5,D1)
ANDW(D4,D1)
SWAP(D1);
LODWAP(A0,D0)
RORW(D5,D0)
ANDW(D4,D0)
SWAP(D0)
LODWAP(A0,D3)
RORW(D5,D3)
ANDW(D4,D3)
SWAP(D3)
LODWAP(A0,D2)
RORW(D5,D2)
ANDW(D4,D2)
SWAP(D2)
};
*/
};
tag008a62:
ui16 *puwA0 = (ui16 *)A0;
A0 += 8;
H1Valid = false;
if (D5W < D7W)
{
D0UH2 = (i16) ((LE16(*(puwA0++))*0x10001)>>D5W);
H1Valid = true;
};
D6UH1 = (i16) D0UH2;
D1UH1 &= (i16) D4UH2;
D0UH2 &= (i16) ~D4UH2;
D0UH2 |= (i16) D1UH1;
D1UH1 = (i16) D6UH1;
/*
_asm
{
SWAP(D6)
LODWAP(A0,D0)
RORW(D5,D0)
MOVEW(D0,D6)
SWAP(D1)
ANDW(D4,D1)
NOTW(D4)
ANDW(D4,D0)
ORW(D1,D0)
MOVEW(D6,D1)
SWAP(D1)
//
//
//
//
*/
if (H1Valid) D1UH2 = (ui16) ((LE16(*(puwA0++))*0x10001)>>D5W);
D6UH1 = (ui16) D1UH2;
D1UH2 &= (ui16) ~D4UH2;
D0UH1 &= (ui16) D4UH2;
D1UH2 |= (ui16) D0UH1;
D0UH1 = (ui16) D6UH1;
/*
LODWAP(A0,D1)
RORW(D5,D1)
MOVEW(D1,D6)
SWAP(D0)
ANDW(D4,D1)
NOTW(D4)
ANDW(D4,D0)
ORW(D0,D1)
MOVEW(D6,D0)
SWAP(D0)
//
//
//
//
*/
if (H1Valid) D2UH2 = (ui16) ((LE16(*(puwA0++))*0x10001)>>D5W);
D6UH1 = D2UH2;
D3UH1 &= D4UH2;
D2UH2 &= ~D4UH2;
D2UH2 |= D3UH1;
D3UH1 = D6UH1;
/*
LODWAP(A0,D2)
RORW(D5,D2)
MOVEW(D2,D6)
SWAP(D3)
ANDW(D4,D3)
NOT(D4)
ANDW(D4,D2)
ORW(D3,D2)
MOVEW(D6,D3)
SWAP(D3)
//
//
//
//
*/
if (H1Valid) D3UH2 = (ui16) ((LE16(*(puwA0++))*0x10001)>>D5W);
D6UH1 = D3UH2;
D3UH2 &= ~D4UH2;
D2UH1 &= D4UH2;
D3UH2 |= D2UH1;
D2UH1 = D6UH1;
/*
LODWAP(A0,D3)
RORW(D5,D3)
MOVEW(D3,D6)
SWAP(D2)
ANDW(D4,D3)
NOTW(D4)
ANDW(D4,D2)
ORW(D2,D3)
MOVEW(D6,D2)
SWAP(D2)
//
//
//
SWAP(D6)
SWAP(D5)
};
*/
#ifdef FusionDebug
if (H1Valid && ((ui8 *)puwA0 > end))
{
char msg[100];
sprintf(msg,"0x%08x 0x%08x", puwA0, end);
UI_MessageBox(msg,"88b0",MESSAGE_OK);
die(2);
};
#endif
D5L = ((D5L&0xffff)<<16) | ((D5L>>16)&0xffff);
goto jumpA2;
};
// *****44139d **
tag008aba:
D0W = LE16(wordGear(A0)); A0+=2;
//D0W = ((*((ui16 *)A0)) * 0x10001) >> 8; A0+=2;
D1W = LE16(wordGear(A0)); A0+=2;
//D1W = ((*((ui16 *)A0)) * 0x10001) >> 8; A0+=2;
D2W = LE16(wordGear(A0)); A0+=2;
//D2W = ((*((ui16 *)A0)) * 0x10001) >> 8; A0+=2;
D3W = LE16(wordGear(A0)); A0+=2;
//D3W = ((*((ui16 *)A0)) * 0x10001) >> 8; A0+=2;
#ifdef FusionDebug
if ((ui8 *)A0 >= end)
{
char msg[100];
sprintf(msg,"0x%08x 0x%08x", A0, end);
UI_MessageBox(msg,"88b0",MESSAGE_OK);
die(2);
};
#endif
SWAP(D5);//D5 = ((D5&0xffff)<<16) | ((D5>>16)&0xffff);
goto jumpA2;
// *****441441
// *****44162b
tag008ac2:
D4W ^= 0xffff;
D0W &= D4W;
D1W &= D4W;
D2W &= D4W;
D3W &= D4W;
D4W ^= 0xffff;
wordGear(A1) &= LE16(D4W);
wordGear(A1) |= LE16(D0W); A1+=2;
wordGear(A1) &= LE16(D4W);
wordGear(A1) |= LE16(D1W); A1+=2;
wordGear(A1) &= LE16(D4W);
wordGear(A1) |= LE16(D2W); A1+=2;
wordGear(A1) &= LE16(D4W);
wordGear(A1) |= LE16(D3W); A1+=2;
// *****4414d1
tag008ade:
D7W -= 16;
if (D7W > 0)
{
//4414eb
if (D7W >= 16)
{
//4414f5
D5W = 0;
SWAP(D5);// = ((D5&0xffff)<<16) | ((D5>>16)&0xffff);
tag008aee:
if (D5W == 0)
{
goto tag008aba;
};
D4W = LOW_I16(A5);
goto tag008a62;
};
//4416f9
D5W = LOCAL_6;
SWAP(D5);// = ((D5&0xffff)<<16) | ((D5>>16)&0xffff);
if (D5W < D7W) goto tag008aee;
SWAP(D0);//D0 = ((D0&0xffff)<<16) | ((D0>>16)&0xffff);
SWAP(D1);// = ((D1&0xffff)<<16) | ((D1>>16)&0xffff);
SWAP(D2);// = ((D2&0xffff)<<16) | ((D2>>16)&0xffff);
SWAP(D3);// = ((D3&0xffff)<<16) | ((D3>>16)&0xffff);
D4W = D0W;
D0W = D1W;
D1W = D4W;
D4W = D2W;
D2W = D3W;
D3W = D4W;