Results 1 to 2 of 2

Thread: my memory Stream class

  1. #1

    my memory Stream class

    hi
    i've finished my simple pack editor , now my pack class member (getfile)function return a just a pointer of memory file , i use it with D3DX9 when loading texture or x files .

    int the 2nd version i want to add a memoryStream class , so i can read files in memory manualy .

    the problem is my memclass give wrong results

    Code:
    type
       PByteArray = ^TByteArray;
       TByteArray = array[0..32767] of Byte;
    
       MemStream = Object
       public
        procedure ReadMem(var buf ; _size :integer; count:DWORD);
        procedure SetMemPos(_indx : integer);
         
       public
        data : pointer;
        _pointer : integer ;
       end;
    
    implementation
    
    procedure MemStream.ReadMem(var buf; _size: integer; count: DWORD);
    var i ,j,L: integer;
    
    begin
    
      L := _size * count;
       for i := _pointer to L do
        begin
          Pbyte(buf)^ := PbyteArray(data)[i]^;
          inc(Pbyte(buf));
        end;
        _pointer := L;
    
    end;
    
    procedure MemStream.SetMemPos(_indx: integer);
    begin
      _pointer := _indx;
    end;
    could any body detect where is the bug !!

    thanks in advance

  2. #2

    Re: my memory Stream class

    solved

    Code:
    procedure MemStream.ReadMem(var buf; _size: integer; count: DWORD);
    var L: integer;
    begin
    
     L := _size * count;
     inc(data,_Pointer);
     move(data^,buf,L);
     _pointer := _pointer + L;
    
    end;

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •