~ubuntu-branches/ubuntu/trusty/mupen64plus-video-rice/trusty

« back to all changes in this revision

Viewing changes to src/ConvertImage16.cpp

  • Committer: Package Import Robot
  • Author(s): Sven Eckelmann
  • Date: 2013-07-05 22:53:25 UTC
  • mfrom: (1.2.2) (3.1.9 experimental)
  • Revision ID: package-import@ubuntu.com-20130705225325-k0fbb2m44xnrju66
Tags: 2.0-1
* New Upstream Version
* Upload to unstable
* debian/control:
  - Build-Depend on debhelper 9.20130604 for support of parameters when
    detecting targets in dh_auto_*
* debian/rules:
  - Work around new debhelper 9.20130624 dh_auto_{clean,test} behavior
    which is causing a FTBFS by adding an explicit
    override_dh_auto_{clean,test} rule
* debian/watch:
  - Verify new upstream versions using GPG key 954F81B094AA5BB226F5

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
 
80
80
    if (tinfo.bSwapped)
81
81
    {
82
 
 
83
82
        for (y = 0; y < tinfo.HeightToLoad; y++)
84
83
        {
85
84
            if ((y%2) == 0)
148
147
        {
149
148
            pWordSrc = (uint32*)&g_Tmem.g_Tmem64bit[tile.dwTMem];
150
149
 
151
 
 
152
150
            for (uint32 y = 0; y < tinfo.HeightToLoad; y++)
153
151
            {
154
152
                uint16 * dwDst = (uint16 *)((uint8 *)dInfo.lpSurface + y*dInfo.lPitch);
169
167
    {
170
168
        if (tinfo.bSwapped)
171
169
        {
172
 
 
173
170
            for (uint32 y = 0; y < tinfo.HeightToLoad; y++)
174
171
            {
175
172
                if ((y%2) == 0)
176
173
                {
177
 
 
178
174
                    uint16 *pDst = (uint16*)((uint8 *)dInfo.lpSurface + y * dInfo.lPitch);
179
175
                    uint8 *pS = (uint8 *)pSrc + (y+tinfo.TopToLoad) * tinfo.Pitch + (tinfo.LeftToLoad*4);
180
176
 
181
177
                    for (uint32 x = 0; x < tinfo.WidthToLoad; x++)
182
178
                    {
183
179
 
184
 
                        *pDst++ = R4G4B4A4_MAKE((pS[3]>>4),     // Red
185
 
                            (pS[2]>>4),
186
 
                            (pS[1]>>4),
187
 
                            (pS[0]>>4));        // Alpha
 
180
                        *pDst++ = R4G4B4A4_MAKE((pS[3]>>4),  // Red
 
181
                                                (pS[2]>>4),  // Green
 
182
                                                (pS[1]>>4),  // Blue
 
183
                                                (pS[0]>>4)); // Alpha
188
184
                        pS+=4;
189
185
                    }
190
186
                }
191
187
                else
192
188
                {
193
 
 
194
189
                    uint16 *pDst = (uint16*)((uint8 *)dInfo.lpSurface + y * dInfo.lPitch);
195
190
                    uint8 *pS = (uint8 *)pSrc + (y+tinfo.TopToLoad) * tinfo.Pitch + (tinfo.LeftToLoad*4);
196
191
                    int n;
198
193
                    n = 0;
199
194
                    for (uint32 x = 0; x < tinfo.WidthToLoad; x++)
200
195
                    {
201
 
                        *pDst++ = R4G4B4A4_MAKE((pS[(n^0x8) + 3]>>4),       // Red
202
 
                            (pS[(n^0x8) + 2]>>4),
203
 
                            (pS[(n^0x8) + 1]>>4),
204
 
                            (pS[(n^0x8) + 0]>>4));  // Alpha
 
196
                        *pDst++ = R4G4B4A4_MAKE((pS[(n^0x8) + 3]>>4),   // Red
 
197
                                                (pS[(n^0x8) + 2]>>4),   // Green
 
198
                                                (pS[(n^0x8) + 1]>>4),   // Blue
 
199
                                                (pS[(n^0x8) + 0]>>4));  // Alpha
205
200
 
206
201
                        n += 4;
207
202
                    }
218
213
                for (uint32 x = 0; x < tinfo.WidthToLoad; x++)
219
214
                {
220
215
                    *pDst++ = R4G4B4A4_MAKE((pS[3]>>4),     // Red
221
 
                        (pS[2]>>4),
222
 
                        (pS[1]>>4),
223
 
                        (pS[0]>>4));        // Alpha
 
216
                                            (pS[2]>>4),     // Green
 
217
                                            (pS[1]>>4),     // Blue
 
218
                                            (pS[0]>>4));    // Alpha
224
219
                    pS+=4;
225
220
                }
226
221
            }
227
 
 
228
222
        }
229
223
    }
230
224
 
231
 
 
232
 
 
233
225
    pTexture->EndUpdate(&dInfo);
234
226
    pTexture->SetOthersVariables();
235
227
 
269
261
 
270
262
                // Even
271
263
                *pDst++ = R4G4B4A4_MAKE(ThreeToFour[(b & 0xE0) >> 5],
272
 
                                      ThreeToFour[(b & 0xE0) >> 5],
273
 
                                      ThreeToFour[(b & 0xE0) >> 5],
274
 
                                      OneToFour[(b & 0x10) >> 4]);
 
264
                                        ThreeToFour[(b & 0xE0) >> 5],
 
265
                                        ThreeToFour[(b & 0xE0) >> 5],
 
266
                                        OneToFour[(b & 0x10) >> 4]);
275
267
    
276
268
                // Odd
277
269
                *pDst++ = R4G4B4A4_MAKE(ThreeToFour[(b & 0x0E) >> 1],
278
 
                                      ThreeToFour[(b & 0x0E) >> 1],
279
 
                                      ThreeToFour[(b & 0x0E) >> 1],
280
 
                                      OneToFour[(b & 0x01)]     );
 
270
                                        ThreeToFour[(b & 0x0E) >> 1],
 
271
                                        ThreeToFour[(b & 0x0E) >> 1],
 
272
                                        OneToFour[(b & 0x01)]     );
281
273
 
282
274
                dwByteOffset++;
283
 
 
284
275
            }
285
 
 
286
276
        }
