summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/jubilee.cpp
blob: bbb516f507c7893a741c14f24ad60deab6133207 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
// license:BSD-3-Clause
// copyright-holders:Roberto Fresca
/****************************************************************************************

  Jubilee Double-Up Poker
  -----------------------

  Driver by Roberto Fresca.


  Games running on this hardware:

  * Double-Up Poker (Jubilee),  1985,  Jubilee.


*****************************************************************************************

  You can find more about this game and the emulation evolution at
  http://www.robertofresca.com/

*****************************************************************************************

  Hardware Notes:
  ---------------

  PCB etched:

  HERBER LTD
  Jubilee Sales Pty Ltd.
  BD No V63-261 ISS1.

  1x TMS9980 CPU.
  1x MC6845P CRTC.

  1x TC5517AP-2 (2048 words x 8 bits Asynchronous CMOS Static RAM), tied to a battery.
  1x 2114       (1024 words x 4 bits RAM).

  3x 2732 labelled 1, 2 and 3.
  3x 2764 labelled Red, Blue and Green (the last one also has '22-3-85').

  1x 6.0 MHz crystal.
  1x Panasonic BR-2/3A lithium battery (3V, 1200 mAh).


  From some forums...

  The memory chips on board are the toshiba TC5517ap powered via the Lithium cell and
  the 2114 find the 74148 or 74ls148, all 9980 cpu's use one, pin3 will generate a reset.
  The 5517 ram is compatible with 6116 or 2018.

  The 9980 has 3 interrupt inputs, but they are binary.
  The ls148 encodes the interrupts to the cpu - the highest interrupt is reset.

  I tried pulling pin 3 of the 74ls148 low and yes, this sets up the reset interrupt
  on pins 23, 24 and 25. The TC5517 checks out ok as a 6116.

  The crystal seems ok and this clock makes it throught to pin 34 of the MPU.
  I was expecting that PHASE 03 - pin 22, should be clocking, but it simply sits at 5v.


*****************************************************************************************

  *** Game Notes ***

  Just insert coins, and play. You can win up to 500 credits! :)

  A default NVRAM is provided. Without it, the game stucks at boot with a memory error
  screen. If this happens, press the key 9 (Attendant). The game will initialize the NVRAM
  and then boots OK.

  The RESET service button (key R) is just for clean credits purposes.

  The Supervisor Key (Key 0), brings a menu for bookkeeping, and replay (still can't see
  the point). The key behaves like a real lock key, with off/on status.

  From the marquee: 'ALL CREDITS REDEEMABLE IN LIQUOR ONLY. NO CASH PAYMENTS'
  So we can assume that is *exclusive* for amusement.

  From the marquee: 'MINIMUM REDEMPTION: 30 CREDITS' (to redeem LESS THAN 30 CREDITS,
  Player must insert coins to bring total Credits to 30).

  Ok... you need to have 30 or more credits to redeem. Otherwise you oddly need to insert
  more coins to reach the minimum of 30 Credits.

  To redeem credits (30 or more!):
  1) Press the Hand Pay button (key 8). You'll get the 'Call Attendant' blinking message.
  2) Press the Attendant button (key 9). You'll get a new message at bottom-left of the
     screen about the amount of credits to pay.
  3) Turn ON/OFF the Supervisor key (key 0). It will clear the credits, with a new message
     at bottom-left of the screen about of value paid.


  Paytable:   Play 1 to 5 coins....

  +----------------+--------+--------+--------+--------+--------+
  |     Hand       | 1 Coin | 2 Coin | 3 Coin | 4 Coin | 5 Coin |
  +----------------+--------+--------+--------+--------+--------+
  | Royal Flush    |  100   |  200   |  300   |  400   |  500   |
  | Straight Flush |   70   |  140   |  210   |  280   |  350   |
  | 4 of a Kind    |   40   |   80   |  120   |  160   |  200   |
  | Full House     |   10   |   20   |   30   |   40   |   50   |
  | Flush          |    7   |   14   |   21   |   28   |   35   |
  | Straight       |    5   |   10   |   15   |   20   |   25   |
  | 3 of a Kind    |    3   |    6   |    9   |   12   |   15   |
  | 2 Pair         |    2   |    4   |    6   |    8   |   10   |
  | Pair Aces      |    1   |    2   |    3   |    4   |    5   |
  +----------------+--------+--------+--------+--------+--------+


*****************************************************************************************

  --------------------
  ***  Memory Map  ***
  --------------------

  0000-2FFF    ; ROM space.
  3000-33FF    ; Video RAM.   ----------> First half of TC5517AP battery backed RAM.
  3400-37FF    ; Working RAM. ----------> Second half of TC5517AP battery backed RAM.
  3800-3BFF    ; Color (ATTR) RAM. -----> Whole 2114 RAM.
  3E00-3E03    ; CRT Controller. -------> MC6845P.

  CRU...

  0080-0080    ; Unknown Read. Maybe a leftover.
  00C8-00C8    ; Multiplexed Input Port.
  0CC2-0CC6    ; Input Port mux selectors.
  0CD0-0CD4    ; Lamps.
  0CE2-0CE2    ; Clear Interrupts line.


  TMS9980A memory map:

  0000-0003 ---> Reset
  0004-0007 ---> Level 1
  0008-000B ---> Level 2
  000C-000F ---> Level 3
  0010-0013 ---> Level 4

  3FFC-3FFF ---> Load


*****************************************************************************************

  DRIVER UPDATES:


  [2014-02-19]

  - Added a default clean NVRAM.
  - Found and implemented the credits input.
    The game is now working!. Still no sound.

  [2014-02-17]

  - Demuxed the input system.
  - Hooked an cleaned all inputs, except the coin in (missing).
  - Added NVRAM support.
  - Hooked CRTC properly.
  - Adjusted the screen size and visible area according to CRTC values.
  - Adjusted the screen pos 8 pixels, to get a bit centered.
  - Fixed palette to 8 colors.
  - Added technical notes.

  [2014-02-17]

  - Corrected the crystal value and derivate clocks via #DEFINE.
  - Improved memory map.
  - Hooked the CRT controller, but the init sequence seems incomplete.
  - Created the accurate graphics banks.
  - Found and mapped the video RAM.
  - Hooked the ATTR RAM.
  - Assigned the correct graphics banks to the proper drawn tiles.
  - Find and mapped an input port.
  - Started a preliminary workaround to demux the input port.
  - Added technical notes.

  [2010-09-05]

  - Initial release.
  - Decoded graphics.
  - Proper tile colors.
  - Hooked the correct CPU.
  - Preliminary memory map.
  - Added technical notes.


  TODO:

  - Analize the remaining CRU writes.
  - Discrete sound?.
  - Check clocks on a PCB (if someday appear one!)


****************************************************************************************/

