Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how to blast an 2d array aout to screen without for-loops?

MalekovitsMalekovits Posts: 24Member
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..

Comments

  • _Atex__Atex_ Posts: 163Member
    : 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..

    [code][color=Blue]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.[/color][/code]
Sign In or Register to comment.