fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
1/*****************************************************************************
2 * pce *
3 *****************************************************************************/
4
5/*****************************************************************************
6 * File name: src/arch/sim405/sercons.c *
7 * Created: 2004-06-01 by Hampa Hug <hampa@hampa.ch> *
8 * Copyright: (C) 2004-2018 Hampa Hug <hampa@hampa.ch> *
9 * Copyright: (C) 2004-2006 Lukas Ruf <ruf@lpr.ch> *
10 *****************************************************************************/
11
12/*****************************************************************************
13 * This program is free software. You can redistribute it and / or modify it *
14 * under the terms of the GNU General Public License version 2 as published *
15 * by the Free Software Foundation. *
16 * *
17 * This program is distributed in the hope that it will be useful, but *
18 * WITHOUT ANY WARRANTY, without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
20 * Public License for more details. *
21 *****************************************************************************/
22
23/*****************************************************************************
24 * This software was developed at the Computer Engineering and Networks *
25 * Laboratory (TIK), Swiss Federal Institute of Technology (ETH) Zurich. *
26 *****************************************************************************/
27
28
29#include "main.h"
30
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34
35#include <unistd.h>
36#include <fcntl.h>
37#include <sys/types.h>
38
39#include "msg.h"
40#include "sim405.h"
41
42#include <lib/sysdep.h>
43
44
45void scon_check (sim405_t *sim)
46{
47 unsigned i, n;
48 unsigned char buf[8];
49 ssize_t r;
50
51 if (par_sig_int) {
52 par_sig_int = 0;
53 s405_set_keycode (sim, 0x03);
54 }
55
56 if (!pce_fd_readable (0, 0)) {
57 return;
58 }
59
60 r = read (0, buf, 8);
61 if (r <= 0) {
62 return;
63 }
64
65 n = (unsigned) r;
66
67 if ((n == 1) && (buf[0] == 0)) {
68 s405_set_msg (sim, "emu.stop", "");
69 return;
70 }
71#if 0
72 if ((n == 1) && (buf[0] == 0x1b)) {
73 s405_set_msg (sim, "emu.stop", "");
74 return;
75 }
76#endif
77 else if ((n == 1) && (buf[0] == 0xe0)) {
78 s405_set_msg (sim, "emu.abort", "");
79 return;
80 }
81
82 for (i = 0; i < n; i++) {
83 s405_set_keycode (sim, buf[i]);
84 }
85}