1 // license:BSD-3-Clause
2 // copyright-holders:Luca Elia
3 /***************************************************************************
4 
5                              -= Galaxy Games =-
6 
7                     driver by Luca Elia (l.elia@tin.it)
8 
9 
10 CPU:    68000
11 Video:  Blitter with two layers and double buffering (Xilinx FPGA)
12 Sound:  OKI M6295
13 Input:  Trackballs and buttons
14 Other:  EEPROM
15 Carts:  EEPROM + Flash + PIC
16 
17 To Do:
18 
19 - Coin optics
20 
21 Notes:
22 
23 - 4 known game carts where produced, these are:
24 
25     Star Pak 1: Seek the Peaks, 21 Thunder, Solar Solitaire, Prism Poker, Pharaoh's Tomb, Magic Black Jack,
26                 Twenty One Thunder Plus, Power Pairs, Prism Poker Plus & Have A Cow
27     Star Pak 2: Pac-Man, Ms.Pac-Man, Pharaoh's Tomb, Solar Solitaire, Power Pairs, Seek The peeks & Have A Cow
28     Star Pak 3: Centipede, Great Wall, Ker-Chunk, Diamond Derby, Word Sleuth, Pull!, Astro Blast & Sweeper
29     Star Pak 4: Berzerk, Neon Nightmare, Battle Checkers, Orbit, Deep Sea Shadow, Star Tiger & Orbit Freefall
30 
31 - Allegedly there is a hard lock that SP1 and the PAC-MAN games (on SP2) cannot play together. Was a licensing issue with Namco.
32   The system checks for cartridges on power up by querying the PIC parts. If the system sees SP1 & SP2 it disables SP2.
33 
34 - Early flyers show "Star Pak 1" titled as Cardmania!
35 - Early flyers show "Star Pak 2" titled as Galaxy Games Volume 2
36 - There is an early flyer showing a Cardmania! cartridge in front of a partialy blocked cartridge labeled Casino
37 
38 ***************************************************************************/
39 
40 #include "emu.h"
41 #include "cpu/m68000/m68000.h"
42 #include "cpu/pic16c5x/pic16c5x.h"
43 #include "machine/eepromser.h"
44 #include "machine/timer.h"
45 #include "machine/watchdog.h"
46 #include "sound/okim6295.h"
47 #include "video/cesblit.h"
48 #include "emupal.h"
49 #include "screen.h"
50 #include "speaker.h"
51 #include "dirom.h"
52 
53 /***************************************************************************
54 
55                               Galgames Cart Device
56 
57  Each cartridge contains a PIC, that provides, among other things, a 32-byte
58  response starting with "CES1997", followed by the contents of the cart rom
59  at some fixed addresses.
60 
61 ***************************************************************************/
62 
63 DECLARE_DEVICE_TYPE(GALGAMES_CART,          galgames_cart_device)
64 DECLARE_DEVICE_TYPE(GALGAMES_BIOS_CART,     galgames_bios_cart_device)
65 DECLARE_DEVICE_TYPE(GALGAMES_STARPAK2_CART, galgames_starpak2_cart_device)
66 DECLARE_DEVICE_TYPE(GALGAMES_STARPAK3_CART, galgames_starpak3_cart_device)
67 DECLARE_DEVICE_TYPE(GALGAMES_SLOT,          galgames_slot_device)
68 
69 // CART declaration
70 
71 class galgames_cart_device : public device_t, public device_rom_interface<21, 1, 0, ENDIANNESS_BIG>
72 {
73 public:
74 	// construction/destruction
75 
galgames_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,u8 cart)76 	galgames_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, u8 cart)
77 		: galgames_cart_device(mconfig, GALGAMES_CART, tag, owner, (u32)0)
78 	{
79 		set_cart(cart);
80 	}
81 
82 	// static configuration
set_cart(u8 cart)83 	void set_cart(u8 cart) { m_cart = cart; }
84 	void set_pic_bits(int clk, int in, int out, int dis);
85 
86 	// ROM
rom_r(offs_t offset)87 	u16 rom_r(offs_t offset)    { return read_word(offset*2); }
88 
89 	// EEPROM
90 	u8 eeprom_r();
91 	void eeprom_w(u8 data);
92 	DECLARE_WRITE_LINE_MEMBER(eeprom_cs_write);
93 
94 	// PIC
95 	u8 pic_status_r();
96 	void pic_data_w(u8 data);
97 	u8 pic_data_r();
98 	void set_pic_reset_line(int state);
99 
100 	u8 int_pic_data_r();
101 	void int_pic_data_w(u8 data);
102 	void int_pic_bank_w(u8 data);
103 
104 protected:
105 	galgames_cart_device(
106 			const machine_config &mconfig,
107 			device_type type,
108 			const char *tag,
109 			device_t *owner,
110 			u32 clock);
111 
112 	// device-level overrides
113 	virtual void device_start() override;
114 	virtual void device_reset() override;
rom_bank_updated()115 	virtual void rom_bank_updated() override { }
116 
117 	bool is_selected();
118 
119 	u8 m_cart;
120 
121 	// SLOT
122 	required_device<galgames_slot_device> m_slot;
123 
124 	// EEPROM
125 	optional_device<eeprom_serial_93cxx_device> m_eeprom;
126 
127 	// PIC
128 	optional_device<pic16c5x_device> m_pic;
129 
130 	u8 m_pic_iobits, m_pic_data, m_pic_data_rdy, m_pic_data_bit, m_pic_data_clk;
131 	u8 m_pic_clk_mask, m_pic_in_mask, m_pic_out_mask, m_pic_dis_mask;
132 
133 	void log_cart_comm(const char *text, u8 data);
134 	void pic_comm_reset();
135 };
136 
137 // device type definition
138 DEFINE_DEVICE_TYPE(GALGAMES_CART, galgames_cart_device, "starpak_cart", "Galaxy Games StarPak Cartridge")
139 
140 
141 // BIOS "cart"
142 
143 class galgames_bios_cart_device : public galgames_cart_device
144 {
145 public:
146 	// construction/destruction
galgames_bios_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,u8 cart)147 	galgames_bios_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, u8 cart)
148 		: galgames_cart_device(mconfig, GALGAMES_BIOS_CART, tag, owner, (u32)0)
149 	{
150 		set_cart(cart);
151 	}
152 
153 protected:
154 	// device-level overrides
155 	virtual void device_add_mconfig(machine_config &config) override;
156 };
157 
158 DEFINE_DEVICE_TYPE(GALGAMES_BIOS_CART, galgames_bios_cart_device, "galgames_bios_cart", "Galaxy Games BIOS Cartridge")
159 
device_add_mconfig(machine_config & config)160 void galgames_bios_cart_device::device_add_mconfig(machine_config &config)
161 {
162 	EEPROM_93C76_8BIT(config, "eeprom");
163 }
164 
165 
166 // STARPAK2 cart
167 
168 class galgames_starpak2_cart_device : public galgames_cart_device
169 {
170 public:
171 	// construction/destruction
galgames_starpak2_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,u8 cart)172 	galgames_starpak2_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, u8 cart)
173 		: galgames_cart_device(mconfig, GALGAMES_STARPAK2_CART, tag, owner, (u32)0)
174 	{
175 		set_cart(cart);
176 		set_pic_bits(5, 4, 2, 1);
177 	}
178 
179 protected:
180 	// device-level overrides
181 	virtual void device_add_mconfig(machine_config &config) override;
182 };
183 
184 DEFINE_DEVICE_TYPE(GALGAMES_STARPAK2_CART, galgames_starpak2_cart_device, "starpak2_cart", "Galaxy Games StarPak 2 Cartridge")
185 
device_add_mconfig(machine_config & config)186 void galgames_starpak2_cart_device::device_add_mconfig(machine_config &config)
187 {
188 	pic16c56_device &pic(PIC16C56(config, "pic", XTAL(4'000'000)));  // !! PIC12C508 !! 4MHz internal RC oscillator (selected by the configuration word)
189 	pic.read_b().set(FUNC(galgames_cart_device::int_pic_data_r));
190 	pic.write_b().set(FUNC(galgames_cart_device::int_pic_data_w));
191 
192 	EEPROM_93C76_8BIT(config, "eeprom");
193 }
194 
195 
196 // STARPAK3 cart
197 
198 class galgames_starpak3_cart_device : public galgames_cart_device
199 {
200 public:
201 	// construction/destruction
galgames_starpak3_cart_device(const machine_config & mconfig,const char * tag,device_t * owner,u8 cart)202 	galgames_starpak3_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, u8 cart)
203 		: galgames_cart_device(mconfig, GALGAMES_STARPAK3_CART, tag, owner, (u32)0)
204 	{
205 		set_cart(cart);
206 		set_pic_bits(0, 2, 3, 4);
207 	}
208 
209 protected:
210 	// device-level overrides
211 	virtual void device_add_mconfig(machine_config &config) override;
212 };
213 
214 DEFINE_DEVICE_TYPE(GALGAMES_STARPAK3_CART, galgames_starpak3_cart_device, "starpak3_cart", "Galaxy Games StarPak 3 Cartridge")
215 
device_add_mconfig(machine_config & config)216 void galgames_starpak3_cart_device::device_add_mconfig(machine_config &config)
217 {
218 	pic16c56_device &pic(PIC16C56(config, "pic", XTAL(4'000'000)));
219 	pic.write_a().set(FUNC(galgames_cart_device::int_pic_bank_w));
220 	pic.read_b().set(FUNC(galgames_cart_device::int_pic_data_r));
221 	pic.write_b().set(FUNC(galgames_cart_device::int_pic_data_w));
222 
223 	EEPROM_93C76_8BIT(config, "eeprom");
224 }
225 
226 
227 /***************************************************************************
228 
229                               Galgames Slot Device
230 
231 ***************************************************************************/
232 
233 // SLOT declaration
234 
235 class galgames_slot_device : public device_t, public device_memory_interface
236 {
237 public:
238 	// construction/destruction
239 	galgames_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
240 
241 	void slot_map(address_map &map);
242 
read(offs_t offset,u16 mem_mask=~0)243 	u16 read(offs_t offset, u16 mem_mask = ~0)               { return m_space->read_word(offset * 2, mem_mask); }
write(offs_t offset,u16 data,u16 mem_mask=~0)244 	void write(offs_t offset, u16 data, u16 mem_mask = ~0)   { m_space->write_word(offset * 2, data, mem_mask); }
245 
246 	// SLOT
247 	void cart_sel_w(u8 data);
248 	void ram_sel_w(u8 data);
249 
250 	// ROM
251 	u16 rom0_r(offs_t offset);
252 	u16 rom_r(offs_t offset);
253 	u16 rom0_or_ram_r(offs_t offset);
254 	u16 rom_or_ram_r(offs_t offset);
255 	void ram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
256 
257 	// PIC
258 	u8 pic_status_r();
259 	void pic_data_w(u8 data);
260 	u8 pic_data_r();
261 	void set_pic_reset_line(int state);
262 
263 	// EEPROM
264 	u8 eeprom_r();
265 	void eeprom_w(u8 data);
266 	DECLARE_WRITE_LINE_MEMBER(eeprom_cs_write);
267 
get_cart() const268 	u8 get_cart() const { return m_cart; }
269 
270 protected:
271 
272 	// device-level overrides
273 	virtual void device_start() override;
274 	virtual void device_reset() override;
275 	virtual space_config_vector memory_space_config() const override;
276 
277 	address_space_config m_space_config;
278 	address_space *m_space;
279 
280 	required_shared_ptr<u16> m_ram;
281 
282 	required_device<galgames_cart_device> m_cart0;
283 
284 	required_device<galgames_cart_device> m_cart1;
285 	required_device<galgames_cart_device> m_cart2;
286 	required_device<galgames_cart_device> m_cart3;
287 	required_device<galgames_cart_device> m_cart4;
288 
289 	void set_cart(int cart);
290 	void reset_eeproms_except(int cart);
291 
292 	galgames_cart_device *m_carts[1+4];
293 
294 	u8 m_cart;
295 	bool m_is_ram_active;
296 };
297 
memory_space_config() const298 device_memory_interface::space_config_vector galgames_slot_device::memory_space_config() const
299 {
300 	return space_config_vector {
301 		std::make_pair(AS_PROGRAM, &m_space_config)
302 	};
303 }
304 
305 // device type definition
306 DEFINE_DEVICE_TYPE(GALGAMES_SLOT, galgames_slot_device, "starpak_slot", "Galaxy Games Slot")
307 
308 // CART implementation
309 
galgames_cart_device(const machine_config & mconfig,device_type type,const char * tag,device_t * owner,u32 clock)310 galgames_cart_device::galgames_cart_device(
311 		const machine_config &mconfig,
312 		device_type type,
313 		const char *tag,
314 		device_t *owner,
315 		u32 clock):
316 	device_t(mconfig, type, tag, owner, clock),
317 	device_rom_interface(mconfig, *this),
318 	m_cart(0),
319 	m_slot(*this, "^slot"),
320 	m_eeprom(*this, "eeprom"),
321 	m_pic(*this, "pic")
322 {
323 }
324 
device_start()325 void galgames_cart_device::device_start()
326 {
327 	save_item(NAME(m_cart));
328 	save_item(NAME(m_pic_iobits));
329 	save_item(NAME(m_pic_data));
330 	save_item(NAME(m_pic_data_rdy));
331 	save_item(NAME(m_pic_data_clk));
332 	save_item(NAME(m_pic_data_bit));
333 }
334 
device_reset()335 void galgames_cart_device::device_reset()
336 {
337 	pic_comm_reset();
338 }
339 
is_selected()340 bool galgames_cart_device::is_selected()
341 {
342 	return m_slot->get_cart() == m_cart;
343 }
344 
set_pic_reset_line(int state)345 void galgames_cart_device::set_pic_reset_line(int state)
346 {
347 	if (!m_pic)
348 		return;
349 
350 //  logerror("reset line = %x\n", state);
351 
352 	if (!m_pic->input_state(INPUT_LINE_RESET) && state)
353 		pic_comm_reset();
354 
355 	m_pic->set_input_line(INPUT_LINE_RESET, state);
356 }
357 
log_cart_comm(const char * text,u8 data)358 void galgames_cart_device::log_cart_comm(const char *text, u8 data)
359 {
360 //  logerror("%s: comm %-10s %02x - data:%02x bit:%02x rdy:%x clk:%02x\n", machine().describe_context(),
361 //      text, data, m_pic_data, m_pic_data_bit, m_pic_data_rdy, m_pic_data_clk );
362 
363 //  logerror("%s: comm %-10s %02x\n", machine().describe_context(), text, data);
364 }
365 
pic_comm_reset()366 void galgames_cart_device::pic_comm_reset()
367 {
368 	m_pic_iobits = m_pic_data = m_pic_data_rdy = m_pic_data_clk = 0;
369 	m_pic_data_bit = 0xff;
370 //  logerror("%s: comm reset\n", machine().describe_context());
371 }
372 
373 // External PIC status and data interface
374 
pic_status_r()375 u8 galgames_cart_device::pic_status_r()
376 {
377 	// bit 7 = data from the cart PIC can be read
378 	return (is_selected() && (m_pic_data_rdy == 2)) ? 0x80 : 0;
379 }
380 
pic_data_r()381 u8 galgames_cart_device::pic_data_r()
382 {
383 	if (is_selected())
384 	{
385 		if (!machine().side_effects_disabled())
386 			m_pic_data_rdy = 0;
387 		return m_pic_data;
388 	}
389 	return 0xff;
390 }
391 
pic_data_w(u8 data)392 void galgames_cart_device::pic_data_w(u8 data)
393 {
394 	if (is_selected())
395 	{
396 		m_pic_data      =   data;
397 		m_pic_data_rdy  =   1;
398 		m_pic_data_bit  =   0xff;
399 		m_pic_data_clk  =   0;
400 		log_cart_comm("EXT WRITE", data);
401 	}
402 }
403 
404 /*
405 galgame2:
406     bit 0 = cleared at boot (never touched again)
407     bit 1 = PIC waits for it to become 0 before reading (or to become 1 when another byte is expected)
408     bit 2 = data out
409     bit 3   unused
410     bit 4 = data in
411     bit 5 = clock
412     bit 6   n.c.
413     bit 7   n.c.
414 
415 galgame3:
416     bit 0 = clock
417     bit 1   unused
418     bit 2 = data in
419     bit 3 = data out
420     bit 4 = PIC waits for it to become 0 before reading (or to become 1 when another byte is expected)
421     bit 5 = 0
422     bit 6 = 1
423     bit 7   unused
424 */
set_pic_bits(int clk,int in,int out,int dis)425 void galgames_cart_device::set_pic_bits(int clk, int in, int out, int dis)
426 {
427 	m_pic_clk_mask  = 1 << clk;
428 	m_pic_in_mask   = 1 << in;
429 	m_pic_out_mask  = 1 << out;
430 	m_pic_dis_mask  = 1 << dis;
431 }
432 
int_pic_data_r()433 u8 galgames_cart_device::int_pic_data_r()
434 {
435 	if (!machine().side_effects_disabled())
436 	{
437 		// clock
438 		u8 clk0 = m_pic_data_clk & 0x80;
439 		m_pic_data_clk += 0x10;
440 		u8 clk1 = m_pic_data_clk & 0x80;
441 
442 		m_pic_iobits = (m_pic_iobits & (~m_pic_clk_mask)) | (clk1 ? m_pic_clk_mask : 0);
443 
444 		// disabled
445 		bool disabled = !is_selected();
446 		m_pic_iobits = (m_pic_iobits & (~m_pic_dis_mask)) | (disabled ? m_pic_dis_mask : 0);
447 
448 		// The PIC waits for a falling edge before reading the new input bit.
449 		// It waits for a rising edge before setting the new output bit.
450 		// Hence we shift the data on the falling edge of the clock.
451 		if (clk0 && !clk1)
452 		{
453 			u8 bit_in = 0;
454 
455 			if (m_pic_data_rdy == 1)
456 			{
457 				if (m_pic_data_bit == 0xff)
458 				{
459 					// first read bit must be 1 (sync)
460 					bit_in = 1;
461 					m_pic_data_bit = 7;
462 				}
463 				else
464 				{
465 					// read current bit and move to the next
466 					bit_in = BIT(m_pic_data, m_pic_data_bit);
467 					--m_pic_data_bit;
468 
469 					if (m_pic_data_bit == 0xff)
470 					{
471 						m_pic_data_rdy = 0;
472 						log_cart_comm("PIC should have READ", m_pic_data);
473 					}
474 				}
475 			}
476 			else if (m_pic_data_rdy == 0)
477 			{
478 				u8 bit_out = m_pic_iobits & m_pic_out_mask;
479 
480 				if (m_pic_data_bit == 0xff)
481 				{
482 					// first written bit must be 1 (sync)
483 					if (bit_out)
484 						m_pic_data_bit = 7;
485 				}
486 				else
487 				{
488 					// write current bit and move to the next
489 					u8 mask = 1 << m_pic_data_bit;
490 					m_pic_data = (m_pic_data & (~mask)) | (bit_out ? mask : 0);
491 					--m_pic_data_bit;
492 
493 					if (m_pic_data_bit == 0xff)
494 					{
495 						m_pic_data_rdy = 2;
496 						log_cart_comm("PIC should have WRITTEN", m_pic_data);
497 					}
498 				}
499 			}
500 
501 			m_pic_iobits = (m_pic_iobits & (~m_pic_in_mask)) | (bit_in ? m_pic_in_mask : 0);
502 		}
503 
504 	//  log_cart_comm("PIC READ", m_pic_iobits);
505 	}
506 	return m_pic_iobits;
507 }
508 
int_pic_data_w(u8 data)509 void galgames_cart_device::int_pic_data_w(u8 data)
510 {
511 	m_pic_iobits = (m_pic_iobits & (~m_pic_out_mask)) | (data & m_pic_out_mask);
512 
513 //  log_cart_comm("PIC WRITE", data);
514 }
515 
516 /*
517 galgame3, port A:
518     bit 2 = bank lsb
519     bit 3 = bank msb
520 */
int_pic_bank_w(u8 data)521 void galgames_cart_device::int_pic_bank_w(u8 data)
522 {
523 	set_rom_bank((data >> 2) & 3);
524 }
525 
526 
527 // External EEPROM interface
528 
eeprom_r()529 u8 galgames_cart_device::eeprom_r()
530 {
531 	return (m_eeprom && m_eeprom->do_read()) ? 0x80 : 0x00;
532 }
533 
eeprom_w(u8 data)534 void galgames_cart_device::eeprom_w(u8 data)
535 {
536 	if (!m_eeprom)
537 		return;
538 
539 	if (data & ~0x03)
540 		logerror("Unknown EEPROM bit written %04X\n", data);
541 
542 	// latch the bit
543 	m_eeprom->di_write(data & 0x01);
544 
545 	// clock line asserted: write latch or select next bit to read
546 	m_eeprom->clk_write((data & 0x02) ? ASSERT_LINE : CLEAR_LINE);
547 }
548 
WRITE_LINE_MEMBER(galgames_cart_device::eeprom_cs_write)549 WRITE_LINE_MEMBER(galgames_cart_device::eeprom_cs_write)
550 {
551 	if (!m_eeprom)
552 		return;
553 
554 	m_eeprom->cs_write(state);
555 }
556 
557 
558 // SLOT implementation
559 
slot_map(address_map & map)560 void galgames_slot_device::slot_map(address_map &map)
561 {
562 	map(0x000000, 0x1fffff).r(FUNC(galgames_slot_device::rom0_r));
563 	map(0x000000, 0x03ffff).rw(FUNC(galgames_slot_device::rom0_or_ram_r), FUNC(galgames_slot_device::ram_w)).share("ram");
564 	map(0x200000, 0x3fffff).r(FUNC(galgames_slot_device::rom_r));
565 	map(0x200000, 0x23ffff).rw(FUNC(galgames_slot_device::rom_or_ram_r), FUNC(galgames_slot_device::ram_w));
566 }
567 
galgames_slot_device(const machine_config & mconfig,const char * tag,device_t * owner,u32 clock)568 galgames_slot_device::galgames_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
569 	device_t(mconfig, GALGAMES_SLOT, tag, owner, clock),
570 	device_memory_interface(mconfig, *this),
571 	m_space_config("slot_space", ENDIANNESS_BIG, 16,22, 0, address_map_constructor(FUNC(galgames_slot_device::slot_map), this)),
572 	m_ram(*this, "ram"),
573 	m_cart0(*this, "^cart0"),
574 	m_cart1(*this, "^cart1"),
575 	m_cart2(*this, "^cart2"),
576 	m_cart3(*this, "^cart3"),
577 	m_cart4(*this, "^cart4")
578 {
579 }
580 
device_start()581 void galgames_slot_device::device_start()
582 {
583 	m_space = &space(AS_PROGRAM);
584 
585 	m_carts[0] = m_cart0;
586 	m_carts[1] = m_cart1;
587 	m_carts[2] = m_cart2;
588 	m_carts[3] = m_cart3;
589 	m_carts[4] = m_cart4;
590 
591 	save_item(NAME(m_cart));
592 	save_item(NAME(m_is_ram_active));
593 }
594 
device_reset()595 void galgames_slot_device::device_reset()
596 {
597 	m_is_ram_active = false;
598 
599 	set_cart(0);
600 	reset_eeproms_except(-1);
601 }
602 
set_cart(int cart)603 void galgames_slot_device::set_cart(int cart)
604 {
605 //  if (m_cart != cart)
606 //      logerror("%s: cart sel = %02x\n", machine().describe_context(), cart);
607 
608 	m_cart = cart;
609 }
610 
reset_eeproms_except(int cart)611 void galgames_slot_device::reset_eeproms_except(int cart)
612 {
613 	// Reset all eeproms except the selected one
614 	for (int i = 0; i < 5; i++)
615 		m_carts[i]->eeprom_cs_write((cart == i) ? ASSERT_LINE : CLEAR_LINE);
616 }
617 
cart_sel_w(u8 data)618 void galgames_slot_device::cart_sel_w(u8 data)
619 {
620 	// cart selection (0 1 2 3 4 7)
621 
622 	switch (data)
623 	{
624 		case 0x07:  // 7 resets all
625 			reset_eeproms_except(-1);
626 			break;
627 
628 		case 0x00:  // cart 0 (motherboard)
629 		case 0x01:  // cart 1
630 		case 0x02:  // cart 2
631 		case 0x03:  // cart 3
632 		case 0x04:  // cart 4
633 			set_cart(data);
634 			reset_eeproms_except(data);
635 			break;
636 
637 		default:
638 			set_cart(0);
639 			reset_eeproms_except(0);
640 			logerror("%s: unknown cart sel = %02x\n", machine().describe_context(), data);
641 			break;
642 	}
643 }
644 
645 // Select RAM, reset PIC
646 
ram_sel_w(u8 data)647 void galgames_slot_device::ram_sel_w(u8 data)
648 {
649 	// bit 3 = PIC reset (active low)
650 	set_pic_reset_line(BIT(data, 3) ? CLEAR_LINE : ASSERT_LINE);
651 
652 	// ROM/RAM banking
653 	if ((data & 0xf7) == 0x05)
654 	{
655 		m_is_ram_active = true;
656 //      logerror("%s: romram bank = %02x\n", machine().describe_context(), data);
657 	}
658 }
659 
660 // External ROM read
661 
rom0_r(offs_t offset)662 u16 galgames_slot_device::rom0_r(offs_t offset)
663 {
664 	return m_carts[0]->rom_r(offset);
665 }
rom_r(offs_t offset)666 u16 galgames_slot_device::rom_r(offs_t offset)
667 {
668 	return m_carts[m_cart]->rom_r(offset);
669 }
670 
rom0_or_ram_r(offs_t offset)671 u16 galgames_slot_device::rom0_or_ram_r(offs_t offset)
672 {
673 	return m_is_ram_active ? m_ram[offset] : m_carts[0]->rom_r(offset);
674 }
rom_or_ram_r(offs_t offset)675 u16 galgames_slot_device::rom_or_ram_r(offs_t offset)
676 {
677 	return !m_is_ram_active ? m_ram[offset] : m_carts[m_cart]->rom_r(offset);
678 }
679 
ram_w(offs_t offset,u16 data,u16 mem_mask)680 void galgames_slot_device::ram_w(offs_t offset, u16 data, u16 mem_mask)
681 {
682 	COMBINE_DATA(m_ram + offset);
683 }
684 
685 // External PIC status and data interface
686 
pic_status_r()687 u8 galgames_slot_device::pic_status_r()
688 {
689 	return m_carts[m_cart]->pic_status_r();
690 }
pic_data_r()691 u8 galgames_slot_device::pic_data_r()
692 {
693 	return m_carts[m_cart]->pic_data_r();
694 }
pic_data_w(u8 data)695 void galgames_slot_device::pic_data_w(u8 data)
696 {
697 	m_carts[m_cart]->pic_data_w(data);
698 }
699 
set_pic_reset_line(int state)700 void galgames_slot_device::set_pic_reset_line(int state)
701 {
702 	m_carts[m_cart]->set_pic_reset_line(state);
703 }
704 
705 // External EEPROM interface
706 
eeprom_r()707 u8 galgames_slot_device::eeprom_r()
708 {
709 	return m_carts[m_cart]->eeprom_r();
710 }
eeprom_w(u8 data)711 void galgames_slot_device::eeprom_w(u8 data)
712 {
713 	m_carts[m_cart]->eeprom_w(data);
714 }
WRITE_LINE_MEMBER(galgames_slot_device::eeprom_cs_write)715 WRITE_LINE_MEMBER(galgames_slot_device::eeprom_cs_write)
716 {
717 	m_carts[m_cart]->eeprom_cs_write(state);
718 }
719 
720 /***************************************************************************
721 
722                                  General
723 
724 ***************************************************************************/
725 
726 class galgames_state : public driver_device
727 {
728 public:
galgames_state(const machine_config & mconfig,device_type type,const char * tag)729 	galgames_state(const machine_config &mconfig, device_type type, const char *tag) :
730 		driver_device(mconfig, type, tag),
731 		m_maincpu(*this, "maincpu"),
732 		m_screen(*this, "screen"),
733 		m_palette(*this, "palette"),
734 		m_blitter(*this, "blitter"),
735 		m_oki(*this, "oki"),
736 		m_slot(*this, "slot"),
737 		m_okiram(*this, "okiram")
738 	{ }
739 
740 	DECLARE_WRITE_LINE_MEMBER(blitter_irq_callback);
741 
742 	TIMER_DEVICE_CALLBACK_MEMBER(scanline_interrupt);
743 	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
744 
745 	void palette_offset_w(u8 data);
746 	void palette_data_w(u8 data);
747 
748 	u8 okiram_r(offs_t offset);
749 	void okiram_w(offs_t offset, u8 data);
750 
751 	u16 fpga_status_r();
752 	void outputs_w(offs_t offset, u16 data, u16 mem_mask = ~0);
753 
754 	void galgames_base(machine_config &config);
755 	void galgbios(machine_config &config);
756 	void galgame2(machine_config &config);
757 	void galgame3(machine_config &config);
758 	void blitter_map(address_map &map);
759 	void galgames_map(address_map &map);
760 	void oki_map(address_map &map);
761 
762 protected:
763 	virtual void video_start() override;
764 
765 	required_device<cpu_device> m_maincpu;
766 	required_device<screen_device> m_screen;
767 	required_device<palette_device> m_palette;
768 	required_device<cesblit_device> m_blitter;
769 	required_device<okim6295_device> m_oki;
770 	required_device<galgames_slot_device> m_slot;
771 	required_shared_ptr<u8> m_okiram;
772 
773 	u8 m_palette_offset;
774 	u8 m_palette_index;
775 	u8 m_palette_data[3];
776 };
777 
WRITE_LINE_MEMBER(galgames_state::blitter_irq_callback)778 WRITE_LINE_MEMBER(galgames_state::blitter_irq_callback)
779 {
780 //  logerror("%s: Blitter IRQ callback state = %x\n", machine().describe_context(), state);
781 	m_maincpu->set_input_line(2, state);
782 }
783 
784 /***************************************************************************
785 
786                                    Video
787 
788 ***************************************************************************/
789 
screen_update(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)790 u32 galgames_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
791 {
792 	bitmap.fill(m_palette->black_pen(), cliprect);
793 	return m_blitter->screen_update(screen, bitmap, cliprect);
794 }
795 
796 // BT481A Palette RAMDAC
797 
palette_offset_w(u8 data)798 void galgames_state::palette_offset_w(u8 data)
799 {
800 	m_palette_offset = data & 0xff;
801 	m_palette_index = 0;
802 }
803 
palette_data_w(u8 data)804 void galgames_state::palette_data_w(u8 data)
805 {
806 	m_palette_data[m_palette_index] = data & 0xff;
807 	if (++m_palette_index == 3)
808 	{
809 		for (int palette_base = 0; palette_base < 0x1000; palette_base += 0x100)
810 			m_palette->set_pen_color(m_palette_offset + palette_base, rgb_t(m_palette_data[0], m_palette_data[1], m_palette_data[2]));
811 		m_palette_index = 0;
812 		m_palette_offset++;
813 	}
814 }
815 
video_start()816 void galgames_state::video_start()
817 {
818 	save_item(NAME(m_palette_offset));
819 	save_item(NAME(m_palette_index));
820 	save_item(NAME(m_palette_data));
821 }
822 
823 /***************************************************************************
824 
825                                    Sound
826 
827 ***************************************************************************/
828 
okiram_r(offs_t offset)829 u8 galgames_state::okiram_r(offs_t offset)
830 {
831 	return m_okiram[offset];
832 }
833 
okiram_w(offs_t offset,u8 data)834 void galgames_state::okiram_w(offs_t offset, u8 data)
835 {
836 	m_okiram[offset] = data;
837 }
838 
839 /***************************************************************************
840 
841                                 Memory Maps
842 
843 ***************************************************************************/
844 
845 // Outputs
846 
outputs_w(offs_t offset,u16 data,u16 mem_mask)847 void galgames_state::outputs_w(offs_t offset, u16 data, u16 mem_mask)
848 {
849 	if (data & mem_mask & ~0x000f)
850 		logerror("%s: Unknown output bit written %04X\n", machine().describe_context(), data);
851 
852 	if (ACCESSING_BITS_0_7)
853 	{
854 		// bit 0 & 1 : ? always on (may be trackball lights or coin lockouts)
855 		// bit 2     : coin counter
856 		// bit 3     : ? set after selecting a game (mostly off in-game)
857 		machine().bookkeeping().coin_counter_w(0, data & 0x0004);
858 	}
859 
860 //  popmessage("OUT %02X", data & mem_mask);
861 }
862 
863 // FPGA
864 
fpga_status_r()865 u16 galgames_state::fpga_status_r()
866 {
867 	return 0x3; // Pass the check at PC = 0xfae & a later one
868 }
869 
galgames_map(address_map & map)870 void galgames_state::galgames_map(address_map &map)
871 {
872 	map(0x000000, 0x3fffff).rw(m_slot, FUNC(galgames_slot_device::read), FUNC(galgames_slot_device::write));
873 
874 	map(0x400000, 0x400011).w(m_blitter, FUNC(cesblit_device::regs_w));
875 	map(0x400012, 0x400013).w(m_blitter, FUNC(cesblit_device::addr_hi_w));
876 	map(0x400014, 0x400015).w(m_blitter, FUNC(cesblit_device::color_w));
877 	map(0x400020, 0x400021).r(m_blitter, FUNC(cesblit_device::status_r));
878 
879 	map(0x600000, 0x600001).r(FUNC(galgames_state::fpga_status_r));
880 	map(0x700000, 0x700001).r(FUNC(galgames_state::fpga_status_r)).nopw();
881 	map(0x800020, 0x80003f).noprw();   // ?
882 	map(0x900000, 0x900001).w("watchdog", FUNC(watchdog_timer_device::reset16_w));
883 
884 	map(0xa00001, 0xa00001).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write));
885 	map(0xb00000, 0xb7ffff).rw(FUNC(galgames_state::okiram_r), FUNC(galgames_state::okiram_w)).umask16(0x00ff); // (only low bytes tested) 4x N341024SJ-15
886 
887 	map(0xc00001, 0xc00001).w(FUNC(galgames_state::palette_offset_w));
888 	map(0xc00003, 0xc00003).w(FUNC(galgames_state::palette_data_w));
889 
890 	map(0xd00000, 0xd00001).portr("TRACKBALL_1_X");
891 	map(0xd00000, 0xd00001).nopw();  // bit 0: FPGA programming serial in (lsb first)
892 	map(0xd00002, 0xd00003).portr("TRACKBALL_1_Y");
893 	map(0xd00004, 0xd00005).portr("TRACKBALL_2_X");
894 	map(0xd00006, 0xd00007).portr("TRACKBALL_2_Y");
895 	map(0xd00008, 0xd00009).portr("P1");
896 	map(0xd0000a, 0xd0000b).portr("P2");
897 	map(0xd0000c, 0xd0000d).portr("SYSTEM").w(FUNC(galgames_state::outputs_w));
898 
899 	map(0xd0000e, 0xd0000f).nopr();
900 	map(0xd0000f, 0xd0000f).w(m_slot, FUNC(galgames_slot_device::cart_sel_w));
901 	map(0xd00011, 0xd00011).rw(m_slot, FUNC(galgames_slot_device::eeprom_r), FUNC(galgames_slot_device::eeprom_w));
902 	map(0xd00013, 0xd00013).rw(m_slot, FUNC(galgames_slot_device::pic_data_r), FUNC(galgames_slot_device::pic_data_w));
903 	map(0xd00015, 0xd00015).rw(m_slot, FUNC(galgames_slot_device::pic_status_r), FUNC(galgames_slot_device::ram_sel_w));
904 }
905 
blitter_map(address_map & map)906 void galgames_state::blitter_map(address_map &map)
907 {
908 	map(0x000000, 0x1fffff).r(":slot", FUNC(galgames_slot_device::rom_r));
909 }
910 
oki_map(address_map & map)911 void galgames_state::oki_map(address_map &map)
912 {
913 	map(0x00000, 0x3ffff).ram().share("okiram");
914 }
915 
916 /***************************************************************************
917 
918                                 Input Ports
919 
920 ***************************************************************************/
921 
922 static INPUT_PORTS_START(galgames)
923 	PORT_START("P1")
924 	PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_UNKNOWN)
925 	PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN)
926 	PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN)
927 	PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN)
928 	PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(1)   // Button A (right)
929 	PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1)   // Button B (left)
930 	PORT_BIT(0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN)
931 	PORT_BIT(0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN)
932 	PORT_BIT(0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN)
933 
934 	PORT_START("P2")
935 	PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_UNKNOWN)
936 	PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN)
937 	PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN)
938 	PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN)
939 	PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(2)   // Button A (right)
940 	PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(2)   // Button B (left)
941 	PORT_BIT(0x0040, IP_ACTIVE_LOW, IPT_SERVICE1)                  // DBA (coin)
942 	PORT_BIT(0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN)
943 	PORT_BIT(0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN)
944 
945 	PORT_START("SYSTEM")
946 	PORT_BIT(0x0001, IP_ACTIVE_LOW, IPT_COIN1)    // CS 1 (coin)
947 	PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_COIN2)    // CS 2 (coin)
PORT_CODE(KEYCODE_F2)948 	PORT_BIT(0x0004, IP_ACTIVE_HIGH,IPT_OTHER) PORT_CODE(KEYCODE_F2) PORT_NAME("Service Mode (Coin Door)") PORT_TOGGLE
949 	PORT_BIT(0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN)
950 	PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN)
951 	PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN)
952 	PORT_BIT(0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN)
953 	PORT_BIT(0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN)
954 	PORT_BIT(0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN)
955 
956 	PORT_START("TRACKBALL_1_X")
957 	PORT_BIT(0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(25) PORT_KEYDELTA(5) PORT_PLAYER(1) PORT_RESET
958 
959 	PORT_START("TRACKBALL_1_Y")
960 	PORT_BIT(0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(25) PORT_KEYDELTA(5) PORT_PLAYER(1) PORT_RESET
961 
962 	PORT_START("TRACKBALL_2_X")
963 	PORT_BIT(0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(25) PORT_KEYDELTA(5) PORT_PLAYER(2) PORT_RESET
964 
965 	PORT_START("TRACKBALL_2_Y")
966 	PORT_BIT(0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(25) PORT_KEYDELTA(5) PORT_PLAYER(2) PORT_RESET
967 INPUT_PORTS_END
968 
969 /***************************************************************************
970 
971                                Machine Drivers
972 
973 ***************************************************************************/
974 
975 TIMER_DEVICE_CALLBACK_MEMBER(galgames_state::scanline_interrupt)
976 {
977 	int scanline = param;
978 
979 	if (scanline == 0) // vblank, FIXME
980 		m_maincpu->set_input_line(3, HOLD_LINE);
981 	else if ((scanline % 16) == 0)
982 		m_maincpu->set_input_line(1, HOLD_LINE);
983 
984 	// lev 2 triggered at the end of the blit
985 }
986 
galgames_compute_addr(u16 reg_low,u16 reg_mid,u16 reg_high)987 int galgames_compute_addr(u16 reg_low, u16 reg_mid, u16 reg_high)
988 {
989 	return reg_low | (reg_mid << 16);
990 }
991 
galgames_base(machine_config & config)992 void galgames_state::galgames_base(machine_config &config)
993 {
994 	M68000(config, m_maincpu, XTAL(24'000'000) / 2);
995 	m_maincpu->set_addrmap(AS_PROGRAM, &galgames_state::galgames_map);
996 	TIMER(config, "scantimer").configure_scanline(FUNC(galgames_state::scanline_interrupt), "screen", 0, 1);
997 	WATCHDOG_TIMER(config, "watchdog");
998 
999 	GALGAMES_SLOT(config, m_slot, 0);
1000 	GALGAMES_BIOS_CART(config, "cart0", 0);
1001 
1002 	// video hardware
1003 	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
1004 	m_screen->set_refresh_hz(60);
1005 	m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0));
1006 	m_screen->set_size(400, 256);
1007 	m_screen->set_visarea(0, 400-1, 0, 256-1);
1008 	m_screen->set_screen_update(FUNC(galgames_state::screen_update));
1009 	m_screen->set_palette(m_palette);
1010 
1011 	CESBLIT(config, m_blitter, XTAL(24'000'000), m_screen);
1012 	m_blitter->set_addrmap(AS_PROGRAM, &galgames_state::blitter_map);
1013 	m_blitter->set_compute_addr(galgames_compute_addr);
1014 	m_blitter->irq_callback().set(FUNC(galgames_state::blitter_irq_callback));
1015 
1016 	PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x1000); // only 0x100 used
1017 
1018 	// sound hardware
1019 	SPEAKER(config, "mono").front_center();
1020 	OKIM6295(config, m_oki, XTAL(24'000'000) / 16, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified (voices in galgame4 seem ok)
1021 	m_oki->set_addrmap(0, &galgames_state::oki_map);
1022 	m_oki->add_route(ALL_OUTPUTS, "mono", 1.0);
1023 }
1024 
galgbios(machine_config & config)1025 void galgames_state::galgbios(machine_config &config)
1026 {
1027 	galgames_base(config);
1028 	GALGAMES_CART(config, "cart1", 1);
1029 	GALGAMES_CART(config, "cart2", 2);
1030 	GALGAMES_CART(config, "cart3", 3);
1031 	GALGAMES_CART(config, "cart4", 4);
1032 }
1033 
galgame2(machine_config & config)1034 void galgames_state::galgame2(machine_config &config)
1035 {
1036 	galgames_base(config);
1037 	GALGAMES_STARPAK2_CART(config, "cart1", 1);
1038 	GALGAMES_CART(config, "cart2", 2);
1039 	GALGAMES_CART(config, "cart3", 3);
1040 	GALGAMES_CART(config, "cart4", 4);
1041 }
1042 
galgame3(machine_config & config)1043 void galgames_state::galgame3(machine_config &config)
1044 {
1045 	galgames_base(config);
1046 	GALGAMES_STARPAK3_CART(config, "cart1", 1);
1047 	GALGAMES_CART(config, "cart2", 2);
1048 	GALGAMES_CART(config, "cart3", 3);
1049 	GALGAMES_CART(config, "cart4", 4);
1050 }
1051 
1052 /***************************************************************************
1053 
1054                                ROMs Loading
1055 
1056 ***************************************************************************/
1057 
1058 
1059 /***************************************************************************
1060 
1061 Galaxy Games BIOS
1062 
1063 This is a multi-game cocktail cabinet released in 1998. Namco and Atari
1064 licensed their IP for some cartridges for it.
1065 
1066 Trackball-based. 'BIOS' has 7 built-in games. There are two LEDs on the PCB.
1067 
1068 More information here : http://www.cesgames.com/museum/galaxy/index.html
1069 
1070 ----
1071 
1072 Board silkscreened  237-0211-00
1073                     REV.-D
1074 
1075 Cartridge based mother board
1076 Holds up to 4 cartridges
1077 Chips labeled
1078     GALAXY U1 V1.90 12/1/98
1079     GALAXY U2 V1.90 12/1/98
1080 
1081 Motorola MC68HC000FN12
1082 24 MHz oscillator
1083 Xilinx XC5206
1084 Xilinx XC5202
1085 BT481AKPJ110 (Palette RAMDAC)
1086 NKK N341024SJ-15    x8  (128kB RAM)
1087 OKI M6295 8092352-2
1088 
1089 PAL16V8H-15 @ U24   Blue dot on it
1090 PAL16V8H-15 @ U25   Yellow dot on it
1091 PAL16V8H-15 @ U26   Red dot on it
1092 PAL16V8H-15 @ U27   Green dot on it
1093 PAL16V8H-15 @ U45   Magenta dot on it
1094 
1095 Copyright notice in rom states: Creative Electronics & Software Written by Keith M. Kolmos May 29,1998
1096 
1097 ***************************************************************************/
1098 
1099 #define ROM_LOAD16_BYTE_BIOS(bios,name,offset,length,hash) \
1100 	ROMX_LOAD(name, offset, length, hash, ROM_SKIP(1) | ROM_BIOS(bios))
1101 
1102 #define GALGAMES_BIOS_ROMS \
1103 	ROM_SYSTEM_BIOS(0, "1.90",   "v1.90 12/01/98") \
1104 	ROM_LOAD16_BYTE_BIOS(0, "galaxy_u2__v1.90_12-01-98.u2", 0x000000, 0x100000, CRC(e51ff184) SHA1(aaa795f2c15ec29b3ceeb5c917b643db0dbb7083)) \
1105 	ROM_LOAD16_BYTE_BIOS(0, "galaxy_u1__v1.90_12-01-98.u1", 0x000001, 0x100000, CRC(c6d7bc6d) SHA1(93c032f9aa38cbbdda59a8a25ff9f38f7ad9c760)) \
1106 	\
1107 	ROM_SYSTEM_BIOS(1, "1.80",   "v1.80 10/05/98") \
1108 	ROM_LOAD16_BYTE_BIOS(1, "galaxy_u2__v1.80_10-15-98.u2", 0x000000, 0x100000, CRC(73cff284) SHA1(e6f7d92999cdb478c21c3b65a04eade84299ac12)) \
1109 	ROM_LOAD16_BYTE_BIOS(1, "galaxy_u1__v1.80_10-15-98.u1", 0x000001, 0x100000, CRC(e3ae423c) SHA1(66d1964845a99a5ed4b19b4135b55cde6b5fe295))
1110 
1111 #define GALGAMES_MB_PALS \
1112 	ROM_REGION(0xa00, "pals", 0) \
1113 	ROM_LOAD("16v8h-blue.u24",    0x000, 0x117, NO_DUMP) \
1114 	ROM_LOAD("16v8h-yellow.u25",  0x200, 0x117, NO_DUMP) \
1115 	ROM_LOAD("16v8h-magenta.u26", 0x400, 0x117, NO_DUMP) \
1116 	ROM_LOAD("16v8h-green.u27",   0x600, 0x117, NO_DUMP) \
1117 	ROM_LOAD("16v8h-red.u45",     0x800, 0x117, NO_DUMP)
1118 
1119 ROM_START(galgbios)
1120 	ROM_REGION16_BE(0x200000, "cart0", 0)
1121 	GALGAMES_BIOS_ROMS
1122 
1123 	ROM_REGION(0x200000, "cart1", ROMREGION_ERASEFF)
1124 	ROM_REGION(0x200000, "cart2", ROMREGION_ERASEFF)
1125 	ROM_REGION(0x200000, "cart3", ROMREGION_ERASEFF)
1126 	ROM_REGION(0x200000, "cart4", ROMREGION_ERASEFF)
1127 
1128 	GALGAMES_MB_PALS
1129 ROM_END
1130 
1131 /***************************************************************************
1132 
1133 Galaxy Games StarPak 2
1134 
1135 NAMCO 307 Cartridge, has surface mount Flash chips in it:
1136 
1137 .U1 AM29F800BB
1138 .U2 AM29F800BB
1139 .U3 93AA76/SN
1140 .U4 PIC 12C508
1141 .L1 Led
1142 
1143 Board silkscreened  237-0209-00
1144                     REV.-C
1145 
1146 ***************************************************************************/
1147 
1148 ROM_START(galgame2)
1149 	ROM_REGION16_BE(0x200000, "cart0", 0)
1150 	GALGAMES_BIOS_ROMS
1151 
1152 	ROM_REGION(0x200000, "cart1", 0)
1153 	ROM_LOAD16_BYTE("am29f800bb.u2", 0x000000, 0x100000, CRC(f43c0c54) SHA1(4a13946c3d173b0e4ab25b01849574fa3302b417))
1154 	ROM_LOAD16_BYTE("am29f800bb.u1", 0x000001, 0x100000, CRC(b8c34a8b) SHA1(40d3b35f573d2bd2ae1c7d876c55fc436864fa3f))
1155 
1156 	ROM_REGION(0x2000, "cart1:pic", 0)
1157 	ROM_LOAD("pic12c508.u4", 0x0000, 0x2000, CRC(bb253913) SHA1(eace069344da6dda7c05673e422876d130ed5d48))  // includes config word at fff, hence size is 2*1000
1158 
1159 	ROM_REGION(0x200000, "cart2", ROMREGION_ERASEFF)
1160 	ROM_REGION(0x200000, "cart3", ROMREGION_ERASEFF)
1161 	ROM_REGION(0x200000, "cart4", ROMREGION_ERASEFF)
1162 
1163 	GALGAMES_MB_PALS
1164 ROM_END
1165 
1166 /***************************************************************************
1167 
1168 Galaxy Games StarPak 3
1169 
1170 Cartridge with 8 games, including Atari licensed Centipede.
1171 
1172 .U1 AM29F032B
1173 .U2 AM29F032B
1174 .U5 93AA76/SN
1175 .U6 PIC 16C56-XT/P
1176 .L1 Led
1177 
1178 Board silkscreened  237-0228-00
1179                     REV.-B
1180 
1181 ***************************************************************************/
1182 
1183 ROM_START(galgame3)
1184 	ROM_REGION16_BE(0x200000, "cart0", 0)
1185 	GALGAMES_BIOS_ROMS
1186 
1187 	ROM_REGION(0x800000, "cart1", 0)
1188 	ROM_LOAD16_BYTE("am29f032b.u2", 0x000000, 0x400000, CRC(a4ffc70a) SHA1(328c6ceef025af7ff5b7998df59a10d90c654d53))
1189 	ROM_LOAD16_BYTE("am29f032b.u1", 0x000001, 0x400000, CRC(b0876751) SHA1(487f052989e4b2df2df2293b283e8e03ffc3ddf4))
1190 
1191 	ROM_REGION(0x800, "cart1:pic", 0)
1192 	ROM_LOAD("pic16c56.u6", 0x000, 0x800, CRC(cf901ed8) SHA1(ebb2da0f50ba82a038f315aab7e6b20b9a1af3a1))
1193 
1194 	ROM_REGION(0x200000, "cart2", ROMREGION_ERASEFF)
1195 	ROM_REGION(0x200000, "cart3", ROMREGION_ERASEFF)
1196 	ROM_REGION(0x200000, "cart4", ROMREGION_ERASEFF)
1197 
1198 	GALGAMES_MB_PALS
1199 ROM_END
1200 
1201 /***************************************************************************
1202 
1203 Galaxy Games StarPak 4
1204 (Cartridge not dumped, but files from a dev board provided by the developer)
1205 
1206 ***************************************************************************/
1207 
1208 ROM_START(galgame4)
1209 	ROM_REGION16_BE(0x200000, "cart0", 0)
1210 	GALGAMES_BIOS_ROMS
1211 
1212 	ROM_REGION(0x800000, "cart1", 0)
1213 	ROM_LOAD16_BYTE("sp4.u2",  0x000000, 0x100000, CRC(e51bc5e1) SHA1(dacf6cefd792713b34382b827952b66e2cb5c2b4)) // JANUARY 12, 1998
1214 	ROM_LOAD16_BYTE("sp4.u1",  0x000001, 0x100000, CRC(695ab775) SHA1(e88d5f982df19e70be6124e6fdf20830475641e0)) // ""
1215 	ROM_LOAD16_BYTE("sp4.u6",  0x200000, 0x100000, CRC(7716895d) SHA1(8f86ffe2d94d3e756a3b7661d480e3a8c53cf178))
1216 	ROM_LOAD16_BYTE("sp4.u5",  0x200001, 0x100000, CRC(6c699ba3) SHA1(f675997e1b808758f79a21b883161526242990b4))
1217 	ROM_LOAD16_BYTE("sp4.u8",  0x400000, 0x100000, CRC(cdf45446) SHA1(da4e1667c7c47239e770018a7d3b8c1e4e2f4a63))
1218 	ROM_LOAD16_BYTE("sp4.u7",  0x400001, 0x100000, CRC(813c46c8) SHA1(3fd4192ec7e8d5e6bfbc2a37d9b4bbebe6132b99))
1219 	ROM_LOAD16_BYTE("sp4.u10", 0x600000, 0x100000, CRC(52dbf088) SHA1(da7c37366e884f40f1dea243d4aea0b2d2b314db))
1220 	ROM_LOAD16_BYTE("sp4.u9",  0x600001, 0x100000, CRC(9ded1dc2) SHA1(5319edfccf47d02dfd3664cb3782cc2281c769c4))
1221 
1222 	ROM_REGION(0x2000, "cart1:pic", 0)
1223 	ROM_LOAD("sp4.pic", 0x000, 0x2000, CRC(008ef1ba) SHA1(4065fcf00922de3e629084f4f4815355f271c954))
1224 
1225 	ROM_REGION(0x200000, "cart2", ROMREGION_ERASEFF)
1226 	ROM_REGION(0x200000, "cart3", ROMREGION_ERASEFF)
1227 	ROM_REGION(0x200000, "cart4", ROMREGION_ERASEFF)
1228 
1229 	GALGAMES_MB_PALS
1230 ROM_END
1231 
1232 
1233 GAME(1998, galgbios, 0,        galgbios, galgames, galgames_state, empty_init, ROT0, "Creative Electronics & Software",         "Galaxy Games BIOS",                  MACHINE_IS_BIOS_ROOT)
1234 GAME(1998, galgame2, galgbios, galgame2, galgames, galgames_state, empty_init, ROT0, "Creative Electronics & Software / Namco", "Galaxy Games StarPak 2",             0)
1235 GAME(1998, galgame3, galgbios, galgame3, galgames, galgames_state, empty_init, ROT0, "Creative Electronics & Software / Atari", "Galaxy Games StarPak 3",             0)
1236 GAME(1998, galgame4, galgbios, galgame3, galgames, galgames_state, empty_init, ROT0, "Creative Electronics & Software",         "Galaxy Games StarPak 4 (prototype)", MACHINE_IMPERFECT_GRAPHICS)
1237