GETCPU.CPP 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/GETCPU.CPP 1 3/03/97 10:24a Joe_bostic $*/
  15. /***********************************************************************************************
  16. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : GETCPU *
  20. * *
  21. * File Name : GETCPU.CPP *
  22. * *
  23. * Programmer : Steve Tall *
  24. * *
  25. * Start Date : 6/26/96 *
  26. * *
  27. * Last Update : June 26th 1996 [ST] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Overview: *
  31. * Example of interface to assembly language code to find CPU type *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * *
  35. * Functions: *
  36. * Get_CPU_Type -- interface to ASM detection code *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. //#define WIN32
  39. //#include <windows.h>
  40. #include <stdio.h>
  41. #include <string.h>
  42. #define bool int
  43. /*
  44. ** Prototypes for linkage to assembly module
  45. */
  46. extern "C" {
  47. bool __cdecl Detect_MMX_Availability(void);
  48. void __cdecl Init_MMX(void);
  49. extern char CPUType;
  50. extern char VendorID;
  51. }
  52. /***********************************************************************************************
  53. * Get_CPU_Type -- Find out what kind of CPU we are running on *
  54. * *
  55. * *
  56. * *
  57. * INPUT: int - reference to cpu type *
  58. * bool - reference to mmx availability flag *
  59. * char* - ptr to buffer to receive chip vendor info *
  60. * int - length of above buffer *
  61. * *
  62. * OUTPUT: Nothing *
  63. * *
  64. * WARNINGS: None *
  65. * *
  66. * HISTORY: *
  67. * 6/26/96 10:15AM ST : Created *
  68. *=============================================================================================*/
  69. void Get_CPU_Type(int & cpu_type, bool & mmx, char * vendor_id, int vendor_id_length)
  70. {
  71. /*
  72. ** Call the asm CPU detection code
  73. */
  74. mmx = Detect_MMX_Availability();
  75. /*
  76. ** Return the promised results
  77. */
  78. cpu_type = (int)CPUType;
  79. char * vendor_ptr = &VendorID;
  80. strncpy(vendor_id, vendor_ptr, vendor_id_length);
  81. }