The Blitz2 Chunky Library (lib #72) - Acid Software --------------------------------------------------- The chunkylib provides functions for manipulating 24 bit graphics. The format for the standard chunky object is: NEWTYPE .chunky tloc.l:tlen ;24 bit (true color) gloc.l:glen ;8 bit (grey scale) width.w:height:flags ;16 size (fixed in scale) wwidth.w End NEWTYPE There are two data fields one for true colour and the other for grey scale. The colour layout is byte per colour (red,green,blue) interleaved each line: rrrrrrrrrrrrrrggggggggggggggbbbbbbbbbbbbbb rrrrrrrrrrrrrrggggggggggggggbbbbbbbbbbbbbb rrrrrrrrrrrrrrggggggggggggggbbbbbbbbbbbbbb rrrrrrrrrrrrrrggggggggggggggbbbbbbbbbbbbbb rrrrrrrrrrrrrrggggggggggggggbbbbbbbbbbbbbb rrrrrrrrrrrrrrggggggggggggggbbbbbbbbbbbbbb rrrrrrrrrrrrrrggggggggggggggbbbbbbbbbbbbbb rrrrrrrrrrrrrrggggggggggggggbbbbbbbbbbbbbb rrrrrrrrrrrrrrggggggggggggggbbbbbbbbbbbbbb The width of a chunky object is rounded up to the nearest 16 pixel boundary for purposes of memory storage. InitChunky Chunky#,width,height,flags (1=24bit 2=8bit) ------------------------------------------------------ Initialises a blank chunky object. Both 24 bit and 8 bit pixelmaps can be created with a flags value of 3. FreeChunky Chunky# ------------------ Frees the chunky object and any memory allocated to it. LoadChunky Chunky#,IFFfilename$ ------------------------------- Creates a chunky object the same size as that of the file, and loads the image into it, currently only creates a 24 bit pixel map. Source IFF can be either palette or 24bit based, HAM not supported. SaveChunky Chunky#,IFFfilename$ ------------------------------- Saves the 24 bit pixel map from the chunky to standard 24bit IFF file. ReadChunky Chunky#,rawfilename$ ------------------------------- Reads memory from a file directly into the initialised 24 bit pixel map of a chunky. WriteChunky Chunky#,rawfilename$ -------------------------------- Writes memory to a file directly from the 24 bit pixel map of a chunky. ProcessChunky chunky#,contrast ------------------------------ Enhances the contrast of a chunky's grey scale map and adjusts 24bit version with result. Chunky MUST have grey pixel map (use Grey Chunky to create one). AdjustChunky chunky#,DeltaRed,DeltaGreen,DeltaBlue -------------------------------------------------- Adjusts level of color components in 24 bit pixel map. ScaleChunkyX srcchunky#,destchunky#,newwidth -------------------------------------------- Creates new chunky modifying source to target width. ScaleChunkyY srcchunky#,destchunky#,newheight --------------------------------------------- Creates new chunky modifying source to target height. CopyChunky srcchunky#,destchunky#,[sx,sy,w,h,dx,dy] --------------------------------------------------- Sort of chunky scroll command at the best of times. GreyChunky chunky# ------------------ Create grey pixel map from 24 bit in same chunky. KillGreyChunky chunky# ---------------------- Frees only grey chunky memory. ColorChunky chunky# ------------------- Creates 24bit pixel map from grey pixel map. ChunkyLoc chunky# ----------------- Retures location of chunky in memory. ChunkyConvert chunky#[,palette]|[,array.l(),numcols] ---------------------------------------------------- Creates a regular palette based pixel map in the grey pixel map memory using either a palette or fast look up array. ChunkyToBitMap Chunky#,Bitmap# ------------------------------ Converts the grey pixel map (usually from ChunkyConvert command) to regular Amiga BitMap. The BitMap must be initialised with correct depth and size prior to use. CPlot Chunky#,x,y[,color.l],[red.b,green.b,blue.b] -------------------------------------------------- Plot pixel onto chunky 24bit pixelmap either in rgb format or packed rgb format (low 24 bits of 32 bit long). GPlot Chunky#,x,y,color.b ------------------------- Plot to grey pixel map of chunky. CPoint (Chunky#,x,y) -------------------- Return color from 24bit pixel map in packed rgb format (low 24 bits of 32 bit long). GPoint (Chunky#,x,y) -------------------- Retrun color from grey pixel map. Col8 (array.l(),numcols,rgb.l) ------------------------------ Hmmm, what did this do? Where's the create suitable palette command gone??? Extra displaylib commands ------------------------- The following 3 commands are used with the new chunky display method (AGA only) supported in Blitz2 for cheesy blocky but fast polygon based display. CustomChunky CopList#,CCOffset,YPos,width,height,res[,splitpos] ;4n+2 --------------------------------------------------------------------- Creates a custom chunky (cheese) display inside a coplist, make sure enough custom cops have been allocated! CustomChunkySize width,height ----------------------------- Returns number of custom cops required for given cheese display, useful for avoiding writing all over your display copper lists. DisplayGenlock BPLCON0 ;2=use external sync 4=interlace ---------------------- Sets genlock bit for displays, would be nice to work out how OS knows an external clock is attached but don't know so we have to do it manually. The Chock Library ----------------- By installing a complex copper list an AGA Amiga can change a color in it's hardware palette table around 96 times per scan line. By creating a 256 color display, laying out a grid of consecutive colored blocks and hitting the palette in such a manner a Chock display can be created. The Blitz chock library offers a small number of very fast rendering commands to operate on such displays. Chock is inherently low resolution, a standard 96x96 pixel display being as good as it gets, however each pixel can be any of 4096 colours without restriction. As chock displays are based around the copper list, double buffering involves swapping between coplists and NOT bitmaps, all chock commands operate on the currently USED coplist. ChunkyCLS color ChunkyPlot x,y,color,[,CLIP] ChunkyVlin x,y1,y2,color,[,CLIP] ChunkyPoly numpts,*coords.w,color[,noblitter] Those interested in texture mapping style routines may do well to use a work buffer in fastmem for rendering before copying to slower chipmem based chocklist.