BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
richunkylib.c File Reference
#include "blitzlib.h"
#include <graphics/gfx.h>

Data Structures

struct  chunky
struct  c2pargs

Macros

#define WIDTHHEIGHT(o)
#define PLSIZ   10240 /* 320*256/8 */
#define C2P8
#define C2PFLUSH(SZ, OFF)

Functions

void _chunkybitmap (void)
void _c2p (void)
void _p2c (void)
void _chunkyloadbitmap (void)
void _chunkydata (void)
void _raycastsky (void)
 RaycastSky chunky#,x,height,column,&texture: height bytes of a texture column to a chunky column, both 320 bytes apart.
void _dofreechunkybitmap (void)
void richunkylib_libinit (void)
void richunkylib_libfinit (void)
void raycastchk (void)
void c2pchk (void)
static void nothing_c (void)
 init, finit, PlanarToChunky bitmap#,chunky# and ChunkyLoadBitMap filename$,chunky#: no code (RTS).
static void freechunky (struct chunky *o, ULONG callerd1)
static void dofreechunkybitmap_c (ULONG callerd1, struct chunky *o)
 The object manager's free routine (_free): frees a chunky object's data.
static void chunkybitmap_c (ULONG w, ULONG h, struct chunky *o)
 ChunkyBitmap chunky#,width,height: a chunky object of width*height bytes (memlib globalloc, MEMF_CLEAR), depth 8.
static ULONG chunkydata_c (struct chunky *o)
 ChunkyData(chunky#): the address of the chunky data.
void c2pcore (void)
static void c2p_run (const struct c2pargs *a)
static int planestride (const struct BitMap *bm, LONG *ps)
static void c2p_c (struct chunky *o, struct BitMap *bm)
 ChunkyToPlanar chunky#,bitmap#: chunky to planar (C2P), the chunky bitmap to the top left of the bitmap's 8 planes.
static void raycastchk_c (ULONG x, ULONG h, ULONG col, const struct chunky *o)
 The error check of RaycastSky (debugger only).
static void c2pchk_c (const struct chunky *o, const struct BitMap *bm)
 The error check of ChunkyToPlanar (debugger only).

Macro Definition Documentation

◆ C2P8

#define C2P8

◆ C2PFLUSH

#define C2PFLUSH ( SZ,
OFF )
Value:
" move." SZ " " OFF "(a6),(a1)\n" /* plane 7 */ \
" suba.l a2,a1\n" \
" move." SZ " -(a6),(a1)\n" /* plane 6 */ \
" suba.l a2,a1\n" \
" move." SZ " " OFF "(a5),(a1)\n" /* plane 5 */ \
" suba.l a2,a1\n" \
" move." SZ " -(a5),(a1)\n" /* plane 4 */ \
" suba.l a2,a1\n" \
" move." SZ " " OFF "(a4),(a1)\n" /* plane 3 */ \
" suba.l a2,a1\n" \
" move." SZ " -(a4),(a1)\n" /* plane 2 */ \
" suba.l a2,a1\n" \
" move." SZ " " OFF "(a3),(a1)\n" /* plane 1 */ \
" suba.l a2,a1\n" \
" move." SZ " -(a3),(a1)\n" /* plane 0 */ \
" adda.l 8(sp),a1\n" /* back: plane 7, the next long */

◆ PLSIZ

#define PLSIZ   10240 /* 320*256/8 */

◆ WIDTHHEIGHT

#define WIDTHHEIGHT ( o)
Value:
(*(ULONG *)&(o)->width)
UWORD width
Definition polylib.c:226

Function Documentation

◆ _c2p()

void _c2p ( void )

◆ _chunkybitmap()

void _chunkybitmap ( void )

◆ _chunkydata()

void _chunkydata ( void )

◆ _chunkyloadbitmap()

void _chunkyloadbitmap ( void )

◆ _dofreechunkybitmap()

void _dofreechunkybitmap ( void )

◆ _p2c()

void _p2c ( void )

◆ _raycastsky()

void _raycastsky ( void )

RaycastSky chunky#,x,height,column,&texture: height bytes of a texture column to a chunky column, both 320 bytes apart.

