From 17356d90936fc7eed6c8bec59bb98e11c0f3116d Mon Sep 17 00:00:00 2001 From: Peter Schorn Date: Tue, 10 Dec 2019 08:42:22 +0100 Subject: [PATCH] AltairZ80: Replace WIN32 dependencies with SIMH API calls and remove redundant includes --- AltairZ80/altairz80_cpu.c | 23 ++----- AltairZ80/altairz80_hdsk.c | 4 +- AltairZ80/altairz80_sio.c | 23 +++---- AltairZ80/i8272.c | 5 -- AltairZ80/mfdc.c | 4 -- AltairZ80/n8vem.c | 4 -- AltairZ80/s100_64fdc.c | 5 -- AltairZ80/s100_adcs6.c | 5 -- AltairZ80/s100_disk1a.c | 5 -- AltairZ80/s100_disk2.c | 5 -- AltairZ80/s100_disk3.c | 5 -- AltairZ80/s100_fif.c | 131 ------------------------------------- AltairZ80/s100_hdc1001.c | 5 -- AltairZ80/s100_if3.c | 5 -- AltairZ80/s100_mdriveh.c | 4 -- AltairZ80/s100_mdsa.c | 4 -- AltairZ80/s100_mdsad.c | 4 -- AltairZ80/s100_scp300f.c | 4 -- AltairZ80/s100_selchan.c | 4 -- AltairZ80/s100_ss1.c | 5 -- AltairZ80/vfdhd.c | 5 -- AltairZ80/wd179x.c | 5 -- 22 files changed, 16 insertions(+), 248 deletions(-) diff --git a/AltairZ80/altairz80_cpu.c b/AltairZ80/altairz80_cpu.c index 3219412d..ab5f724c 100644 --- a/AltairZ80/altairz80_cpu.c +++ b/AltairZ80/altairz80_cpu.c @@ -29,18 +29,13 @@ #include "m68k.h" #include + #define SWITCHCPU_DEFAULT 0xfd /* Debug flags */ #define IN_MSG (1 << 0) #define OUT_MSG (1 << 1) -#if defined (_WIN32) -#include -#else -#include -#endif - #define PCQ_SIZE 64 /* must be 2**n */ #define PCQ_SIZE_LOG2 6 /* log2 of PCQ_SIZE */ #define PCQ_MASK (PCQ_SIZE - 1) @@ -2088,7 +2083,7 @@ static t_stat sim_instr_mmu (void) { tStates = 0; if (rtc_avail) { startTime = sim_os_msec(); - tStatesInSlice = sliceLength*clockFrequency; + tStatesInSlice = sliceLength * clockFrequency; } else /* make sure that sim_os_msec() is not called later */ clockFrequency = startTime = tStatesInSlice = 0; @@ -2107,7 +2102,7 @@ static t_stat sim_instr_mmu (void) { tStates = 0; if (rtc_avail) { startTime = sim_os_msec(); - tStatesInSlice = sliceLength*clockFrequency; + tStatesInSlice = sliceLength * clockFrequency; } else /* make sure that sim_os_msec() is not called later */ clockFrequency = startTime = tStatesInSlice = 0; @@ -2120,13 +2115,8 @@ static t_stat sim_instr_mmu (void) { /* clockFrequency != 0 implies that real time clock is available */ startTime += sliceLength; tStates -= tStatesInSlice; - if (startTime > (now = sim_os_msec())) { -#if defined (_WIN32) - Sleep(startTime - now); -#else - usleep(1000 * (startTime - now)); -#endif - } + if (startTime > (now = sim_os_msec())) + sim_os_ms_sleep(startTime - now); } if (timerInterrupt && (IFF_S & 1)) { @@ -2163,7 +2153,7 @@ static t_stat sim_instr_mmu (void) { if (sim_brk_summ) { if (sim_brk_test(PC, (2u << SIM_BKPT_V_SPC) | SWMASK('E'))) { /* breakpoint? */ - reason = STOP_IBKPT; /* stop simulation */ + reason = STOP_IBKPT; /* stop simulation */ break; } if (sim_brk_test(GetBYTE(PC), (1u << SIM_BKPT_V_SPC) | SWMASK('I'))) { /* instruction breakpoint? */ @@ -6121,7 +6111,6 @@ static t_stat sim_instr_mmu (void) { case 0xfe: /* CP nn */ tStates += 7; /* CPI nn 7 */ - FALSE; temp = RAM_PP(PC); AF = (AF & ~0x28) | (temp & 0x28); acu = HIGH_REGISTER(AF); diff --git a/AltairZ80/altairz80_hdsk.c b/AltairZ80/altairz80_hdsk.c index 61f57530..fd96c543 100644 --- a/AltairZ80/altairz80_hdsk.c +++ b/AltairZ80/altairz80_hdsk.c @@ -190,7 +190,7 @@ static int32 mits[SPT32] = { 0, 17, 2, 19, 4, 21, 6, 23, static DPB dpb[] = { /* name capac spt bsh blm exm dsm drm al0 al1 cks off psh phm ss off skew */ - { "HDSK", HDSK_CAPACITY, 32, 0x05, 0x1F, 0x01, 0x07f9, 0x03FF, + { "HDSK", HDSK_CAPACITY, 32, 0x05, 0x1F, 0x01, 0x07F9, 0x03FF, 0xFF, 0x00, 0x0000, 0x0006, 0x00, 0x00, 0, 0, NULL }, /* AZ80 HDSK */ { "CPM68K", (1 << 24), (1<<17),0, 0, 0, 0, 0, @@ -284,7 +284,7 @@ static DPB dpb[] = { dw 40 ;#128 byte records/track db 4,0fh ;block shift mask (2K) db 1 ;extent mask - dw 194 ;maximun block number + dw 194 ;maximum block number dw 127 ;max number of dir entry - 1 db 0C0H,00h ;alloc vector for directory dw 0020h ;checksum size diff --git a/AltairZ80/altairz80_sio.c b/AltairZ80/altairz80_sio.c index 89498482..9f138a1a 100644 --- a/AltairZ80/altairz80_sio.c +++ b/AltairZ80/altairz80_sio.c @@ -204,13 +204,11 @@ static int32 getStopWatchDeltaPos = 0; /* determines the state for rece static uint32 stopWatchNow = 0; /* stores starting time of stop watch */ static int32 markTimeSP = 0; /* stack pointer for timer stack */ - /* default time in microseconds to sleep for SIMHSleepCmd */ -#if defined (_WIN32) -static uint32 SIMHSleep = 1000; /* Sleep uses milliseconds */ -#elif defined (__MWERKS__) && defined (macintosh) + /* default time in milliseconds to sleep for SIMHSleepCmd */ +#if defined (__MWERKS__) && defined (macintosh) static uint32 SIMHSleep = 0; /* no sleep on Macintosh OS9 */ #else -static uint32 SIMHSleep = 100; /* on other platforms 100 micro seconds is good enough */ +static uint32 SIMHSleep = 1; /* default value is one millisecond */ #endif static uint32 sleepAllowedCounter = 0; /* only sleep on no character available when == 0 */ static uint32 sleepAllowedStart = SLEEP_ALLOWED_START_DEFAULT; /* default start for above counter */ @@ -472,7 +470,7 @@ static REG simh_reg[] = { { DRDATAD (STDP, setTimerDeltaPos, 8, "Status register for receiving the timer delta"), REG_RO }, { DRDATAD (SLEEP, SIMHSleep, 32, - "Sleep time in milliseconds after SIO status check (when enabled)") }, + "Sleep time in milliseconds after SIO status check (when enabled)") }, { DRDATAD (VOSLP, sleepAllowedStart, 32, "Only sleep when this many unsuccessful SIO status checks have been made") }, @@ -483,7 +481,7 @@ static REG simh_reg[] = { { DRDATAD (STPNW, stopWatchNow, 32, "Starting time of stop watch"), REG_RO }, { DRDATAD (MTSP, markTimeSP, 8, - "Stack pointer of timer stack"), REG_RO }, + "Stack pointer of timer stack"), REG_RO }, { DRDATAD (VPOS, versionPos, 8, "Status register for sending version information"), REG_RO }, @@ -1207,7 +1205,7 @@ enum simhPseudoDeviceCommands { /* do not change order or remove commands, add o setTimerInterruptAdrCmd, /* 24 set the address to call by timer interrupts */ resetStopWatchCmd, /* 25 reset the millisecond stop watch */ readStopWatchCmd, /* 26 read the millisecond stop watch */ - SIMHSleepCmd, /* 27 let SIMH sleep for SIMHSleep microseconds */ + SIMHSleepCmd, /* 27 let SIMH sleep for SIMHSleep milliseconds */ getHostOSPathSeparatorCmd, /* 28 obtain the file path separator of the OS under which SIMH runs */ getHostFilenamesCmd, /* 29 perform wildcard expansion and obtain list of file names */ readURLCmd, /* 30 read the contents of an URL */ @@ -1603,13 +1601,8 @@ void do_SIMH_sleep(void) { Otherwise there is the possibility that such interrupts are skipped. */ if ((simh_unit.flags & UNIT_SIMH_TIMERON) && rtc_avail && (sim_os_msec() + 1 >= timeOfNextInterrupt)) return; -#if defined (_WIN32) - if ((SIMHSleep / 1000) && !sio_unit.u4) /* time to sleep and SIO not attached to a file */ - Sleep(SIMHSleep / 1000); -#else - if (SIMHSleep && !sio_unit.u4) /* time to sleep and SIO not attached to a file */ - usleep(SIMHSleep); -#endif + if (SIMHSleep && !sio_unit.u4) /* time to sleep and SIO not attached to a file */ + sim_os_ms_sleep(SIMHSleep); } static int32 simh_out(const int32 port, const int32 data) { diff --git a/AltairZ80/i8272.c b/AltairZ80/i8272.c index d5c9862f..f9c12f2a 100644 --- a/AltairZ80/i8272.c +++ b/AltairZ80/i8272.c @@ -48,11 +48,6 @@ /*#define DBG_MSG */ #include "altairz80_defs.h" - -#if defined (_WIN32) -#include -#endif - #include "sim_imd.h" #include "i8272.h" diff --git a/AltairZ80/mfdc.c b/AltairZ80/mfdc.c index a1a36fc2..49eb2818 100644 --- a/AltairZ80/mfdc.c +++ b/AltairZ80/mfdc.c @@ -48,10 +48,6 @@ #include "altairz80_defs.h" #include "sim_imd.h" -#if defined (_WIN32) -#include -#endif - #ifdef DBG_MSG #define DBG_PRINT(args) sim_printf args #else diff --git a/AltairZ80/n8vem.c b/AltairZ80/n8vem.c index eee85707..a5eec0c5 100644 --- a/AltairZ80/n8vem.c +++ b/AltairZ80/n8vem.c @@ -44,10 +44,6 @@ #include "altairz80_defs.h" -#if defined (_WIN32) -#include -#endif - #ifdef DBG_MSG #define DBG_PRINT(args) sim_printf args #else diff --git a/AltairZ80/s100_64fdc.c b/AltairZ80/s100_64fdc.c index f0151a2e..d0a3d420 100644 --- a/AltairZ80/s100_64fdc.c +++ b/AltairZ80/s100_64fdc.c @@ -44,11 +44,6 @@ /*#define DBG_MSG */ #include "altairz80_defs.h" - -#if defined (_WIN32) -#include -#endif - #include "sim_defs.h" /* simulator definitions */ #include "wd179x.h" diff --git a/AltairZ80/s100_adcs6.c b/AltairZ80/s100_adcs6.c index 11eefc71..2c667bb0 100644 --- a/AltairZ80/s100_adcs6.c +++ b/AltairZ80/s100_adcs6.c @@ -45,11 +45,6 @@ /*#define DBG_MSG */ #include "altairz80_defs.h" - -#if defined (_WIN32) -#include -#endif - #include "sim_defs.h" /* simulator definitions */ #include "wd179x.h" diff --git a/AltairZ80/s100_disk1a.c b/AltairZ80/s100_disk1a.c index d2b29126..6f41a176 100644 --- a/AltairZ80/s100_disk1a.c +++ b/AltairZ80/s100_disk1a.c @@ -44,11 +44,6 @@ /*#define DBG_MSG */ #include "altairz80_defs.h" - -#if defined (_WIN32) -#include -#endif - #include "sim_defs.h" /* simulator definitions */ #include "i8272.h" diff --git a/AltairZ80/s100_disk2.c b/AltairZ80/s100_disk2.c index 6c23f105..302f3649 100644 --- a/AltairZ80/s100_disk2.c +++ b/AltairZ80/s100_disk2.c @@ -42,11 +42,6 @@ *************************************************************************/ #include "altairz80_defs.h" - -#if defined (_WIN32) -#include -#endif - #include "sim_imd.h" /* Debug flags */ diff --git a/AltairZ80/s100_disk3.c b/AltairZ80/s100_disk3.c index cf6171c3..2972da38 100644 --- a/AltairZ80/s100_disk3.c +++ b/AltairZ80/s100_disk3.c @@ -40,11 +40,6 @@ *************************************************************************/ #include "altairz80_defs.h" - -#if defined (_WIN32) -#include -#endif - #include "sim_imd.h" /* Debug flags */ diff --git a/AltairZ80/s100_fif.c b/AltairZ80/s100_fif.c index b9c87614..8bb32e6d 100644 --- a/AltairZ80/s100_fif.c +++ b/AltairZ80/s100_fif.c @@ -365,134 +365,3 @@ static int32 fif_io(const int32 port, const int32 io, const int32 data) { } return 0; } - -#define ERNIES_FTP 0 -#if ERNIES_FTP - -#define WRK_BUF_SZ 150 -#define FCB_SIZE 32 -#define NAME_LTH 8 -#define EXT_LTH 3 - - -/************************************************** -*/ -static void xfero(int32 addr, char *src, int32 lth) -{ - while (lth--) { - PutBYTEWrapper(addr++, *src++); - } -} - -/************************************************** -*/ -static void xferi(int32 addr, char *dst, int32 lth) -{ - while (lth--) { - *dst++ = GetBYTEWrapper(addr++); - } -} - -#if !defined (_WIN32) -static void strupr(char *fn) { - while (*fn) { - if (('a' <= *fn) && (*fn <= 'z')) - *fn -= 'a' - 'A'; - fn++; - } -} -#endif - -/************************************************** -*/ -static void initfcb(char *fcb, char *fn, int32 flg) -{ - char *p1 = fcb; - - if (flg) - { - strupr(fn); - } - memset (fcb, 0 , FCB_SIZE); - memset (fcb + 1, ' ', NAME_LTH + EXT_LTH); - p1++; - while (*fn && (*fn != '.')) - { - *p1++ = *fn++; - } - if (*fn == '.') - { - fn++; - } - p1 = fcb + NAME_LTH + 1; - while (*fn && (*fn != '.')) - { - *p1++ = *fn++; - } -} - -/************************************************** - - FTP interface - most of the work is done here - The IMDOS/CPM application only does minimal work - -*/ - -char message[WRK_BUF_SZ]; -char temp [WRK_BUF_SZ]; -FILE * myfile; - -uint8 FTP(int32 BC, int32 DE) -{ - char *p1, *p2; - int32 retval; - - xferi(DE, temp, SEC_SZ); - p1 = temp; - switch (BC & 0x7f) - { - case 0: - memcpy(message, p1 + 2, *(p1 + 1)); - *(message + *(p1 + 1)) = 0; - p2 = strtok(message, " \t"); - if (!strcmp(p2, "get")) - { - p2 = strtok(NULL, " \t"); - if (myfile = fopen(p2, "rb")) - { - initfcb(temp, p2, 1); - xfero(DE + 2, temp, 32); - retval = 0; - break; - } - } - if (!strcmp(p2, "era")) - { - p2 = strtok(NULL, " \t"); - initfcb(temp, p2, 0); - xfero(DE + 2, temp, 32); - retval = 1; - break; - } - retval = 0xff; - break; - - case 20: - memset(temp, 0x1a, SEC_SZ); - retval = sim_fread(temp, 1, SEC_SZ, myfile) ? 0 : 1; - xfero( DE, temp, SEC_SZ); - if (retval) - { - fclose(myfile); - } - break; - } - return retval; -} - -#endif /* ERNIES_FTP */ - -/* end of the source */ - - - diff --git a/AltairZ80/s100_hdc1001.c b/AltairZ80/s100_hdc1001.c index 37bc5a62..2e4e798b 100644 --- a/AltairZ80/s100_hdc1001.c +++ b/AltairZ80/s100_hdc1001.c @@ -43,11 +43,6 @@ *************************************************************************/ #include "altairz80_defs.h" - -#if defined (_WIN32) -#include -#endif - #include "sim_imd.h" /* Debug flags */ diff --git a/AltairZ80/s100_if3.c b/AltairZ80/s100_if3.c index 18dd1be1..090690e1 100644 --- a/AltairZ80/s100_if3.c +++ b/AltairZ80/s100_if3.c @@ -43,11 +43,6 @@ /*#define DBG_MSG */ #include "altairz80_defs.h" - -#if defined (_WIN32) -#include -#endif - #include #ifdef DBG_MSG diff --git a/AltairZ80/s100_mdriveh.c b/AltairZ80/s100_mdriveh.c index 8f15896f..fc5cb20b 100644 --- a/AltairZ80/s100_mdriveh.c +++ b/AltairZ80/s100_mdriveh.c @@ -43,10 +43,6 @@ #include "altairz80_defs.h" -#if defined (_WIN32) -#include -#endif - #ifdef DBG_MSG #define DBG_PRINT(args) sim_printf args #else diff --git a/AltairZ80/s100_mdsa.c b/AltairZ80/s100_mdsa.c index 39a54a04..49e687b9 100644 --- a/AltairZ80/s100_mdsa.c +++ b/AltairZ80/s100_mdsa.c @@ -16,10 +16,6 @@ #include "altairz80_defs.h" #include "sim_imd.h" -#if defined (_WIN32) -#include -#endif - #ifdef DBG_MSG #define DBG_PRINT(args) printf args #else diff --git a/AltairZ80/s100_mdsad.c b/AltairZ80/s100_mdsad.c index 580f9342..0d752e2c 100644 --- a/AltairZ80/s100_mdsad.c +++ b/AltairZ80/s100_mdsad.c @@ -44,10 +44,6 @@ #include "altairz80_defs.h" #include "sim_imd.h" -#if defined (_WIN32) -#include -#endif - #ifdef DBG_MSG #define DBG_PRINT(args) sim_printf args #else diff --git a/AltairZ80/s100_scp300f.c b/AltairZ80/s100_scp300f.c index d22849e4..5ccefbb7 100644 --- a/AltairZ80/s100_scp300f.c +++ b/AltairZ80/s100_scp300f.c @@ -43,10 +43,6 @@ #include "altairz80_defs.h" -#if defined (_WIN32) -#include -#endif - #ifdef DBG_MSG #define DBG_PRINT(args) sim_printf args #else diff --git a/AltairZ80/s100_selchan.c b/AltairZ80/s100_selchan.c index 695b95c4..6b56c654 100644 --- a/AltairZ80/s100_selchan.c +++ b/AltairZ80/s100_selchan.c @@ -43,10 +43,6 @@ #include "altairz80_defs.h" -#if defined (_WIN32) -#include -#endif - #ifdef DBG_MSG #define DBG_PRINT(args) sim_printf args #else diff --git a/AltairZ80/s100_ss1.c b/AltairZ80/s100_ss1.c index 74f13b6f..eee0461f 100644 --- a/AltairZ80/s100_ss1.c +++ b/AltairZ80/s100_ss1.c @@ -43,11 +43,6 @@ /*#define DBG_MSG */ #include "altairz80_defs.h" - -#if defined (_WIN32) -#include -#endif - #include #ifdef DBG_MSG diff --git a/AltairZ80/vfdhd.c b/AltairZ80/vfdhd.c index 08d42c63..22a816e2 100644 --- a/AltairZ80/vfdhd.c +++ b/AltairZ80/vfdhd.c @@ -43,11 +43,6 @@ #define USE_VGI /* Use 275-byte VGI-format sectors (includes all metadata) */ #include "altairz80_defs.h" - -#if defined (_WIN32) -#include -#endif - #include "sim_imd.h" /* #define DBG_MSG */ diff --git a/AltairZ80/wd179x.c b/AltairZ80/wd179x.c index 8f1d0566..014680f0 100644 --- a/AltairZ80/wd179x.c +++ b/AltairZ80/wd179x.c @@ -42,11 +42,6 @@ /*#define DBG_MSG */ #include "altairz80_defs.h" - -#if defined (_WIN32) -#include -#endif - #include "sim_imd.h" #include "wd179x.h"