int10h.asm

来自「开放源码的编译器open watcom 1.6.0版的源代码」· 汇编 代码 · 共 819 行 · 第 1/2 页

ASM
819
字号
;
;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
;
        .386
_Int10h segment para public 'extension code' use32
        assume cs:_Int10h, ds:nothing, es:nothing
Int10hStart     label byte


;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Int10hOpen      proc    near
;
;Setup int 10h patch.
;
        assume ds:_Int10h
        assume es:_cwMain
        mov     Int10hDSeg,es   ;Store cwCode selector.
        mov     Int10hCSeg,cs   ;store this segment.
        mov     Int10hDDSeg,ds
        ;
        sys     GetSel          ;Get a selector
        jc      @@9
        mov     Int10hStaticSel,bx
        sys     GetSel
        jc      @@9
        mov     Int10hUltraFont,bx
        ;
        mov     bl,10h
        sys     GetVect
        test    es:SystemFlags,1
        jz      @@Use32
        mov     w[OldInt10h],dx
        mov     w[OldInt10h+2],cx
        jmp     @@Use0
@@Use32:        mov     d[OldInt10h],edx
        mov     w[OldInt10h+4],cx
@@Use0: mov     edx,offset Int10h
        mov     cx,cs
        mov     bl,10h
        sys     SetVect
        assume es:nothing
        assume ds:nothing
        clc
@@9:    ;
        db 66h
        retf
Int10hOpen      endp


;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Int10hClose     proc    near
;
;Remove int 10h patch.
;
        push    ds
        mov     ds,cs:Int10hDDSeg
        assume ds:_Int10h
        cmp     d[OldInt10h],0
        jz      @@9
        mov     ds,Int10hDseg
        assume ds:_cwMain
        test    SystemFlags,1
        assume ds:nothing
        mov     ds,cs:Int10hDDSeg
        assume ds:_Int10h
        jz      @@Use32
        movzx   edx,w[OldInt10h]
        mov     cx,w[OldInt10h+2]
        jmp     @@Use0
@@Use32:        mov     edx,d[OldInt10h]
        mov     cx,w[OldInt10h+4]
@@Use0: mov     bl,10h
        sys     SetVect
        assume ds:nothing
@@9:    pop     ds
        ;
        db 66h
        retf
Int10hClose     endp


;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Int10h  proc    far
        cmp     ax,1002h                ;set pen numbers?
        jz      @@SetPens
        cmp     ax,1009h                ;get pen numbers?
        jz      @@GetPens
        cmp     ax,1012h                ;set colour values?
        jz      @@SetColours
        cmp     ax,1017h                ;get colour values?
        jz      @@GetColours
        cmp     ax,1100h                ;Set font?
        jz      @@SetFont1
        cmp     ax,1110h                ;Set font and program CRTC?
        jz      @@SetFont1
        cmp     ax,1130h                ;Get font details?
        jz      @@GetFont
        cmp     ah,13h          ;write teletype string?
        jz      @@WriteString
        cmp     ah,1bh          ;state info?
        jz      @@VideoState
        cmp     ax,1c00h
        jz      @@StateSize
        cmp     ax,1c01h                ;state save?
        jz      @@StateSave
        cmp     ax,1c02h                ;state restore?
        jz      @@StateRestore
        cmp     ax,0cd00h               ;Ultra set palette?
        jz      @@UltraSetPal
        cmp     ax,0cd02h               ;Ultra get palette?
        jz      @@UltraGetPal
        cmp     ax,0cd10h               ;Ultra set font?
        jz      @@UltraSetFont
        jmp     @@NotOurs
        ;
@@GetFont:      ;Get font details?
        ;
        pushm   eax,ebx,esi,edi
        pushm   ds,fs
        mov     edi,offset Int10Buffer
        mov     es,cs:Int10hDseg
        assume es:_cwMain
        mov     es:[edi].Real_EAX,eax
        mov     es:[edi].Real_EBX,ebx
        assume es:nothing
        mov     bl,10h
        sys     IntXX
        mov     bx,es:[edi].Real_ES
        mov     ax,0002h
        int     31h
        jc      @@9
        mov     ebp,es:[edi].Real_EBP
        movzx   ebp,bp
        mov     edx,es:[edi].Real_EDX
        mov     ecx,es:[edi].Real_ECX
        mov     es,ax
@@9:    popm    ds,fs
        popm    eax,ebx,esi,edi
        jmp     @@Done
        ;
