home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / uprotect.zip / SPYHUNT.ASM < prev    next >
Assembly Source File  |  1989-11-26  |  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                           ;move it...
  197.  
  198.         mov     si,0                    ;source offset
  199.         mov     di,0ff1h                ;destination offset
  200.         mov     ax,ds                   ;get the data segment
  201.         add     ax,0e00h                ; and inc it
  202.         mov     ds,ax                   ; 56KB up memory
  203.         mov     ax,es                   ;get the extra segment
  204.         add     ax,0e00h                ; and inc it
  205.         mov     es,ax                   ; 56KB up memory
  206.         mov     cx,0e000h               ;move 56 KB
  207.     rep movsb                           ;move it...
  208.         pop     ds
  209.  
  210. ;set the register for the program
  211.  
  212.         mov     ax,200h                 ;set the
  213.         mov     ds,ax                   ; data segment to 200h
  214.         mov     es,ax                   ; extra segment to 200h
  215.         mov     ax,1e00h                ;set the
  216.         mov     ss,ax                   ; stack segment to 1e00h
  217.         mov     sp,1ff0h                ;set the stack pointer to 200h
  218.  
  219. ;run the program
  220.  
  221.         sti
  222.         db      0eah,0,10h,0,1
  223.  
  224. ;error # 1 -- memory allocation
  225.  
  226. err1:   lea     dx,error1               ;data address
  227.         mov     ah,9h                   ;service 9h of int 21h
  228.         int     21h                     ;display text
  229.         jmp     done
  230.  
  231. ;error # 2 -- file open error
  232.  
  233. err2:   lea     dx,error2               ;data address
  234.         mov     ah,9h                   ;service 9h of int 21h
  235.         int     21h                     ;display text
  236.         jmp     done
  237.  
  238. ;error # 3 -- file read error
  239.  
  240. err3:   mov     ax,es                   ;restore the
  241.         mov     ds,ax                   ; data segment
  242.         lea     dx,error3               ;data address
  243.         mov     ah,9h                   ;service 9h of int 21h
  244.         int     21h                     ;display text
  245.         jmp     done
  246.  
  247. ;error # 4 -- file close error
  248.  
  249. err4:   lea     dx,error4               ;data address
  250.         mov     ah,9h                   ;service 9h of int 21h
  251.         int     21h                     ;display text
  252.  
  253. done:   ret                             ;return to DOS
  254. cosmic  endp
  255. cseg    ends
  256.  
  257. dseg    segment para public 'data'
  258.  
  259. text1   db      'Spy Hunter',CR,LF
  260.         db      '(C) Copyright 1984 by Bally Midway',CR,LF,CR,LF
  261.         db      'Broken by The Ross DOS  5-27-86',CR,LF,CR,LF
  262.         db      'Uses file SPYHUNT.PRG',CR,LF
  263.         db      'Requires DOS 2.XX or 3.XX',CR,LF
  264.         db      'Requires 120k of free memory',CR,LF
  265.         db      'Requires a IBM compatible color graphics adapter',CR,LF,CR,LF
  266.         db      'This program does the following:',CR,LF
  267.         db      ' gets loaded into high memory',CR,LF
  268.         db      ' allocates 120 KB of RAM (enough to load SPYHUNT.PRG into)',CR,LF
  269.         db      ' loads SPYHUNT.PRG into the allocated block',CR,LF
  270.         db      ' sets interupts 8h,9h,10,16h,1bh,1ch to their initial ROM values',CR,LF
  271.         db      ' moves the program to 0:100h (low memory)',CR,LF
  272.         db      ' sets the registers to their required initial values',CR,LF
  273.         db      ' executes the program by doing a far jump to 100:1000h',CR,LF,CR,LF
  274.         db      'Since this game provides no method to return to DOS (and infact destroys DOS',CR,LF
  275.         db      'when moved to low memory), a reboot or power off is required to quit.',CR,LF,CR,LF
  276.         db      'To stop now, press Crtl-Break.',CR,LF,CR,LF
  277.         db      '* Press any key to continue *','$'
  278. text2   db      CR,LF,CR,LF
  279.         db      'Loading...$'
  280. file    db      'SPYHUNT.PRG',0
  281. error1  db      CR,LF,'ERROR: Cannot allocate enough memory',CR,LF,'$'
  282. error2  db      CR,LF,'ERROR: Cannot open file SPYHUNT.PRG',CR,LF,'$'
  283. error3  db      CR,LF,'ERROR: Cannot read file SPYHUNT.PRG',CR,LF,'$'
  284. error4  db      CR,LF,'ERROR: Cannot close file SPYHUNT.PRG',CR,LF,'$'
  285. buffer  dw      ?                       ;holds the buffer segment
  286. int8h   dw      0fea5h                  ;offset of int 1ch
  287. int9h   dw      0e987h                  ;offset of int 1ch
  288. int16h  dw      0e82eh                  ;offset of int 16h
  289. int1bh  dw      0ff53h                  ;offset of int 1ch
  290. int1ch  dw      0ff53h                  ;offset of int 1ch
  291. rom     dw      0f000h                  ;segment ROM starts at
  292. gsize   dw      1d4ch+100h              ;number of paragraphs game program needs
  293. gjump   dd      ?
  294. dseg    ends
  295.  
  296. stack   segment para stack 'stack'
  297.         db      64 dup("stack   ")      ;256 word stack area
  298. stack   ends
  299.         end     cosmic                  ;enter at entpt from DOS
  300.