#include "emu.h"
#include "cpu/tms9900/tms9980a.h"
#include "machine/nvram.h"
#include "video/mc6845.h"
#include "emupal.h"
#include "screen.h"

#define MASTER_CLOCK    XTAL(6'000'000)              /* confirmed */
#define CPU_CLOCK       MASTER_CLOCK           /* guess */
#define CRTC_CLOCK     (MASTER_CLOCK / 8)      /* guess */


class jubilee_state : public driver_device
{
public:
	jubilee_state(const machine_config &mconfig, device_type type, const char *tag) :
		driver_device(mconfig, type, tag),
		m_videoram(*this, "videoworkram"),
		m_colorram(*this, "colorram"),
		m_maincpu(*this, "maincpu"),
		m_gfxdecode(*this, "gfxdecode"),
		m_lamps(*this, "lamp%u", 0U)
	{ }

	void jubileep(machine_config &config);

private:
	DECLARE_WRITE8_MEMBER(jubileep_videoram_w);
	DECLARE_WRITE8_MEMBER(jubileep_colorram_w);
	DECLARE_WRITE8_MEMBER(unk_w);
	DECLARE_READ8_MEMBER(mux_port_r);
	TILE_GET_INFO_MEMBER(get_bg_tile_info);
	uint32_t screen_update_jubileep(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	INTERRUPT_GEN_MEMBER(jubileep_interrupt);
	void jubileep_cru_map(address_map &map);
	void jubileep_map(address_map &map);

	virtual void machine_start() override { m_lamps.resolve(); }
	virtual void video_start() override;

	uint8_t mux_sel;
	uint8_t muxlamps;

	required_shared_ptr<uint8_t> m_videoram;
	required_shared_ptr<uint8_t> m_colorram;
	tilemap_t *m_bg_tilemap;
	required_device<cpu_device> m_maincpu;
	required_device<gfxdecode_device> m_gfxdecode;
	output_finder<9> m_lamps;
};


/*************************
*     Video Hardware     *
*************************/

WRITE8_MEMBER(jubilee_state::jubileep_videoram_w)
{
	m_videoram[offset] = data;
	m_bg_tilemap->mark_tile_dirty(offset);
}

WRITE8_MEMBER(jubilee_state::jubileep_colorram_w)
{
	m_colorram[offset] = data;
	m_bg_tilemap->mark_tile_dirty(offset);
}


TILE_GET_INFO_MEMBER(jubilee_state::get_bg_tile_info)
{
/*  - bits -   (attr for gfx banks 00-03)
    7654 3210
    <no> --xx   bank select.
    <no> xx--   seems unused.
*/
	int attr = m_colorram[tile_index];
	int code = m_videoram[tile_index];
	int bank = (attr & 0x03);
	int color = 0;  /* fixed colors: one rom for each R, G and B. */

	SET_TILE_INFO_MEMBER(bank, code, color, 0);
}


void jubilee_state::video_start()
{
	m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(jubilee_state::get_bg_tile_info), this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
	m_bg_tilemap->set_scrolldx(8, 0); /* guess */
}

uint32_t jubilee_state::screen_update_jubileep(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
	return 0;
}


/**************************
*  Read / Write Handlers  *
**************************/

INTERRUPT_GEN_MEMBER(jubilee_state::jubileep_interrupt)
{
	m_maincpu->set_input_line(INT_9980A_LEVEL1, ASSERT_LINE);
}


/*************************
* Memory Map Information *
*************************/

void jubilee_state::jubileep_map(address_map &map)
{
	map.global_mask(0x3fff);
	map(0x0000, 0x2fff).rom();

/*  Video RAM =   3000-33FF
    Working RAM = 3400-37FF
    Color RAM =   3800-3BFF (lower 4-bits)
*/
	map(0x3000, 0x37ff).ram().w(FUNC(jubilee_state::jubileep_videoram_w)).share("videoworkram");  /* TC5517AP battery backed RAM */
	map(0x3800, 0x3bff).ram().w(FUNC(jubilee_state::jubileep_colorram_w)).share("colorram");      /* Whole 2114 RAM */

/*  CRTC *is* mapped here. Read 00-01 and then write on them.
    Then does the same for 02-03. Initialization seems incomplete since
    set till register 0x0D. Maybe the last registers are unused.
*/
	map(0x3e00, 0x3e01).rw("crtc", FUNC(mc6845_device::status_r), FUNC(mc6845_device::address_w));
	map(0x3e02, 0x3e03).rw("crtc", FUNC(mc6845_device::register_r), FUNC(mc6845_device::register_w));

/*  CRTC address: $3E01; register: $3E03
    CRTC registers: 2f 20 25 64 26 00 20 23 00 07 00 00 00
    screen total: (0x2f+1)*8 (0x26+1)*(0x07+1) ---> 384 x 312
    visible area: 0x20 0x20  ---------------------> 256 x 256
*/
}


WRITE8_MEMBER(jubilee_state::unk_w)
{
/*  In particular, the interrupt from above must be cleared. We assume that
    this is done by one of the output lines, and from the 32 lines that are
    set right after an interrupt is serviced, all are set to 0, and only one
    is set to one. Maybe this one clears the interrupt.
    TODO: Check the schematics.
*/
	if (((offset<<1)==0x0ce2)&&(data==1))
	{
		m_maincpu->set_input_line(INT_9980A_LEVEL1, CLEAR_LINE);
	}

/*  Inputs Multiplexion...

    Should be 0CC0 added as selector?
    Was tested and didn't see any input driven by its state.
    This doesn't mean that couln't be possible.
*/

	if (((offset<<1)==0x0cc2)&&(data==1))
	{
		mux_sel = 1;
	}

	if (((offset<<1)==0x0cc4)&&(data==1))
	{
		mux_sel = 2;
	}

	if (((offset<<1)==0x0cc6)&&(data==1))
	{
		mux_sel = 3;
	}


/*  Lamps, sounds and other writes:

    0CD0 = HOLD3 lamp.
    0CD2 = HOLD2 lamp.
    0CD4 = HOLD1 lamp.

    Can't find more. Could be a kind of multiplexion.
    The input selectors don't seems to be completely involved,
    but 0CC6 is set to 1 when hold 1-2-3 turn on, thing that
    could be normal due to the end value for the state routine.

    Writes to analize:
    0CC0 (write too often... maybe input selector)
    0CCC (write a bit less often...)

    0CE6 = could be either a 'Insert Coin' lamp,
    or coin lockout (inverted), since is active
    low during the game. when the game is over,
    is set to 1.

    Also...

    Pressing cancel ---> writes 1 to 0CE8
    Pressing bet ------> writes 1 to 0CEA
    Pressing hold4 ----> writes 1 to 0CEC
    Pressing hold5 ----> writes 1 to 0CEE
    Pressing hand pay -> writes 1 to 0CF0
    Pressing hold1 ----> writes 1 to 0CF2
    Pressing hold2 ----> writes 1 to 0CF4
    Pressing hold3 ----> writes 1 to 0CF6
    Pressing reset ----> writes 1 to 0CF8
    Pressing deal -----> writes 1 to 0D00

    (See below, in sound writes...)
*/

	if (((offset<<1)==0x0ccc)&&(data==1))
	{
		muxlamps = 1;
	}
	if (((offset<<1)==0x0ccc)&&(data==0))
	{
		muxlamps = 2;
	}

/*  the following structure has 3 states, because I tested the inputs
    selectors 0CC2-0CC4-0CC6 as lamps multiplexers unsuccessfuly.
*/
	if (((offset<<1)==0x0cd0)&&(data==1))
	{
		if (muxlamps == 1)
			{
				m_lamps[0] = BIT(data, 0);  /* lamp */
				logerror("CRU: LAAAAAAMP 0 write to address %04x: %d\n", offset<<1, data & 1);
//              popmessage("LAMP 0");
			}
		if (muxlamps == 2)
			{
				m_lamps[3] = BIT(data, 0);  /* lamp */
				logerror("CRU: LAAAAAAMP 3 write to address %04x: %d\n", offset<<1, data & 1);
//              popmessage("LAMP 3");
			}
		if (muxlamps == 3)
			{
				m_lamps[6] = BIT(data, 0);  /* lamp */
				logerror("CRU: LAAAAAAMP 6 write to address %04x: %d\n", offset<<1, data & 1);
//              popmessage("LAMP 6");
			}
	}

	if (((offset<<1)==0x0cd2)&&(data==1))
	{
		if (muxlamps == 1)
			{
				m_lamps[1] = BIT(data, 0);  /* lamp */
				logerror("CRU: LAAAAAAMP 1 write to address %04x: %d\n", offset<<1, data & 1);
//              popmessage("LAMP 1");
			}
		if (muxlamps == 2)
			{
				m_lamps[4] = BIT(data, 0);  /* lamp */
				logerror("CRU: LAAAAAAMP 4 write to address %04x: %d\n", offset<<1, data & 1);
//              popmessage("LAMP 4");
			}
		if (muxlamps == 3)
			{
				m_lamps[7] = BIT(data, 0);  /* lamp */
				logerror("CRU: LAAAAAAMP 7 write to address %04x: %d\n", offset<<1, data & 1);
//              popmessage("LAMP 7");
			}
	}

	if (((offset<<1)==0x0cd4)&&(data==1))
	{
		if (muxlamps == 1)
			{
				m_lamps[2] = BIT(data, 0);  /* lamp */
				logerror("CRU: LAAAAAAMP 2 write to address %04x: %d\n", offset<<1, data & 1);
//              popmessage("LAMP 2");
			}
		if (muxlamps == 2)
			{
				m_lamps[5] = BIT(data, 0);  /* lamp */
				logerror("CRU: LAAAAAAMP 5 write to address %04x: %d\n", offset<<1, data & 1);
//              popmessage("LAMP 5");
			}
		if (muxlamps == 3)
			{
				m_lamps[8] = BIT(data, 0);  /* lamp */
				logerror("CRU: LAAAAAAMP 8 write to address %04x: %d\n", offset<<1, data & 1);
//              popmessage("LAMP 8");
			}
	}

/*  Sound writes?...

    In case of discrete circuitry, the following writes
    could be the trigger for each sound.

    Pressing cancel ---> writes 1 to 0CE8
    Pressing bet ------> writes 1 to 0CEA
    Pressing hold4 ----> writes 1 to 0CEC
    Pressing hold5 ----> writes 1 to 0CEE
    Pressing hand pay -> writes 1 to 0CF0
    Pressing hold1 ----> writes 1 to 0CF2
    Pressing hold2 ----> writes 1 to 0CF4
    Pressing hold3 ----> writes 1 to 0CF6
    Pressing reset ----> writes 1 to 0CF8
    Pressing deal -----> writes 1 to 0D00
*/

	if (((offset<<1)==0x0ce8)&&(data==1))
	{
		logerror("CRU: SOUND 'CANCEL' write to address %04x: %d\n", offset<<1, data & 1);
//      popmessage("SOUND 'CANCEL': %04x", offset<<1);
	}

	if (((offset<<1)==0x0cea)&&(data==1))
	{
		logerror("CRU: SOUND 'BET' write to address %04x: %d\n", offset<<1, data & 1);
//      popmessage("SOUND 'BET': %04x", offset<<1);
	}

	if (((offset<<1)==0x0cec)&&(data==1))
	{
		logerror("CRU: SOUND 'HOLD4' write to address %04x: %d\n", offset<<1, data & 1);
//      popmessage("SOUND 'HOLD 4': %04x", offset<<1);
	}

	if (((offset<<1)==0x0cee)&&(data==1))
	{
		logerror("CRU: SOUND 'HOLD5' write to address %04x: %d\n", offset<<1, data & 1);
//      popmessage("SOUND 'HOLD 5': %04x", offset<<1);
	}

	if (((offset<<1)==0x0cf0)&&(data==1))
	{
		logerror("CRU: SOUND 'HAND PAY' write to address %04x: %d\n", offset<<1, data & 1);
//      popmessage("SOUND 'HAND PAY': %04x", offset<<1);
	}

	if (((offset<<1)==0x0cf2)&&(data==1))
	{
		logerror("CRU: SOUND 'HOLD1' write to address %04x: %d\n", offset<<1, data & 1);
//      popmessage("SOUND 'HOLD 1': %04x", offset<<1);
	}

	if (((offset<<1)==0x0cf4)&&(data==1))
	{
		logerror("CRU: SOUND 'HOLD2' write to address %04x: %d\n", offset<<1, data & 1);
//      popmessage("SOUND 'HOLD 2': %04x", offset<<1);
	}

	if (((offset<<1)==0x0cf6)&&(data==1))
	{
		logerror("CRU: SOUND 'HOLD3' write to address %04x: %d\n", offset<<1, data & 1);
//      popmessage("SOUND 'HOLD 3': %04x", offset<<1);
	}

	if (((offset<<1)==0x0cf8)&&(data==1))
	{
		logerror("CRU: SOUND 'RESET' write to address %04x: %d\n", offset<<1, data & 1);
//      popmessage("SOUND 'RESET': %04x", offset<<1);
	}

	if (((offset<<1)==0x0d00)&&(data==1))
	{
		logerror("CRU: SOUND 'DEAL' write to address %04x: %d\n", offset<<1, data & 1);
//      popmessage("SOUND 'DEAL': %04x", offset<<1);
	}


	/* for debug purposes */

	logerror("CRU write to address %04x: %d\n", offset<<1, data & 1);
}

READ8_MEMBER(jubilee_state::mux_port_r)
{
	switch( mux_sel )
	{
		case 0x01: return ioport("IN0")->read();
		case 0x02: return ioport("IN1")->read();    /* muxed credits input is here! */
		case 0x03: return ioport("IN2")->read();
	}

	return 0xff;
}


void jubilee_state::jubileep_cru_map(address_map &map)
{
	map(0x00c8, 0x00c8).r(FUNC(jubilee_state::mux_port_r));    /* multiplexed input port */
	map(0x0000, 0x07ff).w(FUNC(jubilee_state::unk_w));
}

/* I/O byte R/W

   0x080  R    ; Input port? Polled once at beginning.
   0x0C8  R    ; Input port.

   Can't see more inputs. There is a multiplexion with the following offsets as selectors:
   0xCC2 / 0xCC4 / 0xCC6.

   0xCC4 status carry the coin input state.

*/

/*************************
*      Input Ports       *
*************************/

static INPUT_PORTS_START( jubileep )
	PORT_START("IN0")
	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_POKER_CANCEL )  PORT_NAME("Cancel / Take")
	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_GAMBLE_BET )    PORT_NAME("Bet / Gamble")
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_POKER_HOLD4 )   PORT_NAME("Hold 4 / Half Gamble")
	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_POKER_HOLD5 )   PORT_NAME("Hold 5 / Red")
	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SERVICE )       PORT_NAME("Hand Pay")             PORT_CODE(KEYCODE_8)
	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_POKER_HOLD1 )   PORT_NAME("Hold 1 / Black")
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_POKER_HOLD2 )   PORT_NAME("Hold 2")
	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_POKER_HOLD3 )   PORT_NAME("Hold 3")

	PORT_START("IN1")
