From: sparky4 Date: Wed, 4 Jan 2017 17:50:43 +0000 (-0600) Subject: FPU detection added X-Git-Url: http://4ch.mooo.com/gitweb/?p=16.git;a=commitdiff_plain;h=e1e1e6b60d5b1808fc4ac80784118287a0437f2d FPU detection added --- diff --git a/16.upx b/16.upx deleted file mode 100755 index e69de29b..00000000 diff --git a/db.exe b/db.exe index 5616e4ae..af80cac8 100755 Binary files a/db.exe and b/db.exe differ diff --git a/makefile b/makefile index d754f957..2c8cde33 100755 --- a/makefile +++ b/makefile @@ -63,21 +63,22 @@ BUILD_ROOT=$+$(%__CWD__)$- DATADIR=data$(DIRSEP) SPRI=$(DATADIR)/spri SRC=src -SRCLIB=src/lib -JSMNLIB=src/lib/jsmn -NYANLIB=src/lib/nyan -EXMMLIB=src/lib/exmm -MODEXLIB16=src/lib/16_vl -MODEXLIB=src/lib/modex -VGMSNDLIB=src/lib/vgmsnd -DOSLIB=src/lib/doslib -WCPULIB=src/lib/wcpu - -DOSLIB_CPU=src/lib/doslib/hw/cpu -DOSLIB_DOS=src/lib/doslib/hw/dos -DOSLIB_VGA=src/lib/doslib/hw/vga -DOSLIB_8250=src/lib/doslib/hw/8250 -DOSLIB_JOYSTICK=src/lib/doslib/hw/joystick +UTIL=$(SRC)/util +SRCLIB=$(SRC)/lib +JSMNLIB=$(SRCLIB)/jsmn +NYANLIB=$(SRCLIB)/nyan +EXMMLIB=$(SRCLIB)/exmm +MODEXLIB16=$(SRCLIB)/16_vl +MODEXLIB=$(SRCLIB)/modex +VGMSNDLIB=$(SRCLIB)/vgmsnd +DOSLIB=$(SRCLIB)/doslib +WCPULIB=$(SRCLIB)/wcpu + +DOSLIB_CPU=$(DOSLIB)/hw/cpu +DOSLIB_DOS=$(DOSLIB)/hw/dos +DOSLIB_VGA=$(DOSLIB)/hw/vga +DOSLIB_8250=$(DOSLIB)/hw/8250 +DOSLIB_JOYSTICK=$(DOSLIB)/hw/joystick DOSLIB_MEMMODE=dos86$(MEMORYMODE) # @@ -110,7 +111,7 @@ LIBFLAGS=$(WLIBQ) -b -n VGMSNDOBJ = vgmSnd.$(OBJ) 16_snd.$(OBJ) OLDLIBOBJS=bitmap.$(OBJ) 16render.$(OBJ) GFXLIBOBJS = 16_vl.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16_vrs.$(OBJ) 16_sprit.$(OBJ) $(OLDLIBOBJS) -16LIBOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_tail.$(OBJ) 16_in.$(OBJ) 16_head.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) wcpu.$(OBJ) 16_timer.$(OBJ) jsmn.$(OBJ) 16_map.$(OBJ) 16text.$(OBJ) +16LIBOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_tail.$(OBJ) 16_in.$(OBJ) 16_head.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) 16_wcpu.$(OBJ) 16_timer.$(OBJ) jsmn.$(OBJ) 16_map.$(OBJ) 16text.$(OBJ) #16planar.$(OBJ) planar.$(OBJ) mapread.$(OBJ) DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ) !ifeq DEBUGSERIAL 1 @@ -129,9 +130,9 @@ DOSLIBLIBS += $(DOSLIB_8250)/$(DOSLIB_MEMMODE)/8250.lib # # Files locations # -.c : $(SRC);$(SRCLIB);$(MODEXLIB16);$(JSMNLIB);$(NYANLIB);$(VGMSNDLIB);$(WCPULIB) +.c : $(SRC);$(SRCLIB);$(MODEXLIB16);$(JSMNLIB);$(NYANLIB);$(VGMSNDLIB);$(WCPULIB);$(UTIL) -.asm : $(MODEXLIB) +.asm : $(MODEXLIB);$(UTIL) .lib : .;$(DOSLIB_CPU)/$(DOSLIB_MEMMODE);$(DOSLIB_DOS)/$(DOSLIB_MEMMODE);$(DOSLIB_VGA)/$(DOSLIB_MEMMODE);$(DOSLIB_8250)/$(DOSLIB_MEMMODE) @@ -156,6 +157,10 @@ DOSLIBLIBS += $(DOSLIB_8250)/$(DOSLIB_MEMMODE)/8250.lib # # List of executables to build # +EXTERNTESTEXEC = & + joytest.exe & + wcpu.exe & + db.exe TESTEXEC = & tesuto.exe & 0.exe & @@ -174,7 +179,7 @@ TESTEXEC2 = & test0.exe & pcxtest.exe & pcxtest2.exe & - db.exe + $(EXTERNTESTEXEC) UTILEXEC = & palettel.exe & palettec.exe @@ -184,8 +189,8 @@ EXEC = & $(UTILEXEC) & $(TESTEXEC) -all: $(EXEC) joytest.exe -testexec: $(EXEC) joytest.exe $(TESTEXEC2) +all: $(EXEC) $(EXTERNTESTEXEC) +testexec: $(EXEC) $(TESTEXEC2) # # game and bakapi executables @@ -224,6 +229,7 @@ fmemtest.exe: fmemtest.$(OBJ) exmmtest.exe: exmmtest.$(OBJ) $(16LIB) $(DOSLIBLIBS) vgmtest.exe: vgmtest.$(OBJ) vgmsnd.lib $(16LIB) $(DOSLIBLIBS) db.exe: db.$(OBJ) +wcpu.exe: wcpu.$(OBJ) $(16LIB) $(DOSLIBLIBS) # # executable's objects @@ -255,7 +261,7 @@ inputest.$(OBJ):$(SRC)/inputest.c #tsthimem.$(OBJ): $(SRC)/tsthimem.c exmmtest.$(OBJ):$(SRC)/exmmtest.c vgmtest.$(OBJ):$(SRC)/vgmtest.c -db.$(OBJ):$(SRC)/util/db.c +db.$(OBJ): $(UTIL)/db.c # # non executable objects libraries @@ -311,7 +317,7 @@ midi.$(OBJ): $(SRCLIB)/midi.c $(SRCLIB)/midi.h jsmn.$(OBJ): $(JSMNLIB)/jsmn.c $(JSMNLIB)/jsmn.h kitten.$(OBJ): $(NYANLIB)/kitten.c $(NYANLIB)/kitten.h vgmSnd.$(OBJ): $(VGMSNDLIB)/vgmSnd.c $(VGMSNDLIB)/vgmSnd.h -wcpu.$(OBJ): $(WCPULIB)/wcpu.c $(WCPULIB)/wcpu.h +16_wcpu.$(OBJ): $(WCPULIB)/16_wcpu.c $(WCPULIB)/16_wcpu.h #memory.$(OBJ):$(EXMMLIB)/memory.c $(EXMMLIB)/memory.h c_utils.$(OBJ):$(MODEXLIB)/c_utils.asm modex.$(OBJ): $(MODEXLIB)/modex.asm diff --git a/src/16.c b/src/16.c index 8ef4d904..b3fa0673 100755 --- a/src/16.c +++ b/src/16.c @@ -23,7 +23,6 @@ #include "src/16.h" engi_stat_t engi_stat; -const char *cpus; byte *dpal, *gpal; player_t player[MaxPlayers]; @@ -53,17 +52,10 @@ main(int argc, char *argv[]) shinku(&gvar); _DEBUGF("Serial debug output printf test %u %u %u\n",1U,2U,3U); } - switch(detectcpu()) - { - case 0: cpus = "8086/8088 or 186/88"; break; - case 1: cpus = "286"; break; - case 2: cpus = "386 or newer"; break; - default: cpus = "internal error"; break; - } Shutdown16(&gvar); VGAmodeX(0, 1, &gvar); printf("Project 16 16.exe. This is supposed to be the actual finished game executable!\n"); printf("version %s\n", VERSION); - printf("detected CPU type: %s\n", cpus); + WCPU_cpufpumesg(); modexFadeOn(4, dpal); } diff --git a/src/16.h b/src/16.h index 253cd9e9..c39155d2 100755 --- a/src/16.h +++ b/src/16.h @@ -26,7 +26,7 @@ #include "src/lib/16_head.h" #include "src/lib/16_tail.h" #include "src/lib/16_vl.h" -#include "src/lib/wcpu/wcpu.h" +#include "src/lib/wcpu/16_wcpu.h" #include "src/lib/scroll16.h" #include "src/lib/16_timer.h" #include "src/lib/16_dbg.h" diff --git a/src/lib/16_timer.c b/src/lib/16_timer.c index 5cb216c1..e05232a0 100755 --- a/src/lib/16_timer.c +++ b/src/lib/16_timer.c @@ -33,7 +33,7 @@ clock_t start_timer(global_game_variables_t *gv) //gv->kurokku.frames_per_second = 60; //turn this off if XT - switch(detectcpu()) + switch(WCPU_detectcpu()) { case 0: gv->kurokku.fpscap=0; diff --git a/src/lib/16_timer.h b/src/lib/16_timer.h index d6e491db..fb2335ce 100755 --- a/src/lib/16_timer.h +++ b/src/lib/16_timer.h @@ -23,7 +23,7 @@ #ifndef _TIMER_H_ #define _TIMER_H_ #include "src/lib/16_head.h" -#include "src/lib/wcpu/wcpu.h" +#include "src/lib/wcpu/16_wcpu.h" clock_t start_timer(global_game_variables_t *gv); double elapsed_timer(global_game_variables_t *gv); diff --git a/src/lib/scroll16.h b/src/lib/scroll16.h index 9dc7b4a5..c8ccab49 100755 --- a/src/lib/scroll16.h +++ b/src/lib/scroll16.h @@ -33,7 +33,7 @@ #include "src/lib/16render.h" //#include "src/lib/16_map.h" //new map stuff #include "src/lib/16_timer.h" -#include "src/lib/wcpu/wcpu.h" +#include "src/lib/wcpu/16_wcpu.h" #include #include diff --git a/src/lib/wcpu/16_wcpu.c b/src/lib/wcpu/16_wcpu.c new file mode 100755 index 00000000..41de0e12 --- /dev/null +++ b/src/lib/wcpu/16_wcpu.c @@ -0,0 +1,164 @@ +/* Project 16 Source Code~ + * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover + * + * This file is part of Project 16. + * + * Project 16 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Project 16 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see , or + * write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301 USA. + * + */ +/* tab size = 8 */ + +#include "src/lib/wcpu/16_wcpu.h" + +//#define USECPUPROBE + +byte WCPU_detectfpu() +{ + byte fputype=0; + word funk=0; + boolean errflag=0; + __asm { + PUSHF ; we gonna modify flags, so back them up +.8087 fninit ; Initialize FPU +// mov [WORD PTR funk], 55AAh ; Set junk value +// fnstsw funk ; Store status word +// cmp [BYTE PTR funk], 0 ; If it's not 0, no FPU + mov funk, 55AAh ; Set junk value + fnstsw funk ; Store status word + cmp funk, 0 ; If it's not 0, no FPU +// jne short _done + jne short _err + jmp _fpu + _err: + mov errflag, 1 + _fpu: +/* } + if(!errflag){ + printf("."); + __asm {*/ + fnstcw funk ; Store control word + mov ax, funk ; If the bits are not the way + and ax, 103Fh ; they should be, no FPU + cmp ax, 3Fh +// jne short _done + je short __err + jmp __fpu + __err: + mov errflag, 1 + __fpu: + /*}} + if(!errflag){ + printf("."); + __asm {*/ +// and [WORD PTR funk], 0FF7Fh ; Clear interrupt bit + and funk, 0FF7Fh ; Clear interrupt bit + fldcw funk ; Load control word + fdisi ; Disable interrupts + fstcw funk ; Store control word +// test [BYTE PTR funk], 80h ; If it changed, it's an 8087 + test funk, 80h ; If it changed, it's an 8087 + mov fputype, 1 + + _done: + POPF ; restore flags we backed up earlier + }//} + //printf("WCPU_detectfpu():\n fputype=%u\n funk=%u errflag=%u\n", fputype, funk, errflag); +#ifdef USECPUPROBE + if (cpu_flags & CPU_FLAG_FPU) printf(" - With FPU\n"); +#endif + return fputype; +} + +byte WCPU_detectcpu() +{ + byte cputype=0; + __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; +} + +const char *WCPU_cpudetectmesg() +{ + const char *cpus; + unsigned char cput; + + cput = WCPU_detectcpu(); + switch(cput) + { + case 0: cpus = "8086/8088 or 186/88"; break; + case 1: cpus = "286"; break; + case 2: cpus = "386 or newer"; break; + default: cpus = "internal error"; break; + } + return cpus; +} + +const char *WCPU_fpudetectmesg() +{ + const char *fpus; + unsigned char fput; + + fput = WCPU_detectfpu(); + switch(fput) + { + case 0: fpus = "none"; break; + case 1: fpus = "8087"; break; + default: fpus = "internal error"; break; + } + return fpus; +} + +void WCPU_cpufpumesg() +{ +#ifdef USECPUPROBE + cpu_probe(); +#endif + printf("detected CPU type: %s\n", WCPU_cpudetectmesg()); + printf("detected FPU type: %s\n", WCPU_fpudetectmesg()); +} diff --git a/src/lib/wcpu/16_wcpu.h b/src/lib/wcpu/16_wcpu.h new file mode 100755 index 00000000..93f97e0f --- /dev/null +++ b/src/lib/wcpu/16_wcpu.h @@ -0,0 +1,38 @@ +/* Project 16 Source Code~ + * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover + * + * This file is part of Project 16. + * + * Project 16 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Project 16 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see , or + * write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef _WCPU_H_ +#define _WCPU_H_ +#include +#include "src/lib/16_t.h" + +#ifdef __WATCOMC__ +#include +#endif + +byte WCPU_detectfpu(void); +byte WCPU_detectcpu(void); +const char *WCPU_cpudetectmesg(); +const char *WCPU_fpudetectmesg(); +void WCPU_cpufpumesg(); + +#endif/*_WCPU_H_*/ diff --git a/src/lib/wcpu/wcpu.c b/src/lib/wcpu/wcpu.c index 92b91919..c72cca70 100755 --- a/src/lib/wcpu/wcpu.c +++ b/src/lib/wcpu/wcpu.c @@ -21,57 +21,15 @@ */ /* 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=0; - __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 - diff --git a/src/lib/wcpu/wcpu.h b/src/lib/wcpu/wcpu.h index c72f5d0f..43aced89 100755 --- a/src/lib/wcpu/wcpu.h +++ b/src/lib/wcpu/wcpu.h @@ -27,6 +27,10 @@ //#define TEST -byte detectcpu(void); +byte WCPU_detectfpu(void); +byte WCPU_detectcpu(void); +const char *WCPU_cpudetectmesg(); +const char *WCPU_fpudetectmesg(); +void WCPU_cpufpumesg(); #endif/*_WCPU_H_*/ diff --git a/src/scroll.c b/src/scroll.c index 131b0435..f14ec0cd 100755 --- a/src/scroll.c +++ b/src/scroll.c @@ -22,7 +22,6 @@ #include "src/lib/scroll16.h" #include "src/lib/16_timer.h" -#include "src/lib/wcpu/wcpu.h" #include "src/lib/16_dbg.h" //#define FADE @@ -39,7 +38,6 @@ pan_t pan; boolean panswitch=0;//1 //extern boolean pageflipflop=1; unsigned int i; - const char *cpus; //static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */ //map_view_db_t pgid[4]; @@ -287,14 +285,7 @@ void main(int argc, char *argv[]) printf("\nProject 16 scroll.exe. This is just a test file!\n"); printf("version %s\n", VERSION); SCROLLEXITMESG; - switch(detectcpu()) - { - case 0: cpus = "8086/8088 or 186/88"; break; - case 1: cpus = "286"; break; - case 2: cpus = "386 or newer"; break; - default: cpus = "internal error"; break; - } - printf("detected CPU type: %s\n", cpus); + WCPU_cpufpumesg(); #ifdef MODEX #ifdef FADE modexFadeOn(4, dpal); diff --git a/src/util/cputype.asm b/src/util/cputype.asm new file mode 100755 index 00000000..f4540acd --- /dev/null +++ b/src/util/cputype.asm @@ -0,0 +1,147 @@ +; To assemble the code using MASM 5.10: +; MASM cputype; +; LINK cputype; +; EXE2COM cputype; +; Version: 1.00b + +; Author: Ben Lunt (Forever Young Software) + +; Date: 20 Nov 1997 + +; If you need an EXE to COM converter, you can get one here +; +; The following code won't assemble with NBASM yet, since +; I have not added all the FPU instructions. I hope to get to them soon. +; Until then, you will have to use a different assembler. Sorry. +; + +CodeSeg segment + assume cs:CodeSeg, ds:CodeSeg, es:CodeSeg +.186 + org 100h +start: mov ax,cs ; free unused part of Mem Block + mov es,ax ; for .COM file format + mov bx,4096 ; + mov ah,4Ah ; + int 21h ; + + mov cx,0121h ; If CH can be shifted by 21h, + shl ch,cl ; then it's an 8086, because + jz short p1_8086 ; a 186+ limits shift counts. + push sp ; If SP is pushed as its + pop ax ; original value, then + cmp ax,sp ; it's a 286+. + jne short p1_186 + mov ax,7000h ; if bits 12,13,14 are still set + push ax ; after pushing/poping to/from + popf ; the flags register then we have + pushf ; a 386+ + pop ax + and ax,7000h + cmp ax,7000h + jne short p1_286 ; it's a 386+ +.386 + push bp ; Align stack to dword + mov bp,sp + and sp,0FFFCh + pushfd ; Save eflags + cli ; No interrupts + pushfd ; EAX = eflags + pop eax + mov ebx,eax ; EBX = eflags + xor eax,40000h ; Toggle AC bit + push eax ; Eflags = EAX + popfd + pushfd ; EAX = eflags + pop eax + popfd ; Restore eflags + mov sp,bp ; Restore stack + pop bp + cmp eax,ebx ; If the bit was not + je short p1_386 ; reset, it's a 486+ + pushfd ; Save eflags + cli ; No interrupts + pushfd ; EAX = eflags + pop eax + xor eax,200000h ; Toggle ID bit + push eax ; Eflags = EAX + popfd + pushfd ; EBX = eflags + pop ebx + popfd ; Restore eflags + cmp eax,ebx ; If the bit was not + jne short p1_486 ; reset, it's a 586+ + mov dx,offset CPUType5 ; 586+ + jmp short cpudone +p1_486: mov dx,offset CPUType4 ; 486 + jmp short cpudone +p1_386: mov dx,offset CPUType3 ; 386 + jmp short cpudone +p1_286: mov dx,offset CPUType2 ; 286 + jmp short cpudone +p1_186: mov dx,offset CPUType1 ; 186 + jmp short cpudone +p1_8086: mov dx,offset CPUType0 ; 8086 +cpudone: mov ah,09 + int 21h +.186 ; make sure we set proc back to 186 +.8087 fninit ; Initialize FPU + mov _Junk,55AAh ; Set junk value + fnstsw _Junk ; Store status word + cmp _Junk,0 ; If it's not 0, no FPU + jne short p2_nofpu + fnstcw _Junk ; Store control word + mov ax,_Junk ; If the bits are not the way + and ax,103Fh ; they should be, no FPU + cmp ax,3Fh + jne short p2_nofpu + + and _Junk,0FF7Fh ; Clear interrupt bit + fldcw _Junk ; Load control word + fdisi ; Disable interrupts + fstcw _Junk ; Store control word + test _Junk,80h ; If it changed, it's an 8087 + jnz short p2_8087 +.286 ; allowes .287 also + finit ; Re-initialize + fld1 ; Divide 1 by 0 to get + fldz ; a positive infinity + fdiv + fld st ; Get a negative infinity + fchs + fcompp ; Compare them + fstsw ax ; Store status word + sahf ; If the FPU thought that they + je short p2_287 ; were equal, it's a 287 + mov dx,offset FPUType3 ; 387 + finit ; Init processor + jmp short fputypeD +p2_287: mov dx,offset FPUType2 ; 287 + finit ; Init processor + jmp short fputypeD +p2_8087: mov dx,offset FPUType0 ; 8087 + finit ; Init processor + jmp short fputypeD +p2_nofpu: mov dx,offset FPUType +fputypeD: mov ah,09 + int 21h +.186 +.8087 + ret + + +_Junk dw 00h +CPUType0 db 13,10,'You have an 8086/88 processor.$' +CPUType1 db 13,10,'You have an 186/88 processor.$' +CPUType2 db 13,10,'You have an 286 processor.$' +CPUType3 db 13,10,'You have an 386 processor.$' +CPUType4 db 13,10,'You have an 486 processor.$' +CPUType5 db 13,10,'You have an 586 or better processor.$' + +FPUType db 13,10,"You don't have a math coprocessor.$" +FPUType0 db 13,10,'You have an 8087 math coprocessor.$' +FPUType2 db 13,10,'You have an 287 math coprocessor.$' +FPUType3 db 13,10,'You have an 387 or better math coprocessor.$' + +CodeSeg ends + end start diff --git a/src/zcroll.c b/src/zcroll.c index 29f329c8..16736543 100755 --- a/src/zcroll.c +++ b/src/zcroll.c @@ -22,7 +22,6 @@ #include "src/lib/scroll16.h" #include "src/lib/16_timer.h" -#include "src/lib/wcpu/wcpu.h" #include "src/lib/16render.h" #include "src/lib/16_dbg.h" @@ -38,7 +37,6 @@ pan_t pan; boolean panswitch=0,baka=0; //extern boolean pageflipflop=1; unsigned int i; -const char *cpus; //static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */ //map_view_db_t pgid[4]; @@ -241,14 +239,7 @@ void main(int argc, char *argv[]) printf("\nProject 16 zcroll.exe. This is just a test file!\n"); printf("version %s\n", VERSION); SCROLLEXITMESG; - switch(detectcpu()) - { - case 0: cpus = "8086/8088 or 186/88"; break; - case 1: cpus = "286"; break; - case 2: cpus = "386 or newer"; break; - default: cpus = "internal error"; break; - } - printf("detected CPU type: %s\n", cpus); + WCPU_cpufpumesg(); #ifdef FADE modexFadeOn(4, dpal); #endif diff --git a/wcpu.exe b/wcpu.exe new file mode 100755 index 00000000..b2b745cb Binary files /dev/null and b/wcpu.exe differ