unit view_zx;
interface
procedure showZX(zxName:string);
implementation
uses Graph,Crt;
type p_bufer=array[0..$1AFF]of byte;
var f:file;
bufer:^p_bufer;
pos,i,j,k,p:integer;
procedure putcolor(_x,_y:integer;_dat:byte);
var my_i,my_j,_i,_j:integer;
col,bgr:byte;
const recol:array[0..7]of byte=(0,1,4,5,2,3,6,7);
function getcol(_c:byte):byte;
var cc:byte;
begin
cc:=recol[_c and $07];
if (_c and $40)<>0 then inc(cc,8);
getcol:=cc;
end;
function getbgr(_c:byte):byte;
begin
getbgr:=recol[(_c and $38)shr 3];
end;

begin
col:=getcol(_dat);
bgr:=getbgr(_dat);

for _j:=0 to 7 do
for _i:=0 to 7 do
 begin
 my_i:=_x*8+_i;
 my_j:=_y*8+_j;
 if getpixel(my_i,my_j)=15 then
 putpixel(my_i,my_j,col) else
 putpixel(my_i,my_j,bgr);
 end;
end;
(****************************************************************************)
procedure putbyte(_x,_y:integer;_dat:byte);
begin
if (_dat and $80)<>0 then putpixel(_x*8+0,_y,15);
if (_dat and $40)<>0 then putpixel(_x*8+1,_y,15);
if (_dat and $20)<>0 then putpixel(_x*8+2,_y,15);
if (_dat and $10)<>0 then putpixel(_x*8+3,_y,15);
if (_dat and $08)<>0 then putpixel(_x*8+4,_y,15);
if (_dat and $04)<>0 then putpixel(_x*8+5,_y,15);
if (_dat and $02)<>0 then putpixel(_x*8+6,_y,15);
if (_dat and $01)<>0 then putpixel(_x*8+7,_y,15);
end;
(****************************************************************************)
function nextbyte:byte;
begin
nextbyte:=bufer^[pos];
inc(pos);
end;
(****************************************************************************)
(****************************************************************************)
procedure showZX(zxName:string);
begin
new(bufer);
pos:=0;
assign(f,zxName);
reset(f,1);
blockread(f,bufer^,sizeof(bufer^));
close(f);
for p:=0 to 2 do
for k:=0 to 7 do
for j:=0 to 7 do
for i:=0 to 31 do
 putbyte(i,64*p+8*j+k,nextbyte);

for j:=0 to 23 do
 for i:=0 to 31 do
  putcolor(i,j,nextbyte);

dispose(bufer);
end;
end.