/*  Don't know if this needs a custom port. Bits 0 and 1 together are the credits input.
    Bit 1 alone could be "Attendant Paid Status (reset)" that does a reset and update the
    paid status, or just is for edge coin-in timeouts... Impossible to say without a PCB.
*/
	PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_COIN1 )    PORT_IMPULSE (2)
//  PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SERVICE )  PORT_NAME("Attendant Paid Status (reset)")  PORT_CODE(KEYCODE_7)
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SERVICE )  PORT_CODE(KEYCODE_9) PORT_NAME("Attendant (to pass the memory error and hand pay)")
	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SERVICE )  PORT_CODE(KEYCODE_0) PORT_NAME("Supervisor Key (Bookkeeping)")  PORT_TOGGLE

	PORT_START("IN2")
	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE )  PORT_CODE(KEYCODE_R) PORT_NAME("Reset")
	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 )   PORT_NAME("Deal / Start")
	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )

INPUT_PORTS_END


/*************************
*    Graphics Layouts    *
*************************/

static const gfx_layout tilelayout =
{
	8, 8,
	0x100,
	3,
	{ RGN_FRAC(2,3), RGN_FRAC(1,3), 0 },    /* bitplanes are separated */
	{ 0, 1, 2, 3, 4, 5, 6, 7 },
	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
	8*8
};


