/* fade.h */

/* For fading the screen */

#ifndef __fade_h
#define __fade_h

#include "scrn.h"

/* Palette entry */
typedef union {
  int value;
  struct {
    char dummy;
    char red;
    char green;
    char blue;
  } rgb;
} fade_rgb;

/* Table of 8-bit colours (look up one colour to find its slightly faded value)
 */
typedef struct {
  char value[256];
} fade_table;

/* Set up RGB table */
void fade_init(void);

/* Fade whole screen */
void fade_screen(void);

/* Fade one 'character' */
void fade_man(void *addr);

/* Machine code functions to perform one fade iteration
   src and dest are current and new screen bank addresses
 */
extern void fadecode_screen(void *dest,void *src,fade_table table,
	      		    int scr_rowsize);

extern void fadecode_screen_vga(void *dest,void *src,fade_table table,
	      		    	int scr_rowsize);
extern void fadecode_man(void *dest,void *src,void *dummy,fade_table table,
	      		 int scr_rowsize);
extern void fadecode_man_vga(void *dest,void *src,void *dummy,fade_table table,
	      		     int scr_rowsize);

/* Pointers to fade functions */
typedef void (fade_fader *)(void *dest,void *src,fade_table table,
	      		    int scr_rowsize);
fade_fader screen_fader;
fade_fader man_fader;

/* Internal functions for setting up table
   These may also come in handy for PC's, say, if it is necessary to program
   the palette to match the Archimedes' */
int fade_rgb_to_byte(fade_rgb rgb);
int fade_byte_to_rgb(int byte);

#endif
