Outils pour utilisateurs

Outils du site


back2root:tutoriaux:vga-avance-dac-part-3

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tutoriaux:vga-avance-dac-part-3 [2021/05/03 16:47] fraterback2root:tutoriaux:vga-avance-dac-part-3 [2023/01/08 00:39] (Version actuelle) frater
Ligne 1: Ligne 1:
-====== Tutoriaux: VGA Avancée - DAC - Part 3 ======+====== VGA Avancée - DAC - Part 3 ======
  
 ===== CopperList avancée ===== ===== CopperList avancée =====
Ligne 27: Ligne 27:
 Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 0x30 LineH LineL Red Green Blue Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 0x30 LineH LineL Red Green Blue
  
-Les bytes "LineH" et "LineL" sont les octets de poids fort et faible du mot qui défini la ligne "cible", celle-ci DOIT être inférieur à copper_maxrow, sans quoi l'excécution des copper s'arretent avec un code d'erreur.+Les bytes "LineH" et "LineL" sont les octets de poids fort et faible du mot qui défini la ligne "cible", celle-ci DOIT être inférieur à copper_maxrow, sans quoi l’exécution des copper s’arrêtent avec un code d'erreur.
  
 === EOC: 0xFF === === EOC: 0xFF ===
Ligne 91: Ligne 91:
         je    w2 }         je    w2 }
  
