Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

File library - easy

Posted on 1998-12-08
22
Medium Priority
?
188 Views
Last Modified: 2010-04-04
I got one game, that keeps all it's files in several "libraries". They're not archived, but only linked + some header. Give me your mail, i'll send you example. I already done extractor, it must work, but it doesn't.
0
Comment
Question by:jack_p50
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 9
  • 2
  • +1
22 Comments
 
LVL 3

Expert Comment

by:williams2
ID: 1349867
Hi Jack! ..send your thing to spacebrain@get2net.dk, and I'll solve your problem :-)

see ya,
Williams
0
 
LVL 3

Expert Comment

by:williams2
ID: 1349868
Hmmm... Jack!

1 ..I've got a "_m" file, I guess that is the library. BUT there's not documentation what so ever teeling what's inside that library.

2. You do not say what to do with the library. Do you want to use the procedures and functions inside? Do you want to extract anything? then what?

Regards,
Williams
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1349869
there are only images there
each image begins with string "GRAPHICS"
in beginning is some header with image files names and i think their size, offset
i done prog to extract it, but it don't work. I want to get all images out of the library(each image-each file).
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 4

Author Comment

by:jack_p50
ID: 1349870
plz help
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1349871
hi jack, hi will!

jack send it over to me:
andreas.naguschewski@vt.siemens.de
maybe i can figure something out.

Black Death.
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1349872
sent
0
 
LVL 3

Expert Comment

by:williams2
ID: 1349873
Hi Blackie, This is weird.

Hi Jack: Tell me, are you using the ressource object to save the graphics? If you don't, I think you should take a look at it. I think I'm going to lookup some details on that _m - thing.

Regards,
Williams
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1349874
As i think, the file structure is following :  
archive name (16 bytes); then for each image linked to library
offset(long)  size(long)    name(16 bytes)
(relative from the end of header)

But it doesn't works, seeming so right

Plz do it for me, i'll raise pts when i have some

0
 
LVL 4

Author Comment

by:jack_p50
ID: 1349875
this library is from dos-game
i didn't understood your idea bout resource
?!
0
 
LVL 3

Expert Comment

by:williams2
ID: 1349876
Sorry, I didn't know that you were dealing with an external source. If you build your library yourself, you should use a ressource file instead. What kind of image is inside? bitmaps? with or wihtout headers, if not I would need to know some info on resolution, width x height, pallette entries etc.

I will though see if I can get some info out of this lib-thing. :-)

Regards, Williams
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1349877
this's spec format
0
 
LVL 3

Expert Comment

by:williams2
ID: 1349878
If that is what you want, here is your answer:

This version of the MPx header extracter is not proffen to be sure to catch the header, as many headers might be hidden longer inside the file of the MP3. This will be corrected in a future release.

unit MPHeUnit;


  // This MPEG Layer 1-3 header extraction utility v1.0 has been developed by
  // Thomas Williams (c) 1997
  // The unit is freeware and can be used in any commercial way as I will be
  // creditet as the author of the functionality.

interface

Uses SysUtils;

Const
  BoolAnswer: Array[0..1] of String = ('No','Yes');
  Modes: Array[0..3] of String = ('Stereo','Joint Stereo','Dual Channel','Mono');
  Freqs: Array[0..6] of Integer =
  ( 44100, 48000, 32000, 22050, 24000, 16000 , 11025 );

  Tabs123: Array[0..(2*3*16-1)] of Integer = (
    0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,0,
    0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,0,
    0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,0,
    0,32,48,56, 64, 80, 96,112,128,144,160,176,192,224,256,0,
    0, 8,16,24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160,0,
    0, 8,16,24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160,0
  );

  Translations: Array[0..(2*3*16-1)] of Integer = (
    0,2,2,2,2,2,2,0,0,0,1,1,1,1,1,0,
    0,2,2,0,0,0,1,1,1,1,1,1,1,1,1,0,
    0,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,
    0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,3,3,3,3,3,3,0,0,0,1,1,1,1,1,0,
    0,3,3,0,0,0,1,1,1,1,1,1,1,1,1,0
  );

Type

  TMpeg3Head = class
  Private
    //                ver., layer, bitrate
    tabsel_123: Array[0..1, 0..2 , 0..15  ] of Integer;
    Translate:  Array[0..1, 0..2 , 0..15  ] of Integer;
    Stereo: Integer;
    jsbound: Integer;
//    single: Integer;
    II_sblimit: Integer;
    lsf: Integer;
    mpg25: Integer;
