[comp.lang.c] Direct output

gandalf@valnet.UUCP (Andrew Davenport) (03/14/91)

    I am writing a program on an IBM AT compatible computer, and I want to
use direct input/output.  I wrote the following function, but it doesn't
work.  Can anyone give me a pointer as to why not?

--------------------------------- Cut Here ----------------------------------

int far *screen = (int far *)0xB8000000;

void dir_scr_write(int x, int y, char *str, char fore, char back)
{
    int c=0, temp=0, string[80];
    unsigned int attr=0;
    int far *tmp = screen;

    temp = strlen(str);
    attr = (((((int)back & 0x0f) << 4) | ((int)fore & 0x0f)) & 0x00ff);
    for(c = 0; c <= temp; c++)
    {
        string[c] = (int)str[c];
        string[c] <<= 8;
        string[c] &= attr;
    }
    tmp += (y * 80) + x;
    memcpy(tmp, string, (temp * 2));
}

--------------------------------- Cut Here ----------------------------------

Also, I want to read/write the cursor position directly...how might that be
done?

Please help!!!

Thanks in advance, and please e-mail responses to gandalf@valnet.UUCP, I'll be
happy to post a summary of replys if there's any interest...

Gandalf (a.k.a. Andrew Davenport)

jfw@ksr.com (John F. Woods) (03/14/91)

gandalf@valnet.UUCP (Andrew Davenport) writes:
>    I am writing a program on an IBM AT compatible computer, and I want to
>use direct input/output.  I wrote the following function, but it doesn't
>work.  Can anyone give me a pointer as to why not?

There is a newsgroup, comp.sys.ibm.pc.programmer, which contains a large
quantity of people who will be able to answer your question.  Your question
isn't a general question about C, it is a very specific question about a
very specific task on a very specific computer, and there really isn't any
reason to expect general C programmers to know the problem.

>        string[c] &= attr;

Though frankly that line looks awfully suspicious.

jdb@reef.cis.ufl.edu (Brian K. W. Hook) (03/14/91)

In article <2678@ksr.com> jfw@ksr.com (John F. Woods) writes:
|>gandalf@valnet.UUCP (Andrew Davenport) writes:
|>>    I am writing a program on an IBM AT compatible computer, and I want to
|>>use direct input/output.  I wrote the following function, but it doesn't
|>>work.  Can anyone give me a pointer as to why not?
|>
|>There is a newsgroup, comp.sys.ibm.pc.programmer, which contains a large
|>quantity of people who will be able to answer your question.  Your question

Actually, a lot more people read comp.os.msdos.programmer than csipp since
it is theoretically default.

Brian