⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 support.c

📁 清华魏永名miniGUI dos下的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
        inc     dx
        out     dx, al

        mov     ax, srcy
        mov     si, srcx
        mov     dx, 80
        mul     dx
        mov     cl, 3
        shr     si, cl
        add     si, ax
        push    si
        
        mov     ax, desty
        mov     di, destx
        mov     dx, 80
        mul     dx
        mov     cl, 3
        shr     di, cl
        add     di, ax
        push    di

        mov     ax, 0a000h
        mov     ds, ax
        mov     es, ax
        
        mov     bx, srcw
        mov     cl, 3
        shr     bx, cl
        mov     dx, 80

        mov     ax, srch
move1:  mov     cx, bx
move2:  movsb
        loop    move2
        pop     di
        pop     si
        add     si, dx
        add     di, dx
        push    si
        push    di
        dec     ax
        cmp     ax, 0
        jne     move1
        
        pop     di
        pop     si
        
        mov     dx, 3ceh
        mov     ax, 0005h
        out     dx, al
        xchg    ah, al
        inc     dx
        out     dx, al

        pop     es
        pop     ds
    }
}

/* LPIMAGEMEM GUIAPI SaveImageUseVirtualMem(int x, int y, int iWidth, int iHeight)
 *
 * Params:  x, y:       the position of image that want to save.
 *          iWidth, iHeight:    the size of image that want to save.
 *                           
 * Return: Handle of virtual memory that save image.
 *
 *  1995.8.10.AM.
 *
 */
_vmhnd_t GUIAPI SaveImageUseVirtualMem(int x, int y, int iWidth, int iHeight)
{
    _vmhnd_t Handle;
    char FAR* lpImageMem;
    unsigned long size;
    
    SetPtrVis(HIDE);
    def_GDC_reg();
    size = (unsigned long)_imagesize(0, 0, iWidth, iHeight);
    Handle = _vmalloc(size);
    if(Handle == _VM_NULL)
        return _VM_NULL;
        
    lpImageMem = (char FAR*)_vload(Handle, _VM_DIRTY);
    _getimage(x, y, x + iWidth, y + iHeight, lpImageMem);
    SetPtrVis(SHOW);

    return Handle;
}

/* void GUIAPI RestoreImageUseVirtualMem( _vmhnd_t hdlImage, int x, int y )
 *
 * Params:  hdlImage:   the handle of image memory;
 *          x, y:       the position that image will be put.
 *
 * Return: None.
 *
 *  1995.8.10.AM.
 *
 */
void GUIAPI RestoreImageUseVirtualMem( _vmhnd_t hdlImage, int x, int y )
{
    char FAR* lpImageMem;
    
    lpImageMem = (char FAR*)_vload(hdlImage, _VM_CLEAN);
    
    SetPtrVis(HIDE);
    def_GDC_reg();
    _putimage(x, y, lpImageMem, _GPSET);
    SetPtrVis(SHOW);
    
    _vfree(hdlImage);
}

/* _vmhnd_t GUIAPI GetIconImageHandler( void )
 *
 * Params:  none.
 *
 * Return: the virtual memomry handler of icon image.
 *
 *  1997.7.3.AM.
 *
 */
_vmhnd_t GUIAPI GetIconImageHandler( void )
{
    return hdlImage;
}


/*
 * Function: void GUIAPI SetCaretPos( short x, short y ).
 *      This function set new caret position.
 * Parameters:
 *      x, y: newposition
 * Return: 
 *      None;
 * Note:
 *      Before call this function, undisplay caret first.
 */
void GUIAPI SetCaretPos( short x, short y )
{
    // Undisplay the old caret.
    if(CaretInfo.fShowOrHide)
    {
        SetPtrVis(HIDE);
        _setwritemode(_GXOR);
        _setcolor(COLOR_lightwhite);
        _moveto(CaretInfo.x, CaretInfo.y+2);
        _lineto(CaretInfo.x, CaretInfo.y+14);
        _moveto(CaretInfo.x + 1, CaretInfo.y+2);
        _lineto(CaretInfo.x + 1, CaretInfo.y+14);
        _setwritemode(_GPSET);
        CaretInfo.fShowOrHide = FALSE;
        SetPtrVis(SHOW);
    }
    
    // set new caret position.
    CaretInfo.x = x;
    CaretInfo.y = y;
    CaretInfo.fDisplay = TRUE;
    CaretInfo.count = 6;
    
    return;
}

/*
 * Function: void GUIAPI FlashCaret(void).
 *      This function flash caret in the current position.
 * Parameters:
 *      none.
 * Return: 
 *      None;
 * Note:
 *      Before call this function, undisplay caret first.
 */
void GUIAPI FlashCaret(void)
{
    if(CaretInfo.fDisplay && CaretInfo.count > 5)
    {
        SetPtrVis(HIDE);
        _setwritemode(_GXOR);
        _setcolor(COLOR_lightwhite);
        _moveto(CaretInfo.x, CaretInfo.y+2);
        _lineto(CaretInfo.x, CaretInfo.y+14);
        _moveto(CaretInfo.x + 1, CaretInfo.y+2);
        _lineto(CaretInfo.x + 1, CaretInfo.y+14);
        _setwritemode(_GPSET);
        SetPtrVis(SHOW);
        
        CaretInfo.count = 0;
        CaretInfo.fShowOrHide = !CaretInfo.fShowOrHide;
    }
}

