IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

x86 16-bits Assembleur Discussion :

[Tetris] Avancement au 12/08


Sujet :

x86 16-bits Assembleur

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2015
    Messages
    52
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2015
    Messages : 52
    Points : 36
    Points
    36
    Par défaut [Tetris] Avancement au 12/08
    Juste pour vous montrer comment j'ai avancé aujourd'hui.

    J'arrive à dessiner tous les blocs de manière aléatoire (mot que je viens d'apprendre sur le chat). Demain je vais essayer la rotation (si quelqu'un pouvait me mettre sur le chemin pour les keyboard interrupt ça serait sympa) et encore une fois merci à vous.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    ;=============================================================================
    ; 32-bit Assembly LES3
    ;=============================================================================
    IDEAL
    P386
    MODEL FLAT, C
    ASSUME cs:_TEXT,ds:FLAT,es:FLAT,fs:FLAT,gs:FLAT
     
    ;=============================================================================
    ; CODE
    ;=============================================================================
    CODESEG
     
    PROC setVideoMode
        ARG mode RETURNS eax
        mov     eax, [mode]
        int     10h
     
        ret
    ENDP setVideoMode
     
    PROC waitKey
        mov     eax, 0
        int     16h
     
        ret
    ENDP waitKey
     
    ; Draw a rectangle at the center of the screen.
    ; W, H passed on stack.
    PROC drawRect
        ARG w:dword, h:dword
        USES eax, ebx, ecx, edx, esi, edi
     
        ; Calculate posX
        mov     eax, [w]
        neg     eax
        add     eax, 320
        shr     eax, 1
        mov     ebx, eax    ; posX is in EBX now
     
        ; Calculate posY
        mov     eax, [h]
        neg     eax
        add     eax, 200
        shr     eax, 1      ; and posY is in EAX
     
        ; Calculate offset of top-left corner
        mov     edx, 320
        mul     edx         ; EAX = posY * SCREENW
        add     eax, ebx    ; EAX now conatins start offset of rectangle
        add     eax, 0a0000h
        push    eax         ; store for left vertical line drawing
     
        ; Draw upper horizontal line
        mov     edi, eax
        mov     ecx, [w]    ; rect W
        mov     al, 1       ; color
        rep     stosb       ; draw
     
        dec     edi
        mov     ebx, edi    ; EBX now contains the start of the right vertical line
     
        ; Draw left vertical line
        pop     edi
        push    ebx         ; store EBX for drawing the right vertical line  
        mov     ecx, [h]    ; rect H
    @@loopLeftLine:
        mov     [edi], al   ; set pixel
        add     edi, 320    ; jump to next pixel (on next line)
        dec     ecx
        jnz     @@loopLeftLine
     
        sub     edi, 320
        mov     ebx, edi    ; EBX now conatins the start of the bottom horizontal line
     
        ; Draw right vertical line
        pop     edi
        push    ebx         ; store EBX for drawing bottom horizontal line
        mov     ecx, [h]    ; rect H
    @@loopRightLine:
        mov     [edi], al   ; set pixel
        add     edi, 320    ; jump to next pixel (on next line)
        dec     ecx
        jnz     @@loopRightLine
     
        ; Draw bottom horizontal line
        pop     edi
        mov     ecx, [w]    ; rect W
        rep     stosb       ; draw
     
        ; done
        ret
    ENDP drawRect
     
     
    ; ================
    ; Start of program
    ; ================
    PROC main
        sti                 ; set The Interrupt Flag
        cld                 ; clear The Direction Flag
     
        push    ds
        pop     es
     
        call    setVideoMode, 13h
     
        mov     edi, 0a0000h
     
        ; setup colors
        mov     esi, offset pal     ; set the palette (DAC) address
        mov     ecx, 2 * 3          ; set color 0 and 1 (2 indexes in total, 2 * 3 bytes)
        mov     dx, 03c8h           ; VGA DAC set port
        mov     al, 0               ; set start color index
        out     dx, al
        inc     dx
        rep     outsb
     
        ; draw
        add     edi, 320*10 + 160
        mov     [byte ptr edi], 1
     
         call    drawRect, 82, 162
     
        ; wait
        call    waitKey
     
        call    setVideoMode, 3h
     
        mov     eax, 4c00h      ; AH = 4Ch - Exit To DOS
        int     21h             ; DOS INT 21h
    ENDP main
     
    ;=============================================================================
    ; DATA
    ;=============================================================================
    DATASEG
     
    pal db 63, 0, 0, 63, 63, 63
     
    ;=============================================================================
    ; STACK
    ;=============================================================================
    STACK 10000h
     
    END main

  2. #2
    Responsable Systèmes


    Homme Profil pro
    Gestion de parcs informatique
    Inscrit en
    Août 2011
    Messages
    17 440
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Gestion de parcs informatique
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Août 2011
    Messages : 17 440
    Points : 43 082
    Points
    43 082
    Par défaut
    Regardes du coté de int 16h
    Ma page sur developpez.com : http://chrtophe.developpez.com/ (avec mes articles)
    Mon article sur le P2V, mon article sur le cloud
    Consultez nos FAQ : Windows, Linux, Virtualisation

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2015
    Messages
    52
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2015
    Messages : 52
    Points : 36
    Points
    36
    Par défaut
    merci pour ta reponse rapide ca ma permis d'avance mais jai absolument envie d'utiliser les flech de mon clavier mais je trouve pas le code ascii pour les utiliser ??

  4. #4
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2015
    Messages
    52
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2015
    Messages : 52
    Points : 36
    Points
    36
    Par défaut
    jai trouver je vous montre le code apres

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Makefile] [Avancé]Récupération de dépendances
    Par Ruok dans le forum Systèmes de compilation
    Réponses: 4
    Dernier message: 06/02/2004, 12h52
  2. [JSP] thread ? Message d'avancement des operations en cours
    Par buffyann dans le forum Servlets/JSP
    Réponses: 14
    Dernier message: 18/12/2003, 11h39
  3. Réponses: 14
    Dernier message: 01/09/2003, 22h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo