home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / PASCAL / FIXMOUSE.ZIP / FIXMOUSE.ASM next >
Encoding:
Assembly Source File  |  1991-05-09  |  3.7 KB  |  133 lines

  1. ;
  2. ; FIXMOUSE.ASM - by Kai Rohrbacher   (S_ROHRBACHER@IRAV1.IRA.UKA.DE)
  3. ;
  4. ; (very short) TSR-Program to stop the mouse cursor disappearing in
  5. ; TurboPascal 6.0 after pressing Alt-F5
  6. ;
  7. ; Original idea by Duncan Murdoch - all credits to him!
  8. ;
  9.  
  10. program segment para 'CODE'
  11.         assume cs:program,ds:program,ss:program
  12.         org 100h
  13.  
  14. inter   equ 33h       ;INT to intercept: mouse INT
  15. count   equ 5Ch       ;word counter used for balancing hide/show mouse calls
  16. oldint  equ 5Eh       ;4 bytes to hold old mouse INT
  17. psp_amount equ 62h    ;use all but the first 62h bytes of the PSP segment
  18.  
  19. main:   jmp short init
  20.  
  21. ;Here starts the new code for INT 33h
  22. resident proc
  23. start_resident:
  24.         pushf      ;save all registers
  25.         push ax
  26.         push bx
  27.         push cx
  28.         push dx
  29.         push si
  30.         push di
  31.         push ds
  32.         push es
  33.  
  34.         or ah,ah        ;only continue processing if AH=0
  35.         jne beende
  36.         or al,al        ;on AL=0/16h/21h: reset counter, save state
  37.         je reset
  38.         cmp al,16h
  39.         je reset
  40.         cmp al,21h
  41.         je reset
  42.         cmp al,1        ;if AL=1 (show cursor): decrement counter
  43.         je show_mouse
  44.         cmp al,2        ;if AL=2 (hide cursor): increment counter
  45.         je hide_mouse
  46.         cmp al,17h      ;if AL=17h (restore state): balance original counter
  47.         jne beende      ;by explicitly inc-/decrementing function calls
  48. restore:
  49.         cmp word ptr cs:[count],0
  50.         je beende
  51.         jl hide
  52.         dec word ptr cs:[count]
  53.         mov ax,1
  54. chain:  pushf
  55.         call dword ptr cs:[oldint]
  56.         jmp short restore
  57. hide:   inc word ptr cs:[count]
  58.         mov ax,2
  59.         jmp short chain
  60.  
  61. show_mouse:
  62.         sub word ptr cs:[count],2
  63. hide_mouse:
  64.         inc word ptr cs:[count]
  65.         jmp short beende
  66. reset:  mov word ptr cs:[count],0
  67.  
  68. beende: 
  69.         pop es
  70.         pop ds
  71.         pop di
  72.         pop si
  73.         pop dx
  74.         pop cx
  75.         pop bx
  76.         pop ax
  77.         popf
  78.         jmp dword ptr cs:[oldint]   ;chain to old INT
  79. end_resident:
  80. resident endp
  81.  
  82. resident_length equ end_resident-start_resident
  83. resident_offset equ start_resident-main+100h
  84.  
  85. ;The initialization part relocates the above stuff into the PSP segment to
  86. ;regain as much RAM as possible (see "The Programmer's Guide To The IBM PC"
  87. ;by Peter Norton for further details)
  88. init:
  89.         push cs
  90.         pop ds
  91.         mov ax,35h shl 8+inter
  92.         int 21h                  ;get actual INT 33h
  93.         cmp bx,psp_amount        ;pointing to our routine?
  94.         jnz install
  95.         mov ah,9
  96.         mov dx,offset Text ;yes, already installed: stop installation!
  97.         int 21h
  98.         mov ax,4c00h
  99.         int 21h                  ;terminate program
  100. Text    db 13,10,'Fixmouse already installed!',13,10,'$'
  101.  
  102. install:
  103.         mov word ptr cs:[oldint],bx   ;save old vector
  104.         mov word ptr cs:[oldint+2],es
  105.  
  106.         push cs                  ;do relocation
  107.         pop es
  108.         push cs
  109.         pop ds
  110.         mov si,resident_offset
  111.         mov di,psp_amount        ;let code start at CS:psp_amount
  112.         mov cx,resident_length
  113.         cld
  114.         rep movsb
  115.  
  116.         mov dx,psp_amount
  117.         mov ax,25h shl 8+inter
  118.         int 21h                 ;redirect INT 33h to our routine
  119.         mov ah,9
  120.         mov dx,offset aktiv     ;inform user
  121.         int 21h
  122.  
  123.         push cs
  124.         pop ds
  125.         mov dx,psp_amount+resident_length
  126.         int 27h                 ;terminate but stay resident
  127. aktiv   db 13,10,'Fixmouse for TurboPascal 6.0 - by Kai Rohrbacher ',13,10
  128.         db 13,10,'Fixmouse has been installed now!',13,10,'$'
  129. program ends
  130.         end main
  131.  
  132. ;THAT'S ALL FOLKS!!!!!!!!!!!
  133.