summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/includes/sms.h
blob: f9d2a6f24204f2337dc6c7bd33a23e4e8bccd529 (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*****************************************************************************
 *
 * includes/sms.h
 *
 ****************************************************************************/

#ifndef SMS_H_
#define SMS_H_

#define LOG_REG
#define LOG_PAGING
#define LOG_COLOR

#define NVRAM_SIZE             (0x08000)
#define CPU_ADDRESSABLE_SIZE   (0x10000)

#define MAX_CARTRIDGES        16

class sms_state : public driver_device
{
public:
	void map_cart_16k( UINT16 address, UINT16 bank );
	void map_cart_8k( UINT16 address, UINT16 bank );
	void map_bios_16k( UINT16 address, UINT16 bank );
	void map_bios_8k( UINT16 address, UINT16 bank );

public:
	sms_state(const machine_config &mconfig, device_type type, const char *tag)
	: driver_device(mconfig, type, tag) { }

	// device_ts
	device_t *m_main_cpu;
	device_t *m_control_cpu;
	sega315_5124_device *m_vdp;
	eeprom_device *m_eeprom;
	device_t *m_ym;
	device_t *m_main_scr;
	device_t *m_left_lcd;
	device_t *m_right_lcd;
	address_space *m_space;

	UINT8 m_bios_page_count;
	UINT8 m_fm_detect;
	UINT8 m_ctrl_reg;
	int m_paused;
	UINT8 m_bios_port;
	UINT8 *m_BIOS;
	UINT8 *m_mapper_ram;
	UINT8 m_mapper[4];
	// we are going to use 1-6, same as bank numbers. Notice, though, that most mappers
	// only work on 16K banks and, hence, banks 4-6 are not always directly set
	// (they often use bank3 + 0x2000 and bank5 + 0x2000)
	UINT8 *m_banking_bios[8];
	UINT8 *m_banking_cart[8];
	UINT8 *m_banking_none;
	UINT8 m_gg_sio[5];
	UINT8 m_store_control;
	UINT8 m_input_port0;
	UINT8 m_input_port1;

	// for gamegear LCD persistence hack
	bitmap_rgb32 m_prev_bitmap;

	// for 3D glass binocular hack
	bitmap_rgb32 m_prevleft_bitmap;
	bitmap_rgb32 m_prevright_bitmap;

	/* Model identifiers */
	UINT8 m_is_gamegear;
	UINT8 m_is_region_japan;
	UINT8 m_has_bios_0400;
	UINT8 m_has_bios_2000;
	UINT8 m_has_bios_full;
	UINT8 m_has_bios;
	UINT8 m_has_fm;

	/* Data needed for Rapid Fire Unit support */
	emu_timer *m_rapid_fire_timer;
	UINT8 m_rapid_fire_state_1;
	UINT8 m_rapid_fire_state_2;

	/* Data needed for Paddle Control controller */
	UINT32 m_last_paddle_read_time;
	UINT8 m_paddle_read_state;

	/* Data needed for Sports Pad controller */
	UINT32 m_last_sports_pad_time_1;
	UINT32 m_last_sports_pad_time_2;
	UINT8 m_sports_pad_state_1;
	UINT8 m_sports_pad_state_2;
	UINT8 m_sports_pad_last_data_1;
	UINT8 m_sports_pad_last_data_2;
	UINT8 m_sports_pad_1_x;
	UINT8 m_sports_pad_1_y;
	UINT8 m_sports_pad_2_x;
	UINT8 m_sports_pad_2_y;

	/* Data needed for Light Phaser */
	emu_timer *m_lphaser_1_timer;
	emu_timer *m_lphaser_2_timer;
	UINT8 m_lphaser_1_latch;
	UINT8 m_lphaser_2_latch;
	int m_lphaser_x_offs;	/* Needed to 'calibrate' lphaser; set at cart loading */

	/* Data needed for SegaScope (3D glasses) */
	UINT8 m_sscope_state;

	/* Cartridge slot info */
	UINT8 m_current_cartridge;
	struct
	{
		UINT8 *ROM;        /* Pointer to ROM image data */
		UINT32 size;       /* Size of the ROM image */
		UINT32 features;   /* on-cartridge special hardware */
		UINT8 *cartSRAM;   /* on-cartridge SRAM */
		UINT8 sram_save;   /* should be the contents of the on-cartridge SRAM be saved */
		UINT8 *cartRAM;    /* additional on-cartridge RAM (64KB for Ernie Els Golf) */
		UINT32 ram_size;   /* size of the on-cartridge RAM */
		UINT8 ram_page;    /* currently swapped in cartridge RAM */

		/* Data needed for Terebi Oekaki (TV Draw) */
		UINT8 m_tvdraw_data;

		/* Data needed for 4pak mapper */
		UINT8 m_4pak_page0;
		UINT8 m_4pak_page1;
		UINT8 m_4pak_page2;

		/* Data needed for 93c46 */
		bool m_93c46_enabled;
		UINT8 m_93c46_lines;
	} m_cartridge[MAX_CARTRIDGES];
	DECLARE_WRITE8_MEMBER(sms_input_write);
	DECLARE_WRITE8_MEMBER(sms_fm_detect_w);
	DECLARE_READ8_MEMBER(sms_fm_detect_r);
	DECLARE_WRITE8_MEMBER(sms_io_control_w);
	DECLARE_READ8_MEMBER(sms_count_r);
	DECLARE_READ8_MEMBER(sms_input_port_0_r);
	DECLARE_READ8_MEMBER(sms_input_port_1_r);
	DECLARE_WRITE8_MEMBER(sms_ym2413_register_port_0_w);
	DECLARE_WRITE8_MEMBER(sms_ym2413_data_port_0_w);
	DECLARE_READ8_MEMBER(gg_input_port_2_r);
	DECLARE_READ8_MEMBER(sms_sscope_r);
	DECLARE_WRITE8_MEMBER(sms_sscope_w);
	DECLARE_READ8_MEMBER(sms_mapper_r);
	DECLARE_WRITE8_MEMBER(sms_tvdraw_axis_w);
	DECLARE_READ8_MEMBER(sms_tvdraw_status_r);
	DECLARE_READ8_MEMBER(sms_tvdraw_data_r);
	DECLARE_WRITE8_MEMBER(sms_93c46_w);
	DECLARE_READ8_MEMBER(sms_93c46_r);
	DECLARE_WRITE8_MEMBER(sms_mapper_w);
	DECLARE_WRITE8_MEMBER(sms_korean_zemina_banksw_w);
	DECLARE_WRITE8_MEMBER(sms_codemasters_page0_w);
	DECLARE_WRITE8_MEMBER(sms_codemasters_page1_w);
	DECLARE_WRITE8_MEMBER(sms_4pak_page0_w);
	DECLARE_WRITE8_MEMBER(sms_4pak_page1_w);
	DECLARE_WRITE8_MEMBER(sms_4pak_page2_w);
	DECLARE_WRITE8_MEMBER(sms_janggun_bank0_w);
	DECLARE_WRITE8_MEMBER(sms_janggun_bank1_w);
	DECLARE_WRITE8_MEMBER(sms_janggun_bank2_w);
	DECLARE_WRITE8_MEMBER(sms_janggun_bank3_w);
	DECLARE_WRITE8_MEMBER(sms_bios_w);
	DECLARE_WRITE8_MEMBER(sms_cartram2_w);
	DECLARE_WRITE8_MEMBER(sms_cartram_w);
	DECLARE_WRITE8_MEMBER(gg_sio_w);
	DECLARE_READ8_MEMBER(gg_sio_r);
	DECLARE_READ8_MEMBER(sms_store_cart_select_r);
	DECLARE_WRITE8_MEMBER(sms_store_cart_select_w);
	DECLARE_READ8_MEMBER(sms_store_select1);
	DECLARE_READ8_MEMBER(sms_store_select2);
	DECLARE_READ8_MEMBER(sms_store_control_r);
	DECLARE_WRITE8_MEMBER(sms_store_control_w);
	DECLARE_DRIVER_INIT(sg1000m3);
	DECLARE_DRIVER_INIT(gamegear);
	DECLARE_DRIVER_INIT(gamegeaj);
	DECLARE_DRIVER_INIT(sms2kr);
	DECLARE_DRIVER_INIT(smsj);
	DECLARE_DRIVER_INIT(sms1);
	DECLARE_DRIVER_INIT(smssdisp);
};


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

/* Function prototypes */

INPUT_CHANGED( lgun1_changed );
INPUT_CHANGED( lgun2_changed );

WRITE_LINE_DEVICE_HANDLER( sms_pause_callback );
WRITE_LINE_DEVICE_HANDLER( sms_store_int_callback );

DEVICE_START( sms_cart );
DEVICE_IMAGE_LOAD( sms_cart );

MACHINE_START( sms );
MACHINE_RESET( sms );


#define IO_EXPANSION    (0x80)	/* Expansion slot enable (1= disabled, 0= enabled) */
#define IO_CARTRIDGE    (0x40)	/* Cartridge slot enable (1= disabled, 0= enabled) */
#define IO_CARD         (0x20)	/* Card slot disabled (1= disabled, 0= enabled) */
#define IO_WORK_RAM     (0x10)	/* Work RAM disabled (1= disabled, 0= enabled) */
#define IO_BIOS_ROM     (0x08)	/* BIOS ROM disabled (1= disabled, 0= enabled) */
#define IO_CHIP         (0x04)	/* I/O chip disabled (1= disabled, 0= enabled) */



VIDEO_START( sms1 );
VIDEO_START( gamegear );
SCREEN_UPDATE_RGB32( sms1 );
SCREEN_UPDATE_RGB32( sms );
SCREEN_UPDATE_RGB32( gamegear );

#endif /* SMS_H_ */