{
Sprite Files:
-------------
        1   short               : Version number (Latest is 5)
	13  bytes		: contains " Sprite File " (with spaces at ends)
	768 unsigned char	: palette info
	1   short		: Version 3.5 or less = max number of sprites per file
				 (Version 3.5 is 1000, previous are 200)
                                  Version 4+ reports number of sprites in file

        For each sprite in the file: (starting index is 0 for version 4+,
                                      1 for all others)

        sprite structure {      (starting index to max sprite)
		1 short: sprite slot status (0=empty, 1=used)
		if sprite is made (1), then read in block
		{
			2 shorts           : width and height
			width*height bytes : image data
		}
{	end


}

program spr2e;
uses dos,crt,artgrafx;
type
   formatdectype  = string[20];
var sprfile,
    efile:file;
    number:byte;
    dumb:word;
    loop:longint;
    tempformatdec : formatdectype;
    sizex,sizey:word;
    x,y:byte;
    palfilename   : filenametype;
    flag:boolean;
const
  formatdec:formatdectype = 'ARTMAN SPRITE FORMAT';
begin
  flag:=false;
  if paramstr(1)<>''
    then
      begin
        Cherche_fichier(paramstr(1)+'.spr',flag);
        if flag=true
          then
            begin
              assign(sprfile,paramstr(1)+'.spr');
              reset(sprfile,1);

              assign(efile,paramstr(1)+'.e');
              rewrite(efile,1);
              x:=0;
              blockwrite(efile,formatdec,sizeof(formatdectype));
              blockwrite(efile,x,sizeof(x));
              seek(sprfile,783);
              blockread(sprfile,dumb,2);
              inc(dumb);
              blockwrite(efile,dumb,2);
              blockwrite(efile,palfilename,sizeof(palfilename));
              writeln('converting ',paramstr(1),'.spr to ',paramstr(1),'.e');
              writeln('processing ',dumb,' sprites');
              while not eof(sprfile) do
                begin
                  blockread(sprfile,dumb,2);
                  blockread(sprfile,sizex,2);
                  blockwrite(efile,sizex,1);
                  blockread(sprfile,sizey,2);
                  blockwrite(efile,sizey,1);
                  write('.');
                  for loop:=1 to sizex*sizey do
                    begin
                      blockread(sprfile,number,1);
                      blockwrite(efile,number,1);
                    end;
                end;
              close(sprfile);
              close(efile);
              writeln;
              writeln('Sprite Converter');
              writeln('by Shawn LeBlanc');
              writeln('World Domination Productions');
            end
          else
            if flag=false
              then
                begin
                  writeln('file not found');
                end;
      end
       else
         begin
           writeln('usage:');
           writeln('spr2e <filename> (no ext.)');
         end;
end.