===============================================================================
Date: 05-08-95 Time: 01:29a Number: 38
From: KJETIL MYHRE Refer: 35
To: BJOERN STAERK Board ID: ROLVSOY Recvd: Yes
Subject: ASM - putpixel 86: Programmerin Status: Public
-------------------------------------------------------------------------------
BS> Ja, det hadde vært fint. Det er jo som oftest ikke de
BS> korteste rutinene som er de raskeste...
Her kommer'n.
----------------------- 8< ------------------------------------------
{$G+}
const VideoSeg : Word = $A000;
BytesPerLine : Word = 80; { 640 / 8 }
SC_INDEX = $3c4; { Sequence Controller Index register }
MAP_MASK = $2; { index of Map Mask register }
GC_INDEX = $03ce; { Graphics Controller Index reg }
SET_RESET = $0; { index of Set/Reset reg }
ENABLE_SET_RESET = $1; { index of Enable Set/Reset reg }
DATA_ROTATE = $3; { index of Data Rotate }
READ_MAP_SELECT = $4; { index of Read Map Select }
MODE = $5; { index of Graphics Mode reg }
BIT_MASK = $8; { index of Bit Mask reg }
procedure Plot ( X_Coor, Y_Coor : Integer; Color : Byte );assembler;
asm
{ set write mode 2 }
mov dx,GC_INDEX
mov ax,(2 shl 8)+MODE { lest's use mode 2 }
out dx,ax
mov dx,GC_INDEX
mov al,DATA_ROTATE
mov ah,000b { 0000 - Store; 1000 - And; 10000 - Or; 110}
out dx,ax
{ calculate the offset }
mov ax,Y_Coor
mov cx,BytesPerLine
mul cx
mov di,ax { di := Y * BytesPerLine }
mov bx,X_Coor
mov cx,bx
shr bx,3 { bx := X div 8 }
add di,bx { di:= Y*80 + X div 8 }
mov ch,80h { 10000000 }
and cl,07h
shr ch,cl { 10000000 >> (X_Coor and 7) }
mov dx,GC_INDEX
mov al,BIT_MASK
mov ah,ch
out dx,ax
mov bl,Color
mov es,VideoSeg { es <- video segment }
mov bh,byte ptr es:[di] { load the latch }
mov byte ptr es:[di],bl
{ you can try to change this on xchg byte ptr es:[di], bl
reading memory is very important since you want to save
the background }
end;
var
oldMode : Byte;
f : Word;
begin
asm
mov ax,0f00h
int 10h
mov oldMode,al
mov ax,0012h
int 10h
end;
for f := 0 to 450 do
Plot(f,f,7);
for f := 0 to 639 do
Plot(f,Round(sin(f))+240,15);
readln;
asm
mov al,oldMode
xor ah,ah
int 10h
end;
end.
------------------------- 8< ----------------------------------------
Du får se om den er brukbar.... :))
-= Kjetil =-
-─-
■ RM 1.3 01431 ■ Bad ideas never die, they just get adopted as goverment poli
===============================================================================