AltairZ80: Replace WIN32 dependencies with SIMH API calls and remove redundant includes
This commit is contained in:
parent
32e266dbac
commit
17356d9093
22 changed files with 16 additions and 248 deletions
|
@ -29,18 +29,13 @@
|
|||
|
||||
#include "m68k.h"
|
||||
#include <ctype.h>
|
||||
|
||||
#define SWITCHCPU_DEFAULT 0xfd
|
||||
|
||||
/* Debug flags */
|
||||
#define IN_MSG (1 << 0)
|
||||
#define OUT_MSG (1 << 1)
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -48,11 +48,6 @@
|
|||
/*#define DBG_MSG */
|
||||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "sim_imd.h"
|
||||
#include "i8272.h"
|
||||
|
||||
|
|
|
@ -48,10 +48,6 @@
|
|||
#include "altairz80_defs.h"
|
||||
#include "sim_imd.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef DBG_MSG
|
||||
#define DBG_PRINT(args) sim_printf args
|
||||
#else
|
||||
|
|
|
@ -44,10 +44,6 @@
|
|||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef DBG_MSG
|
||||
#define DBG_PRINT(args) sim_printf args
|
||||
#else
|
||||
|
|
|
@ -44,11 +44,6 @@
|
|||
/*#define DBG_MSG */
|
||||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "sim_defs.h" /* simulator definitions */
|
||||
#include "wd179x.h"
|
||||
|
||||
|
|
|
@ -45,11 +45,6 @@
|
|||
|
||||
/*#define DBG_MSG */
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "sim_defs.h" /* simulator definitions */
|
||||
#include "wd179x.h"
|
||||
|
||||
|
|
|
@ -44,11 +44,6 @@
|
|||
/*#define DBG_MSG */
|
||||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "sim_defs.h" /* simulator definitions */
|
||||
#include "i8272.h"
|
||||
|
||||
|
|
|
@ -42,11 +42,6 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "sim_imd.h"
|
||||
|
||||
/* Debug flags */
|
||||
|
|
|
@ -40,11 +40,6 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "sim_imd.h"
|
||||
|
||||
/* Debug flags */
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -43,11 +43,6 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "sim_imd.h"
|
||||
|
||||
/* Debug flags */
|
||||
|
|
|
@ -43,11 +43,6 @@
|
|||
/*#define DBG_MSG */
|
||||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#ifdef DBG_MSG
|
||||
|
|
|
@ -43,10 +43,6 @@
|
|||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef DBG_MSG
|
||||
#define DBG_PRINT(args) sim_printf args
|
||||
#else
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
#include "altairz80_defs.h"
|
||||
#include "sim_imd.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef DBG_MSG
|
||||
#define DBG_PRINT(args) printf args
|
||||
#else
|
||||
|
|
|
@ -44,10 +44,6 @@
|
|||
#include "altairz80_defs.h"
|
||||
#include "sim_imd.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef DBG_MSG
|
||||
#define DBG_PRINT(args) sim_printf args
|
||||
#else
|
||||
|
|
|
@ -43,10 +43,6 @@
|
|||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef DBG_MSG
|
||||
#define DBG_PRINT(args) sim_printf args
|
||||
#else
|
||||
|
|
|
@ -43,10 +43,6 @@
|
|||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef DBG_MSG
|
||||
#define DBG_PRINT(args) sim_printf args
|
||||
#else
|
||||
|
|
|
@ -43,11 +43,6 @@
|
|||
/*#define DBG_MSG */
|
||||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#ifdef DBG_MSG
|
||||
|
|
|
@ -43,11 +43,6 @@
|
|||
#define USE_VGI /* Use 275-byte VGI-format sectors (includes all metadata) */
|
||||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "sim_imd.h"
|
||||
|
||||
/* #define DBG_MSG */
|
||||
|
|
|
@ -42,11 +42,6 @@
|
|||
/*#define DBG_MSG */
|
||||
|
||||
#include "altairz80_defs.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "sim_imd.h"
|
||||
#include "wd179x.h"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue