| View previous topic :: View next topic |
| Author |
Message |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Sat Dec 27, 2008 1:00 am Post subject: Help Creating a library for a virtual disk |
|
|
| 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 |
|
 |
Dariusc123456
Joined: 12 Aug 2008 Posts: 394
|
Posted: Sat Dec 27, 2008 2:07 am Post subject: |
|
|
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 |
|
 |
PosX100
Joined: 15 Aug 2007 Posts: 98
|
Posted: Sat Dec 27, 2008 2:43 am Post subject: |
|
|
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 |
|
 |
Dariusc123456
Joined: 12 Aug 2008 Posts: 394
|
Posted: Sat Dec 27, 2008 4:03 am Post subject: |
|
|
| Nice library. |
|
| Back to top |
|
 |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Sat Dec 27, 2008 4:33 am Post subject: |
|
|
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 |
|
 |
PosX100
Joined: 15 Aug 2007 Posts: 98
|
Posted: Sat Dec 27, 2008 5:54 am Post subject: |
|
|
| 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 |
|
 |
Dariusc123456
Joined: 12 Aug 2008 Posts: 394
|
Posted: Sat Dec 27, 2008 8:08 am Post subject: |
|
|
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 |
|
 |
PosX100
Joined: 15 Aug 2007 Posts: 98
|
Posted: Sat Dec 27, 2008 6:01 pm Post subject: |
|
|
| 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 |
|
 |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Wed Dec 31, 2008 7:46 am Post subject: |
|
|
| 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 |
|
 |
PosX100
Joined: 15 Aug 2007 Posts: 98
|
Posted: Fri Jan 02, 2009 7:13 pm Post subject: |
|
|
| 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 |
|
 |
|