/*
 * Function: void GUIAPI UndipslayCaret( void ).
 *      This function erase current caret .
 * Parameters:
 *      None.
 * Return: 
 *      None.
 * Note:
 *      This function always called before update position of caret.
 */
void GUIAPI UndisplayCaret( void )
{
    CaretInfo.fDisplay = FALSE;

    if(CaretInfo.fShowOrHide)
    {
        SetPtrVis(HIDE);
        _setwritemode(_GXOR);
        _setcolor(COLOR_lightwhite);
        _moveto(CaretInfo.x, CaretInfo.y+2);
        _lineto(CaretInfo.x, CaretInfo.y+14);
        _moveto(CaretInfo.x + 1, CaretInfo.y+2);
        _lineto(CaretInfo.x + 1, CaretInfo.y+14);
        _setwritemode(_GPSET);
        CaretInfo.fShowOrHide = FALSE;
        SetPtrVis(SHOW);
    }
}

BOOL GUIAPI IsCaretDisplaying(int* x, int* y)
{
    *x = CaretInfo.x;
    *y = CaretInfo.y;
    return CaretInfo.fDisplay;
}

/* MouseInit - Initialize mouse and turns on mouse pointer. Initializes
 * all internal variables used by other mouse functions. This function
 * should be called whenever a new video mode is set, since internal
 * variables are mode-dependent.
 *
 * Params: none
 *
 * Return: 0 if no mouse available, otherwise number of buttons available
 */
static int MouseInit()
{
//  struct videoconfig vc;
    char _far *pMode = (char _far *)0x00000449; /* Address for mode */

    /* Handle special case of Hercules graphics. To use mouse with video
     * page 0. assume mode 6. To use mouse with page 1, assume mode 5.
     * Since the mouse functions couldn't easily detect and adjust for
     * page changes anyway, this code assumes page 0. Note also that the
     * mouse for Hercules graphics must be set in text mono mode.
     */
    if( vc.mode == _HERCMONO )
    {   
        mi.fExist = 0;
        *pMode = 6;
    }

    mi.fInit = 1;
    _asm
    {
        sub     ax, ax              ; Mouse function 0, reset mouse
        int     33h
        mov     mi.fExist, ax       ; Set existence flag for future calls
        or      ax, ax              ; If AX = 0, there is no mouse
        jnz     exist
        ret                         ; so quit
exist:
        mov     mi.cBtn, bx         ; Save number of mouse buttons for return
    }

    /* Set graphics flag. */
    if( vc.numxpixels )
    {
        mi.fGraph = 1;
        mi.yActual = vc.numypixels - 1;
        mi.xActual = vc.numxpixels - 1;
    }
    else
        mi.fGraph = 0;

    /* The mouse works on a virtual screen of 640 x pixels by (8 * textrows)
     * vertical pixels. By default, it assumes 640 x 200 for 25-line mode.
     * You must call function 8 to adjust for other screen sizes.
     */
    mi.xVirtual = 639;
    if( mi.fGraph )
        mi.yVirtual = vc.numypixels - 1;
    else
        mi.yVirtual = (vc.numtextrows << 3) - 1;

    /* Reset Hercules graphics mode and reset the height. */
    if( vc.mode == _HERCMONO )
    {
        _setvideomode( _HERCMONO );
        mi.xVirtual = 719;
    }

    _asm
    {
        mov     ax, 8               ; Set minimum and maximum vertical
        sub     cx, cx              ; Minimum is 0
        mov     dx, mi.yVirtual     ; Maximum is 8 * rows (or rows SHL 3)
        int     33h                 ; Adjust for 25, 30, 43, 50, or 60 lines

        mov     ax, 1               ; Turn on mouse pointer
        int     33h

        mov     ax, 3               ; Get initial position and button status
        int     33h
        mov     mi.xLast, cx        ; Save internally
        mov     mi.yLast, dx
        mov     mi.fsBtnLast, bx
    }
    return mi.cBtn;                 /* Return the number of mouse buttons */
}

BOOL GUIAPI IsMouseAvailable()
{
    return mi.fExist;
}

/* GetMouseEvent - Check to see if there has been a mouse event. If event
 * occurred, update event structure.
 *
 * Params: pEvent - Pointer to event structure
 *
 * Return: 1 if event, 0 if no event
 */
