summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/includes/apple2gs.h
blob: dd7f7a975d65c97a5f1c791a01c34fc2c377744b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*****************************************************************************
 *
 * includes/apple2gs.h
 *
 * Apple IIgs
 *
 ****************************************************************************/

#ifndef APPLE2GS_H_
#define APPLE2GS_H_

#include "includes/apple2.h"
#include "sound/es5503.h"
#include "machine/nvram.h"

// IIgs clocks as marked on the schematics
#define APPLE2GS_28M  (XTAL_28_63636MHz) // IIGS master clock
#define APPLE2GS_14M  (APPLE2GS_28M/2)
#define APPLE2GS_7M   (APPLE2GS_28M/4)

// screen dimensions
#define BORDER_LEFT	(32)
#define BORDER_RIGHT	(32)
#define BORDER_TOP	(16)	// (plus bottom)


typedef enum
{
	CLOCKMODE_IDLE,
	CLOCKMODE_TIME,
	CLOCKMODE_INTERNALREGS,
	CLOCKMODE_BRAM1,
	CLOCKMODE_BRAM2
} apple2gs_clock_mode;


typedef enum
{
	ADBSTATE_IDLE,
	ADBSTATE_INCOMMAND,
	ADBSTATE_INRESPONSE
} adbstate_t;

#define IRQ_KBD_SRQ			0x01
#define IRQ_ADB_DATA		0x02
#define IRQ_ADB_MOUSE		0x04
#define IRQ_VGC_SCANLINE	0x08
#define IRQ_VGC_SECOND		0x10
#define IRQ_INTEN_QSECOND	0x20
#define IRQ_INTEN_VBL		0x40
#define IRQ_DOC			    0x80
#define IRQ_SLOT            0x100

void apple2gs_add_irq(running_machine &machine, UINT16 irq_mask);
void apple2gs_remove_irq(running_machine &machine, UINT16 irq_mask);

class apple2gs_state : public apple2_state
{
public:
	apple2gs_state(const machine_config &mconfig, device_type type, const char *tag)
		: apple2_state(mconfig, type, tag),
		m_maincpu(*this, "maincpu"),
        m_es5503(*this, "es5503"),
        m_fdc(*this, "fdc")
        { }

	required_device<cpu_device> m_maincpu;
	required_device<es5503_device> m_es5503;
    required_device<device_t> m_fdc;

	UINT8 *m_slowmem;
	UINT8 m_newvideo;
	UINT16 m_bordercolor;
	UINT8 m_vgcint;
	UINT8 m_langsel;
	UINT8 m_sltromsel;
	UINT8 m_cyareg;
	UINT8 m_inten;
	UINT8 m_intflag;
	UINT8 m_shadow;
	UINT16 m_pending_irqs;
	UINT8 m_mouse_x;
	UINT8 m_mouse_y;
	INT8 m_mouse_dx;
	INT8 m_mouse_dy;
	device_t *m_cur_slot6_image;
	emu_timer *m_scanline_timer;
	emu_timer *m_clock_timer;
	emu_timer *m_qsecond_timer;
	UINT8 m_clock_data;
	UINT8 m_clock_control;
	UINT8 m_clock_read;
	UINT8 m_clock_reg1;
	apple2gs_clock_mode m_clock_mode;
	UINT32 m_clock_curtime;
	seconds_t m_clock_curtime_interval;
	UINT8 m_clock_bram[256];
	adbstate_t m_adb_state;
	UINT8 m_adb_command;
	UINT8 m_adb_mode;
	UINT8 m_adb_kmstatus;
	UINT8 m_adb_latent_result;
	INT32 m_adb_command_length;
	INT32 m_adb_command_pos;
	UINT8 m_adb_command_bytes[8];
	UINT8 m_adb_response_bytes[8];
	UINT8 m_adb_response_length;
	INT32 m_adb_response_pos;
	UINT8 m_adb_memory[0x100];
	int m_adb_address_keyboard;
	int m_adb_address_mouse;
	UINT8 m_sndglu_ctrl;
	int m_sndglu_addr;
	int m_sndglu_dummy_read;
	bitmap_ind16 *m_legacy_gfx;
    bool m_is_rom3;
    UINT8 m_echo_bank;

	DECLARE_DIRECT_UPDATE_MEMBER(apple2gs_opbase);

    READ8_MEMBER( apple2gs_c0xx_r );
    WRITE8_MEMBER( apple2gs_c0xx_w );
    WRITE8_MEMBER( apple2gs_main0400_w );
    WRITE8_MEMBER( apple2gs_aux0400_w );
    WRITE8_MEMBER( apple2gs_main2000_w );
    WRITE8_MEMBER( apple2gs_aux2000_w );
    WRITE8_MEMBER( apple2gs_main4000_w );
    WRITE8_MEMBER( apple2gs_aux4000_w );

    UINT8 adb_read_datareg();
    UINT8 adb_read_kmstatus();

    void apple2gs_refresh_delegates();

    write8_delegate write_delegates_2gs0400[2];
    write8_delegate write_delegates_2gs2000[2];
    write8_delegate write_delegates_2gs4000[2];
};


/*----------- defined in machine/apple2gs.c -----------*/

MACHINE_START( apple2gs );
MACHINE_START( apple2gsr1 );
MACHINE_RESET( apple2gs );

void apple2gs_doc_irq(device_t *device, int state);


/*----------- defined in video/apple2gs.c -----------*/

VIDEO_START( apple2gs );
SCREEN_UPDATE_IND16( apple2gs );


#endif /* APPLE2GS_H_ */