From ef6667b05c6ec9372c3d0715f87c62dafdff9573 Mon Sep 17 00:00:00 2001 From: "Howard M. Harte" Date: Mon, 24 Oct 2022 14:15:51 -0700 Subject: [PATCH] Fix AltairZ80 compilation with Visual Studio 2008 (#85) * AltairZ80: SS1: Fix disable after reset. The CompuPro System Support 1 could not be disabled after enabled and used due to timers causing it to be busy. Reset properly so that "set ss1 disabled" works after reset. * AltairZ80: wd179x: Properly reset 179x state. * AltairZ80: M68K: Fix compile with VS2008. * Musashi: Fix compilation with Visual Studio 2008. * AltairZ80: M68K: Resolve warnings in softfloat. * AltairZ80: Add headers to .vcproj --- AltairZ80/m68k/m68kconf.h | 4 ++ AltairZ80/m68k/m68kcpu.h | 3 +- AltairZ80/m68k/softfloat/softfloat.c | 26 ++++---- AltairZ80/s100_ss1.c | 15 +++-- AltairZ80/wd179x.c | 2 + Visual Studio Projects/AltairZ80.vcproj | 80 ++++++++++++++++++++++--- 6 files changed, 103 insertions(+), 27 deletions(-) diff --git a/AltairZ80/m68k/m68kconf.h b/AltairZ80/m68k/m68kconf.h index 06a526d4..3ddc681d 100644 --- a/AltairZ80/m68k/m68kconf.h +++ b/AltairZ80/m68k/m68kconf.h @@ -43,6 +43,10 @@ #define OPT_ON 1 #define OPT_SPECIFY_HANDLER 2 +#if defined(_MSC_VER) +/* Disable MSVC warning 4146: Unary minus. */ +#pragma warning (disable: 4146) +#endif /* ======================================================================== */ /* ============================== MAME STUFF ============================== */ diff --git a/AltairZ80/m68k/m68kcpu.h b/AltairZ80/m68k/m68kcpu.h index f2c8bf43..5adca63e 100755 --- a/AltairZ80/m68k/m68kcpu.h +++ b/AltairZ80/m68k/m68kcpu.h @@ -1911,6 +1911,7 @@ extern jmp_buf m68ki_bus_error_jmp_buf; /* Exception for bus error */ static inline void m68ki_exception_bus_error(void) { + uint sr; int i; /* If we were processing a bus error, address error, or reset, @@ -1932,7 +1933,7 @@ static inline void m68ki_exception_bus_error(void) REG_DA[i] = REG_DA_SAVE[i]; } - uint sr = m68ki_init_exception(); + sr = m68ki_init_exception(); /* Note: This is implemented for 68010 only! */ m68ki_stack_frame_1000(REG_PPC, sr, EXCEPTION_BUS_ERROR); diff --git a/AltairZ80/m68k/softfloat/softfloat.c b/AltairZ80/m68k/softfloat/softfloat.c index 400fd593..fd65afa4 100644 --- a/AltairZ80/m68k/softfloat/softfloat.c +++ b/AltairZ80/m68k/softfloat/softfloat.c @@ -91,7 +91,7 @@ static int32 roundAndPackInt32( flag zSign, bits64 absZ ) roundBits = absZ & 0x7F; absZ = ( absZ + roundIncrement )>>7; absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven ); - z = absZ; + z = (int32)absZ; if ( zSign ) z = - z; if ( ( absZ>>32 ) || ( z && ( ( z < 0 ) ^ zSign ) ) ) { float_raise( float_flag_invalid ); @@ -905,7 +905,7 @@ float32 int64_to_float32( int64 a ) absA = zSign ? - a : a; shiftCount = countLeadingZeros64( absA ) - 40; if ( 0 <= shiftCount ) { - return packFloat32( zSign, 0x95 - shiftCount, absA<>( 64 - expDiff ); + q = (bits32)(q64>>( 64 - expDiff )); bSig <<= 6; aSig = ( ( aSig64>>33 )<<( expDiff - 1 ) ) - bSig * q; } @@ -1971,7 +1971,7 @@ int32 float64_to_int32_round_to_zero( float64 a ) shiftCount = 0x433 - aExp; savedASig = aSig; aSig >>= shiftCount; - z = aSig; + z = (int32)aSig; if ( aSign ) z = - z; if ( ( z < 0 ) ^ aSign ) { invalid: @@ -2101,7 +2101,7 @@ float32 float64_to_float32( float64 a ) return packFloat32( aSign, 0xFF, 0 ); } shift64RightJamming( aSig, 22, &aSig ); - zSig = aSig; + zSig = (bits32)aSig; if ( aExp || zSig ) { zSig |= 0x40000000; aExp -= 0x381; @@ -2673,7 +2673,7 @@ float64 float64_sqrt( float64 a ) } zExp = ( ( aExp - 0x3FF )>>1 ) + 0x3FE; aSig |= LIT64( 0x0010000000000000 ); - zSig = estimateSqrt32( aExp, aSig>>21 ); + zSig = estimateSqrt32( aExp, (bits32)(aSig>>21) ); aSig <<= 9 - ( aExp & 1 ); zSig = estimateDiv128To64( aSig, 0, zSig<<32 ) + ( zSig<<30 ); if ( ( zSig & 0x1FF ) <= 5 ) { @@ -2890,7 +2890,7 @@ int32 floatx80_to_int32_round_to_zero( floatx80 a ) shiftCount = 0x403E - aExp; savedASig = aSig; aSig >>= shiftCount; - z = aSig; + z = (int32)aSig; if ( aSign ) z = - z; if ( ( z < 0 ) ^ aSign ) { invalid: @@ -3012,7 +3012,7 @@ float32 floatx80_to_float32( floatx80 a ) } shift64RightJamming( aSig, 33, &aSig ); if ( aExp || aSig ) aExp -= 0x3F81; - return roundAndPackFloat32( aSign, aExp, aSig ); + return roundAndPackFloat32( aSign, aExp, (bits32)aSig ); } @@ -3887,7 +3887,7 @@ int32 float128_to_int32_round_to_zero( float128 a ) shiftCount = 0x402F - aExp; savedASig = aSig0; aSig0 >>= shiftCount; - z = aSig0; + z = (int32)aSig0; if ( aSign ) z = - z; if ( ( z < 0 ) ^ aSign ) { invalid: @@ -4031,7 +4031,7 @@ float32 float128_to_float32( float128 a ) } aSig0 |= ( aSig1 != 0 ); shift64RightJamming( aSig0, 18, &aSig0 ); - zSig = aSig0; + zSig = (bits32)aSig0; if ( aExp || zSig ) { zSig |= 0x40000000; aExp -= 0x3F81; @@ -4714,7 +4714,7 @@ float128 float128_sqrt( float128 a ) } zExp = ( ( aExp - 0x3FFF )>>1 ) + 0x3FFE; aSig0 |= LIT64( 0x0001000000000000 ); - zSig0 = estimateSqrt32( aExp, aSig0>>17 ); + zSig0 = estimateSqrt32( aExp, (bits32)(aSig0>>17 )); shortShift128Left( aSig0, aSig1, 13 - ( aExp & 1 ), &aSig0, &aSig1 ); zSig0 = estimateDiv128To64( aSig0, aSig1, zSig0<<32 ) + ( zSig0<<30 ); doubleZSig0 = zSig0<<1; diff --git a/AltairZ80/s100_ss1.c b/AltairZ80/s100_ss1.c index 4632e968..fc93b5b1 100644 --- a/AltairZ80/s100_ss1.c +++ b/AltairZ80/s100_ss1.c @@ -81,7 +81,7 @@ static void setClockSS1(void); /* SS1 Interrupt Controller notes: * - * Msster 8259: + * Master 8259: * IRQ0 = VI0 * IRQ1 = VI1 - DISK3 Interrupt * IRQ2 = VI2 - IF3 Rx Interrupt @@ -178,10 +178,10 @@ typedef struct { RTC_REGS ss1_rtc[1] = { { 0 } }; static UNIT ss1_unit[] = { - { UDATA (&ss1_svc, UNIT_FIX | UNIT_DISABLE | UNIT_ROABLE, 0) }, - { UDATA (&ss1_svc, UNIT_FIX | UNIT_DISABLE | UNIT_ROABLE, 0) }, - { UDATA (&ss1_svc, UNIT_FIX | UNIT_DISABLE | UNIT_ROABLE, 0) }, - { UDATA (&ss1_svc, UNIT_FIX | UNIT_DISABLE | UNIT_ROABLE, 0) } + { UDATA (&ss1_svc, UNIT_FIX | UNIT_DISABLE | UNIT_DIS | UNIT_ROABLE, 0) }, + { UDATA (&ss1_svc, UNIT_FIX | UNIT_DISABLE | UNIT_DIS | UNIT_ROABLE, 0) }, + { UDATA (&ss1_svc, UNIT_FIX | UNIT_DISABLE | UNIT_DIS | UNIT_ROABLE, 0) }, + { UDATA (&ss1_svc, UNIT_FIX | UNIT_DISABLE | UNIT_DIS | UNIT_ROABLE, 0) } }; static REG ss1_reg[] = { @@ -262,6 +262,11 @@ static t_stat ss1_reset(DEVICE *dptr) { PNP_INFO *pnp = (PNP_INFO *)dptr->ctxt; + sim_cancel(&dptr->units[0]); + sim_cancel(&dptr->units[1]); + sim_cancel(&dptr->units[2]); + sim_cancel(&dptr->units[3]); + if(dptr->flags & DEV_DIS) { /* Disconnect I/O Ports */ sim_map_resource(pnp->io_base, pnp->io_size, RESOURCE_TYPE_IO, &ss1dev, "ss1dev", TRUE); } else { diff --git a/AltairZ80/wd179x.c b/AltairZ80/wd179x.c index 84594a20..798eec82 100644 --- a/AltairZ80/wd179x.c +++ b/AltairZ80/wd179x.c @@ -309,6 +309,8 @@ static t_stat wd179x_reset(DEVICE *dptr) } } + wd179x_info->cmdtype = 0; + return SCPE_OK; } diff --git a/Visual Studio Projects/AltairZ80.vcproj b/Visual Studio Projects/AltairZ80.vcproj index aa19fad6..11a562e5 100644 --- a/Visual Studio Projects/AltairZ80.vcproj +++ b/Visual Studio Projects/AltairZ80.vcproj @@ -41,7 +41,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="../AltairZ80/;./;../;../slirp;../slirp_glue;../slirp_glue/qemu;../slirp_glue/qemu/win32/include;../../windows-build/include;;../../windows-build/include/SDL2" - PreprocessorDefinitions="NO_INLINE;SIM_BUILD_TOOL=simh-Visual-Studio-Project;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;HAVE_PCRE_H;PCRE_STATIC" + PreprocessorDefinitions="inline=__inline;SIM_BUILD_TOOL=simh-Visual-Studio-Project;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;HAVE_PCRE_H;PCRE_STATIC" KeepComments="false" BasicRuntimeChecks="0" RuntimeLibrary="1" @@ -125,7 +125,7 @@ OmitFramePointers="true" WholeProgramOptimization="true" AdditionalIncludeDirectories="../AltairZ80/;./;../;../slirp;../slirp_glue;../slirp_glue/qemu;../slirp_glue/qemu/win32/include;../../windows-build/include;;../../windows-build/include/SDL2" - PreprocessorDefinitions="NO_INLINE;SIM_BUILD_TOOL=simh-Visual-Studio-Project;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;HAVE_PCRE_H;PCRE_STATIC" + PreprocessorDefinitions="inline=__inline;SIM_BUILD_TOOL=simh-Visual-Studio-Project;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;HAVE_PCRE_H;PCRE_STATIC" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -279,10 +279,6 @@ RelativePath="..\AltairZ80\m68k\m68kops.c" > - - @@ -336,11 +332,11 @@ > + + @@ -444,6 +444,58 @@ RelativePath="..\AltairZ80\altairz80_defs.h" > + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -500,6 +552,18 @@ RelativePath="..\sim_video.h" > + + + + + +