GETCPU.CPP 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /CounterStrike/GETCPU.CPP 1 3/03/97 10:24a Joe_bostic $*/
  19. /***********************************************************************************************
  20. *** 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 ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : GETCPU *
  24. * *
  25. * File Name : GETCPU.CPP *
  26. * *
  27. * Programmer : Steve Tall *
  28. * *
  29. * Start Date : 6/26/96 *
  30. * *
  31. * Last Update : June 26th 1996 [ST] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Overview: *
  35. * Example of interface to assembly language code to find CPU type *
  36. * *
  37. *---------------------------------------------------------------------------------------------*
  38. * *
  39. * Functions: *
  40. * Get_CPU_Type -- interface to ASM detection code *
  41. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  42. //#define WIN32
  43. //#include <windows.h>
  44. #include <stdio.h>
  45. #include <string.h>
  46. #define bool int
  47. /*
  48. ** Prototypes for linkage to assembly module
  49. */
  50. extern "C" {
  51. bool __cdecl Detect_MMX_Availability (void);
  52. extern char CPUType;
  53. extern char VendorID;
  54. }
  55. /***********************************************************************************************
  56. * Get_CPU_Type -- Find out what kind of CPU we are running on *
  57. * *
  58. * *
  59. * *
  60. * INPUT: int - reference to cpu type *
  61. * bool - reference to mmx availability flag *
  62. * char* - ptr to buffer to receive chip vendor info *
  63. * int - length of above buffer *
  64. * *
  65. * OUTPUT: Nothing *
  66. * *
  67. * WARNINGS: None *
  68. * *
  69. * HISTORY: *
  70. * 6/26/96 10:15AM ST : Created *
  71. *=============================================================================================*/
  72. void Get_CPU_Type(int & cpu_type, bool & mmx, char * vendor_id, int vendor_id_length)
  73. {
  74. /*
  75. ** Call the asm CPU detection code
  76. */
  77. mmx = Detect_MMX_Availability();
  78. /*
  79. ** Return the promised results
  80. */
  81. cpu_type = (int)CPUType;
  82. char * vendor_ptr = &VendorID;
  83. strncpy(vendor_id, vendor_ptr, vendor_id_length);
  84. }