@@ -611,13 +611,208 @@ MxDeviceEnumerate::DirectDrawEnumerateCallback(LPGUID p_guid, LPSTR p_driverDesc
611
611
return deviceEnumerate->EnumDirectDrawCallback (p_guid, p_driverDesc, p_driverName);
612
612
}
613
613
614
- // STUB : LEGO1 0x1009c730
614
+ // FUNCTION : LEGO1 0x1009c730
615
615
const char * MxDeviceEnumerate::EnumerateErrorToString (HRESULT p_error)
616
616
{
617
- // TODO: This is a list of error messages, similar to the function in
618
- // MxDirectDraw, except that this one now contains the Direct3D errors.
619
- // Probably just copied from a sample file in the dx5 sdk.
620
- return " " ;
617
+ switch (p_error) {
618
+ case DD_OK:
619
+ return " No error." ;
620
+ case DDERR_GENERIC:
621
+ return " Generic failure." ;
622
+ case DDERR_UNSUPPORTED:
623
+ return " Action not supported." ;
624
+ case DDERR_INVALIDPARAMS:
625
+ return " One or more of the parameters passed to the function are incorrect." ;
626
+ case DDERR_OUTOFMEMORY:
627
+ return " DirectDraw does not have enough memory to perform the operation." ;
628
+ case DDERR_CANNOTATTACHSURFACE:
629
+ return " This surface can not be attached to the requested surface." ;
630
+ case DDERR_ALREADYINITIALIZED:
631
+ return " This object is already initialized." ;
632
+ case DDERR_CURRENTLYNOTAVAIL:
633
+ return " Support is currently not available." ;
634
+ case DDERR_CANNOTDETACHSURFACE:
635
+ return " This surface can not be detached from the requested surface." ;
636
+ case DDERR_HEIGHTALIGN:
637
+ return " Height of rectangle provided is not a multiple of reqd alignment." ;
638
+ case DDERR_EXCEPTION:
639
+ return " An exception was encountered while performing the requested operation." ;
640
+ case DDERR_INVALIDCAPS:
641
+ return " One or more of the caps bits passed to the callback are incorrect." ;
642
+ case DDERR_INCOMPATIBLEPRIMARY:
643
+ return " Unable to match primary surface creation request with existing primary surface." ;
644
+ case DDERR_INVALIDMODE:
645
+ return " DirectDraw does not support the requested mode." ;
646
+ case DDERR_INVALIDCLIPLIST:
647
+ return " DirectDraw does not support the provided cliplist." ;
648
+ case DDERR_INVALIDPIXELFORMAT:
649
+ return " The pixel format was invalid as specified." ;
650
+ case DDERR_INVALIDOBJECT:
651
+ return " DirectDraw received a pointer that was an invalid DIRECTDRAW object." ;
652
+ case DDERR_LOCKEDSURFACES:
653
+ return " Operation could not be carried out because one or more surfaces are locked." ;
654
+ case DDERR_INVALIDRECT:
655
+ return " Rectangle provided was invalid." ;
656
+ case DDERR_NOALPHAHW:
657
+ return " Operation could not be carried out because there is no alpha accleration hardware present or "
658
+ " available." ;
659
+ case DDERR_NO3D:
660
+ return " There is no 3D present." ;
661
+ case DDERR_NOCOLORCONVHW:
662
+ return " Operation could not be carried out because there is no color conversion hardware present or available." ;
663
+ case DDERR_NOCLIPLIST:
664
+ return " No cliplist available." ;
665
+ case DDERR_NOCOLORKEY:
666
+ return " Surface doesn't currently have a color key" ;
667
+ case DDERR_NOCOOPERATIVELEVELSET:
668
+ return " Create function called without DirectDraw object method SetCooperativeLevel being called." ;
669
+ case DDERR_NOEXCLUSIVEMODE:
670
+ return " Operation requires the application to have exclusive mode but the application does not have exclusive "
671
+ " mode." ;
672
+ case DDERR_NOCOLORKEYHW:
673
+ return " Operation could not be carried out because there is no hardware support of the destination color key." ;
674
+ case DDERR_NOGDI:
675
+ return " There is no GDI present." ;
676
+ case DDERR_NOFLIPHW:
677
+ return " Flipping visible surfaces is not supported." ;
678
+ case DDERR_NOTFOUND:
679
+ return " Requested item was not found." ;
680
+ case DDERR_NOMIRRORHW:
681
+ return " Operation could not be carried out because there is no hardware present or available." ;
682
+ case DDERR_NORASTEROPHW:
683
+ return " Operation could not be carried out because there is no appropriate raster op hardware present or "
684
+ " available." ;
685
+ case DDERR_NOOVERLAYHW:
686
+ return " Operation could not be carried out because there is no overlay hardware present or available." ;
687
+ case DDERR_NOSTRETCHHW:
688
+ return " Operation could not be carried out because there is no hardware support for stretching." ;
689
+ case DDERR_NOROTATIONHW:
690
+ return " Operation could not be carried out because there is no rotation hardware present or available." ;
691
+ case DDERR_NOTEXTUREHW:
692
+ return " Operation could not be carried out because there is no texture mapping hardware present or available." ;
693
+ case DDERR_NOT4BITCOLOR:
694
+ return " DirectDrawSurface is not in 4 bit color palette and the requested operation requires 4 bit color "
695
+ " palette." ;
696
+ case DDERR_NOT4BITCOLORINDEX:
697
+ return " DirectDrawSurface is not in 4 bit color index palette and the requested operation requires 4 bit color "
698
+ " index palette." ;
699
+ case DDERR_NOT8BITCOLOR:
700
+ return " DirectDrawSurface is not in 8 bit color mode and the requested operation requires 8 bit color." ;
701
+ case DDERR_NOZBUFFERHW:
702
+ return " Operation could not be carried out because there is no hardware support for zbuffer blitting." ;
703
+ case DDERR_NOVSYNCHW:
704
+ return " Operation could not be carried out because there is no hardware support for vertical blank "
705
+ " synchronized operations." ;
706
+ case DDERR_OUTOFCAPS:
707
+ return " The hardware needed for the requested operation has already been allocated." ;
708
+ case DDERR_NOZOVERLAYHW:
709
+ return " Overlay surfaces could not be z layered based on their BltOrder because the hardware does not support "
710
+ " z layering of overlays." ;
711
+ case DDERR_COLORKEYNOTSET:
712
+ return " No src color key specified for this operation." ;
713
+ case DDERR_OUTOFVIDEOMEMORY:
714
+ return " DirectDraw does not have enough memory to perform the operation." ;
715
+ case DDERR_OVERLAYCANTCLIP:
716
+ return " The hardware does not support clipped overlays." ;
717
+ case DDERR_OVERLAYCOLORKEYONLYONEACTIVE:
718
+ return " Can only have ony color key active at one time for overlays." ;
719
+ case DDERR_PALETTEBUSY:
720
+ return " Access to this palette is being refused because the palette is already locked by another thread." ;
721
+ case DDERR_SURFACEALREADYDEPENDENT:
722
+ return " This surface is already a dependency of the surface it is being made a dependency of." ;
723
+ case DDERR_SURFACEALREADYATTACHED:
724
+ return " This surface is already attached to the surface it is being attached to." ;
725
+ case DDERR_SURFACEISOBSCURED:
726
+ return " Access to surface refused because the surface is obscured." ;
727
+ case DDERR_SURFACEBUSY:
728
+ return " Access to this surface is being refused because the surface is already locked by another thread." ;
729
+ case DDERR_SURFACENOTATTACHED:
730
+ return " The requested surface is not attached." ;
731
+ case DDERR_SURFACELOST:
732
+ return " Access to this surface is being refused because the surface memory is gone. The DirectDrawSurface "
733
+ " object representing this surface should have Restore called on it." ;
734
+ case DDERR_TOOBIGSIZE:
735
+ return " Size requested by DirectDraw is too large, but the individual height and width are OK." ;
736
+ case DDERR_TOOBIGHEIGHT:
737
+ return " Height requested by DirectDraw is too large." ;
738
+ case DDERR_UNSUPPORTEDFORMAT:
739
+ return " FOURCC format requested is unsupported by DirectDraw." ;
740
+ case DDERR_TOOBIGWIDTH:
741
+ return " Width requested by DirectDraw is too large." ;
742
+ case DDERR_VERTICALBLANKINPROGRESS:
743
+ return " Vertical blank is in progress." ;
744
+ case DDERR_UNSUPPORTEDMASK:
745
+ return " Bitmask in the pixel format requested is unsupported by DirectDraw." ;
746
+ case DDERR_XALIGN:
747
+ return " Rectangle provided was not horizontally aligned on required boundary." ;
748
+ case DDERR_WASSTILLDRAWING:
749
+ return " Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is "
750
+ " incomplete." ;
751
+ case DDERR_INVALIDDIRECTDRAWGUID:
752
+ return " The GUID passed to DirectDrawCreate is not a valid DirectDraw driver identifier." ;
753
+ case DDERR_DIRECTDRAWALREADYCREATED:
754
+ return " A DirectDraw object representing this driver has already been created for this process." ;
755
+ case DDERR_NODIRECTDRAWHW:
756
+ return " A hardware-only DirectDraw object creation was attempted but the driver did not support any hardware." ;
757
+ case DDERR_PRIMARYSURFACEALREADYEXISTS:
758
+ return " This process already has created a primary surface." ;
759
+ case DDERR_NOEMULATION:
760
+ return " Software emulation not available." ;
761
+ case DDERR_REGIONTOOSMALL:
762
+ return " Region passed to Clipper::GetClipList is too small." ;
763
+ case DDERR_CLIPPERISUSINGHWND:
764
+ return " An attempt was made to set a cliplist for a clipper object that is already monitoring an hwnd." ;
765
+ case DDERR_NOCLIPPERATTACHED:
766
+ return " No clipper object attached to surface object." ;
767
+ case DDERR_NOHWND:
768
+ return " Clipper notification requires an HWND or no HWND has previously been set as the CooperativeLevel HWND." ;
769
+ case DDERR_HWNDSUBCLASSED:
770
+ return " HWND used by DirectDraw CooperativeLevel has been subclassed, this prevents DirectDraw from restoring "
771
+ " state." ;
772
+ case DDERR_HWNDALREADYSET:
773
+ return " The CooperativeLevel HWND has already been set. It can not be reset while the process has surfaces or "
774
+ " palettes created." ;
775
+ case DDERR_NOPALETTEATTACHED:
776
+ return " No palette object attached to this surface." ;
777
+ case DDERR_NOPALETTEHW:
778
+ return " No hardware support for 16 or 256 color palettes." ;
779
+ case DDERR_BLTFASTCANTCLIP:
780
+ return " Return if a clipper object is attached to the source surface passed into a BltFast call." ;
781
+ case DDERR_NOBLTHW:
782
+ return " No blitter hardware present." ;
783
+ case DDERR_NODDROPSHW:
784
+ return " No DirectDraw ROP hardware." ;
785
+ case DDERR_OVERLAYNOTVISIBLE:
786
+ return " Returned when GetOverlayPosition is called on a hidden overlay." ;
787
+ case DDERR_NOOVERLAYDEST:
788
+ return " Returned when GetOverlayPosition is called on an overlay that UpdateOverlay has never been called on "
789
+ " to establish a destination." ;
790
+ case DDERR_INVALIDPOSITION:
791
+ return " Returned when the position of the overlay on the destination is no longer legal for that destination." ;
792
+ case DDERR_NOTAOVERLAYSURFACE:
793
+ return " Returned when an overlay member is called for a non-overlay surface." ;
794
+ case DDERR_EXCLUSIVEMODEALREADYSET:
795
+ return " An attempt was made to set the cooperative level when it was already set to exclusive." ;
796
+ case DDERR_NOTFLIPPABLE:
797
+ return " An attempt has been made to flip a surface that is not flippable." ;
798
+ case DDERR_CANTDUPLICATE:
799
+ return " Can't duplicate primary & 3D surfaces, or surfaces that are implicitly created." ;
800
+ case DDERR_NOTLOCKED:
801
+ return " Surface was not locked. An attempt to unlock a surface that was not locked at all, or by this "
802
+ " process, has been attempted." ;
803
+ case DDERR_CANTCREATEDC:
804
+ return " Windows can not create any more DCs." ;
805
+ case DDERR_NODC:
806
+ return " No DC was ever created for this surface." ;
807
+ case DDERR_WRONGMODE:
808
+ return " This surface can not be restored because it was created in a different mode." ;
809
+ case DDERR_IMPLICITLYCREATED:
810
+ return " This surface can not be restored because it is an implicitly created surface." ;
811
+ case DDERR_NOTPALETTIZED:
812
+ return " The surface being used is not a palette-based surface." ;
813
+ default :
814
+ return " Unrecognized error value." ;
815
+ }
621
816
}
622
817
623
818
// FUNCTION: LEGO1 0x1009ce60
@@ -734,7 +929,7 @@ int MxDeviceEnumerate::FUN_1009d0d0()
734
929
int i = 0 ;
735
930
int j = 0 ;
736
931
int k = -1 ;
737
- unsigned int und = FUN_1009d1a0 ();
932
+ int cpu_mmx = SupportsMMX ();
738
933
739
934
for (list<MxDriver>::iterator it = m_list.begin ();; it++) {
740
935
if (it == m_list.end ()) {
@@ -746,7 +941,7 @@ int MxDeviceEnumerate::FUN_1009d0d0()
746
941
return j;
747
942
}
748
943
749
- if ((und && (*it2).m_HELDesc .dcmColorModel == D3DCOLOR_RGB && i == 0 ) ||
944
+ if ((cpu_mmx && (*it2).m_HELDesc .dcmColorModel == D3DCOLOR_RGB && i == 0 ) ||
750
945
((*it2).m_HELDesc .dcmColorModel == D3DCOLOR_MONO && i == 0 && k < 0 )) {
751
946
k = j;
752
947
}
@@ -760,16 +955,76 @@ int MxDeviceEnumerate::FUN_1009d0d0()
760
955
return -1 ;
761
956
}
762
957
763
- // STUB : LEGO1 0x1009d1a0
764
- undefined4 MxDeviceEnumerate::FUN_1009d1a0 ()
958
+ // FUNCTION : LEGO1 0x1009d1a0
959
+ int MxDeviceEnumerate::SupportsMMX ()
765
960
{
766
- return 1 ;
961
+ int supports_mmx = SupportsCPUID ();
962
+ if (supports_mmx) {
963
+ #ifdef _MSC_VER
964
+ __asm {
965
+ mov eax, 0x0 ; EAX=0 : Highest Function Parameter and Manufacturer ID
966
+ #if _MSC_VER > 1100
967
+ cpuid ; Run CPUID
968
+ #else
969
+ __emit 0x0f
970
+ __emit 0xa2
971
+ #endif
972
+ mov eax, 0x1 ; EAX=1 : Processor Info and Feature Bits (unused)
973
+ #if _MSC_VER > 1100
974
+ cpuid ; Run CPUID
975
+ #else
976
+ __emit 0x0f
977
+ __emit 0xa2
978
+ #endif
979
+ xor eax, eax ; Zero EAX register
980
+ bt edx, 0x17 ; Test bit 0x17 (23 ): MMX instructions (64 -bit SIMD) (Store in CF)
981
+ adc eax, eax ; Add with carry: EAX = EAX + EAX + CF = CF
982
+ mov supports_mmx, eax ; Save eax into C variable
983
+ }
984
+ #else
985
+ __asm__ (" movl $0x0, %%eax\n\t " // EAX=0: Highest Function Parameter and Manufacturer ID
986
+ " cpuid\n\t " // Run CPUID\n"
987
+ " mov $0x1, %%eax\n\t " // EAX=1: Processor Info and Feature Bits (unused)
988
+ " cpuid\n\t " // Run CPUID
989
+ " xorl %%eax, %%eax\n\t " // Zero EAX register
990
+ " btl $0x15, %%edx\n\t " // Test bit 0x17 (23): MMX instructions (64-bit SIMD) (Store in CF)
991
+ " adc %%eax, %%eax" // Add with carry: EAX = EAX + EAX + CF = CF
992
+ : " =a" (supports_mmx) // supports_mmx == EAX
993
+ );
994
+ #endif
995
+ }
996
+ return supports_mmx;
767
997
}
768
998
769
- // STUB : LEGO1 0x1009d1e0
770
- undefined4 MxDeviceEnumerate::FUN_1009d1e0 ()
999
+ // FUNCTION : LEGO1 0x1009d1e0
1000
+ int MxDeviceEnumerate::SupportsCPUID ()
771
1001
{
772
- return 1 ;
1002
+ int has_cpuid;
1003
+ #ifdef _MSC_VER
1004
+ __asm {
1005
+ xor eax, eax ; Zero EAX register
1006
+ pushfd ; Push EFLAGS register value on the stack
1007
+ or dword ptr[esp], 0x200000 ; Set bit 0x200000 : Able to use CPUID instruction (Pentium+)
1008
+ popfd ; Write the updated value into the EFLAGS register
1009
+ pushfd ; Push EFLAGS register value on the stack (again)
1010
+ btr dword ptr[esp], 0x15 ; Test bit 0x15 (21 ) and reset (set CF)
1011
+ adc eax, eax ; Add with carry: EAX = EAX + EAX + CF = CF
1012
+ popfd ; Push EFLAGS register value on the stack (again, and makes sure the stack remains the same)
1013
+ mov has_cpuid, eax ; Save eax into C variable
1014
+ }
1015
+ #else
1016
+ __asm__ (" xorl %%eax, %%eax\n\t " // Zero EAX register
1017
+ " pushfl\n\t " // Push EFLAGS register value on the stack
1018
+ " orl $0x200000, (%%esp)\n\t " // Set bit 0x200000: Able to use CPUID instruction (Pentium+)
1019
+ " popfl\n\t " // Write the updated value into the EFLAGS register
1020
+ " pushfl\n\t " // Push EFLAGS register value on the stack (again)
1021
+ " btrl $0x15, (%%esp)\n\t " // Test bit 0x15 (21) and reset (set CF)
1022
+ " adc %%eax, %%eax\n\t " // Add with carry: EAX = EAX + EAX + CF = CF
1023
+ " popfl" // Push EFLAGS register value on the stack (again, and makes sure the stack remains the same)
1024
+ : " =a" (has_cpuid) // has_cpuid == EAX
1025
+ );
1026
+ #endif
1027
+ return has_cpuid;
773
1028
}
774
1029
775
1030
// FUNCTION: LEGO1 0x1009d210
0 commit comments