<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Thu, 23 Jul 1992 17:58:39 GMT
From   : dog.ee.lbl.gov!hellgate.utah.edu!cc.usu.edu!ivie@ucbvax.Berkeley.EDU (CP/M lives!)
Subject: PX-8 ROM generator 2/3: PXROM.PAS

{$U+}
Program Argh( Input, Output, InFile, ROMFile );
Label 1, 2, 3, 4, 5, 999;

Var
  Buffer : Array [ 0..127 ] of Byte;
  InFile, ROMFile : File;

Procedure Read_ROM( Block_Number : Integer; Var Buffer );
Begin
  Seek( ROMFile, Block_Number );
  BlockRead( ROMFile, Buffer, 1 );
End;

Procedure Write_ROM( Block_Number : Integer; Var Buffer );
Begin
  Seek( ROMFile, Block_Number );
  BlockWrite( ROMFile, Buffer, 1 );
End;

{$I PXFS.PAS}

Procedure Init_ROM( Blocks : Integer );
Begin
  FillChar( Buffer, 128, $FF );
  Seek( ROMFile, 0 );
  While( Blocks > 0 ) Do
  Begin
    BlockWrite( ROMFile, Buffer, 1 );
    Blocks := Blocks - 1;
  End;
End;

Type
  File_Name = String[ 14 ];

Var
  ROM_FCB : Memory_FCB;
  Blocks : Integer;
  X : Char;
  Name : File_Name;

Procedure Build_FCB( Name : File_Name; Var FCB : Memory_FCB );
Label 1, 2, 3, 4, 5, 6, 7, 8, 999;
Var
  NIX, FIX : Integer;

Begin

1:
  NIX := 1;
  Goto 2;

2:
  FCB.DRV := 0;
  FCB.EX := 0;
  For FIX := 0 to 10 do
    FCB.NAME[ FIX ] := ' ';
  FIX := 0;

3:
  If( NIX > Ord( Name[ 0 ] ) ) Then Goto 999;
  Goto 4;

4:
  If( Name[ NIX ] = ':' ) Then goto 5;
  If( Name[ NIX ] = '.' ) Then Goto 6;
  Goto 7;

5:
  NIX := NIX + 1;
  Goto 2;

6:
  NIX := NIX + 1;
  For FIX := 8 to 10 do
    FCB.NAME[ FIX ] := ' ';
  FIX := 8;
  Goto 3;

7:
  If( FIX > 10 ) Then Goto 999;
  Goto 8;

8:
  FCB.NAME[ FIX ] := Name[ NIX ];
  FIX := FIX + 1;
  NIX := NIX + 1;
  Goto 3;

999:
End;

Procedure Copy_File( Name : File_Name );
Label 1, 2, 3, 4, 5, 6, 999;
Var
  Recs_Read : Integer;

Begin

1:
  Assign( InFile, Name );
  Reset( InFile );
  Assign( ROMFile, 'ROM.DAT' );
  Reset( ROMFile );
  Goto 2;

2:
  Build_FCB( Name, ROM_FCB );
  If( Make_File( ROM_FCB ) ) Then Goto 3;
  Goto 6;

3:
  BlockRead( InFile, Buffer, 1, Recs_Read );
  If( Recs_Read = 0 ) Then Goto 5;
  Goto 4;

4:
  If( Write_Sequential( ROM_FCB, Buffer ) ) Then Goto 3;
  Goto 5;

5:
  Close_File( ROM_FCB );
  Goto 6;

6:
  Close( ROMFile );
  Close( InFile );
  Goto 999;

999:
End;

Begin

  Writeln( 'EPSON Geneva EPROM generator' );
1:
  Write('PXRom> ');
  Read( KBD, X );
  If( ( X = 'I' ) or ( X = 'i' ) ) Then Goto 2;
  If( X = Chr( 26 ) ) Then Goto 3;
  IF( ( X = 'C' ) or ( X = 'c' ) ) Then Goto 4;
  Goto 5;

2:
  Write('Init. Kbytes? ');
  Readln( Blocks );
  Assign( ROMFile, 'ROM.DAT' );
  Rewrite( ROMFile );
  Write( 'Initializing...' );
  Init_ROM( Blocks * 8 );
  Write( 'Zeroing...');
  Zero_Directory( Blocks * 8, 32 );
  Writeln;
  Goto 1;

3:
  Writeln( '*EXIT*' );
  Goto 999;

4:
  Write('Copy file ');
  Readln( Name );
  Copy_File( Name );
  Goto 1;

5:
  Writeln( '?' );
  Goto 1;

999:
End.

<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>