/*

	init.c - initialisations/definitions of structures and arrays,
	and definitions of constants pertaining thereto. :-)

*/


/*
	Emulator preferences
*/
struct specPrefs {
    WORD dummy;
} specPrefs = {
    0
};



/*
	Interrupt handler control data (for all interrupt handlers used).

	Must match the structure defined in asm.a (VBServer section) !!

*/
struct intControl {
    struct Z80_Control *Z80_Ctrl;   /* A quick reference pointer */
    UWORD frozen;  /* Nonzero if emulation is frozen */
	/* periods are in number of vertical blankings */
	/* a zero period turns off the handling */
    UWORD INTperiod, INTcount;
    UWORD UPDtype, UPDperiod, UPDcount;
    UWORD FLASHstate, FLASHperiod, FLASHcount;
} intControl = {
    NULL,
    0,
    1, 1,
    1, 1, 1,  /* type 1, complete screen recalculation, on first update */
    0, 25, 25,	/* flash state starts as "true video" */
};



/*
	Definitions for the Intuition interface:
*/

#define TXTHEIGHT 10


/*  Menu definitions */

#define MENUTXTCOL 6
#define CPUMENUWIDTH 75

static struct IntuiText cputext[] = {
    { MENUTXTCOL,0, JAM1, 1,1, NULL, "INT", NULL },
    { MENUTXTCOL,0, JAM1, 1,1, NULL, "NMI", NULL },
    { MENUTXTCOL,0, JAM1, 1,1, NULL, "RES", NULL }
};

static struct MenuItem cpuitems[] = {
    /* INT, shortcut 'I' */
    { &cpuitems[1], 0, 0, CPUMENUWIDTH, TXTHEIGHT,
    ITEMTEXT | COMMSEQ | ITEMENABLED | HIGHCOMP,
    0, &cputext[0], NULL, 'I', NULL, MENUNULL
    },

    /* NMI, shortcut 'N' */
    { &cpuitems[2], 0, TXTHEIGHT, CPUMENUWIDTH, TXTHEIGHT,
    ITEMTEXT | COMMSEQ | ITEMENABLED | HIGHCOMP,
    0, &cputext[1], NULL, 'N', NULL, MENUNULL
    },

    /* RESET, shortcut 'R' */
    { NULL, 0, TXTHEIGHT*2, CPUMENUWIDTH, TXTHEIGHT,
    ITEMTEXT | COMMSEQ | ITEMENABLED | HIGHCOMP,
    0, &cputext[2], NULL, 'R', NULL, MENUNULL
    }
};

#define SYSMENUWIDTH 120

static struct IntuiText systext[] = {
    { MENUTXTCOL,0,JAM1, 1,1, NULL, "Save Prefs", NULL },
    { MENUTXTCOL,0,JAM1, 1,1, NULL, "Quit", NULL }
};

static struct MenuItem sysitems[] = {
    /* Save prefs */
    { &sysitems[1], 0,0,SYSMENUWIDTH,TXTHEIGHT,
    ITEMTEXT /* | ITEMENABLED */ | HIGHCOMP,
    0, &systext[0], NULL, 0, NULL, MENUNULL
    },

    /* Quit, shortcut 'Q' */
    { NULL, 0,TXTHEIGHT,SYSMENUWIDTH,TXTHEIGHT,
    ITEMTEXT | COMMSEQ | ITEMENABLED | HIGHCOMP,
    0, &systext[1], NULL, 'Q', NULL, MENUNULL
    }
};

struct Menu mainmenu[] = {
    { &mainmenu[1], 0,0,56,0, MENUENABLED,
	"System", &sysitems[0] },
    { NULL, 64,0,CPUMENUWIDTH+4,0, MENUENABLED,
	"Processor", &cpuitems[0] }
};


/* Screen and window definitions */

#define PLVAL 0x0b
#define BRVAL 0x0f

struct ColorSpec screenColors[] = {
    /* colour 0 is the border (background) colour */
    { 0, 0x08, 0x08, 0x08 }, { 1, 0, 0, PLVAL },
    { 2, PLVAL, 0, 0 }, { 3, PLVAL, 0, PLVAL },
    { 4, 0, PLVAL, 0 }, { 5, 0, PLVAL, PLVAL },
    { 6, PLVAL, PLVAL, 0 }, { 7, PLVAL, PLVAL, PLVAL },

    /* colour 8 is used for both "plain black" and "bright black" */
    { 8, 0, 0, 0 }, { 9, 0, 0, BRVAL },
    { 10, BRVAL, 0, 0 }, { 11, BRVAL, 0, BRVAL },
    { 12, 0, BRVAL, 0 }, { 13, 0, BRVAL, BRVAL },
    { 14, BRVAL, BRVAL, 0 }, { 15, BRVAL, BRVAL, BRVAL },

    { -1, 0, 0, 0 }
};

#define DETAILPEN 8
#define BLOCKPEN 15

UWORD screenPens[] = {
    /* detail, block, text, shine, shadow, fill,
       filltext, background (0), highlight */
    DETAILPEN, BLOCKPEN, 8, 15, 1, 5, 8, 0, 10, ~0
};

struct TagItem screenTags[] = {
    { SA_DisplayID, LORES_KEY },
    { SA_Depth, 4 }, { SA_Pens, screenPens },
    { SA_FullPalette, TRUE }, { SA_Colors, screenColors },
    { SA_DetailPen, DETAILPEN }, { SA_BlockPen, BLOCKPEN },
    { SA_Title, "Speccylator 1.0    © 1993 R.C." },
    { SA_AutoScroll, TRUE },
    { TAG_END, NULL }
};


#define backWinIDCMP (IDCMP_GADGETDOWN | IDCMP_GADGETUP \
 | IDCMP_MENUPICK | IDCMP_RAWKEY)

struct TagItem backWinTags[] = {
    { WA_CustomScreen, NULL },
    { WA_Left, 0 }, { WA_Top, 0 },
    { WA_Width, 0}, { WA_Height, 0 },
	/* The entries above this line are set up in getWindows() */
    { WA_IDCMP, backWinIDCMP },
    { WA_Flags, WFLG_SIMPLE_REFRESH | WFLG_NOCAREREFRESH |
	WFLG_BORDERLESS | WFLG_BACKDROP | WFLG_ACTIVATE },
    { TAG_END, NULL }
};


/* The Spectrum window requires verification messages:
*/

/* these are the verification flags used
*/
#define specWinIDCMPverf (IDCMP_MENUVERIFY)

/* the standard flags include the verification flags
*/
#define specWinIDCMP (IDCMP_GADGETDOWN | IDCMP_GADGETUP \
 | IDCMP_MENUPICK | IDCMP_RAWKEY | specWinIDCMPverf)

struct TagItem specWinTags[] = {
    { WA_CustomScreen, NULL },
    { WA_Left, 0 }, { WA_Top, 0 },
	/* The entries above this line are set up in getWindows() */
    { WA_Width, 256 }, { WA_Height, 192 }, /* No doubt about this size! */
    { WA_IDCMP, specWinIDCMP },
    { WA_Flags, WFLG_SIMPLE_REFRESH | WFLG_NOCAREREFRESH |
	WFLG_BORDERLESS },
    { TAG_END, NULL }
};


