1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /***************************************************************************
4 
5     Irem M63 hardware
6 
7 ****************************************************************************
8 
9 Wily Tower              (c) 1984 Irem
10 Fighting Basketball     (c) 1984 Paradise Co. Ltd.
11 
12 driver by Nicola Salmoria
13 
14 
15 PCB Layout (based on Atomic Boy PCB)
16 ------------------------------------
17 
18 Both boards has etched NANAO logo.
19 They (Eizo Nanao Corporation) own Irem Software Engineering.
20 
21 
22 M63-A-A (TOP)
23 
24        1         2       3       4       5       6       7
25 |---------------------------------------------------------------|
26 |              DSW8    74373                                    |   A
27 |                                                               |
28 |-|   74368    DSW8    74373    AY-3-8910     MSM80C39R6       |-|  B
29   |                                                            | |
30   |   74368            74373    AY-3-8910   74373              | |  C
31   |                                                            | |
32   |   74368    7408    74373   wt_a-4d         wt_a-6d        C| |  D
33   |                                                           N| |
34   |   74368    7400    7404    wt_a-4e 7404    7474    74???  1| |  E
35   |2                                                           | |
36   |2                   74138           74367   7474    74367   | |  F
37   |W                                                           | |
38   |A           7432    7427    wt_a-4h D780C                   | |  H
39   |Y                                                           |-|
40   |   74368    74299   wt_a-3j wt_a-4j 74367   74245            |   J
41   |                                                            |-|
42   |            74367   wt_a-3k wt_a-4k 74138   7432            | |  K
43   |                                                            | |
44   |            74299                   74139   7432            | |  L
45   |                                                            | |
46 |-|   74368    74299   wt_a-3m wt_a-4m 74139   M53202  7474   C| |  M
47 |                                                             N| |
48 |     7400     74299   wt_a-3n wt_a-4n 74273   74283   7420   2| |  N
49 |                                                              | |
50 |              74157   wt_a-3p M58725 WT_A-5P  74283   74273   | |  P
51 |                                                              | |
52 |              74299                  WT_A-5R  7432    74157   |-|  R
53 |     AMP                                                       |
54 |              74299   wt_a-3s M58725 WT_A-5S  74273   74157    |   S
55 |---------------------------------------------------------------|
56 
57 M63-B-A (BOTTOM)
58 
59       1        2       3       4       5       6       7       8       9
60 |------------------------------------------------------------------------------|
61 |   74244     74244      74244    wt_b-5a     2128   74244   74244   74245     |   A
62 |                                                                              -
63 |   74373     74273      74299    wt_b-5b     2128   74161   74161   74161    | |  B
64 |                                                                             | |
65 |   74244     74273      74299                       74157   74157   74157    | |  C
66 |                                                                             | |
67 |   74273     74244      74299    wt_b-5d     2128   74157   74157   74157   C| |  D
68 |                                                                            N| |
69 |   2148      74283      74299    wt_b-5e     2128   74157   74157   74157   1| |  E
70 |                                                                             | |
71 |   2148      74283      74299    wt_b-5f     2128   74157   74157   74157    | |  F
72 |                                                                             | |
73 |   74157     7420       74157                2128   2148    7486    7486     |-|  H
74 |                                                                              |
75 |   74157     7430   74367   7474    74273           2148    74367   74367    |-|  J
76 |                                                                             | |
77 |   74161     74139  7420    74161   7486    74139   7474    74161   74161    | |  K
78 |                                                                             | |
79 |   74157     7432   7474    74161   7486    7404    7474    74175   wt_b-9l  | |  L
80 |                                                                            C| |
81 |   74161     7432   74368   74???   74175   7408    7400    7432            N| |  M
82 |                                                                            2| |
83 |             7400   7404    7420    74175   7474    74273   74377   74175    | |  N
84 |                                                                             | |
85 |                    7414    M53202  74163   7486    2148    74241   7427     | |  P
86 |                                                                             |-|
87 |             12MHz  7404            74163   7486    2148    74241   74373     |   R
88 |------------------------------------------------------------------------------|
89 
90 
91 
92 
93 Notes:
94 - Unless there is some special logic related to NMI enable, the game doesn't
95   rely on vblank for timing. It all seems to be controlled by the CPU clock.
96   The NMI handler just handles the "Stop Mode" dip switch.
97 
98 TS 2008.06.14:
99 - Added sound emulation - atomboy and fghtbskt req different interrupt (T1)
100   timing than wilytowr, otherwise music/fx tempo is too fast.
101   Music tempo and pitch verified on real pcb.
102 - Extra space in atomboy 2764 eproms is filled with garbage z80 code
103   (taken from one of code roms, but from different offset)
104 - Fghtbskt has one AY, but every frame writes 0 to 2nd AY regs - probably
105   leftover from Wily Tower sound driver/code
106 - I'm not sure about sound_status write - maybe it's something else or
107   different data (p1?) is used as status
108 
109 TODO:
110 - Sprite positioning is wacky. The electric 'bands' that go along the pipes
111   are drawn 2 pixels off in x/y directions. If you fix that, then the player
112   sprite doesn't slide in the middle of the pipes when climbing...
113 - Clocks
114 
115 Dip locations verified for:
116 - atomboy (manual)
117 
118 ***************************************************************************/
119 
120 #include "emu.h"
121 #include "cpu/z80/z80.h"
122 #include "cpu/mcs48/mcs48.h"
123 #include "machine/74259.h"
124 #include "machine/gen_latch.h"
125 #include "sound/ay8910.h"
126 #include "sound/samples.h"
127 #include "emupal.h"
128 #include "screen.h"
129 #include "speaker.h"
130 #include "tilemap.h"
131 
132 class m63_state : public driver_device
133 {
134 public:
m63_state(const machine_config & mconfig,device_type type,const char * tag)135 	m63_state(const machine_config &mconfig, device_type type, const char *tag) :
136 		driver_device(mconfig, type, tag),
137 		m_spriteram(*this, "spriteram"),
138 		m_scrollram(*this, "scrollram"),
139 		m_videoram2(*this, "videoram2"),
140 		m_videoram(*this, "videoram"),
141 		m_colorram(*this, "colorram"),
142 		m_maincpu(*this, "maincpu"),
143 		m_ay1(*this, "ay1"),
144 		m_ay2(*this, "ay2"),
145 		m_gfxdecode(*this, "gfxdecode"),
146 		m_palette(*this, "palette"),
147 		m_soundcpu(*this, "soundcpu"),
148 		m_samples(*this, "samples"),
149 		m_soundlatch(*this, "soundlatch")
150 	{
151 	}
152 
153 	void atomboy(machine_config &config);
154 	void m63(machine_config &config);
155 	void fghtbskt(machine_config &config);
156 
157 	void init_wilytowr();
158 	void init_fghtbskt();
159 
160 private:
161 	required_shared_ptr<uint8_t> m_spriteram;
162 	required_shared_ptr<uint8_t> m_scrollram;
163 	required_shared_ptr<uint8_t> m_videoram2;
164 	required_shared_ptr<uint8_t> m_videoram;
165 	required_shared_ptr<uint8_t> m_colorram;
166 
167 	uint8_t    m_nmi_mask;
168 
169 	/* video-related */
170 	tilemap_t  *m_bg_tilemap;
171 	tilemap_t  *m_fg_tilemap;
172 	int      m_pal_bank;
173 	int      m_fg_flag;
174 	int      m_sy_offset;
175 
176 	/* sound-related */
177 	uint8_t    m_sound_irq;
178 	int      m_sound_status;
179 	int      m_p1;
180 	int      m_p2;
181 	std::unique_ptr<int16_t[]>    m_samplebuf;
182 
183 	/* devices */
184 	required_device<cpu_device> m_maincpu;
185 	required_device<ay8910_device> m_ay1;
186 	optional_device<ay8910_device> m_ay2;
187 	required_device<gfxdecode_device> m_gfxdecode;
188 	required_device<palette_device> m_palette;
189 	required_device<i8039_device> m_soundcpu;
190 	optional_device<samples_device> m_samples;
191 	required_device<generic_latch_8_device> m_soundlatch;
192 
193 	void m63_videoram_w(offs_t offset, uint8_t data);
194 	void m63_colorram_w(offs_t offset, uint8_t data);
195 	void m63_videoram2_w(offs_t offset, uint8_t data);
196 	DECLARE_WRITE_LINE_MEMBER(pal_bank_w);
197 	DECLARE_WRITE_LINE_MEMBER(m63_flipscreen_w);
198 	DECLARE_WRITE_LINE_MEMBER(fghtbskt_flipscreen_w);
199 	DECLARE_WRITE_LINE_MEMBER(coin1_w);
200 	DECLARE_WRITE_LINE_MEMBER(coin2_w);
201 	void snd_irq_w(uint8_t data);
202 	void snddata_w(offs_t offset, uint8_t data);
203 	void p1_w(uint8_t data);
204 	void p2_w(uint8_t data);
205 	uint8_t snd_status_r();
206 	DECLARE_READ_LINE_MEMBER(irq_r);
207 	uint8_t snddata_r(offs_t offset);
208 	void fghtbskt_samples_w(uint8_t data);
209 	SAMPLES_START_CB_MEMBER(fghtbskt_sh_start);
210 	DECLARE_WRITE_LINE_MEMBER(nmi_mask_w);
211 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
212 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
213 	DECLARE_MACHINE_START(m63);
214 	DECLARE_MACHINE_RESET(m63);
215 	DECLARE_VIDEO_START(m63);
216 	void m63_palette(palette_device &palette) const;
217 	uint32_t screen_update_m63(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
218 	INTERRUPT_GEN_MEMBER(snd_irq);
219 	INTERRUPT_GEN_MEMBER(vblank_irq);
220 	void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
221 	void fghtbskt_map(address_map &map);
222 	void i8039_map(address_map &map);
223 	void i8039_port_map(address_map &map);
224 	void m63_map(address_map &map);
225 };
226 
227 
m63_palette(palette_device & palette) const228 void m63_state::m63_palette(palette_device &palette) const
229 {
230 	uint8_t const *color_prom = memregion("proms")->base();
231 
232 	for (int i = 0; i < 256; i++)
233 	{
234 		int bit0, bit1, bit2, bit3;
235 
236 		// red component
237 		bit0 = BIT(color_prom[i], 0);
238 		bit1 = BIT(color_prom[i], 1);
239 		bit2 = BIT(color_prom[i], 2);
240 		bit3 = BIT(color_prom[i], 3);
241 		int const r =  0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
242 		// green component
243 		bit0 = BIT(color_prom[i + 256], 0);
244 		bit1 = BIT(color_prom[i + 256], 1);
245 		bit2 = BIT(color_prom[i + 256], 2);
246 		bit3 = BIT(color_prom[i + 256], 3);
247 		int const g =  0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
248 		// blue component
249 		bit0 = BIT(color_prom[i + 2*256], 0);
250 		bit1 = BIT(color_prom[i + 2*256], 1);
251 		bit2 = BIT(color_prom[i + 2*256], 2);
252 		bit3 = BIT(color_prom[i + 2*256], 3);
253 		int const b =  0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
254 
255 		palette.set_pen_color(i, rgb_t(r, g, b));
256 	}
257 
258 	color_prom += 3 * 256;
259 
260 	for (int i = 0; i < 4; i++)
261 	{
262 		int bit0, bit1, bit2;
263 
264 		// red component
265 		bit0 = BIT(color_prom[i], 0);
266 		bit1 = BIT(color_prom[i], 1);
267 		bit2 = BIT(color_prom[i], 2);
268 		int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
269 		// green component
270 		bit0 = BIT(color_prom[i], 3);
271 		bit1 = BIT(color_prom[i], 4);
272 		bit2 = BIT(color_prom[i], 5);
273 		int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
274 		// blue component
275 		bit0 = BIT(color_prom[i], 6);
276 		bit1 = BIT(color_prom[i], 7);
277 		int const b = 0x4f * bit0 + 0xa8 * bit1;
278 
279 		palette.set_pen_color(i + 256, rgb_t(r, g, b));
280 	}
281 }
282 
m63_videoram_w(offs_t offset,uint8_t data)283 void m63_state::m63_videoram_w(offs_t offset, uint8_t data)
284 {
285 	m_videoram[offset] = data;
286 	m_bg_tilemap->mark_tile_dirty(offset);
287 }
288 
m63_colorram_w(offs_t offset,uint8_t data)289 void m63_state::m63_colorram_w(offs_t offset, uint8_t data)
290 {
291 	m_colorram[offset] = data;
292 	m_bg_tilemap->mark_tile_dirty(offset);
293 }
294 
m63_videoram2_w(offs_t offset,uint8_t data)295 void m63_state::m63_videoram2_w(offs_t offset, uint8_t data)
296 {
297 	m_videoram2[offset] = data;
298 	m_fg_tilemap->mark_tile_dirty(offset);
299 }
300 
WRITE_LINE_MEMBER(m63_state::pal_bank_w)301 WRITE_LINE_MEMBER(m63_state::pal_bank_w)
302 {
303 	m_pal_bank = state;
304 	m_bg_tilemap->mark_all_dirty();
305 }
306 
WRITE_LINE_MEMBER(m63_state::m63_flipscreen_w)307 WRITE_LINE_MEMBER(m63_state::m63_flipscreen_w)
308 {
309 	flip_screen_set(!state);
310 	machine().tilemap().mark_all_dirty();
311 }
312 
WRITE_LINE_MEMBER(m63_state::fghtbskt_flipscreen_w)313 WRITE_LINE_MEMBER(m63_state::fghtbskt_flipscreen_w)
314 {
315 	flip_screen_set(state);
316 	m_fg_flag = flip_screen() ? TILE_FLIPX : 0;
317 }
318 
319 
TILE_GET_INFO_MEMBER(m63_state::get_bg_tile_info)320 TILE_GET_INFO_MEMBER(m63_state::get_bg_tile_info)
321 {
322 	int attr = m_colorram[tile_index];
323 	int code = m_videoram[tile_index] | ((attr & 0x30) << 4);
324 	int color = (attr & 0x0f) + (m_pal_bank << 4);
325 
326 	tileinfo.set(1, code, color, 0);
327 }
328 
TILE_GET_INFO_MEMBER(m63_state::get_fg_tile_info)329 TILE_GET_INFO_MEMBER(m63_state::get_fg_tile_info)
330 {
331 	int code = m_videoram2[tile_index];
332 
333 	tileinfo.set(0, code, 0, m_fg_flag);
334 }
335 
VIDEO_START_MEMBER(m63_state,m63)336 VIDEO_START_MEMBER(m63_state,m63)
337 {
338 	m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(m63_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
339 	m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(m63_state::get_fg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
340 
341 	m_bg_tilemap->set_scroll_cols(32);
342 	m_fg_tilemap->set_transparent_pen(0);
343 }
344 
draw_sprites(bitmap_ind16 & bitmap,const rectangle & cliprect)345 void m63_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
346 {
347 	int offs;
348 
349 	for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
350 	{
351 		int code = m_spriteram[offs + 1] | ((m_spriteram[offs + 2] & 0x10) << 4);
352 		int color = (m_spriteram[offs + 2] & 0x0f) + (m_pal_bank << 4);
353 		int flipx = m_spriteram[offs + 2] & 0x20;
354 		int flipy = 0;
355 		int sx = m_spriteram[offs + 3];
356 		int sy = m_sy_offset - m_spriteram[offs];
357 
358 		if (flip_screen())
359 		{
360 			sx = 240 - sx;
361 			sy = m_sy_offset - sy;
362 			flipx = !flipx;
363 			flipy = !flipy;
364 		}
365 
366 
367 			m_gfxdecode->gfx(2)->transpen(bitmap,cliprect,
368 			code, color,
369 			flipx, flipy,
370 			sx, sy, 0);
371 
372 		/* sprite wrapping - verified on real hardware*/
373 		if (sx > 0xf0)
374 		{
375 			m_gfxdecode->gfx(2)->transpen(bitmap,cliprect,
376 			code, color,
377 			flipx, flipy,
378 			sx - 0x100, sy, 0);
379 		}
380 
381 	}
382 }
383 
screen_update_m63(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)384 uint32_t m63_state::screen_update_m63(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
385 {
386 	int col;
387 
388 	for (col = 0; col < 32; col++)
389 		m_bg_tilemap->set_scrolly(col, m_scrollram[col * 8]);
390 
391 	m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
392 	draw_sprites(bitmap, cliprect);
393 	m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
394 	return 0;
395 }
396 
397 
WRITE_LINE_MEMBER(m63_state::coin1_w)398 WRITE_LINE_MEMBER(m63_state::coin1_w)
399 {
400 	machine().bookkeeping().coin_counter_w(0, state);
401 }
402 
WRITE_LINE_MEMBER(m63_state::coin2_w)403 WRITE_LINE_MEMBER(m63_state::coin2_w)
404 {
405 	machine().bookkeeping().coin_counter_w(1, state);
406 }
407 
snd_irq_w(uint8_t data)408 void m63_state::snd_irq_w(uint8_t data)
409 {
410 	m_soundcpu->set_input_line(0, ASSERT_LINE);
411 	machine().scheduler().synchronize();
412 }
413 
snddata_w(offs_t offset,uint8_t data)414 void m63_state::snddata_w(offs_t offset, uint8_t data)
415 {
416 	if ((m_p2 & 0xf0) == 0xe0)
417 		m_ay1->address_w(offset);
418 	else if ((m_p2 & 0xf0) == 0xa0)
419 		m_ay1->data_w(offset);
420 	else if (m_ay2 != nullptr && (m_p1 & 0xe0) == 0x60)
421 		m_ay2->address_w(offset);
422 	else if (m_ay2 != nullptr && (m_p1 & 0xe0) == 0x40)
423 			m_ay2->data_w(offset);
424 	else if ((m_p2 & 0xf0) == 0x70 )
425 		m_sound_status = offset;
426 }
427 
p1_w(uint8_t data)428 void m63_state::p1_w(uint8_t data)
429 {
430 	m_p1 = data;
431 }
432 
p2_w(uint8_t data)433 void m63_state::p2_w(uint8_t data)
434 {
435 	m_p2 = data;
436 	if((m_p2 & 0xf0) == 0x50)
437 	{
438 		m_soundcpu->set_input_line(0, CLEAR_LINE);
439 	}
440 }
441 
snd_status_r()442 uint8_t m63_state::snd_status_r()
443 {
444 	return m_sound_status;
445 }
446 
READ_LINE_MEMBER(m63_state::irq_r)447 READ_LINE_MEMBER(m63_state::irq_r)
448 {
449 	if (m_sound_irq)
450 	{
451 		m_sound_irq = 0;
452 		return 1;
453 	}
454 	return 0;
455 }
456 
snddata_r(offs_t offset)457 uint8_t m63_state::snddata_r(offs_t offset)
458 {
459 	switch (m_p2 & 0xf0)
460 	{
461 		case 0x60:  return m_soundlatch->read();
462 		case 0x70:  return memregion("user1")->base()[((m_p1 & 0x1f) << 8) | offset];
463 	}
464 	return 0xff;
465 }
466 
fghtbskt_samples_w(uint8_t data)467 void m63_state::fghtbskt_samples_w(uint8_t data)
468 {
469 	if (data & 1)
470 		m_samples->start_raw(0, m_samplebuf.get() + ((data & 0xf0) << 8), 0x2000, 8000);
471 }
472 
WRITE_LINE_MEMBER(m63_state::nmi_mask_w)473 WRITE_LINE_MEMBER(m63_state::nmi_mask_w)
474 {
475 	m_nmi_mask = state;
476 }
477 
478 
m63_map(address_map & map)479 void m63_state::m63_map(address_map &map)
480 {
481 	map(0x0000, 0xbfff).rom();
482 	map(0xd000, 0xdfff).ram();
483 	map(0xe000, 0xe1ff).ram();
484 	map(0xe200, 0xe2ff).ram().share("spriteram");
485 	map(0xe300, 0xe3ff).ram().share("scrollram");
486 	map(0xe400, 0xe7ff).ram().w(FUNC(m63_state::m63_videoram2_w)).share("videoram2");
487 	map(0xe800, 0xebff).ram().w(FUNC(m63_state::m63_videoram_w)).share("videoram");
488 	map(0xec00, 0xefff).ram().w(FUNC(m63_state::m63_colorram_w)).share("colorram");
489 	map(0xf000, 0xf007).w("outlatch", FUNC(ls259_device::write_d0));
490 	map(0xf800, 0xf800).portr("P1").w(m_soundlatch, FUNC(generic_latch_8_device::write));
491 	map(0xf801, 0xf801).portr("P2").nopw(); /* continues game when in stop mode (cleared by NMI handler) */
492 	map(0xf802, 0xf802).portr("DSW1");
493 	map(0xf803, 0xf803).w(FUNC(m63_state::snd_irq_w));
494 	map(0xf806, 0xf806).portr("DSW2");
495 }
496 
fghtbskt_map(address_map & map)497 void m63_state::fghtbskt_map(address_map &map)
498 {
499 	map(0x0000, 0x5fff).rom();
500 	map(0x8000, 0xbfff).rom();
501 	map(0xc000, 0xc7ff).ram();
502 	map(0xd000, 0xd1ff).ram();
503 	map(0xd200, 0xd2ff).ram().share("spriteram");
504 	map(0xd300, 0xd3ff).ram().share("scrollram");
505 	map(0xd400, 0xd7ff).ram().w(FUNC(m63_state::m63_videoram2_w)).share("videoram2");
506 	map(0xd800, 0xdbff).ram().w(FUNC(m63_state::m63_videoram_w)).share("videoram");
507 	map(0xdc00, 0xdfff).ram().w(FUNC(m63_state::m63_colorram_w)).share("colorram");
508 	map(0xf000, 0xf000).r(FUNC(m63_state::snd_status_r));
509 	map(0xf001, 0xf001).portr("P1");
510 	map(0xf002, 0xf002).portr("P2");
511 	map(0xf003, 0xf003).portr("DSW");
512 	map(0xf000, 0xf000).w(FUNC(m63_state::snd_irq_w));
513 	map(0xf001, 0xf001).nopw();
514 	map(0xf002, 0xf002).w(m_soundlatch, FUNC(generic_latch_8_device::write));
515 	map(0xf800, 0xf807).w("outlatch", FUNC(ls259_device::write_d0));
516 	map(0xf807, 0xf807).w(FUNC(m63_state::fghtbskt_samples_w)); // FIXME
517 }
518 
i8039_map(address_map & map)519 void m63_state::i8039_map(address_map &map)
520 {
521 	map(0x0000, 0x0fff).rom();
522 }
523 
524 
i8039_port_map(address_map & map)525 void m63_state::i8039_port_map(address_map &map)
526 {
527 	map(0x00, 0xff).rw(FUNC(m63_state::snddata_r), FUNC(m63_state::snddata_w));
528 }
529 
530 
531 
532 static INPUT_PORTS_START( wilytowr )
533 	PORT_START("P1")
534 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 )
535 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY
536 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
537 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
538 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
539 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START2 )
540 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START1 )
541 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 )
542 
543 	PORT_START("P2")
544 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL
545 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
546 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
547 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
548 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
549 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN2 )
550 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SERVICE1 )
551 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
552 
553 	PORT_START("DSW1")
554 	PORT_DIPNAME( 0x03, 0x01, DEF_STR( Lives ) )        PORT_DIPLOCATION("SW1:!1,!2")
555 	PORT_DIPSETTING(    0x00, "2" )
556 	PORT_DIPSETTING(    0x01, "3" )
557 	PORT_DIPSETTING(    0x02, "4" )
558 	PORT_DIPSETTING(    0x03, "5" )
559 	PORT_DIPNAME( 0x0c, 0x00, "Bonus Points Rate" )     PORT_DIPLOCATION("SW1:!3,!4")
560 	PORT_DIPSETTING(    0x00, DEF_STR( Normal ) )
561 	PORT_DIPSETTING(    0x04, "x1.2" )
562 	PORT_DIPSETTING(    0x08, "x1.4" )
563 	PORT_DIPSETTING(    0x0c, "x1.6" )
564 	PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )       PORT_DIPLOCATION("SW1:!5,!6") PORT_CONDITION("DSW1",0x04,EQUALS,0x04) /* coin mode 2 */
565 	PORT_DIPSETTING(    0x20, DEF_STR( 3C_1C ) )
566 	PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
567 	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
568 	PORT_DIPSETTING(    0x30, DEF_STR( Free_Play ) )    /* Not documented */
569 	PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )       PORT_DIPLOCATION("SW1:!7,!8") PORT_CONDITION("DSW1",0x04,EQUALS,0x04) /* coin mode 2 */
570 	PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) )
571 	PORT_DIPSETTING(    0x40, DEF_STR( 1C_3C ) )
572 	PORT_DIPSETTING(    0x80, DEF_STR( 1C_5C ) )
573 	PORT_DIPSETTING(    0xc0, DEF_STR( 1C_6C ) )
574 	PORT_DIPNAME( 0xf0, 0x00, DEF_STR( Coinage ) )      PORT_DIPLOCATION("SW1:!5,!6,!7,!8") PORT_CONDITION("DSW1",0x04,EQUALS,0x00) /* coin mode 1 */
575 	PORT_DIPSETTING(    0x60, DEF_STR( 7C_1C ) )
576 	PORT_DIPSETTING(    0x50, DEF_STR( 6C_1C ) )
577 	PORT_DIPSETTING(    0x40, DEF_STR( 5C_1C ) )
578 	PORT_DIPSETTING(    0x30, DEF_STR( 4C_1C ) )
579 	PORT_DIPSETTING(    0x20, DEF_STR( 3C_1C ) )
580 	PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
581 	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
582 	PORT_DIPSETTING(    0x80, DEF_STR( 1C_2C ) )
583 	PORT_DIPSETTING(    0x90, DEF_STR( 1C_3C ) )
584 	PORT_DIPSETTING(    0xa0, DEF_STR( 1C_4C ) )
585 	PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
586 	PORT_DIPSETTING(    0xc0, DEF_STR( 1C_6C ) )
587 	PORT_DIPSETTING(    0xd0, DEF_STR( 1C_7C ) )
588 	PORT_DIPSETTING(    0xe0, DEF_STR( 1C_8C ) )
589 	PORT_DIPSETTING(    0x70, DEF_STR( 1C_9C ) )
590 	PORT_DIPSETTING(    0xf0, DEF_STR( Free_Play ) )
591 
592 	PORT_START("DSW2")
593 	PORT_DIPNAME( 0x01, 0x00, DEF_STR( Flip_Screen ) )  PORT_DIPLOCATION("SW2:!1")
594 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
595 	PORT_DIPSETTING(    0x01, DEF_STR( On ) )
596 	PORT_DIPNAME( 0x02, 0x02, DEF_STR( Cabinet ) )      PORT_DIPLOCATION("SW2:!2")
597 	PORT_DIPSETTING(    0x02, DEF_STR( Upright ) )
598 	PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
599 	/*  "For cabinets with a single coin selector or 2 coin selectors of the same value, set to Mode 1.
600 	    For cabinets with coin selectors of two different values, set to Mode 2." */
601 	PORT_DIPNAME( 0x04, 0x00, "Coin Mode" )             PORT_DIPLOCATION("SW2:!3")
602 	PORT_DIPSETTING(    0x00, "Mode 1" )
603 	PORT_DIPSETTING(    0x04, "Mode 2" )
604 	PORT_DIPUNUSED_DIPLOC( 0x08, 0x00, "SW2:!4" )       /* Listed as "Unused" */
605 	/* In stop mode, press 1 to stop and 2 to restart */
606 	PORT_DIPNAME( 0x10, 0x00, "Stop Mode (Cheat)" )     PORT_DIPLOCATION("SW2:!5")
607 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
608 	PORT_DIPSETTING(    0x10, DEF_STR( On ) )
609 	PORT_DIPUNUSED_DIPLOC( 0x20, 0x00, "SW2:!6" )       /* Listed as "Unused" */
610 	PORT_DIPNAME( 0x40, 0x00, "Invulnerability (Cheat)" ) PORT_DIPLOCATION("SW2:!7")
611 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
612 	PORT_DIPSETTING(    0x40, DEF_STR( On ) )
613 	PORT_SERVICE_DIPLOC(0x80, IP_ACTIVE_HIGH, "SW2:!8" )
614 INPUT_PORTS_END
615 
616 static INPUT_PORTS_START( fghtbskt )
617 	PORT_START("P1")
618 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
619 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
620 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY
621 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
622 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 )
623 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN1 )
624 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
625 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START1 )
626 
627 	PORT_START("P2")
628 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
629 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
630 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
631 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
632 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL
633 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN2 )
634 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
635 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
636 
637 	PORT_START("DSW")
638 	PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coin_A ) )
639 	PORT_DIPSETTING(    0x03, DEF_STR( 3C_1C ) )
640 	PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
641 	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
642 	PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
643 	PORT_DIPNAME( 0x0c, 0x04, DEF_STR( Coin_B ) )
644 	PORT_DIPSETTING(    0x04, DEF_STR( 1C_1C ) )
645 	PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) )
646 	PORT_DIPSETTING(    0x08, DEF_STR( 1C_4C ) )
647 	PORT_DIPSETTING(    0x0c, "99 Credits / Sound Test" )
648 	PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
649 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
650 	PORT_DIPSETTING(    0x10, DEF_STR( On ) )
651 	PORT_DIPNAME( 0x20, 0x00, "Time Count Down" )
652 	PORT_DIPSETTING(    0x00, "Slow" )
653 	PORT_DIPSETTING(    0x20, "Too Fast" )
654 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ) )
655 	PORT_DIPSETTING(    0x40, DEF_STR( Upright ) )
656 	PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
657 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Demo_Sounds ) )
658 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
659 	PORT_DIPSETTING(    0x80, DEF_STR( On ) )
660 INPUT_PORTS_END
661 
662 
663 static const gfx_layout charlayout =
664 {
665 	8,8,
666 	RGN_FRAC(1,2),
667 	2,
668 	{ RGN_FRAC(1,2), RGN_FRAC(0,2) },
669 	{ 0, 1, 2, 3, 4, 5, 6, 7 },
670 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
671 	8*8
672 };
673 
674 static const gfx_layout tilelayout =
675 {
676 	8,8,
677 	RGN_FRAC(1,3),
678 	3,
679 	{ RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
680 	{ 0, 1, 2, 3, 4, 5, 6, 7 },
681 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
682 	8*8
683 };
684 
685 static const gfx_layout spritelayout =
686 {
687 	16,16,
688 	RGN_FRAC(1,6),
689 	3,
690 	{ RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
691 	{ 0, 1, 2, 3, 4, 5, 6, 7,
692 			RGN_FRAC(1,6)+0, RGN_FRAC(1,6)+1, RGN_FRAC(1,6)+2, RGN_FRAC(1,6)+3,
693 			RGN_FRAC(1,6)+4, RGN_FRAC(1,6)+5, RGN_FRAC(1,6)+6, RGN_FRAC(1,6)+7 },
694 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
695 			8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
696 	16*8
697 };
698 
699 static GFXDECODE_START( gfx_m63 )
700 	GFXDECODE_ENTRY( "gfx1", 0, charlayout,   256, 1 )
701 	GFXDECODE_ENTRY( "gfx2", 0, tilelayout,     0, 32 )
702 	GFXDECODE_ENTRY( "gfx3", 0, spritelayout,   0, 32 )
703 GFXDECODE_END
704 
GFXDECODE_START(gfx_fghtbskt)705 static GFXDECODE_START( gfx_fghtbskt )
706 	GFXDECODE_ENTRY( "gfx1", 0, charlayout,   16, 1 )
707 	GFXDECODE_ENTRY( "gfx2", 0, tilelayout,    0, 32 )
708 	GFXDECODE_ENTRY( "gfx3", 0, spritelayout,  0, 32 )
709 GFXDECODE_END
710 
711 
712 SAMPLES_START_CB_MEMBER(m63_state::fghtbskt_sh_start)
713 {
714 	int i, len = memregion("samples")->bytes();
715 	uint8_t *ROM = memregion("samples")->base();
716 
717 	m_samplebuf = std::make_unique<int16_t[]>(len);
718 	save_pointer(NAME(m_samplebuf), len);
719 
720 	for(i = 0; i < len; i++)
721 		m_samplebuf[i] = ((int8_t)(ROM[i] ^ 0x80)) * 256;
722 }
723 
INTERRUPT_GEN_MEMBER(m63_state::snd_irq)724 INTERRUPT_GEN_MEMBER(m63_state::snd_irq)
725 {
726 	m_sound_irq = 1;
727 }
728 
MACHINE_START_MEMBER(m63_state,m63)729 MACHINE_START_MEMBER(m63_state,m63)
730 {
731 	save_item(NAME(m_pal_bank));
732 	save_item(NAME(m_fg_flag));
733 	save_item(NAME(m_sy_offset));
734 
735 	/* sound-related */
736 	save_item(NAME(m_sound_irq));
737 	save_item(NAME(m_sound_status));
738 	save_item(NAME(m_p1));
739 	save_item(NAME(m_p2));
740 }
741 
MACHINE_RESET_MEMBER(m63_state,m63)742 MACHINE_RESET_MEMBER(m63_state,m63)
743 {
744 	m_pal_bank = 0;
745 	m_fg_flag = 0;
746 	m_sound_irq = 0;
747 	m_sound_status = 0;
748 	m_p1 = 0;
749 	m_p2 = 0;
750 }
751 
752 
INTERRUPT_GEN_MEMBER(m63_state::vblank_irq)753 INTERRUPT_GEN_MEMBER(m63_state::vblank_irq)
754 {
755 	if(m_nmi_mask)
756 		device.execute().pulse_input_line(INPUT_LINE_NMI, attotime::zero);
757 }
758 
m63(machine_config & config)759 void m63_state::m63(machine_config &config)
760 {
761 	/* basic machine hardware */
762 	Z80(config, m_maincpu, XTAL(12'000'000)/4); /* 3 MHz */
763 	m_maincpu->set_addrmap(AS_PROGRAM, &m63_state::m63_map);
764 	m_maincpu->set_vblank_int("screen", FUNC(m63_state::vblank_irq));
765 
766 	ls259_device &outlatch(LS259(config, "outlatch")); // probably chip at E7 obscured by pulldown resistor
767 	outlatch.q_out_cb<0>().set(FUNC(m63_state::nmi_mask_w));
768 	outlatch.q_out_cb<2>().set(FUNC(m63_state::m63_flipscreen_w));
769 	outlatch.q_out_cb<3>().set(FUNC(m63_state::pal_bank_w));
770 	outlatch.q_out_cb<6>().set(FUNC(m63_state::coin1_w));
771 	outlatch.q_out_cb<7>().set(FUNC(m63_state::coin2_w));
772 
773 	I8039(config, m_soundcpu, XTAL(12'000'000)/4); /* ????? */
774 	m_soundcpu->set_addrmap(AS_PROGRAM, &m63_state::i8039_map);
775 	m_soundcpu->set_addrmap(AS_IO, &m63_state::i8039_port_map);
776 	m_soundcpu->p1_out_cb().set(FUNC(m63_state::p1_w));
777 	m_soundcpu->p2_out_cb().set(FUNC(m63_state::p2_w));
778 	m_soundcpu->t1_in_cb().set(FUNC(m63_state::irq_r));
779 	m_soundcpu->set_periodic_int(FUNC(m63_state::snd_irq), attotime::from_hz(60));
780 
781 	MCFG_MACHINE_START_OVERRIDE(m63_state,m63)
782 	MCFG_MACHINE_RESET_OVERRIDE(m63_state,m63)
783 
784 	/* video hardware */
785 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
786 	screen.set_refresh_hz(60);
787 	screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
788 	screen.set_size(32*8, 32*8);
789 	screen.set_visarea(0*8, 32*8-1, 2*8, 30*8-1);
790 	screen.set_screen_update(FUNC(m63_state::screen_update_m63));
791 	screen.set_palette(m_palette);
792 
793 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_m63);
794 	PALETTE(config, m_palette, FUNC(m63_state::m63_palette), 256+4);
795 
796 	MCFG_VIDEO_START_OVERRIDE(m63_state,m63)
797 
798 	/* sound hardware */
799 	SPEAKER(config, "mono").front_center(); /* ????? */
800 
801 	GENERIC_LATCH_8(config, m_soundlatch);
802 
803 	AY8910(config, m_ay1, XTAL(12'000'000)/8).add_route(ALL_OUTPUTS, "mono", 0.25);
804 	AY8910(config, m_ay2, XTAL(12'000'000)/8).add_route(ALL_OUTPUTS, "mono", 1.00); /* ????? */
805 }
806 
atomboy(machine_config & config)807 void m63_state::atomboy(machine_config &config)
808 {
809 	m63(config);
810 	m_soundcpu->set_periodic_int(FUNC(m63_state::snd_irq), attotime::from_hz(60/2));
811 }
812 
fghtbskt(machine_config & config)813 void m63_state::fghtbskt(machine_config &config)
814 {
815 	/* basic machine hardware */
816 	Z80(config, m_maincpu, XTAL(12'000'000)/4); /* 3 MHz */
817 	m_maincpu->set_addrmap(AS_PROGRAM, &m63_state::fghtbskt_map);
818 	m_maincpu->set_vblank_int("screen", FUNC(m63_state::vblank_irq));
819 
820 	ls259_device &outlatch(LS259(config, "outlatch"));
821 	outlatch.q_out_cb<1>().set(FUNC(m63_state::nmi_mask_w));
822 	outlatch.q_out_cb<2>().set(FUNC(m63_state::fghtbskt_flipscreen_w));
823 	//outlatch.q_out_cb<7>().set(FUNC(m63_state::fghtbskt_samples_w));
824 
825 	I8039(config, m_soundcpu, XTAL(12'000'000)/4); /* ????? */
826 	m_soundcpu->set_addrmap(AS_PROGRAM, &m63_state::i8039_map);
827 	m_soundcpu->set_addrmap(AS_IO, &m63_state::i8039_port_map);
828 	m_soundcpu->set_periodic_int(FUNC(m63_state::snd_irq), attotime::from_hz(60/2));
829 
830 	MCFG_MACHINE_START_OVERRIDE(m63_state,m63)
831 	MCFG_MACHINE_RESET_OVERRIDE(m63_state,m63)
832 
833 	/* video hardware */
834 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
835 	screen.set_refresh_hz(60);
836 	screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
837 	screen.set_size(32*8, 32*8);
838 	screen.set_visarea(0*8, 32*8-1, 2*8, 30*8-1);
839 	screen.set_screen_update(FUNC(m63_state::screen_update_m63));
840 	screen.set_palette(m_palette);
841 
842 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_fghtbskt);
843 	PALETTE(config, m_palette, palette_device::RGB_444_PROMS, "proms", 256);
844 
845 	MCFG_VIDEO_START_OVERRIDE(m63_state,m63)
846 
847 	/* sound hardware */
848 	SPEAKER(config, "mono").front_center();
849 
850 	GENERIC_LATCH_8(config, m_soundlatch);
851 
852 	AY8910(config, m_ay1, XTAL(12'000'000)/8).add_route(ALL_OUTPUTS, "mono", 1.0);
853 
854 	SAMPLES(config, m_samples);
855 	m_samples->set_channels(1);
856 	m_samples->set_samples_start_callback(FUNC(m63_state::fghtbskt_sh_start));
857 	m_samples->add_route(ALL_OUTPUTS, "mono", 0.50);
858 }
859 
860 
861 /***************************************************************************
862 
863   Game driver(s)
864 
865 ***************************************************************************/
866 
867 ROM_START( wilytowr )
868 	ROM_REGION( 0x10000, "maincpu", 0 )
CRC(a38e4b8a)869 	ROM_LOAD( "wt4e.bin",     0x0000, 0x2000, CRC(a38e4b8a) SHA1(e296ba1764d3e8e2a5cc43bdde7f30a522b437ff) )
870 	ROM_LOAD( "wt4h.bin",     0x2000, 0x2000, CRC(c1405ceb) SHA1(c11dd4cd180bc9576e8042e1f56074620ea00f53) )
871 	ROM_LOAD( "wt4j.bin",     0x4000, 0x2000, CRC(379fb1c3) SHA1(677e4077f6d2140e4fb5c3d86bc7081d3b6cc028) )
872 	ROM_LOAD( "wt4k.bin",     0x6000, 0x2000, CRC(2dd6f9c7) SHA1(88ba58a1ddd25403211b7f920ba7006ed80c13eb) )
873 	ROM_LOAD( "wt_a-4m.bin",  0x8000, 0x2000, CRC(c1f8a7d5) SHA1(4307e7604aec728a1f5b0e6a0d6c9f4d37084da3) )
874 	ROM_LOAD( "wt_a-4n.bin",  0xa000, 0x2000, CRC(b212f7d2) SHA1(dd1c35559982e8bbcb0e778c733a3afb5b6611df) )
875 
876 	ROM_REGION( 0x1000, "soundcpu", 0 ) /* 8039 */
877 	ROM_LOAD( "wt4d.bin",     0x0000, 0x1000, CRC(25a171bf) SHA1(7465dbfa8858d0f5822eb748b96d99753d58d243) )
878 
879 	ROM_REGION( 0x2000, "gfx1", 0 )
880 	/* '3' character is bad, but ROMs have been verified on four boards */
881 	ROM_LOAD( "wt_b-5e.bin",  0x0000, 0x1000, CRC(fe45df43) SHA1(9586a5728069e0c293bd17d4663305ce5758ca01) )
882 	ROM_LOAD( "wt_b-5f.bin",  0x1000, 0x1000, CRC(87a17eff) SHA1(cee2ba2889baf08dc6ee1c8e9150bd277f343be9) )
883 
884 	ROM_REGION( 0x6000, "gfx2", 0 )
885 	ROM_LOAD( "wtb5a.bin",    0x0000, 0x2000, CRC(efc1cbfa) SHA1(9a2ea29e64360ef7b143ac1b6a1ba3e672be4a42) )
886 	ROM_LOAD( "wtb5b.bin",    0x2000, 0x2000, CRC(ab4bfd07) SHA1(1d5010413989895c09d8e5ee903d665506836f94) )
887 	ROM_LOAD( "wtb5d.bin",    0x4000, 0x2000, CRC(40f23e1d) SHA1(abff583021e2cf2d2ec83adbbd4f2e96bfa3e04f) )
888 
889 	ROM_REGION( 0x6000, "gfx3", 0 )
890 	/* there are horizontal lines in some tiles, but ROMs have been verified on four boards */
891 	ROM_LOAD( "wt2j.bin",     0x0000, 0x1000, CRC(d1bf0670) SHA1(8d07bce354bb4538948c358fd696304a8e0640b8) )
892 	ROM_LOAD( "wt3k.bin",     0x1000, 0x1000, CRC(83c39a0e) SHA1(da98f887ac5c3d52281eece3d760c41fb9ecfd5c) )
893 	ROM_LOAD( "wt_a-3m.bin",  0x2000, 0x1000, CRC(e7e468ae) SHA1(17448191b440b668714d83730075938aaaf34b5a) )
894 	ROM_LOAD( "wt_a-3n.bin",  0x3000, 0x1000, CRC(0741d1a9) SHA1(51f5ee03db8a3f7afbf944b9e3e4ae12b2520269) )
895 	ROM_LOAD( "wt_a-3p.bin",  0x4000, 0x1000, CRC(7299f362) SHA1(5ba309d789df8432c08d67e4f9e8bf6c447fc425) )
896 	ROM_LOAD( "wt_a-3s.bin",  0x5000, 0x1000, CRC(9b37d50d) SHA1(a08d4a7654b815cb652be66dbaa097011327f5d5) )
897 
898 	ROM_REGION( 0x2000, "user1", 0 )
899 	ROM_LOAD( "wt_a-6d.bin",  0x0000, 0x1000, CRC(a5dde29b) SHA1(8f7545d2022da7c98d47112179dce717f6c3c5e2) )
900 
901 
902 	ROM_REGION( 0x0320, "proms", 0 )
903 	ROM_LOAD( "wt_a-5s-.bpr", 0x0000, 0x0100, CRC(041950e7) SHA1(8276068bec3f4c5013c773033fca3cd3ed9e82ef) )    /* red */
904 	ROM_LOAD( "wt_a-5r-.bpr", 0x0100, 0x0100, CRC(bc04bf25) SHA1(37d0e89296760f51df5a0d434dca390fb60bb052) )    /* green */
905 	ROM_LOAD( "wt_a-5p-.bpr", 0x0200, 0x0100, CRC(ed819a19) SHA1(76f13dcf1674f136375738756e175ceec469d545) )    /* blue */
906 	ROM_LOAD( "wt_b-9l-.bpr", 0x0300, 0x0020, CRC(d2728744) SHA1(e6b1a570854ca90326414874432ab03ec85b9c8e) )    /* char palette */
907 ROM_END
908 
909 ROM_START( atomboy )
910 	ROM_REGION( 0x10000, "maincpu", 0 )
911 	ROM_LOAD( "wt_a-4e.bin",  0x0000, 0x2000, CRC(f7978185) SHA1(6a108d1e9b1a81cedf865aba3998748dcf1d55ef) )
912 	ROM_LOAD( "wt_a-4h.bin",  0x2000, 0x2000, CRC(0ca9950b) SHA1(d6583fcdf17d16a8884932695caa9c5587a20795) )
913 	ROM_LOAD( "wt_a-4j.bin",  0x4000, 0x2000, CRC(1badbc65) SHA1(e0768f2cd7bbe8908fd68ff6d54dbef84cc7de4c) )
914 	ROM_LOAD( "wt_a-4k.bin",  0x6000, 0x2000, CRC(5a341f75) SHA1(9e1a180e37aaa0afbf8ff45219be40d3f75fe60a) )
915 	ROM_LOAD( "wt_a-4m.bin",  0x8000, 0x2000, CRC(c1f8a7d5) SHA1(4307e7604aec728a1f5b0e6a0d6c9f4d37084da3) )
916 	ROM_LOAD( "wt_a-4n.bin",  0xa000, 0x2000, CRC(b212f7d2) SHA1(dd1c35559982e8bbcb0e778c733a3afb5b6611df) )
917 
918 	ROM_REGION( 0x2000, "soundcpu", 0 ) /* 8039 */
919 	ROM_LOAD( "wt_a-4d-b.bin",  0x0000, 0x2000, CRC(793ea53f) SHA1(9dbff5e011a1f1f48aad68f8e5b02bcdb86c182a) ) /* 2764 ROM, Also had a red dot on label */
920 
921 	ROM_REGION( 0x2000, "gfx1", 0 )
922 	/* '3' character is bad, but ROMs have been verified on four boards */
923 	ROM_LOAD( "wt_b-5e.bin",  0x0000, 0x1000, CRC(fe45df43) SHA1(9586a5728069e0c293bd17d4663305ce5758ca01) )
924 	ROM_LOAD( "wt_b-5f.bin",  0x1000, 0x1000, CRC(87a17eff) SHA1(cee2ba2889baf08dc6ee1c8e9150bd277f343be9) )
925 
926 	ROM_REGION( 0x6000, "gfx2", 0 )
927 	ROM_LOAD( "wt_b-5a.bin",  0x0000, 0x2000, CRC(da22c452) SHA1(bd921baa12087e996d07625e05eda00981608655) )
928 	ROM_LOAD( "wt_b-5b.bin",  0x2000, 0x2000, CRC(4fb25a1f) SHA1(0f90fb3b373760c33ba9be3b56b917eca92c9700) )
929 	ROM_LOAD( "wt_b-5d.bin",  0x4000, 0x2000, CRC(75be2604) SHA1(fe1f110e188aa34a04a9f43412a8308240391fcf) )
930 
931 	ROM_REGION( 0xc000, "gfx3", 0 )
932 	ROM_LOAD( "wt_a-3j-b.bin",  0x0000, 0x2000, CRC(996470f1) SHA1(c0c787a73535917d1314bb2e1e9056aea9859205) ) /* All these ROMs are 2764 type/size */
933 	ROM_LOAD( "wt_a-3k-b.bin",  0x2000, 0x2000, CRC(8f4ec45c) SHA1(525393e0555e1aa24df74e8095da216f02fe3c65) )
934 	ROM_LOAD( "wt_a-3m-b.bin",  0x4000, 0x2000, CRC(4ac40358) SHA1(c71bd62ef1e8d008abd468c193e67b278599a5f3) )
935 	ROM_LOAD( "wt_a-3n-b.bin",  0x6000, 0x2000, CRC(709eef5b) SHA1(95beadcf876a2549836329521f1293634413e983) )
936 	ROM_LOAD( "wt_a-3p-b.bin",  0x8000, 0x2000, CRC(3018b840) SHA1(77df9d4f1c8d76d30c435d03d51ef9e7509fab9c) )
937 	ROM_LOAD( "wt_a-3s-b.bin",  0xa000, 0x2000, CRC(05a251d4) SHA1(1cd9102871507ab988d5fe799024d63b93807448) )
938 
939 	ROM_REGION( 0x2000, "user1", 0 )
940 	ROM_LOAD( "wt_a-6d.bin",  0x0000, 0x1000, CRC(a5dde29b) SHA1(8f7545d2022da7c98d47112179dce717f6c3c5e2) )
941 
942 	ROM_REGION( 0x0320, "proms", 0 )
943 	ROM_LOAD( "wt_a-5s-b.bpr", 0x0000, 0x0100, CRC(991e2a04) SHA1(a70525948ad85ad898e0d8a25fb6d1639a4ec133) )   /* red    TBP24S10 (read as 82s129) */
944 	ROM_LOAD( "wt_a-5r-b.bpr", 0x0100, 0x0100, CRC(fb3822b7) SHA1(bb1ecdd0156acc16bef3c9072e496e4f544b5d9d) )   /* green  TBP24S10 (read as 82s129) */
945 	ROM_LOAD( "wt_a-5p-b.bpr", 0x0200, 0x0100, CRC(95849f7d) SHA1(ad031d6035045b19c1cd65ac6a78c5aa4b647cd6) )   /* blue   TBP24S10 (read as 82s129) */
946 	ROM_LOAD( "wt_b-9l-.bpr",  0x0300, 0x0020, CRC(d2728744) SHA1(e6b1a570854ca90326414874432ab03ec85b9c8e) )   /* char palette */
947 ROM_END
948 
949 ROM_START( atomboya )
950 	ROM_REGION( 0x10000, "maincpu", 0 )
951 	ROM_LOAD( "wt_a-4e.bin",  0x0000, 0x2000, CRC(f7978185) SHA1(6a108d1e9b1a81cedf865aba3998748dcf1d55ef) )
952 	ROM_LOAD( "wt_a-4h.bin",  0x2000, 0x2000, CRC(0ca9950b) SHA1(d6583fcdf17d16a8884932695caa9c5587a20795) )
953 	ROM_LOAD( "wt_a-4j.bin",  0x4000, 0x2000, CRC(1badbc65) SHA1(e0768f2cd7bbe8908fd68ff6d54dbef84cc7de4c) )
954 	ROM_LOAD( "wt_a-4k.bin",  0x6000, 0x2000, CRC(5a341f75) SHA1(9e1a180e37aaa0afbf8ff45219be40d3f75fe60a) )
955 	ROM_LOAD( "wt_a-4m.bin",  0x8000, 0x2000, CRC(c1f8a7d5) SHA1(4307e7604aec728a1f5b0e6a0d6c9f4d37084da3) )
956 	ROM_LOAD( "wt_a-4n.bin",  0xa000, 0x2000, CRC(b212f7d2) SHA1(dd1c35559982e8bbcb0e778c733a3afb5b6611df) )
957 
958 	ROM_REGION( 0x1000, "soundcpu", 0 ) /* 8039 */
959 	ROM_LOAD( "wt_a-4d.bin",  0x0000, 0x1000, CRC(3d43361e) SHA1(2977df9f90d9d214909c56ab44c40ab45fd90675) )
960 
961 	ROM_REGION( 0x2000, "gfx1", 0 )
962 	/* '3' character is bad, but ROMs have been verified on four boards */
963 	ROM_LOAD( "wt_b-5e.bin",  0x0000, 0x1000, CRC(fe45df43) SHA1(9586a5728069e0c293bd17d4663305ce5758ca01) )
964 	ROM_LOAD( "wt_b-5f.bin",  0x1000, 0x1000, CRC(87a17eff) SHA1(cee2ba2889baf08dc6ee1c8e9150bd277f343be9) )
965 
966 	ROM_REGION( 0x6000, "gfx2", 0 )
967 	ROM_LOAD( "wt_b-5a.bin",  0x0000, 0x2000, CRC(da22c452) SHA1(bd921baa12087e996d07625e05eda00981608655) )
968 	ROM_LOAD( "wt_b-5b.bin",  0x2000, 0x2000, CRC(4fb25a1f) SHA1(0f90fb3b373760c33ba9be3b56b917eca92c9700) )
969 	ROM_LOAD( "wt_b-5d.bin",  0x4000, 0x2000, CRC(75be2604) SHA1(fe1f110e188aa34a04a9f43412a8308240391fcf) )
970 
971 	ROM_REGION( 0x6000, "gfx3", 0 )
972 	/* there are horizontal lines in some tiles, but ROMs have been verified on four boards */
973 	ROM_LOAD( "wt_a-3j.bin",  0x0000, 0x1000, CRC(b30ca38f) SHA1(885743893461b8617180a9723f6fcef160a2f05d) )
974 	ROM_LOAD( "wt_a-3k.bin",  0x1000, 0x1000, CRC(9a77eb73) SHA1(2564a3b3744b0be147b41c521fc7efde53bdfea7) )
975 	ROM_LOAD( "wt_a-3m.bin",  0x2000, 0x1000, CRC(e7e468ae) SHA1(17448191b440b668714d83730075938aaaf34b5a) )
976 	ROM_LOAD( "wt_a-3n.bin",  0x3000, 0x1000, CRC(0741d1a9) SHA1(51f5ee03db8a3f7afbf944b9e3e4ae12b2520269) )
977 	ROM_LOAD( "wt_a-3p.bin",  0x4000, 0x1000, CRC(7299f362) SHA1(5ba309d789df8432c08d67e4f9e8bf6c447fc425) )
978 	ROM_LOAD( "wt_a-3s.bin",  0x5000, 0x1000, CRC(9b37d50d) SHA1(a08d4a7654b815cb652be66dbaa097011327f5d5) )
979 
980 	ROM_REGION( 0x1000, "user1", 0 )
981 	ROM_LOAD( "wt_a-6d.bin",  0x0000, 0x1000, CRC(a5dde29b) SHA1(8f7545d2022da7c98d47112179dce717f6c3c5e2) )
982 
983 	ROM_REGION( 0x0320, "proms", 0 )
984 	ROM_LOAD( "wt_a-5s-.bpr", 0x0000, 0x0100, CRC(041950e7) SHA1(8276068bec3f4c5013c773033fca3cd3ed9e82ef) )    /* red */
985 	ROM_LOAD( "wt_a-5r-.bpr", 0x0100, 0x0100, CRC(bc04bf25) SHA1(37d0e89296760f51df5a0d434dca390fb60bb052) )    /* green */
986 	ROM_LOAD( "wt_a-5p-.bpr", 0x0200, 0x0100, CRC(ed819a19) SHA1(76f13dcf1674f136375738756e175ceec469d545) )    /* blue */
987 	ROM_LOAD( "wt_b-9l-.bpr", 0x0300, 0x0020, CRC(d2728744) SHA1(e6b1a570854ca90326414874432ab03ec85b9c8e) )    /* char palette */
988 ROM_END
989 
990 ROM_START( fghtbskt )
991 	ROM_REGION( 0x10000, "maincpu", 0 )
992 	ROM_LOAD( "fb14.0f",      0x0000, 0x2000, CRC(82032853) SHA1(e103ace4cac6df3a429b785f9789b302ae8cdade) )
993 	ROM_LOAD( "fb13.2f",      0x2000, 0x2000, CRC(5306df0f) SHA1(11be226e7167703bb08e48510a113b2d43b211a4) )
994 	ROM_LOAD( "fb12.3f",      0x4000, 0x2000, CRC(ee9210d4) SHA1(c63d036314d635f65a2b5bb192ceb312a587db6e) )
995 	ROM_LOAD( "fb10.6f",      0x8000, 0x2000, CRC(6b47efba) SHA1(cb55c7a9d5afe748c1c88f87dd1909e106932798) )
996 	ROM_LOAD( "fb09.7f",      0xa000, 0x2000, CRC(be69e087) SHA1(be95ecafa494cb0787ee18eb3ecea4ad545a6ae3) )
997 
998 	ROM_REGION( 0x1000, "soundcpu", 0 ) /* 8039 */
999 	ROM_LOAD( "fb07.0b",      0x0000, 0x1000, CRC(50432dbd) SHA1(35a2218ed243bde47dbe06b5a11a65502ba734ea) )
1000 
1001 	ROM_REGION( 0x2000, "gfx1", 0 )
1002 	ROM_LOAD( "fb08.12f",     0x0000, 0x1000, CRC(271cd7b8) SHA1(00cfeb6ba429cf6cc59d6542dea8de2ca79155ed) )
1003 	ROM_FILL(                 0x1000, 0x1000, 0x00 )
1004 
1005 	ROM_REGION( 0x6000, "gfx2", 0 )
1006 	ROM_LOAD( "fb21.25e",     0x0000, 0x2000, CRC(02843591) SHA1(e38ccc97dcbd642d0ac768837f7baf1573fdb91f) )
1007 	ROM_LOAD( "fb22.23e",     0x2000, 0x2000, CRC(cd51d8e7) SHA1(16d55d13b47dddb7c7e6b28b1512540938a4a596) )
1008 	ROM_LOAD( "fb23.22e",     0x4000, 0x2000, CRC(62bcac87) SHA1(dd2272d8c7e46bd0a742b4490c9e960b2bfe14c3) )
1009 
1010 	ROM_REGION( 0xc000, "gfx3", 0 )
1011 	ROM_LOAD( "fb16.35a",     0x0000, 0x2000, CRC(a5df1652) SHA1(76d1443c523851aa418574c6a879f4a8e46dc887) )
1012 	ROM_LOAD( "fb15.37a",     0x2000, 0x2000, CRC(59c4de06) SHA1(594411f10d6bb3577c649c66133b90c6423184d7) )
1013 	ROM_LOAD( "fb18.32a",     0x4000, 0x2000, CRC(c23ddcd7) SHA1(f73d142ac0baae519ed633a923e132eb1836adbb) )
1014 	ROM_LOAD( "fb17.34a",     0x6000, 0x2000, CRC(7db28013) SHA1(305e6a6254f69625c81ae107f4420fd76f9a24ba) )
1015 	ROM_LOAD( "fb20.29a",     0x8000, 0x2000, CRC(1a1b48f8) SHA1(62f7774807aea86f73f0b9380bb1c237d55bf451) )
1016 	ROM_LOAD( "fb19.31a",     0xa000, 0x2000, CRC(7ff7e321) SHA1(4fe4eee9c6260599950080c600187ce8e9dab7d2) )
1017 
1018 	ROM_REGION( 0xa000, "samples", 0 ) /* Samples */
1019 	ROM_LOAD( "fb01.42a",     0x0000, 0x2000, CRC(1200b220) SHA1(8a5f896441c6a6507e72b9b302a8183cc361d118) )
1020 	ROM_LOAD( "fb02.41a",     0x2000, 0x2000, CRC(0b67aa82) SHA1(59b6cf733150eab0bd807beeeb1d2f784ccb6f58) )
1021 	ROM_LOAD( "fb03.40a",     0x4000, 0x2000, CRC(c71269ed) SHA1(71cc6f43877b28d50beb744587c189dabbbaa067) )
1022 	ROM_LOAD( "fb04.39a",     0x6000, 0x2000, CRC(02ddc42d) SHA1(9d40967071f674592c174b5a5470db56a5f99adf) )
1023 	ROM_LOAD( "fb05.38a",     0x8000, 0x2000, CRC(72ea6b49) SHA1(e081a1cad5abf373a2489169b5c86ee63dcf5823) )
1024 
1025 	ROM_REGION( 0x2000, "user1", 0 )
1026 	ROM_LOAD( "fb06.12a",     0x0000, 0x2000, CRC(bea3df99) SHA1(18b795f8626b22f6a1620e04c23f4967c3122c89) )
1027 
1028 	ROM_REGION( 0x0300, "proms", 0 )
1029 	ROM_LOAD( "fb_r.9e",      0x0000, 0x0100, CRC(c5cdc8ba) SHA1(3fcef3ebe0dda72dfa35e042ff611758c345d749) )
1030 	ROM_LOAD( "fb_g.10e",     0x0100, 0x0100, CRC(1460c936) SHA1(f99a544c83931de098a6cfac391f63ae43f5cdd0) )
1031 	ROM_LOAD( "fb_b.11e",     0x0200, 0x0100, CRC(fca5bf0e) SHA1(5846f43aa2906cac58e300fdab197b99f896e3ef) )
1032 ROM_END
1033 
1034 void m63_state::init_wilytowr()
1035 {
1036 	m_sy_offset = 238;
1037 }
1038 
init_fghtbskt()1039 void m63_state::init_fghtbskt()
1040 {
1041 	m_sy_offset = 240;
1042 }
1043 
1044 GAME( 1984, wilytowr, 0,        m63,      wilytowr, m63_state, init_wilytowr, ROT180, "Irem",                    "Wily Tower", MACHINE_SUPPORTS_SAVE )
1045 GAME( 1985, atomboy,  wilytowr, atomboy,  wilytowr, m63_state, init_wilytowr, ROT180, "Irem (Memetron license)", "Atomic Boy (revision B)", MACHINE_SUPPORTS_SAVE )
1046 GAME( 1985, atomboya, wilytowr, atomboy,  wilytowr, m63_state, init_wilytowr, ROT180, "Irem (Memetron license)", "Atomic Boy (revision A)", MACHINE_SUPPORTS_SAVE )
1047 GAME( 1984, fghtbskt, 0,        fghtbskt, fghtbskt, m63_state, init_fghtbskt, ROT0,   "Paradise Co. Ltd.",       "Fighting Basketball", MACHINE_SUPPORTS_SAVE )
1048