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
|
// license:BSD-3-Clause
// copyright-holders:Curt Coder,Tomasz Slanina
/*
Vegas Roulette
World Games 1989
LE1000
6116 PGM Z80 8255
8255 SW1
GFX 6116 YM2149 SW3
SW2
2148
2148
2148
N4
24MHz
---
Driver by Curt Coder
TODO:
Find 'payout on' command to add simulator
Tomasz Slanina 20050225
- colors (4bpp tiles and 3bpp palette ? something is wrong then ....)
- 8255x2
- ball sprite (maybe it's something else in real machine , not sprite)
(hardcoded tile number and palette for now .. maybe x/y must be swapped)
are writes to 8000/c000 related to sprite tile/pal ?
*/
#include "emu.h"
#include "cpu/z80/z80.h"
#include "machine/i8255.h"
#include "machine/nvram.h"
#include "sound/ay8910.h"
#include "emupal.h"
#include "screen.h"
#include "speaker.h"
#include "tilemap.h"
class vroulet_state : public driver_device
{
public:
vroulet_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_generic_paletteram_8(*this, "paletteram"),
m_videoram(*this, "videoram"),
m_colorram(*this, "colorram"),
m_ball(*this, "ball") { }
void vroulet(machine_config &config);
private:
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
required_shared_ptr<uint8_t> m_generic_paletteram_8;
required_shared_ptr<uint8_t> m_videoram;
required_shared_ptr<uint8_t> m_colorram;
required_shared_ptr<uint8_t> m_ball;
tilemap_t *m_bg_tilemap;
DECLARE_WRITE8_MEMBER(paletteram_w);
DECLARE_WRITE8_MEMBER(videoram_w);
DECLARE_WRITE8_MEMBER(colorram_w);
DECLARE_WRITE8_MEMBER(ppi8255_a_w);
DECLARE_WRITE8_MEMBER(ppi8255_b_w);
DECLARE_WRITE8_MEMBER(ppi8255_c_w);
TILE_GET_INFO_MEMBER(get_bg_tile_info);
virtual void video_start() override;
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void vroulet_io_map(address_map &map);
void vroulet_map(address_map &map);
};
/* video */
WRITE8_MEMBER(vroulet_state::paletteram_w)
{
/*
paletteram_xxxxBBBBGGGGRRRR_byte_be_w
but... each palette has 8 colors only, not 16 as expected...
*/
int i,j,a,b;
m_generic_paletteram_8[offset]=data;
for(i=0;i<32;i++)
{
for(j=0;j<16;j++)
{
a=m_generic_paletteram_8[((i*8+j)*2)&0xff ];
b=m_generic_paletteram_8[((i*8+j)*2+1)&0xff ];
m_palette->set_pen_color(i*16+j,pal4bit(b),pal4bit(b>>4),pal4bit(a));
}
}
}
WRITE8_MEMBER(vroulet_state::videoram_w)
{
m_videoram[offset] = data;
m_bg_tilemap->mark_tile_dirty(offset);
}
WRITE8_MEMBER(vroulet_state::colorram_w)
{
m_colorram[offset] = data;
m_bg_tilemap->mark_tile_dirty(offset);
}
TILE_GET_INFO_MEMBER(vroulet_state::get_bg_tile_info)
{
int attr = m_colorram[tile_index];
int code = m_videoram[tile_index] + ((attr & 0xc0) << 2);
int color = attr & 0x1f;
SET_TILE_INFO_MEMBER(0, code, color, 0);
}
void vroulet_state::video_start()
{
m_bg_tilemap = &machine().tilemap().create(
*m_gfxdecode,
tilemap_get_info_delegate(FUNC(vroulet_state::get_bg_tile_info),this),
TILEMAP_SCAN_ROWS,
8, 8, 32, 32);
}
uint32_t vroulet_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, 0x320, 1, 0, 0,
m_ball[1], m_ball[0] - 12, 0);
return 0;
}
/* Memory Maps */
void vroulet_state::vroulet_map(address_map &map)
{
map(0x0000, 0x5fff).rom();
map(0x6000, 0x67ff).ram().share("nvram");
map(0x8000, 0x8000).noprw();
map(0x9000, 0x93ff).ram().w(FUNC(vroulet_state::videoram_w)).share("videoram");
map(0x9400, 0x97ff).ram().w(FUNC(vroulet_state::colorram_w)).share("colorram");
map(0xa000, 0xa001).ram().share("ball");
map(0xb000, 0xb0ff).w(FUNC(vroulet_state::paletteram_w)).share("paletteram");
map(0xc000, 0xc000).noprw();
}
void vroulet_state::vroulet_io_map(address_map &map)
{
map.global_mask(0xff);
map(0x00, 0x00).r("aysnd", FUNC(ym2149_device::data_r));
map(0x00, 0x01).w("aysnd", FUNC(ym2149_device::data_address_w));
map(0x10, 0x13).rw("ppi8255_0", FUNC(i8255_device::read), FUNC(i8255_device::write));
map(0x80, 0x83).rw("ppi8255_1", FUNC(i8255_device::read), FUNC(i8255_device::write));
}
/* Input Ports */
static INPUT_PORTS_START( vroulet )
PORT_START("IN0")
PORT_SERVICE( 0x01, IP_ACTIVE_LOW )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_TILT )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MEMORY_RESET )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON9 ) PORT_NAME("Reset Machine")
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CODE(KEYCODE_4) PORT_NAME("Payout")
PORT_START("IN1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Red")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Blue")
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("2")
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("4")
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("6")
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("10")
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("20")
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
PORT_START("IN2")
PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START("DSWA")
PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )
PORT_DIPSETTING( 0x00, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x01, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x07, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x06, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x05, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0x04, DEF_STR( 1C_4C ) )
PORT_DIPSETTING( 0x03, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x02, "1 Coin/10 Credits" )
PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )
PORT_DIPSETTING( 0x00, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x30, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x28, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x20, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0x18, DEF_STR( 1C_4C ) )
PORT_DIPSETTING( 0x10, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x38, "1 Coin/10 Credits" )
PORT_DIPNAME( 0xc0, 0xc0, "Revolutions" )
PORT_DIPSETTING( 0x80, "1" )
PORT_DIPSETTING( 0xc0, "2" )
PORT_DIPSETTING( 0x40, "3" )
PORT_DIPSETTING( 0x00, "4" )
PORT_START("DSWB")
PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x01, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x02, 0x02, "Max Payout Adjust" )
PORT_DIPSETTING( 0x02, "48" )
PORT_DIPSETTING( 0x00, "60" )
PORT_DIPNAME( 0x04, 0x04, "Extra Payout Control" )
PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )
PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x10, 0x10, "Red & Blue Select" )
PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0xe0, 0xe0, "Winning %" )
PORT_DIPSETTING( 0xc0, "50%" )
PORT_DIPSETTING( 0xa0, "60%" )
PORT_DIPSETTING( 0x80, "65%" )
PORT_DIPSETTING( 0x60, "70%" )
PORT_DIPSETTING( 0xe0, "75%" )
PORT_DIPSETTING( 0x40, "80%" )
PORT_DIPSETTING( 0x20, "90%" )
PORT_DIPSETTING( 0x00, "100%" )
INPUT_PORTS_END
/* Graphics Layout */
static const gfx_layout charlayout =
{
8, 8,
RGN_FRAC(1,1),
4,
{ 0, 1, 2, 3 },
{ 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4 },
{ 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
32*8
};
/* Graphics Decode Information */
static GFXDECODE_START( gfx_vroulet )
GFXDECODE_ENTRY( "gfx1", 0x0000, charlayout, 0, 32 )
GFXDECODE_END
/* PPI8255 Interface */
WRITE8_MEMBER(vroulet_state::ppi8255_a_w){}// watchdog ?
WRITE8_MEMBER(vroulet_state::ppi8255_b_w){}// lamps ?
WRITE8_MEMBER(vroulet_state::ppi8255_c_w){}
/* Machine Driver */
void vroulet_state::vroulet(machine_config &config)
{
// basic machine hardware
Z80(config, m_maincpu, 4000000); //???
m_maincpu->set_addrmap(AS_PROGRAM, &vroulet_state::vroulet_map);
m_maincpu->set_addrmap(AS_IO, &vroulet_state::vroulet_io_map);
m_maincpu->set_vblank_int("screen", FUNC(vroulet_state::irq0_line_hold));
NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_1);
i8255_device &ppi0(I8255A(config, "ppi8255_0"));
ppi0.in_pa_callback().set_ioport("IN0");
ppi0.in_pb_callback().set_ioport("IN1");
ppi0.in_pc_callback().set_ioport("IN2");
i8255_device &ppi1(I8255A(config, "ppi8255_1"));
ppi1.out_pa_callback().set(FUNC(vroulet_state::ppi8255_a_w));
ppi1.out_pb_callback().set(FUNC(vroulet_state::ppi8255_b_w));
ppi1.out_pc_callback().set(FUNC(vroulet_state::ppi8255_c_w));
// video hardware
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_refresh_hz(60);
screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
screen.set_size(32*8, 32*8);
screen.set_visarea(0*8, 32*8-1, 2*8, 30*8-1);
screen.set_screen_update(FUNC(vroulet_state::screen_update));
screen.set_palette(m_palette);
GFXDECODE(config, m_gfxdecode, m_palette, gfx_vroulet);
PALETTE(config, m_palette).set_entries(128*4);
// sound hardware
SPEAKER(config, "mono").front_center();
ym2149_device &aysnd(YM2149(config, "aysnd", 2000000));
aysnd.port_a_read_callback().set_ioport("DSWA");
aysnd.port_b_read_callback().set_ioport("DSWB");
aysnd.add_route(ALL_OUTPUTS, "mono", 0.25);
}
/* ROMs */
ROM_START( vroulet )
ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "roul1.bin", 0x0000, 0x2000, CRC(0cff99e5) SHA1(0aa6680c4b8d780d71b3e6c6fe511f86f40abc4c) )
ROM_LOAD( "roul2.bin", 0x2000, 0x2000, CRC(61924d9f) SHA1(8334d6825ed40e8347909817b8b73be97d23faf8) )
ROM_LOAD( "roul3.bin", 0x4000, 0x2000, CRC(73dedff6) SHA1(d01c4fc99ac8dc03bd6e0cf779c221d403b2b648) )
ROM_REGION( 0x8000, "gfx1", 0 )
ROM_LOAD( "roul.gfx", 0x0000, 0x8000, CRC(4e4f46d2) SHA1(efd00e2b564ff4a9013c67ffaaf91124089b310b) )
ROM_END
/* Game Driver */
GAME( 1989, vroulet, 0, vroulet, vroulet, vroulet_state, empty_init, ROT90, "World Game", "Vegas Roulette", MACHINE_IMPERFECT_GRAPHICS | MACHINE_IMPERFECT_COLORS | MACHINE_SUPPORTS_SAVE )
|