////////////////////////////////////////////////////// // // // DATAMAN V1.4 by James Russell (C) 1998 SCEE // // // // Bug reports: James_Russell@scee.sony.co.uk // // // ////////////////////////////////////////////////////// WHAT IS THE PROBLEM? ==================== If you're a Playstation programmer, you've usually got lots of data files that have to be loaded with 'pqbload' or 'dload' into main memory before you run the main program. Trouble is, these files are always changing in size, and it's a right pain to have to manually maintain the addresses in both the C source file and the siocons batch file. Dataman (short for Data Manager because I was tired) will work all these addresses for you and write them to a file that you can use in your C source or batch files. HOW DOES IT WORK? ================= When Dataman runs, it reads a text file containing commands and filenames. It then generates a file, or a number of files, which can then be used in your C source or batch files. The C source file, for example, would contain lots of #define statements which correspond to the address of the file in Playstation memory. To run the example dataman.txt file, simply run dataman.exe, and look for the results in bananas.h and bananas.mak. Notes: Since this was compiled using an old compiler, dataman can only handle DOS (8.3) filenames. Long filenames and filenames with spaces or more than one period will cause problems. EH? GIMME AN EXAMPLE. ===================== Say you need to load in two files, BANANAS.TMD and WEASEL.TMD. BANANAS.TMD is 0x500 bytes long, and WEASEL.TMD is 0x300 bytes long. Your program is at 0x80100000, so you want all your data to be put at 0x80090000. The Dataman input file will look like this: #This is my dataman input file, and this is a comment start_address=80090000 data=BANANAS.TMD data=WEASEL.TMD That's it! Now call this file 'dataman.txt' (the default) and run Dataman: C:\PSX\SRC\> Dataman Dataman will output 2 files. 'dataman.h' (the default) will contain the following lines: #define BANANAS_DATA 0x80090000 #define WEASEL_DATA 0x80090500 See how WEASEL.TMD has been positioned after BANANAS.TMD? The other file generated ('dataman.mak' by default) will contain a batch file suitable for uploading the data: local dload BANANAS.TMD 80090000 local dload WEASEL.TMD 80090500 These two files can be used in your C source and/or makefiles. Now say you adjust BANANAS.TMD so that it's 0x981 bytes long. If you run Dataman again, the 'dataman.h' file will now look like this: #define BANANAS_DATA 0x80090000 #define WEASEL_DATA 0x80090984 WEASEL_DATA has been moved up (and longword aligned!) so that the two files don't overlap. COOL! WHAT ELSE CAN IT DO? ========================== o The default input filename is 'dataman.txt'. You can specify your own on the command line. o The option switch '/v' turns on verbose mode, so you can see what Dataman is trying to do at each step. o You can have up to 10 different output files. 2 are selected by default, a C output one (.h) and a batchfile output one (.mak). Here's a full list of the commands you can use in the input file. There's one command per line, and each line is processed sequentially. COMMAND DESCRIPTION ======= =========== [Blank lines are ignored] # My comment # begins a comment. You _can't_ have a comment on a command line! start_address=[+¦-]xxxxxxxxx Where xxxxxxxxx is a hex value. The next data file will start at this address. The default is 0x8009000. You can optionally specify + or - as the first character. The current start address will be adjusted by this amount; i.e. start_address=-100 means the next address will be 0x100 less than what it would be if you hadn't performed this command. data=myfile.tmd [label_name] Send the name and label of a data file to all open output streams. If no label name is specified, the output file will contain the datafile name in uppercase, with no extension, appended with '_DATA'. E.G. "data=bananas.tmd" will have the label 'BANANAS_DATA', but "data=bananas.tmd fRuIt_RAW" will have the label 'fRuIt_RAW'. 'data' lines also have a special filename, "_E_N_D_". If this special filename is encountered, the program will not attempt to read the file _E_N_D_, but assume that it has length 0. This can be used (at the end of the input file, say), to calculate the address of the end of the data. path=C:\mydata\ Current path. This string will be pre-pended to the front of all subsequent 'data' lines. The default is no path. @data=myfile.tmd [label_name] Same as for 'data', but the current path will not be pre-pended to the start. output=myoutput Name of the output file, without an extension. The default is 'dataman'. E.G. "output=mydata" means 'mydata.h' and 'mydata.mak' will be used. It is NOT affected by the 'path' command. print 1 2 =hello there Prints the text after '=' directly to the specified output streams (0-9). In this example, it has printed 'hello there' to streams 1 and 2. Macros from the format strings do not work with 'print'. string= This allows you to create or change the format strings used internally to create a line ready for output. is a number from 0-9 which specifies which string you want to operate on. is the file extension you want this file to have (it's appended to the current 'output' parameter. is a string enclosed in quotes that will be output to the file. It can contain anything you like, and tags are used to fill in the current parameters. Valid tags are: ~FILE - The full filename ~SIZE_DEC - The file size in decimal ~SIZE_HEX - The file size in hexidecimal ~LABEL - The current label ~ADDRESS - The target address ~TAB - A Tab character For example: "#define ~LABEL 0x~ADDRESS" will generate lines like: "#define BANANAS_DATA 0x80090000" There are two format lines active by default: 0 .h "#define ~LABEL 0x~ADDRESS /* ~SIZE_DEC */" 1 .mak "local dload ~FILE ~ADDRESS" You can disable an output line by giving it a null format string. E.G. string=4 .dat "" EXAMPLE ======= #This is my dataman.txt file #Let's start off with the music start_address = 80100000 output = c:\psxdev\music\music path = c:\psxdev\data\music data = myXM.mod XM_MODULE_DATA data = sounds.vb XM_VB_RAW data = sounds.vh XM_VH_RAW # Turn output string 1 off so we don't get the END variable in there. string = 1 .mak "" data = _E_N_D_ LAST_ADDRESS # Now we'll do the graphics start_address = 80020000 output = c:\psxdev\gfx\gfx path = c:\psxdev\gfx\mygfx # Change format of output strings, turn 1 back on. string = 0 .h "#define ~LABEL (u_long *)0x~ADDRESS" string = 1 .dat " pqbload ~FILE ~ADDRESS" data = backgrnd.tim Assuming: C:\psxdev\data\music\myXM.mod is 0x4502 bytes long C:\psxdev\data\music\sounds.vb is 0x3000 bytes long C:\psxdev\data\music\sounds.vh is 0x20 bytes long C:\psxdev\gfx\mygfx\backgrnd.tim is 0x8320 bytes long Running Dataman will generate 4 files: c:\psxdev\music\music.h #define XM_MODULE_DATA 0x80100000 /* 17666 */ #define XM_VB_RAW 0x80104510 /* 12288 */ #define XM_VH_RAW 0x80107510 /* 32 */ #define LAST_ADDRESS 0x80107530 /* 0 */ c:\psxdev\music\music.mak local dload C:\psxdev\data\music\myXM.mod 80100000 local dload C:\psxdev\data\music\sounds.vb 80104504 local dload C:\psxdev\data\music\sounds.vh 80107504 c:\psxdev\gfx\gfx.h #define BACKGRND_DATA (u_long *)0x80020000 c:\psxdev\gfx\gfx.dat pqbload C:\psxdev\gfx\mygfx\backgrnd.tim 80020000 REVISION HISTORY ================ 1.4 Added TAB tag. Fixed 'print' bug. Made it possible to reset path back to nothing. Fixed bug with stream closing. 1.1 Considers tabs to be whitespace, not just spaces. Files are now made paragraph aligned, not long word aligned. Made format strings more generic. Fixed a couple of documentation errors. Added the "_E_N_D_" file tag. 1.0 Initial release