1 /*
2 
3   Truco-Tron - (c) 198? Playtronic SRL, Argentina
4 
5   Written by Ernesto Corvi
6 
7   Notes:
8   - Sound is missing. Looking at the code and the scarse info available, i would think it uses a DAC.
9 	(Check writes to $8003/$8004)
10   - The board uses a battery backed ram for protection, mapped at $7c00-$7fff.
11   - If the battery backup data is corrupt, it comes up with some sort of code entry screen.
12 	As far as I can tell, you can't do anything with it.
13   - Replacing the battery backed ram with an eeprom is not really an option since the game stores the
14 	current credits count in the battery backed ram.
15   - System clock is 12 Mhz. The CPU clock is unknown.
16   - The Alternate Gfx mode is funky. Not only it has different bitmaps, but also the strings with the
17   	game options are truncated. Title is also truncated.
18 */
19 
20 #include "driver.h"
21 #include "cpu/m6809/m6809.h"
22 
23 /* from vidhrdw */
24 VIDEO_UPDATE( truco );
25 PALETTE_INIT( truco );
26 
27 
28 /***************************************************************************/
29 
30 
MEMORY_READ_START(readmem)31 static MEMORY_READ_START( readmem )
32 	{ 0x0000, 0x17ff, MRA_RAM },		/* general purpose ram */
33 	{ 0x1800, 0x7bff, MRA_RAM },		/* video ram */
34 	{ 0x7c00, 0x7fff, MRA_RAM },		/* battery backed ram */
35 	{ 0x8000, 0x8000, input_port_0_r },	/* controls (and irq ack?) */
36 	{ 0x8001, 0x8001, MRA_NOP },		/* unknown */
37 	{ 0x8002, 0x8002, input_port_1_r },	/* dipswitches */
38 	{ 0x8003, 0x8007, MRA_NOP },		/* unknown */
39 	{ 0x8008, 0xffff, MRA_ROM },
40 MEMORY_END
41 
42 static MEMORY_WRITE_START( writemem )
43 	{ 0x0000, 0x17ff, MWA_RAM },		/* general purpose ram */
44 	{ 0x1800, 0x7bff, MWA_RAM },		/* video ram */
45 	{ 0x7c00, 0x7fff, MWA_RAM },		/* battery backed ram */
46 	{ 0x8000, 0x8007, MWA_NOP },		/* unknown (dac?) */
47 	{ 0x8008, 0xffff, MWA_ROM },
48 MEMORY_END
49 
50 INPUT_PORTS_START( truco )
51 	PORT_START	/* IN0 */
52 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
53 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
54 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
55 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
56 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
57 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
58 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
59 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
60 
61 	PORT_START /* DSW1 */
62 	PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
63 	PORT_DIPSETTING (	0x01, DEF_STR( Off ) )
64 	PORT_DIPSETTING (	0x00, DEF_STR( On ) )
65 	PORT_DIPNAME( 0x02, 0x02, "Alt. Graphics" )
66 	PORT_DIPSETTING (	0x02, DEF_STR( Off ) )
67 	PORT_DIPSETTING (	0x00, DEF_STR( On ) )
68 	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
69 	PORT_DIPSETTING (	0x04, DEF_STR( Off ) )
70 	PORT_DIPSETTING (	0x00, DEF_STR( On ) )
71 	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
72 	PORT_DIPSETTING (	0x08, DEF_STR( Off ) )
73 	PORT_DIPSETTING (	0x00, DEF_STR( On ) )
74 	PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
75 	PORT_DIPSETTING (	0x10, DEF_STR( Off ) )
76 	PORT_DIPSETTING (	0x00, DEF_STR( On ) )
77 	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
78 	PORT_DIPSETTING (	0x20, DEF_STR( Off ) )
79 	PORT_DIPSETTING (	0x00, DEF_STR( On ) )
80 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
81 	PORT_DIPSETTING (	0x40, DEF_STR( Off ) )
82 	PORT_DIPSETTING (	0x00, DEF_STR( On ) )
83 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
84 	PORT_DIPSETTING (	0x80, DEF_STR( Off ) )
85 	PORT_DIPSETTING (	0x00, DEF_STR( On ) )
86 
87 	PORT_START	/* IN1 - FAKE - Used for coinup */
88 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
89 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
90 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
91 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
92 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
93 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
94 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
95 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
96 INPUT_PORTS_END
97 
98 static MACHINE_INIT( truco )
99 {
100 	int a;
101 	data8_t *	mem = memory_region( REGION_CPU1 );
102 
103 	/* Setup the data on the battery backed RAM */
104 
105 	/* IRQ check */
106 	mem[0x7c02] = 0x51;
107 	mem[0x7c24] = 0x49;
108 	mem[0x7c89] = 0x04;
109 	mem[0x7d70] = 0x12;
110 	mem[0x7da8] = 0xd5;
111 
112 	/* Mainloop check */
113 	mem[0x7c05] = 0x04;
114 	mem[0x7e2B] = 0x46;
115 	mem[0x7e36] = 0xfb;
116 	mem[0x7efe] = 0x1D;
117 	mem[0x7f59] = 0x5A;
118 
119 	/* Boot check */
120 	a = ( mem[0x7c00] << 8 ) | mem[0x7c01];
121 
122 	a += 0x4d2;
123 
124 	mem[0x7c1d] = ( a >> 8 ) & 0xff;
125 	mem[0x7c1e] = a & 0xff;
126 	mem[0x7c20] = mem[0x7c11];
127 }
128 
INTERRUPT_GEN(truco_interrupt)129 static INTERRUPT_GEN( truco_interrupt )
130 {
131 	/* coinup */
132 	static int trigger = 0;
133 
134 	if ( readinputport( 2 ) & 1 )
135 	{
136 		if ( trigger == 0 )
137 		{
138 			cpu_set_irq_line( 0, M6809_IRQ_LINE, PULSE_LINE );
139 			trigger++;
140 		}
141 	} else
142 		trigger = 0;
143 }
144 
145 static MACHINE_DRIVER_START( truco )
146 
147 	/* basic machine hardware */
148 	MDRV_CPU_ADD(M6809, 1000000)        /* 1 MHz ? */
149 	MDRV_CPU_MEMORY(readmem,writemem)
150 
151 	MDRV_FRAMES_PER_SECOND(60)
152 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
153 	MDRV_CPU_VBLANK_INT(truco_interrupt,1)
154 
155 	MDRV_MACHINE_INIT(truco);
156 
157 	/* video hardware */
158 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
159 	MDRV_SCREEN_SIZE(256, 192)
160 	MDRV_VISIBLE_AREA(0, 256-1, 0, 192-1)
161 	MDRV_PALETTE_LENGTH(16)
162 
163 	MDRV_PALETTE_INIT(truco)
164 	MDRV_VIDEO_UPDATE(truco)
165 
166 	/* sound hardware */
167 MACHINE_DRIVER_END
168 
169 
170 /***************************************************************************
171 
172   Game driver(s)
173 
174 ***************************************************************************/
175 
176 ROM_START( truco )
177 	ROM_REGION( 0x10000, REGION_CPU1, 0 )     /* 64k for main CPU */
178 	ROM_LOAD( "truco.u3",   0x08000, 0x4000, CRC(4642fb96) SHA1(e821f6fd582b141a5ca2d5bd53f817697048fb81) )
179 	ROM_LOAD( "truco.u2",   0x0c000, 0x4000, CRC(ff355750) SHA1(1538f20b1919928ffca439e4046a104ddfbc756c) )
180 ROM_END
181 
182 GAMEX( 198?, truco,  0, truco, truco, 0, ROT0, "Playtronic SRL", "Truco-Tron", GAME_NO_SOUND )
183