/* MBrotScan.c
 * Fast parallel Mandelbrot set scanner
 * By Neil A Carson, RiscBSD kernel team, 1996 A.D.
 */

#ifndef __MBROT_H

#define __MBROT_H


/* Size of the grid used
 */
#define BLOCK_SIZE        9

/* Screen data
 */
#define SCREEN_S          477
#define SCREEN_W          640
#define SCREEN_H          480

/* Below this sizw we use 32-bit iteration, not 16
 */
#define SIZE_THRESH 0.15F

/* Data structure for passing list of things to plot to veneer
 */
typedef struct
{
    int calculated;                  /* Has this been calculated yet..? (0/1) */
    int x;                           /* *Mandelbrot* coordinates for this box */
    int y;
    int s;
    int bx;                          /* *Screen* coordinates for this box */
    int by;
    int bs;
} result_data_t;

/* Shift from fixed to FP
 */
#define SHIFT (1 << 29)

/* Exit with an error
 */
#define Exit_Error(x) { printf("MBrot error: %s\n", x); exit(0); }

/* Initialise the veneer, ie. load the code onto any CPU's necessary, and get
 * ready to rumble. If prec=1 then use high precision iteration, otherwise if
 * prec=0 then don't (use low precision, 16 bit)
 */
extern void veneer_start(int prec);

/* Initialise a place to put ``result'' data. The veneer should add a word at
 * the beginning, if it has any sense, to store a semaphore.
 */
extern result_data_t *veneer_get_result(int size_int_bytes);

/* Calculate the Mandelbrot set
 */
extern void veneer_fork(int squares, int maxiter, result_data_t *r);

/* Close down the veneer
 */
extern void veneer_close_down(void);

/* Have we finished...?
 */
extern int veneer_finished(void);

/* Change screen mode to 640x480 and return start address
 */
extern char *veneer_change_mode(void);

#endif
