#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <exec/memory.h>
#include <setjmp.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <libraries/arpbase.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <arpfunctions.h>

#define DEPTH 4
#define SCRNY 80
#define NCOLS (1<<DEPTH)
#define MAXPICS 100
#define PICBUFSIZE 480
#define LITX0 2
#define LITY0 3
#define SIZEX 36
#define SIZEY 20
#define LITX1 (LITX0+SIZEX-1)
#define LITY1 (LITY0+SIZEY-1)
#define BIGPIX 4
#define YDELTA (BIGY0-4*LITY0)
#define LTOBX(N) (((N)<<2))
#define LTOBY(N) (((N)<<2)+YDELTA)
#define BTOLX(N) (int)((N)>>2)
#define BTOLY(N) (int)(((N)-YDELTA)>>2)
#define BIGX0 LTOBX(LITX0)
#define BIGX1 (LTOBX(LITX1)+(BIGPIX-1))
#define BIGY0 (LITY1+10)
#define BIGY1 (LTOBY(LITY1)+(BIGPIX-1))
#define COLOR(N) SetAPen(rp,(N))
#define STDCOL { SetAPen(rp,maincolor); SetBPen(rp,0); }
#define POINT(X,Y) ReadPixel(rp,(X),(Y))
#define BIGPLOT(X,Y) RectFill(rp,LTOBX(X),LTOBY(Y),LTOBX(X)+(BIGPIX-1),LTOBY(Y)+(BIGPIX-1))
#define PSET(X,Y) WritePixel(rp,(X),(Y))
#define PSETC(X,Y,C) { SetAPen(rp,C); PSET(X,Y); }
#define BOTHPLOT(X,Y) { WritePixel(rp,X,Y); BIGPLOT(X,Y); }
#define OPPOSITE(P,P0,P1) ((P1)+(P0)-(P))
#define ISOK(X,Y) (X)>=0 && (Y)>=0 && (X)<SIZEX && (Y)<SIZEY
#define FOR(I,L,H) for ((I)=(L); (I)<=(H); (I)++)
#define INDEX(X,Y) (SIZEY*(X)+(Y))
#define MAXNAMELEN 32
#define PALX (640 >> DEPTH)
#define PALY ((256-SCRNY)-10)
#define NOPTR SetWaitPointer(w)

#define display(S) FPrintf(dfh,"%s\n",(S))

extern struct Window *w, *dw;
extern struct Screen *s;
extern struct RastPort *rp;
extern struct BitMap picbm;
extern struct ViewPort *vp;
extern jmp_buf jmpsave;
extern BPTR dfh;
extern int picx0[MAXPICS+1], picy0[MAXPICS+1];
extern char picbuf[PICBUFSIZE];
extern int maincolor, mx, my, button, minundo, npic;
