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

📄 tsr.c

📁 用来将电脑连接到电视荧幕, 并以15Khz输出的源码, 请只用在支援15Khz的荧幕上, 以免伤害荧幕
💻 C
📖 第 1 页 / 共 3 页
字号:

static void Init_PROGRAM_VideoModes(void)
{
    extern SCRLIST ScrModeList[];
    CRTCPARAM Param;
    VIDEOMODE Mode;
    int idx;
    WORD d0;

    idx = 0;
    while(idx < MAXVIDEOMODES){
        PROGRAM.VideoModes[idx].VESAmode = 0xFFFF;
        PROGRAM.VideoModes[idx].index    = 0xFFFF;
        PROGRAM.VideoModes[idx].width    = 0;
        PROGRAM.VideoModes[idx].height   = 0;
        idx += 1;
    }

    idx = 0;
    d0 = GetActualVesaMode(1024, 768, GetAvailableBpp(8));
    PROGRAM.VideoModes[idx].VESAmode = d0;
    PROGRAM.VideoModes[idx].index    = d0;
    PROGRAM.VideoModes[idx].width    = 1024;
    PROGRAM.VideoModes[idx].height   = 768;
    idx += 1;
    d0 = GetActualVesaMode(1024, 768, GetAvailableBpp(16));
    PROGRAM.VideoModes[idx].VESAmode = d0;
    PROGRAM.VideoModes[idx].index    = d0;
    PROGRAM.VideoModes[idx].width    = 1024;
    PROGRAM.VideoModes[idx].height   = 768;
    idx += 1;
    PROGRAM.start_own_vesa_mode = idx;

    idx = 0;
    while(idx < MAXVIDEOMODES){
        if(ScrModeList[idx].forx == 0 || ScrModeList[idx].fory == 0) break;
        Param = *(ScrModeList[idx].cp);
        Copy_CRTCPARAM_to_VIDEOMODE(&Mode, &Param);
        AddMode(&Mode);
        idx += 1;
    }
}




#ifdef SUPPORT_DBCS

static void DBCS_get_vector(void)
{
    asm {
        pusha
        push    ds
        xor     ax, ax
        mov     ds, ax
        mov     si, ax
        mov     ax, 6300h
        int     21h
        mov     bx, ds
        pop     ds
        mov     [byte ptr dbcs_supported], al
        mov     [word ptr dbcs_ds], bx
        mov     [word ptr dbcs_si], si
        popa
    }
}

#endif


void int8h_sub(void)
{
        INT8

        if (PROGRAM.current_ticks) /* We have a possible pending modex mode */
        {
                if(PROGRAM.current_ticks==PROGRAM.max_ticks)
                {
                        PROGRAM.current_ticks=0;
                        SetModeX(PROGRAM.center_x, PROGRAM.center_y, PROGRAM.h_sync_delay, PROGRAM.h_disp_delay);
//                        SetTextHeight(1);
                }
                else
                        PROGRAM.current_ticks++;
        }
}





int int10h_sub(const WORD regtop)
{
    WORD d0;
    WORD d1;
    WORD d2;
    DWORD d3;
    WORD d4;

    d0 = get_reg(regtop, ofsAX);

    if(PROGRAM.enabled == 0) /* TSR not active */
        return 0;

    if((PROGRAM.use_pm_interface != 0) && (d0 == 0x4F0A)) /* GET Protect Mode Interlace */
    {
        d1 = get_reg(regtop, ofsBX);
        if( (d1 & 0xFF) == 0x00){
            set_reg(regtop, ofsDI, get_pm_table_offset());
            set_reg(regtop, ofsES, get_pm_table_segment());
            set_reg(regtop, ofsCX, get_pm_table_length());
            set_reg(regtop, ofsAX, 0x004F);
        }else{
            set_reg(regtop, ofsAX, 0x014F);
        }
        return 1;
    }

    if(d0 == 0x4F00)    /* VESA SuperVGA BIOS - GET SuperVGA INFORMATION */
    {
        generic_oldint10h_for_c_code(regtop);

        _DX = (PROGRAM.membytes >> 10) >> 6;
        _AX = get_reg(regtop, ofsES);
        _ES = _AX;
        _DI = get_reg(regtop, ofsDI);
        asm     mov     [es:di + 012h], dx     /* memory emulation */

        VESA_MakeModeList();

        _AX = get_reg(regtop, ofsES);
        _ES = _AX;
        _DI = get_reg(regtop, ofsDI);
        asm     mov     [es:di + 10h], ds
        asm     mov     ax, offset VESAmodes
        asm     mov     [es:di + 0eh], ax

        return 1;
    }

    if(d0 == 0x4F01)    /* GET SuperVGA MODE INFORMATION */
    {
        d1 = get_reg(regtop, ofsCX) & 0x01FF;
        if( VESA_ModeInfo(d1, regtop) == 0xFFFF ){
            set_reg(regtop, ofsAX, 0x014F);
            return 1;
        }

        /* Code to copy from our buffer to there buffer */
        _ES = get_reg(regtop, ofsES);
        _DI = get_reg(regtop, ofsDI);
        asm mov     si, offset VESAbuffer
        asm mov     cx, 256
copyloop:
        asm mov     al, [ds:si]
        asm mov     [es:di], al
        asm add     si, 1
        asm add     di, 1
        asm dec     cx
        asm jnz     copyloop

        asm sub     di, 256             /* Restore DI to correct position */
#if 0
        asm mov     al, 127
        asm mov     [es:di + 1dh], al   /* Max out on pages for increased compatability */
#endif
        set_reg(regtop, ofsAX, 0x004F);
        return 1;
    }

    if(d0 == 0x4F02)    /* SET SuperVGA VIDEO MODE */
    {
        d1 = get_reg(regtop, ofsBX);
        d4 = d1 & 0x01FF;                       /* d4 = own vesa mode    */
        d2 = VESA_ModeInfo(d4, regtop);         /* d2 = actual vesa mode */
        if(d2 == 0xFFFF){
            set_reg(regtop, ofsAX, 0x014F);
            return 1;
        }
        d1  = d1 & ~0x01FF;
        d1 |= d2 &  0x01FF;
        set_reg(regtop, ofsBX, d1);
        set_reg(regtop, ofsAX, 0x4F02);
        generic_oldint10h_for_c_code(regtop);
        if( get_reg(regtop, ofsAX) != 0x004F )
            return 1;

        if(d4 >= CUSTOM_MODE){
            /* CALL YOUR CARD 15khz section here */
#ifndef debug
            SetSVGA(VESAbuffer.width, VESAbuffer.height, PROGRAM.center_x, PROGRAM.center_y, PROGRAM.h_sync_delay, PROGRAM.h_disp_delay);
#endif
        }
        /* The correct scanbyte/width and so on if it was called in its native mode */
        PROGRAM.bitsperpixel = VESAbuffer.bpp;
        if(PROGRAM.bitsperpixel == 15){
            PROGRAM.bitsperpixel = 16;
        }
        PROGRAM.scanbyte  = (VESAbuffer.width / 8) * PROGRAM.bitsperpixel;
        PROGRAM.scanwidth = VESAbuffer.width;
        SetBytesPerLine(PROGRAM.scanbyte);

        /* Workout total number of scanlines available */
        PROGRAM.scantotal=(PROGRAM.membytes/(unsigned long)PROGRAM.scanbyte);

        return 1;
    }

    if(d0 == 0x4F06)    /* GET/SET LOGICAL SCAN LINE LENGTH */
    {
        d1 = get_reg(regtop, ofsBX) & 0x00FF;
        if(d1 == 0x00 || d1 == 0x02){           /* SET */
            d2 = get_reg(regtop, ofsCX);
            if(d1 == 0x00){
                PROGRAM.scanbyte  = CalcBytesPerLine(d2, PROGRAM.bitsperpixel);
            }else{
                PROGRAM.scanbyte  = d2;
            }
            PROGRAM.scanwidth = CalcPixelsPerLine(PROGRAM.scanbyte,
                                                 PROGRAM.bitsperpixel);
            PROGRAM.scantotal = PROGRAM.membytes / PROGRAM.scanbyte;
            SetBytesPerLine(PROGRAM.scanbyte);
            set_reg(regtop, ofsBX, PROGRAM.scanbyte);
            set_reg(regtop, ofsCX, PROGRAM.scanwidth);
            set_reg(regtop, ofsDX, PROGRAM.scantotal);
            set_reg(regtop, ofsAX, 0x004F);
        }else if(_BL == 0x01){
            set_reg(regtop, ofsBX, PROGRAM.scanbyte);
            set_reg(regtop, ofsCX, PROGRAM.scanwidth);
            set_reg(regtop, ofsDX, PROGRAM.scantotal);
            set_reg(regtop, ofsAX, 0x004F);
        }else if(_BL == 0x03){
            d2 = GetMaxBytesPerLine();
            set_reg(regtop, ofsCX, CalcPixelsPerLine(d2, PROGRAM.bitsperpixel));
            set_reg(regtop, ofsBX, d2);
            set_reg(regtop, ofsAX, 0x004F);
        }else{
            set_reg(regtop, ofsAX, 0x014F);
        }
        return 1;
    }

    if(d0 == 0x4F07)    /* GET/SET Display Start */
    {
        d1 = get_reg(regtop, ofsBX) & 0x00FF;
        if(d1 == 0x00 || d1 == 0x80){           /* SET */
            d2  = get_reg(regtop, ofsDX);
            d3  = (DWORD)d2 * PROGRAM.scanbyte;
            d2  = get_reg(regtop, ofsCX);
            d3 += (DWORD)CalcBytesPerLine(d2, PROGRAM.bitsperpixel);
            SetScreenStartAddress(d3);
            if(d1 == 0x80) VsyncVga();
            set_reg(regtop, ofsAX, 0x004F);
        }else if(_BL == 0x01){
            d3 = GetScreenStartAddress();
            d2 = d3 / PROGRAM.scanbyte;
            set_reg(regtop, ofsDX, d2);
            d2 = CalcPixelsPerLine(d3 % PROGRAM.scanbyte, PROGRAM.bitsperpixel);
            set_reg(regtop, ofsCX, d2);
            set_reg(regtop, ofsAX, 0x004F);
        }else{
            set_reg(regtop, ofsAX, 0x014F);
        }
        return 1;
    }

#ifndef debug
    if(d0 <= 0x13 && PROGRAM.vga_hook_enabled != 0)  /* Standard VGA modes */
    {
        generic_oldint10h_for_c_code(regtop);
        switch(d0)      //
        {
            case 0x13:
                if(PROGRAM.max_ticks != 0){
                        PROGRAM.current_ticks=1;    /* Could be a modex mode so re-program after a delay */
                }else{
                        /* we always think of MODE13h as 320x200 */
                        SetTextHeight(1);
                        SetVGA(640, 200, PROGRAM.center_x, PROGRAM.center_y, PROGRAM.h_sync_delay, PROGRAM.h_disp_delay);
                }
                break;

            case 0x04:
            case 0x05:
                SetVGA(320, 200, PROGRAM.center_x, PROGRAM.center_y, PROGRAM.h_sync_delay, PROGRAM.h_disp_delay);
                SetTextHeight(2);
                break;

            case 0x0D:
                SetVGA(320, 200, PROGRAM.center_x, PROGRAM.center_y, PROGRAM.h_sync_delay, PROGRAM.h_disp_delay);
                SetTextHeight(1);
                break;

            case 0x06:
                SetVGA(640, 200, PROGRAM.center_x, PROGRAM.center_y, PROGRAM.h_sync_delay, PROGRAM.h_disp_delay);
                SetTextHeight(2);
                break;

            case 0x0E:
                SetVGA(640, 200, PROGRAM.center_x, PROGRAM.center_y, PROGRAM.h_sync_delay, PROGRAM.h_disp_delay);
                SetTextHeight(1);
                break;

            case 0x0F:
            case 0x10:
            case 0x11:
            case 0x12:
                SetVGA(640, 480, PROGRAM.center_x, PROGRAM.center_y, PROGRAM.h_sync_delay, PROGRAM.h_disp_delay);
                SetTextHeight(1);
                break;

            case 0x03:
#ifdef SUPPORT_DBCS
                if(PROGRAM.use_dbcs != 0){
                    if(dbcs_supported == 0){
                        asm {
                            push    es
                            push    si
                            mov     es, [word ptr dbcs_ds]
                            mov     si, [word ptr dbcs_si]
                            mov     ax, [word ptr es:si]
                            pop     si
                            pop     es
                        }
                        if(_AX != 0){
                            SetVGA(640, 476, PROGRAM.center_x, PROGRAM.center_y, PROGRAM.h_sync_delay, PROGRAM.h_disp_delay);
                            SetTextHeight(1);
                            break;
                        }
                    }
                }
#endif
                /*  fall through  */
            case 0x02:
            case 0x07:
                SetVGAText80x25(PROGRAM.center_x, PROGRAM.center_y, PROGRAM.h_sync_delay, PROGRAM.h_disp_delay);
                d1 = get_reg(regtop, ofsAX);
                d2 = get_reg(regtop, ofsBX);
                set_reg(regtop, ofsAX, 0x1102);
                set_reg(regtop, ofsBX, 0x0000);
                generic_oldint10h_for_c_code(regtop);
                set_reg(regtop, ofsAX, d1);
                set_reg(regtop, ofsBX, d2);
                break;

            case 0x00:
            case 0x01:
                SetVGAText40x25(PROGRAM.center_x, PROGRAM.center_y, PROGRAM.h_sync_delay, PROGRAM.h_disp_delay);
                d1 = get_reg(regtop, ofsAX);
                d2 = get_reg(regtop, ofsBX);
                set_reg(regtop, ofsAX, 0x1102);
                set_reg(regtop, ofsBX, 0x0000);
                generic_oldint10h_for_c_code(regtop);
                set_reg(regtop, ofsAX, d1);
                set_reg(regtop, ofsBX, d2);
                break;
        }
        return 1;
    }
#endif

    generic_oldint10h_for_c_code(regtop);

    return 1;
}

⌨️ 快捷键说明

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