1 // license:BSD-3-Clause
2 // copyright-holders:Luca Elia
3 /***************************************************************************
4 
5 Joy Stand Private
6 Yuvo 1999 (31st October, 1999)
7 
8 driver by Luca Elia
9 
10 This is a sticker machine with camera, printer and light pen.
11 
12 PCB Layout
13 ----------
14 
15 Main board
16 
17 JSP-NM515
18 |---------------------------------------------------------|
19 |TA8201A     POWER-IN     TD62083  TD62083     CONTROL    |
20 |     JRC3404             D71055   D71055            T531A|
21 |SP   JRC3404                     CN10                    |
22 |VR2  JRC3404      JSP001 JSP-FRM         JSP003B TC551001|
23 |VR1            M6295     JSP-MAP                         |
24 |CAM-IN JRC2235    JSP002  C46M1 TMP68301 JSP004B TC551001|
25 |PRN-IN JRC2233 YM2413                                    |
26 |VR3    JRC3404                 JSP-XCT                   |
27 |VR4                            16MHz            32.767kHz|
28 |VR5  SONY_A1585Q       M548262 M548262             M6242B|
29 |     3.579545MHz       M548262 M548262            3V_BATT|
30 |       JRC2240  D6951  M548262 M548262                   |
31 |RGB-OUT         D6951  M548262 M548262               JACK|
32 |                D6951                  XC3042A           |
33 |       SONY_CXA1645M           KM68257 KM68257   JRC2903 |
34 |SV-OUT          D6901                            LIGHTPEN|
35 |       JRC2244  D6901  XC3030A  XC3030A   XC3030A        |
36 |       JRC2244  D6901            CN11            PRN_CONT|
37 |---------------------------------------------------------|
38 Notes:
39       Main CPU is Toshiba TMP68301 @ 16MHz
40       No custom chips, using only Xilinx XC30xx FPGA
41       Sound Oki M6295 @ 1MHz [16/16], YM2413 @ 3.579545MHz
42       PALs type PALCE16V8H
43       EPROMs are 27C040/27C020
44       CN10/11 - Connector for sub-board
45       Many other connectors for camera, printer, lightpen etc.
46 
47 
48 Sub board
49 
50 JSP-NS515
51 MODEL-NP001
52 9.10.31
53 |-------------------------------|
54 |                J2             |
55 |                               |
56 |      JSP-SUB                  |
57 |                               |
58 |                  |-|      |-| |
59 |JSP005 JSP007A    | |      | | |
60 |                  | |      | | |
61 |                  | |      | | |
62 |                  | |      | | |
63 |JSP006 JSP008A    | |      | | |
64 |                  | |      | | |
65 |                  |-|      |-| |
66 |                J1             |
67 |-------------------------------|
68 
69 
70 Cart board
71 
72 NS514-F040DD
73 |---------------------|
74 |  U1 U2 U3 U4 U5 U6  |
75 |                     |
76 | U7 U8 U9 U10 U11 U12|
77 |                     |
78 -|                  |-|
79  |------------------|
80  Notes:
81        U* - TMS29F040 (TSOP32, x12)
82 
83 
84 Notes:
85 
86 - To unlock some hidden items in test mode, go in the option menu and move:
87   left, right, left, left
88 
89 ***************************************************************************/
90 
91 #include "emu.h"
92 #include "cpu/m68000/m68000.h"
93 #include "machine/eepromser.h"
94 #include "machine/intelfsh.h"
95 #include "machine/msm6242.h"
96 #include "machine/tmp68301.h"
97 #include "sound/okim6295.h"
98 #include "sound/ym2413.h"
99 #include "emupal.h"
100 #include "screen.h"
101 #include "speaker.h"
102 #include "tilemap.h"
103 
104 class joystand_state : public driver_device
105 {
106 public:
joystand_state(const machine_config & mconfig,device_type type,const char * tag)107 	joystand_state(const machine_config &mconfig, device_type type, const char *tag) :
108 		driver_device(mconfig, type, tag),
109 		m_maincpu(*this, "maincpu"),
110 		m_palette(*this, "palette"),
111 		m_bg15_palette(*this, "bg15_palette"),
112 		m_gfxdecode(*this, "gfxdecode"),
113 		m_eeprom(*this, "eeprom"),
114 		m_cart_u1(*this, "cart.u1"),
115 		m_cart_u2(*this, "cart.u2"),
116 		m_cart_u3(*this, "cart.u3"),
117 		m_cart_u4(*this, "cart.u4"),
118 		m_cart_u5(*this, "cart.u5"),
119 		m_cart_u6(*this, "cart.u6"),
120 		m_cart_u7(*this, "cart.u7"),
121 		m_cart_u8(*this, "cart.u8"),
122 		m_cart_u9(*this, "cart.u9"),
123 		m_cart_u10(*this, "cart.u10"),
124 		m_cart_u11(*this, "cart.u11"),
125 		m_cart_u12(*this, "cart.u12"),
126 		m_oki(*this, "oki"),
127 		m_bg1_ram(*this, "bg1_ram"),
128 		m_bg2_ram(*this, "bg2_ram"),
129 		m_bg15_0_ram(*this, "bg15_0_ram"),
130 		m_bg15_1_ram(*this, "bg15_1_ram"),
131 		m_scroll(*this, "scroll"),
132 		m_enable(*this, "enable"),
133 		m_outputs(*this, "outputs")
134 	{ }
135 
136 	void joystand(machine_config &config);
137 
138 protected:
139 	virtual void machine_start() override;
140 	virtual void machine_reset() override;
141 	virtual void video_start() override;
142 
143 private:
144 	// devices
145 	required_device<tmp68301_device> m_maincpu;
146 	required_device<palette_device> m_palette;
147 	required_device<palette_device> m_bg15_palette;
148 	required_device<gfxdecode_device> m_gfxdecode;
149 	required_device<eeprom_serial_93cxx_device> m_eeprom;
150 	required_device<intelfsh8_device> m_cart_u1;
151 	required_device<intelfsh8_device> m_cart_u2;
152 	required_device<intelfsh8_device> m_cart_u3;
153 	required_device<intelfsh8_device> m_cart_u4;
154 	required_device<intelfsh8_device> m_cart_u5;
155 	required_device<intelfsh8_device> m_cart_u6;
156 	required_device<intelfsh8_device> m_cart_u7;
157 	required_device<intelfsh8_device> m_cart_u8;
158 	required_device<intelfsh8_device> m_cart_u9;
159 	required_device<intelfsh8_device> m_cart_u10;
160 	required_device<intelfsh8_device> m_cart_u11;
161 	required_device<intelfsh8_device> m_cart_u12;
162 	intelfsh8_device *m_cart_flash[12];
163 	required_device<okim6295_device> m_oki;
164 
165 	// memory pointers
166 	required_shared_ptr<uint16_t> m_bg1_ram;
167 	required_shared_ptr<uint16_t> m_bg2_ram;
168 	required_shared_ptr<uint16_t> m_bg15_0_ram;
169 	required_shared_ptr<uint16_t> m_bg15_1_ram;
170 	required_shared_ptr<uint16_t> m_scroll;
171 	required_shared_ptr<uint16_t> m_enable;
172 	required_shared_ptr<uint16_t> m_outputs;
173 
174 	// tilemaps
175 	tilemap_t *m_bg1_tmap;
176 	tilemap_t *m_bg2_tmap;
177 	void bg1_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
178 	void bg2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
179 	TILE_GET_INFO_MEMBER(get_bg1_tile_info);
180 	TILE_GET_INFO_MEMBER(get_bg2_tile_info);
181 
182 	// r5g5b5 layers
183 	bitmap_rgb32 m_bg15_bitmap[2];
184 	void bg15_0_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
185 	void bg15_1_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
186 	static const rgb_t BG15_TRANSPARENT;
187 	void draw_bg15_tile(address_space &space, int x, int y, uint16_t code);
188 	void draw_bg15_tilemap();
189 	bool bg15_tiles_dirty;
190 
191 	// eeprom
192 	uint16_t eeprom_r();
193 	void eeprom_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
194 
195 	// cart
196 	uint16_t cart_r(offs_t offset);
197 	void cart_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
198 
199 	// misc
200 	uint16_t fpga_r();
201 	void oki_bank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
202 	uint16_t e00000_r();
203 	uint16_t e00020_r();
204 	void outputs_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
205 
206 	// screen updates
207 	uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
208 
209 	// machine
210 	INTERRUPT_GEN_MEMBER(joystand_interrupt);
211 	void joystand_map(address_map &map);
212 };
213 
214 const rgb_t joystand_state::BG15_TRANSPARENT = 0x99999999;
215 
216 /***************************************************************************
217 
218     Tilemaps
219 
220 ***************************************************************************/
221 
TILE_GET_INFO_MEMBER(joystand_state::get_bg1_tile_info)222 TILE_GET_INFO_MEMBER(joystand_state::get_bg1_tile_info)
223 {
224 	uint32_t code = (m_bg1_ram[tile_index * 2 + 0] << 16) | m_bg1_ram[tile_index * 2 + 1];
225 	tileinfo.set(0, code & 0x00ffffff, code >> 24, 0);
226 }
227 
TILE_GET_INFO_MEMBER(joystand_state::get_bg2_tile_info)228 TILE_GET_INFO_MEMBER(joystand_state::get_bg2_tile_info)
229 {
230 	uint32_t code = (m_bg2_ram[tile_index * 2 + 0] << 16) | m_bg2_ram[tile_index * 2 + 1];
231 	tileinfo.set(0, code & 0x00ffffff, code >> 24, 0);
232 }
233 
bg1_w(offs_t offset,uint16_t data,uint16_t mem_mask)234 void joystand_state::bg1_w(offs_t offset, uint16_t data, uint16_t mem_mask)
235 {
236 	COMBINE_DATA(&m_bg1_ram[offset]);
237 	m_bg1_tmap->mark_tile_dirty(offset/2);
238 }
239 
bg2_w(offs_t offset,uint16_t data,uint16_t mem_mask)240 void joystand_state::bg2_w(offs_t offset, uint16_t data, uint16_t mem_mask)
241 {
242 	COMBINE_DATA(&m_bg2_ram[offset]);
243 	m_bg2_tmap->mark_tile_dirty(offset/2);
244 }
245 
246 /***************************************************************************
247 
248     r5g5b5 Layers
249 
250 ***************************************************************************/
251 
252 // pixel-based
bg15_0_w(offs_t offset,uint16_t data,uint16_t mem_mask)253 void joystand_state::bg15_0_w(offs_t offset, uint16_t data, uint16_t mem_mask)
254 {
255 	uint16_t val = COMBINE_DATA(&m_bg15_0_ram[offset]);
256 	m_bg15_bitmap[0].pix(offset >> 9, offset & 0x1ff) = (val & 0x8000) ? BG15_TRANSPARENT : m_bg15_palette->pen_color(val & 0x7fff);
257 }
258 
259 // tile-based
draw_bg15_tile(address_space & space,int x,int y,uint16_t code)260 void joystand_state::draw_bg15_tile(address_space &space, int x, int y, uint16_t code)
261 {
262 	x *= 16;
263 	y *= 16;
264 	int srcaddr = 0x800000 + (code % (0x800 * 6)) * 16 * 16 * 2;
265 
266 	for (int ty = 0; ty < 16; ++ty)
267 	{
268 		for (int tx = 0; tx < 16; ++tx)
269 		{
270 			uint16_t val = space.read_word(srcaddr + ty * 16 * 2 + tx * 2);
271 			m_bg15_bitmap[1].pix(y + ty , x + tx) = (val & 0x8000) ? BG15_TRANSPARENT : m_bg15_palette->pen_color(val & 0x7fff);
272 		}
273 	}
274 }
275 
draw_bg15_tilemap()276 void joystand_state::draw_bg15_tilemap()
277 {
278 	if (!bg15_tiles_dirty)
279 		return;
280 
281 	bg15_tiles_dirty = false;
282 
283 	address_space &space = m_maincpu->space(AS_PROGRAM);
284 	uint16_t *src = m_bg15_1_ram + 2/2;
285 	for (int y = 0; y < 0x10; ++y)
286 	{
287 		for (int x = 0; x < 0x20; ++x)
288 		{
289 			draw_bg15_tile(space, x, y, *src);
290 			src += 8/2;
291 		}
292 		src += 0x100/2;
293 	}
294 }
295 
bg15_1_w(address_space & space,offs_t offset,uint16_t data,uint16_t mem_mask)296 void joystand_state::bg15_1_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask)
297 {
298 	uint16_t code = COMBINE_DATA(&m_bg15_1_ram[offset]);
299 	if ((offset & 0x83) == 0x01)
300 		draw_bg15_tile(space, (offset/4) & 0x1f, offset/0x100, code);
301 }
302 
303 /***************************************************************************
304 
305     Screen Update
306 
307 ***************************************************************************/
308 
video_start()309 void joystand_state::video_start()
310 {
311 	m_bg1_tmap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(joystand_state::get_bg1_tile_info)), TILEMAP_SCAN_ROWS,  8,  8, 0x40, 0x20);
312 	m_bg2_tmap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(joystand_state::get_bg2_tile_info)), TILEMAP_SCAN_ROWS,  8,  8, 0x40, 0x40);
313 
314 	m_bg1_tmap->set_transparent_pen(0xf);
315 	m_bg2_tmap->set_transparent_pen(0xf);
316 
317 	for (auto & elem : m_bg15_bitmap)
318 	{
319 		elem.allocate(0x200, 0x200);
320 		elem.fill(BG15_TRANSPARENT);
321 	}
322 
323 	bg15_tiles_dirty = true;
324 }
325 
screen_update(screen_device & screen,bitmap_rgb32 & bitmap,const rectangle & cliprect)326 uint32_t joystand_state::screen_update( screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect )
327 {
328 	int layers_ctrl = -1;
329 
330 #ifdef MAME_DEBUG
331 	if (machine().input().code_pressed(KEYCODE_Z))
332 	{
333 		int msk = 0;
334 		if (machine().input().code_pressed(KEYCODE_Q))  msk |= 1;
335 		if (machine().input().code_pressed(KEYCODE_W))  msk |= 2;
336 		if (machine().input().code_pressed(KEYCODE_A))  msk |= 4;
337 		if (machine().input().code_pressed(KEYCODE_S))  msk |= 8;
338 		if (msk != 0) layers_ctrl &= msk;
339 	}
340 #endif
341 
342 	m_bg1_tmap->set_scrollx(0, 0);
343 	m_bg1_tmap->set_scrolly(0, 0);
344 
345 	m_bg2_tmap->set_scrollx(0, m_scroll[0] - 0xa);
346 	m_bg2_tmap->set_scrolly(0, m_scroll[1]);
347 
348 	draw_bg15_tilemap();
349 
350 	bitmap.fill(m_palette->black_pen(), cliprect);
351 	if (layers_ctrl & 4)    copybitmap_trans(bitmap, m_bg15_bitmap[0], 0, 0, 1, 0, cliprect, BG15_TRANSPARENT);
352 	if (layers_ctrl & 8)    copybitmap_trans(bitmap, m_bg15_bitmap[1], 0, 0, 0, 0, cliprect, BG15_TRANSPARENT);
353 	if (layers_ctrl & 1)    m_bg1_tmap->draw(screen, bitmap, cliprect, 0, 0);
354 	if (layers_ctrl & 2)    m_bg2_tmap->draw(screen, bitmap, cliprect, 0, 0);
355 
356 	popmessage("S0: %04X S1: %04X EN: %04X OUT: %04X", m_scroll[0], m_scroll[1], m_enable[0], m_outputs[0]);
357 	return 0;
358 }
359 
360 /***************************************************************************
361 
362     Memory Maps
363 
364 ***************************************************************************/
365 
fpga_r()366 uint16_t joystand_state::fpga_r()
367 {
368 	return 0xffff;
369 }
370 
oki_bank_w(offs_t offset,uint16_t data,uint16_t mem_mask)371 void joystand_state::oki_bank_w(offs_t offset, uint16_t data, uint16_t mem_mask)
372 {
373 	if (ACCESSING_BITS_0_7)
374 		m_oki->set_rom_bank((data >> 6) & 3);
375 }
376 
eeprom_r()377 uint16_t joystand_state::eeprom_r()
378 {
379 	// mask 0x0020 ? (active low)
380 	// mask 0x0040 ? ""
381 	return (m_eeprom->do_read() & 1) << 3;
382 }
eeprom_w(offs_t offset,uint16_t data,uint16_t mem_mask)383 void joystand_state::eeprom_w(offs_t offset, uint16_t data, uint16_t mem_mask)
384 {
385 	if (ACCESSING_BITS_8_15)
386 	{
387 		// latch the data bit
388 		m_eeprom->di_write ( (data & 0x0004) ? ASSERT_LINE : CLEAR_LINE );
389 
390 		// reset line asserted: reset.
391 		m_eeprom->cs_write ( (data & 0x0001) ? ASSERT_LINE : CLEAR_LINE );
392 
393 		// clock line asserted: write latch or select next bit to read
394 		m_eeprom->clk_write( (data & 0x0002) ? ASSERT_LINE : CLEAR_LINE );
395 
396 		// mask 0x1000 ?
397 	}
398 }
399 
outputs_w(offs_t offset,uint16_t data,uint16_t mem_mask)400 void joystand_state::outputs_w(offs_t offset, uint16_t data, uint16_t mem_mask)
401 {
402 	COMBINE_DATA(&m_outputs[0]);
403 	if (ACCESSING_BITS_8_15)
404 	{
405 		machine().bookkeeping().coin_counter_w(0,            BIT(data, 0)); // coin counter 1
406 		machine().bookkeeping().coin_counter_w(1,            BIT(data, 1)); // coin counter 2
407 
408 		output().set_value("blocker",             BIT(data, 2));
409 		output().set_value("error_lamp",          BIT(data, 3)); // counter error
410 		output().set_value("photo_lamp",          BIT(data, 4)); // during photo
411 	}
412 	if (ACCESSING_BITS_8_15)
413 	{
414 		output().set_value("ok_button_led",       BIT(data, 8));
415 		output().set_value("cancel_button_led",   BIT(data, 9));
416 	}
417 }
418 
419 // carts
420 
421 // copy slot
e00000_r()422 uint16_t joystand_state::e00000_r()
423 {
424 	return ioport("COPY")->read();
425 }
426 // master slot
e00020_r()427 uint16_t joystand_state::e00020_r()
428 {
429 	return ioport("MASTER")->read();
430 }
431 
cart_r(offs_t offset)432 uint16_t joystand_state::cart_r(offs_t offset)
433 {
434 	int which = offset / 0x80000;
435 	int addr  = offset & 0x7ffff;
436 	return (m_cart_flash[which * 2 + 0]->read(addr) << 8) | m_cart_flash[which * 2 + 1]->read(addr);
437 }
438 
cart_w(offs_t offset,uint16_t data,uint16_t mem_mask)439 void joystand_state::cart_w(offs_t offset, uint16_t data, uint16_t mem_mask)
440 {
441 	int which = offset / 0x80000;
442 	int addr  = offset & 0x7ffff;
443 
444 	if (ACCESSING_BITS_0_7)
445 		m_cart_flash[which * 2 + 1]->write(addr, data & 0xff);
446 	if (ACCESSING_BITS_8_15)
447 		m_cart_flash[which * 2 + 0]->write(addr, data >> 8);
448 
449 	bg15_tiles_dirty = true;
450 }
451 
joystand_map(address_map & map)452 void joystand_state::joystand_map(address_map &map)
453 {
454 	map(0x000000, 0x07ffff).rom();
455 	map(0x100000, 0x13ffff).ram();
456 	map(0x200000, 0x200003).w("ym2413", FUNC(ym2413_device::write)).umask16(0x00ff);
457 	map(0x200009, 0x200009).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write));
458 	map(0x200010, 0x200011).portr("IN0"); // r/w
459 	map(0x200012, 0x200013).ram().w(FUNC(joystand_state::outputs_w)).share("outputs"); // r/w
460 	map(0x200014, 0x200015).rw(FUNC(joystand_state::fpga_r), FUNC(joystand_state::oki_bank_w)); // r/w
461 //  map(0x200016, 0x200017) // write $9190 at boot
462 
463 	map(0x400000, 0x47ffff).ram().w(FUNC(joystand_state::bg15_0_w)).share("bg15_0_ram"); // r5g5b5 200x200 pixel-based
464 	map(0x480000, 0x4fffff).ram(); // more rgb layers? (writes at offset 0)
465 	map(0x500000, 0x57ffff).ram(); // ""
466 	map(0x580000, 0x5fffff).ram(); // ""
467 
468 	map(0x600000, 0x603fff).ram().w(FUNC(joystand_state::bg2_w)).share("bg2_ram");
469 	map(0x604000, 0x605fff).ram().w(FUNC(joystand_state::bg1_w)).share("bg1_ram");
470 	map(0x606000, 0x607fff).ram().w(FUNC(joystand_state::bg15_1_w)).share("bg15_1_ram"); // r5g5b5 200x200 tile-based
471 	map(0x608000, 0x609fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
472 	map(0x60c000, 0x60c003).ram().share("scroll"); // write
473 	map(0x60c00c, 0x60c00d).ram().share("enable"); // write
474 
475 	map(0x800000, 0xdfffff).rw(FUNC(joystand_state::cart_r), FUNC(joystand_state::cart_w)); // r/w (cart flash)
476 //  map(0xe00080, 0xe00081) // write (bit 0 = cart? bit 1 = ? bit 3 = ?)
477 	map(0xe00000, 0xe00001).r(FUNC(joystand_state::e00000_r)); // copy slot
478 	map(0xe00020, 0xe00021).r(FUNC(joystand_state::e00020_r)); // master slot
479 
480 	map(0xe80040, 0xe8005f).rw("rtc", FUNC(msm6242_device::read), FUNC(msm6242_device::write)).umask16(0x00ff);
481 }
482 
483 
484 static INPUT_PORTS_START( joystand )
485 	// Cart status:
486 	// mask 0x1000 -> cart flash addressing (0 = sequential, 1 = interleaved even/odd)
487 	// mask 0x6000 == 0 -> cart present?
488 	// mask 0x8000 -> cart ready?
489 
490 	PORT_START("MASTER")
491 	PORT_CONFNAME( 0x1000, 0x1000, "Master Flash Addressing" )
492 	PORT_CONFSETTING(      0x1000, "Interleaved" )
493 	PORT_CONFSETTING(      0x0000, "Sequential" )
494 	PORT_CONFNAME( 0x2000, 0x0000, "Master Slot Sense 1" )
495 	PORT_CONFSETTING(      0x2000, "Empty" )
496 	PORT_CONFSETTING(      0x0000, "Cart" )
497 	PORT_CONFNAME( 0x4000, 0x0000, "Master Slot Sense 2" )
498 	PORT_CONFSETTING(      0x4000, "Empty" )
499 	PORT_CONFSETTING(      0x0000, "Cart" )
500 	PORT_BIT( 0x8fff, IP_ACTIVE_LOW, IPT_UNKNOWN )
501 
502 	PORT_START("COPY")
503 	PORT_CONFNAME( 0x1000, 0x1000, "Copy Flash Addressing" )
504 	PORT_CONFSETTING(      0x1000, "Interleaved" )
505 	PORT_CONFSETTING(      0x0000, "Sequential" )
506 	PORT_CONFNAME( 0x2000, 0x2000, "Copy Slot Sense 1" )
507 	PORT_CONFSETTING(      0x2000, "Empty" )
508 	PORT_CONFSETTING(      0x0000, "Cart" )
509 	PORT_CONFNAME( 0x4000, 0x4000, "Copy Slot Sense 2" )
510 	PORT_CONFSETTING(      0x4000, "Empty" )
511 	PORT_CONFSETTING(      0x0000, "Cart" )
512 	PORT_BIT( 0x8fff, IP_ACTIVE_LOW, IPT_UNKNOWN )
513 
514 	PORT_START("IN0")
515 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    ) // up
516 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  ) // down
517 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  ) // left
518 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) // right
519 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1        ) // ok
520 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2        ) // cancel
521 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN        )
522 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN        )
523 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_COIN1          ) // coin
524 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_SERVICE1       ) // service
525 	PORT_SERVICE_NO_TOGGLE( 0x0400, IP_ACTIVE_LOW       ) // test
526 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN        )
527 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN        )
528 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN        )
529 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN        )
530 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN        )
531 INPUT_PORTS_END
532 
533 
534 static const gfx_layout layout_8x8x4 =
535 {
536 	8,8,
537 	RGN_FRAC(1,1),
538 	4,
539 	{ STEP4(0, 1) },
540 	{ STEP8(0, 4) },
541 	{ STEP8(0, 4*8) },
542 	8*8*4
543 };
544 
545 static const gfx_layout layout_16x16x8 =
546 {
547 	16,16,
548 	RGN_FRAC(1,1),
549 	8,
550 	{ STEP8(0, 1) },
551 	{ STEP16(0, 8) },
552 	{ STEP16(0, 8*16) },
553 	16*16*8
554 };
555 
556 static GFXDECODE_START( gfx_joystand )
557 	GFXDECODE_ENTRY( "tiles",    0, layout_8x8x4,   0, 0x100 )
558 	GFXDECODE_ENTRY( "cart.u5",  0, layout_16x16x8, 0,  0x10 )
559 	GFXDECODE_ENTRY( "cart.u6",  0, layout_16x16x8, 0,  0x10 )
560 	GFXDECODE_ENTRY( "cart.u3",  0, layout_16x16x8, 0,  0x10 )
561 	GFXDECODE_ENTRY( "cart.u4",  0, layout_16x16x8, 0,  0x10 )
562 	GFXDECODE_ENTRY( "cart.u1",  0, layout_16x16x8, 0,  0x10 )
563 	GFXDECODE_ENTRY( "cart.u2",  0, layout_16x16x8, 0,  0x10 )
564 GFXDECODE_END
565 
566 
machine_start()567 void joystand_state::machine_start()
568 {
569 	m_cart_flash[0]  = m_cart_u11;      m_cart_flash[1]  = m_cart_u5;
570 	m_cart_flash[2]  = m_cart_u12;      m_cart_flash[3]  = m_cart_u6;
571 	m_cart_flash[4]  = m_cart_u9;       m_cart_flash[5]  = m_cart_u3;
572 	m_cart_flash[6]  = m_cart_u10;      m_cart_flash[7]  = m_cart_u4;
573 	m_cart_flash[8]  = m_cart_u7;       m_cart_flash[9]  = m_cart_u1;
574 	m_cart_flash[10] = m_cart_u8;       m_cart_flash[11] = m_cart_u2;
575 }
576 
machine_reset()577 void joystand_state::machine_reset()
578 {
579 }
580 
INTERRUPT_GEN_MEMBER(joystand_state::joystand_interrupt)581 INTERRUPT_GEN_MEMBER(joystand_state::joystand_interrupt)
582 {
583 	// VBlank is connected to INT1 (external interrupts pin 1)
584 	m_maincpu->external_interrupt_1();
585 }
586 
joystand(machine_config & config)587 void joystand_state::joystand(machine_config &config)
588 {
589 	// basic machine hardware
590 	TMP68301(config, m_maincpu, XTAL(16'000'000));
591 	m_maincpu->set_addrmap(AS_PROGRAM, &joystand_state::joystand_map);
592 	m_maincpu->set_vblank_int("screen", FUNC(joystand_state::joystand_interrupt));
593 	m_maincpu->in_parallel_callback().set(FUNC(joystand_state::eeprom_r));
594 	m_maincpu->out_parallel_callback().set(FUNC(joystand_state::eeprom_w));
595 
596 	// video hardware
597 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
598 	screen.set_refresh_hz(60);
599 	screen.set_screen_update(FUNC(joystand_state::screen_update));
600 	screen.set_size(0x200, 0x100);
601 	screen.set_visarea(0x40, 0x40+0x178-1, 0x10, 0x100-1);
602 
603 	PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 0x1000);
604 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_joystand);
605 
606 	PALETTE(config, m_bg15_palette, palette_device::RGB_555);
607 
608 	// sound hardware
609 	SPEAKER(config, "mono").front_center();
610 
611 	YM2413(config, "ym2413", XTAL(3'579'545)).add_route(ALL_OUTPUTS, "mono", 0.80);
612 
613 	OKIM6295(config, m_oki, XTAL(16'000'000) / 16, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "mono", 0.50); // pin 7 not verified
614 
615 	// cart
616 	TMS_29F040(config, "cart.u1");
617 	TMS_29F040(config, "cart.u2");
618 	TMS_29F040(config, "cart.u3");
619 	TMS_29F040(config, "cart.u4");
620 	TMS_29F040(config, "cart.u5");
621 	TMS_29F040(config, "cart.u6");
622 	TMS_29F040(config, "cart.u7");
623 	TMS_29F040(config, "cart.u8");
624 	TMS_29F040(config, "cart.u9");
625 	TMS_29F040(config, "cart.u10");
626 	TMS_29F040(config, "cart.u11");
627 	TMS_29F040(config, "cart.u12");
628 
629 	// devices
630 	EEPROM_93C46_16BIT(config, "eeprom");
631 	MSM6242(config, "rtc", XTAL(32'768));
632 }
633 
634 
635 /***************************************************************************
636 
637     Machine driver(s)
638 
639 ***************************************************************************/
640 
641 ROM_START( joystand )
642 	ROM_REGION( 0x80000, "maincpu", 0 )
643 	ROM_LOAD16_BYTE( "yuvo_jsp003b.ic3",  0x00000, 0x40000, CRC(0c85bc77) SHA1(ad8ec80b02e82cf43e3f0732cc6e5468c6d21297) )
644 	ROM_LOAD16_BYTE( "yuvo_jsp004b.ic63", 0x00001, 0x40000, CRC(333396e5) SHA1(fc605890676efed476b67abcd1fcb8d509324be2) )
645 
646 	ROM_REGION( 0x180000, "tiles", 0 )
647 	ROM_LOAD16_BYTE( "yuvo_jsp005.2j",  0x000000, 0x80000, CRC(98caff66) SHA1(e201bb0119bc6560b7def40d42d2ef5b788ca3d4) )
648 	ROM_LOAD16_BYTE( "yuvo_jsp006.4j",  0x000001, 0x80000, CRC(6c9f8048) SHA1(3fd6effa83b0e429b97d55041697f1b5ee6eafe2) )
649 	ROM_LOAD16_BYTE( "yuvo_jsp007a.2g", 0x100000, 0x40000, CRC(ccfd5b72) SHA1(29bf14c888731d63f5d6705d0efb840f1de0fc91) ) // 1xxxxxxxxxxxxxxxxx = 0xFF
650 	ROM_LOAD16_BYTE( "yuvo_jsp008a.4g", 0x100001, 0x40000, CRC(fdaf369c) SHA1(488741b9f2c5ccd27ee1aa5120834ec8b161d6b1) ) // 1xxxxxxxxxxxxxxxxx = 0xFF
651 
652 	ROM_REGION( 0x80000, "cart.u1", 0 )
653 	ROM_LOAD( "jsp.u1",  0x00000, 0x80000, CRC(5478b779) SHA1(5d76645de2833cefb20374480572f06ef496ce30) )
654 	ROM_REGION( 0x80000, "cart.u2", 0 )
655 	ROM_LOAD( "jsp.u2",  0x00000, 0x80000, CRC(adba9522) SHA1(574e925b35ef3f732989f712caf3f92e16106c22) )
656 	ROM_REGION( 0x80000, "cart.u3", 0 )
657 	ROM_LOAD( "jsp.u3",  0x00000, 0x80000, CRC(6e293f82) SHA1(e29099c5337c5e7b4776da01a3bd45141b4900b9) )
658 	ROM_REGION( 0x80000, "cart.u4", 0 )
659 	ROM_LOAD( "jsp.u4",  0x00000, 0x80000, CRC(4caab540) SHA1(5cd88dc93c57d3ae9a6b3773222d8f6001b74634) )
660 	ROM_REGION( 0x80000, "cart.u5", 0 )
661 	ROM_LOAD( "jsp.u5",  0x00000, 0x80000, CRC(2cfee501) SHA1(2f07179accca0181d20bb0af797194a8ddad4f7a) )
662 	ROM_REGION( 0x80000, "cart.u6", 0 )
663 	ROM_LOAD( "jsp.u6",  0x00000, 0x80000, CRC(6069d711) SHA1(e969dcc4b5da6951b4140a78fa7cda350167ca66) )
664 	ROM_REGION( 0x80000, "cart.u7", 0 )
665 	ROM_LOAD( "jsp.u7",  0x00000, 0x80000, CRC(9f58df4d) SHA1(e4933087204624c021420bf632a6ddfd7b26179c) )
666 	ROM_REGION( 0x80000, "cart.u8", 0 )
667 	ROM_LOAD( "jsp.u8",  0x00000, 0x80000, CRC(829ddce6) SHA1(614ac45d55abe487aaa0e5ca7354926caaa03346) )
668 	ROM_REGION( 0x80000, "cart.u9", 0 )
669 	ROM_LOAD( "jsp.u9",  0x00000, 0x80000, CRC(e5ee5d8d) SHA1(ea6ea2fe4fc8b9eaf556453b430c85434ddf1570) )
670 	ROM_REGION( 0x80000, "cart.u10", 0 )
671 	ROM_LOAD( "jsp.u10", 0x00000, 0x80000, CRC(97234b84) SHA1(06a5dc290e925f5d6a8bade89d970964f32c9945) )
672 	ROM_REGION( 0x80000, "cart.u11", 0 )
673 	ROM_LOAD( "jsp.u11", 0x00000, 0x80000, CRC(8b138563) SHA1(8a2092d80d02ac685014540837b9aa38dfe0eb47) )
674 	ROM_REGION( 0x80000, "cart.u12", 0 )
675 	ROM_LOAD( "jsp.u12", 0x00000, 0x80000, CRC(10001cab) SHA1(5de49061f9ab81a4dc7e3405132ecec35a63248d) )
676 
677 	ROM_REGION( 0x100000, "oki", 0 )
678 	ROM_LOAD( "yuvo_jsp001.ic14", 0x00000, 0x80000, CRC(bf2b4557) SHA1(932b96f4b3553e9d52509d678c7c2d4dcfc32cd7) )
679 	ROM_LOAD( "yuvo_jsp002.ic13", 0x80000, 0x80000, CRC(0eb6db96) SHA1(e5f88f5357709def987f807d1a2d21514b5aa107) ) // 1ST AND 2ND HALF IDENTICAL
680 
681 	ROM_REGION( 0x117, "pld", 0 )
682 	ROM_LOAD( "jsp-frm.ic100", 0x000, 0x117, NO_DUMP )
683 	ROM_LOAD( "jsp-map.ic4",   0x000, 0x117, NO_DUMP )
684 	ROM_LOAD( "jsp-sub.1f",    0x000, 0x117, NO_DUMP )
685 	ROM_LOAD( "jsp-xct.ic5",   0x000, 0x117, NO_DUMP )
686 ROM_END
687 
688 GAME( 1997, joystand, 0, joystand, joystand, joystand_state, empty_init, ROT0, "Yuvo", "Joy Stand Private", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE )
689