/* MISC.C - Stuff that has no where else to go */

#include "lsdino.h"
#include "lsdincl\endscrn.h"
#include <disp.h>

void notenoughmem(char *s)
{
        txtmode();
        printf("Error: LSDino does not have enough memory for %s\r\n",s);
        exit(1);
}


/* This routine is the general put-pix routine.  A call to it allows you to
   put a pixel onto the screen in several different ways.  There are #define's
   in lsdino.h which are the different types.
*/
void putpixtype(int x, int y, int color,int type)
{
     if(type&0xFF0)
	    distort(type,x,y,&color);
     switch(type&0x0F){
	    case NORMAL: putpix(x,y,color); break;
	    case XOR:    putpix(x,y,getpix(x,y)^color); break;
	    case OR:     putpix(x,y,getpix(x,y)|color); break;
	    case AND:    putpix(x,y,getpix(x,y)&color); break;
	    case AVG:    putpix(x,y,(getpix(x,y)*avg_first+color*avg_second)/(avg_first+avg_second)); break;
	    case BLEND:  putpix(x,y,(getpix(x,y)*y-3+ color*(200-y))/200); break;
	  case DBLAVG: break;
     }
}

/* End of the program, wrap it up and say good bye! */
void end(void)
{
        int i;

        txtmode();
        disp_open(); /* Symantec function - opens up the display library */
        disp_pokebox((unsigned short *)ENDSCRN,0,0,24,79); /* pop up our
                end screen */
        disp_move(14,0);
        disp_printf(" %s %s - Compiled on %s @ %s\n\n",__DATE__,__TIME__,version,vernum);
        disp_printf(" E-Mail Address: viehland@umr.edu\n");
        disp_printf(" World Wide Web: http://www.umr.edu/~viehland\n\n");
        disp_printf(" Run with -help option for help (or read the docs).\n");
        disp_printf(" For those who haven't read the docs, try lsdino -rand@3\n");
        for(i=0;i<23;i++)
                printf("\r\n");
        exit(1);
}
