TIP: Click on subject to list as thread! ANSI
echo: public_domain
to: All
from: andrew clarke
date: 1996-03-06 23:19:36
subject: VidMgr 2 of 4

* Crossposted in area ED_CODE, AUST_C_HERE, C_ECHO, PUBLIC_DOMAIN

>>>>>>>>>> CSplit: Version 2.1
>>>>>>>>>>
>>>>>>>>>> CSplit: Begin part 2/4
>>>>>>>>>>
    return (char) *((char FAR *) MK_FP(0x0040, 0x0049));
}

char vm_getscreenwidth(void)
{
    return (char) *((char FAR *) MK_FP(0x0040, 0x004a));
}

char vm_getscreenheight(void)
{
    return (char) (*((char FAR *) MK_FP(0x0040, 0x0084)) + 1);
}

short vm_getscreensize(void)
{
    return (short) *((short FAR *) MK_FP(0x0040, 0x004c));
}

char vm_wherex(void)
{
    return (char) (*((char FAR *) MK_FP(0x0040, 0x0050)) + 1);
}

char vm_wherey(void)
{
    return (char) (*((char FAR *) MK_FP(0x0040, 0x0051)) + 1);
}

char FAR *vm_screenptr(char x, char y)
{
    register char FAR *seg;
    if (vm_iscolorscreen())
        seg = (char FAR *) MK_FP(0xb800, 0x0000);
    else
        seg = (char FAR *) MK_FP(0xb000, 0x0000);
    return seg + (y * vm_getscreenwidth() * 2) + (x * 2);
}

#if !defined(__WATCOMC__)

void vm_setscreenmode(char mode)
{
    _asm {
        mov    ah,0x00
        mov    al,[mode]
        int    0x10
    }
}

void vm_gotoxy(char x, char y)
{
    _asm {
        dec    [x]
        dec    [y]
        mov    ah,0x02
        mov    bh,0
        mov    dh,[y]
        mov    dl,[x]
        int    0x10
    }
}

void vm_setcursorsize(char start, char end)
{
    _asm {
        mov    ah,0x01
        mov    ch,[start]
        mov    cl,[end]
        int    0x10
    }
}

void vm_getcursorsize(char *start, char *end)
{
    char _start, _end;
    _asm {
        mov    ah,0x03
        mov    bh,0
        int    0x10
        mov    [_start],ch
        mov    [_end],cl
    }
    *start = _start;
    *end = _end;
}

int vm_kbhit(void)
{
    short flags;
    _asm {
        mov    ah,0x01
        int    0x16
        pushf
        pop    [flags]
    }
    return !(flags & 0x40);
}

int vm_getch(void)
{
    unsigned char chChar, chScan;

    while (!vm_kbhit()) {
        /* do nothing for now */
    }

    _asm {
        mov    ah,0x00
        int    0x16
        mov    [chScan],ah
        mov    [chChar],al
    }

    if (chChar == 0xe0) {
        if (chScan) {
            chChar = 0;         /* force scan return */
        } else {                /* get next block */
            chChar = 0;

            _asm {
                mov    ah,0x00
                int    0x16
                mov    [chScan],ah
                mov    [chChar],al
            }

            if (!chScan) {      /* still no scan? */
                chScan = chChar;  /* move new char over */
                chChar = 0;     /* force its return */
            } else {
                chChar = 0;     /* force new scan */
            }
        }
    }
    if (chScan == 0xe0) {
        if (!chChar) {
            chScan = 0;

            _asm {
                mov    ah,0x00
                int    0x16
                mov    [chScan],ah
                mov    [chChar],al
            }

            if (!chScan) {      /* still no scan? */
                chScan = chChar;  /* move new char over */
                chChar = 0;     /* force its return */
            } else {
                chChar = 0;     /* force new scan */
            }
        } else {
            chScan = 0;         /* handle 0xe00d case */
        }
    }
    if (chChar)
        chScan = 0;

    return (int) ((chScan << 8) + (chChar));
}

#else

void vm_setscreenmode(char mode)
{
    union REGS regs;
    regs.h.ah = 0x00;
    regs.h.al = mode;
#if defined(__386__)
    int386(0x10, ®s, ®s);
#else
    int86(0x10, ®s, ®s);
#endif
}

void vm_gotoxy(char x, char y)
{
    union REGS regs;
    regs.h.ah = 0x02;
    regs.h.bh = 0;
    regs.h.dh = y - 1;
    regs.h.dl = x - 1;
#if defined(__386__)
    int386(0x10, ®s, ®s);
#else
    int86(0x10, ®s, ®s);
#endif
}