287
277
    }
288
278
    else
301
291
 
302
292
                // Even
303
293
                *pDst++ = R4G4B4A4_MAKE(ThreeToFour[(b & 0xE0) >> 5],
304
 
                                      ThreeToFour[(b & 0xE0) >> 5],
305
 
                                      ThreeToFour[(b & 0xE0) >> 5],
306
 
                                      OneToFour[(b & 0x10) >> 4]);
 
294
                                        ThreeToFour[(b & 0xE0) >> 5],
 
295
                                        ThreeToFour[(b & 0xE0) >> 5],
 
296
                                        OneToFour[(b & 0x10) >> 4]);
307
297
    
308
298
                // Odd
309
299
                *pDst++ = R4G4B4A4_MAKE(ThreeToFour[(b & 0x0E) >> 1],
310
 
                                      ThreeToFour[(b & 0x0E) >> 1],
311
 
                                      ThreeToFour[(b & 0x0E) >> 1],
312
 
                                      OneToFour[(b & 0x01)]     );
313
 
 
 
300
                                        ThreeToFour[(b & 0x0E) >> 1],
 
301
                                        ThreeToFour[(b & 0x0E) >> 1],
 
302
                                        OneToFour[(b & 0x01)]     );
314
303
 
315
304
                dwByteOffset++;
316
 
 
317
305
            }
318
 
        }   
 
306
        }
319
307
    }
320
308
    
321
309
    pTexture->EndUpdate(&dInfo);
322
310
    pTexture->SetOthersVariables();
323
 
 
324
311
}
325
312
 
326
313
// E.g Mario's head textures
356
343
 
357
344
                dwByteOffset++;
358
345
            }
359
 
 
360
 
        }       
 
346
        }
361
347
    }
362
348
    else
363
349
    {
364
 
 
365
350
        for (uint32 y = 0; y < tinfo.HeightToLoad; y++)
366
351
        {
367
352
            uint16 *pDst = (uint16*)((uint8 *)dInfo.lpSurface + y * dInfo.lPitch);
368
353
 
369
 
 
370
354
            // Points to current byte
371
355
            uint32 dwByteOffset = ((y+tinfo.TopToLoad) * tinfo.Pitch) + tinfo.LeftToLoad;
372
356
 
379
363
                dwByteOffset++;
380
364
            }
381
365
        }
