forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help Creating a library for a virtual disk

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Sat Dec 27, 2008 1:00 am    Post subject: Help Creating a library for a virtual disk Reply with quote

i wanna create a virtual hard drive / database i guess that has a folder struct and holds files and i can access them by folder how would i go about doing this got any suggestions
Back to top
View user's profile Send private message MSN Messenger
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Sat Dec 27, 2008 2:07 am    Post subject: Reply with quote

To do so, you will need to load the files from the ram.

Take a look at dosbox, for example.

struct is short for structure. Its use do store data. Im not really sure if you want one for the psp or pc.
Back to top
View user's profile Send private message AIM Address
PosX100



Joined: 15 Aug 2007
Posts: 98

PostPosted: Sat Dec 27, 2008 2:43 am    Post subject: Reply with quote

You can use my library(ATL - http://forums.ps2dev.org/viewtopic.php?t=11390 -) , it does what you want , plus many more.

Here's an example how to pack/stream entries:

__

Code:

void pack() // used by the packer application
{
   //init
   atlInit(ATL_ENABLE_LOGGING|ATL_ENABLE_OPTIMIZED_VFPU_MEMCPY);

   //packing
   atlAddEntryFromExternalSource("data\\hero.tga","data\\hero.tga");
   atlAddEntryFromExternalSource("data\\hero1.tga","data\\hero1.tga");
   atlAddEntryFromExternalSource("data\\hero2.tga","data\\hero2.tga");

   //creating the package
   atlSaveMemoryToFile("memory.bin");

   //cya
   atlShutdown();
}


Loading whole package:
Code:

   atlLoadMemoryFromFile("memory.bin");


Or loading(streaming) specific entry:
Code:

   atlLoadSpecificEntryFromMemoryFile("memory.bin","data\\hero.tga");


Usage:
Code:

   ATL_NODE* node = atlFindEntry("data\\hero.tga");

   SomeImage* img = someFunctionThatTakesAsParamABuffer(node->type,node->type_size);
Back to top
View user's profile Send private message
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Sat Dec 27, 2008 4:03 am    Post subject: Reply with quote

Nice library.
Back to top
View user's profile Send private message AIM Address
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Sat Dec 27, 2008 4:33 am    Post subject: Reply with quote

so can this pull one data from the .bin file instead of all because i dont want to load all of the data just what i need to conserve memory i saw the function but that is what it does right

edit:
what if i want to add some data or modify data without accessing pulling / opening the entire memory.bin to memory will that work like if i want to add

dummy.bin (5000kb) + dummy2.bin(10000kb) + dummy3.bin (25mb) that will overload the memory so does it load all of them to memory then write or stream it to memory from the existing files
Back to top
View user's profile Send private message MSN Messenger
PosX100



Joined: 15 Aug 2007
Posts: 98

PostPosted: Sat Dec 27, 2008 5:54 am    Post subject: Reply with quote

Quote:

so can this pull one data from the .bin file instead of all because i dont want to load all of the data just what i need to conserve memory i saw the function but that is what it does right


Yes,it is possible...
See my previous post(@ "loading(streaming) specific entry").

Quote:

edit:
what if i want to add some data or modify data without accessing pulling / opening the entire memory.bin to memory will that work like if i want to add

dummy.bin (5000kb) + dummy2.bin(10000kb) + dummy3.bin (25mb) that will overload the memory so does it load all of them to memory then write or stream it to memory from the existing files


I don't quite get your question , but , if you're asking if its possible
to modify a package , then the answer is "YES".

You can replace/add/delete an entry & then rebuild the package...
Back to top
View user's profile Send private message
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Sat Dec 27, 2008 8:08 am    Post subject: Reply with quote

He asking will a large size overload the memory.

It really shouldnt, but it might go slow when reading the data.

My library that packs, and unpack read as :

header
custom hash/checksum
size[of each file]
blocks of data[of each file]
total size
encrypted sha1 hash

The total size that can be hold is 512 mb. It reads at a 512kbps(on psp slim) and can hold 500 files or more

Now, PosX has a much better lib. Nice job again.
Back to top
View user's profile Send private message AIM Address
PosX100



Joined: 15 Aug 2007
Posts: 98

PostPosted: Sat Dec 27, 2008 6:01 pm    Post subject: Reply with quote

Quote:

what if i want to add some data or modify data without accessing pulling / opening the entire memory.bin to memory will that work like if i want to add

dummy.bin (5000kb) + dummy2.bin(10000kb) + dummy3.bin (25mb) that will overload the memory so does it load all of them to memory then write or stream it to memory from the existing files


No , currently there is no way to pack a new file(in existing package) without loading the whole package(i might add this feature soon though).

Anyway , if you want to stream a specific entry , just use this :

Code:

atlLoadSpecificEntryFromMemoryFile( package source  , entry name )
Back to top
View user's profile Send private message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Wed Dec 31, 2008 7:46 am    Post subject: Reply with quote

cool thanks for the update now one more thing can i also remove entries from an existing package and add just a variable / void * data to package
Back to top
View user's profile Send private message MSN Messenger
PosX100



Joined: 15 Aug 2007
Posts: 98

PostPosted: Fri Jan 02, 2009 7:13 pm    Post subject: Reply with quote

coolkehon wrote:
cool thanks for the update now one more thing can i also remove entries from an existing package and add just a variable / void * data to package

Quote:

cool thanks for the update now one more thing can i also remove entries from an existing package and add just a variable / void * data to package


No , you can not remove an entry without re-compiling the whole package(or , loading it back in memory,remove/replace an entry , then rebuild the package) ,
because it requires full-rebuilding of the entire
package structure :).

Just create more than 1 package for everything that you really need.

Eg :

For SFX , create a package named "sfx.bin" , For gfx , "gfx.bin" ,or
create "session" packages , eg :"gameplay_lvl0_p0_.bin" and load only what
you really need.

Now , you're asking how to import a native packed type
into an existing package , well , yes , it is possible(a hack-ish way):
Code:


add entry   nat_type
extract entry @nat_type , some_filename.some_ext
import source some_filename.some_ext, some_package.some_ext
remove extracted file some_filename.some_ext


or (non-"Hack"-ish way) if the package is small in size:

Code:


load memory
modify entries
save memory

.

In some later release , i might add full entry streaming support(using a pre-compiled static stream table).
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group