Annotation of uae/src/serial.c, revision 1.1

1.1     ! root        1:  /* 
        !             2:   * UAE - The Un*x Amiga Emulator
        !             3:   * 
        !             4:   *  Serial Line Emulation
        !             5:   *
        !             6:   * (c) 1996 Stefan Reinauer
        !             7:   */
        !             8: 
        !             9: #include "sysconfig.h"
        !            10: #include "sysdeps.h"
        !            11: 
        !            12: #include "config.h"
        !            13: #include "options.h"
        !            14: #include "memory.h"
        !            15: #include "custom.h"
        !            16: #include "newcpu.h"
        !            17: 
        !            18: void serial_init(void);
        !            19: void serial_exit(void);
        !            20: 
        !            21: UWORD SERDATR(void);
        !            22: void  SERPER(UWORD w);
        !            23: void  SERDAT(UWORD w);
        !            24: 
        !            25: int sersend;
        !            26: int serrecv;
        !            27: int sd = -1;
        !            28: 
        !            29: UWORD serdat;
        !            30: 
        !            31: void SERPER(UWORD w)
        !            32: {
        !            33:     if (!use_serial)
        !            34:        return;
        !            35: 
        !            36: #ifndef __DOS__
        !            37:     if (w&0x8000) fprintf (stdout, "SERPER: 9 Bit Transmission not implemented\n");
        !            38:     fprintf (stdout, "serial port baudrate set to ");
        !            39:     switch (w & 0x7fff)
        !            40:     {
        !            41:      case 0x2e9b: fprintf (stdout, "  300\n"); return;
        !            42:      case 0x0ba6: fprintf (stdout, " 1200\n"); return;
        !            43:      case 0x02e9: fprintf (stdout, " 4800\n"); return;
        !            44:      case 0x0174: fprintf (stdout, " 9600\n"); return;
        !            45:      case 0x00b9: fprintf (stdout, "19200\n"); return;
        !            46:      case 0x005c: fprintf (stdout, "38400\n"); return;
        !            47:      default:
        !            48:        fprintf(stdout,"%d (approx.)\n",
        !            49:                (unsigned int)(3579546.471/(double)((w&0x7fff)+1)));  return;
        !            50:     }
        !            51: #else
        !            52:     if (w&0x8000) fprintf (stderr, "SERPER: 9 Bit Transmission not implemented\n");
        !            53:     fprintf (stderr, "serial port baudrate set to ");
        !            54:     switch (w & 0x7fff)
        !            55:     {
        !            56:      case 0x2e9b: fprintf (stderr, "  300\n"); return;
        !            57:      case 0x0ba6: fprintf (stderr, " 1200\n"); return;
        !            58:      case 0x02e9: fprintf (stderr, " 4800\n"); return;
        !            59:      case 0x0174: fprintf (stderr, " 9600\n"); return;
        !            60:      case 0x00b9: fprintf (stderr, "19200\n"); return;
        !            61:      case 0x005c: fprintf (stderr, "38400\n"); return;
        !            62:      default:
        !            63:        fprintf(stderr,"%d (approx.)\n",
        !            64:                (unsigned int)(3579546.471/(double)((w&0x7fff)+1)));  return;
        !            65:     }
        !            66: #endif
        !            67: }
        !            68: 
        !            69: void SERDAT(UWORD w)
        !            70: {
        !            71:     char z;
        !            72: 
        !            73:     if (!use_serial)
        !            74:        return;
        !            75: 
        !            76:     fprintf(stderr,"SERDAT: wrote 0x%04x\n",w);
        !            77:     z=(char)(w&0xff);
        !            78:     if (sd>0) {
        !            79:        write (sd,&z,1);
        !            80:     }   
        !            81:     return;
        !            82: }
        !            83: 
        !            84: UWORD SERDATR(void)
        !            85: {
        !            86:     char z;
        !            87: 
        !            88:     if (!use_serial)
        !            89:        return;
        !            90: 
        !            91:     if ((read (sd, &z,1))==1) {
        !            92:        serdat=0x6100;
        !            93:        intreq|=0x0800;
        !            94:        serdat+=(int)z;
        !            95: #ifndef __DOS__
        !            96:        fprintf (stdout,"SERDATR: received 0x%02x\n",(int)z);
        !            97: #else
        !            98:        fprintf (stderr,"SERDATR: received 0x%02x\n",(int)z);
        !            99: #endif
        !           100:     }
        !           101:     return serdat;
        !           102: }
        !           103: 
        !           104: void serial_init(void)
        !           105: {
        !           106:     if (!use_serial)
        !           107:        return;
        !           108: 
        !           109: #ifndef __DOS__
        !           110:     if ((sd=open(sername,O_RDWR|O_NONBLOCK))<0)
        !           111:        fprintf (stderr,"Error: Could not open Device %s\n",sername);
        !           112: #else
        !           113:     if ((sd=open(sername,O_RDWR|O_NONBLOCK|O_BINARY))<0)
        !           114:        fprintf (stderr,"Error: Could not open Device %s\n",sername);
        !           115: #endif
        !           116:     serdat=0x2000;
        !           117:     return;
        !           118: }
        !           119: 
        !           120: void serial_exit(void)
        !           121: {
        !           122:     if (sd >= 0)
        !           123:        close(sd);
        !           124:     return;
        !           125: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.