//    down_sample: Integer;
//    header_change: Integer;
//    block_size: Integer;
    lay: Integer;
    error_protection: Integer;
    bitrate_index: Integer;
    sampling_frequency: Integer;
    padding: Integer;
    extension: Integer;
    mode: Integer;
    mode_ext: Integer;
    copyright_: Integer;
    original_: Integer;
    emphasis_: Integer;
    Privat_: Integer;
    Size_: Integer;
    MSB,LSB: Word;
    Bit: Array[0..31] of 0..1;
    Procedure SetBits;
    Procedure Get_II_stuff;
  Public
    Error: String;
    Version: String;
    Frames: String;
    Length: String;
    Frequency: String;
    Layer: String;
    BitRate, BitRateExt: String;
    OutputMode, OutputModeExt: String;
    Privat: String;
    CRC: String;
    Copyright: String;
    Original: String;
    Emphasis: String;
    Header: String;
    Size: String;
    Constructor Create;
    Function GetHeader(FilePath, FileName: String): Boolean;
  End;

implementation

  Function getLength(var S: String): Integer;
  Begin Result:= Length(S) End;

  Constructor TMpeg3Head.Create;
  var  //
    x,y,z,i: Integer;
  Begin
    i:= 0;
    For z:= 0 to 1 do
      For y:= 0 to 2 do
        For x:= 0 to 15 do
        begin
          Tabsel_123[z,y,x]:= Tabs123[i];
          Translate[z,y,x]:= Translations[i];
          inc(i);
        End;
    Error:= '';
  End;

  Procedure TMpeg3Head.SetBits;
  var
    i: Integer;
  Begin
    For i:= 0 to 15 do
      Bit[i]:= (LSB Shr i) AND $1;
    For i:= 0 to 15 do
      Bit[i+16]:= (MSB Shr i) AND $1;
  End;

  Procedure TMpeg3Head.Get_II_stuff;
  Const
    sblims: Array[0..4] of Integer = ( 27 , 30 , 8, 12 , 30 );
  var
    table: Integer;
  Begin
    if lsf<>0 then
      table := 4
    else
      table := translate[sampling_frequency,2 - stereo,bitrate_index];
    II_sblimit := sblims[table];;
