Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to blast an 2d array aout to screen without for-loops? Posted by Malekovits on 12 Nov 2010 at 5:22 AM
Hi all! I'm using borland pascal (1992) and I wonder how to blast an 2d array out to screen without using the standard two for-loops:

for i:=1 to... do
begin
for j:=1 to... do
write....
writeln

I wonder if there is something like the fillchar function, that if u use it you can "erase" the contents of an array in a simple function, without the for-loops, to write all the contents of an 2d array at once..
Report
Re: how to blast an 2d array aout to screen without for-loops? Posted by _Atex_ on 12 Nov 2010 at 6:47 PM
: I wonder if there is something like the fillchar function, that if u
: use it you can "erase" the contents of an array in a simple
: function, without the for-loops, to write all the contents of an 2d
: array at once..

uses crt;


procedure fillbyte(var x;count:word;b:byte);assembler; { similar to FillChar, but faster, it takes bytes }
 asm
  les di,[x]
  mov cx,count
  mov al,b
  mov ah,al
  cld
  shr cx,1
  rep stosw
  adc cx,cx
  rep stosb
 end;

procedure fillword(var x;count,w:word);assembler; { same as above, 16 bit }
 asm
  les di,[x]
  mov cx,count
  mov ax,w
  cld
  rep stosw
 end;



var a:array[0..3999] of byte absolute $b800:0;
    i:word;

begin
 repeat
  for i:=0 to 3999 do a[i]:=random(256);
  delay(100);
 until keypressed;
 readkey;

 i:=0;
 repeat
  fillbyte(ptr($b800,0)^,4000,i);
  inc(i);
  delay(100);
 until keypressed;
 readkey;

 i:=0;
 repeat
  fillword(ptr($b800,0)^,2000,i shl 8+(255-i));
  inc(i);
  delay(100);
 until keypressed;
 readkey;

 clrscr;
end.




 

Recent Jobs