home *** CD-ROM | disk | FTP | other *** search
/ PC Interdit / pc-interdit.iso / trainer / trainer.asm < prev    next >
Assembly Source File  |  1994-10-27  |  6KB  |  217 lines

  1. ;                ***                                ***
  2. ;                ***   Entraîneur pour *******      ***
  3. ;                ***                                ***
  4. ;                ***   (c) 1994 by DATA Becker      ***
  5. ;                ***                                ***
  6. ;                ***   Auteur: Boris Bertelsons     ***
  7. ;                ***                                ***
  8. ;                **************************************
  9. ;
  10. ;
  11.  
  12. .286
  13.   w equ word ptr
  14.   b equ byte ptr
  15. code segment public
  16. public insthand
  17. public handler21
  18. public reslim
  19. public oldint21
  20. public oldint65
  21. public signature
  22. public siglong
  23. public check_inst
  24.  
  25. assume cs:code,ds:code
  26. signature:  db 'MICRO APPLICATION'
  27. oldint21: dd 0
  28. oldint65: dd 0
  29. proced: dd ?
  30. siglong equ offset oldint21 - offset signature
  31.  
  32.  
  33. ;  *********************************************************************
  34. ;  ***                                                               ***
  35. ;  ***  Ici commencent les routines proprement dites de l'entraîneur ***
  36. ;  ***                                                               ***
  37. ;  *********************************************************************
  38.  
  39. ;  **********************************************************************
  40. ;  ***                                                                ***
  41. ;  ***  Nouvelle interruption 21h. La procédure teste si à l'endroit  ***
  42. ;  ***  indiqué de la mémoire se trouve l'instruction "in al,60h",    ***
  43. ;  ***  et la remplace le cas échéant par "int 65h" !                 ***
  44. ;  ***                                                                ***
  45. ;  **********************************************************************
  46. handler21 proc pascal
  47.   pushf
  48.   push bp
  49.   push ds
  50.   push bx
  51.   mov  bp,sp
  52.   mov  bx,[bp+10]  ; cs au moment de l'interruption en BX, DOS !!!
  53.            ; ATTENTION ! Dans TD [bp+16] !!!
  54.   add  bx,0366h    ; CS de la 1ère INT 21h + 2136h = CS de la routine du clavier
  55.   mov  ds,bx                      ; cs de la routine du clavier en ds
  56.   mov  bx,568Bh                   ; 8B56h = mov dx,[bp+06]
  57.   cmp  ds:word ptr [0005h],bx     ; motif présent dans la routine ?
  58.   jne  pas_changer
  59.   mov  ds:word ptr [0005h],9090h  ; écrire Int 65h !
  60.   mov  ds:word ptr [0007h],65CDh  ; écrire Int 65h!
  61. pas_changer:
  62.   pop  bx
  63.   pop  ds
  64.   pop  bp
  65.   popf
  66.   jmp dword ptr cs:oldint21       ; appelle l'ancienne Int 21h
  67. handler21 endp
  68.  
  69.  
  70. ;  *************************************************************************
  71. ;  ***                                                                   ***
  72. ;  ***  L'interruption 65h - Procédure, lit un caractère par "in al,60h" ***
  73. ;  ***  et teste si la touche correspondante a été définie dans          ***
  74. ;  ***  l'entraîneur. Si oui, les modifications de mémoire et les appels ***
  75. ;  ***  de procédure indiqués sont effectués. Vous devrez reporter ici   ***
  76. ;  ***  vos variables d'entraînement                                     ***
  77. ;  ***                                                                   ***
  78. ;  *************************************************************************
  79.  
  80. handler65 proc far
  81.   pushf
  82.   push bp
  83.   push ds
  84.   push bx
  85.   mov  bp,sp
  86.   mov  bx,[bp+10]  ; cs au moment de l'interruption en BX
  87.   in  al,60h       ; lit un caractère
  88.   cmp al,63        ; touche F5
  89.   je  Full_Shoots_j
  90.   cmp al,64        ; touche F6
  91.   je  Full_Lives_J
  92.   cmp al,65        ; touche F7
  93.   je Weapon_new_j  ;
  94.   cmp al,66        ; touche F6
  95.   je Weapon_new_j  ;
  96.   cmp al,67        ; touche F9
  97.   je Weapon_new_j  ;
  98.   cmp al,68        ; touche F10
  99.   je  More_Points_J
  100.  
  101. Fin_keyb:
  102.   pop bx
  103.   pop ds
  104.   pop bp
  105.   popf
  106.   iret
  107.  
  108. Full_Shoots_j:
  109.   jmp Full_Shoots
  110. Full_Lives_j:
  111.   jmp Full_Lives
  112. More_Points_j:
  113.   jmp More_Points
  114. Weapon_new_j:
  115.   jmp Weapon_new
  116.  
  117. Full_Shoots:
  118.   pushf
  119.   PUSHA
  120.   sub  bx,0                     ; CS déjà OK
  121.   mov word ptr proced+2,bx
  122.   mov  bx,1401h                 ; es:[bx]  =  14EF:1401
  123.   mov word ptr proced,bx
  124. ;--------
  125.   mov ds:byte ptr [0DA3h],20h
  126.   mov ax,20h
  127.   push ax
  128.   call dword ptr [proced]
  129.   POPA
  130.   popf
  131.   jmp Fin_keyb
  132.  
  133. Full_Lives:
  134.   pushf
  135.   pusha
  136.   sub  bx,0  ;
  137.   mov word ptr proced+2,bx
  138.   mov  bx,1317h                 ; es:[bx]  =  14EF:1317
  139.   mov word ptr proced,bx
  140. ;-----------
  141.   mov ds:byte ptr [0DA3h],0009
  142.   mov ax,9
  143.   push ax
  144.   call dword ptr [proced]
  145.   popa
  146.   popf
  147.   jmp Fin_keyb
  148.  
  149. Weapon_new:
  150.   pushf
  151.   pusha
  152.   sub  bx,0  
  153.   mov word ptr proced+2,bx
  154.   mov  bx,1454h                 ; es:[bx]  =  14EF:1454
  155.   mov word ptr proced,bx
  156. ;-----------
  157.   sub al,65
  158.   mov ah,0
  159.   mov ds:byte ptr [0DA2h],al
  160.   push ax
  161.   call dword ptr [proced]
  162.   popa
  163.   popf
  164.   jmp Fin_keyb
  165.  
  166. More_Points:
  167.   pushf
  168.   pusha
  169.   sub  bx,0  
  170.   mov word ptr proced+2,bx
  171.   mov  bx,1BD0h                 ; es:[bx]  =  14EF:1BD0
  172.   mov word ptr proced,bx
  173. ;-----------
  174.   mov ax,1000
  175.   push ax
  176.   call dword ptr [proced]
  177.   popa
  178.   popf
  179.   jmp Fin_keyb
  180.  
  181. handler65 endp
  182.  
  183. insthand proc pascal
  184. reslim label byte
  185.     push ds
  186.   pop ds
  187.     mov ax,3521h            ; sauve l'ancienne INT 21
  188.   int 21h
  189.   mov w oldint21,bx
  190.   mov w oldint21 + 2,es
  191.     mov ax,3565h            ; sauve l'ancienne INT 65h 
  192.   int 21h
  193.   mov w oldint65,bx
  194.   mov w oldint65 + 2,es
  195.   mov ax,2521h                  ; détournement de l'INT 21h
  196.   lea dx,handler21
  197.   int 21h
  198.   mov ax,2565h                  ; INT 65h sur routine de clavier personnelle
  199.   lea dx,handler65
  200.   int 21h
  201.     ret
  202. insthand endp
  203.  
  204. check_inst proc near
  205.   mov ax,3521h                  ; lit le vecteur d'interruption
  206.   int 21h
  207.   mov di,bx
  208.   mov si,offset signature
  209.   mov di,si
  210.   mov cx,siglong
  211.   repe cmpsb                    ; teste la signature
  212.     ret
  213. check_inst endp
  214.  
  215. code ends
  216. end
  217.