//    static struct al_table *tables[5] =
//         { alloc_0, alloc_1, alloc_2, alloc_3 , alloc_4 };
//    fr->alloc = tables[table];
  End;

  Function TMpeg3Head.GetHeader(FilePath, FileName: String): Boolean;
  Const
    RIFF_SKIP = $46;
  var
    FrameSize,Frames_,Secs: Integer;
    Bytes: Array[1..4] of Byte;
    F: File of Byte;
  Begin
    Try
      AssignFile(F,FilePath+FileName);
      FileMode := 0; // Read Only
      Reset(F);
      Size_:= FileSize(F);
      If Size_<4 then Error:='Invalid MPEG file' else
      Begin
        Read(F,Bytes[1],Bytes[2],Bytes[3],Bytes[4]);
        If   (Bytes[1]=Ord('R')) AND (Bytes[2]=Ord('I'))
         AND (Bytes[3]=Ord('F')) AND (Bytes[4]=Ord('F')) then
        If Size_<=(RIFF_SKIP +4) then Error:='Invalid MPEG file' else
        Begin
          Seek(F,RIFF_SKIP);
          Read(F,Bytes[1],Bytes[2],Bytes[3],Bytes[4]);
          Dec(Size_,RIFF_SKIP);
        End;
        MSB:= Bytes[1]*256+Bytes[2];
        LSB:= Bytes[3]*256+Bytes[4];
        SetBits;
        If (MSB And $ffe0) <> $ffe0 then Error:= 'Invalid Header' else
        Begin
          Error:= '';
          if Bit[20]=1 then
          Begin
            lsf:= 1-Bit[19];
            mpg25:= 0;
          End else
          Begin
            lsf:= 1;
            mpg25:= 1;
          End;
          lay := 4 - (Bit[18]*2+Bit[17]);//((MSB shr 1) AND 3);
          BitRate_index := ((LSB shr 12) AND $F);
          If Bit[11]*2+Bit[10]=3 then Error:= 'Stream Error!';
          if mpg25=1 then
            sampling_frequency := 6
          else
            sampling_frequency := (Bit[11]*2+Bit[10]) + lsf * 3;
          error_protection := Bit[16] XOR 1;
          Padding:=    Bit[9];
          Extension:=  Bit[8];
          Mode:=       Bit[7]*2+Bit[6];
          Mode_Ext:=   Bit[5]*2+Bit[4];
          Copyright_:= Bit[3];
          Original_:=  Bit[2];
          Privat_:=    Bit[1];
          Emphasis_:=  Bit[0];
          If mode = 3 then // MD_MONO
            Stereo:= 1 else Stereo:= 2;
          If BitRate_Index=0 then Error:= 'Free format not Supported';
          Case lay Of
            1 : Begin
                  if mode=1 then
                    jsbound:= mode_ext*4+4
                  else
                    jsbound:= 32;
                  FrameSize:=  Tabsel_123[lsf,0,BitRate_index]*12000;
                  FrameSize:=  FrameSize div Freqs[sampling_frequency];
                  FrameSize:= (FrameSize + Padding) * 4 - 4;
                End;
            2 : Begin
                  Get_II_stuff;
                  if mode=1 then
                    jsbound:= mode_ext*4+4
                  else
                    jsbound:= II_Sblimit;
                  FrameSize:=  Tabsel_123[lsf,1,BitRate_index]*144000;
                  FrameSize:=  FrameSize div Freqs[sampling_frequency];
                  FrameSize:=  FrameSize + Padding - 4;
                End;
            3 : Begin
                  FrameSize:=  Tabsel_123[lsf,2,BitRate_index]*144000;
                  FrameSize:=  FrameSize div Freqs[sampling_frequency];
                  FrameSize:=  FrameSize + Padding - 4;
                End;
           Else Begin
                  Error:= 'Layer not supported!';
                  Result:= False;
                  Exit
                End;
          End;
          Inc(FrameSize,3); // Skip Header Info
          If mpg25=1 then Version:='MPEG 2.5' else
            If lsf=0 then Version:= 'MPEG 1.0' else Version:= 'MPEG 2.0';
          Frames_ := size_ div FrameSize;
          Frames := IntToStr(Frames_ * 2);
          Secs := (Frames_*2) div 77;
          Length:= IntToStr(Secs mod 60);
          If getLength(Length)=1 then Length:= '0'+Length;

          Length := IntToStr(Secs Div 60)+':'+Length;
          Layer := 'Layer '+IntToStr(Lay);
          Frequency := IntToStr(freqs[sampling_frequency])+'Hz';
          BitRate := IntToStr(tabsel_123[lsf,lay-1,bitrate_index])+' Kbits/s';
          BitRateExt := IntToStr(Extension);
          OutputMode := Modes[Mode];
          OutputModeExt := IntToStr(Mode_Ext);
          CRC := BoolAnswer[error_protection];
          Copyright := BoolAnswer[Copyright_];
          Original := BoolAnswer[Original_];
          Privat:= BoolAnswer[Privat_];
          Emphasis := BoolAnswer[Emphasis_];
          Header:= IntToHex(MSB,4)+IntToHex(LSB,4);
          Size:= IntToStr(Size_);
        End;
      End;
    finally
      CloseFile(F);
    End;
    Result:= Error='';
  End;

end.

0
 
LVL 3

Expert Comment

by:williams2
ID: 1349879
****!!! ..sorry, This was ment for another question, PLEASE REJECT THE ANSWER!


With humble regards,
Williams
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1349880
Subdue the foul language slightly, please.
My poor innocent eyes can't stand all this pointless cursing.

Send me the code and i'll have a look (john.johansson@peek.se).

/// John
0
 
LVL 3

Expert Comment

by:williams2
ID: 1349881
Sorry, if I offended anyone, it sort of slipped out of my keys :-)

Regards, Williams
0
 
LVL 3

Expert Comment

by:williams2
ID: 1349882
Jack, I've been analyzing your library, and I think you need to provide some more information, because that SPRITE thing holds something interesting, do you know what it is?

Ok! Here's what I've got so far. You'll just need a form with OnCreate and OnDetroy events assigned to it, then cut'n'paste this ****:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

{$V-}

const
  Memo_StepWidth = 16;

type
  PHeadItem = ^Headitem;
  HeadItem = record
    Name: String[16];
    offset: Longint;
    Size: Longint;
    Block: PByteArray;
  End;

  TForm1 = class(TForm)
  procedure FormCreate(Sender: TObject);
  procedure FormDestroy(Sender: TObject);
  Private
    ListBox1: TListBox;
    Memo1: TMemo;
    procedure ListBox1Click(Sender: TObject);
  private
    { Private declarations }
    Lib: TFileStream;
    HList: TList;
    procedure GetHeaders;
    procedure ExtractStuff;
    procedure AddToListBox;
    procedure AddToMemo(Bytes: PByteArray; offset,size: Integer);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