-start:asm {                            // protection+start:asm {                           // protection
         mov   al,0x05                 // error 1         mov   al,0x05                 // error 1
         cmp   cx,copper_maxrow        // line counter copper> max ?         cmp   cx,copper_maxrow        // line counter copper> max ?
         jb    start2                  // go         jb    start2                  // go
-        jmp    eocl }                  // exit+        jmp    eocl }                 // exit
  
 start2: asm { start2: asm {
-        lodsb                          // load copper list operand+        lodsb                         // load copper list operand
         cmp   al,0xFF                 // eocl ?         cmp   al,0xFF                 // eocl ?
         jne   start3         jne   start3
Ligne 123: Ligne 123:
 // ------------------------------------- GRADIENT // ------------------------------------- GRADIENT
 gradient: asm { gradient: asm {
-        mov    line_start,cx            // preserve line start+        mov    line_start,cx          // preserve line start
         lodsw         lodsw
-        mov    bh,al                   // reverse endian+        mov    bh,al                  // reverse endian
         mov   bl,ah         mov   bl,ah
-        mov   line_end,bx              // preserve line end+        mov   line_end,bx             // preserve line end
  
         // calculate the number of line between line_start and line_end         // calculate the number of line between line_start and line_end
         sub    bx,cx         sub    bx,cx
-        mov    line_delta,bx           // pct_max = line count between line_start and end+        mov    line_delta,bx          // pct_max = line count between line_start and end
  
-        lodsb                          // load red_end +        lodsb                         // load red_end 
-        shr    al,2                    // reduce to 6 bits only +        shr    al,2                   // reduce to 6 bits only 
-        mov    red_end,al              // preserve red target+        mov    red_end,al             // preserve red target
         mov    ah,al         mov    ah,al
  
-        mov    bl,red_prec                  // bl = red start +        mov    bl,red_prec            // bl = red start 
-        sub    al,bl                    // end - start +        sub    al,bl                  // end - start 
-        mov   red_step,al              // calculate Red Stepping +        mov   red_step,al             // calculate Red Stepping 
-        mov    red_prec,ah                  //+        mov    red_prec,ah            //
  
-        lodsb                          // load green_end+        lodsb                         // load green_end
         shr    al,2         shr    al,2
         mov    green_end,al         mov    green_end,al
         mov    ah,al         mov    ah,al
-        mov    bl,green_prec                // get green start+        mov    bl,green_prec          // get green start
         sub    al,bl         sub    al,bl
-        mov   green_step,al            // calculate green stepping+        mov   green_step,al           // calculate green stepping
         mov    green_prec,ah         mov    green_prec,ah
  
-        lodsb                          // load blue_end+        lodsb                         // load blue_end
         shr    al,2         shr    al,2
         mov    blue_end,al         mov    blue_end,al
Ligne 159: Ligne 159:
         sub    al,bl         sub    al,bl
         mov   blue_step,al         mov   blue_step,al
-        mov    blue_prec,ah }              // calculate Blue Stepping+        mov    blue_prec,ah }         // calculate Blue Stepping
  
 gr_start: asm { gr_start: asm {
-        inc    cx                      // cx = cx+1 +        inc    cx                     // cx = cx+1 
-        cmp   cx,line_end              // gradient complet ?+        cmp   cx,line_end             // gradient complet ?
         jb    gradient_hbl         jb    gradient_hbl
-        jmp    start  }                 // next operant+        jmp    start  }               // next operant
  
 gradient_hbl:asm { gradient_hbl:asm {
-        mov    dx,0x3da }              // read input state+        mov    dx,0x3da }             // read input state
 gr_in_retrace:asm  { gr_in_retrace:asm  {
-        in    al,dx                    // test if we are redrawing+        in    al,dx                   // test if we are redrawing
         test  al,1         test  al,1
         jne    gr_in_retrace }         jne    gr_in_retrace }
Ligne 180: Ligne 180:
  
         mov    ax,cx         mov    ax,cx
-        sub    ax,line_start            // pct_current(ax) = currentline(cx) - line_start +        sub    ax,line_start          // pct_current(ax) = currentline(cx) - line_start 
-        mov    bx,line_delta            // bx = line_start - line_end+        mov    bx,line_delta          // bx = line_start - line_end
  
         xor   dx,dx         xor   dx,dx
-        shl   ax,PRECIS                // increase precision+        shl   ax,PRECIS               // increase precision
         div   bx                      // pct_current / pct_max         div   bx                      // pct_current / pct_max
-        mov    bx,ax                   // bx = percentage 0..100+        mov    bx,ax                  // bx = percentage 0..100
  
         cli         cli
Ligne 199: Ligne 199:
         shr   ax,PRECIS         shr   ax,PRECIS
         add   al,red_prec         add   al,red_prec
-        out    dx,al                    // set RED to dac+        out    dx,al                  // set RED to dac
         mov    red_end,al         mov    red_end,al
  
Ligne 207: Ligne 207:
         shr   ax,PRECIS         shr   ax,PRECIS
         add   al,green_prec         add   al,green_prec
-        out    dx,al                     // set GREEN to dac+        out    dx,al                  // set GREEN to dac
         mov    green_end,al         mov    green_end,al
  
Ligne 215: Ligne 215:
         shr   ax,PRECIS         shr   ax,PRECIS
         add   al,blue_prec         add   al,blue_prec
-        out    dx,al                    // set BLUE to dac+        out    dx,al                  // set BLUE to dac
         mov    blue_end,al         mov    blue_end,al
         sti         sti
Ligne 224: Ligne 224:
 wait_line:asm  { wait_line:asm  {
         lodsw         lodsw
-        mov    bh,al                    // swap byte endian encoding craps +        mov    bh,al                  // swap byte endian encoding craps 
-        mov   bl,ah                    // bx = line word +        mov   bl,ah                   // bx = line word 
-        mov    dx,0x3da }              // input state+        mov    dx,0x3da }             // input state
  
 wait_next: asm { wait_next: asm {
-        inc    cx                      // cx = cx+1+        inc    cx                     // cx = cx+1
         cmp   cx,bx                   // current line>= wait_line ?         cmp   cx,bx                   // current line>= wait_line ?
         jae   wait_end }              // YES : next operand please         jae   wait_end }              // YES : next operand please
  
 in_retrace:asm  { in_retrace:asm  {
-        in    al,dx                    // read input state, test if we are redrawing+        in    al,dx                   // read input state, test if we are redrawing
         test  al,1         test  al,1
         jne    in_retrace }         jne    in_retrace }
Ligne 249: Ligne 249:
 set_color: asm { set_color: asm {
         cli         cli
-        lodsb                          // get color index+        lodsb                         // get color index
         mov   color,al         mov   color,al
         mov    dx,0x3c8         mov    dx,0x3c8
Ligne 255: Ligne 255:
         inc   dx                      // mov   dx,0x3c9         inc   dx                      // mov   dx,0x3c9
  
-        lodsb                          // get RED level+        lodsb                         // get RED level
         shr    al,2         shr    al,2
         mov   red_prec,al         mov   red_prec,al
-        out    dx,al                    // set RED to dac+        out    dx,al                  // set RED to dac
  
-        lodsb                          // get GREEN level+        lodsb                         // get GREEN level
         shr    al,2         shr    al,2
         mov   green_prec,al         mov   green_prec,al
-        out    dx,al                    // set GREEN to dac+        out    dx,al                  // set GREEN to dac
  
-        lodsb                          // get BLUE level+        lodsb                         // get BLUE level
         shr    al,2         shr    al,2
         mov   blue_prec,al         mov   blue_prec,al
-        out    dx,al                    // set BLUE to dac+        out    dx,al                  // set BLUE to dac
         sti         sti
         jmp   start }                 // get next operand         jmp   start }                 // get next operand
Ligne 276: Ligne 276:
         pop    si         pop    si
         pop    ds         pop    ds
-        mov   copper_error, al       // set error (if any)+        mov   copper_error, al        // set error (if any)
  
-        xor    al,al                   // normally we should restore whole DAC's status +        xor    al,al                  // normally we should restore whole DAC's status 
-        mov    dx,0x3c8                // but we only reset color 0 to black+        mov    dx,0x3c8               // but we only reset color 0 to black
         out    dx,al         out    dx,al
         inc    dx         inc    dx
-        out    dx,al                   // turn to RGB 0,0,0+        out    dx,al                  // turn to RGB 0,0,0
         out    dx,al         out    dx,al
         out    dx,al  }         out    dx,al  }
Ligne 315: Ligne 315:
 == Commentaire sur les sources == == Commentaire sur les sources ==
  
 +<WRAP center round info 95%>
 A cause des limitations du x86 concernant les jump conditionnels (near) il a fallut mettre en place un structure de type switch case. A cause des limitations du x86 concernant les jump conditionnels (near) il a fallut mettre en place un structure de type switch case.
  
-Le build-in assembler de borland C++ n'est pas capable de faire de sauts conditionnel au delà d'un delta de -126 +127; car l'oppérande n'est que de 2 octets, pour contourner ce problème il aurait fallut écrire le code assembleur .386 dans un fichier .asm et ensuite le linker au code C, ce qui aurait permis de réduire la "boucle" comme ceci:+Le build-in assembler de borland C++ n'est pas capable de faire de sauts conditionnel au delà d'un delta de -126 +127; car l'oppérande n'est que de 2 octets, pour contourner ce problème il aurait fallut écrire le code assembleur .386 dans un fichier .asm et ensuite le linker au code C, ce qui aurait permis de réduire la "boucle" comme ci-dessous. 
 + 
 +</WRAP>
  
 <code asm> <code asm>
Ligne 615: Ligne 618:
  
 #endif #endif
- 
- 
 </code> </code>
  
-<nspages tutoriaux -simpleList -h1 -exclude:start -textPages="Tutoriaux disponible">+<nspages back2root/tutoriaux -simpleList -h1 -exclude:start -textPages="Tutoriaux disponible">
  
  
back2root/tutoriaux/vga-avance-dac-part-3.1620053263.txt.gz · Dernière modification : 2021/05/03 16:47 de frater