@@UltraSetFont: ;UltraVision set font.
        ;
        pushm   ebx,ecx,edx,esi,edi,ebp
        pushm   ds,es,fs
        push    eax
        xor     eax,eax
        mov     ax,es
        lsl     eax,eax
        cmp     eax,10000h
        jnc     @@Use32Bit503
        movzx   ebp,bp
@@Use32Bit503:  xor     eax,eax
        mov     ax,ds
        lsl     eax,eax
        cmp     eax,10000h
        jnc     @@Use32Bit504
        movzx   esi,si
@@Use32Bit504:  pop     eax
        pushm   ax,bx,cx,dx
        push    ds
        mov     ds,cs:Int10hDseg
        assume ds:_cwMain
        mov     fs,PSPSegment
        xor     edi,edi
        mov     es,fs:w[EPSP_TransProt]
        pop     ds
        assume ds:nothing
        mov     ecx,8
        cld
        rep     movsb           ;copy into transfer buffer.
        popm    ax,bx,cx,dx
        pushm   ax,bx,cx,dx
        movzx   ax,bh
        mul     cx
        movzx   ecx,ax
        mov     esi,ebp         ;source buffer.
        push    es
        mov     ds,cs:Int10hDseg
        assume ds:_cwMain
        mov     fs,PSPSegment
        mov     edi,8
        mov     es,fs:w[EPSP_TransProt]
        pop     ds
        assume ds:nothing
        cld
        rep     movsb           ;copy into transfer buffer.
        popm    ax,bx,cx,dx
        mov     edi,offset Int10Buffer
        mov     es,cs:Int10hDseg
        assume es:_cwMain
        mov     es:[edi].Real_EAX,eax
        mov     es:[edi].Real_EBX,ebx
        mov     es:[edi].Real_ECX,ecx
        mov     es:[edi].Real_EDX,edx
        mov     es:[edi].Real_ESI,0
        mov     es:[edi].Real_EBP,8
        mov     ax,fs:w[EPSP_TransReal]
        mov     es:[edi].Real_DS,ax
        mov     es:[edi].Real_ES,ax
        assume es:nothing
        mov     bl,10h
        sys     IntXX
        mov     eax,es:[edi].Real_EAX
        popm    ds,es,fs
        popm    ebx,ecx,edx,esi,edi,ebp
        jmp     @@Done
        ;
@@UltraGetPal:  ;UltraVision get palette.
        ;
        pushm   eax,ebx,ecx,edi,ebp
        pushm   es,fs
        mov     edi,offset Int10Buffer
        mov     es,cs:Int10hDseg
        assume es:_cwMain
        mov     fs,es:PSPSegment
        mov     es:[edi].Real_EAX,eax
        assume es:nothing
        mov     bl,10h
        sys     IntXX           ;read pen values.
        mov     ds,cs:Int10hDDseg
        assume ds:_Int10h
        mov     bx,Int10hUltraFont
        assume ds:nothing
        movzx   edx,es:[edi].Real_DS
        shl     edx,4
        mov     ecx,65535
        sys     SetSelDet32
        mov     ds,bx
        mov     edx,es:[edi].Real_EDX
        mov     esi,es:[edi].Real_ESI
        movzx   esi,si
        movzx   edx,dx
        popm    es,fs
        popm    eax,ebx,ecx,edi,ebp
        jmp     @@Done
        ;
@@UltraSetPal:  ;UltraVision set palette.
        ;
        pushm   eax,ebx,ecx,edx,esi,edi,ebp
        pushm   ds,es,fs
        push    eax
        xor     eax,eax
        mov     ax,ds
        lsl     eax,eax
        cmp     eax,10000h
        jnc     @@Use32Bit502
        movzx   edx,dx
@@Use32Bit502:  pop     eax
        mov     esi,edx         ;source buffer.
        push    ds
        mov     ds,cs:Int10hDseg
        assume ds:_cwMain
        mov     fs,PSPSegment
        xor     edi,edi
        mov     es,fs:w[EPSP_TransProt]
        pop     ds
        assume ds:nothing
        cld
        mov     ecx,16
        rep     movsb           ;copy into transfer buffer.
        mov     edi,offset Int10Buffer
        mov     es,cs:Int10hDseg
        assume es:_cwMain
        xor     edx,edx
        mov     es:[edi].Real_EAX,eax
        mov     es:[edi].Real_ECX,ecx
        mov     es:[edi].Real_EDX,edx
        mov     ax,fs:w[EPSP_TransReal]
        mov     es:[edi].Real_DS,ax
        assume es:nothing
        mov     bl,10h
        sys     IntXX
        popm    ds,es,fs
        popm    eax,ebx,ecx,edx,esi,edi,ebp
        jmp     @@Done
        ;
