Skip to content

Commit

Permalink
SCP: Remove legacy support for OS2 and MetroWerks on Macintosh OS 9
Browse files Browse the repository at this point in the history
  • Loading branch information
markpizz committed Apr 5, 2023
1 parent f981568 commit 287f292
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 419 deletions.
4 changes: 0 additions & 4 deletions scp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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<argc; i++)
Expand Down
284 changes: 1 addition & 283 deletions sim_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ int32 sim_dbg_int_char = 0; /* SIGINT char under deb
static t_bool sigint_message_issued = FALSE;
int32 sim_brk_char = 000; /* break character */
int32 sim_tt_pchar = 0x00002780;
#if defined (_WIN32) || defined (__OS2__) || (defined (__MWERKS__) && defined (macintosh))
#if defined (_WIN32)
int32 sim_del_char = '\b'; /* delete character */
#else
int32 sim_del_char = 0177;
Expand Down Expand Up @@ -3690,288 +3690,6 @@ if (program[0] != '\0') {
return sim_messagef (SCPE_NOFNC, "Can't find a telnet program to connect to the console in a window\n");
}

/* OS/2 routines, from Bruce Ray and Holger Veit */

#elif defined (__OS2__)

#include <conio.h>

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 <console.h>
#include <Mactypes.h>
#include <string.h>
#include <sioux.h>
#include <unistd.h>
#include <siouxglobals.h>
#include <Traps.h>
#include <LowMem.h>

/* 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)
Expand Down
45 changes: 0 additions & 45 deletions sim_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -1416,8 +1373,6 @@ shutdown(sock, SD_BOTH);
closesocket (sock);
}

#endif /* end else !implemented */

#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion sim_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sys/types.h> /* for fcntl, getpid */
#include <sys/socket.h> /* for sockets */
#include <string.h>
Expand Down
Loading

0 comments on commit 287f292

Please sign in to comment.