Petalus: Información y documentos de retroinformática

Visualizador de SCR para PC

  • Imprimir

Mediante esta rutina en pascal, se pueden visualizar ficheros SCR capturados por algún emulador.

 


 

Descripción: Por completar (artículo inacabado).

Descargas: Está disponible esta rutina como programa y como unidad.

Ejemplo: Este programa en pascal representa en pantalla una imagen capturada procendente de un archivo .SCR.

Uses graph,dos,crt;
{ Programa para leer y dibujar en la pantalla archivos .SCR procedentes de un emu de Sinclair }
 
Var
  FromF, ToF: file;
  NumRead, NumWritten: Word;
  Buf: array[1..1] of Char;
  pal: array[1..767] of Char;
  ct,ck:integer;x,y:integer;co:integer;cf:integer;ford:integer;
  GC:INTEGER;r:integer;
  
Function gpa(x:integer):integer;
var sa:integer;
begin
sa:=0;
if x>55 then sa:=7 else
if x>47 then sa:=14 else
if x>39 then sa:=11 else
if x>31 then sa:=10 else
if x>23 then sa:=13 else
if x>15 then sa:=4 else
if x>7 then sa:=9 else sa:=7;
gpa:=sa;
end;
 
Function ginc(x:integer):integer;
var se:integer;sa:integer;
begin
se:=x;sa:=0;
if se>55 then se:=se-56;
if se>47 then se:=se-47;
if se>39 then se:=se-39;
if se>31 then se:=se-31;
if se>23 then se:=se-24;
if se>15 then se:=se-16;
if se>7 then se:=se-10;
if se=0 then sa:=0;
if se=1 then sa:=9;
if se=2 then sa:=4;
if se=3 then sa:=13;
if se=4 then sa:=10;
if se=5 then sa:=11;
if se=6 then sa:=14;
if se=7 then sa:=15;
if se=8 then sa:=7;
if se=9 then sa:=7;
ginc:=sa;
end;
 
 
PROCEDURE PUTPIXELD (X,Y,NU,co,cu:INTEGER);
BEGIN
IF NU>127 THEN BEGIN PUTPIXEL (X+0,Y,co);NU:=NU-128;END else PUTPIXEL (X+0,Y,cu);
IF NU>63 THEN BEGIN  PUTPIXEL (X+1,Y,co);NU:=NU-64;END else PUTPIXEL (X+1,Y,cu);
IF NU>31 THEN BEGIN  PUTPIXEL (X+2,Y,co);NU:=NU-32;END else PUTPIXEL (X+2,Y,cu);
IF NU>15 THEN BEGIN  PUTPIXEL (X+3,Y,co);NU:=NU-16;END else PUTPIXEL (X+3,Y,cu);
IF NU>7 THEN BEGIN   PUTPIXEL (X+4,Y,co);NU:=NU-8;END else PUTPIXEL (X+4,Y,cu);
IF NU>3 THEN BEGIN   PUTPIXEL (X+5,Y,co);NU:=NU-4;END else PUTPIXEL (X+5,Y,cu);
IF NU>1 THEN BEGIN   PUTPIXEL (X+6,Y,co);NU:=NU-2;END else PUTPIXEL (X+6,Y,cu);
IF NU>0 THEN BEGIN   PUTPIXEL (X+7,Y,co);NU:=NU-1;END else PUTPIXEL (X+7,Y,cu);
END;
 
begin
if paramstr(1)='' then begin
WRITELN ('Emulador de memoria de pantalla de Sinclair ZX-SPECTRUM. Pr Vaporatorius 1995.');
WRITELN ('VISOR DE FICHEROS SCR. VERSION 0.5');
WRITELN;
writeln ('Sintaxis : ViSCR nombrefichero.scr');
halt (0);
end;
 
  Assign(FromF, ParamStr(1));
{$i-}
  Reset(FromF, 1);
{$i+}
if ioresult<>0 then begin
 writeln ('error: fichero ',paramstr(1),' no encontrado...');
 halt (1);
 end;
 
for r:=1 to 6144 do blockread (fromf,buf,sizeof(buf),numread);
blockread (fromf,pal,sizeof(pal),numread);
reset (fromf,1);
ct:=0;ck:=0;
initgraph (ct,ck,'d:\borlandp\bgi');
 co:=0;cf:=0;ford:=0;
  x:=0;y:=0; GC:=0;
  repeat
    begin
    BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
    putpixelD (x*8,y*8+CF+FORD*8,ord(buf[1]),ginc(ord(pal[1+x+y*32])),gpa(ord(pal[1+x+y*32])));
    inc (x);
    if x>31 then begin X:=0;Y:=Y+1 end;
    IF Y>7 THEN IF CF>6 THEN BEGIN FORD:=FORD+8;Y:=0;X:=0;CF:=0;END;
    IF Y>7 THEN BEGIN X:=0;Y:=0;CF:=CF+1;END;INC (GC);
    IF GC=6144 tHEN NUMREAD:=0;
    end;
  until ((NumRead = 0) OR (EOF(FROMF)));
  Close(FromF);
  readln;
closegraph;
end.