/******************************
* Graphics Decode Information *
******************************/

static GFXDECODE_START( gfx_jubileep )      /* 4 different graphics banks */
	GFXDECODE_ENTRY( "gfx1", 0, tilelayout, 0, 1 )
	GFXDECODE_ENTRY( "gfx1", 0x0800, tilelayout, 0, 1 )
	GFXDECODE_ENTRY( "gfx1", 0x1000, tilelayout, 0, 1 )
	GFXDECODE_ENTRY( "gfx1", 0x1800, tilelayout, 0, 1 )
GFXDECODE_END


/*************************
*    Machine Drivers     *
*************************/

MACHINE_CONFIG_START(jubilee_state::jubileep)

	// Main CPU TMS9980A, no line connections.
	TMS9980A(config, m_maincpu, CPU_CLOCK);
	m_maincpu->set_addrmap(AS_PROGRAM, &jubilee_state::jubileep_map);
	m_maincpu->set_addrmap(AS_IO, &jubilee_state::jubileep_cru_map);
	m_maincpu->set_vblank_int("screen", FUNC(jubilee_state::jubileep_interrupt));

	NVRAM(config, "videoworkram", nvram_device::DEFAULT_ALL_0);

	/* video hardware */
	MCFG_SCREEN_ADD("screen", RASTER)
	MCFG_SCREEN_REFRESH_RATE(60)
	MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
	MCFG_SCREEN_SIZE(32*8, 32*8)                         /* (47+1*8, 38+1*8) from CRTC settings */
	MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1)   /* (32*8, 32*8) from CRTC settings */
	MCFG_SCREEN_UPDATE_DRIVER(jubilee_state, screen_update_jubileep)
	MCFG_SCREEN_PALETTE("palette")

	GFXDECODE(config, m_gfxdecode, "palette", gfx_jubileep);
	MCFG_PALETTE_ADD("palette",8)

	mc6845_device &crtc(MC6845(config, "crtc", CRTC_CLOCK));
	crtc.set_screen("screen");
	crtc.set_show_border_area(false);
	crtc.set_char_width(8);
