fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
at master 78 lines 2.6 kB view raw
1/***************************************************************************** 2 * pce * 3 *****************************************************************************/ 4 5/***************************************************************************** 6 * File name: src/arch/simarm/sercons.c * 7 * Created: 2004-11-04 by Hampa Hug <hampa@hampa.ch> * 8 * Copyright: (C) 2004-2013 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#include "sercons.h" 31#include "simarm.h" 32 33#include <stdio.h> 34#include <stdlib.h> 35#include <string.h> 36 37#include <unistd.h> 38#include <fcntl.h> 39#include <sys/types.h> 40 41#include <lib/sysdep.h> 42 43 44void scon_check (simarm_t *sim) 45{ 46 unsigned i, n; 47 unsigned char buf[8]; 48 ssize_t r; 49 50 if (par_sig_int) { 51 par_sig_int = 0; 52 sarm_set_keycode (sim, 0x03); 53 } 54 55 if (!pce_fd_readable (0, 0)) { 56 return; 57 } 58 59 r = read (0, buf, 8); 60 if (r <= 0) { 61 return; 62 } 63 64 n = (unsigned) r; 65 66 if ((n == 1) && (buf[0] == 0)) { 67 sarm_set_msg (sim, "emu.stop", ""); 68 return; 69 } 70 else if ((n == 1) && (buf[0] == 0xe0)) { 71 sarm_set_msg (sim, "emu.abort", ""); 72 return; 73 } 74 75 for (i = 0; i < n; i++) { 76 sarm_set_keycode (sim, buf[i]); 77 } 78}