mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-19 17:29:15 +02:00
* fixed set/getvgargbpalette for VGA 16 color modes
This commit is contained in:
parent
2ad775b888
commit
0fa97f88ea
@ -87,6 +87,10 @@
|
|||||||
|
|
||||||
NUM_MODES = $8 ; { # of Mode X Variations }
|
NUM_MODES = $8 ; { # of Mode X Variations }
|
||||||
|
|
||||||
|
{ in 16 color modes, the actual colors used are no 0..15, but: }
|
||||||
|
ToRealCols16: Array[0..15] of word =
|
||||||
|
(0,1,2,3,4,5,7,20,56,57,58,59,60,61,62,63);
|
||||||
|
|
||||||
var
|
var
|
||||||
ScrWidth : word absolute $40:$4a;
|
ScrWidth : word absolute $40:$4a;
|
||||||
|
|
||||||
@ -1662,49 +1666,56 @@ const CrtAddress: word = 0;
|
|||||||
|
|
||||||
{ VGA is never a direct color mode, so no need to check ... }
|
{ VGA is never a direct color mode, so no need to check ... }
|
||||||
Procedure SetVGARGBPalette(ColorNum, RedValue, GreenValue,
|
Procedure SetVGARGBPalette(ColorNum, RedValue, GreenValue,
|
||||||
BlueValue : Integer); {$ifndef fpc}far;{$endif fpc} assembler;
|
BlueValue : Integer); {$ifndef fpc}far;{$endif fpc}
|
||||||
asm
|
begin
|
||||||
{ on some hardware - there is a snow like effect }
|
{ translate the color number for 16 color mode }
|
||||||
{ when changing the palette register directly }
|
If MaxColor = 16 Then
|
||||||
{ so we wait for a vertical retrace start period. }
|
ColorNum := ToRealCols16[ColorNum];
|
||||||
mov dx, $03da
|
asm
|
||||||
@1:
|
{ on some hardware - there is a snow like effect }
|
||||||
in al, dx { Get input status register }
|
{ when changing the palette register directly }
|
||||||
test al, $08 { check if in vertical retrace }
|
{ so we wait for a vertical retrace start period. }
|
||||||
jnz @1 { yes, complete it }
|
mov dx, $03da
|
||||||
{ we have to wait for the next }
|
@1:
|
||||||
{ retrace to assure ourselves }
|
in al, dx { Get input status register }
|
||||||
{ that we have time to complete }
|
test al, $08 { check if in vertical retrace }
|
||||||
{ the DAC operation within }
|
jnz @1 { yes, complete it }
|
||||||
{ the vertical retrace period }
|
{ we have to wait for the next }
|
||||||
@2:
|
{ retrace to assure ourselves }
|
||||||
in al, dx
|
{ that we have time to complete }
|
||||||
test al, $08
|
{ the DAC operation within }
|
||||||
jz @2 { repeat until vertical retrace start }
|
{ the vertical retrace period }
|
||||||
|
@2:
|
||||||
|
in al, dx
|
||||||
|
test al, $08
|
||||||
|
jz @2 { repeat until vertical retrace start }
|
||||||
|
|
||||||
mov dx, $03c8 { Set color register address to use }
|
mov dx, $03c8 { Set color register address to use }
|
||||||
mov ax, [ColorNum]
|
mov ax, [ColorNum]
|
||||||
out dx, al
|
out dx, al
|
||||||
inc dx { Point to DAC registers }
|
inc dx { Point to DAC registers }
|
||||||
mov ax, [RedValue] { Get RedValue }
|
mov ax, [RedValue] { Get RedValue }
|
||||||
{ and ax, $ff } { mask out all upper bits }
|
{ and ax, $ff } { mask out all upper bits }
|
||||||
shr al, 2 { convert to LSB RGB format }
|
shr al, 2 { convert to LSB RGB format }
|
||||||
out dx, al
|
out dx, al
|
||||||
mov ax, [GreenValue]{ Get RedValue }
|
mov ax, [GreenValue]{ Get RedValue }
|
||||||
{ and ax, $ff } { mask out all upper bits }
|
{ and ax, $ff } { mask out all upper bits }
|
||||||
shr al, 2 { convert to LSB RGB format }
|
shr al, 2 { convert to LSB RGB format }
|
||||||
out dx, al
|
out dx, al
|
||||||
mov ax, [BlueValue] { Get RedValue }
|
mov ax, [BlueValue] { Get RedValue }
|
||||||
{ and ax, $ff } { mask out all upper bits }
|
{ and ax, $ff } { mask out all upper bits }
|
||||||
shr al, 2 { convert to LSB RGB format }
|
shr al, 2 { convert to LSB RGB format }
|
||||||
out dx, al
|
out dx, al
|
||||||
end;
|
end
|
||||||
|
End;
|
||||||
|
|
||||||
|
|
||||||
{ VGA is never a direct color mode, so no need to check ... }
|
{ VGA is never a direct color mode, so no need to check ... }
|
||||||
Procedure GetVGARGBPalette(ColorNum: integer; Var
|
Procedure GetVGARGBPalette(ColorNum: integer; Var
|
||||||
RedValue, GreenValue, BlueValue : integer); {$ifndef fpc}far;{$endif fpc}
|
RedValue, GreenValue, BlueValue : integer); {$ifndef fpc}far;{$endif fpc}
|
||||||
begin
|
begin
|
||||||
|
If MaxColor = 16 Then
|
||||||
|
ColorNum := ToRealCols16[ColorNum];
|
||||||
Port[$03C7] := ColorNum;
|
Port[$03C7] := ColorNum;
|
||||||
{ we must convert to lsb values... because the vga uses the 6 msb bits }
|
{ we must convert to lsb values... because the vga uses the 6 msb bits }
|
||||||
{ which is not compatible with anything. }
|
{ which is not compatible with anything. }
|
||||||
@ -2451,7 +2462,10 @@ const CrtAddress: word = 0;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.21 1999-09-27 23:34:40 peter
|
Revision 1.22 1999-10-08 14:28:18 jonas
|
||||||
|
* fixed set/getvgargbpalette for VGA 16 color modes
|
||||||
|
|
||||||
|
Revision 1.21 1999/09/27 23:34:40 peter
|
||||||
* new graph unit is default for go32v2
|
* new graph unit is default for go32v2
|
||||||
* removed warnings/notes
|
* removed warnings/notes
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user