home *** CD-ROM | disk | FTP | other *** search
/ Various Unprotection Examples / unprotect.zip / unprotect / SPYHUNT / SPYHUNT.ASM < prev    next >
Assembly Source File  |  1986-05-12  |  13KB  |  300 lines

  1.         page    ,132
  2.         title   Spy Hunter
  3.  
  4. ;spyhunt.asm -- loader program for Spy Hunter
  5. ; The Ross DOS
  6. ; 5-27-86
  7. ; From a great southern Engineering / Science college
  8.  
  9. CR      equ     13                      ;carriage return
  10. LF      equ     10                      ;line feed
  11.  
  12. cseg    segment para public 'code'
  13.         assume cs:cseg,ss:stack         ;already set by DOS loader
  14.  
  15. cosmic  proc    far                     ;entry point from dos
  16.         push    ds                      ;set up the stack to
  17.         xor     ax,ax                   ; the double word vector so the
  18.         push    ax                      ; far return will go back to dos
  19.  
  20.         mov     ax,dseg                 ;set up addressability to
  21.         mov     ds,ax                   ; the data segment
  22.         assume  ds:dseg                 ;tell the assembler what I did
  23.  
  24. ;switch to the color monitor
  25.  
  26.         push    es                      ;save the extra segment
  27.         mov     ax,0                    ;set the
  28.         mov     es,ax                   ; extra segment to 0
  29.         mov     bx,449h                 ;offset
  30.         mov     byte ptr es:[bx],2      ;80-colomn text, no color, CGA
  31.         pop     es                      ;restore the extra segment
  32.  
  33. ;set video mode
  34.  
  35.         mov     al,2                    ;mode, text 80x25
  36.         mov     ah,0                    ;service 0 of int 10h
  37.         int     10h                     ;set video mode
  38.  
  39. ;turn off the screen
  40.  
  41.         mov     dx,3d8h                 ;CGA port to set mode
  42.         mov     al,0001b                ;set bit 3 off to turn video off
  43.         out     dx,al                   ;set new mode
  44.  
  45. ;display text
  46.  
  47.         mov     dx,offset text1         ;data address
  48.         mov     ah,9h                   ;service 9h of int 21h
  49.         int     21h                     ;display text
  50.  
  51. ;turn on the screen
  52.  
  53.         mov     dx,3d8h                 ;CGA port to set mode
  54.         mov     al,1001b                ;set bit 3 on to turn video on
  55.         out     dx,al                   ;set new mode
  56.  
  57. ;wait for a key
  58.  
  59.         mov     ah,8h                   ;service 8h of int 21h
  60.         int     21h                     ;wait for a key
  61.  
  62. ;display text
  63.  
  64.         mov     dx,offset text2         ;data address
  65.         mov     ah,9h                   ;service 9h of int 21h
  66.         int     21h                     ;display text
  67.  
  68. ;modify memory block allocated by DOS
  69.  
  70.                                         ;the extra segment is already set
  71.         mov     bx,10h                  ;skip to the end of the PSP
  72.         mov     ah,4ah                  ;service 4ah of int 21h
  73.         int     21h                     ;free memory
  74.  
  75. ;allocate enough memory
  76.  
  77.         mov     bx,gsize                ;memory game program needs
  78.         mov     ah,48h                  ;service 48h of int 21h
  79.         int     21h                     ;allocate memory
  80.         jnc     sabs                    ;jump if no error
  81.         jmp     err1                    ;jump on error
  82. sabs:   mov     buffer,ax               ;save allocated buffer segment
  83.  
  84. ;open the program file
  85.  
  86.         mov     dx,offset file          ;data address
  87.         mov     al,0                    ;read only
  88.         mov     ah,3dh                  ;service 3dh
  89.         int     21h                     ; of int 21h
  90.         jnc     rtf                     ;jump if no error
  91.         jmp     err2                    ;jump on error
  92.  
  93. ;read the file into memory
  94.  
  95. rtf:    mov     bx,ax                   ;bx is the file handle
  96.         mov     ax,ds                   ;save the data segment
  97.         mov     es,ax                   ; using the extra segment
  98.  
  99.         mov     cx,28                   ;read in 28 tracks (112 KB)
  100.         mov     ax,buffer               ;get the buffer's segment address
  101.         mov     ds,ax                   ;ds now starts at the buffer
  102.  
  103. rfm:    push    cx                      ;save the count
  104.         mov     dx,0                    ;buffer offset is 0
  105.         mov     cx,1000h                ;read in 4 KB of data
  106.         mov     ah,3fh                  ;service 3fh of int 21h
  107.         int     21h                     ;read in part of the file
  108.         pop     cx                      ;restore the count
  109.         jnc     ids                     ;jump on no error
  110.         jmp     err3                    ;jump on error
  111. ids:    mov     ax,ds                   ;increment the data segment
  112.         add     ax,100h                 ; by 100h
  113.         mov     ds,ax                   ; which is 4 KB (absolute address)
  114.         loop    rfm                     ;loop and finish the count
  115.  
  116. ;restore the data segment
  117.  
  118.         mov     ax,es                   ;get the data segment from
  119.         mov     ds,ax                   ; the extra sement
  120.  
  121. ;close the file
  122.  
  123.         mov     ah,3eh                  ;service 3ef of int 21h
  124.         int     21h                     ;close the file
  125.         jnc     wuds                    ;jump on no error
  126.         jmp     err4                    ;jump on error
  127.  
  128. ;wait until the drive stops
  129.  
  130. wuds:   mov     ax,0                    ;set the
  131.         mov     es,ax                   ; extra segment to beginning of memory
  132. wait:   mov     al,es:[43fh]            ;get the byte which has the drive status
  133.         cmp     al,0                    ;is it zero?
  134.         jne     wait                    ;no, then loop until it is
  135.  
  136. ;reset the int 8h vector
  137.  
  138.         mov     ax,0                    ;set the
  139.         mov     es,ax                   ; extra segment to beginning of memory
  140.         mov     bx,8h*4                 ;vector offset
  141.         mov     ax,int8h                ;offset
  142.         mov     cx,rom                  ;segment
  143.         mov     es:[bx],ax              ;reset vector offset
  144.         mov     es:[bx+2],cx            ;reset vector segment
  145.  
  146. ;reset the int 9h vector
  147.  
  148.         mov     ax,0                    ;set the
  149.         mov     es,ax                   ; extra segment to beginning of memory
  150.         mov     bx,9h*4                 ;vector offset
  151.         mov     ax,int9h                ;offset
  152.         mov     cx,rom                  ;segment
  153.         mov     es:[bx],ax              ;reset vector offset
  154.         mov     es:[bx+2],cx            ;reset vector segment
  155.  
  156. ;reset the int 16h vector
  157.  
  158.         mov     ax,0                    ;set the
  159.         mov     es,ax                   ; extra segment to beginning of memory
  160.         mov     bx,16h*4                ;vector offset
  161.         mov     ax,int16h               ;offset
  162.         mov     cx,rom                  ;segment
  163.         mov     es:[bx],ax              ;reset vector offset
  164.         mov     es:[bx+2],cx            ;reset vector segment
  165.  
  166. ;reset the int 1bh vector
  167.  
  168.         mov     ax,0                    ;set the
  169.         mov     es,ax                   ; extra segment to beginning of memory
  170.         mov     bx,1bh*4                ;vector offset
  171.         mov     ax,int1ch               ;offset
  172.         mov     cx,rom                  ;segment
  173.         mov     es:[bx],ax              ;reset vector offset
  174.         mov     es:[bx+2],cx            ;reset vector segment
  175.  
  176. ;reset the int 1ch vector
  177.  
  178.         mov     ax,0                    ;set the
  179.         mov     es,ax                   ; extra segment to beginning of memory
  180.         mov     bx,1ch*4                ;vector offset
  181.         mov     ax,int1ch               ;offset
  182.         mov     cx,rom                  ;segment
  183.         mov     es:[bx],ax              ;reset vector offset
  184.         mov     es:[bx+2],cx            ;reset vector segment
  185.  
  186. ;move the program down to low memory
  187.  
  188.         push    ds
  189.         mov     si,0                    ;source offset
  190.         mov     di,0ff1h                ;destination offset
  191.         mov     ax,buffer               ;set the data segment
  192.         mov     ds,ax                   ; to the buffer
  193.         mov     ax,100h                 ;set the extra segment
  194.         mov     es,ax                   ; to low memory
  195.         mov     cx,0e000h               ;move 56 KB
  196.     rep movsb