int GUIAPI GetMouseEvent( EVENT _far *pEvent )
{
    int rtn;

    /* Make sure that mouse exists. */
    if( !mi.fExist )
        return 0;

    _asm
    {
        mov     ax, 3               ; Get Mouse position and button status
        int     33h
        sub     ax, ax              ; Assume no event

        cmp     cx, mi.xLast        ; Has column changed?
        jne     event
        cmp     dx, mi.yLast        ; Has row changed?
        jne     event
        cmp     bx, mi.fsBtnLast    ; Has button changed?
        je      noevent
event:
        mov     ax, 1               ; If something changed, event occurred
        mov     mi.xLast, cx        ; Update internal variables
        mov     mi.yLast, dx
        mov     mi.fsBtnLast, bx
noevent:
        mov     rtn, ax             ; Set return value
    }

    /* If event, put adjust values in structure. */
    if( rtn )
    {
        /* If graphics mode, adjust virtual mouse position to actual
         * screen coordinates.
         */
        if( mi.fGraph )
        {
            pEvent->hotx = (short)(((long)mi.xLast * mi.xActual) / mi.xVirtual);
            pEvent->hoty = (short)(((long)mi.yLast * mi.yActual) / mi.yVirtual);
        }
        /* If text mode, adjust virtual mouse position to 1-based
         * row/column.
         */
        else
        {
            pEvent->hotx = (mi.xLast >> 3) + 1;
            pEvent->hoty = (mi.yLast >> 3) + 1;
        }
        pEvent->fsBtn = mi.fsBtnLast;
    }
    return rtn;
}

/* GetPtrPos - Get mouse pointer position and button status regardless of
 * whether there was an event.
 *
 * Params: pEvent - Pointer to event structure
 *
 * Return: 0 if no mouse, otherwise 1
 */
int GUIAPI GetPtrPos( EVENT FAR *pEvent )
{
    /* Make sure that mouse exists. */
    if( !mi.fExist )
        return 0;

    _asm
    {
        mov     ax, 3               ; Get Mouse position and button status
        int     33h
        les     di, pEvent
        mov     es:[di].hotx, cx
        mov     es:[di].hoty, dx
        mov     es:[di].fsBtn, bx
    }

    /* If graphics mode, adjust virtual mouse position to actual
     * screen coordinates.
     */
    if( mi.fGraph )
    {
        pEvent->hotx = (short)(((long)pEvent->hotx * mi.xActual) / mi.xVirtual);
        pEvent->hoty = (short)(((long)pEvent->hoty * mi.yActual) / mi.yVirtual);
    }
    /* If text mode, adjust virtual mouse position to 1-based
     * row/column.
     */
    else
    {
        pEvent->hotx >>= 3;
        pEvent->hoty >>= 3;
        pEvent->hotx++;
        pEvent->hoty++;
    }
    return 1;
}

/* SetPtrVis - Set pointer visibility.
 *
 * Params: state - SHOW or HIDE
 *
 * Return: 0 if no mouse, otherwise 1
 */
int GUIAPI SetPtrVis( enum PTRVIS pv )
{
    /* Make sure that mouse exists. */
    if( !mi.fExist )
        return 0;

    _asm
    {
        mov ax, pv                  ; Show or hide mouse pointer
        int 33h
    }
}

/* SetPtrPos - Set mouse pointer position.
 *
 * Params: x - column position in text modes, actual x coordinate in graphics
 *         y - row position in text modes, actual y coordinate in graphics
 *
 * Return: 0 if no mouse, otherwise 1
 */
int GUIAPI SetPtrPos( short x, short y )
{
    /* Make sure that mouse exists. */
    if( !mi.fExist )
        return 0;

    /* If graphics, adjust actual coordinates to virtual coordinates. */
    if( mi.fGraph )
    {
        x = (short)(((long)x * mi.xActual) / mi.xVirtual);
        y = (short)(((long)y * mi.yActual) / mi.yVirtual);
    }
    /* If text, adjust row/column to 0-based virtual coordinates. */
    else
    {
        x--;
        y--;
        x <<= 3;
        y <<= 3;
    }

    _asm
    {
        mov     ax, 4               ; Set mouse position
        mov     cx, x
        mov     dx, y
        int     33h
    }
    return 1;
}

/* SetPtrShape - Set mouse pointer shape.
 *
 * Params: x - column position in text modes, actual x coordinate in graphics
 *         y - row position in text modes, actual y coordinate in graphics
 *
 * Return: 0 if no mouse, otherwise 1
 */
int GUIAPI SetPtrShape( PTRSHAPE FAR *ps )
{
    /* Make sure that mouse exists. */
    if( !mi.fExist )
        return 0;

    /* If graphics, use pointer shape bitmask array. */
    if( mi.fGraph )
    {
        _asm
        {
            les     di, ps
            mov     bx, es:[di].g.xHot      ; Load hot spot offsets
            mov     cx, es:[di].g.yHot
            mov     dx, di
            add     dx, 4

            mov     ax, 9                   ; Set graphics pointer
            int     33h
        }
    }
    /* If text, use pointer color/character values. */
    else
    {
        _asm
        {
            les     di, ps
            mov     bx, 0                   ; Use software cursor
            mov     cl, es:[di].t.chScreen
            mov     ch, es:[di].t.atScreen
            mov     dl, es:[di].t.chCursor
            mov     dh, es:[di].t.atCursor

            mov     ax, 10                  ; Set text pointer
            int     33h
        }
    }
    return 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -