]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/wcpu/wcpu.c
updated the copyleft wwww i am not deAD! i just been 2 busy last 6 monthes
[16.git] / src / lib / wcpu / wcpu.c
old mode 100644 (file)
new mode 100755 (executable)
index ea76843..39dcad7
@@ -1,5 +1,5 @@
 /* Project 16 Source Code~
- * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
+ * Copyright (C) 2012-2018 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
  *
  * This file is part of Project 16.
  *
  */
 /* tab size = 8 */
 
-#include "src/lib/wcpu/wcpu.h"
+#include "src/lib/wcpu/16_wcpu.h"
 
-byte detectcpu()
+void main(int argc, char **argv)
 {
-       byte cputype;
-       __asm
-       {
-               PUSHF                   ; we gonna modify flags, so back them up
-               ; first check if its 8086/8088 or 80186/80188
-               PUSHF                   ; FLAGS -> STACK
-               POP     AX              ; STACK -> AX
-               AND     AX, 00FFFh      ; clear 12-15 bits (they are always 1 on 8086/8088 and 80186/80188)
-               PUSH    AX              ; AX -> STACK
-               POPF                    ; STACK -> FLAGS
-               ; this is where magic happen
-               PUSHF                   ; FLAGS -> STACK
-               POP     AX              ; STACK -> AX
-               AND     AX, 0F000h      ; 0-11 bits aren't important to us
-               CMP     AX, 0F000h      ; check if all 12-15 bits are set (simple comparision)
-               JNE     _286p           ; if no, 286+ CPU
-               MOV     cputype, 0      ; if yes, we are done, set cputype to 0 and end this
-               JMP     _done
-       _286p:
-               ; now check if its 286 or newer
-               PUSHF                   ; FLAGS -> STACK
-               POP     AX              ; STACK -> AX
-               OR      AX, 07000h      ; set 12-14 bits (they are always cleared by 286 if its real mode)
-               PUSH    AX              ; AX -> STACK
-               POPF                    ; STACK -> FLAGS
-               ; this is where magic happen
-               PUSHF                   ; FLAGS -> STACK
-               POP     AX              ; STACK -> AX
-               TEST    AX, 07000h      ; check if at least 1 bit in 12-14 bits range is set (15th won't be set anyway)
-               JNZ     _386p           ; not all bits clear, its 386+
-               MOV     cputype, 1      ; all bits clear, its 286, we are done
-               JMP     _done
-       _386p:
-               MOV     cputype, 2      ; its 386 or newer, but we don't care if its newer at this point
-       _done:
-               POPF                    ; restore flags we backed up earlier
-       }
-       return cputype;
-}
-
-#ifdef TEST
-int main(int argc, char **argv)
-{
-       const char *cpus;
-       unsigned char cput;
+       /*const char *cpus, *fpus;
+       unsigned char cput, fput;
 
-       cput = detectcpu();
+       cput = WCPU_detectcpu();
+       fput = WCPU_detectfpu();
        switch(cput)
        {
                case 0: cpus = "8086/8088 or 186/88"; break;
@@ -79,8 +37,15 @@ int main(int argc, char **argv)
                case 2: cpus = "386 or newer"; break;
                default: cpus = "internal error"; break;
        }
+
+       switch(fput)
+       {
+               case 0: fpus = "none"; break;
+               case 1: fpus = "8087"; break;
+               default: fpus = "internal error"; break;
+       }
        printf("detected CPU type: %s\n", cpus);
-       return 0;
+       printf("detected FPU type: %s\n",       fpus);*/
+       WCPU_cpufpumesg();
+       //if (cpu_flags & CPU_FLAG_FPU) printf(" - With FPU\n");
 }
-#endif
-