382
 
    }   
 
366
    }
383
367
    
384
368
    pTexture->EndUpdate(&dInfo);
385
369
    pTexture->SetOthersVariables();
415
399
 
416
400
            dwWordOffset += 2;
417
401
        }
418
 
    }       
 
402
    }
 
403
 
419
404
    pTexture->EndUpdate(&dInfo);
420
405
    pTexture->SetOthersVariables();
421
406
}
470
455
 
471
456
                dwByteOffset++;
472
457
            }
473
 
 
474
 
        }   
475
 
 
 
458
        }
476
459
    }
477
460
    else
478
461
    {
479
 
 
480
462
        for (uint32 y = 0; y < tinfo.HeightToLoad; y++)
481
463
        {
482
464
            uint8 *pDst = (uint8 *)dInfo.lpSurface + y * dInfo.lPitch;
500
482
            }
501
483
        }
502
484
    }
 
485
    
503
486
    pTexture->EndUpdate(&dInfo);
504
487
    pTexture->SetOthersVariables();
505
488
}
510
493
    DrawInfo dInfo;
511
494
    uint32 nFiddle;
512
495
 
513
 
    long pSrc = (long) (tinfo.pPhysicalAddress);
 
496
    long long pSrc = (long long) (tinfo.pPhysicalAddress);
514
497
    if (!pTexture->StartUpdate(&dInfo))
515
498
        return;
516
499
 
532
515
                uint8 b = *(uint8*)((pSrc+dwByteOffset)^nFiddle);
533
516
 
534
517
                *pDst++ = R4G4B4A4_MAKE(b>>4,
535
 
                    b>>4,
536
 
                    b>>4,
537
 
                    b>>4);
 
518
                                        b>>4,
 
519
                                        b>>4,
 
520
                                        b>>4);
538
521
 
539
522
                dwByteOffset++;
540
523
            }
541
 
        }   
 
524
        }
542
525
    }
543
526
    else
544
527
    {
553
536
                uint8 b = *(uint8*)((pSrc+dwByteOffset)^0x3);
554
537
 
555
538
                *pDst++ = R4G4B4A4_MAKE(b>>4,
556
 
                                      b>>4,
557
 
                                      b>>4,
558
 
                                      b>>4);
 
539
                                        b>>4,
 
540
                                        b>>4,
 
541
                                        b>>4);
559
542
 
560
543
                dwByteOffset++;
561
544
            }
562
 
        }   
 
545
        }
563
546
 
564
547
    }
565
548
    pTexture->EndUpdate(&dInfo);
612
595
    }
613
596
    else
614
597
    {
615
 
 
616
598
        for (uint32 y = 0; y <  tinfo.HeightToLoad; y++)
617
599
        {
618
600
            uint16 * pDst = (uint16 *)((uint8 *)dInfo.lpSurface + y * dInfo.lPitch);
632
614
 
633
615
                dwByteOffset++;
634
616
            }
635
 
        }   
636
 
 
 
617
        }
637
618
    }
 
619
 
638
620
    pTexture->EndUpdate(&dInfo);
639
621
    pTexture->SetOthersVariables();
640
622
}
642
624
//*****************************************************************************
643
625
// Convert CI4 images. We need to switch on the palette type
644
626
//*****************************************************************************
645
 
void    ConvertCI4_16( CTexture * p_texture, const TxtrInfo & tinfo )
 