//  FParenWin: THandle;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Lib:= TFileStream.Create('_m',fmOpenRead OR fmShareDenyNone);
  Lib.Position:= 24;
  HList:= TList.Create;
  Getheaders;
  ExtractStuff;
  ListBox1:= TListBox.Create(Self);
  ListBox1.Parent:= Self;
  ListBox1.SetBounds(0,0,100,100);
  ListBox1.Align:= alLeft;
  ListBox1.OnClick:= ListBox1Click;
  Memo1:= TMemo.Create(Self);
  Memo1.Parent:= Self;
  Memo1.Font.name := 'Courier';
  Memo1.Font.Height:= 8;
  Memo1.ReadOnly:= True;
  Memo1.ScrollBars:= ssVertical;
  Memo1.Align:= alClient;
  WindowState:= wsMaximized;
  AddToListBox;
end;

procedure TForm1.FormDestroy(Sender: TObject);
var
  Item: PHeadItem;
  pB: PByteArray;
begin
  While HList.Count>0 do
  Begin
    Item:= PHeadItem(HList.Items[0]);
    pB:= Item^.Block;
    Dispose(pB);
    Dispose(Item);
    HList.Delete(0);
  End;
  Lib.Free;
end;

procedure TForm1.GetHeaders;
const
  Done = 'GRAPHICS';
var
  pS: pChar;
  Item: PHeadItem;
begin
  pS:= AllocMem(16);
  Lib.Read(pS^,16);
  While StrLIComp(ps,Done,Length(Done))<>0 do
  Begin
    new(Item);
    Item^.Name:= StrPas(pS);
    Lib.Read(Item^.offset,SizeOf(LongInt));
    Lib.Read(Item^.Size,SizeOf(LongInt));
    HList.Add(Item);
    Lib.Read(pS^,16);
  End;
  FreeMem(pS);
End;

procedure TForm1.ExtractStuff;
var
  i: Integer;
  Item: PHeadItem;
  pB: PByteArray;
Begin
  i:= 0;
  While i<HList.Count do
  Begin
    Item:= HList.Items[i];
    pB:= AllocMem(Item^.Size);
    Lib.position:= Item^.offset;
    Lib.Read(pB^,item^.Size);
    Item^.Block:= pB;
    inc(i);
  End;
End;

procedure TForm1.AddToListBox;
var
  i: Integer;
  Item: PHeadItem;
Begin
  i:= 0;
  While i<HList.Count do
  Begin
    Item:= HList.Items[i];
    ListBox1.Items.AddObject(Item^.name,TObject(Item));
    Inc(i);
  End;
End;

procedure TForm1.AddToMemo(Bytes: PByteArray; offset, size: Integer);
var
  S,T: String;
  i: Integer;
begin
  S:= ''; T:= '';
  For i:= 0 to size-1 do
  begin
    S:= S + IntToHex(bytes[i],2)+' ';
    If bytes[i]>32 then T:= T + Chr(bytes[i]) else T:= T + '.';
  End;
  While i<Memo_StepWidth do S:= S+'   ';
  Memo1.Lines.Add(IntToHex(offset,4)+' : '+S+': '+T+Chr(13));
End;

procedure TForm1.ListBox1Click(Sender: TObject);
var
  index: Integer;
  Item: PHeadItem;
  size,step: Integer;
begin
  index:= ListBox1.ItemIndex;
  if index>-1 then
  Begin
    memo1.Visible:= False;
    Memo1.Clear;
    Item:= PHeadItem(ListBox1.Items.Objects[index]);
    Step:= 0;
    While step<Item^.Size do
    Begin
      size:= Item^.Size-Step;
      If size>Memo_StepWidth then size:= Memo_StepWidth;
      AddToMemo(@Item^.Block[step],step,size);
      Inc(Step,size);
    End;
    memo1.Visible:= True;
  End;
end;

end.
0
 
LVL 3

Expert Comment

by:williams2
ID: 1349883
..By the way, hehe, Your library should also be there! :-)

Regards,
Williams
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1349884
ok, i'll see the code you've given
btw, Sprites contains animated graphics
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1349885
Wow, it's working. Mysterious my extractor don't work, doing the same thing ???????????????????????????, but never mind; post any dummy answer; i'll accept
Thx
0
 
LVL 3

Accepted Solution

by:
williams2 earned 120 total points
ID: 1349886
I'm glad to be at any help!

Hmmmm.. I still couldn't figure about the sprites, what is it anyway. I'M CURIOUS!! :-)))

See ya later Jack

regards,
Williams
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1349887
sorry, i was too slow.
got lotsa trouble (with programming) at the time being.

glad williams2 could help ya.

have a nice xmas & a happy new one.

bye,

Black Death.
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1349888
i'll send you my sprite converter/viewer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question