summaryrefslogtreecommitdiff
path: root/baud.c
blob: f80ce13e8fd8b915d12380f3dbbfa318798142a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "fossil.h"
#include <dos.h>
#include <stdlib.h>

int F_Set_Baud(long baud)
{
        union REGS      regs;
        int  value;

        switch (baud) {
        case 300:
                value = 0x43;  /* sets also 8 bit words, No parity, 1 stopbit */
                break;
        case 600:
                value = 0x63;
                break;
        case 1200:
                value = 0x83;
                break;
        case 2400:
                value = 0xA3;
                break;
        case 4800:
                value = 0xC3;
                break;
        case 9600:
                value = 0xE3;
                break;
        case 19200:
                value = 3;
                break;
        case 38400:
                value = 0x23;
                break;
        default:
                return (FALSE);
        }

        regs.h.ah = 0x00;
        regs.h.al = (unsigned char) value;
        regs.x.dx = (unsigned char) port;
        int86(FOSSIL_INT, &regs, &regs);
        return (regs.x.ax);
}