Ce programme vous aide à manipuler les interuptions du système.
1- Vous montre une technique en mode texte - comme si on est en mode graphique - pour effacer l'écran.
2- Programme vos propres routines d'intérruptions - ici routine clavier.
3- Sauvegarer l'ancien routines, et la réstorée à la fin du programme.
4- Comment faire la gestion de l'écran.
5- Une téchnique pour faire une animation des caractères. une tombée. et un éclattement.
le programme est écrit pour L'Assembleur MASM 2.0, et n'includ aucun *.inc
il s'execute sur des machines trés lorde, comme le 3.86, ou P1 maximum, sur des machines rapides il ne serrait pas visible.
trés simple à comprendre.
Source / Exemple :
TOUCH_ESC EQU 129 TOUCH_FIN EQU 1 CAPACITE EQU 2*80*25 ECRAN EQU 0B800H pile segment stack db 32 dup (0) pile ends extra segment extra ends data segment AUSSI DB 0 BOOM DB "\|/-\***" UNO db "AZERTYUIOP" DUE db "QSDFGHJKLM" TRE db "WXCVBN" TOUMOT db 0 scoor db 0 GAME db 13,10,"************ GAME OVER *************|",13,10 DB " Votre scoor est : $" effac db 13,13,13,10," Mon 1Sr jeux",13,10 db " Aprendre les touches du clavier",13,10 db " jeux.asm (c) by Madani-2001 $" MES_END db " POITS . c'est BON ", 13,10," Merci FIN " DB " . Veulez-vous quiter ? (Y/N) $" LETTRE DB "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIKLMNOPQRSTUVWXYZ" DB "ABCDEFGHIJKLMNOPQRSTUVWYZABCDFGHIJKLMNOPQSTUVWXYZ" MOT db ? Temps dw 310 v_al db ? v_dl db ? colon db ? page_cours db ? touche db 0 clavier db 1 touch_ascii equ this dword cent db 30h dixenes db 30h unit db 30h finish db "$" INT9_PTR equ this dword int9_ofs dw 0 int9_seg dw 0 data ends code segment assume cs:code, ds:data, ss:pile, es:extra PRINC PROC FAR mov ax, data mov ds, ax mov ax, ECRAN mov es, ax lEA DX, effac mov ah, 9 int 21h mov ah,1 int 21h mov ah, 0fh int 10h mov page_cours, bh xor di, di mov al, 20h mov ah, 74h mov cx, CAPACITE cld aayyy: STOSW xor dx, dx azert: dec dx jnz azert dec cx dec cx jnz aayyy lea dx, effac mov ah, 9 int 21h mov ax, 3509h int 21h mov int9_ofs, bx mov int9_seg, es mov bx, 09Ffh grd1: mov cx, 0ffffh ptt1: loop ptt1 dec bx jnz grd1 mov ax, ECRAN mov es, ax xor di, di mov al, 20h mov ah, 074h mov cx, CAPACITE cld rep STOSW push ds push cs pop ds mov dx, offset int09h mov ax, 2509h int 21h pop ds AFFICHAGE: cmp clavier, 0 je t_fin1 ; **************************************** mov ah, 2ch int 21h mov al, dl cmp dl, 79 ja corige SUITE: mov Si, offset LETTRE XOR AH, AH ADD SI, AX MOV al, [SI] mov mot, al mov colon, dl jmp ssaut t_fin1: jmp fin1 corige: push ax mov al, dl xor ah, ah mov dl, 80 div dl mov dl, ah pop ax jmp suite ssaut: xor dh, dh encor: mov bh, page_cours mov dl, colon mov ah, 02 int 10h mov ah, 2 mov dl, MOT int 21h mov dl, colon mov ah, 2 int 10h mov bx, Temps popop: mov cx, 0ffffh azqs: loop azqs dec bx jnz popop mov dl, 20h mov ah, 2 int 21h jmp temrre encor0: jmp encor temrre: ; ------------------------------------------------ push si push bx mov bl, touche cmp bl, 144 jb faute cmp bl, 153 ja suite0 sub bl, 144 xor bh, bh lea si, uno add si, bx mov bl, [SI] mov toumot, bl faute:jmp sortie suite0:cmp bl, 158 jb faute cmp bl, 167 ja suite2 sub bl, 158 xor bh, bh lea si, due add si, bx mov bl, [SI] MOV TOUMOT, BL sortie:jmp sortie2 suite2:cmp bl, 172 jb faute cmp bl, 177 ja faute sub bl, 172 xor bh, bh lea si, tre add si, bx mov bl, [SI] mov toumot, bl sortie2: pop bx pop si ; ------------------------------------------- mov bl, toumot cmp bl, mot je bravo AHMED: inc dh cmp dh, 25 jne encor0 jmp GamOvr ; ***************************************** bravo: mov al, scoor inc al mov scoor, al mov CX, 8 lea di, BOOM ECLAT: mov dl, colon mov ah, 2 int 10h PUSH CX mov bx, 80 ppp: mov cx, 0ffffh aqs: loop aqs dec bx jnz ppp POP CX mov ah, 2 mov DL, [DI] int 21h inc di LOOP ECLAT mov dl, colon mov ah, 2 int 10h mov dl, 20h mov ah, 2 int 21h mov bx, temps DEC BX mov temps, bx jmp AFFICHAGE GamOvr: lEA DX, GAME mov ah, 9 int 21h mov bx, 999 popo1p: mov cx, 0ffffh azq1s: loop azq1s dec bx jnz popo1p fin1: mov dl, scoor mov al, dl xor ah, ah mov dl, 10 div dl add ah, 30h mov unit, ah xor ah, ah mov dl, 10 div dl add ah, 30h mov dixenes, ah add al,30h mov cent, al lea dx, touch_ascii mov ah, 9 int 21h fin: push ds cli mov ax, 2509h mov dx, int9_ofs mov ds, int9_seg int 21h pop ds lea dx, mes_end mov ah, 9 int 21h mov ax, 4c00h int 21h PRINC ENDP INT09H PROC FAR push ax in al, 60h mov ds:touche, al cmp al, TOUCH_FIN jne i9_end0 mov ds:clavier, 0 jmp i9_end i9_end0: cmp al,TOUCH_ESC JNE i9_end mov ds:clavier, 0 i9_end: pop ax jmp [int9_ptr] INT09H ENDP CODE ENDS END PRINC
Conclusion :
C'est un programme DOS ........
Pour compiler ce programme il faut :
1- avoire les deux executables : TASM.EXE , et TLINK.EXE.
2- executez la commande :
TASM Nom_Fichier.asm
TLINK Nom_fichier.OBJ
/* Le fichioer *.OBJ est le résultat du TASM.EXE sur le *.asm */
/* Le fichier *.exe est le résultats du TLINK.exe sur le *.obj */
3- Ce programme ne s'éxecute que sous le mode MS-DOS.
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.