x and column are added as signed words (offsets: x may hold rows of 320 bytes); with runtime error checking raycastchk refuses a column that leaves the chunky data and a negative texture column (fixed, #887), the release code checks nothing. A height below 1 copies nothing: fixed (#887), the original's DBRA count height - 1 copied 65536 rows for a height of 0 (BLT after the SUBQ: 8 cycles per call). An assembler entry in the original's form, without a thunk (a user-level statement: it changes d2, a0 and a1, as the original, which the register rule allows): the per-column call of a ray caster, at the original's speed (bchunky.raycast*). In: d1 x (the offset in the chunky data, a signed word), d2 the height (a word), d3 the column (the offset in the texture, a signed word), d4 the texture, a0 the object.

◆ c2p_c()

void c2p_c ( struct chunky * o,
struct BitMap * bm )
static

ChunkyToPlanar chunky#,bitmap#: chunky to planar (C2P), the chunky bitmap to the top left of the bitmap's 8 planes.

Nothing without chunky data, nothing for a bitmap of depth below 8. Fixed (#884): the chunky bitmap's width and height are converted, row by row with the bitmap's BytesPerRow, into planes that are equally spaced (the stride from the plane pointers, checked once per call); nothing (with runtime error checking c2pchk's error) for a width that is not a multiple of 16, a chunky bitmap wider or higher than the bitmap, or planes that are not equally spaced. The original always converted 320 x 256 pixels into planes 10240 bytes apart from plane 0, reading behind smaller chunky data and writing behind smaller bitmaps. Fixed (#883): the depth is the byte Depth; the original compared Flags and Depth as one signed word. The conversion is c2pcore, the original's merge network in assembler (speed).

Parameters
oa0: the chunky object
bma1: the bitmap (a struct BitMap)

◆ c2p_run()

void c2p_run ( const struct c2pargs * a)
static

◆ c2pchk()

void c2pchk ( void )

◆ c2pchk_c()

void c2pchk_c ( const struct chunky * o,
const struct BitMap * bm )
static

The error check of ChunkyToPlanar (debugger only).

Fixed (#884), not in the original: the shapes ChunkyToPlanar refuses without a word in release code. Nothing for a bitmap of depth below 8 or a chunky bitmap without data (the release code does nothing there, as the original).

Errors: "Chunky bitmap width not a multiple of 16", "Chunky bitmap larger than the bitmap" (wider than BytesPerRow * 8 or higher than Rows), "Bitmap planes not equally spaced" (the 8 plane pointers).

Parameters
oa0: the chunky object
bma1: the bitmap

◆ c2pcore()

void c2pcore ( void )

◆ chunkybitmap_c()

void chunkybitmap_c ( ULONG w,
ULONG h,
struct chunky * o )
static

ChunkyBitmap chunky#,width,height: a chunky object of width*height bytes (memlib globalloc, MEMF_CLEAR), depth 8.

Amiga mode only. An object with data is freed first, decided by the data pointer: fixed (#885), the original tested the long at offset 6 (the unused word and the pointer's upper word), so data below $10000 was never freed and a failing allocation left the old pointer in the object. On failure ('cantalloc) width, height and depth are 0.

Parameters
wd1: the width (a word)
hd2: the height (a word)
oa0: the object (!libs richunkylib,ia0|pd0)

◆ chunkydata_c()

ULONG chunkydata_c ( struct chunky * o)
static

ChunkyData(chunky#): the address of the chunky data.

Parameters
oa0: the object
Returns
d0: the data, 0 if the object has none

◆ dofreechunkybitmap_c()

void dofreechunkybitmap_c ( ULONG callerd1,
struct chunky * o )
static

The object manager's free routine (_free): frees a chunky object's data.

As freechunky: nothing without data, else globfree and the fields cleared (fixed, #886: the original also toggles CIA-A PRA bit 1).

Parameters
callerd1d1: the caller's d1 (its upper word goes to lmullib)
oa3: the object

◆ freechunky()

void freechunky ( struct chunky * o,
ULONG callerd1 )
static

◆ nothing_c()

void nothing_c ( void )
static

init, finit, PlanarToChunky bitmap#,chunky# and ChunkyLoadBitMap filename$,chunky#: no code (RTS).

The two commands are declared but do nothing (their arguments are ignored).

◆ planestride()

int planestride ( const struct BitMap * bm,
LONG * ps )
static

◆ raycastchk()

void raycastchk ( void )

◆ raycastchk_c()

void raycastchk_c ( ULONG x,
ULONG h,
ULONG col,
const struct chunky * o )
static

The error check of RaycastSky (debugger only).

Fixed (#887), not in the original (richunkylib had no error check area): RaycastSky adds x and column to the chunky data and the texture as signed words and copies height bytes 320 apart without a look at the chunky bitmap: a negative x wrote before the chunky data, an x whose column runs past the last row behind it, a negative column read before the texture. The release code is unchanged (invalid arguments, D-005). A height below 1 is not checked: RaycastSky copies nothing for it (fixed, #887).

Errors: "RaycastSky outside the chunky bitmap" (x below 0, or x + 320 * (rows - 1) not below width * height: also an object without data), "RaycastSky column below 0" (column, a word, below 0).

Parameters
xd1: the offset in the chunky data (a word)
hd2: the number of rows (a word)
cold3: the offset in the texture (a word)
oa0: the object

◆ richunkylib_libfinit()

void richunkylib_libfinit ( void )

◆ richunkylib_libinit()

void richunkylib_libinit ( void )