flat assembler
Message board for the users of flat assembler.

flat assembler > High Level Languages > Why the last loop doesn't start painting at 0,0 position?

Author
Thread Post new topic Reply to topic
arcangel



Joined: 19 Aug 2009
Posts: 39
Code:
{ En el modo 640x480 el banco ocupa 16400 bytes, 4 subbancos de 0 a 16399 }

{$M 8192,0,655360}
uses crt;

label loop0, loop1, exit;

type
  pMemoria = ^memoria;                   (* Puntero a la memoria *)

  memoria = record                       (* Datos almacenados *)
    punto: array [0..16399] of byte;
end;

var
  indice: array [0..19] of pMemoria;   (* Punteros a toda la memoria de video *)

procedure ModoVESA64x48;
begin
    asm;
            mov ah,$4f
            mov al,$2
            mov bx,$101
            int $10
    end;
end;

PROCEDURE SetText;
  Begin;
    asm
       mov        ax,0003h    { Mueve 0003h al registro ax }
       int        10h               { Llama a la interrupciĆ³n 10h  }
    end;
  End;

procedure CambiaBancoVESA(banco:byte);
begin
    asm;
            mov ah,$4f
            mov al,$5
            xor bx,bx
            xor dh,dh
            mov dl,banco
            int $10
    end;
end;

procedure refresca;
var i,j: longint;
begin
CambiaBancoVESA(0);

{ primer banco 0 }
i:=0;
j:=0;
repeat
MEM[$A000:j]:=indice[0]^.punto[i];
inc(i);
inc(j);
until i = 16400;

i:=0;
repeat
MEM[$A000:j]:=indice[1]^.punto[i];
inc(i);
inc(j);
until i = 16400;

i:=0;
repeat
MEM[$A000:j]:=indice[2]^.punto[i];
inc(i);
inc(j);
until i = 16400;


i:=0;
repeat
MEM[$A000:j]:=indice[3]^.punto[i];
inc(i);
inc(j);
until i = 16400;


CambiaBancoVESA(1);

{ primer banco 1 }
i:=0;
j:=0;
repeat
MEM[$A000:j]:=indice[4]^.punto[i];
inc(i);
inc(j);
until i = 16400;

i:=0;
repeat
MEM[$A000:j]:=indice[5]^.punto[i];
inc(i);
inc(j);
until i = 16400;

i:=0;
repeat
MEM[$A000:j]:=indice[6]^.punto[i];
inc(i);
inc(j);
until i = 16400;


i:=0;
repeat
MEM[$A000:j]:=indice[7]^.punto[i];
inc(i);
inc(j);
until i = 16400;

CambiaBancoVESA(2);

{ primer banco 2 }
i:=0;
j:=0;
repeat
MEM[$A000:j]:=indice[8]^.punto[i];
inc(i);
inc(j);
until i = 16400;

i:=0;
repeat
MEM[$A000:j]:=indice[9]^.punto[i];
inc(i);
inc(j);
until i = 16400;

i:=0;
repeat
MEM[$A000:j]:=indice[10]^.punto[i];
inc(i);
inc(j);
until i = 16400;


i:=0;
repeat
MEM[$A000:j]:=indice[11]^.punto[i];
inc(i);
inc(j);
until i = 16400;


CambiaBancoVESA(3);

{ primer banco 3 }
i:=0;
j:=0;
repeat
MEM[$A000:j]:=indice[12]^.punto[i];
inc(i);
inc(j);
until i = 16400;

i:=0;
repeat
MEM[$A000:j]:=indice[13]^.punto[i];
inc(i);
inc(j);
until i = 16400;

i:=0;
repeat
MEM[$A000:j]:=indice[14]^.punto[i];
inc(i);
inc(j);
until i = 16400;


i:=0;
repeat
MEM[$A000:j]:=indice[15]^.punto[i];
inc(i);
inc(j);
until i = 16400;


CambiaBancoVESA(4);

{ primer banco 4 }
i:=0;
j:=0;
repeat
MEM[$A000:j]:=indice[16]^.punto[i];
inc(i);
inc(j);
until i = 16400;

i:=0;
repeat
MEM[$A000:j]:=indice[17]^.punto[i];
inc(i);
inc(j);
until i = 16400;

i:=0;
repeat
MEM[$A000:j]:=indice[18]^.punto[i];
inc(i);
inc(j);
until i = 16400;


i:=0;
repeat
MEM[$A000:j]:=indice[19]^.punto[i];
inc(i);
inc(j);
until i = 16400;
end;


var i,j,x,y: longint;

begin
for i:=0 to 19 do new(indice[i]);

ModoVESA64x48;
for i:=0 to 16399 do indice[0]^.punto[i]:=2;
for i:=0 to 16399 do indice[1]^.punto[i]:=2;
for i:=0 to 16399 do indice[2]^.punto[i]:=2;
for i:=0 to 16399 do indice[3]^.punto[i]:=2;
refresca;
readln;
for i:=0 to 16399 do indice[0]^.punto[i]:=0;
refresca;
readln;
SetText;
end.
    


