home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / asm_programming / TEST / LIGHTS.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-02-06  |  3.0 KB  |  109 lines

  1.         .radix 16
  2.      code       segment
  3.         model  small
  4.         assume cs:code, ds:code, es:code
  5.  
  6.         org 100h
  7.  
  8. len             equ offset last - begin
  9.  
  10. begin:
  11.         jmp     cut_hole
  12.         db      'ߥ.ÑîkådëMû$'
  13. cut_hole:  
  14.         mov     ax,cs                    ; reduce memory size     
  15.         dec     ax                           
  16.         mov     ds,ax                        
  17.         cmp     byte ptr ds:[0000],5a        
  18.         jne     abort                        
  19.         mov     ax,ds:[0003]                 
  20.         sub     ax,40                        
  21.         mov     ds:0003,ax
  22. Zopy_me:  
  23.         mov     bx,ax                    ; copy to claimed block  
  24.         mov     ax,es                        
  25.         add     ax,bx                       
  26.         mov     es,ax
  27.         mov     cx,len                   
  28.         mov     ax,ds                       
  29.         inc     ax
  30.         mov     ds,ax
  31.         lea     si,ds:[begin]            
  32.         lea     di,es:0100                  
  33.         rep     movsb                       
  34.                             
  35.         mov     [vir_seg],es        
  36.         mov     ax,cs                       
  37.         mov     es,ax
  38. Grab_21:                                     
  39.         cli
  40.         mov     ax,351Ch                   ; hook 1c (clock tick)
  41.         int     21h                     
  42.         mov     ds,[vir_seg]   
  43.         mov     ds:[old_1Ch],bx
  44.         mov     ds:[old_1Ch+2],es
  45.         mov     dx,offset lights
  46.         mov     ax,251Ch                
  47.         int     21h                     
  48.         sti                            
  49. abort:          int     20h
  50.  
  51.         
  52. lights:         
  53.         push    ds           ; save these            
  54.         push    ax
  55.         push    bx
  56.         push    dx
  57.         cmp     [click], 80d         ; after 80 clicks
  58.         je      one
  59.         cmp     [click], 160d        ; after 160 clicks
  60.         je      two
  61.         cmp     [click], 240d        ; after 240 clicks
  62.         je      three
  63.         cmp     [click], 0ffh        ; have we counted to 255?
  64.         je      clear
  65.         inc     [click]              ; increase click count
  66.         jmp     endme
  67. clear:          mov     [click], 00h         ; clear click count
  68.         mov     ax, 40h
  69.         mov     ds, ax
  70.         mov     bx, 17h              ; ds:bx = location o' flags
  71.         and     byte ptr [bx],0      ; clear keyboard flag(s)
  72.         jmp     endme
  73. one:            inc     [click]
  74.         mov     ax, 40h
  75.         mov     ds, ax
  76.         mov     bx, 17h
  77.         mov     byte ptr [bx],20h    ; set numlock flag
  78.         jmp     endme
  79. two:            inc     [click]
  80.         mov     ax, 40h
  81.         mov     ds, ax
  82.         mov     bx, 17h
  83.         mov     byte ptr [bx],40h    ; set caps lock flag
  84.         jmp     endme
  85. three:          inc     [click]
  86.         mov     ax, 40h
  87.         mov     ds, ax
  88.         mov     bx, 17h              
  89.         mov     byte ptr [bx],10h    ; set scroll lock flag
  90.         jmp     endme
  91.  
  92.  
  93. endme:       
  94.         pop     dx                         ; byebye
  95.         pop     bx                         ; restore shit
  96.         pop     ax
  97.         pop     ds
  98.         cli
  99.         db      0EAh                       ; jmp to old 1c 
  100. old_1Ch         dw  00h,00h                        ; in case someone else
  101. click           db  00h                            ; wants it
  102. vir_seg         dw  ?
  103.  
  104. last            db  090h                                   
  105.  
  106.  
  107. code            ends
  108.         end begin
  109.