Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
tutoriaux:vga-avance-dac-part-3 [2021/05/03 16:34] – frater | back2root:tutoriaux:vga-avance-dac-part-3 [2023/01/08 00:39] (Version actuelle) – frater | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== | + | ====== 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 " | + | Les bytes " |
=== EOC: 0xFF === | === EOC: 0xFF === | ||
Ligne 91: | Ligne 91: | ||
je w2 } | je w2 } | ||
- | start:asm { // protection | + | start:asm { |
mov | mov | ||
cmp | cmp | ||
jb start2 | jb start2 | ||
- | jmp eocl } // exit | + | jmp eocl } |
start2: asm { | start2: asm { | ||
- | lodsb // load copper list operand | + | lodsb |
cmp | cmp | ||
jne | jne | ||
Ligne 123: | Ligne 123: | ||
// ------------------------------------- GRADIENT | // ------------------------------------- GRADIENT | ||
gradient: asm { | gradient: asm { | ||
- | mov line_start, | + | mov line_start, |
lodsw | lodsw | ||
- | mov bh,al | + | mov bh,al // reverse endian |
mov bl,ah | mov bl,ah | ||
- | mov | + | mov |
// 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, | + | mov line_delta, |
- | lodsb // load red_end | + | lodsb |
- | shr al,2 // reduce to 6 bits only | + | shr al,2 |
- | mov red_end, | + | mov red_end, |
mov ah,al | mov ah,al | ||
- | mov bl, | + | mov bl, |
- | sub al,bl // end - start | + | sub al,bl // end - start |
- | mov | + | mov |
- | mov red_prec, | + | mov red_prec, |
- | lodsb // load green_end | + | lodsb |
shr al,2 | shr al,2 | ||
mov green_end, | mov green_end, | ||
mov ah,al | mov ah,al | ||
- | mov bl, | + | mov bl, |
sub al,bl | sub al,bl | ||
- | mov | + | mov |
mov green_prec, | mov green_prec, | ||
- | lodsb // load blue_end | + | lodsb |
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 | mov | ||
- | mov blue_prec, | + | mov blue_prec, |
gr_start: asm { | gr_start: asm { | ||
- | inc cx // cx = cx+1 | + | inc cx |
- | cmp | + | cmp |
jb gradient_hbl | jb gradient_hbl | ||
- | jmp start } | + | jmp start } |
gradient_hbl: | gradient_hbl: | ||
- | mov dx,0x3da } // read input state | + | mov dx,0x3da } |
gr_in_retrace: | gr_in_retrace: | ||
- | in al,dx // test if we are redrawing | + | in al,dx |
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, | + | sub ax, |
- | mov bx, | + | mov bx, |
xor dx,dx | xor dx,dx | ||
- | shl | + | shl |
div | div | ||
- | mov bx,ax | + | mov bx,ax // bx = percentage 0..100 |
cli | cli | ||
Ligne 199: | Ligne 199: | ||
shr | shr | ||
add | add | ||
- | 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 | shr | ||
add | add | ||
- | out dx,al | + | out dx,al // set GREEN to dac |
mov green_end, | mov green_end, | ||
Ligne 215: | Ligne 215: | ||
shr | shr | ||
add | add | ||
- | 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: | wait_line: | ||
lodsw | lodsw | ||
- | mov bh,al // swap byte endian encoding craps | + | mov bh,al // swap byte endian encoding craps |
- | mov | + | mov |
- | mov dx,0x3da } // input state | + | mov dx,0x3da } |
wait_next: asm { | wait_next: asm { | ||
- | inc cx // cx = cx+1 | + | inc cx |
cmp | cmp | ||
jae | jae | ||
in_retrace: | in_retrace: | ||
- | in al,dx // read input state, test if we are redrawing | + | in al,dx |
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 |
mov | mov | ||
mov dx,0x3c8 | mov dx,0x3c8 | ||
Ligne 255: | Ligne 255: | ||
inc | inc | ||
- | lodsb // get RED level | + | lodsb |
shr al,2 | shr al,2 | ||
mov | mov | ||
- | out dx,al // set RED to dac | + | out dx,al // set RED to dac |
- | lodsb // get GREEN level | + | lodsb |
shr al,2 | shr al,2 | ||
mov | mov | ||
- | out dx,al // set GREEN to dac | + | out dx,al // set GREEN to dac |
- | lodsb // get BLUE level | + | lodsb |
shr al,2 | shr al,2 | ||
mov | mov | ||
- | 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 | + | mov |
- | xor al,al | + | xor al,al // normally we should restore whole DAC's status |
- | mov dx, | + | mov dx, |
out dx,al | out dx,al | ||
inc dx | inc dx | ||
- | out dx,al | + | out dx,al // turn to RGB 0,0,0 |
out dx,al | out dx,al | ||
out dx,al } | out dx,al } | ||
Ligne 309: | Ligne 309: | ||
printf(" | printf(" | ||
} | } | ||
+ | |||
</ | </ | ||
Ligne 314: | 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' | + | 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' |
+ | |||
+ | </ | ||
<code asm> | <code asm> | ||
Ligne 333: | Ligne 337: | ||
je gradient | je gradient | ||
jmp | jmp | ||
+ | |||
</ | </ | ||
Ligne 597: | Ligne 602: | ||
END | END | ||
+ | |||
</ | </ | ||
Ligne 612: | Ligne 618: | ||
#endif | #endif | ||
- | |||
</ | </ | ||
- | <nspages tutoriaux -simpleList -h1 -exclude: | + | < |