Why the last loop doesn't start painting at 0,0 position? Crying or Very sad
Post 22 Feb 2014, 19:09
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
arcangel,

16400*4==65600, thus offset wraps around and overwrites 64 pixels at the beginning of window A. Use different color for indice[3] and you'll see it clearly.
Post 28 Feb 2014, 12:53
View user's profile Send private message Reply with quote
arcangel



Joined: 19 Aug 2009
Posts: 39
baldr wrote:
arcangel,

16400*4==65600, thus offset wraps around and overwrites 64 pixels at the beginning of window A. Use different color for indice[3] and you'll see it clearly.


The bank is 65536 bytes...

Code:
{ En el modo 640x480 el banco ocupa 16383 bytes, 4 subbancos de 0 a 16383 } 

{$M 8192,0,655360} 
uses crt; 

label loop0, loop1, exit; 

type 
  pMemoria = ^memoria;                   (* Puntero a la memoria *) 

  memoria = record                       (* Datos almacenados *) 
    punto: array [0..16383] of byte; 
end; 

var 
  indice: array [0..19] of pMemoria;   (* Punteros a toda la memoria de video *) 

procedure ModoVESA64x48; 
begin 
    asm; 
            mov ah,$4f 
            mov al,$2 
            mov bx,$101 
            int $10 
    end; 
end; 

PROCEDURE SetText; 
  Begin; 
    asm 
       mov        ax,0003h    { Mueve 0003h al registro ax } 
       int        10h               { Llama a la interrupciĆ³n 10h  } 
    end; 
  End; 

procedure CambiaBancoVESA(banco:byte); 
begin 
    asm; 
            mov ah,$4f 
            mov al,$5 
            xor bx,bx 
            xor dh,dh 
            mov dl,banco 
            int $10 
    end; 
end; 

procedure refresca; 
var i,j: longint; 
begin 
CambiaBancoVESA(0); 

{ primer banco 0 } 
i:=0; 
j:=0; 
repeat 
MEM[$A000:j]:=indice[0]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 

i:=0; 
repeat 
MEM[$A000:j]:=indice[1]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 

i:=0; 
repeat 
MEM[$A000:j]:=indice[2]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 


i:=0; 
repeat 
MEM[$A000:j]:=indice[3]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 


CambiaBancoVESA(1); 

{ primer banco 1 } 
i:=0; 
j:=0; 
repeat 
MEM[$A000:j]:=indice[4]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 

i:=0; 
repeat 
MEM[$A000:j]:=indice[5]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 

i:=0; 
repeat 
MEM[$A000:j]:=indice[6]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 


i:=0; 
repeat 
MEM[$A000:j]:=indice[7]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 

CambiaBancoVESA(2); 

{ primer banco 2 } 
i:=0; 
j:=0; 
repeat 
MEM[$A000:j]:=indice[8]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 

i:=0; 
repeat 
MEM[$A000:j]:=indice[9]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 

i:=0; 
repeat 
MEM[$A000:j]:=indice[10]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 


i:=0; 
repeat 
MEM[$A000:j]:=indice[11]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 


CambiaBancoVESA(3); 

{ primer banco 3 } 
i:=0; 
j:=0; 
repeat 
MEM[$A000:j]:=indice[12]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 

i:=0; 
repeat 
MEM[$A000:j]:=indice[13]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 

i:=0; 
repeat 
MEM[$A000:j]:=indice[14]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 


i:=0; 
repeat 
MEM[$A000:j]:=indice[15]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 


CambiaBancoVESA(4); 

{ primer banco 4 } 
i:=0; 
j:=0; 
repeat 
MEM[$A000:j]:=indice[16]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 

i:=0; 
repeat 
MEM[$A000:j]:=indice[17]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 

i:=0; 
repeat 
MEM[$A000:j]:=indice[18]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 


i:=0; 
repeat 
MEM[$A000:j]:=indice[19]^.punto[i]; 
inc(i); 
inc(j); 
until i = 16383; 
end; 


var i,j,x,y: longint; 

begin 
for i:=0 to 19 do new(indice[i]); 

ModoVESA64x48; 
for i:=0 to 16399 do indice[0]^.punto[i]:=2; 
for i:=0 to 16399 do indice[1]^.punto[i]:=2; 
for i:=0 to 16399 do indice[2]^.punto[i]:=2; 
for i:=0 to 16399 do indice[3]^.punto[i]:=2; 
refresca; 
readln; 
for i:=0 to 16399 do indice[0]^.punto[i]:=0; 
refresca; 
readln; 
SetText; 
end. 
    


baldr, Thank you very much Smile
Post 06 May 2014, 17:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.