home *** CD-ROM | disk | FTP | other *** search
- Library Name:
- elmoreinclib #111 ;see other doc
-
- Author:
- Richard T Elmore, HeadSoft, 126 STATE ST. #20, SPEARFISH, SD 57783, USA
-
- OverView:
- This is a crippled version of a library which Richard has put
- a whole heap of time into. It basically allows you to include
- compressed object data into your programs which you can unpack
- at your leisure. Please see the registration material at the
- bottom of this file if you like what you see.
-
- Demo, util and lh.library are in userlibprogs/elmore.
-
- Commands:
- IncSound *success=IncSound(Sound#, ?Label)
- IncBitmap *success=IncBitmap(bitmap#,?Label)
- IncMod *success=IncMod(ST-NT Module#,?Label)
- IncMed *success=IncMed(MEDModule#,?Label)
- IncShape *success=IncShape(Shape#,?Label[,Cookiecut?])
- IncNextShape *success=IncNextShape [CookieCut?]
-
- IncText$ string$=IncText$(?Label[,optional length])
- SaveIncData *success=SaveIncData(Filename$,?Label)
- IncData Address=IncData(?Label,memory type)
- IncData asmloc.l=IncData(?mlroutine,0)
- IncSize FreeIncData IncSize(?mlroutine),asmloc
- IncDataAbs bytesize=IncDataAbs(?Label,Destination Address)
-
- Author's Docs:
-
-
-
- ABOUT INCLUDE.ELMORELIB
- =========================
-
-
- The Include library by Richard T. Elmore of HeadSoft Software enables
- Blitz2 programmers to make stand-alone files that don't require special
- directories, external IFF files, etc. to run. To achieve this in the most
- efficient manner possible, the incredible efficiency and speed of the
- LH.Library is used (in the INCLUDE-UTIL tool, which is freely distributeable.)
-
- At present, the Include library supports Bitmaps, (up to 8 bitplanes!)
- sound effects, MED music modules, IFF brushes for Blitz2 SHAPES,
- Blitz2 SHAPES-FILES for multiple shapes, (as created by the SAVESHAPES command
- or with the SHAPESMAKER utility) entire ASCII text files, or raw binary data
- which gives the advanced programmer the ability to include other object types
- or other data such as executeable programs, variable arrays for cosine tables,
- etc.
-
- The library was designed with Blitz2's INCBIN compiler directive, but may
- also be used with data loaded with READMEM or similar commands, to conserve
- disk space when you don't mind having external files, not to mention they will
- be made next to impossible to "rip" by anyone without the Include Library!
-
-
- NOTE: Your executeables do NOT require the "lh.library" to run... They
- will have their own self-contained decrunching routine (which is much faster
- than the crunching routine in lh.library!)
-
-
-
-
-
-
- USING THE INCLUDE-UTIL PROGRAM
- ================================
-
- In order to include the above-mentioned data in your Blitz2 executeables,
- the original data files must be converted and packed so that the resulting
- runtime program consumes the least memory possible. This also allows the data
- to be stored in public or "fast" memory, not just CHIP ram. The INCLUDE-UTIL
- program is supplied with the library to convert the data for you.
-
-
- First, ensure the "LH.Library" file resides in your LIBS: directory. The
- INCLUDE-UTIL program will crash if it isn't availble.
-
-
- In order to run the program, just click on it's icon, and a custom screen
- will appear containing icons representing the types of data you wish to
- convert to includeable data. Note that the ST/NT Module button is ghosted, as
- this data type is not supported in the public domain release of the library.
-
- You may note there is a gadget to "quit" even though there is also a "close"
- gadget in the top-left of the main window. Clicking the close-gadget will
- NOT quit the program, it will merely close the window and screen, then an
- icon will appear on the Workbench screen. Simply click the icon to reactivate
- the program. (While in this idle mode, INCLUDE-UTIL uses no processor time
- and consumes less memory.)
-
- Upon clicking one of the other icons, a file requester will appear prompting
- you to select a source file (the IFF, text, MOD, whatever) to convert.
- Note that you may load either IFF brushes *OR* BB2 shapes-files in the
- SHAPES filerequester, the appropriate INCLUDE-OBJECT type will be created.
-
- After the file has been converted to it's INCLUDE-OBJECT form, you will be
- given a filerequester to SAVE the object with. Note that an INCLUDE-OBJECT
- extension will be appended to the filename to help you more easily recognise
- the object types in a directory listing. They are:
-
-
-
- .ISFX - Sound effects
- .IBMP - Bitmaps
- .ISHP - Single shapes
- .ISHPS - Multiple shapes
- .IMED - MED modules
- .IBIN - Either binary or text (IncText$, IncDataABS, IncData, etc.)
-
-
-
-
- The INCLUDE-UTIL program accepts tooltypes for default paths. Then
- whenever you click on an appropriate gadget the file requester will use
- the path you prefer. The following keywords identify the paths:
-
-
- SOUNDS=pathname
- BITMAPS=pathname
- SHAPES=pathname
- MODULES=pathname
- BINARIES=pathname
- SAVE=pathname (This is the same path for saving all object types)
-
-
- You should keep the name of this utility "INCLUDE-UTIL" or the
- tooltype preferences will not be available.
-
-
- A few features are available under OS2.0 and above only: Notably,
- when you iconify INCLUDE-UTIL, it uses a real appicon, so you can drag
- objects onto it to have them automatically identified and loaded. You
- can also simply double-click the icon without dragging anything if you
- just want to wake the program up.
-
-
-
-
-
- Now that you have your INCLUDE-OBJECTs, how do you go about making them
- part of your Blitz2 executeables? It is relatively simple, but you must be
- careful to follow these guidelines unless you know EXACTLY what you're doing
- or you'll crash your Amiga!
-
-
- 1. Place a copy of Include.ElmoreLib in your Blitzlibs:Userlibs directory,
- then optionally create a new DEFLIBS file.
-
-
-
- 2. Write and debug your program using normal loading routines until you're
- satisfied with it. No need to use INCLUDE-OBJECTs during debugging, as it
- will only slow down development. (Before being made executeable, Blitz2
- will both load the objects from disk AND decrunch them.)
-
-
-
- 3. Go to the end of your sourcecode (usually the safest place) and select
- a different program label for EACH INCLUDE-OBJECT to be decrunched at
- run-time. Directly following the label, enter INCBIN "filename" which should
- reference the name you saved the INCLUDE-OBJECT as from INCLUDE-UTIL.
- See page 8-3 of your Blitz2 reference manual for details on INCBIN and
- INCDIR commands if you're not familiar with them.
-
-
-
- 4. Ensure you have an "END" statement or some such before your fist
- INCLUDE-OBJECT's label. If program flow continues into the data, you will
- almost surely have a crash.
-
-
-
- 5. Replace your Blitz2 DOS-based loading commands with the approriate
- Include library versions. It's wise to check the results of those commands
- that return "success" or "failure" (TRUE or FALSE) so that your program can
- exit gracefully if there isn't enough memory, etc. when its run.
-
-
-
- 6. That's all! You should be able to run your program normally, and
- executeables you create will run fine with graphics, sounds, whatever you
- want, and *NO* external files needed!! Of course since all the data is
- included in the size of the executeable, it will be much larger than usual.
- (Size of INCLUDE-OBJECTs+normal executeable size) You may have some success
- crunching the entire executeable with PowerPacker or similar programs, but
- if the percentage of INCLUDE-OBJECT data in the executeable is very high,
- most crunchers will choke on it, since most of the program is already crunched
- by INCLUDE-UTIL.
-
-
-
-
-
- ELMORE.INCLUDELIB
-
-
- Well, okay, these docs are not the best, but I only had 25 minutes! :-)
-
-
- Anyway, I will give you the syntax and an example for each command, and
- I'll get some example sourcecodes to you as soon as possible.
-
- Commands marked with a star (*) can be used either as a function or a
- statement, depending upon whether you're interested in their success or
- not. About the only reason the commands could fail is insufficient memory
- or the executeable was corrupt or something.
-
- Functions that are marked with *success=..... will return either TRUE
- or FALSE (-1 or 0) depending on whether they could be unpacked etc.
-
-
-
-
-
- *success=IncSound(Sound#, ?Label)
-
- Ensure you put the question mark before the label name or you'll have
- errors! The actual include-object should be INCBINed directly after the
- label, and be careful to put an END statement somewhere above your INCBIN
- data or you'll crash!
-
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;Example
-
- If IncSound(0,?Mysound)=False Then End ;Unpack the sound or end!
-
- Sound 0,15 ;Play it back!
-
- Mousewait ;pause for the user....
-
- End
-
-
-
- Mysound:
- IncBin "RAM:SoundEffect.isfx"
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-
- NOTE: In the above example the FUNCTION version was used so you could
- test it with an IF/THEN statement to see if it was successful... If
- you don't think you'll need to be so careful, the STATEMENT version would
- be:
-
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;Example
-
- IncSound 0,?Mysound ;Unpack the sound (Note no parentheses for statement!)
-
- Sound 0,15 ;Play it back!
-
- Mousewait ;pause for the user....
-
- End
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-
-
-
-
-
-
-
-
-
- *success=IncBitmap(bitmap#,?Label)
-
- Nearly identical in useage to IncSound (above)
- Note that if the bitmap already exists, it should be the same dimensions
- such as 640x256x4 or IncBitmap will return FALSE (for failure) if you
- don't know for sure, you can let IncBitmap create the bitmap exactly like
- it was Included by doing FREE BITMAP 0 or some such before you INCBITMAP it.
-
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;Example
-
- Blitz
-
- If IncBitmap(0,?Mypicture)=0 Then End
-
- Slice 0,32,4
-
- Show 0
-
- Mousewait:end
-
-
- Mypicture:
- IncBin "RAM:Picture.ibmp"
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-
-
-
-
-
- *success=IncMod(ST-NT Module#,?Label)
-
- Like the above examples, only for music mods. You could then
- use StartModule etc. just as if you had loaded it from disk.
-
- ----------- NOTE: This function is a bit buggy, so it has
- been temporarily disabled with this release of
- the library! (Sorry!) --------------------------------
-
-
-
-
- *success=IncMed(MEDModule#,?Label)
-
- For including MED modules. Usage is otherwise the same as IncMod.
-
-
-
-
-
- *success=IncShape(Shape#,?Label[,Cookiecut?])
- ^^^^^^^^^^^^
- OPTIONAL DUMMY VALUE
-
-
- The one you've been waiting for! Will retrieve the shape# for BLITTING...
- Along with the command below, IncNextShape, you can even include several
- shapes in one step! I will be adding multiple shapes as an option in the
- INCLUDE-UTIL program as well... For now, just INCBIN as many shapes as you
- want (only need label for the first one)
-
- Note: If you don't need a cookiecut for the shape, you can leave out the
- CookieCut parameter. Any number placed in the cookiecut parameter will
- cause a cookiecut to be made for the shape when it is made however. If
- you plan to do BLITs etc. you should always use the cookiecut.
-
-
- *success=IncNextShape [CookieCut?]
- ^^^^^^^^^^^^
- OPTIONAL DUMMY VALUE
-
-
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
- ;Example:
-
-
- ;Include shape #0
- IncShape(0,?Shapes,1)
-
-
- ;Will loop 3 times from shape #1 to #3 in this case
-
- While IncNextShape(1):Wend
-
-
- ;(Do your blitting stuff etc. here)
-
-
- End
-
-
-
- Shapes:
- IncBin "Shape0.ISHP"
- IncBin "Shape1.ISHP"
- IncBin "Shape2.ISHP"
- IncBin "Shape3.ISHP"
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-
-
- ;(Note this is a FUNCTION only, no statement version)
-
-
- string$=IncText$(?Label[,optional length])
-
-
- Used with BINARY include types.... You can then put whole text files
- into strings. The optional LENGTH will limit then string length to
- whatever number you want, similar to the LEFT$ function.
- It will only return a null-string "" in case of failure.
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- a$=IncText$(?text)
- Nprint a$
-
- b$=IncText$(?text2,32)
- Nprint b$
-
- Mousewait:End
-
-
- text:
- IncBin "Message.IBIN"
-
- text2:
- IncBin "Greetz.IBIN"
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-
-
-
- *success=SaveIncData(Filename$,?Label)
-
-
- This will write to disk the unpacked version of whatever BINARY
- include-object you specify. One good use of this is to save
- programs to RAM and then EXECUTE them, and DELETE them again.
-
- Of course there are hundreds of uses....
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- If SaveIncData("Ram:newfile",?executeable)=0 Then End
-
- Execute_ "Ram:Newfile"
-
- KillFile "Ram:Newfile"
-
- End
-
-
- executeable:
- IncBin "myprog.ibin"
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-
-
-
- Address=IncData(?Label,memory type)
-
- This allows you to include BINARY data for any number of uses that
- aren't provided with the other functions. Memory types are:
-
-
- 0- Any kind of memory (preferably FAST RAM)
-
- 2- CHIP RAM ONLY!
-
-
-
- This function will return the address of the binary data in
- memory, or 0 for failure....
-
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;Example of including a pure ASM routine object file for execution:
-
-
- asmloc.l=IncData(?mlroutine,0)
-
- Call asmloc
-
- End
-
-
- mlroutine:
- IncBin "Ram:MLRoutine.IBIN"
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
- size.l=IncSize(?Label)
-
- Returns the size in bytes of the BINARY object at the specified label
- Among other uses, you need it if you want to FREE the uncrunched
- binary data. (It will automatically be freed when your program ends)
-
-
-
- FreeIncData Size,Address
-
-
- If you wanted to free up the memory allocated by the above IncData
- function, here is how you'd do it:
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- FreeIncData IncSize(?mlroutine),asmloc
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-
-
-
- ***********************************************************
- ** **
- ** A D V A N C E D : Use with caution! **
- ** **
- ***********************************************************
-
-
-
- This command will unpack the binary data directly to the area of memory
- you specify, so if you're not sure what you're doing you'll probably
- GURU the Amiga! However, it is very useful to fill arrays, uncrunch data
- directly to Banks, or whatever. Just be careful!
-
-
- bytesize=IncDataAbs(?Label,Destination Address)
-
- It will return zero for failure, or the number of bytes in the binary
- object. I'll provide a better example of making use of this function
- later.... (Filling up array variables, etc.)
-
-
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
- InitBank 0,1000,0
-
- size.l=IncDataAbs(?Binary,BankLoc(0))
-
- Mousewait:End
-
- Binary:
- IncBin "binarydata.IBIN"
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
- That's it for now---- I'm improving the INCLUDE-UTIL to make it
- easier to use and provide a few more functions like multiple shapes
- and source-code generator.... Anyway, call me if you have any questions
- or find a bug....
-
-
- 1-605-642-1564
-