627
void ConvertCI4_16( CTexture * p_texture, const TxtrInfo & tinfo )
646
628
{
647
629
    if ( tinfo.TLutFmt == TLUT_FMT_RGBA16 )
648
630
    {
657
639
//*****************************************************************************
658
640
// Convert CI8 images. We need to switch on the palette type
659
641
//*****************************************************************************
660
 
void    ConvertCI8_16( CTexture * p_texture, const TxtrInfo & tinfo )
 
642
void ConvertCI8_16( CTexture * p_texture, const TxtrInfo & tinfo )
661
643
{
662
644
    if ( tinfo.TLutFmt == TLUT_FMT_RGBA16 )
663
645
    {
682
664
 
683
665
    if (tinfo.bSwapped)
684
666
    {
685
 
 
686
667
        for (uint32 y = 0; y <  tinfo.HeightToLoad; y++)
687
668
        {
688
669
            if ((y%2) == 0)
690
671
            else
691
672
                nFiddle = 0x7;
692
673
 
693
 
 
694
674
            uint16 * pDst = (uint16 *)((uint8 *)dInfo.lpSurface + y * dInfo.lPitch);
695
675
 
696
676
            uint32 dwByteOffset = ((y+tinfo.TopToLoad) * tinfo.Pitch) + (tinfo.LeftToLoad / 2);
707
687
                pDst += 2;
708
688
                dwByteOffset++;
709
689
            }
710
 
        }   
711
 
        
 
690
        }
712
691
    }
713
692
    else
714
693
    {
715
 
 
716
694
        for (uint32 y = 0; y <  tinfo.HeightToLoad; y++)
717
695
        {
718
696
            uint16 * pDst = (uint16 *)((uint8 *)dInfo.lpSurface + y * dInfo.lPitch);
732
710
 
733
711
                dwByteOffset++;
734
712
            }
735
 
        }   
736
 
 
 
713
        }
737
714
    }
 
715
 
738
716
    pTexture->EndUpdate(&dInfo);
739
717
    pTexture->SetOthersVariables();
740
718
}
741
719
 
742
720
 
743
 
 
744
 
 
745
721
// Used by MarioKart for Cars etc
746
722
void ConvertCI8_RGBA16_16(CTexture *pTexture, const TxtrInfo &tinfo)
747
723
{
755
731
 
756
732
    if (tinfo.bSwapped)
757
733
    {
758
 
 
759
 
 
760
734
        for (uint32 y = 0; y < tinfo.HeightToLoad; y++)
761
735
        {
762
736
            if ((y%2) == 0)
776
750
 
777
751
                dwByteOffset++;
778
752
            }
779
 
        }   
780
 
    
781
 
 
 
753
        }
782
754
    }
783
755
    else
784
756
    {
785
 
 
786
757
        for (uint32 y = 0; y < tinfo.HeightToLoad; y++)
787
758
        {
788
759
            uint16 *pDst = (uint16 *)((uint8 *)dInfo.lpSurface + y * dInfo.lPitch);
799
770
            }
800
771
        }
801
772
    }
 
773
 
802
774
    pTexture->EndUpdate(&dInfo);
803
775
    pTexture->SetOthersVariables();
804
 
 
805
776
}
806
777
 
807
778
 
818
789
 
819
790
    if (tinfo.bSwapped)
820
791
    {
821
 
 
822
 
 
823
792
        for (uint32 y = 0; y < tinfo.HeightToLoad; y++)
824
793
        {
825
794
            if ((y%2) == 0)
839
808
 
840
809
                dwByteOffset++;
841
810
            }
842
 
        }   
843
 
    
844
 
 
 
811
        }
845
812
    }
846
813
    else
847
814
    {
848
 
 
849
815
        for (uint32 y = 0; y < tinfo.HeightToLoad; y++)
850
816
        {
851
817
            uint16 *pDst = (uint16 *)((uint8 *)dInfo.lpSurface + y * dInfo.lPitch);
862
828
            }
863
829
        }
864
830
    }
 
831
 
865
832
    pTexture->EndUpdate(&dInfo);
866
833
    pTexture->SetOthersVariables();
867
834
}
887
854
            pSrc = (uint16*)(tinfo.pPhysicalAddress);
888
855
 
889
856
        uint8 * pByteSrc = (uint8 *)pSrc;
890
 
 
891
857
        for (y = 0; y < tinfo.HeightToLoad; y++)
892
858
        {
893
859
            nFiddle = ( y&1 )? 0x4 : 0;
917
883
 
918
884
        if (tinfo.bSwapped)
919
885
        {
920
 
 
921
886
            for (y = 0; y < tinfo.HeightToLoad; y++)
922
887
            {
923
888
                if ((y%2) == 0)
990
955
}
991
956
 
992
957
 
993
 
 
994
 
 
995
958
// Used by Starfox intro
996
959
void Convert4b_16(CTexture *pTexture, const TxtrInfo &tinfo)
997
960
{