MACHINE_CONFIG_END


/*************************
*        Rom Load        *
*************************/

ROM_START( jubileep )
	ROM_REGION( 0x4000, "maincpu", 0 ) /* TMS9980 code */
	ROM_LOAD( "1_ic59.bin", 0x0000, 0x1000, CRC(534c81c2) SHA1(4ce1d4492de9cbbc37e5a946b1183d8e8b0ba989) )
	ROM_LOAD( "2_ic58.bin", 0x1000, 0x1000, CRC(69984028) SHA1(c919a5cb43f23a0d9e496107997c74799709b347) )
	ROM_LOAD( "3_ic57.bin", 0x2000, 0x1000, CRC(c9ae423d) SHA1(8321e3e6fd60d92202b0c7b47e2a333a567b5c22) )

	ROM_REGION( 0x6000, "gfx1", 0 )
	ROM_LOAD( "ic47.bin",   0x0000, 0x2000, CRC(55dc8482) SHA1(53f22bd66e5fcad5e2397998bc58109c3c19af96) ) /* red */
	ROM_LOAD( "ic48.bin",   0x2000, 0x2000, CRC(a687ec96) SHA1(6a3e0d3796a1505c6d68a9194e9b2b4ef8df5649) ) /* green */
	ROM_LOAD( "ic49.bin",   0x4000, 0x2000, CRC(3e0bc116) SHA1(613c57f0a8baaaa4a04c243a3a139983fa7854e5) ) /* blue */

	ROM_REGION( 0x0800, "videoworkram", 0 )    /* default NVRAM */
	ROM_LOAD( "jubileep_videoworkram.bin", 0x0000, 0x0800, CRC(595bf2b3) SHA1(ae311873b15d8cebfb6ef6a80f27fafc9544178c) )
ROM_END


/*************************
*      Game Drivers      *
*************************/

//    YEAR  NAME      PARENT  MACHINE   INPUT     STATE          INIT        ROT   COMPANY    FULLNAME                     FLAGS
GAME( 1985, jubileep, 0,      jubileep, jubileep, jubilee_state, empty_init, ROT0, "Jubilee", "Double-Up Poker (Jubilee)", MACHINE_NO_SOUND )