diff --git a/scp.c b/scp.c index 6036040cb..80a911a85 100644 --- a/scp.c +++ b/scp.c @@ -2878,10 +2878,6 @@ t_bool device_unit_tests = FALSE; t_stat stat = SCPE_OK; CTAB *docmdp = NULL; -#if defined (__MWERKS__) && defined (macintosh) -argc = ccommand (&argv); -#endif - /* Make sure that argv has at least 10 elements and that it ends in a NULL pointer */ targv = (char **)calloc (1+MAX(10, argc), sizeof(*targv)); for (i=0; i - -static t_stat sim_os_ttinit (void) -{ -return SCPE_OK; -} - -static t_stat sim_os_ttrun (void) -{ -return SCPE_OK; -} - -static t_stat sim_os_ttcmd (void) -{ -return SCPE_OK; -} - -static t_stat sim_os_ttclose (void) -{ -return SCPE_OK; -} - -static t_bool sim_os_fd_isatty (int fd) -{ -return 1; -} - -static t_stat sim_os_poll_kbd (void) -{ -int c; - -sim_debug (DBG_TRC, &sim_con_telnet, "sim_os_poll_kbd()\n"); - -#if defined (__EMX__) -switch (c = _read_kbd(0,0,0)) { /* EMX has _read_kbd */ - - case -1: /* no char*/ - return SCPE_OK; - - case 0: /* char pending */ - c = _read_kbd(0,1,0); - break; - - default: /* got char */ - break; - } -#else -if (!kbhit ()) - return SCPE_OK; -c = getch(); -#endif -if ((c & 0177) == sim_del_char) - c = 0177; -if ((c & 0177) == sim_int_char) - return SCPE_STOP; -if (sim_brk_char && ((c & 0177) == sim_brk_char)) - return SCPE_BREAK; -return c | SCPE_KFLAG; -} - -static t_bool sim_os_poll_kbd_ready (int ms_timeout) /* Don't know how to do this on this platform */ -{ -sim_os_ms_sleep (MIN(20,ms_timeout)); /* Wait a little */ -return TRUE; /* force a poll */ -} - -static t_stat sim_os_putchar (int32 c) -{ -if (c != 0177) { -#if defined (__EMX__) - putchar (c); -#else - putch (c); -#endif - fflush (stdout); - } -return SCPE_OK; -} - -/* Metrowerks CodeWarrior Macintosh routines, from Louis Chretien and - Peter Schorn */ - -#elif defined (__MWERKS__) && defined (macintosh) - -#include -#include -#include -#include -#include -#include -#include -#include - -/* function prototypes */ - -Boolean SIOUXIsAppWindow(WindowPtr window); -void SIOUXDoMenuChoice(long menuValue); -void SIOUXUpdateMenuItems(void); -void SIOUXUpdateScrollbar(void); -int ps_kbhit(void); -int ps_getch(void); - -extern pSIOUXWin SIOUXTextWindow; -static CursHandle iBeamCursorH = NULL; /* contains the iBeamCursor */ - -static void updateCursor(void) { - WindowPtr window; - window = FrontWindow(); - if (SIOUXIsAppWindow(window)) { - GrafPtr savePort; - Point localMouse; - GetPort(&savePort); - SetPort(window); -#if TARGET_API_MAC_CARBON - GetGlobalMouse(&localMouse); -#else - localMouse = LMGetMouseLocation(); -#endif - GlobalToLocal(&localMouse); - if (PtInRect(localMouse, &(*SIOUXTextWindow->edit)->viewRect) && iBeamCursorH) { - SetCursor(*iBeamCursorH); - } - else { - SetCursor(&qd.arrow); - } - TEIdle(SIOUXTextWindow->edit); - SetPort(savePort); - } - else { - SetCursor(&qd.arrow); - TEIdle(SIOUXTextWindow->edit); - } - return; -} - -int ps_kbhit(void) { - EventRecord event; - int c; - updateCursor(); - SIOUXUpdateScrollbar(); - while (GetNextEvent(updateMask | osMask | mDownMask | mUpMask | activMask | - highLevelEventMask | diskEvt, &event)) { - SIOUXHandleOneEvent(&event); - } - if (SIOUXQuitting) { - exit(1); - } - if (EventAvail(keyDownMask,&event)) { - c = event.message&charCodeMask; - if ((event.modifiers & cmdKey) && (c > 0x20)) { - GetNextEvent(keyDownMask, &event); - SIOUXHandleOneEvent(&event); - if (SIOUXQuitting) { - exit(1); - } - return false; - } - return true; - } - else { - return false; - } -} - -int ps_getch(void) { - int c; - EventRecord event; - fflush(stdout); - updateCursor(); - while(!GetNextEvent(keyDownMask,&event)) { - if (GetNextEvent(updateMask | osMask | mDownMask | mUpMask | activMask | - highLevelEventMask | diskEvt, &event)) { - SIOUXUpdateScrollbar(); - SIOUXHandleOneEvent(&event); - } - } - if (SIOUXQuitting) { - exit(1); - } - c = event.message&charCodeMask; - if ((event.modifiers & cmdKey) && (c > 0x20)) { - SIOUXUpdateMenuItems(); - SIOUXDoMenuChoice(MenuKey(c)); - } - if (SIOUXQuitting) { - exit(1); - } - return c; -} - -/* Note that this only works if the call to sim_ttinit comes before any output to the console */ - -static t_stat sim_os_ttinit (void) -{ - int i; - - sim_debug (DBG_TRC, &sim_con_telnet, "sim_os_ttinit()\n"); - - /* this blank will later be replaced by the number of characters */ - char title[50] = " "; - unsigned char ptitle[50]; - SIOUXSettings.autocloseonquit = TRUE; - SIOUXSettings.asktosaveonclose = FALSE; - SIOUXSettings.showstatusline = FALSE; - SIOUXSettings.columns = 80; - SIOUXSettings.rows = 40; - SIOUXSettings.toppixel = 42; - SIOUXSettings.leftpixel = 6; - iBeamCursorH = GetCursor(iBeamCursor); - strlcat(title, sim_name, sizeof(title)); - strlcat(title, " Simulator", sizeof(title)); - title[0] = strlen(title) - 1; /* Pascal string done */ - for (i = 0; i <= title[0]; i++) { /* copy to unsigned char */ - ptitle[i] = title[i]; - } - SIOUXSetTitle(ptitle); - return SCPE_OK; -} - -static t_stat sim_os_ttrun (void) -{ -return SCPE_OK; -} - -static t_stat sim_os_ttcmd (void) -{ -return SCPE_OK; -} - -static t_stat sim_os_ttclose (void) -{ -return SCPE_OK; -} - -static t_bool sim_os_fd_isatty (int fd) -{ -return 1; -} - -static t_stat sim_os_poll_kbd (void) -{ -int c; - -sim_debug (DBG_TRC, &sim_con_telnet, "sim_os_poll_kbd()\n"); - -if (!ps_kbhit ()) - return SCPE_OK; -c = ps_getch(); -if ((c & 0177) == sim_del_char) - c = 0177; -if ((c & 0177) == sim_int_char) - return SCPE_STOP; -if (sim_brk_char && ((c & 0177) == sim_brk_char)) - return SCPE_BREAK; -return c | SCPE_KFLAG; -} - -static t_bool sim_os_poll_kbd_ready (int ms_timeout) /* Don't know how to do this on this platform */ -{ -sim_os_ms_sleep (MIN(20,ms_timeout)); /* Wait a little */ -return TRUE; /* force a poll */ -} - -static t_stat sim_os_putchar (int32 c) -{ -if (c != 0177) { - putchar (c); - fflush (stdout); - } -return SCPE_OK; -} - -static t_stat sim_os_connect_telnet (int port) -{ -return SCPE_NOFNC; -} - - /* BSD UNIX routines */ #elif defined (BSDTTY) diff --git a/sim_sock.c b/sim_sock.c index 908c4ef6a..a8f2b0070 100644 --- a/sim_sock.c +++ b/sim_sock.c @@ -83,49 +83,6 @@ extern "C" { sim_setnonblock set socket non-blocking */ -/* First, all the non-implemented versions */ - -#if defined (__OS2__) && !defined (__EMX__) - -void sim_init_sock (void) -{ -} - -void sim_cleanup_sock (void) -{ -} - -SOCKET sim_master_sock_ex (const char *hostport, int *parse_status, int opt_flags) -{ -return INVALID_SOCKET; -} - -SOCKET sim_connect_sock_ex (const char *sourcehostport, const char *hostport, const char *default_host, const char *default_port, int opt_flags) -{ -return INVALID_SOCKET; -} - -SOCKET sim_accept_conn (SOCKET master, char **connectaddr); -{ -return INVALID_SOCKET; -} - -int sim_read_sock (SOCKET sock, char *buf, int nbytes) -{ -return -1; -} - -int sim_write_sock (SOCKET sock, char *msg, int nbytes) -{ -return 0; -} - -void sim_close_sock (SOCKET sock) -{ -return; -} - -#else /* endif unimpl */ /* UNIX, Win32, Macintosh, VMS, OS2 (Berkeley socket) routines */ @@ -1416,8 +1373,6 @@ shutdown(sock, SD_BOTH); closesocket (sock); } -#endif /* end else !implemented */ - #ifdef __cplusplus } #endif diff --git a/sim_sock.h b/sim_sock.h index af56c1b8b..f88d68634 100644 --- a/sim_sock.h +++ b/sim_sock.h @@ -71,7 +71,7 @@ extern "C" { #pragma pop_macro ("PURE") #pragma pop_macro ("INT_PTR") -#elif !defined (__OS2__) || defined (__EMX__) /* VMS, Mac, Unix, OS/2 EMX */ +#else /* VMS, Mac, Unix */ #include /* for fcntl, getpid */ #include /* for sockets */ #include diff --git a/sim_timer.c b/sim_timer.c index 1e6a00026..991bf55be 100644 --- a/sim_timer.c +++ b/sim_timer.c @@ -552,92 +552,6 @@ return 0; } #endif -#elif defined (__OS2__) - -/* OS/2 routines, from Bruce Ray */ - -const t_bool rtc_avail = FALSE; - -static uint32 _sim_os_msec (void) -{ -return 0; -} - -void sim_os_sleep (unsigned int sec) -{ -} - -uint32 sim_os_ms_sleep_init (void) -{ -return 0; -} - -uint32 sim_os_ms_sleep (unsigned int msec) -{ -return 0; -} - -/* Metrowerks CodeWarrior Macintosh routines, from Ben Supnik */ - -#elif defined (__MWERKS__) && defined (macintosh) - -#include -#include -#include -#include -#include -#define NANOS_PER_MILLI 1000000 -#define MILLIS_PER_SEC 1000 - -const t_bool rtc_avail = TRUE; - -static uint32 _sim_os_msec (void) -{ -unsigned long long micros; -UnsignedWide macMicros; -unsigned long millis; - -Microseconds (&macMicros); -micros = *((unsigned long long *) &macMicros); -millis = micros / 1000LL; -return (uint32) millis; -} - -void sim_os_sleep (unsigned int sec) -{ -sleep (sec); -} - -uint32 sim_os_ms_sleep_init (void) -{ -return _compute_minimum_sleep (); -} - -uint32 sim_os_ms_sleep (unsigned int milliseconds) -{ -uint32 stime = sim_os_msec (); -struct timespec treq; - -treq.tv_sec = milliseconds / MILLIS_PER_SEC; -treq.tv_nsec = (milliseconds % MILLIS_PER_SEC) * NANOS_PER_MILLI; -(void) nanosleep (&treq, NULL); -return sim_os_msec () - stime; -} - -#if defined(NEED_CLOCK_GETTIME) -int clock_gettime(int clk_id, struct timespec *tp) -{ -struct timeval cur; - -if (clk_id != CLOCK_REALTIME) - return -1; -gettimeofday (&cur, NULL); -tp->tv_sec = cur.tv_sec; -tp->tv_nsec = cur.tv_usec*1000; -return 0; -} -#endif - #else /* UNIX routines */