richunkylib
This library keeps chunky bitmaps: images with one byte per pixel,
which a program can draw into with plain Pokes, and converts them to
the planar bitmaps the Amiga displays. Chunky bitmaps are numbered
Blitz objects of their own, 0 to 7 by default; ChunkyBitmap makes
one and ChunkyData gives the address of its pixels, row after row.
The memory of a chunky bitmap is freed at the end of the program.
ChunkyToPlanar converts a chunky bitmap into the top left of a
bitmap of 8 bitplanes (256 colours) that is at least as big. The width
of the chunky bitmap must be a multiple of 16 pixels, and the
bitplanes of the bitmap equally far apart, one after the other in one
block of memory or interleaved. RaycastSky, which copies a column of
a texture for a ray caster, assumes rows of 320 bytes in the chunky
bitmap and in the texture. PlanarToChunky and ChunkyLoadBitMap
were never written and do nothing. ChunkyBitmap works in Amiga mode
only.
ChunkyToPlanar is a little faster than the original’s, and
RaycastSky about as fast.
A chunky bitmap with one dot, converted into a bitmap whose planes lie in one block of chip memory:
ChunkyBitmap 0,320,256
Poke.b ChunkyData(0)+100*320+160,255
m.l=AllocMem_(81920,$10002)
CludgeBitMap 1,320,256,8,m
ChunkyToPlanar 0,1Library number 24. It manages ChunkyBitmap objects, by default at most 8 (the compiler options set the maximum).
Commands
ChunkyBitmap
Makes a chunky bitmap of width x height pixels, one byte each, all 0. Data the object held before is freed first.
Statement. Help text: bitmap#,width,height
Arguments: .w, .w, .w
Amiga mode only. If the memory cannot be allocated, the program stops with the runtime error “Out of Memory!”.
ChunkyData
Returns the address of the pixels of a chunky bitmap, 0 if it has none.
Function, result .l. Help text: chunkybitmap#
Arguments: .w
ChunkyLoadBitMap
Does nothing; the command was never written.
Statement. Help text: filename$,chunkybitmap#
Arguments: $, .w
ChunkyToPlanar
Converts a chunky bitmap into the eight bitplanes of a bitmap. Its width x height pixels go to the top left of the bitmap, row by row; the width must be a multiple of 16, and the bitmap at least as wide and as high.
Statement. Help text: chunkybitmap,bitmap --320x256x8 bitmap
Arguments: .w, .w
The bitplanes of the bitmap must be equally far apart, as they are when they lie one after the other in one block of memory or are interleaved. Nothing happens if the bitmap has fewer than 8 bitplanes or the chunky bitmap has no data.
A chunky bitmap whose width is not a multiple of 16, one that is wider or higher than the bitmap, and a bitmap whose bitplanes are not equally far apart are not converted, and nothing is written. With runtime error checking these are the errors “Chunky bitmap width not a multiple of 16”, “Chunky bitmap larger than the bitmap” and “Bitmap planes not equally spaced”. The help line names a 320x256x8 bitmap, the only size the original library converted.
PlanarToChunky
Does nothing; the command was never written.
Statement. Help text: bitmap,chunkybitmap --320x256x8 bitmap
Arguments: .w, .w
RaycastSky
Copies height bytes of a column of a texture into column x of a chunky bitmap, both with rows of 320 bytes. column is the column in the texture, &texture the address of the texture.
Statement. Help text: chunkybitmap#,x,height,column,&texture
Arguments: .w, .w, .w, .w, .l
A height below 1 copies nothing. x and column are offsets from
the start of the chunky bitmap and of the texture, so x may also
hold whole rows of 320 bytes.
With runtime error checking, an x below 0, or one whose column
would run past the end of the chunky bitmap, is the error
“RaycastSky outside the chunky bitmap”, and a column below 0 is
the error “RaycastSky column below 0”. Without runtime error
checking, neither is checked, and such a call writes or reads
outside the chunky bitmap or the texture.