The ExtGraph Library is an add-on to the TIGCC Library (TIGCCLIB).
It's a compile-time library (used functions are fetched from the library during the linking stage)
and it contains various useful graphics related routines which are missing in the
TIGCCLIB or modified routines which are implemented with maximum speed in mind (without stupid
excessive speed optimizations).
Note: ExtGraph works with TIGCC, which complies with C99 / GNU C standards. We do not /
cannot guarantee that it works with any other compiler or cross-compiler for TI-68k calculators.
The ExtGraph demos were tested on PedroM 0.79. PedroM exits demo12 and demo17 because
ROM_CALL CharNumber (not currently documented in TIGCC) is not reimplemented, but all other
demos work (although PedroM 0.79 seems to suffer more from the keyboard rebounds, tested on VTI)
and show that PedroM uses more efficient algorithms than AMS: ExtGraph outperforms PedroM on
lines by <~10% and rectangles by >~3x, while it outperforms AMS by >~5x on lines and >~7x on
rectangles.
Several people complained rather hard and repeatedly, on various boards, about the fact ExtGraph
is to be integrated into TIGCCLIB (which will of course happen after a beta-test period and a
separate release).
First, they would have been aware of that for more than two years if they had read the TIGCC/TICT
board on a regular basis.
Second, I don't remember reading complaints from the same people, about the fact GenLib is in
the PreOS distribution... At least, they never posted such a thing on our board... OK, PpHd,
you explained me something about that, but the facts remain.
The ExtGraph 2 series is supposed to be backwards compatible with the previous versions,
except:
If you find something else that won't compile, please report it to us !
ABOUT THE GRAYSCALE MONSTER FUNCTIONS:
The GraySprite routines are real "monsters" due to their number of parameters.
I've never planned to implement them this way, but there were too many requests.
Reducing a bit the number of parameters is planned for special GrayClipSprite16x16 (most used
sprite format), by switching to a special sprite format, but we will NOT combine the consecutive
planes into one double-sized plane. Indeed, the latter a) doesn't have any significant advantage
speed-wise or size-wise compared to the normal method and b) it forbids writing directly to
the grayscale outputscreen or using doublebuffering, because the buffers used by the TIGCCLIB
grayscale routine are not combined this way on HW1. Therefore I've decided to implement these
"monsters".
Note that the special GrayClipSprite16x16 routines will be highly speed-optimized by unrolling
the loops AND using two different loops to optimize shiftings.
Great improvements in the ExtGraph 2.xx series are the availability of __regparm__ mode
(functions whose name ends with "_R"; as a consequence, TIGCC 0.93 is not supported any more,
which is not a problem anyway since the current release is no longer 0.93), clipped sprite
routines, grayscale transparency routines (TRANB_R / TRANW_R), the tilemap engine.
Clipped sprite routines can be used just like the normal (non-clipped) sprite routines, their
prototypes are identical. They assume the planes they are given are 240x128 pixels.
__regparm__ routines are faster and smaller than __stkparm__ routines which are left (most
were rewritten though) for compatibility. You should update to __regparm__ routines.
This is a beta, this means it may contain bugs we might not have seen despite our tests. We
already saw several more or less severe ones in Beta 0 and 1.
The most recent version of the tilemap engine can always be found on
Julien's site. Everything is written in
French, but it's easy to navigate. Note that you will have to merge the ExtGraph directory and
the tilemap directory (we did on purpose that trees are identical).
Sprite8_AND Sprite16_AND Sprite32_AND SpriteX8_AND Sprite8_AND_R Sprite16_AND_R Sprite32_AND_R SpriteX8_AND_R GraySprite8_AND GraySprite16_AND GraySprite32_AND GraySpriteX8_AND GraySprite8_AND_R GraySprite16_AND_R GraySprite32_AND_R GraySpriteX8_AND_R ClipSprite8_AND_R ClipSprite16_AND_R ClipSprite32_AND_R GrayClipSprite8_AND_R GrayClipSprite16_AND_R GrayClipSprite32_AND_R Sprite8_BLIT Sprite16_BLIT Sprite32_BLIT SpriteX8_BLIT Sprite8_BLIT_R Sprite16_BLIT_R Sprite32_BLIT_R SpriteX8_BLIT_R GraySprite8_BLIT GraySprite16_BLIT GraySprite32_BLIT GraySpriteX8_BLIT GraySprite8_BLIT_R GraySprite16_BLIT_R GraySprite32_BLIT_R GraySpriteX8_BLIT_R ClipSprite8_BLIT_R ClipSprite16_BLIT_R ClipSprite32_BLIT_R GrayClipSprite8_BLIT_R GrayClipSprite16_BLIT GrayClipSprite32_BLIT_R Sprite8Get Sprite16Get Sprite32Get SpriteX8Get Sprite8Get_R Sprite16Get_R Sprite32Get_R SpriteX8Get_R Sprite8_MASK Sprite16_MASK Sprite32_MASK SpriteX8_MASK Sprite8_MASK_R Sprite16_MASK_R Sprite32_MASK_R SpriteX8_MASK_R GraySprite8_MASK GraySprite16_MASK GraySprite32_MASK GraySpriteX8_MASK GraySprite8_MASK_R GraySprite16_MASK_R GraySprite32_MASK_R GraySpriteX8_MASK_R ClipSprite8_MASK_R ClipSprite16_MASK_R ClipSprite32_MASK_R GrayClipSprite8_MASK_R GrayClipSprite16_MASK_R GrayClipSprite32_MASK_R Sprite8_OR Sprite16_OR Sprite32_OR SpriteX8_OR Sprite8_OR_R Sprite16_OR_R Sprite32_OR_R SpriteX8_OR_R GraySprite8_OR GraySprite16_OR GraySprite32_OR GraySpriteX8_OR GraySprite8_OR_R GraySprite16_OR_R GraySprite32_OR_R GraySpriteX8_OR_R ClipSprite8_OR_R ClipSprite16_OR_R ClipSprite32_OR_R GrayClipSprite8_OR_R GrayClipSprite16_OR_R GrayClipSprite32_OR_R Sprite8_XOR Sprite16_XOR Sprite32_XOR SpriteX8_XOR Sprite8_XOR_R Sprite16_XOR_R Sprite32_XOR_R SpriteX8_XOR_R GraySprite8_XOR GraySprite16_XOR GraySprite32_XOR GraySpriteX8_XOR GraySprite8_XOR_R GraySprite16_XOR_R GraySprite32_XOR_R GraySpriteX8_XOR_R ClipSprite8_XOR_R ClipSprite16_XOR_R ClipSprite32_XOR_R GrayClipSprite8_XOR_R GrayClipSprite16_XOR_R GrayClipSprite32_XOR_R SpriteX8_MIRROR_H SpriteX8_MIRROR_V SpriteX8_MIRROR_H_R SpriteX8_MIRROR_V_R ScaleSprite8_AND ScaleSprite16_AND ScaleSprite32_AND ScaleSprite64_AND ScaleSprite8_AND_R ScaleSprite16_AND_R ScaleSprite32_AND_R ScaleSprite64_AND_R ScaleSprite8_OR ScaleSprite16_OR ScaleSprite32_OR ScaleSprite64_OR ScaleSprite8_OR_R ScaleSprite16_OR_R ScaleSprite32_OR_R ScaleSprite64_OR_R ScaleSprite8_XOR ScaleSprite16_XOR ScaleSprite32_XOR ScaleSprite64_XOR ScaleSprite8_XOR_R ScaleSprite16_XOR_R ScaleSprite32_XOR_R ScaleSprite64_XOR_R ScrollLeft160 ScrollLeft160_R ScrollLeft240 ScrollLeft240_R ScrollRight160 ScrollRight160_R ScrollRight240 ScrollRight240_R ScrollUp160 ScrollUp160_R ScrollUp240 ScrollUp240_R ScrollDown160 ScrollDown160_R ScrollDown240 ScrollDown240_R FastCopyScreen FastCopyScreen_R FastDrawLine FastDrawLine_R FastDrawHLine FastDrawHLine_R FastDrawVLine FastDrawVLine_R ClearGrayScreen ClearGrayScreen2B DrawGrayRect DrawGrayRect2B InvertGrayRect InvertGrayRect2B DrawGrayLine DrawGrayLine2B FastDrawGrayLine FastDrawGrayLine2B FastDrawGrayHLine FastDrawGrayHLine2B DrawGrayChar DrawGrayChar2B DrawGrayStr DrawGrayStr2B DrawGrayStrExt DrawGrayStrExt2B FloodFill FloodFillMF UnpackBuffer (or) ttunpack_decompress TestCollide8 TestCollide16the following predefined types:
GrayColors FillAttrs ExtAttrs TTUNPACK_HEADER TTARCHIVE_HEADER TTARCHIVE_ENTRYthe following global variables:
EXTGRAPH_VERSION_STR EXTGRAPH_VERSION_PWDSTR EXTGRAPH_VERSION_MAIN EXTGRAPH_VERSION_SUBand the following macros:
EXT_PIXOFFSET EXT_PIXADDR EXT_PIXMASK EXT_PIXNBIT EXT_PIXUP EXT_PIXDOWN EXT_PIXLEFT_AM EXT_PIXRIGHT_AM EXT_SETPIX_AM EXT_CLRPIX_AM EXT_XORPIX_AM EXT_GETPIX_AM EXT_SETPIX_AN EXT_CLRPIX_AN EXT_XORPIX_AN EXT_GETPIX_AN EXT_SETPIX EXT_CLRPIX EXT_XORPIX EXT_GETPIX ttarchive_valid ttarchive_entries ttarchive_desc ttarchive_data ttarchive_size ttarchive_info ttunpack_size ttunpack_valid TTUNPACK_OKAY TTUNPACK_NOESCFOUND TTUNPACK_ESCBITS TTUNPACK_MAXGAMMA TTUNPACK_EXTRALZP TTUNPACK_NOMAGIC TTUNPACK_OUTBUFOVERRUN TTUNPACK_LZPOSUNDERRUN BOUNDS_COLLIDE BOUNDS_COLLIDE8 BOUNDS_COLLIDE16 BOUNDS_COLLIDE32 These two macros are removed starting from 2.00, they are now integrated in TIGCC, in a more "transparent" way. /* CheckHWMatch() DESIRED_CALCTYPE */
#include "extgraph.h"to your sourcecode.
tigcc myprog.c extgraph.aIf you are using the IDE add extgraph.a to the archive file folder of your project. That's all. Simple, isn't it?
Courtesy of Jim Haskell (jimhaskell@yahoo.com) [routines slightly modified (and bugfixed) to fit the needs] New (faster) routines by Julien Richard-Foy (julien.rf@wanadoo.fr) are on the way.
DrawGrayStrExt(0,50,"Welcome!",A_REPLACE | A_CENTERED,F_4x6);will draw "Welcome!" horizontally centered at line 50 with font F_4x6.
Courtesy of Zeljko Juric (zjuric@utic.net.ba) [routine slightly modified to fit the needs]
Exepack-Compression is a compression algorithm which was initially developed to compress
executables (-pack option of TIGCC compiler) and to generate eBooks for TiCT's eBookReader.
Everything (tools, sources, headerfiles etc.) which is necessary to use this compression
in your own projects can be found in the TIGCC Tools Suite which can be download from the
TiCT-HQ at http://tict.ticalc.org.
To make things easy for you I have decided to integrate support for exepack
decompression and ttarchives into library ExtGraph. It's no longer necessary nor recommented
to include file ttunpack.h and ttarchive.h into your sources. Just include extgraph.h and
link against extgraph.a. That's all. To generate the compressed data files and ttarchive files
you still need the TIGCC Tools Suite, of course (especially the tools ttpack and ttarchive).
An exepacked file is just a single data file which is compressed using tool ttpack.
TTArchive files are, as the name already implies, archives which can hold many entries not just
one. Each entry can be compressed using ttpack or any other program before you stuff it into the
TTArchive file. Tool ttarchive won't care about the content of the entries at all.
To use the exepack decompression routine and/or the ttarchive access macros you'll need a pointer to the memory where the external variable is stored first. This can be simply done function like the following:
//------------------------------------------------------------------ // returns pointer to start of external variable which name is given // by fname. // if variable cannot be found NULL is returned // // NOTE: this routine internally locks the variable. Due to the fact // that the variable has to be unlocked again if you don't // need it anymore, it uses the given pointer to a HANDLE // to store the handle of the locked variable in it. //------------------------------------------------------------------ unsigned char* GetPointerToFile(char* fname,HANDLE* h) { SYM_ENTRY* symptr; unsigned char* src; if ((symptr = DerefSym(SymFind(SYMSTR(fname))))) { *h = symptr->handle; if (!(src = (unsigned char*)HLock(*h))) return NULL; src+=2; return src; } else { return NULL; } }
The Exepack decompression routine needs takes two pointers. A source and a destination pointer. The source pointer points to the memory which holds the exepacked destination and the destination pointer should point to a buffer which is large enough to hold the decompressed data. Suppose you have an external variable which hold the compressed data (generated with tool ttpack) and you have already implemented the above function GetPointerToFile(). Then decompressing this file can be easily done with a function like this:
//------------------------------------------------------------------ // decompresses an external variable and returns an allocated buffer // (don't forget to free the returned buffer) // // if an error occurs this function returns NULL //------------------------------------------------------------------ unsigned char* GetDecompressedData(char* fname) { HANDLE h; unsigned char* src = GetPointerToFile(fname,&h); unsigned char* dest; if (!src) return NULL; // file not found // check if data is really exepacked if (!ttunpack_valid(src)) { HeapUnlock(h); // data NOT valid - unlock locked variable again!! return NULL; } // allocate buffer for decompressed data if (!(dest = malloc(ttunpack_size(src)))) { HeapUnlock(h); // out of memory - unlock locked variable again!! return NULL; } // decompress the data if (ttunpack_decompress(src,dest) != TTUNPACK_OKAY) { free(dest); dest = NULL; } HeapUnlock(h); return dest; }
The first step to retrieve an entry of an archive is to get again a pointer to the start of the external variable which holds the ttarchive. The following code shows how to loop through all entries of an ttarchive which is stored in a variabled called "mydata". Of course, the following loop is not really useful, but it demonstrates almost everything which is necessary to now about TTArchives.
HANDLE h; unsigned char* src = GetPointerToFile("mydata",&h); if (!src) { // variable not found !!! } else { if (ttarchive_valid(src)) { unsigned short i; unsigned short nr_entries = ttarchive_entries(src); // get number of entries for (i=0;i<nr_entries;i++) { unsigned char* pointer_to_entry = ttarchive_data(src,i); unsigned short size_of_entry = ttarchive_desc(src,i)->length; unsigned char* decompressed; //----------------------------------------------------------------------- // Now we have a pointer to the entry and we know how large this entry is // If the entry is compressed we could easily decompress it like this: //----------------------------------------------------------------------- if (ttunpack_valid(pointer_to_entry)) { // this entry is compressed ... if ((decompressed = malloc(ttunpack_size(pointer_to_entry)))) { if (ttunpack_decompress(pointer_to_entry,decompressed) == TTUNPACK_OKAY) { //--------------------------------- // entry successfully decompressed. // do something with it. //--------------------------------- } free(decompressed); // free allocated memory for decompressed entry again } else { // out of memory!! } } else { // this entry is NOT compressed. Do something else with it .... } } } HeapUnlock(h); // unlock variable again .... }[The above routines are apriori tested thanks to Malcolm Smith (TRgenius). They used to contain at least one severe bug.]
Version Date Changes 2.00 Beta 2 - restrainted distribution xx/xx/2004 Tilemap engine widely updated, more functions and power (although currently incompatible with the "real" TIGCCLIB doublebuffering); documentation now in English, thanks to Malcolm Smith (TRGenius) for fixing our translation. Documentation update started, far from complete. Added a sprite function test program, see right above. Added another unpacking routine, the new one doesn't disable interrupts (slower but doesn't mess up grayscale). demo6 now uses the full 92+/V200 screen. Fixed various bugs: thanks to Jordan Krage (jmank88), Nicolas Lalevée (hibou), ? (Vertyos) for the report. Slightly optimized many (Gray)(Clip)SpriteX functions (jackiechan), other optimizations are on the way. Missing SpriteX8_MIRROR_HV_R written. New routines (GraySpriteX_SHADOW, transition effects, tile (aligned sprite) routines, (Gray)(Clip)SpriteX_RPLC, non-clipped outlined circle drawing, etc.).
Various other routines are on the way (preshifted sprites, more rectangle-drawing routines, more transition effects...). We're open to suggestions up to some extent, too.2.00 Beta 1 19/12/2003 Tilemap engine added (documentation currently in French, it will be translated into English ASAP). Small changes in the documentation. 2.00 "Beta 0" 18/12/2003 Massive update !
Credits for this version go to:
- Julien Richard-Foy (jackiechan): the vast majority of sprite routines, the upcoming tilemap engine, new scaling routines, several line routines... He's the main contributor, of course. The majority of the work for this version was done by him.
- Christophe Molon-Noblot (Ximoon): SpriteX8 routines.
- Olivier Armand (ExtendeD): generic line routine supporting the three drawing modes (optimized a bit).
- Lionel Debroux: general maintaining, reorganization of the library, tests.
- Greg Dietsche, Samuel Stearley: updated unpacking routine (safe and faster). Current hexarray taken from SuperStart.
1.02 22/05/2002 Stepped back to old version of decompression function, because the new one causes random errors to be thrown. For TIGCC versions greater than 0.93 all functions are declared with "__attribute__((__stkparm__))" in extgraph.h to work correctly with commandline switch -mregparm 1.01 08/05/2002 Bug in exepack decompression function fixed. Thanks to MastaZog from the TIGCC Programming Forum for the report. 1.00 05/04/2002 Address calculations in almost all routines changed for speedup (using 0x1e instead of 0xffffe). Thanks to Francesco Orabona (bremen79@infinito.it) for this suggestion. Macros for bounding rectangle collision testing (BOUNDS_COLLIDE,BOUNDS_COLLIDE8, BOUNDS_COLLIDE16 and BOUNDS_COLLIDE32) added Functions for Collision detection (TestCollide8() and TestCollide16()) added bug in macro EXT_PIXOFFSET (missing brackets) fixed. Thanks to Greg Dietsche (greg@gregd.org) for the report. Demo11 added which shows how to use the collision detection functions TestCollide8() and TestCollide16() 0.97 02/04/2002 Function FastDrawVLine() added (thanks Lionel, for the original code) All functions which takes a color argument optimized by using internally the fact that the color values are bit-flags Demo1 is built now separately for each calctype to reduce codesize 2 bugs in FastDrawHLine() fixed by Francesco Orabona (bremen79@infinito.it) 0.95 25/02/2002 FastDrawHLine: missing static keyword for local array added to gain speed and size reduction Local arrays in scaling function declared static to gain speed and size ClearGrayScreen2B - converted to ASM file (.s) FastCopyScreen - converted to ASM file (.s) Exepack decompression routine added (taken from TIGCC Tools Suite) ttunpack.h and ttarchive.h integrated into extgraph.h for ease of use Section about Exepack Decompression and TTArchives added to docs 0.90 22/02/2002 Demos modified by Lionel Debroux (lionel_debroux@yahoo.fr) Utilities: EXTGRAPH_VERSION_STR, EXTGRAPH_VERSION_PWDSTR, EXTGRAPH_VERSION_MAIN, EXTGRAPH_VERSION_SUB added Utilities: CheckHWMatch() and DESIRED_CALCTYPE added 0.87 05/02/2002 Adaptions to compile correctly with TIGCC 0.93 and beyond 0.86 31/07/2001 ClearGrayScreen2B and FastCopyScreen converted to pure ASM routines Function FastDrawHLine added (horizontal line drawing) Functions FastDrawGrayHLine/FastDrawGrayHLine2B added Misstyped -w option changed to -W in batch files Misstyped -w option changed to -W in batch files All problems reported by -W fixed Routines DrawGrayChar and DrawGrayChar2B added Warning added to docs of FastCopyScreen Grayscale variants of sprite drawing routines added Documentation of SpriteX_BLIT functions fixed Typo in macro EXT_PIXADDR fixed (thanks FlashZ for reporting) 0.80 31/05/2001 Routines FloodFill and FloodFillMF added Demo8 (floodfill demo) added Routines SpriteX8_MIRROR_H and SpriteX8_MIRROR_V added Demo9 (sprite x8 mirror demo) added ClearGrayScreen re-implemented as very fast ASM loop Routine FastCopyScreen added Demo10 (fastcopyscreen demo) added 0.76 22/05/2001 Format information of wide sprites added to X8 functions Misstyped macro DrawGrayRect() fixed Second bug in treatment of x position in ALL scaling routines fixed ClearGrayScreen/ClearGrayScreen2B added SpriteX8_MASK and SpriteX8_BLIT fixed Usage info changed 0.75 17/05/2001 All TABs removed from the sources Grayscale support routines for doublebuffering added (DrawStr2B etc.) Problems with grayscale support routines fixed Demo6 and demo7 programs added Wide sprite routines (SpriteX8_OR/_AND/_XOR/_BLIT/_MASK/Get) added x position treatment in scaling routines fixed 0.70 15/05/2001 Fast Pixel Access Macros added FastDrawLine supports now A_NORMAL, too DrawGrayStrExt restores now previously active font Documentation of KronicDeth reformatted and incorporated 0.51 07/05/2001 Sprite scale routines added 0.50 06/05/2001 Sprite get routines added 0.30 14/04/2001 Grayscale routines added (taken from TI-Chess and slightly modified) 0.20 13/04/2001 Sprite routines added (formerly released as TSE) and library renamed to extgraph 0.10 12/04/2001 Project started (scroll routines and linedrawing routine)