void vm_setcursorsize(char start, char end)
{
    union REGS regs;
    regs.h.ah = 0x01;
    regs.h.ch = start;
    regs.h.cl = end;
#if defined(__386__)
    int386(0x10, ®s, ®s);
#else
    int86(0x10, ®s, ®s);
#endif
}

void vm_getcursorsize(char *start, char *end)
{
    union REGS regs;
    regs.h.ah = 0x03;
    regs.h.bh = 0;
#if defined(__386__)
    int386(0x10, ®s, ®s);
#else
    int86(0x10, ®s, ®s);
#endif
    *start = regs.h.ch;
    *end = regs.h.cl;
}

int vm_kbhit(void)
{
    union REGS regs;
    regs.h.ah = 0x01;
#if defined(__386__)
    int386(0x16, ®s, ®s);
#else
    int86(0x16, ®s, ®s);
#endif
    return !(regs.w.cflag & 0x40);
}

int vm_getch(void)
{
    union REGS regs;
    unsigned char chChar, chScan;

    while (!vm_kbhit()) {
        /* do nothing for now */
    }

    regs.h.ah = 0x00;
#if defined(__386__)
    int386(0x16, ®s, ®s);
#else
    int86(0x16, ®s, ®s);
#endif
    chScan = regs.h.ah;
    chChar = regs.h.al;

    if (chChar == 0xe0) {
        if (chScan) {
            chChar = 0;         /* force scan return */
        } else {                /* get next block */
            chChar = 0;

            regs.h.ah = 0x00;
#if defined(__386__)
            int386(0x16, ®s, ®s);
#else
            int86(0x16, ®s, ®s);
#endif
            chScan = regs.h.ah;
            chChar = regs.h.al;

            if (!chScan) {      /* still no scan? */
                chScan = chChar;  /* move new char over */
                chChar = 0;     /* force its return */
            } else {
                chChar = 0;     /* force new scan */
            }
        }
    }
    if (chScan == 0xe0) {
        if (!chChar) {
            chScan = 0;

            regs.h.ah = 0x00;
#if defined(__386__)
            int386(0x16, ®s, ®s);
#else
            int86(0x16, ®s, ®s);
#endif
            chScan = regs.h.ah;
            chChar = regs.h.al;

            if (!chScan) {      /* still no scan? */
                chScan = chChar;  /* move new char over */
                chChar = 0;     /* force its return */
            } else {
                chChar = 0;     /* force new scan */
            }
        } else {
            chScan = 0;         /* handle 0xe00d case */
        }
    }
    if (chChar)
        chScan = 0;

    return (int) ((chScan << 8) + (chChar));
}

#endif

char vm_getchxy(char x, char y)
{
    register char FAR *p;
    p = vm_screenptr((char) (x - 1), (char) (y - 1));
    return *p;
}

char vm_getattrxy(char x, char y)
{
    register char FAR *p;
    p = vm_screenptr((char) (x - 1), (char) (y - 1));
    return *(p + 1);
}

void vm_xgetchxy(char x, char y, char *attr, char *ch)
{
    register char FAR *p;
    p = vm_screenptr((char) (x - 1), (char) (y - 1));
    *ch = *p;
    *attr = *(p + 1);
}

void vm_setcursorstyle(int style)
{
    switch (style) {
    case CURSOR_HALF:
        if (vm_iscolorscreen())
            vm_setcursorsize(4, 7);
        else
            vm_setcursorsize(8, 13);
        break;
    case CURSOR_FULL:
        if (vm_iscolorscreen())
            vm_setcursorsize(0, 7);
        else
            vm_setcursorsize(0, 13);
        break;
    case CURSOR_NORM:
        if (vm_iscolorscreen())
            vm_setcursorsize(7, 8);
        else
            vm_setcursorsize(11, 13);
        break;
    case CURSOR_HIDE:
        vm_setcursorsize(32, 32);
        break;
    default:
        break;
    }
}

void vm_putch(char x, char y, char ch)
{
>>>>>>>>>> CSplit: End part 2/4 crc: 8c2f
>>>>>>>>>>

--- Msgedsq/2 3.30
* Origin: This one HAS to be original X (3:635/727.4{at}fidonet)
SEEN-BY: 50/99 78/0 635/309 503 544 727 640/230 690/718 711/401 410 413 430
SEEN-BY: 711/808 809 934 712/610 713/888 800/1 7877/2809
@PATH: 635/727 544 50/99 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.