;       Автор - Александр Белоусов (Mirex)
IDEAL
P486

segment CSEG
ASSUME cs:CSEG, ds:CSEG, es:CSEG, ss:CSEG
        org     100h
Start:
        jmp     Init
;-------- обработчик
MagicWord       dw 0FACh

PROC Interr FAR
        pushf
        pusha
        mov     al,[cs:gate]
        or      al,al
        jnz     Shit
        mov     [byte ptr cs:gate],1

        xor     ax,ax
        mov     fs,ax
        mov     al,[fs:449h]
        cmp     al,13h
        jne     Shit
        ; OUTPUT
        ;mov     ah,13h
        ;xor     al,al
        ;xor     bh,bh
        ;mov     bl,10
        ;mov     cx,14
        ;mov     dh,10
        ;mov     dl,10
        ;push    es
        ;push    cs
        ;pop     es
        ;push    bp
        ;mov     bp,offset string
        ;int     10h
        ;pop     bp
        ;pop     es
        mov     si,0
NextLine:
        mov     di,0
        mov     ax,14
        mul     si
        mov     bx,ax
        NextPixel:
                   mov  al,[cs:BMP+bx+di]
                   cmp  al,0
                   je   notPut
                   push bx

                   mov  cx,153 ; X
                   mov  bx,95  ; Y

                   add  bx,si
                   add  cx,di

                   mov  ax,bx
                   mov  dx,320
                   mul  dx
                   add  ax,cx

                   mov  bx,ax

                   push 0A000h
                   pop  gs
                   mov  [byte ptr gs:bx],10
                   pop  bx
        NotPut:
                   inc   di
                   cmp   di,14
                   jne   NextPixel
        inc   si
        cmp   si,10
        jne   NextLine

Shit:
        mov     [byte ptr cs:gate],0
        popa
        popf

        db      0EAh            ;jmp far на старый обработчик
old_ofs dw      ?
old_seg dw      ?
gate    db      0
BMP     db      10,10,00,10,00,10,00,00,10,10,00,10,00,00
        db      10,00,00,10,00,10,00,10,00,00,00,10,00,10
        db      10,10,00,10,00,10,00,10,00,00,00,10,10,00
        db      10,00,00,10,00,10,00,10,00,00,00,10,00,10
        db      10,00,00,00,10,00,00,00,10,10,00,10,00,10
        db      00,00,00,00,00,00,00,00,00,00,00,00,00,00
        db      00,00,00,10,00,10,00,00,10,00,00,10,00,10
        db      00,00,00,10,00,10,00,10,00,10,00,10,00,10
        db      00,00,00,00,10,00,00,10,00,10,00,10,00,10
        db      00,00,00,00,10,00,00,00,10,00,00,00,10,00
ENDP Interr

finish          EQU $
;-------- конец его
PROC Init
        mov     ax,351Ch
        int     21h
        mov     ax,[es:bx-2]
        cmp     ax,[cs:MagicWord]
        jne     Install
        jmp     UnInstall
ENDP Init
;--- Установка
PROC Install
        mov     [cs:old_ofs],bx
        mov     [cs:old_seg],es
        push    cs
        pop     ds
        mov     dx,offset Interr
        mov     ax,251Ch
        int     21h

        push    cs
        pop     ds
        mov     dx,offset imsg
        mov     ah,09h
        int     21h

        mov     dx,offset finish
        int     27h
ENDP Install
;--- Убрать
PROC UnInstall
        mov     ax,[es:old_seg]
        mov     ds,ax
        mov     dx,[es:old_ofs]
        mov     ax,251Ch
        int     21h
        ;--
        push    cs
        pop     ds
        mov     dx,offset umsg
        mov     ah,09h
        int     21h
        ;--
        mov     ax,4C00h
        int     21h
ENDP UnInstall

imsg    db "Установлен",13,10,"$"
umsg    db "Убран",13,10,"$"

ends    CSEG

END     Start