@@VideoState:   ;Some sort of video state table function.
        ;
        or      bx,bx
        jnz     @@NotOurs
        pushm   ebx,ecx,edx,esi,edi,ebp
        pushm   ds,es,fs
        push    eax
        xor     eax,eax
        mov     ax,es
        lsl     eax,eax
        cmp     eax,10000h
        jnc     @@Use32Bit501
        movzx   edi,di
@@Use32Bit501:  pop     eax
        pushm   edi,es
        ;
        mov     edi,offset Int10Buffer
        mov     es,cs:Int10hDseg
        assume es:_cwMain
        mov     fs,es:PSPSegment
        xor     edx,edx
        mov     es:[edi].Real_EAX,eax
        mov     es:[edi].Real_EBX,ebx
        mov     es:[edi].Real_EDX,edx
        mov     ax,fs:w[EPSP_TransReal]
        mov     es:[edi].Real_ES,ax
        assume es:nothing
        mov     bl,10h
        sys     IntXX           ;read pen values.
        mov     eax,es:[edi].Real_EAX
        popm    edi,es
        cmp     al,1bh
        jz      @@ok100
        popm    ds,es,fs
        popm    eax,ebx,ecx,edx,esi,edi,ebp
        xor     eax,eax
        jmp     @@Done
@@ok100:        push    eax
        push    edi
        mov     ds,cs:Int10hDseg
        assume ds:_cwMain
        xor     esi,esi
        mov     ds,fs:w[EPSP_TransProt]
        assume ds:nothing
        mov     ecx,64
        cld
        rep     movsb           ;copy the results.
        pop     edi
        movzx   edx,es:w[edi+2]
        shl     edx,4
        mov     ecx,65535
        mov     ds,cs:Int10hDDseg
        assume ds:_Int10h
        mov     bx,Int10hStaticSel
        assume ds:nothing
        mov     es:w[edi+2],bx
        sys     SetSelDet32
        pop     eax
        popm    ds,es,fs
        popm    ebx,ecx,edx,esi,edi,ebp
        jmp     @@Done
        ;
@@SetFont1:     ;Load user font into character generator ram.
        ;
        pushm   eax,ebx,ecx,edx,esi,edi,ebp
        pushm   ds,es,fs
        push    eax
        xor     eax,eax
        mov     ax,es
        lsl     eax,eax
        cmp     eax,10000h
        jnc     @@Use32Bit500
        movzx   ebp,bp
@@Use32Bit500:  pop     eax
        pushm   ax,bx,cx,dx
        movzx   ax,bh
        mul     cx
        movzx   ecx,ax
        mov     esi,ebp         ;source buffer.
        push    es
        mov     ds,cs:Int10hDseg
        assume ds:_cwMain
        mov     fs,PSPSegment
        xor     edi,edi
        mov     es,fs:w[EPSP_TransProt]
        pop     ds
        assume ds:nothing
        cld
        rep     movsb           ;copy into transfer buffer.
        popm    ax,bx,cx,dx
        mov     edi,offset Int10Buffer
        mov     es,cs:Int10hDseg
        assume es:_cwMain
        mov     es:[edi].Real_EAX,eax
        mov     es:[edi].Real_EBX,ebx
        mov     es:[edi].Real_ECX,ecx
        mov     es:[edi].Real_EDX,edx
        mov     es:[edi].Real_EBP,0
        mov     ax,fs:w[EPSP_TransReal]
        mov     es:[edi].Real_ES,ax
        assume es:nothing
        mov     bl,10h
        sys     IntXX
        popm    ds,es,fs
        popm    eax,ebx,ecx,edx,esi,edi,ebp
        jmp     @@Done
        ;
@@SetPens:      ;ES:DX - List of 17 bytes to send to video.
        ;
        pushm   eax,ebx,ecx,edx,esi,edi,ebp
        pushm   ds,es,fs
        push    eax
        xor     eax,eax
        mov     ax,es
        lsl     eax,eax
        cmp     eax,10000h
        jnc     @@Use32Bit50
        movzx   edx,dx
@@Use32Bit50:   pop     eax
        mov     esi,edx         ;source buffer.
        push    es
        mov     ds,cs:Int10hDseg
        assume ds:_cwMain
        mov     fs,PSPSegment
        xor     edi,edi
        mov     es,fs:w[EPSP_TransProt]
        pop     ds
        assume ds:nothing
        cld
        mov     ecx,17
        rep     movsb           ;copy into transfer buffer.
        mov     edi,offset Int10Buffer
        mov     es,cs:Int10hDseg
        assume es:_cwMain

⌨️ 快捷键说明

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