Board index » delphi » NEED MAJOR HELP (VIDEO MEMORY)

NEED MAJOR HELP (VIDEO MEMORY)

Hi, I need help, I am trying to use asembly in pascal to display pixels
very fast, but I dont know the routine to use video memory, could
someone write me a program or tell me where I can get a procedure for a
pascal that I just call up and say eg. putpix (x,y,col); and it is
extreamly fast and uses asembly.  I know and understand Video memory
$A000, but wanted to do it in asembly.

Thanks to anyone who can help

 

Re:NEED MAJOR HELP (VIDEO MEMORY)


Quote
Coolman wrote:

> Hi, I need help, I am trying to use asembly in pascal to display pixels
> very fast, but I dont know the routine to use video memory, could
> someone write me a program or tell me where I can get a procedure for a
> pascal that I just call up and say eg. putpix (x,y,col); and it is
> extreamly fast and uses asembly.  I know and understand Video memory
> $A000, but wanted to do it in asembly.

(i assume mode 13h here)

well, even by using asm, putpixeling a whole screen is S L O W, so,
do some thinking... ok, u know and understand video mem, great...
to get the speed, you draw whatever you want to draw in runs, ie
multiple pixels at a time, like this bogus program:

addr:= 0; { make sure we start in upper left corner }

for y:= 0 to 199 do
   for x:= 0 to 319 do
   begin
        mem[$a000:addr]:= x xor y; { just display some {*word*99} }
        inc(addr); { update address/offset }
   end;

this would be very fast compared to using putpixel

for y:= 0 to 199 do
   for x:= 0 to 319 do
   begin
        putpixel(x,y,x xor y); { just display some {*word*99} }
   end;

so, i dunno what you want to do, but try to calculate the address as
few times as possible, and draw several pixels at a time...

if you still want it, this one is fairly fast

procedure PutPixel(x,y,c,where: word); assembler;
asm
   mov es, [where]
   mov di, [y]
   mov dx, [y]
   shl di, 8
   shl dx, 6
   add di, dx
   add di, [x]
   mov ax, [c]
   mov es:[di],al
end;

call it like this:

PutPixel(100,100,9,$a000);

hope it helps some..
- asbj?rn

Re:NEED MAJOR HELP (VIDEO MEMORY)


You can make an array in video memory for fast access.

type
  TScreen=array[0..199,0..319] of Byte;

var
  Screen: TScreen absolute $A000:$0000;

[...]
  for Y:=0 to 199 do
    for X:=0 to 199 do
      Screen[Y,X]:=X+Y;

If you need protected mode support, you'll have to change some things on
it: Make a PScreen pointer type for TScreen and set it to
"Screen:=Ptr(segA000,0);". You can then access it using "Screen^:=...".

Arsne von Wyss
avonwyss @ beaulieu-software.ch

Visit my homepage: http://www.beaulieu-software.ch/avonwyss

******************************************************
*    I removed my reply address to avoid spamming.   *
* Please use the address above to reply or write me. *
******************************************************

Coolman <710...@ican.net> schrieb im Beitrag
<3473227B.85644...@ican.net>...

Quote
> Hi, I need help, I am trying to use asembly in pascal to display pixels
> very fast, but I dont know the routine to use video memory, could
> someone write me a program or tell me where I can get a procedure for a
> pascal that I just call up and say eg. putpix (x,y,col); and it is
> extreamly fast and uses asembly.  I know and understand Video memory
> $A000, but wanted to do it in asembly.

> Thanks to anyone who can help

Other Threads