* cleaned up, fixed, optimized a little and enabled the assembler version of PutPixel16

git-svn-id: trunk@40896 -
This commit is contained in:
nickysn 2019-01-18 15:17:43 +00:00
parent ff78058f8c
commit 09c76c78c6

View File

@ -21,6 +21,8 @@ interface
{$hugecode on} {$hugecode on}
{$endif} {$endif}
{$define asmgraph}
{$i graphh.inc} {$i graphh.inc}
{$i vesah.inc} {$i vesah.inc}
@ -1559,11 +1561,10 @@ end;
Procedure PutPixel16(X,Y : smallint; Pixel: ColorType);
{$ifndef asmgraph} {$ifndef asmgraph}
Procedure PutPixel16(X,Y : smallint; Pixel: ColorType);
var offset: word; var offset: word;
dummy: byte; dummy: byte;
{$endif asmgraph}
Begin Begin
{ verify clipping and then convert to absolute coordinates...} { verify clipping and then convert to absolute coordinates...}
if ClipPixels then if ClipPixels then
@ -1575,7 +1576,6 @@ end;
end; end;
X:= X + StartXViewPort; X:= X + StartXViewPort;
Y:= Y + StartYViewPort; Y:= Y + StartYViewPort;
{$ifndef asmgraph}
offset := y * 80 + (x shr 3) + VideoOfs; offset := y * 80 + (x shr 3) + VideoOfs;
PortW[$3ce] := $0f01; { Index 01 : Enable ops on all 4 planes } PortW[$3ce] := $0f01; { Index 01 : Enable ops on all 4 planes }
PortW[$3ce] := (Pixel and $ff) shl 8; { Index 00 : Enable correct plane and write color } PortW[$3ce] := (Pixel and $ff) shl 8; { Index 00 : Enable correct plane and write color }
@ -1585,38 +1585,54 @@ end;
Mem[Sega000: offset] := dummy; { Write the data into video memory } Mem[Sega000: offset] := dummy; { Write the data into video memory }
PortW[$3ce] := $ff08; { Enable all bit planes. } PortW[$3ce] := $ff08; { Enable all bit planes. }
PortW[$3ce] := $0001; { Index 01 : Disable ops on all four planes. } PortW[$3ce] := $0001; { Index 01 : Disable ops on all four planes. }
end;
{$else asmgraph} {$else asmgraph}
Procedure PutPixel16(X,Y : smallint; Pixel: ColorType);
Begin
{ verify clipping and then convert to absolute coordinates...}
if ClipPixels then
begin
if (X < 0) or (X > ViewWidth) then
exit;
if (Y < 0) or (Y > ViewHeight) then
exit;
end;
X:= X + StartXViewPort;
Y:= Y + StartYViewPort;
asm asm
{$ifndef fpc} {$ifdef FPC_MM_HUGE}
mov ax, SEG SegA000
mov es, ax
mov es, es:[SegA000]
{$else FPC_MM_HUGE}
mov es, [SegA000] mov es, [SegA000]
{$endif FPC_MM_HUGE}
{ enable the set / reset function and load the color } { enable the set / reset function and load the color }
mov dx, 3ceh mov dx, 3ceh
mov ax, 0f01h mov ax, 0f01h
out dx, ax out dx, ax
{ setup set/reset register } { setup set/reset register }
mov ax, [Pixel] mov ah, byte ptr [Pixel]
shl ax, 8 xor al, al
out dx, ax out dx, ax
{ setup the bit mask register } { setup the bit mask register }
mov al, 8 mov al, 8
out dx, al
inc dx
{ load the bitmask register } { load the bitmask register }
mov cx, [X] mov cl, byte ptr [X]
and cx, 0007h and cl, 07h
mov al, 80h mov ah, 80h
shr al, cl shr ah, cl
out dx, ax out dx, ax
{ get the x index and divide by 8 for 16-color } { get the x index and divide by 8 for 16-color }
mov ax,[X] mov ax,[X]
shr ax,3 mov cl, 3
push ax shr ax, cl
xchg ax, si
{ determine the address } { determine the address }
mov ax,80 mov ax,80
mov bx,[Y] mov bx,[Y]
mul bx mul bx
pop cx add ax,si
add ax,cx
mov di,ax mov di,ax
add di, [VideoOfs] add di, [VideoOfs]
{ send the data through the display memory through set/reset } { send the data through the display memory through set/reset }
@ -1624,71 +1640,17 @@ end;
mov es:[di],bl mov es:[di],bl
{ reset for formal vga operation } { reset for formal vga operation }
mov dx,3ceh
mov ax,0ff08h mov ax,0ff08h
out dx,ax out dx,ax
{ restore enable set/reset register } { restore enable set/reset register }
mov ax,0001h mov ax,0001h
out dx,ax out dx,ax
{$else fpc} end ['AX','BX','CX','DX','SI','DI'];
push eax
push ebx
push ecx
push edx
push edi
{ enable the set / reset function and load the color }
mov dx, 3ceh
mov ax, 0f01h
out dx, ax
{ setup set/reset register }
mov ax, [Pixel]
shl ax, 8
out dx, ax
{ setup the bit mask register }
mov al, 8
out dx, al
inc dx
{ load the bitmask register }
mov cx, [X]
and cx, 0007h
mov al, 80h
shr al, cl
out dx, ax
{ get the x index and divide by 8 for 16-color }
movzx eax,[X]
shr eax,3
push eax
{ determine the address }
mov eax,80
mov bx,[Y]
mul bx
pop ecx
add eax,ecx
mov edi,eax
add edi, [VideoOfs]
{ send the data through the display memory through set/reset }
mov bl,fs:[edi+$a0000]
mov fs:[edi+$a0000],bl
{ reset for formal vga operation }
mov dx,3ceh
mov ax,0ff08h
out dx,ax
{ restore enable set/reset register }
mov ax,0001h
out dx,ax
pop edi
pop edx
pop ecx
pop ebx
pop eax
{$endif fpc}
end;
{$endif asmgraph}
end; end;
{$endif asmgraph}
{$undef asmgraph}
Function GetPixel16(X,Y: smallint):ColorType; Function GetPixel16(X,Y: smallint):ColorType;
{$ifndef asmgraph} {$ifndef asmgraph}